aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDean Roberts2011-10-20 11:05:58 (EDT)
committerRemy Suen2011-10-20 11:05:58 (EDT)
commit22e84694f3f452ad215d941388bbd1628e768024 (patch)
treebee7a5570115b0e20b1eeb0edeae2baac8d81860
parentf16d6c4775e91caa31b7a6a3b4f9453ab960a9d0 (diff)
downloadeclipse.platform.ui-22e84694f3f452ad215d941388bbd1628e768024.zip
eclipse.platform.ui-22e84694f3f452ad215d941388bbd1628e768024.tar.gz
eclipse.platform.ui-22e84694f3f452ad215d941388bbd1628e768024.tar.bz2
Bug 355497 [Compatibility] Activities/Capabilities in Eclipse4
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledFolderLayout.java5
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPageLayout.java52
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPlaceholderFolderLayout.java11
3 files changed, 53 insertions, 15 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledFolderLayout.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledFolderLayout.java
index 994f61b..3a6256b 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledFolderLayout.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledFolderLayout.java
@@ -39,7 +39,10 @@ public class ModeledFolderLayout extends ModeledPlaceholderFolderLayout
parent = parent.getParent();
}
folderModel.setToBeRendered(true);
- viewModel.setToBeRendered(isViewVisible(viewId));
+ boolean isViewVisible = layout.isViewVisible(viewId);
+ if (!isViewVisible)
+ layout.addViewActivator(viewModel);
+ viewModel.setToBeRendered(isViewVisible);
folderModel.getChildren().add(viewModel);
}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPageLayout.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPageLayout.java
index 608fdd3..9dabd15 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPageLayout.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPageLayout.java
@@ -37,8 +37,13 @@ import org.eclipse.ui.IFolderLayout;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveDescriptor;
import org.eclipse.ui.IPlaceholderFolderLayout;
+import org.eclipse.ui.IPluginContribution;
import org.eclipse.ui.IViewLayout;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.activities.IIdentifier;
+import org.eclipse.ui.activities.IIdentifierListener;
+import org.eclipse.ui.activities.IWorkbenchActivitySupport;
+import org.eclipse.ui.activities.IdentifierEvent;
import org.eclipse.ui.activities.WorkbenchActivityHelper;
import org.eclipse.ui.internal.WorkbenchMessages;
import org.eclipse.ui.internal.WorkbenchPage;
@@ -86,6 +91,34 @@ public class ModeledPageLayout implements IPageLayout {
private IViewRegistry viewRegistry;
+ private class ViewActivator implements IIdentifierListener {
+ private MUIElement element;
+
+ public ViewActivator(MUIElement element) {
+ this.element = element;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.activities.IIdentifierListener#identifierChanged(org
+ * .eclipse.ui.activities.IdentifierEvent)
+ */
+ public void identifierChanged(IdentifierEvent identifierEvent) {
+ IIdentifier identifier = identifierEvent.getIdentifier();
+
+ // Not activated, do nothing
+ if (!identifier.isEnabled())
+ return;
+
+ // stop listening for activations
+ identifier.removeIdentifierListener(this);
+
+ element.setToBeRendered(true);
+ }
+ }
+
public ModeledPageLayout(MWindow window, EModelService modelService,
EPartService partService,
MPerspective perspModel, IPerspectiveDescriptor descriptor, WorkbenchPage page,
@@ -187,8 +220,8 @@ public class ModeledPageLayout implements IPageLayout {
public void addStandaloneView(String viewId, boolean showTitle,
int relationship, float ratio, String refId) {
- insertView(viewId, relationship, ratio, refId, true,
- false);
+ boolean isVisible = isViewVisible(viewId);
+ insertView(viewId, relationship, ratio, refId, isVisible, false);
}
public void addStandaloneViewPlaceholder(String viewId, int relationship,
@@ -210,12 +243,23 @@ public class ModeledPageLayout implements IPageLayout {
addView(viewId, relationship, ratio, refId);
}
- private boolean isViewVisible(String viewID) {
+ protected boolean isViewVisible(String viewID) {
IViewDescriptor viewDescriptor = viewRegistry.find(viewID);
- // .filterItem() can accept null as an argument
+ if (viewDescriptor == null)
+ return false;
+ if (WorkbenchActivityHelper.restrictUseOf(viewDescriptor))
+ return false;
return !WorkbenchActivityHelper.filterItem(viewDescriptor);
}
+ protected void addViewActivator(MUIElement element) {
+ IWorkbenchActivitySupport support = PlatformUI.getWorkbench().getActivitySupport();
+ IIdentifier identifier = support.getActivityManager().getIdentifier(
+ WorkbenchActivityHelper.createUnifiedId((IPluginContribution) descriptor));
+
+ identifier.addIdentifierListener(new ViewActivator(element));
+ }
+
public IFolderLayout createFolder(String folderId, int relationship,
float ratio, String refId) {
MPartStack stack = insertStack(folderId, relationship, ratio, refId,
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPlaceholderFolderLayout.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPlaceholderFolderLayout.java
index 6ceac31..2c3f687 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPlaceholderFolderLayout.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/e4/compatibility/ModeledPlaceholderFolderLayout.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * Copyright (c) 2009, 2011 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
@@ -16,8 +16,6 @@ import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
import org.eclipse.e4.ui.model.application.ui.basic.MStackElement;
import org.eclipse.ui.IPlaceholderFolderLayout;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.activities.WorkbenchActivityHelper;
-import org.eclipse.ui.views.IViewDescriptor;
import org.eclipse.ui.views.IViewRegistry;
public class ModeledPlaceholderFolderLayout implements IPlaceholderFolderLayout {
@@ -57,11 +55,4 @@ public class ModeledPlaceholderFolderLayout implements IPlaceholderFolderLayout
public void setProperty(String id, String value) {
// folderModel.setProperty(id, value);
}
-
- protected boolean isViewVisible(String viewID) {
- IViewDescriptor viewDescriptor = viewRegistry.find(viewID);
- // .filterItem() can accept null as an argument
- return !WorkbenchActivityHelper.filterItem(viewDescriptor);
- }
-
}