Un-comment default user menu. Client application might define a "org.argeo.ui.openHom...
authorBruno Sinou <bsinou@argeo.org>
Wed, 18 Feb 2015 09:55:50 +0000 (09:55 +0000)
committerBruno Sinou <bsinou@argeo.org>
Wed, 18 Feb 2015 09:55:50 +0000 (09:55 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@7926 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/commands/DoNothing.java [new file with mode: 0644]
org.argeo.security.ui.rap/plugin.xml
org.argeo.security.ui.rap/src/org/argeo/security/ui/rap/RapActionBarAdvisor.java
org.argeo.security.ui.rap/src/org/argeo/security/ui/rap/commands/OpenHome.java [new file with mode: 0644]
org.argeo.security.ui/src/org/argeo/security/ui/commands/OpenHomePerspective.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 (file)
index 0000000..2f8e56c
--- /dev/null
@@ -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;
+       }
+}
index 53e65909dbc59403b9e733bf5020375450eeb98c..75547a5199ab318b8bf779928d187954b5874c5b 100644 (file)
       </entrypoint>
    </extension>
 
-       <extension
-         point="org.eclipse.rap.ui.branding">
-       <!-- themeId attribute is by default set to this value.
-                       Left anyway to provide the pattern when defining a later 
-                       own default theme for Argeo Rap UIs. 
-                       corresponding theme is found in spite of the warning -->
-               
-       <!--
-       body="branding/login.html" 
-       body attribute pointing to an auto refresh page triggers weird side effects: 
-       the whole workbench is re-loaded (like pressing on F5) every now and then. 
-       Must be checked. Removed from the time being.-->   
-               <branding
-                       id="org.argeo.security.ui.rap.defaultBranding"
-            themeId="org.eclipse.rap.rwt.theme.Default"
-            title="Argeo Web UI"
-            favicon="branding/favicon.ico">
-       </branding>
-       <!-- we need a servlet with this name j_spring_security_logout
-                for the logout filter -->
-       <branding
-                       id="org.argeo.security.ui.rap.logoutBranding"
-            title="Argeo Logout"
-            favicon="branding/favicon.ico"
-            body="branding/empty.html">
-       </branding>
-       </extension>
-       
-       <!-- LOCAL THEMES - Use the following to extend or overwrite default theme --> 
-       <!--    <extension
-               point="org.eclipse.rap.ui.themes">
-               <themeContribution
-                       themeId="org.eclipse.rap.rwt.theme.Default"
-                       file="theme/defaultExt.css" /> 
-       </extension> -->
-
-  <!-- <extension point="org.eclipse.ui.menus">
-    <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar">
-        <toolbar id="org.argeo.security.ui.rap.userToolbar">
-           <command
-                 commandId="org.argeo.security.ui.rap.mainMenuCommand"
-                 icon="icons/main.gif"
-                 id="org.argeo.security.ui.rap.mainMenu"
-                 style="pulldown">
-           </command>
-           <command commandId="org.eclipse.ui.file.save"/>
-           <command commandId="org.eclipse.ui.file.saveAll"/>
-        </toolbar>
-     </menuContribution>
-               <menuContribution locationURI="menu:org.argeo.security.ui.rap.mainMenu">
-        <command
-              commandId="org.argeo.security.ui.rap.userMenuCommand"
-              icon="icons/home.gif"
-              id="org.argeo.security.ui.rap.userMenu">
-        </command>
-        <command
-              commandId="org.eclipse.ui.window.preferences"
-              icon="icons/preferences.png"/>
-        <command
-              commandId="org.argeo.security.ui.rap.openChangePasswordDialog"
-              icon="icons/password.gif"
-              label="Change password"/>
-        <separator
-              name="org.argeo.security.ui.rap.beforeFile"
-              visible="true">
-        </separator>
-        <command
-              commandId="org.eclipse.ui.file.closeAll"
-              icon="icons/closeAll.gif"/>
-           <command commandId="org.eclipse.ui.file.save"/>
-           <command commandId="org.eclipse.ui.file.saveAll"/>
-        <separator
-              name="org.argeo.security.ui.rap.beforeExit"
-              visible="true">
-        </separator>
-        <command commandId="org.eclipse.ui.file.exit" icon="icons/exit.png"/>
-     </menuContribution>
-  </extension> -->
-               
-        <!--<command commandId="org.eclipse.ui.views.showView"/>-->
-        <!--<command commandId="org.eclipse.ui.perspectives.showPerspective"/>-->
-
-
        <!-- COMMANDS --> 
        <extension point="org.eclipse.ui.commands">
+               <command
+                       id="org.argeo.security.ui.rap.mainMenuCommand"
+                       defaultHandler="org.argeo.security.ui.rap.commands.OpenHome"
+                       name="Main"> 
+               </command>
                <command
                        id="org.argeo.security.ui.rap.openChangePasswordDialog"
                        defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
                        name="Change Password">
                </command>
-               <command
-                       id="org.argeo.security.ui.rap.mainMenuCommand"
-                       defaultHandler="org.argeo.security.ui.commands.OpenHomePerspective"
-                       name="Main">
-               </command>
-               
-       <!-- Register a default command that enable an "open file" action in a single sourced application  -->  
+               <!-- Enable an "open file" action in a single sourced application  -->  
                <command
                        defaultHandler="org.argeo.eclipse.spring.SpringExtensionFactory"
                        id="org.argeo.security.ui.specific.openFile"
                        </commandParameter>
                </command>
        </extension>
