Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2016-04-11 21:40:15 +0000
committerChristian W. Damus2016-04-11 21:40:15 +0000
commit5f7e110b3bfb1fc1d917bd988a1b67c42e2c6ad1 (patch)
tree6ec6dda4d4fb5ab2b72c435430fa7cc0b0027f21 /plugins/infra
parent7cca05b51c3404269b2f32899b38cfffbeef2421 (diff)
downloadorg.eclipse.papyrus-5f7e110b3bfb1fc1d917bd988a1b67c42e2c6ad1.tar.gz
org.eclipse.papyrus-5f7e110b3bfb1fc1d917bd988a1b67c42e2c6ad1.tar.xz
org.eclipse.papyrus-5f7e110b3bfb1fc1d917bd988a1b67c42e2c6ad1.zip
Bug 491478: [Element Types] RuntimeValuesAdviceEditHelperAdvice ignores dialog cancellation
https://bugs.eclipse.org/bugs/show_bug.cgi?id=491478 Check the edit dialog's return code and only complete the command if the user pressed OK. If there was no dialog shown, then the default result is OK. Change-Id: Ie2634ebb0299f65ecf72aead29176e9801f45925
Diffstat (limited to 'plugins/infra')
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.types.ui/src/org/eclipse/papyrus/infra/emf/types/internal/ui/advice/RuntimeValuesAdviceEditHelperAdvice.java279
1 files changed, 142 insertions, 137 deletions
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.types.ui/src/org/eclipse/papyrus/infra/emf/types/internal/ui/advice/RuntimeValuesAdviceEditHelperAdvice.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.types.ui/src/org/eclipse/papyrus/infra/emf/types/internal/ui/advice/RuntimeValuesAdviceEditHelperAdvice.java
index c03d4dbb34e..9b9acdddb82 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.types.ui/src/org/eclipse/papyrus/infra/emf/types/internal/ui/advice/RuntimeValuesAdviceEditHelperAdvice.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.types.ui/src/org/eclipse/papyrus/infra/emf/types/internal/ui/advice/RuntimeValuesAdviceEditHelperAdvice.java
@@ -1,137 +1,142 @@
-/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.types.internal.ui.advice;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
-import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
-import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
-import org.eclipse.papyrus.infra.emf.types.ui.advices.values.RuntimeValuesAdviceConfiguration;
-import org.eclipse.papyrus.infra.emf.types.ui.advices.values.ViewToDisplay;
-import org.eclipse.papyrus.infra.properties.contexts.View;
-import org.eclipse.papyrus.infra.properties.ui.creation.EditionDialog;
-import org.eclipse.papyrus.infra.services.edit.utils.ElementTypeUtils;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * advice for the {@link SetValuesAdviceConfiguration}
- */
-public class RuntimeValuesAdviceEditHelperAdvice extends AbstractEditHelperAdvice {
-
- /** list of views to display */
- protected Set<View> viewsToDisplay;
-
-
- /**
- * Default Constructor
- */
- public RuntimeValuesAdviceEditHelperAdvice(RuntimeValuesAdviceConfiguration configuration) {
- viewsToDisplay = new HashSet<View>();
- for (ViewToDisplay display : configuration.getViewsToDisplay()) {
- View view = display.getView();
- if (view != null) {
- viewsToDisplay.add(view);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean approveRequest(IEditCommandRequest request) {
- return super.approveRequest(request);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ICommand getBeforeCreateCommand(CreateElementRequest request) {
- return super.getBeforeCreateCommand(request);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ICommand getAfterCreateCommand(CreateElementRequest request) {
- return super.getAfterCreateCommand(request);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ICommand getBeforeConfigureCommand(ConfigureRequest request) {
- return super.getBeforeConfigureCommand(request);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ICommand getAfterConfigureCommand(final ConfigureRequest request) {
- final EObject elementToConfigure = request.getElementToConfigure();
- if (elementToConfigure == null) {
- return null;
- }
-
- final boolean dialogCancellable = ElementTypeUtils.dialogCancellable(request);
-
- return new AbstractTransactionalCommand(request.getEditingDomain(), "Editing " + EMFCoreUtil.getName(elementToConfigure), Collections.singletonList(WorkspaceSynchronizer.getFile((elementToConfigure.eResource())))) {
- /**
- * {@inheritDoc}
- */
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- Set<View> viewsToDisplay = getViewsToDisplay();
- if (!viewsToDisplay.isEmpty()) {
- EditionDialog dialog = new EditionDialog(Display.getCurrent().getActiveShell(), dialogCancellable) {
-
- };
- dialog.setTitle("Edit " + EMFCoreUtil.getName(elementToConfigure));
- dialog.setViews(viewsToDisplay);
- dialog.setInput(elementToConfigure);
-
- dialog.open();
- }
-
- return CommandResult.newOKCommandResult(elementToConfigure);
- }
- };
-
- }
-
-
- /**
- * @return the viewsToDisplay
- */
- public Set<View> getViewsToDisplay() {
- return viewsToDisplay;
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2014, 2016 CEA LIST, Christian W. Damus, and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ * Christian W. Damus - bug 491478
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.emf.types.internal.ui.advice;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.infra.emf.types.ui.advices.values.RuntimeValuesAdviceConfiguration;
+import org.eclipse.papyrus.infra.emf.types.ui.advices.values.ViewToDisplay;
+import org.eclipse.papyrus.infra.properties.contexts.View;
+import org.eclipse.papyrus.infra.properties.ui.creation.EditionDialog;
+import org.eclipse.papyrus.infra.services.edit.utils.ElementTypeUtils;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * advice for the {@link SetValuesAdviceConfiguration}
+ */
+public class RuntimeValuesAdviceEditHelperAdvice extends AbstractEditHelperAdvice {
+
+ /** list of views to display */
+ protected Set<View> viewsToDisplay;
+
+
+ /**
+ * Default Constructor
+ */
+ public RuntimeValuesAdviceEditHelperAdvice(RuntimeValuesAdviceConfiguration configuration) {
+ viewsToDisplay = new HashSet<View>();
+ for (ViewToDisplay display : configuration.getViewsToDisplay()) {
+ View view = display.getView();
+ if (view != null) {
+ viewsToDisplay.add(view);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean approveRequest(IEditCommandRequest request) {
+ return super.approveRequest(request);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ICommand getBeforeCreateCommand(CreateElementRequest request) {
+ return super.getBeforeCreateCommand(request);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ICommand getAfterCreateCommand(CreateElementRequest request) {
+ return super.getAfterCreateCommand(request);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ICommand getBeforeConfigureCommand(ConfigureRequest request) {
+ return super.getBeforeConfigureCommand(request);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ICommand getAfterConfigureCommand(final ConfigureRequest request) {
+ final EObject elementToConfigure = request.getElementToConfigure();
+ if (elementToConfigure == null) {
+ return null;
+ }
+
+ final boolean dialogCancellable = ElementTypeUtils.dialogCancellable(request);
+
+ return new AbstractTransactionalCommand(request.getEditingDomain(), "Editing " + EMFCoreUtil.getName(elementToConfigure), Collections.singletonList(WorkspaceSynchronizer.getFile((elementToConfigure.eResource())))) {
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ int dialogResult = Window.OK;
+ Set<View> viewsToDisplay = getViewsToDisplay();
+ if (!viewsToDisplay.isEmpty()) {
+ EditionDialog dialog = new EditionDialog(Display.getCurrent().getActiveShell(), dialogCancellable) {
+
+ };
+ dialog.setTitle("Edit " + EMFCoreUtil.getName(elementToConfigure));
+ dialog.setViews(viewsToDisplay);
+ dialog.setInput(elementToConfigure);
+
+ dialogResult = dialog.open();
+ }
+
+ return (dialogResult == Window.OK)
+ ? CommandResult.newOKCommandResult(elementToConfigure)
+ : CommandResult.newCancelledCommandResult();
+ }
+ };
+
+ }
+
+
+ /**
+ * @return the viewsToDisplay
+ */
+ public Set<View> getViewsToDisplay() {
+ return viewsToDisplay;
+ }
+
+}

Back to the top