Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Staudacher2010-03-10 10:54:07 +0000
committerHolger Staudacher2010-03-10 10:54:07 +0000
commit69c8658d5ca7442bca5e60f613bd87c0b7041324 (patch)
tree1fbd09edf20b14cbcfb19c5c41260c32052a6807
parenteb9a9a06055fa65c4dd7ca74753886d1874382c1 (diff)
downloadorg.eclipse.rap-69c8658d5ca7442bca5e60f613bd87c0b7041324.tar.gz
org.eclipse.rap-69c8658d5ca7442bca5e60f613bd87c0b7041324.tar.xz
org.eclipse.rap-69c8658d5ca7442bca5e60f613bd87c0b7041324.zip
RESOLVED - 280299: [design] provide a solution to make all viewactions visible
https://bugs.eclipse.org/bugs/show_bug.cgi?id=280299
-rw-r--r--bundles/org.eclipse.rap.design.example/plugin.xml6
-rw-r--r--bundles/org.eclipse.rap.design.example/src/org/eclipse/rap/internal/design/example/stacks/ViewStackPresentation.java3
-rw-r--r--bundles/org.eclipse.rap.ui.workbench/Eclipse UI/org/eclipse/rap/ui/interactiondesign/ConfigurationAction.java78
-rw-r--r--bundles/org.eclipse.rap.ui/schema/rap/branding.exsd7
-rw-r--r--tests/org.eclipse.rap.ui.tests/IAD API Tests.launch4
-rw-r--r--tests/org.eclipse.rap.ui.tests/IAD API Tests/org/eclipse/rap/interactiondesign/tests/ConfigurationActionTest.java26
-rw-r--r--tests/org.eclipse.rap.ui.tests/IAD API Tests/org/eclipse/rap/interactiondesign/tests/impl/ConfigurationActionImpl.java72
-rw-r--r--tests/org.eclipse.rap.ui.tests/plugin.xml3
8 files changed, 177 insertions, 22 deletions
diff --git a/bundles/org.eclipse.rap.design.example/plugin.xml b/bundles/org.eclipse.rap.design.example/plugin.xml
index 2a1f622afc..5a09544cba 100644
--- a/bundles/org.eclipse.rap.design.example/plugin.xml
+++ b/bundles/org.eclipse.rap.design.example/plugin.xml
@@ -25,7 +25,8 @@
<presentationFactory
defaultLayoutId="org.eclipse.rap.design.example.business.layout"
id="org.eclipse.rap.design.example.business.factory"
- name="Business Presentation Factory">
+ name="Business Presentation Factory"
+ viewActionsVisible="false">
<defaultStackPresentation
id="org.eclipse.rap.design.example.stack.view">
</defaultStackPresentation>
@@ -40,7 +41,8 @@
<presentationFactory
defaultLayoutId="org.eclipse.rap.design.example.fancy.layout"
id="org.eclipse.rap.design.example.fancy.factory"
- name="Fancy Presentation Factory">
+ name="Fancy Presentation Factory"
+ viewActionsVisible="false">
<defaultStackPresentation
id="org.eclipse.rap.design.example.stack.view">
</defaultStackPresentation>
diff --git a/bundles/org.eclipse.rap.design.example/src/org/eclipse/rap/internal/design/example/stacks/ViewStackPresentation.java b/bundles/org.eclipse.rap.design.example/src/org/eclipse/rap/internal/design/example/stacks/ViewStackPresentation.java
index 4ec134eb2a..69d67a942b 100644
--- a/bundles/org.eclipse.rap.design.example/src/org/eclipse/rap/internal/design/example/stacks/ViewStackPresentation.java
+++ b/bundles/org.eclipse.rap.design.example/src/org/eclipse/rap/internal/design/example/stacks/ViewStackPresentation.java
@@ -343,7 +343,8 @@ public class ViewStackPresentation extends ConfigurableStack {
IToolBarManager manager = getPartToolBarManager();
boolean hasViewActions
= manager != null && manager.getItems().length > 0;
- if( hasViewActions || hasViewMenu ) {
+ if( ( hasViewActions || hasViewMenu )
+ && !ConfigAction.allActionsVisible() ) {
if( confButton != null ) {
// enable conf button
confButton.setEnabled( true );
diff --git a/bundles/org.eclipse.rap.ui.workbench/Eclipse UI/org/eclipse/rap/ui/interactiondesign/ConfigurationAction.java b/bundles/org.eclipse.rap.ui.workbench/Eclipse UI/org/eclipse/rap/ui/interactiondesign/ConfigurationAction.java
index 52683d00a9..3e48eeec7b 100644
--- a/bundles/org.eclipse.rap.ui.workbench/Eclipse UI/org/eclipse/rap/ui/interactiondesign/ConfigurationAction.java
+++ b/bundles/org.eclipse.rap.ui.workbench/Eclipse UI/org/eclipse/rap/ui/interactiondesign/ConfigurationAction.java
@@ -11,10 +11,16 @@ package org.eclipse.rap.ui.interactiondesign;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.rap.ui.interactiondesign.internal.ConfigurableStackProxy;
+import org.eclipse.rwt.branding.AbstractBranding;
+import org.eclipse.rwt.internal.branding.BrandingUtil;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.internal.LayoutPart;
import org.eclipse.ui.internal.WorkbenchWindow;
@@ -64,6 +70,44 @@ public abstract class ConfigurationAction extends Action {
private IStackPresentationSite site;
private StackPresentation stackPresentation;
private List configurationChangeListeners = new ArrayList();
+
+ /**
+ * Helper method to check if all view contrib items are visible by default.
+ * @return true if all items are visible by default.
+ */
+ public static boolean allActionsVisible() {
+ boolean result = false;
+ AbstractBranding branding = BrandingUtil.findBranding();
+ if( branding != null ) {
+ String brandingId = branding.getId();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ final String id = "org.eclipse.rap.ui.branding";
+ IExtensionPoint brandingPoint = registry.getExtensionPoint( id );
+ if( brandingPoint != null ) {
+ IConfigurationElement[] elements
+ = brandingPoint.getConfigurationElements();
+ boolean found = false;
+ for( int i = 0; i < elements.length && !found; i++ ) {
+ String tempId = elements[ i ].getAttribute( "id" );
+ if( tempId.equals( brandingId ) ) {
+ found = true;
+ IConfigurationElement[] factory
+ = elements[ i ].getChildren( "presentationFactory" );
+ if( factory.length > 0 ) {
+ String visibility
+ = factory[ 0 ].getAttribute( "viewActionsVisible" );
+ if( visibility != null
+ && Boolean.valueOf( visibility ).booleanValue() )
+ {
+ result = true;
+ }
+ }
+ }
+ }
+ }
+ }
+ return result;
+ }
/**
* Method to add a <code>{@link IConfigurationChangeListener}.
@@ -205,12 +249,14 @@ public abstract class ConfigurationAction extends Action {
* @return the visibility of the part menu.
*/
public boolean isPartMenuVisible() {
- boolean result = false;
- if( stackPresentation instanceof ConfigurableStack ) {
- ConfigurableStack configStack = ( ConfigurableStack )stackPresentation;
- String paneId = configStack.getPaneId( site );
- String identifier = getPartMenuIdentifier( paneId );
- result = loadPartmenuVisibility( identifier );
+ boolean result = true;
+ if( !allActionsVisible() ) {
+ if( stackPresentation instanceof ConfigurableStack ) {
+ ConfigurableStack configStack = ( ConfigurableStack )stackPresentation;
+ String paneId = configStack.getPaneId( site );
+ String identifier = getPartMenuIdentifier( paneId );
+ result = loadPartmenuVisibility( identifier );
+ }
}
return result;
}
@@ -240,18 +286,18 @@ public abstract class ConfigurationAction extends Action {
* @see Action
* @see ScopedPreferenceStore
*/
- public boolean isViewActionVisibile(
- final String viewId, final String actionId )
+ public boolean isViewActionVisibile( final String viewId,
+ final String actionId )
{
- boolean result = false;
- String identifier = getActionIdentifier( viewId, actionId );
-
- ScopedPreferenceStore prefStore
- = ( ScopedPreferenceStore ) PrefUtil.getAPIPreferenceStore();
- result = prefStore.getBoolean( identifier );
-
+ boolean result = true;
+ if( !allActionsVisible() ) {
+ String identifier = getActionIdentifier( viewId, actionId );
+ ScopedPreferenceStore prefStore
+ = ( ScopedPreferenceStore ) PrefUtil.getAPIPreferenceStore();
+ result = prefStore.getBoolean( identifier );
+ }
return result;
- }
+ }
/**
* Removes a <code>{@link IConfigurationChangeListener}</code> from this
diff --git a/bundles/org.eclipse.rap.ui/schema/rap/branding.exsd b/bundles/org.eclipse.rap.ui/schema/rap/branding.exsd
index 144673efa9..80279b32ec 100644
--- a/bundles/org.eclipse.rap.ui/schema/rap/branding.exsd
+++ b/bundles/org.eclipse.rap.ui/schema/rap/branding.exsd
@@ -300,6 +300,13 @@ This is not supported by every browser.
</documentation>
</annotation>
</attribute>
+ <attribute name="viewActionsVisible" type="boolean">
+ <annotation>
+ <documentation>
+ Sets the default vibility for a view&apos;s contribution items (actions/commands). The default value is false. When set to true, all items are visible by default. Otherwise all items are invisible and can be configured via the configuration menu.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
diff --git a/tests/org.eclipse.rap.ui.tests/IAD API Tests.launch b/tests/org.eclipse.rap.ui.tests/IAD API Tests.launch
index ea1b299bc4..192d0ef520 100644
--- a/tests/org.eclipse.rap.ui.tests/IAD API Tests.launch
+++ b/tests/org.eclipse.rap.ui.tests/IAD API Tests.launch
@@ -52,10 +52,10 @@
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
<booleanAttribute key="show_selected_only" value="false"/>
-<stringAttribute key="target_bundles" value="javax.servlet@default:default,org.eclipse.osgi.services@default:default,org.eclipse.equinox.http.servlet@default:default,com.ibm.icu.base@default:default,org.eclipse.help@default:default,org.eclipse.equinox.preferences@default:default,org.junit@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.core.resources@default:default,org.mortbay.jetty.server@default:default,org.mortbay.jetty.util@default:default,org.eclipse.core.commands@default:default,org.eclipse.equinox.app@default:default,org.eclipse.core.databinding.beans@default:default,org.eclipse.equinox.http.jetty@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.databinding@default:default,org.eclipse.osgi@-1:true,org.eclipse.core.databinding.property@default:default,org.eclipse.jdt.junit.runtime@default:default,org.eclipse.equinox.http.registry@default:default,org.eclipse.equinox.common@2:true,org.eclipse.core.runtime@default:true"/>
+<stringAttribute key="target_bundles" value="org.eclipse.equinox.http.jetty@default:default,org.eclipse.core.filesystem@default:default,org.eclipse.core.runtime@default:true,org.eclipse.core.databinding.beans@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.databinding@default:default,org.eclipse.update.configurator@default:default,org.mortbay.jetty.util@default:default,javax.servlet@default:default,org.eclipse.core.runtime.compatibility*3.2.0.v20090413@default:default,org.eclipse.core.resources@default:default,org.mortbay.jetty.server@default:default,org.eclipse.equinox.http.registry@default:default,com.ibm.icu.base@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.help@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.jdt.junit.runtime@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.core.filesystem.macosx@default:false,org.eclipse.osgi@-1:true,org.eclipse.core.jobs@default:default,org.junit@default:default,org.eclipse.equinox.http.servlet@default:default,org.eclipse.osgi.services@default:default,org.eclipse.core.commands@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.common@2:true"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useDefaultConfig" value="true"/>
<booleanAttribute key="useDefaultConfigArea" value="false"/>
<booleanAttribute key="useProduct" value="true"/>
-<stringAttribute key="workspace_bundles" value="org.eclipse.core.tests.harness@default:default,org.eclipse.rap.ui.tests.harness@default:default,org.eclipse.rap.ui.workbench@default:default,org.eclipse.rap.rwt.testfixture@default:false,org.eclipse.update.configurator@3:true,org.eclipse.rap.rwt.q07@default:false,org.eclipse.rap.ui.forms.test@default:false,org.eclipse.rap.jface.databinding@default:default,org.eclipse.rap.rwt.test@default:false,org.eclipse.rap.ui@default:default,org.eclipse.rap.junit@default:default,org.eclipse.rap.rwt.q07.test@default:false,org.eclipse.rap.ui.views@default:default,org.eclipse.rap.jface@default:default,org.eclipse.rap.ui.forms@default:default,org.eclipse.rap.ui.tests@default:default,org.eclipse.rap.rwt@default:default,org.eclipse.rap.rwt.test.mockup@default:false,org.eclipse.test.performance@default:default,org.eclipse.rap.junit.runtime@default:default,org.eclipse.core.runtime.compatibility@default:default"/>
+<stringAttribute key="workspace_bundles" value="org.eclipse.rap.ui.tests@default:default,org.eclipse.rap.jface@default:default,org.eclipse.rap.junit.runtime@default:default,org.eclipse.rap.rwt@default:default,org.eclipse.rap.rwt.q07@default:false,org.eclipse.rap.equinox.registry@default:false,org.eclipse.rap.ui.workbench@default:default,org.eclipse.rap.ui@default:default,org.eclipse.rap.ui.forms@default:default,org.eclipse.rap.ui.views@default:default,org.eclipse.test.performance@default:default,org.eclipse.rap.ui.tests.harness@default:default,org.eclipse.core.tests.harness@default:default,org.eclipse.rap.junit@default:default,org.eclipse.rap.jface.databinding@default:default"/>
</launchConfiguration>
diff --git a/tests/org.eclipse.rap.ui.tests/IAD API Tests/org/eclipse/rap/interactiondesign/tests/ConfigurationActionTest.java b/tests/org.eclipse.rap.ui.tests/IAD API Tests/org/eclipse/rap/interactiondesign/tests/ConfigurationActionTest.java
index e9103817d3..ecebe5eec6 100644
--- a/tests/org.eclipse.rap.ui.tests/IAD API Tests/org/eclipse/rap/interactiondesign/tests/ConfigurationActionTest.java
+++ b/tests/org.eclipse.rap.ui.tests/IAD API Tests/org/eclipse/rap/interactiondesign/tests/ConfigurationActionTest.java
@@ -16,6 +16,7 @@ import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.rap.interactiondesign.tests.impl.ConfigurableStackImpl;
+import org.eclipse.rap.interactiondesign.tests.impl.ConfigurationActionImpl;
import org.eclipse.rap.junit.RAPTestCase;
import org.eclipse.rap.ui.interactiondesign.ConfigurableStack;
import org.eclipse.rap.ui.interactiondesign.ConfigurationAction;
@@ -140,6 +141,18 @@ public class ConfigurationActionTest extends RAPTestCase {
assertFalse( visible );
}
+ public void testPartMenuVisibilityWithGlobalValue() {
+ boolean visible = configAction.isPartMenuVisible();
+ assertFalse( visible );
+ ConfigurationActionImpl action = ( ConfigurationActionImpl ) configAction;
+ action.setGlobalVisibilityAttribute( true );
+ visible = configAction.isPartMenuVisible();
+ assertTrue( visible );
+ action.setGlobalVisibilityAttribute( false );
+ visible = configAction.isPartMenuVisible();
+ assertFalse( visible );
+ }
+
public void testActionVisibility() {
String viewId = "org.eclipse.view";
String actionId = "org.eclipse.action";
@@ -153,6 +166,19 @@ public class ConfigurationActionTest extends RAPTestCase {
assertFalse( visible );
}
+ public void testActionVisibilityWithGlobalValue() {
+ String viewId = "org.eclipse.view";
+ String actionId = "org.eclipse.action";
+ boolean visible = configAction.isViewActionVisibile( viewId, actionId );
+ assertFalse( visible );
+ ConfigurationActionImpl action = ( ConfigurationActionImpl ) configAction;
+ action.setGlobalVisibilityAttribute( true );
+ visible = configAction.isViewActionVisibile( viewId, actionId );
+ assertTrue( visible );
+ action.setGlobalVisibilityAttribute( false );
+ visible = configAction.isViewActionVisibile( viewId, actionId );
+ assertFalse( visible );
+ }
private ConfigurableStack getConfigurableStack() {
ConfigurableStack result = null;
diff --git a/tests/org.eclipse.rap.ui.tests/IAD API Tests/org/eclipse/rap/interactiondesign/tests/impl/ConfigurationActionImpl.java b/tests/org.eclipse.rap.ui.tests/IAD API Tests/org/eclipse/rap/interactiondesign/tests/impl/ConfigurationActionImpl.java
index e8f8700a10..00b1bc3523 100644
--- a/tests/org.eclipse.rap.ui.tests/IAD API Tests/org/eclipse/rap/interactiondesign/tests/impl/ConfigurationActionImpl.java
+++ b/tests/org.eclipse.rap.ui.tests/IAD API Tests/org/eclipse/rap/interactiondesign/tests/impl/ConfigurationActionImpl.java
@@ -9,12 +9,84 @@
*******************************************************************************/
package org.eclipse.rap.interactiondesign.tests.impl;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.rap.ui.interactiondesign.ConfigurableStack;
import org.eclipse.rap.ui.interactiondesign.ConfigurationAction;
+import org.eclipse.rap.ui.interactiondesign.internal.ConfigurableStackProxy;
+import org.eclipse.ui.internal.util.PrefUtil;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
public class ConfigurationActionImpl extends ConfigurationAction {
+
+ /**
+ * Helper method to check if all view contrib items are visible by default.
+ * @return true if all items are visible by default.
+ */
+ public static boolean allActionsVisible() {
+ return visibility;
+ }
+
+ private static boolean visibility = false;
+
+ public void setGlobalVisibilityAttribute( final boolean visibility ) {
+ ConfigurationActionImpl.visibility = visibility;
+ }
public ConfigurationActionImpl() {
}
+ public boolean isViewActionVisibile( final String viewId,
+ final String actionId )
+ {
+ boolean result = true;
+ if( !allActionsVisible() ) {
+ String identifier = getActionIdentifier( viewId, actionId );
+ ScopedPreferenceStore prefStore
+ = ( ScopedPreferenceStore ) PrefUtil.getAPIPreferenceStore();
+ result = prefStore.getBoolean( identifier );
+ }
+ return result;
+ }
+
+ public boolean isPartMenuVisible() {
+ boolean result = true;
+ if( !allActionsVisible() ) {
+ if( getStackPresentation() instanceof ConfigurableStack ) {
+ ConfigurableStack configStack
+ = ( ConfigurableStack ) getStackPresentation();
+ String paneId = configStack.getPaneId( getSite() );
+ String identifier = getPartMenuIdentifier( paneId );
+ result = loadPartmenuVisibility( identifier );
+ }
+ }
+ return result;
+ }
+
+ private boolean loadPartmenuVisibility( final String identifier ) {
+ boolean result = false;
+ IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore();
+ result = preferenceStore.getBoolean( identifier );
+ return result;
+ }
+
+ private String getActionIdentifier( final String viewId,
+ final String actionId )
+ {
+ return
+ ConfigurableStackProxy.STACK_PRESENTATION_ID
+ + "/"
+ + viewId
+ + "/"
+ + actionId;
+ }
+
+ private String getPartMenuIdentifier( final String paneId ) {
+ return
+ ConfigurableStackProxy.STACK_PRESENTATION_ID
+ + "/"
+ + paneId
+ + "/partMenu";
+ }
+
}
diff --git a/tests/org.eclipse.rap.ui.tests/plugin.xml b/tests/org.eclipse.rap.ui.tests/plugin.xml
index 0eea6ff6a3..ba01265bd7 100644
--- a/tests/org.eclipse.rap.ui.tests/plugin.xml
+++ b/tests/org.eclipse.rap.ui.tests/plugin.xml
@@ -3855,7 +3855,8 @@
<presentationFactory
defaultLayoutId="org.eclipse.rap.ui.interactiondesign.test.layout2"
id="org.eclipse.rap.ui.interactiondesign.test.factory"
- name="TestFactory">
+ name="TestFactory"
+ viewActionsVisible="false">
<stackPresentation
id="org.eclipse.rap.ui.interactiondesign.test.stackPresentation"
name="TestStack"

Back to the top