-       <!-- SERVICE HANDLERS --> 
+
+       <!-- MENUS --> 
+       <extension point="org.eclipse.ui.menus">
+       <!-- Main tool bar menu -->
+       <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar">
+               <toolbar id="org.argeo.security.ui.rap.userToolbar">
+                               <command
+                                       commandId="org.argeo.security.ui.rap.mainMenuCommand"
+                                       icon="icons/home.gif"
+                                       id="org.argeo.security.ui.rap.mainMenu"
+                                       style="pulldown">
+                       </command>
+                       <command commandId="org.eclipse.ui.file.save"/>
+                       <command commandId="org.eclipse.ui.file.saveAll"/>
+               </toolbar>
+               </menuContribution>
+               
+               <!-- User drop down default menu -->
+               <menuContribution locationURI="menu:org.argeo.security.ui.rap.mainMenu">
+                       <!-- Managed programmatically in the RapActionBarAdvisor to enable 
+                            the display of the current logged-in user id -->
+                       <command
+                               commandId="org.argeo.security.ui.rap.userMenuCommand"
+                               icon="icons/main.gif"
+                               id="org.argeo.security.ui.rap.userMenu">
+                       </command>
+                       <!-- Still unused
+                       <command
+                               commandId="org.eclipse.ui.window.preferences"
+                               icon="icons/preferences.png"/> -->
+               <command
+                               commandId="org.argeo.security.ui.rap.openChangePasswordDialog"
+                               icon="icons/password.gif"
+                               label="Change password"/>
+                       <separator
+                               name="org.argeo.security.ui.rap.beforeFile"
+                               visible="true">
+                       </separator>
+                       <command
+                               commandId="org.eclipse.ui.file.closeAll"
+                               icon="icons/closeAll.gif"/>
+                       <command commandId="org.eclipse.ui.file.save"/>
+                       <command commandId="org.eclipse.ui.file.saveAll"/>
+       
+                       <!--<command commandId="org.eclipse.ui.views.showView"/>-->
+               <!--<command commandId="org.eclipse.ui.perspectives.showPerspective"/>-->
+       
+                       <separator
+                               name="org.argeo.security.ui.rap.beforeExit"
+                               visible="true">
+                       </separator>
+                       <command commandId="org.eclipse.ui.file.exit" icon="icons/exit.png"/>
+               </menuContribution>
+       </extension>
+               
+    <!-- SERVICE HANDLERS --> 
        <extension point="org.eclipse.rap.ui.serviceHandler">
-               <!-- The required rap specific handler to call the open file command over the internet-->
+               <!-- Rap specific service handler to enable file download over the internet-->
                <serviceHandler
                        class="org.argeo.eclipse.ui.specific.OpenFileService"
                        id="org.argeo.security.ui.specific.openFileService">
                </serviceHandler>
        </extension>
     
+    <!-- ACTIVITIES -->
        <extension
            point="org.eclipse.ui.activities">
         <activity
                    </not>
                  </enabledWhen>
         </activity>
-        <activityPatternBinding
+               <activityPatternBinding
               activityId="org.argeo.security.ui.rap.notAnonymousActivity"
-              pattern="org.argeo.security.ui.rap/org.argeo.security.ui.rap.userMenuCommand"/>
-        <activityPatternBinding
+              pattern="org.argeo.security.ui.rap/org.argeo.security.ui.rap.userMenuCommand"/>         <activityPatternBinding
               activityId="org.argeo.security.ui.rap.notAnonymousActivity"
               pattern="org.argeo.security.ui.rap/org.eclipse.ui.window.preferences"/>
         <activityPatternBinding
               activityId="org.argeo.security.ui.rap.notAnonymousActivity"
               pattern="org.argeo.security.ui.rap/org.argeo.security.ui.rap.openChangePasswordDialog"/>
      </extension>
-</plugin>
+    
+    <!-- BRANDINGS --> 
+     <extension
+         point="org.eclipse.rap.ui.branding">
+       <branding
+                       id="org.argeo.security.ui.rap.defaultBranding"
+            themeId="org.eclipse.rap.rwt.theme.Default"
+            title="Argeo Web UI"
+            favicon="branding/favicon.ico">
+       </branding>
+       <!-- we need a servlet with this name j_spring_security_logout
+                for the logout filter -->
+       <branding
+                       id="org.argeo.security.ui.rap.logoutBranding"
+            title="Argeo Logout"
+            favicon="branding/favicon.ico"
+            body="branding/empty.html">
+       </branding>
+       </extension>
+</plugin>
\ No newline at end of file
index 074b798c7ee42179a36fc68e9e0a7eb1b806d812..f29fc8e4e5b3b7109f22317aa27597d821f1685a 100644 (file)
@@ -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 (file)
index 0000000..37ebe35
--- /dev/null
@@ -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;
+       }
+}
index a530a4e9a85ead9bc03252eb4f71bfd0742738e3..49a6575815fc2a26b600ad470a541b0d944a4bac 100644 (file)
@@ -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);