diff options
author | Johannes Faltermeier | 2017-05-05 08:08:20 +0000 |
---|---|---|
committer | Johannes Faltermeier | 2017-05-05 08:08:20 +0000 |
commit | 8d58c35f1c8b020acc880112ef5368ace89337fc (patch) | |
tree | bf8cb152371a70ddab62b4448590be72e79bb6f2 | |
parent | 492159b81a25ee83fe133b3dbfc3b0172f38b076 (diff) | |
parent | 7d52da857cd304126d786bcda58dd0ed196db236 (diff) | |
download | org.eclipse.emf.edapt-8d58c35f1c8b020acc880112ef5368ace89337fc.tar.gz org.eclipse.emf.edapt-8d58c35f1c8b020acc880112ef5368ace89337fc.tar.xz org.eclipse.emf.edapt-8d58c35f1c8b020acc880112ef5368ace89337fc.zip |
Merge branch 'develop' into 12x
29 files changed, 154 insertions, 84 deletions
diff --git a/plugins/org.eclipse.emf.edapt.common.ui/src/org/eclipse/emf/edapt/common/ui/HandlerUtils.java b/plugins/org.eclipse.emf.edapt.common.ui/src/org/eclipse/emf/edapt/common/ui/HandlerUtils.java index 1ead24d..044852e 100644 --- a/plugins/org.eclipse.emf.edapt.common.ui/src/org/eclipse/emf/edapt/common/ui/HandlerUtils.java +++ b/plugins/org.eclipse.emf.edapt.common.ui/src/org/eclipse/emf/edapt/common/ui/HandlerUtils.java @@ -39,15 +39,15 @@ public final class HandlerUtils { } /** Get the selected element of type V. */ - public static <V> V getSelectedElement(ExecutionEvent event) { + public static <V> V getSelectedElement(ExecutionEvent event, Class<V> type) { final ISelection selection = HandlerUtil.getCurrentSelection(event); - return SelectionUtils.getSelectedElement(selection); + return SelectionUtils.getSelectedElement(selection, type); } /** Get a list of selected elements of type V. */ - public static <V> List<V> getSelectedElements(ExecutionEvent event) { + public static <V> List<V> getSelectedElements(ExecutionEvent event, Class<V> type) { final ISelection selection = HandlerUtil.getCurrentSelection(event); - return SelectionUtils.getSelectedElements(selection); + return SelectionUtils.getSelectedElements(selection, type); } /** Get the active page from within a handler. */ diff --git a/plugins/org.eclipse.emf.edapt.common.ui/src/org/eclipse/emf/edapt/common/ui/MultiValueSelectionDialog.java b/plugins/org.eclipse.emf.edapt.common.ui/src/org/eclipse/emf/edapt/common/ui/MultiValueSelectionDialog.java index 15279fc..b6bee1c 100644 --- a/plugins/org.eclipse.emf.edapt.common.ui/src/org/eclipse/emf/edapt/common/ui/MultiValueSelectionDialog.java +++ b/plugins/org.eclipse.emf.edapt.common.ui/src/org/eclipse/emf/edapt/common/ui/MultiValueSelectionDialog.java @@ -238,7 +238,7 @@ public class MultiValueSelectionDialog extends SelectionStatusDialog { @SuppressWarnings("unchecked") protected void downSelectedValues() { final List<Object> selectedValues = SelectionUtils - .getSelectedElements(valuesViewer.getSelection()); + .getSelectedElements(valuesViewer.getSelection(), Object.class); sortSelectedValues(selectedValues); Collections.reverse(selectedValues); for (final Object element : selectedValues) { @@ -258,7 +258,7 @@ public class MultiValueSelectionDialog extends SelectionStatusDialog { @SuppressWarnings("unchecked") protected void upSelectedValues() { final List<Object> selectedValues = SelectionUtils - .getSelectedElements(valuesViewer.getSelection()); + .getSelectedElements(valuesViewer.getSelection(), Object.class); sortSelectedValues(selectedValues); for (final Object element : selectedValues) { final int index = values.indexOf(element); @@ -290,7 +290,7 @@ public class MultiValueSelectionDialog extends SelectionStatusDialog { @SuppressWarnings("unchecked") protected void removeSelectedValues() { final List<Object> selectedValues = SelectionUtils - .getSelectedElements(valuesViewer.getSelection()); + .getSelectedElements(valuesViewer.getSelection(), Object.class); values.removeAll(selectedValues); valuesViewer.refresh(); } diff --git a/plugins/org.eclipse.emf.edapt.common.ui/src/org/eclipse/emf/edapt/common/ui/SelectionUtils.java b/plugins/org.eclipse.emf.edapt.common.ui/src/org/eclipse/emf/edapt/common/ui/SelectionUtils.java index a9a03e5..81a3bb6 100644 --- a/plugins/org.eclipse.emf.edapt.common.ui/src/org/eclipse/emf/edapt/common/ui/SelectionUtils.java +++ b/plugins/org.eclipse.emf.edapt.common.ui/src/org/eclipse/emf/edapt/common/ui/SelectionUtils.java @@ -8,6 +8,7 @@ * Contributors: * BMW Car IT - Initial API and implementation * Technische Universitaet Muenchen - Major refactoring and extension + * Johannes Faltermeier - Add explicit type parameters *******************************************************************************/ package org.eclipse.emf.edapt.common.ui; @@ -38,16 +39,15 @@ public final class SelectionUtils { /** * Get the selected element of type V. */ - @SuppressWarnings("unchecked") - public static <V> V getSelectedElement(ISelection selection) { + public static <V> V getSelectedElement(ISelection selection, Class<V> type) { if (selection != null && selection instanceof IStructuredSelection) { final IStructuredSelection structuredSelection = (IStructuredSelection) selection; if (!structuredSelection.isEmpty()) { - try { - return (V) structuredSelection.getFirstElement(); - } catch (final ClassCastException e) { + final Object firstElement = structuredSelection.getFirstElement(); + if (!type.isInstance(firstElement)) { return null; } + return type.cast(firstElement); } } return null; @@ -56,17 +56,16 @@ public final class SelectionUtils { /** * Get a list of selected elements of type V. */ - @SuppressWarnings("unchecked") - public static <V> List<V> getSelectedElements(ISelection selection) { + public static <V> List<V> getSelectedElements(ISelection selection, Class<V> type) { final List<V> elements = new ArrayList<V>(); if (selection != null && selection instanceof IStructuredSelection) { final IStructuredSelection structuredSelection = (IStructuredSelection) selection; for (final Iterator i = structuredSelection.iterator(); i.hasNext();) { - try { - elements.add((V) i.next()); - } catch (final ClassCastException e) { - // ignore + final Object next = i.next(); + if (!type.isInstance(next)) { + continue; } + elements.add(type.cast(next)); } } return elements; diff --git a/plugins/org.eclipse.emf.edapt.common.ui/src/org/eclipse/emf/edapt/common/ui/ValueSelectionComposite.java b/plugins/org.eclipse.emf.edapt.common.ui/src/org/eclipse/emf/edapt/common/ui/ValueSelectionComposite.java index 0ffcc90..65ebdc8 100644 --- a/plugins/org.eclipse.emf.edapt.common.ui/src/org/eclipse/emf/edapt/common/ui/ValueSelectionComposite.java +++ b/plugins/org.eclipse.emf.edapt.common.ui/src/org/eclipse/emf/edapt/common/ui/ValueSelectionComposite.java @@ -334,7 +334,7 @@ public class ValueSelectionComposite extends Composite { */ public List<Object> getSelectedElements() { return SelectionUtils - .getSelectedElements(filteredViewer.getSelection()); + .getSelectedElements(filteredViewer.getSelection(), Object.class); } /** diff --git a/plugins/org.eclipse.emf.edapt.history.edit/src/org/eclipse/emf/edapt/history/recorder/EditingDomainListener.java b/plugins/org.eclipse.emf.edapt.history.edit/src/org/eclipse/emf/edapt/history/recorder/EditingDomainListener.java index cee0971..efeec28 100644 --- a/plugins/org.eclipse.emf.edapt.history.edit/src/org/eclipse/emf/edapt/history/recorder/EditingDomainListener.java +++ b/plugins/org.eclipse.emf.edapt.history.edit/src/org/eclipse/emf/edapt/history/recorder/EditingDomainListener.java @@ -135,6 +135,12 @@ public class EditingDomainListener { try { historyResource.load(null); EcoreUtil.resolveAll(historyResource); + if (historyResource.getContents().isEmpty()) { + return false; + } + if (!History.class.isInstance(historyResource.getContents().get(0))) { + return false; + } return true; } catch (final IOException e) { resourceSet.getResources().remove(historyResource); diff --git a/plugins/org.eclipse.emf.edapt.history.editor/plugin.xml b/plugins/org.eclipse.emf.edapt.history.editor/plugin.xml index 003845d..27edf96 100644 --- a/plugins/org.eclipse.emf.edapt.history.editor/plugin.xml +++ b/plugins/org.eclipse.emf.edapt.history.editor/plugin.xml @@ -331,18 +331,26 @@ style="push"> <visibleWhen checkEnabled="false"> - <with - variable="selection"> - <count - value="1"> - </count> - <iterate - ifEmpty="false"> + <and> + <with + variable="selection"> + <count + value="1"> + </count> + <iterate + ifEmpty="false"> + <instanceof + value="org.eclipse.emf.ecore.resource.Resource"> + </instanceof> + </iterate> + </with> + <with + variable="activeEditor"> <instanceof - value="org.eclipse.emf.ecore.resource.Resource"> + value="org.eclipse.emf.ecore.presentation.EcoreEditor"> </instanceof> - </iterate> - </with> + </with> + </and> </visibleWhen> </command> </menu> @@ -531,22 +539,30 @@ style="push"> <visibleWhen checkEnabled="false"> - <with - variable="selection"> - <count - value="+"> - </count> - <iterate - ifEmpty="false"> + <and> + <with + variable="selection"> + <count + value="+"> + </count> + <iterate + ifEmpty="false"> + <instanceof + value="org.eclipse.emf.edapt.spi.history.Change"> + </instanceof> + </iterate> + <test + forcePluginActivation="true" + property="org.eclipse.emf.edapt.history.editor.subsequentChanges"> + </test> + </with> + <with + variable="activeEditor"> <instanceof - value="org.eclipse.emf.edapt.spi.history.Change"> + value="org.eclipse.emf.ecore.presentation.EcoreEditor"> </instanceof> - </iterate> - <test - forcePluginActivation="true" - property="org.eclipse.emf.edapt.history.editor.subsequentChanges"> - </test> - </with> + </with> + </and> </visibleWhen> </command> </menu> diff --git a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/OperationBrowserHandlerBase.java b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/OperationBrowserHandlerBase.java index 260002e..67e636b 100644 --- a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/OperationBrowserHandlerBase.java +++ b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/OperationBrowserHandlerBase.java @@ -17,6 +17,7 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.Assert; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IViewPart; import org.eclipse.ui.IViewReference; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.handlers.HandlerUtil; @@ -51,7 +52,13 @@ public abstract class OperationBrowserHandlerBase extends AbstractHandler { for (final IViewReference reference : window.getActivePage() .getViewReferences()) { if (OperationBrowser.ID.equals(reference.getId())) { - return (OperationBrowser) reference.getView(true); + final IViewPart view = reference.getView(true); + /* + * check the instance since due to problems with the workspace, etc. the view might be an ErrorViewPart + */ + if (view instanceof OperationBrowser) { + return (OperationBrowser) view; + } } } return null; diff --git a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/OperationSash.java b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/OperationSash.java index 84b59b0..b3035d9 100644 --- a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/OperationSash.java +++ b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/instantiation/ui/OperationSash.java @@ -88,7 +88,7 @@ public class OperationSash extends SashForm { @Override public void selectionChanged(SelectionChangedEvent event) { final OperationInstance operationInstance = SelectionUtils - .getSelectedElement(event.getSelection()); + .getSelectedElement(event.getSelection(), OperationInstance.class); if (operationInstance != null) { parameterViewer.setInput(operationInstance); updateConstraints(operationInstance); @@ -167,7 +167,7 @@ public class OperationSash extends SashForm { */ public OperationInstance getSelectedOperation() { final OperationInstance operationInstance = SelectionUtils - .getSelectedElement(operationViewer.getSelection()); + .getSelectedElement(operationViewer.getSelection(), OperationInstance.class); return operationInstance; } diff --git a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/CreateMigrationHandler.java b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/CreateMigrationHandler.java index b463851..e73a150 100644 --- a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/CreateMigrationHandler.java +++ b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/CreateMigrationHandler.java @@ -30,7 +30,7 @@ public class CreateMigrationHandler extends EditingDomainHandlerBase { /** {@inheritDoc} */ @Override protected Object execute(EditingDomain domain, ExecutionEvent event) { - final EObject element = HandlerUtils.getSelectedElement(event); + final EObject element = HandlerUtils.getSelectedElement(event, EObject.class); final IType javaType = JavaUIUtils.createCustomMigration(element); if (javaType != null) { createMigration(element, javaType.getFullyQualifiedName(), domain); diff --git a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/EditMigrationHandler.java b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/EditMigrationHandler.java index 8f34e09..48b9971 100644 --- a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/EditMigrationHandler.java +++ b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/EditMigrationHandler.java @@ -30,7 +30,7 @@ public class EditMigrationHandler extends EditingDomainHandlerBase { /** {@inheritDoc} */ @Override protected Object execute(EditingDomain domain, ExecutionEvent event) { - final MigrationChange change = HandlerUtils.getSelectedElement(event); + final MigrationChange change = HandlerUtils.getSelectedElement(event, MigrationChange.class); JavaUIUtils.showCustomMigration(change); return null; } diff --git a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/FlattenCompositeHandler.java b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/FlattenCompositeHandler.java index 23c0f99..8f01420 100644 --- a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/FlattenCompositeHandler.java +++ b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/FlattenCompositeHandler.java @@ -33,7 +33,7 @@ public class FlattenCompositeHandler extends EditingDomainHandlerBase { /** {@inheritDoc} */ @Override protected Object execute(EditingDomain domain, ExecutionEvent event) { - final CompositeChange change = HandlerUtils.getSelectedElement(event); + final CompositeChange change = HandlerUtils.getSelectedElement(event, CompositeChange.class); final Release release = (Release) change.eContainer(); final Command command = new ChangeCommand(release) { diff --git a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/FlattenMigrationHandler.java b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/FlattenMigrationHandler.java index a3b2a0e..bf60c79 100644 --- a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/FlattenMigrationHandler.java +++ b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/FlattenMigrationHandler.java @@ -38,7 +38,7 @@ public class FlattenMigrationHandler extends EditingDomainHandlerBase { final ISelection selection = HandlerUtil.getCurrentSelection(event); final MigrationChange change = SelectionUtils - .getSelectedElement(selection); + .getSelectedElement(selection, MigrationChange.class); final Release release = (Release) change.eContainer(); final Command command = new ChangeCommand(release) { diff --git a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/SetMigrationHandler.java b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/SetMigrationHandler.java index 8a6e44a..077d1d6 100644 --- a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/SetMigrationHandler.java +++ b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/SetMigrationHandler.java @@ -23,7 +23,7 @@ public class SetMigrationHandler extends EditingDomainHandlerBase { /** {@inheritDoc} */ @Override protected Object execute(EditingDomain domain, ExecutionEvent event) { - final MigrationChange change = HandlerUtils.getSelectedElement(event); + final MigrationChange change = HandlerUtils.getSelectedElement(event, MigrationChange.class); final IType javaType = JavaUIUtils.selectCustomMigration(change); if (javaType != null) { final Command command = SetCommand.create(domain, change, diff --git a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/SubsequentChangesHandler.java b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/SubsequentChangesHandler.java index 3a910ee..0ebd02f 100644 --- a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/SubsequentChangesHandler.java +++ b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/SubsequentChangesHandler.java @@ -36,7 +36,8 @@ public abstract class SubsequentChangesHandler<C extends Change> extends @Override protected final Object execute(EditingDomain domain, ExecutionEvent event) throws ExecutionException { - final List<C> changes = HandlerUtils.getSelectedElements(event); + @SuppressWarnings("unchecked") + final List<C> changes = (List<C>) HandlerUtils.getSelectedElements(event, Change.class); final Release release = SubsequentChangesPropertyTester.sort(changes); return execute(release, changes, domain, event); } @@ -44,5 +45,5 @@ public abstract class SubsequentChangesHandler<C extends Change> extends /** Convenience method to execute this command. */ protected abstract Object execute(Release release, List<C> changes, EditingDomain domain, ExecutionEvent event) - throws ExecutionException; + throws ExecutionException; } diff --git a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/SubsequentChangesPropertyTester.java b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/SubsequentChangesPropertyTester.java index 1f31b11..30942f2 100644 --- a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/SubsequentChangesPropertyTester.java +++ b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/presentation/action/SubsequentChangesPropertyTester.java @@ -37,7 +37,7 @@ public class SubsequentChangesPropertyTester extends PropertyTester { Object expectedValue) { final ISelection selection = (ISelection) receiver; - final List<Change> changes = SelectionUtils.getSelectedElements(selection); + final List<Change> changes = SelectionUtils.getSelectedElements(selection, Change.class); return isValid(changes); } diff --git a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/reconstruction/ui/CheckIntegrityHandler.java b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/reconstruction/ui/CheckIntegrityHandler.java index 5ceceba..8cfb889 100644 --- a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/reconstruction/ui/CheckIntegrityHandler.java +++ b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/reconstruction/ui/CheckIntegrityHandler.java @@ -37,7 +37,7 @@ public class CheckIntegrityHandler extends AbstractHandler { @Override public Object execute(ExecutionEvent event) { final History history = SelectionUtils.getSelectedElement(HandlerUtil - .getCurrentSelection(event)); + .getCurrentSelection(event), History.class); @SuppressWarnings("unused") final IEditingDomainProvider editor = (IEditingDomainProvider) HandlerUtil .getActiveEditor(event); diff --git a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/reconstruction/ui/CompareHandler.java b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/reconstruction/ui/CompareHandler.java index 5dcdd7b..7be4396 100644 --- a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/reconstruction/ui/CompareHandler.java +++ b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/reconstruction/ui/CompareHandler.java @@ -37,7 +37,7 @@ public class CompareHandler extends AbstractHandler { @Override public Object execute(ExecutionEvent event) { final List<EObject> selectedElements = HandlerUtils - .getSelectedElements(event); + .getSelectedElements(event, EObject.class); if (!selectedElements.isEmpty()) { final EObject from = selectedElements.get(0); final EObject to = selectedElements.get(selectedElements.size() - 1); diff --git a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/reconstruction/ui/ReconstructHandler.java b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/reconstruction/ui/ReconstructHandler.java index ba1e665..435490b 100644 --- a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/reconstruction/ui/ReconstructHandler.java +++ b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/reconstruction/ui/ReconstructHandler.java @@ -40,13 +40,14 @@ public class ReconstructHandler extends AbstractHandler { /** {@inheritDoc} */ @Override public Object execute(ExecutionEvent event) { - final EObject target = HandlerUtils.getSelectedElement(event); + final EObject target = HandlerUtils.getSelectedElement(event, EObject.class); final EditorPart editor = (EditorPart) HandlerUtil.getActiveEditor(event); final FileEditorInput editorInput = (FileEditorInput) editor.getEditorInput(); final ContainerSelectionDialog dialog = new ContainerSelectionDialog(Display .getCurrent().getActiveShell(), editorInput.getFile() - .getParent(), false, ""); //$NON-NLS-1$ + .getParent(), + false, ""); //$NON-NLS-1$ if (dialog.open() == IDialogConstants.OK_ID) { final IPath path = (IPath) dialog.getResult()[0]; diff --git a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/reconstruction/ui/ReconstructionView.java b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/reconstruction/ui/ReconstructionView.java index 18136ba..5c59629 100644 --- a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/reconstruction/ui/ReconstructionView.java +++ b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/reconstruction/ui/ReconstructionView.java @@ -70,7 +70,7 @@ public class ReconstructionView extends SyncedMetamodelEditorViewBase { @Override public void doubleClick(DoubleClickEvent event) { final Object element = SelectionUtils - .getSelectedElement(event.getSelection()); + .getSelectedElement(event.getSelection(), Object.class); if (element != null) { final Object source = reconstructor.getMapping() .resolveSource(element); @@ -137,8 +137,13 @@ public class ReconstructionView extends SyncedMetamodelEditorViewBase { final ValueChange valueChange = (ValueChange) change; final EObject element = reconstructor.getMapping().resolveTarget( valueChange.getElement()); - structureViewer.setSelection(new StructuredSelection(element), - true); + if (element != null) { + /* + * don't try to select an element in case we couldn't resolve the target. + * Otherwise we will get a NPE. + */ + structureViewer.setSelection(new StructuredSelection(element), true); + } } } else if (change instanceof OperationChange) { final OperationChange operationChange = (OperationChange) change; diff --git a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/reconstruction/ui/ShowReconstructionHandler.java b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/reconstruction/ui/ShowReconstructionHandler.java index 9d790f0..88f45d0 100644 --- a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/reconstruction/ui/ShowReconstructionHandler.java +++ b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/reconstruction/ui/ShowReconstructionHandler.java @@ -34,7 +34,7 @@ public class ShowReconstructionHandler extends AbstractHandler { /** {@inheritDoc} */ @Override public Object execute(ExecutionEvent event) { - final EObject element = HandlerUtils.getSelectedElement(event); + final EObject element = HandlerUtils.getSelectedElement(event, EObject.class); try { final ReconstructionView view = (ReconstructionView) HandlerUtils .showView(event, ReconstructionView.ID); diff --git a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/recorder/ui/AddResourceHandler.java b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/recorder/ui/AddResourceHandler.java index 5e5fbb2..88facf0 100644 --- a/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/recorder/ui/AddResourceHandler.java +++ b/plugins/org.eclipse.emf.edapt.history.editor/src/org/eclipse/emf/edapt/history/recorder/ui/AddResourceHandler.java @@ -51,7 +51,7 @@ public class AddResourceHandler extends AbstractHandler { } else { final ISelection selection = HandlerUtil.getCurrentSelection(event); - final Resource resource = SelectionUtils.getSelectedElement(selection); + final Resource resource = SelectionUtils.getSelectedElement(selection, Resource.class); final AddResourceCommand command = new AddResourceCommand(listener, resource); diff --git a/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/ChoiceDialog.java b/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/ChoiceDialog.java index 8905014..ab56c45 100644 --- a/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/ChoiceDialog.java +++ b/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/ChoiceDialog.java @@ -225,7 +225,7 @@ public class ChoiceDialog extends ResizeableDialogBase { @Override public void doubleClick(DoubleClickEvent event) { final Object element = SelectionUtils.getSelectedElement(event - .getSelection()); + .getSelection(), Object.class); modelViewer.setSelection(new StructuredSelection(element)); } @@ -241,7 +241,7 @@ public class ChoiceDialog extends ResizeableDialogBase { @Override protected void okPressed() { selectedElement = SelectionUtils.getSelectedElement(choiceViewer - .getSelection()); + .getSelection(), Object.class); super.okPressed(); } diff --git a/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/LaunchUtils.java b/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/LaunchUtils.java index 97f8680..1b1d5c3 100644 --- a/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/LaunchUtils.java +++ b/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/LaunchUtils.java @@ -39,7 +39,6 @@ public final class LaunchUtils { * Get the value of an attribute of type List of Strings from a launch * configuration. */ - @SuppressWarnings("unchecked") public static List<String> getAttribute(ILaunchConfiguration configuration, String attributeName, List<String> defaultValue) { try { diff --git a/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/MigrationLaunchConfigurationMainTab.java b/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/MigrationLaunchConfigurationMainTab.java index c38a740..91f2047 100644 --- a/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/MigrationLaunchConfigurationMainTab.java +++ b/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/MigrationLaunchConfigurationMainTab.java @@ -431,7 +431,7 @@ class MigrationLaunchConfigurationMainTab extends // validation final ValidationLevel level = SelectionUtils - .getSelectedElement(validationCombo.getSelection()); + .getSelectedElement(validationCombo.getSelection(), ValidationLevel.class); configuration.setAttribute(VALIDATION_LEVEL.id(), level.toString()); // backup @@ -451,7 +451,7 @@ class MigrationLaunchConfigurationMainTab extends configuration.setAttribute(option.id(), -1); } else { final Release release = SelectionUtils.getSelectedElement(combo - .getSelection()); + .getSelection(), Release.class); if (release != null) { configuration.setAttribute(option.id(), release.getNumber()); } @@ -510,7 +510,7 @@ class MigrationLaunchConfigurationMainTab extends private boolean isValidRelease(Button check, ComboViewer combo, MigratorCommandLineOption option) { if (!check.getSelection() - && SelectionUtils.getSelectedElement(combo.getSelection()) == null) { + && SelectionUtils.getSelectedElement(combo.getSelection(), Object.class) == null) { setErrorMessage(StringUtils.upperCamelCaseToText(option.name()) + " must be set"); //$NON-NLS-1$ return false; @@ -634,7 +634,7 @@ class MigrationLaunchConfigurationMainTab extends @Override public void widgetSelected(SelectionEvent e) { final List<String> elements = SelectionUtils - .getSelectedElements(modelViewer.getSelection()); + .getSelectedElements(modelViewer.getSelection(), String.class); final String modelURI = modelURIs.get(0); modelURIs.removeAll(elements); modelViewer.refresh(); diff --git a/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/MigratorHandlerBase.java b/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/MigratorHandlerBase.java index 719a1a2..b8306db 100644 --- a/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/MigratorHandlerBase.java +++ b/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/MigratorHandlerBase.java @@ -81,6 +81,12 @@ public abstract class MigratorHandlerBase extends AbstractHandler { /** Get the migrator for a model. */ protected Migrator getMigrator(final List<URI> modelURIs) { + if (modelURIs.isEmpty()) { + MessageDialog.openError(Display.getDefault().getActiveShell(), + "Namespace", "Not a valid model"); //$NON-NLS-1$ //$NON-NLS-2$ + return null; + } + MigratorOptions.getInstance().setOracle(new InteractiveOracle()); MigratorOptions.getInstance().setDebugger(new InteractiveDebugger()); @@ -152,7 +158,7 @@ public abstract class MigratorHandlerBase extends AbstractHandler { /** Update the selection. */ private void updateSelection(ISelection selection) { - selectedFiles = SelectionUtils.getSelectedElements(selection); + selectedFiles = SelectionUtils.getSelectedElements(selection, IFile.class); } /** Get the selected files. */ diff --git a/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/RegisterMetamodelHandler.java b/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/RegisterMetamodelHandler.java index 262363e..78795f6 100644 --- a/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/RegisterMetamodelHandler.java +++ b/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/RegisterMetamodelHandler.java @@ -38,7 +38,7 @@ public class RegisterMetamodelHandler extends AbstractHandler { /** {@inheritDoc} */ @Override public Object execute(ExecutionEvent event) { - final IFile file = HandlerUtils.getSelectedElement(event); + final IFile file = HandlerUtils.getSelectedElement(event, IFile.class); final URI uri = URIUtils.getURI(file); try { final ResourceSet resourceSet = ResourceUtils.loadResourceSet(uri); diff --git a/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/ReleaseDialog.java b/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/ReleaseDialog.java index 7ccd99e..1dd757e 100644 --- a/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/ReleaseDialog.java +++ b/plugins/org.eclipse.emf.edapt.migration.ui/src/org/eclipse/emf/edapt/migration/ui/ReleaseDialog.java @@ -97,7 +97,7 @@ public class ReleaseDialog extends TitleMessageDialogBase { */ @Override protected void okPressed() { - release = SelectionUtils.getSelectedElement(releaseCombo.getSelection()); + release = SelectionUtils.getSelectedElement(releaseCombo.getSelection(), Release.class); super.okPressed(); } diff --git a/tests/org.eclipse.emf.edapt.rcptt/context/Import EMFForms Example Model.ctx b/tests/org.eclipse.emf.edapt.rcptt/context/Import EMFForms Example Model.ctx index c2e0a37..6f0027a 100644 --- a/tests/org.eclipse.emf.edapt.rcptt/context/Import EMFForms Example Model.ctx +++ b/tests/org.eclipse.emf.edapt.rcptt/context/Import EMFForms Example Model.ctx @@ -14,7 +14,7 @@ Entry-Name: .ecl.context get-menu "File/New/Example..." | click with [get-window "New Example"] { - get-tree | select "EMF Forms/Make it happen: example model" + get-tree | select "Make it happen: example model" get-button Finish | click } ------=_.ecl.context-718f04b4-ed39-33e3-af62-0995e4561998-- diff --git a/tests/org.eclipse.emf.edapt.rcptt/pom.xml b/tests/org.eclipse.emf.edapt.rcptt/pom.xml index 24e2232..bf8a3e2 100644 --- a/tests/org.eclipse.emf.edapt.rcptt/pom.xml +++ b/tests/org.eclipse.emf.edapt.rcptt/pom.xml @@ -1,5 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.eclipse.emf.edapt</groupId> <artifactId>org.eclipse.emf.edapt.rcptt</artifactId> @@ -7,9 +8,10 @@ <packaging>rcpttTest</packaging> <properties> - <rcptt-maven-version>2.0.1</rcptt-maven-version> - <rcptt-runner-version>2.0.0</rcptt-runner-version> - </properties> + <rcptt-maven-version>2.1.0</rcptt-maven-version> + <rcptt-runner-version>2.1.0</rcptt-runner-version> + <toolchains-version>1.1</toolchains-version> + </properties> <pluginRepositories> <pluginRepository> @@ -17,12 +19,39 @@ <name>RCPTT Maven repository</name> <url>https://repo.eclipse.org/content/repositories/rcptt-releases/</url> </pluginRepository> - </pluginRepositories> + <pluginRepository> + <id>rcptt-snapshots</id> + <name>RCPTT Maven Snapshots repository</name> + <snapshots> + <updatePolicy>always</updatePolicy> + </snapshots> + <url>https://repo.eclipse.org/content/repositories/rcptt-snapshots/</url> + </pluginRepository> + </pluginRepositories> <build> <plugins> <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-toolchains-plugin</artifactId> + <version>${toolchains-version}</version> + <executions> + <execution> + <goals> + <goal>toolchain</goal> + </goals> + </execution> + </executions> + <configuration> + <toolchains> + <jdk> + <id>JavaSE-1.8</id> + </jdk> + </toolchains> + </configuration> + </plugin> + <plugin> <groupId>org.eclipse.rcptt</groupId> <artifactId>rcptt-maven-plugin</artifactId> <version>${rcptt-maven-version}</version> @@ -34,29 +63,30 @@ <vmArg>-Dorg.eclipse.swt.browser.DefaultType=mozilla</vmArg> </vmArgs> </runner> - <!-- The main configuration section goes here --> + <!-- The main configuration section goes here --> <aut> - <explicit>http://download.eclipse.org/technology/epp/downloads/release/mars/2/eclipse-dsl-mars-2-linux-gtk-x86_64.tar.gz</explicit> + <explicit>/home/data/httpd/download.eclipse.org/edapt/aut/aut.tar.gz</explicit> <injections> <injection> <site>http://download.eclipse.org/ecp/releases/releases_18/</site> <features> <feature>org.eclipse.emf.ecp.emfforms.idetooling.feature.source.feature.group</feature> - </features> + </features> </injection> <injection> <site>http://download.eclipse.org/releases/mars</site> <features> <feature>org.eclipse.ocl.all.sdk.feature.group</feature> <feature>org.eclipse.emf.compare.ide.ui.feature.group</feature> - </features> + <feature>org.eclipse.emf.compare.feature.group</feature> + </features> </injection> <injection> <site>http://download.eclipse.org/edapt/p2/nightly</site> <features> <feature>org.eclipse.emf.edapt.runtime.feature.feature.group</feature> <feature>org.eclipse.emf.edapt.recorder.feature.feature.group</feature> - </features> + </features> </injection> </injections> <args> |