This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java and have Dr. Raoul-Gabriel Urma & Richard Warburton on-line!
See this thread for details.
Win a copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

How to add another project as dependency?

Ranch Hand
Posts: 420
  • 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 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.

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
- since the patch is just a self-contained method, it's easiest to just
open and paste in the method that I've included below these
3. Use it
- select your own project that uses the Browser, right-click ->
- 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 (again, assuming win32):

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


"Siegfried Heintze" <> wrote in message
> Grant,
> That you very much for your help thus far. I'm confused about this
> procedure.
> (1) Should the patch be called 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
> package explorer. I try right clicking on everything in the package
> and it seems that only the containing project will give me the team menu.
> was hoping I could right click on the
> org.eclipse.swt.win32.win32.x86_3.1.1.jar and apply the patch. Am I
> 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
> 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
> 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
> ".getText".
> Thanks,
> Siegfried
Siegfried Heintze
Ranch Hand
Posts: 420
  • 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?

Siegfried Heintze
Ranch Hand
Posts: 420
  • 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.
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!
girl power ... turns out to be about a hundred watts. But they seriuosly don't like being connected to the grid. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!