[Title]Move smart launch to common and support web/native(+profile) launch
authorhyunsik.noh <hyunsik.noh@samsung.com>
Mon, 13 May 2013 05:15:05 +0000 (14:15 +0900)
committerhyunsik.noh <hyunsik.noh@samsung.com>
Mon, 13 May 2013 12:53:40 +0000 (21:53 +0900)
Change UI and structure
[Type]
[Module]common
[Priority]
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]

Change-Id: I3f5c850da4efd1fb720bfcfb795dbab5da4292e2

32 files changed:
org.tizen.common.feature/feature.xml
org.tizen.common.gom/.classpath [new file with mode: 0644]
org.tizen.common.gom/.project [new file with mode: 0644]
org.tizen.common.gom/META-INF/MANIFEST.MF [new file with mode: 0644]
org.tizen.common.gom/OSGI-INF/l10n/bundle.properties [new file with mode: 0644]
org.tizen.common.gom/build.properties [new file with mode: 0644]
org.tizen.common.gom/icons/default_project_icon.png [new file with mode: 0644]
org.tizen.common.gom/icons/smart_launch.png [new file with mode: 0644]
org.tizen.common.gom/plugin.xml [new file with mode: 0644]
org.tizen.common.gom/src/org/tizen/common/gom/GomPlugin.java [new file with mode: 0644]
org.tizen.common.gom/src/org/tizen/common/gom/launch/GomLaunchData.java [new file with mode: 0644]
org.tizen.common.gom/src/org/tizen/common/gom/launch/IGomSmartLaunchShortcut.java [new file with mode: 0644]
org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/GomSmartLaunchManager.java [new file with mode: 0644]
org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/GomSmartLauncher.java [new file with mode: 0644]
org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/action/GomSmartLaunchAction.java [new file with mode: 0644]
org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/action/GomSmartLaunchToolbarAction.java [new file with mode: 0644]
org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/handler/GomSmartLaunchCycleHandler.java [new file with mode: 0644]
org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/handler/GomSmartLaunchHandler.java [new file with mode: 0644]
org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/messages/GomMessages.java [new file with mode: 0644]
org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/messages/GomMessages.properties [new file with mode: 0644]
org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/ui/GomContentProvider.java [new file with mode: 0644]
org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/ui/GomDialog.java [new file with mode: 0644]
org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/ui/GomLabelProvider.java [new file with mode: 0644]
org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/ui/GomTreeViewer.java [new file with mode: 0644]
org.tizen.common/META-INF/MANIFEST.MF
org.tizen.common/src/org/tizen/common/adapter/ITizenLaunchConfiguration.java [new file with mode: 0644]
org.tizen.common/src/org/tizen/common/adapter/ITizenNativeLaunchConfiguration.java [new file with mode: 0644]
org.tizen.common/src/org/tizen/common/adapter/ITizenNativeProject.java [new file with mode: 0644]
org.tizen.common/src/org/tizen/common/adapter/ITizenProject.java [new file with mode: 0644]
org.tizen.common/src/org/tizen/common/adapter/ITizenWebLaunchConfiguration.java [new file with mode: 0644]
org.tizen.common/src/org/tizen/common/adapter/ITizenWebProject.java [new file with mode: 0644]
org.tizen.common/src/org/tizen/common/util/ProjectUtil.java

index 8214501..46ea31f 100755 (executable)
          version="0.0.0"
          unpack="false"/>
 
+   <plugin
+         id="org.tizen.common.gom"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
 </feature>
