From 04d717a79d5547a8b426942b91ed4d3ba2f12353 Mon Sep 17 00:00:00 2001 From: Bruno Sinou Date: Wed, 18 Feb 2015 09:55:50 +0000 Subject: [PATCH] Un-comment default user menu. Client application might define a "org.argeo.ui.openHomeCommandId" system property to enable the call of a custom command that will trigger application specific behaviour. git-svn-id: https://svn.argeo.org/commons/trunk@7926 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../ui/workbench/commands/DoNothing.java | 15 ++ org.argeo.security.ui.rap/plugin.xml | 183 ++++++++---------- .../security/ui/rap/RapActionBarAdvisor.java | 2 +- .../security/ui/rap/commands/OpenHome.java | 46 +++++ .../ui/commands/OpenHomePerspective.java | 6 + 5 files changed, 154 insertions(+), 98 deletions(-) create mode 100644 org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/commands/DoNothing.java create mode 100644 org.argeo.security.ui.rap/src/org/argeo/security/ui/rap/commands/OpenHome.java diff --git a/org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/commands/DoNothing.java b/org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/commands/DoNothing.java new file mode 100644 index 000000000..2f8e56ceb --- /dev/null +++ b/org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/commands/DoNothing.java @@ -0,0 +1,15 @@ +package org.argeo.eclipse.ui.workbench.commands; + +import org.argeo.eclipse.ui.workbench.WorkbenchUiPlugin; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +/** Utilitary command to enable sub menus in various toolbars. Does nothing */ +public class DoNothing extends AbstractHandler { + public final static String ID = WorkbenchUiPlugin.ID + ".doNothing"; + + public Object execute(ExecutionEvent event) throws ExecutionException { + return null; + } +} diff --git a/org.argeo.security.ui.rap/plugin.xml b/org.argeo.security.ui.rap/plugin.xml index 53e65909d..75547a519 100644 --- a/org.argeo.security.ui.rap/plugin.xml +++ b/org.argeo.security.ui.rap/plugin.xml @@ -34,103 +34,19 @@ - - - - - - - - - - - - - - - - - - - - + + - - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - - + + + + + + + + + + \ No newline at end of file diff --git a/org.argeo.security.ui.rap/src/org/argeo/security/ui/rap/RapActionBarAdvisor.java b/org.argeo.security.ui.rap/src/org/argeo/security/ui/rap/RapActionBarAdvisor.java index 074b798c7..f29fc8e4e 100644 --- a/org.argeo.security.ui.rap/src/org/argeo/security/ui/rap/RapActionBarAdvisor.java +++ b/org.argeo.security.ui.rap/src/org/argeo/security/ui/rap/RapActionBarAdvisor.java @@ -110,6 +110,7 @@ public class RapActionBarAdvisor extends ActionBarAdvisor { @Override protected void fillCoolBar(ICoolBarManager coolBar) { + // Add a command which label is the login of the current logged-in user if (username != null) { ICommandService cmdService = (ICommandService) getActionBarConfigurer() .getWindowConfigurer().getWorkbenchConfigurer() @@ -117,7 +118,6 @@ public class RapActionBarAdvisor extends ActionBarAdvisor { Category userMenus = cmdService.getCategory(ID_BASE + ".userMenus"); if (!userMenus.isDefined()) userMenus.define("User Menus", "User related menus"); - Command userMenu = cmdService.getCommand(ID_BASE + ".userMenuCommand"); if (userMenu.isDefined()) diff --git a/org.argeo.security.ui.rap/src/org/argeo/security/ui/rap/commands/OpenHome.java b/org.argeo.security.ui.rap/src/org/argeo/security/ui/rap/commands/OpenHome.java new file mode 100644 index 000000000..37ebe3572 --- /dev/null +++ b/org.argeo.security.ui.rap/src/org/argeo/security/ui/rap/commands/OpenHome.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2007-2012 Argeo GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.argeo.security.ui.rap.commands; + +import org.argeo.eclipse.ui.dialogs.ErrorFeedback; +import org.argeo.eclipse.ui.workbench.CommandUtils; +import org.argeo.security.ui.UserHomePerspective; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.ui.WorkbenchException; +import org.eclipse.ui.handlers.HandlerUtil; + +/** Default action of the user menu */ +public class OpenHome extends AbstractHandler { + private final static String PROP_OPEN_HOME_CMD_ID = "org.argeo.ui.openHomeCommandId"; + + public Object execute(ExecutionEvent event) throws ExecutionException { + + String defaultCmdId = System.getProperty(PROP_OPEN_HOME_CMD_ID, ""); + if (!"".equals(defaultCmdId.trim())) + CommandUtils.callCommand(defaultCmdId); + else { + try { + HandlerUtil.getActiveSite(event).getWorkbenchWindow() + .openPage(UserHomePerspective.ID, null); + } catch (WorkbenchException e) { + ErrorFeedback.show("Cannot open home perspective", e); + } + } + return null; + } +} diff --git a/org.argeo.security.ui/src/org/argeo/security/ui/commands/OpenHomePerspective.java b/org.argeo.security.ui/src/org/argeo/security/ui/commands/OpenHomePerspective.java index a530a4e9a..49a657581 100644 --- a/org.argeo.security.ui/src/org/argeo/security/ui/commands/OpenHomePerspective.java +++ b/org.argeo.security.ui/src/org/argeo/security/ui/commands/OpenHomePerspective.java @@ -27,6 +27,12 @@ import org.eclipse.ui.handlers.HandlerUtil; public class OpenHomePerspective extends AbstractHandler { public Object execute(ExecutionEvent event) throws ExecutionException { + + + String defaultCmdId = System.getProperty( + "argeo.try", ""); + System.out.println("System prop" + defaultCmdId ); + try { HandlerUtil.getActiveSite(event).getWorkbenchWindow() .openPage(UserHomePerspective.ID, null); -- 2.30.2