Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Scholz2014-11-06 23:49:35 +0000
committerLars Vogel2014-12-17 17:34:14 +0000
commit1a36b3f47fcd86cfc0725b651dbe07f1cfa6597d (patch)
tree942e9415565327a42622492a3f2143dc3d4d4b36
parente649d6391893bef3d32d5ebd4d78dd19a92a5103 (diff)
downloadeclipse.platform.ui-1a36b3f47fcd86cfc0725b651dbe07f1cfa6597d.tar.gz
eclipse.platform.ui-1a36b3f47fcd86cfc0725b651dbe07f1cfa6597d.tar.xz
eclipse.platform.ui-1a36b3f47fcd86cfc0725b651dbe07f1cfa6597d.zip
Bug 450411 - EPartService should contain a method, which checks if an
MPart is shown in a certain Perpective Change-Id: Id9fece2e5d2da58019932d5482bfab761a3a6b68 Signed-off-by: Simon Scholz <simon.scholz@vogella.com>
-rw-r--r--bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ApplicationPartServiceImpl.java5
-rw-r--r--bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java24
-rw-r--r--bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/workbench/modeling/EPartService.java17
3 files changed, 45 insertions, 1 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ApplicationPartServiceImpl.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ApplicationPartServiceImpl.java
index 45a1a7f5627..5554f65e471 100644
--- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ApplicationPartServiceImpl.java
+++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ApplicationPartServiceImpl.java
@@ -58,6 +58,11 @@ public class ApplicationPartServiceImpl implements EPartService {
}
@Override
+ public boolean isPartOrPlaceholderInPerspective(String elementId, MPerspective perspective) {
+ return getActiveWindowService().isPartOrPlaceholderInPerspective(elementId, perspective);
+ }
+
+ @Override
public void switchPerspective(MPerspective perspective) {
getActiveWindowService().switchPerspective(perspective);
}
diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java
index 46a50f1b3a1..b57dd80e4e5 100644
--- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java
+++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Lars Vogel (Lars.Vogel@gmail.com) - Bug 416082
+ * Simon Scholz <simon.scholz@vogella.com> - Bug 450411
******************************************************************************/
package org.eclipse.e4.ui.internal.workbench;
@@ -549,6 +550,29 @@ public class PartServiceImpl implements EPartService {
}
@Override
+ public boolean isPartOrPlaceholderInPerspective(String elementId, MPerspective perspective) {
+ List<MPart> findElements = modelService.findElements(perspective, elementId, MPart.class, null);
+ if (!findElements.isEmpty()) {
+ MPart part = findElements.get(0);
+
+ // if that is a shared part, check the placeholders
+ if (workbenchWindow.getSharedElements().contains(part)) {
+ List<MPlaceholder> placeholders = modelService.findElements(perspective, elementId,
+ MPlaceholder.class, null);
+ for (MPlaceholder mPlaceholder : placeholders) {
+ if (mPlaceholder.isVisible() && mPlaceholder.isToBeRendered()) {
+ return true;
+ }
+ }
+ return false;
+ }
+ // not a shared part
+ return part.isVisible() && part.isToBeRendered();
+ }
+ return false;
+ }
+
+ @Override
public void switchPerspective(MPerspective perspective) {
Assert.isNotNull(perspective);
MWindow window = getWindow();
diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/workbench/modeling/EPartService.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/workbench/modeling/EPartService.java
index cea6ed18607..d4fff0cc690 100644
--- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/workbench/modeling/EPartService.java
+++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/workbench/modeling/EPartService.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2013 IBM Corporation and others.
+ * Copyright (c) 2009, 2014 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Simon Scholz <simon.scholz@vogella.com> - Bug 450411
******************************************************************************/
package org.eclipse.e4.ui.workbench.modeling;
@@ -344,4 +345,18 @@ public interface EPartService {
* @noreference This method is not intended to be referenced by clients.
*/
public void switchPerspective(MPerspective perspective);
+
+ /**
+ * Indicates whether a part with a certain elementId is currently rendered in a certain
+ * perspective or not.
+ *
+ * @param elementId
+ * the id of the part, which should be checked
+ * @param perspective
+ * the perspective, which may contain the part with the given elementId
+ * @return <code>true</code> if the part with the given elementId is rendered in the given
+ * perspective and <code>false</code> otherwise
+ * @since 1.3
+ */
+ public boolean isPartOrPlaceholderInPerspective(String elementId, MPerspective perspective);
} \ No newline at end of file

Back to the top