Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThanh Liem PHAN2017-02-03 10:18:06 +0000
committerGerrit Code Review @ Eclipse.org2017-02-13 16:31:07 +0000
commitab72855fe5e4410565b1521fc6d9fc968d473a6b (patch)
treeeed040729abdcfb2df8ad5d56dd543b4ea7a21ac /plugins/infra/ui
parent6d837be05a8f6c176c25d0e3e0e452aecba1fb81 (diff)
downloadorg.eclipse.papyrus-ab72855fe5e4410565b1521fc6d9fc968d473a6b.tar.gz
org.eclipse.papyrus-ab72855fe5e4410565b1521fc6d9fc968d473a6b.tar.xz
org.eclipse.papyrus-ab72855fe5e4410565b1521fc6d9fc968d473a6b.zip
Bug 509357: [Model Explorer] Rename... Contextual menu doesn't exist
anymore for element https://bugs.eclipse.org/bugs/show_bug.cgi?id=509357 - Add commands to rename an element and its label - Refactor common methods into the ModelExplorerEditionUtil class - Refactor rename handlers - Correct an NPE in DirectEditorEditingSupport - Externalise the dialog's parameters Change-Id: I96dd078590139bde342fa6c0e633d04c4cd40b92 Signed-off-by: Thanh Liem PHAN <thanhliem.phan@all4tec.net>
Diffstat (limited to 'plugins/infra/ui')
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/command/AbstractCommandHandler.java1
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/util/WorkbenchPartHelper.java59
2 files changed, 33 insertions, 27 deletions
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/command/AbstractCommandHandler.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/command/AbstractCommandHandler.java
index c80791a8047..46088acc19a 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/command/AbstractCommandHandler.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/command/AbstractCommandHandler.java
@@ -183,7 +183,6 @@ public abstract class AbstractCommandHandler extends AbstractPapyrusHandler {
if (selection instanceof Collection<?>) {
this.selection = (selection instanceof List<?>) ? (List<?>) selection : new java.util.ArrayList<Object>((Collection<?>) selection);
setBaseEnabled(computeEnabled(context));
- this.selection = Collections.EMPTY_LIST;
}
}
super.setEnabled(evaluationContext);
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/util/WorkbenchPartHelper.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/util/WorkbenchPartHelper.java
index 440fd597ff0..240874d8f23 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/util/WorkbenchPartHelper.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui/src/org/eclipse/papyrus/infra/ui/util/WorkbenchPartHelper.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
+ * Copyright (c) 2012, 2017 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,7 +8,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
- *
+ * Thanh Liem PHAN (ALL4TEC) thanhliem.phan@all4tec.net - Bug 509357
*****************************************************************************/
package org.eclipse.papyrus.infra.ui.util;
@@ -21,11 +20,14 @@ import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
/**
- *
- * a helper for the Eclipse workbench part
+ * A helper for retrieving from Eclipse Platform UI:
+ * <ul>
+ * <li>the active editor part</li>
+ * <li>the active workbench part</li>
+ * <li>and the active workbench</li>
+ * </ul>
*
* @since 1.2
- *
*/
public class WorkbenchPartHelper {
@@ -34,40 +36,45 @@ public class WorkbenchPartHelper {
}
/**
- *
* @return
- * the current IWorkbenchPart or <code>null</code> if not found
+ * The current {@link IWorkbenchPage} or <code>null</code> if not found
*/
- public static final IWorkbenchPart getCurrentActiveWorkbenchPart() {
+ public static final IWorkbenchPage getCurrentActiveWorkbenchPage() {
final IWorkbench workbench = PlatformUI.getWorkbench();
- if (workbench != null) {
+ if (null != workbench) {
final IWorkbenchWindow activeWorkbench = workbench.getActiveWorkbenchWindow();
- if (activeWorkbench != null) {
- final IWorkbenchPage activePage = activeWorkbench.getActivePage();
- if (activePage != null) {
- return activePage.getActivePart();
- }
+ if (null != activeWorkbench) {
+ return activeWorkbench.getActivePage();
}
}
+
+ return null;
+ }
+
+
+ /**
+ * @return
+ * The current {@link IWorkbenchPart} or <code>null</code> if not found
+ */
+ public static final IWorkbenchPart getCurrentActiveWorkbenchPart() {
+ final IWorkbenchPage activePage = getCurrentActiveWorkbenchPage();
+ if (null != activePage) {
+ return activePage.getActivePart();
+ }
+
return null;
}
/**
- *
* @return
- * the current IEditorPart or <code>null</code> if not found
+ * The current {@link IEditorPart} or <code>null</code> if not found
*/
public static final IEditorPart getCurrentActiveEditorPart() {
- final IWorkbench workbench = PlatformUI.getWorkbench();
- if (workbench != null) {
- final IWorkbenchWindow activeWorkbench = workbench.getActiveWorkbenchWindow();
- if (activeWorkbench != null) {
- final IWorkbenchPage activePage = activeWorkbench.getActivePage();
- if (activePage != null) {
- return activePage.getActiveEditor();
- }
- }
+ final IWorkbenchPage activePage = getCurrentActiveWorkbenchPage();
+ if (null != activePage) {
+ return activePage.getActiveEditor();
}
+
return null;
}
}

Back to the top