diff --git a/org.tizen.common.gom/.classpath b/org.tizen.common.gom/.classpath
new file mode 100644 (file)
index 0000000..ad32c83
--- /dev/null
@@ -0,0 +1,7 @@
+<?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>
diff --git a/org.tizen.common.gom/.project b/org.tizen.common.gom/.project
new file mode 100644 (file)
index 0000000..6fac219
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.tizen.common.gom</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.tizen.common.gom/META-INF/MANIFEST.MF b/org.tizen.common.gom/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..442502b
--- /dev/null
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.tizen.common.gom;singleton:=true
+Bundle-Version: 2.0.0.qualifier
+Bundle-Activator: org.tizen.common.gom.GomPlugin
+Bundle-Vender: %Bundle-Vendor
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.ui
+Bundle-ClassPath: .
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.eclipse.core.resources,
+ org.eclipse.debug.core,
+ org.eclipse.debug.internal.ui,
+ org.eclipse.debug.internal.ui.launchConfigurations,
+ org.eclipse.debug.ui,
+ org.eclipse.debug.ui.actions,
+ org.eclipse.jface.dialogs,
+ org.eclipse.swt,
+ org.eclipse.swt.graphics,
+ org.eclipse.swt.widgets,
+ org.slf4j,
+ org.tizen.common,
+ org.tizen.common.adapter,
+ org.tizen.common.connection,
+ org.tizen.common.util,
+ org.tizen.common.util.log,
+ org.tizen.sdblib
+Export-Package: org.tizen.common.gom.launch,
+ org.tizen.common.gom.smartlaunch
+Bundle-ActivationPolicy: lazy
diff --git a/org.tizen.common.gom/OSGI-INF/l10n/bundle.properties b/org.tizen.common.gom/OSGI-INF/l10n/bundle.properties
new file mode 100644 (file)
index 0000000..e6712c2
--- /dev/null
@@ -0,0 +1,5 @@
+Bundle-Name = Tizen Common Gom Tools - Smart Launch
+Bundle-Vendor = The Linux Foundation
+
+Gom.SmartLaunch.Label=Smart Launch
+Gom.SmartLaunch.Tooltip=Smart Launch
\ No newline at end of file
diff --git a/org.tizen.common.gom/build.properties b/org.tizen.common.gom/build.properties
new file mode 100644 (file)
index 0000000..e9863e2
--- /dev/null
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml
diff --git a/org.tizen.common.gom/icons/default_project_icon.png b/org.tizen.common.gom/icons/default_project_icon.png
new file mode 100644 (file)
index 0000000..d1d5cf3
Binary files /dev/null and b/org.tizen.common.gom/icons/default_project_icon.png differ
diff --git a/org.tizen.common.gom/icons/smart_launch.png b/org.tizen.common.gom/icons/smart_launch.png
new file mode 100644 (file)
index 0000000..d339df0
Binary files /dev/null and b/org.tizen.common.gom/icons/smart_launch.png differ
diff --git a/org.tizen.common.gom/plugin.xml b/org.tizen.common.gom/plugin.xml
new file mode 100644 (file)
index 0000000..fb35c90
--- /dev/null
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+   <extension
+         point="org.eclipse.ui.actionSets">
+      <actionSet id="org.eclipse.debug.ui.SmartLaunchActionSet"
+               label="%Gom.SmartLaunch.Label">
+       <action
+             class="org.tizen.common.gom.smartlaunch.action.GomSmartLaunchToolbarAction"
+             icon="icons/smart_launch.png"
+             id="org.eclipse.debug.ui.SmartLaunchActionSet"
+             label="%Gom.SmartLaunch.Label"
+             style="pulldown"
+             toolbarPath="buildConfig"
+             tooltip="%Gom.SmartLaunch.Tooltip"/>
+      </actionSet>
+    </extension>
+    <extension
+          point="org.eclipse.ui.commands">
+       <command
+             categoryId="org.tizen.common.gom.category"
+             defaultHandler="org.tizen.common.gom.smartlaunch.handler.GomSmartLaunchCycleHandler:true"
+             id="org.tizen.common.gom.smartlaunch.ui.tizensmartlauncher.up"
+             name="Backward Launch History">
+       </command>
+       <command
+             categoryId="org.tizen.common.gom.category"
+             defaultHandler="org.tizen.common.gom.smartlaunch.handler.GomSmartLaunchCycleHandler:true"
+             id="org.tizen.common.gom.smartlaunch.ui.tizensmartlauncher.down"
+             name="Forward Launch History">
+       </command>
+       <command
+             categoryId="org.tizen.common.gom.category"
+             defaultHandler="org.tizen.common.gom.smartlaunch.handler.GomSmartLaunchHandler:true"
+             id="org.tizen.common.gom.smartlaunch.ui.tizensmartlauncher.new"
+             name="New Launch Configuration">
+       </command>
+       <category
+             id="org.tizen.common.gom.category"
+             name="Smart Launch">
+       </category>
+    </extension>
+    <extension
+          point="org.eclipse.ui.bindings">
+       <key
+             commandId="org.tizen.common.gom.smartlaunch.ui.tizensmartlauncher.down"
+             contextId="org.eclipse.ui.contexts.window"
+             schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+             sequence="SHIFT+ALT+[">
+       </key>
+       <key
+             commandId="org.tizen.common.gom.smartlaunch.ui.tizensmartlauncher.up"
+             contextId="org.eclipse.ui.contexts.window"
+             schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+             sequence="SHIFT+ALT+]">
+       </key>
+       <key
+             commandId="org.tizen.common.gom.smartlaunch.ui.tizensmartlauncher.new"
+             contextId="org.eclipse.ui.contexts.window"
+             schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+             sequence="SHIFT+ALT+F12">
+       </key>
+    </extension>
+</plugin>
diff --git a/org.tizen.common.gom/src/org/tizen/common/gom/GomPlugin.java b/org.tizen.common.gom/src/org/tizen/common/gom/GomPlugin.java
new file mode 100644 (file)
index 0000000..d67873b
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.gom;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+public class GomPlugin extends AbstractUIPlugin {
+    
+    public static final String PLUGIN_ID = "org.tizen.common.gom";
+
+    public void start(BundleContext context) throws Exception {
+        super.start(context);
+    }
+
+    public void stop(BundleContext context) throws Exception {
+        super.stop(context);
+    }
+    
+    /**
+     * Returns an image descriptor for the image file at the given
+     * plug-in relative path
+     *
+     * @param path the path
+     * @return the image descriptor
+     */
+    public static ImageDescriptor getImageDescriptorFromPlugin(String path) {
+        return imageDescriptorFromPlugin(PLUGIN_ID, path);
+    }
+
+}
diff --git a/org.tizen.common.gom/src/org/tizen/common/gom/launch/GomLaunchData.java b/org.tizen.common.gom/src/org/tizen/common/gom/launch/GomLaunchData.java
new file mode 100644 (file)
index 0000000..0cbba0c
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.gom.launch;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tizen.common.adapter.ITizenNativeLaunchConfiguration;
+import org.tizen.common.adapter.ITizenWebLaunchConfiguration;
+import org.tizen.common.adapter.ITizenLaunchConfiguration;
+import org.tizen.common.gom.smartlaunch.GomSmartLauncher;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.SmartDevelopmentBridge;
+
+public class GomLaunchData {
+    
+    private Logger logger = LoggerFactory.getLogger(getClass());
+    
+    private IProject project;
+    private ILaunchConfiguration launchConfiguration;
+    private String launchConfigurationName;
+    private String buildConfiguration;
+    private String mode;
+    private LaunchShortcutExtension ext;
+    private IDevice device;
+    
+    public GomLaunchData(IProject project, String configurationName, String buildConfiguration, String mode, LaunchShortcutExtension ext, IDevice device)
+    {
+        this.project = project;
+        this.launchConfiguration = null;
+        this.launchConfigurationName = configurationName;
+        this.buildConfiguration = buildConfiguration;
+        this.mode = mode;
+        this.ext = ext;
+        this.device = device;
+    }
+    
+    //launch add
+    public GomLaunchData(ILaunch launch)
+    {
+        launchConfiguration = launch.getLaunchConfiguration();
+        launchConfigurationName = launchConfiguration.getName();
+        mode = launch.getLaunchMode();
+        this.device = null;
+        String deviceSerialNo = null;
+        try {
+            deviceSerialNo = launchConfiguration.getAttribute(GomSmartLauncher.ATTR_CONFIG_DEVICE_SERIALNO,
+                    GomSmartLauncher.ATTR_CONFIG_NO_DEVICE);
+        } catch (CoreException e) {
+            logger.error("Fail to get device serial number", e);
+        }
+        
+        ITizenLaunchConfiguration launchConfigurationAdapter = null;
+
+        if(!GomSmartLauncher.ATTR_CONFIG_NO_DEVICE.equals(deviceSerialNo))
+        {
+            launchConfigurationAdapter = (ITizenNativeLaunchConfiguration) launchConfiguration.getAdapter(ITizenNativeLaunchConfiguration.class);
+            IDevice[] devices = SmartDevelopmentBridge.getBridge().getDevices();
+            for(IDevice device : devices)
+            {
+                if(deviceSerialNo.equals(device.getSerialNumber()))
+                {
+                    this.device = device;
+                }
+            }
+        } else {
+            launchConfigurationAdapter = (ITizenWebLaunchConfiguration) launchConfiguration.getAdapter(ITizenWebLaunchConfiguration.class);
+        }
+        project = launchConfigurationAdapter.getProject();
+    }
+    
+    public IProject getProject()
+    {
+        return project;
+    }
+    
+    public ILaunchConfiguration getLaunchConfiguration()
+    {
+        return launchConfiguration;
+    }
+    
+    public String getLaunchConfigurationName()
+    {
+        return launchConfigurationName;
+    }
+    
+    public String getDataInfo()
+    {
+        if(device != null) {
+            return launchConfiguration.getName() + " on " + device;
+        } else {
+            return launchConfiguration.getName();
+        }
+    }
+    
+    public String getMode()
+    {
+        return mode;
+    }
+    
+    public IDevice getDevice()
+    {
+        return device;
+    }
+    
+    public LaunchShortcutExtension getExt() {
+        return ext;
+    }
+    
+    public String getBuildConfiguration() {
+        return buildConfiguration;
+    }
+}
diff --git a/org.tizen.common.gom/src/org/tizen/common/gom/launch/IGomSmartLaunchShortcut.java b/org.tizen.common.gom/src/org/tizen/common/gom/launch/IGomSmartLaunchShortcut.java
new file mode 100644 (file)
index 0000000..3e75bee
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.gom.launch;
+
+public interface IGomSmartLaunchShortcut {
+    
+    public void smartLaunch(GomLaunchData data);
+}
diff --git a/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/GomSmartLaunchManager.java b/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/GomSmartLaunchManager.java
new file mode 100644 (file)
index 0000000..6242f65
--- /dev/null
@@ -0,0 +1,212 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.gom.smartlaunch;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationListener;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.ILaunchesListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.tizen.common.gom.launch.GomLaunchData;
+import org.tizen.common.util.ViewUtil;
+
+public class GomSmartLaunchManager implements ISelectionListener, ILaunchesListener
+    , ILaunchConfigurationListener, IResourceChangeListener{
+    
+    private static GomSmartLaunchManager launchManager = null;
+    private HashMap<IProject, GomLaunchData> map = new HashMap<IProject, GomLaunchData>();
+    private List<GomLaunchData> launchList = new ArrayList<GomLaunchData>();
+    private int max = 10;
+
+    public static GomSmartLaunchManager getDefault()
+    {
+        if(launchManager == null)
+        {
+            launchManager = new GomSmartLaunchManager();
+        }
+        return launchManager;
+    }
+
+    public void addListener()
+    {
+        IWorkbenchWindow workbenchWindow = ViewUtil.getWorkbenchWindow();
+        if(workbenchWindow != null && workbenchWindow.getSelectionService() != null)
+        {
+            workbenchWindow.getSelectionService().addPostSelectionListener(this);
+        }
+        ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.PRE_DELETE);
+        ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+        launchManager.addLaunchConfigurationListener(this);
+        launchManager.addLaunchListener(this);
+    }
+
+    public void removeListener()
+    {
+        IWorkbenchWindow workbenchWindow = ViewUtil.getWorkbenchWindow();
+        if(workbenchWindow != null && workbenchWindow.getSelectionService() != null)
+        {
+            workbenchWindow.getSelectionService().removePostSelectionListener(this);
+        }
+        ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+        ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+        launchManager.removeLaunchConfigurationListener(this);
+        launchManager.removeLaunchListener(this);
+    }
+
+    @Override
+    public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+        if(selection instanceof IStructuredSelection)
+        {
+            Object s = ((IStructuredSelection) selection).getFirstElement();
+            if(s instanceof IProject)
+            {
+                IProject project = (IProject)s;
+                GomLaunchData data = map.get(project);
+                if(data != null)
+                {
+                    IViewSite site = (IViewSite) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite();
+                    site.getActionBars().getStatusLineManager().setMessage(data.getDataInfo());
+                }
+            }
+        }
+    }
+    
+    public List<GomLaunchData> getLaunchList() {
+        return launchList;
+    }
+
+    @Override
+    public void launchesRemoved(ILaunch[] launches) {
+    }
+
+    @Override
+    public void launchesAdded(ILaunch[] launches) {
+        updateProjectLaunchData(launches[0]);
+    }
+
+    @Override
+    public void launchesChanged(ILaunch[] launches) {
+    }
+
+    @Override
+    public void resourceChanged(IResourceChangeEvent event) {
+        IProject project = (IProject)event.getResource();
+        removeLaunchHistory(project);
+    }
+
+    @Override
+    public void launchConfigurationAdded(ILaunchConfiguration configuration) {
+    }
+
+    @Override
+    public void launchConfigurationChanged(ILaunchConfiguration configuration) {
+    }
+
+    @Override
+    public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
+    }
+    
+    private void updateProjectLaunchData(ILaunch launch)
+    {
+        GomLaunchData launchData = new GomLaunchData(launch);
+        map.put(launchData.getProject(), launchData);
+        updateLaunchHistory(launchData);
+    }
+    
+    /**
+     * Updates launch list
+     * @param launchInfo
+     */
+    public void updateLaunchHistory(GomLaunchData launchInfo)
+    {
+        Iterator<GomLaunchData> iter = launchList.iterator();
+        while(iter.hasNext())
+        {
+            GomLaunchData info = iter.next();
+            if(launchInfo.getDataInfo().equals(info.getDataInfo()))
+            {
+                iter.remove();
+            }
+        }
+        launchList.add(launchInfo);
+        
+        iter = launchList.iterator();
+        while(iter.hasNext())
+        {
+            iter.next();
+            if(launchList.size() > max)
+            {
+                iter.remove();
+            }
+            else
+            {
+                break;
+            }
+        }
+    }
+    
+    private void removeLaunchHistory(Object obj)
+    {
+        Iterator<GomLaunchData> iter = launchList.iterator();
+        while(iter.hasNext())
+        {
+            GomLaunchData item = iter.next();
+            if( obj instanceof IProject)
+            {
+                IProject project = (IProject)obj;
+                if(project.getName().equals(item.getProject().getName()))
+                {
+                    iter.remove();
+                }
+            }
+            else if( obj instanceof ILaunchConfiguration)
+            {
+                ILaunchConfiguration configuration = (ILaunchConfiguration)obj;
+                if(configuration.getName().equals(item.getLaunchConfiguration().getName()))
+                {
+                    iter.remove();
+                }
+            }
+        }
+    }
+}
diff --git a/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/GomSmartLauncher.java b/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/GomSmartLauncher.java
new file mode 100644 (file)
index 0000000..3a3a46e
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.gom.smartlaunch;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.common.gom.launch.GomLaunchData;
+import org.tizen.common.gom.launch.IGomSmartLaunchShortcut;
+import org.tizen.common.gom.smartlaunch.messages.GomMessages;
+import org.tizen.common.gom.smartlaunch.ui.GomDialog;
+import org.tizen.common.util.ProjectUtil;
+import org.tizen.common.util.SWTUtil;
+import org.tizen.sdblib.IDevice;
+
+public class GomSmartLauncher {
+    
+    public static final String ATTR_CONFIG_DEVICE_SERIALNO = "org.tizen.common.launch.device.serialNumber";
+    public static final String ATTR_CONFIG_NO_DEVICE = "";
+
+    private final static Logger logger = LoggerFactory.getLogger(GomSmartLauncher.class);
+
+    public static void smartLaunch(final GomLaunchData data) {
+        if(data.getLaunchConfiguration() == null) {
+            
+            IGomSmartLaunchShortcut shortcut = null;
+            try {
+                shortcut = (IGomSmartLaunchShortcut)data.getExt().getConfigurationElement().createExecutableExtension("class");
+            } catch (CoreException e) {
+                logger.error("SmartLaunch: Failed to get shortcut");
+            }
+            shortcut.smartLaunch(data);
+        } else {
+            SWTUtil.syncExec(new Runnable()
+            {
+                @Override
+                public void run() {
+                    DebugUITools.launch(data.getLaunchConfiguration(), data.getMode());
+                }
+            });
+        }
+    }
+    
+    public static void openDialog(IWorkbenchWindow window) {
+        if(checkBeforeDialogOpen(window)) {
+            GomDialog gomDialog = new GomDialog(window.getShell());
+            if(gomDialog.open() == Window.OK) {
+                IProject project = gomDialog.getProject();
+                if(checkBeforeLaunch(project, window)) {
+                    smartLaunch(getLaunchData(gomDialog));
+                }
+            }
+        }
+    }
+    
+    private static GomLaunchData getLaunchData(GomDialog dialog) {
+        GomLaunchData data = new GomLaunchData(dialog.getProject(), dialog.getConfigurationName(), dialog.getBuildConfiguration()
+                , dialog.getMode(), dialog.getLaunchShortcutExtension(), null);
+        return data;
+    }
+    
+    private static boolean checkBeforeDialogOpen(IWorkbenchWindow window) {
+        boolean result = false;
+        
+        if(window != null) {
+            IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+            if(projects.length != 0) {
+                for(IProject project: projects) {
+                    if(ProjectUtil.isTizenProject(project)) {
+                        result = true;
+                        break;
+                    }
+                }
+            }
+        }
+        
+        return result;
+    }
+
+    public static boolean checkBeforeLaunch(IProject project, IWorkbenchWindow window) {
+        boolean result = false;
+        
+        if(!project.exists()) {
+            MessageDialog.openError(window.getShell(), GomMessages.SMARTLAUNCH_FAIL, NLS.bind(GomMessages.SMARTLAUNCH_UNEXIST_PROJECT, project.getName()));
+        } else {
+            if(ProjectUtil.isTizenNativeProject(project)) {
+                IDevice selectedDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+                if(selectedDevice != null) {
+                    result = true;
+                } else {
+                    MessageDialog.openError(window.getShell(), GomMessages.SMARTLAUNCH_FAIL, GomMessages.SMARTLAUNCH_DISCONNECTED_DEVICE);
+                }
+            } else {
+                result = true;
+            }
+        }
+        return result;
+    }
+}
diff --git a/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/action/GomSmartLaunchAction.java b/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/action/GomSmartLaunchAction.java
new file mode 100644 (file)
index 0000000..a3eaf7f
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.gom.smartlaunch.action;
+
+import org.eclipse.debug.ui.actions.LaunchAction;
+import org.tizen.common.gom.launch.GomLaunchData;
+
+public class GomSmartLaunchAction  extends LaunchAction{
+
+    public GomSmartLaunchAction(GomLaunchData data) {
+        super(data.getLaunchConfiguration(), data.getMode());
+        this.setText(data.getDataInfo());
+        this.setToolTipText(data.toString());
+    }
+
+}
diff --git a/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/action/GomSmartLaunchToolbarAction.java b/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/action/GomSmartLaunchToolbarAction.java
new file mode 100644 (file)
index 0000000..3c89c65
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.gom.smartlaunch.action;
+
+import java.util.List;
+
+import org.eclipse.debug.ui.actions.LaunchAction;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
+import org.tizen.common.gom.launch.GomLaunchData;
+import org.tizen.common.gom.smartlaunch.GomSmartLauncher;
+import org.tizen.common.gom.smartlaunch.GomSmartLaunchManager;
+import org.tizen.common.gom.smartlaunch.messages.GomMessages;
+
+public class GomSmartLaunchToolbarAction implements IWorkbenchWindowPulldownDelegate2 {
+    
+    private IWorkbenchWindow window;
+
+    @Override
+    public Menu getMenu(Control parent) {
+        Menu menu = new Menu(parent);
+        addMenuListener(menu);
+        return menu;
+    }
+
+    @Override
+    public void dispose() {
+        GomSmartLaunchManager.getDefault().removeListener();
+    }
+
+    @Override
+    public void init(IWorkbenchWindow window) {
+        this.window = window;
+        GomSmartLaunchManager.getDefault().addListener();
+    }
+
+    @Override
+    public void run(IAction action) {
+        List<GomLaunchData> list = GomSmartLaunchManager.getDefault().getLaunchList();
+        int recentIndex = list.size() -1;
+        if(recentIndex > -1)
+        {
+            GomLaunchData data = list.get(recentIndex);
+            if(GomSmartLauncher.checkBeforeLaunch(data.getProject(), window)) {
+                new GomSmartLaunchAction(data).run();
+            }
+        }else
+        {
+            GomSmartLauncher.openDialog(window);
+        }
+    }
+
+    @Override
+    public void selectionChanged(IAction action, ISelection selection) {
+    }
+
+    @Override
+    public Menu getMenu(Menu parent) {
+        Menu menu = new Menu(parent);
+        addMenuListener(menu);
+        return menu;
+    }
+    
+    private void addMenuListener(Menu menu) {
+        menu.addMenuListener(new MenuAdapter() {
+            @Override
+            public void menuShown(MenuEvent e) {
+                 fillMenu((Menu)e.widget);
+            }
+        });
+    }
+    
+    protected void fillMenu(Menu menu) {
+        List<GomLaunchData> list = GomSmartLaunchManager.getDefault().getLaunchList();
+
+        int listCount = list.size();
+        int accelerator = 1;
+
+        for (int i = list.size() - 1; i >= 0; i--)
+        {
+            GomLaunchData data = list.get(i);
+            LaunchAction action= new GomSmartLaunchAction(data);
+            addToMenu(menu, action, accelerator);
+            accelerator++;
+        }
+        
+        if(listCount > 0)
+        {
+            new MenuItem(menu, SWT.SEPARATOR);
+        }
+        
+        Action addAction = new Action(){
+            @Override
+            public void run()
+            {
+                GomSmartLauncher.openDialog(window);
+            }
+        };
+        addAction.setText(GomMessages.SMARTLAUNCH_NEW);
+        addToMenu(menu, addAction, accelerator);
+    }
+    
+    protected void addToMenu(Menu menu, IAction action, int accelerator) {
+        StringBuffer label= new StringBuffer();
+        if (accelerator >= 0 && accelerator < 10) {
+            //add the numerical accelerator
+            label.append('&');
+            label.append(accelerator);
+            label.append(' ');
+        }
+        label.append(action.getText());
+        action.setText(label.toString());
+        ActionContributionItem item= new ActionContributionItem(action);
+        item.fill(menu, -1);
+    }
+
+}
diff --git a/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/handler/GomSmartLaunchCycleHandler.java b/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/handler/GomSmartLaunchCycleHandler.java
new file mode 100644 (file)
index 0000000..88781a9
--- /dev/null
@@ -0,0 +1,259 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.gom.smartlaunch.handler;
+
+import java.util.List;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ParameterizedCommand;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.contexts.IContextService;
+import org.eclipse.ui.internal.CycleBaseHandler;
+import org.eclipse.ui.internal.WorkbenchPage;
+import org.tizen.common.gom.launch.GomLaunchData;
+import org.tizen.common.gom.smartlaunch.GomSmartLaunchManager;
+import org.tizen.common.gom.smartlaunch.GomSmartLauncher;
+import org.tizen.sdblib.IDevice;
+
+@SuppressWarnings("restriction")
+public class GomSmartLaunchCycleHandler extends CycleBaseHandler {
+    
+    private String[] columns = {"Mode", "Project", "LaunchConfiguration", "DeviceSerialNo"};
+    private String[] sampleColumns = {"Profile", "ProjectProject", "LaunchConfigurationLaunchConfiguration", "emulator-xxxxx"};
+    
+    private final String TIZEN_SMART_LAUNCH_UP_ID="org.tizen.common.gom.smartlaunch.ui.tizensmartlauncher.up";
+    private final String TIZEN_SMART_LAUNCH_DOWN_ID="org.tizen.common.gom.smartlaunch.ui.tizensmartlauncher.down";
+
+    @Override
+    protected void addItems(Table table, WorkbenchPage page) {
+        List<GomLaunchData> list = GomSmartLaunchManager.getDefault().getLaunchList();
+        setTable(table, list);
+    }
+
+    @Override
+    protected ParameterizedCommand getBackwardCommand() {
+        final ICommandService commandService = (ICommandService) window
+                .getWorkbench().getService(ICommandService.class);
+        final Command command = commandService
+                .getCommand(TIZEN_SMART_LAUNCH_UP_ID);
+        ParameterizedCommand commandBack = new ParameterizedCommand(command,
+                null);
+        return commandBack;
+    }
+
+    @Override
+    protected ParameterizedCommand getForwardCommand() {
+        final ICommandService commandService = (ICommandService) window
+                .getWorkbench().getService(ICommandService.class);
+        final Command command = commandService
+                .getCommand(TIZEN_SMART_LAUNCH_DOWN_ID);
+        ParameterizedCommand commandForward = new ParameterizedCommand(command, null);
+        return commandForward;
+    }
+
+    @Override
+    protected String getTableHeader(IWorkbenchPart activePart) {
+        return null;
+    }
+    
+    @Override
+    protected void openDialog(WorkbenchPage page, IWorkbenchPart activePart) {
+        final int MAX_ITEMS = 22;
+        Shell shell = null;
+        if (activePart != null)
+            shell = activePart.getSite().getShell();
+        if (shell == null)
+            shell = window.getShell();
+        final Shell dialog = new Shell(shell, SWT.MODELESS);
+        Display display = dialog.getDisplay();
+        dialog.setLayout(new FillLayout());
+
+        final Table table = new Table(dialog, SWT.SINGLE | SWT.FULL_SELECTION);
+        table.setHeaderVisible(true);
+        table.setLinesVisible(true);
+
+        for(int i = 0 ;i < columns.length ; i++)
+        {
+            createTableColumn(table, sampleColumns[i], columns[i]);
+        }
+
+        addItems(table, page);
+        int tableItemCount = table.getItemCount();
+
+        switch (tableItemCount) {
+        case 0:
+            cancel(dialog);
+            return;
+        case 1:
+            table.setSelection(0);
+            break;
+        default:
+            int i;
+            if (gotoDirection) {
+                i= getCurrentItemIndex() + 1;
+                if (i >= tableItemCount)
+                    i= 0;
+            } else {
+                i= getCurrentItemIndex() - 1;
+                if (i < 0)
+                    i= tableItemCount - 1;
+            }
+            table.setSelection(i);
+        }
+
+        table.pack();
+        dialog.pack();
+
+        Rectangle tableBounds = table.getBounds();
+        tableBounds.height = Math.min(tableBounds.height, table.getItemHeight()
+                * MAX_ITEMS);
+        table.setBounds(tableBounds);
+
+        dialog.setBounds(dialog.computeTrim(tableBounds.x, tableBounds.y,
+                tableBounds.width, tableBounds.height));
+
+        table.setFocus();
+        table.addFocusListener(new FocusListener() {
+            public void focusGained(FocusEvent e) {
+                // Do nothing
+            }
+
+            public void focusLost(FocusEvent e) {
+                cancel(dialog);
+            }
+        });
+
+        table.addMouseMoveListener(new MouseMoveListener() {
+            TableItem lastItem = null;
+
+            public void mouseMove(MouseEvent e) {
+                if (table.equals(e.getSource())) {
+                    Object o = table.getItem(new Point(e.x, e.y));
+                    if (lastItem == null ^ o == null) {
+                        table.setCursor(o == null ? null : table.getDisplay().getSystemCursor(
+                                SWT.CURSOR_HAND));
+                    }
+                    if (o instanceof TableItem) {
+                        if (!o.equals(lastItem)) {
+                            lastItem = (TableItem) o;
+                            table.setSelection(new TableItem[] { lastItem });
+                        }
+                    } else if (o == null) {
+                        lastItem = null;
+                    }
+                }
+            }
+        });
+
+        setDialogLocation(dialog, activePart);
+
+        final IContextService contextService = (IContextService) window
+                .getWorkbench().getService(IContextService.class);
+        try {
+            dialog.open();
+            addMouseListener(table, dialog);
+            contextService.registerShell(dialog, IContextService.TYPE_NONE);
+            addKeyListener(table, dialog);
+            addTraverseListener(table);
+
+            while (!dialog.isDisposed()) {
+                if (!display.readAndDispatch()) {
+                    display.sleep();
+                }
+            }
+        } finally {
+            if (!dialog.isDisposed()) {
+                cancel(dialog);
+            }
+            contextService.unregisterShell(dialog);
+        }
+    }
+    
+    private TableColumn createTableColumn(Table table, String sampleText, String text)
+    {
+        TableColumn tc = new TableColumn(table, SWT.NONE);
+        tc.setResizable(true);
+        tc.setText(sampleText);
+        tc.pack();
+        tc.setText(text);
+        return tc;
+    }
+    
+    private void setTable(Table table, List<GomLaunchData> list) {
+        setTableItem(table, list);
+    }
+
+    private void setTableItem(Table table, List<GomLaunchData> list) {
+        if (list.size() == 0) {
+            return;
+        }
+
+        for (int i = list.size() - 1; i >= 0; i--) {
+            GomLaunchData info = list.get(i);
+            TableItem item = new TableItem(table, SWT.NONE);
+            item.setText(0, info.getMode());
+            item.setText(1, info.getProject().getName());
+            item.setText(2, info.getLaunchConfiguration().getName());
+            IDevice device = info.getDevice();
+            item.setText(3, device == null ? "" : info.getDevice().getSerialNumber());
+            item.setData(info);
+        }
+    }
+    
+    @Override
+    protected void activate(IWorkbenchPage page, Object selectedItem) {
+        if (page == null) {
+            return;
+        }
+
+        if (selectedItem == null) {
+            return;
+        }
+
+        if (selectedItem instanceof GomLaunchData) {
+            GomLaunchData data = (GomLaunchData)selectedItem;
+            if(GomSmartLauncher.checkBeforeLaunch(data.getProject(), window)) {
+                GomSmartLauncher.smartLaunch(data);
+            }
+        }
+
+    }
+}
diff --git a/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/handler/GomSmartLaunchHandler.java b/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/handler/GomSmartLaunchHandler.java
new file mode 100644 (file)
index 0000000..731d054
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.gom.smartlaunch.handler;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.tizen.common.gom.smartlaunch.GomSmartLauncher;
+
+public class GomSmartLaunchHandler extends AbstractHandler {
+
+    @Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
+        IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
+        GomSmartLauncher.openDialog(window);
+        return null;
+    }
+}
diff --git a/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/messages/GomMessages.java b/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/messages/GomMessages.java
new file mode 100644 (file)
index 0000000..57e8b68
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.gom.smartlaunch.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+public class GomMessages extends NLS{
+    
+    static {
+        NLS.initializeMessages(GomMessages.class.getName(), GomMessages.class);
+    }
+    
+    public static String SMARTLAUNCH_DIALOG_TITLE;
+    public static String SMARTLAUNCH_DIALOG_DESCRIPTION;
+    public static String SMARTLAUNCH_NEW;
+    public static String SMARTLAUNCH_NEW_DIALOG_LABEL_CONFIGURATION;
+    public static String SMARTLAUNCH_NEW_DIALOG_LABEL_PROJECT;
+    public static String SMARTLAUNCH_NEW_DIALOG_GROUP_BUILD_CONFIGURATION;
+    public static String SMARTLAUNCH_NEW_DIALOG_GROUP_DEVICE;
+    public static String SMARTLAUNCH_NEW_DIALOG_GROUP_MODE_AND_CONFIGURATION;
+    
+    public static String SMARTLAUNCH_FAIL;
+    public static String SMARTLAUNCH_UNEXIST_PROJECT;
+    public static String SMARTLAUNCH_DISCONNECTED_DEVICE;
+    
+    public static String SMARTLAUNCH_NEW_DIALOG_INVALID_NAME;
+    public static String SMARTLAUNCH_NEW_DIALOG_NO_NAME;
+    public static String SMARTLAUNCH_NEW_DIALOG_MESSAGE_FAIL_BUILDINFO;
+}
diff --git a/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/messages/GomMessages.properties b/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/messages/GomMessages.properties
new file mode 100644 (file)
index 0000000..8496575
--- /dev/null
@@ -0,0 +1,21 @@
+SMARTLAUNCH_DIALOG_TITLE = New Launch
+SMARTLAUNCH_DIALOG_DESCRIPTION = Create launch configuration
+SMARTLAUNCH_FAIL =  Fail to launch
+SMARTLAUNCH_UNEXIST_PROJECT = There is no {0} Tizen project to launch
+SMARTLAUNCH_DISCONNECTED_DEVICE = There is no Tizen device to launch
+
+SMARTLAUNCH_NEW=New Launch Configuration
+SMARTLAUNCH_NEW_DIALOG_TITLE=New Launch Configuration
+SMARTLAUNCH_NEW_DIALOG_DESCRIPTION=Launch with new launch configuration
+SMARTLAUNCH_NEW_DIALOG_LABEL_CONFIGURATION=Configuration name: 
+SMARTLAUNCH_NEW_DIALOG_LABEL_PROJECT=Project name:
+SMARTLAUNCH_NEW_DIALOG_GROUP_BUILD_CONFIGURATION=Build configuration: 
+SMARTLAUNCH_NEW_DIALOG_GROUP_DEVICE=Device
+SMARTLAUNCH_NEW_DIALOG_GROUP_MODE_AND_CONFIGURATION=Launch mode and configuration type
+SMARTLAUNCH_NEW_DIALOG_UNABLE_LAUNCH=Unable To Launch
+SMARTLAUNCH_NEW_DIALOG_NO_PROJECT_MESSAGE=There is no Tizen project to launch
+SMARTLAUNCH_NEW_DIALOG_NO_DEVICE_MESSAGE=There is no Tizen device to launch
+SMARTLAUNCH_NEW_DIALOG_DISCONNECTED_DEVICE_MESSAGE=There is no {0} device to launch
+SMARTLAUNCH_NEW_DIALOG_INVALID_NAME=Invalid characters(\\/:*?\<>|) in a configuration name
+SMARTLAUNCH_NEW_DIALOG_NO_NAME=A name is required for the configuration
+SMARTLAUNCH_NEW_DIALOG_MESSAGE_FAIL_BUILDINFO=Fail to get build information about {0}
\ No newline at end of file
diff --git a/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/ui/GomContentProvider.java b/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/ui/GomContentProvider.java
new file mode 100644 (file)
index 0000000..1ea97a5
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.gom.smartlaunch.ui;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+public class GomContentProvider implements ITreeContentProvider{
+
+    @Override
+    public void dispose() {
+    }
+
+    @Override
+    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+    }
+
+    @Override
+    public Object[] getElements(Object inputElement) {
+        if (inputElement instanceof IProject[]) {
+            IProject[] projects = (IProject[])inputElement;
+            return projects;
+            } 
+        return null;
+    }
+
+    @Override
+    public Object[] getChildren(Object parentElement) {
+        return null;
+    }
+
+    @Override
+    public Object getParent(Object element) {
+        return null;
+    }
+
+    @Override
+    public boolean hasChildren(Object element) {
+        return false;
+    }
+
+}
diff --git a/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/ui/GomDialog.java b/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/ui/GomDialog.java
new file mode 100644 (file)
index 0000000..9383304
--- /dev/null
@@ -0,0 +1,475 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.gom.smartlaunch.ui;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.activities.WorkbenchActivityHelper;
+import org.tizen.common.TizenHelpContextIds;
+import org.tizen.common.adapter.ITizenNativeProject;
+import org.tizen.common.gom.smartlaunch.messages.GomMessages;
+import org.tizen.common.util.FilenameUtil;
+import org.tizen.common.util.OSChecker;
+import org.tizen.common.util.ProjectUtil;
+import org.tizen.common.util.StringUtil;
+
+public class GomDialog extends TitleAreaDialog{
+    
+    private final int WIDTH = 500;
+    private final int HEIGHT = 450;
+    
+    private Text configName;
+    private Combo buildConfigurationCombo;
+    private Combo shortcutCombo;
+    
+    private String[] modes= {ILaunchManager.RUN_MODE, ILaunchManager.DEBUG_MODE, ILaunchManager.PROFILE_MODE};
+    private List<IProject> projectList = new ArrayList<IProject>();
+    private List<String> configList = new ArrayList<String>();
+    private List filteredShortCuts = null;
+    
+    private String configurationName;
+    private IProject project;
+    private String buildConfigName;
+    private String mode;
+    private LaunchShortcutExtension ext;
+    private IProject [] projects;
+    
+    private boolean isDirtyName = false;
+    
+    public GomDialog(Shell shell) {
+        super(shell);
+        setShellStyle(SWT.MODELESS | SWT.TITLE | SWT.CLOSE | SWT.RESIZE);
+        projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+    }
+    
+    @Override
+    protected void configureShell(Shell newShell) {
+        super.configureShell(newShell);
+        newShell.setText(GomMessages.SMARTLAUNCH_DIALOG_TITLE);
+        
+        Rectangle bounds = newShell.getBounds();
+        int x = bounds.x + (bounds.width - WIDTH) / 2;
+        int y = bounds.y + (bounds.height - HEIGHT) / 2;
+        newShell.setLocation(x, y);
+        
+        newShell.setSize(WIDTH, HEIGHT);
+    }
+    
+    @Override
+    protected Control createContents(Composite parent) {
+        Control contents = super.createContents(parent);
+        PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), TizenHelpContextIds.HELP_NATIVE_SMART_LAUNCH_CONTEXT);
+        return contents;
+    }
+    
+    /**
+     * Create contents of the dialog.
+     *
+     * @param parent
+     */
+    @Override
+    protected Control createDialogArea(Composite parent) {
+        Composite container = (Composite) super.createDialogArea(parent);
+        container.setLayout(new GridLayout(1, false));
+        container.setLayoutData(new GridData(GridData.FILL_BOTH));
+        
+        createDescriptionArea(container);
+        createContentArea(container);
+        
+        return container;
+    }
+    
+    private void createDescriptionArea(Composite composite) {
+        
+        Composite topComp = new Composite(composite, SWT.NONE);
+        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+        topComp.setLayoutData(gd);
+        GridLayout topLayout = new GridLayout(2, false);
+        topLayout.marginHeight = 0;
+        topLayout.marginWidth = 0;
+        topComp.setLayout(topLayout);
+        
+        setTitle(GomMessages.SMARTLAUNCH_DIALOG_DESCRIPTION);
+    }
+    
+    private void createContentArea(Composite composite) {
+        SashForm sash = new SashForm(composite, SWT.SMOOTH);
+        sash.setOrientation(SWT.HORIZONTAL);
+        
+        GridData gd = new GridData(GridData.FILL_BOTH);
+        sash.setLayoutData(gd);
+        sash.setVisible(true);
+        
+        Control projectArea = createProjectSelectionArea(sash);
+        projectArea.setLayoutData(new GridData(GridData.FILL_BOTH));
+        
+        Control launchArea = createLaunchArea(sash);
+        launchArea.setLayoutData(new GridData(GridData.FILL_BOTH));
+        
+        sash.setWeights(new int[]{2, 5});
+    }
+    
+    private Control createProjectSelectionArea(Composite composite) {
+        Composite comp = new Composite(composite, SWT.BORDER);
+        GridLayout gridLayout = new GridLayout(1, false);
+        gridLayout.marginHeight = 0;
+        gridLayout.marginWidth = 0;
+        comp.setLayout(gridLayout);
+        comp.setLayoutData(new GridData(GridData.FILL_BOTH));
+        
+        comp.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+        
+        createProjectViewer(comp);
+        
+        return comp;
+    }
+    
+    private void createProjectViewer(Composite composite) {
+        projectList.clear();
+        TreeViewer viewer = new TreeViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
+        final Tree tree = viewer.getTree();
+        viewer.setContentProvider(new GomContentProvider());
+        viewer.setLabelProvider(new GomLabelProvider(composite.getDisplay()));
+        
+        tree.addSelectionListener(new SelectionAdapter()
+        {
+            @Override
+            public void widgetSelected(SelectionEvent e)
+            {
+                project = (IProject) tree.getSelection()[0].getData();
+                setBuildConfigurationCombo();
+                setShortcutCombo();
+                modifyDefaultConfigName();
+            }
+        });
+        
+        for(IProject project: projects) {
+            if(ProjectUtil.isTizenProject(project)) {
+                projectList.add(project);
+            }
+        }
+        
+        if(projectList.size() > 0) {
+            project = projectList.get(0);
+        }
+        
+        viewer.setInput(projectList.toArray(new IProject [projectList.size()]));
+    }
+    
+    private Control createLaunchArea(Composite composite) {
+        Composite comp = new Composite(composite, SWT.BORDER);
+        GridLayout gridLayout = new GridLayout(1, false);
+        gridLayout.marginHeight = 0;
+        gridLayout.marginWidth = 0;
+        comp.setLayout(gridLayout);
+        comp.setLayoutData(new GridData(GridData.FILL_BOTH));
+        
+        createWidget(comp);
+        
+        return comp;
+    }
+    
+    private void createWidget(Composite composite) {
+        
+        createConfigNamePart(composite);
+        createBuildConfigPart(composite);
+        createModeAndShortcutPart(composite);
+    }
+    
+    private void createConfigNamePart(Composite composite) {
+        Label lbName = new Label(composite, SWT.NONE);
+        lbName.setText(GomMessages.SMARTLAUNCH_NEW_DIALOG_LABEL_CONFIGURATION);
+        
+        configName = new Text(composite, SWT.BORDER);
+        configName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+        configName.addModifyListener(new ModifyListener()
+        {
+            @Override
+            public void modifyText(ModifyEvent e)
+            {
+                Text text = (Text) e.widget;
+                configurationName = text.getText();
+                validateInput(configurationName);
+                isDirtyName = true;
+            }
+        });
+    }
+    
+    private void createBuildConfigPart(Composite composite) {
+        Label lbBuild = new Label(composite, SWT.NONE);
+        lbBuild.setText(GomMessages.SMARTLAUNCH_NEW_DIALOG_GROUP_BUILD_CONFIGURATION);
+        
+        buildConfigurationCombo = new Combo(composite, SWT.READ_ONLY);
+        buildConfigurationCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+        buildConfigurationCombo.addSelectionListener(new SelectionListener()
+        {
+            @Override
+            public void widgetSelected(SelectionEvent e)
+            {
+                Combo combo = (Combo) e.widget;
+                setSelectionBuildConfiguration(combo.getSelectionIndex());
+                modifyDefaultConfigName();
+            }
+            
+            @Override
+            public void widgetDefaultSelected(SelectionEvent e)
+            {
+            }
+        });
+        
+        setBuildConfigurationCombo();
+    }
+    
+    private void setBuildConfigurationCombo()
+    {
+        buildConfigurationCombo.removeAll();
+        
+        if(ProjectUtil.isTizenWebProject(project)) {
+            buildConfigurationCombo.setEnabled(false);
+            return ;
+        }
+        
+        buildConfigurationCombo.setEnabled(true);
+        configList.clear();
+        
+        ITizenNativeProject adapter = (ITizenNativeProject) project.getAdapter(ITizenNativeProject.class);
+        configList = adapter.getBuildConfiguration();
+        String defaultConfig = adapter.getDefaultBuildConfiguration();
+
+        if(configList.size() == 0)
+        {
+            MessageDialog.openError(getShell(),"Error",
+                    project.getName() + " failed");
+            return ;
+        }
+
+        for(int i = 0; i < configList.size() ; i++)
+        {
+            String config = configList.get(i);
+            buildConfigurationCombo.add(configList.get(i));
+            if(defaultConfig == config)
+            {
+                setSelectionBuildConfiguration(i);
+            }
+        }
+    }
+    
+    private void setSelectionBuildConfiguration(int index)
+    {
+        buildConfigurationCombo.select(index);
+        
+        buildConfigName = configList.get(index);
+    }
+    
+    private void createModeAndShortcutPart(Composite composite) {
+        Group grpModeAndShortcut = new Group(composite, SWT.NONE);
+        grpModeAndShortcut.setText(GomMessages.SMARTLAUNCH_NEW_DIALOG_GROUP_MODE_AND_CONFIGURATION);
+        grpModeAndShortcut.setLayout(new GridLayout(1, false));
+        GridData radio_gd = new GridData(GridData.FILL_HORIZONTAL);
+        grpModeAndShortcut.setLayoutData(radio_gd);
+        
+        Button[] btnMode = new Button[modes.length];
+        for(int i = 0; i < modes.length; i++) {
+            btnMode[i] = new Button(grpModeAndShortcut, SWT.RADIO);
+            btnMode[i].setText(StringUtil.convertFirstLetterUpperCase(modes[i]));
+            btnMode[i].addSelectionListener(new SelectionListener(){
+
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    Button btn = (Button)e.widget;
+                    for(String m: modes) {
+                        if(m.equals(btn.getText().toLowerCase())) {
+                            mode = m;
+                        }
+                    }
+                    setShortcutCombo();
+                    modifyDefaultConfigName();
+                }
+                @Override
+                public void widgetDefaultSelected(SelectionEvent e) {
+                }
+                
+            });
+        }
+        
+        btnMode[0].setSelection(true);
+        mode = modes[0];
+        
+        shortcutCombo = new Combo(grpModeAndShortcut, SWT.READ_ONLY);
+        shortcutCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+        shortcutCombo.addSelectionListener(new SelectionListener()
+        {
+            @Override
+            public void widgetSelected(SelectionEvent e)
+            {
+                Combo combo = (Combo) e.widget;
+                ext = (LaunchShortcutExtension)filteredShortCuts.get(combo.getSelectionIndex());
+            }
+
+            @Override
+            public void widgetDefaultSelected(SelectionEvent e)
+            {
+            }
+        });
+        setShortcutCombo();
+    }
+    
+    private void setShortcutCombo() {
+        shortcutCombo.removeAll();
+        
+        LaunchConfigurationManager mgr = DebugUIPlugin.getDefault().getLaunchConfigurationManager();
+        List allShortCuts = mgr.getLaunchShortcuts(project);
+        Iterator iter = allShortCuts.iterator();
+        filteredShortCuts = new ArrayList();
+        while (iter.hasNext()) {
+            LaunchShortcutExtension ext = (LaunchShortcutExtension) iter.next();
+            if (!WorkbenchActivityHelper.filterItem(ext)) {
+                Set modes = ext.getModes(); // supported launch modes
+                Iterator modeIter = modes.iterator();
+                while (modeIter.hasNext()) {
+                    String modee = (String) modeIter.next();
+                    if (modee.equals(mode)) {
+                        filteredShortCuts.add(ext);
+                        shortcutCombo.add(ext.getContextLabel(mode));
+                    }
+                }
+            }
+        }
+        
+        if(setComboSelectDefault(shortcutCombo))
+        {
+            ext = (LaunchShortcutExtension)filteredShortCuts.get(0);
+        }
+    }
+    
+    private boolean setComboSelectDefault(Combo combo)
+    {
+        if(combo.getItemCount() > 0) {
+            combo.select(0);
+            return true;
+        }
+        return false;
+    }
+    
+    private void validateInput(String text)
+    {
+        String errorMessage = null;
+        errorMessage = isValidConfigName(text);
+        setErrorMessage(errorMessage);
+    }
+    
+    private String isValidConfigName(String fileName)
+    {
+        int validLinuxCheck = FilenameUtil.isVaildName(fileName, OSChecker.LINUX);
+        int validWinCheck = FilenameUtil.isVaildName(fileName, OSChecker.WINDOWS);
+
+        if (validLinuxCheck != FilenameUtil.IS_VALID_NAME || validWinCheck != FilenameUtil.IS_VALID_NAME)
+        {
+            if (validLinuxCheck == FilenameUtil.HAS_INVALID_CHARACTER || validWinCheck == FilenameUtil.HAS_INVALID_CHARACTER)
+            {
+                return GomMessages.SMARTLAUNCH_NEW_DIALOG_INVALID_NAME;
+            }
+            else if (validLinuxCheck == FilenameUtil.HAS_NO_NAME || validWinCheck == FilenameUtil.HAS_NO_NAME)
+            {
+                return GomMessages.SMARTLAUNCH_NEW_DIALOG_NO_NAME;
+            }
+        }
+        return null;
+    }
+    
+    public void modifyDefaultConfigName()
+    {
+        if(!isDirtyName)
+        {
+            setDefaultConfigName();
+        }
+    }
+
+    private void setDefaultConfigName()
+    {
+        String buildConfigInfo = ProjectUtil.isTizenNativeProject(project) ? ("_" + buildConfigName) : "";
+        String defaultName = "[" + StringUtil.convertFirstLetterUpperCase(mode)
+                + "] " + project.getName() + buildConfigInfo;
+        configName.setText(defaultName);
+        isDirtyName = false;
+    }
+
+    public IProject getProject()
+    {
+        return project;
+    }
+    
+    public String getConfigurationName()
+    {
+        return configurationName;
+    }
+
+    public String getMode() {
+        return mode;
+    }
+    
+    public String getBuildConfiguration()
+    {
+        return buildConfigName;
+    }
+    
+    public LaunchShortcutExtension getLaunchShortcutExtension()
+    {
+        return ext;
+    }
+}
diff --git a/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/ui/GomLabelProvider.java b/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/ui/GomLabelProvider.java
new file mode 100644 (file)
index 0000000..a8da15d
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.gom.smartlaunch.ui;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.tizen.common.gom.GomPlugin;
+import org.tizen.common.util.SWTUtil;
+
+public class GomLabelProvider implements ILabelProvider{
+    
+    private final Image tempImage;
+    
+    public GomLabelProvider(Display display) {
+        tempImage = GomPlugin.getImageDescriptorFromPlugin("icons/default_project_icon.png").createImage();
+    }
+
+    @Override
+    public void addListener(ILabelProviderListener listener) {
+    }
+
+    @Override
+    public void dispose() {
+        SWTUtil.tryDispose(tempImage);
+    }
+
+    @Override
+    public boolean isLabelProperty(Object element, String property) {
+        return false;
+    }
+
+    @Override
+    public void removeListener(ILabelProviderListener listener) {
+    }
+
+    @Override
+    public Image getImage(Object element) {
+        Image image = null;
+        if(element instanceof IProject) {
+            image = tempImage;
+        }
+        return image;
+    }
+
+    @Override
+    public String getText(Object element) {
+        String text = null;
+        if(element instanceof IProject) {
+            IProject project = (IProject)element;
+            
+            text = project.getName();
+        }
+        return text;
+    }
+
+}
diff --git a/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/ui/GomTreeViewer.java b/org.tizen.common.gom/src/org/tizen/common/gom/smartlaunch/ui/GomTreeViewer.java
new file mode 100644 (file)
index 0000000..beb6e73
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.gom.smartlaunch.ui;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+public class GomTreeViewer extends TreeViewer {
+    
+    private TreeViewer viewer;
+    private IProject[] projects;
+
+    public GomTreeViewer(Composite parent) {
+        super(parent);
+        projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+        createControl(parent);
+    }
+    
+    private Control createControl(Composite parent) {
+        
+        viewer = new TreeViewer(parent);
+         
+        viewer.setContentProvider(new GomContentProvider());
+        viewer.setLabelProvider(new GomLabelProvider(parent.getDisplay()));
+        viewer.setInput(projects);
+        
+        return viewer.getTree();
+    }
+
+}
index 7c5ff76..96a73ee 100755 (executable)
@@ -177,6 +177,7 @@ Export-Package:
  org.powermock.tests.utils.impl,
  org.slf4j,
  org.tizen.common,
