[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[platform-dev] Re: platform-dev Digest, Vol 4, Issue 4
|
platform-dev-request,您好!
======= 2005-07-08 00:00:07 您在来信中写道:=======
>Send platform-dev mailing list submissions to
> platform-dev@xxxxxxxxxxx
>
>To subscribe or unsubscribe via the World Wide Web, visit
> https://dev.eclipse.org/mailman/listinfo/platform-dev
>or, via email, send a message with subject or body 'help' to
> platform-dev-request@xxxxxxxxxxx
>
>You can reach the person managing the list at
> platform-dev-owner@xxxxxxxxxxx
>
>When replying, please edit your Subject line so it is more specific
>than "Re: Contents of platform-dev digest..."
>
>
>Today's Topics:
>
> 1. Finding ITextSelection's document and file (Chris Hull)
>
>
>----------------------------------------------------------------------
>
>Message: 1
>Date: Wed, 6 Jul 2005 12:01:11 -0700
>From: "Chris Hull" <chull@xxxxxxxxxx>
>Subject: [platform-dev] Finding ITextSelection's document and file
>To: <platform-dev@xxxxxxxxxxx>
>Message-ID:
> <E71EDB0A344AB44780D8F3ED82375A23DD74@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
>
>Content-Type: text/plain; charset="us-ascii"
>
>
>
>Hello fellow Eclipsoids;
>
>This code is straight out of Chapter 21; The Java Developer's Guide to
>Eclips. See below...
>
>I am building a plug-in that generates makefiles. What I need to know
>is, what path and filename is associated with the test the user
>selected.
>
>There doesn't seem to be a way to get from ITestSelection, or Action to
>the actual path and filename is. One would think you could call
>getDocument on ITestSelection and go from there, but the interface is
>very narrow. I can see via the debugger that the selection knows what
>Doc and file it belongs to, but all that info seems to be private.
>
>Perhaps there's a static way... Eclipse.getCurrentDocument.. or
>something.
>
>There's gotta be a way to get the current editor, and from there, the
>filename and path.
>
>Any help would be appreciated.
>Thanks;
>-Chris
>
>
>-- Code snippet ---
>
>
>
>
>
>
>private void processSelection (IAction action, ISelection selection)
>{
>
> // If we have clicked in an editor, we need to dig for
>the
> // file and pathname... maybe this way???
> if ( action != null ){
> if (action instanceof EditorPluginAction){
> EditorPluginAction ea =
>(EditorPluginAction)action;
> }
> }
>
>
> if (selection != null){
> if (selection instanceof IStructuredSelection){
> IStructuredSelection ss =
>(IStructuredSelection)selection;
> if (ss.isEmpty()) {
> System.out.println(" Selection
>is empty ");
> } else {
> System.out.println (" First
>element is " +
>
>ss.getFirstElement().getClass() );
> }
>
> fFunctionName =
>ss.getFirstElement().toString();
> }
> else if (selection instanceof ITextSelection) {
> ITextSelection ts = (ITextSelection)
>selection;
> System.out.println("Selected text is ["
>+ ts.getText() + "]" );
> fFunctionName = ts.getText();
> }
>
>
> } else {
> System.out.println("Empty selection");
> }
>
>
>
>
>
>
>
>
>
>
>
>
>Christopher Hull
>Altera Santa Cruz Technology Center
>Office: 408 544 8526
>Cell: 415 385 HTML
>chull@xxxxxxxxxx
>
>"If you're tired of Santa Cruz, you're tired of life!"
>
>
>
>
>------------------------------
>
>_______________________________________________
>platform-dev mailing list
>platform-dev@xxxxxxxxxxx
>https://dev.eclipse.org/mailman/listinfo/platform-dev
>
>
>End of platform-dev Digest, Vol 4, Issue 4
>******************************************
>
= = = = = = = = = = = = = = = = = = = =
致
礼!
侯捷
houjiestar@xxxxxxx
2005-07-08