Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 7761 - [Contributions] Can't distinguish structured selection from text selection
Summary: [Contributions] Can't distinguish structured selection from text selection
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Paul Webster CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 7750 (view as bug list)
Depends on:
Blocks: 7383
  Show dependency tree
 
Reported: 2002-01-16 11:35 EST by Dirk Baeumer CLA
Modified: 2007-06-20 11:12 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2002-01-16 11:35:57 EST
The JDT UI has a couple of global actions (Refactor menu) that work on both a 
strucutured selection and a text selection. Currently it is not possible to 
define enablement criterias depending on the type of the selection. I would 
like to write down something like this:

<enablement>
  <if selection_class= "....ITextSelection">
     <enablesFor value="1"/>
  </endif>
  <if selection_class= "...IStructuredSelection">
     <enablesFor value="1"/>
     <objectClass name="org.eclipse.jdt.core.IMethod"/>
  </endif>
</enablement>

Any idea how to do that ?
Comment 1 Nick Edgar CLA 2002-01-16 21:41:59 EST
See org.eclipse.ui/doc/actionExpressions.html.

You should be able to do:
  <enablement> 
    <or> 
      <objectClass name="....ITextSelection"/> 
      <objectClass name="....IStructuredSelection"/> 
    </or> 
  </enablement> 

The enablesFor can only be specified once since it's an attribute on the action.

Alternatively, using the old mechanism, specifying two separate contributions 
for the same action but with different criteria would work.
Comment 2 Dirk Baeumer CLA 2002-01-17 04:10:17 EST
From the same document:

An objectClass element is used to evaluate the class of each object in the 
selection.  The name attribute of the objectClass contains a fully qualified 
class name.  If each object in the selection implements this class, the 
expression is evaluated as true.

I don't want to check if elements in the selection are of a certain type. What 
I want to express is the following (Java pseudo code):

if (selection instanceof ITextSelection) {
  return ((ITextSelection)selection).getLength > 0;
} else if (selection instanceof IStrucuturedSelection) {
  return allElementsAreOfType(selection, IMethod.class)
}

Can you please give me a hint how to do this with the old mechanism using two 
different contributions. I have no idea what to do.
Comment 3 Dirk Baeumer CLA 2002-01-17 04:47:56 EST
Forget to reopen ...
Comment 4 Nick Edgar CLA 2002-01-17 09:23:26 EST
Will investigate.
Comment 5 Dirk Baeumer CLA 2002-01-23 11:48:16 EST
Can be postponed > 2.0
Comment 6 Nick Edgar CLA 2002-01-23 11:56:06 EST
Curious, how did you work around this?
Comment 7 Dirk Baeumer CLA 2002-01-23 12:18:53 EST
We do it now in code. Since the refactoring actions are normally only present 
in JDT perspecitives this is not a problem. If you add them to the resource 
perspective all actions are enabled and you get the "Action is not available" 
dialog.

I think we can live with that for 2.0
Comment 8 Eduardo Pereira CLA 2002-01-28 15:53:22 EST
See bug 7750.
Comment 9 Eduardo Pereira CLA 2002-05-30 17:48:39 EDT
Marked bug 7750 as LATER. Doing the same here.
Comment 10 Randy Giffen CLA 2002-08-09 10:50:50 EDT
Reopened for investigation
Comment 11 Simon Arsenault CLA 2002-09-03 14:21:24 EDT
*** Bug 7750 has been marked as a duplicate of this bug. ***
Comment 12 Chris McLaren CLA 2005-12-12 16:57:28 EST
Reassigning to Platform-UI-Inbox (I left IBM 18 months ago..)
Comment 13 Michael Van Meekeren CLA 2006-04-21 13:56:16 EDT
Moving Dougs bugs
Comment 14 Paul Webster CLA 2007-04-05 19:01:11 EDT
Assigning to component owner
PW
Comment 15 Paul Webster CLA 2007-06-20 11:12:50 EDT
These will not be worked on.  Please re-open if you feel the community should get a crack at them.

PW