+ org.tizen.common.adapter,
  org.tizen.common.classloader,
  org.tizen.common.config,
  org.tizen.common.config.loader,
diff --git a/org.tizen.common/src/org/tizen/common/adapter/ITizenLaunchConfiguration.java b/org.tizen.common/src/org/tizen/common/adapter/ITizenLaunchConfiguration.java
new file mode 100644 (file)
index 0000000..3da32b9
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.adapter;
+
+import org.eclipse.core.resources.IProject;
+/**
+ * Interface to get information from launch configuration for Tizen project
+ * @author hyunsik
+ *
+ */
+public interface ITizenLaunchConfiguration {
+    /**
+     * Return project by a project attribute
+     * @return IProject
+     */
+    public IProject getProject();
+}
diff --git a/org.tizen.common/src/org/tizen/common/adapter/ITizenNativeLaunchConfiguration.java b/org.tizen.common/src/org/tizen/common/adapter/ITizenNativeLaunchConfiguration.java
new file mode 100644 (file)
index 0000000..b1dec87
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.adapter;
+
+
+public interface ITizenNativeLaunchConfiguration extends ITizenLaunchConfiguration{
+}
diff --git a/org.tizen.common/src/org/tizen/common/adapter/ITizenNativeProject.java b/org.tizen.common/src/org/tizen/common/adapter/ITizenNativeProject.java
new file mode 100644 (file)
index 0000000..f26bda3
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.adapter;
+
+import java.util.List;
+
+/**
+ * Interface about Tizen native project
+ * @author hyunsik
+ *
+ */
+public interface ITizenNativeProject extends ITizenProject{
+    /**
+     * Return build configuration list
+     * @return a List&lt;String&gt;
+     */
+    public List<String> getBuildConfiguration();
+    /**
+     * Return default build configuration name.
+     * @return String
+     */
+    public String getDefaultBuildConfiguration();
+
+}
diff --git a/org.tizen.common/src/org/tizen/common/adapter/ITizenProject.java b/org.tizen.common/src/org/tizen/common/adapter/ITizenProject.java
new file mode 100644 (file)
index 0000000..8c72aef
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.adapter;
+
+import org.tizen.common.TizenProjectType;
+
+/**
+ * Interface to get information about Tizen project
+ * @author hyunsik
+ *
+ */
+public interface ITizenProject {
+    /**
+     * Returns true if project is for Tizen native.
+     * 
+     * @return boolean
+     */
+    
+    boolean isTizenNativeProject();
+    /**
+     * Returns true if project is for Tizen web.
+     * 
+     * @return boolean
+     */
+    
+    boolean isTizenWebProject();
+    /**
+     * Returns the App ID from a config.xml.
+     * 
+     * @return an App ID string. If could not get a value, return null.
+     */
+    
+    public String getAppId();
+    
+    /**
+     * Returns the Package ID from a manifest.xml.
+     * 
+     * @return a Package ID string. If could not get a value, return null.
+     */
+    public String getPackageId();
+    
+    /**
+     * Returns the Tizen project type
+     * 
+     * @return TizenProjectType
+     */
+    public TizenProjectType getTizenProjectType();
+}
diff --git a/org.tizen.common/src/org/tizen/common/adapter/ITizenWebLaunchConfiguration.java b/org.tizen.common/src/org/tizen/common/adapter/ITizenWebLaunchConfiguration.java
new file mode 100644 (file)
index 0000000..b3b46f7
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.adapter;
+
+/**
+ * Interface to get information from launch configuration for Tizen web project
+ * @author hyunsik
+ *
+ */
+public interface ITizenWebLaunchConfiguration extends ITizenLaunchConfiguration{
+}
diff --git a/org.tizen.common/src/org/tizen/common/adapter/ITizenWebProject.java b/org.tizen.common/src/org/tizen/common/adapter/ITizenWebProject.java
new file mode 100644 (file)
index 0000000..5316ef9
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.adapter;
+
+/**
+ * Interface to get information about Tizen web project
+ * @author hyunsik
+ *
+ */
+public abstract class ITizenWebProject implements ITizenProject{
+
+}
index 9093bca..64bf5bd 100644 (file)
@@ -30,12 +30,16 @@ import java.util.Map;
 import org.eclipse.core.resources.ICommand;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.Platform;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.tizen.common.adapter.ITizenNativeProject;
