Contributing to org.eclipse.ui.popupMenus from GEF [message #218950] |
Wed, 05 July 2006 13:18 |
Eclipse User |
|
|
|
Originally posted by: cricard.businessobjects.com
Hi all,
So far I've been rather successful in achieving what's mentioned in the
subject of this thread by adding 'xxxPart' entries (where xxxPart points to
some EditPart of interest) in plugin.xml.
But a problem has suddenly arisen when the MarqueeSelectionTool is involved:
if I select in such a way some TableParts (which host ColumnParts), a
heterogeneous IStructuredSelection containing both TableParts and
ColumnParts is created and passed to my viewer, and the standard popupMenu
workflow fails to create the menu since it doesn't know on which type of
EditPart it should rely (actually, it should only take TableParts into
account).
Of course, if my ColumnParts return false when isSelectable is called, the
ambiguity is solved... but my columns won't be considered anymore a valid
target for displaying a popup menu :/
I first considered filtering the objects contained in the
IStructuredSelection, but I think it's bad practice since there are other
listeners.
After that, I tried to override MarqueeSelectionTool.performMarqueeSelect(),
but too many fields and methods are private.
Would someone be kind enough to suggest a workaround?
Christophe.
|
|
|
Re: Contributing to org.eclipse.ui.popupMenus from GEF [message #219135 is a reply to message #218950] |
Fri, 07 July 2006 14:23 |
Eclipse User |
|
|
|
Originally posted by: cricard.businessobjects.com
Well, I come back with what looks like a rather satisfying solution as far
as I'm concerned.
All you have to do is write the following lines:
viewer.setSelectionManager(new SelectionManager() {
public void setSelection(ISelection selection) { // Only called
by GEF after a lasso selection
if (! (selection instanceof IStructuredSelection))
return;
IStructuredSelection filteredSelection =
(IStructuredSelection)selection;
List<ColumnPart> columns = new ArrayList<ColumnPart>();
List<TablePart> tables = new ArrayList<TablePart>();
List<xxxPart> xxx = new ArrayList<xxxPart>();
List<yyyPart> yyy = new ArrayList<yyyPart>();
if(! myHelper.scanSelectedParts(filteredSelection, columns,
tables, xxx, yyy)) { // Heterogeneous selection
if(xxx.size() == 0 && yyy.size() == 0) // Only
tables and columns are involved
filteredSelection = new
StructuredSelection(tables.toArray()); // Keep tables, discard columns
}
super.setSelection(filteredSelection);
}
});
Cheers,
Christophe.
"cricri" <cricard@businessobjects.com> wrote in message
news:e8ge7b$m39$1@utils.eclipse.org...
> Hi all,
>
> So far I've been rather successful in achieving what's mentioned in the
> subject of this thread by adding 'xxxPart' entries (where xxxPart points
> to some EditPart of interest) in plugin.xml.
> But a problem has suddenly arisen when the MarqueeSelectionTool is
> involved: if I select in such a way some TableParts (which host
> ColumnParts), a heterogeneous IStructuredSelection containing both
> TableParts and ColumnParts is created and passed to my viewer, and the
> standard popupMenu workflow fails to create the menu since it doesn't know
> on which type of EditPart it should rely (actually, it should only take
> TableParts into account).
>
> Of course, if my ColumnParts return false when isSelectable is called, the
> ambiguity is solved... but my columns won't be considered anymore a valid
> target for displaying a popup menu :/
>
> I first considered filtering the objects contained in the
> IStructuredSelection, but I think it's bad practice since there are other
> listeners.
> After that, I tried to override
> MarqueeSelectionTool.performMarqueeSelect(), but too many fields and
> methods are private.
>
> Would someone be kind enough to suggest a workaround?
>
> Christophe.
>
|
|
|
|
|
Re: Contributing to org.eclipse.ui.popupMenus from GEF [message #219188 is a reply to message #219180] |
Sun, 09 July 2006 01:22 |
Eclipse User |
|
|
|
Originally posted by: alnospammajor.noboxspamspoon.com
cool! i was missing the part about implementing IObjectActionDelegate.
i'm trying to integrate my actions into a Common Navigation Framework
based view. at this point, my action is getting called properly.
now i need to figure out a way to get the view to implement a command
stack. how are you dealing with this situation? are you using the GEF
command stack or one based on the platform operation history?
al
cricri wrote:
> If like me you plan to rely on object contributions - as opposed to viewer
> contributions - all you really need is actions that EXTEND
> org.eclipse.jface.action.Action (GEF actions do, have a look at
> org.eclipse.gef.ui.actions.WorkbenchPartAction for example), and IMPLEMENT
> at least org.eclipse.ui.IObjectActionDelegate (as stated there:
> http://help.eclipse.org/help30/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench_basicext_popupMenus.htm,
> another interesting interface being org.eclipse.ui.IEditorActionDelegate).
>
> I've included a snapshot of what my plugin.xml would look like if, say, I
> wanted to refresh/delete something if one of my TableParts was selected.
>
> Hope it helps,
>
> Christophe.
>
> "Al Major" <alnospammajor@noboxspamspoon.com> wrote in message
> news:e8msb1$50f$1@utils.eclipse.org...
>> are you adding GEF actions to the popup menu? i'm trying to do something
>> similar. what does the entry in your 'plugin.xml' look like?
>>
>> al
>
>
|
|
|
Re: Contributing to org.eclipse.ui.popupMenus from GEF [message #219257 is a reply to message #219188] |
Mon, 10 July 2006 17:18 |
Eclipse User |
|
|
|
Originally posted by: cricard.businessobjects.com
Sorry, we are handling the undo/redo mechanism at model-level :/
"Al Major" <alnospammajor@noboxspamspoon.com> wrote in message
news:e8plof$fg3$1@utils.eclipse.org...
> cool! i was missing the part about implementing IObjectActionDelegate. i'm
> trying to integrate my actions into a Common Navigation Framework based
> view. at this point, my action is getting called properly.
>
> now i need to figure out a way to get the view to implement a command
> stack. how are you dealing with this situation? are you using the GEF
> command stack or one based on the platform operation history?
>
> al
>
> cricri wrote:
>> If like me you plan to rely on object contributions - as opposed to
>> viewer contributions - all you really need is actions that EXTEND
>> org.eclipse.jface.action.Action (GEF actions do, have a look at
>> org.eclipse.gef.ui.actions.WorkbenchPartAction for example), and
>> IMPLEMENT at least org.eclipse.ui.IObjectActionDelegate (as stated there:
>> http://help.eclipse.org/help30/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench_basicext_popupMenus.htm,
>> another interesting interface being
>> org.eclipse.ui.IEditorActionDelegate).
>>
>> I've included a snapshot of what my plugin.xml would look like if, say, I
>> wanted to refresh/delete something if one of my TableParts was selected.
>>
>> Hope it helps,
>>
>> Christophe.
>>
>> "Al Major" <alnospammajor@noboxspamspoon.com> wrote in message
>> news:e8msb1$50f$1@utils.eclipse.org...
>>> are you adding GEF actions to the popup menu? i'm trying to do something
>>> similar. what does the entry in your 'plugin.xml' look like?
>>>
>>> al
>>
|
|
|
Powered by
FUDForum. Page generated in 0.03840 seconds