Home » Eclipse Projects » Standard Widget Toolkit (SWT) » getText() For Browser
getText() For Browser [message #460824] |
Thu, 08 September 2005 11:02 |
Eclipse User |
|
|
|
Originally posted by: kent.generatescape.com
I would like to be able to somehow get the text or rather html that the
browser uses, is there no way to do this?
thanks
|
|
| | | |
Re: getText() For Browser [message #460912 is a reply to message #460884] |
Fri, 09 September 2005 15:01 |
Eclipse User |
|
|
|
Originally posted by: kent.generatescape.com
unfortunately that won't work for me, I need the html that was loaded and
rendered. The reason I can't just load the browser and then keep the html is
that I need the IE agent settings, and I really don't want to masquerade as
IE.
"Kalman" <kalman@zikal.com> wrote in message
news:dfs14p$9ak$1@news.eclipse.org...
> What I did in the past to solve this problem was just to keep track of the
> text I was gonna put into the browser in a variable of some sort.
>
> --
> HTH,
> - Kalman (http://www.zikal.com/)
>
> "kent" <kent@generatescape.com> wrote in message
> news:dfpfqu$2qm$1@news.eclipse.org...
>> thanks, do you have any tips how I could use the attached solution?
>>
>> One is not supposed to subclass browser so that is out, If I just go and
>> call the class something else, that fails becuase of certain package
>> scope. I don't know would something like the decorator pattern here help?
>>
>> "Grant Gayed" <grant_gayed@ca.ibm.com> wrote in message
>> news:dfpcjn$t6m$1@news.eclipse.org...
>>> This is not currently implemented, but there is a request for this, see
>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=107142 .
>>>
>>> Grant
>>>
>>> "kent" <kent@generatescape.com> wrote in message
>>> news:dfp25k$e5e$1@news.eclipse.org...
>>>> I would like to be able to somehow get the text or rather html that the
>>>> browser uses, is there no way to do this?
>>>>
>>>> thanks
>>>>
>>>>
>>>
>>>
>>
>>
>
>
|
|
|
Re: getText() For Browser [message #460913 is a reply to message #460842] |
Fri, 09 September 2005 14:36 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Widgets can be subclassed in dire circumstances [sic] by overriding the
checkSubclass() method to do nothing. A decorator would not really be any
more helpful.
However, the report's attached solution utilizes the Browser's "auto" field,
which is only visible to classes within the org.eclipse.swt.browser package.
So if you added your subclass to this package then it should be workable.
But then again, if you're looking at locally modifying your swt anyways, you
could just change your Browser implementation to incorporate the report's
changes.
Grant
"kent" <kent@generatescape.com> wrote in message
news:dfpfqu$2qm$1@news.eclipse.org...
> thanks, do you have any tips how I could use the attached solution?
>
> One is not supposed to subclass browser so that is out, If I just go and
> call the class something else, that fails becuase of certain package
scope.
> I don't know would something like the decorator pattern here help?
>
> "Grant Gayed" <grant_gayed@ca.ibm.com> wrote in message
> news:dfpcjn$t6m$1@news.eclipse.org...
> > This is not currently implemented, but there is a request for this, see
> > https://bugs.eclipse.org/bugs/show_bug.cgi?id=107142 .
> >
> > Grant
> >
> > "kent" <kent@generatescape.com> wrote in message
> > news:dfp25k$e5e$1@news.eclipse.org...
> >> I would like to be able to somehow get the text or rather html that the
> >> browser uses, is there no way to do this?
> >>
> >> thanks
> >>
> >>
> >
> >
>
>
|
|
|
Re: getText() For Browser [message #460920 is a reply to message #460913] |
Sat, 10 September 2005 00:11 |
Eclipse User |
|
|
|
Originally posted by: kent.generatescape.com
just one quick question, when you say "locally modifying your swt anyways",
I suppose the only way to do this is to download the swt code, make my
change and then rebuild into a new swt jar?
"Grant Gayed" <grant_gayed@ca.ibm.com> wrote in message
news:dfs6ki$hg7$1@news.eclipse.org...
> Widgets can be subclassed in dire circumstances [sic] by overriding the
> checkSubclass() method to do nothing. A decorator would not really be any
> more helpful.
>
> However, the report's attached solution utilizes the Browser's "auto"
> field,
> which is only visible to classes within the org.eclipse.swt.browser
> package.
> So if you added your subclass to this package then it should be workable.
> But then again, if you're looking at locally modifying your swt anyways,
> you
> could just change your Browser implementation to incorporate the report's
> changes.
>
> Grant
>
> "kent" <kent@generatescape.com> wrote in message
> news:dfpfqu$2qm$1@news.eclipse.org...
>> thanks, do you have any tips how I could use the attached solution?
>>
>> One is not supposed to subclass browser so that is out, If I just go and
>> call the class something else, that fails becuase of certain package
> scope.
>> I don't know would something like the decorator pattern here help?
>>
>> "Grant Gayed" <grant_gayed@ca.ibm.com> wrote in message
>> news:dfpcjn$t6m$1@news.eclipse.org...
>> > This is not currently implemented, but there is a request for this, see
>> > https://bugs.eclipse.org/bugs/show_bug.cgi?id=107142 .
>> >
>> > Grant
>> >
>> > "kent" <kent@generatescape.com> wrote in message
>> > news:dfp25k$e5e$1@news.eclipse.org...
>> >> I would like to be able to somehow get the text or rather html that
>> >> the
>> >> browser uses, is there no way to do this?
>> >>
>> >> thanks
>> >>
>> >>
>> >
>> >
>>
>>
>
>
|
|
|
Re: getText() For Browser [message #460921 is a reply to message #460920] |
Sat, 10 September 2005 00:16 |
Eclipse User |
|
|
|
Originally posted by: kent.generatescape.com
I suppose I could move the new class over into the swt jar wherever it is
now, using the update feature of the jar utility.
"kent" <kent@generatescape.com> wrote in message
news:dft4o4$onu$1@news.eclipse.org...
> just one quick question, when you say "locally modifying your swt
> anyways", I suppose the only way to do this is to download the swt code,
> make my change and then rebuild into a new swt jar?
>
>
>
> "Grant Gayed" <grant_gayed@ca.ibm.com> wrote in message
> news:dfs6ki$hg7$1@news.eclipse.org...
>> Widgets can be subclassed in dire circumstances [sic] by overriding the
>> checkSubclass() method to do nothing. A decorator would not really be
>> any
>> more helpful.
>>
>> However, the report's attached solution utilizes the Browser's "auto"
>> field,
>> which is only visible to classes within the org.eclipse.swt.browser
>> package.
>> So if you added your subclass to this package then it should be workable.
>> But then again, if you're looking at locally modifying your swt anyways,
>> you
>> could just change your Browser implementation to incorporate the report's
>> changes.
>>
>> Grant
>>
>> "kent" <kent@generatescape.com> wrote in message
>> news:dfpfqu$2qm$1@news.eclipse.org...
>>> thanks, do you have any tips how I could use the attached solution?
>>>
>>> One is not supposed to subclass browser so that is out, If I just go and
>>> call the class something else, that fails becuase of certain package
>> scope.
>>> I don't know would something like the decorator pattern here help?
>>>
>>> "Grant Gayed" <grant_gayed@ca.ibm.com> wrote in message
>>> news:dfpcjn$t6m$1@news.eclipse.org...
>>> > This is not currently implemented, but there is a request for this,
>>> > see
>>> > https://bugs.eclipse.org/bugs/show_bug.cgi?id=107142 .
>>> >
>>> > Grant
>>> >
>>> > "kent" <kent@generatescape.com> wrote in message
>>> > news:dfp25k$e5e$1@news.eclipse.org...
>>> >> I would like to be able to somehow get the text or rather html that
>>> >> the
>>> >> browser uses, is there no way to do this?
>>> >>
>>> >> thanks
>>> >>
>>> >>
>>> >
>>> >
>>>
>>>
>>
>>
>
>
|
|
|
Re: getText() For Browser [message #460939 is a reply to message #460921] |
Mon, 12 September 2005 14:39 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Yes, this should work. Just be sure that the Browser.class and all of its
accompanying Browser$?.class files make it in.
Grant
"kent" <kent@generatescape.com> wrote in message
news:dft51q$p28$1@news.eclipse.org...
> I suppose I could move the new class over into the swt jar wherever it is
> now, using the update feature of the jar utility.
> "kent" <kent@generatescape.com> wrote in message
> news:dft4o4$onu$1@news.eclipse.org...
> > just one quick question, when you say "locally modifying your swt
> > anyways", I suppose the only way to do this is to download the swt code,
> > make my change and then rebuild into a new swt jar?
> >
> >
> >
> > "Grant Gayed" <grant_gayed@ca.ibm.com> wrote in message
> > news:dfs6ki$hg7$1@news.eclipse.org...
> >> Widgets can be subclassed in dire circumstances [sic] by overriding the
> >> checkSubclass() method to do nothing. A decorator would not really be
> >> any
> >> more helpful.
> >>
> >> However, the report's attached solution utilizes the Browser's "auto"
> >> field,
> >> which is only visible to classes within the org.eclipse.swt.browser
> >> package.
> >> So if you added your subclass to this package then it should be
workable.
> >> But then again, if you're looking at locally modifying your swt
anyways,
> >> you
> >> could just change your Browser implementation to incorporate the
report's
> >> changes.
> >>
> >> Grant
> >>
> >> "kent" <kent@generatescape.com> wrote in message
> >> news:dfpfqu$2qm$1@news.eclipse.org...
> >>> thanks, do you have any tips how I could use the attached solution?
> >>>
> >>> One is not supposed to subclass browser so that is out, If I just go
and
> >>> call the class something else, that fails becuase of certain package
> >> scope.
> >>> I don't know would something like the decorator pattern here help?
> >>>
> >>> "Grant Gayed" <grant_gayed@ca.ibm.com> wrote in message
> >>> news:dfpcjn$t6m$1@news.eclipse.org...
> >>> > This is not currently implemented, but there is a request for this,
> >>> > see
> >>> > https://bugs.eclipse.org/bugs/show_bug.cgi?id=107142 .
> >>> >
> >>> > Grant
> >>> >
> >>> > "kent" <kent@generatescape.com> wrote in message
> >>> > news:dfp25k$e5e$1@news.eclipse.org...
> >>> >> I would like to be able to somehow get the text or rather html that
> >>> >> the
> >>> >> browser uses, is there no way to do this?
> >>> >>
> >>> >> thanks
> >>> >>
> >>> >>
> >>> >
> >>> >
> >>>
> >>>
> >>
> >>
> >
> >
>
>
|
|
|
Re: getText() For Browser [message #460986 is a reply to message #460939] |
Tue, 13 September 2005 23:20 |
Eclipse User |
|
|
|
Originally posted by: kent.generatescape.com
thanks.
"Grant Gayed" <grant_gayed@ca.ibm.com> wrote in message
news:dg43uj$6ol$1@news.eclipse.org...
> Yes, this should work. Just be sure that the Browser.class and all of its
> accompanying Browser$?.class files make it in.
>
> Grant
>
> "kent" <kent@generatescape.com> wrote in message
> news:dft51q$p28$1@news.eclipse.org...
>> I suppose I could move the new class over into the swt jar wherever it is
>> now, using the update feature of the jar utility.
>> "kent" <kent@generatescape.com> wrote in message
>> news:dft4o4$onu$1@news.eclipse.org...
>> > just one quick question, when you say "locally modifying your swt
>> > anyways", I suppose the only way to do this is to download the swt
>> > code,
>> > make my change and then rebuild into a new swt jar?
>> >
>> >
>> >
>> > "Grant Gayed" <grant_gayed@ca.ibm.com> wrote in message
>> > news:dfs6ki$hg7$1@news.eclipse.org...
>> >> Widgets can be subclassed in dire circumstances [sic] by overriding
>> >> the
>> >> checkSubclass() method to do nothing. A decorator would not really be
>> >> any
>> >> more helpful.
>> >>
>> >> However, the report's attached solution utilizes the Browser's "auto"
>> >> field,
>> >> which is only visible to classes within the org.eclipse.swt.browser
>> >> package.
>> >> So if you added your subclass to this package then it should be
> workable.
>> >> But then again, if you're looking at locally modifying your swt
> anyways,
>> >> you
>> >> could just change your Browser implementation to incorporate the
> report's
>> >> changes.
>> >>
>> >> Grant
>> >>
>> >> "kent" <kent@generatescape.com> wrote in message
>> >> news:dfpfqu$2qm$1@news.eclipse.org...
>> >>> thanks, do you have any tips how I could use the attached solution?
>> >>>
>> >>> One is not supposed to subclass browser so that is out, If I just go
> and
>> >>> call the class something else, that fails becuase of certain package
>> >> scope.
>> >>> I don't know would something like the decorator pattern here help?
>> >>>
>> >>> "Grant Gayed" <grant_gayed@ca.ibm.com> wrote in message
>> >>> news:dfpcjn$t6m$1@news.eclipse.org...
>> >>> > This is not currently implemented, but there is a request for this,
>> >>> > see
>> >>> > https://bugs.eclipse.org/bugs/show_bug.cgi?id=107142 .
>> >>> >
>> >>> > Grant
>> >>> >
>> >>> > "kent" <kent@generatescape.com> wrote in message
>> >>> > news:dfp25k$e5e$1@news.eclipse.org...
>> >>> >> I would like to be able to somehow get the text or rather html
>> >>> >> that
>> >>> >> the
>> >>> >> browser uses, is there no way to do this?
>> >>> >>
>> >>> >> thanks
>> >>> >>
>> >>> >>
>> >>> >
>> >>> >
>> >>>
>> >>>
>> >>
>> >>
>> >
>> >
>>
>>
>
>
|
|
|
Re: getText() For Browser [message #461064 is a reply to message #460986] |
Thu, 15 September 2005 13:26 |
Eclipse User |
|
|
|
Originally posted by: kent.generatescape.com
you may or may not be aware of this, but this solution as of 3.1 is slightly
incompatible.
there are some minor issues about the info field, I will try and upload a
new solution.
"kent" <kent@generatescape.com> wrote in message
news:dg7j8q$fo5$1@news.eclipse.org...
> thanks.
> "Grant Gayed" <grant_gayed@ca.ibm.com> wrote in message
> news:dg43uj$6ol$1@news.eclipse.org...
>> Yes, this should work. Just be sure that the Browser.class and all of
>> its
>> accompanying Browser$?.class files make it in.
>>
>> Grant
>>
>> "kent" <kent@generatescape.com> wrote in message
>> news:dft51q$p28$1@news.eclipse.org...
>>> I suppose I could move the new class over into the swt jar wherever it
>>> is
>>> now, using the update feature of the jar utility.
>>> "kent" <kent@generatescape.com> wrote in message
>>> news:dft4o4$onu$1@news.eclipse.org...
>>> > just one quick question, when you say "locally modifying your swt
>>> > anyways", I suppose the only way to do this is to download the swt
>>> > code,
>>> > make my change and then rebuild into a new swt jar?
>>> >
>>> >
>>> >
>>> > "Grant Gayed" <grant_gayed@ca.ibm.com> wrote in message
>>> > news:dfs6ki$hg7$1@news.eclipse.org...
>>> >> Widgets can be subclassed in dire circumstances [sic] by overriding
>>> >> the
>>> >> checkSubclass() method to do nothing. A decorator would not really
>>> >> be
>>> >> any
>>> >> more helpful.
>>> >>
>>> >> However, the report's attached solution utilizes the Browser's "auto"
>>> >> field,
>>> >> which is only visible to classes within the org.eclipse.swt.browser
>>> >> package.
>>> >> So if you added your subclass to this package then it should be
>> workable.
>>> >> But then again, if you're looking at locally modifying your swt
>> anyways,
>>> >> you
>>> >> could just change your Browser implementation to incorporate the
>> report's
>>> >> changes.
>>> >>
>>> >> Grant
>>> >>
>>> >> "kent" <kent@generatescape.com> wrote in message
>>> >> news:dfpfqu$2qm$1@news.eclipse.org...
>>> >>> thanks, do you have any tips how I could use the attached solution?
>>> >>>
>>> >>> One is not supposed to subclass browser so that is out, If I just go
>> and
>>> >>> call the class something else, that fails becuase of certain package
>>> >> scope.
>>> >>> I don't know would something like the decorator pattern here help?
>>> >>>
>>> >>> "Grant Gayed" <grant_gayed@ca.ibm.com> wrote in message
>>> >>> news:dfpcjn$t6m$1@news.eclipse.org...
>>> >>> > This is not currently implemented, but there is a request for
>>> >>> > this,
>>> >>> > see
>>> >>> > https://bugs.eclipse.org/bugs/show_bug.cgi?id=107142 .
>>> >>> >
>>> >>> > Grant
>>> >>> >
>>> >>> > "kent" <kent@generatescape.com> wrote in message
>>> >>> > news:dfp25k$e5e$1@news.eclipse.org...
>>> >>> >> I would like to be able to somehow get the text or rather html
>>> >>> >> that
>>> >>> >> the
>>> >>> >> browser uses, is there no way to do this?
>>> >>> >>
>>> >>> >> thanks
>>> >>> >>
>>> >>> >>
>>> >>> >
>>> >>> >
>>> >>>
>>> >>>
>>> >>
>>> >>
>>> >
>>> >
>>>
>>>
>>
>>
>
>
|
|
| |
Re: getText() For Browser [message #461166 is a reply to message #461159] |
Mon, 19 September 2005 11:55 |
Eclipse User |
|
|
|
Originally posted by: kent.generatescape.com
thanks for the code, my idea was to use the browser so that I could fetch
some html and then it would use the IE user agent, normally in my code I use
httpclient and I didn't want to pretend to be IE. But in the end the idea
was flawed because the server even blocked the IE agent.
"Christophe Cornu" <christophe_cornu@ca.ibm.com> wrote in message
news:a06f05995de86adf8f9bbe99bf5b9834$1@www.eclipse.org...
> Would this do? I use a variant of Snippet160 'query DOM node value' to
> retrieve the userAgent property. On my machine this outputs the following
> value:
>
> Node value: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
>
> Chris
>
> /*
> * Browser example snippet: query DOM node value
> *
> * For a list of all SWT example snippets see
> * http://www.eclipse.org/swt/snippets/
> */
> import org.eclipse.swt.*;
> import org.eclipse.swt.browser.*;
> import org.eclipse.swt.layout.*;
> import org.eclipse.swt.widgets.*;
>
> public class SWTTest {
> public static void main(String [] args) {
> final String html = "<html><title>Snippet</title><body><p id='myid'>Best
> Friends</p><p id='myid2'>Cat and Dog</p></body></html>";
> Display display = new Display();
> final Shell shell = new Shell(display);
> shell.setLayout(new FillLayout());
> final Browser browser = new Browser(shell, SWT.NONE);
> browser.addStatusTextListener(new StatusTextListener() {
> public void changed(StatusTextEvent event) {
> browser.setData("query", event.text);
> }
> });
> browser.addProgressListener(new ProgressListener() {
> public void changed(ProgressEvent event) {
> }
> public void completed(ProgressEvent event) {
> /* * Use JavaScript to query the desired node content through the Document
> Object Model
> * * Assign result to the window property status to pass the result to the
> StatusTextListener
> * This trick is required since <code>execute</code> does not return the
> <code>String</code>
> * directly.
> */
> boolean result = browser.execute("window.status=navigator.userAgent;");
> if (!result) {
> /* Script may fail or may not be supported on certain platforms. */
> System.out.println("Script was not executed.");
> return;
> }
> String value = (String)browser.getData("query");
> System.out.println("Node value: "+value);
> }
> });
> /* Load an HTML document */
> browser.setText(html);
> shell.open();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> display.dispose();
> }
> }
>
|
|
|
Goto Forum:
Current Time: Fri Apr 26 12:19:09 GMT 2024
Powered by FUDForum. Page generated in 0.04036 seconds
|