Added Command Bar
authorkh5325.kim <kh5325.kim@samsung.com>
Sat, 31 Aug 2013 08:19:07 +0000 (17:19 +0900)
committerkh5325.kim <kh5325.kim@samsung.com>
Sat, 31 Aug 2013 08:19:07 +0000 (17:19 +0900)
38 files changed:
NOTICE
org.tizen.common.ui/.classpath
org.tizen.common.ui/META-INF/MANIFEST.MF
org.tizen.common.ui/about.html [new file with mode: 0644]
org.tizen.common.ui/about_files/LICENSE-2.0.htm [new file with mode: 0644]
org.tizen.common.ui/about_files/jsoup-LICENSE.txt [new file with mode: 0644]
org.tizen.common.ui/build.properties
org.tizen.common.ui/icons/commandbar_x24.png [new file with mode: 0644]
org.tizen.common.ui/icons/commandbar_x32.png [new file with mode: 0644]
org.tizen.common.ui/lib/commons-cli-1.2.jar [new file with mode: 0644]
org.tizen.common.ui/lib/howdoi.jar [new file with mode: 0644]
org.tizen.common.ui/lib/httpclient-4.2.5.jar [new file with mode: 0644]
org.tizen.common.ui/lib/httpcore-4.2.4.jar [new file with mode: 0644]
org.tizen.common.ui/lib/jsoup-1.6.3.jar [new file with mode: 0644]
org.tizen.common.ui/lib/tizen-cli.jar [new file with mode: 0644]
org.tizen.common.ui/plugin.xml
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/Assistant.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/Messages.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/StatusBar.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/StatusBarHandler.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/ConsoleCommand.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/HelpCommand.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/ProjectCommand.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/QueryCommand.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/SdbCommand.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/ShowSignCommand.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/SystemCommand.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/TimeCommand.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/TimeEndCommand.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/TimeStartCommand.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/launcher/CommandLauncher.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/launcher/HyperlinkPatternMatchLinstener.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/launcher/SystemLauncher.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/launcher/TimeLauncher.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/launcher/TizenHandler.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/textAssist/CommandProvider.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/textAssist/TextAssist.java [new file with mode: 0644]
org.tizen.common.ui/src/org/tizen/common/ui/commandbar/textAssist/TextAssistContentProvider.java [new file with mode: 0644]

diff --git a/NOTICE b/NOTICE
index 312ba7e..d6faeef 100644 (file)
--- a/NOTICE
+++ b/NOTICE
@@ -35,6 +35,7 @@ http://jackson.codehaus.org/
 
 ============================================================
 Notices for file(s):
+/org.tizen.common.ui/lib/jsoup-1.6.3.jar
 /org.tizen.common.verrari/lib/jsoup-1.6.3.jar
 ------------------------------------------------------------
 MIT
@@ -61,3 +62,18 @@ Notices for file(s):
 ------------------------------------------------------------
 Apache License, Version 2.0
 http://santuario.apache.org/
+
+============================================================
+Notices for file(s):
+/org.tizen.common.ui/lib/httpclient-4.2.5.jar
+/org.tizen.common.ui/lib/httpcore-4.2.4.jar
+------------------------------------------------------------
+Apache License, Version 2.0
+http://hc.apache.org/
+
+============================================================
+Notices for file(s):
+/org.tizen.common.ui/lib/commons-cli-1.2.jar
+------------------------------------------------------------
+Apache License, Version 2.0
+http://commons.apache.org/proper/commons-cli/
index ad32c83..0c12807 100644 (file)
@@ -1,7 +1,13 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="src" path="src"/>
-       <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry exported="true" kind="lib" path="lib/httpclient-4.2.5.jar"/>\r
+       <classpathentry exported="true" kind="lib" path="lib/httpcore-4.2.4.jar"/>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+       <classpathentry kind="src" path="src"/>\r
+       <classpathentry kind="lib" path="lib/commons-cli-1.2.jar"/>\r
+       <classpathentry kind="lib" path="lib/tizen-cli.jar"/>\r
+       <classpathentry kind="lib" path="lib/jsoup-1.6.3.jar"/>\r
+       <classpathentry kind="lib" path="lib/howdoi.jar"/>\r
+       <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
index 8e8c8a5..9c1cdfa 100644 (file)
@@ -10,11 +10,22 @@ Require-Bundle: org.eclipse.ui,
  org.tizen.common
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Import-Package: org.eclipse.core.resources,
+ org.eclipse.jface.text,
+ org.eclipse.ui.console,
  org.eclipse.ui.dialogs,
  org.eclipse.ui.wizards.newresource,
  org.mihalis.opal.preferenceWindow,
  org.mihalis.opal.preferenceWindow.widgets,
- org.tizen.common.project.util
+ org.mihalis.opal.promptSupport,
+ org.tizen.common.project.util,
+ org.tizen.common.sign.preferences
 Export-Package: org.tizen.common.ui,
  org.tizen.common.ui.wizards
 Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: lib/commons-cli-1.2.jar,