+import org.tizen.common.adapter.ITizenWebProject;
+import org.tizen.common.adapter.ITizenProject;
 
 /**
  * ProjectUtil.
@@ -212,4 +216,46 @@ public class ProjectUtil {
         }
         return descriptionLocation.removeLastSegments(2).toFile().equals(Platform.getLocation().toFile());
     }
+    
+    /**
+     * Check whether project is for tizen native or not.
+     * @param project 
+     * @return true if it is tizen native project.
+     */
+    public static boolean isTizenNativeProject(IProject project) {
+        ITizenProject adapter = (ITizenProject) project.getAdapter(ITizenNativeProject.class);
+        return adapter.isTizenNativeProject();
+    }
+    
+    /**
+     * Check whether project is for tizen web or not.
+     * @param project 
+     * @return true if it is tizen web project.
+     */
+    public static boolean isTizenWebProject(IProject project) {
+        ITizenProject adapter = (ITizenProject) project.getAdapter(ITizenWebProject.class);
+        return adapter.isTizenWebProject();
+    }
+    
+    /**
+     * Check whether project is for tizen or not.
+     * @param project 
+     * @return true if it is tizen project.
+     */
+    public static boolean isTizenProject(IProject project) {
+        return (isTizenNativeProject(project) || isTizenWebProject(project));
+    }
+    
+    /**
+     * Returns project from the given project name, or <code>null</code> otherwise.
+     * @param projectName
+     * @return
+     */
+    public static IProject getProject(String projectName) {
+        IProject proj = null;
+        if (projectName != null) {
+            proj = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+        }
+        return proj;
+    }
 }