<elements xsi:type="basic:PartDescriptor" xmi:id="_rg3MoKKbEeee0INlRJv_6Q" elementId="eu.etaxonomy.taxeditor.editor.view.checklist.e4.ChecklistEditorE4" label="%editor.name.8" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.editor/icons/check.png" closeable="true" dirtyable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.checklist.e4.ChecklistEditorE4"/>
<elements xsi:type="basic:PartDescriptor" xmi:id="_f13LIKO5EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.editor.key.e4.KeyEditorE4" label="%editor.name.1" closeable="true" dirtyable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.e4.KeyEditorE4">
<handlers xmi:id="_AXKLwKO9EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.editor.key.e4.handler.ApplyLayoutHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.e4.handler.ApplyLayoutHandlerE4" command="_zN-H8KO8EeeWePK798pdTw"/>
- <handlers xmi:id="_Umd9sKO9EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.DeleteNodeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.DeleteNodeHandlerE4" command="_uM4zsKO8EeeWePK798pdTw"/>
- <handlers xmi:id="_3a0tcKO9EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.InsertNewNodeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.InsertNewNodeHandlerE4" command="_jJ_4kKO9EeeWePK798pdTw"/>
<menus xsi:type="menu:PopupMenu" xmi:id="_Y-mtgKO7EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.editor.popupmenu.0">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_n9Na0KO7EeeWePK798pdTw" coreExpressionId="isCdmStoreConnected"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_Z1D0YKO7EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.commandlabel20" label="%command.label.20" command="_jJ_4kKO9EeeWePK798pdTw"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_dm1c4KO7EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.commandlabel22" label="%command.label.22" command="_zN-H8KO8EeeWePK798pdTw"/>
</menus>
</elements>
- <elements xsi:type="basic:PartDescriptor" xmi:id="_ghDAsKO6EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyGraphEditorE4" label="%editor.name.2" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyGraphEditorE4"/>
- <elements xsi:type="basic:PartDescriptor" xmi:id="_tJeg0KO6EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4" label="%editor.name.3" closeable="true" dirtyable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4"/>
+ <elements xsi:type="basic:PartDescriptor" xmi:id="_ghDAsKO6EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyGraphEditorE4" label="%editor.name.2" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyGraphEditorE4">
+ <handlers xmi:id="_dpB_kKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.key.e4.handler.ApplyLayoutHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.e4.handler.ApplyLayoutHandlerE4" command="_zN-H8KO8EeeWePK798pdTw"/>
+ <menus xsi:type="menu:PopupMenu" xmi:id="_J8Q6AKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.popupmenu.polytomouskeygrapheditor" toBeRendered="false" visible="false">
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_bnPG8KRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.keygraph.newnode" label="%command.label.20" command="_jJ_4kKO9EeeWePK798pdTw"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_wKd6cKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.keygraph.delete" label="%command.label.21" command="_uM4zsKO8EeeWePK798pdTw"/>
+ <children xsi:type="menu:MenuSeparator" xmi:id="_whq5gKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.18"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_w9X-EKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.keygraph.applylayout" label="%command.label.22" command="_zN-H8KO8EeeWePK798pdTw"/>
+ </menus>
+ </elements>
+ <elements xsi:type="basic:PartDescriptor" xmi:id="_tJeg0KO6EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4" label="%editor.name.3" closeable="true" dirtyable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4">
+ <handlers xmi:id="_yHjdwKRREeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.InsertNewNodeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.InsertNewNodeHandlerE4" command="_jJ_4kKO9EeeWePK798pdTw"/>
+ <handlers xmi:id="_zCFMUKRREeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.DeleteNodeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.DeleteNodeHandlerE4" command="_uM4zsKO8EeeWePK798pdTw"/>
+ <handlers xmi:id="_8DficKRREeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.CreateChildNodeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.CreateChildNodeHandlerE4" command="_tyHGwKO9EeeWePK798pdTw"/>
+ <handlers xmi:id="_QHL6QKRSEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.CreateSiblingNodeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.CreateSiblingNodeHandlerE4" command="_rkKogKO9EeeWePK798pdTw"/>
+ <handlers xmi:id="_pDoJsKRSEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.RefreshNodeNumberingHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.RefreshNodeNumberingHandlerE4" command="_mH1G8KRSEeePufXF8uhoCw"/>
+ <menus xsi:type="menu:PopupMenu" xmi:id="_2JO_8KRQEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.popupmenu.polytomouskeylisteditor">
+ <children xsi:type="menu:Menu" xmi:id="_2yjpwKRQEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.menu.polytomouskeylist.newkeynumber" label="%menu.label.4">
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_DWtt4KRREeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.polytomouskeylist.new.insertNode" label="%command.label.58" command="_jJ_4kKO9EeeWePK798pdTw"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_GeKnAKRREeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.polytomouskeylist.new.aftercurrent" label="%command.label.23" command="_tyHGwKO9EeeWePK798pdTw"/>
+ </children>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_Iqi_AKRREeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.polytomouskeylist.newAlternative" label="%command.label.24" command="_rkKogKO9EeeWePK798pdTw"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_LJ-14KRREeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.polytomouskeylist.refreshNodes" label="%command.label.25" command="_mH1G8KRSEeePufXF8uhoCw"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_Rf4A8KRREeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.polytomouskeylist.delete" label="%command.label.26" command="_uM4zsKO8EeeWePK798pdTw"/>
+ </menus>
+ </elements>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="__mwtMDVpEee_b7RlBzTDRw" featurename="commands" parentElementId="xpath:/">
<elements xsi:type="commands:Command" xmi:id="_BjF3ADVqEee_b7RlBzTDRw" elementId="eu.etaxonomy.taxeditor.editor.command.specimeneditor.create_field_unit" commandName="%command.commandname.1"/>
<elements xsi:type="commands:Command" xmi:id="_jJ_4kKO9EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.key.polytomous.command.new.node" commandName="%command.name.58"/>
<elements xsi:type="commands:Command" xmi:id="_rkKogKO9EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.key.polytomous.command.new.sibling" commandName="%command.name.29"/>
<elements xsi:type="commands:Command" xmi:id="_tyHGwKO9EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.key.polytomous.command.new.child" commandName="%command.name.28"/>
+ <elements xsi:type="commands:Command" xmi:id="_mH1G8KRSEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.key.polytomous.command.refresh" commandName="%command.name.30"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_pZmusEalEeeXMc6kSYO7Xg" featurename="children" parentElementId="eu.etaxonomy.taxeditor.menu.showView" positionInList="after:eu.etaxonomy.taxeditor.store.menuseparator.afterSupplemental">
<elements xsi:type="menu:MenuSeparator" xmi:id="_eAVmMJ7SEee0IagNh8pHpQ" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.14"/>
visible="true">
</separator>
</menuContribution>
- <menuContribution
- locationURI="popup:eu.etaxonomy.taxeditor.editor.key.polytomous.list">
- <menu
- label="%menu.label.4">
- <command
- commandId="eu.etaxonomy.taxeditor.key.polytomous.command.new.node"
- label="%command.label.58"
- style="push">
- </command>
- <command
- commandId="eu.etaxonomy.taxeditor.key.polytomous.command.new.child"
- label="%command.label.23"
- style="push">
- </command>
- </menu>
- <command
- commandId="eu.etaxonomy.taxeditor.key.polytomous.command.new.sibling"
- label="%command.label.24"
- style="push">
- </command>
- <!-- <dynamic
- class="eu.etaxonomy.taxeditor.view.CdmViewerContextMenu"
- id="eu.etaxonomy.taxeditor.editor.polytomous.list.cdmViewerContextMenu">
- </dynamic>-->
- <command
- commandId="eu.etaxonomy.taxeditor.key.polytomous.command.refresh"
- label="%command.label.25"
- style="push">
- </command>
- <command
- commandId="eu.etaxonomy.taxeditor.key.polytomous.command.delete"
- label="%command.label.26"
- style="push">
- </command>
- <separator
- name="eu.etaxonomy.taxeditor.editor.separator1">
- </separator>
- </menuContribution>
<menuContribution
locationURI="popup:eu.etaxonomy.taxeditor.editor.view.dataimport.SpecimenImportEditor">
<dynamic
id="eu.etaxonomy.taxeditor.editor.command.new.person"
name="%command.name.26">
</command>
- <command
- categoryId="eu.etaxonomy.taxeditor.editor.key.category"
-
- id="eu.etaxonomy.taxeditor.key.polytomous.command.refresh"
- name="%command.name.30">
- </command>
<category
id="eu.etaxonomy.taxeditor.editor.view.concept.category"
name="%category.name.6">
*/
package eu.etaxonomy.taxeditor.editor.key.e4;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.GroupMarker;
+import javax.inject.Inject;
+
+import org.eclipse.e4.ui.di.Focus;
+import org.eclipse.e4.ui.di.Persist;
+import org.eclipse.e4.ui.model.application.ui.MDirtyable;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.part.EditorPart;
import org.eclipse.zest.core.viewers.AbstractZoomableViewer;
import org.eclipse.zest.core.viewers.GraphViewer;
import org.eclipse.zest.core.viewers.IZoomableWorkbenchPart;
import org.eclipse.zest.core.viewers.ZoomContributionViewItem;
-import org.eclipse.zest.core.widgets.ZestStyles;
import org.eclipse.zest.layouts.LayoutAlgorithm;
import org.eclipse.zest.layouts.LayoutStyles;
import org.eclipse.zest.layouts.algorithms.TreeLayoutAlgorithm;
import eu.etaxonomy.cdm.model.description.IIdentificationKey;
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorInput;
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
/**
- * @author n.hoffmann
*
+ * @author pplitzner
+ * @since Sep 28, 2017
+ *
+ * @param <T>
*/
public abstract class AbstractGraphKeyEditorE4<T extends IIdentificationKey>
- extends EditorPart implements IConversationEnabled,
+implements IConversationEnabled,
IZoomableWorkbenchPart, IPostOperationEnabled,
IDirtyMarkable {
- private CdmFormFactory formFactory;
- private Composite container;
+ protected CdmFormFactory formFactory;
+ protected Composite container;
protected GraphViewer viewer;
private LayoutAlgorithm layoutAlgoritm;
private ZoomContributionViewItem zoomContributionViewItem;
- private boolean dirty = false;
private IToolBarManager toolBarManager;
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.
- * IProgressMonitor)
- */
- @Override
- public void doSave(IProgressMonitor monitor) {
- getConversationHolder().commit(true);
- setDirty(false);
- viewer.refresh();
- }
+ private PolytomousKeyEditorInput input;
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.EditorPart#doSaveAs()
- */
- @Override
- public void doSaveAs() {
- doSave(null);
- }
+ @Inject
+ protected ESelectionService selService;
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite,
- * org.eclipse.ui.IEditorInput)
- */
- @Override
- public void init(IEditorSite site, IEditorInput input)
- throws PartInitException {
- setSite(site);
- setInput(input);
- formFactory = new CdmFormFactory(site.getShell().getDisplay());
- }
+ @Inject
+ private MDirtyable dirty;
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.EditorPart#isDirty()
- */
- @Override
- public boolean isDirty() {
- return dirty;
- }
+ protected ISelectionChangedListener selectionChangedListener;
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
- */
- @Override
- public boolean isSaveAsAllowed() {
- return false;
- }
+ @Inject
+ private MPart thisPart;
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets
- * .Composite)
- */
- @Override
- public void createPartControl(Composite parent) {
- container = formFactory.createComposite(parent);
-
- container.setLayout(new FillLayout());
- viewer = new GraphViewer(container, SWT.NONE);
- getSite().setSelectionProvider(viewer);
-
- viewer.setContentProvider(getContentProvider());
- viewer.setLabelProvider(getLabelProvider());
-
- viewer.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED);
-
- viewer.setLayoutAlgorithm(getLayoutAlgoritm(), false);
-
- createMenu();
-
- createToolbar();
-
- viewer.setInput(getKey());
-
- container.addControlListener(new ControlListener() {
-
- @Override
- public void controlResized(ControlEvent e) {
- // applyLayout();
- }
-
- @Override
- public void controlMoved(ControlEvent e) {
- // TODO Auto-generated method stub
-
- }
- });
+ @Persist
+ public void doSave() {
+ getConversationHolder().commit(true);
+ setDirty(false);
+ viewer.refresh();
}
- private void createToolbar() {
- getToolBarManager().add(getZoomContributionViewItem());
+ public void init(PolytomousKeyEditorInput input) {
+ this.input = input;
}
- private void createMenu() {
- // Add context menu to tree
- MenuManager menuMgr = new MenuManager();
- menuMgr.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
-
- // MenuManager zoomMenu = new MenuManager("Zoom");
- // zoomMenu.add(getZoomContributionViewItem());
-
- ZoomContributionViewItem zoomItem = getZoomContributionViewItem();
- menuMgr.add(zoomItem);
- getSite().registerContextMenu(menuMgr, viewer);
-
- Control control = viewer.getGraphControl();
- Menu menu = menuMgr.createContextMenu(control);
+ public boolean isDirty() {
+ return dirty.isDirty();
+ }
- control.setMenu(menu);
+ public PolytomousKeyEditorInput getEditorInput() {
+ return input;
+ }
- }
+ //FIXME E4 migrate
+// private void createToolbar() {
+// getToolBarManager().add(getZoomContributionViewItem());
+// }
protected abstract IBaseLabelProvider getLabelProvider();
*/
public abstract T getKey();
- @Override
+ @Focus
public void setFocus() {
- viewer.getControl().setFocus();
+ if(viewer!=null && viewer.getControl()!=null && !viewer.getControl().isDisposed()) {
+ viewer.getControl().setFocus();
+ }
}
public void refresh() {
viewer.refresh();
- // graphViewer.applyLayout();
}
@Override
return viewer;
}
- private LayoutAlgorithm getLayoutAlgoritm() {
+ protected LayoutAlgorithm getLayoutAlgoritm() {
if (layoutAlgoritm == null) {
// layoutAlgoritm = new CompositeLayoutAlgorithm(
// LayoutStyles.NO_LAYOUT_NODE_RESIZING,
return true;
}
- private IToolBarManager getToolBarManager() {
- if (toolBarManager == null) {
- toolBarManager = getEditorSite().getActionBars()
- .getToolBarManager();
- }
- return toolBarManager;
- }
+ //FIXME E4 migrate
+// private IToolBarManager getToolBarManager() {
+// if (toolBarManager == null) {
+// toolBarManager = getEditorSite().getActionBars()
+// .getToolBarManager();
+// }
+// return toolBarManager;
+// }
public void applyLayout() {
viewer.applyLayout();
}
public void setDirty(boolean dirty) {
- this.dirty = dirty;
- firePropertyChange(PROP_DIRTY);
+ this.dirty.setDirty(dirty);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider#changed(
- * java.lang.Object)
- */
@Override
public void changed(Object element) {
setDirty(true);
viewer.update(element, null);
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider#forceDirty()
- */
@Override
public void forceDirty() {
changed(null);
+++ /dev/null
-/**
- * Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy
- * http://www.e-taxonomy.eu
- *
- * The contents of this file are subject to the Mozilla Public License Version 1.1
- * See LICENSE.TXT at the top of this package for the full license terms.
- */
-
-package eu.etaxonomy.taxeditor.editor.key.e4;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.forms.editor.FormEditor;
-
-import eu.etaxonomy.cdm.api.application.CdmApplicationState;
-import eu.etaxonomy.cdm.api.application.CdmChangeEvent;
-import eu.etaxonomy.cdm.api.application.ICdmChangeListener;
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
-import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
-import eu.etaxonomy.cdm.model.common.CdmBase;
-import eu.etaxonomy.cdm.model.description.PolytomousKey;
-import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
-import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorInput;
-import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyGraphEditor;
-import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyListEditor;
-import eu.etaxonomy.taxeditor.editor.l10n.Messages;
-import eu.etaxonomy.taxeditor.model.DataChangeBridge;
-import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
-import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
-
-/**
- * @author n.hoffmann
- * @created Mar 30, 2011
- * @version 1.0
- */
-public class KeyEditorE4 extends FormEditor implements IConversationEnabled,
- IDirtyMarkable, IPartContentHasDetails, ICdmChangeListener {
-
- public static final String ID = "eu.etaxonomy.taxeditor.editor.key"; //$NON-NLS-1$
-
- private ConversationHolder conversation;
-
- private boolean dirty;
-
- private KeyEditorDataChangeBehaviour dataChangeBehavior;
-
- private PolytomousKeyEditorInput polytomousKeyEditorInput;
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite,
- * org.eclipse.ui.IEditorInput)
- */
- @Override
- public void init(IEditorSite site, IEditorInput input)
- throws PartInitException {
- polytomousKeyEditorInput = (PolytomousKeyEditorInput)input;
- CdmApplicationState.getCurrentDataChangeService().register(this);
- super.init(site, input);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.
- * IProgressMonitor)
- */
- @Override
- public void doSave(IProgressMonitor monitor) {
- try {
- monitor.beginTask(Messages.KeyEditor_SAVING, 1);
- getConversationHolder().bind();
- getConversationHolder().commit(true);
- polytomousKeyEditorInput.merge();
- setDirty(false);
- monitor.worked(1);
- } finally {
- monitor.done();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.EditorPart#doSaveAs()
- */
- @Override
- public void doSaveAs() {
- // not allowed
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
- */
- @Override
- public boolean isSaveAsAllowed() {
- return false;
- }
-
- @Override
- public void setFocus() {
- getConversationHolder().commit(true);
- getConversationHolder().bind();
- polytomousKeyEditorInput.bind();
- super.setFocus();
- }
- /*
- * (non-Javadoc)
- *
- * @see
- * eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update
- * (eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
- */
- @Override
- public void update(CdmDataChangeMap map) {
- if(dataChangeBehavior == null){
- dataChangeBehavior = new KeyEditorDataChangeBehaviour(this);
- }
- DataChangeBridge.handleDataChange(map, dataChangeBehavior);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder
- * ()
- */
- @Override
- public ConversationHolder getConversationHolder() {
- return conversation;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider#changed(
- * java.lang.Object)
- */
- @Override
- public void changed(Object element) {
- if (element != null){
- editorDirtyStateChanged();
- }
- IEditorPart activeEditor = getActiveEditor();
- if (activeEditor instanceof IDirtyMarkable) {
- ((IDirtyMarkable) activeEditor).changed(element);
- }
- }
-
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.model.IDirtyMarkableSelectionProvider#forceDirty()
- */
- @Override
- public void forceDirty() {
- changed(null);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.editor.FormEditor#editorDirtyStateChanged()
- */
- @Override
- public void editorDirtyStateChanged() {
- dirty = true;
- super.editorDirtyStateChanged();
- }
-
- @Override
- protected void handlePropertyChange(int propertyId) {
- if (propertyId == PROP_DIRTY) {
- setDirty(true);
- }
- super.handlePropertyChange(propertyId);
- }
-
- private void setDirty(boolean dirty) {
- this.dirty = dirty;
- firePropertyChange(PROP_DIRTY);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.editor.FormEditor#isDirty()
- */
- @Override
- public boolean isDirty() {
- return dirty;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.editor.FormEditor#dispose()
- */
- @Override
- public void dispose() {
- conversation.unregisterForDataStoreChanges(this);
- conversation.close();
- polytomousKeyEditorInput.dispose();
- CdmApplicationState.getCurrentDataChangeService().unregister(this);
- super.dispose();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
- */
- @Override
- protected void addPages() {
- conversation = polytomousKeyEditorInput.getConversationHolder();
- conversation.registerForDataStoreChanges(this);
-
- try {
- addPage(0, new PolytomousKeyListEditor(this), polytomousKeyEditorInput);
- setPageText(0, Messages.KeyEditor_LIST);
- addPage(1, new PolytomousKeyGraphEditor(this), polytomousKeyEditorInput);
- setPageText(1, Messages.KeyEditor_GRAPH);
- } catch (PartInitException e) {
- MessagingUtils.error(getClass(), e);
- }
-
-
-
- setPartName();
-
- }
-
- /**
- *
- */
- public void setPartName() {
- PolytomousKey key = polytomousKeyEditorInput.getKey();
- setPartName(key.getTitleCache());
- }
-
- /* (non-Javadoc)
- * @see eu.etaxonomy.cdm.api.application.ICdmChangeListener#onChange(eu.etaxonomy.cdm.api.application.CdmChangeEvent)
- */
- @Override
- public void onChange(CdmChangeEvent event) {
- editorDirtyStateChanged();
- IEditorPart activeEditor = getActiveEditor();
- if (activeEditor instanceof IDirtyMarkable) {
- for(CdmBase cdmBase : event.getChangedObjects()) {
- ((IDirtyMarkable) activeEditor).changed(cdmBase);
- }
- }
- }
-}
public class PolytomousKeyEditorInput extends AbstractIdentificationEditorInput<PolytomousKey> {
private final String name;
- private final UUID keyUuid;
private PolytomousKey key;
protected PolytomousKeyEditorInput(ConversationHolder conversation,
UUID polytomousKeyUuid) {
super(conversation);
- this.keyUuid = polytomousKeyUuid;
List<String> propertyPath = new ArrayList<>();
propertyPath.add("root");
propertyPath.add("root.*");
@Override
public void merge() {
key = CdmStore.getService(IPolytomousKeyService.class).merge(key,true).getMergedEntity();
-
+
}
@Override
* @created Mar 30, 2011
* @version 1.0
*/
-class PolytomousKeyGraphContentProvider implements IGraphContentProvider {
+public class PolytomousKeyGraphContentProvider implements IGraphContentProvider {
private List<PolytomousKeyRelationship> relations;
/**
* Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy
+ * European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
- *
+ *
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
import eu.etaxonomy.taxeditor.store.CdmStore;
/**
- *
+ *
* @author n.hoffmann
* @created Mar 30, 2011
* @version 1.0
*/
-class PolytomousKeyLabelProvider extends LabelProvider implements
+public class PolytomousKeyLabelProvider extends LabelProvider implements
IEntityStyleProvider {
public static final String LEAF_BUT_NO_TAXON = Messages.PolytomousKeyLabelProvider_LEAF_BUT_NO_TAXON;
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.zest.core.viewers.IEntityStyleProvider#fisheyeNode(java.lang
* .Object)
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.zest.core.viewers.IEntityStyleProvider#getBackgroundColour
* (java.lang.Object)
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.zest.core.viewers.IEntityStyleProvider#getBorderColor(java
* .lang.Object)
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.zest.core.viewers.IEntityStyleProvider#getBorderHighlightColor
* (java.lang.Object)
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.zest.core.viewers.IEntityStyleProvider#getBorderWidth(java
* .lang.Object)
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.zest.core.viewers.IEntityStyleProvider#getForegroundColour
* (java.lang.Object)
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.zest.core.viewers.IEntityStyleProvider#getNodeHighlightColor
* (java.lang.Object)
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.zest.core.viewers.IEntityStyleProvider#getTooltip(java.lang
* .Object)
/**
- *
+ *
*/
package eu.etaxonomy.taxeditor.editor.key.polytomous.e4;
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.eclipse.e4.ui.services.EMenuService;
+import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.zest.core.viewers.GraphViewer;
+import org.eclipse.zest.core.widgets.ZestStyles;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.model.description.PolytomousKey;
-import eu.etaxonomy.taxeditor.editor.key.AbstractGraphKeyEditor;
-import eu.etaxonomy.taxeditor.editor.key.KeyEditor;
+import eu.etaxonomy.taxeditor.editor.key.e4.AbstractGraphKeyEditorE4;
+import eu.etaxonomy.taxeditor.editor.key.polytomous.IPolytomousKeyEditorPage;
+import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyGraphContentProvider;
+import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyLabelProvider;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
/**
* @author n.hoffmann
- *
+ *
*/
public class PolytomousKeyGraphEditorE4 extends
- AbstractGraphKeyEditor<PolytomousKey> implements
+ AbstractGraphKeyEditorE4<PolytomousKey> implements
IPolytomousKeyEditorPage {
public static final String ID = "eu.etaxonomy.taxeditor.editor.key.polytomous.graph"; //$NON-NLS-1$
- private final KeyEditor editor;
- /**
- * @param keyEditor
- */
- public PolytomousKeyGraphEditorE4(KeyEditor editor) {
- this.editor = editor;
+ @Inject
+ public PolytomousKeyGraphEditorE4() {
}
-
+
+ @PostConstruct
+ public void createPartControl(Composite parent, EMenuService menuService,
+ @Named(IServiceConstants.ACTIVE_SHELL)Shell shell) {
+ container = formFactory.createComposite(parent);
+
+ container.setLayout(new FillLayout());
+ viewer = new GraphViewer(container, SWT.NONE);
+
+ viewer.setContentProvider(getContentProvider());
+ viewer.setLabelProvider(getLabelProvider());
+
+ viewer.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED);
+
+ viewer.setLayoutAlgorithm(getLayoutAlgoritm(), false);
+
+ //propagate selection
+ selectionChangedListener = (event -> selService.setSelection(event.getSelection()));
+ viewer.addSelectionChangedListener(selectionChangedListener);
+
+ //create context menu
+ menuService.registerContextMenu(viewer.getControl(), "eu.etaxonomy.taxeditor.editor.popupmenu.polytomouskeygrapheditor");
+
+ //FIXME E4 migrate
+// createToolbar();
+
+ viewer.setInput(getKey());
+
+ container.addControlListener(new ControlListener() {
+
+ @Override
+ public void controlResized(ControlEvent e) {
+ // applyLayout();
+ }
+
+ @Override
+ public void controlMoved(ControlEvent e) {
+
+ }
+ });
+
+ formFactory = new CdmFormFactory(shell.getDisplay());
+ }
+
@Override
public ConversationHolder getConversationHolder() {
- return ((PolytomousKeyEditorInput) getEditorInput())
+ return getEditorInput()
.getConversationHolder();
}
@Override
public PolytomousKey getKey() {
- return ((PolytomousKeyEditorInput) getEditorInput()).getKey();
+ return getEditorInput().getKey();
}
@Override
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.key.KeyEditor;
+import eu.etaxonomy.taxeditor.editor.key.KeyEditorDataChangeBehaviour;
import eu.etaxonomy.taxeditor.editor.key.polytomous.IPolytomousKeyEditorPage;
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorInput;
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyListContentProvider;
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyListLabelProvider;
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
+import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
/**
*
*/
public class PolytomousKeyListEditorE4 implements
- IConversationEnabled, IDirtyMarkable,
+ IConversationEnabled, IDirtyMarkable, IPartContentHasDetails,
IPolytomousKeyEditorPage {
private class LinkListener extends MouseAdapter {
private TableViewer viewer;
+ private ConversationHolder conversation;
+
+ private KeyEditorDataChangeBehaviour dataChangeBehavior;
+
private PolytomousKeyEditorInput input;
@Inject
@Persist
public void doSave(IProgressMonitor monitor) {
- }
+ try {
+ monitor.beginTask(Messages.KeyEditor_SAVING, 1);
+ getConversationHolder().bind();
+ getConversationHolder().commit(true);
+ input.merge();
+ dirty.setDirty(false);
+ monitor.worked(1);
+ } finally {
+ monitor.done();
+ }
+ }
public void init(PolytomousKeyEditorInput input) {
this.input = input;
viewer.setContentProvider(new PolytomousKeyListContentProvider());
viewer.setLabelProvider(new PolytomousKeyListLabelProvider());
- //propagate selection
- selectionChangedListener = (event -> selService.setSelection(AbstractUtility.getElementsFromSelectionChangedEvent(event)));
+ //propagate selection
+ selectionChangedListener = (event -> selService.setSelection(event.getSelection()));
viewer.addSelectionChangedListener(selectionChangedListener);
//create context menu
if(viewer!=null && viewer.getControl()!=null){
viewer.getControl().setFocus();
}
+ if(input!=null){
+ input.bind();
+ }
}
@Override
viewer.update(child, null);
}
}
-
+ dirty.setDirty(true);
viewer.refresh();
}
--- /dev/null
+/**
+* Copyright (C) 2016 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler;
+
+import eu.etaxonomy.taxeditor.editor.key.polytomous.IPolytomousKeyEditorPage;
+import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
+
+/**
+ * @author k.luther
+ * @date 24.11.2016
+ *
+ */
+public abstract class AbstractPolytomousKeyNodeHandlerE4 extends RemotingCdmHandlerE4 {
+
+
+ IPolytomousKeyEditorPage editorPage;
+
+ public AbstractPolytomousKeyNodeHandlerE4(String label) {
+ super(label);
+ }
+
+}
--- /dev/null
+/**
+ *
+ */
+package eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler;
+
+import javax.inject.Named;
+
+import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+import eu.etaxonomy.cdm.model.description.PolytomousKey;
+import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4;
+import eu.etaxonomy.taxeditor.editor.key.polytomous.operation.CreateNodeOperation;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+
+/**
+ *
+ * @author pplitzner
+ * @since Sep 28, 2017
+ *
+ */
+public class CreateChildNodeHandlerE4 {
+
+
+ @Execute
+ public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+ @Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+ MHandledMenuItem menuItem) {
+
+ PolytomousKeyListEditorE4 editor = (PolytomousKeyListEditorE4) activePart.getObject();
+
+ if(editor.getTableItemCount() == 0) {
+ PolytomousKey pk = editor.getViewerInputKey();
+ String label = menuItem.getLocalizedLabel();
+ IUndoContext undoContext = EditorUtil.getUndoContext();
+
+
+ AbstractPostOperation operation = new CreateNodeOperation(
+ label, undoContext, pk.getRoot(), editor);
+ AbstractUtility.executeOperation(operation);
+ } else {
+
+ String label = menuItem.getLocalizedLabel();
+ IUndoContext undoContext = EditorUtil.getUndoContext();
+
+ PolytomousKeyNode keyNode = (PolytomousKeyNode) selection
+ .getFirstElement();
+
+ AbstractPostOperation operation = new CreateNodeOperation(
+ label, undoContext, keyNode, editor);
+ AbstractUtility.executeOperation(operation);
+ }
+ }
+
+}
--- /dev/null
+package eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler;
+
+import javax.inject.Named;
+
+import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4;
+import eu.etaxonomy.taxeditor.editor.key.polytomous.operation.CreateNodeOperation;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+
+/**
+ * Handler responsible for creating sibling nodes of Polytomous Key Nodes
+ *
+ * @author c.mathew
+ *
+ */
+
+public class CreateSiblingNodeHandlerE4 {
+
+ @Execute
+ public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart,
+ @Named(IServiceConstants.ACTIVE_SELECTION) IStructuredSelection selection, MHandledMenuItem menuItem) {
+
+ PolytomousKeyListEditorE4 editor = (PolytomousKeyListEditorE4) activePart.getObject();
+
+ String label = menuItem.getLocalizedLabel();
+ IUndoContext undoContext = EditorUtil.getUndoContext();
+
+ PolytomousKeyNode keyNode = (PolytomousKeyNode) selection.getFirstElement();
+
+ AbstractPostOperation operation = new CreateNodeOperation(label, undoContext, keyNode.getParent(),
+ editor);
+ AbstractUtility.executeOperation(operation);
+ }
+}
import javax.inject.Named;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.core.commands.operations.AbstractOperation;
import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.e4.core.di.annotations.CanExecute;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.swt.widgets.Shell;
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.key.KeyEditor;
-import eu.etaxonomy.taxeditor.editor.key.polytomous.IPolytomousKeyEditorPage;
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorLabels;
-import eu.etaxonomy.taxeditor.editor.key.polytomous.handler.AbstractPolytomousKeyNodeHandler;
+import eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4;
import eu.etaxonomy.taxeditor.editor.key.polytomous.operation.DeleteNodeOperation;
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
-import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
/**
* @author n.hoffmann
* @created Dec 6, 2010
* @version 1.0
*/
-public class DeleteNodeHandlerE4 extends AbstractPolytomousKeyNodeHandler {
+public class DeleteNodeHandlerE4 extends AbstractPolytomousKeyNodeHandlerE4 {
private static final String DO_YOU_REALLY_WANT_TO_DELETE_THE_NODE_THIS_OPERATION_IS_NOT_REVERSABLE = Messages.DeleteNodeHandler_REALLY_DELETE;
private static final String YES = Messages.DeleteNodeHandler_YES;
PolytomousKeyNode nodeToBeDeleted;
boolean deleteChildren;
- /**
- * @param label
- */
+
public DeleteNodeHandlerE4(String label) {
super(label);
-
}
-
-
public DeleteNodeHandlerE4() {
super(PolytomousKeyEditorLabels.DELETE_NODE_POLYTOMOUS_KEY_NODE_LABEL);
}
- /**
- * {@inheritDoc}
- */
@Override
- public IStatus allowOperations(ExecutionEvent event) {
- IEditorPart editor = HandlerUtil.getActiveEditor(event);
- IStructuredSelection selection = (IStructuredSelection) HandlerUtil
- .getCurrentSelection(event);
- AbstractPostOperation operation;
- if (editor instanceof KeyEditor) {
- editorPage = (IPolytomousKeyEditorPage) ((KeyEditor) editor)
- .getActiveEditor();
- }
-
+ public IStatus allowOperations(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+ @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
+ @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+ MHandledMenuItem menuItem) {
if (selection.getFirstElement() instanceof PolytomousKeyNode) {
- try {
- String label = event.getCommand().getName();
- IUndoContext undoContext = EditorUtil.getUndoContext();
- PolytomousKeyNode node = (PolytomousKeyNode)selection.getFirstElement();
- nodeToBeDeleted = node;
- MessageDialog dialog;
- if (node.getChildren().size()>0){
- String[] buttonLables = {YES, NO,CANCEL};
- dialog = new MessageDialog(null, CONFIRM_DELETION_OF_CHILDREN, null, DO_YOU_REALLY_WANT_TO_DELETE_THE_NODE_THIS_OPERATION_IS_NOT_REVERSABLE+Messages.DeleteNodeHandler_NODE_HAS_CHILDREN, MessageDialog.QUESTION_WITH_CANCEL, buttonLables, 0);
- int returnCode = dialog.open();
-
- if (returnCode == 0){
- deleteChildren = false;
- } else if (returnCode == 1){
- deleteChildren = true;
- } else{
- return new Status(IStatus.CANCEL, "unknown", //$NON-NLS-1$
- null);
- }
-
-
- }else{
- String[] buttonLables = {YES, CANCEL};
- dialog = new MessageDialog(null, CONFIRM_DELETION_OF_CHILDREN, null, DO_YOU_REALLY_WANT_TO_DELETE_THE_NODE_THIS_OPERATION_IS_NOT_REVERSABLE, MessageDialog.QUESTION_WITH_CANCEL, buttonLables, 1);
- int returnCode = dialog.open();
-
- if (returnCode == 0){
- deleteChildren = false;
- } else if (returnCode == 1){
- return new Status(IStatus.CANCEL, "unknown", //$NON-NLS-1$
- null);
- }
+ label = menuItem.getLocalizedLabel();
+ PolytomousKeyNode node = (PolytomousKeyNode)selection.getFirstElement();
+ nodeToBeDeleted = node;
+ MessageDialog dialog;
+ if (node.getChildren().size()>0){
+ String[] buttonLables = {YES, NO,CANCEL};
+ dialog = new MessageDialog(null, CONFIRM_DELETION_OF_CHILDREN, null, DO_YOU_REALLY_WANT_TO_DELETE_THE_NODE_THIS_OPERATION_IS_NOT_REVERSABLE+Messages.DeleteNodeHandler_NODE_HAS_CHILDREN, MessageDialog.QUESTION_WITH_CANCEL, buttonLables, 0);
+ int returnCode = dialog.open();
+
+ if (returnCode == 0){
+ deleteChildren = false;
+ } else if (returnCode == 1){
+ deleteChildren = true;
+ } else{
+ return new Status(IStatus.CANCEL, "unknown", //$NON-NLS-1$
+ null);
}
-
-
- } catch (NotDefinedException e) {
- MessagingUtils.warn(getClass(), "Command name not set."); //$NON-NLS-1$
+ }else{
+ String[] buttonLables = {YES, CANCEL};
+ dialog = new MessageDialog(null, CONFIRM_DELETION_OF_CHILDREN, null, DO_YOU_REALLY_WANT_TO_DELETE_THE_NODE_THIS_OPERATION_IS_NOT_REVERSABLE, MessageDialog.QUESTION_WITH_CANCEL, buttonLables, 1);
+ int returnCode = dialog.open();
+
+ if (returnCode == 0){
+ deleteChildren = false;
+ } else if (returnCode == 1){
+ return new Status(IStatus.CANCEL, "unknown", //$NON-NLS-1$
+ null);
+ }
}
} else {
MessageDialog.openInformation(
- AbstractUtility.getShell(),
+ shell,
PolytomousKeyEditorLabels.NO_KEY_NODE_SELECTED,
PolytomousKeyEditorLabels.NO_KEY_NODE_FOR_INSERT_NODE_SELECTED_MESSAGE
);
return Status.OK_STATUS;
}
- /**
- * {@inheritDoc}
- */
@Override
- public AbstractOperation prepareOperation(ExecutionEvent event) {
+ public AbstractOperation prepareOperation(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+ @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
+ @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+ MHandledMenuItem menuItem) {
IUndoContext undoContext = EditorUtil.getUndoContext();
- String label = ""; //$NON-NLS-1$
- IEditorPart editor = HandlerUtil.getActiveEditor(event);
+ PolytomousKeyListEditorE4 editor = (PolytomousKeyListEditorE4) activePart.getObject();
if (editor.isDirty()){
boolean proceed = MessageDialog.openQuestion(null,
Messages.DeleteNodeHandler_SAVE_CHANGES_TITLE, Messages.DeleteNodeHandler_SAVE_CHANGES_MESSAGE);
if (!proceed) {
return null;
}else{
- editor.doSave(EditorUtil.getMonitor());
+ editor.doSave(AbstractUtility.getMonitor());
}
}
- try {
- label = event.getCommand().getName();
- } catch (NotDefinedException e) {
- MessagingUtils.warn(getClass(), "Command name not set."); //$NON-NLS-1$
- }
+ label = menuItem.getLocalizedLabel();
DeleteNodeOperation operation ;
if (deleteChildren){
operation = new DeleteNodeOperation(label, undoContext, nodeToBeDeleted, editorPage, true);
return operation;
}
+ @Override
+ public void onComplete() {
+ }
+
/**
* {@inheritDoc}
*/
@Override
- public void onComplete() {
- // TODO Auto-generated method stub
-
+ protected Object getTrigger() {
+ return this;
}
@CanExecute
/**
-* Copyright (C) 2016 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
+ * Copyright (C) 2016 EDIT
+ * European Distributed Institute of Taxonomy
+ * http://www.e-taxonomy.eu
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
package eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler;
import javax.inject.Named;
-import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.operations.AbstractOperation;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.e4.core.di.annotations.CanExecute;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.swt.widgets.Shell;
import eu.etaxonomy.cdm.model.description.PolytomousKey;
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
-import eu.etaxonomy.taxeditor.editor.key.KeyEditor;
-import eu.etaxonomy.taxeditor.editor.key.polytomous.IPolytomousKeyEditorPage;
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorLabels;
-import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyListEditor;
-import eu.etaxonomy.taxeditor.editor.key.polytomous.handler.AbstractPolytomousKeyNodeHandler;
+import eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4;
import eu.etaxonomy.taxeditor.editor.key.polytomous.operation.InsertPolytomousKeyNodeOperation;
/**
* @date 17.11.2016
*
*/
-public class InsertNewNodeHandlerE4 extends AbstractPolytomousKeyNodeHandler{
+public class InsertNewNodeHandlerE4 extends AbstractPolytomousKeyNodeHandlerE4{
private PolytomousKeyNode parentNode ;
super(PolytomousKeyEditorLabels.INSERT_NODE_POLYTOMOUS_KEY_NODE_LABEL);
}
-
- /**
- * {@inheritDoc}
- */
@Override
- public IStatus allowOperations(ExecutionEvent event) {
- IEditorPart editor = HandlerUtil.getActiveEditor(event);
-
- if (editor instanceof KeyEditor) {
- editorPage = (IPolytomousKeyEditorPage) ((KeyEditor) editor)
- .getActiveEditor();
-
- if (editorPage instanceof PolytomousKeyListEditor) {
- PolytomousKeyListEditor klEditor = (PolytomousKeyListEditor) editorPage;
- if(klEditor.getTableItemCount() == 0) {
- PolytomousKey pk = klEditor.getViewerInputKey();
- parentNode = pk.getRoot();
-
- } else {
- IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
- if (selection.getFirstElement() instanceof PolytomousKeyNode) {
- parentNode = ((PolytomousKeyNode) selection.getFirstElement()).getParent();
- } else {
- return new Status(IStatus.ERROR,
- "unknown", //$NON-NLS-1$
- PolytomousKeyEditorLabels.NO_KEY_NODE_FOR_INSERT_NODE_SELECTED_MESSAGE);
- }
- }
+ public IStatus allowOperations(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+ @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
+ @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+ MHandledMenuItem menuItem) {
+
+ PolytomousKeyListEditorE4 editor = (PolytomousKeyListEditorE4) activePart.getObject();
+
+ if(editor.getTableItemCount() == 0) {
+ PolytomousKey pk = editor.getViewerInputKey();
+ parentNode = pk.getRoot();
+
+ } else {
+ if (selection.getFirstElement() instanceof PolytomousKeyNode) {
+ parentNode = ((PolytomousKeyNode) selection.getFirstElement()).getParent();
+ } else {
+ return new Status(IStatus.ERROR,
+ "unknown", //$NON-NLS-1$
+ PolytomousKeyEditorLabels.NO_KEY_NODE_FOR_INSERT_NODE_SELECTED_MESSAGE);
}
}
return Status.OK_STATUS;
}
- /**
- * {@inheritDoc}
- */
@Override
- public AbstractOperation prepareOperation(ExecutionEvent event) {
- return new InsertPolytomousKeyNodeOperation(event.getTrigger(), false, parentNode, editorPage);
+ public AbstractOperation prepareOperation(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+ @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
+ @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+ MHandledMenuItem menuItem) {
+ return new InsertPolytomousKeyNodeOperation(getTrigger(), false, parentNode, editorPage);
}
- /**
- * {@inheritDoc}
- */
@Override
public void onComplete() {
- // TODO Auto-generated method stub
-
}
@CanExecute
return canExecute;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Object getTrigger() {
+ return this;
+ }
+
}
--- /dev/null
+package eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler;
+
+import javax.inject.Named;
+
+import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4;
+import eu.etaxonomy.taxeditor.editor.key.polytomous.operation.RefreshNodeNumberingOperation;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+
+public class RefreshNodeNumberingHandlerE4 {
+
+ @Execute
+ public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+ @Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+ MHandledMenuItem menuItem){
+
+ PolytomousKeyListEditorE4 editor = (PolytomousKeyListEditorE4) activePart.getObject();
+
+ if (selection.getFirstElement() instanceof PolytomousKeyNode) {
+ String label = menuItem.getLocalizedLabel();
+ IUndoContext undoContext = EditorUtil.getUndoContext();
+
+ PolytomousKeyNode keyNode = (PolytomousKeyNode) selection
+ .getFirstElement();
+
+ AbstractPostOperation operation = new RefreshNodeNumberingOperation(
+ label, undoContext, keyNode, editor);
+ AbstractUtility.executeOperation(operation);
+ }
+ }
+
+}
<children xsi:type="menu:HandledMenuItem" xmi:id="_Fajhp6QUEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.polytomouskey.edit" label="%command.label.16">
<command href="../eu.etaxonomy.taxeditor.editor/fragment.e4xmi#_uM4zsKO8EeeWePK798pdTw"/>
</children>
- <children xsi:type="menu:Menu" xmi:id="_IKePEKQVEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.menu.menulabel0" label="%menu.label.0">
- <children xsi:type="menu:HandledMenuItem" xmi:id="_JS0-QKQVEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.commandlabel17" label="%command.label.17" command="_4BQ6YKQVEeeTrq_CRrR-jg"/>
- <children xsi:type="menu:HandledMenuItem" xmi:id="_JsJdMKQVEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.commandlabel18" label="%command.label.18" command="_6S6M4KQVEeeTrq_CRrR-jg"/>
+ <children xsi:type="menu:Menu" xmi:id="_IKePEKQVEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.menu.polytomouskey.refresh" label="%menu.label.0">
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_JS0-QKQVEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.polytomouskey.refreshlist" label="%command.label.17" command="_4BQ6YKQVEeeTrq_CRrR-jg"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_JsJdMKQVEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.polytomouskey.refreshnodes" label="%command.label.18" command="_6S6M4KQVEeeTrq_CRrR-jg"/>
</children>
<children xsi:type="menu:MenuSeparator" xmi:id="_FajhqKQUEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.18"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_FajhqaQUEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.polytomouskey.refresh" label="%command.label.19">
*/
public abstract class RemotingCdmHandlerE4 {
- private final String label;
+ protected String label;
@Inject
protected EPartService partService;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
-import javax.inject.Inject;
-import javax.inject.Named;
import org.apache.log4j.Logger;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.e4.ui.di.Focus;
-import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
protected final Logger logger = Logger.getLogger(DataImportViewE4.class);
- @Inject
- private Shell shell;
-
protected Collection<T> results = new ArrayList<T>();
protected boolean updated = false;
*/
public DataImportViewE4() {
CdmStore.getContextManager().addContextListener(this);
- if(CdmStore.isActive()){
- initConversation();
- }
+
}
/**
* @param parent
*/
@PostConstruct
- public void createPartControl(Composite parent, @Named(IServiceConstants.ACTIVE_SHELL)Shell shell) {
- this.shell = shell;
+ public void createPartControl(Composite parent) {
+ if(CdmStore.isActive()){
+ initConversation();
+ }
+ else{
+ return;
+ }
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(2, false));
@Override
public void handleEvent(Event event) {
if(event.widget==btnBrowseClassification){
- classification = SelectionDialogFactory.getSelectionFromDialog(Classification.class, shell, null, null);
+ classification = SelectionDialogFactory.getSelectionFromDialog(Classification.class, event.widget.getDisplay().getActiveShell(), null, null);
if(classification!=null){
textClassification.setText(classification.getTitleCache());
}