Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to add another project as dependency?

 
Siegfried Heintze
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got a great response from Grant in the eclipse/swt newsgroup. See below. However, after following the procedure as carefully as I can several times, it does not work. I solicited for more help but no one as responded.

I've been executng snippet128 which demonstrates an SWT web browser and I want to retrieve the HTML from the browser. Grant supplied me with the patch . However, snippet128 still has the red squiggly lines when I try to call getText.

As I result of following the procedure below, I have a new project
called org.eclipse.swt.win32.win32.x86 which I have tried to add as a dependency for my current project. I save the files and compile, but it does not appear that the java for org.eclipse.swt.win32.win32.x86 is being compiled.

I see build.properties but no build.xml. I wonder if the problem is that it is looking in the wrong copy of org.eclipse.swt.win32.win32.x86? Presumably there are two copies now: the old and the new. I bet it is still using the old even though I added the new as a project in the project/properities dialog box.

I hope someone can help me.

Thanks,
Siegfried
-------------------------------------------------------------------------
Do the following:

1. Bring swt into your workspace:
- File -> Import...
- Plug-in Development - Plug-ins and Fragments, Next
- select "Projects with source folders" radio button, Next
- select the org.eclipse.swt and org.eclipse.swt.win32.win32.x86
plug-ins (assuming you're running on win32) in the left list and press the
"Add-->" button, Finish
2. Update Browser.java
- since the patch is just a self-contained method, it's easiest to just
open Browser.java and paste in the method that I've included below these
steps
3. Use it
- select your own project that uses the Browser, right-click ->
Properties
- go to the Java Build Path page
- go to the Projects tab
- press Add... and check the two org.eclipse.swt projects that were
previously imported, OK, OK
- that should be it

The method to paste into Browser.java (again, assuming win32):

public String getText() {
checkWidget();
/* get the document object */
int[] rgdispid = auto.getIDsOfNames(new String[]{"Document"});
//$NON-NLS-1$
Variant pVarResult = auto.getProperty(rgdispid[0]);
if (pVarResult == null || pVarResult.getType() == COM.VT_EMPTY) return "";
//$NON-NLS-1$
OleAutomation document = pVarResult.getAutomation();
pVarResult.dispose();
/* get the html object */
rgdispid = document.getIDsOfNames(new String[] {"documentElement"});
//$NON-NLS-1$
if (rgdispid == null) {
/* implies that the browser is displaying non-HTML content */
document.dispose();
return ""; //$NON-NLS-1$
}
pVarResult = document.getProperty(rgdispid[0]);
document.dispose();
if (pVarResult == null || pVarResult.getType() == COM.VT_EMPTY) return "";
//$NON-NLS-1$
OleAutomation element = pVarResult.getAutomation();
pVarResult.dispose();
/* get its outerHTML property */
rgdispid = element.getIDsOfNames(new String[] {"outerHTML"}); //$NON-NLS-1$
pVarResult = element.getProperty(rgdispid[0]);
element.dispose();
if (pVarResult == null || pVarResult.getType() == COM.VT_EMPTY) return "";
//$NON-NLS-1$
String result = pVarResult.getString();
pVarResult.dispose();
return result;
}

Grant


"Siegfried Heintze" <siegfried@heintze.com> wrote in message
news:e35cv4$11q$1@utils.eclipse.org...
> Grant,
> That you very much for your help thus far. I'm confused about this
patching
> procedure.
> (1) Should the patch be called Browser.java with the contents below? That
> seems like a strange file extension for a patch.
> (2) When I F3 on the Brower, it takes me file called Browser.class that
> appearns to have a the source code for the Browser class (I did not think
> class files contained java source code -- why does this have a .class
> extension?)
> (4) I right click again in the Browser.class file and tell it to display
the
> package explorer. I try right clicking on everything in the package
explorer
> and it seems that only the containing project will give me the team menu.
I
> was hoping I could right click on the
> org.eclipse.swt.win32.win32.x86_3.1.1.jar and apply the patch. Am I
supposed
> to apply the patch to the project/directory that contains the .jar and src
> files?
> (5) When I right click on the directory and select team->apply patch, I
> select my project and then I am at liberty to select any of the source
files
> but not the org.eclipse.swt.win32.win32.x86_3.1.1.jar file (which is the
> problem).
> I can only get the team menu entry when I select the project. I find this
> confusing.
> (6) Now I thougth I already applied this patch but as I am typing this
> response, I decided try it again and it looks like it let me. What is this
> "apply-patch" supposed to do? edit the Browser.class file? I do a search
in
> the Browser.class file and cannot find the new "getText" function. Which
> file did the apply-patch modify?
> (7) Now what do I do? Recompile? I'm still get a syntax error for my call
to
> ".getText".
>
> Thanks,
> Siegfried
>
>
 
Siegfried Heintze
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm... no reply. Maybe I should have posted this under IDEs because it has more to do with eclipse than SWT? This is a question about applying a patch to an SWT class by creating a new project with the import feature and adding that new project as a dependency. Can I clarify anything?

Thanks,
Siegfried
 
Siegfried Heintze
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem solved: I had to remove the SWT libary a second time before it would look to my imported project. I don't know why it did not work the first time.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, the IDE forum might have been better. Anyway, nice to see that you solved your problem!
 
Get off me! Here, read this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!