+ lib/howdoi.jar,
+ lib/jsoup-1.6.3.jar,
+ lib/tizen-cli.jar,
+ lib/httpclient-4.2.5.jar,
+ lib/httpcore-4.2.4.jar,
+ .
diff --git a/org.tizen.common.ui/about.html b/org.tizen.common.ui/about.html
new file mode 100644 (file)
index 0000000..c14570d
--- /dev/null
@@ -0,0 +1,77 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>May, 2011</p>
+<h3>Tizen SDK</h3>
+
+<p><a href="https://developer.tizen.org/" target="_blank">Tizen SDK</a> 
+is a set of Eclipse plug-ins that helps programmers to develop applications for 
+the mobile platform.</p>
+
+<h3>License</h3>
+
+<p>See <a href="about_files/LICENSE-2.0.htm">Apache License, Version 2.0</a>.</p>
+
+<h3>Third Party Content</h3>
+
+<p>The Content includes items that have been sourced from third parties as set out below. If you did not
+receive this Content directly from the Eclipse Foundation, the following is provided for informational
+purposes only, and you should look to the Redistributor's license for terms and conditions of use.</p>
+
+<h4>jsoup</h4>
+<p>
+jsoup is a Java library for working with real-world HTML. It provides a very convenient API for extracting and manipulating data, using the best of DOM, CSS, and jquery-like methods
+</p>
+
+<p>
+A copy of the license is included in <a href="about_files/jsoup-LICENSE.txt">about_files/jsoup-LICENSE.txt</a>. The home page is located at:
+<ul>
+<a href="http://jsoup.org/">http://jsoup.org/</a>
+</ul>
+</p>
+
+<h4>Commons CLI</h4>
+<p>
+The Apache Commons CLI library provides an API for parsing command line options passed to programs. It's also able to print help messages detailing the options available for a command line tool. 
+</p>
+
+<p>
+A copy of the license is included in <a href="about_files/LICENSE-2.0.htm">about_files/LICENSE-2.0.htm</a>. The home page is located at:
+<ul>
+<a href="http://commons.apache.org/proper/commons-cli/">http://commons.apache.org/proper/commons-cli/</a>
+</ul>
+</p>
+
+<h4>Apache HttpComponents</h4>
+<p>
+The Apache HttpComponents<sup>TM</sup> project is responsible for creating and maintaining a toolset of low level Java components focused on HTTP and associated protocols.
+</p>
+
+<p>
+A copy of the license is included in <a href="about_files/LICENSE-2.0.htm">about_files/LICENSE-2.0.htm</a>. The home page is located at:
+<ul>
+<a href="http://hc.apache.org/">http://hc.apache.org/</a>
+</ul>
+</p>
+
+<h4>howdoi</h4>
+<p>
+The Java port of howdoi.
+</p>
+
+<p>
+The home page is located at:
+<ul>
+<a href="https://github.com/cimfalab/howdoi">https://github.com/cimfalab/howdoi</a>
+</ul>
+</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/org.tizen.common.ui/about_files/LICENSE-2.0.htm b/org.tizen.common.ui/about_files/LICENSE-2.0.htm
new file mode 100644 (file)
index 0000000..f7ca656
--- /dev/null
@@ -0,0 +1,191 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html lang="en">
+  <head>
+    <title>Apache License, Version 2.0</title>
+
+    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+    <meta property="og:image" content="http://www.apache.org/images/asf_logo.gif" />
+
+    <link rel="stylesheet" type="text/css" media="screen" href="/css/style.css">
+    <link rel="stylesheet" type="text/css" media="screen" href="/css/code.css">
+
+    <script type="text/javascript" src="/js/jquery.js"></script>
+    <script type="text/javascript" src="/js/apache_boot.js"></script>
+
+    
+
+    
+    <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file to you under the Apache License, Version 2.0 (the &quot;License&quot;); 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 &quot;AS IS&quot; 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. -->
+  </head>
+
+  <body>
+    <div id="page" class="container_16">
+      <div id="header" class="grid_8">
+        <h1>The Apache Software Foundation</h1>
+        <h2>Apache License, Version 2.0</h2>
+      </div>
+
+      <div class="clear"></div>
+      <div id="content" class="grid_16"><div class="section-content"><p>Apache License<br></br>Version 2.0, January 2004<br></br>
+<a href="http://www.apache.org/licenses/">http://www.apache.org/licenses/</a> </p>
+<p>TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION</p>
+<p><strong><a name="definitions">1. Definitions</a></strong>.</p>
+<p>"License" shall mean the terms and conditions for use, reproduction, and
+distribution as defined by Sections 1 through 9 of this document.</p>
+<p>"Licensor" shall mean the copyright owner or entity authorized by the
+copyright owner that is granting the License.</p>
+<p>"Legal Entity" shall mean the union of the acting entity and all other
+entities that control, are controlled by, or are under common control with
+that entity. For the purposes of this definition, "control" means (i) the
+power, direct or indirect, to cause the direction or management of such
+entity, whether by contract or otherwise, or (ii) ownership of fifty
+percent (50%) or more of the outstanding shares, or (iii) beneficial
+ownership of such entity.</p>
+<p>"You" (or "Your") shall mean an individual or Legal Entity exercising
+permissions granted by this License.</p>
+<p>"Source" form shall mean the preferred form for making modifications,
+including but not limited to software source code, documentation source,
+and configuration files.</p>
+<p>"Object" form shall mean any form resulting from mechanical transformation
+or translation of a Source form, including but not limited to compiled
+object code, generated documentation, and conversions to other media types.</p>
+<p>"Work" shall mean the work of authorship, whether in Source or Object form,
+made available under the License, as indicated by a copyright notice that
+is included in or attached to the work (an example is provided in the
+Appendix below).</p>
+<p>"Derivative Works" shall mean any work, whether in Source or Object form,
+that is based on (or derived from) the Work and for which the editorial
+revisions, annotations, elaborations, or other modifications represent, as
+a whole, an original work of authorship. For the purposes of this License,
+Derivative Works shall not include works that remain separable from, or
+merely link (or bind by name) to the interfaces of, the Work and Derivative
+Works thereof.</p>
+<p>"Contribution" shall mean any work of authorship, including the original
+version of the Work and any modifications or additions to that Work or
+Derivative Works thereof, that is intentionally submitted to Licensor for
+inclusion in the Work by the copyright owner or by an individual or Legal
+Entity authorized to submit on behalf of the copyright owner. For the
+purposes of this definition, "submitted" means any form of electronic,
+verbal, or written communication sent to the Licensor or its
+representatives, including but not limited to communication on electronic
+mailing lists, source code control systems, and issue tracking systems that
+are managed by, or on behalf of, the Licensor for the purpose of discussing
+and improving the Work, but excluding communication that is conspicuously
+marked or otherwise designated in writing by the copyright owner as "Not a
+Contribution."</p>
+<p>"Contributor" shall mean Licensor and any individual or Legal Entity on
+behalf of whom a Contribution has been received by Licensor and
+subsequently incorporated within the Work.</p>
+<p><strong><a name="copyright">2. Grant of Copyright License</a></strong>. Subject to the
+terms and conditions of this License, each Contributor hereby grants to You
+a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+copyright license to reproduce, prepare Derivative Works of, publicly
+display, publicly perform, sublicense, and distribute the Work and such
+Derivative Works in Source or Object form.</p>
+<p><strong><a name="patent">3. Grant of Patent License</a></strong>. Subject to the terms
+and conditions of this License, each Contributor hereby grants to You a
+perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+(except as stated in this section) patent license to make, have made, use,
+offer to sell, sell, import, and otherwise transfer the Work, where such
+license applies only to those patent claims licensable by such Contributor
+that are necessarily infringed by their Contribution(s) alone or by
+combination of their Contribution(s) with the Work to which such
+Contribution(s) was submitted. If You institute patent litigation against
+any entity (including a cross-claim or counterclaim in a lawsuit) alleging
+that the Work or a Contribution incorporated within the Work constitutes
+direct or contributory patent infringement, then any patent licenses
+granted to You under this License for that Work shall terminate as of the
+date such litigation is filed.</p>
+<p><strong><a name="redistribution">4. Redistribution</a></strong>. You may reproduce and
+distribute copies of the Work or Derivative Works thereof in any medium,
+with or without modifications, and in Source or Object form, provided that
+You meet the following conditions:</p>
+<ol>
+<li>
+<p>You must give any other recipients of the Work or Derivative Works a
+copy of this License; and</p>
+</li>
+<li>
+<p>You must cause any modified files to carry prominent notices stating
+that You changed the files; and</p>
+</li>
+<li>
+<p>You must retain, in the Source form of any Derivative Works that You
+distribute, all copyright, patent, trademark, and attribution notices from
+the Source form of the Work, excluding those notices that do not pertain to
+any part of the Derivative Works; and</p>
+</li>
+<li>
+<p>If the Work includes a "NOTICE" text file as part of its distribution,
+then any Derivative Works that You distribute must include a readable copy
+of the attribution notices contained within such NOTICE file, excluding
+those notices that do not pertain to any part of the Derivative Works, in
+at least one of the following places: within a NOTICE text file distributed
+as part of the Derivative Works; within the Source form or documentation,
+if provided along with the Derivative Works; or, within a display generated
+by the Derivative Works, if and wherever such third-party notices normally
+appear. The contents of the NOTICE file are for informational purposes only
+and do not modify the License. You may add Your own attribution notices
+within Derivative Works that You distribute, alongside or as an addendum to
+the NOTICE text from the Work, provided that such additional attribution
+notices cannot be construed as modifying the License.
+You may add Your own copyright statement to Your modifications and may
+provide additional or different license terms and conditions for use,
+reproduction, or distribution of Your modifications, or for any such
+Derivative Works as a whole, provided Your use, reproduction, and
+distribution of the Work otherwise complies with the conditions stated in
+this License.</p>
+</li>
+</ol>
+<p><strong><a name="contributions">5. Submission of Contributions</a></strong>. Unless You
+explicitly state otherwise, any Contribution intentionally submitted for
+inclusion in the Work by You to the Licensor shall be under the terms and
+conditions of this License, without any additional terms or conditions.
+Notwithstanding the above, nothing herein shall supersede or modify the
+terms of any separate license agreement you may have executed with Licensor
+regarding such Contributions.</p>
+<p><strong><a name="trademarks">6. Trademarks</a></strong>. This License does not grant
+permission to use the trade names, trademarks, service marks, or product
+names of the Licensor, except as required for reasonable and customary use
+in describing the origin of the Work and reproducing the content of the
+NOTICE file.</p>
+<p><strong><a name="no-warranty">7. Disclaimer of Warranty</a></strong>. Unless required by
+applicable law or agreed to in writing, Licensor provides the Work (and
+each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including,
+without limitation, any warranties or conditions of TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You
+are solely responsible for determining the appropriateness of using or
+redistributing the Work and assume any risks associated with Your exercise
+of permissions under this License.</p>
+<p><strong><a name="no-liability">8. Limitation of Liability</a></strong>. In no event and
+under no legal theory, whether in tort (including negligence), contract, or
+otherwise, unless required by applicable law (such as deliberate and
+grossly negligent acts) or agreed to in writing, shall any Contributor be
+liable to You for damages, including any direct, indirect, special,
+incidental, or consequential damages of any character arising as a result
+of this License or out of the use or inability to use the Work (including
+but not limited to damages for loss of goodwill, work stoppage, computer
+failure or malfunction, or any and all other commercial damages or losses),
+even if such Contributor has been advised of the possibility of such
+damages.</p>
+<p><strong><a name="additional">9. Accepting Warranty or Additional Liability</a></strong>.
+While redistributing the Work or Derivative Works thereof, You may choose
+to offer, and charge a fee for, acceptance of support, warranty, indemnity,
+or other liability obligations and/or rights consistent with this License.
+However, in accepting such obligations, You may act only on Your own behalf
+and on Your sole responsibility, not on behalf of any other Contributor,
+and only if You agree to indemnify, defend, and hold each Contributor
+harmless for any liability incurred by, or claims asserted against, such
+Contributor by reason of your accepting any such warranty or additional
+liability.</p>
+<p>END OF TERMS AND CONDITIONS</p>
+
+    <div class="clear"></div>
+    
+    </div>
+    <div id="copyright" class="container_16">
+      <p>Copyright &#169; 2011 The Apache Software Foundation, Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.<br/>Apache and the Apache feather logo are trademarks of The Apache Software Foundation.</p>
+    </div>
+  </body>
+</html>
diff --git a/org.tizen.common.ui/about_files/jsoup-LICENSE.txt b/org.tizen.common.ui/about_files/jsoup-LICENSE.txt
new file mode 100644 (file)
index 0000000..fda732e
--- /dev/null
@@ -0,0 +1,21 @@
+The MIT License\r
+\r
+Copyright (c) 2009, 2010, 2011, 2012 Jonathan Hedley <jonathan@hedley.net>\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining a copy\r
+of this software and associated documentation files (the "Software"), to deal\r
+in the Software without restriction, including without limitation the rights\r
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
+copies of the Software, and to permit persons to whom the Software is\r
+furnished to do so, subject to the following conditions:\r
+\r
+The above copyright notice and this permission notice shall be included in\r
+all copies or substantial portions of the Software.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+THE SOFTWARE.
\ No newline at end of file
index e55344e..797e860 100644 (file)
@@ -5,4 +5,13 @@ bin.includes = META-INF/,\
                OSGI-INF/,\
                plugin.xml,\
                icons/,\
-               images/
+               images/,\
+               lib/,\
+               lib/commons-cli-1.2.jar,\
+               lib/howdoi.jar,\
+               lib/jsoup-1.6.3.jar,\
+               lib/tizen-cli.jar,\
+               lib/httpclient-4.2.5.jar,\
+               lib/httpcore-4.2.4.jar,\
+               about.html,\
+               about_files/
diff --git a/org.tizen.common.ui/icons/commandbar_x24.png b/org.tizen.common.ui/icons/commandbar_x24.png
new file mode 100644 (file)
index 0000000..5ac2ce1
Binary files /dev/null and b/org.tizen.common.ui/icons/commandbar_x24.png differ
diff --git a/org.tizen.common.ui/icons/commandbar_x32.png b/org.tizen.common.ui/icons/commandbar_x32.png
new file mode 100644 (file)
index 0000000..4f001cc
Binary files /dev/null and b/org.tizen.common.ui/icons/commandbar_x32.png differ
diff --git a/org.tizen.common.ui/lib/commons-cli-1.2.jar b/org.tizen.common.ui/lib/commons-cli-1.2.jar
new file mode 100644 (file)
index 0000000..ce4b9ff
Binary files /dev/null and b/org.tizen.common.ui/lib/commons-cli-1.2.jar differ
diff --git a/org.tizen.common.ui/lib/howdoi.jar b/org.tizen.common.ui/lib/howdoi.jar
new file mode 100644 (file)
index 0000000..43f8e55
Binary files /dev/null and b/org.tizen.common.ui/lib/howdoi.jar differ
diff --git a/org.tizen.common.ui/lib/httpclient-4.2.5.jar b/org.tizen.common.ui/lib/httpclient-4.2.5.jar
new file mode 100644 (file)
index 0000000..5310588
Binary files /dev/null and b/org.tizen.common.ui/lib/httpclient-4.2.5.jar differ
diff --git a/org.tizen.common.ui/lib/httpcore-4.2.4.jar b/org.tizen.common.ui/lib/httpcore-4.2.4.jar
new file mode 100644 (file)
index 0000000..9f45bd9
Binary files /dev/null and b/org.tizen.common.ui/lib/httpcore-4.2.4.jar differ
diff --git a/org.tizen.common.ui/lib/jsoup-1.6.3.jar b/org.tizen.common.ui/lib/jsoup-1.6.3.jar
new file mode 100644 (file)
index 0000000..b3421d5
Binary files /dev/null and b/org.tizen.common.ui/lib/jsoup-1.6.3.jar differ
diff --git a/org.tizen.common.ui/lib/tizen-cli.jar b/org.tizen.common.ui/lib/tizen-cli.jar
new file mode 100644 (file)
index 0000000..2a8c035
Binary files /dev/null and b/org.tizen.common.ui/lib/tizen-cli.jar differ
index 4fa2561..fea5d95 100644 (file)
             class="org.tizen.common.ui.Startup">\r
       </startup>\r
    </extension>\r
+\r
+    <!-- Command Bar -->\r
+    <extension\r
+          point="org.eclipse.ui.startup">\r
+       <startup\r
+             class="org.tizen.common.ui.commandbar.Assistant"></startup>\r
+    </extension>\r
+    <extension point="org.eclipse.ui.menus">\r
+       <group id="org.tizen.common.ui.commandbar" separatorsVisible="true">\r
+             <location>\r
+               <bar type="trim"></bar>\r
+               <order position="before" relativeTo="status"></order>\r
+             </location>\r
+       </group>\r
+       <widget class="org.tizen.common.ui.commandbar.StatusBar" id="org.tizen.common.ui.commandbar.status">\r
+             <location>\r
+               <bar path="org.tizen.common.ui.commandbar" type="trim"></bar>\r
+             </location>\r
+       </widget>\r
+    </extension>\r
+    <extension\r
+         point="org.eclipse.ui.commands">\r
+       <command\r
+            categoryId="org.tizen.common.ui.category"\r
+            defaultHandler="org.tizen.common.ui.commandbar.StatusBarHandler"\r
+            description="Command Bar"\r
+            id="org.tizen.common.ui.commandbar.commands.CommandBar"\r
+            name="Command Bar">\r
+       </command>\r
+    </extension>\r
+    <extension\r
+         point="org.eclipse.ui.menus">\r
+       <menuContribution\r
+            locationURI="menu:tizensdkhelp">\r
+            <command\r
+                  commandId="org.tizen.common.ui.commandbar.commands.CommandBar"\r
+                  style="push">\r
+            </command>\r
+       </menuContribution>\r
+    </extension>\r
+    <extension\r
+         point="org.eclipse.ui.bindings">\r
+       <key\r
+            commandId="org.tizen.common.ui.commandbar.commands.CommandBar"\r
+            contextId="org.eclipse.ui.contexts.window"\r
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"\r
+            sequence="M1+M2+C">\r
+       </key>\r
+    </extension>\r
 </plugin>\r
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/Assistant.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/Assistant.java
new file mode 100644 (file)
index 0000000..e15670a
--- /dev/null
@@ -0,0 +1,144 @@
+/*\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
+import org.eclipse.swt.widgets.Display;\r
+import org.eclipse.ui.IEditorPart;\r
+import org.eclipse.ui.IPartListener;\r
+import org.eclipse.ui.IStartup;\r
+import org.eclipse.ui.IWorkbenchPart;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.tizen.common.ui.Activator;\r
+\r
+public class Assistant implements IStartup {\r
+    protected Logger logger = LoggerFactory.getLogger(getClass());\r
+\r
+    private Map<IWorkbenchPart, Object> fActiveMap;\r
+    private static StatusBar status;\r
+    // TODO:\r
+    private Object hookObject = new Object();\r
+\r
+    public void earlyStartup() {\r
+        fActiveMap = new HashMap<IWorkbenchPart, Object>();\r
+\r
+        Display.getDefault().asyncExec(new Runnable() {\r
+            public void run() {\r
+                try {\r
+                    IEditorPart startupEditorPart = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();\r
+                    if (startupEditorPart != null) {\r
+                        activated(Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart());\r
+                    }\r
+                } catch (Exception e) {\r
+                    logger.error("Failed to hook startupEditorPart", e);\r
+                }\r
+\r
+                Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().addPartListener(new IPartListener() {\r
+                    public void partActivated(IWorkbenchPart part) {\r
+                        activated(part);\r
+                    }\r
+\r
+                    public void partBroughtToTop(IWorkbenchPart part) {\r
+                        activated(part);\r
+                    }\r
+\r
+                    public void partClosed(IWorkbenchPart part) {\r
+                        unhook(part);\r
+                    }\r
+\r
+                    public void partDeactivated(IWorkbenchPart part) {\r
+                        deactivated(part);\r
+                    }\r
+\r
+                    public void partOpened(IWorkbenchPart part) {\r
+                        activated(part);\r
+                    }\r
+                });\r
+            }\r
+        });\r
+    }\r
+\r
+    private void activated(IWorkbenchPart part) {\r
+        try {\r
+            /*\r
+            JavaSourcePopup.kill(10);\r
+\r
+            IEditorPart editorPart = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();\r
+            setEditor(editorPart);\r
+\r
+            ITextViewer viewer = callGetSourceViewer((AbstractTextEditor) editorPart);\r
+            if (viewer == null) return;\r
+            */\r
+            hook(part);\r
+        } catch (Exception e) {\r
+            logger.error("Failed to hook the part", e);\r
+        }\r
+    }\r
+\r
+    private void deactivated(IWorkbenchPart part) {\r
+    }\r
+\r
+    private void hook(final IWorkbenchPart part) {\r
+        if (fActiveMap.get(part) == hookObject)\r
+            return;\r
+        logger.trace("Assistant hook (part - " + part + ")");\r
+\r
+        Display.getDefault().asyncExec(new Runnable() {\r
+            public void run() {\r
+                /*\r
+                textViewer.getTextWidget().addListener(SWT.MouseHover, new Listener() {\r
+                    public void handleEvent(Event event) {\r
+                        if (Activator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.SHOW_ON_HOVER)) {\r
+                            keyDown(textViewer, event, true);\r
+                        }\r
+                    }\r
+                });\r
+                */\r
+                //new AssistantPopup(Activator.getDefault().getWorkbench().getDisplay().getActiveShell());\r
+                fActiveMap.put(part, hookObject);\r
+            }\r
+        });\r
+    }\r
+\r
+    private void unhook(final IWorkbenchPart part) {\r
+        Object obj = fActiveMap.get(part);\r
+        if (obj == null) return;\r
+    }\r
+\r
+    public static void setStatusBar(StatusBar status) {\r
+        Assistant.status = status;\r
+    }\r
+\r
+    public static StatusBar getStatusBar() {\r
+        return status;\r
+    }\r
+}\r
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
new file mode 100644 (file)
index 0000000..3e785e0
--- /dev/null
@@ -0,0 +1,74 @@
+/*\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
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/StatusBar.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/StatusBar.java
new file mode 100644 (file)
index 0000000..aff7d9c
--- /dev/null
@@ -0,0 +1,168 @@
+/*\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 static org.eclipse.swt.SWT.BOTTOM;\r
+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
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.swt.widgets.Listener;\r
+import org.eclipse.ui.IWorkbenchWindow;\r
+import org.eclipse.ui.menus.AbstractWorkbenchTrimWidget;\r
+import org.mihalis.opal.promptSupport.PromptSupport;\r
+import org.mihalis.opal.promptSupport.PromptSupport.FocusBehavior;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.tizen.common.CommonPlugin;\r
+import org.tizen.common.ui.Activator;\r
+import org.tizen.common.ui.HelpToolTip;\r
+import org.tizen.common.ui.commandbar.command.HelpCommand;\r
+import org.tizen.common.ui.commandbar.command.launcher.CommandLauncher;\r
+import org.tizen.common.ui.commandbar.textAssist.CommandProvider;\r
+import org.tizen.common.ui.commandbar.textAssist.TextAssist;\r
+import org.tizen.common.ui.commandbar.textAssist.TextAssistContentProvider;\r
+import org.tizen.common.ui.commandbar.textAssist.TextAssist.SubmitListener;\r
+import org.tizen.common.util.CollectionUtil;\r
+import org.tizen.common.util.SWTUtil;\r
+import org.tizen.common.util.StringUtil;\r
+\r
+public class StatusBar extends AbstractWorkbenchTrimWidget implements SubmitListener {\r
+    protected Logger logger = LoggerFactory.getLogger(getClass());\r
+\r
+    private Composite fComposite;\r
+    private TextAssist fTxtAssist;\r
+    private CommandLauncher fCommandLauncher;\r
+\r
+    @Override\r
+    public void init(IWorkbenchWindow workbenchWindow) {\r
+        super.init(workbenchWindow);\r
+        Assistant.setStatusBar(this);\r
+        fCommandLauncher = new CommandLauncher(this);\r
+    }\r
+\r
+    @Override\r
+    public void fill(Composite parent, int oldSide, int newSide) {\r
+        fComposite = new Composite(parent, NONE);\r
+\r
+        RowLayout layout = new RowLayout();\r
+        layout.marginHeight = 4;\r
+        layout.marginWidth = 2;\r
+        layout.center = true;\r
+        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.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
+        final TextAssistContentProvider contentProvider = new CommandProvider();\r
+        fTxtAssist = new TextAssist(fComposite, SWT.SINGLE, contentProvider);\r
+        fTxtAssist.setLayoutData(getRowData(newSide));\r
+        final StyledText txt = fTxtAssist.getTextControl();\r
+        PromptSupport.setPrompt("Search or type a command", txt);\r
+        PromptSupport.setFontStyle(SWT.NONE, txt);\r
+        PromptSupport.setFocusBehavior(FocusBehavior.HIGHLIGHT_PROMPT, txt);\r
+        PromptSupport.setForeground(txt.getDisplay().getSystemColor(SWT.COLOR_GRAY), txt);\r
+\r
+        fTxtAssist.addSubmitListener(this);\r
+        //fTxtAssist.addTableSelectionListener(this);\r
+\r
+        HelpToolTip toolTip = new HelpToolTip(fComposite);\r
+        toolTip.setText("Show command bar help");\r
+        toolTip.addControlSelectionListener(new Listener() {\r
+            @Override\r
+            public void handleEvent(Event event) {\r
+                HelpCommand command = new HelpCommand(StatusBar.this);\r
+                CommonPlugin.getDefault().getExecutor().execute(command);\r
+            }\r
+        });\r
+\r
+        fComposite.layout();\r
+    }\r
+\r
+    RowData getRowData(int newSide) {\r
+        RowData rowData = new RowData();\r
+        if ((newSide == BOTTOM) || (newSide == TOP)) {\r
+            rowData.width = 300;\r
+        }\r
+        return rowData;\r
+    }\r
+\r
+    public void showWelcome() {\r
+        String[][] welcomeMessage = {\r
+            { "Welcome to Command Bar", "" },\r
+            { "", "Just hit 'help' to see what you can do" }\r
+        };\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.setFocus();\r
+    }\r
+\r
+    public void showPopup(List<String[]> values) {\r
+        fTxtAssist.showPopup(values);\r
+    }\r
+\r
+    @Override\r
+    public void dispose() {\r
+        fTxtAssist.removeSubmitListener(this);\r
+        //fTxtAssist.removeTableSelectionListener(this);\r
+        SWTUtil.tryDispose(fComposite);\r
+    }\r
+\r
+    @Override\r
+    public void onSubmit(String text) {\r
+        // Select <query> in case "query --tizen <query>"\r
+        int start = Messages.getArgumentStartIndex(text);\r
+        if (start != -1) {\r
+            fTxtAssist.getTextControl().setSelection(start, text.length());\r
+            return; // And just return not to execute the command\r
+        } else {\r
+            fTxtAssist.getTextControl().setSelection(text.length());\r
+\r
+            String[] commands = StringUtil.split(text, " ");\r
+            try {\r
+                fCommandLauncher.launchCommand(commands);\r
+            } catch (Exception e) {\r
+                logger.error("Failed to launch command", e);\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/StatusBarHandler.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/StatusBarHandler.java
new file mode 100644 (file)
index 0000000..9c57d3e
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Changhyun Lee <changhyun1.lee@samsung.com>
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>
+ * BonYong Lee <bonyong.lee@samsung.com>
+ * Kangho Kim <kh5325.kim@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;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+public class StatusBarHandler extends AbstractHandler {
+    @Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
+        Assistant.getStatusBar().showWelcome();
+        return null;
+    }
+}
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/ConsoleCommand.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/ConsoleCommand.java
new file mode 100644 (file)
index 0000000..841c8ea
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Changhyun Lee <changhyun1.lee@samsung.com>
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>
+ * BonYong Lee <bonyong.lee@samsung.com>
+ * Kangho Kim <kh5325.kim@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.command;
+
+import org.tizen.common.core.command.AbstractCommand;
+
+public abstract class ConsoleCommand extends AbstractCommand<Object> {
+    public static final String CONSOLE_NAME = "Command Bar";
+}
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/HelpCommand.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/HelpCommand.java
new file mode 100644 (file)
index 0000000..fc6eb8b
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Changhyun Lee <changhyun1.lee@samsung.com>
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>
+ * BonYong Lee <bonyong.lee@samsung.com>
+ * Kangho Kim <kh5325.kim@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.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.StatusBar;
+import org.tizen.common.util.CollectionUtil;
+
+public class HelpCommand extends AbstractCommand<Object> {
+    StatusBar status;
+
+    public HelpCommand(StatusBar status) {
+        this.status = status;
+    }
+
+    public void run(final Executor executor, final ExecutionContext context) throws Exception {
+        status.showPopup((List<String[]>) CollectionUtil.asList(Messages.HELP));
+    }
+}
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/ProjectCommand.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/ProjectCommand.java
new file mode 100644 (file)
index 0000000..122770c
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Changhyun Lee <changhyun1.lee@samsung.com>
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>
+ * BonYong Lee <bonyong.lee@samsung.com>
+ * Kangho Kim <kh5325.kim@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.command;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.console.IConsoleConstants;
+import org.eclipse.ui.internal.dialogs.PropertyDialog;
+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.util.ProjectUtil;
+import org.tizen.common.util.SWTUtil;
+import org.tizen.common.util.ViewUtil;
+
+public class ProjectCommand extends AbstractCommand<Object> {
+    public void run(final Executor executor, final ExecutionContext context) throws Exception {
+        final String[] args = (String[]) context.getValue("args");
+        runProjectCommand(args);
+    }
+
+    private void runProjectCommand(String[] args) {
+        String name = args[0].substring(Messages.IDENTIFIER_RESERVED.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 {
+            if ("build".equals(opt)) {
+                buildProject(project);
+            }
+            else if ("tizen".equals(opt)) {
+                showPropertyDialog(project, "org.tizen.nativecommon.build.ui.TizenSettingsPage");
+            }
+        }
+    }
+
+
+    private void buildProject(final IProject project) {
+        ViewUtil.showView(IConsoleConstants.ID_CONSOLE_VIEW, false);
+        SWTUtil.asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new NullProgressMonitor());
+                } catch (CoreException e) {
+                    logger.error("Failed to built the project '" + project.getName() + "'", e);
+                }
+            }
+        });
+    }
+
+    private void showPropertyDialog(final IProject project, String initialPageId) {
+        /*
+        String commandId = "org.eclipse.ui.file.properties";
+        IHandlerService handlerService = (IHandlerService) ViewUtil.getWorkbenchWindow().getService(IHandlerService.class);
+        // cf.)) org.eclipse.ui.dialogs.PropertyDialogAction
+        handlerService.executeCommand(commandId, null);
+        */
+        /*
+        PropertyDialogAction pda = new PropertyDialogAction(
+            new IShellProvider() {
+                public Shell getShell() {
+                    return SWTUtil.getShell();
+                }
+            },
+            new ISelectionProvider() {
+                public void addSelectionChangedListener(ISelectionChangedListener listener) {
+                }
+                public ISelection getSelection() {
+                    return new StructuredSelection(new Object[] { project });
+                }
+                public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+                }
+                public void setSelection(ISelection selection) {
+                }
+            }
+        );
+        pda.run();
+        */
+        PropertyDialog dialog = PropertyDialog.createDialogOn(SWTUtil.getShell(), initialPageId, new StructuredSelection(new Object[] { project }));
+        dialog.open();
+        
+    }
+}
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/QueryCommand.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/QueryCommand.java
new file mode 100644 (file)
index 0000000..1db8530
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Changhyun Lee <changhyun1.lee@samsung.com>
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>
+ * BonYong Lee <bonyong.lee@samsung.com>
+ * Kangho Kim <kh5325.kim@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.command;
+
+import howdoi.Handler;
+import howdoi.Main;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.cli.CommandLine;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+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.command.launcher.HyperlinkPatternMatchLinstener;
+import org.tizen.common.ui.commandbar.command.launcher.TizenHandler;
+import org.tizen.common.ui.view.console.ConsoleManager;
+
+public class QueryCommand extends ConsoleCommand {
+    public void run(final Executor executor, final ExecutionContext context) throws Exception {
+        final CommandLine cmdLine = (CommandLine) context.getValue("cmdLine");
+        runQueryCommand(cmdLine);
+    }
+
+    private void runQueryCommand(final CommandLine cmdLine) throws Exception {
+        ConsoleManager consoleManager = new ConsoleManager(CONSOLE_NAME, true);
+        final MessageConsole console = (MessageConsole) consoleManager.getConsole();
+        final MessageConsoleStream messageConsoleStream = consoleManager.getMessageConsoleStream();
+        //messageConsoleStream.setActivateOnWrite(true);
+        // cf.)) http://www.eclipse.org/forums/index.php/t/99411/
+        console.addPatternMatchListener(new HyperlinkPatternMatchLinstener(console));
+
+        Job job = new Job("Console Job") {
+            @Override
+            protected IStatus run(IProgressMonitor monitor) {
+                Main howdoi = new Main();
+                Handler handler = null;
+                List<String> opts = new ArrayList<String>();
+                // howdoi --num-answers 3 format date bash
+                opts.add("--num-answers");
+                opts.add("" + Messages.QUERY_COMMAND_MAX_ANSWERS);
+
+                String[] args = cmdLine.getArgs();
+                if (cmdLine.hasOption("tizen")) {
+                    handler = new TizenHandler();
+                    opts.add("--site");
+                    opts.add("developer.tizen.org");
+                }
+                String[] cmd = new String[args.length + opts.size()];
+                System.arraycopy(opts.toArray(), 0, cmd, 0, opts.size());
+                System.arraycopy(args, 0, cmd, opts.size(), args.length);
+                try {
+                    howdoi.run(cmd, handler, messageConsoleStream);
+                } catch (Exception e) {
+                    logger.error("Failed to run howdoi", e);
+                }
+                return Status.OK_STATUS;
+            }
+        };
+        job.schedule(); 
+    }
+}
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/SdbCommand.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/SdbCommand.java
new file mode 100644 (file)
index 0000000..874d9ed
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Changhyun Lee <changhyun1.lee@samsung.com>
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>
+ * BonYong Lee <bonyong.lee@samsung.com>
+ * Kangho Kim <kh5325.kim@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.command;
+
+import org.tizen.common.core.application.InstallPathConfig;
+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.command.launcher.SystemLauncher;
+import org.tizen.common.util.ArrayUtil;
+
+public class SdbCommand extends AbstractCommand<Object> {
+    public void run(final Executor executor, final ExecutionContext context) throws Exception {
+        final String[] opts = (String[]) context.getValue("args");
+        new SystemLauncher(ArrayUtil.prepend(opts, InstallPathConfig.getSDBPath())).run();
+    }
+}
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/ShowSignCommand.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/ShowSignCommand.java
new file mode 100644 (file)
index 0000000..61a1f71
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Changhyun Lee <changhyun1.lee@samsung.com>
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>
+ * BonYong Lee <bonyong.lee@samsung.com>
+ * Kangho Kim <kh5325.kim@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.command;
+
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+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.sign.preferences.SigningPreferencePage;
+import org.tizen.common.util.SWTUtil;
+
+public class ShowSignCommand extends AbstractCommand<Object> {
+    public void run(final Executor executor, final ExecutionContext context) throws Exception {
+        SWTUtil.asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(SWTUtil.getActiveShell(), SigningPreferencePage.PREFERENCE_PAGE_ID, new String[] { SigningPreferencePage.PREFERENCE_PAGE_ID }, null);
+                dialog.open();
+            }
+        });
+    }
+}
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/SystemCommand.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/SystemCommand.java
new file mode 100644 (file)
index 0000000..41b557a
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Changhyun Lee <changhyun1.lee@samsung.com>
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>
+ * BonYong Lee <bonyong.lee@samsung.com>
+ * Kangho Kim <kh5325.kim@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.command;
+
+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.command.launcher.SystemLauncher;
+
+public class SystemCommand extends AbstractCommand<Object> {
+    public void run(final Executor executor, final ExecutionContext context) throws Exception {
+        final String[] args = (String[]) context.getValue("args");
+        new SystemLauncher(args).run();
+    }
+}
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/TimeCommand.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/TimeCommand.java
new file mode 100644 (file)
index 0000000..f016b69
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Changhyun Lee <changhyun1.lee@samsung.com>
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>
+ * BonYong Lee <bonyong.lee@samsung.com>
+ * Kangho Kim <kh5325.kim@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.command;
+
+import org.tizen.common.core.command.ExecutionContext;
+import org.tizen.common.core.command.Executor;
+import org.tizen.common.ui.view.console.ConsoleManager;
+
+public abstract class TimeCommand extends ConsoleCommand {
+    protected abstract void run(ConsoleManager consoleManager) throws Exception;
+
+    public void run(final Executor executor, final ExecutionContext context) throws Exception {
+        ConsoleManager consoleManager = new ConsoleManager(CONSOLE_NAME, true);
+        try {
+            run(consoleManager);
+        } catch (Exception e) {
+            consoleManager.print(e.getMessage());
+        }
+    }
+}
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/TimeEndCommand.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/TimeEndCommand.java
new file mode 100644 (file)
index 0000000..332b728
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Changhyun Lee <changhyun1.lee@samsung.com>
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>
+ * BonYong Lee <bonyong.lee@samsung.com>
+ * Kangho Kim <kh5325.kim@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.command;
+
+import org.tizen.common.ui.commandbar.command.launcher.TimeLauncher;
+import org.tizen.common.ui.view.console.ConsoleManager;
+
+public class TimeEndCommand extends TimeCommand {
+    public void run(ConsoleManager consoleManager) throws Exception {
+        long elapsed = TimeLauncher.getInstance().stop();
+        consoleManager.print("Elapsed time is " + String.format("%.1f", ((float) elapsed) / 1000) + " (s)");
+    }
+}
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/TimeStartCommand.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/TimeStartCommand.java
new file mode 100644 (file)
index 0000000..ee3d388
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Changhyun Lee <changhyun1.lee@samsung.com>
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>
+ * BonYong Lee <bonyong.lee@samsung.com>
+ * Kangho Kim <kh5325.kim@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.command;
+
+import org.tizen.common.ui.commandbar.command.launcher.TimeLauncher;
+import org.tizen.common.ui.view.console.ConsoleManager;
+
+public class TimeStartCommand extends TimeCommand {
+    public void run(ConsoleManager consoleManager) throws Exception {
+        TimeLauncher.getInstance().start();
+        consoleManager.print("Stopwatch was started.");
+    }
+}
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/launcher/CommandLauncher.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/launcher/CommandLauncher.java
new file mode 100644 (file)
index 0000000..d7dcf95
--- /dev/null
@@ -0,0 +1,171 @@
+/*\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.command.launcher;\r
+\r
+import java.util.Arrays;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import org.apache.commons.cli.CommandLine;\r
+import org.apache.commons.cli.OptionBuilder;\r
+import org.apache.commons.cli.Options;\r
+import org.apache.commons.cli.Option;\r
+import org.slf4j.Logger;\r
+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.StatusBar;\r
+import org.tizen.common.ui.commandbar.command.HelpCommand;\r
+import org.tizen.common.ui.commandbar.command.ProjectCommand;\r
+import org.tizen.common.ui.commandbar.command.QueryCommand;\r
+import org.tizen.common.ui.commandbar.command.SdbCommand;\r
+import org.tizen.common.ui.commandbar.command.ShowSignCommand;\r
+import org.tizen.common.ui.commandbar.command.SystemCommand;\r
+import org.tizen.common.ui.commandbar.command.TimeEndCommand;\r
+import org.tizen.common.ui.commandbar.command.TimeStartCommand;\r
+import org.tizen.common.util.ArrayUtil;\r
+import org.tizen.common.core.command.AbstractCommand;\r
+import org.tizen.common.core.command.Command;\r
+import org.tizen.common.core.command.ExecutionContext;\r
+\r
+public class CommandLauncher extends AbstractLauncher {\r
+    protected Logger logger = LoggerFactory.getLogger(getClass());\r
+\r
+    StatusBar status;\r
+\r
+    private Map<Option, AbstractCommand> commandMap = new HashMap<Option, AbstractCommand>();\r
+\r
+    public CommandLauncher(StatusBar status) {\r
+        this.status = status;\r
+    }\r
+\r
+    public void launchCommand(String[] args) throws Exception {\r
+        if (!ArrayUtil.isEmpty(args)) {\r
+            if (args[0].startsWith(Messages.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
+                    executeImpl(null, null, args);\r
+                } catch (Throwable t) {\r
+                    logger.error("Failed to launch command", t);\r
+                }\r
+            } else {\r
+                super.run(args);\r
+            }\r
+        }\r
+    }\r
+\r
+    @Override\r
+    protected void execute(CommandLine cmdLine) throws Exception {\r
+        try {\r
+            executeImpl(cmdLine, getInputCmd(), cmdLine.getArgs());\r
+        } catch (Throwable t) {\r
+            // Should catch because of exit() in org.tizen.cli.exec.AbstractLauncher.handleException(Throwable)\r
+            logger.error("Failed to execute", t);\r
+        }\r
+    }\r
+\r
+    private void executeCommand(Command command, CommandLine cmdLine, final String[] args) {\r
+        ExecutionContext context = ExecutionContext.getCurrentContext();\r
+        context.setValue("cmdLine", cmdLine);\r
+        context.setValue("args", args);\r
+        CommonPlugin.getDefault().getExecutor().execute(context, command);\r
+    }\r
+\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
+        if (command == null) {\r
+            if (args[0].startsWith(Messages.IDENTIFIER_RESERVED)) {\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
+                args = (String[]) ArrayUtil.prepend(ArrayUtil.remove(args, 0), systemCmd);\r
+                command = new SystemCommand();\r
+            }\r
+        }\r
+        executeCommand(command, cmdLine, args);\r
+    }\r
+\r
+    private AbstractCommand getCommand(String inputCmd, Option[] options) {\r
+        // First, search the command for option like "show --sign"\r
+        if (!ArrayUtil.isEmpty(options)) {\r
+            for (Option option : options) {\r
+                for (Object o : commandMap.keySet()) {\r
+                    if (o.equals(option)) {\r
+                        return commandMap.get(option);\r
+                    }\r
+                }\r
+            }\r
+        }\r
+        // Search the command for like "query --tizen" (--tizen option does not its specific command)\r
+        for (Object o : commandMap.keySet()) {\r
+            Option option = (Option) o;\r
+            if (option.getOpt().equals(inputCmd)) {\r
+                return commandMap.get(option);\r
+            }\r
+        }\r
+        return null;\r
+    }\r
+\r
+    private void addOption(Options result, Option option, AbstractCommand command) {\r
+        result.addOption(option);\r
+        commandMap.put(option, command);\r
+    }\r
+\r
+    @Override\r
+    protected Options getCommands() {\r
+        Options result = super.getCommands();\r
+        addOption(result, OptionBuilder.hasArg(false).create("help"), 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
+        return result;\r
+    }\r
+\r
+    @Override\r
+    protected Options getOptions() {\r
+        Options result = super.getOptions();\r
+        //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
+            result.addOption(OptionBuilder.hasArg(false).create("tizen"));\r
+        else if ("time".equals(getInputCmd())) {\r
+            addOption(result, OptionBuilder.hasArg(false).create("end"), new TimeEndCommand());\r
+        }\r
+        return result;\r
+    }\r
+}\r
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/launcher/HyperlinkPatternMatchLinstener.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/launcher/HyperlinkPatternMatchLinstener.java
new file mode 100644 (file)
index 0000000..2004e32
--- /dev/null
@@ -0,0 +1,104 @@
+/*\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.command.launcher;\r
+\r
+import java.net.URL;\r
+\r
+import org.eclipse.jface.text.BadLocationException;\r
+import org.eclipse.jface.text.IRegion;\r
+import org.eclipse.ui.console.IHyperlink;\r
+import org.eclipse.ui.console.IPatternMatchListener;\r
+import org.eclipse.ui.console.MessageConsole;\r
+import org.eclipse.ui.console.PatternMatchEvent;\r
+import org.eclipse.ui.console.TextConsole;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.tizen.common.util.OpenBrowserUtil;\r
+import org.tizen.common.util.SWTUtil;\r
+\r
+public class HyperlinkPatternMatchLinstener implements IPatternMatchListener {\r
+    protected Logger logger = LoggerFactory.getLogger(getClass());\r
+\r
+    MessageConsole console;\r
+\r
+    public HyperlinkPatternMatchLinstener(MessageConsole console) {\r
+        this.console = console;\r
+    }\r
+\r
+    @Override\r
+    public void connect(TextConsole console) {\r
+    }\r
+\r
+    @Override\r
+    public void disconnect() {\r
+    }\r
+\r
+    @Override\r
+    public void matchFound(final PatternMatchEvent event) {\r
+        try {\r
+            console.addHyperlink(new IHyperlink() {\r
+                @Override\r
+                public void linkEntered() {\r
+                }\r
+\r
+                @Override\r
+                public void linkExited() {\r
+                }\r
+\r
+                @Override\r
+                public void linkActivated() {\r
+                    IRegion region = console.getRegion(this);\r
+                    try {\r
+                        String hyperlink = console.getDocument().get(region.getOffset(), region.getLength());\r
+                        OpenBrowserUtil.open(new URL(hyperlink), SWTUtil.getDisplay());\r
+                    } catch (Exception e) {\r
+                        logger.error("Failed to open the browser", e);\r
+                    }\r
+                }\r
+            }, event.getOffset(), event.getLength());\r
+            console.removePatternMatchListener(this);\r
+        } catch (BadLocationException e) {\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public String getPattern() {\r
+        return "(http|https)://.*";\r
+    }\r
+\r
+    @Override\r
+    public int getCompilerFlags() {\r
+        return 0;\r
+    }\r
+\r
+    @Override\r
+    public String getLineQualifier() {\r
+        return null;\r
+    }\r
+}\r
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/launcher/SystemLauncher.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/launcher/SystemLauncher.java
new file mode 100644 (file)
index 0000000..77b775d
--- /dev/null
@@ -0,0 +1,67 @@
+/*\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.command.launcher;\r
+\r
+import java.util.concurrent.atomic.AtomicReference;\r
+\r
+import org.tizen.common.ui.commandbar.command.ConsoleCommand;\r
+import org.tizen.common.util.CollectionUtil;\r
+import org.tizen.common.util.HostUtil;\r
+import org.tizen.common.util.SWTUtil;\r
+\r
+public class SystemLauncher {\r
+    String[] cmds;\r
+\r
+    public SystemLauncher(String[] cmds) {\r
+        this.cmds = cmds;\r
+    }\r
+\r
+    public void run() throws Exception {\r
+        final AtomicReference<Exception> exRef = new AtomicReference<Exception>();\r
+        SWTUtil.syncExec(new Runnable() {\r
+            @Override\r
+            public void run() {\r
+                try {\r
+                    runSystemCommnad(cmds);\r
+                } catch (Exception e) {\r
+                    exRef.set(e);\r
+                }\r
+            }\r
+        });\r
+        Exception ex = exRef.get();\r
+        if (ex != null) {\r
+            throw ex;\r
+        }\r
+    }\r
+\r
+    private void runSystemCommnad(String[] cmds) throws Exception {\r
+        String cmd = CollectionUtil.concatenate(cmds, " ");\r
+        HostUtil.executeWithConsole(cmd, ConsoleCommand.CONSOLE_NAME);\r
+    }\r
+}\r
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/launcher/TimeLauncher.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/launcher/TimeLauncher.java
new file mode 100644 (file)
index 0000000..640ffd5
--- /dev/null
@@ -0,0 +1,88 @@
+/*\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.command.launcher;\r
+\r
+import org.apache.commons.lang3.time.StopWatch;\r
+\r
+public class TimeLauncher implements Runnable {\r
+    static boolean isRunning;\r
+    private Thread thread;\r
+    static StopWatch stopWatch = new StopWatch();\r
+    static TimeLauncher _instance = new TimeLauncher();\r
+\r
+    public static TimeLauncher getInstance() {\r
+        return _instance;\r
+    }\r
+\r
+    private TimeLauncher() {\r
+    }\r
+\r
+    public void start() {\r
+        stopWatch.start();\r
+\r
+        isRunning = true;\r
+        thread = new Thread(this);\r
+        thread.setName("TimeLauncherThread");\r
+        thread.setDaemon(true);\r
+        thread.start();\r
+    }\r
+\r
+    public long stop() throws Exception {\r
+        stopWatch.stop();\r
+        long elapsed = getElapsedTime();\r
+        stopWatch.reset();\r
+\r
+        isRunning = false;\r
+        if (thread != null) {\r
+            Thread t = thread;\r
+            thread = null;\r
+            t.interrupt();\r
+        }\r
+\r
+        return elapsed;\r
+    }\r
+\r
+    public long getElapsedTime() {\r
+        return stopWatch.getTime();\r
+    }\r
+\r
+    protected boolean isRunning() {\r
+        return isRunning;\r
+    }\r
+\r
+    @Override\r
+    public void run() {\r
+        while (isRunning()) {\r
+            try {\r
+                Thread.sleep(30 * 1000);\r
+            } catch (InterruptedException e) {\r
+            }\r
+        }\r
+    }\r
+}\r
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/launcher/TizenHandler.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/command/launcher/TizenHandler.java
new file mode 100644 (file)
index 0000000..ae5ae25
--- /dev/null
@@ -0,0 +1,100 @@
+/*\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.command.launcher;\r
+\r
+import java.io.OutputStream;\r
+import java.util.List;\r
+\r
+import howdoi.Handler;\r
+\r
+import org.jsoup.helper.StringUtil;\r
+import org.jsoup.nodes.Document;\r
+\r
+public class TizenHandler implements Handler {\r
+    private final String HOST = "https://developer.tizen.org";\r
+\r
+    public boolean isQuestion(String link) {\r
+        return true;\r
+    }\r
+\r
+    public String getAnswerQueryString() {\r
+        return "";\r
+    }\r
+\r
+    private boolean isHelp(String link) {\r
+        return link.matches(HOST + "/help/.*");\r
+    }\r
+\r
+    private boolean isForum(String link) {\r
+        return link.matches(HOST + "/forums/.*");\r
+    }\r
+\r
+    private static String left(String str, int len) {\r
+        if (str == null)\r
+            return null;\r
+        if (len < 0)\r
+            return "";\r
+        if (str.length() <= len)\r
+            return str;\r
+        else\r
+            return str.substring(0, len);\r
+    }\r
+\r
+    public String getAnswer(String link, Document doc, OutputStream out) throws Exception {\r
+        String title = doc.select("title").get(0).text();\r
+        String answer = "";\r
+        if (isForum(link)) {\r
+            String post = doc.select(".field-item").get(0).text();\r
+            String count = doc.select(".topic-post-count").get(0).text();\r
+            answer = String.format("%s (%s)\n" + // title & replies\r
+                " >%s\n" + // link\r
+                " >%s...", // Post (Max: 200 chars)\r
+                title, count, link, left(post, 200));\r
+        } else {\r
+            answer = String.format("%s\n" + // title\r
+                " >%s", // link\r
+                title, link);\r
+        }\r
+        //answer += "\n";\r
+        //out.write(answer.getBytes("UTF-8"));\r
+        //out.flush();\r
+        return answer;\r
+    }\r
+\r
+    public boolean useCustomFormat() {\r
+        return true;\r
+    }\r
+\r
+    public String formatOutput(List<String> answers) {\r
+        return String.format("\n" +\r
+            "Answers\n" +\r
+            "-------\n" +\r
+            "%s", StringUtil.join(answers, "\n"));\r
+    }\r
+}\r
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/textAssist/CommandProvider.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/textAssist/CommandProvider.java
new file mode 100644 (file)
index 0000000..30a40eb
--- /dev/null
@@ -0,0 +1,92 @@
+/*\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.textAssist;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.regex.Matcher;\r
+import java.util.regex.Pattern;\r
+\r
+import org.tizen.common.ui.commandbar.Messages;\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
+\r
+    @Override\r
+    public List<String[]> getContent(final String entry) {\r
+        final List<String[]> returnedList = new ArrayList<String[]>();\r
+\r
+        String key = entry.toLowerCase();\r
+        for (final String[] message : Messages.HELP) {\r
+            if (message[0].toLowerCase().startsWith(key)) {\r
+                returnedList.add(message);\r
+            }\r
+            if (message[0].toLowerCase().startsWith(Messages.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
+                            if (cmd.startsWith(cmdKey)) {\r
+                                returnedList.add(new String[] { sdbCommand + " " + cmd, "" });\r
+                            }\r
+                        }\r
+                    } else {\r
+                        for (String cmd : Messages.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
+    }\r
+}\r
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/textAssist/TextAssist.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/textAssist/TextAssist.java
new file mode 100644 (file)
index 0000000..bae8db3
--- /dev/null
@@ -0,0 +1,902 @@
+/*******************************************************************************\r
+ * Copyright (c) 2011 Laurent CARON.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     IBM Corporation - initial API and implementation (Snippet 320)\r
+ *     Laurent CARON (laurent.caron@gmail.com) - Make a widget from the snippet\r
+ *******************************************************************************/\r
+package org.tizen.common.ui.commandbar.textAssist;\r
+\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
+import org.eclipse.swt.custom.StyledText;\r
+import org.eclipse.swt.events.ModifyListener;\r
+import org.eclipse.swt.events.SelectionListener;\r
+import org.eclipse.swt.events.VerifyListener;\r
+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
+import org.eclipse.swt.graphics.Rectangle;\r
+import org.eclipse.swt.layout.FillLayout;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Display;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Listener;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.swt.widgets.Table;\r
+import org.eclipse.swt.widgets.TableColumn;\r
+import org.eclipse.swt.widgets.TableItem;\r
+import org.eclipse.swt.widgets.Widget;\r
+import org.tizen.common.util.ObjectUtil;\r
+import org.tizen.common.util.SWTUtil;\r
+\r
+/**\r
+ * Instances of this class are selectable user interface objects that allow the\r
+ * user to enter and modify text. The difference with the Text widget is that\r
+ * when the user types something, some propositions are displayed.\r
+ * \r
+ * @see org.eclipse.swt.widgets.Text\r
+ */\r
+public class TextAssist extends Composite {\r
+\r
+    private final StyledText text;\r
+    private final Shell popup;\r
+    private final Table table;\r
+    private TextAssistContentProvider contentProvider;\r
+    private int numberOfLines = 20;\r
+\r
+    final int TEXT_MARGIN = 3;\r
+    private Font HELP_COMMAND_FONT;\r
+    private Color HELP_COMMAND_DESC_COLOR;\r
+    private Color HELP_SEPARATOR_COLOR;\r
+    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
+    private int MAX_HISTORY = 5;\r
+    private Stack<String> historyStack;\r
+    private int historyPos;\r
+    static Image oldImage;\r
+\r
+    private static final int STATE_TABLE_UNFOCUSED = 0;\r
+    private static final int STATE_TABLE_FOCUSED = 1;\r
+    private int tableState = STATE_TABLE_UNFOCUSED;\r
+\r
+    /**\r
+     * Constructs a new instance of this class given its parent and a style\r
+     * value describing its behavior and appearance.\r
+     * <p>\r
+     * The style value is either one of the style constants defined in class\r
+     * <code>SWT</code> which is applicable to instances of this class, or must\r
+     * be built by <em>bitwise OR</em>'ing together (that is, using the\r
+     * <code>int</code> "|" operator) two or more of those <code>SWT</code>\r
+     * style constants. The class description lists the style constants that are\r
+     * applicable to the class. Style bits are also inherited from superclasses.\r
+     * </p>\r
+     * \r
+     * @param parent a composite control which will be the parent of the new\r
+     *            instance (cannot be null)\r
+     * @param style the style of control to construct\r
+     * @param contentProvider the content provider\r
+     * \r
+     * @exception IllegalArgumentException <ul>\r
+     *                <li>ERROR_NULL_ARGUMENT - if the parent is null</li>\r
+     *                </ul>\r
+     * @exception SWTException <ul>\r
+     *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the\r
+     *                thread that created the parent</li>\r
+     *                <li>ERROR_INVALID_SUBCLASS - if this class is not an\r
+     *                allowed subclass</li>\r
+     *                </ul>\r
+     * \r
+     * @see SWT#SINGLE\r
+     * @see SWT#MULTI\r
+     * @see SWT#READ_ONLY\r
+     * @see SWT#WRAP\r
+     * @see SWT#LEFT\r
+     * @see SWT#RIGHT\r
+     * @see SWT#CENTER\r
+     * @see SWT#PASSWORD\r
+     * @see SWT#SEARCH\r
+     * @see SWT#ICON_SEARCH\r
+     * @see SWT#ICON_CANCEL\r
+     * @see Widget#checkSubclass\r
+     * @see Widget#getStyle\r
+     */\r
+    public TextAssist(final Composite parent, final int style, final TextAssistContentProvider contentProvider) {\r
+        super(parent, style);\r
+        this.contentProvider = contentProvider;\r
+        this.contentProvider.setTextAssist(this);\r
+\r
+        this.setLayout(new FillLayout());\r
+        this.text = new StyledText(this, style | SWT.BORDER);\r
+        this.popup = new Shell(this.getDisplay(), SWT.ON_TOP);\r
+        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.Modify, createModifyListener());\r
+        this.text.addListener(SWT.FocusOut, createFocusOutListener());\r
+\r
+        Listener listener = createSelectionListener();\r
+        this.table.addListener(SWT.DefaultSelection, listener);\r
+        this.table.addListener(SWT.MouseDown, listener);\r
+        this.table.addListener(SWT.KeyDown, new Listener() {\r
+            @Override\r
+            public void handleEvent(final Event event) {\r
+                int index = -1;\r
+                switch (event.keyCode) {\r
+                case SWT.ESC:\r
+                    TextAssist.this.popup.setVisible(false);\r
+                    break;\r
+                case SWT.ARROW_DOWN:\r
+                    index = Math.min(TextAssist.this.table.getItemCount() - 1, TextAssist.this.table.getSelectionIndex() + 1) % TextAssist.this.table.getItemCount();\r
+                    handleArrowKey(index, event, true);\r
+                    break;\r
+                case SWT.ARROW_UP:\r
+                    index = Math.max(0, TextAssist.this.table.getSelectionIndex() - 1);\r
+                    handleArrowKey(index, event, true);\r
+                    break;\r
+                }\r
+            }\r
+        });\r
+\r
+        this.table.addListener(SWT.FocusOut, createFocusOutListener());\r
+\r
+        getShell().addListener(SWT.Move, new Listener() {\r
+            @Override\r
+            public void handleEvent(final Event event) {\r
+                TextAssist.this.popup.setVisible(false);\r
+            }\r
+        });\r
+\r
+        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
+        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
+                    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
+        // 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
+        //  it does not work when Console view is selected (org.eclipse.ui.console.actions.TextViewerAction)\r
+        // So, I should implement key listener for CTRL-A, CTRL-C and CTRL-V.\r
+        // cf.)) http://wiki.eclipse.org/FAQ_How_do_I_hook_into_global_actions,_such_as_Copy_and_Delete%3F\r
+        //  Each view or editor is allowed to contribute a handler for these actions; when a new part becomes active, its handler takes control of that action.\r
+        text.addListener(SWT.KeyUp, new Listener() {\r
+            @Override\r
+            public void handleEvent(Event event) {\r
+                if (event.stateMask == SWT.MOD1) {\r
+                    if (event.keyCode == 'A' || event.keyCode == 'a') {\r
+                        text.selectAll();\r
+                    }\r
+                    else if (event.keyCode == 'C' || event.keyCode == 'c') {\r
+                        text.copy();\r
+                    }\r
+                    else if (event.keyCode == 'V' || event.keyCode == 'v') {\r
+                        text.paste();\r
+                    }\r
+                }\r
+            }\r
+        });\r
+        this.text.addListener(SWT.MouseDown, new Listener() {\r
+            @Override\r
+            public void handleEvent(Event event) {\r
+                text.selectAll();\r
+            }\r
+        });\r
+        this.text.addListener(SWT.Resize, new Listener() {\r
+            public void handleEvent(Event event) {\r
+                Display display = SWTUtil.getDisplay();\r
+                Rectangle rect = text.getClientArea();\r
+                Image newImage = new Image(display, Math.max(1, rect.width), Math.max(1, rect.height));\r
+                GC gc = new GC(newImage);\r
+                gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));\r
+                gc.setBackground(new Color(display, 240, 240, 240));\r
+                //gc.setBackground(new Color(display, 204, 204, 209));\r
+                gc.fillGradientRectangle(rect.x + 100, rect.y, rect.width, rect.height, false);\r
+                gc.dispose();\r
+                text.setBackgroundImage(newImage);\r
+                SWTUtil.tryDispose(oldImage);\r
+                oldImage = newImage;\r
+            }\r
+        });\r
+        column1 = new TableColumn(table, SWT.NONE);\r
+        column2 = new TableColumn(table, SWT.NONE);\r
+\r
+        historyStack = new Stack<String>();\r
+    }\r
+\r
+    @Override\r
+    public void dispose() {\r
+        SWTUtil.tryDispose(HELP_SEPARATOR_COLOR, HELP_COMMAND_DESC_COLOR, HELP_COMMAND_FONT);\r
+        super.dispose();\r
+    }\r
+\r
+    private Listener createSelectionListener() {\r
+        return new Listener() {\r
+            @Override\r
+            public void handleEvent(final Event event) {\r
+                String text = TextAssist.this.table.getSelection()[0].getText();\r
+                TextAssist.this.text.setText(text);\r
+                TextAssist.this.popup.setVisible(false);\r
+                fireTableSelection(text);\r
+            }\r
+        };\r
+    }\r
+\r
+    private boolean isPopupShown() {\r
+        return TextAssist.this.popup.isVisible();\r
+    }\r
+\r
+    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
+        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
+        return new Listener() {\r
+            @Override\r
+            public void handleEvent(final Event event) {\r
+                int index = -1;\r
+                switch (event.keyCode) {\r
+                case SWT.ARROW_DOWN:\r
+                    if (TextAssist.this.table.getItemCount() > 0) {\r
+                        index = (TextAssist.this.table.getSelectionIndex() + 1) % TextAssist.this.table.getItemCount();\r
+                    }\r
+                    handleArrowKey(index, event, false);\r
+                    break;\r
+                case SWT.ARROW_UP:\r
+                    index = TextAssist.this.table.getSelectionIndex() - 1;\r
+                    if (index < 0) {\r
+                        index = TextAssist.this.table.getItemCount() - 1;\r
+                    }\r
+                    handleArrowKey(index, event, false);\r
+                    break;\r
+                case SWT.CR:\r
+                    if (TextAssist.this.popup.isVisible() && TextAssist.this.table.getSelectionIndex() != -1) {\r
+                        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
+                case SWT.ESC:\r
+                    TextAssist.this.popup.setVisible(false);\r
+                    tableState = STATE_TABLE_UNFOCUSED;\r
+                    break;\r
+                    \r
+                default:\r
+                    break;\r
+                }\r
+            }\r
+        };\r
+    }\r
+\r
+    private void showHistory(int arrow) {\r
+        if (historyStack.isEmpty())\r
+            return;\r
+\r
+        switch (arrow) {\r
+        case SWT.ARROW_UP:\r
+            historyPos = Math.max(0, --historyPos);\r
+            break;\r
+        case SWT.ARROW_DOWN:\r
+            historyPos = Math.min(historyStack.size() - 1, ++historyPos);\r
+            break;\r
+        }\r
+        TextAssist.this.text.setText(historyStack.get(historyPos));\r
+        selectAll();\r
+    }\r
+\r
+    private void addHistory(String text) {\r
+        if (historyStack.size() == MAX_HISTORY)\r
+            historyStack.remove(historyStack.firstElement());\r
+        historyStack.push(text);\r
+        historyPos = historyStack.size() - 1;\r
+    }\r
+\r
+    private Font deriveFont(Font font, int style) {\r
+        FontData[] fontData = font.getFontData();\r
+        for(FontData fontDatum : fontData)\r
+            fontDatum.setStyle(fontDatum.getStyle() | style);\r
+\r
+        return new Font(getDisplay(), fontData);\r
+    }\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
+            final TableItem tableItem = new TableItem(TextAssist.this.table, SWT.NONE);\r
+            tableItem.setFont(0, HELP_COMMAND_FONT);\r
+            tableItem.setForeground(1, HELP_COMMAND_DESC_COLOR);\r
+            tableItem.setText(values.get(i));\r
+            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
+        column2.pack();\r
+\r
+        final Point point = TextAssist.this.text.toDisplay(TextAssist.this.text.getLocation().x, TextAssist.this.text.getSize().y + TextAssist.this.text.getBorderWidth() - 3);\r
+        int x = point.x;\r
+        int y = point.y;\r
+\r
+        final Rectangle displayRect = getMonitor().getClientArea();\r
+        final Rectangle parentRect = getDisplay().map(getParent(), null, getBounds());\r
+        TextAssist.this.popup.pack();\r
+        final int width = TextAssist.this.popup.getBounds().width;\r
+        final int height = TextAssist.this.popup.getBounds().height;\r
+\r
+        if (y + height > displayRect.y + displayRect.height) {\r
+            y = parentRect.y - height;\r
+        }\r
+        if (x + width > displayRect.x + displayRect.width) {\r
+            x = displayRect.x + displayRect.width - width;\r
+        }\r
+\r
+        TextAssist.this.popup.setLocation(x, y);\r
+        TextAssist.this.popup.setVisible(true);\r
+    }\r
+\r
+    /**\r
+     * @return a listener for the modify event\r
+     */\r
+    private Listener createModifyListener() {\r
+        return new Listener() {\r
+            @Override\r
+            public void handleEvent(final Event event) {\r
+                // If the popup is shown, the text is displayed by arrow key in the popup.\r
+                // So, the popup should be not filtered by the displayed text.\r
+                if (tableState == STATE_TABLE_FOCUSED) {\r
+                    return;\r
+                }\r
+                final String string = TextAssist.this.text.getText();\r
+                if (string.length() == 0) {\r
+                    TextAssist.this.popup.setVisible(false);\r
+                    return;\r
+                }\r
+\r
+                List<String[]> values = TextAssist.this.contentProvider.getContent(string);\r
+                if (values == null || values.isEmpty()) {\r
+                    TextAssist.this.popup.setVisible(false);\r
+                    return;\r
+                }\r
+\r
+                if (values.size() > TextAssist.this.numberOfLines) {\r
+                    values = values.subList(0, TextAssist.this.numberOfLines);\r
+                }\r
+\r
+                showPopup(values);\r
+\r
+            }\r
+        };\r
+    }\r
+\r
+    /**\r
+     * @return a listener for the FocusOut event\r
+     */\r
+    private Listener createFocusOutListener() {\r
+        return new Listener() {\r
+            @Override\r
+            public void handleEvent(final Event event) {\r
+                /* async is needed to wait until focus reaches its new Control */\r
+                TextAssist.this.getDisplay().asyncExec(new Runnable() {\r
+                    @Override\r
+                    public void run() {\r
+                        if (TextAssist.this.getDisplay().isDisposed()) {\r
+                            return;\r
+                        }\r
+                        final Control control = TextAssist.this.getDisplay().getFocusControl();\r
+                        if (control == null || control != TextAssist.this.text && control != TextAssist.this.table) {\r
+                            TextAssist.this.popup.setVisible(false);\r
+                        }\r
+                    }\r
+                });\r
+            }\r
+        };\r
+    }\r
+\r
+    /**\r
+     * @return the contentProvider\r
+     */\r
+    public TextAssistContentProvider getContentProvider() {\r
+        checkWidget();\r
+        return this.contentProvider;\r
+    }\r
+\r
+    /**\r
+     * @param contentProvider the contentProvider to set\r
+     */\r
+    public void setContentProvider(final TextAssistContentProvider contentProvider) {\r
+        checkWidget();\r
+        this.contentProvider = contentProvider;\r
+    }\r
+\r
+    /**\r
+     * @return the numberOfLines\r
+     */\r
+    public int getNumberOfLines() {\r
+        checkWidget();\r
+        return this.numberOfLines;\r
+    }\r
+\r
+    /**\r
+     * @param numberOfLines the numberOfLines to set\r
+     */\r
+    public void setNumberOfLines(final int numberOfLines) {\r
+        checkWidget();\r
+        this.numberOfLines = numberOfLines;\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#addModifyListener(org.eclipse.swt.events.ModifyListener)\r
+     */\r
+    public void addModifyListener(final ModifyListener listener) {\r
+        checkWidget();\r
+        this.text.addModifyListener(listener);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#addSelectionListener(org.eclipse.swt.events.SelectionListener)\r
+     */\r
+    public void addSelectionListener(final SelectionListener listener) {\r
+        checkWidget();\r
+        this.text.addSelectionListener(listener);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#addVerifyListener(org.eclipse.swt.events.VerifyListener)\r
+     */\r
+    public void addVerifyListener(final VerifyListener listener) {\r
+        checkWidget();\r
+        this.text.addVerifyListener(listener);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#append(java.lang.String)\r
+     */\r
+    public void append(final String string) {\r
+        checkWidget();\r
+        this.text.append(string);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#computeSize(int, int, boolean)\r
+     */\r
+    @Override\r
+    public Point computeSize(final int wHint, final int hHint, final boolean changed) {\r
+        checkWidget();\r
+        return this.text.computeSize(wHint, hHint, changed);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#computeTrim(int, int, int, int)\r
+     */\r
+    @Override\r
+    public Rectangle computeTrim(final int x, final int y, final int width, final int height) {\r
+        checkWidget();\r
+        return super.computeTrim(x, y, width, height);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#copy()\r
+     */\r
+    public void copy() {\r
+        checkWidget();\r
+        this.text.copy();\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#cut()\r
+     */\r
+    public void cut() {\r
+        checkWidget();\r
+        this.text.cut();\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#getCharCount()\r
+     */\r
+    public int getCharCount() {\r
+        checkWidget();\r
+        return this.text.getCharCount();\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#getDoubleClickEnabled()\r
+     */\r
+    public boolean getDoubleClickEnabled() {\r
+        checkWidget();\r
+        return this.text.getDoubleClickEnabled();\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#getEditable()\r
+     */\r
+    public boolean getEditable() {\r
+        checkWidget();\r
+        return this.text.getEditable();\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#getLineCount()\r
+     */\r
+    public int getLineCount() {\r
+        checkWidget();\r
+        return this.text.getLineCount();\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#getLineDelimiter()\r
+     */\r
+    public String getLineDelimiter() {\r
+        checkWidget();\r
+        return this.text.getLineDelimiter();\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#getLineHeight()\r
+     */\r
+    public int getLineHeight() {\r
+        checkWidget();\r
+        return this.text.getLineHeight();\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#getOrientation()\r
+     */\r
+    public int getOrientation() {\r
+        checkWidget();\r
+        return this.text.getOrientation();\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#getSelection()\r
+     */\r
+    public Point getSelection() {\r
+        checkWidget();\r
+        return this.text.getSelection();\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#getSelectionCount()\r
+     */\r
+    public int getSelectionCount() {\r
+        checkWidget();\r
+        return this.text.getSelectionCount();\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#getSelectionText()\r
+     */\r
+    public String getSelectionText() {\r
+        checkWidget();\r
+        return this.text.getSelectionText();\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#getTabs()\r
+     */\r
+    public int getTabs() {\r
+        checkWidget();\r
+        return this.text.getTabs();\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#getText()\r
+     */\r
+    public String getText() {\r
+        checkWidget();\r
+        return this.text.getText();\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#getText(int, int)\r
+     */\r
+    public String getText(final int start, final int end) {\r
+        checkWidget();\r
+        return this.text.getText(start, end);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#getTextLimit()\r
+     */\r
+    public int getTextLimit() {\r
+        checkWidget();\r
+        return this.text.getTextLimit();\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#getTopIndex()\r
+     */\r
+    public int getTopIndex() {\r
+        checkWidget();\r
+        return this.text.getTopIndex();\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#getTopPixel()\r
+     */\r
+    public int getTopPixel() {\r
+        checkWidget();\r
+        return this.text.getTopPixel();\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#insert(java.lang.String)\r
+     */\r
+    public void insert(final String string) {\r
+        checkWidget();\r
+        this.text.insert(string);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#paste()\r
+     */\r
+    public void paste() {\r
+        checkWidget();\r
+        this.text.paste();\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#removeModifyListener(org.eclipse.swt.events.ModifyListener)\r
+     */\r
+    public void removeModifyListener(final ModifyListener listener) {\r
+        checkWidget();\r
+        this.text.removeModifyListener(listener);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#removeSelectionListener(org.eclipse.swt.events.SelectionListener)\r
+     */\r
+    public void removeSelectionListener(final SelectionListener listener) {\r
+        checkWidget();\r
+        this.text.removeSelectionListener(listener);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#removeVerifyListener(org.eclipse.swt.events.VerifyListener)\r
+     */\r
+    public void removeVerifyListener(final VerifyListener listener) {\r
+        checkWidget();\r
+        this.text.removeVerifyListener(listener);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#selectAll()\r
+     */\r
+    public void selectAll() {\r
+        checkWidget();\r
+        this.text.selectAll();\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#setDoubleClickEnabled(boolean)\r
+     */\r
+    public void setDoubleClickEnabled(final boolean doubleClick) {\r
+        checkWidget();\r
+        this.text.setDoubleClickEnabled(doubleClick);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#setEditable(boolean)\r
+     */\r
+    public void setEditable(final boolean editable) {\r
+        checkWidget();\r
+        this.text.setEditable(editable);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#setFont(org.eclipse.swt.graphics.Font)\r
+     */\r
+    @Override\r
+    public void setFont(final Font font) {\r
+        checkWidget();\r
+        this.text.setFont(font);\r
+        this.table.setFont(font);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#setOrientation(int)\r
+     */\r
+    public void setOrientation(final int orientation) {\r
+        checkWidget();\r
+        this.text.setOrientation(orientation);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#setRedraw(boolean)\r
+     */\r
+    @Override\r
+    public void setRedraw(final boolean redraw) {\r
+        checkWidget();\r
+        this.text.setRedraw(redraw);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#setSelection(int, int)\r
+     */\r
+    public void setSelection(final int start, final int end) {\r
+        checkWidget();\r
+        this.text.setSelection(start, end);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#setSelection(int)\r
+     */\r
+    public void setSelection(final int start) {\r
+        checkWidget();\r
+        this.text.setSelection(start);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#setSelection(org.eclipse.swt.graphics.Point)\r
+     */\r
+    public void setSelection(final Point selection) {\r
+        checkWidget();\r
+        this.text.setSelection(selection);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#setTabs(int)\r
+     */\r
+    public void setTabs(final int tabs) {\r
+        checkWidget();\r
+        this.text.setTabs(tabs);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#setText(java.lang.String)\r
+     */\r
+    public void setText(final String text) {\r
+        checkWidget();\r
+        this.text.setText(text);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#setTextLimit(int)\r
+     */\r
+    public void setTextLimit(final int textLimit) {\r
+        checkWidget();\r
+        this.text.setTextLimit(textLimit);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#setTopIndex(int)\r
+     */\r
+    public void setTopIndex(final int topIndex) {\r
+        checkWidget();\r
+        this.text.setTopIndex(topIndex);\r
+    }\r
+\r
+    /**\r
+     * @see org.eclipse.swt.widgets.Text#showSelection()\r
+     */\r
+    public void showSelection() {\r
+        checkWidget();\r
+        this.text.showSelection();\r
+    }\r
+\r
+    public StyledText getTextControl() {\r
+        return text;\r
+    }\r
+\r
+    public Table getTableControl() {\r
+        return table;\r
+    }\r
+\r
+    protected void fireSubmit(String text) {\r
+        for (SubmitListener listener : submitListenerList)\r
+            listener.onSubmit(text);\r
+    }\r
+\r
+    protected void fireTableSelection(String text) {\r
+        for (TableSelectionListener listener : tableSelectionListenerList)\r
+            listener.onTableSelection(text);\r
+    }\r
+\r
+    public void addSubmitListener(SubmitListener listener) {\r
+        submitListenerList.add(listener);\r
+    }\r
+\r
+    public void removeSubmitListener(SubmitListener listener) {\r
+        submitListenerList.remove(listener);\r
+    }\r
+\r
+    public void addTableSelectionListener(TableSelectionListener listener) {\r
+        tableSelectionListenerList.add(listener);\r
+    }\r
+\r
+    public void removeTableSelectionListener(TableSelectionListener listener) {\r
+        tableSelectionListenerList.remove(listener);\r
+    }\r
+\r
+    public interface SubmitListener {\r
+        void onSubmit(String text);\r
+    }\r
+\r
+    public interface TableSelectionListener {\r
+        void onTableSelection(String text);\r
+    }\r
+}\r
diff --git a/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/textAssist/TextAssistContentProvider.java b/org.tizen.common.ui/src/org/tizen/common/ui/commandbar/textAssist/TextAssistContentProvider.java
new file mode 100644 (file)
index 0000000..0cd07cb
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************\r
+ * Copyright (c) 2011 Laurent CARON.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     Laurent CARON (laurent.caron@gmail.com) - initial API and implementation\r
+ *******************************************************************************/\r
+package org.tizen.common.ui.commandbar.textAssist;\r
+\r
+import java.util.List;\r
+\r
+/**\r
+ * This class is a content provider for the TextAssist widget. When the user\r
+ * types something, an instance returns an arraylist of proposition based on the\r
+ * typed text.\r
+ * \r
+ */\r
+public abstract class TextAssistContentProvider {\r
+    private TextAssist textAssist;\r
+\r
+    /**\r
+     * Provides the content\r
+     * \r
+     * @param entry text typed by the user\r
+     * @return an array list of String that contains propositions for the entry\r
+     *         typed by the user\r
+     */\r
+    public abstract List<String[]> getContent(final String entry);\r
+\r
+    /**\r
+     * @param textAssist the textAssist to set\r
+     */\r
+    protected void setTextAssist(final TextAssist textAssist) {\r
+        this.textAssist = textAssist;\r
+    }\r
+\r
+    /**\r
+     * @return the max number of propositions.\r
+     */\r
+    protected int getMaxNumberOfLines() {\r
+        return this.textAssist.getNumberOfLines();\r
+    }\r
+}\r