Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/pasteInNewTable/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/EditorHelper.java')
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/EditorHelper.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/EditorHelper.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/EditorHelper.java
new file mode 100644
index 00000000000..6ca2e7a1d0d
--- /dev/null
+++ b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/EditorHelper.java
@@ -0,0 +1,51 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.tools.util;
+
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ *
+ * a helper for the Editor
+ *
+ */
+public class EditorHelper {
+
+ private EditorHelper() {
+ //nothing to do
+ }
+
+ /**
+ *
+ * @return
+ * the current editor or <code>null</code> if not found
+ */
+ public static final IEditorPart getCurrentEditor() {
+ 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();
+ }
+ }
+ }
+ return null;
+ }
+}

Back to the top