package version up (2.1.90), Some improvements for 'Command Bar'
authorkh5325.kim <kh5325.kim@samsung.com>
Thu, 5 Sep 2013 09:09:49 +0000 (18:09 +0900)
committerkh5325.kim <kh5325.kim@samsung.com>
Thu, 5 Sep 2013 09:11:09 +0000 (18:11 +0900)
19 files changed:
org.tizen.common.ui/META-INF/MANIFEST.MF
org.tizen.common.ui/OSGI-INF/l10n/bundle.properties
org.tizen.common.ui/build.properties
org.tizen.common.ui/plugin.xml
org.tizen.common.ui/schema/org.tizen.common.ui.commandbar.exsd [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/Command.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/CommandGroup.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/Commands.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/IProjectCreator.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/Messages.java [deleted file]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/StatusBar.java
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/HelpCommand.java
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/ProjectCommand.java
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/QueryCommand.java
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/launcher/CommandLauncher.java
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/textAssist/CommandProvider.java
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/textAssist/TextAssist.java
package/changelog
package/pkginfo.manifest

index 9c1cdfa..7b307c6 100644 (file)
@@ -20,6 +20,7 @@ Import-Package: org.eclipse.core.resources,
  org.tizen.common.project.util,
  org.tizen.common.sign.preferences
 Export-Package: org.tizen.common.ui,
+ org.tizen.common.ui.commandbar,
  org.tizen.common.ui.wizards
 Bundle-ActivationPolicy: lazy
 Bundle-ClassPath: lib/commons-cli-1.2.jar,
index 6b9d436..e2ca0a7 100644 (file)
@@ -2,3 +2,5 @@ Bundle-Vendor = The Linux Foundation
 Bundle-Name = Tizen Common UI
 
 wizard.preferences.name = Wizard
+
+extension-point.commandbar = Command Bar Extension
index 797e860..bebbaca 100644 (file)
@@ -14,4 +14,5 @@ bin.includes = META-INF/,\
                lib/httpclient-4.2.5.jar,\
                lib/httpcore-4.2.4.jar,\
                about.html,\
-               about_files/
+               about_files/,\
+               schema/
index e471be2..7747695 100644 (file)
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
 <?eclipse version="3.4"?>\r
 <plugin>\r
+   <extension-point id="org.tizen.common.ui.commandbar" name="%extension-point.commandbar" schema="schema/org.tizen.common.ui.commandbar.exsd"/>\r
    <extension\r
          point="org.eclipse.ui.commands">\r
       <category\r
diff --git a/org.tizen.common.ui/schema/org.tizen.common.ui.commandbar.exsd b/org.tizen.common.ui/schema/org.tizen.common.ui.commandbar.exsd
new file mode 100644 (file)
index 0000000..2708116
--- /dev/null
@@ -0,0 +1,119 @@
+<?xml version='1.0' encoding='UTF-8'?>\r
+<!-- Schema file written by PDE -->\r
+<schema targetNamespace="org.tizen.common.ui" xmlns="http://www.w3.org/2001/XMLSchema">\r
+<annotation>\r
+      <appinfo>\r
+         <meta.schema plugin="org.tizen.common.ui" id="org.tizen.common.project.adapter" name="Command Bar Extension"/>\r
+      </appinfo>\r
+      <documentation>\r
+         Provides the extension point for the Command Bar.\r
+      </documentation>\r
+   </annotation>\r
+\r
+   <element name="extension">\r
+      <annotation>\r
+         <appinfo>\r
+            <meta.element />\r
+         </appinfo>\r
+      </annotation>\r
+      <complexType>\r
+         <sequence>\r
+            <element ref="projectCreator"/>\r
+         </sequence>\r
+         <attribute name="point" type="string" use="required">\r
+            <annotation>\r
+               <documentation>\r
+                  \r
+               </documentation>\r
+               <appinfo>\r
+                  <meta.attribute kind="java"/>\r
+               </appinfo>\r
+            </annotation>\r
+         </attribute>\r
+         <attribute name="id" type="string">\r
+            <annotation>\r
+               <documentation>\r
+                  \r
+               </documentation>\r
+            </annotation>\r
+         </attribute>\r
+         <attribute name="name" type="string">\r
+            <annotation>\r
+               <documentation>\r
+                  \r
+               </documentation>\r
+               <appinfo>\r
+                  <meta.attribute translatable="true"/>\r
+               </appinfo>\r
+            </annotation>\r
+         </attribute>\r
+      </complexType>\r
+   </element>\r
+\r
+   <element name="projectCreator">\r
+      <complexType>\r
+         <attribute name="class" type="string" use="required">\r
+            <annotation>\r
+               <documentation>\r
+                  \r
+               </documentation>\r
+               <appinfo>\r
+                  <meta.attribute kind="java" basedOn=":org.tizen.common.ui.commandbar.IProjectCreator"/>\r
+               </appinfo>\r
+            </annotation>\r
+         </attribute>\r
+         <attribute name="perspectiveId" type="string" use="required">\r
+            <annotation>\r
+               <documentation>\r
+                  \r
+               </documentation>\r
+            </annotation>\r
+         </attribute>\r
+      </complexType>\r
+   </element>\r
+\r
+   <annotation>\r
+      <appinfo>\r
+         <meta.section type="since"/>\r
+      </appinfo>\r
+      <documentation>\r
+         [Enter the first release in which this extension point appears.]\r
+      </documentation>\r
+   </annotation>\r
+\r
+   <annotation>\r
+      <appinfo>\r
+         <meta.section type="examples"/>\r
+      </appinfo>\r
+      <documentation>\r
+         &lt;extension\r
+        id=&quot;org.tizen.nativecpp.csviewer.crashreporter&quot;\r
+            name=&quot;crashreporter&quot;\r
+            point=&quot;org.tizen.common.crashreporter&quot;&gt;\r
+        &lt;client\r
+            class=&quot;org.tizen.nativecpp.csviewer.CrashReportServiceListener&quot;&gt;\r
+        &lt;/client&gt;\r
+&lt;/extension&gt;\r
+      </documentation>\r
+   </annotation>\r
+\r
+   <annotation>\r
+      <appinfo>\r
+         <meta.section type="apiinfo"/>\r
+      </appinfo>\r
+      <documentation>\r
+         [Enter API information here.]\r
+      </documentation>\r
+   </annotation>\r
+\r
+   <annotation>\r
+      <appinfo>\r
+         <meta.section type="implementation"/>\r
+      </appinfo>\r
+      <documentation>\r
+         [Enter information about supplied implementation of this extension point.]\r
+      </documentation>\r
+   </annotation>\r
+\r
+\r
+</schema>\r
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/Command.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/Command.java
new file mode 100644 (file)
index 0000000..3054144
--- /dev/null
@@ -0,0 +1,66 @@
+/*\r
+ * Common\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Changhyun Lee <changhyun1.lee@samsung.com>\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * BonYong Lee <bonyong.lee@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ *\r
+ */\r
+\r
+package org.tizen.common.ui.commandbar;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+public class Command {\r
+    String command;\r
+    String description;\r
+    Map<String, Object> properties;\r
+\r
+    public Command(String command, String description) {\r
+        this.command = command;\r
+        this.description = description;\r
+        this.properties = new HashMap<String, Object>();\r
+    }\r
+\r
+    public String getCommand() {\r
+        return command;\r
+    }\r
+\r
+    public String getDescription() {\r
+        return description;\r
+    }\r
+\r
+    public Command setProperty(String key, Object value) {\r
+        properties.put(key, value);\r
+        return this;\r
+    }\r
+\r
+    public Object getProperty(String key) {\r
+        return properties.get(key);\r
+    }\r
+\r
+    @Override\r
+    public String toString() {\r
+        return "Command [command=" + command + ", description=" + description + "]";\r
+    }\r
+}\r
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/CommandGroup.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/CommandGroup.java
new file mode 100644 (file)
index 0000000..1956a99
--- /dev/null
@@ -0,0 +1,52 @@
+/*\r
+ * Common\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Changhyun Lee <changhyun1.lee@samsung.com>\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * BonYong Lee <bonyong.lee@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ *\r
+ */\r
+\r
+package org.tizen.common.ui.commandbar;\r
+\r
+import java.util.Collection;\r
+import java.util.LinkedHashMap;\r
+import java.util.Map;\r
+\r
+public class CommandGroup {\r
+    String key;\r
+    Map<String, Command> commandMap;\r
+\r
+    public CommandGroup(String key) {\r
+        this.key = key;\r
+        commandMap = new LinkedHashMap<String, Command>();\r
+    }\r
+\r
+    public CommandGroup addCommand(Command command) {\r
+        commandMap.put(command.getCommand(), command);\r
+        return this;\r
+    }\r
+\r
+    public Collection<Command> getCommands() {\r
+        return commandMap.values();\r
+    }\r
+}\r
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/Commands.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/Commands.java
new file mode 100644 (file)
index 0000000..1335547
--- /dev/null
@@ -0,0 +1,173 @@
+/*\r
+ * Common\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Changhyun Lee <changhyun1.lee@samsung.com>\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * BonYong Lee <bonyong.lee@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ *\r
+ */\r
+\r
+package org.tizen.common.ui.commandbar;\r
+\r
+import java.util.ArrayList;\r
+import java.util.LinkedHashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+public class Commands {\r
+    private Map<String, CommandGroup> commandGroups;\r
+    private List<String[]> help;\r
+\r
+    private static Commands _instance = new Commands();\r
+\r
+    public final static String IDENTIFIER_SYSTEM_COMMAND = "#";\r
+    public final static String HELP_COMMAND = "help";\r
+    public final static String PROJECT_COMMAND = "@";\r
+    public final static String QUERY_COMMAND = "query";\r
+    public final static String SDB_COMMAND = "sdb";\r
+        public final static String[] SDB_COMMANDS = {\r
+            "kill-server",\r
+            "start-server",\r
+            "forward",\r
+            "uninstall",\r
+            "install",\r
+            "shell",\r
+            "disconnect",\r
+            "connect",\r
+            "devices"\r
+        };\r
+    public final static String SHOW_COMMAND = "show";\r
+    public final static String SYSTEM_COMMAND = "system";\r
+    public final static String TIME_COMMAND = "time";\r
+\r
+    public final static int QUERY_COMMAND_MAX_ANSWERS = 3;\r
+\r
+    public static Commands getInstance() {\r
+        return _instance;\r
+    }\r
+\r
+    /*\r
+    public static final String[][] HELP = new String[][] {\r
+        { "help",                  "Show available commands" },\r
+        { "@<project>",            "View the project properties" },\r
+        { "@<project> build",      "Build the project incrementally" },\r
+        { "@<project> create",     "Create the project by the active perspective" },\r
+        { "@<project> tizen",      "View the project [Tizen Settings] properties" },\r
+        { "#<cmd>",                "Run system command" },\r
+        { "query <query>",         "View the instant coding answers from http://stackoverflow.com" },\r
+        { "query --tizen <query>", "View the instant answers from https://developer.tizen.org" },\r
+        { "sdb <cmd>",             "Run sdb command" },\r
+        { "show --sign",           "Show the signing preferences dialog" },\r
+        { "time",                  "Start the timer" },\r
+        { "time --end",            "Stop the timer to see the elapsed time after starting it" }\r
+    };\r
+\r
+    public static List<String[]> getProjectHelp() {\r
+        List<String[]> list = new ArrayList<String[]>();\r
+        for (final String[] message : HELP) {\r
+            if (message[0].startsWith(PROJECT_COMMAND)) {\r
+                list.add(message);\r
+            }\r
+        }\r
+        return list;\r
+    }\r
+    */\r
+\r
+    Commands() {\r
+        commandGroups = new LinkedHashMap<String, CommandGroup>();\r
+\r
+        createCommandGroup("help")\r
+            .addCommand(createCommand("help",                  "Show available commands"));\r
+        createCommandGroup(PROJECT_COMMAND)\r
+            .addCommand(createCommand("@<project>",            "View the project properties").setProperty("projectExists", true))\r
+            .addCommand(createCommand("@<project> build",      "Build the project incrementally").setProperty("projectExists", true))\r
+            .addCommand(createCommand("@<project> create",     "Create the project by the active perspective").setProperty("projectExists", false))\r
+            .addCommand(createCommand("@<project> tizen",      "View the project [Tizen Settings] properties").setProperty("projectExists", true));\r
+        createCommandGroup(SYSTEM_COMMAND)\r
+            .addCommand(createCommand("#<cmd>",                "Run system command"));\r
+        createCommandGroup(QUERY_COMMAND)\r
+            .addCommand(createCommand("query <query>",         "View the instant coding answers from http://stackoverflow.com"))\r
+            .addCommand(createCommand("query --tizen <query>", "View the instant answers from https://developer.tizen.or"));\r
+        createCommandGroup(SDB_COMMAND)\r
+            .addCommand(createCommand("sdb <cmd>",             "Run sdb command"));\r
+        createCommandGroup(SHOW_COMMAND)\r
+            .addCommand(createCommand("show --sign",           "Show the signing preferences dialog"));\r
+        createCommandGroup(TIME_COMMAND)\r
+            .addCommand(createCommand("time",                  "Start the timer"))\r
+            .addCommand(createCommand("time --end",            "Stop the timer to see the elapsed time after starting it"));\r
+    }\r
+\r
+    public List<String[]> getHelp() {\r
+        if (help != null)\r
+            return help;\r
+\r
+        help = new ArrayList<String[]>();\r
+        for (CommandGroup commandGroup : commandGroups.values()) {\r
+            for (Command command : commandGroup.getCommands()) {\r
+                help.add(new String[] { command.getCommand(), command.getDescription() });\r
+            }\r
+        }\r
+        return help;\r
+    }\r
+\r
+    public List<String[]> getHelp(String key) {\r
+        return getHelp(key, null, null);\r
+    }\r
+\r
+    public List<String[]> getHelp(String key, String propertyKey, Object propertyValue) {\r
+        if (propertyKey == null && propertyValue != null)\r
+            throw new UnsupportedOperationException();\r
+\r
+        List<String[]> help = new ArrayList<String[]>();\r
+        CommandGroup commandGroup = commandGroups.get(key);\r
+        if (commandGroup != null) {\r
+            for (Command command : commandGroup.getCommands()) {\r
+                if (propertyKey == null || (propertyValue.equals(command.getProperty(propertyKey)))) {\r
+                    help.add(new String[] { command.getCommand(), command.getDescription() });\r
+                }\r
+            }\r
+        }\r
+        return help;\r
+    }\r
+\r
+    CommandGroup createCommandGroup(String key) {\r
+        CommandGroup commandGroup = new CommandGroup(key);\r
+        commandGroups.put(key, commandGroup);\r
+        return commandGroup;\r
+        \r
+    }\r
+\r
+    Command createCommand(String command, String description) {\r
+        Command c = new Command(command, description);\r
+        return c;\r
+    }\r
+\r
+    public int getArgumentStartIndex(String s) {\r
+        for (String[] commands : getHelp()) {\r
+            String command = commands[0];\r
+            if (s.equals(command)) {\r
+                return s.indexOf('<');\r
+            }\r
+        }\r
+        return -1;\r
+    }\r
+}\r
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/IProjectCreator.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/IProjectCreator.java
new file mode 100644 (file)
index 0000000..89fe6d6
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * 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.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.ui.commandbar;
+
+/**
+ * Interface about create the project programmatically.
+ * @author mariah
+ *
+ */
+public interface IProjectCreator {
+    public void createProject(String name);
+}
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/Messages.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/Messages.java
deleted file mode 100644 (file)
index 3e785e0..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*\r
- * Common\r
- *\r
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
- *\r
- * Contact:\r
- * Changhyun Lee <changhyun1.lee@samsung.com>\r
- * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
- * BonYong Lee <bonyong.lee@samsung.com>\r
- * Kangho Kim <kh5325.kim@samsung.com>\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *\r
- * Contributors:\r
- * - S-Core Co., Ltd\r
- *\r
- */\r
-\r
-package org.tizen.common.ui.commandbar;\r
-\r
-public class Messages {\r
-    public final static String IDENTIFIER_RESERVED = "@";\r
-    public final static String IDENTIFIER_SYSTEM_COMMAND = "#";\r
-    public final static String PROJECT_COMMAND = "@<project>";\r
-    public final static String IDENTIFIER_QUERY_COMMAND = "query";\r
-    public final static String SDB_COMMAND = "sdb";\r
-    public final static String[] SDB_COMMANDS = {\r
-        "kill-server",\r
-        "start-server",\r
-        "forward",\r
-        "uninstall",\r
-        "install",\r
-        "shell",\r
-        "disconnect",\r
-        "connect",\r
-        "devices"\r
-    };\r
-\r
-    public final static int QUERY_COMMAND_MAX_ANSWERS = 3;\r
-\r
-    public static final String[][] HELP = new String[][] {\r
-        { "help",                  "Show available commands" },\r
-        { "@<project>",            "View the project properties" },\r
-        { "@<project> build",      "Build the project incrementally" },\r
-        { "@<project> tizen",      "View the project [Tizen Settings] properties" },\r
-        { "#<cmd>",                "Run system command" },\r
-        { "query <query>",         "View the instant coding answers from http://stackoverflow.com" },\r
-        { "query --tizen <query>", "View the instant answers from https://developer.tizen.org" },\r
-        { "sdb <cmd>",             "Run sdb command" },\r
-        { "show --sign",           "Show the signing preferences dialog" },\r
-        { "time",                  "Start the timer" },\r
-        { "time --end",            "Stop the timer to see the elapsed time after starting it" }\r
-    };\r
-\r
-    public static int getArgumentStartIndex(String s) {\r
-        for (String[] commands : HELP) {\r
-            String command = commands[0];\r
-            if (s.equals(command)) {\r
-                return s.indexOf('<');\r
-            }\r
-        }\r
-        return -1;\r
-    }\r
-}\r
index aff7d9c..070e77d 100644 (file)
@@ -32,12 +32,10 @@ import static org.eclipse.swt.SWT.BOTTOM;
 import static org.eclipse.swt.SWT.NONE;\r
 import static org.eclipse.swt.SWT.TOP;\r
 \r
-import java.util.ArrayList;\r
 import java.util.List;\r
 \r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.custom.StyledText;\r
-import org.eclipse.swt.graphics.Image;\r
 import org.eclipse.swt.layout.RowData;\r
 import org.eclipse.swt.layout.RowLayout;\r
 import org.eclipse.swt.widgets.Composite;\r
@@ -88,10 +86,10 @@ public class StatusBar extends AbstractWorkbenchTrimWidget implements SubmitList
         fComposite.setLayout(layout);\r
 \r
         Label icon = new Label(fComposite, SWT.NONE);\r
-        icon.setImage(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/commandbar_x32.png").createImage());\r
+        icon.setImage(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/commandbar_x24.png").createImage());\r
         icon.setToolTipText("Command Bar for your convenience. What could I do for you?");\r
-        Label glue = new Label(fComposite, SWT.NONE);\r
-        glue.setLayoutData(new RowData(2, -1));\r
+        //Label glue = new Label(fComposite, SWT.NONE);\r
+        //glue.setLayoutData(new RowData(2, -1));\r
         final TextAssistContentProvider contentProvider = new CommandProvider();\r
         fTxtAssist = new TextAssist(fComposite, SWT.SINGLE, contentProvider);\r
         fTxtAssist.setLayoutData(getRowData(newSide));\r
@@ -130,9 +128,9 @@ public class StatusBar extends AbstractWorkbenchTrimWidget implements SubmitList
             { "Welcome to Command Bar", "" },\r
             { "", "Just hit 'help' to see what you can do" }\r
         };\r
-        List<Image> imageList = new ArrayList<Image>();\r
+        //List<Image> imageList = new ArrayList<Image>();\r
         //imageList.add(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/commandbar_x24.png").createImage());\r
-        fTxtAssist.showPopup(imageList, (List<String[]>) CollectionUtil.asList(welcomeMessage));\r
+        fTxtAssist.showPopup((List<String[]>) CollectionUtil.asList(welcomeMessage));\r
         fTxtAssist.setFocus();\r
     }\r
 \r
@@ -150,7 +148,7 @@ public class StatusBar extends AbstractWorkbenchTrimWidget implements SubmitList
     @Override\r
     public void onSubmit(String text) {\r
         // Select <query> in case "query --tizen <query>"\r
-        int start = Messages.getArgumentStartIndex(text);\r
+        int start = Commands.getInstance().getArgumentStartIndex(text);\r
         if (start != -1) {\r
             fTxtAssist.getTextControl().setSelection(start, text.length());\r
             return; // And just return not to execute the command\r
index fc6eb8b..446a8c7 100644 (file)
 
 package org.tizen.common.ui.commandbar.command;
 
-import java.util.List;
-
 import org.tizen.common.core.command.AbstractCommand;
 import org.tizen.common.core.command.ExecutionContext;
 import org.tizen.common.core.command.Executor;
-import org.tizen.common.ui.commandbar.Messages;
+import org.tizen.common.ui.commandbar.Commands;
 import org.tizen.common.ui.commandbar.StatusBar;
-import org.tizen.common.util.CollectionUtil;
 
 public class HelpCommand extends AbstractCommand<Object> {
     StatusBar status;
@@ -45,6 +42,6 @@ public class HelpCommand extends AbstractCommand<Object> {
     }
 
     public void run(final Executor executor, final ExecutionContext context) throws Exception {
-        status.showPopup((List<String[]>) CollectionUtil.asList(Messages.HELP));
+        status.showPopup(Commands.getInstance().getHelp());
     }
 }
index 122770c..587c7df 100644 (file)
@@ -31,45 +31,81 @@ package org.tizen.common.ui.commandbar.command;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IncrementalProjectBuilder;
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.RegistryFactory;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.console.IConsoleConstants;
+import org.eclipse.ui.console.MessageConsoleStream;
+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
 import org.eclipse.ui.internal.dialogs.PropertyDialog;
-import org.tizen.common.core.command.AbstractCommand;
+import org.eclipse.ui.progress.UIJob;
+import org.eclipse.ui.wizards.IWizardDescriptor;
 import org.tizen.common.core.command.ExecutionContext;
 import org.tizen.common.core.command.Executor;
-import org.tizen.common.ui.commandbar.Messages;
+import org.tizen.common.ui.commandbar.IProjectCreator;
+import org.tizen.common.ui.commandbar.Commands;
+import org.tizen.common.ui.view.console.ConsoleManager;
 import org.tizen.common.util.ProjectUtil;
 import org.tizen.common.util.SWTUtil;
 import org.tizen.common.util.ViewUtil;
 
-public class ProjectCommand extends AbstractCommand<Object> {
+public class ProjectCommand extends ConsoleCommand {
+    ConsoleManager consoleManager = new ConsoleManager(CONSOLE_NAME, true);
+    MessageConsoleStream messageStream = consoleManager.getMessageConsoleStream();
+
     public void run(final Executor executor, final ExecutionContext context) throws Exception {
         final String[] args = (String[]) context.getValue("args");
         runProjectCommand(args);
     }
 
+    private boolean checkProject(IProject project) {
+        if (project == null) {
+            return false;
+        }
+        else if (!project.isAccessible()) {
+            messageStream.println(String.format("A project '%s' does not exist.", project.getName()));
+            return false;
+        }
+        return true;
+    }
+
     private void runProjectCommand(String[] args) {
-        String name = args[0].substring(Messages.IDENTIFIER_RESERVED.length());
+        String name = args[0].substring(Commands.PROJECT_COMMAND.length());
         final IProject project = ProjectUtil.getProject(name);
-        if (project == null || !project.isAccessible())
-            return;
         String opt = (args.length > 1) ? args[1] : null;
         if (opt == null) {
             showPropertyDialog(project, null);
         } else {
+            //ViewUtil.showView(IConsoleConstants.ID_CONSOLE_VIEW, false);
+            consoleManager.showConsoleView();
             if ("build".equals(opt)) {
                 buildProject(project);
             }
             else if ("tizen".equals(opt)) {
                 showPropertyDialog(project, "org.tizen.nativecommon.build.ui.TizenSettingsPage");
             }
+            else if ("create".equals(opt)) {
+                createProject(name);
+            }
         }
     }
 
-
     private void buildProject(final IProject project) {
-        ViewUtil.showView(IConsoleConstants.ID_CONSOLE_VIEW, false);
+        if (!checkProject(project))
+            return;
+
         SWTUtil.asyncExec(new Runnable() {
             @Override
             public void run() {
@@ -83,6 +119,9 @@ public class ProjectCommand extends AbstractCommand<Object> {
     }
 
     private void showPropertyDialog(final IProject project, String initialPageId) {
+        if (!checkProject(project))
+            return;
+
         /*
         String commandId = "org.eclipse.ui.file.properties";
         IHandlerService handlerService = (IHandlerService) ViewUtil.getWorkbenchWindow().getService(IHandlerService.class);
@@ -112,6 +151,75 @@ public class ProjectCommand extends AbstractCommand<Object> {
         */
         PropertyDialog dialog = PropertyDialog.createDialogOn(SWTUtil.getShell(), initialPageId, new StructuredSelection(new Object[] { project }));
         dialog.open();
-        
+    }
+
+    private void openWizardDialog(final String name) throws Exception {
+        IWizardDescriptor descriptor = PlatformUI.getWorkbench().getNewWizardRegistry().findWizard("org.tizen.web.project.wizard.webapp");
+        if (descriptor != null) {
+            final IWizard wizard = descriptor.createWizard();
+            WizardDialog wd = new WizardDialog(SWTUtil.getActiveShell(), wizard) {
+                @Override
+                protected Control createContents(Composite parent) {
+                    Control c = super.createContents(parent);
+                    IWizardPage page = wizard.getStartingPage();
+                    if (page instanceof WizardNewProjectCreationPage) {
+                        ((WizardNewProjectCreationPage) page).setInitialProjectName(name);
+                    }
+                    return c;
+                }
+            };
+            wd.setTitle(wizard.getWindowTitle());
+            wd.open();
+        }
+    }
+
+    private void createProject(final String name) {
+        if (ProjectUtil.getProject(name).exists()) {
+            messageStream.println(String.format("A project '%s' already exists.", name));
+            return;
+        }
+
+        try {
+            String activePerspectiveId = SWTUtil.getActivePerspectiveId();
+
+            IProjectCreator creator = null;
+            IExtensionRegistry x = RegistryFactory.getRegistry();
+            IConfigurationElement[] ces = x.getConfigurationElementsFor("org.tizen.common.ui.commandbar");
+            for (IConfigurationElement ce : ces) {
+                if ("projectCreator".equals(ce.getName())) {
+                    String className = ce.getAttribute("class");
+                    if (className == null)
+                        continue;
+                    String perspectiveId = ce.getAttribute("perspectiveId");
+                    if (perspectiveId == null)
+                        continue;
+                    if (perspectiveId.equals(activePerspectiveId)) { // "org.tizen.web.ui.perspective.WebWidget"
+                        Object obj = ce.createExecutableExtension("class");
+                        if (obj instanceof IProjectCreator) {
+                            creator = (IProjectCreator) obj;
+                            break;
+                        }
+                    }
+                }
+            }
+
+            if (creator != null) {
+                final IProjectCreator projectCreator = creator;
+                messageStream.println(String.format("Creating web project '%s'...", name));
+                UIJob job = new UIJob("ProjectCommand") {
+                    @Override
+                    public IStatus runInUIThread(IProgressMonitor monitor) {
+                        projectCreator.createProject(name);
+                        messageStream.println("Created successfully");
+                        return Status.OK_STATUS;
+                    }
+                };
+                job.schedule();
+            } else {
+                messageStream.println(String.format("Sorry, not implemented yet for the perspective '%s'.", activePerspectiveId));
+            }
+        } catch (Exception e) {
+            messageStream.println("Failed to create a project: " + e.getMessage());
+        }
     }
 }
index 1db8530..99c7de5 100644 (file)
@@ -43,7 +43,7 @@ import org.eclipse.ui.console.MessageConsole;
 import org.eclipse.ui.console.MessageConsoleStream;
 import org.tizen.common.core.command.ExecutionContext;
 import org.tizen.common.core.command.Executor;
-import org.tizen.common.ui.commandbar.Messages;
+import org.tizen.common.ui.commandbar.Commands;
 import org.tizen.common.ui.commandbar.command.launcher.HyperlinkPatternMatchLinstener;
 import org.tizen.common.ui.commandbar.command.launcher.TizenHandler;
 import org.tizen.common.ui.view.console.ConsoleManager;
@@ -70,7 +70,7 @@ public class QueryCommand extends ConsoleCommand {
                 List<String> opts = new ArrayList<String>();
                 // howdoi --num-answers 3 format date bash
                 opts.add("--num-answers");
-                opts.add("" + Messages.QUERY_COMMAND_MAX_ANSWERS);
+                opts.add("" + Commands.QUERY_COMMAND_MAX_ANSWERS);
 
                 String[] args = cmdLine.getArgs();
                 if (cmdLine.hasOption("tizen")) {
@@ -89,6 +89,6 @@ public class QueryCommand extends ConsoleCommand {
                 return Status.OK_STATUS;
             }
         };
-        job.schedule(); 
+        job.schedule();
     }
 }
index d7dcf95..be2fc87 100644 (file)
@@ -40,7 +40,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;\r
 import org.tizen.cli.exec.AbstractLauncher;\r
 import org.tizen.common.CommonPlugin;\r
-import org.tizen.common.ui.commandbar.Messages;\r
+import org.tizen.common.ui.commandbar.Commands;\r
 import org.tizen.common.ui.commandbar.StatusBar;\r
 import org.tizen.common.ui.commandbar.command.HelpCommand;\r
 import org.tizen.common.ui.commandbar.command.ProjectCommand;\r
@@ -68,7 +68,7 @@ public class CommandLauncher extends AbstractLauncher {
 \r
     public void launchCommand(String[] args) throws Exception {\r
         if (!ArrayUtil.isEmpty(args)) {\r
-            if (args[0].startsWith(Messages.IDENTIFIER_SYSTEM_COMMAND)) {\r
+            if (args[0].startsWith(Commands.IDENTIFIER_SYSTEM_COMMAND)) {\r
                 // org.apache.commons.cli has parsing error for '#ls -l'\r
                 // E: Invalid usage [Missing argument for option: l]\r
                 try {\r
@@ -101,13 +101,13 @@ public class CommandLauncher extends AbstractLauncher {
 \r
     private void executeImpl(CommandLine cmdLine, String cmd, String[] args) throws Exception {\r
         logger.info(String.format("execute (args - %s, inputCmd - %s)", Arrays.toString(args), cmd));\r
-        AbstractCommand command = getCommand(cmd, cmdLine.getOptions());\r
+        AbstractCommand command = getCommand(cmd, (cmdLine == null) ? null : cmdLine.getOptions());\r
         if (command == null) {\r
-            if (args[0].startsWith(Messages.IDENTIFIER_RESERVED)) {\r
+            if (args[0].startsWith(Commands.PROJECT_COMMAND)) {\r
                 command = new ProjectCommand();\r
             }\r
-            else if (args[0].startsWith(Messages.IDENTIFIER_SYSTEM_COMMAND)) {\r
-                final String systemCmd = args[0].substring(Messages.IDENTIFIER_SYSTEM_COMMAND.length());\r
+            else if (args[0].startsWith(Commands.IDENTIFIER_SYSTEM_COMMAND)) {\r
+                final String systemCmd = args[0].substring(Commands.IDENTIFIER_SYSTEM_COMMAND.length());\r
                 args = (String[]) ArrayUtil.prepend(ArrayUtil.remove(args, 0), systemCmd);\r
                 command = new SystemCommand();\r
             }\r
@@ -144,14 +144,14 @@ public class CommandLauncher extends AbstractLauncher {
     @Override\r
     protected Options getCommands() {\r
         Options result = super.getCommands();\r
-        addOption(result, OptionBuilder.hasArg(false).create("help"), new HelpCommand(status));\r
+        addOption(result, OptionBuilder.hasArg(false).create(Commands.HELP_COMMAND), new HelpCommand(status));\r
         // TODO: need to use custom OptionValidator?\r
         // opt contains illegal character value '@'\r
         //result.addOption(OptionBuilder.hasArg(true).create("@q"));\r
-        addOption(result, OptionBuilder.hasArg(true).create("query"), new QueryCommand());\r
-        result.addOption(OptionBuilder.hasArg(true).create("show"));\r
-        addOption(result, OptionBuilder.hasArg(true).create("sdb"), new SdbCommand());\r
-        addOption(result, OptionBuilder.hasArg(true).create("time"), new TimeStartCommand());\r
+        addOption(result, OptionBuilder.hasArg(true).create(Commands.QUERY_COMMAND), new QueryCommand());\r
+        result.addOption(OptionBuilder.hasArg(true).create(Commands.SHOW_COMMAND));\r
+        addOption(result, OptionBuilder.hasArg(true).create(Commands.SDB_COMMAND), new SdbCommand());\r
+        addOption(result, OptionBuilder.hasArg(true).create(Commands.TIME_COMMAND), new TimeStartCommand());\r
         return result;\r
     }\r
 \r
@@ -161,7 +161,7 @@ public class CommandLauncher extends AbstractLauncher {
         //result.addOption(OptionBuilder.hasArg().withLongOpt("name").withDescription("name").create("n"));\r
         if ("show".equals(getInputCmd()))\r
             addOption(result, OptionBuilder.hasArg(false).create("sign"), new ShowSignCommand());\r
-        else if (Messages.IDENTIFIER_QUERY_COMMAND.equals(getInputCmd()))\r
+        else if (Commands.QUERY_COMMAND.equals(getInputCmd()))\r
             result.addOption(OptionBuilder.hasArg(false).create("tizen"));\r
         else if ("time".equals(getInputCmd())) {\r
             addOption(result, OptionBuilder.hasArg(false).create("end"), new TimeEndCommand());\r
index 30a40eb..9fa02af 100644 (file)
@@ -33,58 +33,95 @@ import java.util.List;
 import java.util.regex.Matcher;\r
 import java.util.regex.Pattern;\r
 \r
-import org.tizen.common.ui.commandbar.Messages;\r
+import org.eclipse.core.resources.IProject;\r
+import org.eclipse.core.resources.ResourcesPlugin;\r
+import org.tizen.common.ui.commandbar.Commands;\r
+import org.tizen.common.util.ProjectUtil;\r
 \r
 \r
 public class CommandProvider extends TextAssistContentProvider {\r
     Pattern PROJECT_COMMAND_PATTERN = Pattern.compile("(@[\\w]+)(\\s.*)*");\r
-    Pattern SDB_COMMAND_PATTERN = Pattern.compile("(" + Messages.SDB_COMMAND + ")(\\s.*)*");\r
+    Pattern SDB_COMMAND_PATTERN = Pattern.compile("(" + Commands.SDB_COMMAND + ")(\\s.*)*");\r
 \r
     @Override\r
     public List<String[]> getContent(final String entry) {\r
-        final List<String[]> returnedList = new ArrayList<String[]>();\r
-\r
+        List<String[]> returnedList = new ArrayList<String[]>();\r
         String key = entry.toLowerCase();\r
-        for (final String[] message : Messages.HELP) {\r
+        // Propose all the accessible projects for the query '@'\r
+        if (key.equals(Commands.PROJECT_COMMAND)) {\r
+            returnedList.addAll(getProjectList(""));\r
+        }\r
+        else if (key.startsWith(Commands.PROJECT_COMMAND)) {\r
+            // "@prj1 " -> group2 [ ], "@prj1 build" -> group2 [ build]\r
+            Matcher m = PROJECT_COMMAND_PATTERN.matcher(key);\r
+            if (m.find()) {\r
+                String atProjectName = m.group(1);\r
+                String projectName = atProjectName.substring(Commands.PROJECT_COMMAND.length());\r
+\r
+                boolean hasArg = m.group(2) != null; // @prj1 build\r
+                boolean projectExists = ProjectUtil.getProject(projectName).exists();\r
+                if (!hasArg)\r
+                    returnedList.addAll(getProjectList(projectName));\r
+                for (final String[] message : Commands.getInstance().getHelp(Commands.PROJECT_COMMAND, "projectExists", projectExists)) {\r
+                    if (hasArg) {\r
+                        // @prj1 build\r
+                        String arg = m.group(2).trim();\r
+                        if (replace(message[0], "").trim().startsWith(arg)) {\r
+                            returnedList.add(new String[] { replace(message[0], atProjectName), message[1] });\r
+                        }\r
+                    } else {\r
+                        // @prj1\r
+                        returnedList.add(new String[] { replace(message[0], atProjectName), message[1] });\r
+                    }\r
+                }\r
+            }\r
+        }\r
+        else {\r
+            returnedList.addAll(getHelpContent(key));\r
+        }\r
+        return returnedList;\r
+    }\r
+\r
+    private String replace(String s, String replacement) {\r
+        return s.replaceAll("@<.*>", replacement);\r
+    }\r
+\r
+    private List<String[]> getProjectList(String key) {\r
+        List<String[]> returnedList = new ArrayList<String[]>();\r
+        IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();\r
+        for (IProject project : projects) {\r
+            String projectName = project.getName();\r
+            if (project.isAccessible() && projectName.startsWith(key)) {\r
+                returnedList.add(new String[] { Commands.PROJECT_COMMAND + projectName, "" });\r
+            }\r
+        }\r
+        return returnedList;\r
+    }\r
+\r
+    private List<String[]> getHelpContent(String key) {\r
+        final List<String[]> returnedList = new ArrayList<String[]>();\r
+        for (final String[] message : Commands.getInstance().getHelp()) {\r
             if (message[0].toLowerCase().startsWith(key)) {\r
                 returnedList.add(message);\r
             }\r
-            if (message[0].toLowerCase().startsWith(Messages.SDB_COMMAND)) {\r
+            if (message[0].toLowerCase().startsWith(Commands.SDB_COMMAND)) {\r
                 Matcher m = SDB_COMMAND_PATTERN.matcher(key);\r
                 if (m.find()) {\r
                     String sdbCommand = m.group(1);\r
                     if (m.group(2) != null) {\r
                         String cmdKey = m.group(2).trim();\r
-                        for (String cmd : Messages.SDB_COMMANDS) {\r
+                        for (String cmd : Commands.SDB_COMMANDS) {\r
                             if (cmd.startsWith(cmdKey)) {\r
                                 returnedList.add(new String[] { sdbCommand + " " + cmd, "" });\r
                             }\r
                         }\r
                     } else {\r
-                        for (String cmd : Messages.SDB_COMMANDS) {\r
+                        for (String cmd : Commands.SDB_COMMANDS) {\r
                             returnedList.add(new String[] { sdbCommand + " " + cmd, "" });\r
                         }\r
                     }\r
                 }\r
             }\r
-\r
-            // "@prj1 " -> group2 [ ], "@prj1 build" -> group2 [ build]\r
-            Matcher m = PROJECT_COMMAND_PATTERN.matcher(key);\r
-            if (m.find()) {\r
-                String atProjectName = m.group(1);\r
-                if (message[0].startsWith(Messages.PROJECT_COMMAND)) {\r
-                    if (m.group(2) != null) {\r
-                        // @prj1 build\r
-                        String arg = m.group(2).trim();\r
-                        if (message[0].startsWith(Messages.PROJECT_COMMAND + " " + arg)) {\r
-                            returnedList.add(new String[] { message[0].replace(Messages.PROJECT_COMMAND, atProjectName), message[1] });\r
-                        }\r
-                    } else {\r
-                        // @prj1\r
-                        returnedList.add(new String[] { message[0].replace(Messages.PROJECT_COMMAND, atProjectName), message[1] });\r
-                    }\r
-                }\r
-            }\r
         }\r
 \r
         return returnedList;\r
index e8cc18c..e473600 100644 (file)
@@ -13,7 +13,6 @@ package org.tizen.common.ui.commandbar.textAssist;
 \r
 import java.util.ArrayList;\r
 import java.util.List;\r
-import java.util.Stack;\r
 \r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.SWTException;\r
@@ -24,7 +23,6 @@ import org.eclipse.swt.events.VerifyListener;
 import org.eclipse.swt.graphics.Color;\r
 import org.eclipse.swt.graphics.Font;\r
 import org.eclipse.swt.graphics.FontData;\r
-import org.eclipse.swt.graphics.FontMetrics;\r
 import org.eclipse.swt.graphics.GC;\r
 import org.eclipse.swt.graphics.Image;\r
 import org.eclipse.swt.graphics.Point;\r
@@ -65,10 +63,11 @@ public class TextAssist extends Composite {
     private TableColumn column1, column2;\r
     private List<SubmitListener> submitListenerList = new ArrayList<SubmitListener>();\r
     private List<TableSelectionListener> tableSelectionListenerList = new ArrayList<TableSelectionListener>();\r
-    // TODO: make persistent\r
+    /*\r
     private int MAX_HISTORY = 5;\r
     private Stack<String> historyStack;\r
     private int historyPos;\r
+    */\r
     static Image oldImage;\r
 \r
     private static final int STATE_TABLE_UNFOCUSED = 0;\r
@@ -127,7 +126,7 @@ public class TextAssist extends Composite {
         this.popup.setLayout(new FillLayout());\r
         this.table = new Table(this.popup, SWT.SINGLE);\r
 \r
-        this.text.addListener(SWT.KeyDown, createKeyDownListener());\r
+        this.text.addListener(SWT.KeyDown, createKeyDownInTextListener());\r
         this.text.addListener(SWT.Modify, createModifyListener());\r
         this.text.addListener(SWT.FocusOut, createFocusOutListener());\r
 \r
@@ -166,55 +165,24 @@ public class TextAssist extends Composite {
         HELP_COMMAND_FONT = deriveFont(table.getFont(), SWT.BOLD);\r
         HELP_COMMAND_DESC_COLOR = new Color(Display.getDefault(), 153, 153, 153);\r
         HELP_SEPARATOR_COLOR = new Color(Display.getDefault(), 229, 229, 229);\r
-        final int itemHeight = table.getItemHeight();\r
-        GC gc = new GC(table);\r
-        FontMetrics metrics = gc.getFontMetrics();\r
-        final int fontHeight = metrics.getHeight();\r
-        table.addListener(SWT.MeasureItem, new Listener() {\r
-            public void handleEvent(Event event) {\r
-                TableItem item = (TableItem) event.item;\r
-                event.height = (int) (event.gc.getFontMetrics().getHeight() * 1.5);\r
-\r
-                Image image = (Image) item.getData();\r
-                if (image != null && event.index == 0) {\r
-                    event.width += image.getBounds().width + TEXT_MARGIN;\r
-                    event.height = Math.max(event.height, image.getBounds().height);\r
-                }\r
-            }\r
-        });\r
+        //final int itemHeight = table.getItemHeight();\r
+        //GC gc = new GC(table);\r
+        //FontMetrics metrics = gc.getFontMetrics();\r
+        //final int fontHeight = metrics.getHeight();\r
         table.addListener(SWT.PaintItem, new Listener() {\r
             public void handleEvent(Event event) {\r
                 TableItem item = (TableItem) event.item;\r
                 Rectangle rect = item.getBounds(event.index);\r
                 int y = rect.y + rect.height - 1;\r
                 boolean lastItem = (Boolean) ObjectUtil.nvl(item.getData("lastItem"), false);\r
-\r
-                Color oldColor = event.gc.getForeground();\r
-                Image image = (Image) item.getData();\r
-                if (!lastItem && (image == null)) {\r
+                if (!lastItem) {\r
                     event.gc.setForeground(HELP_SEPARATOR_COLOR);\r
                     event.gc.setLineWidth(1);\r
                     event.gc.drawLine(rect.x, y, rect.x + rect.width, y);\r
                 }\r
-                if (image != null && event.index == 0) {\r
-                    int x = event.x;\r
-                    event.gc.drawImage(image, x, event.y);\r
-                    x += image.getBounds().width + TEXT_MARGIN;\r
-                    event.gc.setForeground(oldColor);\r
-                    event.gc.setFont(HELP_COMMAND_FONT);\r
-                    event.gc.drawString(item.getText(event.index), x, event.y + (itemHeight - fontHeight) / 2);\r
-                }\r
-            }\r
-        });\r
-        table.addListener(SWT.EraseItem, new Listener() {\r
-            public void handleEvent(Event event) {\r
-                TableItem item = (TableItem) event.item;\r
-                Image image = (Image) item.getData();\r
-                if (image != null && event.index == 0) {\r
-                    event.detail &= ~SWT.FOREGROUND;\r
-                }\r
             }\r
         });\r
+\r
         // In the text widget in status bar, Copy and Paste works or doesn't work by which view is active.\r
         // For example,\r
         //  it works when Connection Explorer view is selected (org.eclipse.ui.internal.handlers.WidgetMethodHandler)\r
@@ -263,7 +231,7 @@ public class TextAssist extends Composite {
         column1 = new TableColumn(table, SWT.NONE);\r
         column2 = new TableColumn(table, SWT.NONE);\r
 \r
-        historyStack = new Stack<String>();\r
+        //historyStack = new Stack<String>();\r
     }\r
 \r
     @Override\r
@@ -291,19 +259,18 @@ public class TextAssist extends Composite {
     private void handleArrowKey(int index, final Event event, boolean doit) {\r
         TextAssist.this.table.setSelection(index);\r
         //TextAssist.this.table.setFocus();\r
-        tableState = STATE_TABLE_FOCUSED;\r
+        if (isPopupShown())\r
+            tableState = STATE_TABLE_FOCUSED;\r
         String text = TextAssist.this.table.getSelection()[0].getText();\r
         TextAssist.this.text.setText(text);\r
         TextAssist.this.text.setSelection(text.length());\r
-        if (!isPopupShown())\r
-            showHistory(event.keyCode);\r
         event.doit = doit;\r
     }\r
 \r
     /**\r
      * @return a listener for the keydown event\r
      */\r
-    private Listener createKeyDownListener() {\r
+    private Listener createKeyDownInTextListener() {\r
         return new Listener() {\r
             @Override\r
             public void handleEvent(final Event event) {\r
@@ -327,9 +294,7 @@ public class TextAssist extends Composite {
                         TextAssist.this.text.setText(TextAssist.this.table.getSelection()[0].getText());\r
                         TextAssist.this.popup.setVisible(false);\r
                     }\r
-                    addHistory(TextAssist.this.text.getText());\r
                     fireSubmit(TextAssist.this.text.getText());\r
-                    break;\r
                 case SWT.ESC:\r
                     TextAssist.this.popup.setVisible(false);\r
                     tableState = STATE_TABLE_UNFOCUSED;\r
@@ -342,6 +307,7 @@ public class TextAssist extends Composite {
         };\r
     }\r
 \r
+    /*\r
     private void showHistory(int arrow) {\r
         if (historyStack.isEmpty())\r
             return;\r
@@ -364,6 +330,7 @@ public class TextAssist extends Composite {
         historyStack.push(text);\r
         historyPos = historyStack.size() - 1;\r
     }\r
+    */\r
 \r
     private Font deriveFont(Font font, int style) {\r
         FontData[] fontData = font.getFontData();\r
@@ -374,10 +341,6 @@ public class TextAssist extends Composite {
     }\r
 \r
     public void showPopup(List<String[]> values) {\r
-        showPopup(null, values);\r
-    }\r
-\r
-    public void showPopup(List<Image> imageList, List<String[]> values) {\r
         TextAssist.this.table.removeAll();\r
         final int numberOfRows = Math.min(values.size(), TextAssist.this.numberOfLines);\r
         for (int i = 0; i < numberOfRows; i++) {\r
@@ -388,12 +351,6 @@ public class TextAssist extends Composite {
             if (i == numberOfRows - 1) {\r
                 tableItem.setData("lastItem", true);\r
             }\r
-            if (imageList != null) {\r
-                try {\r
-                    tableItem.setData(imageList.get(i));\r
-                } catch (IndexOutOfBoundsException e) {\r
-                }\r
-            }\r
         }\r
 \r
         column1.pack();\r
@@ -449,7 +406,6 @@ public class TextAssist extends Composite {
                 }\r
 \r
                 showPopup(values);\r
-\r
             }\r
         };\r
     }\r
index 3c90d3f..3d5f425 100644 (file)
@@ -1,3 +1,6 @@
+* 2.1.90
+- Some improvements for "Command Bar"
+== kh5325.kim <kh5325.kim@samsung.com> 2013-09-02
 * 2.1.89
 - fix test case bug
 == ho.namkoong <ho.namkoong@samsung.com> 2013-09-05 17:14
index fd90992..288cd68 100644 (file)
@@ -1,4 +1,4 @@
-Version:2.1.89
+Version:2.1.90
 Source:common-eplugin
 Maintainer:kangho kim <kh5325.kim@samsung.com>, yoonki park <yoonki.park@samsung.com>, hyunsik non <hyunsik.noh@samsung.com>, taeyoung son <taeyoung2.son@samsung.com>, gune Kim <gune.kim@samsung.com>, ho namkoong <ho.namkoong@samsung.com>, hyeongseok heo <hyeong-seok.heo@samsung.com>, gyeongseok seo <gyeongseok.seo@samsung.com>, jihoon song <jihoon80.song@samsung.com>, changhyun lee <changhyun1.lee@samsung.com>, bonyong lee <bonyong.lee@samsung.com>, shingil kang <shingil.kang@samsung.com>