From c97d01bc8ed4f347e712f3f9a44c8ba500167364 Mon Sep 17 00:00:00 2001 From: "donghyuk.yang" Date: Fri, 16 Nov 2012 16:50:57 +0900 Subject: [PATCH] [Title] Added attach debugging modules --- org.tizen.nativeplatform/plugin.xml | 4 +- .../launch/ITizenLaunchConfigurationConstants.java | 3 + .../launch/TizenDebianLaunchDelegate.java | 83 ++-- .../launch/TizenDebianLaunchDelegateForAttach.java | 186 ++++---- .../launch/TizenDebianLaunchMessages.java | 7 + .../launch/TizenDebianLaunchMessages.properties | 7 + .../launch/ui/LaunchTabUIMessages.properties | 25 ++ .../launch/ui/TizenDebianMainAttachTab.java | 472 +++++++++++++++++++++ .../launch/ui/TizenDebianMainTab.java | 46 +- .../TizenDebianProjectAttachLaunchShortcut.java | 168 +++++++- .../shortcut/TizenDebianProjectLaunchShortcut.java | 77 +--- .../wizards/LaunchWizardUIMessages.properties | 22 + .../launch/wizards/PlatformAttachLaunchWizard.java | 115 +++++ .../wizards/PlatformLaunchSettingAppPage.java | 38 +- .../wizards/PlatformLaunchSettingBinPage.java | 17 +- .../wizards/PlatformLaunchSettingProcPage.java | 265 ++++++++++++ .../launch/wizards/PlatformLaunchUtils.java | 169 ++++++++ .../launch/wizards/PlatformLaunchWizard.java | 69 +-- .../launch/wizards/PlatformLaunchWizardDialog.java | 31 ++ .../launch/wizards/ShowPackageStatusDialog.java | 39 +- .../wizards/TizenPlatformProjectWizard.java | 6 + 21 files changed, 1521 insertions(+), 328 deletions(-) create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/LaunchTabUIMessages.properties create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/TizenDebianMainAttachTab.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/LaunchWizardUIMessages.properties create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformAttachLaunchWizard.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchSettingProcPage.java diff --git a/org.tizen.nativeplatform/plugin.xml b/org.tizen.nativeplatform/plugin.xml index e0e3ba3..6e8ad90 100644 --- a/org.tizen.nativeplatform/plugin.xml +++ b/org.tizen.nativeplatform/plugin.xml @@ -327,10 +327,10 @@ + class="org.tizen.nativeplatform.launch.ui.TizenDebianMainAttachTab"> diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ITizenLaunchConfigurationConstants.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ITizenLaunchConfigurationConstants.java index 7ad172a..7e8c610 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ITizenLaunchConfigurationConstants.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ITizenLaunchConfigurationConstants.java @@ -7,6 +7,9 @@ public interface ITizenLaunchConfigurationConstants { public static final String ATTR_REINSTALL_OPTION = PLATFORM_LAUNCH_ID + ".REINSTALL_OP_ATTR"; //$NON-NLS-1$ public static final String ATTR_SELECTPKG_OPTION = PLATFORM_LAUNCH_ID + ".SELECTPKG_OP_ATTR"; //$NON-NLS-1$ public static final String ATTR_FROM_SHORTCUT = PLATFORM_LAUNCH_ID + ".FROM_SHORTCUT_ATTR"; //$NON-NLS-1$ + public static final String ATTR_PROCESSNAME_OPTION = PLATFORM_LAUNCH_ID + ".PROCESS_NAME_ATTR"; //$NON-NLS-1$ + public static final String ATTR_PROCESSID_OPTION = PLATFORM_LAUNCH_ID + ".PROCESS_ID_ATTR"; //$NON-NLS-1$ } + \ No newline at end of file diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegate.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegate.java index 53eeab1..4b41507 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegate.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegate.java @@ -30,9 +30,7 @@ package org.tizen.nativeplatform.launch; import java.io.File; import java.io.FilenameFilter; -import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; @@ -48,14 +46,10 @@ import org.eclipse.cdt.launch.AbstractCLaunchDelegate; import org.eclipse.cdt.launch.LaunchUtils; import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.cdt.managedbuilder.core.IConfiguration; -import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; -import org.eclipse.cdt.managedbuilder.core.IManagedProject; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.ui.newui.CDTPropertyManager; -import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; @@ -71,9 +65,6 @@ import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.core.model.IProcess; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.window.Window; @@ -102,21 +93,20 @@ import org.tizen.nativeplatform.build.PlatformConfigurationManager; import org.tizen.nativeplatform.build.PlatformProjectPackaging; import org.tizen.nativeplatform.launch.wizards.PlatformLaunchUtils; import org.tizen.nativeplatform.launch.wizards.ShowPackageStatusDialog; -import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander; import org.tizen.nativeplatform.pkgmgr.model.LocalPackage; import org.tizen.sdblib.IDevice; +import org.tizen.sdblib.SdbShellProcess; public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate { protected IConfiguration selectedConfig; protected IDevice currentDevice; + protected SdbShellProcess serverProc = null; protected String executeResult = ""; protected int localDebugPort = -1; protected ICDISession debugSession; protected static final int defaultTimeOut = 60000; - private Shell shell; - private boolean result; - private ArrayList BuildSystemPkgs = null; - private ArrayList DevicePkgs = null; + protected Shell shell; + private boolean result; protected String getPluginID() { return Activator.PLUGIN_ID; @@ -136,12 +126,12 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate { verifyBuildConfiguration(config, mode, new SubProgressMonitor(monitor, 1)); if (!fromShortcut(config)) { - verifyExistPackages(config, new SubProgressMonitor(monitor, 1)); + setConfigIfNotFromShortcut(config, mode, new SubProgressMonitor(monitor, 1)); } - if (mode.equals(ILaunchManager.DEBUG_MODE)) { - verifyTizenDebianProjectSettings(config); + if (mode.equals(ILaunchManager.DEBUG_MODE)) { setDebugConfigAttributes(config); + verifyTizenDebianProjectSettings(config); setDefaultSourceLocator(launch, config); IBinaryObject exeFile = getBinaryObject(config); launchApplicationForDebug(launch, config, exeFile, new SubProgressMonitor(monitor, 10)); @@ -157,10 +147,18 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate { ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); launchManager.removeLaunch(launch); } - monitor.done(); + monitor.done(); + if (serverProc != null) { + serverProc.destroy(); + } } } + protected void setConfigIfNotFromShortcut(ILaunchConfiguration config, String mode, IProgressMonitor monitor) + throws CoreException { + installPackages(config, mode, monitor); + } + private boolean fromShortcut(ILaunchConfiguration config) { boolean result = false; try { @@ -199,7 +197,7 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate { } } - private boolean packagingProject(IProject targetProj, IConfiguration config, IProgressMonitor monitor) { + protected boolean packagingProject(IProject targetProj, IConfiguration config, IProgressMonitor monitor) { boolean packagingResult = false; packagingResult = PlatformProjectPackaging.RPMPackaging(targetProj, config, monitor); @@ -215,7 +213,7 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate { return packagingResult; } - private void verifyExistPackages(ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException { + protected void installPackages(ILaunchConfiguration config, String mode, IProgressMonitor monitor) throws CoreException { IProject platformProject = getProject(config); IProject appProject = null; final PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(); @@ -235,14 +233,13 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate { final ArrayList platformPkgs = launchUtils.getProjectPackages(platformProject, buildConfigName); if (platformPkgs.isEmpty()) { - String msg = String.format("\"%s\" project does not have package files(*.rpm)\n" + - "Do you want packaging now ?\n", platformProject.getName()); + String msg = String.format(TizenDebianLaunchMessages.QUESTION_PACKAGING, platformProject.getName()); if (64 == DialogUtil.openQuestionDialog(msg)) { if (packagingProject(platformProject, buildConfig, new SubProgressMonitor(monitor, 1))) { platformPkgs.addAll(launchUtils.getProjectPackages(platformProject, buildConfigName)); } else { - if (64 != DialogUtil.openQuestionDialog("Do you want to continue ?")) { - newCoreException("Canceled", null); + if (64 != DialogUtil.openQuestionDialog(TizenDebianLaunchMessages.QUESTION_CONTINUE)) { + newCoreException(TizenDebianLaunchMessages.CANCELED_LAUNCH, null); } } } @@ -255,14 +252,13 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate { appPkgs = launchUtils.getProjectPackages(appProject, buildConfigName); if (appPkgs.isEmpty()) { - String msg = String.format("\"%s\" project does not have package files(*.rpm)\n" + - "Do you want packaging now ?\n", appProject.getName()); + String msg = String.format(TizenDebianLaunchMessages.QUESTION_PACKAGING, appProject.getName()); if (64 == DialogUtil.openQuestionDialog(msg)) { if (packagingProject(appProject, buildConfig, new SubProgressMonitor(monitor, 1))) { appPkgs.addAll(launchUtils.getProjectPackages(appProject, buildConfigName)); } else { - if (64 != DialogUtil.openQuestionDialog("Do you want to continue ?")) { - newCoreException("Canceled", null); + if (64 != DialogUtil.openQuestionDialog(TizenDebianLaunchMessages.QUESTION_CONTINUE)) { + newCoreException(TizenDebianLaunchMessages.CANCELED_LAUNCH, null); } } } @@ -287,16 +283,18 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate { final ArrayList BuildSystemPkgs = new ArrayList(); final ArrayList DevicePkgs = new ArrayList(); - launchUtils.filterBuildsystemPkgs(packages, BuildSystemPkgs, rootstrapPath, reinstallOp); + if (mode.equals(ILaunchManager.DEBUG_MODE)) { + launchUtils.filterBuildsystemPkgs(packages, BuildSystemPkgs, rootstrapPath, reinstallOp); + } launchUtils.filterDevicePackages(packages, DevicePkgs, currentDevice, reinstallOp); try { - monitor.beginTask("Install packages", 4); - monitor.subTask("Checking package status"); + monitor.beginTask(TizenDebianLaunchMessages.INSTALL_PACKAGE, 4); + monitor.subTask(TizenDebianLaunchMessages.CHECK_PKG_STATUS); if (selectPkgOp) { if (!openPkgStatusDialog(BuildSystemPkgs, DevicePkgs)) { - newCoreException("Canceled", null); + newCoreException(TizenDebianLaunchMessages.CANCELED_LAUNCH, null); } } @@ -304,19 +302,18 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate { ArrayList selecteDvPkgs = launchUtils.getSelectedPackages(DevicePkgs); monitor.worked(1); - monitor.subTask("Install packages to rootstrap"); + monitor.subTask(TizenDebianLaunchMessages.INSTALL_PACKAGES_TO_BUILDSYSTEM); if (selecteBsPkgs != null && !selecteBsPkgs.isEmpty()) { launchUtils.installPkgsToRootstrap(selecteBsPkgs, rootstrapPath, new SubProgressMonitor(monitor, 1)); } - //monitor.worked(2); - monitor.subTask("Install packages to device"); + + monitor.subTask(TizenDebianLaunchMessages.INSTALL_PACKAGES_TO_DEVICE); if (selecteDvPkgs != null && !selecteDvPkgs.isEmpty()) { launchUtils.installPkgsToDevice(selecteDvPkgs, currentDevice, new SubProgressMonitor(monitor, 1)); } - //monitor.worked(3); + monitor.done(); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } } @@ -489,8 +486,8 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate { protected void launchApplicationForDebug(ILaunch launch, ILaunchConfiguration config, IBinaryObject exeFile, IProgressMonitor monitor) throws CoreException, OperationCanceledException { try { monitor.beginTask(TizenLaunchMessages.LAUNCH_APPLICATION, 1); - //monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION); - launchApplicationWithGDBServer(launch, config, new SubProgressMonitor(monitor, 1)); + monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION); + launchApplicationWithGDBServer(launch, config, new SubProgressMonitor(monitor, 1)); launchApplicationWithGDBClient(launch, config, exeFile, new SubProgressMonitor(monitor, 1)); } finally { monitor.done(); @@ -500,13 +497,13 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate { protected void launchApplicationWithGDBServer(ILaunch launch, ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException { try { monitor.beginTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBSERVER, 1); - //monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBSERVER); + monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBSERVER); String gdbserverPort = config.getAttribute(TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT, TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT); String gdbserverCmd = TizenPlatformConstants.GDBSERVER_PLATFORM_CMD + " :" + gdbserverPort; String execArg = setArguments(config); String envCmd = setEnvironments(config); String command = envCmd + gdbserverCmd + " " + execArg; - currentDevice.executeShellCommand(command); + serverProc = currentDevice.executeShellCommand(command); } catch (Exception e) { newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER, null); } finally { @@ -517,7 +514,7 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate { protected void launchApplicationWithGDBClient(ILaunch launch, ILaunchConfiguration config, IBinaryObject exeFile, IProgressMonitor monitor) throws CoreException { try { monitor.beginTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBCLIENT, 1); - //monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBCLIENT); + monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBCLIENT); TizenDebugger debugger = new TizenDebugger(); debugSession = ((ICDIDebugger2)debugger).createSession(launch, exeFile.getPath().toFile(), new SubProgressMonitor(monitor, 1)); @@ -677,7 +674,7 @@ public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate { return new Path(rootstrapPath); } - private boolean openPkgStatusDialog(final ArrayList BuildSystemPkgs, final ArrayList DevicePkgs) { + protected boolean openPkgStatusDialog(final ArrayList BuildSystemPkgs, final ArrayList DevicePkgs) { SWTUtil.syncExec(new Runnable() { public void run() { ShowPackageStatusDialog statusDlg = new ShowPackageStatusDialog(shell, BuildSystemPkgs, DevicePkgs); diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegateForAttach.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegateForAttach.java index cf2a75f..d955754 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegateForAttach.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchDelegateForAttach.java @@ -28,37 +28,40 @@ */ package org.tizen.nativeplatform.launch; +import java.util.ArrayList; + import org.eclipse.cdt.core.IProcessInfo; -import org.eclipse.cdt.core.IProcessList; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.mi.core.IGDBServerMILaunchConfigurationConstants; -import org.eclipse.cdt.launch.internal.ui.LaunchImages; -import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.dialogs.TwoPaneElementSelector; +import org.eclipse.debug.core.ILaunchManager; import org.tizen.common.TizenPlatformConstants; -import org.tizen.nativecommon.launch.TizenDeviceProcessList; +import org.tizen.common.util.DialogUtil; +import org.tizen.nativecommon.build.SmartBuildInterface; +import org.tizen.nativecommon.build.exception.SBIException; import org.tizen.nativecommon.launch.TizenLaunchConfigurationConstants; import org.tizen.nativecommon.launch.TizenLaunchMessages; +import org.tizen.nativeplatform.build.PlatformConfigurationManager; +import org.tizen.nativeplatform.launch.wizards.PlatformLaunchUtils; +import org.tizen.nativeplatform.pkgmgr.model.LocalPackage; public class TizenDebianLaunchDelegateForAttach extends TizenDebianLaunchDelegate { - protected Integer pid = Integer.valueOf(-1); + + protected Integer pid = Integer.valueOf(-1); + protected IProcessInfo procInfo = null; @Override protected void setDebugConfigAttributes(ILaunchConfiguration config) throws CoreException { ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy(); + + pid = wc.getAttribute(ITizenLaunchConfigurationConstants.ATTR_PROCESSID_OPTION, -1); wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, true); wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, TizenPlatformConstants.LOCALHOST); String gdbserverPort = wc.getAttribute(TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT, TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT); @@ -77,21 +80,28 @@ public class TizenDebianLaunchDelegateForAttach extends TizenDebianLaunchDelegat } @Override + protected void setConfigIfNotFromShortcut(ILaunchConfiguration config, String mode, IProgressMonitor monitor) + throws CoreException { + setAttachProcess(config); + installPackages(config, mode, monitor); + } + + @Override protected void launchApplicationWithGDBServer(ILaunch launch, ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException { try { monitor.beginTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBSERVER, 1); monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION_WITH_GDBSERVER); - setPID(); - if (pid.equals(Integer.valueOf(-1)) || pid.equals(Integer.valueOf(0))) + if (pid.equals(Integer.valueOf(-1)) || pid.equals(Integer.valueOf(0))) { newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER + ICDTLaunchConfigurationConstants.ERR_NO_PROCESSID, null); + } String gdbserverPort = config.getAttribute(TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT, TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT); String commandArguments = ":" + gdbserverPort + TizenPlatformConstants.ATTACH_OPTION + pid; String gdbserverCmd = TizenPlatformConstants.GDBSERVER_PLATFORM_CMD + " " + commandArguments; String envCmd = setEnvironments(config); String command = envCmd + gdbserverCmd; - currentDevice.executeShellCommand(command); + serverProc = currentDevice.executeShellCommand(command); } catch (Exception e) { newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER, null); } finally { @@ -99,71 +109,91 @@ public class TizenDebianLaunchDelegateForAttach extends TizenDebianLaunchDelegat } } - private void setPID() { - Display.getDefault().syncExec(new Runnable() { - public void run() { - pid = promptForProcessID(); - } - }); - } - - private Integer promptForProcessID() { - try { - return selectProcess(); - } catch (CoreException e) { - return Integer.valueOf(-1); - } - } + private void setAttachProcess(ILaunchConfiguration config) throws CoreException { + final PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(); + String processName = config.getAttribute(ITizenLaunchConfigurationConstants.ATTR_PROCESSNAME_OPTION, ""); + + IProcessInfo procInfo = launchUtils.getProcess(shell, currentDevice, processName); + if (procInfo == null) { + newCoreException("Canceled", null); + } + + String programPath = procInfo.getName().trim(); + int pid = procInfo.getPid(); + + ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy(); + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programPath); + wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_PROCESSID_OPTION, pid); + wc.doSave(); + } - private Integer selectProcess() throws CoreException { - Shell shell = LaunchUIPlugin.getShell(); - if (shell == null) - newCoreException(TizenLaunchMessages.CANNOT_LAUNCH, null); - - ILabelProvider topprovider = new LabelProvider() { - public String getText(Object element) { - IProcessInfo pinfo = (IProcessInfo)element; - IPath ppath = new Path(pinfo.getName()); - return ppath.lastSegment() + " - " + pinfo.getPid(); //$NON-NLS-1$ - } + protected void installPackages(ILaunchConfiguration config, String mode, IProgressMonitor monitor) throws CoreException { + IProject platformProject = getProject(config); + final PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(); + + boolean reinstallOp = config.getAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, true); + boolean selectPkgOp = config.getAttribute(ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, true); + + ArrayList packages = new ArrayList(); + + String buildConfigName = getBuildConfigName(config); + IConfiguration buildConfig = getBuildConfiguration(buildConfigName, platformProject); + String targetID = PlatformConfigurationManager.getBuildTargetName(buildConfig); + + final ArrayList platformPkgs = launchUtils.getProjectPackages(platformProject, buildConfigName); + if (platformPkgs.isEmpty()) { + String msg = String.format(TizenDebianLaunchMessages.QUESTION_PACKAGING, platformProject.getName()); + if (64 == DialogUtil.openQuestionDialog(msg)) { + if (packagingProject(platformProject, buildConfig, new SubProgressMonitor(monitor, 1))) { + platformPkgs.addAll(launchUtils.getProjectPackages(platformProject, buildConfigName)); + } else { + if (64 != DialogUtil.openQuestionDialog(TizenDebianLaunchMessages.QUESTION_CONTINUE)) { + newCoreException(TizenDebianLaunchMessages.CANCELED_LAUNCH, null); + } + } + } + } + + packages.addAll(platformPkgs); - public Image getImage(Object element) { - return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC); + String path = ""; + try { + path = SmartBuildInterface.getInstance().getRootstrapPath(targetID); + } catch (SBIException e) { + newCoreException(TizenDebianLaunchMessages.CANNOT_FIND_HOST_ROOTSTRAP_PATH, e); } - }; - - ILabelProvider downprovider = new LabelProvider() { - public String getText(Object element) { - IProcessInfo info = (IProcessInfo)element; - return info.getName(); - } - - public Image getImage(Object element) { - return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC); + + final String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(path); + + final ArrayList BuildSystemPkgs = new ArrayList(); + final ArrayList DevicePkgs = new ArrayList(); + + if (mode.equals(ILaunchManager.DEBUG_MODE)) { + launchUtils.filterBuildsystemPkgs(packages, BuildSystemPkgs, rootstrapPath, reinstallOp); } - }; - - TwoPaneElementSelector dlg = new TwoPaneElementSelector(shell, topprovider, downprovider); - dlg.setTitle("Select Process"); //$NON-NLS-1$ - dlg.setMessage("Select a Process to attach debugger to:"); //$NON-NLS-1$ - - IProcessList processList = null; - processList = new TizenDeviceProcessList(currentDevice); - IProcessInfo pInfos[] = null; - pInfos = processList.getProcessList(); - - if(pInfos == null) - newCoreException(TizenLaunchMessages.CANNOT_LAUNCH, null); + try { + monitor.beginTask(TizenDebianLaunchMessages.INSTALL_PACKAGE, 4); + monitor.subTask(TizenDebianLaunchMessages.CHECK_PKG_STATUS); - dlg.setElements(pInfos); - - if (dlg.open() == Window.OK) { - IProcessInfo info = (IProcessInfo)dlg.getFirstResult(); - if (info != null) - return Integer.valueOf(info.getPid()); - } - - return Integer.valueOf(-1); - } + if (selectPkgOp) { + if (!openPkgStatusDialog(BuildSystemPkgs, DevicePkgs)) { + newCoreException(TizenDebianLaunchMessages.CANCELED_LAUNCH, null); + } + } + + ArrayList selecteBsPkgs = launchUtils.getSelectedPackages(BuildSystemPkgs); + + monitor.worked(1); + monitor.subTask(TizenDebianLaunchMessages.INSTALL_PACKAGES_TO_BUILDSYSTEM); + if (selecteBsPkgs != null && !selecteBsPkgs.isEmpty()) { + launchUtils.installPkgsToRootstrap(selecteBsPkgs, rootstrapPath, new SubProgressMonitor(monitor, 1)); + } + monitor.subTask(TizenDebianLaunchMessages.INSTALL_PACKAGES_TO_DEVICE); + // Nothing to do for device + monitor.done(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } } \ No newline at end of file diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchMessages.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchMessages.java index 35705c8..6e79897 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchMessages.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchMessages.java @@ -58,4 +58,11 @@ public class TizenDebianLaunchMessages extends NLS { public static String CREATE_PACKAGE; public static String TRANSFER_PACKAGE; public static String INSTALL_PACKAGE; + public static String INSTALL_PACKAGES_TO_BUILDSYSTEM; + public static String INSTALL_PACKAGES_TO_DEVICE; + public static String CHECK_PKG_STATUS; + public static String CANCELED_LAUNCH; + public static String QUESTION_PACKAGING; + public static String QUESTION_CONTINUE; + public static String FAILED_INSTALL_PKGS; } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchMessages.properties b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchMessages.properties index 516b3ec..431df9e 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchMessages.properties +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/TizenDebianLaunchMessages.properties @@ -21,3 +21,10 @@ START_DEPLOY_PROCESS = Starting the deployment process... CREATE_PACKAGE = Creating the package... TRANSFER_PACKAGE = Transferring the package... INSTALL_PACKAGE = Installing the package... +INSTALL_PACKAGES_TO_BUILDSYSTEM = Installing packages to buildsystem +INSTALL_PACKAGES_TO_DEVICE = Installing packages to device +CHECK_PKG_STATUS = Checking package status +CANCELED_LAUNCH = Canceled launching +QUESTION_PACKAGING = "%s" project does not have package files(*.rpm)\nDo you want packaging now ?\n +QUESTION_CONTINUE = Do you want to continue ? +FAILED_INSTALL_PKGS = Failed to install packages. See below logs \ No newline at end of file diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/LaunchTabUIMessages.properties b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/LaunchTabUIMessages.properties new file mode 100644 index 0000000..d4b36e6 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/LaunchTabUIMessages.properties @@ -0,0 +1,25 @@ +AppPage.Title = Setting Tizen Application +AppPage.Desc = Please select a tizen application or add RPM files for testing +Label.AdditionPkgs = Additional Packages: +Label.App.Project = Tizen Application Project: +Label.App.Path = Tizen Application Path: +Label.Proc.Name = Attach Process: +File.Dialog.Title.File = Select RPM files + +BinPage.Title = Setting binary path +BinPage.Desc = Please set a path for test binary +Button.Browse = Remote Browse... +Button.Find = Find +Remote.Dialog.Title = Select an Application + +ProcPage.Title = Select Process +ProcPage.Desc = Please select a process for attach debugging + +PkgDialog.Title = Select packages to be installed +PkgDialog.Desc = Checked packages will be installed to buildsystem and device +PkgDialog.Label.Buildsystem = To Buildsystem: +PkgDialog.Label.Device = To Device: + + +Button.Reinstall.Op = Reinstall if the package is already present +Button.SelectPkg.Op = Select packages to be installed manually \ No newline at end of file diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/TizenDebianMainAttachTab.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/TizenDebianMainAttachTab.java new file mode 100644 index 0000000..bbfcc0e --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/TizenDebianMainAttachTab.java @@ -0,0 +1,472 @@ +/* +* Inhouse +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: +* Taejun Ha +* Jiil Hyoun +* Donghyuk Yang +* Hoon Kang +* DongHee Yang +* +* 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.nativeplatform.launch.ui; + +import java.util.ArrayList; +import java.util.List; +import java.util.ResourceBundle; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.ICDescriptor; +import org.eclipse.cdt.core.IProcessInfo; +import org.eclipse.cdt.core.model.CModelException; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.IBinary; +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; +import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants; +import org.eclipse.cdt.launch.internal.ui.LaunchMessages; +import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; +import org.eclipse.cdt.launch.ui.CMainTab; +import org.eclipse.cdt.ui.CElementLabelProvider; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerSorter; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.MessageBox; +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.swt.widgets.Text; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.ElementListSelectionDialog; + +import org.tizen.common.connection.ConnectionPlugin; +import org.tizen.common.connection.ui.TizenRemoteFileDialog; +import org.tizen.common.connection.ui.TizenRemoteFileDialog.TizenRemoteFileDialogResult; +import org.tizen.common.util.ImageUtil; +import org.tizen.nativecommon.launch.TizenLaunchMessages; +import org.tizen.nativeplatform.Activator; +import org.tizen.nativeplatform.launch.ITizenLaunchConfigurationConstants; +import org.tizen.nativeplatform.launch.wizards.PlatformLaunchUtils; +import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander; +import org.tizen.nativeplatform.pkgmgr.model.LocalPackage; +import org.tizen.nativeplatform.rootstrap.RootstrapManager; + +import org.tizen.sdblib.FileListingService.FileEntry; +import org.tizen.sdblib.IDevice; + +public class TizenDebianMainAttachTab extends CMainTab { + + private final String BUNDLE_NAME = TizenDebianMainAttachTab.class.getPackage().getName() + ".LaunchTabUIMessages";//$NON-NLS-1$ + private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + + private Label fProcLabel; + private Text fProgText; + private Text fProcText; + private Button fProcButton; + private Button fReinstallOp; + private Button fSelectPkgOp; + private TableViewer tableViewer; + private boolean fSpecifyCoreFile; + private IDevice device; + private ArrayList packages = new ArrayList(); + private static final String DEFAULT_APP_PATH = "/opt/apps/"; + private String filePath = ""; + private String selectedFileList = ""; + + public TizenDebianMainAttachTab() { + this(false); + } + + public TizenDebianMainAttachTab(boolean specifyCoreFile) { + fSpecifyCoreFile = specifyCoreFile; + device = ConnectionPlugin.getDefault().getCurrentDevice(); + } + + @Override + public void createControl(Composite parent) { + Composite comp = new Composite(parent, SWT.NONE); + setControl(comp); + + GridLayout topLayout = new GridLayout(); + comp.setLayout(topLayout); + + createVerticalSpacer(comp, 1); + createProjectGroup(comp, 1); + createProcessGroup(comp, 1); + createOptionGroupComposite(comp); + + if (fSpecifyCoreFile) + createCoreFileGroup(comp, 1); + createVerticalSpacer(comp, 1); + } + + + @Override + protected String handleBrowseButtonSelected() { + FileDialog fileDialog = new FileDialog(getShell(), SWT.NONE); + if (fProgText != null) + fileDialog.setFileName(fProgText.getText()); + else if (fCoreText != null) + fileDialog.setFileName(fCoreText.getText()); + return fileDialog.open(); + } + + private void createOptionGroupComposite(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_END)); + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 1; + gridLayout.marginWidth = 0; + gridLayout.marginHeight = 0; + composite.setLayout(gridLayout); + + fReinstallOp = new Button(composite, SWT.CHECK); + fReinstallOp.setText(resources.getString("Button.Reinstall.Op")); + fSelectPkgOp = new Button(composite, SWT.CHECK); + fSelectPkgOp.setText(resources.getString("Button.SelectPkg.Op")); + + fReinstallOp.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent evt) { + updateLaunchConfigurationDialog(); + } + }); + + fSelectPkgOp.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent evt) { + updateLaunchConfigurationDialog(); + } + }); + } + + private void createTableTitleComposite(Composite parent) { + Label tableLabel = new Label(parent, SWT.NONE); + tableLabel.setText(resources.getString("Label.AdditionPkgs")); + } + + private boolean existsPkg(LocalPackage pkg) { + for (LocalPackage p : packages) { + if (pkg.getPath().equals(p.getPath())) { + return true; + } + } + return false; + } + + private void createProcessGroup(Composite parent, int colSpan) { + Composite projComp = new Composite(parent, SWT.NONE); + GridLayout projLayout = new GridLayout(); + projLayout.numColumns = 2; + projLayout.marginHeight = 0; + projLayout.marginWidth = 0; + projComp.setLayout(projLayout); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = colSpan; + projComp.setLayoutData(gd); + + fProcLabel = new Label(projComp, SWT.NONE); + fProcLabel.setText(resources.getString("Label.Proc.Name")); + gd = new GridData(); + gd.horizontalSpan = 2; + fProcLabel.setLayoutData(gd); + + fProcText = new Text(projComp, SWT.SINGLE | SWT.BORDER); + gd = new GridData(GridData.FILL_HORIZONTAL); + fProcText.setLayoutData(gd); + fProcText.addModifyListener(new ModifyListener() { + + public void modifyText(ModifyEvent evt) { + // if project changes, invalidate program name cache + fPreviouslyCheckedProgram = null; + + updateBuildConfigCombo(""); //$NON-NLS-1$ + updateLaunchConfigurationDialog(); + } + }); + + fProcButton = createPushButton(projComp, resources.getString("Button.Find"), null); + fProcButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent evt) { + PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(); + IProcessInfo procInfo = launchUtils.getProcess(getShell(), device); + if (procInfo != null) { + IPath ppath = new Path(procInfo.getName()); + String name = ppath.lastSegment().trim(); + fProcText.setText(name); + updateLaunchConfigurationDialog(); + } + } + }); + } + + protected ICProject chooseCAppProject(String currentProjectName) { + + try { + ICProject[] projects = getCProjects(currentProjectName); + + ILabelProvider labelProvider = new CElementLabelProvider(); + ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider); + dialog.setTitle(LaunchMessages.CMainTab_Project_Selection); + dialog.setMessage(LaunchMessages.CMainTab_Choose_project_to_constrain_search_for_program); + dialog.setElements(projects); + + ICProject cProject = getCProject(); + if (cProject != null) { + dialog.setInitialSelections(new Object[] { cProject }); + } + if (dialog.open() == Window.OK) { + return (ICProject)dialog.getFirstResult(); + } + } catch (CModelException e) { + LaunchUIPlugin.errorDialog("Launch UI internal error", e); //$NON-NLS-1$ + } + return null; + } + + protected ICProject[] getCProjects(String currentProjectName) throws CModelException { + ICProject cproject[] = CoreModel.getDefault().getCModel().getCProjects(); + ArrayList list = new ArrayList(cproject.length); + + for (int i = 0; i < cproject.length; i++) { + if (currentProjectName.length() != 0 && + cproject[i].getProject().getName().equals(currentProjectName)) { + continue; + } + ICDescriptor cdesciptor = null; + try { + cdesciptor = CCorePlugin.getDefault().getCProjectDescription((IProject) cproject[i].getResource(), false); + if (cdesciptor != null) { + String projectPlatform = cdesciptor.getPlatform(); + if (filterPlatform.equals("*") //$NON-NLS-1$ + || projectPlatform.equals("*") //$NON-NLS-1$ + || filterPlatform.equalsIgnoreCase(projectPlatform) == true) { + list.add(cproject[i]); + } + } else { + list.add(cproject[i]); + } + } catch (CoreException e) { + list.add(cproject[i]); + } + } + return list.toArray(new ICProject[list.size()]); + } + + private void createExeFileField(Composite parent, int colSpan) { + Composite mainComp = new Composite(parent, SWT.NONE); + GridLayout mainLayout = new GridLayout(); + mainLayout.numColumns = 3; + mainLayout.marginHeight = 0; + mainLayout.marginWidth = 0; + mainComp.setLayout(mainLayout); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = colSpan; + mainComp.setLayoutData(gd); + fProgLabel = new Label(mainComp, SWT.NONE); + fProgLabel.setText(resources.getString("Label.App.Path")); // $NON-NLS-1$ + gd = new GridData(); + gd.horizontalSpan = 3; + fProgLabel.setLayoutData(gd); + fProgText = new Text(mainComp, SWT.SINGLE | SWT.BORDER); + gd = new GridData(GridData.FILL_HORIZONTAL); + fProgText.setLayoutData(gd); + fProgText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent evt) { + updateLaunchConfigurationDialog(); + } + }); + + Button fBrowseForBinaryButton; + fBrowseForBinaryButton = createPushButton(mainComp, resources.getString("Button.Browse"), null); //$NON-NLS-1$ + fBrowseForBinaryButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent evt) { + handleRemoteBrowseButtonSelected(); + updateLaunchConfigurationDialog(); + } + }); + } + + protected void handleRemoteBrowseButtonSelected() { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) { + IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows(); + window = windows[0]; + } + + final Shell shell = window.getShell(); + if (shell != null) { + IDevice device = ConnectionPlugin.getDefault().getCurrentDevice(); + if (device == null) { + MessageBox msgBox = new MessageBox(shell, SWT.ICON_INFORMATION); + msgBox.setMessage(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE); + msgBox.open(); + return; + } + + shell.getDisplay().syncExec( new Runnable() { + public void run() { + IDevice device = ConnectionPlugin.getDefault().getCurrentDevice(); + TizenRemoteFileDialog dlg = new TizenRemoteFileDialog(shell, + resources.getString("Remote.Dialog.Title"), device, false, DEFAULT_APP_PATH); + if(dlg.open() == TizenRemoteFileDialogResult.OK) { + FileEntry selectedFile = dlg.getSelectedFileEntry(); + filePath = selectedFile.getFullPath(); + fProgText.setText(filePath); + } else + filePath = null; + } + }); + } + return; + } + + + @Override + public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { + configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, true); + configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS, false); + configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED); + configuration.setAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, true); + configuration.setAttribute(ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, true); + ICElement cElement = null; + cElement = getContext(configuration, getPlatform(configuration)); + if (cElement != null) + initializeCProject(cElement, configuration); + } + + @Override + public void initializeFrom(ILaunchConfiguration configuration) { + updateProjectFromConfig(configuration); + updateProcessFromConfig(configuration); + updateReinstallOpFromConfig(configuration); + updateSelectPkgOpFromConfig(configuration); + if (fSpecifyCoreFile) + updateCoreFromConfig(configuration); + } + + @Override + public boolean isValid(ILaunchConfiguration config) { + return true; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.launch.ui.CMainTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) + */ + @Override + public void performApply(ILaunchConfigurationWorkingCopy config) { + //String programPath = fProgText.getText().trim(); + String name = fProjText.getText().trim(); + String procName = fProcText.getText().trim(); + boolean reinstallOp = fReinstallOp.getSelection(); + boolean selectPkgOp = fSelectPkgOp.getSelection(); + ArrayList pkgs = new ArrayList(); + + for (LocalPackage p : packages) { + pkgs.add(p.getPath()); + } + + config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, name); + config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_PROCESSNAME_OPTION, procName); + config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, reinstallOp); + config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, selectPkgOp); + } + + @Override + protected void updateProjectFromConfig(ILaunchConfiguration config) { + String projectName = EMPTY_STRING; + try { + projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, EMPTY_STRING); + } catch (CoreException ce) { + LaunchUIPlugin.log(ce); + } + fProjText.setText(projectName); + } + + protected void updateProcessFromConfig(ILaunchConfiguration config) { + String procName = EMPTY_STRING; + try { + procName = config.getAttribute(ITizenLaunchConfigurationConstants.ATTR_PROCESSNAME_OPTION, EMPTY_STRING); + } catch (CoreException ce) { + LaunchUIPlugin.log(ce); + } + fProcText.setText(procName); + } + + protected void updateReinstallOpFromConfig(ILaunchConfiguration config) { + boolean option = true; + try { + option = config.getAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, true); + } catch (CoreException ce) { + LaunchUIPlugin.log(ce); + } + fReinstallOp.setSelection(option); + } + + protected void updateSelectPkgOpFromConfig(ILaunchConfiguration config) { + boolean option = true; + try { + option = config.getAttribute(ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, true); + } catch (CoreException ce) { + LaunchUIPlugin.log(ce); + } + fSelectPkgOp.setSelection(option); + } +} \ No newline at end of file diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/TizenDebianMainTab.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/TizenDebianMainTab.java index b013f21..382ba03 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/TizenDebianMainTab.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/TizenDebianMainTab.java @@ -29,13 +29,12 @@ package org.tizen.nativeplatform.launch.ui; import java.util.ArrayList; -import java.util.List; +import java.util.ResourceBundle; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.ICDescriptor; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.model.IBinary; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; @@ -45,13 +44,10 @@ import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.cdt.launch.ui.CMainTab; import org.eclipse.cdt.ui.CElementLabelProvider; import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Path; -import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ITableLabelProvider; @@ -68,7 +64,6 @@ import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; @@ -99,7 +94,6 @@ import org.tizen.nativecommon.launch.TizenLaunchMessages; import org.tizen.nativeplatform.Activator; import org.tizen.nativeplatform.launch.ITizenLaunchConfigurationConstants; import org.tizen.nativeplatform.launch.wizards.PlatformLaunchUtils; -import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander; import org.tizen.nativeplatform.pkgmgr.model.LocalPackage; import org.tizen.nativeplatform.rootstrap.RootstrapManager; @@ -107,7 +101,10 @@ import org.tizen.sdblib.FileListingService.FileEntry; import org.tizen.sdblib.IDevice; public class TizenDebianMainTab extends CMainTab { -//public class TizenDebianMainTab extends AbstractLaunchConfigurationTab { + + private final String BUNDLE_NAME = TizenDebianMainTab.class.getPackage().getName() + ".LaunchTabUIMessages";//$NON-NLS-1$ + private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + private Label fProgLabel; private Text fProgText; private Text fAppProjText; @@ -117,11 +114,7 @@ public class TizenDebianMainTab extends CMainTab { private TableViewer tableViewer; private boolean fSpecifyCoreFile; private ArrayList packages = new ArrayList(); - //private ArrayList packages = new ArrayList(); - private static final String LABEL_TEXT = "Tizen Application Path :"; private static final String DEFAULT_APP_PATH = "/opt/apps/"; - private static final String REMOTE_BROWSE = "Remote Browse..."; - private static final String SELECT_AN_APPLICATION = "Select an Application"; private String filePath = ""; private String selectedFileList = ""; @@ -174,9 +167,9 @@ public class TizenDebianMainTab extends CMainTab { composite.setLayout(gridLayout); fReinstallOp = new Button(composite, SWT.CHECK); - fReinstallOp.setText("Reinstall if the package is already present"); + fReinstallOp.setText(resources.getString("Button.Reinstall.Op")); fSelectPkgOp = new Button(composite, SWT.CHECK); - fSelectPkgOp.setText("Select packages to be installed"); + fSelectPkgOp.setText(resources.getString("Button.SelectPkg.Op")); fReinstallOp.addSelectionListener(new SelectionAdapter() { @Override @@ -195,7 +188,7 @@ public class TizenDebianMainTab extends CMainTab { private void createTableTitleComposite(Composite parent) { Label tableLabel = new Label(parent, SWT.NONE); - tableLabel.setText("Additional Packages:"); + tableLabel.setText(resources.getString("Label.AdditionPkgs")); } private void createTableGroupComposite(Composite parent) { @@ -271,8 +264,7 @@ public class TizenDebianMainTab extends CMainTab { Button addBt = new Button(composite, SWT.PUSH); Image addIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/add.gif"); - addBt.setImage(addIcon); - //addBt.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + addBt.setImage(addIcon); addBt.addMouseListener(new MouseListener() { @Override @@ -282,7 +274,7 @@ public class TizenDebianMainTab extends CMainTab { @Override public void mouseDown(MouseEvent e) { FileDialog fd = new FileDialog(getShell(), SWT.OPEN|SWT.MULTI); - fd.setText("Select RPM files"); + fd.setText(resources.getString("File.Dialog.Title.File")); String[] filterExt = { "*.rpm" }; fd.setFilterExtensions(filterExt); selectedFileList = fd.open(); @@ -351,7 +343,7 @@ public class TizenDebianMainTab extends CMainTab { projComp.setLayoutData(gd); fProjLabel = new Label(projComp, SWT.NONE); - fProjLabel.setText("Tizen Application Project:"); + fProjLabel.setText(resources.getString("Label.App.Project")); gd = new GridData(); gd.horizontalSpan = 2; fProjLabel.setLayoutData(gd); @@ -390,15 +382,6 @@ public class TizenDebianMainTab extends CMainTab { String projectName = project.getElementName(); fAppProjText.setText(projectName); - /* - if (currentProjectName.length() == 0) { - // New project selected for the first time, set the program name default too. - IBinary[] bins = getBinaryFiles(project); - if (bins != null && bins.length == 1) { - fProgText.setText(bins[0].getResource().getProjectRelativePath().toOSString()); - } - } - */ } protected ICProject chooseCAppProject(String currentProjectName) { @@ -465,7 +448,7 @@ public class TizenDebianMainTab extends CMainTab { gd.horizontalSpan = colSpan; mainComp.setLayoutData(gd); fProgLabel = new Label(mainComp, SWT.NONE); - fProgLabel.setText(LABEL_TEXT); // $NON-NLS-1$ + fProgLabel.setText(resources.getString("Label.App.Path")); // $NON-NLS-1$ gd = new GridData(); gd.horizontalSpan = 3; fProgLabel.setLayoutData(gd); @@ -479,7 +462,7 @@ public class TizenDebianMainTab extends CMainTab { }); Button fBrowseForBinaryButton; - fBrowseForBinaryButton = createPushButton(mainComp, REMOTE_BROWSE, null); //$NON-NLS-1$ + fBrowseForBinaryButton = createPushButton(mainComp, resources.getString("Button.Browse"), null); //$NON-NLS-1$ fBrowseForBinaryButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent evt) { @@ -509,7 +492,8 @@ public class TizenDebianMainTab extends CMainTab { shell.getDisplay().syncExec( new Runnable() { public void run() { IDevice device = ConnectionPlugin.getDefault().getCurrentDevice(); - TizenRemoteFileDialog dlg = new TizenRemoteFileDialog(shell, SELECT_AN_APPLICATION, device, false, DEFAULT_APP_PATH); + TizenRemoteFileDialog dlg = new TizenRemoteFileDialog(shell, + resources.getString("Remote.Dialog.Title"), device, false, DEFAULT_APP_PATH); if(dlg.open() == TizenRemoteFileDialogResult.OK) { FileEntry selectedFile = dlg.getSelectedFileEntry(); filePath = selectedFile.getFullPath(); diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/TizenDebianProjectAttachLaunchShortcut.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/TizenDebianProjectAttachLaunchShortcut.java index 45891f5..00a71b2 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/TizenDebianProjectAttachLaunchShortcut.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/TizenDebianProjectAttachLaunchShortcut.java @@ -28,6 +28,11 @@ */ package org.tizen.nativeplatform.launch.ui.shortcut; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -38,19 +43,31 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDebugConfiguration; +import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer; +import org.eclipse.cdt.debug.internal.core.sourcelookup.MapEntrySourceContainer; import org.eclipse.cdt.debug.internal.ui.launch.CApplicationLaunchShortcut; import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.debug.ui.ICDebuggerPage; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationType; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.model.ISourceLocator; +import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector; +import org.eclipse.debug.core.sourcelookup.ISourceContainer; +import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; +import org.eclipse.debug.core.sourcelookup.containers.DirectorySourceContainer; import org.eclipse.debug.ui.DebugUITools; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ISelection; @@ -62,16 +79,29 @@ import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.ElementListSelectionDialog; +import org.tizen.nativecommon.build.SmartBuildInterface; import org.tizen.nativecommon.launch.TizenLaunchConfigurationConstants; import org.tizen.nativeplatform.Activator; -import org.tizen.nativeplatform.launch.TizenDebianLaunchMessages; +import org.tizen.nativeplatform.build.PlatformConfigurationManager; +import org.tizen.nativeplatform.launch.ITizenLaunchConfigurationConstants; +import org.tizen.nativeplatform.launch.wizards.PlatformAttachLaunchWizard; +import org.tizen.nativeplatform.launch.wizards.PlatformLaunchUtils; +import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizardDialog; +import org.tizen.nativeplatform.rootstrap.RootstrapManager; +import org.tizen.nativeplatform.views.model.PlatformRootstrap; public class TizenDebianProjectAttachLaunchShortcut extends CApplicationLaunchShortcut { - private static final String APPLICATION_PATH_INPUT_DIALOG_TITLE = "Input Tizen Application Path"; - private static final String APPLICATION_PATH_INPUT_DIALOG_TEXT = "Input Tizen Application Path : "; + + private String programPath = null; + private boolean reinstallOp = true; + private boolean selectPkgOp = true; + private String procName = ""; + private int pid; + + private ISourceLookupDirector fLocator; public void launch(IProject project, String mode) { searchAndLaunch(new Object[] {project}, mode); @@ -182,13 +212,20 @@ public class TizenDebianProjectAttachLaunchShortcut extends CApplicationLaunchSh protected ILaunchConfiguration createConfiguration(IProject project, ICDebugConfiguration debugConfig, String mode) { ILaunchConfiguration config = null; try { - String projectName = project.getProjectRelativePath().toString(); ILaunchConfigurationType configType = getCLaunchConfigType(); ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(project.getName())); - String programName = getProgramName(); - if (programName != null) - wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programName); + + if (!setLaunchConfiguration(project, mode)) { + return null; + } + + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programPath); + wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, reinstallOp); + wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, selectPkgOp); + wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_PROCESSNAME_OPTION, procName); + wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_PROCESSID_OPTION, pid); + wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_FROM_SHORTCUT, true); wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getName()); wc.setMappedResources(new IResource[] {project}); @@ -211,6 +248,7 @@ public class TizenDebianProjectAttachLaunchShortcut extends CApplicationLaunchSh // Load up the debugger page to set the defaults. There should probably be a separate // extension point for this. ICDebuggerPage page = CDebugUIPlugin.getDefault().getDebuggerPage(debugConfig.getID()); + setSourceContainer(project, wc); page.setDefaults(wc); config = wc.doSave(); @@ -220,7 +258,10 @@ public class TizenDebianProjectAttachLaunchShortcut extends CApplicationLaunchSh return config; } - private String getProgramName() throws CoreException { + private boolean setLaunchConfiguration(IProject project, String mode) { + IManagedBuildInfo info = ManagedBuildManager.getBuildInfo( project ) ; + IConfiguration defaultConfig = info.getDefaultConfiguration(); + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window == null) { IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows(); @@ -228,16 +269,109 @@ public class TizenDebianProjectAttachLaunchShortcut extends CApplicationLaunchSh } final Shell shell = window.getShell(); - TizenPathInputDialog dlg = new TizenPathInputDialog(shell, - APPLICATION_PATH_INPUT_DIALOG_TITLE, - APPLICATION_PATH_INPUT_DIALOG_TEXT, - null); - if (Window.OK == dlg.open()) - return dlg.getValue(); - else - newCoreException(TizenDebianLaunchMessages.OPERATION_CANCELED, null); + PlatformAttachLaunchWizard wizard = new PlatformAttachLaunchWizard(shell, project, defaultConfig, mode); + PlatformLaunchWizardDialog dlg = new PlatformLaunchWizardDialog(shell, wizard); + dlg.create(); + if (Window.OK == dlg.open()) { + programPath = dlg.getProgramPath(); + reinstallOp = dlg.getReinstallOp(); + selectPkgOp = dlg.getSelectPkgOp(); + procName = dlg.getProcName(); + pid = dlg.getProcId(); + return true; + } else { + return false; + } + } + + private void setSourceContainer(IProject project, ILaunchConfigurationWorkingCopy configuration) { - return null; + IManagedBuildInfo info = ManagedBuildManager.getBuildInfo( project ) ; + IConfiguration config = info.getDefaultConfiguration(); + String targetId = PlatformConfigurationManager.getBuildTargetName(config); + String rootId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetId); + PlatformRootstrap rootstrap = RootstrapManager.getRootstrap(rootId); + + String basePath = rootstrap.getPath().toOSString(); + PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(); + String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(basePath); + DirectorySourceContainer container = new DirectorySourceContainer(new Path(rootstrapPath), true); + MappingSourceContainer mappingContainer = new MappingSourceContainer("Source mapping"); + MapEntrySourceContainer entry = new MapEntrySourceContainer(); + String[] infos = launchUtils.getProjectInfo(project); + if (infos == null) { + // TODO: error handling + } + String backend = String.format("/usr/src/debug/%s-%s", infos[0], infos[1]); + String local = project.getLocation().toOSString(); + + entry.setBackendPath(new Path(backend)); + entry.setLocalPath(new Path(local)); + mappingContainer.addMapEntry(entry); + + if (fLocator != null) { + fLocator.dispose(); + fLocator = null; + } + + String memento = null; + String type = null; + try{ + memento = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null); + type = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null); + if (type == null) { + type = configuration.getType().getSourceLocatorId(); + } + } catch(CoreException e){ + return; + } + + if(type == null) { + return; + } + + try { + ISourceLocator locator = getLaunchManager().newSourceLocator(type); + if(!(locator instanceof AbstractSourceLookupDirector)) { + // migrate to the new source lookup infrastructure + memento = null; // don't use old memento + type = configuration.getType().getSourceLocatorId(); + if(type == null) { + return; + } + locator = getLaunchManager().newSourceLocator(type); + if (!(locator instanceof AbstractSourceLookupDirector)) { + return; + } + } + fLocator = (AbstractSourceLookupDirector)locator; + if (memento == null) { + fLocator.initializeDefaults(configuration); + } else { + fLocator.initializeFromMemento(memento, configuration); + } + } catch (CoreException e) { + return; + } + + configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null); + configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null); + + int length = fLocator.getSourceContainers().length; + ISourceContainer[] containers = new ISourceContainer[length + 2]; + containers[0] = mappingContainer; + containers[1] = container; + containers[2] = fLocator.getSourceContainers()[0]; + + fLocator.setSourceContainers(containers); + + try { + configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, fLocator.getMemento()); + configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, fLocator.getId()); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } private void newCoreException(String message, Throwable exception) throws CoreException { diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/TizenDebianProjectLaunchShortcut.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/TizenDebianProjectLaunchShortcut.java index b7720bd..ad2f854 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/TizenDebianProjectLaunchShortcut.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/TizenDebianProjectLaunchShortcut.java @@ -28,11 +28,6 @@ */ package org.tizen.nativeplatform.launch.ui.shortcut; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -50,7 +45,6 @@ import org.eclipse.cdt.debug.ui.ICDebuggerPage; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; -import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; @@ -76,7 +70,6 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchWindow; @@ -90,7 +83,7 @@ import org.tizen.nativecommon.launch.TizenLaunchMessages; import org.tizen.nativeplatform.Activator; import org.tizen.nativeplatform.build.PlatformConfigurationManager; import org.tizen.nativeplatform.launch.ITizenLaunchConfigurationConstants; -import org.tizen.nativeplatform.launch.TizenDebianLaunchMessages; +import org.tizen.nativeplatform.launch.wizards.PlatformLaunchUtils; import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizard; import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizardDialog; import org.tizen.nativeplatform.pkgmgr.model.LocalPackage; @@ -99,8 +92,6 @@ import org.tizen.nativeplatform.views.model.PlatformRootstrap; import org.tizen.sdblib.IDevice; public class TizenDebianProjectLaunchShortcut extends CApplicationLaunchShortcut { - private static final String APPLICATION_PATH_INPUT_DIALOG_TITLE = "Input Tizen Application Path"; - private static final String APPLICATION_PATH_INPUT_DIALOG_TEXT = "Input Tizen Application Path : "; private static final String APP_PROJ_DEFAULT_SELECTION = "[Not required]"; @@ -110,7 +101,7 @@ public class TizenDebianProjectLaunchShortcut extends CApplicationLaunchShortcut private boolean reinstallOp = true; private boolean selectPkgOp = true; - protected ISourceLookupDirector fLocator; + private ISourceLookupDirector fLocator; public void launch(IProject project, String mode) { searchAndLaunch(new Object[] {project}, mode); @@ -232,7 +223,7 @@ public class TizenDebianProjectLaunchShortcut extends CApplicationLaunchShortcut ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(project.getName())); - if (!setLaunchConfiguration(project)) { + if (!setLaunchConfiguration(project, mode)) { return null; } @@ -296,7 +287,7 @@ public class TizenDebianProjectLaunchShortcut extends CApplicationLaunchShortcut } - private boolean setLaunchConfiguration(IProject project) { + private boolean setLaunchConfiguration(IProject project, String mode) { IManagedBuildInfo info = ManagedBuildManager.getBuildInfo( project ) ; IConfiguration defaultConfig = info.getDefaultConfiguration(); @@ -307,7 +298,7 @@ public class TizenDebianProjectLaunchShortcut extends CApplicationLaunchShortcut } final Shell shell = window.getShell(); - PlatformLaunchWizard wizard = new PlatformLaunchWizard(shell, project, defaultConfig); + PlatformLaunchWizard wizard = new PlatformLaunchWizard(shell, project, defaultConfig, mode); PlatformLaunchWizardDialog dlg = new PlatformLaunchWizardDialog(shell, wizard); dlg.create(); if (Window.OK == dlg.open()) { @@ -331,11 +322,12 @@ public class TizenDebianProjectLaunchShortcut extends CApplicationLaunchShortcut PlatformRootstrap rootstrap = RootstrapManager.getRootstrap(rootId); String basePath = rootstrap.getPath().toOSString(); + PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(); String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(basePath); DirectorySourceContainer container = new DirectorySourceContainer(new Path(rootstrapPath), true); MappingSourceContainer mappingContainer = new MappingSourceContainer("Source mapping"); MapEntrySourceContainer entry = new MapEntrySourceContainer(); - String[] infos = getProjectInfo(project); + String[] infos = launchUtils.getProjectInfo(project); if (infos == null) { // TODO: error handling } @@ -410,59 +402,4 @@ public class TizenDebianProjectLaunchShortcut extends CApplicationLaunchShortcut e.printStackTrace(); } } - - private String[] getProjectInfo(IProject project) { - String[] infos = new String[2]; - String name = null; - String version = null; - IFolder folder = project.getFolder("packaging"); - File dir = new File(folder.getLocation().toOSString()); - File specfile = null; - if (dir.exists()) { - for (File f : dir.listFiles()) { - if (f.isFile() && f.getName().endsWith(".spec")) { - specfile = f; - break; - } - } - } - - try { - BufferedReader in = new BufferedReader(new FileReader(specfile.getPath())); - String s; - - while ((s = in.readLine()) != null ) { - s = s.trim(); - if (s.trim().startsWith("Name:")) { - String[] arrStr = s.split(":"); - if (arrStr.length == 2) { - name = arrStr[1].trim(); - continue; - } - } else if (s.trim().startsWith("Version:")) { - String[] arrStr = s.split(":"); - if (arrStr.length == 2) { - version = arrStr[1].trim(); - continue; - } - } - - if (name != null && version != null) { - break; - } - } - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - - if (name != null && version != null) { - infos[0] = name; - infos[1] = version; - return infos; - } else { - return null; - } - } } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/LaunchWizardUIMessages.properties b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/LaunchWizardUIMessages.properties new file mode 100644 index 0000000..875d2b3 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/LaunchWizardUIMessages.properties @@ -0,0 +1,22 @@ +AppPage.Title = Setting Tizen Application +AppPage.Desc = Please select a tizen application or add RPM files for testing +AppPage.Label.AdditionPkgs = Additional Packages: +AppPage.Label.Project = Tizen Application Project: +AppPage.Dialog.Title.File = Select RPM files + +BinPage.Title = Setting binary path +BinPage.Desc = Please set a path for test binary +BinPage.Button.Browse = Remote Browse... +BinPage.Remote.Dialog.Title = Select an Application + +ProcPage.Title = Select Process +ProcPage.Desc = Please select a process for attach debugging + +PkgDialog.Title = Select packages to be installed +PkgDialog.Desc = Checked packages will be installed to buildsystem and device +PkgDialog.Label.Buildsystem = To Buildsystem: +PkgDialog.Label.Device = To Device: + + +Button.Reinstall.Op = Reinstall if the package is already present +Button.SelectPkg.Op = Select packages to be installed manually \ No newline at end of file diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformAttachLaunchWizard.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformAttachLaunchWizard.java new file mode 100644 index 0000000..bf3cc44 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformAttachLaunchWizard.java @@ -0,0 +1,115 @@ +package org.tizen.nativeplatform.launch.wizards; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.ResourceBundle; + +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.wizard.IWizardContainer; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.swt.widgets.Shell; +import org.tizen.nativeplatform.launch.TizenDebianLaunchMessages; +import org.tizen.nativeplatform.pkgmgr.model.LocalPackage; +import org.tizen.nativeplatform.views.ui.AddRootstrapDialog; + + +public class PlatformAttachLaunchWizard extends PlatformLaunchWizard { + + private final String BUNDLE_NAME = PlatformAttachLaunchWizard.class.getPackage().getName() + ".LaunchWizardUIMessages";//$NON-NLS-1$ + private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + + private int pid; + private String procName; + + private final String SETTING_PROC_PAGE = "setting_proc"; + + public PlatformAttachLaunchWizard(Shell shell, IProject project, IConfiguration config, String mode) { + super(shell, project, config, mode); + } + + @Override + public void addPages() { + addPage(new PlatformLaunchSettingProcPage(shell, SETTING_PROC_PAGE, project, config)); + + WizardDialog dialog = (WizardDialog)getContainer(); + dialog.addPageChangedListener(this); + dialog.addPageChangingListener(this); + } + + public String getProgramPath() { + return programPath; + } + + public int getPid() { + return pid; + } + + public String getProcName() { + return procName; + } + + @Override + public boolean performFinish() { + PlatformLaunchSettingProcPage page = (PlatformLaunchSettingProcPage)getPage(SETTING_PROC_PAGE); + programPath = page.getProgramPath(); + pid = page.getPid(); + + final String rootstrapPath = page.getRootstrapPath(); + packages = page.getPackages(); + IWizardContainer container = getContainer(); + final PlatformLaunchUtils launchUtil = new PlatformLaunchUtils(); + reinstallOp = page.getReinstallOp(); + selectPkgOp = page.getSelectPkgOp(); + procName = page.getProcName(); + pid = page.getPid(); + + //container.run(fork, cancelable, runnable) + + try { + container.run(true, true, + new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) + throws InvocationTargetException, + InterruptedException { + monitor.beginTask(TizenDebianLaunchMessages.INSTALL_PACKAGE, 2); + monitor.subTask(TizenDebianLaunchMessages.CHECK_PKG_STATUS); + + final ArrayList BuildSystemPkgs = new ArrayList(); + final ArrayList DevicePkgs = new ArrayList(); + + launchUtil.filterBuildsystemPkgs(packages, BuildSystemPkgs, rootstrapPath, reinstallOp); + + if (selectPkgOp) { + if (!openPkgStatusDialog(BuildSystemPkgs, DevicePkgs)) { + return; + } + } + + ArrayList selecteBsPkgs = launchUtil.getSelectedPackages(BuildSystemPkgs); + + monitor.worked(1); + monitor.subTask(TizenDebianLaunchMessages.INSTALL_PACKAGES_TO_BUILDSYSTEM); + + if (selecteBsPkgs != null && !selecteBsPkgs.isEmpty()) { + launchUtil.installPkgsToRootstrap(selecteBsPkgs, rootstrapPath, new SubProgressMonitor(monitor, 1)); + } + + monitor.done(); + } + }); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + openLogDialog(TizenDebianLaunchMessages.FAILED_INSTALL_PKGS, e.getMessage()); + } + + return true; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchSettingAppPage.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchSettingAppPage.java index e98f53f..55800c2 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchSettingAppPage.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchSettingAppPage.java @@ -1,9 +1,9 @@ package org.tizen.nativeplatform.launch.wizards; -import java.io.File; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.HashMap; +import java.util.ResourceBundle; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; @@ -13,7 +13,6 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.jface.dialogs.MessageDialog; @@ -46,26 +45,26 @@ 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.swt.widgets.Text; -import org.tizen.common.connection.ConnectionPlugin; import org.tizen.common.util.DialogUtil; import org.tizen.common.util.ImageUtil; import org.tizen.nativecommon.build.CommonBuildMessages; import org.tizen.nativecommon.build.SmartBuildInterface; import org.tizen.nativeplatform.Activator; import org.tizen.nativeplatform.views.model.PlatformRootstrap; +import org.tizen.nativeplatform.views.ui.AddRootstrapDialog; import org.tizen.nativeplatform.build.PlatformConfigurationManager; import org.tizen.nativeplatform.build.PlatformProjectPackaging; +import org.tizen.nativeplatform.launch.TizenDebianLaunchMessages; import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander; import org.tizen.nativeplatform.pkgmgr.model.LocalPackage; import org.tizen.nativeplatform.rootstrap.RootstrapManager; -import org.tizen.sdblib.IDevice; - public class PlatformLaunchSettingAppPage extends WizardPage { - private Text text; + private final String BUNDLE_NAME = PlatformLaunchSettingAppPage.class.getPackage().getName() + ".LaunchWizardUIMessages";//$NON-NLS-1$ + private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + private TableViewer tableViewer; private FileDialog fd; private Combo projectCombo; @@ -78,8 +77,6 @@ public class PlatformLaunchSettingAppPage extends WizardPage { private IProject platformProject; private PlatformRootstrap rootstrap; private String rootPath = ""; - private IDevice device; - private IStatus status; private boolean packagingResult; private ArrayList platformPackages = new ArrayList(); private ArrayList appPackages = new ArrayList(); @@ -93,14 +90,13 @@ public class PlatformLaunchSettingAppPage extends WizardPage { protected PlatformLaunchSettingAppPage(Shell shell, String pageName, IProject project, IConfiguration config) { super(pageName); - setTitle("Setting test application"); - setDescription("Please select a test application or add RPM files for testing"); + setTitle(resources.getString("AppPage.Title")); + setDescription(resources.getString("AppPage.Desc")); setPageComplete(true); this.platformProject = project; this.config = config; this.shell = shell; - this.device = ConnectionPlugin.getDefault().getCurrentDevice(); String targetId = PlatformConfigurationManager.getBuildTargetName(config); String rootId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetId); this.rootstrap = RootstrapManager.getRootstrap(rootId); @@ -116,8 +112,7 @@ public class PlatformLaunchSettingAppPage extends WizardPage { platformPackages = launchUtils.getProjectPackages(platformProject, config.getName()); if (platformPackages.isEmpty()) { - String msg = String.format("\"%s\" project does not have package files(*.rpm)\n" + - "Do you want packaging now ?", platformProject.getName()); + String msg = String.format(TizenDebianLaunchMessages.QUESTION_PACKAGING, platformProject.getName()); if (64 == DialogUtil.openQuestionDialog(msg)) { if (packagingProject(platformProject)) { setPlatformPackages(); @@ -133,8 +128,7 @@ public class PlatformLaunchSettingAppPage extends WizardPage { PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(); appPackages = launchUtils.getProjectPackages(appProj, config.getName()); if (appPackages.isEmpty()) { - String msg = String.format("\"%s\" project does not have package files(*.rpm)\n" + - "Do you want packaging now ?\n", appProj.getName()); + String msg = String.format(TizenDebianLaunchMessages.QUESTION_PACKAGING, appProj.getName()); if (64 == DialogUtil.openQuestionDialog(msg)) { if (packagingProject(appProj)) { setAppPackages(appProj); @@ -198,16 +192,16 @@ public class PlatformLaunchSettingAppPage extends WizardPage { composite.setLayout(gridLayout); reinstallOp = new Button(composite, SWT.CHECK); - reinstallOp.setText("Reinstall if the package is already present"); + reinstallOp.setText(resources.getString("Button.Reinstall.Op")); reinstallOp.setSelection(true); selectPkgOp = new Button(composite, SWT.CHECK); - selectPkgOp.setText("Select packages to be installed"); - selectPkgOp.setSelection(true); + selectPkgOp.setText(resources.getString("Button.SelectPkg.Op")); + selectPkgOp.setSelection(false); } private void createTableTitleComposite(Composite parent) { Label tableLabel = new Label(parent, SWT.NONE); - tableLabel.setText("Additional Packages:"); + tableLabel.setText(resources.getString("AppPage.Label.AdditionPkgs")); } private void createProjectsComposite(Composite parent) { @@ -219,7 +213,7 @@ public class PlatformLaunchSettingAppPage extends WizardPage { gridLayout.marginHeight = 0; composite.setLayout(gridLayout); Label projectLabel = new Label(composite, SWT.NONE); - projectLabel.setText("Test Application Project : "); + projectLabel.setText(resources.getString("AppPage.Label.Project")); GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); composite.setLayoutData(gridData); @@ -333,7 +327,7 @@ public class PlatformLaunchSettingAppPage extends WizardPage { @Override public void mouseDown(MouseEvent e) { fd = new FileDialog(shell, SWT.OPEN|SWT.MULTI); - fd.setText("Select RPM files"); + fd.setText(resources.getString("AppPage.Dialog.Title.File")); String[] filterExt = { "*.rpm" }; fd.setFilterExtensions(filterExt); selectedFileList = fd.open(); diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchSettingBinPage.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchSettingBinPage.java index de6ca41..f32f580 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchSettingBinPage.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchSettingBinPage.java @@ -1,5 +1,7 @@ package org.tizen.nativeplatform.launch.wizards; +import java.util.ResourceBundle; + import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -17,21 +19,23 @@ import org.tizen.common.connection.ConnectionPlugin; import org.tizen.common.connection.ui.TizenRemoteFileDialog; import org.tizen.common.connection.ui.TizenRemoteFileDialog.TizenRemoteFileDialogResult; import org.tizen.nativecommon.launch.TizenLaunchMessages; +import org.tizen.nativeplatform.views.ui.AddRootstrapDialog; import org.tizen.sdblib.IDevice; import org.tizen.sdblib.FileListingService.FileEntry; public class PlatformLaunchSettingBinPage extends WizardPage { + private final String BUNDLE_NAME = PlatformLaunchSettingBinPage.class.getPackage().getName() + ".LaunchWizardUIMessages";//$NON-NLS-1$ + private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + private Text text; private String filePath = ""; - private static final String SELECT_AN_APPLICATION = "Select an Application"; private static final String DEFAULT_APP_PATH = "/opt/apps/"; - private static final String REMOTE_BROWSE = "Remote Browse..."; protected PlatformLaunchSettingBinPage(String pageName) { super(pageName); - setTitle("Setting binary path"); - setDescription("Please set a path for test binary"); + setTitle(resources.getString("BinPage.Title")); + setDescription(resources.getString("BinPage.Desc")); setPageComplete(true); } @@ -46,7 +50,7 @@ public class PlatformLaunchSettingBinPage extends WizardPage { text.setLayoutData(data); Button browseButton = new Button(composite, SWT.PUSH); - browseButton.setText(REMOTE_BROWSE); + browseButton.setText(resources.getString("BinPage.Button.Browse")); browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent evt) { @@ -80,7 +84,8 @@ public class PlatformLaunchSettingBinPage extends WizardPage { shell.getDisplay().syncExec( new Runnable() { public void run() { IDevice device = ConnectionPlugin.getDefault().getCurrentDevice(); - TizenRemoteFileDialog dlg = new TizenRemoteFileDialog(shell, SELECT_AN_APPLICATION, device, false, DEFAULT_APP_PATH); + TizenRemoteFileDialog dlg = new TizenRemoteFileDialog(shell, + resources.getString("BinPage.Remote.Dialog.Title"), device, false, DEFAULT_APP_PATH); if(dlg.open() == TizenRemoteFileDialogResult.OK) { FileEntry selectedFile = dlg.getSelectedFileEntry(); filePath = selectedFile.getFullPath(); diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchSettingProcPage.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchSettingProcPage.java new file mode 100644 index 0000000..263b8af --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchSettingProcPage.java @@ -0,0 +1,265 @@ +package org.tizen.nativeplatform.launch.wizards; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.ResourceBundle; + +import org.eclipse.cdt.core.IProcessInfo; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Path; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +import org.tizen.common.connection.ConnectionPlugin; +import org.tizen.common.util.DialogUtil; +import org.tizen.nativecommon.build.CommonBuildMessages; +import org.tizen.nativecommon.build.SmartBuildInterface; +import org.tizen.nativeplatform.views.model.PlatformRootstrap; +import org.tizen.nativeplatform.build.PlatformConfigurationManager; +import org.tizen.nativeplatform.build.PlatformProjectPackaging; +import org.tizen.nativeplatform.launch.TizenDebianLaunchMessages; +import org.tizen.nativeplatform.pkgmgr.model.LocalPackage; +import org.tizen.nativeplatform.rootstrap.RootstrapManager; + +import org.tizen.sdblib.IDevice; + +public class PlatformLaunchSettingProcPage extends WizardPage { + + private final String BUNDLE_NAME = PlatformLaunchSettingProcPage.class.getPackage().getName() + ".LaunchWizardUIMessages";//$NON-NLS-1$ + private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + + private Button reinstallOp; + private Button selectPkgOp; + private Text processText; + private Text pathText; + private int pid; + private IProcessInfo procInfo; + private Shell shell; + private String rootPath = ""; + private String procName = ""; + + + private IConfiguration config; + private IProject platformProject; + private PlatformRootstrap rootstrap; + private IDevice device; + private boolean packagingResult; + private ArrayList platformPackages = new ArrayList(); + private ArrayList packages = new ArrayList(); + + protected PlatformLaunchSettingProcPage(Shell shell, String pageName, IProject project, IConfiguration config) { + super(pageName); + + setTitle(resources.getString("ProcPage.Title")); + setDescription("ProcPage.Desc"); + setPageComplete(true); + + this.platformProject = project; + this.config = config; + this.shell = shell; + this.device = ConnectionPlugin.getDefault().getCurrentDevice(); + String targetId = PlatformConfigurationManager.getBuildTargetName(config); + String rootId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetId); + this.rootstrap = RootstrapManager.getRootstrap(rootId); + this.rootPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(rootstrap.getPath().toOSString()); + + setPlatformPackages(); + } + + public void setPlatformPackages() { + platformPackages.clear(); + PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(); + platformPackages = launchUtils.getProjectPackages(platformProject, config.getName()); + + if (platformPackages.isEmpty()) { + String msg = String.format(TizenDebianLaunchMessages.QUESTION_PACKAGING, platformProject.getName()); + if (64 == DialogUtil.openQuestionDialog(msg)) { + if (packagingProject(platformProject)) { + setPlatformPackages(); + } + } + } else { + packages.addAll(platformPackages); + } + } + + @Override + public void createControl(Composite parent) { + Composite composite = new Composite( parent, SWT.NONE); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + composite.setLayout(new GridLayout(1, false)); + GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); + gridData.minimumHeight = 0; + composite.setLayoutData(gridData); + + createProcessComposite(composite); + createProcessInfoComposite(composite); + createOptionGroupComposite(composite); + + setControl(composite); + } + + private void createOptionGroupComposite(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_END)); + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 1; + gridLayout.marginWidth = 0; + gridLayout.marginHeight = 0; + composite.setLayout(gridLayout); + + reinstallOp = new Button(composite, SWT.CHECK); + reinstallOp.setText(resources.getString("Button.Reinstall.Op")); + reinstallOp.setSelection(true); + selectPkgOp = new Button(composite, SWT.CHECK); + selectPkgOp.setText(resources.getString("Button.SelectPkg.Op")); + selectPkgOp.setSelection(false); + } + + private void createProcessComposite(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 3; + gridLayout.marginWidth = 0; + gridLayout.marginHeight = 0; + composite.setLayout(gridLayout); + GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); + composite.setLayoutData(gridData); + + Label procLabel = new Label(composite, SWT.NONE); + procLabel.setText("Process : "); + + processText = new Text(composite, SWT.BORDER | SWT.READ_ONLY); + processText.setLayoutData(gridData); + Button findBt = new Button(composite, SWT.PUSH); + findBt.setText("Find"); + findBt.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent evt) { + PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(); + procInfo = launchUtils.getProcess(shell, device); + if (procInfo != null) { + IPath ppath = new Path(procInfo.getName()); + pid = procInfo.getPid(); + String name = ppath.lastSegment().trim(); + String value = name + " [" + String.valueOf(pid) + "]"; + processText.setText(value); + procName = name; + pathText.setText(procInfo.getName()); + } + } + }); + } + + private void createProcessInfoComposite(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 2; + gridLayout.marginWidth = 0; + gridLayout.marginHeight = 0; + composite.setLayout(gridLayout); + GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); + composite.setLayoutData(gridData); + + Label procPath = new Label(composite, SWT.NONE); + procPath.setText("Path : "); + + pathText = new Text(composite, SWT.BORDER | SWT.READ_ONLY); + pathText.setLayoutData(gridData); + pathText.setEnabled(false); + } + + public String getProgramPath() { + return pathText.getText().trim(); + } + + public int getPid() { + return pid; + } + + public String getRootstrapPath() { + return rootPath; + } + + public String getProcName() { + return procName; + } + + public ArrayList getPackages() { + return packages; + } + + public boolean getReinstallOp() { + return reinstallOp.getSelection(); + } + + public boolean getSelectPkgOp() { + return selectPkgOp.getSelection(); + } + + + private boolean packagingProject(final IProject targetProj) { + boolean result = false; + + try { + if (getContainer() == null) { + ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); + + dialog.run(true, true, new IRunnableWithProgress() { + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, + InterruptedException { + packagingResult = PlatformProjectPackaging.RPMPackaging(targetProj, config, monitor); + } + }); + } else { + getContainer().run(true, true, + new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) + throws InvocationTargetException, + InterruptedException { + packagingResult = PlatformProjectPackaging.RPMPackaging(targetProj, config, monitor); + } + }); + } + } catch (InvocationTargetException e) { + e.printStackTrace(); + MessageDialog.openError(shell, CommonBuildMessages.BUILD_RESULT, + e.getMessage()); + return false; + } catch (InterruptedException e) { + e.printStackTrace(); + MessageDialog.openError(shell, CommonBuildMessages.BUILD_RESULT, + e.getMessage()); + return false; + } + + if (packagingResult) { + MessageDialog.openInformation(shell, CommonBuildMessages.BUILD_RESULT, + CommonBuildMessages.SUCCESS_TO_BUILD_PACKAGE); + result = true; + } else { + MessageDialog.openError(shell, CommonBuildMessages.BUILD_RESULT, + CommonBuildMessages.FAIL_TO_BUILD_PACKAGE); + result = false; + } + + return result; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchUtils.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchUtils.java index 54e169f..113c903 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchUtils.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchUtils.java @@ -1,10 +1,17 @@ package org.tizen.nativeplatform.launch.wizards; +import java.io.BufferedReader; import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; +import org.eclipse.cdt.core.IProcessInfo; +import org.eclipse.cdt.core.IProcessList; +import org.eclipse.cdt.launch.internal.ui.LaunchImages; +import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; import org.eclipse.cdt.managedbuilder.core.IManagedProject; @@ -13,12 +20,22 @@ import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspace; 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.Path; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.console.MessageConsoleStream; +import org.eclipse.ui.dialogs.TwoPaneElementSelector; import org.tizen.common.ui.view.console.ConsoleManager; import org.tizen.common.util.FileUtil; +import org.tizen.nativecommon.launch.TizenDeviceProcessList; +import org.tizen.nativecommon.launch.TizenLaunchMessages; import org.tizen.nativeplatform.build.PlatformConfigurationManager; import org.tizen.nativeplatform.pkgmgr.PackageManagerOuputReceiver; import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander; @@ -37,6 +54,8 @@ import org.w3c.dom.NodeList; public class PlatformLaunchUtils { + private IProcessInfo procInfo; + public PlatformLaunchUtils() { } @@ -378,4 +397,154 @@ public class PlatformLaunchUtils { return rec; } + + public IProcessInfo getProcess(final Shell shell, final IDevice device) { + Display.getDefault().syncExec(new Runnable() { + public void run() { + procInfo = selectProcess(shell, device, null); + } + }); + + return procInfo; + } + + public IProcessInfo getProcess(final Shell shell, final IDevice device, final String procName) { + Display.getDefault().syncExec(new Runnable() { + public void run() { + procInfo = selectProcess(shell, device, procName); + } + }); + + return procInfo; + } + + private IProcessInfo selectProcess(Shell shell, IDevice device, String procName) { + if (shell == null) { + return null; + } + + IProcessList processList = null; + processList = new TizenDeviceProcessList(device); + + IProcessInfo pInfos[] = null; + IProcessInfo resultInfo = null; + pInfos = processList.getProcessList(); + + if(pInfos == null) { + return null; + } + + int count = 0; + if (procName != null) { + for (IProcessInfo info : pInfos) { + String name = new Path(info.getName()).lastSegment().trim(); + if (procName.equals(name)) { + resultInfo = info; + count++; + } + } + } + + if (count == 1) { + return resultInfo; + } + + ILabelProvider topprovider = new LabelProvider() { + public String getText(Object element) { + IProcessInfo pinfo = (IProcessInfo)element; + IPath ppath = new Path(pinfo.getName()); + return ppath.lastSegment().trim() + " [" + String.valueOf(pinfo.getPid()) + "]"; //$NON-NLS-1$ + } + + public Image getImage(Object element) { + return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC); + } + }; + + ILabelProvider downprovider = new LabelProvider() { + public String getText(Object element) { + IProcessInfo info = (IProcessInfo)element; + return info.getName(); + } + + public Image getImage(Object element) { + return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC); + } + }; + + TwoPaneElementSelector dlg = new TwoPaneElementSelector(shell, topprovider, downprovider); + dlg.setTitle("Select Process"); //$NON-NLS-1$ + String dlgMsg = ""; + if (procName != null && count == 0) { + dlgMsg = String.format("There is no \"%s\" process.\n", procName); + } else if (procName != null && count > 1) { + dlgMsg = String.format("There are some \"%s\" processes.\n", procName); + } + dlgMsg = dlgMsg + "Select a Process to attach debugger to:"; + dlg.setMessage(dlgMsg); //$NON-NLS-1$ + dlg.setElements(pInfos); + + if (dlg.open() == Window.OK) { + resultInfo = (IProcessInfo)dlg.getFirstResult(); + return resultInfo; + } + + return null; + } + + public String[] getProjectInfo(IProject project) { + String[] infos = new String[2]; + String name = null; + String version = null; + IFolder folder = project.getFolder("packaging"); + File dir = new File(folder.getLocation().toOSString()); + File specfile = null; + if (dir.exists()) { + for (File f : dir.listFiles()) { + if (f.isFile() && f.getName().endsWith(".spec")) { + specfile = f; + break; + } + } + } + + try { + BufferedReader in = new BufferedReader(new FileReader(specfile.getPath())); + String s; + + while ((s = in.readLine()) != null ) { + s = s.trim(); + if (s.trim().startsWith("Name:")) { + String[] arrStr = s.split(":"); + if (arrStr.length == 2) { + name = arrStr[1].trim(); + continue; + } + } else if (s.trim().startsWith("Version:")) { + String[] arrStr = s.split(":"); + if (arrStr.length == 2) { + version = arrStr[1].trim(); + continue; + } + } + + if (name != null && version != null) { + break; + } + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + if (name != null && version != null) { + infos[0] = name; + infos[1] = version; + return infos; + } else { + return null; + } + } + } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizard.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizard.java index 8017b86..19e1daa 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizard.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizard.java @@ -7,6 +7,7 @@ import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.debug.core.ILaunchManager; import org.eclipse.jface.dialogs.IPageChangedListener; import org.eclipse.jface.dialogs.IPageChangingListener; import org.eclipse.jface.dialogs.PageChangedEvent; @@ -20,23 +21,25 @@ import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.widgets.Shell; import org.tizen.common.connection.ConnectionPlugin; import org.tizen.common.util.SWTUtil; +import org.tizen.nativeplatform.launch.TizenDebianLaunchMessages; import org.tizen.nativeplatform.pkgmgr.model.LocalPackage; import org.tizen.sdblib.IDevice; public class PlatformLaunchWizard extends Wizard implements IPageChangingListener, IPageChangedListener { - private IProject project; - private IConfiguration config; - private IDevice device; - private Shell shell; - private String programPath = ""; - private String appProjectName = ""; - boolean reinstallOp; - boolean selectPkgOp; - private ArrayList packages = new ArrayList(); - private ArrayList extraPackages = new ArrayList(); - private String appProject = ""; - private boolean result; + protected IProject project; + protected IConfiguration config; + protected IDevice device; + protected Shell shell; + protected String programPath = ""; + protected String appProjectName = ""; + protected boolean reinstallOp; + protected boolean selectPkgOp; + protected ArrayList packages = new ArrayList(); + protected ArrayList extraPackages = new ArrayList(); + protected String appProject = ""; + protected String mode = ""; + protected boolean result; private final String SETTING_APP_PAGE = "setting_app"; private final String SETTING_BIN_PAGE = "setting_bin"; @@ -44,11 +47,12 @@ public class PlatformLaunchWizard extends Wizard implements IPageChangingListene public PlatformLaunchWizard() { } - public PlatformLaunchWizard(Shell shell, IProject project, IConfiguration config) { + public PlatformLaunchWizard(Shell shell, IProject project, IConfiguration config, String mode) { this.project = project; this.config = config; this.shell = shell; this.device = ConnectionPlugin.getDefault().getCurrentDevice(); + this.mode = mode; setWindowTitle("Launch Configuration"); setNeedsProgressMonitor(true); } @@ -107,9 +111,12 @@ public class PlatformLaunchWizard extends Wizard implements IPageChangingListene } @Override - public void pageChanged(PageChangedEvent event) { - - Object a = event.getSelectedPage(); + public void pageChanged(PageChangedEvent event) { + + WizardPage selectedPage = (WizardPage)event.getSelectedPage(); + if (selectedPage.getName().equals(SETTING_APP_PAGE)) { + + } } @Override @@ -136,13 +143,15 @@ public class PlatformLaunchWizard extends Wizard implements IPageChangingListene public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - monitor.beginTask("Install packages", 3); - monitor.subTask("Checking package status"); + monitor.beginTask(TizenDebianLaunchMessages.INSTALL_PACKAGE, 3); + monitor.subTask(TizenDebianLaunchMessages.CHECK_PKG_STATUS); final ArrayList BuildSystemPkgs = new ArrayList(); final ArrayList DevicePkgs = new ArrayList(); - launchUtil.filterBuildsystemPkgs(packages, BuildSystemPkgs, rootstrapPath, reinstallOp); + if (mode.equals(ILaunchManager.DEBUG_MODE)) { + launchUtil.filterBuildsystemPkgs(packages, BuildSystemPkgs, rootstrapPath, reinstallOp); + } launchUtil.filterDevicePackages(packages, DevicePkgs, device, reinstallOp); if (selectPkgOp) { @@ -156,17 +165,16 @@ public class PlatformLaunchWizard extends Wizard implements IPageChangingListene ArrayList selecteDvPkgs = launchUtil.getSelectedPackages(DevicePkgs); monitor.worked(1); - monitor.subTask("Installing packages to rootstrap"); - + monitor.subTask(TizenDebianLaunchMessages.INSTALL_PACKAGES_TO_BUILDSYSTEM); + if (selecteBsPkgs != null && !selecteBsPkgs.isEmpty()) { launchUtil.installPkgsToRootstrap(selecteBsPkgs, rootstrapPath, new SubProgressMonitor(monitor, 1)); - } - //monitor.worked(2); - monitor.subTask("Installing packages to device"); + } + + monitor.subTask(TizenDebianLaunchMessages.INSTALL_PACKAGES_TO_DEVICE); if (selecteDvPkgs != null && !selecteDvPkgs.isEmpty()) { launchUtil.installPkgsToDevice(selecteDvPkgs, device, new SubProgressMonitor(monitor, 1)); } - //monitor.worked(3); monitor.done(); } }); @@ -175,19 +183,18 @@ public class PlatformLaunchWizard extends Wizard implements IPageChangingListene e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block - e.printStackTrace(); - String desc = "Failed to install packages. See below logs"; - openLogDialog(desc, e.getMessage()); + e.printStackTrace(); + openLogDialog(TizenDebianLaunchMessages.FAILED_INSTALL_PKGS, e.getMessage()); cancelChanging(event); } } } - private void cancelChanging(PageChangingEvent event) { + public void cancelChanging(PageChangingEvent event) { event.doit = false; } - private void openLogDialog(final String desc, final String log) { + public void openLogDialog(final String desc, final String log) { SWTUtil.syncExec(new Runnable() { public void run() { ShowLogDialog dialog = new ShowLogDialog(shell, desc, log); @@ -196,7 +203,7 @@ public class PlatformLaunchWizard extends Wizard implements IPageChangingListene }); } - private boolean openPkgStatusDialog(final ArrayList BuildSystemPkgs, final ArrayList DevicePkgs) { + public boolean openPkgStatusDialog(final ArrayList BuildSystemPkgs, final ArrayList DevicePkgs) { SWTUtil.syncExec(new Runnable() { public void run() { ShowPackageStatusDialog statusDlg = new ShowPackageStatusDialog(shell, BuildSystemPkgs, DevicePkgs); diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizardDialog.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizardDialog.java index a515ccc..877baad 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizardDialog.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizardDialog.java @@ -9,6 +9,7 @@ import org.tizen.nativeplatform.pkgmgr.model.LocalPackage; public class PlatformLaunchWizardDialog extends WizardDialog { private PlatformLaunchWizard wizard = null; + private PlatformAttachLaunchWizard attachWizard = null; public PlatformLaunchWizardDialog(Shell shell, PlatformLaunchWizard wizard) { super(shell, wizard); @@ -16,9 +17,19 @@ public class PlatformLaunchWizardDialog extends WizardDialog { this.wizard = wizard; } + public PlatformLaunchWizardDialog(Shell shell, PlatformAttachLaunchWizard wizard) { + super(shell, wizard); + + this.attachWizard = wizard; + } + + + public String getProgramPath() { if (wizard != null) { return wizard.getProgramPath(); + } else if (attachWizard != null) { + return attachWizard.getProgramPath(); } else { return null; } @@ -43,6 +54,8 @@ public class PlatformLaunchWizardDialog extends WizardDialog { public boolean getReinstallOp() { if (wizard != null) { return wizard.getReinstallOp(); + } else if (attachWizard != null) { + return attachWizard.getReinstallOp(); } else { return true; } @@ -51,8 +64,26 @@ public class PlatformLaunchWizardDialog extends WizardDialog { public boolean getSelectPkgOp() { if (wizard != null) { return wizard.getSelectPkgOp(); + } else if (attachWizard != null) { + return attachWizard.getSelectPkgOp(); } else { return true; } } + + public String getProcName() { + if (attachWizard != null) { + return attachWizard.getProcName(); + } else { + return null; + } + } + + public int getProcId() { + if (attachWizard != null) { + return attachWizard.getPid(); + } else { + return -1; + } + } } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/ShowPackageStatusDialog.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/ShowPackageStatusDialog.java index d58fd2d..5876141 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/ShowPackageStatusDialog.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/ShowPackageStatusDialog.java @@ -1,6 +1,7 @@ package org.tizen.nativeplatform.launch.wizards; import java.util.ArrayList; +import java.util.ResourceBundle; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; @@ -22,32 +23,26 @@ 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.console.MessageConsoleStream; -import org.tizen.common.ui.view.console.ConsoleManager; -import org.tizen.nativeplatform.pkgmgr.PackageManagerOuputReceiver; import org.tizen.nativeplatform.pkgmgr.model.LocalPackage; import org.tizen.nativeplatform.pkgmgr.model.Package; -import org.tizen.sdblib.IDevice; public class ShowPackageStatusDialog extends Dialog { + private final String BUNDLE_NAME = ShowPackageStatusDialog.class.getPackage().getName() + ".LaunchWizardUIMessages";//$NON-NLS-1$ + private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + private int x = 0; private int y = 0; private final int width = 800; private final int height = 700; private Shell shell; - private String rootstrapPath = ""; - private IDevice device; - - + private TableViewer bsViewer; private TableViewer dvViewer; private ArrayList bsPackages = new ArrayList(); private ArrayList dvPackages = new ArrayList(); private ArrayList selectedBsPackages = new ArrayList(); - private ArrayList selectedDvPackages = new ArrayList(); - - private ArrayList packages; + private ArrayList selectedDvPackages = new ArrayList(); public ShowPackageStatusDialog(Shell parentShell, ArrayList bsPkgs, ArrayList dvPkgs) { @@ -65,7 +60,7 @@ public class ShowPackageStatusDialog extends Dialog { protected void configureShell(Shell newShell) { super.configureShell(newShell); - newShell.setText("Select packages to be installed"); + newShell.setText(resources.getString("PkgDialog.Title")); newShell.setLocation(x, y); newShell.setSize(width, height); } @@ -93,7 +88,7 @@ public class ShowPackageStatusDialog extends Dialog { composite.setLayout(new GridLayout(1, false)); Label message = new Label(composite, SWT.NONE); - message.setText("Checked packages will be installed to buildsystem and device"); + message.setText(resources.getString("PkgDialog.Desc")); } @Override @@ -143,7 +138,7 @@ public class ShowPackageStatusDialog extends Dialog { composite.setLayout(new GridLayout(1, false)); Label tableDesc = new Label(composite, SWT.NONE); - tableDesc.setText("To Buildsystem : "); + tableDesc.setText(resources.getString("PkgDialog.Label.Buildsystem")); } private void createBuildSystemComposite(Composite parent) { @@ -179,7 +174,7 @@ public class ShowPackageStatusDialog extends Dialog { composite.setLayout(new GridLayout(1, false)); Label tableDesc = new Label(composite, SWT.NONE); - tableDesc.setText("To Device : "); + tableDesc.setText(resources.getString("PkgDialog.Label.Device")); } private void createDeviceComposite(Composite parent) { @@ -278,8 +273,7 @@ public class ShowPackageStatusDialog extends Dialog { private TableViewerColumn createTableViewerColumn(TableViewer viewer, String title, int bound, int Style) { final TableViewerColumn viewerColumn = new TableViewerColumn( viewer, Style); - final TableColumn column = viewerColumn.getColumn(); - //column.addSelectionListener(new PackageTableSelectionAdapter(bsViewer)); + final TableColumn column = viewerColumn.getColumn(); column.setText(title); column.setWidth(bound); column.setResizable(true); @@ -287,17 +281,6 @@ public class ShowPackageStatusDialog extends Dialog { return viewerColumn; } - private PackageManagerOuputReceiver getNewOuputReceiver() { - ConsoleManager cm = new ConsoleManager("debug launch", true); - cm.clear(); - MessageConsoleStream mcsError = cm.getMessageConsoleStream(); - MessageConsoleStream mcs = cm.getMessageConsoleStream(); - PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver(); - rec.setMessageConsoleStream(mcs); - - return rec; - } - private void tableRefresh() { int recentTableIndex = bsViewer.getTable().getItemCount(); for (int i = 0; i < recentTableIndex; i++) { diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/wizards/TizenPlatformProjectWizard.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/wizards/TizenPlatformProjectWizard.java index b3cabae..8cd17f9 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/wizards/TizenPlatformProjectWizard.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/wizards/TizenPlatformProjectWizard.java @@ -131,4 +131,10 @@ public class TizenPlatformProjectWizard extends TizenProjectWizard { // TODO Auto-generated method stub } + + @Override + protected void doTemplatePreprocess(IPath projectPath, String _projectType) { + // TODO Auto-generated method stub + + } } -- 2.7.4