--- /dev/null
+package org.tizen.common.gom.launch;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension;
+import org.tizen.sdblib.IDevice;
+
+public class GomDebugAttachLaunchData extends GomLaunchData{
+
+ private boolean isHybridLaunch = false;
+
+ public GomDebugAttachLaunchData(IProject project, String configurationName, String buildConfiguration, String mode,
+ LaunchShortcutExtension ext, IDevice device, boolean isHybridLaunch) {
+ super(project, configurationName, buildConfiguration, mode, ext, device);
+ this.isHybridLaunch = isHybridLaunch;
+ }
+
+ public boolean isHybridLaunch() {
+ return isHybridLaunch;
+ }
+
+}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tizen.common.gom.smartlaunch.GomSmartLauncher;
+import org.tizen.common.gom.smartlaunch.GomSmartUILauncher;
import org.tizen.common.launch.ITizenLaunchConfiguration;
import org.tizen.common.launch.ITizenNativeLaunchConfiguration;
import org.tizen.common.launch.ITizenWebLaunchConfiguration;
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;
+ private IProject project = null;
+ private ILaunchConfiguration launchConfiguration = null;
+ private String launchConfigurationName = null;
+ private String buildConfiguration = null;
+ private String mode = null;
+ private LaunchShortcutExtension ext = null;
+ private IDevice device = null;
+ /**
+ * This is a value object has various information needed to launch Tizen project.
+ * @param project Tizen project.
+ * @param configurationName Launch configuration name(make new one if it is not exist).
+ * @param buildConfiguration Configuration name to build Tizen native project(not need for Tizen web project).
+ * it uses current build configuration if this argument is null.
+ * @param mode Three type of launch mode: Run, Debug, Dynamic Analyzer
+ * @param ext Launch shortcut extension.
+ * @param device Device to launch Tizen project. It determines device later if this argument is null.
+ */
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.device = device;
}
- //launch add
+ /**
+ * This is a value object has various information needed to launch Tizen project.
+ * It get the values from previous launch.
+ * @param launch previous launch.
+ * @throws CoreException
+ */
public GomLaunchData(ILaunch launch)
{
launchConfiguration = launch.getLaunchConfiguration();
launchConfigurationName = launchConfiguration.getName();
mode = launch.getLaunchMode();
- this.device = null;
String config_device_id = null;
try {
config_device_id = launchConfiguration.getAttribute(GomSmartLauncher.ATTR_CONFIG_DEVICE_ID,
{
return launchConfigurationName;
}
-
+ /**
+ * This method returns short information from launch configuration.
+ * @return
+ */
public String getDataInfo()
{
if(device != null) {
*/
package org.tizen.common.gom.smartlaunch;
+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.core.runtime.CoreException;
+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.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.eclipse.ui.activities.WorkbenchActivityHelper;
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 static final String ATTR_CONFIG_DEVICE_ID = "org.tizen.common.launch.device.id";
public static final String ATTR_CONFIG_DEVICE_IS_EMULATOR = "org.tizen.common.launch.device.emulator";
-
public static final String ATTR_CONFIG_NO_DEVICE = "";
+ private static final String DEBUG_ATTACH = "Attach";
+
+ public static enum MODES {
+ RUN(ILaunchManager.RUN_MODE),
+ DEBUG(ILaunchManager.DEBUG_MODE),
+ PROFILE(ILaunchManager.PROFILE_MODE);
+
+ private String mode;
+
+ private MODES(String mode) {
+ this.mode = mode;
+ }
+ public String getMode() {
+ return mode;
+ }
+ }
- private static GomDialog gomDialog = null;
-
private final static Logger logger = LoggerFactory.getLogger(GomSmartLauncher.class);
-
+
public static void smartLaunch(final GomLaunchData data) {
if(data.getLaunchConfiguration() == null) {
}
}
- public static void openDialog(IWorkbenchWindow window) {
- if(gomDialog == null) {
- if(existTizenProjectBeforeDialogOpen(window)) {
- gomDialog = new GomDialog(window.getShell());
- if(gomDialog.open() == Window.OK) {
- IProject project = gomDialog.getProject();
- if(existProjectAndDeviceBeforeLaunch(project, window)) {
- smartLaunch(getLaunchData(gomDialog));
- }
- }
- gomDialog = null;
- } else {
- MessageDialog.openError(window.getShell(), GomMessages.SMARTLAUNCH_FAIL, GomMessages.SMARTLAUNCH_NO_PROJECT);
- }
- }
- }
-
- 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 existTizenProjectBeforeDialogOpen(IWorkbenchWindow window) {
+ public static boolean isExistProjectAndDevice(IProject project, 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 existProjectAndDeviceBeforeLaunch(IProject project, IWorkbenchWindow window) {
- boolean result = false;
-
+ String message = null;
if(!project.exists()) {
- MessageDialog.openError(window.getShell(), GomMessages.SMARTLAUNCH_FAIL, NLS.bind(GomMessages.SMARTLAUNCH_UNEXIST_PROJECT, project.getName()));
+ message = 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);
+ message = GomMessages.SMARTLAUNCH_DISCONNECTED_DEVICE;
}
} else {
result = true;
}
}
+ if(message != null) {
+ logger.error(message);
+ if(window != null) {
+ MessageDialog.openError(window.getShell(), GomMessages.SMARTLAUNCH_FAIL, message);
+ }
+ }
return result;
}
+
+ public static List getShortcuts(IProject project, String mode) {
+ LaunchConfigurationManager mgr = DebugUIPlugin.getDefault().getLaunchConfigurationManager();
+ List allShortcuts = mgr.getLaunchShortcuts(project);
+ Iterator iter = allShortcuts.iterator();
+ List 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);
+ }
+ }
+ }
+ }
+ return filteredShortcuts;
+ }
+
+ public static LaunchShortcutExtension getDebugAttachShortcut(IProject project) {
+ String mode = MODES.DEBUG.mode;
+ List shortcuts = getShortcuts(project, mode);
+ LaunchShortcutExtension ext = null;
+ Iterator iter = shortcuts.iterator();
+ while (iter.hasNext()) {
+ ext = (LaunchShortcutExtension) iter.next();
+ String label= ext.getContextLabel(mode);
+ if(label.contains(DEBUG_ATTACH)) {
+ System.out.println(label);
+ break;
+ }
+ }
+ return ext;
+ }
}
--- /dev/null
+/*
+ * 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.jface.dialogs.MessageDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tizen.common.gom.launch.GomLaunchData;
+import org.tizen.common.gom.smartlaunch.messages.GomMessages;
+import org.tizen.common.gom.smartlaunch.ui.GomDialog;
+import org.tizen.common.util.ProjectUtil;
+
+public class GomSmartUILauncher {
+
+ private static GomDialog gomDialog = null;
+
+ private final static Logger logger = LoggerFactory.getLogger(GomSmartUILauncher.class);
+
+ public static void openDialog(IWorkbenchWindow window) {
+ if(gomDialog == null) {
+ if(existTizenProjectBeforeDialogOpen(window)) {
+ gomDialog = new GomDialog(window.getShell());
+ if(gomDialog.open() == Window.OK) {
+ IProject project = gomDialog.getProject();
+ if(GomSmartLauncher.isExistProjectAndDevice(project, window)) {
+ GomSmartLauncher.smartLaunch(getLaunchData(gomDialog));
+ }
+ }
+ gomDialog = null;
+ } else {
+ MessageDialog.openError(window.getShell(), GomMessages.SMARTLAUNCH_FAIL, GomMessages.SMARTLAUNCH_NO_PROJECT);
+ }
+ }
+ }
+
+ 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 existTizenProjectBeforeDialogOpen(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;
+ }
+}
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.GomSmartUILauncher;
import org.tizen.common.gom.smartlaunch.GomSmartLaunchManager;
import org.tizen.common.gom.smartlaunch.messages.GomMessages;
if(recentIndex > -1)
{
GomLaunchData data = list.get(recentIndex);
- if(GomSmartLauncher.existProjectAndDeviceBeforeLaunch(data.getProject(), window)) {
+ if(GomSmartLauncher.isExistProjectAndDevice(data.getProject(), window)) {
new GomSmartLaunchAction(data).run();
}
}else
{
- GomSmartLauncher.openDialog(window);
+ GomSmartUILauncher.openDialog(window);
}
}
@Override
public void run()
{
- GomSmartLauncher.openDialog(window);
+ GomSmartUILauncher.openDialog(window);
}
};
addAction.setText(GomMessages.SMARTLAUNCH_NEW);
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.GomSmartUILauncher;
import org.tizen.common.gom.smartlaunch.GomSmartLauncher;
import org.tizen.common.gom.smartlaunch.messages.GomMessages;
import org.tizen.sdblib.IDevice;
if (selectedItem instanceof GomLaunchData) {
GomLaunchData data = (GomLaunchData)selectedItem;
- if(GomSmartLauncher.existProjectAndDeviceBeforeLaunch(data.getProject(), window)) {
+ if(GomSmartLauncher.isExistProjectAndDevice(data.getProject(), window)) {
GomSmartLauncher.smartLaunch(data);
}
}
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
-import org.tizen.common.gom.smartlaunch.GomSmartLauncher;
+import org.tizen.common.gom.smartlaunch.GomSmartUILauncher;
public class GomSmartLaunchHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
- GomSmartLauncher.openDialog(window);
+ GomSmartUILauncher.openDialog(window);
return null;
}
}
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
import org.eclipse.ui.activities.WorkbenchActivityHelper;
import org.tizen.common.ITizenNativeProject;
import org.tizen.common.TizenHelpContextIds;
+import org.tizen.common.gom.smartlaunch.GomSmartLauncher;
+import org.tizen.common.gom.smartlaunch.GomSmartLauncher.MODES;
import org.tizen.common.gom.smartlaunch.messages.GomMessages;
import org.tizen.common.util.FilenameUtil;
import org.tizen.common.util.OSChecker;
private Combo comboBuildConfiguration;
private Combo comboShortcut;
- private String[] modes= {ILaunchManager.RUN_MODE, ILaunchManager.DEBUG_MODE, ILaunchManager.PROFILE_MODE};
+ private String[] modes= {MODES.RUN.getMode(), MODES.DEBUG.getMode(), MODES.PROFILE.getMode()};
private List<IProject> projectList = new ArrayList<IProject>();
private List<String> configList = new ArrayList<String>();
- private List filteredShortCuts = null;
+ private List filteredShortcuts = null;
private String configurationName;
private IProject project;
public void widgetSelected(SelectionEvent e)
{
Combo combo = (Combo) e.widget;
- ext = (LaunchShortcutExtension)filteredShortCuts.get(combo.getSelectionIndex());
+ ext = (LaunchShortcutExtension)filteredShortcuts.get(combo.getSelectionIndex());
}
@Override
private void setShortcutCombo() {
comboShortcut.removeAll();
- LaunchConfigurationManager mgr = DebugUIPlugin.getDefault().getLaunchConfigurationManager();
- List allShortCuts = mgr.getLaunchShortcuts(project);
- Iterator iter = allShortCuts.iterator();
- filteredShortCuts = new ArrayList();
+ filteredShortcuts = GomSmartLauncher.getShortcuts(project, mode);
+ Iterator iter = filteredShortcuts.iterator();
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);
- comboShortcut.add(ext.getContextLabel(mode));
- }
- }
- }
+ comboShortcut.add(ext.getContextLabel(mode));
}
if(setComboSelectDefault(comboShortcut))
{
- ext = (LaunchShortcutExtension)filteredShortCuts.get(0);
+ ext = (LaunchShortcutExtension)filteredShortcuts.get(0);
}
}