commandId="eu.etaxonomy.taxeditor.bulkeditor.convertTeam2Person">
</handler>
<handler
- class="eu.etaxonomy.taxeditor.bulkeditor.handler.ConvertPerson2TeamHandler"
+ class="eu.etaxonomy.taxeditor.bulkeditor.handler.ConvertPerson2TeamRemotingHandler"
commandId="eu.etaxonomy.taxeditor.bulkeditor.convertPerson2Team">
+ <activeWhen>
+ <reference
+ definitionId="isRemoting">
+ </reference>
+ </activeWhen>
</handler>
<handler
class="eu.etaxonomy.taxeditor.bulkeditor.handler.defaultHandler.OpenBulkEditorForIdentifiableEntity"
--- /dev/null
+/**
+* Copyright (C) 2017 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.bulkeditor.handler;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.core.commands.operations.AbstractOperation;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.agent.Person;
+import eu.etaxonomy.taxeditor.bulkeditor.l10n.Messages;
+import eu.etaxonomy.taxeditor.bulkeditor.operation.ConvertPerson2TeamOperation;
+import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
+
+/**
+ * @author k.luther
+ * @date 10.05.2017
+ *
+ */
+public class ConvertPerson2TeamRemotingHandler extends RemotingCdmHandler {
+ IEditorPart editor;
+
+ /**
+ * @param label
+ */
+ public ConvertPerson2TeamRemotingHandler() {
+ super(Messages.ConvertPerson2TeamHandler_lable);
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IStatus allowOperations(ExecutionEvent event) {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+
+ editor = HandlerUtil.getActiveEditor(event);
+
+ IEditorInput input = editor.getEditorInput();
+ if (editor.isDirty()){
+ boolean proceed = MessageDialog.openQuestion(null,
+ "Save changes", "You have made changes that must be saved before this query can be executed. Would you like to proceed?");
+ if (proceed) {
+ editor.doSave(null);
+ } else {
+ return Status.CANCEL_STATUS;
+ }
+ }
+ Iterator<IStructuredSelection> it = ((IStructuredSelection) selection).iterator();
+ while( it.hasNext()){
+ Object object =it.next();
+ if (!(object instanceof Person)){
+ MessageDialog.openInformation(null, "Operation not applicable.", "This operation is only applicable for persons");
+ return Status.CANCEL_STATUS;
+ }
+ }
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public AbstractOperation prepareOperation(ExecutionEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getActiveSite(event).getSelectionProvider().getSelection();
+
+ try {
+ String label = event.getCommand().getName();
+ Iterator<IStructuredSelection> it = selection.iterator();
+ ConvertPerson2TeamOperation operation;
+ List<Person> persons = new ArrayList<Person>();
+ while( it.hasNext()){
+ Object object =it.next();
+ if (object instanceof Person){
+ Person person = HibernateProxyHelper.deproxy(object, Person.class);
+ persons.add(person);
+ }
+ }
+ return new ConvertPerson2TeamOperation(label, persons, true, editor);
+
+
+ } catch (NotDefinedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onComplete() {
+ // TODO Auto-generated method stub
+
+ }
+
+
+
+}
--- /dev/null
+/**
+* Copyright (C) 2017 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.bulkeditor.operation;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.IEditorPart;
+
+import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
+import eu.etaxonomy.cdm.api.service.IAgentService;
+import eu.etaxonomy.cdm.api.service.UpdateResult;
+import eu.etaxonomy.cdm.model.agent.Person;
+import eu.etaxonomy.cdm.model.agent.Team;
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.strategy.merge.MergeException;
+import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
+import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author k.luther
+ * @date 10.05.2017
+ *
+ */
+public class ConvertPerson2TeamOperation extends RemotingCdmUpdateOperation {
+ List<Person> persons;
+ List<Team> teams;
+ IEditorPart editor;
+
+ /**
+ * @param label
+ * @param editor
+ * @param undoContext
+ * @param element
+ */
+ public ConvertPerson2TeamOperation(String label, List<Person> persons, boolean async, IEditorPart editor) {
+ super(label, Action.Update, persons, async);
+ this.persons = persons;
+ this.editor = editor;
+ this.teams = new ArrayList<Team>();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ UpdateResult result = new UpdateResult();
+ try {
+ for (Person person: persons){
+ UpdateResult resultTemp = CdmStore.getService(IAgentService.class).convertPerson2Team(person.getUuid());
+ result.includeResult(resultTemp);
+ result.addUpdatedObject(resultTemp.getCdmEntity());
+
+ }
+ for (CdmBase team:result.getUpdatedObjects()){
+
+ teams.add((Team)team);
+ }
+ } catch (IllegalArgumentException e) {
+ MessagingUtils.errorDialog("Can not convert Person into a Team", null, e.getLocalizedMessage(), TaxeditorBulkeditorPlugin.PLUGIN_ID,e, true);
+ } catch (MergeException e) {
+ MessagingUtils.informationDialog("Convert not possible", "Person can not be transformed into team as it is already part of a team.");
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected IStatus onComplete(boolean success) {
+
+ ((BulkEditor) editor).getSearchBar().updateEditorInput();
+ return Status.OK_STATUS;
+ }
+
+
+
+}
org.eclipse.ui.forms,
eu.etaxonomy.taxeditor.store,
eu.etaxonomy.taxeditor.bulkeditor,
+ eu.etaxonomy.taxeditor.workbench,
org.eclipse.zest.core,
org.eclipse.zest.layouts,
eu.etaxonomy.taxeditor.cdmlib,
commandId="eu.etaxonomy.taxeditor.editor.media.command.newimagegallery"
label="%command.label.37"
style="push">
- <visibleWhen>
+ <!-- <visibleWhen>
<or>
<reference
definitionId="isBulkEditor">
definitionId="isDerivateEditor">
</reference>
</or>
- </visibleWhen>
+ </visibleWhen>-->
</command>
<separator
name="taxeditor-editor.separator1"
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
import eu.etaxonomy.taxeditor.view.supplementaldata.SupplementalDataViewPart;
+import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
/**
* @author n.hoffmann
private ConceptRelationViewer viewer;
@Override
- protected void selectionChanged_internal(IWorkbenchPart part, ISelection selection) {
+ protected void selectionChanged_internal(IWorkbenchPart workbenchPart, ISelection selection) {
if(part == this){
return;
}
+ Object part = workbenchPart;
+ Object wrappedPart = WorkbenchUtility.getE4WrappedPart(part);
+ if(wrappedPart!=null){
+ part = wrappedPart;
+ }
if(AbstractUtility.getActiveE4Editor() == null){
showEmptyPage();
return;
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
+import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
/**
* @author andreas
* @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
*/
@Override
- protected void selectionChanged_internal(IWorkbenchPart part, ISelection selection) {
+ protected void selectionChanged_internal(IWorkbenchPart workbenchPart, ISelection selection) {
+ Object part = workbenchPart;
+ Object wrappedPart = WorkbenchUtility.getE4WrappedPart(part);
+ if(wrappedPart!=null){
+ part = wrappedPart;
+ }
// if(part instanceof ConceptGraphView){
// // ConceptGraphView is maximized
// return;
IEditorInput input = ((IEditorPart) part).getEditorInput();
showViewer(part, new StructuredSelection(input));
}
- showViewer();
}
}
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeNode;
import org.eclipse.jface.viewers.TreeSelection;
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
import eu.etaxonomy.taxeditor.editor.view.derivate.searchFilter.DerivateSearchCompositeController;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.IContextListener;
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateContentProvider;
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
+import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
/**
* Displays the derivate hierarchy of the specimen specified in the editor input.
*/
public class DerivateView implements IPartContentHasFactualData, IConversationEnabled,
ICdmEntitySessionEnabled, IDirtyMarkable, IPostOperationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IPartContentHasMedia,
- IContextListener {
+ IContextListener, IE4SavablePart {
private static final String SPECIMEN_EDITOR = Messages.DerivateView_SPECIMEN_EDITOR;
viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
viewer.getTree().setEnabled(CdmStore.isActive());
- selectionChangedListener = new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection isel = (IStructuredSelection) event.getSelection();
- selService.setSelection((isel.size() == 1 ? isel.getFirstElement() : isel.toArray()));
- }
- };
+ //propagate selection
+ selectionChangedListener = (event -> selService.setSelection(AbstractUtility.getElementsFromSelectionChangedEvent(event)));
viewer.addSelectionChangedListener(selectionChangedListener);
//create context menu
}
@Persist
- public void doSave(IProgressMonitor monitor) {
+ @Override
+ public void save(IProgressMonitor monitor) {
String taskName = Messages.DerivateView_SAVING_HIERARCHY;
monitor.beginTask(taskName, 3);
if (!conversation.isBound()) {
@Override
public void changed(Object element) {
setDirty(true);
-// firePropertyChange(IEditorPart.PROP_DIRTY);
+ //firePropertyChange(IEditorPart.PROP_DIRTY);
viewer.update(new TreeNode(element), null);
}
import org.eclipse.e4.ui.workbench.modeling.EModelService;
+import eu.etaxonomy.cdm.model.media.Media;
import eu.etaxonomy.cdm.model.molecular.DnaSample;
import eu.etaxonomy.cdm.model.occurrence.DerivationEventType;
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
public class AddMediaSpecimenHandler extends AbstractAddDerivativeHandler{
- @Inject
- private EModelService modelService;
+// @Inject
+// private EModelService modelService;
@Override
protected boolean isAllowed(Object derivative) {
*/
@Override
protected DerivedUnit createDerivative() {
- return MediaSpecimen.NewInstance(SpecimenOrObservationType.StillImage);
+ MediaSpecimen mediaSpecimen = MediaSpecimen.NewInstance(SpecimenOrObservationType.StillImage);
+ mediaSpecimen.setMediaSpecimen(Media.NewInstance());
+ return mediaSpecimen;
}
/**
import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.internal.E4PartWrapper;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor;
-import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
import eu.etaxonomy.taxeditor.editor.view.media.MediaViewPart;
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
import eu.etaxonomy.taxeditor.model.FeatureNodeContainerTree;
+import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
import eu.etaxonomy.taxeditor.view.supplementaldata.SupplementalDataViewPart;
+import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
/**
* @author n.hoffmann
private DescriptiveContentProvider provider;
+
/** {@inheritDoc} */
@Override
public void createViewer(Composite parent) {
/** {@inheritDoc} */
@Override
- protected void selectionChanged_internal(IWorkbenchPart part, ISelection selection) {
- if(AbstractUtility.getActiveE4Editor() == null){
- showEmptyPage();
- return;
- }
+ protected void selectionChanged_internal(IWorkbenchPart workbenchPart, ISelection selection) {
+// if(AbstractUtility.getActiveE4Editor() == null){
+// showEmptyPage();
+// return;
+// }
if(part == this){
return;
}
+
+ Object part = workbenchPart;
+ Object wrappedPart = WorkbenchUtility.getE4WrappedPart(part);
+ if(wrappedPart!=null){
+ part = wrappedPart;
+ }
+
if (part instanceof DetailsViewPart || part instanceof SupplementalDataViewPart
|| part instanceof MediaViewPart) {
// do not show empty page as these views are also used to edit the
return;
}
// unpackage TreeNode of DerivateView
- else if(part instanceof DerivateView){
+ else if(part instanceof E4PartWrapper && ((E4PartWrapper)part).getPartName().equals("%command.label.DERIVATIVE_EDITOR")){
TreeNode treeNodeOfSelection = EditorUtil.getTreeNodeOfSelection(selection);
if(treeNodeOfSelection!=null){
selection = new StructuredSelection(treeNodeOfSelection.getValue());
+ showViewer(part, (IStructuredSelection) selection);
+ return;
}
}
else if(part instanceof ChecklistEditor){
showEmptyPage();
}
}
-
+
@Override
protected String getViewName(){
return Messages.DescriptiveViewPart_FACTUAL_DATA;
((BulkEditor) part).forceDirty();
IStructuredSelection selection = (IStructuredSelection) ((BulkEditor) part).getSelectionProvider().getSelection();
((BulkEditor) part).changed(selection.getFirstElement());
-
+
}
+ if (part instanceof E4PartWrapper){
+ part = WorkbenchUtility.getE4WrappedPart(part);
+ if (part instanceof IDirtyMarkable){
+ StructuredSelection selection = new StructuredSelection(object);
+ ((IDirtyMarkable)part).changed(selection.getFirstElement());
+ }
+ }
+
super.changed(object);
}
provider.toggleShowOnlyIndividualAssociations();
viewer.refresh();
}
+
+
+
}
*/
package eu.etaxonomy.taxeditor.editor.view.descriptive.handler;
+import java.util.Collection;
+
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part : null;
IEditorPart editor = HandlerUtil.getActiveEditor(event);
+
if (editor instanceof FormEditor) {
editor = ((FormEditor) editor).getActiveEditor();
}
- IEditorInput input = editor.getEditorInput();
+ Object input;
+ if (editor == null && part instanceof DescriptiveViewPart){
+ input = ((DescriptiveViewPart)part).getViewer().getInput();
+ }else{
+ input = editor.getEditorInput();
+ }
AbstractPostOperation<?> operation;
// taxon description
import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.internal.E4PartWrapper;
import eu.etaxonomy.cdm.model.description.IDescribable;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
import eu.etaxonomy.taxeditor.view.supplementaldata.SupplementalDataViewPart;
+import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
/**
* @author n.hoffmann
/** {@inheritDoc} */
@Override
- protected void selectionChanged_internal(IWorkbenchPart part, ISelection selection) {
+ protected void selectionChanged_internal(IWorkbenchPart workbenchPart, ISelection selection) {
+ Object part = workbenchPart;
+
if(part==this){
return;
}
- if(AbstractUtility.getActiveE4Editor() == null){
- showEmptyPage();
- return;
- }
+
+ Object wrappedPart = WorkbenchUtility.getE4WrappedPart(part);
+ if(wrappedPart!=null){
+ part = wrappedPart;
+ }
+// if(AbstractUtility.getActiveE4Editor() == null){
+// showEmptyPage();
+// return;
+// }
+
if (part instanceof DetailsViewPart || part instanceof SupplementalDataViewPart
|| part instanceof DescriptiveViewPart) {
return;
}
- if(part instanceof IPartContentHasMedia && ((IPartContentHasMedia) part).canAttachMedia()){
+ if(part instanceof IPartContentHasMedia && ((IPartContentHasMedia) part).canAttachMedia() ){
if(selection instanceof IStructuredSelection){
Object firstElement = ((IStructuredSelection) selection).getFirstElement();
if(firstElement instanceof TreeNode){
}
}
}
+ if (selection instanceof IStructuredSelection){
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ if(structuredSelection.getFirstElement() instanceof TreeNode){
+ if (((TreeNode)structuredSelection.getFirstElement()).getValue() instanceof SpecimenOrObservationBase){
+ structuredSelection = new StructuredSelection(((TreeNode)structuredSelection.getFirstElement()).getValue());
+ showViewer(part, structuredSelection);
+ return;
+ }
+ }
+ }
+
showEmptyPage();
}
((BulkEditor) part).changed(selection.getFirstElement());
}
+ if (part instanceof E4PartWrapper){
+ part = WorkbenchUtility.getE4WrappedPart(part);
+ if (part instanceof IDirtyMarkable){
+ StructuredSelection selection = new StructuredSelection(object);
+ ((IDirtyMarkable)part).changed(selection.getFirstElement());
+ }
+ }
+
+
super.changed(object);
}
</wizard>
<wizard
category="eu.etaxonomy.taxeditor.export.category.cdm"
- class="eu.etaxonomy.taxeditor.io.wizard.OutputModelExportWizard"
+ class="eu.etaxonomy.taxeditor.io.wizard.CdmLightExportWizard"
id="eu.etaxonomy.taxeditor.io.export.output_model"
name="%wizard.name.22">
</wizard>
import eu.etaxonomy.cdm.model.description.FeatureNode;
import eu.etaxonomy.cdm.model.description.FeatureTree;
import eu.etaxonomy.taxeditor.featuretree.AvailableFeaturesWizard;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
import eu.etaxonomy.taxeditor.store.CdmStore;
composite.getButton_add().setEnabled(selection.size() <= 1);
composite.getButton_remove().setEnabled(selection.size() > 0);
//propagate selection
- IStructuredSelection isel = (IStructuredSelection) event.getSelection();
- selService.setSelection((isel.size() == 1 ? isel.getFirstElement() : isel.toArray()));
+ selService.setSelection(AbstractUtility.getElementsFromSelectionChangedEvent(event));
}
@Focus
import eu.etaxonomy.cdm.api.application.ICdmRepository;
import eu.etaxonomy.cdm.common.IoResultBase;
+import eu.etaxonomy.cdm.io.common.ExportResult;
import eu.etaxonomy.cdm.io.common.IIoConfigurator;
import eu.etaxonomy.cdm.io.common.ImportResult;
import eu.etaxonomy.taxeditor.store.CdmStore;
StringBuffer reportTextTemp = ioResult.createReport();
final StringBuffer reportText;
if (StringUtils.isBlank(reportTextTemp.toString()) && ioResult instanceof ImportResult){
- //reportTextTemp.append("No update result available");
+ reportTextTemp.append("The import was successfull.");
//TODO: this is a workaround because the abcd import writes the report in the report part...
ImportResult importResult = (ImportResult)ioResult;
if (!importResult.getReports().isEmpty() && importResult.getReports().get(0) != null){
}
}
reportText = reportTextTemp;
- if (StringUtils.isBlank(reportText.toString())){ return;}
+ if (StringUtils.isBlank(reportText.toString()) && ioResult instanceof ExportResult ){ reportText.append("The Export was succesfull.");}
display.asyncExec(new Runnable() {
@Override
package eu.etaxonomy.taxeditor.model;
-import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.resource.ColorRegistry;
import org.eclipse.jface.resource.FontRegistry;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
-import org.eclipse.ui.internal.E4PartWrapper;
import org.eclipse.ui.part.EditorPart;
import org.eclipse.ui.progress.IProgressConstants;
import org.eclipse.ui.progress.IProgressService;
import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer;
import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
import eu.etaxonomy.taxeditor.view.supplementaldata.SupplementalDataViewPart;
+import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
/**
*
IWorkbenchPage activePage = getActivePage();
if(activePage!=null){
IWorkbenchPart activePart = activePage.getActivePart();
- Object e4WrappedPart = getE4WrappedPart(activePart);
+ Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(activePart);
return e4WrappedPart!=null?e4WrappedPart:activePart;
}
return null;
}
- public static Object getE4WrappedPart(Object activePart){
- if(activePart instanceof E4PartWrapper){
- //FIXME can be removed when E4 migration is complete
- try {
- Field field = activePart.getClass().getDeclaredField("wrappedPart");
- field.setAccessible(true);
- Object object = field.get(activePart);
- if(object instanceof MPart){
- return ((MPart) object).getObject();
- }
- } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
- e.printStackTrace();
- }
- }
- return null;
- }
-
public static IWorkbench getWorkbench() {
return TaxeditorStorePlugin.getDefault().getWorkbench();
}
public static Object getActiveE4Editor() {
if(getActivePage()!=null){
IEditorPart activeEditor = getActivePage().getActiveEditor();
- Object wrappedPart = getE4WrappedPart(getActivePage().getActivePart());
+ Object wrappedPart = WorkbenchUtility.getE4WrappedPart(getActivePage().getActivePart());
return wrappedPart!=null?wrappedPart:activeEditor;
}
return null;
}
}
}
+
+ /**
+ * @param event
+ * @return
+ */
+ public static Object getElementsFromSelectionChangedEvent(SelectionChangedEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ Object selectionToSet;
+ if(selection.size() == 1){
+ selectionToSet = selection.getFirstElement();
+ }
+ else if(!selection.isEmpty()){
+ selectionToSet = selection.toArray();
+ }
+ else{
+ selectionToSet = selection;
+ }
+ return selectionToSet;
+ }
}
package eu.etaxonomy.taxeditor.view;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
import eu.etaxonomy.taxeditor.editor.ISecuredEditor;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
+import eu.etaxonomy.taxeditor.workbench.part.ISelectionElementEditingPart;
/**
* <p>
* @created Sep 21, 2010
* @version 1.0
*/
-public abstract class AbstractCdmEditorViewPart extends AbstractCdmViewPart {
+public abstract class AbstractCdmEditorViewPart extends AbstractCdmViewPart implements ISelectionElementEditingPart {
private DelaySelection delaySelection = null;
/**
*/
private boolean isInDelay;
+ protected Object selectionProvidingPart;
+
/**
* This class invokes internal_selectionChanged() in a separate thread.
}
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void showViewer(Object part, IStructuredSelection selection) {
+ super.showViewer(part, selection);
+ selectionProvidingPart = part;
+ }
+
+ @Override
+ public Object getSelectionProvidingPart() {
+ return selectionProvidingPart;
+ }
+
/** {@inheritDoc} */
return AbstractUtility.getActiveEditor();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void showEmptyPage() {
+ selectionProvidingPart = null;
+ super.showEmptyPage();
+ }
+
/** {@inheritDoc} */
@Override
public void setFocus() {
}
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void dispose() {
+ selectionProvidingPart = null;
+ super.dispose();
+ }
+
/** {@inheritDoc} */
@Override
public void changed(Object object) {
import org.eclipse.jface.viewers.TreeNode;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IWorkbenchPart;
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
+import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
/**
* <p>DetailsViewPart class.</p>
private DetailsViewer viewer;
- //FIXME E4: this can be removed when working with E4 event system
- private Object selectionProvidingPart;
-
/** {@inheritDoc} */
@Override
public void createViewer(Composite parent) {
@Override
protected void selectionChanged_internal(IWorkbenchPart workbenchPart, ISelection selection){
Object part = workbenchPart;
- Object wrappedPart = AbstractUtility.getE4WrappedPart(part);
+ Object wrappedPart = WorkbenchUtility.getE4WrappedPart(part);
if(wrappedPart!=null){
part = wrappedPart;
}
return;
}
}
- selectionProvidingPart = part;
showViewer(part, structuredSelection);
}else{
showEmptyPage();
@Override
public void showEmptyPage() {
- selectionProvidingPart = null;
viewer.setSelection(null);
super.showEmptyPage();
}
if (element instanceof Taxon){
Taxon taxon = HibernateProxyHelper.deproxy(element, Taxon.class);
if (taxon.isMisapplication()){
-
+
if (part instanceof ITaxonEditor){
Taxon accepted= ((ITaxonEditor)part).getTaxon();
- Set<TaxonRelationship> rels = taxon.getTaxonRelations(accepted);
-
+ Set<TaxonRelationship> rels = taxon.getTaxonRelations(accepted);
+
if (rels.iterator().hasNext()){
TaxonRelationship rel = rels.iterator().next();
if (rel.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
getViewer().setInput(rel);
- showViewer();
+ super.showViewer(part, selection);
return;
}
}
}
-
-
+
+
}
}
getViewer().setInput(element);
- showViewer();
+ super.showViewer(part, selection);
}
}
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
+import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
/**
@Override
protected void selectionChanged_internal(IWorkbenchPart workbenchPart, ISelection selection) {
Object part = workbenchPart;
- Object wrappedPart = AbstractUtility.getE4WrappedPart(part);
+ Object wrappedPart = WorkbenchUtility.getE4WrappedPart(part);
if(wrappedPart!=null){
part = wrappedPart;
}
org.eclipse.equinox.p2.metadata;bundle-version="2.3.100",
org.eclipse.equinox.p2.operations;bundle-version="2.4.200",
org.eclipse.e4.core.di,
- org.eclipse.e4.ui.services
+ org.eclipse.e4.ui.services,
+ org.eclipse.e4.core.commands
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: javax.inject;version="1.0.0"
Bundle-ActivationPolicy: lazy
+Export-Package: eu.etaxonomy.taxeditor.workbench,
+ eu.etaxonomy.taxeditor.workbench.part
<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:commands="http://www.eclipse.org/ui/2010/UIModel/application/commands" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmlns:ui="http://www.eclipse.org/ui/2010/UIModel/application/ui" xmi:id="_pdAMoB4DEeehWtOSgLepjA">
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_FaGnoCQNEeen_7LZsZSNoA" featurename="menuContributions" parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="menu:MenuContribution" xmi:id="_FaGnoSQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.workbench.menu" parentId="org.eclipse.ui.main.menu">
- <children xsi:type="menu:Menu" xmi:id="_FaGnoiQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.workbench.menu.file" label="%menu.label">
- <children xsi:type="menu:Menu" xmi:id="_FaGnoyQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.navigation.menu.new" label="%menu.label.3"/>
+ <children xsi:type="menu:Menu" xmi:id="_FaGnoiQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.workbench.menu.file" label="%menu.label" mnemonics="G">
+ <children xsi:type="menu:Menu" xmi:id="_FaGnoyQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.navigation.menu.new" label="%menu.label.3" mnemonics="N"/>
<children xsi:type="menu:MenuSeparator" xmi:id="_FaGnpCQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.application.menuseparator.0"/>
- <children xsi:type="menu:HandledMenuItem" xmi:id="_FaGnpSQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.application.handledmenuitem.close" label="%command.label">
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_FaGnpSQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.application.handledmenuitem.close" label="%command.label" mnemonics="C">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_FaGnpiQNEeen_7LZsZSNoA" coreExpressionId="isCdmStoreConnected"/>
<command href="../eu.etaxonomy.taxeditor.application/fragment.e4xmi#_LVTo8B62EeePLJ5to5QrXQ"/>
</children>
- <children xsi:type="menu:HandledMenuItem" xmi:id="_FaGnpyQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.application.handledmenuitem.closeAll" label="%command.label.0">
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_FaGnpyQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.application.handledmenuitem.closeAll" label="%command.label.0" mnemonics="">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_FaGnqCQNEeen_7LZsZSNoA" coreExpressionId="isCdmStoreConnected"/>
<command href="../eu.etaxonomy.taxeditor.application/fragment.e4xmi#_MrLPsB62EeePLJ5to5QrXQ"/>
</children>
<children xsi:type="menu:MenuSeparator" xmi:id="_FaGnqSQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.application.menuseparator.3"/>
- <children xsi:type="menu:HandledMenuItem" xmi:id="_FaGnryQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.application.handledmenuitem.save" label="%command.label.1">
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_FaGnryQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.application.handledmenuitem.save" label="%command.label.1" mnemonics="S">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_FaGnsCQNEeen_7LZsZSNoA" coreExpressionId="isCdmStoreConnected"/>
<command href="../eu.etaxonomy.taxeditor.application/fragment.e4xmi#_PkWcQB62EeePLJ5to5QrXQ"/>
</children>
<command href="../eu.etaxonomy.taxeditor.application/fragment.e4xmi#_RWLmQB62EeePLJ5to5QrXQ"/>
</children>
<children xsi:type="menu:MenuSeparator" xmi:id="_FaGnriQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.application.menuseparator.1"/>
- <children xsi:type="menu:HandledMenuItem" xmi:id="_FaGnqiQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.application.handledmenuitem.import" label="%command.label.3">
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_FaGnqiQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.application.handledmenuitem.import" label="%command.label.3" mnemonics="I">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_FaGnqyQNEeen_7LZsZSNoA" coreExpressionId="isCdmStoreConnected"/>
<command href="../eu.etaxonomy.taxeditor.application/fragment.e4xmi#_dlo3oB60EeePLJ5to5QrXQ"/>
</children>
- <children xsi:type="menu:HandledMenuItem" xmi:id="_FaGnrCQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.application.handledmenuitem.export" label="%command.label.4">
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_FaGnrCQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.application.handledmenuitem.export" label="%command.label.4" mnemonics="E">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_FaGnrSQNEeen_7LZsZSNoA" coreExpressionId="isCdmStoreConnected"/>
<command href="../eu.etaxonomy.taxeditor.application/fragment.e4xmi#_CYHrgB62EeePLJ5to5QrXQ"/>
</children>
<children xsi:type="menu:MenuSeparator" xmi:id="_FaGnsyQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.application.filemenu.io"/>
- <children xsi:type="menu:HandledMenuItem" xmi:id="_FaGntCQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.application.handledmenuitem.exit" label="%command.label.5">
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_FaGntCQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.application.handledmenuitem.exit" label="%command.label.5" mnemonics="x">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_FaGntSQNEeen_7LZsZSNoA" coreExpressionId="isCdmStoreConnected"/>
<command href="../eu.etaxonomy.taxeditor.application/fragment.e4xmi#_TvLd8B62EeePLJ5to5QrXQ"/>
</children>
</children>
- <children xsi:type="menu:Menu" xmi:id="_FaGntiQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.workbench.menu.edit" label="%menu.label.0">
+ <children xsi:type="menu:Menu" xmi:id="_FaGntiQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.workbench.menu.edit" label="%menu.label.0" mnemonics="E">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_O7JxAFJ5EeeL4Lhic-6yjw" coreExpressionId="isCdmStoreConnected"/>
- <children xsi:type="menu:HandledMenuItem" xmi:id="_19-hwFJ4EeeL4Lhic-6yjw" elementId="eu.etaxonomy.taxeditor.workbench.handledmenuitem.commandlabel8" label="%command.label.8" command="_PhIAwB7EEeeRW_RHu3JLqQ"/>
- <children xsi:type="menu:HandledMenuItem" xmi:id="_7V-hMFJ4EeeL4Lhic-6yjw" elementId="eu.etaxonomy.taxeditor.workbench.handledmenuitem.commandlabel9" label="%command.label.9" command="_RxxNsB7EEeeRW_RHu3JLqQ"/>
- <children xsi:type="menu:HandledMenuItem" xmi:id="_9PVPgFJ4EeeL4Lhic-6yjw" elementId="eu.etaxonomy.taxeditor.workbench.handledmenuitem.commandlabel10" label="%command.label.10" command="_TmIHQB7EEeeRW_RHu3JLqQ"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_19-hwFJ4EeeL4Lhic-6yjw" elementId="eu.etaxonomy.taxeditor.workbench.handledmenuitem.commandlabel8" label="%command.label.8" mnemonics="u" command="_PhIAwB7EEeeRW_RHu3JLqQ"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_7V-hMFJ4EeeL4Lhic-6yjw" elementId="eu.etaxonomy.taxeditor.workbench.handledmenuitem.commandlabel9" label="%command.label.9" mnemonics="o" command="_RxxNsB7EEeeRW_RHu3JLqQ"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_9PVPgFJ4EeeL4Lhic-6yjw" elementId="eu.etaxonomy.taxeditor.workbench.handledmenuitem.commandlabel10" label="%command.label.10" mnemonics="P" command="_TmIHQB7EEeeRW_RHu3JLqQ"/>
<children xsi:type="menu:MenuSeparator" xmi:id="__NwEAFJ4EeeL4Lhic-6yjw" elementId="eu.etaxonomy.taxeditor.workbench.menuseparator.3"/>
- <children xsi:type="menu:HandledMenuItem" xmi:id="__2Uf4FJ4EeeL4Lhic-6yjw" elementId="eu.etaxonomy.taxeditor.workbench.handledmenuitem.commandlabel11" label="%command.label.11" command="_WOTDYB7EEeeRW_RHu3JLqQ"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="__2Uf4FJ4EeeL4Lhic-6yjw" elementId="eu.etaxonomy.taxeditor.workbench.handledmenuitem.commandlabel11" label="%command.label.11" mnemonics="D" command="_WOTDYB7EEeeRW_RHu3JLqQ"/>
</children>
- <children xsi:type="menu:Menu" xmi:id="_FaGntyQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.workbench.menu.window" label="%menu.label.1">
- <children xsi:type="menu:Menu" xmi:id="_DH_m0CkKEeeCvszP-_feIA" elementId="eu.etaxonomy.taxeditor.menu.showView" label="Show View"/>
+ <children xsi:type="menu:Menu" xmi:id="_FaGntyQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.workbench.menu.window" label="%menu.label.1" mnemonics="W">
+ <children xsi:type="menu:Menu" xmi:id="_DH_m0CkKEeeCvszP-_feIA" elementId="eu.etaxonomy.taxeditor.menu.showView" label="Show View" mnemonics="V"/>
<children xsi:type="menu:MenuSeparator" xmi:id="_FaGnuCQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.application.windowMenu.last"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_FaGnuSQNEeen_7LZsZSNoA" elementId="org.eclipse.ui.main.menu.window.preferences" label="%command.label.12">
<command href="../eu.etaxonomy.taxeditor.application/fragment.e4xmi#_l9kXoB7PEeeC-JvycL9ysA"/>
</children>
</children>
- <children xsi:type="menu:Menu" xmi:id="_FaGnuiQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.workbench.menu.admin" label="%menu.label.4">
+ <children xsi:type="menu:Menu" xmi:id="_FaGnuiQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.workbench.menu.admin" label="%menu.label.4" mnemonics="A">
<children xsi:type="menu:HandledMenuItem" xmi:id="_b4RFsCQsEeeq76l4saMAFQ" elementId="eu.etaxonomy.taxeditor.workbench.menu.admin.dbpreferences" label="%command.label.23" command="_VawPsCQsEeeq76l4saMAFQ">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_b4RFsSQsEeeq76l4saMAFQ" coreExpressionId="hasROLE_PROJECT_MANAGER_AND_isCdmStoreConnected"/>
</children>
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_cWhvASQsEeeq76l4saMAFQ" coreExpressionId="hasROLE_PROJECT_MANAGER_AND_isCdmStoreConnected"/>
</children>
</children>
- <children xsi:type="menu:Menu" xmi:id="_FaGnvyQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.workbench.menu.help" label="%menu.label.2">
- <children xsi:type="menu:HandledMenuItem" xmi:id="_3cDNACQ7EeeKsvEah5BAoQ" elementId="eu.etaxonomy.taxeditor.workbench.menu.help.help_contents" label="%command.label.13" command="_xOYw4CQ7EeeKsvEah5BAoQ"/>
- <children xsi:type="menu:HandledMenuItem" xmi:id="_HqntYCQ8EeeKsvEah5BAoQ" elementId="eu.etaxonomy.taxeditor.workbench.menu.help.search" label="%command.label.14" command="_-t3NwCQ7EeeKsvEah5BAoQ"/>
+ <children xsi:type="menu:Menu" xmi:id="_FaGnvyQNEeen_7LZsZSNoA" elementId="eu.etaxonomy.taxeditor.workbench.menu.help" label="%menu.label.2" mnemonics="H">
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_3cDNACQ7EeeKsvEah5BAoQ" elementId="eu.etaxonomy.taxeditor.workbench.menu.help.help_contents" label="%command.label.13" mnemonics="H" command="_xOYw4CQ7EeeKsvEah5BAoQ"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_HqntYCQ8EeeKsvEah5BAoQ" elementId="eu.etaxonomy.taxeditor.workbench.menu.help.search" label="%command.label.14" mnemonics="S" command="_-t3NwCQ7EeeKsvEah5BAoQ"/>
<children xsi:type="menu:MenuSeparator" xmi:id="_7NbM4CQ7EeeKsvEah5BAoQ" elementId="eu.etaxonomy.taxeditor.workbench.menuseparator.0"/>
- <children xsi:type="menu:HandledMenuItem" xmi:id="_Wg-doCQ8EeeKsvEah5BAoQ" elementId="eu.etaxonomy.taxeditor.workbench.menu.help.dynamic" label="%command.label.15" command="_UIXAcCQ8EeeKsvEah5BAoQ"/>
- <children xsi:type="menu:HandledMenuItem" xmi:id="_dTyBcCQsEeeq76l4saMAFQ" elementId="eu.etaxonomy.taxeditor.workbench.menu.help.parser" label="%command.label.16" command="_UZ_WQCQsEeeq76l4saMAFQ"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_Wg-doCQ8EeeKsvEah5BAoQ" elementId="eu.etaxonomy.taxeditor.workbench.menu.help.dynamic" label="%command.label.15" mnemonics="D" command="_UIXAcCQ8EeeKsvEah5BAoQ"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_dTyBcCQsEeeq76l4saMAFQ" elementId="eu.etaxonomy.taxeditor.workbench.menu.help.parser" label="%command.label.16" mnemonics="P" command="_UZ_WQCQsEeeq76l4saMAFQ"/>
<children xsi:type="menu:MenuSeparator" xmi:id="_QZlooCQ8EeeKsvEah5BAoQ" elementId="eu.etaxonomy.taxeditor.workbench.menuseparator.1"/>
- <children xsi:type="menu:HandledMenuItem" xmi:id="_JCjXYCRBEeeKsvEah5BAoQ" elementId="eu.etaxonomy.taxeditor.workbench.handledmenuitem.commandlabel17" label="%command.label.17" command="_rSmScCQ8EeeKsvEah5BAoQ"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_JCjXYCRBEeeKsvEah5BAoQ" elementId="eu.etaxonomy.taxeditor.workbench.handledmenuitem.commandlabel17" label="%command.label.17" mnemonics="C" command="_rSmScCQ8EeeKsvEah5BAoQ"/>
<children xsi:type="menu:MenuSeparator" xmi:id="_moFrICQ8EeeKsvEah5BAoQ" elementId="eu.etaxonomy.taxeditor.workbench.menuseparator.2"/>
- <children xsi:type="menu:HandledMenuItem" xmi:id="_MtO5YCRBEeeKsvEah5BAoQ" elementId="eu.etaxonomy.taxeditor.workbench.handledmenuitem.commandlabel19" label="%command.label.19" command="_tmIbUCQ8EeeKsvEah5BAoQ"/>
- <children xsi:type="menu:HandledMenuItem" xmi:id="_d0m2kCQsEeeq76l4saMAFQ" elementId="eu.etaxonomy.taxeditor.workbench.menu.help.about_edit" label="%command.label.20" command="_UZ2zYCQsEeeq76l4saMAFQ"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_MtO5YCRBEeeKsvEah5BAoQ" elementId="eu.etaxonomy.taxeditor.workbench.handledmenuitem.commandlabel19" label="%command.label.19" mnemonics="T" command="_tmIbUCQ8EeeKsvEah5BAoQ"/>
+ <children xsi:type="menu:HandledMenuItem" xmi:id="_d0m2kCQsEeeq76l4saMAFQ" elementId="eu.etaxonomy.taxeditor.workbench.menu.help.about_edit" label="%command.label.20" mnemonics="E" command="_UZ2zYCQsEeeq76l4saMAFQ"/>
</children>
</elements>
</fragments>
<elements xsi:type="menu:TrimContribution" xmi:id="_FIbzwB92EeeIA_2gwq7JKg" elementId="eu.etaxonomy.taxeditor.workbench.trimcontribution.mainToolbar" parentId="org.eclipse.ui.main.toolbar" positionInParent="after=additions">
<children xsi:type="menu:ToolBar" xmi:id="_KDVngB92EeeIA_2gwq7JKg" elementId="eu.etaxonomy.taxeditor.workbench.menu.toolbar.0">
<children xsi:type="menu:HandledToolItem" xmi:id="_KvxPsB92EeeIA_2gwq7JKg" elementId="eu.etaxonomy.taxeditor.workbench.menu.toolbar.new" label="%command.label.21" iconURI="platform:/plugin/org.eclipse.ui/icons/full/etool16/new_wiz.png" command="_hooiQB7QEeeC-JvycL9ysA"/>
- <children xsi:type="menu:HandledToolItem" xmi:id="_ARn5AB96EeeIA_2gwq7JKg" elementId="eu.etaxonomy.taxeditor.workbench.menu.toolbar.save" label="%command.label.22" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/save_edit.gif" command="_PkWcQB62EeePLJ5to5QrXQ"/>
+ <children xsi:type="menu:HandledToolItem" xmi:id="_hnQUcFp0Eee4PsIXei-TMg" elementId="eu.etaxonomy.taxeditor.workbench.menu.toolbar.save" label="%command.label.22" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/save_edit.gif" command="_X-56IFp0Eee4PsIXei-TMg"/>
</children>
</elements>
</fragments>
<elements xsi:type="commands:Command" xmi:id="_CYHrgB62EeePLJ5to5QrXQ" elementId="org.eclipse.ui.file.export" commandName="%command.label.4"/>
<elements xsi:type="commands:Command" xmi:id="_LVTo8B62EeePLJ5to5QrXQ" elementId="org.eclipse.ui.file.close" commandName="%command.label"/>
<elements xsi:type="commands:Command" xmi:id="_MrLPsB62EeePLJ5to5QrXQ" elementId="org.eclipse.ui.file.closeAll" commandName="%command.label.0"/>
- <elements xsi:type="commands:Command" xmi:id="_PkWcQB62EeePLJ5to5QrXQ" elementId="org.eclipse.ui.file.save" commandName="%command.label.1"/>
+ <elements xsi:type="commands:Command" xmi:id="_X-56IFp0Eee4PsIXei-TMg" elementId="eu.etaxonomy.taxeditor.workbench.save" commandName="%command.label.1"/>
<elements xsi:type="commands:Command" xmi:id="_RWLmQB62EeePLJ5to5QrXQ" elementId="org.eclipse.ui.file.saveAll" commandName="%command.label.2"/>
<elements xsi:type="commands:Command" xmi:id="_TvLd8B62EeePLJ5to5QrXQ" elementId="org.eclipse.ui.file.exit" commandName="%command.label.5"/>
<elements xsi:type="commands:Command" xmi:id="_5pfmIB7DEeeRW_RHu3JLqQ" elementId="org.eclipse.ui.edit.undo" commandName="%command.label.6"/>
<elements xsi:type="commands:Handler" xmi:id="_uzAhUCRAEeeKsvEah5BAoQ" elementId="eu.etaxonomy.taxeditor.update.UpdateHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.update.UpdateHandler" command="_rSmScCQ8EeeKsvEah5BAoQ"/>
<elements xsi:type="commands:Handler" xmi:id="_nSIiECUKEeeHw5lTgGMs1Q" elementId="eu.etaxonomy.taxeditor.handler.OpenImportPreferenceHandler" command="_fdEqUCUKEeeHw5lTgGMs1Q"/>
<elements xsi:type="commands:Handler" xmi:id="_2fnUYCZ0EeeQLpuomSmVoQ" elementId="eu.etaxonomy.taxeditor.workbench.OpenPartHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.OpenPartHandler" command="_hMjgECZsEeer_rabtodzWA"/>
+ <elements xsi:type="commands:Handler" xmi:id="_dBGosFp0Eee4PsIXei-TMg" elementId="eu.etaxonomy.taxeditor.workbench.SaveHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.SaveHandler" command="_X-56IFp0Eee4PsIXei-TMg"/>
+ </fragments>
+ <fragments xsi:type="fragment:StringModelFragment" xmi:id="_Z4f0kFsaEeebk7BsM35KOg" featurename="children" parentElementId="org.eclipse.ui.contexts.dialogAndWindow">
+ <elements xsi:type="commands:BindingContext" xmi:id="_5pEDMFsaEeebk7BsM35KOg" elementId="eu.etaxonomy.taxeditor.workbench.bindingcontext" name="Taxonomic Editor Keybinding Context"/>
+ </fragments>
+ <fragments xsi:type="fragment:StringModelFragment" xmi:id="_9BSjQFsaEeebk7BsM35KOg" featurename="bindingTables" parentElementId="org.eclipse.e4.legacy.ide.application">
+ <elements xsi:type="commands:BindingTable" xmi:id="_-q2iEFsaEeebk7BsM35KOg" elementId="eu.etaxonomy.taxeditor.workbench.bindingtable" bindingContext="_5pEDMFsaEeebk7BsM35KOg">
+ <bindings xmi:id="__6bTkFsaEeebk7BsM35KOg" elementId="eu.etaxonomy.taxeditor.workbench.keybinding.save" keySequence="M1+S" command="_X-56IFp0Eee4PsIXei-TMg"/>
+ </elements>
</fragments>
</fragment:ModelFragments>
apply="always"
uri="fragment.e4xmi">
</fragment>
+ <processor
+ apply="always"
+ beforefragment="false"
+ class="eu.etaxonomy.taxeditor.workbench.WorkbenchProcessor">
+ <element
+ id="org.eclipse.ui.contexts.window">
+ </element>
+ <element
+ id="eu.etaxonomy.taxeditor.workbench.keybinding.save">
+ </element>
+ </processor>
</extension>
</plugin>
package eu.etaxonomy.taxeditor.workbench;
+import java.util.Collections;
+
import javax.inject.Named;
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ParameterizedCommand;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.e4.core.commands.ECommandService;
+import org.eclipse.e4.core.commands.EHandlerService;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
+import org.eclipse.ui.ISaveablePart;
+import org.eclipse.ui.internal.e4.compatibility.CompatibilityPart;
+
+import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
+import eu.etaxonomy.taxeditor.workbench.part.ISelectionElementEditingPart;
public class SaveHandler {
@Execute
- public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, EPartService partService) {
- partService.savePart(activePart, false);
+ public void execute(EPartService partService, ECommandService commandService, EHandlerService handlerService
+ , @Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
+ if(activePart.isDirty()){
+ savePart(partService, commandService, handlerService, activePart);
+ } else {
+ Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(activePart.getObject());
+ if(e4WrappedPart instanceof ISelectionElementEditingPart){
+ ISelectionElementEditingPart editingPart = (ISelectionElementEditingPart)e4WrappedPart;
+ Object savablePart = findSavablePart(editingPart);
+ if(savablePart instanceof ISaveablePart){
+ ((ISaveablePart) savablePart).doSave(new NullProgressMonitor());
+ }
+ else if(savablePart instanceof IE4SavablePart){
+ ((IE4SavablePart) savablePart).save(new NullProgressMonitor());
+ }
+ }
+ }
+ }
+
+ private Object findSavablePart(ISelectionElementEditingPart part){
+ Object selectionProvidingPart = part.getSelectionProvidingPart();
+ if(selectionProvidingPart instanceof ISaveablePart || selectionProvidingPart instanceof IE4SavablePart){
+ return selectionProvidingPart;
+ }
+ else if(selectionProvidingPart instanceof ISelectionElementEditingPart){
+ return findSavablePart((ISelectionElementEditingPart) selectionProvidingPart);
+ }
+ return null;
}
+ private void savePart(EPartService partService, ECommandService commandService, EHandlerService handlerService,
+ MPart mPart) {
+ if(mPart.getObject() instanceof CompatibilityPart){
+ //FIXME E4 remove when fully migrated
+ Command command = commandService.getCommand("org.eclipse.ui.file.save");
+ ParameterizedCommand parameterizedCommand = ParameterizedCommand.generateCommand(command, Collections.EMPTY_MAP);
+ handlerService.executeHandler(parameterizedCommand);
+ }
+ else{
+ partService.savePart(mPart, false);
+ }
+ }
+
+
@CanExecute
- public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
- return activePart.isDirty();
+ public boolean canExecute(EPartService partService) {
+ return !partService.getDirtyParts().isEmpty();
}
}
\ No newline at end of file
--- /dev/null
+package eu.etaxonomy.taxeditor.workbench;
+
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.model.application.commands.MBindingTable;
+import org.eclipse.e4.ui.model.application.commands.MKeyBinding;
+
+public class WorkbenchProcessor {
+
+ @Inject
+ @Named("org.eclipse.ui.contexts.window")
+ private MBindingTable bindingTable;
+
+ @Inject
+ @Named("eu.etaxonomy.taxeditor.workbench.keybinding.save")
+ private MKeyBinding saveBinding;
+
+
+ @Execute
+ public void execute() {
+ //swap legacy CTRL+S with the one defined in our model fragment
+ //to allow using our SaveHandler for all save actions
+ List<MKeyBinding> bindings = bindingTable.getBindings();
+ MKeyBinding legacySaveBinding = null;
+ for (MKeyBinding mKeyBinding : bindings) {
+ String keySequence = mKeyBinding.getKeySequence();
+ if(keySequence.equals("CTRL+S")){
+ legacySaveBinding = mKeyBinding;
+ break;
+ }
+ }
+ if(legacySaveBinding!=null){
+ bindings.remove(legacySaveBinding);
+ }
+ bindings.add(saveBinding);
+ }
+}
--- /dev/null
+/**
+* Copyright (C) 2017 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.workbench;
+
+import java.lang.reflect.Field;
+
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.ui.internal.E4PartWrapper;
+import org.eclipse.ui.internal.e4.compatibility.CompatibilityView;
+
+/**
+ * Utility class for e4 workbench related operations
+ * @author pplitzner
+ * @since Jun 27, 2017
+ *
+ */
+public class WorkbenchUtility {
+
+ /**
+ * Checks if the activePart is an E4 wrapper for a legacy part and returns
+ * that part
+ *
+ * @param activePart the e4 wrapper
+ * @return the wrapped legacy part or <code>null</code>
+ */
+ public static Object getE4WrappedPart(Object activePart){
+ //FIXME can be removed when E4 migration is complete
+
+ Object object = null;
+ try {
+ if(activePart instanceof E4PartWrapper){
+ Field field = activePart.getClass().getDeclaredField("wrappedPart");
+ field.setAccessible(true);
+ object = field.get(activePart);
+ }
+ else if(activePart instanceof CompatibilityView){
+ Field field = activePart.getClass().getSuperclass().getDeclaredField("wrapped");
+ field.setAccessible(true);
+ object = field.get(activePart);
+ }
+ } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ if(object instanceof MPart){
+ object =((MPart) object).getObject();
+ }
+ return object;
+ }
+}
--- /dev/null
+/**
+* Copyright (C) 2017 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.workbench.part;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * This interface is used to be able to save a part when it is providing
+ * an element which is edited in another part.
+ *
+ * <br>
+ * This interface is used as a temporary workaround during e4 migration
+ * for simulating the IEditorPart behavior of editors VS views
+ *
+ * @see ISelectionElementEditingPart
+ * @author pplitzner
+ * @since Jun 28, 2017
+ *
+ */
+public interface IE4SavablePart {
+ //FIXME E4
+
+ /**
+ * Save this part
+ * @param monitor the progress monitor for long running save actions
+ */
+ public void save(IProgressMonitor monitor);
+}
--- /dev/null
+/**
+* Copyright (C) 2017 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.workbench.part;
+
+/**
+ * Classes implementing this interface should be parts that edit elements
+ * coming from other parts via a selection change
+ * <br>
+ * This interface is used as a temporary workaround during e4 migration
+ * for simulating the IEditorPart behavior of editors VS views
+ *
+ *@see IE4SavablePart
+ * @author pplitzner
+ * @since Jun 27, 2017
+ *
+ */
+@Deprecated
+//FIXME E4 migration
+public interface ISelectionElementEditingPart {
+
+ /**
+ * Returns the part that has provided the last selection
+ * @return the selection providing part
+ */
+ public Object getSelectionProvidingPart();
+
+}