org.eclipse.egit.core;version="0.12.1",
org.eclipse.egit.core.op;version="0.12.1",
org.eclipse.egit.ui.internal.sharing;version="0.12.1",
+ org.eclipse.jface.text,
org.eclipse.jgit.lib;version="0.12.1",
org.eclipse.jgit.storage.file;version="0.12.1",
org.eclipse.jgit.transport;version="0.12.1",
org.tizen.nativeappcommon.templateengine,
org.tizen.nativeappcommon.wizards,
org.tizen.nativeappcommon.wizards.model,
- org.tizen.sdblib
+ org.tizen.sdblib,
+ org.tizen.sdblib.exception,
+ org.tizen.sdblib.receiver,
+ org.tizen.sdblib.service,
+ org.tizen.sdblib.util
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<!-- build start -->
+ <extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.eclipse.core.resources.IProject"
+ class="org.tizen.nativeplatform.PlatformProjectAdapterFactory">
+ <adapter
+ type="org.tizen.nativeplatform.IPlatformProject">
+ </adapter>
+ </factory>
+ </extension>
+
<extension
id="org.tizen.nativeplatform.gdbserver"
name="org.tizen.nativeplatform.gdbserver"
buildRunner="org.tizen.nativeplatform.build.PlatformExternalBuildRunner"
name="%Platform.proj.builder">
</builder>
+ <!--
+ <tool
+ id="org.tizen.nativeide.tool.gbs"
+ command="gbs"
+ natureFilter="ccnature"
+ name="GBS">
+ <option
+ name="Include"
+ id="org.tizen.gbs.includes"
+ valueType="userObjs"
+ valueHandler="org.tizen.nativeplatform.build.PlatformIncludePathOptionValueHandler">
+ </option>
+ <option
+ name="Include path"
+ id="org.tizen.gbs.include.paths"
+ valueType="includePath"
+ browseType="directory">
+ </option>
+ <enablement
+ type="ALL">
+ <true/>
+ </enablement>
+ </tool>
+ -->
<tool
id="org.tizen.nativeide.tool.sbi.gnu.archiver.platform.base"
superClass="org.tizen.nativeide.tool.sbi.gnu.archiver.base">
<extension
point="org.eclipse.debug.core.launchConfigurationTypes">
<launchConfigurationType
- delegate="org.tizen.nativeplatform.launch.TizenDebianLaunchDelegate"
- id="org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationType"
+ delegate="org.tizen.nativeplatform.launch.PlatformLaunchDelegate"
+ id="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationType"
name="%Platformlaunch.run"
public="true"/>
<launchConfigurationType
- delegate="org.tizen.nativeplatform.launch.TizenDebianLaunchDelegateForAttach"
- id="org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationTypeForAttach"
+ delegate="org.tizen.nativeplatform.launch.PlatformLaunchDelegateForAttach"
+ id="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForAttach"
name="%Platformlaunch.debug.attach"
public="true"/>
<!--
<launchConfigurationType
- delegate="org.tizen.nativeplatform.launch.TizenDebianLaunchDelegateForCore"
- id="org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationTypeForCore"
+ delegate="org.tizen.nativeplatform.launch.PlatformLaunchDelegateForCore"
+ id="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForCore"
name="Tizen Platform Project - Coredump"
public="true"/>
- -->
+ -->
</extension>
<extension
point="org.eclipse.debug.ui.launchConfigurationTypeImages">
<launchConfigurationTypeImage
icon="icons/Tizen_Custom_Debian_ConfigurationType_Image.gif"
- configTypeID="org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationType"
- id="org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationType.image"/>
+ configTypeID="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationType"
+ id="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationType.image"/>
<launchConfigurationTypeImage
icon="icons/Tizen_Custom_Debian_ConfigurationType_Image_Attach.gif"
- configTypeID="org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationTypeForAttach"
- id="org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationTypeForAttach.image"/>
+ configTypeID="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForAttach"
+ id="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForAttach.image"/>
<launchConfigurationTypeImage
icon="icons/Tizen_Custom_Debian_ConfigurationType_Image_Core.gif"
- configTypeID="org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationTypeForCore"
- id="org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationTypeForCore.image"/>
+ configTypeID="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForCore"
+ id="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForCore.image"/>
</extension>
<extension
point="org.eclipse.debug.core.launchDelegates">
<launchDelegate
- delegate="org.tizen.nativeplatform.launch.TizenDebianLaunchDelegate"
- id="org.tizen.nativeplatform.launch.TizenDebianLaunchDelegate"
+ delegate="org.tizen.nativeplatform.launch.PlatformLaunchDelegate"
+ id="org.tizen.nativeplatform.launch.PlatformLaunchDelegate"
modes="run,debug"
name="%Platformlaunch.run"
delegateDescription="The Tizen Platform Project Launcher supports running Tizen application on device"
sourceLocatorId="org.eclipse.cdt.debug.core.sourceLocator"
sourcePathComputerId="org.eclipse.cdt.debug.core.sourcePathComputer"
- type="org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationType"/>
+ type="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationType"/>
<launchDelegate
- delegate="org.tizen.nativeplatform.launch.TizenDebianLaunchDelegateForAttach"
- id="org.tizen.nativeplatform.launch.TizenDebianLaunchDelegateForAttach"
+ delegate="org.tizen.nativeplatform.launch.PlatformLaunchDelegateForAttach"
+ id="org.tizen.nativeplatform.launch.PlatformLaunchDelegateForAttach"
modes="debug"
name="%Platformlaunch.debug.attach"
delegateDescription="The Tizen Platform Project Launcher supports attach debugging Tizen process on device"
sourceLocatorId="org.eclipse.cdt.debug.core.sourceLocator"
sourcePathComputerId="org.eclipse.cdt.debug.core.sourcePathComputer"
- type="org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationTypeForAttach"/>
+ type="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForAttach"/>
<!--
<launchDelegate
- delegate="org.tizen.nativeplatform.launch.TizenDebianLaunchDelegateForCore"
- id="org.tizen.nativeplatform.launch.TizenDebianLaunchDelegateForCore"
+ delegate="org.tizen.nativeplatform.launch.PlatformLaunchDelegateForCore"
+ id="org.tizen.nativeplatform.launch.PlatformLaunchDelegateForCore"
modes="debug"
name="Tizen Platform Project - Coredump"
delegateDescription="The Tizen Platform Project Launcher supports coredump debugging"
sourceLocatorId="org.eclipse.cdt.debug.core.sourceLocator"
sourcePathComputerId="org.eclipse.cdt.debug.core.sourcePathComputer"
- type="org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationTypeForCore"/>
+ type="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForCore"/>
-->
</extension>
<extension
point="org.eclipse.debug.ui.launchConfigurationTabGroups">
<launchConfigurationTabGroup
- class="org.tizen.nativeplatform.launch.ui.TizenDebianLaunchConfigurationTabGroup"
- id="org.tizen.nativeplatform.launch.ui.TizenDebianLaunchConfigurationTabGroup"
- type="org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationType"/>
+ class="org.tizen.nativeplatform.launch.ui.PlatformLaunchConfigurationTabGroup"
+ id="org.tizen.nativeplatform.launch.ui.PlatformLaunchConfigurationTabGroup"
+ type="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationType"/>
<launchConfigurationTabGroup
- class="org.tizen.nativeplatform.launch.ui.TizenDebianLaunchConfigurationForAttachTabGroup"
- id="org.tizen.nativeplatform.launch.ui.TizenDebianLaunchConfigurationForAttachTabGroup"
- type="org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationTypeForAttach"/>
+ class="org.tizen.nativeplatform.launch.ui.PlatformLaunchConfigurationForAttachTabGroup"
+ id="org.tizen.nativeplatform.launch.ui.PlatformLaunchConfigurationForAttachTabGroup"
+ type="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForAttach"/>
<launchConfigurationTabGroup
- class="org.tizen.nativeplatform.launch.ui.TizenDebianLaunchConfigurationForCoreTabGroup"
- id="org.tizen.nativeplatform.launch.ui.TizenDebianLaunchConfigurationForCoreTabGroup"
- type="org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationTypeForCore"/>
+ class="org.tizen.nativeplatform.launch.ui.PlatformLaunchConfigurationForCoreTabGroup"
+ id="org.tizen.nativeplatform.launch.ui.PlatformLaunchConfigurationForCoreTabGroup"
+ type="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForCore"/>
</extension>
<extension
point="org.eclipse.debug.ui.launchConfigurationTabs">
<tab
- id="org.tizen.nativeplatform.launch.ui.TizenDebianMainTab"
- group="org.tizen.nativeplatform.launch.ui.TizenDebianLaunchConfigurationTabGroup"
+ id="org.tizen.nativeplatform.launch.ui.PlatformMainTab"
+ group="org.tizen.nativeplatform.launch.ui.PlatformLaunchConfigurationTabGroup"
name="%Platformlaunch.conf.tab"
- class="org.tizen.nativeplatform.launch.ui.TizenDebianMainTab">
- <associatedDelegate delegate="org.tizen.nativeplatform.launch.TizenDebianLaunchDelegate"/>
+ class="org.tizen.nativeplatform.launch.ui.PlatformMainTab">
+ <associatedDelegate delegate="org.tizen.nativeplatform.launch.PlatformLaunchDelegate"/>
</tab>
<tab
- id="org.tizen.nativeplatform.launch.ui.TizenDebianMainAttachTab"
- group="org.tizen.nativeplatform.launch.ui.TizenDebianLaunchConfigurationForAttachTabGroup"
+ id="org.tizen.nativeplatform.launch.ui.PlatformMainAttachTab"
+ group="org.tizen.nativeplatform.launch.ui.PlatformLaunchConfigurationForAttachTabGroup"
name="%Platformlaunch.conf.tab"
- class="org.tizen.nativeplatform.launch.ui.TizenDebianMainAttachTab">
- <associatedDelegate delegate="org.tizen.nativeplatform.launch.TizenDebianLaunchDelegateForAttach"/>
+ class="org.tizen.nativeplatform.launch.ui.PlatformMainAttachTab">
+ <associatedDelegate delegate="org.tizen.nativeplatform.launch.PlatformLaunchDelegateForAttach"/>
</tab>
<!--
<tab
- id="org.tizen.nativeplatform.launch.ui.TizenDebianMainCoreTab"
- group="org.tizen.nativeplatform.launch.ui.TizenDebianLaunchConfigurationForCoreTabGroup"
+ id="org.tizen.nativeplatform.launch.ui.PlatformMainCoreTab"
+ group="org.tizen.nativeplatform.launch.ui.PlatformLaunchConfigurationForCoreTabGroup"
name="Tizen Platform Project main tab for coredump"
- class="org.tizen.nativeplatform.launch.ui.TizenDebianMainCoreTab">
- <associatedDelegate delegate="org.tizen.nativeplatform.launch.TizenDebianLaunchDelegateForCore"/>
+ class="org.tizen.nativeplatform.launch.ui.PlatformMainCoreTab">
+ <associatedDelegate delegate="org.tizen.nativeplatform.launch.PlatformLaunchDelegateForCore"/>
</tab>
-->
</extension>
namespace="org.tizen.nativeplatform.launch.ui.shortcut"
properties="isTizenCustomDebianProject, belongTizenCustomDebianProject"
type="org.eclipse.core.resources.IResource"
- class="org.tizen.nativeplatform.launch.ui.shortcut.TizenDebianPropertyTester"
- id="org.tizen.nativeplatform.launch.ui.shortcut.TizenDebianPropertyTester"/>
+ class="org.tizen.nativeplatform.launch.ui.shortcut.PlatformPropertyTester"
+ id="org.tizen.nativeplatform.launch.ui.shortcut.PlatformPropertyTester"/>
</extension>
<extension
label="%Platformlaunch.run"
icon="icons/Tizen_Custom_Debian_ConfigurationType_Image.gif"
modes="run,debug"
- class="org.tizen.nativeplatform.launch.ui.shortcut.TizenDebianProjectLaunchShortcut"
- id="org.tizen.nativeplatform.launch.ui.shortcut.TizenDebianProjectLaunchShortcut">
+ class="org.tizen.nativeplatform.launch.ui.shortcut.PlatformProjectLaunchShortcut"
+ id="org.tizen.nativeplatform.launch.ui.shortcut.PlatformProjectLaunchShortcut">
<!--
<contextualLaunch>
<enablement>
mode="debug"
description="%Platformlaunch.debug.desc"/>
<configurationType
- id="org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationType">
+ id="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationType">
</configurationType>
</shortcut>
label="%Platformlaunch.debug.attach"
icon="icons/Tizen_Custom_Debian_ConfigurationType_Image_Attach.gif"
modes="debug"
- class="org.tizen.nativeplatform.launch.ui.shortcut.TizenDebianProjectAttachLaunchShortcut"
- id="org.tizen.nativeplatform.launch.ui.shortcut.TizenDebianProjectAttachLaunchShortcut">
+ class="org.tizen.nativeplatform.launch.ui.shortcut.PlatformProjectAttachLaunchShortcut"
+ id="org.tizen.nativeplatform.launch.ui.shortcut.PlatformProjectAttachLaunchShortcut">
<!--
<contextualLaunch>
<enablement>
mode="debug"
description="%Platformlaunch.debug.attach.desc"/>
<configurationType
- id="org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationTypeForAttach">
+ id="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForAttach">
</configurationType>
</shortcut>
<!--
label="Tizen Platform Project - Coredump"
icon="icons/Tizen_Custom_Debian_ConfigurationType_Image_Core.gif"
modes="debug"
- class="org.tizen.nativeplatform.launch.ui.shortcut.TizenDebianProjectCoredumpLaunchShortcut"
- id="org.tizen.nativeapp.launch.ui.shortcut.TizenDebianProjectCoredumpLaunchShortcut">
+ class="org.tizen.nativeplatform.launch.ui.shortcut.PlatformProjectCoredumpLaunchShortcut"
+ id="org.tizen.nativeapp.launch.ui.shortcut.PlatformProjectCoredumpLaunchShortcut">
<contextualLaunch>
<enablement>
<and>
mode="debug"
description="Coredump Debugs a Tizen Platform Project"/>
<configurationType
- id="org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationTypeForCore">
+ id="org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForCore">
</configurationType>
</shortcut>
-->
<enablement></enablement>
</commonWizard>
</extension>
-
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
ratio="1"
relationship="bottom"
relative="org.eclipse.ui.navigator.ProjectExplorer"
- id="org.tizen.common.connection.ui.ConnectionExplorer">
+ id="org.tizen.common.connection.explorer.ConnectionExplorer">
</view>
<viewShortcut
- id="org.tizen.common.connection.ui.ConnectionExplorer">
+ id="org.tizen.common.connection.explorer.ConnectionExplorer">
</viewShortcut>
</perspectiveExtension>
</extension>
<perspectiveExtension
targetID="org.tizen.nativeplatform.perspective">
<view
- id="org.tizen.common.connection.ui.LogView"
+ id="org.tizen.common.connection.log.LogView"
ratio="1"
relationship="stack"
relative="org.eclipse.ui.views.TaskList">
</view>
<viewShortcut
- id="org.tizen.common.connection.ui.LogView">
+ id="org.tizen.common.connection.log.LogView">
</viewShortcut>
</perspectiveExtension>
</extension>
-
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
--- /dev/null
+package org.tizen.nativeplatform;
+import java.util.List;
+
+import org.tizen.common.ITizenProject;
+import org.tizen.common.TizenProjectType;
+
+
+public interface IPlatformProject extends ITizenProject {
+ /**
+ * Returns build configuration list.
+ * @return a build configuration list
+ */
+ public List<String> getBuildConfigurations();
+
+ /**
+ * Returns default build configuration name.
+ * @return a default build configuration name
+ */
+ public String getDefaultBuildConfiguration();
+
+ public boolean isEFLApplication();
+}
--- /dev/null
+package org.tizen.nativeplatform;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.tizen.common.TizenProjectType;
+
+public interface IPlatformXMLStore {
+ /**
+ * Sets the project of this xml store.
+ * @param project - project in which xml is stored.
+ */
+ public void setProject(IProject project);
+
+ /**
+ * This roles same as {@link IXMLStore#setProject(IProject),
+ * except that this is for CLI because CLI cannot use IProject.
+ *
+ * @param projectPath path of project in which xml will be stored
+ */
+ public void setProject(String projectPath);
+
+ /**
+ * Parses xml files and loads.
+ */
+ public boolean loadXml();
+
+ /**
+ * Returns application's version.
+ * @return application's version.
+ */
+ public String getVersion();
+
+ /**
+ * Returns application's id.
+ * @return application's id.
+ */
+ public String getAppId();
+
+ /**
+ * Returns application's label.
+ * @return application's label.
+ */
+ public String getAppLabel();
+
+ /**
+ * Returns icon file list of this xml store.
+ * @return list of icon files.
+ */
+ public List<String> getIconFileList();
+
+ /**
+ * Returns application type.
+ * @return application type.
+ */
+ public TizenProjectType getApplicationType();
+
+ /**
+ * Returns application's executable files.
+ * @return application's executable files.
+ */
+ public List<String> getExecutableFiles();
+
+ /**
+ * Returns application's authors.
+ * @return application's authors.
+ */
+ public List<String> getAuthors();
+
+}
--- /dev/null
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+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.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.tizen.common.TizenProjectType;
+import org.tizen.nativecommon.ProjectUtil;
+import org.tizen.nativeplatform.build.PlatformConfigurationManager;
+import org.tizen.nativeplatform.filefilter.XmlFileFilter;
+
+public class PlatformProject implements IPlatformProject, IAdaptable {
+ private final String PKG_PREFIX = "org.tizen.";
+ private IProject project;
+
+ public PlatformProject(IProject project) {
+ this.project = project;
+ }
+
+ @Override
+ @SuppressWarnings("rawtypes")
+ public Object getAdapter(Class adapter) {
+ return Platform.getAdapterManager().getAdapter(this, adapter);
+ }
+
+ @Override
+ public String getAppId() {
+ // return PlatformProjectUtil.getAppId(project);
+ // return ProjectUtil.getAppId(getProject());
+ return null;
+ }
+
+ @Override
+ /**
+ * Returns {@code null} for the native project.
+ */
+ public String getPackageId() {
+ return null;
+ }
+
+ @Override
+ public TizenProjectType getTizenProjectType() {
+ String arteType = ProjectUtil.getProjectArtefactType(project);
+
+ if (PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE.equals(arteType)) {
+ return TizenProjectType.TIZEN_PLATFORM_PROJECT;
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public List<String> getBuildConfigurations() {
+ List<String> list = new ArrayList<String>();
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+
+ IConfiguration[] configs = info.getManagedProject().getConfigurations();
+ for (IConfiguration config : configs) {
+ list.add(config.getName());
+ }
+ return list;
+ }
+
+ @Override
+ public String getDefaultBuildConfiguration() {
+ // return
+ // PlatformProjectUtil.getDefaultConfiguration(project).getName();
+ return null;
+ }
+
+ protected IProject getProject() {
+ return project;
+ }
+
+ @Override
+ public boolean isEFLApplication() {
+ File projectPath = project.getLocation().toFile();
+ // get ".xml" file list
+ String[] files = projectPath.list(new XmlFileFilter());
+ // return false if ".xml" file does not exist
+ for (String file : files) {
+ if (file.trim().startsWith(PKG_PREFIX)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
--- /dev/null
+package org.tizen.nativeplatform;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdapterFactory;
+
+public class PlatformProjectAdapterFactory implements IAdapterFactory {
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if (adapterType == IPlatformProject.class) {
+ return new PlatformProject((IProject)adaptableObject);
+ }
+ return null;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Class[] getAdapterList() {
+ return new Class[] { PlatformProject.class };
+ }
+}
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PlatformUI;
-
import org.tizen.nativecommon.build.CommonBuildMessages;
import org.tizen.nativecommon.build.CommonBuildPackageFile;
+import org.tizen.nativeplatform.pkg.commander.IPackager;
+import org.tizen.nativeplatform.pkg.commander.PackagerFactory;
-public class PlatformBuildPackageObjectAction implements IWorkbenchWindowActionDelegate, IObjectActionDelegate {
+public class PlatformBuildPackageObjectAction implements IWorkbenchWindowActionDelegate,
+ IObjectActionDelegate {
protected IProject project;
protected IWorkbenchWindow window;
private boolean packagingResult = false;
ProgressMonitorDialog dialog = new ProgressMonitorDialog(window.getShell());
try {
- dialog.run(true, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
- IConfiguration config = ManagedBuildManager.getBuildInfo( project ).getDefaultConfiguration();
- packagingResult = PlatformProjectPackaging.RPMPackaging(project, config, monitor);
- }
- });
- } catch (InvocationTargetException e1) {
- e1.printStackTrace();
- } catch (InterruptedException e1) {
- e1.printStackTrace();
- }
-
+ dialog.run(true, true, new IRunnableWithProgress() {
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+ IConfiguration config = ManagedBuildManager.getBuildInfo(project)
+ .getDefaultConfiguration();
+ IPackager packager = PackagerFactory.getPackager(project, config);
+ packagingResult = packager.packaging(monitor);
+
+ }
+ });
+ } catch (InvocationTargetException e1) {
+ e1.printStackTrace();
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+
if (packagingResult) {
- MessageDialog.openInformation(window.getShell(), CommonBuildMessages.BUILD_RESULT,
- CommonBuildMessages.SUCCESS_TO_BUILD_PACKAGE);
- } else {
- MessageDialog.openError(window.getShell(), CommonBuildMessages.BUILD_RESULT,
- CommonBuildMessages.FAIL_TO_BUILD_PACKAGE);
- }
+ MessageDialog.openInformation(window.getShell(), CommonBuildMessages.BUILD_RESULT,
+ CommonBuildMessages.SUCCESS_TO_BUILD_PACKAGE);
+ } else {
+ MessageDialog.openError(window.getShell(), CommonBuildMessages.BUILD_RESULT,
+ CommonBuildMessages.FAIL_TO_BUILD_PACKAGE);
+ }
// refresh the project explorer
try {
- project.refreshLocal(IResource.DEPTH_INFINITE, null );
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
e.printStackTrace();
}
Object obj = null;
if (selection instanceof TreeSelection) {
- TreeSelection _selection = (TreeSelection)selection;
+ TreeSelection _selection = (TreeSelection) selection;
if (_selection != null) {
obj = _selection.getFirstElement();
// do nothing
}
}
-
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.internal.envvar.BuildEnvVar;
+import org.tizen.nativecommon.build.SmartBuildInterface;
+@SuppressWarnings("restriction")
public class PlatformConfigurationEnvVarSupplier implements
- IConfigurationEnvironmentVariableSupplier {
-
- @Override
- public IBuildEnvironmentVariable getVariable(String variableName,
- IConfiguration configuration, IEnvironmentVariableProvider provider) {
- // set "SBI_SYSROOT" variable
- String sysrootPath = PlatformConfigurationManager.getRootstrapPath( configuration );
- return new BuildEnvVar("SBI_SYSROOT", sysrootPath, IBuildEnvironmentVariable.ENVVAR_REPLACE, null );
- }
-
- @Override
- public IBuildEnvironmentVariable[] getVariables(
- IConfiguration configuration, IEnvironmentVariableProvider provider) {
-
- ArrayList<IBuildEnvironmentVariable> list = new ArrayList<IBuildEnvironmentVariable>();
-
- // set "SBI_SYSROOT" variable
- String sysrootPath = PlatformConfigurationManager.getRootstrapPath( configuration );
- list.add( new BuildEnvVar("SBI_SYSROOT", sysrootPath, IBuildEnvironmentVariable.ENVVAR_REPLACE, null ) );
- return list.toArray( new IBuildEnvironmentVariable[0] );
- }
+ IConfigurationEnvironmentVariableSupplier {
+
+ @Override
+ public IBuildEnvironmentVariable getVariable(String variableName, IConfiguration configuration,
+ IEnvironmentVariableProvider provider) {
+ // set "SBI_SYSROOT" variable
+ String basePath = PlatformConfigurationManager.getRootstrapPath(configuration);
+ String sysrootPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(basePath);
+ return new BuildEnvVar("SBI_SYSROOT", sysrootPath,
+ IBuildEnvironmentVariable.ENVVAR_REPLACE, null);
+ }
+
+ @Override
+ public IBuildEnvironmentVariable[] getVariables(IConfiguration configuration,
+ IEnvironmentVariableProvider provider) {
+
+ ArrayList<IBuildEnvironmentVariable> list = new ArrayList<IBuildEnvironmentVariable>();
+
+ // set "SBI_SYSROOT" variable
+ String basePath = PlatformConfigurationManager.getRootstrapPath(configuration);
+ String sysrootPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(basePath);
+ list.add(new BuildEnvVar("SBI_SYSROOT", sysrootPath,
+ IBuildEnvironmentVariable.ENVVAR_REPLACE, null));
+ return list.toArray(new IBuildEnvironmentVariable[0]);
+ }
}
package org.tizen.nativeplatform.build;
import java.util.ArrayList;
+import java.util.List;
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativecommon.build.exception.SBIException;
-
@SuppressWarnings("restriction")
-public class PlatformConfigurationManager extends CommonConfigurationManager
-{
- // ProjectInfo
- public static final String CURRENT_SLP_PROJECT_VERSION = "1.0.0";
- public static final String TIZEN_PLATFORM_ARTIFACT_TYPE = "org.tizen.nativeide.buildArtefactType.platform";
- public static final String OLD_SLP_CUSTOM_DEBIAN_ARTIFACT_TYPE = "com.samsung.slp.project.custom.debian";
-
- // SBI Compatibility
- public static final String SBI_PROJECT_TYPE_ID = "org.tizen.nativebuild.target.sbi.gcc45.platform";
- public static final String SBI_DEFAULT_I386_CONFIGRATION_ID = "org.tizen.nativeide.config.sbi.gcc45.platform.emulator";
- public static final String SBI_DEFAULT_ARM_CONFIGRATION_ID = "org.tizen.nativeide.config.sbi.gcc45.platform.device";
-
- static final String SBI_PLATFORM_CPP_COMPILER_TOOL_ID = "org.tizen.nativeide.tool.sbi.gnu.cpp.compiler.platform.base";
- static final String SBI_PLATFORM_CPP_COMPILER_GBS_OPTION_ID = "sbi.gnu.cpp.compiler.option.gbs.platform";
-
- // get compiler flags
- public static String getAllCFlags( IConfiguration config )
- {
- String c_compiler_id = SBI_BASE_C_COMPILER_TOOL_ID;
- return getAllCompilerFlags( config, c_compiler_id );
- }
-
- public static String getAllCPPFlags( IConfiguration config )
- {
- String cpp_compiler_id = SBI_BASE_CPP_COMPILER_TOOL_ID;
- return getAllCompilerFlags( config, cpp_compiler_id );
- }
-
- @SuppressWarnings("deprecation")
- protected static String getAllCompilerFlags( IConfiguration config, String compilerId ) {
-
- ITool compilerTool = config.getToolsBySuperClassId(compilerId)[0];
-
- String compilerFlags = "";
-
- try {
- compilerFlags = compilerTool.getToolFlags();
-
- // skip "-c" option and replace double quotes
- String[] flags = compilerFlags.split(" ");
- compilerFlags = "";
- for( int i = 0; i < flags.length ; i ++ ) {
-
- if ( flags[i].compareTo("-c") == 0 ) {
- continue;
- }
-
- flags[i] = flags[i].replace("\"", "\\\"");
- compilerFlags = compilerFlags + " " + flags[i];
- }
- } catch (BuildException e) {
- e.printStackTrace();
- }
-
- compilerFlags = compilerFlags.trim();
- return compilerFlags;
- }
-
- public static void setGBSOptions( IConfiguration config, Tool tool, ArrayList<String> optionList )
- {
- String tool_id = tool.getBaseId();
- String option_id = "";
-
- if (tool_id.contains(SBI_PLATFORM_CPP_COMPILER_TOOL_ID)) {
- option_id = SBI_PLATFORM_CPP_COMPILER_GBS_OPTION_ID;
- } else {
- return;
- }
-
- ITool cpp_linkerTool =config.getToolsBySuperClassId(tool_id)[0];
- IOption dynamicAnalysisOption = cpp_linkerTool.getOptionBySuperClassId(option_id);
- ManagedBuildManager.setOption( config, cpp_linkerTool, dynamicAnalysisOption, optionList.toArray( new String[0] ));
- }
-
- public static void setGBSOptions( IConfiguration config, ArrayList<String> optionList ) {
- if (config instanceof MultiConfiguration) {
- Object o[] = ((MultiConfiguration) config).getItems();
- for (IConfiguration c : (IConfiguration[])o) {
- internalSetGBSOptions(c, optionList);
- }
- } else {
- internalSetGBSOptions(config, optionList);
- }
- }
-
- private static void internalSetGBSOptions( IConfiguration config, ArrayList<String> optionList )
- {
- String cpp_compiler_id = SBI_PLATFORM_CPP_COMPILER_TOOL_ID;
- String option_id = SBI_PLATFORM_CPP_COMPILER_GBS_OPTION_ID;
-
- // cpp compiler
- ITool tool =config.getToolsBySuperClassId(cpp_compiler_id)[0];
- IOption gbsOption = tool.getOptionBySuperClassId(option_id);
- ManagedBuildManager.setOption( config, tool, gbsOption, optionList.toArray( new String[0] ));
- }
-
- public static void addGBSOptions(IConfiguration config, String newOption)
- {
- if (config instanceof MultiConfiguration) {
- Object o[] = ((MultiConfiguration) config).getItems();
- for (IConfiguration c : (IConfiguration[])o) {
- internalAddGBSOption(c, newOption);
- }
- } else {
- internalAddGBSOption(config, newOption);
- }
- }
-
- private static void internalAddGBSOption(IConfiguration config, String newOption) {
- String cpp_compiler_id = SBI_PLATFORM_CPP_COMPILER_TOOL_ID;
- String option_id = SBI_PLATFORM_CPP_COMPILER_GBS_OPTION_ID;
-
- // cpp compiler
- ITool tool =config.getToolsBySuperClassId(cpp_compiler_id)[0];
- IOption gbsOption = tool.getOptionBySuperClassId(option_id);
- ArrayList<String> oldOptions = getGBSOptions(config);
-
- for(String op : oldOptions) {
- if (newOption.equals(op)) {
- return;
- }
- }
-
- oldOptions.add(newOption);
- ManagedBuildManager.setOption( config, tool, gbsOption, oldOptions.toArray( new String[0] ));
- }
-
-
- public static void removeGBSOptions( IConfiguration config, String option )
- {
- if (config instanceof MultiConfiguration) {
- Object o[] = ((MultiConfiguration) config).getItems();
- for (IConfiguration c : (IConfiguration[])o) {
- internalRemoveGBSOption(c, option);
- }
- } else {
- internalRemoveGBSOption(config, option);
- }
- }
-
- private static void internalRemoveGBSOption(IConfiguration config, String option) {
- String cpp_compiler_id = SBI_PLATFORM_CPP_COMPILER_TOOL_ID;
- String option_id = SBI_PLATFORM_CPP_COMPILER_GBS_OPTION_ID;
-
- // cpp compiler
- ITool tool =config.getToolsBySuperClassId(cpp_compiler_id)[0];
- IOption gbsOption = tool.getOptionBySuperClassId(option_id);
- ArrayList<String> oldOptions = getGBSOptions(config);
- ArrayList<String> newOptions = new ArrayList<String>();
- String removeKey = option.split("=")[0];
- for(String op : oldOptions) {
- String key = op.split("=")[0];
- if (removeKey.equals(key)) {
- continue;
- } else {
- newOptions.add(op);
- }
- }
-
- ManagedBuildManager.setOption( config, tool, gbsOption, newOptions.toArray( new String[0] ));
- }
-
- public static void replaceGBSOptions( IConfiguration config, String option )
- {
- removeGBSOptions(config, option);
- addGBSOptions(config, option);
- }
-
- public static ArrayList<String> getGBSOptions( IConfiguration config )
- {
- String cpp_compiler_id = SBI_PLATFORM_CPP_COMPILER_TOOL_ID;
- String option_id = SBI_PLATFORM_CPP_COMPILER_GBS_OPTION_ID;
-
- ArrayList<String> flags = new ArrayList<String>();
-
- // c compiler
- ITool tool =config.getToolsBySuperClassId(cpp_compiler_id)[0];
- IOption gbsOption = tool.getOptionBySuperClassId(option_id);
-
-
- try {
- for ( String f: gbsOption.getStringListValue() ) {
- flags.add( f );
- }
- } catch (BuildException e) {
- e.printStackTrace();
- }
-
- return flags;
- }
-
- protected static boolean isCPPProject( IConfiguration config )
- {
- try {
- IProject project = (IProject)config.getOwner();
-
- if ( project.hasNature( CCProjectNature.CC_NATURE_ID ) )
- return true;
- } catch (CoreException e1) {
- e1.printStackTrace();
- }
-
- return false;
- }
-
- public static void changeToolchain(IConfiguration config, String targetId) {
- setBuildTargetName(config, targetId);
- setToolCommand(config);
- }
-
- public static String getRootstrapPath( IConfiguration config ) {
-
- try {
- String targetID = getBuildTargetName(config);
- if (targetID == null) {
- targetID = getDefaultBuildTargetName(config);
- }
- SmartBuildInterface sbi = SmartBuildInterface.getInstance();
- String path = sbi.getRootstrapPath(targetID);
- if (path == null) {
- return "";
- } else {
- return sbi.getRootstrapPath(targetID);
- }
- } catch (SBIException e) {
- e.printStackTrace();
- return "/";
- }
- }
+public class PlatformConfigurationManager extends CommonConfigurationManager {
+ // ProjectInfo
+ public static final String CURRENT_SLP_PROJECT_VERSION = "1.0.0";
+ public static final String TIZEN_PLATFORM_ARTIFACT_TYPE = "org.tizen.nativeide.buildArtefactType.platform";
+ public static final String OLD_SLP_CUSTOM_DEBIAN_ARTIFACT_TYPE = "com.samsung.slp.project.custom.debian";
+
+ // SBI Compatibility
+ public static final String SBI_PROJECT_TYPE_ID = "org.tizen.nativebuild.target.sbi.gcc45.platform";
+ public static final String SBI_DEFAULT_I386_CONFIGRATION_ID = "org.tizen.nativeide.config.sbi.gcc45.platform.emulator";
+ public static final String SBI_DEFAULT_ARM_CONFIGRATION_ID = "org.tizen.nativeide.config.sbi.gcc45.platform.device";
+
+ static final String GBS_TOOL_ID = "org.tizen.nativeide.tool.gbs";
+ static final String GBS_TOOL_INCLUDE_OPTION_ID = "org.tizen.gbs.include.paths";
+ static final String SBI_PLATFORM_CPP_COMPILER_TOOL_ID = "org.tizen.nativeide.tool.sbi.gnu.cpp.compiler.platform.base";
+ static final String SBI_PLATFORM_CPP_COMPILER_GBS_OPTION_ID = "sbi.gnu.cpp.compiler.option.gbs.platform";
+
+ // get compiler flags
+ public static String getAllCFlags(IConfiguration config) {
+ String c_compiler_id = SBI_BASE_C_COMPILER_TOOL_ID;
+ return getAllCompilerFlags(config, c_compiler_id);
+ }
+
+ public static String getAllCPPFlags(IConfiguration config) {
+ String cpp_compiler_id = SBI_BASE_CPP_COMPILER_TOOL_ID;
+ return getAllCompilerFlags(config, cpp_compiler_id);
+ }
+
+ @SuppressWarnings("deprecation")
+ protected static String getAllCompilerFlags(IConfiguration config, String compilerId) {
+
+ ITool compilerTool = config.getToolsBySuperClassId(compilerId)[0];
+
+ String compilerFlags = "";
+
+ try {
+ compilerFlags = compilerTool.getToolFlags();
+
+ // skip "-c" option and replace double quotes
+ String[] flags = compilerFlags.split(" ");
+ compilerFlags = "";
+ for (int i = 0; i < flags.length; i++) {
+
+ if (flags[i].compareTo("-c") == 0) {
+ continue;
+ }
+
+ flags[i] = flags[i].replace("\"", "\\\"");
+ compilerFlags = compilerFlags + " " + flags[i];
+ }
+ } catch (BuildException e) {
+ e.printStackTrace();
+ }
+
+ compilerFlags = compilerFlags.trim();
+ return compilerFlags;
+ }
+
+ public static void setGBSOptions(IConfiguration config, Tool tool, ArrayList<String> optionList) {
+ String tool_id = tool.getBaseId();
+ String option_id = "";
+
+ if (tool_id.contains(SBI_PLATFORM_CPP_COMPILER_TOOL_ID)) {
+ option_id = SBI_PLATFORM_CPP_COMPILER_GBS_OPTION_ID;
+ } else {
+ return;
+ }
+
+ ITool cpp_linkerTool = config.getToolsBySuperClassId(tool_id)[0];
+ IOption dynamicAnalysisOption = cpp_linkerTool.getOptionBySuperClassId(option_id);
+ ManagedBuildManager.setOption(config, cpp_linkerTool, dynamicAnalysisOption,
+ optionList.toArray(new String[0]));
+ }
+
+ public static void setGBSOptions(IConfiguration config, ArrayList<String> optionList) {
+ if (config instanceof MultiConfiguration) {
+ Object o[] = ((MultiConfiguration) config).getItems();
+ for (IConfiguration c : (IConfiguration[]) o) {
+ internalSetGBSOptions(c, optionList);
+ }
+ } else {
+ internalSetGBSOptions(config, optionList);
+ }
+ }
+
+ private static void internalSetGBSOptions(IConfiguration config, ArrayList<String> optionList) {
+ String cpp_compiler_id = SBI_PLATFORM_CPP_COMPILER_TOOL_ID;
+ String option_id = SBI_PLATFORM_CPP_COMPILER_GBS_OPTION_ID;
+
+ // cpp compiler
+ ITool tool = config.getToolsBySuperClassId(cpp_compiler_id)[0];
+ IOption gbsOption = tool.getOptionBySuperClassId(option_id);
+ ManagedBuildManager.setOption(config, tool, gbsOption, optionList.toArray(new String[0]));
+ }
+
+ public static void addGBSOptions(IConfiguration config, String newOption) {
+ if (config instanceof MultiConfiguration) {
+ Object o[] = ((MultiConfiguration) config).getItems();
+ for (IConfiguration c : (IConfiguration[]) o) {
+ internalAddGBSOption(c, newOption);
+ }
+ } else {
+ internalAddGBSOption(config, newOption);
+ }
+ }
+
+ private static void internalAddGBSOption(IConfiguration config, String newOption) {
+ String cpp_compiler_id = SBI_PLATFORM_CPP_COMPILER_TOOL_ID;
+ String option_id = SBI_PLATFORM_CPP_COMPILER_GBS_OPTION_ID;
+
+ // cpp compiler
+ ITool tool = config.getToolsBySuperClassId(cpp_compiler_id)[0];
+ IOption gbsOption = tool.getOptionBySuperClassId(option_id);
+ ArrayList<String> oldOptions = getGBSOptions(config);
+
+ for (String op : oldOptions) {
+ if (newOption.equals(op)) {
+ return;
+ }
+ }
+
+ oldOptions.add(newOption);
+ ManagedBuildManager.setOption(config, tool, gbsOption, oldOptions.toArray(new String[0]));
+ }
+
+ public static void removeGBSOptions(IConfiguration config, String option) {
+ if (config instanceof MultiConfiguration) {
+ Object o[] = ((MultiConfiguration) config).getItems();
+ for (IConfiguration c : (IConfiguration[]) o) {
+ internalRemoveGBSOption(c, option);
+ }
+ } else {
+ internalRemoveGBSOption(config, option);
+ }
+ }
+
+ private static void internalRemoveGBSOption(IConfiguration config, String option) {
+ String cpp_compiler_id = SBI_PLATFORM_CPP_COMPILER_TOOL_ID;
+ String option_id = SBI_PLATFORM_CPP_COMPILER_GBS_OPTION_ID;
+
+ // cpp compiler
+ ITool tool = config.getToolsBySuperClassId(cpp_compiler_id)[0];
+ IOption gbsOption = tool.getOptionBySuperClassId(option_id);
+ ArrayList<String> oldOptions = getGBSOptions(config);
+ ArrayList<String> newOptions = new ArrayList<String>();
+ String removeKey = option.split("=")[0];
+ for (String op : oldOptions) {
+ String key = op.split("=")[0];
+ if (removeKey.equals(key)) {
+ continue;
+ } else {
+ newOptions.add(op);
+ }
+ }
+
+ ManagedBuildManager.setOption(config, tool, gbsOption, newOptions.toArray(new String[0]));
+ }
+
+ public static void replaceGBSOptions(IConfiguration config, String option) {
+ removeGBSOptions(config, option);
+ addGBSOptions(config, option);
+ }
+
+ public static ArrayList<String> getGBSOptions(IConfiguration config) {
+ String cpp_compiler_id = SBI_PLATFORM_CPP_COMPILER_TOOL_ID;
+ String option_id = SBI_PLATFORM_CPP_COMPILER_GBS_OPTION_ID;
+
+ ArrayList<String> flags = new ArrayList<String>();
+
+ // c compiler
+ ITool tool = config.getToolsBySuperClassId(cpp_compiler_id)[0];
+ IOption gbsOption = tool.getOptionBySuperClassId(option_id);
+
+ try {
+ for (String f : gbsOption.getStringListValue()) {
+ flags.add(f);
+ }
+ } catch (BuildException e) {
+ e.printStackTrace();
+ }
+
+ return flags;
+ }
+
+ protected static boolean isCPPProject(IConfiguration config) {
+ try {
+ IProject project = (IProject) config.getOwner();
+
+ if (project.hasNature(CCProjectNature.CC_NATURE_ID))
+ return true;
+ } catch (CoreException e1) {
+ e1.printStackTrace();
+ }
+
+ return false;
+ }
+
+ public static void changeToolchain(IConfiguration config, String targetId) {
+ setBuildTargetName(config, targetId);
+ setToolCommand(config);
+ }
+
+ public static String getRootstrapPath(IConfiguration config) {
+
+ try {
+ String targetID = getBuildTargetName(config);
+ if (targetID == null) {
+ targetID = getDefaultBuildTargetName(config);
+ }
+ SmartBuildInterface sbi = SmartBuildInterface.getInstance();
+ String path = sbi.getRootstrapPath(targetID);
+ if (path == null) {
+ return "";
+ } else {
+ return sbi.getRootstrapPath(targetID);
+ }
+ } catch (SBIException e) {
+ e.printStackTrace();
+ return "/";
+ }
+ }
+
+ public static void setIncludePaths(IConfiguration config, Tool tool, List<String> includePaths) {
+ String tool_id = tool.getBaseId();
+ String option_id = "";
+
+ if (tool_id.contains(GBS_TOOL_ID)) {
+ option_id = GBS_TOOL_INCLUDE_OPTION_ID;
+ } else {
+ return;
+ }
+
+ ITool t = config.getToolsBySuperClassId(tool_id)[0];
+ IOption options = t.getOptionBySuperClassId(option_id);
+ ManagedBuildManager.setOption(config, t, options, includePaths.toArray(new String[0]));
+ }
+
+ public static void setIncludePaths(IConfiguration config, List<String> includePaths) {
+ String tool_id = GBS_TOOL_ID;
+ String option_id = GBS_TOOL_INCLUDE_OPTION_ID;
+
+ ITool t = config.getToolsBySuperClassId(tool_id)[0];
+ IOption options = t.getOptionBySuperClassId(option_id);
+ if (includePaths != null && !includePaths.isEmpty()) {
+ ManagedBuildManager.setOption(config, t, options, includePaths.toArray(new String[0]));
+ }
+ }
}
--- /dev/null
+/*
+ * NativeApp
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.build;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
+import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.internal.core.FolderInfo;
+import org.eclipse.cdt.managedbuilder.internal.core.Tool;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tizen.nativecommon.build.RebuildResourcesManager;
+import org.tizen.nativecommon.build.SmartBuildInterface;
+
+@SuppressWarnings("restriction")
+public class PlatformIncludePathOptionValueHandler implements IManagedOptionValueHandler {
+
+ private Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ @Override
+ public boolean handleValue(IBuildObject configuration, IHoldsOptions holder, IOption option,
+ String extraArgument, int event) {
+
+ if (event != IManagedOptionValueHandler.EVENT_OPEN
+ && event != IManagedOptionValueHandler.EVENT_APPLY
+ && event != IManagedOptionValueHandler.EVENT_SETDEFAULT) {
+ return false;
+ }
+
+ if (configuration instanceof FolderInfo) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public boolean isDefaultValue(IBuildObject arg0, IHoldsOptions arg1, IOption arg2, String arg3) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isEnumValueAppropriate(IBuildObject arg0, IHoldsOptions arg1, IOption arg2,
+ String arg3, String arg4) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+}
}
@Override
- public void buildPackage(String pkgType, boolean signApp)
+ public void buildPackage(String pkgType, boolean signApp, boolean isLaunchMode)
throws SBIException, CoreException {
buildPackage(pkgType);
}
+++ /dev/null
-/*
- * Native Platform
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Donghyuk Yang <donghyuk.yang@samsung.com>
- * DongHee Yang <donghee.yang@samsung.com>
- * Kangho Kim <kh5325.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.nativeplatform.build;
-
-import java.util.ArrayList;
-
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.tizen.nativecommon.build.CommonProjectDependentPackager;
-import org.tizen.nativecommon.build.ProjectTypeManager;
-import org.tizen.nativecommon.build.SmartBuildInterface;
-import org.tizen.nativecommon.build.exception.SBIException;
-import org.tizen.nativeplatform.launch.wizards.PlatformLaunchUtils;
-import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
-import org.tizen.nativeplatform.repository.RepoManager;
-import org.tizen.nativeplatform.rootstrap.RootstrapManager;
-import org.tizen.nativeplatform.views.model.PlatformRootstrap;
-
-public class PlatformProjectPackaging {
- public static boolean RPMPackaging(final IProject targetProj, IConfiguration config, IProgressMonitor monitor) {
- String PKGTYPE = "RPM";
- boolean result = false;
- int totalWorks = 2;
-
- CommonProjectDependentPackager packager = ProjectTypeManager.getProjectPackagerInstance(targetProj);
- SmartBuildInterface sbi = SmartBuildInterface.getInstance(targetProj);
- String targetId = PlatformConfigurationManager.getBuildTargetName(config);
- String rootId = sbi.getRootstrapIDFromTargetID(targetId);
- PlatformRootstrap rootstrap = RootstrapManager.getRootstrap(rootId);
-
- boolean initialized = rootstrap.isInitialized();
-
- if (!initialized) {
- totalWorks = 4;
- }
-
- monitor.beginTask("Packaging...", totalWorks);
-
- PlatformCheckCancelJob cancelJob = new PlatformCheckCancelJob(monitor, targetProj, packager.getSbi());
- Thread checkCancelThread = new Thread(cancelJob);
- checkCancelThread.start();
-
- try {
- monitor.subTask("Packaging " + targetProj.getName());
- packager.buildPackage(PKGTYPE);
- } catch (SBIException e) {
- e.printStackTrace();
- cancelJob.setFinishFlag(true);
- monitor.done();
- return false;
- } catch (CoreException e) {
- cancelJob.setFinishFlag(true);
- monitor.done();
- return false;
- }
- monitor.worked(1);
- cancelJob.setFinishFlag(true);
-
- monitor.subTask("Refreshing project...");
- PlatformLaunchUtils launchUtils = new PlatformLaunchUtils();
- ArrayList<LocalPackage> pkgfiles = launchUtils.getProjectPackages(targetProj, config.getName());
-
- try {
- targetProj.refreshLocal(IResource.DEPTH_INFINITE, null );
- } catch (CoreException e) {
- e.printStackTrace();
- }
- monitor.worked(2);
-
- result = !pkgfiles.isEmpty();
-
- if (result && !initialized) {
- monitor.subTask("Reset repositories...");
- RepoManager.resetReposToRootstrap(rootstrap);
- monitor.worked(3);
- monitor.subTask("Refreshing rootstraps...");
- rootstrap.setInitialized(true);
- RootstrapManager.modifyRootstrap(rootstrap);
- monitor.worked(4);
- }
-
- monitor.done();
- return result;
- }
-}
--- /dev/null
+package org.tizen.nativeplatform.filefilter;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+public class XmlFileFilter implements FilenameFilter{
+
+ final String XML_EXT = ".xml";
+
+ @Override
+ public boolean accept(File dir, String name) {
+ boolean isAccept = false;
+
+ if (name.toLowerCase().endsWith(XML_EXT)) {
+ isAccept = true;
+ }
+
+ return isAccept;
+ }
+}
package org.tizen.nativeplatform.launch;
+import static org.tizen.sdblib.util.DeviceUtil.isOnline;
+
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.tizen.nativecommon.launch.TizenUIThreadForConfirmMessage;
import org.tizen.nativeplatform.Activator;
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.pkg.commander.IPackager;
+import org.tizen.nativeplatform.pkg.commander.IPkgCommander;
+import org.tizen.nativeplatform.pkg.commander.PackagerFactory;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
+import org.tizen.nativeplatform.rootstrap.RootstrapManager;
+import org.tizen.nativeplatform.util.PlatformProjectUtil;
+import org.tizen.nativeplatform.views.model.PlatformRootstrap;
+import org.tizen.sdblib.Arch;
import org.tizen.sdblib.IDevice;
-import org.tizen.sdblib.IDevice.Arch;
-import org.tizen.sdblib.SdbCommandRejectedException;
-import org.tizen.sdblib.SdbShellProcess;
-import org.tizen.sdblib.TimeoutException;
+import org.tizen.sdblib.exception.SdbCommandRejectedException;
+import org.tizen.sdblib.exception.TimeoutException;
+import org.tizen.sdblib.util.SdbShellProcess;
@SuppressWarnings("restriction")
-public class TizenDebianLaunchDelegate extends AbstractCLaunchDelegate {
+public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
protected IConfiguration selectedConfig;
protected IDevice currentDevice;
+ protected PlatformRootstrap rootstrap;
+ protected PkgCommandTarget target = null;
protected SdbShellProcess serverProc = null;
protected String executeResult = "";
protected int localDebugPort = -1;
protected ICDISession debugSession;
protected static final int defaultTimeOut = 60000;
protected Shell shell;
- private boolean result;
+ private boolean result;
protected TizenLaunchCommand tizenCommand = null;
protected String getPluginID() {
return Activator.PLUGIN_ID;
}
- public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
- shell = LaunchUIPlugin.getShell();
+ public void launch(ILaunchConfiguration config, String mode, ILaunch launch,
+ IProgressMonitor monitor) throws CoreException {
+ shell = LaunchUIPlugin.getShell();
if (monitor == null)
monitor = new NullProgressMonitor();
try {
monitor.beginTask(TizenLaunchMessages.LAUNCH_APPLICATION, 20);
- monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION);
+ monitor.subTask(TizenLaunchMessages.LAUNCH_APPLICATION);
- tizenCommand = new TizenLaunchCommand(currentDevice, null);
+ tizenCommand = new TizenLaunchCommand(currentDevice, null);
activateProgressView();
- verifyDeviceReachability(getProject(config), new SubProgressMonitor(monitor, 8));
+ verifyDeviceReachability();
+ setRootstrap(config);
+ setPkgCommandTarget();
verifyBuildConfiguration(config, mode, new SubProgressMonitor(monitor, 1));
-
- if (!fromShortcut(config)) {
- setConfigIfNotFromShortcut(config, mode, new SubProgressMonitor(monitor, 1));
- }
- if (mode.equals(ILaunchManager.DEBUG_MODE)) {
+ if (needsSetConfiguration(config)) {
+ setConfiguration(config, mode, new SubProgressMonitor(monitor, 1));
+ }
+
+ if (mode.equals(ILaunchManager.DEBUG_MODE)) {
setDebugConfigAttributes(config);
- verifyTizenDebianProjectSettings(config);
+ verifyPlatformProjectSettings(config);
setDefaultSourceLocator(launch, config);
IBinaryObject exeFile = getBinaryObject(config);
- launchApplicationForDebug(launch, config, exeFile, new SubProgressMonitor(monitor, 10));
+ launchApplicationForDebug(launch, config, exeFile, new SubProgressMonitor(monitor,
+ 10));
} else {
launchApplicationForRun(config, launch, new SubProgressMonitor(monitor, 10));
}
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
launchManager.removeLaunch(launch);
}
- monitor.done();
+ monitor.done();
if (serverProc != null) {
- serverProc.destroy();
+ serverProc.destroy();
}
}
}
-
- protected void setConfigIfNotFromShortcut(ILaunchConfiguration config, String mode, IProgressMonitor monitor)
- throws CoreException {
- installPackages(config, mode, monitor);
+
+ protected void setConfiguration(ILaunchConfiguration config, String mode,
+ IProgressMonitor monitor)
+ // protected void setConfigIfNotFromShortcut(ILaunchConfiguration config,
+ // String mode, IProgressMonitor monitor)
+ throws CoreException {
+ installPackages(config, mode, monitor);
}
-
+
private boolean fromShortcut(ILaunchConfiguration config) {
- boolean result = false;
- try {
- ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
- result = wc.getAttribute(ITizenLaunchConfigurationConstants.ATTR_FROM_SHORTCUT, false);
- if (result) {
- wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_FROM_SHORTCUT, !result);
- wc.doSave();
- }
- } catch (CoreException e) {
- e.printStackTrace();
- }
- return result;
- }
-
- protected void processPostDebug(ILaunchConfiguration config)
- throws CoreException {
+ boolean result = false;
+ try {
+ ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
+ result = wc.getAttribute(ITizenLaunchConfigurationConstants.ATTR_FROM_SHORTCUT, false);
+ if (result) {
+ wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_FROM_SHORTCUT, !result);
+ wc.doSave();
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+ protected void processPostDebug(ILaunchConfiguration config) throws CoreException {
if (debugSession != null) {
Process process;
- try {
- process = debugSession.getSessionProcess();
- } catch (CDIException e) {
- e.printStackTrace();
- process = null;
- }
+ try {
+ process = debugSession.getSessionProcess();
+ } catch (CDIException e) {
+ e.printStackTrace();
+ process = null;
+ }
if (process != null) {
- try {
- process.waitFor();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
+ try {
+ process.waitFor();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
}
}
ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
- String gdbserverPort = wc.getAttribute(TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT, TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT);
+ String gdbserverPort = wc.getAttribute(
+ TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT,
+ TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT);
if (localDebugPort != -1) {
- try {
- currentDevice.removeForward(localDebugPort, Integer.parseInt(gdbserverPort));
- } catch (NumberFormatException e) {
- e.printStackTrace();
- } catch (TimeoutException e) {
- e.printStackTrace();
- } catch (SdbCommandRejectedException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
+ try {
+ currentDevice.removeForward(localDebugPort, Integer.parseInt(gdbserverPort));
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ } catch (TimeoutException e) {
+ e.printStackTrace();
+ } catch (SdbCommandRejectedException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
}
}
-
- protected boolean packagingProject(IProject targetProj, IConfiguration config, IProgressMonitor monitor) {
- boolean packagingResult = false;
-
- packagingResult = PlatformProjectPackaging.RPMPackaging(targetProj, config, monitor);
-
- if (packagingResult) {
- DialogUtil.openMessageDialog(shell, CommonBuildMessages.BUILD_RESULT,
- CommonBuildMessages.SUCCESS_TO_BUILD_PACKAGE);
- } else {
- DialogUtil.openErrorDialog(shell, CommonBuildMessages.BUILD_RESULT,
- CommonBuildMessages.FAIL_TO_BUILD_PACKAGE);
- }
-
+
+ protected boolean packagingProject(IProject targetProj, IConfiguration config,
+ IProgressMonitor monitor) {
+ boolean packagingResult = false;
+ IPackager packager = PackagerFactory.getPackager(targetProj, config);
+ packagingResult = packager.packaging(monitor);
+
+ if (packagingResult) {
+ DialogUtil.openMessageDialog(shell, CommonBuildMessages.BUILD_RESULT,
+ CommonBuildMessages.SUCCESS_TO_BUILD_PACKAGE);
+ } else {
+ DialogUtil.openErrorDialog(shell, CommonBuildMessages.BUILD_RESULT,
+ CommonBuildMessages.FAIL_TO_BUILD_PACKAGE);
+ }
+
return packagingResult;
}
-
- protected void installPackages(ILaunchConfiguration config, String mode, IProgressMonitor monitor) throws CoreException {
- IProject platformProject = getProject(config);
- IProject appProject = null;
- final PlatformLaunchUtils launchUtils = new PlatformLaunchUtils();
-
- boolean reinstallOp = config.getAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, true);
- boolean selectPkgOp = config.getAttribute(ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, true);
- String appProjectName = config.getAttribute(ITizenLaunchConfigurationConstants.ATTR_APP_PROJECT_NAME, "");
- @SuppressWarnings("unchecked")
- ArrayList<String> extraPkgs =
- (ArrayList<String>) config.getAttribute(ITizenLaunchConfigurationConstants.ATTR_EXTRA_PACKAGE_LIST, new ArrayList<String>());
-
- ArrayList<LocalPackage> appPkgs = null;
- ArrayList<LocalPackage> packages = new ArrayList<LocalPackage>();
-
- String buildConfigName = getBuildConfigName(config);
- IConfiguration buildConfig = getBuildConfiguration(buildConfigName, platformProject);
- String targetID = PlatformConfigurationManager.getBuildTargetName(buildConfig);
- String rootstrapId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetID);
-
- final ArrayList<LocalPackage> 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);
-
- if (!appProjectName.isEmpty()) {
- appProject = launchUtils.getProjectInstance(appProjectName);
- appPkgs = launchUtils.getProjectPackages(appProject, buildConfigName);
-
- if (appPkgs.isEmpty()) {
- 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(TizenDebianLaunchMessages.QUESTION_CONTINUE)) {
- newCoreException(TizenDebianLaunchMessages.CANCELED_LAUNCH, null);
- }
- }
- }
- }
-
- packages.addAll(appPkgs);
- }
-
- if (!extraPkgs.isEmpty()) {
- packages.addAll(launchUtils.getLocalPackages(extraPkgs));
- }
- String path = "";
- try {
- path = SmartBuildInterface.getInstance().getRootstrapPath(targetID);
- } catch (SBIException e) {
- newCoreException(TizenDebianLaunchMessages.CANNOT_FIND_HOST_ROOTSTRAP_PATH, e);
+ protected void installPackages(ILaunchConfiguration config, String mode,
+ IProgressMonitor monitor) throws CoreException {
+ IProject platformProject = getProject(config);
+ IProject appProject = null;
+ final PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(target);
+
+ boolean reinstallOp = config.getAttribute(
+ ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, true);
+ boolean selectPkgOp = config.getAttribute(
+ ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, true);
+ String appProjectName = config.getAttribute(
+ ITizenLaunchConfigurationConstants.ATTR_APP_PROJECT_NAME, "");
+ @SuppressWarnings("unchecked")
+ List<String> extraPkgs = (ArrayList<String>) config
+ .getAttribute(ITizenLaunchConfigurationConstants.ATTR_EXTRA_PACKAGE_LIST,
+ new ArrayList<String>());
+
+ List<LocalPackage> appPkgs = null;
+ List<LocalPackage> packages = new ArrayList<LocalPackage>();
+
+ String buildConfigName = getBuildConfigName(config);
+ IConfiguration buildConfig = getBuildConfiguration(buildConfigName, platformProject);
+ final List<LocalPackage> platformPkgs = launchUtils.getProjectPackages(platformProject,
+ buildConfigName);
+ if (platformPkgs.isEmpty()) {
+ String msg = String.format(PlatformLaunchMessages.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(PlatformLaunchMessages.QUESTION_CONTINUE)) {
+ newCoreException(PlatformLaunchMessages.CANCELED_LAUNCH, null);
+ }
+ }
+ }
+ }
+
+ packages.addAll(platformPkgs);
+
+ if (!appProjectName.isEmpty()) {
+ appProject = launchUtils.getProjectInstance(appProjectName);
+ appPkgs = launchUtils.getProjectPackages(appProject, buildConfigName);
+
+ if (appPkgs.isEmpty()) {
+ String msg = String.format(PlatformLaunchMessages.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(PlatformLaunchMessages.QUESTION_CONTINUE)) {
+ newCoreException(PlatformLaunchMessages.CANCELED_LAUNCH, null);
+ }
+ }
+ }
+ }
+
+ packages.addAll(appPkgs);
+ }
+
+ if (!extraPkgs.isEmpty()) {
+ packages.addAll(launchUtils.getLocalPackages(extraPkgs));
}
-
- final String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(path);
-
- final ArrayList<LocalPackage> BuildSystemPkgs = new ArrayList<LocalPackage>();
- final ArrayList<LocalPackage> DevicePkgs = new ArrayList<LocalPackage>();
-
+
+ final List<LocalPackage> BuildSystemPkgs = new ArrayList<LocalPackage>();
+ final List<LocalPackage> DevicePkgs = new ArrayList<LocalPackage>();
+
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
- if (!launchUtils.validateRootstrap(rootstrapId)) {
- String msg = String.format(TizenDebianLaunchMessages.IS_NOT_INITIALIZED_ROOTSTRAP,
- rootstrapId);
- newCoreException(msg, null);
- }
- launchUtils.filterBuildsystemPkgs(packages, BuildSystemPkgs, rootstrapPath, reinstallOp);
+ if (!launchUtils.validateRootstrap(rootstrap.getId())) {
+ String msg = String.format(PlatformLaunchMessages.IS_NOT_INITIALIZED_ROOTSTRAP,
+ rootstrap.getId());
+ newCoreException(msg, null);
+ }
+ launchUtils.filterBuildsystemPkgs(packages, BuildSystemPkgs, reinstallOp);
}
- launchUtils.filterDevicePackages(packages, DevicePkgs, currentDevice, reinstallOp);
-
- try {
- monitor.beginTask(TizenDebianLaunchMessages.INSTALL_PACKAGE, 4);
- monitor.subTask(TizenDebianLaunchMessages.CHECK_PKG_STATUS);
-
- if (selectPkgOp) {
- if (!openPkgStatusDialog(BuildSystemPkgs, DevicePkgs)) {
- newCoreException(TizenDebianLaunchMessages.CANCELED_LAUNCH, null);
- }
- }
-
- ArrayList<LocalPackage> selecteBsPkgs = launchUtils.getSelectedPackages(BuildSystemPkgs);
- ArrayList<LocalPackage> selecteDvPkgs = launchUtils.getSelectedPackages(DevicePkgs);
-
- 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);
- if (selecteDvPkgs != null && !selecteDvPkgs.isEmpty()) {
- launchUtils.installPkgsToDevice(selecteDvPkgs, currentDevice, new SubProgressMonitor(monitor, 1));
- }
-
- monitor.done();
- } catch (InterruptedException e) {
- // This exception is occurred if device is not root on or failed to install
- newCoreException(TizenDebianLaunchMessages.FAILED_INSTALL_PKGS, e);
- }
- }
-
- protected void verifyTizenDebianProjectSettings(ILaunchConfiguration config) throws CoreException {
- String appPath = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
+ launchUtils.filterDevicePackages(packages, DevicePkgs, reinstallOp);
+
+ try {
+ monitor.beginTask(PlatformLaunchMessages.INSTALL_PACKAGE, 4);
+ monitor.subTask(PlatformLaunchMessages.CHECK_PKG_STATUS);
+
+ if (selectPkgOp) {
+ if (!openPkgStatusDialog(BuildSystemPkgs, DevicePkgs)) {
+ newCoreException(PlatformLaunchMessages.CANCELED_LAUNCH, null);
+ }
+ }
+
+ List<LocalPackage> selecteBsPkgs = launchUtils.getSelectedPackages(BuildSystemPkgs);
+ List<LocalPackage> selecteDvPkgs = launchUtils.getSelectedPackages(DevicePkgs);
+
+ monitor.worked(1);
+ monitor.subTask(PlatformLaunchMessages.INSTALL_PACKAGES_TO_BUILDSYSTEM);
+ if (selecteBsPkgs != null && !selecteBsPkgs.isEmpty()) {
+ launchUtils.installPkgsToRootstrap(selecteBsPkgs, monitor);
+ }
+
+ monitor.subTask(PlatformLaunchMessages.INSTALL_PACKAGES_TO_DEVICE);
+ if (selecteDvPkgs != null && !selecteDvPkgs.isEmpty()) {
+ if (PlatformProjectUtil.isEFLApplication(platformProject)) {
+ launchUtils.installPkgsToDevice(selecteDvPkgs, IPkgCommander.TOOL.PKGCMD,
+ monitor);
+ } else {
+ launchUtils.installPkgsToDevice(selecteDvPkgs, monitor);
+ }
+ }
+
+ monitor.done();
+ } catch (InterruptedException e) {
+ // This exception is occurred if device is not root on or failed to
+ // install
+ newCoreException(PlatformLaunchMessages.FAILED_INSTALL_PKGS, e);
+ }
+ }
+
+ protected void verifyPlatformProjectSettings(ILaunchConfiguration config) throws CoreException {
+ String appPath = config
+ .getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
IPath hostPath = getHostPath(appPath, config);
if (hostPath != null) {
if (hostPath.toFile().exists())
return;
else
- newCoreException(TizenDebianLaunchMessages.CANNOT_FIND_EXECUTABLE_IN_A_HOST_ROOTSTRAP, null);
+ newCoreException(PlatformLaunchMessages.CANNOT_FIND_EXECUTABLE_IN_A_HOST_ROOTSTRAP,
+ null);
} else {
- newCoreException(TizenDebianLaunchMessages.CANNOT_FIND_EXECUTABLE_IN_A_HOST_ROOTSTRAP, null);
+ newCoreException(PlatformLaunchMessages.CANNOT_FIND_EXECUTABLE_IN_A_HOST_ROOTSTRAP,
+ null);
}
}
-
- protected void verifyBuildConfiguration(ILaunchConfiguration config, String mode, IProgressMonitor monitor) throws CoreException {
-
- monitor.beginTask("Verifying build configuration", 2);
+
+ protected void verifyBuildConfiguration(ILaunchConfiguration config, String mode,
+ IProgressMonitor monitor) throws CoreException {
+
+ monitor.beginTask("Verifying build configuration", 2);
monitor.subTask(TizenLaunchMessages.PREPARE_TO_LAUNCH);
-
+
// FIXME : Match by deviceType, not buildTargetArchitecture.
IProject project = getProject(config);
String buildConfigName = getBuildConfigName(config);
-
+
IConfiguration configuration = getBuildConfiguration(buildConfigName, project);
- //String buildTargetArchitecture = SLPConfigurationManager.getArchitecture(configuration);
- //String buildTargetArchitecture = CommonConfigurationOld.getArchitecture(configuration);
String buildTargetArchitecture = CommonConfigurationManager.getArchitecture(configuration);
- if (currentDevice.isEmulator() && currentDevice.getArch() == Arch.X86) {
- if(!PlatformConfigurationManager.isEmulatorArch(buildTargetArchitecture))
+ if (currentDevice.getArch() == Arch.X86 || currentDevice.getArch().equals("X86")) {
+ if (!PlatformConfigurationManager.isEmulatorArch(buildTargetArchitecture))
resolveProblematicConfiguration(config, "i386");
- } else {
- if(!PlatformConfigurationManager.isDeviceArch(buildTargetArchitecture))
+ } else {
+ if (!PlatformConfigurationManager.isDeviceArch(buildTargetArchitecture))
+ resolveProblematicConfiguration(config, "armel");
+ }
+ /*
+ if (currentDevice.isEmulator() &&
+ (currentDevice.getArch() == Arch.X86 || currentDevice.getArch().equals("X86"))) {
+ if (!PlatformConfigurationManager.isEmulatorArch(buildTargetArchitecture))
+ resolveProblematicConfiguration(config, "i386");
+ } else {
+ if (!PlatformConfigurationManager.isDeviceArch(buildTargetArchitecture))
resolveProblematicConfiguration(config, "armel");
}
+ */
monitor.done();
}
- protected void resolveProblematicConfiguration(ILaunchConfiguration config, final String arch) throws CoreException {
+ protected void resolveProblematicConfiguration(ILaunchConfiguration config, final String arch)
+ throws CoreException {
final IProject project = getProject(config);
Display.getDefault().syncExec(new Runnable() {
public void run() {
});
if (selectedConfig == null)
- newCoreException(TizenLaunchMessages.BUILD_CONFIGURATION_DOES_NOT_MATCH_WITH_CURRENT_DEVICE_TYPE, null);
-
+ newCoreException(
+ TizenLaunchMessages.BUILD_CONFIGURATION_DOES_NOT_MATCH_WITH_CURRENT_DEVICE_TYPE,
+ null);
+
ICProjectDescription projDes = CDTPropertyManager.getProjectDescription(project);
ICConfigurationDescription cDesc = projDes.getConfigurationByName(selectedConfig.getName());
ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, cDesc.getConfiguration().getId());
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, cDesc
+ .getConfiguration().getId());
wc.doSave();
}
protected IConfiguration selectBuildConfiguration(IProject project, String arch) {
- Shell shell = LaunchUIPlugin.getShell();
+ Shell shell = LaunchUIPlugin.getShell();
ILabelProvider topprovider = new LabelProvider() {
public String getText(Object element) {
- IConfiguration buildConfig = (IConfiguration)element;
+ IConfiguration buildConfig = (IConfiguration) element;
return buildConfig.getName();
}
};
-
+
ILabelProvider downprovider = new LabelProvider() {
public String getText(Object element) {
- IConfiguration buildConfig = (IConfiguration)element;
+ IConfiguration buildConfig = (IConfiguration) element;
return buildConfig.getName();
}
};
-
+
TwoPaneElementSelector dlg = new TwoPaneElementSelector(shell, topprovider, downprovider);
dlg.setTitle("Select a new build configuration"); //$NON-NLS-1$
dlg.setMessage("Build configuration doesn't match with current active device.\nSelect a new build configuration to launch"); //$NON-NLS-1$
-
- IConfiguration[] configurations = ManagedBuildManager.getBuildInfo(project).getManagedProject().getConfigurations();
+
+ IConfiguration[] configurations = ManagedBuildManager.getBuildInfo(project)
+ .getManagedProject().getConfigurations();
List<IConfiguration> adaptableConfigs = new ArrayList<IConfiguration>(0);
- for(IConfiguration c : configurations) {
- //String buildTargetArchitecture = SLPConfigurationManager.getArchitecture(c);
- //String buildTargetArchitecture = CommonConfigurationOld.getArchitecture(c);
- String buildTargetArchitecture = CommonConfigurationManager.getArchitecture(c);
+ for (IConfiguration c : configurations) {
+ // String buildTargetArchitecture =
+ // SLPConfigurationManager.getArchitecture(c);
+ // String buildTargetArchitecture =
+ // CommonConfigurationOld.getArchitecture(c);
+ String buildTargetArchitecture = CommonConfigurationManager.getArchitecture(c);
if (buildTargetArchitecture.equals(arch))
adaptableConfigs.add(c);
}
dlg.setElements(adaptableConfigs.toArray());
-
+
if (dlg.open() == Window.OK) {
- IConfiguration selectedConfig = (IConfiguration)dlg.getFirstResult();
+ IConfiguration selectedConfig = (IConfiguration) dlg.getFirstResult();
return selectedConfig;
}
-
+
return null;
}
- protected IConfiguration getBuildConfiguration(String buildConfigName, IProject project) throws CoreException {
+ protected IConfiguration getBuildConfiguration(String buildConfigName, IProject project)
+ throws CoreException {
IConfiguration configuration = null;
- IConfiguration[] configurations = ManagedBuildManager.getBuildInfo(project).getManagedProject().getConfigurations();
+ IConfiguration[] configurations = ManagedBuildManager.getBuildInfo(project)
+ .getManagedProject().getConfigurations();
for (IConfiguration c : configurations) {
- if (c.getName().equals(buildConfigName) ) {
+ if (c.getName().equals(buildConfigName)) {
configuration = c;
break;
}
}
if (configuration == null)
- newCoreException(TizenLaunchMessages.BUILD_CONFIGURATION_DOES_NOT_MATCH_WITH_CURRENT_DEVICE_TYPE, null);
-
+ newCoreException(
+ TizenLaunchMessages.BUILD_CONFIGURATION_DOES_NOT_MATCH_WITH_CURRENT_DEVICE_TYPE,
+ null);
+
return configuration;
}
protected String getBuildConfigName(ILaunchConfiguration config) throws CoreException {
IProject project = getProject(config);
-
- String buildConfigName = config.getAttribute(TizenLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_NAME, "");
-
+
+ String buildConfigName = config.getAttribute(
+ TizenLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_NAME, "");
+
if (buildConfigName.isEmpty()) {
- IConfiguration configuration = ManagedBuildManager.getBuildInfo(project).getDefaultConfiguration();
+ IConfiguration configuration = ManagedBuildManager.getBuildInfo(project)
+ .getDefaultConfiguration();
return configuration.getName();
- } else
- return buildConfigName;
+ } else
+ return buildConfigName;
}
-
- protected boolean resolveProblematicConfiguration(IProject project, IConfiguration problematicConfig, String arch, String mode) {
- TizenUIThreadForConfirmMessage runnable = new TizenUIThreadForConfirmMessage(project, problematicConfig, arch, mode);
+ protected boolean resolveProblematicConfiguration(IProject project,
+ IConfiguration problematicConfig, String arch, String mode) {
+ TizenUIThreadForConfirmMessage runnable = new TizenUIThreadForConfirmMessage(project,
+ problematicConfig, arch, mode);
Display.getDefault().syncExec(runnable);
- if(runnable.getResult()) {
- ManagedBuildManager.getBuildInfo( project ).setDefaultConfiguration(runnable.getSuitableConfigName());
+ if (runnable.getResult()) {
+ ManagedBuildManager.getBuildInfo(project).setDefaultConfiguration(
+ runnable.getSuitableConfigName());
return true;
} else {
return false;
}
}
- protected void verifyDeviceReachability(IProject project, IProgressMonitor monitor) throws CoreException {
- try {
- monitor.beginTask(TizenLaunchMessages.PREPARE_TO_LAUNCH, 2);
- monitor.subTask(TizenLaunchMessages.PREPARE_TO_LAUNCH);
+ protected void setRootstrap(ILaunchConfiguration config) throws CoreException {
+ IProject project = getProject(config);
+ String buildConfigName = getBuildConfigName(config);
+ IConfiguration buildConfig = getBuildConfiguration(buildConfigName, project);
+ String targetID = PlatformConfigurationManager.getBuildTargetName(buildConfig);
+ String rootstrapId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetID);
+ rootstrap = RootstrapManager.getRootstrap(rootstrapId);
+ }
- currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
- if (currentDevice == null) {
- newCoreException(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE, null);
- }
- if (currentDevice.isOffline()) {
- newCoreException(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE, null);
- }
- } finally {
- monitor.done();
+ protected void verifyDeviceReachability() throws CoreException {
+ currentDevice = ConnectionPlugin.getDefault().getCurrentDevice();
+ if (currentDevice == null) {
+ newCoreException(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE, null);
+ }
+ if (!isOnline(currentDevice)) {
+ newCoreException(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE, null);
+ }
+ if (!currentDevice.isRoot()) {
+ newCoreException(PlatformLaunchMessages.DEVICE_IS_NOT_ROOT_ON, null);
}
}
} catch (Exception e) {
newCoreException(TizenLaunchMessages.CANNOT_LAUNCH, e);
} finally {
- monitor.worked(1);
+ monitor.worked(1);
monitor.done();
}
}
- protected void launchApplicationForDebug(ILaunch launch, ILaunchConfiguration config, IBinaryObject exeFile, IProgressMonitor monitor) throws CoreException, OperationCanceledException {
+ 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));
- launchApplicationWithGDBClient(launch, config, exeFile, new SubProgressMonitor(monitor, 1));
+ launchApplicationWithGDBServer(launch, config, new SubProgressMonitor(monitor, 1));
+ launchApplicationWithGDBClient(launch, config, exeFile, new SubProgressMonitor(monitor,
+ 1));
} finally {
monitor.done();
}
}
- protected void launchApplicationWithGDBServer(ILaunch launch, ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException {
-
+ 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);
-
+
IPath path = getHostPath(TizenPlatformConstants.HOST_GDBSERVER_PATH, config);
- PlatformLaunchUtils launchUtils = new PlatformLaunchUtils();
+ PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(target);
launchUtils.readyGdbServer(currentDevice, tizenCommand, path);
String gdbserverRunCommand = getGdbserverRunCommand(config);
String resultCommand = null;
// is gdbserver running now ? then
- resultCommand = String.format(TizenPlatformConstants.PROCESS_GET_PROCESS_ID_COMMAND, gdbserverRunCommand.trim());
+ resultCommand = String.format(TizenPlatformConstants.PROCESS_GET_PROCESS_ID_COMMAND,
+ gdbserverRunCommand.trim());
tizenCommand.run(resultCommand, null);
if (tizenCommand.getEndLine() != null) {
if (StringUtil.isInteger(tizenCommand.getEndLine().trim())) {
- resultCommand = String.format(TizenPlatformConstants.PROCESS_SIGKILL_COMMAND, tizenCommand.getEndLine() + TizenPlatformConstants.CMD_RESULT_CHECK);
+ resultCommand = String.format(TizenPlatformConstants.PROCESS_SIGKILL_COMMAND,
+ tizenCommand.getEndLine() + TizenPlatformConstants.CMD_RESULT_CHECK);
try {
tizenCommand.run(resultCommand, "0");
} catch (CoreException e) {
- newCoreException(TizenLaunchMessages.GDBSERVER_ALREADY_RUNNING, null);
- } catch (Exception e) {
- newCoreException(TizenLaunchMessages.GDBSERVER_ALREADY_RUNNING, null);
+ newCoreException(TizenLaunchMessages.GDBSERVER_ALREADY_RUNNING, null);
+ } catch (Exception e) {
+ newCoreException(TizenLaunchMessages.GDBSERVER_ALREADY_RUNNING, null);
}
}
}
// Run gdbserver as blocking mode!
tizenCommand.run(gdbserverRunCommand, null, true);
} catch (CoreException e) {
- newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER, null);
+ newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER, null);
} catch (Exception e) {
- newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER, null);
+ newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER, null);
} finally {
monitor.done();
}
}
- protected void launchApplicationWithGDBClient(ILaunch launch, ILaunchConfiguration config, IBinaryObject exeFile, IProgressMonitor monitor) throws CoreException {
+ 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);
TizenDebugger debugger = new TizenDebugger();
- debugSession = ((ICDIDebugger2)debugger).createSession(launch,
- getGDBClientArgument(exeFile), new SubProgressMonitor(monitor, 1));
- if(debugSession == null)
+ debugSession = ((ICDIDebugger2) debugger).createSession(launch,
+ getGDBClientArgument(exeFile), new SubProgressMonitor(monitor, 1));
+ if (debugSession == null)
newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBCLIENT, null);
- boolean attrDebuggerStopAtMain = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
+ boolean attrDebuggerStopAtMain = config.getAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
String attrDebuggerStopAtMainSymbol = null;
if (attrDebuggerStopAtMain)
- attrDebuggerStopAtMainSymbol = launch.getLaunchConfiguration().getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT);
+ attrDebuggerStopAtMainSymbol = launch.getLaunchConfiguration().getAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL,
+ ICDTLaunchConfigurationConstants.DEBUGGER_STOP_AT_MAIN_SYMBOL_DEFAULT);
ICDITarget[] targetArray = debugSession.getTargets();
for (int i = 0; i < targetArray.length; i++) {
if (proc != null)
iproc = DebugPlugin.newProcess(launch, proc, exeFile.getName(), null);
IProject project = getProject(config);
- CDIDebugModel.newDebugTarget(launch, project, targetArray[i],
- "Tizen debugger",
+ CDIDebugModel.newDebugTarget(launch, project, targetArray[i], "Tizen debugger",
iproc, exeFile, true, false, attrDebuggerStopAtMainSymbol, true);
}
} catch (DebugException e) {
monitor.done();
}
}
-
- protected String getGdbserverRunCommand(ILaunchConfiguration config)
- throws CoreException, Exception {
-
- String gdbserverPort = config.getAttribute(TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT, TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT);
+
+ protected String getGdbserverRunCommand(ILaunchConfiguration config) throws CoreException,
+ Exception {
+
+ 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;
return command;
- }
+ }
protected void setDebugConfigAttributes(ILaunchConfiguration config) throws CoreException {
ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
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);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
+ wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST,
+ TizenPlatformConstants.LOCALHOST);
+ String gdbserverPort = wc.getAttribute(
+ TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT,
+ TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
+ ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
try {
localDebugPort = getDebugPort();
if (localDebugPort < 0)
String localPort = Integer.valueOf(localDebugPort).toString();
wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, localPort);
wc.doSave();
- } catch (TimeoutException e) {
+ } catch (TimeoutException e) {
newCoreException(TizenLaunchMessages.CANNOT_CREATE_FORWARD, e);
- } catch (SdbCommandRejectedException e) {
+ } catch (SdbCommandRejectedException e) {
newCoreException(TizenLaunchMessages.CANNOT_CREATE_FORWARD, e);
} catch (CoreException e) {
newCoreException(TizenLaunchMessages.CANNOT_CREATE_FORWARD, e);
while ((port < 65535) && !LocalPortChecker.isPortAvailable(port)) {
port += 10;
}
-
+
if (LocalPortChecker.isPortAvailable(port))
return port;
- else
+ else
return -1;
}
}
protected String setArguments(ILaunchConfiguration config) throws CoreException {
- String appPath = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
- String arguments = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "");
- String executableWithArguments= "";
+ String appPath = config
+ .getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
+ String arguments = config.getAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "");
+ String executableWithArguments = "";
if (!arguments.equals(""))
executableWithArguments = appPath + " " + arguments;
else
Display.getDefault().syncExec(new Runnable() {
public void run() {
try {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("org.eclipse.ui.views.ProgressView");
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+ .showView("org.eclipse.ui.views.ProgressView");
} catch (PartInitException e) {
e.printStackTrace();
}
}
});
}
-
+
protected File findFirstFilebyExtension(File searchPath, String ext) {
File[] allFiles = searchPath.listFiles(new ExtFilter(ext));
- if (allFiles == null || allFiles.length == 0)
+ if (allFiles == null || allFiles.length == 0)
return null;
-
+
return allFiles[0];
}
return name.endsWith(ext);
}
}
-
+
protected void newCoreException(String message, Throwable exception) throws CoreException {
Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, message, exception);
throw new CoreException(status);
}
protected void refreshResources(IProject project) throws CoreException {
- if(!project.isSynchronized(IResource.DEPTH_INFINITE))
+ if (!project.isSynchronized(IResource.DEPTH_INFINITE))
project.refreshLocal(IResource.DEPTH_INFINITE, null);
}
protected IBinaryObject getBinaryObject(ILaunchConfiguration config) throws CoreException {
- String appPath = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
+ String appPath = config
+ .getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
IPath hostPath = getHostPath(appPath, config);
IBinaryObject binaryObject = LaunchUtils.getBinary(getProject(config), hostPath);
return binaryObject;
}
protected IProject getProject(ILaunchConfiguration config) throws CoreException {
- String projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
+ String projectName = config.getAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
if (projectName == null || projectName.equals(""))
- newCoreException(TizenDebianLaunchMessages.CANNOT_FIND_PROJECT_NAME, null);
+ newCoreException(PlatformLaunchMessages.CANNOT_FIND_PROJECT_NAME, null);
return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
}
protected IPath getHostPath(String exePath, ILaunchConfiguration config) throws CoreException {
- CommonProjectDependentBuilder builder = ProjectTypeManager.getProjectBuilderInstance(getProject(config));
+ CommonProjectDependentBuilder builder = ProjectTypeManager
+ .getProjectBuilderInstance(getProject(config));
String targetID = builder.getTargetID();
String path = "";
try {
path = SmartBuildInterface.getInstance().getRootstrapPath(targetID);
} catch (SBIException e) {
- newCoreException(TizenDebianLaunchMessages.CANNOT_FIND_HOST_ROOTSTRAP_PATH, e);
+ newCoreException(PlatformLaunchMessages.CANNOT_FIND_HOST_ROOTSTRAP_PATH, e);
}
String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(path);
return new Path(rootstrapPath);
}
-
- protected boolean openPkgStatusDialog(final ArrayList<LocalPackage> BuildSystemPkgs, final ArrayList<LocalPackage> DevicePkgs) {
- SWTUtil.syncExec(new Runnable() {
+
+ protected boolean openPkgStatusDialog(final List<LocalPackage> BuildSystemPkgs,
+ final List<LocalPackage> DevicePkgs) {
+ SWTUtil.syncExec(new Runnable() {
public void run() {
- ShowPackageStatusDialog statusDlg = new ShowPackageStatusDialog(shell, BuildSystemPkgs, DevicePkgs);
- if (Window.OK == statusDlg.open()) {
- result = true;
- } else {
- result = false;
- }
+ ShowPackageStatusDialog statusDlg = new ShowPackageStatusDialog(shell,
+ BuildSystemPkgs, DevicePkgs);
+ if (Window.OK == statusDlg.open()) {
+ result = true;
+ } else {
+ result = false;
+ }
}
});
-
- return result;
- }
-
+
+ return result;
+ }
+
protected File getGDBClientArgument(IBinaryObject exeFile) {
return exeFile.getPath().toFile();
}
+
+ protected boolean needsSetConfiguration(ILaunchConfiguration config) throws CoreException {
+ IProject project = getProject(config);
+ boolean isEflApp = PlatformProjectUtil.isEFLApplication(project);
+ boolean isNotFromShortcut = !fromShortcut(config);
+
+ return (isEflApp | isNotFromShortcut);
+ }
+
+ protected void setPkgCommandTarget() {
+ target = new PkgCommandTarget(currentDevice, rootstrap);
+ }
}
--- /dev/null
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.launch;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.core.IProcessInfo;
+import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+import org.eclipse.cdt.debug.mi.core.IGDBServerMILaunchConfigurationConstants;
+import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.utils.PathUtil;
+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.debug.core.ILaunchManager;
+import org.tizen.common.TizenPlatformConstants;
+import org.tizen.common.util.DialogUtil;
+import org.tizen.common.util.StringUtil;
+import org.tizen.nativecommon.ProjectUtil;
+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;
+import org.tizen.sdblib.exception.SdbCommandRejectedException;
+import org.tizen.sdblib.exception.TimeoutException;
+
+public class PlatformLaunchDelegateForAttach extends PlatformLaunchDelegate {
+
+ protected Integer pid = Integer.valueOf(-1);
+ protected IProcessInfo procInfo = null;
+
+ @Override
+ protected void setDebugConfigAttributes(ILaunchConfiguration config) throws CoreException {
+
+ setSharedlibrarySearchPath(config);
+ 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);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
+ ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH);
+ try {
+ int localDebugPort = getDebugPort();
+ if (localDebugPort < 0)
+ newCoreException(TizenLaunchMessages.CANNOT_CREATE_FORWARD, null);
+ currentDevice.createForward(localDebugPort, Integer.parseInt(gdbserverPort));
+ String localPort = Integer.valueOf(localDebugPort).toString();
+ wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, localPort);
+ wc.doSave();
+ } catch (TimeoutException e) {
+ newCoreException(TizenLaunchMessages.CANNOT_CREATE_FORWARD, e);
+ } catch (SdbCommandRejectedException e) {
+ newCoreException(TizenLaunchMessages.CANNOT_CREATE_FORWARD, e);
+ } catch (CoreException e) {
+ newCoreException(TizenLaunchMessages.CANNOT_CREATE_FORWARD, e);
+ } catch (IOException e) {
+ newCoreException(TizenLaunchMessages.CANNOT_CREATE_FORWARD, e);
+ }
+ }
+
+ private void setSharedlibrarySearchPath(ILaunchConfiguration config) throws CoreException {
+
+ // Attach debugging should add the "Debug" directory to its [Shared
+ // Libraries] path.
+ List<String> values = config.getAttribute(
+ IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, new ArrayList(1));
+ ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
+ IProject proj = ProjectUtil.getProject(config);
+ String appPath = config
+ .getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
+ if (!appPath.isEmpty()) {
+ appPath = new Path(appPath).removeLastSegments(1).toOSString();
+ } else {
+ newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER, null);
+ }
+ IConfiguration buildConfig = ProjectUtil.getDefaultConfiguration(proj);
+ String targetID = "";
+ String rootstrapPath = "";
+ try {
+ targetID = PlatformConfigurationManager.getDefaultBuildTargetName(buildConfig);
+ String path = SmartBuildInterface.getInstance().getRootstrapPath(targetID);
+ rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(path);
+ } catch (SBIException e) {
+ newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER, null);
+ }
+
+ IPath debugProjPath = new Path(rootstrapPath + File.separatorChar + "usr"
+ + File.separatorChar + "lib" + File.separatorChar + "debug" + File.separatorChar
+ + appPath);
+
+ if (canAddLibrarySearchPath(config, debugProjPath)) {
+ values.add(debugProjPath.toOSString());
+ }
+
+ IPath debugBinPath = new Path(rootstrapPath + File.separatorChar + "usr"
+ + File.separatorChar + "lib" + File.separatorChar + "debug" + File.separatorChar
+ + "usr" + File.separatorChar + "bin");
+
+ if (canAddLibrarySearchPath(config, debugBinPath)) {
+ values.add(debugBinPath.toOSString());
+ }
+
+ IPath debugLibPath = new Path(rootstrapPath + File.separatorChar + "usr"
+ + File.separatorChar + "lib" + File.separatorChar + "debug" + File.separatorChar
+ + "usr" + File.separatorChar + "lib");
+
+ if (canAddLibrarySearchPath(config, debugLibPath)) {
+ values.add(debugLibPath.toOSString());
+ }
+
+ // set shared library search path
+ if (values.size() > 0) {
+ wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, values);
+ }
+ wc.doSave();
+ }
+
+ protected boolean canAddLibrarySearchPath(ILaunchConfiguration config, IPath searchPath)
+ throws CoreException {
+ List<String> values = config.getAttribute(
+ IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, Collections.EMPTY_LIST);
+ Iterator it = values.iterator();
+ boolean ret = true;
+
+ while (it.hasNext()) {
+ IPath oldPath = new Path((String) it.next());
+ if (PathUtil.equalPath(oldPath, searchPath)) {
+ ret = false;
+ break;
+ }
+ }
+ return ret;
+ }
+
+ @Override
+ protected void setConfiguration(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);
+
+ IPath path = getHostPath(TizenPlatformConstants.HOST_GDBSERVER_PATH, config);
+ PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(target);
+ launchUtils.readyGdbServer(currentDevice, tizenCommand, path);
+
+ if (pid.equals(Integer.valueOf(-1)) || pid.equals(Integer.valueOf(0))) {
+ newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER
+ + ICDTLaunchConfigurationConstants.ERR_NO_PROCESSID, null);
+ }
+
+ String gdbserverRunCommand = getGdbserverRunCommand(config);
+ String resultCommand = null;
+
+ // is gdbserver running now ? then
+ resultCommand = String.format(TizenPlatformConstants.PROCESS_GET_PROCESS_ID_COMMAND,
+ gdbserverRunCommand.trim());
+ tizenCommand.run(resultCommand, null);
+ if (tizenCommand.getEndLine() != null) {
+ if (StringUtil.isInteger(tizenCommand.getEndLine().trim())) {
+ resultCommand = String.format(TizenPlatformConstants.PROCESS_SIGKILL_COMMAND,
+ tizenCommand.getEndLine() + TizenPlatformConstants.CMD_RESULT_CHECK);
+ try {
+ tizenCommand.run(resultCommand, "0");
+ } catch (CoreException e) {
+ newCoreException(TizenLaunchMessages.GDBSERVER_ALREADY_RUNNING, null);
+ } catch (Exception e) {
+ newCoreException(TizenLaunchMessages.GDBSERVER_ALREADY_RUNNING, null);
+ }
+ }
+ }
+ // Run gdbserver as blocking mode!
+ tizenCommand.run(gdbserverRunCommand, null, true);
+ } catch (CoreException e) {
+ newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER, null);
+ } catch (Exception e) {
+ newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER, null);
+ } finally {
+ monitor.done();
+ }
+ }
+
+ protected String getGdbserverRunCommand(ILaunchConfiguration config) throws CoreException,
+ Exception {
+
+ 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;
+
+ return command;
+ }
+
+ private void setAttachProcess(ILaunchConfiguration config) throws CoreException {
+ final PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(target);
+ 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();
+ }
+
+ protected void installPackages(ILaunchConfiguration config, String mode,
+ IProgressMonitor monitor) throws CoreException {
+ IProject platformProject = getProject(config);
+ final PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(target);
+
+ boolean reinstallOp = config.getAttribute(
+ ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, true);
+ boolean selectPkgOp = config.getAttribute(
+ ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, true);
+
+ List<LocalPackage> packages = new ArrayList<LocalPackage>();
+
+ String buildConfigName = getBuildConfigName(config);
+ IConfiguration buildConfig = getBuildConfiguration(buildConfigName, platformProject);
+ String targetID = PlatformConfigurationManager.getBuildTargetName(buildConfig);
+ String rootstrapId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetID);
+
+ final List<LocalPackage> platformPkgs = launchUtils.getProjectPackages(platformProject,
+ buildConfigName);
+ if (platformPkgs.isEmpty()) {
+ String msg = String.format(PlatformLaunchMessages.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(PlatformLaunchMessages.QUESTION_CONTINUE)) {
+ newCoreException(PlatformLaunchMessages.CANCELED_LAUNCH, null);
+ }
+ }
+ }
+ }
+
+ packages.addAll(platformPkgs);
+
+ final List<LocalPackage> BuildSystemPkgs = new ArrayList<LocalPackage>();
+ final List<LocalPackage> DevicePkgs = new ArrayList<LocalPackage>();
+
+ if (mode.equals(ILaunchManager.DEBUG_MODE)) {
+ if (!launchUtils.validateRootstrap(rootstrapId)) {
+ String msg = String.format(PlatformLaunchMessages.IS_NOT_INITIALIZED_ROOTSTRAP,
+ rootstrapId);
+ newCoreException(msg, null);
+ }
+ // launchUtils.filterBuildsystemPkgs(packages, BuildSystemPkgs,
+ // rootstrapPath, reinstallOp);
+ launchUtils.filterBuildsystemPkgs(packages, BuildSystemPkgs, reinstallOp);
+ }
+
+ try {
+ monitor.beginTask(PlatformLaunchMessages.INSTALL_PACKAGE, 4);
+ monitor.subTask(PlatformLaunchMessages.CHECK_PKG_STATUS);
+
+ if (selectPkgOp) {
+ if (!openPkgStatusDialog(BuildSystemPkgs, DevicePkgs)) {
+ newCoreException(PlatformLaunchMessages.CANCELED_LAUNCH, null);
+ }
+ }
+
+ List<LocalPackage> selectedBsPkgs = launchUtils.getSelectedPackages(BuildSystemPkgs);
+
+ monitor.worked(1);
+ monitor.subTask(PlatformLaunchMessages.INSTALL_PACKAGES_TO_BUILDSYSTEM);
+ if (selectedBsPkgs != null && !selectedBsPkgs.isEmpty()) {
+ // launchUtils.installPkgsToRootstrap(selectedBsPkgs,
+ // rootstrapPath, new SubProgressMonitor(monitor, 1));
+ launchUtils.installPkgsToRootstrap(selectedBsPkgs, monitor);
+ }
+ monitor.subTask(PlatformLaunchMessages.INSTALL_PACKAGES_TO_DEVICE);
+ // Nothing to do for device
+ monitor.done();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ protected File getGDBClientArgument(IBinaryObject exeFile) {
+ // It should be null. If <binary_path> is passed as an gdb argument,
+ // breakpoint address is corrupted.
+ // 1) gdb
+ // 2) target remote :<port>
+ // 3) set solib-search-path <binary_path>
+ return null;
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.launch;
+
+import org.eclipse.osgi.util.NLS;
+
+public class PlatformLaunchMessages extends NLS {
+ static {
+ NLS.initializeMessages(PlatformLaunchMessages.class.getName(), PlatformLaunchMessages.class);
+ }
+ // error messages
+ public static String CANNOT_FIND_PROJECT_NAME;
+ public static String CANNOT_CONNECT_TO_DEVICE;
+ public static String CANNOT_FIND_EXECUTABLE_IN_A_HOST_ROOTSTRAP;
+ public static String CANNOT_CREATE_PACKAGE;
+ public static String CANNOT_TRANSFER_FILE;
+ public static String CANNOT_INSTALL;
+ public static String CANNOT_LAUNCH;
+ public static String CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER;
+ public static String CANNOT_LAUNCH_APPLICATION_WITH_GDBCLIENT;
+ public static String BUILD_CONFIGURATION_DOES_NOT_MATCH_WITH_CURRENT_DEVICE_TYPE;
+ public static String CANNOT_FIND_HOST_ROOTSTRAP_PATH;
+ public static String CANNOT_FIND_DEBIAN_CONTROL_FILE;
+ public static String CANNOT_FIND_PACKAGE_SECTION_IN_CONTROL_FILE;
+ public static String OPERATION_CANCELED;
+ public static String IS_NOT_INITIALIZED_ROOTSTRAP;
+ public static String DEVICE_IS_NOT_ROOT_ON;
+ // non-error messages
+ public static String LAUNCH_APPLICATION;
+ public static String LAUNCH_APPLICATION_WITH_GDBSERVER;
+ public static String LAUNCH_APPLICATION_WITH_GDBCLIENT;
+ public static String PREPARE_TO_LAUNCH;
+ public static String START_DEPLOY_PROCESS;
+ 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;
+}
+++ /dev/null
-/*
- * Native Platform
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Donghyuk Yang <donghyuk.yang@samsung.com>
- * DongHee Yang <donghee.yang@samsung.com>
- * Kangho Kim <kh5325.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.nativeplatform.launch;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.core.IProcessInfo;
-import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
-import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
-import org.eclipse.cdt.debug.mi.core.IGDBServerMILaunchConfigurationConstants;
-import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.utils.PathUtil;
-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.debug.core.ILaunchManager;
-import org.tizen.common.TizenPlatformConstants;
-import org.tizen.common.util.DialogUtil;
-import org.tizen.common.util.StringUtil;
-import org.tizen.nativecommon.ProjectUtil;
-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;
-import org.tizen.sdblib.SdbCommandRejectedException;
-import org.tizen.sdblib.TimeoutException;
-
-public class TizenDebianLaunchDelegateForAttach extends TizenDebianLaunchDelegate {
-
- protected Integer pid = Integer.valueOf(-1);
- protected IProcessInfo procInfo = null;
-
- @Override
- protected void setDebugConfigAttributes(ILaunchConfiguration config) throws CoreException {
-
- setSharedlibrarySearchPath(config);
- 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);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH);
- try {
- int localDebugPort = getDebugPort();
- if (localDebugPort < 0)
- newCoreException(TizenLaunchMessages.CANNOT_CREATE_FORWARD, null);
- currentDevice.createForward(localDebugPort, Integer.parseInt(gdbserverPort));
- String localPort = Integer.valueOf(localDebugPort).toString();
- wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, localPort);
- wc.doSave();
- } catch (TimeoutException e) {
- newCoreException(TizenLaunchMessages.CANNOT_CREATE_FORWARD, e);
- } catch (SdbCommandRejectedException e) {
- newCoreException(TizenLaunchMessages.CANNOT_CREATE_FORWARD, e);
- } catch (CoreException e) {
- newCoreException(TizenLaunchMessages.CANNOT_CREATE_FORWARD, e);
- } catch (IOException e) {
- newCoreException(TizenLaunchMessages.CANNOT_CREATE_FORWARD, e);
- }
- }
-
- private void setSharedlibrarySearchPath(ILaunchConfiguration config) throws CoreException {
-
- // Attach debugging should add the "Debug" directory to its [Shared Libraries] path.
- List<String> values = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, new ArrayList(1));
- ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
- IProject proj = ProjectUtil.getProject(config);
- String appPath = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
- if (!appPath.isEmpty()) {
- appPath = new Path(appPath).removeLastSegments(1).toOSString();
- } else {
- newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER, null);
- }
- IConfiguration buildConfig = ProjectUtil.getDefaultConfiguration(proj);
- String targetID = "";
- String rootstrapPath = "";
- try {
- targetID = PlatformConfigurationManager.getDefaultBuildTargetName(buildConfig);
- String path = SmartBuildInterface.getInstance().getRootstrapPath(targetID);
- rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(path);
- } catch (SBIException e) {
- newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER, null);
- }
-
- IPath debugProjPath = new Path(rootstrapPath + File.separatorChar
- + "usr" + File.separatorChar
- + "lib" + File.separatorChar
- + "debug" + File.separatorChar
- + appPath);
-
- if (canAddLibrarySearchPath(config, debugProjPath)) {
- values.add(debugProjPath.toOSString());
- }
-
- IPath debugBinPath = new Path(rootstrapPath + File.separatorChar
- + "usr" + File.separatorChar
- + "lib" + File.separatorChar
- + "debug" + File.separatorChar
- + "usr" + File.separatorChar
- + "bin");
-
- if (canAddLibrarySearchPath(config, debugBinPath)) {
- values.add(debugBinPath.toOSString());
- }
-
- IPath debugLibPath = new Path(rootstrapPath + File.separatorChar
- + "usr" + File.separatorChar
- + "lib" + File.separatorChar
- + "debug" + File.separatorChar
- + "usr" + File.separatorChar
- + "lib");
-
- if (canAddLibrarySearchPath(config, debugLibPath)) {
- values.add(debugLibPath.toOSString());
- }
-
- // set shared library search path
- if (values.size() > 0) {
- wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, values);
- }
- wc.doSave();
- }
-
- protected boolean canAddLibrarySearchPath(ILaunchConfiguration config, IPath searchPath) throws CoreException {
- List values = config.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, Collections.EMPTY_LIST);
- Iterator it = values.iterator();
- boolean ret = true;
-
- while (it.hasNext()) {
- IPath oldPath = new Path((String) it.next());
- if (PathUtil.equalPath(oldPath, searchPath)) {
- ret = false;
- break;
- }
- }
- return ret;
- }
-
-
- @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);
-
- IPath path = getHostPath(TizenPlatformConstants.HOST_GDBSERVER_PATH, config);
- PlatformLaunchUtils launchUtils = new PlatformLaunchUtils();
- launchUtils.readyGdbServer(currentDevice, tizenCommand, path);
-
- if (pid.equals(Integer.valueOf(-1)) || pid.equals(Integer.valueOf(0))) {
- newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER + ICDTLaunchConfigurationConstants.ERR_NO_PROCESSID, null);
- }
-
- String gdbserverRunCommand = getGdbserverRunCommand(config);
- String resultCommand = null;
-
- // is gdbserver running now ? then
- resultCommand = String.format(TizenPlatformConstants.PROCESS_GET_PROCESS_ID_COMMAND, gdbserverRunCommand.trim());
- tizenCommand.run(resultCommand, null);
- if (tizenCommand.getEndLine() != null) {
- if (StringUtil.isInteger(tizenCommand.getEndLine().trim())) {
- resultCommand = String.format(TizenPlatformConstants.PROCESS_SIGKILL_COMMAND, tizenCommand.getEndLine() + TizenPlatformConstants.CMD_RESULT_CHECK);
- try {
- tizenCommand.run(resultCommand, "0");
- } catch (CoreException e) {
- newCoreException(TizenLaunchMessages.GDBSERVER_ALREADY_RUNNING, null);
- } catch (Exception e) {
- newCoreException(TizenLaunchMessages.GDBSERVER_ALREADY_RUNNING, null);
- }
- }
- }
- // Run gdbserver as blocking mode!
- tizenCommand.run(gdbserverRunCommand, null, true);
- } catch (CoreException e) {
- newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER, null);
- } catch (Exception e) {
- newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER, null);
- } finally {
- monitor.done();
- }
- }
-
- protected String getGdbserverRunCommand(ILaunchConfiguration config)
- throws CoreException, Exception {
-
- 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;
-
- return command;
- }
-
- 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();
- }
-
- 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<LocalPackage> packages = new ArrayList<LocalPackage>();
-
- String buildConfigName = getBuildConfigName(config);
- IConfiguration buildConfig = getBuildConfiguration(buildConfigName, platformProject);
- String targetID = PlatformConfigurationManager.getBuildTargetName(buildConfig);
- String rootstrapId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetID);
-
- final ArrayList<LocalPackage> 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);
-
- String path = "";
- try {
- path = SmartBuildInterface.getInstance().getRootstrapPath(targetID);
- } catch (SBIException e) {
- newCoreException(TizenDebianLaunchMessages.CANNOT_FIND_HOST_ROOTSTRAP_PATH, e);
- }
-
- final String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(path);
-
- final ArrayList<LocalPackage> BuildSystemPkgs = new ArrayList<LocalPackage>();
- final ArrayList<LocalPackage> DevicePkgs = new ArrayList<LocalPackage>();
-
- if (mode.equals(ILaunchManager.DEBUG_MODE)) {
- if (!launchUtils.validateRootstrap(rootstrapId)) {
- String msg = String.format(TizenDebianLaunchMessages.IS_NOT_INITIALIZED_ROOTSTRAP,
- rootstrapId);
- newCoreException(msg, null);
- }
- launchUtils.filterBuildsystemPkgs(packages, BuildSystemPkgs, rootstrapPath, reinstallOp);
- }
-
- try {
- monitor.beginTask(TizenDebianLaunchMessages.INSTALL_PACKAGE, 4);
- monitor.subTask(TizenDebianLaunchMessages.CHECK_PKG_STATUS);
-
- if (selectPkgOp) {
- if (!openPkgStatusDialog(BuildSystemPkgs, DevicePkgs)) {
- newCoreException(TizenDebianLaunchMessages.CANCELED_LAUNCH, null);
- }
- }
-
- ArrayList<LocalPackage> 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();
- }
- }
-
- @Override
- protected File getGDBClientArgument(IBinaryObject exeFile) {
- // It should be null. If <binary_path> is passed as an gdb argument, breakpoint address is corrupted.
- // 1) gdb
- // 2) target remote :<port>
- // 3) set solib-search-path <binary_path>
- return null;
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Native Platform
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Donghyuk Yang <donghyuk.yang@samsung.com>
- * DongHee Yang <donghee.yang@samsung.com>
- * Kangho Kim <kh5325.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.nativeplatform.launch;
-
-import org.eclipse.osgi.util.NLS;
-
-public class TizenDebianLaunchMessages extends NLS {
- static {
- NLS.initializeMessages(TizenDebianLaunchMessages.class.getName(), TizenDebianLaunchMessages.class);
- }
- // error messages
- public static String CANNOT_FIND_PROJECT_NAME;
- public static String CANNOT_CONNECT_TO_DEVICE;
- public static String CANNOT_FIND_EXECUTABLE_IN_A_HOST_ROOTSTRAP;
- public static String CANNOT_CREATE_PACKAGE;
- public static String CANNOT_TRANSFER_FILE;
- public static String CANNOT_INSTALL;
- public static String CANNOT_LAUNCH;
- public static String CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER;
- public static String CANNOT_LAUNCH_APPLICATION_WITH_GDBCLIENT;
- public static String BUILD_CONFIGURATION_DOES_NOT_MATCH_WITH_CURRENT_DEVICE_TYPE;
- public static String CANNOT_FIND_HOST_ROOTSTRAP_PATH;
- public static String CANNOT_FIND_DEBIAN_CONTROL_FILE;
- public static String CANNOT_FIND_PACKAGE_SECTION_IN_CONTROL_FILE;
- public static String OPERATION_CANCELED;
- public static String IS_NOT_INITIALIZED_ROOTSTRAP;
- public static String DEVICE_IS_NOT_ROOT_ON;
- // non-error messages
- public static String LAUNCH_APPLICATION;
- public static String LAUNCH_APPLICATION_WITH_GDBSERVER;
- public static String LAUNCH_APPLICATION_WITH_GDBCLIENT;
- public static String PREPARE_TO_LAUNCH;
- public static String START_DEPLOY_PROCESS;
- 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;
-}
import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
import org.tizen.nativecommon.launch.ui.TizenDebuggerTab;
-
-public class TizenDebianLaunchConfigurationForAttachTabGroup extends AbstractLaunchConfigurationTabGroup {
- @Override
+public class PlatformLaunchConfigurationForAttachTabGroup extends
+ AbstractLaunchConfigurationTabGroup {
+ @Override
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
- ILaunchConfigurationTab[] tabs = null;
- tabs = new ILaunchConfigurationTab[] { new TizenDebuggerTab(true), new SourceLookupTab() };
- setTabs(tabs);
+ ILaunchConfigurationTab[] tabs = null;
+ tabs = new ILaunchConfigurationTab[] { new TizenDebuggerTab(true), new SourceLookupTab() };
+ setTabs(tabs);
}
}
\ No newline at end of file
import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
import org.tizen.nativecommon.launch.ui.TizenDebuggerForCoreTab;
-
-public class TizenDebianLaunchConfigurationForCoreTabGroup extends AbstractLaunchConfigurationTabGroup {
- @Override
- public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
- ILaunchConfigurationTab[] tabs = null;
- tabs = new ILaunchConfigurationTab[] { new TizenDebuggerForCoreTab(), new SourceLookupTab() };
- setTabs(tabs);
+public class PlatformLaunchConfigurationForCoreTabGroup extends AbstractLaunchConfigurationTabGroup {
+ @Override
+ public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ ILaunchConfigurationTab[] tabs = null;
+ tabs = new ILaunchConfigurationTab[] { new TizenDebuggerForCoreTab(), new SourceLookupTab() };
+ setTabs(tabs);
}
}
\ No newline at end of file
import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
import org.tizen.nativecommon.launch.ui.TizenDebuggerTab;
+public class PlatformLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
+ @Override
+ public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ ILaunchConfigurationTab[] tabs = null;
-public class TizenDebianLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
- @Override
- public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
- ILaunchConfigurationTab[] tabs = null;
+ if (mode.equals("debug"))
+ tabs = new ILaunchConfigurationTab[] { new TizenDebuggerTab(false),
+ new SourceLookupTab() };
+ else
+ tabs = new ILaunchConfigurationTab[] {};
- if (mode.equals("debug"))
- tabs = new ILaunchConfigurationTab[] { new TizenDebuggerTab(false), new SourceLookupTab() };
- else
- tabs = new ILaunchConfigurationTab[] {};
-
- setTabs(tabs);
+ setTabs(tabs);
}
}
\ No newline at end of file
--- /dev/null
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.launch.ui;
+
+import java.util.ArrayList;
+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.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.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+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.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.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+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.nativecommon.launch.TizenLaunchMessages;
+import org.tizen.nativeplatform.launch.ITizenLaunchConfigurationConstants;
+import org.tizen.nativeplatform.launch.wizards.PlatformLaunchUtils;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
+import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.service.FileEntry;
+
+public class PlatformMainAttachTab extends CMainTab {
+
+ private final String BUNDLE_NAME = PlatformMainAttachTab.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<LocalPackage> packages = new ArrayList<LocalPackage>();
+ private String filePath = "";
+ private String selectedFileList = "";
+
+ private PkgCommandTarget target = null;
+
+ public PlatformMainAttachTab() {
+ this(false);
+ target = new PkgCommandTarget();
+ }
+
+ public PlatformMainAttachTab(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(target);
+ 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<ICProject> list = new ArrayList<ICProject>(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, device
+ .getAppInstallPath() + "/");
+ 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<String> pkgs = new ArrayList<String>();
+
+ 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
package org.tizen.nativeplatform.launch.ui;
-public class TizenDebianMainCoreTab extends TizenDebianMainTab {
- public TizenDebianMainCoreTab() {
- super(true);
- }
+public class PlatformMainCoreTab extends PlatformMainTab {
+ public PlatformMainCoreTab() {
+ super(true);
+ }
}
\ No newline at end of file
--- /dev/null
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.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.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.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+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.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.pkg.commander.PkgCommandTarget;
+import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
+import org.tizen.nativeplatform.rootstrap.RootstrapManager;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.service.FileEntry;
+
+@SuppressWarnings({ "deprecation", "restriction" })
+public class PlatformMainTab extends CMainTab {
+
+ private final String BUNDLE_NAME = PlatformMainTab.class.getPackage().getName()
+ + ".LaunchTabUIMessages";//$NON-NLS-1$
+ private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Label fProgLabel;
+ private Text fProgText;
+ private Text fAppProjText;
+ private Button fAppProjButton;
+ private Button fReinstallOp;
+ private Button fSelectPkgOp;
+ private TableViewer tableViewer;
+ private boolean fSpecifyCoreFile;
+ private List<LocalPackage> packages = new ArrayList<LocalPackage>();
+ private String filePath = "";
+ private String selectedFileList = "";
+
+ private PkgCommandTarget target = null;
+
+ public PlatformMainTab() {
+ this(false);
+ target = new PkgCommandTarget();
+ }
+
+ public PlatformMainTab(boolean specifyCoreFile) {
+ fSpecifyCoreFile = specifyCoreFile;
+ }
+
+ @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);
+ createAppProjectGroup(comp, 1);
+ createExeFileField(comp, 1);
+ createExtraTableGroup(comp);
+ 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));
+ 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 void createTableGroupComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ // composite.setLayout(new GridLayout(2, false));
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 2;
+ gridLayout.marginWidth = 0;
+ gridLayout.marginHeight = 0;
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ gridData.minimumHeight = 100;
+ gridData.minimumWidth = 300;
+
+ composite.setLayout(gridLayout);
+ composite.setLayoutData(gridData);
+
+ createTableComposite(composite);
+ createTableButtonComposite(composite);
+ }
+
+ private void createTableComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new FillLayout());
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ tableViewer = new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ Table table = tableViewer.getTable();
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ String[] columnNames = new String[] { "File Name" };
+
+ int[] columnWidths = new int[] { 300 };
+ for (int i = 0; i < columnNames.length; i++) {
+ TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
+
+ tableColumn.setText(columnNames[i]);
+ tableColumn.setWidth(columnWidths[i]);
+ tableColumn.setResizable(true);
+ tableColumn.addSelectionListener(new TooltableSelectionAdapter());
+ }
+
+ tableViewer.setLabelProvider(new TableViewerProvider());
+ tableViewer.setContentProvider(new ArrayContentProvider());
+ tableViewer.setInput(RootstrapManager.getRootstraps());
+ tableViewer.getTable().addSelectionListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ });
+
+ table.addListener(SWT.Dispose, tableListener);
+ table.addListener(SWT.KeyDown, tableListener);
+ table.addListener(SWT.MouseMove, tableListener);
+ table.addListener(SWT.MouseHover, tableListener);
+ }
+
+ private void createTableButtonComposite(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 1;
+ gridLayout.marginWidth = 0;
+ gridLayout.marginHeight = 0;
+ composite.setLayout(gridLayout);
+ composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+
+ Button addBt = new Button(composite, SWT.PUSH);
+ Image addIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/add.gif");
+ addBt.setImage(addIcon);
+ addBt.addMouseListener(new MouseListener() {
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ FileDialog fd = new FileDialog(getShell(), SWT.OPEN | SWT.MULTI);
+ fd.setText(resources.getString("File.Dialog.Title.File"));
+ String[] filterExt = { "*.rpm" };
+ fd.setFilterExtensions(filterExt);
+ selectedFileList = fd.open();
+ System.out.println(selectedFileList);
+ PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(target);
+ if (selectedFileList != null) {
+ String[] files = fd.getFileNames();
+ String path = fd.getFilterPath();
+ for (String f : files) {
+ String filePath = new Path(path).append(f).toOSString();
+ LocalPackage p = launchUtils.getLocalPackage(filePath);
+ if (!existsPkg(p)) {
+ packages.add(p);
+ }
+ }
+
+ tableViewer.refresh();
+ updateLaunchConfigurationDialog();
+ }
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ }
+
+ });
+
+ Button removeBt = new Button(composite, SWT.PUSH);
+ Image removeIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/remove.gif");
+ removeBt.setImage(removeIcon);
+ }
+
+ private void createExtraTableGroup(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout projLayout = new GridLayout();
+ projLayout.numColumns = 1;
+ projLayout.marginHeight = 0;
+ projLayout.marginWidth = 0;
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ composite.setLayout(projLayout);
+ composite.setLayoutData(gd);
+
+ createTableTitleComposite(composite);
+ createTableGroupComposite(composite);
+ }
+
+ private boolean existsPkg(LocalPackage pkg) {
+ for (LocalPackage p : packages) {
+ if (pkg.getPath().equals(p.getPath())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void createAppProjectGroup(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);
+
+ fProjLabel = new Label(projComp, SWT.NONE);
+ fProjLabel.setText(resources.getString("Label.App.Project"));
+ gd = new GridData();
+ gd.horizontalSpan = 2;
+ fProjLabel.setLayoutData(gd);
+
+ fAppProjText = new Text(projComp, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ fAppProjText.setLayoutData(gd);
+ fAppProjText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent evt) {
+ // if project changes, invalidate program name cache
+ fPreviouslyCheckedProgram = null;
+
+ updateBuildConfigCombo(""); //$NON-NLS-1$
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ fAppProjButton = createPushButton(projComp, LaunchMessages.Launch_common_Browse_1, null);
+ fAppProjButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent evt) {
+ handleAppProjectButtonSelected();
+ updateLaunchConfigurationDialog();
+ }
+ });
+ }
+
+ protected void handleAppProjectButtonSelected() {
+ String currentProjectName = fProjText.getText();
+ ICProject project = chooseCAppProject(currentProjectName);
+ if (project == null) {
+ return;
+ }
+
+ String projectName = project.getElementName();
+ fAppProjText.setText(projectName);
+ }
+
+ 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<ICProject> list = new ArrayList<ICProject>(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, device
+ .getAppInstallPath() + "/");
+ 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) {
+ updateProgramFromConfig(configuration);
+ updateProjectFromConfig(configuration);
+ updateAppProjectFromConfig(configuration);
+ updateExtraTableFromConfig(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 appProj = fAppProjText.getText().trim();
+ boolean reinstallOp = fReinstallOp.getSelection();
+ boolean selectPkgOp = fSelectPkgOp.getSelection();
+ ArrayList<String> pkgs = new ArrayList<String>();
+
+ for (LocalPackage p : packages) {
+ pkgs.add(p.getPath());
+ }
+
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programPath);
+ config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, name);
+ config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_APP_PROJECT_NAME, appProj);
+ config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_EXTRA_PACKAGE_LIST, pkgs);
+ 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);
+ }
+
+ @Override
+ protected void updateProgramFromConfig(ILaunchConfiguration config) {
+ if (fProgText != null) {
+ String programName = EMPTY_STRING;
+ try {
+
+ programName = config.getAttribute(
+ ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, EMPTY_STRING);
+ } catch (CoreException ce) {
+ LaunchUIPlugin.log(ce);
+ }
+ fProgText.setText(programName);
+ }
+ }
+
+ protected void updateAppProjectFromConfig(ILaunchConfiguration config) {
+ String projectName = EMPTY_STRING;
+ try {
+ projectName = config.getAttribute(
+ ITizenLaunchConfigurationConstants.ATTR_APP_PROJECT_NAME, EMPTY_STRING);
+ } catch (CoreException ce) {
+ LaunchUIPlugin.log(ce);
+ }
+ fAppProjText.setText(projectName);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void updateExtraTableFromConfig(ILaunchConfiguration config) {
+ ArrayList<String> pkgs = null;
+ try {
+ pkgs = (ArrayList<String>) config.getAttribute(
+ ITizenLaunchConfigurationConstants.ATTR_EXTRA_PACKAGE_LIST,
+ new ArrayList<String>());
+ } catch (CoreException ce) {
+ LaunchUIPlugin.log(ce);
+ }
+ PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(target);
+ // packages.addAll(launchUtils.getLocalPackages(pkgs));
+ packages = launchUtils.getLocalPackages(pkgs);
+ tableViewer.setInput(packages);
+ }
+
+ 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);
+ }
+
+ private class TooltableSelectionAdapter extends SelectionAdapter {
+ public void widgetSelected(SelectionEvent e) {
+
+ final int column = tableViewer.getTable().indexOf((TableColumn) e.widget);
+ tableViewer.getTable().setSortColumn((TableColumn) e.widget);
+ if (tableViewer.getTable().getSortDirection() == SWT.DOWN) {
+ tableViewer.getTable().setSortDirection(SWT.UP);
+ } else {
+ tableViewer.getTable().setSortDirection(SWT.DOWN);
+ }
+
+ tableViewer.setSorter(new ViewerSorter() {
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ LocalPackage pkg_1 = (LocalPackage) e1;
+ LocalPackage pkg_2 = (LocalPackage) e2;
+
+ String fileName_1 = new Path(pkg_1.getPath()).lastSegment();
+ String fileName_2 = new Path(pkg_2.getPath()).lastSegment();
+
+ switch (column) {
+ case 1:
+ if (tableViewer.getTable().getSortDirection() == SWT.DOWN) {
+ return fileName_1.compareTo(fileName_2);
+ } else {
+ return fileName_2.compareTo(fileName_1);
+ }
+ default:
+ break;
+ }
+ return fileName_1.compareTo(fileName_2);
+ }
+ });
+
+ }
+ }
+
+ /* selected package table provider */
+ private class TableViewerProvider extends LabelProvider implements ITableLabelProvider {
+ @Override
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ @Override
+ public String getColumnText(Object element, int columnIndex) {
+ if (element instanceof LocalPackage) {
+ LocalPackage pkg = (LocalPackage) element;
+ String file = pkg.getPath();
+ String name = new Path(file).lastSegment();
+
+ switch (columnIndex) {
+ case 0:
+ return name;
+ default:
+ break;
+ }
+ }
+ return null;
+ }
+ }
+
+ Listener tableListener = new Listener() {
+ Shell tip = null;
+ Label label = null;
+
+ public void handleEvent(Event event) {
+ switch (event.type) {
+ case SWT.Dispose:
+ case SWT.KeyDown:
+ case SWT.MouseMove: {
+ if (tip == null) {
+ break;
+ }
+ tip.dispose();
+ tip = null;
+ label = null;
+ break;
+ }
+ case SWT.MouseHover: {
+ TableItem item = tableViewer.getTable().getItem(new Point(event.x, event.y));
+ if (item != null) {
+ if (tip != null && !tip.isDisposed()) {
+ tip.dispose();
+ }
+ tip = new Shell(getShell(), SWT.ON_TOP | SWT.TOOL);
+ tip.setLayout(new FillLayout());
+ label = new Label(tip, SWT.NONE);
+ LocalPackage pkg = (LocalPackage) item.getData();
+
+ label.setForeground(getShell().getDisplay().getSystemColor(
+ SWT.COLOR_INFO_FOREGROUND));
+ label.setBackground(getShell().getDisplay().getSystemColor(
+ SWT.COLOR_INFO_BACKGROUND));
+
+ label.setData("_TABLEITEM", item);
+ label.setText(pkg.getPath());
+ label.addListener(SWT.MouseExit, labelListener);
+ label.addListener(SWT.MouseDown, labelListener);
+ Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ Rectangle rect = item.getBounds(0);
+ Point pt = tableViewer.getTable().toDisplay(rect.x, rect.y);
+ tip.setBounds(pt.x + 50, pt.y + 10, size.x, size.y);
+ tip.setVisible(true);
+ }
+ }
+ default:
+ break;
+ }
+ }
+ };
+
+ // Implement a "fake" tooltip
+ final Listener labelListener = new Listener() {
+ public void handleEvent(Event event) {
+ Label label = (Label) event.widget;
+ Shell shell = label.getShell();
+ switch (event.type) {
+ case SWT.MouseDown:
+ Event e = new Event();
+ e.item = (TableItem) label.getData("_TABLEITEM");
+ // Assuming table is single select, set the selection as if
+ // the mouse down event went through to the table
+ tableViewer.getTable().setSelection(new TableItem[] { (TableItem) e.item });
+ tableViewer.getTable().notifyListeners(SWT.Selection, e);
+ // fall through
+ case SWT.MouseExit:
+ shell.dispose();
+ break;
+ default:
+ break;
+ }
+ }
+ };
+}
\ No newline at end of file
+++ /dev/null
-/*
- * Native Platform
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Donghyuk Yang <donghyuk.yang@samsung.com>
- * DongHee Yang <donghee.yang@samsung.com>
- * Kangho Kim <kh5325.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.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<LocalPackage> packages = new ArrayList<LocalPackage>();
- 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<ICProject> list = new ArrayList<ICProject>(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, device.getAppInstallPath() + "/");
- 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<String> pkgs = new ArrayList<String>();
-
- 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
+++ /dev/null
-/*
- * Native Platform
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Donghyuk Yang <donghyuk.yang@samsung.com>
- * DongHee Yang <donghee.yang@samsung.com>
- * Kangho Kim <kh5325.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.nativeplatform.launch.ui;
-
-import java.util.ArrayList;
-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.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.runtime.CoreException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-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.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.model.LocalPackage;
-import org.tizen.nativeplatform.rootstrap.RootstrapManager;
-
-import org.tizen.sdblib.FileListingService.FileEntry;
-import org.tizen.sdblib.IDevice;
-
-@SuppressWarnings({ "deprecation", "restriction" })
-public class TizenDebianMainTab extends CMainTab {
-
- 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;
- private Button fAppProjButton;
- private Button fReinstallOp;
- private Button fSelectPkgOp;
- private TableViewer tableViewer;
- private boolean fSpecifyCoreFile;
- private ArrayList<LocalPackage> packages = new ArrayList<LocalPackage>();
- private String filePath = "";
- private String selectedFileList = "";
-
- public TizenDebianMainTab() {
- this(false);
- }
-
- public TizenDebianMainTab(boolean specifyCoreFile) {
- fSpecifyCoreFile = specifyCoreFile;
- }
-
- @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);
- createAppProjectGroup(comp, 1);
- createExeFileField(comp, 1);
- createExtraTableGroup(comp);
- 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));
- 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 void createTableGroupComposite(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- //composite.setLayout(new GridLayout(2, false));
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 2;
- gridLayout.marginWidth = 0;
- gridLayout.marginHeight = 0;
- GridData gridData = new GridData(GridData.FILL_BOTH);
- gridData.minimumHeight = 100;
- gridData.minimumWidth = 300;
-
- composite.setLayout(gridLayout);
- composite.setLayoutData(gridData);
-
- createTableComposite(composite);
- createTableButtonComposite(composite);
- }
-
- private void createTableComposite(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new FillLayout());
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- tableViewer = new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- Table table = tableViewer.getTable();
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- String[] columnNames = new String[] {"File Name"};
-
- int[] columnWidths = new int[] {300};
- for (int i = 0; i < columnNames.length ; i++) {
- TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
-
- tableColumn.setText(columnNames[i]);
- tableColumn.setWidth(columnWidths[i]);
- tableColumn.setResizable(true);
- tableColumn.addSelectionListener(new TooltableSelectionAdapter());
- }
-
- tableViewer.setLabelProvider(new TableViewerProvider());
- tableViewer.setContentProvider(new ArrayContentProvider());
- tableViewer.setInput(RootstrapManager.getRootstraps());
- tableViewer.getTable().addSelectionListener(new SelectionListener() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- });
-
- table.addListener(SWT.Dispose, tableListener);
- table.addListener(SWT.KeyDown, tableListener);
- table.addListener(SWT.MouseMove, tableListener);
- table.addListener(SWT.MouseHover, tableListener);
- }
-
- private void createTableButtonComposite(Composite parent) {
-
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 1;
- gridLayout.marginWidth = 0;
- gridLayout.marginHeight = 0;
- composite.setLayout(gridLayout);
- composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
-
- Button addBt = new Button(composite, SWT.PUSH);
- Image addIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/add.gif");
- addBt.setImage(addIcon);
- addBt.addMouseListener(new MouseListener() {
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- FileDialog fd = new FileDialog(getShell(), SWT.OPEN|SWT.MULTI);
- fd.setText(resources.getString("File.Dialog.Title.File"));
- String[] filterExt = { "*.rpm" };
- fd.setFilterExtensions(filterExt);
- selectedFileList = fd.open();
- System.out.println(selectedFileList);
- PlatformLaunchUtils launchUtils = new PlatformLaunchUtils();
- if (selectedFileList != null) {
- String[] files = fd.getFileNames();
- String path = fd.getFilterPath();
- for (String f : files) {
- String filePath = new Path(path).append(f).toOSString();
- LocalPackage p = launchUtils.getLocalPackage(filePath);
- if (!existsPkg(p)) {
- packages.add(p);
- }
- }
-
- tableViewer.refresh();
- updateLaunchConfigurationDialog();
- }
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- }
-
- });
-
- Button removeBt = new Button(composite, SWT.PUSH);
- Image removeIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/remove.gif");
- removeBt.setImage(removeIcon);
- }
-
- private void createExtraTableGroup(Composite parent) {
-
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout projLayout = new GridLayout();
- projLayout.numColumns = 1;
- projLayout.marginHeight = 0;
- projLayout.marginWidth = 0;
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- composite.setLayout(projLayout);
- composite.setLayoutData(gd);
-
- createTableTitleComposite(composite);
- createTableGroupComposite(composite);
- }
-
- private boolean existsPkg(LocalPackage pkg) {
- for (LocalPackage p : packages) {
- if (pkg.getPath().equals(p.getPath())) {
- return true;
- }
- }
- return false;
- }
-
- private void createAppProjectGroup(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);
-
- fProjLabel = new Label(projComp, SWT.NONE);
- fProjLabel.setText(resources.getString("Label.App.Project"));
- gd = new GridData();
- gd.horizontalSpan = 2;
- fProjLabel.setLayoutData(gd);
-
- fAppProjText = new Text(projComp, SWT.SINGLE | SWT.BORDER);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- fAppProjText.setLayoutData(gd);
- fAppProjText.addModifyListener(new ModifyListener() {
-
- public void modifyText(ModifyEvent evt) {
- // if project changes, invalidate program name cache
- fPreviouslyCheckedProgram = null;
-
- updateBuildConfigCombo(""); //$NON-NLS-1$
- updateLaunchConfigurationDialog();
- }
- });
-
- fAppProjButton = createPushButton(projComp, LaunchMessages.Launch_common_Browse_1, null);
- fAppProjButton.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent evt) {
- handleAppProjectButtonSelected();
- updateLaunchConfigurationDialog();
- }
- });
- }
-
- protected void handleAppProjectButtonSelected() {
- String currentProjectName = fProjText.getText();
- ICProject project = chooseCAppProject(currentProjectName);
- if (project == null) {
- return;
- }
-
- String projectName = project.getElementName();
- fAppProjText.setText(projectName);
- }
-
- 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<ICProject> list = new ArrayList<ICProject>(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, device.getAppInstallPath() + "/");
- 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) {
- updateProgramFromConfig(configuration);
- updateProjectFromConfig(configuration);
- updateAppProjectFromConfig(configuration);
- updateExtraTableFromConfig(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 appProj = fAppProjText.getText().trim();
- boolean reinstallOp = fReinstallOp.getSelection();
- boolean selectPkgOp = fSelectPkgOp.getSelection();
- ArrayList<String> pkgs = new ArrayList<String>();
-
- for (LocalPackage p : packages) {
- pkgs.add(p.getPath());
- }
-
- config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programPath);
- config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, name);
- config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_APP_PROJECT_NAME, appProj);
- config.setAttribute(ITizenLaunchConfigurationConstants.ATTR_EXTRA_PACKAGE_LIST, pkgs);
- 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);
- }
-
- @Override
- protected void updateProgramFromConfig(ILaunchConfiguration config) {
- if (fProgText != null)
- {
- String programName = EMPTY_STRING;
- try {
-
- programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, EMPTY_STRING);
- } catch (CoreException ce) {
- LaunchUIPlugin.log(ce);
- }
- fProgText.setText(programName);
- }
- }
-
- protected void updateAppProjectFromConfig(ILaunchConfiguration config) {
- String projectName = EMPTY_STRING;
- try {
- projectName = config.getAttribute(ITizenLaunchConfigurationConstants.ATTR_APP_PROJECT_NAME, EMPTY_STRING);
- } catch (CoreException ce) {
- LaunchUIPlugin.log(ce);
- }
- fAppProjText.setText(projectName);
- }
-
- @SuppressWarnings("unchecked")
- protected void updateExtraTableFromConfig(ILaunchConfiguration config) {
- ArrayList<String> pkgs = null;
- try {
- pkgs = (ArrayList<String>) config.getAttribute(ITizenLaunchConfigurationConstants.ATTR_EXTRA_PACKAGE_LIST, new ArrayList<String>());
- } catch (CoreException ce) {
- LaunchUIPlugin.log(ce);
- }
- PlatformLaunchUtils launchUtils = new PlatformLaunchUtils();
- //packages.addAll(launchUtils.getLocalPackages(pkgs));
- packages = launchUtils.getLocalPackages(pkgs);
- tableViewer.setInput(packages);
- }
-
- 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);
- }
-
- private class TooltableSelectionAdapter extends SelectionAdapter
- {
- public void widgetSelected(SelectionEvent e) {
-
- final int column = tableViewer.getTable().indexOf((TableColumn) e.widget);
- tableViewer.getTable().setSortColumn((TableColumn)e.widget);
- if (tableViewer.getTable().getSortDirection() == SWT.DOWN) {
- tableViewer.getTable().setSortDirection(SWT.UP);
- } else {
- tableViewer.getTable().setSortDirection(SWT.DOWN);
- }
-
- tableViewer.setSorter(new ViewerSorter() {
- public int compare(Viewer viewer, Object e1, Object e2) {
- LocalPackage pkg_1 = (LocalPackage)e1;
- LocalPackage pkg_2 = (LocalPackage)e2;
-
- String fileName_1 = new Path(pkg_1.getPath()).lastSegment();
- String fileName_2 = new Path(pkg_2.getPath()).lastSegment();
-
- switch (column) {
- case 1:
- if (tableViewer.getTable().getSortDirection() == SWT.DOWN) {
- return fileName_1.compareTo(fileName_2);
- } else {
- return fileName_2.compareTo(fileName_1);
- }
- default:
- break;
- }
- return fileName_1.compareTo(fileName_2);
- }
- });
-
- }
- }
-
- /* selected package table provider */
- private class TableViewerProvider extends LabelProvider implements ITableLabelProvider
- {
- @Override
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- @Override
- public String getColumnText(Object element, int columnIndex) {
- if ( element instanceof LocalPackage) {
- LocalPackage pkg = (LocalPackage)element;
- String file = pkg.getPath();
- String name = new Path(file).lastSegment();
-
- switch(columnIndex) {
- case 0 :
- return name;
- default:
- break;
- }
- }
- return null;
- }
- }
-
- Listener tableListener = new Listener() {
- Shell tip = null;
- Label label = null;
-
- public void handleEvent(Event event) {
- switch (event.type) {
- case SWT.Dispose:
- case SWT.KeyDown:
- case SWT.MouseMove: {
- if (tip == null) {
- break;
- }
- tip.dispose();
- tip = null;
- label = null;
- break;
- }
- case SWT.MouseHover: {
- TableItem item = tableViewer.getTable().getItem(new Point(event.x, event.y));
- if (item != null) {
- if (tip != null && !tip.isDisposed()) {
- tip.dispose();
- }
- tip = new Shell(getShell(), SWT.ON_TOP | SWT.TOOL);
- tip.setLayout(new FillLayout());
- label = new Label(tip, SWT.NONE);
- LocalPackage pkg = (LocalPackage)item.getData();
-
- label.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- label.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
-
- label.setData("_TABLEITEM", item);
- label.setText(pkg.getPath());
- label.addListener(SWT.MouseExit, labelListener);
- label.addListener(SWT.MouseDown, labelListener);
- Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- Rectangle rect = item.getBounds(0);
- Point pt = tableViewer.getTable().toDisplay(rect.x, rect.y);
- tip.setBounds(pt.x + 50, pt.y + 10, size.x, size.y);
- tip.setVisible(true);
- }
- }
- default:
- break;
- }
- }
- };
-
- // Implement a "fake" tooltip
- final Listener labelListener = new Listener() {
- public void handleEvent(Event event) {
- Label label = (Label) event.widget;
- Shell shell = label.getShell();
- switch (event.type) {
- case SWT.MouseDown:
- Event e = new Event();
- e.item = (TableItem) label.getData("_TABLEITEM");
- // Assuming table is single select, set the selection as if
- // the mouse down event went through to the table
- tableViewer.getTable().setSelection(new TableItem[] { (TableItem) e.item });
- tableViewer.getTable().notifyListeners(SWT.Selection, e);
- // fall through
- case SWT.MouseExit:
- shell.dispose();
- break;
- default:
- break;
- }
- }
- };
-}
\ No newline at end of file
--- /dev/null
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.launch.ui.shortcut;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+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.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.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;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+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.util.DialogUtil;
+import org.tizen.nativecommon.build.SmartBuildInterface;
+import org.tizen.nativecommon.launch.TizenLaunchConfigurationConstants;
+import org.tizen.nativecommon.launch.TizenLaunchMessages;
+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.pkg.commander.PkgCommandTarget;
+import org.tizen.nativeplatform.rootstrap.RootstrapManager;
+import org.tizen.nativeplatform.views.model.PlatformRootstrap;
+import org.tizen.sdblib.IDevice;
+
+@SuppressWarnings("restriction")
+public class PlatformProjectAttachLaunchShortcut extends CApplicationLaunchShortcut {
+
+ private String programPath = null;
+ private boolean reinstallOp = true;
+ private boolean selectPkgOp = true;
+ private String procName = "";
+ private IDevice device = null;
+ private int pid;
+ private PkgCommandTarget target = null;
+
+ private ISourceLookupDirector fLocator;
+
+ public void launch(IProject project, String mode) {
+ searchAndLaunch(new Object[] { project }, mode);
+ }
+
+ @Override
+ public void launch(IEditorPart editor, String mode) {
+ searchAndLaunch(new Object[] { editor.getEditorInput() }, mode);
+ }
+
+ @Override
+ public void launch(ISelection selection, String mode) {
+ if (selection instanceof IStructuredSelection) {
+ searchAndLaunch(((IStructuredSelection) selection).toArray(), mode);
+ }
+ }
+
+ private void searchAndLaunch(final Object[] elements, String mode) {
+ device = ConnectionPlugin.getDefault().getCurrentDevice();
+ if (device == null) {
+ DialogUtil.openErrorDialog(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE);
+ return;
+ }
+
+ if (elements != null && elements.length > 0) {
+ int nElements = elements.length;
+ for (int i = 0; i < nElements; i++) {
+ if (elements[i] instanceof IAdaptable) {
+ IResource r = (IResource) ((IAdaptable) elements[i])
+ .getAdapter(IResource.class);
+ if (r != null) {
+ IProject project = r.getProject();
+ if (project != null) {
+ ILaunchConfiguration config = findLaunchConfiguration(project, mode);
+ if (config != null) {
+ DebugUITools.launch(config, mode);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected ILaunchConfiguration findLaunchConfiguration(IProject project, String mode) {
+ ILaunchConfiguration configuration = null;
+ // Set the default debugger based on the active toolchain on the project
+ // (if possible)
+ ICDebugConfiguration debugConfig = null;
+ ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project);
+ ICConfigurationDescription configDesc = projDesc.getActiveConfiguration();
+ String configId = configDesc.getId();
+ ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault()
+ .getActiveDebugConfigurations();
+ int matchLength = 0;
+ for (int i = 0; i < debugConfigs.length; ++i) {
+ ICDebugConfiguration dc = debugConfigs[i];
+ String[] patterns = dc.getSupportedBuildConfigPatterns();
+ if (patterns != null) {
+ for (int j = 0; j < patterns.length; ++j) {
+ if (patterns[j].length() > matchLength && configId.matches(patterns[j])) {
+ debugConfig = dc;
+ matchLength = patterns[j].length();
+ }
+ }
+ }
+ }
+
+ if (debugConfig == null) {
+ // Prompt the user if more then 1 debugger.
+ debugConfigs = CDebugCorePlugin.getDefault().getActiveDebugConfigurations();
+ List<ICDebugConfiguration> debugList = new ArrayList<ICDebugConfiguration>(
+ debugConfigs.length);
+ for (int i = 0; i < debugConfigs.length; i++) {
+ if (debugConfigs[i]
+ .supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
+ if (debugConfigs[i].getName().contains("Tizen")) //$NON-NLS-1$
+ debugList.add(debugConfigs[i]);
+ }
+ }
+ debugConfigs = (ICDebugConfiguration[]) debugList.toArray(new ICDebugConfiguration[0]);
+ if (debugConfigs.length == 1)
+ debugConfig = debugConfigs[0];
+ else if (debugConfigs.length > 1)
+ debugConfig = chooseDebugConfig(debugConfigs, mode);
+ }
+
+ configuration = createConfiguration(project, debugConfig, mode);
+
+ return configuration;
+ }
+
+ private ICDebugConfiguration chooseDebugConfig(ICDebugConfiguration[] debugConfigs, String mode) {
+ ILabelProvider provider = new LabelProvider() {
+ public String getText(Object element) {
+ if (element == null) {
+ return ""; //$NON-NLS-1$
+ } else if (element instanceof ICDebugConfiguration) {
+ return ((ICDebugConfiguration) element).getName();
+ }
+ return element.toString();
+ }
+ };
+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), provider);
+ dialog.setElements(debugConfigs);
+ dialog.setTitle(getDebugConfigDialogTitleString(debugConfigs, mode));
+ dialog.setMessage(getDebugConfigDialogMessageString(debugConfigs, mode));
+ dialog.setMultipleSelection(false);
+ int result = dialog.open();
+ provider.dispose();
+ if (result == Window.OK) {
+ return (ICDebugConfiguration) dialog.getFirstResult();
+ }
+ return null;
+ }
+
+ private void setPkgCommandTarget(IProject project) {
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ IConfiguration defaultConfig = info.getDefaultConfiguration();
+ String targetId = PlatformConfigurationManager.getBuildTargetName(defaultConfig);
+ String rootId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetId);
+ PlatformRootstrap rootstrap = RootstrapManager.getRootstrap(rootId);
+ target = new PkgCommandTarget(device, rootstrap);
+ }
+
+ protected ILaunchConfiguration createConfiguration(IProject project,
+ ICDebugConfiguration debugConfig, String mode) {
+ ILaunchConfiguration config = null;
+ try {
+ setPkgCommandTarget(project);
+ ILaunchConfigurationType configType = getCLaunchConfigType();
+ ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager()
+ .generateLaunchConfigurationName(project.getName()));
+
+ 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 });
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
+ ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID,
+ TizenLaunchConfigurationConstants.DEBUGGER_ID);
+ wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY,
+ ITizenLaunchConfigurationConstants.COMMAND_FACTORY_ID);
+ wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, true);
+ wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS,
+ false);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH,
+ ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED);
+
+ ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(project);
+ if (projDes != null) {
+ String buildConfigID = projDes.getActiveConfiguration().getId();
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID,
+ buildConfigID);
+ }
+
+ // 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();
+ } catch (CoreException ce) {
+ CDebugUIPlugin.log(ce);
+ }
+ return config;
+ }
+
+ 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();
+ window = windows[0];
+ }
+ final Shell shell = window.getShell();
+
+ PlatformAttachLaunchWizard wizard = new PlatformAttachLaunchWizard(shell, project,
+ defaultConfig, target, 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) {
+ /*
+ * 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);
+ */
+ PlatformRootstrap rootstrap = target.getRootstrap();
+
+ String basePath = rootstrap.getPath().toOSString();
+ PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(target);
+ 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);
+ 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) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ protected ILaunchConfigurationType getCLaunchConfigType() {
+ return getLaunchManager().getLaunchConfigurationType(
+ "org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForAttach");
+ }
+}
--- /dev/null
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.launch.ui.shortcut;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+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.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.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.Status;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.jface.viewers.ILabelProvider;
+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.swt.widgets.Shell;
+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.launch.TizenLaunchConfigurationConstants;
+import org.tizen.nativeplatform.Activator;
+import org.tizen.nativeplatform.launch.ITizenLaunchConfigurationConstants;
+import org.tizen.nativeplatform.launch.PlatformLaunchMessages;
+
+@SuppressWarnings("restriction")
+public class PlatformProjectCoredumpLaunchShortcut 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 : ";
+
+ public void launch(IProject project, String mode) {
+ searchAndLaunch(new Object[] { project }, mode);
+ }
+
+ @Override
+ public void launch(IEditorPart editor, String mode) {
+ searchAndLaunch(new Object[] { editor.getEditorInput() }, mode);
+ }
+
+ @Override
+ public void launch(ISelection selection, String mode) {
+ if (selection instanceof IStructuredSelection) {
+ searchAndLaunch(((IStructuredSelection) selection).toArray(), mode);
+ }
+ }
+
+ private void searchAndLaunch(final Object[] elements, String mode) {
+ if (elements != null && elements.length > 0) {
+ int nElements = elements.length;
+ for (int i = 0; i < nElements; i++) {
+ if (elements[i] instanceof IAdaptable) {
+ IResource r = (IResource) ((IAdaptable) elements[i])
+ .getAdapter(IResource.class);
+ if (r != null) {
+ IProject project = r.getProject();
+ if (project != null) {
+ ILaunchConfiguration config = findLaunchConfiguration(project, mode);
+ if (config != null) {
+ DebugUITools.launch(config, mode);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected ILaunchConfiguration findLaunchConfiguration(IProject project, String mode) {
+ ILaunchConfiguration configuration = null;
+ // Set the default debugger based on the active toolchain on the project
+ // (if possible)
+ ICDebugConfiguration debugConfig = null;
+ ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project);
+ ICConfigurationDescription configDesc = projDesc.getActiveConfiguration();
+ String configId = configDesc.getId();
+ ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault()
+ .getActiveDebugConfigurations();
+ int matchLength = 0;
+ for (int i = 0; i < debugConfigs.length; ++i) {
+ ICDebugConfiguration dc = debugConfigs[i];
+ String[] patterns = dc.getSupportedBuildConfigPatterns();
+ if (patterns != null) {
+ for (int j = 0; j < patterns.length; ++j) {
+ if (patterns[j].length() > matchLength && configId.matches(patterns[j])) {
+ debugConfig = dc;
+ matchLength = patterns[j].length();
+ }
+ }
+ }
+ }
+
+ if (debugConfig == null) {
+ // Prompt the user if more then 1 debugger.
+ debugConfigs = CDebugCorePlugin.getDefault().getActiveDebugConfigurations();
+ List<ICDebugConfiguration> debugList = new ArrayList<ICDebugConfiguration>(
+ debugConfigs.length);
+ for (int i = 0; i < debugConfigs.length; i++) {
+ if (debugConfigs[i]
+ .supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
+ if (debugConfigs[i].getName().contains("Tizen")) //$NON-NLS-1$
+ debugList.add(debugConfigs[i]);
+ }
+ }
+ debugConfigs = (ICDebugConfiguration[]) debugList.toArray(new ICDebugConfiguration[0]);
+ if (debugConfigs.length == 1)
+ debugConfig = debugConfigs[0];
+ else if (debugConfigs.length > 1)
+ debugConfig = chooseDebugConfig(debugConfigs, mode);
+ }
+
+ configuration = createConfiguration(project, debugConfig, mode);
+
+ return configuration;
+ }
+
+ private ICDebugConfiguration chooseDebugConfig(ICDebugConfiguration[] debugConfigs, String mode) {
+ ILabelProvider provider = new LabelProvider() {
+ public String getText(Object element) {
+ if (element == null) {
+ return ""; //$NON-NLS-1$
+ } else if (element instanceof ICDebugConfiguration) {
+ return ((ICDebugConfiguration) element).getName();
+ }
+ return element.toString();
+ }
+ };
+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), provider);
+ dialog.setElements(debugConfigs);
+ dialog.setTitle(getDebugConfigDialogTitleString(debugConfigs, mode));
+ dialog.setMessage(getDebugConfigDialogMessageString(debugConfigs, mode));
+ dialog.setMultipleSelection(false);
+ int result = dialog.open();
+ provider.dispose();
+ if (result == Window.OK) {
+ return (ICDebugConfiguration) dialog.getFirstResult();
+ }
+ return null;
+ }
+
+ protected ILaunchConfiguration createConfiguration(IProject project,
+ ICDebugConfiguration debugConfig, String mode) {
+ ILaunchConfiguration config = null;
+ try {
+ 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);
+
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getName());
+ wc.setMappedResources(new IResource[] { project });
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
+ ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID,
+ TizenLaunchConfigurationConstants.DEBUGGER_ID);
+ wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY,
+ ITizenLaunchConfigurationConstants.COMMAND_FACTORY_ID);
+ wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, true);
+ wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS,
+ false);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH,
+ ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED);
+
+ ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(project);
+ if (projDes != null) {
+ String buildConfigID = projDes.getActiveConfiguration().getId();
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID,
+ buildConfigID);
+ }
+
+ // 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());
+ page.setDefaults(wc);
+
+ config = wc.doSave();
+ } catch (CoreException ce) {
+ CDebugUIPlugin.log(ce);
+ }
+ return config;
+ }
+
+ private String getProgramName() throws CoreException {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window == null) {
+ IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
+ window = windows[0];
+ }
+ 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(PlatformLaunchMessages.OPERATION_CANCELED, null);
+
+ return null;
+ }
+
+ private void newCoreException(String message, Throwable exception) throws CoreException {
+ Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, message, exception);
+ throw new CoreException(status);
+ }
+
+ @Override
+ protected ILaunchConfigurationType getCLaunchConfigType() {
+ return getLaunchManager().getLaunchConfigurationType(
+ "org.tizen.nativeplatform.launch.PlatformLaunchConfigurationTypeForCore");
+ }
+}
--- /dev/null
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.launch.ui.shortcut;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+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.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.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;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+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.util.DialogUtil;
+import org.tizen.nativecommon.build.SmartBuildInterface;
+import org.tizen.nativecommon.launch.TizenLaunchConfigurationConstants;
+import org.tizen.nativecommon.launch.TizenLaunchMessages;
+import org.tizen.nativeplatform.build.PlatformConfigurationManager;
+import org.tizen.nativeplatform.launch.ITizenLaunchConfigurationConstants;
+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.launch.wizards.SelectItemDialog;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
+import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
+import org.tizen.nativeplatform.rootstrap.RootstrapManager;
+import org.tizen.nativeplatform.util.PlatformProjectUtil;
+import org.tizen.nativeplatform.views.model.PlatformRootstrap;
+import org.tizen.sdblib.IDevice;
+
+@SuppressWarnings("restriction")
+public class PlatformProjectLaunchShortcut extends CApplicationLaunchShortcut {
+
+ private static final String APP_PROJ_DEFAULT_SELECTION = "[Not required]";
+
+ private String programPath = null;
+ private String appProjectName = null;
+ private List<LocalPackage> packages = null;
+ private boolean reinstallOp = true;
+ private boolean selectPkgOp = true;
+ private IDevice device = null;
+ private PkgCommandTarget target = null;
+
+ private ISourceLookupDirector fLocator;
+
+ public void launch(IProject project, String mode) {
+ searchAndLaunch(new Object[] { project }, mode);
+ }
+
+ @Override
+ public void launch(IEditorPart editor, String mode) {
+ searchAndLaunch(new Object[] { editor.getEditorInput() }, mode);
+ }
+
+ @Override
+ public void launch(ISelection selection, String mode) {
+ if (selection instanceof IStructuredSelection) {
+ searchAndLaunch(((IStructuredSelection) selection).toArray(), mode);
+ }
+ }
+
+ private void searchAndLaunch(final Object[] elements, String mode) {
+ device = ConnectionPlugin.getDefault().getCurrentDevice();
+ if (device == null) {
+ DialogUtil.openErrorDialog(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE);
+ return;
+ }
+
+ if (elements != null && elements.length > 0) {
+ int nElements = elements.length;
+ for (int i = 0; i < nElements; i++) {
+ if (elements[i] instanceof IAdaptable) {
+ IResource r = (IResource) ((IAdaptable) elements[i])
+ .getAdapter(IResource.class);
+ if (r != null) {
+ IProject project = r.getProject();
+ if (project != null) {
+ ILaunchConfiguration config = findLaunchConfiguration(project, mode);
+ if (config != null) {
+ DebugUITools.launch(config, mode);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected ILaunchConfiguration findLaunchConfiguration(IProject project, String mode) {
+ ILaunchConfiguration configuration = null;
+ // Set the default debugger based on the active toolchain on the project
+ // (if possible)
+ ICDebugConfiguration debugConfig = null;
+ ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project);
+ ICConfigurationDescription configDesc = projDesc.getActiveConfiguration();
+ String configId = configDesc.getId();
+ ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault()
+ .getActiveDebugConfigurations();
+ int matchLength = 0;
+ for (int i = 0; i < debugConfigs.length; ++i) {
+ ICDebugConfiguration dc = debugConfigs[i];
+ String[] patterns = dc.getSupportedBuildConfigPatterns();
+ if (patterns != null) {
+ for (int j = 0; j < patterns.length; ++j) {
+ if (patterns[j].length() > matchLength && configId.matches(patterns[j])) {
+ debugConfig = dc;
+ matchLength = patterns[j].length();
+ }
+ }
+ }
+ }
+
+ if (debugConfig == null) {
+ // Prompt the user if more then 1 debugger.
+ debugConfigs = CDebugCorePlugin.getDefault().getActiveDebugConfigurations();
+ List<ICDebugConfiguration> debugList = new ArrayList<ICDebugConfiguration>(
+ debugConfigs.length);
+ for (int i = 0; i < debugConfigs.length; i++) {
+ if (debugConfigs[i]
+ .supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
+ if (debugConfigs[i].getName().contains("Tizen")) //$NON-NLS-1$
+ debugList.add(debugConfigs[i]);
+ }
+ }
+ debugConfigs = (ICDebugConfiguration[]) debugList.toArray(new ICDebugConfiguration[0]);
+ if (debugConfigs.length == 1)
+ debugConfig = debugConfigs[0];
+ else if (debugConfigs.length > 1)
+ debugConfig = chooseDebugConfig(debugConfigs, mode);
+ }
+
+ configuration = createConfiguration(project, debugConfig, mode);
+
+ return configuration;
+ }
+
+ private ICDebugConfiguration chooseDebugConfig(ICDebugConfiguration[] debugConfigs, String mode) {
+ ILabelProvider provider = new LabelProvider() {
+ public String getText(Object element) {
+ if (element == null) {
+ return ""; //$NON-NLS-1$
+ } else if (element instanceof ICDebugConfiguration) {
+ return ((ICDebugConfiguration) element).getName();
+ }
+ return element.toString();
+ }
+ };
+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), provider);
+ dialog.setElements(debugConfigs);
+ dialog.setTitle(getDebugConfigDialogTitleString(debugConfigs, mode));
+ dialog.setMessage(getDebugConfigDialogMessageString(debugConfigs, mode));
+ dialog.setMultipleSelection(false);
+ int result = dialog.open();
+ provider.dispose();
+ if (result == Window.OK) {
+ return (ICDebugConfiguration) dialog.getFirstResult();
+ }
+ return null;
+ }
+
+ private void setPkgCommandTarget(IProject project) {
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ IConfiguration defaultConfig = info.getDefaultConfiguration();
+ String targetId = PlatformConfigurationManager.getBuildTargetName(defaultConfig);
+ String rootId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetId);
+ PlatformRootstrap rootstrap = RootstrapManager.getRootstrap(rootId);
+ target = new PkgCommandTarget(device, rootstrap);
+ }
+
+ protected ILaunchConfiguration createConfiguration(IProject project,
+ ICDebugConfiguration debugConfig, String mode) {
+
+ ILaunchConfiguration config = null;
+ try {
+ setPkgCommandTarget(project);
+ ILaunchConfigurationType configType = getCLaunchConfigType();
+ ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager()
+ .generateLaunchConfigurationName(project.getName()));
+
+ if (!setLaunchConfiguration(project, mode)) {
+ return null;
+ }
+
+ if (programPath != null) {
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programPath);
+ }
+
+ if (appProjectName != null && !APP_PROJ_DEFAULT_SELECTION.equals(appProjectName)) {
+ wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_APP_PROJECT_NAME,
+ appProjectName);
+ }
+
+ if (packages != null) {
+ List<String> strs = new ArrayList<String>();
+ for (LocalPackage p : packages) {
+ strs.add(p.getPath());
+ }
+ wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_EXTRA_PACKAGE_LIST, strs);
+ }
+
+ wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, reinstallOp);
+ wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, selectPkgOp);
+ wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_FROM_SHORTCUT, true);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getName());
+ wc.setMappedResources(new IResource[] { project });
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
+ ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID,
+ TizenLaunchConfigurationConstants.DEBUGGER_ID);
+ wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY,
+ ITizenLaunchConfigurationConstants.COMMAND_FACTORY_ID);
+ wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, true);
+ wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS,
+ false);
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH,
+ ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED);
+
+ ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(project);
+ if (projDes != null) {
+ String buildConfigID = projDes.getActiveConfiguration().getId();
+ wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID,
+ buildConfigID);
+ }
+
+ // 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();
+ } catch (CoreException ce) {
+ CDebugUIPlugin.log(ce);
+ }
+ return config;
+ }
+
+ @Override
+ protected ILaunchConfigurationType getCLaunchConfigType() {
+ return getLaunchManager().getLaunchConfigurationType(
+ "org.tizen.nativeplatform.launch.PlatformLaunchConfigurationType");
+ }
+
+ 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();
+ window = windows[0];
+ }
+ final Shell shell = window.getShell();
+ boolean isEflApp = PlatformProjectUtil.isEFLApplication(project);
+ if (isEflApp) {
+ PlatformLaunchUtils launchUtil = new PlatformLaunchUtils(target);
+ appProjectName = null;
+ String[] files = launchUtil.getProgramPath(project);
+ if (files != null) {
+ if (files.length > 1) {
+ SelectItemDialog dlg = new SelectItemDialog(shell, files);
+ dlg.create();
+ if (Window.OK == dlg.open()) {
+ programPath = dlg.getSelectedItem();
+ } else {
+ return false;
+ }
+ } else if (files.length == 1) {
+ programPath = files[0];
+ } else {
+ programPath = null;
+ }
+ }
+ // programPath = launchUtil.getProgramPath(project);
+ packages = null;
+ reinstallOp = true;
+ selectPkgOp = false;
+ return true;
+ } else {
+ PlatformLaunchWizard wizard = new PlatformLaunchWizard(shell, project, defaultConfig,
+ target, mode);
+ PlatformLaunchWizardDialog dlg = new PlatformLaunchWizardDialog(shell, wizard);
+ dlg.create();
+ if (Window.OK == dlg.open()) {
+ appProjectName = dlg.getAppProjectName();
+ programPath = dlg.getProgramPath();
+ packages = dlg.getExtraPackages();
+ reinstallOp = dlg.getReinstallOp();
+ selectPkgOp = dlg.getSelectPkgOp();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void setSourceContainer(IProject project, ILaunchConfigurationWorkingCopy configuration) {
+ PlatformRootstrap rootstrap = target.getRootstrap();
+ String basePath = rootstrap.getPath().toOSString();
+ PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(target);
+ 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);
+ 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();
+ }
+ }
+}
* @deprecated It is not used anymore (commented out in plugin.xml).
*/
@Deprecated
-public class TizenDebianPropertyTester extends PropertyTester {
+public class PlatformPropertyTester extends PropertyTester {
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
if ("isTizenCustomDebianProject".equals(property)) {
if (receiver instanceof IProject) {
- IProject project = (IProject)receiver;
+ IProject project = (IProject) receiver;
return testProject(project);
}
} else if ("belongTizenCustomDebianProject".equals(property)) {
if (receiver instanceof IResource) {
- IResource r = (IResource)receiver;
+ IResource r = (IResource) receiver;
IProject project = r.getProject();
return testProject(project);
}
IConfiguration cfg = info.getDefaultConfiguration();
IManagedProject managedProject = cfg.getManagedProject();
if (managedProject != null && managedProject.getProjectType() != null) {
- String projectArtifactType = managedProject.getProjectType().getBuildArtefactType().getId();
- if (projectArtifactType.equals(PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE) ||
- projectArtifactType.equals(PlatformConfigurationManager.OLD_SLP_CUSTOM_DEBIAN_ARTIFACT_TYPE))
+ String projectArtifactType = managedProject.getProjectType().getBuildArtefactType()
+ .getId();
+ if (projectArtifactType
+ .equals(PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE)
+ || projectArtifactType
+ .equals(PlatformConfigurationManager.OLD_SLP_CUSTOM_DEBIAN_ARTIFACT_TYPE))
return true;
else
return false;
+++ /dev/null
-/*
- * Native Platform
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Donghyuk Yang <donghyuk.yang@samsung.com>
- * DongHee Yang <donghee.yang@samsung.com>
- * Kangho Kim <kh5325.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.nativeplatform.launch.ui.shortcut;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-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.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.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;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Shell;
-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.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;
-
-
-
-
-@SuppressWarnings("restriction")
-public class TizenDebianProjectAttachLaunchShortcut extends CApplicationLaunchShortcut {
-
- 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);
- }
-
- @Override
- public void launch(IEditorPart editor, String mode) {
- searchAndLaunch(new Object[] { editor.getEditorInput()}, mode);
- }
-
- @Override
- public void launch(ISelection selection, String mode) {
- if (selection instanceof IStructuredSelection) {
- searchAndLaunch(((IStructuredSelection) selection).toArray(), mode);
- }
- }
-
- private void searchAndLaunch(final Object[] elements, String mode) {
- if (elements != null && elements.length > 0) {
- int nElements = elements.length;
- for (int i = 0; i < nElements; i++) {
- if (elements[i] instanceof IAdaptable) {
- IResource r = (IResource) ((IAdaptable) elements[i]).getAdapter(IResource.class);
- if (r != null) {
- IProject project = r.getProject();
- if (project != null) {
- ILaunchConfiguration config = findLaunchConfiguration(project, mode);
- if (config != null) {
- DebugUITools.launch(config, mode);
- }
- }
- }
- }
- }
- }
- }
-
- protected ILaunchConfiguration findLaunchConfiguration(IProject project, String mode) {
- ILaunchConfiguration configuration = null;
- // Set the default debugger based on the active toolchain on the project (if possible)
- ICDebugConfiguration debugConfig = null;
- ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project);
- ICConfigurationDescription configDesc = projDesc.getActiveConfiguration();
- String configId = configDesc.getId();
- ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault().getActiveDebugConfigurations();
- int matchLength = 0;
- for (int i = 0; i < debugConfigs.length; ++i) {
- ICDebugConfiguration dc = debugConfigs[i];
- String[] patterns = dc.getSupportedBuildConfigPatterns();
- if (patterns != null) {
- for (int j = 0; j < patterns.length; ++j) {
- if (patterns[j].length() > matchLength && configId.matches(patterns[j])) {
- debugConfig = dc;
- matchLength = patterns[j].length();
- }
- }
- }
- }
-
- if ( debugConfig == null ) {
- // Prompt the user if more then 1 debugger.
- debugConfigs = CDebugCorePlugin.getDefault().getActiveDebugConfigurations();
- List<ICDebugConfiguration> debugList = new ArrayList<ICDebugConfiguration>(debugConfigs.length);
- for (int i = 0; i < debugConfigs.length; i++) {
- if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
- if (debugConfigs[i].getName().contains("Tizen")) //$NON-NLS-1$
- debugList.add(debugConfigs[i]);
- }
- }
- debugConfigs = (ICDebugConfiguration[]) debugList.toArray(new ICDebugConfiguration[0]);
- if (debugConfigs.length == 1)
- debugConfig = debugConfigs[0];
- else if (debugConfigs.length > 1)
- debugConfig = chooseDebugConfig(debugConfigs, mode);
- }
-
- configuration = createConfiguration(project, debugConfig, mode);
-
- return configuration;
- }
-
- private ICDebugConfiguration chooseDebugConfig(ICDebugConfiguration[] debugConfigs, String mode) {
- ILabelProvider provider = new LabelProvider() {
- public String getText(Object element) {
- if (element == null) {
- return ""; //$NON-NLS-1$
- } else if (element instanceof ICDebugConfiguration) {
- return ((ICDebugConfiguration) element).getName();
- }
- return element.toString();
- }
- };
- ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), provider);
- dialog.setElements(debugConfigs);
- dialog.setTitle(getDebugConfigDialogTitleString(debugConfigs, mode));
- dialog.setMessage(getDebugConfigDialogMessageString(debugConfigs, mode));
- dialog.setMultipleSelection(false);
- int result = dialog.open();
- provider.dispose();
- if (result == Window.OK) {
- return (ICDebugConfiguration) dialog.getFirstResult();
- }
- return null;
- }
-
- protected ILaunchConfiguration createConfiguration(IProject project, ICDebugConfiguration debugConfig, String mode) {
- ILaunchConfiguration config = null;
- try {
- ILaunchConfigurationType configType = getCLaunchConfigType();
- ILaunchConfigurationWorkingCopy wc =
- configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(project.getName()));
-
- 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});
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, TizenLaunchConfigurationConstants.DEBUGGER_ID);
- wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY, ITizenLaunchConfigurationConstants.COMMAND_FACTORY_ID);
- wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, true);
- wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS, false);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED);
-
-
- ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(project);
- if (projDes != null) {
- String buildConfigID = projDes.getActiveConfiguration().getId();
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, buildConfigID);
- }
-
- // 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();
- } catch (CoreException ce) {
- CDebugUIPlugin.log(ce);
- }
- return config;
- }
-
- 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();
- window = windows[0];
- }
- final Shell shell = window.getShell();
-
- 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) {
-
- 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);
- 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) {
- e.printStackTrace();
- }
- }
-
-
- @Override
- protected ILaunchConfigurationType getCLaunchConfigType() {
- return getLaunchManager().getLaunchConfigurationType("org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationTypeForAttach");
- }
-}
+++ /dev/null
-/*
- * Native Platform
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Donghyuk Yang <donghyuk.yang@samsung.com>
- * DongHee Yang <donghee.yang@samsung.com>
- * Kangho Kim <kh5325.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.nativeplatform.launch.ui.shortcut;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-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.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.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.Status;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.ui.DebugUITools;
-import org.eclipse.jface.viewers.ILabelProvider;
-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.swt.widgets.Shell;
-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.launch.TizenLaunchConfigurationConstants;
-import org.tizen.nativeplatform.Activator;
-import org.tizen.nativeplatform.launch.ITizenLaunchConfigurationConstants;
-import org.tizen.nativeplatform.launch.TizenDebianLaunchMessages;
-
-
-
-
-@SuppressWarnings("restriction")
-public class TizenDebianProjectCoredumpLaunchShortcut 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 : ";
-
- public void launch(IProject project, String mode) {
- searchAndLaunch(new Object[] {project}, mode);
- }
-
- @Override
- public void launch(IEditorPart editor, String mode) {
- searchAndLaunch(new Object[] { editor.getEditorInput()}, mode);
- }
-
- @Override
- public void launch(ISelection selection, String mode) {
- if (selection instanceof IStructuredSelection) {
- searchAndLaunch(((IStructuredSelection) selection).toArray(), mode);
- }
- }
-
- private void searchAndLaunch(final Object[] elements, String mode) {
- if (elements != null && elements.length > 0) {
- int nElements = elements.length;
- for (int i = 0; i < nElements; i++) {
- if (elements[i] instanceof IAdaptable) {
- IResource r = (IResource) ((IAdaptable) elements[i]).getAdapter(IResource.class);
- if (r != null) {
- IProject project = r.getProject();
- if (project != null) {
- ILaunchConfiguration config = findLaunchConfiguration(project, mode);
- if (config != null) {
- DebugUITools.launch(config, mode);
- }
- }
- }
- }
- }
- }
- }
-
- protected ILaunchConfiguration findLaunchConfiguration(IProject project, String mode) {
- ILaunchConfiguration configuration = null;
- // Set the default debugger based on the active toolchain on the project (if possible)
- ICDebugConfiguration debugConfig = null;
- ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project);
- ICConfigurationDescription configDesc = projDesc.getActiveConfiguration();
- String configId = configDesc.getId();
- ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault().getActiveDebugConfigurations();
- int matchLength = 0;
- for (int i = 0; i < debugConfigs.length; ++i) {
- ICDebugConfiguration dc = debugConfigs[i];
- String[] patterns = dc.getSupportedBuildConfigPatterns();
- if (patterns != null) {
- for (int j = 0; j < patterns.length; ++j) {
- if (patterns[j].length() > matchLength && configId.matches(patterns[j])) {
- debugConfig = dc;
- matchLength = patterns[j].length();
- }
- }
- }
- }
-
- if ( debugConfig == null ) {
- // Prompt the user if more then 1 debugger.
- debugConfigs = CDebugCorePlugin.getDefault().getActiveDebugConfigurations();
- List<ICDebugConfiguration> debugList = new ArrayList<ICDebugConfiguration>(debugConfigs.length);
- for (int i = 0; i < debugConfigs.length; i++) {
- if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
- if (debugConfigs[i].getName().contains("Tizen")) //$NON-NLS-1$
- debugList.add(debugConfigs[i]);
- }
- }
- debugConfigs = (ICDebugConfiguration[]) debugList.toArray(new ICDebugConfiguration[0]);
- if (debugConfigs.length == 1)
- debugConfig = debugConfigs[0];
- else if (debugConfigs.length > 1)
- debugConfig = chooseDebugConfig(debugConfigs, mode);
- }
-
- configuration = createConfiguration(project, debugConfig, mode);
-
- return configuration;
- }
-
- private ICDebugConfiguration chooseDebugConfig(ICDebugConfiguration[] debugConfigs, String mode) {
- ILabelProvider provider = new LabelProvider() {
- public String getText(Object element) {
- if (element == null) {
- return ""; //$NON-NLS-1$
- } else if (element instanceof ICDebugConfiguration) {
- return ((ICDebugConfiguration) element).getName();
- }
- return element.toString();
- }
- };
- ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), provider);
- dialog.setElements(debugConfigs);
- dialog.setTitle(getDebugConfigDialogTitleString(debugConfigs, mode));
- dialog.setMessage(getDebugConfigDialogMessageString(debugConfigs, mode));
- dialog.setMultipleSelection(false);
- int result = dialog.open();
- provider.dispose();
- if (result == Window.OK) {
- return (ICDebugConfiguration) dialog.getFirstResult();
- }
- return null;
- }
-
- protected ILaunchConfiguration createConfiguration(IProject project, ICDebugConfiguration debugConfig, String mode) {
- ILaunchConfiguration config = null;
- try {
- 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);
-
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getName());
- wc.setMappedResources(new IResource[] {project});
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, TizenLaunchConfigurationConstants.DEBUGGER_ID);
- wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY, ITizenLaunchConfigurationConstants.COMMAND_FACTORY_ID);
- wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, true);
- wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS, false);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED);
-
- ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(project);
- if (projDes != null) {
- String buildConfigID = projDes.getActiveConfiguration().getId();
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, buildConfigID);
- }
-
- // 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());
- page.setDefaults(wc);
-
- config = wc.doSave();
- } catch (CoreException ce) {
- CDebugUIPlugin.log(ce);
- }
- return config;
- }
-
- private String getProgramName() throws CoreException {
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null) {
- IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
- window = windows[0];
- }
- 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);
-
- return null;
- }
-
- private void newCoreException(String message, Throwable exception) throws CoreException {
- Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, message, exception);
- throw new CoreException(status);
- }
-
- @Override
- protected ILaunchConfigurationType getCLaunchConfigType() {
- return getLaunchManager().getLaunchConfigurationType("org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationTypeForCore");
- }
-}
+++ /dev/null
-/*
- * Native Platform
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Donghyuk Yang <donghyuk.yang@samsung.com>
- * DongHee Yang <donghee.yang@samsung.com>
- * Kangho Kim <kh5325.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.nativeplatform.launch.ui.shortcut;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-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.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.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.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.sourcelookup.containers.DirectorySourceContainer;
-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.cdt.debug.core.sourcelookup.MappingSourceContainer;
-import org.eclipse.cdt.debug.internal.core.sourcelookup.MapEntrySourceContainer;
-import org.eclipse.debug.ui.DebugUITools;
-import org.eclipse.jface.viewers.ILabelProvider;
-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.swt.widgets.Shell;
-import org.eclipse.ui.IEditorPart;
-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.util.DialogUtil;
-import org.tizen.nativecommon.build.SmartBuildInterface;
-import org.tizen.nativecommon.launch.TizenLaunchConfigurationConstants;
-import org.tizen.nativecommon.launch.TizenLaunchMessages;
-import org.tizen.nativeplatform.build.PlatformConfigurationManager;
-import org.tizen.nativeplatform.launch.ITizenLaunchConfigurationConstants;
-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;
-import org.tizen.nativeplatform.rootstrap.RootstrapManager;
-import org.tizen.nativeplatform.views.model.PlatformRootstrap;
-import org.tizen.sdblib.IDevice;
-
-@SuppressWarnings("restriction")
-public class TizenDebianProjectLaunchShortcut extends CApplicationLaunchShortcut {
-
- private static final String APP_PROJ_DEFAULT_SELECTION = "[Not required]";
-
- private String programPath = null;
- private String appProjectName = null;
- private ArrayList<LocalPackage> packages = null;
- private boolean reinstallOp = true;
- private boolean selectPkgOp = true;
-
- private ISourceLookupDirector fLocator;
-
- public void launch(IProject project, String mode) {
- searchAndLaunch(new Object[] {project}, mode);
- }
-
- @Override
- public void launch(IEditorPart editor, String mode) {
- searchAndLaunch(new Object[] { editor.getEditorInput()}, mode);
- }
-
- @Override
- public void launch(ISelection selection, String mode) {
- if (selection instanceof IStructuredSelection) {
- searchAndLaunch(((IStructuredSelection) selection).toArray(), mode);
- }
- }
-
- private void searchAndLaunch(final Object[] elements, String mode) {
- IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
- if (device == null) {
- DialogUtil.openErrorDialog(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE);
- return;
- }
-
- if (elements != null && elements.length > 0) {
- int nElements = elements.length;
- for (int i = 0; i < nElements; i++) {
- if (elements[i] instanceof IAdaptable) {
- IResource r = (IResource) ((IAdaptable) elements[i]).getAdapter(IResource.class);
- if (r != null) {
- IProject project = r.getProject();
- if (project != null) {
- ILaunchConfiguration config = findLaunchConfiguration(project, mode);
- if (config != null) {
- DebugUITools.launch(config, mode);
- }
- }
- }
- }
- }
- }
- }
-
- protected ILaunchConfiguration findLaunchConfiguration(IProject project, String mode) {
- ILaunchConfiguration configuration = null;
- // Set the default debugger based on the active toolchain on the project (if possible)
- ICDebugConfiguration debugConfig = null;
- ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project);
- ICConfigurationDescription configDesc = projDesc.getActiveConfiguration();
- String configId = configDesc.getId();
- ICDebugConfiguration[] debugConfigs = CDebugCorePlugin.getDefault().getActiveDebugConfigurations();
- int matchLength = 0;
- for (int i = 0; i < debugConfigs.length; ++i) {
- ICDebugConfiguration dc = debugConfigs[i];
- String[] patterns = dc.getSupportedBuildConfigPatterns();
- if (patterns != null) {
- for (int j = 0; j < patterns.length; ++j) {
- if (patterns[j].length() > matchLength && configId.matches(patterns[j])) {
- debugConfig = dc;
- matchLength = patterns[j].length();
- }
- }
- }
- }
-
- if ( debugConfig == null ) {
- // Prompt the user if more then 1 debugger.
- debugConfigs = CDebugCorePlugin.getDefault().getActiveDebugConfigurations();
- List<ICDebugConfiguration> debugList = new ArrayList<ICDebugConfiguration>(debugConfigs.length);
- for (int i = 0; i < debugConfigs.length; i++) {
- if (debugConfigs[i].supportsMode(ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN)) {
- if (debugConfigs[i].getName().contains("Tizen")) //$NON-NLS-1$
- debugList.add(debugConfigs[i]);
- }
- }
- debugConfigs = (ICDebugConfiguration[]) debugList.toArray(new ICDebugConfiguration[0]);
- if (debugConfigs.length == 1)
- debugConfig = debugConfigs[0];
- else if (debugConfigs.length > 1)
- debugConfig = chooseDebugConfig(debugConfigs, mode);
- }
-
- configuration = createConfiguration(project, debugConfig, mode);
-
- return configuration;
- }
-
- private ICDebugConfiguration chooseDebugConfig(ICDebugConfiguration[] debugConfigs, String mode) {
- ILabelProvider provider = new LabelProvider() {
- public String getText(Object element) {
- if (element == null) {
- return ""; //$NON-NLS-1$
- } else if (element instanceof ICDebugConfiguration) {
- return ((ICDebugConfiguration) element).getName();
- }
- return element.toString();
- }
- };
- ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), provider);
- dialog.setElements(debugConfigs);
- dialog.setTitle(getDebugConfigDialogTitleString(debugConfigs, mode));
- dialog.setMessage(getDebugConfigDialogMessageString(debugConfigs, mode));
- dialog.setMultipleSelection(false);
- int result = dialog.open();
- provider.dispose();
- if (result == Window.OK) {
- return (ICDebugConfiguration) dialog.getFirstResult();
- }
- return null;
- }
-
- protected ILaunchConfiguration createConfiguration(IProject project, ICDebugConfiguration debugConfig, String mode) {
-
- ILaunchConfiguration config = null;
- try {
- ILaunchConfigurationType configType = getCLaunchConfigType();
- ILaunchConfigurationWorkingCopy wc =
- configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(project.getName()));
-
- if (!setLaunchConfiguration(project, mode)) {
- return null;
- }
-
- if (programPath != null) {
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, programPath);
- }
-
- if (appProjectName != null && !APP_PROJ_DEFAULT_SELECTION.equals(appProjectName)) {
- wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_APP_PROJECT_NAME, appProjectName);
- }
-
- if (packages != null) {
- ArrayList<String> strs = new ArrayList<String>();
- for (LocalPackage p : packages) {
- strs.add(p.getPath());
- }
- wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_EXTRA_PACKAGE_LIST, strs);
- }
-
- wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, reinstallOp);
- wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, selectPkgOp);
- wc.setAttribute(ITizenLaunchConfigurationConstants.ATTR_FROM_SHORTCUT, true);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getName());
- wc.setMappedResources(new IResource[] {project});
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, TizenLaunchConfigurationConstants.DEBUGGER_ID);
- wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY, ITizenLaunchConfigurationConstants.COMMAND_FACTORY_ID);
- wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, true);
- wc.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS, false);
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED);
-
- ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(project);
- if (projDes != null) {
- String buildConfigID = projDes.getActiveConfiguration().getId();
- wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, buildConfigID);
- }
-
- // 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();
- } catch (CoreException ce) {
- CDebugUIPlugin.log(ce);
- }
- return config;
- }
-
- @Override
- protected ILaunchConfigurationType getCLaunchConfigType() {
- return getLaunchManager().getLaunchConfigurationType("org.tizen.nativeplatform.launch.TizenDebianLaunchConfigurationType");
- }
-
-
- 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();
- window = windows[0];
- }
- final Shell shell = window.getShell();
-
- PlatformLaunchWizard wizard = new PlatformLaunchWizard(shell, project, defaultConfig, mode);
- PlatformLaunchWizardDialog dlg = new PlatformLaunchWizardDialog(shell, wizard);
- dlg.create();
- if (Window.OK == dlg.open()) {
- appProjectName = dlg.getAppProjectName();
- programPath = dlg.getProgramPath();
- packages = dlg.getExtraPackages();
- reinstallOp = dlg.getReinstallOp();
- selectPkgOp = dlg.getSelectPkgOp();
- return true;
- } else {
- return false;
- }
- }
-
- private void setSourceContainer(IProject project, ILaunchConfigurationWorkingCopy configuration) {
-
- 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);
- 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();
- }
- }
-}
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
-
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.sdblib.FileListingService.FileEntry;
import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.service.FileEntry;
public class TizenPathInputDialog extends Dialog {
/**
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.ResourceBundle;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.core.resources.ResourcesPlugin;
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.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
-
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.build.PlatformConfigurationManager;
-import org.tizen.nativeplatform.build.PlatformProjectPackaging;
-import org.tizen.nativeplatform.launch.TizenDebianLaunchMessages;
+import org.tizen.nativeplatform.launch.PlatformLaunchMessages;
import org.tizen.nativeplatform.launch.wizards.PlatformLaunchUtils;
-import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander;
+import org.tizen.nativeplatform.pkg.commander.IPackager;
+import org.tizen.nativeplatform.pkg.commander.PackagerFactory;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
-import org.tizen.nativeplatform.rootstrap.RootstrapManager;
+import org.tizen.nativeplatform.views.model.PlatformRootstrap;
public class PlatformLaunchSettingAppPage extends WizardPage {
-
- private final String BUNDLE_NAME = PlatformLaunchSettingAppPage.class.getPackage().getName() + ".LaunchWizardPageUIMessages";//$NON-NLS-1$
- private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
-
- private TableViewer tableViewer;
- private FileDialog fd;
- private Combo projectCombo;
- private Button reinstallOp;
- private Button selectPkgOp;
- private String selectedFileList = "";
- private Shell shell;
-
- private IConfiguration config;
- private IProject platformProject;
- private PlatformRootstrap rootstrap;
- private String rootPath = "";
- private boolean packagingResult;
- private ArrayList<LocalPackage> platformPackages = new ArrayList<LocalPackage>();
- private ArrayList<LocalPackage> appPackages = new ArrayList<LocalPackage>();
- private ArrayList<LocalPackage> extraPackages = new ArrayList<LocalPackage>();
- private ArrayList<LocalPackage> packages = new ArrayList<LocalPackage>();
- private ArrayList<String> projectNames = new ArrayList<String>();
- private HashMap<String, IProject> projectMap = new HashMap<String, IProject>();
-
- private static final String APP_PROJ_DEFAULT_SELECTION = "[Not required]";
-
- public PlatformLaunchSettingAppPage(Shell shell, String pageName, IProject project, IConfiguration config) {
- super(pageName);
-
- setTitle(resources.getString("AppPage.Title"));
- setDescription(resources.getString("AppPage.Desc"));
- setPageComplete(true);
-
+
+ private final String BUNDLE_NAME = PlatformLaunchSettingAppPage.class.getPackage().getName()
+ + ".LaunchWizardPageUIMessages";//$NON-NLS-1$
+ private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private TableViewer tableViewer;
+ private FileDialog fd;
+ private Combo projectCombo;
+ private Button reinstallOp;
+ private Button selectPkgOp;
+ private String selectedFileList = "";
+ private Shell shell;
+
+ private IConfiguration config;
+ private IProject platformProject;
+ private PlatformRootstrap rootstrap;
+ private PkgCommandTarget target = null;
+ private String rootPath = "";
+ private boolean packagingResult;
+ private List<LocalPackage> platformPackages = new ArrayList<LocalPackage>();
+ private List<LocalPackage> appPackages = new ArrayList<LocalPackage>();
+ private List<LocalPackage> extraPackages = new ArrayList<LocalPackage>();
+ private List<LocalPackage> packages = new ArrayList<LocalPackage>();
+ private List<String> projectNames = new ArrayList<String>();
+ private Map<String, IProject> projectMap = new HashMap<String, IProject>();
+
+ private static final String APP_PROJ_DEFAULT_SELECTION = "[Not required]";
+
+ public PlatformLaunchSettingAppPage(Shell shell, String pageName, IProject project,
+ IConfiguration config, PkgCommandTarget target) {
+ super(pageName);
+
+ setTitle(resources.getString("AppPage.Title"));
+ setDescription(resources.getString("AppPage.Desc"));
+ setPageComplete(true);
+
this.platformProject = project;
this.config = config;
this.shell = shell;
- String targetId = PlatformConfigurationManager.getBuildTargetName(config);
- String rootId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetId);
- this.rootstrap = RootstrapManager.getRootstrap(rootId);
- this.rootPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(rootstrap.getPath().toOSString());
-
+ this.target = target;
+ this.rootstrap = target.getRootstrap();
+ this.rootPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(
+ rootstrap.getPath().toOSString());
+
setPlatformPackages();
setProjectMap();
- }
+ }
+
+ public void setPlatformPackages() {
+ platformPackages.clear();
+ PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(target);
+ platformPackages = launchUtils.getProjectPackages(platformProject, config.getName());
- 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();
- }
- }
+ String msg = String.format(PlatformLaunchMessages.QUESTION_PACKAGING,
+ platformProject.getName());
+ if (64 == DialogUtil.openQuestionDialog(msg)) {
+ if (packagingProject(platformProject)) {
+ setPlatformPackages();
+ }
+ }
} else {
- packages.addAll(platformPackages);
- }
- }
-
- private void setAppPackages(IProject appProj) {
- appPackages.clear();
- PlatformLaunchUtils launchUtils = new PlatformLaunchUtils();
- appPackages = launchUtils.getProjectPackages(appProj, config.getName());
- if (appPackages.isEmpty()) {
- String msg = String.format(TizenDebianLaunchMessages.QUESTION_PACKAGING, appProj.getName());
- if (64 == DialogUtil.openQuestionDialog(msg)) {
- if (packagingProject(appProj)) {
- setAppPackages(appProj);
- }
- }
+ packages.addAll(platformPackages);
}
- }
-
- private void setProjectMap() {
- IWorkspace works = ResourcesPlugin.getWorkspace();
- IProject[] projs = works.getRoot().getProjects();
- projectNames.add(APP_PROJ_DEFAULT_SELECTION);
- for (IProject p : projs) {
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(p);
- if( info == null) {
- continue;
- }
- IConfiguration cfg = info.getDefaultConfiguration();
- if( cfg == null) {
- continue;
- }
- IManagedProject managedProject = cfg.getManagedProject();
- if( managedProject == null) {
- continue;
- }
- String projectArtifactType = managedProject.getProjectType() != null ? managedProject.getProjectType().getBuildArtefactType().getId() : null;
- if (projectArtifactType != null &&
- projectArtifactType.equals(PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE) &&
- !platformProject.getName().equals(p.getName())) {
- String name = p.getName();
- projectMap.put(name, p);
- projectNames.add(name);
- }
- }
- }
-
- @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);
-
- createProjectsComposite(composite);
- createTableTitleComposite(composite);
- createTableGroupComposite(composite);
- createOptionGroupComposite(composite);
-
- setControl(composite);
- }
-
- private void createOptionGroupComposite(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout gridLayout = new GridLayout();
+ }
+
+ private void setAppPackages(IProject appProj) {
+ appPackages.clear();
+ PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(target);
+ appPackages = launchUtils.getProjectPackages(appProj, config.getName());
+ if (appPackages.isEmpty()) {
+ String msg = String
+ .format(PlatformLaunchMessages.QUESTION_PACKAGING, appProj.getName());
+ if (64 == DialogUtil.openQuestionDialog(msg)) {
+ if (packagingProject(appProj)) {
+ setAppPackages(appProj);
+ }
+ }
+ }
+ }
+
+ private void setProjectMap() {
+ IWorkspace works = ResourcesPlugin.getWorkspace();
+ IProject[] projs = works.getRoot().getProjects();
+ projectNames.add(APP_PROJ_DEFAULT_SELECTION);
+ for (IProject p : projs) {
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(p);
+ if (info == null) {
+ continue;
+ }
+ IConfiguration cfg = info.getDefaultConfiguration();
+ if (cfg == null) {
+ continue;
+ }
+ IManagedProject managedProject = cfg.getManagedProject();
+ if (managedProject == null) {
+ continue;
+ }
+ String projectArtifactType = managedProject.getProjectType() != null ? managedProject
+ .getProjectType().getBuildArtefactType().getId() : null;
+ if (projectArtifactType != null
+ && projectArtifactType
+ .equals(PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE)
+ && !platformProject.getName().equals(p.getName())) {
+ String name = p.getName();
+ projectMap.put(name, p);
+ projectNames.add(name);
+ }
+ }
+ }
+
+ @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);
+
+ createProjectsComposite(composite);
+ createTableTitleComposite(composite);
+ createTableGroupComposite(composite);
+ createOptionGroupComposite(composite);
+
+ setControl(composite);
+ }
+
+ private void createOptionGroupComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ 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 createTableTitleComposite(Composite parent) {
- Label tableLabel = new Label(parent, SWT.NONE);
- tableLabel.setText(resources.getString("AppPage.Label.AdditionPkgs"));
- }
-
+ 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 createTableTitleComposite(Composite parent) {
+ Label tableLabel = new Label(parent, SWT.NONE);
+ tableLabel.setText(resources.getString("AppPage.Label.AdditionPkgs"));
+ }
+
private void createProjectsComposite(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout gridLayout = new GridLayout();
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
- composite.setLayout(gridLayout);
- Label projectLabel = new Label(composite, SWT.NONE);
- projectLabel.setText(resources.getString("AppPage.Label.Project"));
-
- GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
- composite.setLayoutData(gridData);
-
- projectCombo = new Combo(composite, SWT.READ_ONLY);
- projectCombo.setLayoutData(gridData);
- projectCombo.setItems(projectNames.toArray(new String[0]));
- projectCombo.addSelectionListener(new SelectionListener() {
-
+ composite.setLayout(gridLayout);
+ Label projectLabel = new Label(composite, SWT.NONE);
+ projectLabel.setText(resources.getString("AppPage.Label.Project"));
+
+ GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+ composite.setLayoutData(gridData);
+
+ projectCombo = new Combo(composite, SWT.READ_ONLY);
+ projectCombo.setLayoutData(gridData);
+ projectCombo.setItems(projectNames.toArray(new String[0]));
+ projectCombo.addSelectionListener(new SelectionListener() {
+
@Override
- public void widgetSelected(SelectionEvent e)
- {
- String selected = projectCombo.getText().trim();
- if (APP_PROJ_DEFAULT_SELECTION.equals(selected)) {
- packages.clear();
- packages.addAll(platformPackages);
- packages.addAll(extraPackages);
- } else {
- IProject proj = projectMap.get(selected);
- setAppPackages(proj);
- packages.clear();
- packages.addAll(platformPackages);
- packages.addAll(appPackages);
- packages.addAll(extraPackages);
- }
+ public void widgetSelected(SelectionEvent e) {
+ String selected = projectCombo.getText().trim();
+ if (APP_PROJ_DEFAULT_SELECTION.equals(selected)) {
+ packages.clear();
+ packages.addAll(platformPackages);
+ packages.addAll(extraPackages);
+ } else {
+ IProject proj = projectMap.get(selected);
+ setAppPackages(proj);
+ packages.clear();
+ packages.addAll(platformPackages);
+ packages.addAll(appPackages);
+ packages.addAll(extraPackages);
+ }
}
@Override
- public void widgetDefaultSelected(SelectionEvent e)
- {}
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
});
-
- projectCombo.select(0);
+
+ projectCombo.select(0);
}
-
+
private void createTableComposite(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout gridLayout = new GridLayout();
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 1;
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
- composite.setLayout(gridLayout);
- GridData gridData = new GridData(GridData.FILL_BOTH);
- gridData.minimumWidth = 350;
- gridData.minimumHeight = 200;
- composite.setLayoutData(gridData);
-
- Composite t_composite = new Composite(composite, SWT.NONE);
- t_composite.setLayout(new FillLayout());
- t_composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- tableViewer = new TableViewer(t_composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- Table table = tableViewer.getTable();
-
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- String[] columnNames = new String[] {"RPM files"};
-
- int[] columnWidths = new int[] {450};
- for (int i = 0; i < columnNames.length ; i++) {
- TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
-
- tableColumn.setText(columnNames[i]);
- tableColumn.setWidth(columnWidths[i]);
- tableColumn.setResizable(true);
- //tableColumn.addSelectionListener(new TooltableSelectionAdapter());
- }
-
- tableViewer.setLabelProvider(new TableViewerProvider());
- tableViewer.setContentProvider(new ArrayContentProvider());
- packages.addAll(extraPackages);
- tableViewer.setInput(extraPackages);
- tableViewer.getTable().addSelectionListener(new SelectionListener() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- });
-
- table.addListener(SWT.Dispose, tableListener);
- table.addListener(SWT.KeyDown, tableListener);
- table.addListener(SWT.MouseMove, tableListener);
- table.addListener(SWT.MouseHover, tableListener);
- }
+ composite.setLayout(gridLayout);
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ gridData.minimumWidth = 350;
+ gridData.minimumHeight = 200;
+ composite.setLayoutData(gridData);
+
+ Composite t_composite = new Composite(composite, SWT.NONE);
+ t_composite.setLayout(new FillLayout());
+ t_composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ tableViewer = new TableViewer(t_composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ Table table = tableViewer.getTable();
+
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ String[] columnNames = new String[] { "RPM files" };
+
+ int[] columnWidths = new int[] { 450 };
+ for (int i = 0; i < columnNames.length; i++) {
+ TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
+
+ tableColumn.setText(columnNames[i]);
+ tableColumn.setWidth(columnWidths[i]);
+ tableColumn.setResizable(true);
+ // tableColumn.addSelectionListener(new
+ // TooltableSelectionAdapter());
+ }
+
+ tableViewer.setLabelProvider(new TableViewerProvider());
+ tableViewer.setContentProvider(new ArrayContentProvider());
+ packages.addAll(extraPackages);
+ tableViewer.setInput(extraPackages);
+ tableViewer.getTable().addSelectionListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ });
+ table.addListener(SWT.Dispose, tableListener);
+ table.addListener(SWT.KeyDown, tableListener);
+ table.addListener(SWT.MouseMove, tableListener);
+ table.addListener(SWT.MouseHover, tableListener);
+ }
- private void createTableButtonsComposite(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
- GridLayout gridLayout = new GridLayout();
+ private void createTableButtonsComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+ GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 1;
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
- composite.setLayout(gridLayout);
-
- Button addBt = new Button(composite, SWT.PUSH);
- Image addIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/add.gif");
- addBt.setImage(addIcon);
- addBt.addMouseListener(new MouseListener() {
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- fd = new FileDialog(shell, SWT.OPEN|SWT.MULTI);
- fd.setText(resources.getString("AppPage.Dialog.Title.File"));
- String[] filterExt = { "*.rpm" };
- fd.setFilterExtensions(filterExt);
- selectedFileList = fd.open();
- System.out.println(selectedFileList);
- if (selectedFileList != null) {
- String[] files = fd.getFileNames();
- String path = fd.getFilterPath();
- for (String f : files) {
- LocalPackage p = new LocalPackage();
- p.setPath(new Path(path).append(f).toOSString());
- String name = RPMPackageCommander.getPkgNameForFile(p.getPath());
- p.setName(name);
- extraPackages.add(p);
- //rpmFiles.add(f);
- }
- //tableViewer.refresh();
- packages.clear();
- packages.addAll(platformPackages);
- packages.addAll(appPackages);
- packages.addAll(extraPackages);
- tableViewer.refresh();
- }
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- }
-
- });
-
-
- Button removeBt = new Button(composite, SWT.PUSH);
- Image removeIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/remove.gif");
- removeBt.setImage(removeIcon);
+ composite.setLayout(gridLayout);
+
+ Button addBt = new Button(composite, SWT.PUSH);
+ Image addIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/add.gif");
+ addBt.setImage(addIcon);
+ addBt.addMouseListener(new MouseListener() {
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ fd = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
+ fd.setText(resources.getString("AppPage.Dialog.Title.File"));
+ String[] filterExt = { "*.rpm" };
+ fd.setFilterExtensions(filterExt);
+ selectedFileList = fd.open();
+ System.out.println(selectedFileList);
+ if (selectedFileList != null) {
+ String[] files = fd.getFileNames();
+ String path = fd.getFilterPath();
+ for (String f : files) {
+ LocalPackage p = new LocalPackage();
+ p.setPath(new Path(path).append(f).toOSString());
+ String name = target.getHostCommander().getNameFromFile(p.getPath());
+ p.setName(name);
+ extraPackages.add(p);
+ // rpmFiles.add(f);
+ }
+ // tableViewer.refresh();
+ packages.clear();
+ packages.addAll(platformPackages);
+ packages.addAll(appPackages);
+ packages.addAll(extraPackages);
+ tableViewer.refresh();
+ }
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ }
+
+ });
+
+ Button removeBt = new Button(composite, SWT.PUSH);
+ Image removeIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/remove.gif");
+ removeBt.setImage(removeIcon);
}
-
+ private void createTableGroupComposite(Composite parent) {
- private void createTableGroupComposite(Composite parent) {
-
- Composite composite = new Composite( parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout gridLayout = new GridLayout();
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
- composite.setLayout(gridLayout);
-
- createTableComposite(composite);
- createTableButtonsComposite(composite);
+ composite.setLayout(gridLayout);
+
+ createTableComposite(composite);
+ createTableButtonsComposite(composite);
}
-
+
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);
+ 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);
+ IPackager packager = PackagerFactory.getPackager(targetProj, config);
+ packagingResult = packager.packaging(monitor);
+ }
+ });
+ } else {
+ getContainer().run(true, true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+ // packagingResult =
+ // PlatformProjectPackaging.RPMPackaging(targetProj,
+ // config, monitor);
+ IPackager packager = PackagerFactory.getPackager(targetProj, config);
+ packagingResult = packager.packaging(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);
+ } else {
+ MessageDialog.openError(shell, CommonBuildMessages.BUILD_RESULT,
+ CommonBuildMessages.FAIL_TO_BUILD_PACKAGE);
result = false;
- }
-
+ }
+
return result;
}
- /* selected package table provider */
- private class TableViewerProvider extends LabelProvider implements ITableLabelProvider
- {
- @Override
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- @Override
- public String getColumnText(Object element, int columnIndex) {
- if ( element instanceof LocalPackage) {
- LocalPackage p = (LocalPackage)element;
- String name = new Path(p.getPath()).lastSegment();
-
- switch(columnIndex) {
- case 0:
- return name;
- default:
- break;
- }
- }
- return null;
- }
- }
-
- public ArrayList<LocalPackage> getPackages() {
- return packages;
- }
-
- public ArrayList<LocalPackage> getExtraPackages() {
- return extraPackages;
- }
-
- public String getRootstrapPath() {
- return rootPath;
- }
-
- public String getAppProjectName() {
- return projectCombo.getText().trim();
- }
-
- public boolean getReinstallOp() {
- return reinstallOp.getSelection();
- }
-
- public boolean getSelectPkgOp() {
- return selectPkgOp.getSelection();
- }
-
- Listener tableListener = new Listener() {
- Shell tip = null;
- Label label = null;
-
- public void handleEvent(Event event) {
- switch (event.type) {
- case SWT.Dispose:
- case SWT.KeyDown:
- case SWT.MouseMove: {
- if (tip == null) {
- break;
- }
- tip.dispose();
- tip = null;
- label = null;
- break;
- }
- case SWT.MouseHover: {
- TableItem item = tableViewer.getTable().getItem(new Point(event.x, event.y));
- if (item != null) {
- if (tip != null && !tip.isDisposed()) {
- tip.dispose();
- }
- tip = new Shell(getShell(), SWT.ON_TOP | SWT.TOOL);
- tip.setLayout(new FillLayout());
- label = new Label(tip, SWT.NONE);
- LocalPackage pkg = (LocalPackage)item.getData();
-
- label.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- label.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
-
- label.setData("_TABLEITEM", item);
- label.setText(pkg.getPath());
- label.addListener(SWT.MouseExit, labelListener);
- label.addListener(SWT.MouseDown, labelListener);
- Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- Rectangle rect = item.getBounds(0);
- Point pt = tableViewer.getTable().toDisplay(rect.x, rect.y);
- tip.setBounds(pt.x + 50, pt.y + 10, size.x, size.y);
- tip.setVisible(true);
- }
- }
- default:
- break;
- }
- }
- };
-
- // Implement a "fake" tooltip
- final Listener labelListener = new Listener() {
- public void handleEvent(Event event) {
- Label label = (Label) event.widget;
- Shell shell = label.getShell();
- switch (event.type) {
- case SWT.MouseDown:
- Event e = new Event();
- e.item = (TableItem) label.getData("_TABLEITEM");
- // Assuming table is single select, set the selection as if
- // the mouse down event went through to the table
- tableViewer.getTable().setSelection(new TableItem[] { (TableItem) e.item });
- tableViewer.getTable().notifyListeners(SWT.Selection, e);
- // fall through
- case SWT.MouseExit:
- shell.dispose();
- break;
- default:
- break;
- }
- }
- };
-
+ /* selected package table provider */
+ private class TableViewerProvider extends LabelProvider implements ITableLabelProvider {
+ @Override
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ @Override
+ public String getColumnText(Object element, int columnIndex) {
+ if (element instanceof LocalPackage) {
+ LocalPackage p = (LocalPackage) element;
+ String name = new Path(p.getPath()).lastSegment();
+
+ switch (columnIndex) {
+ case 0:
+ return name;
+ default:
+ break;
+ }
+ }
+ return null;
+ }
+ }
+
+ public List<LocalPackage> getPackages() {
+ return packages;
+ }
+
+ public List<LocalPackage> getExtraPackages() {
+ return extraPackages;
+ }
+
+ public String getRootstrapPath() {
+ return rootPath;
+ }
+
+ public String getAppProjectName() {
+ return projectCombo.getText().trim();
+ }
+
+ public boolean getReinstallOp() {
+ return reinstallOp.getSelection();
+ }
+
+ public boolean getSelectPkgOp() {
+ return selectPkgOp.getSelection();
+ }
+
+ Listener tableListener = new Listener() {
+ Shell tip = null;
+ Label label = null;
+
+ public void handleEvent(Event event) {
+ switch (event.type) {
+ case SWT.Dispose:
+ case SWT.KeyDown:
+ case SWT.MouseMove: {
+ if (tip == null) {
+ break;
+ }
+ tip.dispose();
+ tip = null;
+ label = null;
+ break;
+ }
+ case SWT.MouseHover: {
+ TableItem item = tableViewer.getTable().getItem(new Point(event.x, event.y));
+ if (item != null) {
+ if (tip != null && !tip.isDisposed()) {
+ tip.dispose();
+ }
+ tip = new Shell(getShell(), SWT.ON_TOP | SWT.TOOL);
+ tip.setLayout(new FillLayout());
+ label = new Label(tip, SWT.NONE);
+ LocalPackage pkg = (LocalPackage) item.getData();
+
+ label.setForeground(getShell().getDisplay().getSystemColor(
+ SWT.COLOR_INFO_FOREGROUND));
+ label.setBackground(getShell().getDisplay().getSystemColor(
+ SWT.COLOR_INFO_BACKGROUND));
+
+ label.setData("_TABLEITEM", item);
+ label.setText(pkg.getPath());
+ label.addListener(SWT.MouseExit, labelListener);
+ label.addListener(SWT.MouseDown, labelListener);
+ Point size = tip.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ Rectangle rect = item.getBounds(0);
+ Point pt = tableViewer.getTable().toDisplay(rect.x, rect.y);
+ tip.setBounds(pt.x + 50, pt.y + 10, size.x, size.y);
+ tip.setVisible(true);
+ }
+ }
+ default:
+ break;
+ }
+ }
+ };
+
+ // Implement a "fake" tooltip
+ final Listener labelListener = new Listener() {
+ public void handleEvent(Event event) {
+ Label label = (Label) event.widget;
+ Shell shell = label.getShell();
+ switch (event.type) {
+ case SWT.MouseDown:
+ Event e = new Event();
+ e.item = (TableItem) label.getData("_TABLEITEM");
+ // Assuming table is single select, set the selection as if
+ // the mouse down event went through to the table
+ tableViewer.getTable().setSelection(new TableItem[] { (TableItem) e.item });
+ tableViewer.getTable().notifyListeners(SWT.Selection, e);
+ // fall through
+ case SWT.MouseExit:
+ shell.dispose();
+ break;
+ default:
+ break;
+ }
+ }
+ };
+
}
import org.tizen.common.connection.ui.TizenRemoteFileDialog.TizenRemoteFileDialogResult;
import org.tizen.nativecommon.launch.TizenLaunchMessages;
import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizard;
-import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizardDialog;
-import org.tizen.nativeplatform.views.ui.AddRootstrapDialog;
import org.tizen.sdblib.IDevice;
-import org.tizen.sdblib.FileListingService.FileEntry;
+import org.tizen.sdblib.service.FileEntry;
public class PlatformLaunchSettingBinPage extends WizardPage {
-
- private final String BUNDLE_NAME = PlatformLaunchSettingBinPage.class.getPackage().getName() + ".LaunchWizardPageUIMessages";//$NON-NLS-1$
- private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
- private PlatformLaunchWizard wizard;
-
- private Text text;
- private String filePath = "";
-
- public PlatformLaunchSettingBinPage(PlatformLaunchWizard wizard, String pageName) {
- super(pageName);
- this.wizard = wizard;
- setTitle(resources.getString("BinPage.Title"));
- setDescription(resources.getString("BinPage.Desc"));
- setPageComplete(true);
- }
- @Override
- public void createControl(Composite parent) {
- // TODO Auto-generated method stub
- Composite composite = new Composite(parent, SWT.NULL);
- composite.setLayout(new GridLayout(2, false));
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- text = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
+ private final String BUNDLE_NAME = PlatformLaunchSettingBinPage.class.getPackage().getName()
+ + ".LaunchWizardPageUIMessages";//$NON-NLS-1$
+ private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
+ private PlatformLaunchWizard wizard;
+
+ private Text text;
+ private String filePath = "";
+
+ public PlatformLaunchSettingBinPage(PlatformLaunchWizard wizard, String pageName) {
+ super(pageName);
+ this.wizard = wizard;
+ setTitle(resources.getString("BinPage.Title"));
+ setDescription(resources.getString("BinPage.Desc"));
+ setPageComplete(true);
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ // TODO Auto-generated method stub
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout(2, false));
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ text = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
- text.setLayoutData(data);
-
- Button browseButton = new Button(composite, SWT.PUSH);
- browseButton.setText(resources.getString("BinPage.Button.Browse"));
- browseButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent evt) {
- String path = handleBrowseButtonSelected();
- if (path != null) {
- text.setText(path);
- wizard.setEnableFinish(true);
- wizard.getContainer().updateButtons();
- } else {
- wizard.setEnableFinish(false);
- wizard.getContainer().updateButtons();
- }
- }
- });
-
- setControl(composite);
- }
-
- protected String handleBrowseButtonSelected() {
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null) {
- IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
- window = windows[0];
- }
+ text.setLayoutData(data);
+
+ Button browseButton = new Button(composite, SWT.PUSH);
+ browseButton.setText(resources.getString("BinPage.Button.Browse"));
+ browseButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent evt) {
+ String path = handleBrowseButtonSelected();
+ if (path != null) {
+ text.setText(path);
+ wizard.setEnableFinish(true);
+ wizard.getContainer().updateButtons();
+ } else {
+ wizard.setEnableFinish(false);
+ wizard.getContainer().updateButtons();
+ }
+ }
+ });
+
+ setControl(composite);
+ }
+
+ protected String handleBrowseButtonSelected() {
+ 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 null;
+ }
- 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 null;
- }
+ shell.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
+ TizenRemoteFileDialog dlg = new TizenRemoteFileDialog(shell, resources
+ .getString("BinPage.Remote.Dialog.Title"), device, false, device
+ .getAppInstallPath() + "/");
+ if (dlg.open() == TizenRemoteFileDialogResult.OK) {
+ FileEntry selectedFile = dlg.getSelectedFileEntry();
+ filePath = selectedFile.getFullPath().trim();
+ } else
+ filePath = null;
+ }
+ });
+ }
+ return filePath;
+ }
- shell.getDisplay().syncExec( new Runnable() {
- public void run() {
- IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
- TizenRemoteFileDialog dlg = new TizenRemoteFileDialog(shell,
- resources.getString("BinPage.Remote.Dialog.Title"), device, false, device.getAppInstallPath() + "/");
- if(dlg.open() == TizenRemoteFileDialogResult.OK) {
- FileEntry selectedFile = dlg.getSelectedFileEntry();
- filePath = selectedFile.getFullPath().trim();
- } else
- filePath = null;
- }
- });
- }
- return filePath;
- }
-
-
- public String getPath() {
- return text.getText().trim();
- }
+ public String getPath() {
+ return text.getText().trim();
+ }
}
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.List;
import java.util.ResourceBundle;
import org.eclipse.cdt.core.IProcessInfo;
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.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.launch.PlatformLaunchMessages;
import org.tizen.nativeplatform.launch.wizards.PlatformLaunchUtils;
import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizard;
+import org.tizen.nativeplatform.pkg.commander.IPackager;
+import org.tizen.nativeplatform.pkg.commander.PackagerFactory;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
-import org.tizen.nativeplatform.rootstrap.RootstrapManager;
-
+import org.tizen.nativeplatform.views.model.PlatformRootstrap;
import org.tizen.sdblib.IDevice;
-public class PlatformLaunchSettingProcPage extends WizardPage {
-
- private final String BUNDLE_NAME = PlatformLaunchSettingProcPage.class.getPackage().getName() + ".LaunchWizardPageUIMessages";//$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 PlatformLaunchWizard wizard;
-
-
- private IConfiguration config;
- private IProject platformProject;
- private PlatformRootstrap rootstrap;
- private IDevice device;
- private boolean packagingResult;
- private ArrayList<LocalPackage> platformPackages = new ArrayList<LocalPackage>();
- private ArrayList<LocalPackage> packages = new ArrayList<LocalPackage>();
-
- public PlatformLaunchSettingProcPage(PlatformLaunchWizard wizard, Shell shell, String pageName, IProject project, IConfiguration config) {
- super(pageName);
-
- setTitle(resources.getString("ProcPage.Title"));
- setDescription(resources.getString("ProcPage.Desc"));
- setPageComplete(true);
-
- this.wizard = wizard;
+public class PlatformLaunchSettingProcPage extends WizardPage {
+
+ private final String BUNDLE_NAME = PlatformLaunchSettingProcPage.class.getPackage().getName()
+ + ".LaunchWizardPageUIMessages";//$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 PlatformLaunchWizard wizard;
+
+ private IConfiguration config;
+ private IProject platformProject;
+ private PlatformRootstrap rootstrap;
+ private IDevice device;
+ private PkgCommandTarget target = null;
+ private boolean packagingResult;
+ private List<LocalPackage> platformPackages = new ArrayList<LocalPackage>();
+ private List<LocalPackage> packages = new ArrayList<LocalPackage>();
+
+ public PlatformLaunchSettingProcPage(PlatformLaunchWizard wizard, Shell shell, String pageName,
+ IProject project, IConfiguration config, PkgCommandTarget target) {
+ super(pageName);
+
+ setTitle(resources.getString("ProcPage.Title"));
+ setDescription(resources.getString("ProcPage.Desc"));
+ setPageComplete(true);
+
+ this.wizard = wizard;
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());
-
+ this.target = target;
+ this.device = target.getDevice();
+ this.rootstrap = target.getRootstrap();
+ this.rootPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(
+ rootstrap.getPath().toOSString());
+
setPlatformPackages();
- }
+ }
+
+ public void setPlatformPackages() {
+ platformPackages.clear();
+ PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(target);
+ platformPackages = launchUtils.getProjectPackages(platformProject, config.getName());
- 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();
- }
- }
+ String msg = String.format(PlatformLaunchMessages.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();
+ 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);
- }
-
+ 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();
+ 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(resources.getString("ProcPage.Label.ProcName"));
-
- processText = new Text(composite, SWT.BORDER | SWT.READ_ONLY);
- processText.setLayoutData(gridData);
- Button findBt = new Button(composite, SWT.PUSH);
- findBt.setText(resources.getString("ProcPage.Button.Browse"));
- 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());
- wizard.setEnableFinish(true);
- wizard.getContainer().updateButtons();
- } else {
- wizard.setEnableFinish(false);
- wizard.getContainer().updateButtons();
- }
- }
- });
+ 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(resources.getString("ProcPage.Label.ProcName"));
+
+ processText = new Text(composite, SWT.BORDER | SWT.READ_ONLY);
+ processText.setLayoutData(gridData);
+ Button findBt = new Button(composite, SWT.PUSH);
+ findBt.setText(resources.getString("ProcPage.Button.Browse"));
+ findBt.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent evt) {
+ PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(target);
+ 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());
+ wizard.setEnableFinish(true);
+ wizard.getContainer().updateButtons();
+ } else {
+ wizard.setEnableFinish(false);
+ wizard.getContainer().updateButtons();
+ }
+ }
+ });
}
-
+
private void createProcessInfoComposite(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout gridLayout = new GridLayout();
+ 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(resources.getString("ProcPage.Label.ProcPath"));
-
- pathText = new Text(composite, SWT.BORDER | SWT.READ_ONLY);
- pathText.setLayoutData(gridData);
+ 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(resources.getString("ProcPage.Label.ProcPath"));
+
+ pathText = new Text(composite, SWT.BORDER | SWT.READ_ONLY);
+ pathText.setLayoutData(gridData);
}
-
+
public String getProgramPath() {
- return pathText.getText().trim();
+ return pathText.getText().trim();
}
-
+
public int getPid() {
- return pid;
+ return pid;
+ }
+
+ public String getRootstrapPath() {
+ return rootPath;
+ }
+
+ public String getProcName() {
+ return procName;
+ }
+
+ public List<LocalPackage> getPackages() {
+ return packages;
}
-
- public String getRootstrapPath() {
- return rootPath;
- }
-
- public String getProcName() {
- return procName;
- }
-
- public ArrayList<LocalPackage> getPackages() {
- return packages;
- }
-
- public boolean getReinstallOp() {
- return reinstallOp.getSelection();
- }
-
- public boolean getSelectPkgOp() {
- return selectPkgOp.getSelection();
- }
-
-
+
+ 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);
+ 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);
+ IPackager packager = PackagerFactory.getPackager(targetProj, config);
+ packagingResult = packager.packaging(monitor);
+ }
+ });
+ } else {
+ getContainer().run(true, true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+ // packagingResult =
+ // PlatformProjectPackaging.RPMPackaging(targetProj,
+ // config, monitor);
+ IPackager packager = PackagerFactory.getPackager(targetProj, config);
+ packagingResult = packager.packaging(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);
+ } else {
+ MessageDialog.openError(shell, CommonBuildMessages.BUILD_RESULT,
+ CommonBuildMessages.FAIL_TO_BUILD_PACKAGE);
result = false;
- }
-
+ }
+
return result;
- }
+ }
}
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
-import java.util.ResourceBundle;
+import java.util.List;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.core.resources.IProject;
import org.tizen.common.util.SWTUtil;
import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativeplatform.build.PlatformConfigurationManager;
-import org.tizen.nativeplatform.launch.TizenDebianLaunchMessages;
+import org.tizen.nativeplatform.launch.PlatformLaunchMessages;
import org.tizen.nativeplatform.launch.wizard.pages.PlatformLaunchSettingProcPage;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
-import org.tizen.nativeplatform.views.ui.AddRootstrapDialog;
-
public class PlatformAttachLaunchWizard extends PlatformLaunchWizard {
-
- 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(this, 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();
-
- final String targetId = PlatformConfigurationManager.getBuildTargetName(config);
- final String rootstrapId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetId);
-
- //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<LocalPackage> BuildSystemPkgs = new ArrayList<LocalPackage>();
- final ArrayList<LocalPackage> DevicePkgs = new ArrayList<LocalPackage>();
-
- if (!launchUtil.validateRootstrap(rootstrapId)) {
- String msg = String.format(TizenDebianLaunchMessages.IS_NOT_INITIALIZED_ROOTSTRAP,
- rootstrapId);
- openErrorDialog(msg);
- return;
- }
- launchUtil.filterBuildsystemPkgs(packages, BuildSystemPkgs, rootstrapPath, reinstallOp);
-
- if (selectPkgOp) {
- if (!openPkgStatusDialog(BuildSystemPkgs, DevicePkgs)) {
- return;
- }
- }
-
- ArrayList<LocalPackage> 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;
- }
-
- public void openErrorDialog(final String error) {
- SWTUtil.syncExec(new Runnable() {
+
+ private int pid;
+ private String procName;
+
+ private final String SETTING_PROC_PAGE = "setting_proc";
+
+ public PlatformAttachLaunchWizard(Shell shell, IProject project, IConfiguration config,
+ PkgCommandTarget target, String mode) {
+ super(shell, project, config, target, mode);
+ }
+
+ @Override
+ public void addPages() {
+ addPage(new PlatformLaunchSettingProcPage(this, shell, SETTING_PROC_PAGE, project, config,
+ target));
+
+ 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(target);
+ reinstallOp = page.getReinstallOp();
+ selectPkgOp = page.getSelectPkgOp();
+ procName = page.getProcName();
+ pid = page.getPid();
+
+ final String targetId = PlatformConfigurationManager.getBuildTargetName(config);
+ final String rootstrapId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(
+ targetId);
+
+ // container.run(fork, cancelable, runnable)
+
+ try {
+ container.run(true, true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+ monitor.beginTask(PlatformLaunchMessages.INSTALL_PACKAGE, 2);
+ monitor.subTask(PlatformLaunchMessages.CHECK_PKG_STATUS);
+
+ final ArrayList<LocalPackage> BuildSystemPkgs = new ArrayList<LocalPackage>();
+ final ArrayList<LocalPackage> DevicePkgs = new ArrayList<LocalPackage>();
+
+ if (!launchUtil.validateRootstrap(rootstrapId)) {
+ String msg = String.format(
+ PlatformLaunchMessages.IS_NOT_INITIALIZED_ROOTSTRAP, rootstrapId);
+ openErrorDialog(msg);
+ return;
+ }
+ launchUtil.filterBuildsystemPkgs(packages, BuildSystemPkgs, reinstallOp);
+
+ if (selectPkgOp) {
+ if (!openPkgStatusDialog(BuildSystemPkgs, DevicePkgs)) {
+ return;
+ }
+ }
+
+ List<LocalPackage> selecteBsPkgs = launchUtil
+ .getSelectedPackages(BuildSystemPkgs);
+
+ monitor.worked(1);
+ monitor.subTask(PlatformLaunchMessages.INSTALL_PACKAGES_TO_BUILDSYSTEM);
+
+ if (selecteBsPkgs != null && !selecteBsPkgs.isEmpty()) {
+ launchUtil.installPkgsToRootstrap(selecteBsPkgs, monitor);
+ }
+
+ monitor.done();
+ }
+ });
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ openLogDialog(PlatformLaunchMessages.FAILED_INSTALL_PKGS, e.getMessage());
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ openLogDialog(PlatformLaunchMessages.FAILED_INSTALL_PKGS, e.getMessage());
+ }
+
+ return true;
+ }
+
+ public void openErrorDialog(final String error) {
+ SWTUtil.syncExec(new Runnable() {
public void run() {
- DialogUtil.openErrorDialog(error);
+ DialogUtil.openErrorDialog(error);
}
});
- }
+ }
}
package org.tizen.nativeplatform.launch.wizards;
+import static org.tizen.sdblib.service.SyncServiceConstants.RESULT_OK;
+import static org.tizen.sdblib.util.DeviceUtil.isOnline;
+
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;
import org.eclipse.cdt.core.IProcessInfo;
import org.eclipse.cdt.core.IProcessList;
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.TizenPlatformConstants;
-import org.tizen.common.ui.view.console.ConsoleManager;
-import org.tizen.common.util.FileUtil;
import org.tizen.nativecommon.TizenNativeException;
-import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativecommon.launch.LaunchUtils;
import org.tizen.nativecommon.launch.TizenDeviceProcessList;
import org.tizen.nativecommon.launch.TizenLaunchCommand;
import org.tizen.nativecommon.launch.TizenLaunchMessages;
+import org.tizen.nativeplatform.IPlatformXMLStore;
import org.tizen.nativeplatform.build.PlatformConfigurationManager;
-import org.tizen.nativeplatform.launch.TizenDebianLaunchMessages;
-import org.tizen.nativeplatform.pkgmgr.PackageManagerOuputReceiver;
-import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander;
+import org.tizen.nativeplatform.filefilter.RpmFileFilter;
+import org.tizen.nativeplatform.launch.PlatformLaunchMessages;
+import org.tizen.nativeplatform.pkg.commander.ICommandStatus;
+import org.tizen.nativeplatform.pkg.commander.IPkgCommander;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
+import org.tizen.nativeplatform.pkgmgr.PkgMgrInitializer;
import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
import org.tizen.nativeplatform.pkgmgr.model.Package;
-import org.tizen.nativeplatform.preferences.PreferencesManager;
import org.tizen.nativeplatform.rootstrap.RootstrapManager;
-import org.tizen.nativeplatform.views.model.PlatformRootstrap;
+import org.tizen.nativeplatform.util.PlatformProjectUtil;
import org.tizen.sdblib.IDevice;
-import org.tizen.sdblib.SdbCommandRejectedException;
-import org.tizen.sdblib.SyncService;
-import org.tizen.sdblib.SyncService.SyncResult;
-import org.tizen.sdblib.TimeoutException;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
+import org.tizen.sdblib.exception.SdbCommandRejectedException;
+import org.tizen.sdblib.exception.TimeoutException;
+import org.tizen.sdblib.service.SyncResult;
+import org.tizen.sdblib.util.DeviceUtil;
@SuppressWarnings("restriction")
public class PlatformLaunchUtils {
-
- private IProcessInfo procInfo;
-
- public PlatformLaunchUtils() {
-
- }
-
- public boolean installPkgsToRootstrap(ArrayList<LocalPackage> packages, String rootPath,
- IProgressMonitor monitor) throws InterruptedException {
-
- monitor.beginTask("Installing packages to rootstrap", 3);
-
- String rpmPathList = "";
- String localPkgList = "";
-
- for (LocalPackage p : packages) {
- String filePath = p.getPath();
- String filename = new File(filePath).getName();
- String pathOnRootstrap = "/tmp/" + filename;
- String copyToPath = rootPath + pathOnRootstrap;
- try {
- FileUtil.copyTo(filePath, copyToPath);
- } catch (IOException e) {
- e.printStackTrace();
- }
- rpmPathList = rpmPathList.concat(pathOnRootstrap + " ");
- localPkgList = localPkgList.concat(p.getName() + " ");
- }
-
- boolean error = false;
- String log = "";
-
- //monitor.subTask("Installing packages..");
-
-
- String proxy = PreferencesManager.getProxyURL();
- RPMPackageCommander.setHttpProxy(proxy);
- Document doc = RPMPackageCommander.InstallPkgWithZypperXmlOut(rootPath, rpmPathList, true, true);
-
- doc.getDocumentElement().normalize();
- NodeList messageNodes = doc.getElementsByTagName("message");
-
-
- for (int i = 0; i < messageNodes.getLength() ; i++) {
- Node ii = messageNodes.item(i);
- NamedNodeMap map = ii.getAttributes();
- Node node = map.getNamedItem("type");
- if (node != null) {
- String type = node.getNodeValue();
- if (type.equals("error")) {
- error = true;
- log = log + "[ERROR] " + ii.getFirstChild().getNodeValue() + "\n";
- } else {
- log = log + "[INFO] " + ii.getFirstChild().getNodeValue() + "\n";
- }
- }
- }
-
- if (error) {
- newException(log);
- }
- monitor.worked(1);
-
- monitor.subTask("Checking installed successfully..");
- String failedInstallPkgs = "";
- for (LocalPackage p : packages) {
- String name = p.getName();
- if(!RPMPackageCommander.pkgInstalledSuccessfullyForRootstrap(name, rootPath)) {
- failedInstallPkgs = failedInstallPkgs + " - " + name + newline();
- }
- }
-
- if (failedInstallPkgs != "") {
- newException(log);
- }
- monitor.worked(2);
- monitor.done();
-
- return true;
- }
-
- public boolean installPkgsToDevice(ArrayList<LocalPackage> packages, IDevice device, IProgressMonitor monitor)
- throws InterruptedException {
-
- monitor.beginTask("Installing packages to rootstrap", 3);
-
- if (!device.isRoot()) {
- String msg = "Device is not root on";
- newException(msg);
+
+ private PkgCommandTarget target;
+ private IProcessInfo procInfo;
+
+ public PlatformLaunchUtils(PkgCommandTarget target) {
+ this.target = target;
+ }
+
+ public boolean installPkgsToRootstrap(List<LocalPackage> packages, IProgressMonitor monitor)
+ throws InterruptedException {
+ if (!target.getRootstrap().checkInitialized()) {
+ newException(String.format(PlatformLaunchMessages.IS_NOT_INITIALIZED_ROOTSTRAP, target
+ .getRootstrap().getId()));
+ } else {
+ PkgMgrInitializer initializer = new PkgMgrInitializer(target);
+ initializer.initRootstrapRepoInfo();
+ }
+ return installPkgs(target.getRootstrapCommander(), IPkgCommander.TOOL.ZYPPER, packages,
+ monitor);
+ }
+
+ public boolean installPkgsToDevice(List<LocalPackage> packages, IProgressMonitor monitor)
+ throws InterruptedException {
+ if (!isOnline(target.getDevice())) {
+ newException(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE);
+ } else if (!target.getDevice().isRoot()) {
+ newException(PlatformLaunchMessages.DEVICE_IS_NOT_ROOT_ON);
+ } else {
+ PkgMgrInitializer initializer = new PkgMgrInitializer(target);
+ initializer.initDeviceRepoInfo();
+ }
+ return installPkgs(target.getDeviceCommander(), IPkgCommander.TOOL.ZYPPER, packages,
+ monitor);
+ }
+
+ public boolean installPkgsToDevice(List<LocalPackage> packages, IPkgCommander.TOOL type,
+ IProgressMonitor monitor) throws InterruptedException {
+ if (!DeviceUtil.isOnline(target.getDevice())) {
+ newException(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE);
+ } else if (!target.getDevice().isRoot()) {
+ newException(PlatformLaunchMessages.DEVICE_IS_NOT_ROOT_ON);
+ } else {
+ PkgMgrInitializer initializer = new PkgMgrInitializer(target);
+ initializer.initDeviceRepoInfo();
+ }
+ return installPkgs(target.getDeviceCommander(), type, packages, monitor);
+ }
+
+ private boolean installPkgs(IPkgCommander commander, IPkgCommander.TOOL type,
+ List<LocalPackage> packages, IProgressMonitor monitor) throws InterruptedException {
+ monitor.beginTask("Installing packages to rootstrap", 2);
+
+ List<String> paths = new ArrayList<String>();
+
+ for (LocalPackage p : packages) {
+ String filePath = p.getPath();
+ paths.add(filePath.trim());
}
-
- ArrayList<LocalPackage> packagesForDevice = new ArrayList<LocalPackage>();
- ConsoleManager cm = new ConsoleManager("package manager", true);
- //cm.clear();
- MessageConsoleStream mcs = cm.getMessageConsoleStream();
- PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver();
- rec.setMessageConsoleStream(mcs);
-
- ArrayList<String> localPkgList = new ArrayList<String>();
-
- for (LocalPackage p : packages) {
- String file = new File(p.getPath()).getName();
-
- if (file.contains("-debugsource") || file.contains("-debuginfo") ||
- file.contains("-devel")) {
- continue;
- }
-
- packagesForDevice.add(p);
- localPkgList.add(p.getPath());
- }
-
- //monitor.subTask("Installing packages..");
- RPMPackageCommander.InstallLocalPkgToDevice(localPkgList, device);
- monitor.worked(1);
-
- // check to install successfully
- monitor.subTask("Checking installed successfully..");
- String failedInstallPkgs = "";
- for (LocalPackage p : packagesForDevice) {
- String name = p.getName();
- if(!RPMPackageCommander.pkgInstalledSuccessfullyForDevice(name, device, rec)) {
- failedInstallPkgs = failedInstallPkgs + " - " + name + newline();
- }
- }
-
- if (failedInstallPkgs != "") {
- String msg = String.format("Follow package does not installed successfully.\n\n" +
- "%s\n" +
- "You can install package through package manager manually.", failedInstallPkgs);
- newException(msg);
- return false;
- }
- monitor.worked(2);
- monitor.done();
-
- return true;
- }
-
- private String newline() {
- return "\n";
- }
+
+ ICommandStatus status = commander.installLocalPkg(paths.toArray(new String[0]), type,
+ monitor);
+ monitor.worked(1);
+
+ if (!status.isOk()) {
+ newException(status.getMessage());
+ }
+
+ List<String> value = status.getValues();
+ String log = "";
+ if (value != null && !value.isEmpty()) {
+ for (String s : value) {
+ log += s + newline();
+ }
+ }
+
+ monitor.subTask("Checking installed successfully..");
+ String failedInstallPkgs = "";
+ for (LocalPackage p : packages) {
+ String name = p.getName();
+ if (!commander.checkPkgInstalled(name)) {
+ failedInstallPkgs = failedInstallPkgs + " - " + name + newline();
+ }
+ }
+ monitor.worked(2);
+
+ if (!failedInstallPkgs.isEmpty()) {
+ newException(log);
+ }
+
+ return true;
+ }
+
+ private String newline() {
+ return "\n";
+ }
protected void newException(String message) throws InterruptedException {
- //Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, message, exception);
- //throw new CoreException(status);
- throw new InterruptedException(message);
+ throw new InterruptedException(message);
}
-
+
public IProject getProjectInstance(String projectName) {
- IWorkspace works = ResourcesPlugin.getWorkspace();
- IProject[] projs = works.getRoot().getProjects();
- IProject result = null;
- for (IProject p : projs) {
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(p);
- if( info == null) {
- continue;
- }
- IConfiguration cfg = info.getDefaultConfiguration();
- if( cfg == null) {
- continue;
- }
- IManagedProject managedProject = cfg.getManagedProject();
- if( managedProject == null) {
- continue;
- }
- String projectArtifactType = managedProject.getProjectType() != null ? managedProject.getProjectType().getBuildArtefactType().getId() : null;
- if (projectArtifactType != null &&
- projectArtifactType.equals(PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE) &&
- projectName.equals(p.getName())) {
- result = p;
- break;
- }
- }
-
- return result;
+ IWorkspace works = ResourcesPlugin.getWorkspace();
+ IProject[] projs = works.getRoot().getProjects();
+ IProject result = null;
+ for (IProject p : projs) {
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(p);
+ if (info == null) {
+ continue;
+ }
+ IConfiguration cfg = info.getDefaultConfiguration();
+ if (cfg == null) {
+ continue;
+ }
+ IManagedProject managedProject = cfg.getManagedProject();
+ if (managedProject == null) {
+ continue;
+ }
+ String projectArtifactType = managedProject.getProjectType() != null ? managedProject
+ .getProjectType().getBuildArtefactType().getId() : null;
+ if (projectArtifactType != null
+ && projectArtifactType
+ .equals(PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE)
+ && projectName.equals(p.getName())) {
+ result = p;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ public List<LocalPackage> getProjectPackages(IProject project, String configName) {
+ List<LocalPackage> pkgs = new ArrayList<LocalPackage>();
+ IFolder folder = project.getFolder(configName);
+ File dir = new File(folder.getLocation().toOSString());
+ if (dir.exists()) {
+ // get ".rpm" file list
+ String[] files = dir.list(new RpmFileFilter());
+ for (String file : files) {
+ IPath pkgPath = new Path(dir.getPath()).append(file);
+ LocalPackage pkg = getLocalPackage(pkgPath.toOSString());
+ pkgs.add(pkg);
+ }
+ }
+
+ return pkgs;
+ }
+
+ public LocalPackage getLocalPackage(String pkgfilePath) {
+ LocalPackage pkg = new LocalPackage();
+ pkg.setPath(pkgfilePath);
+ String name = target.getHostCommander().getNameFromFile(pkg.getPath());
+ pkg.setName(name);
+ return pkg;
}
-
- public ArrayList<LocalPackage> getProjectPackages(IProject project, String configName) {
- ArrayList<LocalPackage> pkgs = new ArrayList<LocalPackage>();
- IFolder folder = project.getFolder(configName);
- File dir = new File(folder.getLocation().toOSString());
- if (dir.exists()) {
- for (File f : dir.listFiles()) {
- if (f.isFile() && f.getName().endsWith(".rpm")) {
- IPath pkgPath = new Path(dir.getPath()).append(f.getName());
- LocalPackage pkg = getLocalPackage(pkgPath.toOSString());
- pkgs.add(pkg);
- }
- }
- }
-
- return pkgs;
+
+ public List<LocalPackage> getLocalPackages(List<String> pkgPaths) {
+ List<LocalPackage> pkgs = new ArrayList<LocalPackage>();
+ for (String path : pkgPaths) {
+ LocalPackage pkg = getLocalPackage(path);
+ pkgs.add(pkg);
+ }
+
+ return pkgs;
}
-
- public LocalPackage getLocalPackage(String pkgfilePath) {
- LocalPackage pkg = new LocalPackage();
- pkg.setPath(pkgfilePath);
- String name = RPMPackageCommander.getPkgNameForFile(pkg.getPath());
- pkg.setName(name);
- return pkg;
+
+ public void filterBuildsystemPkgs(List<LocalPackage> totalPackages,
+ List<LocalPackage> buildsystePkgs, boolean reinstallOp) {
+
+ for (LocalPackage pkg : totalPackages) {
+ buildsystePkgs.add(pkg.clone());
+ }
+ updatePkgs(target.getRootstrapCommander(), buildsystePkgs, reinstallOp);
}
-
- public ArrayList<LocalPackage> getLocalPackages(ArrayList<String> pkgPaths) {
- ArrayList<LocalPackage> pkgs = new ArrayList<LocalPackage>();
- for (String path : pkgPaths) {
- LocalPackage pkg = getLocalPackage(path);
- pkgs.add(pkg);
- }
-
- return pkgs;
- }
-
- public void filterBuildsystemPkgs(ArrayList<LocalPackage> totalPackages,
- ArrayList<LocalPackage> buildsystePkgs, String rootstrapPath, boolean reinstallOp) {
-
- for (LocalPackage pkg : totalPackages) {
- buildsystePkgs.add(pkg.clone());
- }
-
- updateBuildsystemPkgs(buildsystePkgs, rootstrapPath, reinstallOp);
- }
-
- public void filterDevicePackages(ArrayList<LocalPackage> totalPackages,
- ArrayList<LocalPackage> devicePkgs, IDevice device, boolean reinstallOp) {
-
- for (LocalPackage pkg : totalPackages) {
- String name = pkg.getName();
- if (name.contains("-debugsource") || name.contains("-debuginfo") ||
- name.contains("-devel")) {
- continue;
- } else {
- devicePkgs.add(pkg.clone());
- }
- }
-
- updateDevicePkgs(devicePkgs, device, reinstallOp);
- }
-
- private void updateBuildsystemPkgs(ArrayList<LocalPackage> pkgs, String rootstrapPath,
- boolean reinstallOp) {
- for (LocalPackage pkg : pkgs) {
- String newVer = RPMPackageCommander.getPkgVerForFile(pkg.getPath());
- String arch = RPMPackageCommander.getArchForFile(pkg.getPath());
- String installedVerForRootstrap = RPMPackageCommander.getPkgInstalledVerForRootstrap(pkg.getName(), rootstrapPath);
-
- pkg.setNewVersion(newVer);
- pkg.setArch(arch);
- pkg.setInstalledVersion(installedVerForRootstrap);
-
- pkg.setCheckColumn(true);
-
- if ("".equals(newVer)) {
- pkg.setCheckColumn(false);
- } else if (!"".equals(installedVerForRootstrap)) {
- if (!installedVerForRootstrap.equals(newVer)) {
- pkg.setInstallInfo(Package.INSTALLINFO.DIFFERENT_VERSION);
- } else {
- if (RPMPackageCommander.pkgInstalledSuccessfullyForRootstrap(pkg.getName(), rootstrapPath)) {
- pkg.setInstallInfo(Package.INSTALLINFO.INSTALLED);
- if (!reinstallOp) {
- pkg.setCheckColumn(false);
- }
- }
- }
- }
- }
- }
-
- private void updateDevicePkgs(ArrayList<LocalPackage> pkgs, IDevice device,
- boolean reinstallOp) {
- PackageManagerOuputReceiver rec = getNewOuputReceiver();
-
- for (LocalPackage pkg : pkgs) {
- String newVer = RPMPackageCommander.getPkgVerForFile(pkg.getPath());
- String arch = RPMPackageCommander.getArchForFile(pkg.getPath());
- String installedVer = RPMPackageCommander.getPkgInstalledVerForDevice(pkg.getName(), device, rec);
-
- pkg.setNewVersion(newVer);
- pkg.setArch(arch);
- pkg.setInstalledVersion(installedVer);
-
- pkg.setCheckColumn(true);
-
- if ("".equals(newVer)) {
- pkg.setCheckColumn(false);
- } else if (!"".equals(installedVer)) {
- if (!installedVer.equals(newVer)) {
- pkg.setInstallInfo(Package.INSTALLINFO.DIFFERENT_VERSION);
- } else {
- if (RPMPackageCommander.pkgInstalledSuccessfullyForDevice(pkg.getName(), device, rec)) {
- pkg.setInstallInfo(Package.INSTALLINFO.INSTALLED);
- if (!reinstallOp) {
- pkg.setCheckColumn(false);
- }
- }
- }
- }
- }
- }
-
- public ArrayList<LocalPackage> getSelectedPackages(ArrayList<LocalPackage> pkgs) {
- ArrayList<LocalPackage> selectedPkgs = new ArrayList<LocalPackage>();
- for (LocalPackage pkg : pkgs) {
- if (pkg.getCheckColumn()) {
- selectedPkgs.add(pkg);
- }
- }
-
- return selectedPkgs;
- }
-
-
- private PackageManagerOuputReceiver getNewOuputReceiver() {
- ConsoleManager cm = new ConsoleManager("debug launch", true);
- cm.clear();
- MessageConsoleStream mcs = cm.getMessageConsoleStream();
- PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver();
- rec.setMessageConsoleStream(mcs);
-
- return rec;
- }
-
- public IProcessInfo getProcess(final Shell shell, final IDevice device) {
- Display.getDefault().syncExec(new Runnable() {
+
+ public void filterDevicePackages(List<LocalPackage> totalPackages,
+ List<LocalPackage> devicePkgs, boolean reinstallOp) {
+
+ for (LocalPackage pkg : totalPackages) {
+ String name = pkg.getName();
+ if (name.contains("-debugsource") || name.contains("-debuginfo")
+ || name.contains("-devel")) {
+ continue;
+ } else {
+ devicePkgs.add(pkg.clone());
+ }
+ }
+ updatePkgs(target.getDeviceCommander(), devicePkgs, reinstallOp);
+ }
+
+ private void updatePkgs(IPkgCommander commander, List<LocalPackage> pkgs, boolean reinstallOp) {
+ for (LocalPackage pkg : pkgs) {
+ String newVer = commander.getVerFromFile(pkg.getPath());
+ String arch = commander.getArchFromFile(pkg.getPath());
+ String[] installedVer = commander.getVer(pkg.getName());
+
+ pkg.setCheckColumn(true);
+ pkg.setNewVersion(newVer);
+ pkg.setArch(arch);
+ if (installedVer.length > 0) {
+ pkg.setInstalledVersion(installedVer[0]);
+ } else {
+ continue;
+ }
+ if ("".equals(newVer)) {
+ pkg.setCheckColumn(false);
+ } else if (!"".equals(installedVer)) {
+ if (!installedVer[0].equals(newVer)) {
+ pkg.setInstallInfo(Package.INSTALLINFO.DIFFERENT_VERSION);
+ } else {
+ if (commander.checkPkgInstalled(pkg.getName())) {
+ pkg.setInstallInfo(Package.INSTALLINFO.INSTALLED);
+ if (!reinstallOp) {
+ pkg.setCheckColumn(false);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public List<LocalPackage> getSelectedPackages(List<LocalPackage> pkgs) {
+ List<LocalPackage> selectedPkgs = new ArrayList<LocalPackage>();
+ for (LocalPackage pkg : pkgs) {
+ if (pkg.getCheckColumn()) {
+ selectedPkgs.add(pkg);
+ }
+ }
+
+ return selectedPkgs;
+ }
+
+ public IProcessInfo getProcess(final Shell shell, final IDevice device) {
+ Display.getDefault().syncExec(new Runnable() {
public void run() {
- procInfo = selectProcess(shell, device, null);
+ procInfo = selectProcess(shell, device, null);
}
});
-
- return procInfo;
+
+ return procInfo;
}
-
- public IProcessInfo getProcess(final Shell shell, final IDevice device, final String procName) {
- Display.getDefault().syncExec(new Runnable() {
+
+ 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);
+ procInfo = selectProcess(shell, device, procName);
}
});
-
- return procInfo;
+
+ return procInfo;
}
-
+
private IProcessInfo selectProcess(Shell shell, IDevice device, String procName) {
if (shell == null) {
return null;
}
-
+
IProcessList processList = null;
- processList = new TizenDeviceProcessList(device);
-
+ processList = new TizenDeviceProcessList(device);
+
IProcessInfo pInfos[] = null;
IProcessInfo resultInfo = null;
pInfos = processList.getProcessList();
-
- if(pInfos == null) {
- return null;
+
+ 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++;
- }
- }
+ for (IProcessInfo info : pInfos) {
+ String name = new Path(info.getName()).lastSegment().trim();
+ if (procName.equals(name)) {
+ resultInfo = info;
+ count++;
+ }
+ }
}
-
+
if (count == 1) {
- return resultInfo;
+ return resultInfo;
}
ILabelProvider topprovider = new LabelProvider() {
public String getText(Object element) {
- IProcessInfo pinfo = (IProcessInfo)element;
+ IProcessInfo pinfo = (IProcessInfo) element;
IPath ppath = new Path(pinfo.getName());
return ppath.lastSegment().trim() + " [" + String.valueOf(pinfo.getPid()) + "]"; //$NON-NLS-1$
}
return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC);
}
};
-
+
ILabelProvider downprovider = new LabelProvider() {
public String getText(Object element) {
- IProcessInfo info = (IProcessInfo)element;
+ IProcessInfo info = (IProcessInfo) element;
return info.getName();
}
return LaunchImages.get(LaunchImages.IMG_OBJS_EXEC);
}
};
-
+
TwoPaneElementSelector dlg = new TwoPaneElementSelector(shell, topprovider, downprovider);
dlg.setTitle(String.format("Select Process [%s]", device.getDeviceName())); //$NON-NLS-1$
String dlgMsg = "";
if (procName != null && count == 0) {
- dlgMsg = String.format("There is no \"%s\" process.\n", procName);
+ 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:";
+ 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;
+ 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;
- }
- }
-
- public boolean checkGdbServerInDevice(IDevice device, TizenLaunchCommand command)
- throws CoreException {
-
- String resultCommand = TizenPlatformConstants.GDBSERVER_PLATFORM_CMD + " --version"
+
+ 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;
+ }
+ }
+
+ public boolean checkGdbServerInDevice(IDevice device, TizenLaunchCommand command)
+ throws CoreException {
+
+ String resultCommand = TizenPlatformConstants.GDBSERVER_PLATFORM_CMD + " --version"
+ TizenPlatformConstants.CMD_RESULT_CHECK;
- try {
- command.run(resultCommand, "0");
- } catch (TizenNativeException e) {
- return false;
+ try {
+ command.run(resultCommand, "0");
+ } catch (TizenNativeException e) {
+ return false;
} catch (Exception e) {
- return false;
+ return false;
}
-
+
return true;
- }
-
- public void readyGdbServer(IDevice device, TizenLaunchCommand command, IPath srcPath)
- throws CoreException, TimeoutException, SdbCommandRejectedException, IOException, Exception {
- File gdbserver = new File(srcPath.toOSString());
-
- if (!gdbserver.exists()) {
- LaunchUtils.newCoreException(NLS.bind(TizenLaunchMessages.CANNOT_FIND_GDBSERVER, device.getDeviceName()), null);
- }
-
- if (!checkGdbServerInDevice(device, command)) {
- copyFileToDevice(device, srcPath.toOSString(), TizenPlatformConstants.GDBSERVER_PLATFORM_CMD);
- device.executeShellCommand(String.format("chmod +x %s", TizenPlatformConstants.GDBSERVER_PLATFORM_CMD));
- }
- }
-
- public void copyFileToDevice(IDevice device, String srcPath, String descPath) throws CoreException, TimeoutException, SdbCommandRejectedException, IOException {
- SyncResult syncSuccess = device.getSyncService().pushFile(srcPath,
- descPath, SyncService.getNullProgressMonitor());
-
- if (syncSuccess.getCode() != SyncService.RESULT_OK) {
+ }
+
+ public void readyGdbServer(IDevice device, TizenLaunchCommand command, IPath srcPath)
+ throws CoreException, TimeoutException, SdbCommandRejectedException, IOException,
+ Exception {
+ File gdbserver = new File(srcPath.toOSString());
+
+ if (!gdbserver.exists()) {
+ LaunchUtils.newCoreException(
+ NLS.bind(TizenLaunchMessages.CANNOT_FIND_GDBSERVER, device.getDeviceName()),
+ null);
+ }
+
+ if (!checkGdbServerInDevice(device, command)) {
+ copyFileToDevice(device, srcPath.toOSString(),
+ TizenPlatformConstants.GDBSERVER_PLATFORM_CMD);
+ device.executeShellCommand(String.format("chmod +x %s",
+ TizenPlatformConstants.GDBSERVER_PLATFORM_CMD));
+ }
+ }
+
+ public void copyFileToDevice(IDevice device, String srcPath, String descPath)
+ throws CoreException, TimeoutException, SdbCommandRejectedException, IOException {
+ String path = new Path(descPath).removeLastSegments(1).toOSString();
+ SyncResult syncResult = device.getSyncService().push(srcPath, device.getFileEntry(path));
+ if (syncResult.getCode() != RESULT_OK) {
LaunchUtils.newCoreException(TizenLaunchMessages.CANNOT_TRANSFER_FILE, null);
}
- }
-
- public boolean checkGdbServerInBuildSystem(String rootstrapPath) {
- IPath path = new Path(rootstrapPath).append("usr").append("bin").append("gdbserver");
- File gdbserver = new File(path.toOSString());
-
- return gdbserver.exists();
- }
-
- public boolean validateRootstrap(String rootstrapId) {
- return RootstrapManager.isInitialized(rootstrapId);
- }
+ }
+
+ public boolean checkGdbServerInBuildSystem(String rootstrapPath) {
+ IPath path = new Path(rootstrapPath).append("usr").append("bin").append("gdbserver");
+ File gdbserver = new File(path.toOSString());
+
+ return gdbserver.exists();
+ }
+
+ public boolean validateRootstrap(String rootstrapId) {
+ // return RootstrapManager.isInitialized(rootstrapId);
+ return RootstrapManager.checkInitialized(rootstrapId);
+ }
+
+ public String[] getProgramPath(IProject project) {
+ IPlatformXMLStore store = PlatformProjectUtil.getManifestXmlStore(project);
+ if (store.loadXml()) {
+ return getProgramPath(store);
+ } else {
+ return null;
+ }
+ }
+
+ public String[] getProgramPath(IPlatformXMLStore store) {
+ List<String> files = store.getExecutableFiles();
+ if (files != null && files.size() > 0) {
+ // return files.get(0);
+ return files.toArray(new String[0]);
+ } else {
+ return null;
+ }
+ }
}
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.List;
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.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.widgets.Shell;
-import org.tizen.common.connection.ConnectionPlugin;
import org.tizen.common.util.DialogUtil;
import org.tizen.common.util.SWTUtil;
import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativeplatform.build.PlatformConfigurationManager;
-import org.tizen.nativeplatform.launch.TizenDebianLaunchMessages;
+import org.tizen.nativeplatform.launch.PlatformLaunchMessages;
import org.tizen.nativeplatform.launch.wizard.pages.PlatformLaunchSettingAppPage;
import org.tizen.nativeplatform.launch.wizard.pages.PlatformLaunchSettingBinPage;
+import org.tizen.nativeplatform.pkg.commander.IPkgCommander;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
+import org.tizen.nativeplatform.util.PlatformProjectUtil;
import org.tizen.sdblib.IDevice;
-public class PlatformLaunchWizard extends Wizard implements IPageChangingListener, IPageChangedListener {
-
- 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<LocalPackage> packages = new ArrayList<LocalPackage>();
- protected ArrayList<LocalPackage> extraPackages = new ArrayList<LocalPackage>();
- protected String appProject = "";
- protected String mode = "";
- protected boolean result;
- protected boolean canFinish = false;
-
- private final String SETTING_APP_PAGE = "setting_app";
- private final String SETTING_BIN_PAGE = "setting_bin";
-
- public PlatformLaunchWizard() {
- }
-
- 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);
- }
-
- @Override
- public boolean needsProgressMonitor() {
- return true;
- }
-
- @Override
- public boolean canFinish() {
- return canFinish;
- }
-
- public void setEnableFinish(boolean value) {
- canFinish = value;
- }
-
- @Override
- public boolean performFinish() {
- PlatformLaunchSettingBinPage binPage = (PlatformLaunchSettingBinPage)getPage(SETTING_BIN_PAGE);
- programPath = binPage.getPath();
-
- PlatformLaunchSettingAppPage appPage = (PlatformLaunchSettingAppPage)getPage(SETTING_APP_PAGE);
- appProjectName = appPage.getAppProjectName();
- extraPackages = appPage.getExtraPackages();
-
- return true;
- }
-
- public String getProgramPath() {
- return programPath;
- }
-
- public ArrayList<LocalPackage> getPackages() {
- return packages;
- }
-
- public ArrayList<LocalPackage> getExtraPackages() {
- return extraPackages;
- }
-
- public String getAppProjectName() {
- return appProjectName;
- }
-
- public boolean getReinstallOp() {
- return reinstallOp;
- }
-
- public boolean getSelectPkgOp() {
- return selectPkgOp;
- }
-
- @Override
- public void addPages() {
- addPage(new PlatformLaunchSettingAppPage(shell, SETTING_APP_PAGE, project, config));
- addPage(new PlatformLaunchSettingBinPage(this, SETTING_BIN_PAGE));
-
- WizardDialog dialog = (WizardDialog)getContainer();
- dialog.addPageChangedListener(this);
- dialog.addPageChangingListener(this);
- }
-
- @Override
- public void pageChanged(PageChangedEvent event) {
- }
-
- @Override
- public void handlePageChanging(final PageChangingEvent event) {
- // TODO Auto-generated method stub
- WizardPage currentPage = (WizardPage)event.getCurrentPage();
- WizardPage targetPage = (WizardPage)event.getTargetPage();
-
- if (currentPage.getName().equals(SETTING_APP_PAGE) && targetPage.getName().equals(SETTING_BIN_PAGE)) {
- PlatformLaunchSettingAppPage page = (PlatformLaunchSettingAppPage)currentPage;
- final String rootstrapPath = page.getRootstrapPath();
- packages = page.getPackages();
- IWizardContainer container = getContainer();
- final PlatformLaunchUtils launchUtil = new PlatformLaunchUtils();
- final IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
- reinstallOp = page.getReinstallOp();
- selectPkgOp = page.getSelectPkgOp();
-
- final String targetId = PlatformConfigurationManager.getBuildTargetName(config);
- final String rootstrapId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetId);
-
- //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, 3);
- monitor.subTask(TizenDebianLaunchMessages.CHECK_PKG_STATUS);
-
- final ArrayList<LocalPackage> BuildSystemPkgs = new ArrayList<LocalPackage>();
- final ArrayList<LocalPackage> DevicePkgs = new ArrayList<LocalPackage>();
-
- if (mode.equals(ILaunchManager.DEBUG_MODE)) {
- if (!launchUtil.validateRootstrap(rootstrapId)) {
- String msg = String.format(TizenDebianLaunchMessages.IS_NOT_INITIALIZED_ROOTSTRAP,
- rootstrapId);
- openErrorDialog(msg);
- cancelChanging(event);
- return;
- }
- launchUtil.filterBuildsystemPkgs(packages, BuildSystemPkgs, rootstrapPath, reinstallOp);
- }
- launchUtil.filterDevicePackages(packages, DevicePkgs, device, reinstallOp);
-
- if (selectPkgOp) {
- if (!openPkgStatusDialog(BuildSystemPkgs, DevicePkgs)) {
- cancelChanging(event);
- return;
- }
- }
-
- ArrayList<LocalPackage> selecteBsPkgs = launchUtil.getSelectedPackages(BuildSystemPkgs);
- ArrayList<LocalPackage> selecteDvPkgs = launchUtil.getSelectedPackages(DevicePkgs);
-
- monitor.worked(1);
- monitor.subTask(TizenDebianLaunchMessages.INSTALL_PACKAGES_TO_BUILDSYSTEM);
-
- if (selecteBsPkgs != null && !selecteBsPkgs.isEmpty()) {
- launchUtil.installPkgsToRootstrap(selecteBsPkgs, rootstrapPath, new SubProgressMonitor(monitor, 1));
- }
-
- monitor.subTask(TizenDebianLaunchMessages.INSTALL_PACKAGES_TO_DEVICE);
- if (selecteDvPkgs != null && !selecteDvPkgs.isEmpty()) {
- launchUtil.installPkgsToDevice(selecteDvPkgs, device, new SubProgressMonitor(monitor, 1));
- }
- monitor.done();
- }
- });
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- } catch (InterruptedException e) {
- // This exception is occurred if device is not root on or failed to install
- e.printStackTrace();
- openLogDialog(TizenDebianLaunchMessages.FAILED_INSTALL_PKGS, e.getMessage());
- cancelChanging(event);
- }
- }
- }
-
- public void cancelChanging(PageChangingEvent event) {
- event.doit = false;
- }
-
- public void openLogDialog(final String desc, final String log) {
- SWTUtil.syncExec(new Runnable() {
+public class PlatformLaunchWizard extends Wizard implements IPageChangingListener,
+ IPageChangedListener {
+
+ protected IProject project;
+ protected IConfiguration config;
+ protected IDevice device;
+ protected PkgCommandTarget target;
+ protected Shell shell;
+ protected String programPath = "";
+ protected String appProjectName = "";
+ protected boolean reinstallOp;
+ protected boolean selectPkgOp;
+ protected List<LocalPackage> packages = new ArrayList<LocalPackage>();
+ protected List<LocalPackage> extraPackages = new ArrayList<LocalPackage>();
+ protected String appProject = "";
+ protected String mode = "";
+ protected boolean result;
+ protected boolean canFinish = false;
+
+ private final String SETTING_APP_PAGE = "setting_app";
+ private final String SETTING_BIN_PAGE = "setting_bin";
+
+ public PlatformLaunchWizard() {
+ }
+
+ public PlatformLaunchWizard(Shell shell, IProject project, IConfiguration config,
+ PkgCommandTarget target, String mode) {
+ this.project = project;
+ this.config = config;
+ this.shell = shell;
+ this.target = target;
+ this.device = target.getDevice();
+ this.mode = mode;
+ setWindowTitle("Launch Configuration");
+ setNeedsProgressMonitor(true);
+ }
+
+ @Override
+ public boolean needsProgressMonitor() {
+ return true;
+ }
+
+ @Override
+ public boolean canFinish() {
+ return canFinish;
+ }
+
+ public void setEnableFinish(boolean value) {
+ canFinish = value;
+ }
+
+ @Override
+ public boolean performFinish() {
+ PlatformLaunchSettingBinPage binPage = (PlatformLaunchSettingBinPage) getPage(SETTING_BIN_PAGE);
+ programPath = binPage.getPath();
+
+ PlatformLaunchSettingAppPage appPage = (PlatformLaunchSettingAppPage) getPage(SETTING_APP_PAGE);
+ appProjectName = appPage.getAppProjectName();
+ extraPackages = appPage.getExtraPackages();
+
+ return true;
+ }
+
+ public String getProgramPath() {
+ return programPath;
+ }
+
+ public List<LocalPackage> getPackages() {
+ return packages;
+ }
+
+ public List<LocalPackage> getExtraPackages() {
+ return extraPackages;
+ }
+
+ public String getAppProjectName() {
+ return appProjectName;
+ }
+
+ public boolean getReinstallOp() {
+ return reinstallOp;
+ }
+
+ public boolean getSelectPkgOp() {
+ return selectPkgOp;
+ }
+
+ @Override
+ public void addPages() {
+ addPage(new PlatformLaunchSettingAppPage(shell, SETTING_APP_PAGE, project, config, target));
+ addPage(new PlatformLaunchSettingBinPage(this, SETTING_BIN_PAGE));
+
+ WizardDialog dialog = (WizardDialog) getContainer();
+ dialog.addPageChangedListener(this);
+ dialog.addPageChangingListener(this);
+ }
+
+ @Override
+ public void pageChanged(PageChangedEvent event) {
+ }
+
+ @Override
+ public void handlePageChanging(final PageChangingEvent event) {
+ // TODO Auto-generated method stub
+ WizardPage currentPage = (WizardPage) event.getCurrentPage();
+ WizardPage targetPage = (WizardPage) event.getTargetPage();
+
+ if (currentPage.getName().equals(SETTING_APP_PAGE)
+ && targetPage.getName().equals(SETTING_BIN_PAGE)) {
+ PlatformLaunchSettingAppPage page = (PlatformLaunchSettingAppPage) currentPage;
+ packages = page.getPackages();
+ IWizardContainer container = getContainer();
+ final PlatformLaunchUtils launchUtil = new PlatformLaunchUtils(target);
+ reinstallOp = page.getReinstallOp();
+ selectPkgOp = page.getSelectPkgOp();
+
+ final String targetId = PlatformConfigurationManager.getBuildTargetName(config);
+ final String rootstrapId = SmartBuildInterface.getInstance()
+ .getRootstrapIDFromTargetID(targetId);
+
+ // container.run(fork, cancelable, runnable)
+
+ try {
+ container.run(true, true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+ monitor.beginTask(PlatformLaunchMessages.INSTALL_PACKAGE, 3);
+ monitor.subTask(PlatformLaunchMessages.CHECK_PKG_STATUS);
+
+ final ArrayList<LocalPackage> BuildSystemPkgs = new ArrayList<LocalPackage>();
+ final ArrayList<LocalPackage> DevicePkgs = new ArrayList<LocalPackage>();
+
+ if (mode.equals(ILaunchManager.DEBUG_MODE)) {
+ if (!launchUtil.validateRootstrap(rootstrapId)) {
+ String msg = String.format(
+ PlatformLaunchMessages.IS_NOT_INITIALIZED_ROOTSTRAP,
+ rootstrapId);
+ openErrorDialog(msg);
+ cancelChanging(event);
+ return;
+ }
+ launchUtil
+ .filterBuildsystemPkgs(packages, BuildSystemPkgs, reinstallOp);
+ }
+ launchUtil.filterDevicePackages(packages, DevicePkgs, reinstallOp);
+
+ if (selectPkgOp) {
+ if (!openPkgStatusDialog(BuildSystemPkgs, DevicePkgs)) {
+ cancelChanging(event);
+ return;
+ }
+ }
+
+ List<LocalPackage> selecteBsPkgs = launchUtil
+ .getSelectedPackages(BuildSystemPkgs);
+ List<LocalPackage> selecteDvPkgs = launchUtil
+ .getSelectedPackages(DevicePkgs);
+
+ monitor.worked(1);
+ monitor.subTask(PlatformLaunchMessages.INSTALL_PACKAGES_TO_BUILDSYSTEM);
+
+ if (selecteBsPkgs != null && !selecteBsPkgs.isEmpty()) {
+ launchUtil.installPkgsToRootstrap(selecteBsPkgs, monitor);
+ }
+
+ monitor.subTask(PlatformLaunchMessages.INSTALL_PACKAGES_TO_DEVICE);
+ if (selecteDvPkgs != null && !selecteDvPkgs.isEmpty()) {
+ if (PlatformProjectUtil.isEFLApplication(project)) {
+ launchUtil.installPkgsToDevice(selecteDvPkgs,
+ IPkgCommander.TOOL.PKGCMD, monitor);
+ } else {
+ launchUtil.installPkgsToDevice(selecteDvPkgs, monitor);
+ }
+ }
+ monitor.done();
+ }
+ });
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ openLogDialog(PlatformLaunchMessages.FAILED_INSTALL_PKGS, e.getMessage());
+ cancelChanging(event);
+ } catch (InterruptedException e) {
+ // This exception is occurred if device is not root on or failed
+ // to install
+ e.printStackTrace();
+ openLogDialog(PlatformLaunchMessages.FAILED_INSTALL_PKGS, e.getMessage());
+ cancelChanging(event);
+ }
+ }
+ }
+
+ public void cancelChanging(PageChangingEvent event) {
+ event.doit = false;
+ }
+
+ public void openLogDialog(final String desc, final String log) {
+ SWTUtil.syncExec(new Runnable() {
public void run() {
- ShowLogDialog dialog = new ShowLogDialog(shell, desc, log);
+ ShowLogDialog dialog = new ShowLogDialog(shell, desc, log);
dialog.open();
}
});
- }
-
- public void openErrorDialog(final String error) {
- SWTUtil.syncExec(new Runnable() {
+ }
+
+ public void openErrorDialog(final String error) {
+ SWTUtil.syncExec(new Runnable() {
public void run() {
- DialogUtil.openErrorDialog(error);
+ DialogUtil.openErrorDialog(error);
}
});
- }
-
- public boolean openPkgStatusDialog(final ArrayList<LocalPackage> BuildSystemPkgs, final ArrayList<LocalPackage> DevicePkgs) {
- SWTUtil.syncExec(new Runnable() {
+ }
+
+ public boolean openPkgStatusDialog(final ArrayList<LocalPackage> BuildSystemPkgs,
+ final ArrayList<LocalPackage> DevicePkgs) {
+ SWTUtil.syncExec(new Runnable() {
public void run() {
- ShowPackageStatusDialog statusDlg = new ShowPackageStatusDialog(shell, BuildSystemPkgs, DevicePkgs);
- if (Window.OK == statusDlg.open()) {
- result = true;
- } else {
- result = false;
- }
+ ShowPackageStatusDialog statusDlg = new ShowPackageStatusDialog(shell,
+ BuildSystemPkgs, DevicePkgs);
+ if (Window.OK == statusDlg.open()) {
+ result = true;
+ } else {
+ result = false;
+ }
}
});
-
- return result;
- }
+
+ return result;
+ }
}
package org.tizen.nativeplatform.launch.wizards;
-import java.util.ArrayList;
+import java.util.List;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
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);
-
- 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;
- }
- }
-
- public ArrayList<LocalPackage> getExtraPackages() {
- if (wizard != null) {
- return wizard.getExtraPackages();
- } else {
- return null;
- }
- }
-
- public String getAppProjectName() {
- if (wizard != null) {
- return wizard.getAppProjectName();
- } else {
- return null;
- }
- }
-
- public boolean getReinstallOp() {
- if (wizard != null) {
- return wizard.getReinstallOp();
- } else if (attachWizard != null) {
- return attachWizard.getReinstallOp();
- } else {
- return true;
- }
- }
-
- 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;
- }
- }
+
+ private PlatformLaunchWizard wizard = null;
+ private PlatformAttachLaunchWizard attachWizard = null;
+
+ public PlatformLaunchWizardDialog(Shell shell, PlatformLaunchWizard wizard) {
+ super(shell, wizard);
+
+ 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;
+ }
+ }
+
+ public List<LocalPackage> getExtraPackages() {
+ if (wizard != null) {
+ return wizard.getExtraPackages();
+ } else {
+ return null;
+ }
+ }
+
+ public String getAppProjectName() {
+ if (wizard != null) {
+ return wizard.getAppProjectName();
+ } else {
+ return null;
+ }
+ }
+
+ public boolean getReinstallOp() {
+ if (wizard != null) {
+ return wizard.getReinstallOp();
+ } else if (attachWizard != null) {
+ return attachWizard.getReinstallOp();
+ } else {
+ return true;
+ }
+ }
+
+ 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;
+ }
+ }
}
--- /dev/null
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.launch.wizards;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+public class SelectItemDialog extends Dialog {
+
+ private int x = 0;
+ private int y = 0;
+ private final int width = 400;
+ private int height = 150;
+ private Shell shell;
+ private String[] items = null;
+ private Button[] radios = null;
+ private String selectedItem;
+ private final int MAX_HEIGHT = 800;
+
+ private final String TITLE = "Select executable binary";
+
+ public SelectItemDialog(Shell parentShell, String[] items) {
+ super(parentShell);
+ this.shell = parentShell;
+ this.items = items;
+ this.height = items.length * 80;
+ if (this.height > MAX_HEIGHT) {
+ this.height = MAX_HEIGHT;
+ }
+ Rectangle bounds = parentShell.getBounds();
+ x = bounds.x + (bounds.width - width)/2;
+ y = bounds.y + (bounds.height - height)/2;
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(TITLE);
+ newShell.setLocation(x, y);
+ newShell.setSize(width, height);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+
+ Composite composite = new Composite( parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ composite.setLayout(new GridLayout(1, false));
+
+ createSelectionGroup(composite);
+ return null;
+ }
+
+ private void createSelectionGroup(Composite parent) {
+
+ Composite composite = new Composite( parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
+ composite.setLayout(new GridLayout(1, false));
+
+ radios = new Button[items.length];
+ for(int i = 0 ; i < items.length ; i++) {
+ radios[i] = new Button(composite, SWT.RADIO);
+ radios[i].setText(items[i]);
+ if (i == 0) {
+ radios[i].setSelection(true);
+ }
+ }
+ }
+
+ public String getSelectedItem() {
+ return selectedItem;
+ }
+
+ @Override
+ protected void okPressed() {
+
+ for(int i = 0 ; i < radios.length ; i++) {
+ if (radios[i].getSelection()) {
+ selectedItem = radios[i].getText();
+ }
+ }
+
+ super.okPressed();
+ }
+}
import org.eclipse.swt.widgets.Text;
public class ShowLogDialog extends Dialog {
-
- private int x = 0;
- private int y = 0;
- private final int width = 700;
- private final int height = 500;
- private Shell shell;
- private String desc = "";
- private String log = "";
-
- protected ShowLogDialog(Shell parentShell, String desc, String log) {
- super(parentShell);
- this.shell = parentShell;
- Rectangle bounds = parentShell.getBounds();
- x = bounds.x + (bounds.width - width)/2;
- y = bounds.y + (bounds.height - height)/2;
-
+
+ private int x = 0;
+ private int y = 0;
+ private final int width = 700;
+ private final int height = 500;
+ private Shell shell;
+ private String desc = "";
+ private String log = "";
+
+ private final String TITLE = "Show log";
+
+ protected ShowLogDialog(Shell parentShell, String desc, String log) {
+ super(parentShell);
+ this.shell = parentShell;
+ Rectangle bounds = parentShell.getBounds();
+ x = bounds.x + (bounds.width - width) / 2;
+ y = bounds.y + (bounds.height - height) / 2;
+
this.desc = desc;
this.log = log;
- }
-
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
-
- newShell.setText("Show Log");
- newShell.setLocation(x, y);
- newShell.setSize(width, height);
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
-
- Composite composite = new Composite( parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- composite.setLayout(new GridLayout(1, false));
-
- createDescComposite(composite);
- createTextAreaComposite(composite);
- return null;
- }
-
- private void createDescComposite(Composite parent) {
-
- Composite composite = new Composite( parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
- composite.setLayout(new GridLayout(1, false));
-
- Label message = new Label(composite, SWT.NONE);
- message.setText(desc);
- }
-
- private void createTextAreaComposite(Composite parent) {
- Composite composite = new Composite( parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- composite.setLayout(new GridLayout(1, false));
-
- Text text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL);
- GridData gridData = new GridData(GridData.FILL_BOTH);
- text.setLayoutData(gridData);
- text.setText(log);
- }
-
- protected void createButtonsForButtonBar(Composite parent)
- {
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, true);
- }
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+
+ newShell.setText(TITLE);
+ newShell.setLocation(x, y);
+ newShell.setSize(width, height);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ composite.setLayout(new GridLayout(1, false));
+
+ createDescComposite(composite);
+ createTextAreaComposite(composite);
+ return null;
+ }
+
+ private void createDescComposite(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
+ | GridData.VERTICAL_ALIGN_BEGINNING));
+ composite.setLayout(new GridLayout(1, false));
+
+ Label message = new Label(composite, SWT.NONE);
+ message.setText(desc);
+ }
+
+ private void createTextAreaComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ composite.setLayout(new GridLayout(1, false));
+
+ Text text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL
+ | SWT.V_SCROLL);
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ text.setLayoutData(gridData);
+ text.setText(log);
+ }
+
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, true);
+ }
}
package org.tizen.nativeplatform.launch.wizards;
import java.util.ArrayList;
+import java.util.List;
import java.util.ResourceBundle;
import org.eclipse.jface.dialogs.Dialog;
import org.tizen.nativeplatform.pkgmgr.model.Package;
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 TableViewer bsViewer;
- private TableViewer dvViewer;
- private ArrayList<LocalPackage> bsPackages = new ArrayList<LocalPackage>();
- private ArrayList<LocalPackage> dvPackages = new ArrayList<LocalPackage>();
- private ArrayList<LocalPackage> selectedBsPackages = new ArrayList<LocalPackage>();
- private ArrayList<LocalPackage> selectedDvPackages = new ArrayList<LocalPackage>();
-
- public ShowPackageStatusDialog(Shell parentShell,
- ArrayList<LocalPackage> bsPkgs, ArrayList<LocalPackage> dvPkgs) {
- super(parentShell);
- Rectangle bounds = parentShell.getBounds();
- x = bounds.x + (bounds.width - width)/2;
- y = bounds.y + (bounds.height - height)/2;
+
+ 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 TableViewer bsViewer;
+ private TableViewer dvViewer;
+ private List<LocalPackage> bsPackages = new ArrayList<LocalPackage>();
+ private List<LocalPackage> dvPackages = new ArrayList<LocalPackage>();
+ private List<LocalPackage> selectedBsPackages = new ArrayList<LocalPackage>();
+ private List<LocalPackage> selectedDvPackages = new ArrayList<LocalPackage>();
+
+ public ShowPackageStatusDialog(Shell parentShell, List<LocalPackage> bsPkgs,
+ List<LocalPackage> dvPkgs) {
+ super(parentShell);
+ Rectangle bounds = parentShell.getBounds();
+ x = bounds.x + (bounds.width - width) / 2;
+ y = bounds.y + (bounds.height - height) / 2;
this.bsPackages = bsPkgs;
this.dvPackages = dvPkgs;
- }
-
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
-
- newShell.setText(resources.getString("PkgDialog.Title"));
- newShell.setLocation(x, y);
- newShell.setSize(width, height);
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
-
- Composite composite = new Composite( parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- composite.setLayout(new GridLayout(1, false));
-
- createDescComposite(composite);
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+
+ newShell.setText(resources.getString("PkgDialog.Title"));
+ newShell.setLocation(x, y);
+ newShell.setSize(width, height);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ composite.setLayout(new GridLayout(1, false));
+
+ createDescComposite(composite);
createBuildSystemLabelComposite(composite);
createBuildSystemComposite(composite);
createDeviceLabelComposite(composite);
createDeviceComposite(composite);
tableRefresh();
- return null;
- }
-
- private void createDescComposite(Composite parent) {
-
- Composite composite = new Composite( parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
- composite.setLayout(new GridLayout(1, false));
-
- Label message = new Label(composite, SWT.NONE);
- message.setText(resources.getString("PkgDialog.Desc"));
- }
-
- @Override
- protected void okPressed() {
- selectedBsPackages.clear();
- selectedDvPackages.clear();
-
- int recentTableIndex = bsViewer.getTable().getItemCount();
- for (int i = 0; i < recentTableIndex; i++) {
- TableItem item = null;
- item = bsViewer.getTable().getItem(i);
- LocalPackage pkg = (LocalPackage)item.getData();
- if (pkg.getCheckColumn()) {
- selectedBsPackages.add(pkg);
- }
- }
-
- recentTableIndex = dvViewer.getTable().getItemCount();
- for (int i = 0; i < recentTableIndex; i++) {
- TableItem item = null;
- item = dvViewer.getTable().getItem(i);
- LocalPackage pkg = (LocalPackage)item.getData();
- if (pkg.getCheckColumn()) {
- selectedDvPackages.add(pkg);
- }
- }
-
- super.okPressed();
- }
-
- @Override
- protected void cancelPressed() {
- super.cancelPressed();
- }
-
- public ArrayList<LocalPackage> getSelectedBsPkgs() {
- return selectedBsPackages;
- }
-
- public ArrayList<LocalPackage> getSelectedDvPkgs() {
- return selectedDvPackages;
- }
-
- private void createBuildSystemLabelComposite(Composite parent) {
- Composite composite = new Composite( parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
- composite.setLayout(new GridLayout(1, false));
-
- Label tableDesc = new Label(composite, SWT.NONE);
- tableDesc.setText(resources.getString("PkgDialog.Label.Buildsystem"));
- }
-
- private void createBuildSystemComposite(Composite parent) {
- Composite composite = new Composite( parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- composite.setLayout(new FillLayout());
-
- bsViewer = new TableViewer( composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK );
- createColumns( composite, bsViewer);
+ return null;
+ }
+
+ private void createDescComposite(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
+ | GridData.VERTICAL_ALIGN_BEGINNING));
+ composite.setLayout(new GridLayout(1, false));
+
+ Label message = new Label(composite, SWT.NONE);
+ message.setText(resources.getString("PkgDialog.Desc"));
+ }
+
+ @Override
+ protected void okPressed() {
+ selectedBsPackages.clear();
+ selectedDvPackages.clear();
+
+ int recentTableIndex = bsViewer.getTable().getItemCount();
+ for (int i = 0; i < recentTableIndex; i++) {
+ TableItem item = null;
+ item = bsViewer.getTable().getItem(i);
+ LocalPackage pkg = (LocalPackage) item.getData();
+ if (pkg.getCheckColumn()) {
+ selectedBsPackages.add(pkg);
+ }
+ }
+
+ recentTableIndex = dvViewer.getTable().getItemCount();
+ for (int i = 0; i < recentTableIndex; i++) {
+ TableItem item = null;
+ item = dvViewer.getTable().getItem(i);
+ LocalPackage pkg = (LocalPackage) item.getData();
+ if (pkg.getCheckColumn()) {
+ selectedDvPackages.add(pkg);
+ }
+ }
+
+ super.okPressed();
+ }
+
+ @Override
+ protected void cancelPressed() {
+ super.cancelPressed();
+ }
+
+ public List<LocalPackage> getSelectedBsPkgs() {
+ return selectedBsPackages;
+ }
+
+ public List<LocalPackage> getSelectedDvPkgs() {
+ return selectedDvPackages;
+ }
+
+ private void createBuildSystemLabelComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
+ | GridData.VERTICAL_ALIGN_BEGINNING));
+ composite.setLayout(new GridLayout(1, false));
+
+ Label tableDesc = new Label(composite, SWT.NONE);
+ tableDesc.setText(resources.getString("PkgDialog.Label.Buildsystem"));
+ }
+
+ private void createBuildSystemComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ composite.setLayout(new FillLayout());
+
+ bsViewer = new TableViewer(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK);
+ createColumns(composite, bsViewer);
Table packageTable = bsViewer.getTable();
- packageTable.addListener( SWT.Selection, new Listener(){
-
- @Override
- public void handleEvent(Event event) {
- if( event.detail == SWT.CHECK )
- {
- Package pkg = (Package)event.item.getData();
- pkg.setCheckColumn( !pkg.getCheckColumn() );
- }
- }
- });
+ packageTable.addListener(SWT.Selection, new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ if (event.detail == SWT.CHECK) {
+ Package pkg = (Package) event.item.getData();
+ pkg.setCheckColumn(!pkg.getCheckColumn());
+ }
+ }
+ });
packageTable.setHeaderVisible(true);
packageTable.setLinesVisible(true);
bsViewer.setContentProvider(new ArrayContentProvider());
bsViewer.setInput(bsPackages);
- }
-
- private void createDeviceLabelComposite(Composite parent) {
- Composite composite = new Composite( parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
- composite.setLayout(new GridLayout(1, false));
-
- Label tableDesc = new Label(composite, SWT.NONE);
- tableDesc.setText(resources.getString("PkgDialog.Label.Device"));
- }
-
- private void createDeviceComposite(Composite parent) {
- Composite composite = new Composite( parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- composite.setLayout(new FillLayout());
-
- dvViewer = new TableViewer( composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK );
- createColumns( composite, dvViewer);
+ }
+
+ private void createDeviceLabelComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
+ | GridData.VERTICAL_ALIGN_BEGINNING));
+ composite.setLayout(new GridLayout(1, false));
+
+ Label tableDesc = new Label(composite, SWT.NONE);
+ tableDesc.setText(resources.getString("PkgDialog.Label.Device"));
+ }
+
+ private void createDeviceComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ composite.setLayout(new FillLayout());
+
+ dvViewer = new TableViewer(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK);
+ createColumns(composite, dvViewer);
Table packageTable = dvViewer.getTable();
- packageTable.addListener( SWT.Selection, new Listener(){
-
- @Override
- public void handleEvent(Event event) {
- if( event.detail == SWT.CHECK )
- {
- Package pkg = (Package)event.item.getData();
- pkg.setCheckColumn( !pkg.getCheckColumn() );
- }
- }
- });
+ packageTable.addListener(SWT.Selection, new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ if (event.detail == SWT.CHECK) {
+ Package pkg = (Package) event.item.getData();
+ pkg.setCheckColumn(!pkg.getCheckColumn());
+ }
+ }
+ });
packageTable.setHeaderVisible(true);
packageTable.setLinesVisible(true);
dvViewer.setContentProvider(new ArrayContentProvider());
dvViewer.setInput(dvPackages);
- }
-
- protected void createButtonsForButtonBar(Composite parent)
- {
- createButton(parent, IDialogConstants.OK_ID, "Continue", true);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- private void createColumns( Composite parent, TableViewer viewer )
- {
- String[] titles = {"Package Name", "Arch", "New Version", "Installed Version", "Status"};
- int[] bounds = {250, 60, 150, 150, 150};
-
- TableViewerColumn colPackage = createTableViewerColumn( viewer, titles[0], bounds[0], SWT.NONE);
-
- colPackage.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getText(Object element) {
- Package pkg = (Package)element;
- return pkg.getName();
- }
- });
-
- TableViewerColumn colArch = createTableViewerColumn( viewer, titles[1], bounds[1], SWT.NONE);
-
- colArch.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getText(Object element) {
- Package pkg = (Package)element;
- String arch = pkg.getArch();
- return arch;
- }
- });
-
- TableViewerColumn colNewVer = createTableViewerColumn( viewer, titles[2], bounds[2], SWT.NONE);
-
- colNewVer.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getText(Object element) {
- Package pkg = (Package)element;
- String newVer = pkg.getNewVersion();
- return newVer;
- }
- });
-
- TableViewerColumn colInsVer = createTableViewerColumn( viewer, titles[3], bounds[3], SWT.NONE);
- colInsVer.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getText(Object element) {
- Package pkg = (Package)element;
- String installedVer = pkg.getInstalledVersion();
- return installedVer;
- }
- });
-
- TableViewerColumn colStatus = createTableViewerColumn( viewer, titles[4], bounds[4], SWT.NONE);
-
- colStatus.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getText(Object element) {
- Package pkg = (Package)element;
- String status = pkg.getInstallInfo().toString();
- return status;
- }
- });
- }
-
- private TableViewerColumn createTableViewerColumn(TableViewer viewer, String title, int bound, int Style) {
-
- final TableViewerColumn viewerColumn = new TableViewerColumn( viewer, Style);
- final TableColumn column = viewerColumn.getColumn();
- column.setText(title);
- column.setWidth(bound);
- column.setResizable(true);
- column.setMoveable(true);
- return viewerColumn;
- }
-
- private void tableRefresh() {
- int recentTableIndex = bsViewer.getTable().getItemCount();
- for (int i = 0; i < recentTableIndex; i++) {
- TableItem item = null;
- item = bsViewer.getTable().getItem(i);
- Package pkg = (Package)item.getData();
- item.setChecked(pkg.getCheckColumn());
- }
-
- recentTableIndex = dvViewer.getTable().getItemCount();
- for (int i = 0; i < recentTableIndex; i++) {
- TableItem item = null;
- item = dvViewer.getTable().getItem(i);
- Package pkg = (Package)item.getData();
- item.setChecked(pkg.getCheckColumn());
- }
- }
+ }
+
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, "Continue", true);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ }
+
+ private void createColumns(Composite parent, TableViewer viewer) {
+ String[] titles = { "Package Name", "Arch", "New Version", "Installed Version", "Status" };
+ int[] bounds = { 250, 60, 150, 150, 150 };
+
+ TableViewerColumn colPackage = createTableViewerColumn(viewer, titles[0], bounds[0],
+ SWT.NONE);
+
+ colPackage.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ Package pkg = (Package) element;
+ return pkg.getName();
+ }
+ });
+
+ TableViewerColumn colArch = createTableViewerColumn(viewer, titles[1], bounds[1], SWT.NONE);
+
+ colArch.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ Package pkg = (Package) element;
+ String arch = pkg.getArch();
+ return arch;
+ }
+ });
+
+ TableViewerColumn colNewVer = createTableViewerColumn(viewer, titles[2], bounds[2],
+ SWT.NONE);
+
+ colNewVer.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ Package pkg = (Package) element;
+ String newVer = pkg.getNewVersion();
+ return newVer;
+ }
+ });
+
+ TableViewerColumn colInsVer = createTableViewerColumn(viewer, titles[3], bounds[3],
+ SWT.NONE);
+ colInsVer.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ Package pkg = (Package) element;
+ String installedVer = pkg.getInstalledVersion();
+ return installedVer;
+ }
+ });
+
+ TableViewerColumn colStatus = createTableViewerColumn(viewer, titles[4], bounds[4],
+ SWT.NONE);
+
+ colStatus.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ Package pkg = (Package) element;
+ String status = pkg.getInstallInfo().toString();
+ return status;
+ }
+ });
+ }
+
+ private TableViewerColumn createTableViewerColumn(TableViewer viewer, String title, int bound,
+ int Style) {
+
+ final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, Style);
+ final TableColumn column = viewerColumn.getColumn();
+ column.setText(title);
+ column.setWidth(bound);
+ column.setResizable(true);
+ column.setMoveable(true);
+ return viewerColumn;
+ }
+
+ private void tableRefresh() {
+ int recentTableIndex = bsViewer.getTable().getItemCount();
+ for (int i = 0; i < recentTableIndex; i++) {
+ TableItem item = null;
+ item = bsViewer.getTable().getItem(i);
+ Package pkg = (Package) item.getData();
+ item.setChecked(pkg.getCheckColumn());
+ }
+
+ recentTableIndex = dvViewer.getTable().getItemCount();
+ for (int i = 0; i < recentTableIndex; i++) {
+ TableItem item = null;
+ item = dvViewer.getTable().getItem(i);
+ Package pkg = (Package) item.getData();
+ item.setChecked(pkg.getCheckColumn());
+ }
+ }
}
--- /dev/null
+package org.tizen.nativeplatform.manifest;
+
+public class ApplicationData {
+ private String id;
+ private String exec;
+ private String type;
+ private String icon;
+
+ public ApplicationData() {
+ }
+
+ public ApplicationData(String id, String exec, String type, String icon) {
+ this.id = id;
+ this.exec = exec;
+ this.type = type;
+ this.icon = icon;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setExec(String exec) {
+ this.exec = exec;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public void setIcon(String icon) {
+ this.icon = icon;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getExec() {
+ return exec;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getIcon() {
+ return icon;
+ }
+}
--- /dev/null
+package org.tizen.nativeplatform.manifest;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.tizen.nativeplatform.messages";//$NON-NLS-1$
+
+
+ public static String PlatformXmlStore_EXCEPTION_WRITING_FILE;
+ public static String UNSUPPORTED_METHOD_EXCEPTION;
+ public static String PlatformXmlStore_PROJECT_NOT_EXIST ;
+ public static String PlatformXmlStore_MANIFEST_NOT_EXIST;
+
+ private Messages() {
+ //do not initiate
+ }
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+}
--- /dev/null
+package org.tizen.nativeplatform.manifest;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PlatformManifestModel {
+ private String appId;
+ private String label;
+ private List<ApplicationData> appDatas;
+
+ public PlatformManifestModel() {
+ appDatas = new ArrayList<ApplicationData>();
+ }
+
+ public void setAppId(String id) {
+ this.appId = id;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public void addAppData(ApplicationData data) {
+ appDatas.add(data);
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public List<ApplicationData> getAppDatas() {
+ return appDatas;
+ }
+
+ public List<String> getExecutableFiles() {
+ if (appDatas.size() <= 0) {
+ return null;
+ }
+
+ List<String> files = new ArrayList<String>();
+ for (ApplicationData data : appDatas) {
+ String exec = data.getExec();
+ if (exec != null && !exec.isEmpty()) {
+ files.add(exec);
+ }
+ }
+
+ return files;
+ }
+
+ public void clear() {
+ appDatas.clear();
+ }
+}
+
\ No newline at end of file
--- /dev/null
+package org.tizen.nativeplatform.manifest;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.osgi.util.NLS;
+import org.slf4j.LoggerFactory;
+import org.tizen.common.TizenProjectType;
+import org.tizen.common.util.IOUtil;
+import org.tizen.nativeplatform.IPlatformXMLStore;
+import org.tizen.nativeplatform.filefilter.XmlFileFilter;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+public class PlatformManifestXMLStore implements IPlatformXMLStore {
+
+ private static final String ELEMENT_MANIFEST = "manifest";
+ private static final String ELEMENT_LABEL = "label";
+ private static final String ELEMENT_APP = "ui-application";
+
+ private static final String ATTR_APPID = "appid";
+ private static final String ATTR_EXEC = "exec";
+
+ private String projectPath;
+ private File manifestFile;
+
+ private PlatformManifestModel model = new PlatformManifestModel();
+ private static final org.slf4j.Logger logger = LoggerFactory.getLogger(PlatformManifestXMLStore.class);
+
+ @Override
+ public void setProject(IProject project) {
+ setProject(project.getLocation().toFile().getAbsolutePath());
+ }
+
+ @Override
+ public boolean loadXml() {
+
+ if(!new File(projectPath).exists()) {
+ logger.error(NLS.bind(Messages.PlatformXmlStore_PROJECT_NOT_EXIST, this.projectPath));
+ clear();
+ return false;
+ }
+
+ if(manifestFile == null || !manifestFile.exists()) {
+ logger.error(NLS.bind(Messages.PlatformXmlStore_MANIFEST_NOT_EXIST, this.projectPath));
+ return false;
+ }
+
+ String filePath = manifestFile.getAbsolutePath();
+
+ try {
+ loadXML(filePath);
+ } catch (IOException e) {
+ return false;
+ } catch (SAXException e2){
+ return false;
+ } catch (ParserConfigurationException e3){
+ return false;
+ }
+
+ return true;
+ }
+
+ private boolean loadXML(final String path) throws FileNotFoundException, IOException, ParserConfigurationException, SAXException {
+ clear();
+ FileInputStream stream = null;
+
+ try {
+ File file = new File(path);
+ if (!file.exists()){
+ return false;
+ }
+ stream = new FileInputStream(file);
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document dom = db.parse(stream);
+
+ parse(dom);
+ } finally{
+ IOUtil.tryClose(stream);
+ }
+
+ return true;
+ }
+
+ private boolean parse(Document dom)
+ {
+ Element root = dom.getDocumentElement();
+ String rootName = root.getNodeName();
+
+ if (rootName.equals(ELEMENT_MANIFEST)) {
+ for (Node node = root.getFirstChild(); node != null; node = node
+ .getNextSibling()) {
+ String nodeName = node.getNodeName();
+ if (nodeName.equals(ELEMENT_LABEL)) {
+ model.setLabel(getChildValue(node));
+ } else if (nodeName.equals(ELEMENT_APP)) {
+ parseApp(node, model);
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private void parseApp(Node node, PlatformManifestModel model) {
+ Element eNode = (Element) node;
+ ApplicationData app = new ApplicationData();
+
+ String appId = eNode.getAttribute(ATTR_APPID);
+ String exec = eNode.getAttribute(ATTR_EXEC);
+
+ app.setId(appId);
+ app.setExec(exec);
+
+ model.addAppData(app);
+ }
+
+ @Override
+ public String getVersion() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<String> getIconFileList() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public TizenProjectType getApplicationType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<String> getExecutableFiles() {
+ return model.getExecutableFiles();
+ }
+
+ @Override
+ public List<String> getAuthors() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setProject(String projectPath) {
+ this.projectPath = projectPath;
+ File dir = new File(projectPath);
+
+ // get ".xml" file list
+ String[] files = dir.list(new XmlFileFilter());
+ // return false if ".xml" file does not exist
+ if (files.length != 0) {
+ String xmlFileName = files[0];
+ IPath filePath = new Path(projectPath).append(xmlFileName);
+ manifestFile = filePath.toFile();
+ }
+ }
+
+ private void clear() {
+ model.clear();
+ }
+
+ private static String getChildValue(Node node) {
+ if (node.getFirstChild() != null)
+ return node.getFirstChild().getNodeValue();
+ return null;
+ }
+
+ @Override
+ public String getAppId() {
+ return model.getAppId();
+ }
+
+ @Override
+ public String getAppLabel() {
+ return model.getLabel();
+ }
+}
--- /dev/null
+UNSUPPORTED_METHOD_EXCEPTION = This class does not support {0}
+PlatformXmlStore_MANIFEST_NOT_EXIST={0} does not have .xml file
+PlatformXmlStore_PROJECT_NOT_EXIST=Project: {0} does not exist
+PlatformXmlStore_EXCEPTION_WRITING_FILE=Exception occurred while writing file: {0}
\ No newline at end of file
--- /dev/null
+package org.tizen.nativeplatform.pkg.commander;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+
+public class CommandStatus implements ICommandStatus {
+ private int severity = OK;
+ private String command = "";
+ private String message = "";
+ private int code;
+ private List<String> values = null;
+ private Throwable exception = null;
+
+ public CommandStatus(int severity, int code, String command, String message,
+ List<String> value, Throwable exception) {
+ setCommand(command);
+ setSeverity(severity);
+ setMessage(message);
+ setCode(code);
+ setException(exception);
+ setValue(value);
+ }
+
+ public CommandStatus(int severity, String command, String message, Throwable exception) {
+ setCommand(command);
+ setSeverity(severity);
+ setMessage(message);
+ setCode(severity);
+ setException(exception);
+ }
+
+ public CommandStatus(int severity, String command, String message, List<String> value,
+ Throwable exception) {
+ setCommand(command);
+ setSeverity(severity);
+ setMessage(message);
+ setCode(severity);
+ setValue(value);
+ setException(exception);
+ }
+
+ public CommandStatus(int severity, List<String> value, Throwable exception) {
+ setSeverity(severity);
+ setCode(severity);
+ setValue(value);
+ setException(exception);
+ }
+
+ public void setCommand(String command) {
+ this.command = command;
+ }
+
+ public void setSeverity(int severity) {
+ this.severity = severity;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public void setException(Throwable exception) {
+ this.exception = exception;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public void setValue(List<String> values) {
+ this.values = values;
+ }
+
+ @Override
+ public int getCode() {
+ return code;
+ }
+
+ @Override
+ public Throwable getException() {
+ return exception;
+ }
+
+ @Override
+ public String getMessage() {
+ return message;
+ }
+
+ @Override
+ public int getSeverity() {
+ return severity;
+ }
+
+ public List<String> getValues() {
+ return values;
+ }
+
+ @Override
+ public boolean isOk() {
+ return severity == OK;
+ }
+
+ @Override
+ public String getCommand() {
+ return command;
+ }
+
+}
--- /dev/null
+package org.tizen.nativeplatform.pkg.commander;
+
+public interface IChangedLogListener {
+ void changedLog(String log);
+}
--- /dev/null
+package org.tizen.nativeplatform.pkg.commander;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+
+public interface ICommandStatus {
+ // Status severity constant (value 0) indicating this status represents the
+ // nominal case.
+ public static final int OK = 0;
+
+ // Status type severity (bit mask, value 1) indicating this status is
+ // informational only.
+ public static final int INFO = 0x01;
+
+ // Status type severity (bit mask, value 2) indicating this status
+ // represents a warning.
+ public static final int WARNING = 0x02;
+
+ // Status type severity (bit mask, value 4) indicating this status
+ // represents an error.
+ public static final int ERROR = 0x04;
+
+ // Status type severity (bit mask, value 8) indicating this status
+ // represents a
+ public static final int CANCEL = 0x08;
+
+ int getSeverity();
+
+ int getCode();
+
+ String getCommand();
+
+ String getMessage();
+
+ List<String> getValues();
+
+ Throwable getException();
+
+ boolean isOk();
+}
--- /dev/null
+package org.tizen.nativeplatform.pkg.commander;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public interface IPackager {
+ boolean packaging(IProgressMonitor monitor);
+}
--- /dev/null
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.pkg.commander;
+
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.tizen.nativeplatform.pkgmgr.PackageManagerOuputReceiver;
+import org.tizen.nativeplatform.pkgmgr.model.Package;
+
+public interface IPkgCommander {
+
+ enum TOOL {
+ RPM, ZYPPER, PKGCMD
+ }
+
+ PackageManagerOuputReceiver getOutputReceiver();
+
+ void setHttpProxy(String proxy);
+
+ String getArchFromFile(String filePath);
+
+ String getNameFromFile(String filePath);
+
+ String getVerFromFile(String filePath);
+
+ String[] getArch(String pkg);
+
+ String[] getName(String pkg);
+
+ String[] getVer(String pkg);
+
+ ICommandStatus installLocalPkg(String[] files, TOOL type, IProgressMonitor monitor);
+
+ ICommandStatus installLocalPkg(String[] files, IProgressMonitor monitor);
+
+ ICommandStatus installLocalPkg(String file, IProgressMonitor monitor);
+
+ ICommandStatus installRemotePkg(String[] pkgs, IProgressMonitor monitor);
+
+ ICommandStatus installRemotePkg(String pkg, IProgressMonitor monitor);
+
+ ICommandStatus uninstallPkg(String[] pkgs, IProgressMonitor monitor);
+
+ ICommandStatus uninstallPkg(String pkg, IProgressMonitor monitor);
+
+ ICommandStatus copyFiles(String[] fileList);
+
+ List<Package> getAllPkgList();
+
+ Map<String, Package> getAllPkgMap();
+
+ Map<String, Package> getRemotePkgList();
+
+ Map<String, Package> getLocalPkgList();
+
+ Map<String, String> getRepoList();
+
+ ICommandStatus upgrade(IProgressMonitor monitor);
+
+ void resetRepo();
+
+ ICommandStatus refreshRepoList();
+
+ ICommandStatus addRepo(String name, String url);
+
+ ICommandStatus addLocalRepo(String name, String path);
+
+ ICommandStatus removeRepo(String name);
+
+ boolean checkPkgInstalled(String pkg);
+
+ boolean existsFile(String file);
+}
--- /dev/null
+package org.tizen.nativeplatform.pkg.commander;
+
+public interface IPkgType {
+ enum PKGTYPE {
+ RPM("rpm");
+
+ final String ext;
+
+ private PKGTYPE(String ext) {
+ this.ext = ext;
+ }
+
+ public String getExe() {
+ return ext;
+ }
+ }
+}
--- /dev/null
+package org.tizen.nativeplatform.pkg.commander;
+
+public interface IPkgVersionComparer {
+ public int compare(String ver1, String ver2);
+}
--- /dev/null
+package org.tizen.nativeplatform.pkg.commander;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.core.resources.IProject;
+import org.tizen.nativeplatform.pkg.commander.rpm.RpmPackager;
+
+public class PackagerFactory {
+
+ public static IPackager getPackager(IProject project, IConfiguration config) {
+ return getPackager(IPkgType.PKGTYPE.RPM, project, config);
+ }
+
+ public static IPackager getPackager(IPkgType.PKGTYPE type, IProject project,
+ IConfiguration config) {
+ if (type.equals(IPkgType.PKGTYPE.RPM)) {
+ return new RpmPackager(project, config);
+ } else {
+ return null;
+ }
+ }
+}
--- /dev/null
+package org.tizen.nativeplatform.pkg.commander;
+
+import org.tizen.nativeplatform.pkg.commander.PkgCommanderFactory;
+import org.tizen.nativeplatform.preferences.PreferencesManager;
+import org.tizen.nativeplatform.views.model.PlatformRootstrap;
+import org.tizen.sdblib.IDevice;
+
+public class PkgCommandTarget {
+ private IDevice device = null;
+ private PlatformRootstrap rootstrap = null;
+ private IPkgCommander hsCommander = null;
+ private IPkgCommander dvCommander = null;
+ private IPkgCommander rtCommander = null;
+ private String http_proxy = "";
+
+ public PkgCommandTarget() {
+ http_proxy = PreferencesManager.getHttpProxyURL();
+ }
+
+ public PkgCommandTarget(IDevice device) {
+ setDevice(device);
+ http_proxy = PreferencesManager.getHttpProxyURL();
+ }
+
+ public PkgCommandTarget(PlatformRootstrap rootstrap) {
+ setRootstrap(rootstrap);
+ http_proxy = PreferencesManager.getHttpProxyURL();
+ }
+
+ public PkgCommandTarget(IDevice device, PlatformRootstrap rootstrap) {
+ setDevice(device);
+ setRootstrap(rootstrap);
+ http_proxy = PreferencesManager.getHttpProxyURL();
+ }
+
+ public void setDevice(IDevice device) {
+ this.device = device;
+ }
+
+ public void setRootstrap(PlatformRootstrap rootstrap) {
+ this.rootstrap = rootstrap;
+ }
+
+ public IDevice getDevice() {
+ return device;
+ }
+
+ public PlatformRootstrap getRootstrap() {
+ return rootstrap;
+ }
+
+ public IPkgCommander getHostCommander() {
+ if (hsCommander == null) {
+ hsCommander = PkgCommanderFactory.getHostCommander();
+ hsCommander.setHttpProxy(http_proxy);
+ }
+
+ return hsCommander;
+ }
+
+ public IPkgCommander getDeviceCommander() {
+ if (dvCommander == null) {
+ dvCommander = PkgCommanderFactory.getDeviceCommander(this);
+ dvCommander.setHttpProxy(http_proxy);
+ }
+
+ return dvCommander;
+ }
+
+ public IPkgCommander getRootstrapCommander() {
+ if (rtCommander == null) {
+ rtCommander = PkgCommanderFactory.getRootstrapCommander(this);
+ rtCommander.setHttpProxy(http_proxy);
+ }
+
+ return rtCommander;
+ }
+
+ public boolean isSetDevice() {
+ return (device != null);
+ }
+
+ public boolean isSetRootstrap() {
+ return (rootstrap != null);
+ }
+}
--- /dev/null
+package org.tizen.nativeplatform.pkg.commander;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.tizen.nativecommon.build.SmartBuildInterface;
+import org.tizen.nativeplatform.pkg.commander.rpm.RpmCommanderDevice;
+import org.tizen.nativeplatform.pkg.commander.rpm.RpmCommanderHost;
+import org.tizen.nativeplatform.pkg.commander.rpm.RpmCommanderRootstrap;
+
+public class PkgCommanderFactory {
+
+ public static IPkgCommander getDeviceCommander(PkgCommandTarget target) {
+ return getDeviceCommander(IPkgType.PKGTYPE.RPM, target);
+ }
+
+ public static IPkgCommander getRootstrapCommander(PkgCommandTarget target) {
+ return getRootstrapCommander(IPkgType.PKGTYPE.RPM, target);
+ }
+
+ public static IPkgCommander getHostCommander() {
+ return getHostCommander(IPkgType.PKGTYPE.RPM);
+ }
+
+ public static IPkgCommander getHostCommander(IPkgType.PKGTYPE type) {
+ if (type.equals(IPkgType.PKGTYPE.RPM)) {
+ return new RpmCommanderHost();
+ } else {
+ return null;
+ }
+ }
+
+ public static IPkgCommander getDeviceCommander(IPkgType.PKGTYPE type, PkgCommandTarget target) {
+ if (type.equals(IPkgType.PKGTYPE.RPM)) {
+ if (target.isSetDevice()) {
+ return new RpmCommanderDevice(target.getDevice());
+ } else {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ public static IPkgCommander getRootstrapCommander(IPkgType.PKGTYPE type, PkgCommandTarget target) {
+ if (type.equals(IPkgType.PKGTYPE.RPM)) {
+ if (target.isSetRootstrap()) {
+ IPath basePath = target.getRootstrap().getPath();
+ String rootPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(
+ basePath);
+ return new RpmCommanderRootstrap(new Path(rootPath));
+ } else {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+}
--- /dev/null
+package org.tizen.nativeplatform.pkg.commander;
+
+import org.tizen.nativeplatform.pkg.commander.rpm.RpmVersionComparer;
+
+public class PkgVersionComparerFactory {
+
+ public static IPkgVersionComparer getComparer() {
+ return getComparer(IPkgType.PKGTYPE.RPM);
+ }
+
+ public static IPkgVersionComparer getComparer(IPkgType.PKGTYPE type) {
+ if (type.equals(IPkgType.PKGTYPE.RPM)) {
+ return new RpmVersionComparer();
+ } else {
+ return null;
+ }
+ }
+}
--- /dev/null
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.pkg.commander.rpm;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ui.console.MessageConsoleStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tizen.common.ui.view.console.ConsoleManager;
+import org.tizen.nativeplatform.pkg.commander.ICommandStatus;
+import org.tizen.nativeplatform.pkg.commander.IPkgCommander;
+import org.tizen.nativeplatform.pkg.tools.PkgcmdTool;
+import org.tizen.nativeplatform.pkg.tools.RpmTool;
+import org.tizen.nativeplatform.pkg.tools.ZypperTool;
+import org.tizen.nativeplatform.pkg.tools.ZypperXmlParser;
+import org.tizen.nativeplatform.pkgmgr.PackageManagerOuputReceiver;
+import org.tizen.nativeplatform.pkgmgr.model.Package;
+import org.tizen.nativeplatform.util.CharacterStripper;
+import org.tizen.nativeplatform.util.CommandLauncher;
+
+public abstract class RpmCommanderCommon implements IPkgCommander {
+
+ protected final String CONSOLE_NAME = "Platform Internal";
+ protected final String CMD_DELIMITER = ";";
+ protected final String LOG_COMMAND_PREFIX = "[command]";
+ protected final String LOG_RESULT_PREFIX = "[result]";
+ protected final String LOG_INFO_PREFIX = "[info]";
+ protected final String NL = System.getProperty("line.separator");
+ protected final String WS = " ";
+ protected final String TMP_DIR = "/tmp";
+
+ protected final String CMD_RESET_REPO = "rm -rf /etc/zypp/repos.d/*";
+ protected final String CMD_RESET_RPM_DB = "rm -f /var/lib/rpm/__db*";
+ protected final String CMD_FILE_FILE = "ls %s 2>/dev/null";
+ protected final String CMD_EXPORT_PROXY = "export http_proxy=%s";
+
+ protected final Logger logger = LoggerFactory.getLogger(RpmCommanderCommon.class);
+ protected String http_proxy;
+ protected PackageManagerOuputReceiver rec;
+
+ /**
+ * This console is for getting log, not printing log to console
+ */
+ abstract protected PackageManagerOuputReceiver getNewOuputReceiver();
+
+ abstract public Map<String, Package> getLocalPkgList();
+
+ abstract public ICommandStatus copyFiles(String[] fileList);
+
+ abstract protected ICommandStatus execute(String command, IProgressMonitor monitor);
+
+ abstract protected ICommandStatus execute(String command, IProgressMonitor monitor,
+ boolean printlog);
+
+ abstract protected ICommandStatus execute(String command, PackageManagerOuputReceiver rec,
+ IProgressMonitor monitor);
+
+ abstract protected ICommandStatus execute(String command, PackageManagerOuputReceiver rec,
+ IProgressMonitor monitor, boolean printLog);
+
+ abstract protected void changeUpdateMode();
+
+ abstract protected void actionBeforeUsingZypper();
+
+ public RpmCommanderCommon() {
+ rec = getNewOuputReceiverWithConsole();
+ }
+
+ public RpmCommanderCommon(String consoleName) {
+ rec = getNewOuputReceiver(consoleName);
+ }
+
+ public PackageManagerOuputReceiver getOutputReceiver() {
+ return rec;
+ }
+
+ public void setHttpProxy(String proxy) {
+ if (proxy == null) {
+ return;
+ } else {
+ http_proxy = proxy;
+ printResultLog(String.format("Set proxy: %s", proxy));
+ }
+ }
+
+ public String getArchFromFile(String filePath) {
+ String result = "";
+ if (!new File(filePath).exists()) {
+ return result;
+ }
+ String command = RpmTool.fileArchCommand(filePath);
+ try {
+ result = CommandLauncher.executeOutput(command);
+ // result = hostExecute(command);
+ } catch (InterruptedException e) {
+ logger.error(e.getMessage(), e);
+ }
+ String[] name = result.split(",");
+ if (name.length > 0) {
+ return name[0];
+ } else {
+ return "";
+ }
+ }
+
+ public String getNameFromFile(String filePath) {
+ String result = "";
+ if (!new File(filePath).exists()) {
+ return result;
+ }
+ String command = RpmTool.fileNameCommand(filePath);
+ try {
+ result = CommandLauncher.executeOutput(command);
+ } catch (InterruptedException e) {
+ logger.error(e.getMessage(), e);
+ }
+ String[] name = result.split(",");
+ if (name.length > 0) {
+ return name[0];
+ } else {
+ return "";
+ }
+ }
+
+ public String getVerFromFile(String filePath) {
+ String result = "";
+ if (!new File(filePath).exists()) {
+ return result;
+ }
+ String command = RpmTool.fileFullVerCommand(filePath);
+ try {
+ result = CommandLauncher.executeOutput(command);
+ } catch (InterruptedException e) {
+ logger.error(e.getMessage(), e);
+ }
+ String[] name = result.split(",");
+ if (name.length > 0) {
+ return name[0];
+ } else {
+ return "";
+ }
+ }
+
+ public String[] getArch(String pkg) {
+ if (!checkPkgInstalled(pkg)) {
+ return new String[0];
+ }
+ String command = makeCommand(getResetRpmDb(), RpmTool.pkgArchCommand(pkg));
+ PackageManagerOuputReceiver hrec = getNewOuputReceiver();
+ ICommandStatus status = execute(command, hrec, null);
+ if (!status.isOk()) {
+ return null;
+ }
+ List<String> result = new ArrayList<String>();
+ List<String> value = status.getValues();
+ String arch = "";
+ if (value != null && !value.isEmpty()) {
+ // the last index of array is real value
+ arch = value.get(value.size() - 1);
+ for (String s : arch.split(",")) {
+ result.add(s.trim());
+ }
+
+ }
+ if (!result.isEmpty()) {
+ printResultLog(String.format("Checked arch: %s (%s)", arch, pkg));
+ } else {
+ printResultLog(String.format("Failed to get arch: (%s)", pkg));
+ }
+ return result.toArray(new String[0]);
+ }
+
+ public String[] getName(String pkg) {
+ if (!checkPkgInstalled(pkg)) {
+ return new String[0];
+ }
+ String command = makeCommand(getResetRpmDb(), RpmTool.pkgNameCommand(pkg));
+ PackageManagerOuputReceiver hrec = getNewOuputReceiver();
+ ICommandStatus status = execute(command, hrec, null);
+ if (!status.isOk()) {
+ return null;
+ }
+ List<String> value = status.getValues();
+ List<String> result = new ArrayList<String>();
+ String name = "";
+ if (value != null && !value.isEmpty()) {
+ // the last index of array is real value
+ name = value.get(value.size() - 1);
+ for (String s : name.split(",")) {
+ result.add(s.trim());
+ }
+
+ }
+ if (!result.isEmpty()) {
+ printResultLog(String.format("Checked name: %s (%s)", name, pkg));
+ } else {
+ printResultLog(String.format("Failed to get name: (%s)", pkg));
+ }
+ return result.toArray(new String[0]);
+ }
+
+ public String[] getVer(String pkg) {
+ if (!checkPkgInstalled(pkg)) {
+ return new String[0];
+ }
+ String command = makeCommand(getResetRpmDb(), RpmTool.pkgFullVerCommand(pkg));
+ PackageManagerOuputReceiver hrec = getNewOuputReceiver();
+ ICommandStatus status = execute(command, hrec, null);
+ if (!status.isOk()) {
+ return null;
+ }
+
+ List<String> value = status.getValues();
+ List<String> result = new ArrayList<String>();
+ String version = "";
+ if (value != null && !value.isEmpty()) {
+ // the last index of array is real value
+ version = value.get(value.size() - 1);
+ for (String s : version.split(",")) {
+ result.add(s.trim());
+ }
+ }
+
+ if (!result.isEmpty()) {
+ printResultLog(String.format("Checked version: %s (%s)", version, pkg));
+ } else {
+ printResultLog(String.format("Failed to get version: (%s)", pkg));
+ }
+
+ return result.toArray(new String[0]);
+ }
+
+ public ICommandStatus installLocalPkg(String[] files, TOOL type, IProgressMonitor monitor) {
+ ICommandStatus status = copyFiles(files);
+ if (!status.isOk()) {
+ logger.error(status.getMessage(), status.getException());
+ return status;
+ }
+
+ List<String> value = status.getValues();
+ if (value != null && value.size() > 0) {
+ changeUpdateMode();
+ if (type == TOOL.RPM) {
+ String command = makeCommand(getResetRpmDb(),
+ RpmTool.installCommand(value.toArray(new String[0])));
+ status = execute(command, monitor);
+ } else if (type == TOOL.ZYPPER) {
+ String command = makeCommand(getResetRpmDb(),
+ ZypperTool.installLocalCommand(value.toArray(new String[0])));
+ status = execute(command, monitor);
+ } else if (type == TOOL.PKGCMD) {
+ String command = makeCommand(getResetRpmDb(),
+ PkgcmdTool.installCommand(value.toArray(new String[0])));
+ status = execute(command, monitor);
+ }
+ }
+
+ return status;
+ }
+
+ public ICommandStatus installLocalPkg(String[] files, IProgressMonitor monitor) {
+ return installLocalPkg(files, TOOL.ZYPPER, monitor);
+ }
+
+ public ICommandStatus installLocalPkg(String file, IProgressMonitor monitor) {
+ String[] files = { file };
+ return installLocalPkg(files, monitor);
+ }
+
+ public ICommandStatus installRemotePkg(String[] pkgs, IProgressMonitor monitor) {
+ changeUpdateMode();
+ String command = makeCommand(getProxyCommand(), getResetRpmDb(),
+ ZypperTool.installRemoteCommand(pkgs));
+ ICommandStatus status = execute(command, monitor);
+ return status;
+ }
+
+ public ICommandStatus installRemotePkg(String pkg, IProgressMonitor monitor) {
+ String[] pkgs = { pkg };
+ return installRemotePkg(pkgs, monitor);
+ }
+
+ public ICommandStatus uninstallPkg(String[] pkgs, IProgressMonitor monitor) {
+ changeUpdateMode();
+ String command = makeCommand(getResetRpmDb(), RpmTool.uninstallCommand(pkgs));
+ ICommandStatus status = execute(command, monitor);
+
+ /*
+ * Following error can be occurred in case of using zypper.
+ *
+ * Error: Subprocess failed. Error: RPM failed: error: db4 error(-30971)
+ * from dbenv->open: DB_VERSION_MISMATCH: Database environment version
+ * mismatch error: cannot open Packages index using db4 - (-30971)
+ * error: cannot open Packages database in /var/lib/rpm error: db4
+ * error(-30971) from dbenv->open: DB_VERSION_MISMATCH: Database
+ * environment version mismatch error: cannot open Packages database in
+ * /var/lib/rpm
+ */
+
+ /*
+ * String command = makeCommand(getResetRpmDb(),
+ * ZypperTool.uninstallCommand(pkgs)); ICommandStatus status =
+ * execute(command, monitor);
+ */
+ return status;
+ }
+
+ public ICommandStatus uninstallPkg(String pkg, IProgressMonitor monitor) {
+ String[] pkgs = { pkg };
+ return uninstallPkg(pkgs, monitor);
+ }
+
+ public List<Package> getAllPkgList() {
+ Map<String, Package> pkgMap = getAllPkgMap();
+ List<Package> list = new ArrayList<Package>();
+ if (pkgMap != null && !pkgMap.isEmpty()) {
+ for (Entry<String, Package> set : pkgMap.entrySet()) {
+ list.add(set.getValue());
+ }
+ }
+ return list;
+ }
+
+ public Map<String, Package> getAllPkgMap() {
+ Map<String, Package> allPkgs = new HashMap<String, Package>();
+ Map<String, Package> localPkgs = getLocalPkgList();
+ Map<String, Package> remotePkgs = getRemotePkgList();
+
+ if (remotePkgs != null) {
+ allPkgs.putAll(remotePkgs);
+ }
+
+ if (localPkgs != null) {
+ if (!allPkgs.isEmpty()) {
+ for (Entry<String, Package> e : localPkgs.entrySet()) {
+ String name = e.getKey();
+ // if remote list has the package and it is not installed,
+ // set install version and put it.
+ if (remotePkgs.containsKey(name)) {
+ Package pkg = remotePkgs.get(name);
+ if (!pkg.isInstalled()) {
+ Package lpkg = e.getValue();
+ pkg.setInstalledVersion(lpkg.getInstalledVersion());
+ allPkgs.remove(name);
+ allPkgs.put(name, pkg);
+ }
+ // if remote list does not have the package, put it
+ } else {
+ allPkgs.put(name, e.getValue());
+ }
+ }
+ } else {
+ allPkgs.putAll(localPkgs);
+ }
+ }
+
+ printResultLog(String.format("Get all package list: %d", allPkgs.size()));
+ return allPkgs;
+ }
+
+ public Map<String, Package> getRemotePkgList() {
+ String command = makeCommand(getProxyCommand(), getResetRpmDb(),
+ ZypperTool.remotePkgListCommandWithXmlOut());
+ PackageManagerOuputReceiver hrec = getNewOuputReceiver();
+ ICommandStatus status = execute(command, hrec, null);
+ if (!status.isOk()) {
+ printResultLog("Failed to get remote package list");
+ return null;
+ }
+
+ Map<String, Package> result = null;
+ List<String> value = status.getValues();
+ if (value != null && value.size() > 0) {
+ String xml = makeNewlineString(value);
+ ZypperXmlParser parser = new ZypperXmlParser();
+ parser.setDoc(xml);
+ String log = parser.getAllMessages();
+ printLog(log);
+ result = parser.getPkgList();
+ }
+ if (result != null) {
+ printResultLog(String.format("Get remote package list: %d", result.size()));
+ } else {
+ printResultLog("Failed to get remote package list");
+ }
+ return result;
+ }
+
+ public Map<String, Package> getLocalPkgList(String tag) {
+ String command = makeCommand(getResetRpmDb(), RpmTool.pkgListByTagCommand(tag));
+ PackageManagerOuputReceiver hrec = getNewOuputReceiver();
+ ICommandStatus status = execute(command, hrec, null);
+ if (!status.isOk()) {
+ printResultLog("Failed to get local package list");
+ return null;
+ }
+
+ Map<String, Package> pkgMap = new HashMap<String, Package>();
+ List<String> value = status.getValues();
+ String content = "";
+ if (value != null && value.size() > 0) {
+ for (String s : value) {
+ s = s.trim();
+ if (s.startsWith("<pkg>")) {
+ content = s;
+ break;
+ }
+ }
+ }
+
+ String[] splitStr = content.split("</pkg>");
+ for (String s : splitStr) {
+ s = s.replaceAll(" ", "").replaceAll("<pkg>", "");
+ String[] part = s.split(",");
+ if (part.length == 3) {
+ String name = part[0];
+ String version = part[1];
+ String arch = part[2];
+ Package pkg = pkgMap.get(name);
+ if (pkg == null) {
+ pkgMap.put(name, new Package(name, version, Package.INSTALLINFO.INSTALLED, "",
+ arch));
+ } else {
+ pkg.setInstalledVersion(version);
+ pkg.setInstallInfo(Package.INSTALLINFO.INSTALLED);
+ }
+ }
+ }
+
+ printResultLog(String.format("Get local package list: %d", pkgMap.size()));
+ return pkgMap;
+ }
+
+ public Map<String, String> getRepoList() {
+ String command = makeCommand(getResetRpmDb(), ZypperTool.RepoListCommandXmlOut());
+ PackageManagerOuputReceiver hrec = getNewOuputReceiver();
+ ICommandStatus status = execute(command, hrec, null);
+ if (!status.isOk()) {
+ printResultLog("Failed to get repository list");
+ return null;
+ }
+ Map<String, String> result = null;
+ List<String> value = status.getValues();
+ if (value != null && value.size() > 0) {
+ String xml = makeNewlineString(value);
+ ZypperXmlParser parser = new ZypperXmlParser();
+ parser.setDoc(xml);
+ String log = parser.getAllMessages();
+ printLog(log);
+ result = parser.getRepoList();
+ }
+ if (result != null) {
+ printResultLog(String.format("Get repository list: %d", result.size()));
+ printResultLog(result.toString());
+ } else {
+ printResultLog("Failed to get repository list");
+ }
+ return result;
+
+ }
+
+ public ICommandStatus refreshRepoListXmlOut() {
+ String command = makeCommand(getProxyCommand(), getResetRpmDb(),
+ ZypperTool.refreshRepoCommandXmlOut());
+ PackageManagerOuputReceiver hrec = getNewOuputReceiver();
+ ICommandStatus status = execute(command, hrec, null);
+ if (!status.isOk()) {
+ printResultLog("Failed to refresh repository");
+ } else {
+ List<String> value = status.getValues();
+ if (value != null && value.size() > 0) {
+ String xml = makeNewlineString(value);
+ ZypperXmlParser parser = new ZypperXmlParser();
+ parser.setDoc(xml);
+ String log = parser.getAllMessages();
+ printLog(log);
+ }
+ }
+ return status;
+ }
+
+ public ICommandStatus refreshRepoList() {
+ // refreshRepoListXmlOut();
+ String command = makeCommand(getProxyCommand(), getResetRpmDb(),
+ ZypperTool.refreshRepoCommand());
+ ICommandStatus status = execute(command, null);
+ if (!status.isOk()) {
+ printResultLog("Failed to refresh repository");
+ }
+
+ return status;
+ }
+
+ private ICommandStatus addRepoXmlOut(String name, String url) {
+ String command = ZypperTool.addRemoteRepoCommandXmlOut(name, url);
+ PackageManagerOuputReceiver hrec = getNewOuputReceiver();
+ ICommandStatus status = execute(command, hrec, null);
+ if (!status.isOk()) {
+ printResultLog("Failed to add repository");
+ } else {
+ List<String> value = status.getValues();
+ if (value != null && value.size() > 0) {
+ String xml = makeNewlineString(value);
+ ZypperXmlParser parser = new ZypperXmlParser();
+ parser.setDoc(xml);
+ String log = parser.getAllMessages();
+ printLog(log);
+ }
+ }
+ return status;
+ }
+
+ public ICommandStatus addRepo(String name, String url) {
+ changeUpdateMode();
+ // addRepoXmlOut(name, url);
+ String command = makeCommand(getProxyCommand(), getResetRpmDb(),
+ ZypperTool.addRemoteRepoCommand(name, url));
+ ICommandStatus status = execute(command, null);
+ if (!status.isOk()) {
+ printResultLog("Failed to add repository");
+ }
+ return status;
+ }
+
+ public ICommandStatus addLocalRepoXmlOut(String name, String path) {
+ String command = ZypperTool.addLocalRepoCommandXmlOut(name, path);
+ PackageManagerOuputReceiver hrec = getNewOuputReceiver();
+ ICommandStatus status = execute(command, hrec, null);
+ if (!status.isOk()) {
+ printResultLog("Failed to add local repository");
+ } else {
+ List<String> value = status.getValues();
+ if (value != null && value.size() > 0) {
+ String xml = makeNewlineString(value);
+ ZypperXmlParser parser = new ZypperXmlParser();
+ parser.setDoc(xml);
+ String log = parser.getAllMessages();
+ printLog(log);
+ }
+ }
+ return status;
+ }
+
+ public ICommandStatus addLocalRepo(String name, String path) {
+ changeUpdateMode();
+ // addLocalRepoXmlOut(name, path);
+ String command = makeCommand(getProxyCommand(), getResetRpmDb(),
+ ZypperTool.addLocalRepoCommand(name, path));
+ ICommandStatus status = execute(command, null);
+ if (!status.isOk()) {
+ printResultLog("Failed to add local repository");
+ }
+ return status;
+ }
+
+ public ICommandStatus removeRepoXmlOut(String name) {
+ String command = ZypperTool.removeRepoCommandXmlOut(name);
+ PackageManagerOuputReceiver hrec = getNewOuputReceiver();
+ ICommandStatus status = execute(command, hrec, null);
+ if (!status.isOk()) {
+ printResultLog("Failed to remove repository");
+ } else {
+ List<String> value = status.getValues();
+ if (value != null && value.size() > 0) {
+ String xml = makeNewlineString(value);
+ ZypperXmlParser parser = new ZypperXmlParser();
+ parser.setDoc(xml);
+ String log = parser.getAllMessages();
+ printLog(log);
+ }
+ }
+ return status;
+ }
+
+ public ICommandStatus removeRepo(String name) {
+ changeUpdateMode();
+ // removeRepoXmlOut(name);
+ String command = makeCommand(getProxyCommand(), getResetRpmDb(),
+ ZypperTool.removeRepoCommand(name));
+ ICommandStatus status = execute(command, null);
+ if (!status.isOk()) {
+ printResultLog("Failed to add repository");
+ }
+ return status;
+ }
+
+ public boolean checkPkgInstalled(String pkg) {
+ boolean ret = false;
+
+ String command = makeCommand(getResetRpmDb(), RpmTool.pkgListCommand(pkg));
+ // Do not use global output receiver
+ // because this log is not needed to print in console
+ PackageManagerOuputReceiver hrec = getNewOuputReceiver();
+ ICommandStatus status = execute(command, hrec, null);
+ if (!status.isOk()) {
+ return ret;
+ }
+
+ List<String> value = status.getValues();
+ if (value != null) {
+ for (String s : value) {
+ if (s.trim().startsWith(pkg)) {
+ ret = true;
+ pkg = s;
+ break;
+ }
+ }
+ }
+ if (ret) {
+ printResultLog(String.format("Checked package: %s", pkg));
+ } else {
+ printResultLog(String.format("Failed to check package: %s", pkg));
+ }
+ return ret;
+ }
+
+ public boolean existsFile(String file) {
+ boolean ret = false;
+ String command = String.format(CMD_FILE_FILE, file);
+ PackageManagerOuputReceiver hrec = getNewOuputReceiver();
+ ICommandStatus status = execute(command, hrec, null);
+ if (!status.isOk()) {
+ return ret;
+ }
+ List<String> value = status.getValues();
+ if (value != null) {
+ for (String s : value) {
+ if (s.trim().equals(file)) {
+ ret = true;
+ break;
+ }
+ }
+ }
+ if (ret) {
+ printResultLog(String.format("Checked file: %s", file));
+ } else {
+ printResultLog(String.format("Failed to check file: %s", file));
+ }
+ return ret;
+ }
+
+ public void resetRepo() {
+ String command = makeCommand(CMD_RESET_REPO);
+ PackageManagerOuputReceiver hrec = getNewOuputReceiver();
+ ICommandStatus status = execute(command, hrec, null);
+ if (!status.isOk()) {
+ printResultLog("Failed to reset repository");
+ }
+ printResultLog("Reset repository");
+ }
+
+ private ICommandStatus upgradeXmlOut(IProgressMonitor monitor) {
+ String command = makeCommand(getProxyCommand(), getResetRpmDb(),
+ ZypperTool.distUpgradeCommandXmlOut());
+ PackageManagerOuputReceiver hrec = getNewOuputReceiver();
+ ICommandStatus status = execute(command, hrec, monitor);
+ if (!status.isOk()) {
+ printResultLog("Failed to upgrade dist");
+ } else {
+ List<String> value = status.getValues();
+ if (value != null && value.size() > 0) {
+ String xml = makeNewlineString(value);
+ ZypperXmlParser parser = new ZypperXmlParser();
+ parser.setDoc(xml);
+ String log = parser.getAllMessages();
+ printLog(log);
+ }
+ }
+ return status;
+ }
+
+ public ICommandStatus upgrade(IProgressMonitor monitor) {
+ String command = makeCommand(getProxyCommand(), getResetRpmDb(),
+ ZypperTool.distUpgradeCommand());
+ ICommandStatus status = execute(command, null);
+ if (!status.isOk()) {
+ printResultLog("Failed to upgrade dist");
+ }
+ return status;
+ }
+
+ protected String getResetRpmDb() {
+ return CMD_RESET_RPM_DB;
+ }
+
+ protected String getProxyCommand() {
+ if (http_proxy != null && !http_proxy.isEmpty()) {
+ return String.format(CMD_EXPORT_PROXY, http_proxy);
+ } else {
+ return "";
+ }
+ }
+
+ protected String getResultString(String msg) {
+ return LOG_RESULT_PREFIX + WS + msg;
+ }
+
+ protected String getInfoString(String msg) {
+ return LOG_INFO_PREFIX + WS + msg;
+ }
+
+ protected PackageManagerOuputReceiver getNewOuputReceiverWithConsole() {
+ return getNewOuputReceiver(CONSOLE_NAME);
+ }
+
+ protected PackageManagerOuputReceiver getNewOuputReceiver(String consoleName) {
+ ConsoleManager cm = new ConsoleManager(consoleName, true);
+ MessageConsoleStream mcs = cm.getMessageConsoleStream();
+ PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver();
+ rec.setMessageConsoleStream(mcs);
+
+ return rec;
+ }
+
+ protected String makeNewlineString(List<String> list) {
+ String xml = "";
+ for (String s : list) {
+ xml += s + NL;
+ }
+
+ String stripXml = CharacterStripper.stripShellEscapseSequence(CharacterStripper
+ .stripNonValidXMLCharacters(xml));
+
+ return stripXml;
+ }
+
+ protected void printLog(String log) {
+ if (log.isEmpty()) {
+ return;
+ }
+ rec.setPrintConsole(true);
+ rec.processNewLines(log.split(NL));
+ }
+
+ protected void printResultLog(String log) {
+ printLog(getResultString(log));
+ }
+
+ protected void pringInfoLog(String log) {
+ printLog(getInfoString(log));
+ }
+
+ protected void printCommandLog(String command) {
+ String[] log = { NL + LOG_COMMAND_PREFIX + WS + command };
+ rec.setPrintConsole(true);
+ rec.processNewLines(log);
+ }
+
+ protected String makeCommand(String... cmds) {
+ String command = "";
+ int size = cmds.length;
+ for (int i = 0; i < size; i++) {
+ String cmd = cmds[i];
+ cmd = cmd.trim();
+ if (cmd.isEmpty())
+ continue;
+ if (i != size - 1) {
+ cmd = (cmd.endsWith(";")) ? cmd : cmd + CMD_DELIMITER;
+ }
+ command += cmd;
+ }
+ return command;
+ }
+
+}
--- /dev/null
+package org.tizen.nativeplatform.pkg.commander.rpm;
+
+import static org.tizen.sdblib.service.SyncServiceConstants.RESULT_OK;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.tizen.nativeplatform.pkg.commander.CommandStatus;
+import org.tizen.nativeplatform.pkg.commander.ICommandStatus;
+import org.tizen.nativeplatform.pkgmgr.PackageManagerOuputReceiver;
+import org.tizen.nativeplatform.pkgmgr.model.Package;
+import org.tizen.nativeplatform.util.CommandLauncherOnDevice;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.exception.SdbCommandRejectedException;
+import org.tizen.sdblib.exception.TimeoutException;
+import org.tizen.sdblib.service.SyncResult;
+import org.tizen.sdblib.service.SyncService;
+
+public class RpmCommanderDevice extends RpmCommanderCommon {
+
+ private static final String CONSOLE_NAME = "Device Internal";
+ private final String CMD_CHANGE_UPDATEMODE = "/bin/change-booting-mode.sh --update";
+ private final String CMD_ACTION_FOR_USING_ZYPPER = "sed -i \"s/# arch = s390/arch = i686/g\" /etc/zypp/zypp.conf";
+ private final String ZYPPER_CONF_FILE = "/etc/zypp/zypp.conf";
+
+ private IDevice device;
+
+ public RpmCommanderDevice() {
+ super(CONSOLE_NAME);
+ actionBeforeUsingZypper();
+ }
+
+ public RpmCommanderDevice(IDevice device) {
+ super(CONSOLE_NAME);
+ this.device = device;
+ actionBeforeUsingZypper();
+ }
+
+ public ICommandStatus copyFiles(String[] fileList) {
+ List<String> value = new ArrayList<String>();
+ for (String filePath : fileList) {
+ String filename = new File(filePath).getName();
+ IPath pathOnDevice = new Path(TMP_DIR).append(filename);
+ SyncService syncService;
+ try {
+ syncService = device.getSyncService();
+ } catch (TimeoutException e) {
+ return new CommandStatus(IStatus.ERROR, "", e.getMessage(), e);
+ } catch (SdbCommandRejectedException e) {
+ return new CommandStatus(IStatus.ERROR, "", e.getMessage(), e);
+ } catch (IOException e) {
+ return new CommandStatus(IStatus.ERROR, "", e.getMessage(), e);
+ }
+ SyncResult syncResult = syncService.push(filePath, device.getFileEntry( TMP_DIR ) );// Fixxed
+ if (syncResult.getCode() != RESULT_OK) {
+ return new CommandStatus(IStatus.ERROR, "", syncResult.getMessage(), null);
+ }
+ value.add(pathOnDevice.toOSString());
+ }
+
+ return new CommandStatus(IStatus.OK, value, null);
+ }
+
+ @Override
+ public Map<String, Package> getLocalPkgList() {
+ String tag = "\\<pkg\\>%{NAME},%{VERSION}-%{RELEASE},%{ARCH}\\<\\/pkg\\>";
+ return getLocalPkgList(tag);
+ }
+
+ protected void changeUpdateMode() {
+ if (!device.isEmulator()) {
+ execute(CMD_CHANGE_UPDATEMODE, null);
+ }
+ }
+
+ protected void actionBeforeUsingZypper() {
+ if (device.isEmulator()) {
+ if (existsFile(ZYPPER_CONF_FILE)) {
+ String command = CMD_ACTION_FOR_USING_ZYPPER;
+ execute(command, null);
+ }
+ }
+ }
+
+ protected ICommandStatus execute(String command, IProgressMonitor monitor) {
+ return execute(command, monitor, true);
+ }
+
+ protected ICommandStatus execute(String command, IProgressMonitor monitor, boolean printlog) {
+ if (printlog) {
+ printCommandLog(command);
+ }
+ ICommandStatus status = CommandLauncherOnDevice.execute(device, command, rec);
+ if (!status.isOk()) {
+ logger.error(status.getMessage(), status.getException());
+ }
+ return status;
+ }
+
+ protected ICommandStatus execute(String command, PackageManagerOuputReceiver rec,
+ IProgressMonitor monitor) {
+ return execute(command, rec, monitor, true);
+ }
+
+ protected ICommandStatus execute(String command, PackageManagerOuputReceiver rec,
+ IProgressMonitor monitor, boolean printlog) {
+ if (printlog) {
+ printCommandLog(command);
+ }
+ ICommandStatus status = CommandLauncherOnDevice.execute(device, command, rec);
+ if (!status.isOk()) {
+ logger.error(status.getMessage(), status.getException());
+ }
+ return status;
+ }
+
+ protected PackageManagerOuputReceiver getNewOuputReceiver() {
+ PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver();
+ rec.setPrintConsole(false);
+ return rec;
+ }
+}
--- /dev/null
+package org.tizen.nativeplatform.pkg.commander.rpm;
+
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.tizen.nativeplatform.pkg.commander.ICommandStatus;
+import org.tizen.nativeplatform.pkgmgr.PackageManagerOuputReceiver;
+import org.tizen.nativeplatform.pkgmgr.model.Package;
+
+public class RpmCommanderHost extends RpmCommanderCommon {
+
+ public RpmCommanderHost() {
+ super();
+ }
+
+ @Override
+ protected PackageManagerOuputReceiver getNewOuputReceiver() {
+ return null;
+ }
+
+ @Override
+ public Map<String, Package> getLocalPkgList() {
+ return null;
+ }
+
+ @Override
+ public ICommandStatus copyFiles(String[] fileList) {
+ return null;
+ }
+
+ @Override
+ protected ICommandStatus execute(String command, IProgressMonitor monitor) {
+ return null;
+ }
+
+ @Override
+ protected ICommandStatus execute(String command, IProgressMonitor monitor, boolean printlog) {
+ return null;
+ }
+
+ @Override
+ protected ICommandStatus execute(String command, PackageManagerOuputReceiver rec,
+ IProgressMonitor monitor) {
+ return null;
+ }
+
+ @Override
+ protected ICommandStatus execute(String command, PackageManagerOuputReceiver rec,
+ IProgressMonitor monitor, boolean printLog) {
+ return null;
+ }
+
+ @Override
+ protected void changeUpdateMode() {
+ return;
+ }
+
+ @Override
+ protected void actionBeforeUsingZypper() {
+ return;
+ }
+}
--- /dev/null
+package org.tizen.nativeplatform.pkg.commander.rpm;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.tizen.common.util.FileUtil;
+import org.tizen.nativeplatform.pkg.commander.CommandStatus;
+import org.tizen.nativeplatform.pkg.commander.ICommandStatus;
+import org.tizen.nativeplatform.pkgmgr.PackageManagerOuputReceiver;
+import org.tizen.nativeplatform.pkgmgr.model.Package;
+import org.tizen.nativeplatform.util.CommandLauncherOnRootstrap;
+
+public class RpmCommanderRootstrap extends RpmCommanderCommon {
+
+ private static final String CONSOLE_NAME = "Rootstrap Internal";
+ private final String REMOVE_PKGS = "rpm-x86-arm";
+
+ private IPath rootPath;
+
+ public RpmCommanderRootstrap(IPath rootPath) {
+ super(CONSOLE_NAME);
+ this.rootPath = rootPath;
+ actionBeforeUsingZypper();
+ }
+
+ protected void actionBeforeUsingZypper() {
+ /*
+ * (with --nodeps --force) Error: Subprocess failed. Error: RPM failed:
+ * error: db4 error(-30971) from dbenv->open: DB_VERSION_MISMATCH:
+ * Database environment version mismatch error: cannot open Packages
+ * index using db4 - (-30971) error: cannot open Packages database in
+ * /var/lib/rpm error: db4 error(-30971) from dbenv->open:
+ * DB_VERSION_MISMATCH: Database environment version mismatch error:
+ * cannot open Packages database in /var/lib/rpm
+ */
+ if (checkPkgInstalled(REMOVE_PKGS)) {
+ uninstallPkg(REMOVE_PKGS, null);
+ }
+ }
+
+ public ICommandStatus copyFiles(String[] fileList) {
+ List<String> value = new ArrayList<String>();
+ for (String filePath : fileList) {
+ String filename = new File(filePath).getName();
+ IPath pathOnRootstrap = new Path(TMP_DIR).append(filename);
+ IPath toFilePath = rootPath.append(pathOnRootstrap);
+ try {
+ FileUtil.copyTo(filePath, toFilePath.toOSString());
+ } catch (IOException e) {
+ return new CommandStatus(IStatus.ERROR, "", e.getMessage(), e);
+ }
+ value.add(pathOnRootstrap.toOSString());
+ }
+ return new CommandStatus(IStatus.OK, value, null);
+ }
+
+ @Override
+ public Map<String, Package> getLocalPkgList() {
+ String tag = "\\\\<pkg\\\\>%{NAME},%{VERSION}-%{RELEASE},%{ARCH}\\\\<\\\\/pkg\\\\>";
+ return getLocalPkgList(tag);
+ }
+
+ protected ICommandStatus execute(String command, IProgressMonitor monitor) {
+ return execute(command, monitor, true);
+ }
+
+ protected ICommandStatus execute(String command, IProgressMonitor monitor, boolean printlog) {
+ String chrootedCommand = getChrootedCommand(command);
+ if (printlog) {
+ printCommandLog(chrootedCommand);
+ }
+ ICommandStatus status = CommandLauncherOnRootstrap.executeSudo(chrootedCommand, null, rec,
+ monitor);
+ if (!status.isOk()) {
+ logger.error(status.getMessage(), status.getException());
+ }
+ return status;
+ }
+
+ protected ICommandStatus execute(String command, PackageManagerOuputReceiver rec,
+ IProgressMonitor monitor) {
+ return execute(command, rec, monitor, true);
+ }
+
+ protected ICommandStatus execute(String command, PackageManagerOuputReceiver rec,
+ IProgressMonitor monitor, boolean printlog) {
+ String chrootedCommand = getChrootedCommand(command);
+ if (printlog) {
+ printCommandLog(chrootedCommand);
+ }
+ ICommandStatus status = CommandLauncherOnRootstrap.executeSudo(chrootedCommand, null, rec,
+ monitor);
+ if (!status.isOk()) {
+ logger.error(status.getMessage(), status.getException());
+ }
+ return status;
+ }
+
+ private String getChrootedCommand(String cmd) {
+ return String.format("sudo -S chroot %s sh -c \\\"%s\\\"", rootPath.toOSString(), cmd);
+ }
+
+ protected PackageManagerOuputReceiver getNewOuputReceiver() {
+ return null;
+ }
+
+ @Override
+ protected void changeUpdateMode() {
+ return;
+ }
+}
--- /dev/null
+package org.tizen.nativeplatform.pkg.commander.rpm;
+
+import java.util.List;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.tizen.nativecommon.build.CommonProjectDependentPackager;
+import org.tizen.nativecommon.build.ProjectTypeManager;
+import org.tizen.nativecommon.build.exception.SBIException;
+import org.tizen.nativeplatform.build.PlatformCheckCancelJob;
+import org.tizen.nativeplatform.launch.wizards.PlatformLaunchUtils;
+import org.tizen.nativeplatform.pkg.commander.IPackager;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
+import org.tizen.nativeplatform.pkgmgr.model.LocalPackage;
+
+public class RpmPackager implements IPackager {
+
+ private IProject project = null;
+ private IConfiguration config = null;
+
+ public RpmPackager(IProject proj, IConfiguration config) {
+ this.project = proj;
+ this.config = config;
+ }
+
+ @Override
+ public boolean packaging(IProgressMonitor monitor) {
+ String PKGTYPE = "RPM";
+ boolean result = false;
+
+ CommonProjectDependentPackager packager = ProjectTypeManager
+ .getProjectPackagerInstance(project);
+
+ monitor.beginTask("Packaging...", 2);
+
+ PlatformCheckCancelJob cancelJob = new PlatformCheckCancelJob(monitor, project,
+ packager.getSbi());
+ Thread checkCancelThread = new Thread(cancelJob);
+ checkCancelThread.start();
+
+ try {
+ monitor.subTask("Packaging " + project.getName());
+ packager.buildPackage(PKGTYPE);
+ } catch (SBIException e) {
+ e.printStackTrace();
+ cancelJob.setFinishFlag(true);
+ monitor.done();
+ return false;
+ } catch (CoreException e) {
+ cancelJob.setFinishFlag(true);
+ monitor.done();
+ return false;
+ }
+ monitor.worked(1);
+ cancelJob.setFinishFlag(true);
+ monitor.subTask("Refreshing project...");
+ PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(new PkgCommandTarget());
+ List<LocalPackage> pkgfiles = launchUtils.getProjectPackages(project, config.getName());
+ try {
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ monitor.worked(2);
+ result = !pkgfiles.isEmpty();
+ monitor.done();
+ return result;
+ }
+}
--- /dev/null
+package org.tizen.nativeplatform.pkg.commander.rpm;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.tizen.nativeplatform.pkg.commander.IPkgVersionComparer;
+
+public class RpmVersionComparer implements IPkgVersionComparer {
+
+ public RpmVersionComparer() {
+ }
+
+ @Override
+ public int compare(String ver1, String ver2) {
+ List<String> tokList1 = tokenizeVersionString(ver1);
+ List<String> tokList2 = tokenizeVersionString(ver2);
+ int maxTokens = tokList1.size() > tokList2.size() ? tokList1.size() : tokList2.size();
+
+ for (int i = 0; i < maxTokens; i++) {
+ // check length
+ if (i == tokList1.size()) {
+ return -1;
+ }
+ if (i == tokList2.size()) {
+ return 1;
+ }
+
+ String tok1 = tokList1.get(i);
+ String tok2 = tokList2.get(i);
+
+ int value1 = -1, value2 = -1;
+ try {
+ value1 = Integer.parseInt(tok1);
+ } catch (NumberFormatException e) {
+ // do nothing
+ // e.printStackTrace();
+ }
+
+ try {
+ value2 = Integer.parseInt(tok2);
+ } catch (NumberFormatException e) {
+ // do nothing
+ // e.printStackTrace();
+ }
+
+ if (value1 > value2) {
+ return 1;
+ } else if (value1 < value2) {
+ return -1;
+ } else {
+ int result = tok1.compareTo(tok2);
+ if (result != 0) {
+ return result;
+ }
+ }
+ }
+
+ return 0;
+ }
+
+ private static List<String> tokenizeVersionString(String ver) {
+ List<String> result = new ArrayList<String>();
+ final int NUM = 0;
+ final int ALPHA = 1;
+ final int NONALPHANUM = 2;
+ int oldStatus = NONALPHANUM;
+ String buf = "";
+ for (int i = 0; i < ver.length(); i++) {
+ char c = ver.charAt(i);
+ int newStatus;
+ if (c >= '0' && c <= '9') {
+ newStatus = NUM;
+ } else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
+ newStatus = ALPHA;
+ } else {
+ newStatus = NONALPHANUM;
+ }
+
+ if (oldStatus != newStatus) {
+ if (!buf.isEmpty()) {
+ result.add(buf);
+ }
+ if (newStatus != NONALPHANUM) {
+ buf = String.valueOf(c);
+ } else {
+ buf = "";
+ }
+ oldStatus = newStatus;
+ } else {
+ if (newStatus != NONALPHANUM) {
+ buf += String.valueOf(c);
+ }
+ }
+ }
+ if (!buf.isEmpty()) {
+ result.add(buf);
+ }
+
+ return result;
+ }
+
+}
--- /dev/null
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.pkg.tools;
+
+public class PkgcmdTool {
+
+ private final static String WS = " ";
+ private final static String TOOL = "pkgcmd";
+ private final static String INSTALL_OP = "--install";
+
+ private final static String PKGTYPE_OP = "--package-type";
+ private final static String PKGPATH_OP = "--package-path";
+
+ private final static String QUIET_OP = "--quiet";
+
+ public static String installCommand(String[] list) {
+ return installCommand(list[0]);
+ }
+
+ public static String installCommand(String file) {
+ return makeCommand(INSTALL_OP, QUIET_OP, PKGTYPE_OP, "rpm", PKGPATH_OP, file);
+ }
+
+ private static String makeCommand(String... options) {
+ String command = TOOL + WS;
+ for (String op : options) {
+ op = op.trim();
+ if (op.isEmpty())
+ continue;
+ command += op + WS;
+ }
+ return command.trim();
+ }
+}
--- /dev/null
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.pkg.tools;
+
+public class RpmTool {
+
+ private final static String WS = " ";
+ private final static String TOOL = "rpm";
+ private final static String UNINSTALL_OP = "--erase";
+ private final static String INSTALL_OP = "--install";
+ private final static String VERBOSE_OP = "--verbose";
+ private final static String HASH_OP = "--hash";
+ private final static String IGNOREOS_OP = "--ignoreos";
+ private final static String FORCE_OP = "--force";
+ private final static String NODEPS_OP = "--nodeps";
+ private final static String IGNOREARCH_OP = "--ignorearch";
+ private final static String QUERY_PKGLIST_OP = "-qa";
+ private final static String QUERY_PKGINFO_OP = "-qi";
+ private final static String QUERY_RPMFILE_INFO_OP = "-qp";
+ private final static String QUERY_INFO_TAG_OP = "--qf";
+
+ private final static String TAG_ARCH = "%{ARCH},";
+ private final static String TAG_NAME = "%{NAME},";
+ private final static String TAG_FULL_VER = "%{VERSION}-%{RELEASE},";
+ private final static String TAG_VER = "%{VERSION}";
+ private final static String TAG_RELEASE_VER = "%{RELEASE}";
+
+ public static String installCommand(String[] list) {
+ // Command.Install.Local.Pkg.RPM = rpm -ihv %s --ignoreos --force
+ // --nodeps --ignorearch
+
+ String files = "";
+ for (String s : list) {
+ files = files + s + WS;
+ }
+ files = files.trim();
+ return makeCommand(INSTALL_OP, HASH_OP, VERBOSE_OP, IGNOREOS_OP, FORCE_OP, NODEPS_OP,
+ IGNOREARCH_OP, files);
+ }
+
+ public static String uninstallCommand(String[] list) {
+ // Command.Uninstall.Pkg.NoDeps = rpm -e %s --nodeps
+ String pkgs = "";
+ for (String s : list) {
+ pkgs = pkgs + s + " ";
+ }
+ pkgs = pkgs.trim();
+ return makeCommand(UNINSTALL_OP, NODEPS_OP, pkgs);
+ }
+
+ public static String pkgListCommand() {
+ // Command.Show.Pkg = rpm -qa
+ return makeCommand(QUERY_PKGLIST_OP);
+ }
+
+ public static String pkgListCommand(String pkg) {
+ // Command.Show.Pkg = rpm -qa %s
+ return makeCommand(QUERY_PKGLIST_OP, pkg);
+ }
+
+ public static String pkgInfoCommand(String pkg) {
+ // Command.Show.Info.Pkg = rpm -qi %s
+ return makeCommand(QUERY_PKGINFO_OP, pkg);
+ }
+
+ public static String fileInfoByTagCommand(String tag, String file) {
+
+ // Command.Info.Pkg.File = rpm -qp --qf "%%{%s}\n" %s
+ return makeCommand(QUERY_RPMFILE_INFO_OP, QUERY_INFO_TAG_OP, tag, file);
+ }
+
+ public static String pkgInfoByTagCommand(String tag, String pkg) {
+ return makeCommand(QUERY_PKGLIST_OP, QUERY_INFO_TAG_OP, tag, pkg);
+ }
+
+ public static String pkgListByTagCommand(String tag) {
+ // Command.List.Installed.Pkg = rpm -qa --qf
+ // \\\\<pkg\\\\>%{NAME},%{VERSION}-%{RELEASE},%{ARCH}\\\\<\\\\/pkg\\\\>
+ // Command.List.Installed.Pkg.Device = rpm -qa --qf
+ // \\<pkg\\>%{NAME},%{VERSION}-%{RELEASE},%{ARCH}\\<\\/pkg\\>
+ // return makeCommand(QUERY_PKGLIST_OP, QUERY_INFO_TAG_OP, tag);
+ return makeCommand(QUERY_PKGLIST_OP, QUERY_INFO_TAG_OP, tag);
+ }
+
+ public static String fileArchCommand(String file) {
+ return fileInfoByTagCommand(TAG_ARCH, file);
+ }
+
+ public static String fileNameCommand(String file) {
+ return fileInfoByTagCommand(TAG_NAME, file);
+ }
+
+ public static String fileFullVerCommand(String file) {
+ return fileInfoByTagCommand(TAG_FULL_VER, file);
+ }
+
+ public static String fileVerCommand(String file) {
+ return fileInfoByTagCommand(TAG_VER, file);
+ }
+
+ public static String fileRelVerCommand(String file) {
+ return fileInfoByTagCommand(TAG_RELEASE_VER, file);
+ }
+
+ public static String pkgArchCommand(String pkg) {
+ return pkgInfoByTagCommand(TAG_ARCH, pkg);
+ }
+
+ public static String pkgNameCommand(String pkg) {
+ return pkgInfoByTagCommand(TAG_NAME, pkg);
+ }
+
+ public static String pkgFullVerCommand(String pkg) {
+ return pkgInfoByTagCommand(TAG_FULL_VER, pkg);
+ }
+
+ public static String pkgVerCommand(String pkg) {
+ return pkgInfoByTagCommand(TAG_VER, pkg);
+ }
+
+ public static String pkgRelVerCommand(String pkg) {
+ return pkgInfoByTagCommand(TAG_RELEASE_VER, pkg);
+ }
+
+ private static String makeCommand(String... options) {
+ String command = TOOL + WS;
+ for (String op : options) {
+ op = op.trim();
+ if (op.isEmpty())
+ continue;
+ command += op + WS;
+ }
+ return command.trim();
+ }
+}
--- /dev/null
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.pkg.tools;
+
+public class ZypperTool {
+
+ private static final String WS = " ";
+ private static final String TOOL = "zypper";
+
+ // Global options
+ private static final String NON_INTERACITVE_OP = "--non-interactive";
+ private static final String XMLOUT_OP = "--xmlout";
+
+ // Package management
+ private static final String INSTALL_OP = "install";
+ private static final String INSTALL_FORCE_OP = "--force";
+ private static final String UNINSTALL_OP = "remove";
+ private static final String UPDATE_OP = "update";
+
+ // Repository management
+ private static final String REPO_ADD_OP = "addrepo";
+ private static final String REPO_ADD_TYPE_OP = "--type";
+ private static final String REPO_REMOVE_OP = "removerepo";
+ private static final String REPO_REFRESH_OP = "refresh";
+ private static final String REPO_LIST_OP = "repos";
+ private static final String REPO_LIST_URI_OP = "-u";
+
+ // Querying
+ private static final String QUERY_PKGLIST_OP = "packages";
+
+ // Update management
+ private static final String PKG_UPDATE_OP = "update";
+ private static final String DIST_UPGRADE_OP = "dist-upgrade";
+
+ public static String installLocalCommand(String[] list) {
+ // Command.Install.Local.Pkg = zypper --non-interactive in --force %s
+ String pkgs = "";
+ for (String s : list) {
+ pkgs = pkgs + s + WS;
+ }
+ pkgs = pkgs.trim();
+ return makeCommand(NON_INTERACITVE_OP, INSTALL_OP, INSTALL_FORCE_OP, pkgs);
+ }
+
+ public static String installRemoteCommand(String[] list) {
+ // Command.Install.Remote.Pkg = zypper --non-interactive in %s
+
+ String pkgs = "";
+ for (String s : list) {
+ pkgs = pkgs + s + WS;
+ }
+ pkgs = pkgs.trim();
+ return makeCommand(NON_INTERACITVE_OP, INSTALL_OP, pkgs);
+ }
+
+ public static String installLocalCommandXmlOut(String[] list) {
+ String pkgs = "";
+ for (String s : list) {
+ pkgs = pkgs + s + WS;
+ }
+ pkgs = pkgs.trim();
+ return makeCommand(XMLOUT_OP, NON_INTERACITVE_OP, INSTALL_OP, INSTALL_FORCE_OP, pkgs);
+ }
+
+ public static String installRemoteCommandXmlOut(String[] list) {
+ String pkgs = "";
+ for (String s : list) {
+ pkgs = pkgs + s + WS;
+ }
+ pkgs = pkgs.trim();
+ return makeCommand(XMLOUT_OP, NON_INTERACITVE_OP, INSTALL_OP, pkgs);
+ }
+
+ public static String uninstallCommand(String[] list) {
+ // Command.Uninstall.Pkg = zypper --non-interactive remove %s
+
+ String pkgs = "";
+ for (String s : list) {
+ pkgs = pkgs + s + WS;
+ }
+ pkgs = pkgs.trim();
+ return makeCommand(NON_INTERACITVE_OP, UNINSTALL_OP, pkgs);
+ }
+
+ public static String uninstallCommandXmlOut(String[] list) {
+ String pkgs = "";
+ for (String s : list) {
+ pkgs = pkgs + s + WS;
+ }
+ pkgs = pkgs.trim();
+ return makeCommand(XMLOUT_OP, NON_INTERACITVE_OP, UNINSTALL_OP, pkgs);
+ }
+
+ public static String remotePkgListCommand() {
+ // Command.List.Remote.Pkg = zypper --non-interactive pa
+ return makeCommand(NON_INTERACITVE_OP, QUERY_PKGLIST_OP);
+ }
+
+ public static String remotePkgListCommandWithXmlOut() {
+ // Command.List.Remote.Pkg = zypper --non-interactive pa
+ return makeCommand(XMLOUT_OP, NON_INTERACITVE_OP, QUERY_PKGLIST_OP);
+ }
+
+ public static String addLocalRepoCommand(String name, String url) {
+ return makeCommand(NON_INTERACITVE_OP, REPO_ADD_OP, REPO_ADD_TYPE_OP, "plaindir", url, name);
+ }
+
+ public static String addLocalRepoCommandXmlOut(String name, String url) {
+ return makeCommand(XMLOUT_OP, NON_INTERACITVE_OP, REPO_ADD_OP, REPO_ADD_TYPE_OP,
+ "plaindir", url, name);
+ }
+
+ public static String addRemoteRepoCommand(String name, String url) {
+ return makeCommand(NON_INTERACITVE_OP, REPO_ADD_OP, url, name);
+ }
+
+ public static String addRemoteRepoCommandXmlOut(String name, String url) {
+ return makeCommand(XMLOUT_OP, NON_INTERACITVE_OP, REPO_ADD_OP, url, name);
+ }
+
+ public static String removeRepoCommand(String name) {
+ return makeCommand(NON_INTERACITVE_OP, REPO_REMOVE_OP, name);
+ }
+
+ public static String removeRepoCommandXmlOut(String name) {
+ return makeCommand(XMLOUT_OP, NON_INTERACITVE_OP, REPO_REMOVE_OP, name);
+ }
+
+ public static String refreshRepoCommand() {
+ return makeCommand(NON_INTERACITVE_OP, REPO_REFRESH_OP);
+ }
+
+ public static String refreshRepoCommandXmlOut() {
+ return makeCommand(XMLOUT_OP, NON_INTERACITVE_OP, REPO_REFRESH_OP);
+ }
+
+ public static String distUpgradeCommand() {
+ return makeCommand(NON_INTERACITVE_OP, DIST_UPGRADE_OP);
+ }
+
+ public static String distUpgradeCommandXmlOut() {
+ return makeCommand(XMLOUT_OP, NON_INTERACITVE_OP, DIST_UPGRADE_OP);
+ }
+
+ public static String RepoListCommand() {
+ return makeCommand(REPO_LIST_OP, REPO_LIST_URI_OP);
+ }
+
+ public static String RepoListCommandXmlOut() {
+ return makeCommand(XMLOUT_OP, REPO_LIST_OP, REPO_LIST_URI_OP);
+ }
+
+ private static String makeCommand(String... options) {
+ String command = TOOL + WS;
+ for (String op : options) {
+ op = op.trim();
+ if (op.isEmpty())
+ continue;
+ command += op + WS;
+ }
+ return command.trim();
+ }
+}
--- /dev/null
+package org.tizen.nativeplatform.pkg.tools;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tizen.nativeplatform.pkgmgr.model.Package;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class ZypperXmlParser {
+ public final String TAG_MESSAGE = "message";
+ public final String TAG_STREAM = "stream";
+ public final String ATTR_TYPE = "type";
+ public final String ATTR_TYPE_ERROR = "error";
+ public final String ATTR_TYPE_INFO = "info";
+ public final String ATTR_TYPE_WARN = "warning";
+
+ public final String RESULT_ERROR_PREFIX = "[ERROR]";
+ public final String RESULT_INFO_PREFIX = "[INFO]";
+ public final String RESULT_WARN_PREFIX = "[WARN]";
+ public final String XML_PREFIX = "<?xml";
+ public final String NEW_LINE = "\n";
+
+ private Document doc = null;
+
+ private final Logger logger = LoggerFactory.getLogger(ZypperXmlParser.class);
+
+ public ZypperXmlParser() {
+ }
+
+ public ZypperXmlParser(Document doc) {
+ setDoc(doc);
+ }
+
+ public void setDoc(Document doc) {
+ this.doc = doc;
+ }
+
+ public boolean setDoc(String xml) {
+ if (xml.contains(XML_PREFIX)) {
+ int index = xml.indexOf(XML_PREFIX);
+ xml = xml.substring(index);
+ }
+
+ Document doc = null;
+ StringReader sr = new StringReader(xml);
+ InputSource is = new InputSource(sr);
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db;
+ try {
+ db = dbf.newDocumentBuilder();
+ doc = db.parse(is);
+ } catch (ParserConfigurationException e) {
+ logger.error(e.getMessage(), e);
+ return false;
+ } catch (SAXException e) {
+ logger.error(e.getMessage(), e);
+ return false;
+ } catch (IOException e) {
+ logger.error(e.getMessage(), e);
+ return false;
+ }
+ if (doc != null) {
+ this.doc = doc;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public String getErrorMessages() {
+ return getMessages(ATTR_TYPE, ATTR_TYPE_ERROR);
+ }
+
+ public String getInfoMessages() {
+ return getMessages(ATTR_TYPE, ATTR_TYPE_INFO);
+ }
+
+ public String getWarnMessages() {
+ return getMessages(ATTR_TYPE, ATTR_TYPE_WARN);
+ }
+
+ public String getErrorInfoMessages() {
+ return getMessages(ATTR_TYPE, ATTR_TYPE_ERROR, ATTR_TYPE_INFO);
+ }
+
+ public String getAllMessages() {
+ return getMessages(ATTR_TYPE, ATTR_TYPE_ERROR, ATTR_TYPE_WARN, ATTR_TYPE_INFO);
+ }
+
+ public String getErrorWarnMessages() {
+ return getMessages(ATTR_TYPE, ATTR_TYPE_ERROR, ATTR_TYPE_WARN);
+ }
+
+ public String getPkgListFromStreams() {
+ NodeList streamNodes = doc.getElementsByTagName(TAG_STREAM);
+ String content = "";
+ if (streamNodes.getLength() > 0) {
+ // <stream> node length should be one.
+ Node node = streamNodes.item(0).getLastChild();
+ if (node == null)
+ return "";
+ content = node.getNodeValue();
+ }
+ return content;
+ }
+
+ public Map<String, Package> getPkgList() {
+ String list = getPkgListFromStreams();
+ Map<String, Package> pkgMap = new HashMap<String, Package>();
+
+ if (!list.isEmpty()) {
+ for (String s : list.split(NEW_LINE)) {
+ s = s.replaceAll(" ", "").trim();
+ String[] part = s.split("\\|");
+ if (part.length == 5 && !isTitleLineInPkgList(part)) {
+ String name = part[2];
+ String version = part[3];
+ String arch = part[4];
+ if (part[0].equals("i")) {
+ pkgMap.put(name, new Package(name, version, Package.INSTALLINFO.INSTALLED,
+ version, arch));
+ /*
+ * } else if (part[0].equals("v")) { Package p =
+ * pkgMap.get(name); if (p != null &&
+ * version.compareTo(p.getNewVersion()) > 0) {
+ * p.setNewVersion(version); } else { pkgMap.put(name,
+ * new Package(name, "", version, arch)); }
+ */
+ } else {
+ pkgMap.put(name, new Package(name, "", version, arch));
+ }
+ }
+ }
+ }
+
+ return pkgMap;
+ }
+
+ public Map<String, String> getRepoList() {
+ if (doc == null) {
+ return null;
+ }
+
+ Map<String, String> repoMap = new HashMap<String, String>();
+
+ doc.getDocumentElement().normalize();
+ NodeList repoNodes = doc.getElementsByTagName("repo");
+ for (int i = 0; i < repoNodes.getLength(); i++) {
+ String alias = "";
+ String url = "";
+ Node repoNode = repoNodes.item(i);
+ NamedNodeMap map = repoNode.getAttributes();
+ Node node = map.getNamedItem("alias");
+ if (node != null) {
+ alias = node.getNodeValue();
+ } else {
+ continue;
+ }
+
+ NodeList urlNodes = repoNode.getChildNodes();
+ for (int j = 0; j < urlNodes.getLength(); j++) {
+ Node urlNode = urlNodes.item(j);
+ if (urlNode.getNodeName().equals("url")) {
+ url = urlNode.getTextContent();
+ break;
+ }
+ }
+
+ repoMap.put(alias, url);
+ }
+
+ return repoMap;
+
+ }
+
+ public String getMessages(String attr, String... attrValue) {
+ if (doc == null) {
+ return "";
+ }
+ String result = "";
+ doc.getDocumentElement().normalize();
+ NodeList messageNodes = doc.getElementsByTagName(TAG_MESSAGE);
+ for (int i = 0; i < messageNodes.getLength(); i++) {
+ Node ii = messageNodes.item(i);
+ NamedNodeMap map = ii.getAttributes();
+ Node node = map.getNamedItem(attr);
+ if (node != null) {
+ String type = node.getNodeValue();
+ for (String value : attrValue) {
+ if (type.equals(value)) {
+ Node fChild = ii.getFirstChild();
+ if (fChild == null)
+ continue;
+ String str = fChild.getNodeValue();
+ if (str == null || str.isEmpty())
+ continue;
+ result += "[" + value + "] " + str
+ + ((str.endsWith(NEW_LINE)) ? "" : NEW_LINE);
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private boolean isTitleLineInPkgList(String[] line) {
+ return ((line.length == 5) && (line[1].equals("Repository")) && (line[2].equals("Name"))) ? true
+ : false;
+ }
+}
+++ /dev/null
-/*
- * Native Platform
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Donghyuk Yang <donghyuk.yang@samsung.com>
- * DongHee Yang <donghee.yang@samsung.com>
- * Kangho Kim <kh5325.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.nativeplatform.pkgmgr;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedProject;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.tizen.common.connection.ConnectionPlugin;
-import org.tizen.nativecommon.build.CurrentEnabledProject;
-import org.tizen.nativecommon.build.SmartBuildInterface;
-import org.tizen.nativecommon.build.exception.SBIException;
-import org.tizen.nativeplatform.build.PlatformConfigurationManager;
-import org.tizen.nativeplatform.pkgmgr.ui.RPMPackageDialog;
-import org.tizen.sdblib.IDevice;
-
-public class DialogActionDelegate implements IWorkbenchWindowActionDelegate {
-
- private IWorkbenchWindow window;
-
- private SmartBuildInterface sbi = null;
- private final String BUNDLE_NAME = DialogActionDelegate.class.getPackage().getName() + ".RPMPackageCommands";
- private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
-
- @Override
- public void run(IAction action) {
- IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
- String target = null;
- boolean enableRootstrap = true;
- boolean enableTarget = true;
-
- IProject project = CurrentEnabledProject.getCurrentProject();
- Shell shell = window.getShell();
- if (project == null) {
- MessageDialog.openError(shell, "Error", resources.getString("PkgMgr.Error.Noselected.Project"));
- return;
- }
- sbi = SmartBuildInterface.getInstance(project);
-
- IConfiguration cfg = ManagedBuildManager.getBuildInfo( project ).getDefaultConfiguration();
- String targetName = PlatformConfigurationManager.getBuildTargetName(cfg);
-
- IManagedProject managedProject = cfg.getManagedProject();
- String projectArtifactType = managedProject.getProjectType().getBuildArtefactType().getId();
- if (!projectArtifactType.equals(PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE)) {
- MessageDialog.openError(shell, "Error", resources.getString("PkgMgr.Error.Not.Platformproject"));
- return;
- }
-
- if (device == null) {
- enableTarget = false;
- } else {
- target = device.getSerialNumber();
- if (target == null) {
- enableTarget = false;
- }
- }
-
- String result = "";
- try {
- result = sbi.queryStdOut("command", targetName, null);
- } catch (SBIException e) {
- e.printStackTrace();
- }
- if (!result.contains("passwd")) {
- MessageDialog.openError(shell, "Error", resources.getString("PkgMgr.Error.Not.SupportedRpm"));
- return;
- }
- RPMPackageDialog pkgdlg = new RPMPackageDialog(window.getShell(), target, enableRootstrap, enableTarget);
- pkgdlg.open();
- }
-
- @Override
- public void selectionChanged(IAction action, ISelection selection) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void init(IWorkbenchWindow window) {
- this.window = window;
- }
-
-}
+++ /dev/null
-/*
- * Native Platform
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Donghyuk Yang <donghyuk.yang@samsung.com>
- * DongHee Yang <donghee.yang@samsung.com>
- * Kangho Kim <kh5325.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.nativeplatform.pkgmgr;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedProject;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import org.tizen.common.connection.ConnectionPlugin;
-
-import org.tizen.nativeplatform.pkgmgr.ui.RPMPackageDialog;
-import org.tizen.nativecommon.build.CurrentEnabledProject;
-import org.tizen.nativecommon.build.SmartBuildInterface;
-import org.tizen.nativecommon.build.exception.SBIException;
-import org.tizen.nativeplatform.build.PlatformConfigurationManager;
-import org.tizen.sdblib.IDevice;
-
-/**
- * Our sample handler extends AbstractHandler, an IHandler base class.
- * @see org.eclipse.core.commands.IHandler
- * @see org.eclipse.core.commands.AbstractHandler
- */
-public class PackageManagerHandler extends AbstractHandler {
-
- private SmartBuildInterface sbi = null;
-
- private final String BUNDLE_NAME = PackageManagerHandler.class.getPackage().getName() + ".RPMPackageCommands";
- private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
-
- /**
- * The constructor.
- */
- public PackageManagerHandler() {
- }
-
- /**
- * the command has been executed, so extract extract the needed information
- * from the application context.
- */
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
- IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
- String target = null;
- boolean enableRootstrap = true;
- boolean enableTarget = true;
-
- IProject project = CurrentEnabledProject.getCurrentProject();
- Shell shell = window.getShell();
- if (project == null) {
- MessageDialog.openError(shell, "Error", resources.getString("PkgMgr.Error.Noselected.Project"));
- return null;
- }
- sbi = SmartBuildInterface.getInstance(project);
-
- IConfiguration cfg = ManagedBuildManager.getBuildInfo( project ).getDefaultConfiguration();
- String targetName = PlatformConfigurationManager.getBuildTargetName(cfg);
-
- IManagedProject managedProject = cfg.getManagedProject();
- String projectArtifactType = managedProject.getProjectType().getBuildArtefactType().getId();
- if (!projectArtifactType.equals(PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE)) {
- MessageDialog.openError(shell, "Error", resources.getString("PkgMgr.Error.Not.Platformproject"));
- return null;
- }
-
- if (device == null) {
- enableTarget = false;
- } else {
- target = device.getSerialNumber();
- if (target == null) {
- enableTarget = false;
- }
- }
-
- String result = "";
- try {
- result = sbi.queryStdOut("command", targetName, null);
- } catch (SBIException e) {
- e.printStackTrace();
- }
- if (!result.contains("passwd")) {
- MessageDialog.openError(shell, "Error", resources.getString("PkgMgr.Error.Not.SupportedRpm"));
- return null;
- }
- RPMPackageDialog pkgdlg = new RPMPackageDialog(window.getShell(), target, enableRootstrap, enableTarget);
- pkgdlg.open();
-
- return null;
- }
-}
\ No newline at end of file
import java.util.ArrayList;
import org.eclipse.ui.console.MessageConsoleStream;
-
-import org.tizen.sdblib.MultiLineReceiver;
+import org.tizen.sdblib.receiver.MultiLineReceiver;
public class PackageManagerOuputReceiver extends MultiLineReceiver {
public boolean isCancelled = false;
private boolean printConsole = true;
- private ArrayList<String> log = null;
+ private ArrayList<String> log = null;
private MessageConsoleStream mcs = null;
public PackageManagerOuputReceiver() {
super();
+ setTrimLines(false);
+ }
- setTrimLine(false);
+ public void setMessageConsoleStream(MessageConsoleStream mcs) {
+ this.mcs = mcs;
}
-
- public void setMessageConsoleStream(MessageConsoleStream mcs) {
- this.mcs = mcs;
+
+ public MessageConsoleStream getMsgConsoleStream() {
+ return mcs;
}
-
+
public void setPrintConsole(boolean b) {
- printConsole = b;
+ printConsole = b;
}
@Override
public void processNewLines(String[] lines) {
+ for (String line : lines) {
+ processNewLine(line);
+ }
+ }
+
+ public void processNewLine(String line) {
+ // String stripLine =
+ // CharacterStripper.stripNonValidXMLCharacters(line);
if (isCancelled == false) {
- //processLogLines(lines);
- for( String line: lines ) {
- if ( log == null ) {
- log = new ArrayList<String>();
- }
- log.add(line);
- }
- if (printConsole) {
- for (String line : lines) {
- if (line.endsWith("\n")) {
- mcs.print(line);
- } else {
- mcs.println(line);
- }
- }
- }
- }
+ if (log == null) {
+ log = new ArrayList<String>();
+ }
+ log.add(line);
+
+ if (printConsole) {
+ if (line.endsWith("\n")) {
+ mcs.print(line);
+ } else {
+ mcs.println(line);
+ }
+ }
+ }
}
-
+
public String[] getLog() {
- if (log == null) {
- return null;
- }
- return log.toArray(new String[0]);
+ if (log == null) {
+ return null;
+ }
+ return log.toArray(new String[0]);
}
-
+
public void cleanLog() {
- log = null;
+ log = null;
}
public boolean isCancelled() {
return isCancelled;
}
-
}
--- /dev/null
+package org.tizen.nativeplatform.pkgmgr;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.tizen.nativeplatform.pkg.commander.IPkgCommander;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
+import org.tizen.nativeplatform.pkgmgr.model.PackageProvider;
+import org.tizen.nativeplatform.pkgmgr.model.Repository;
+import org.tizen.nativeplatform.pkgmgr.model.RepositoryProvider;
+import org.tizen.nativeplatform.repository.LocalRepoMounter;
+import org.tizen.nativeplatform.repository.RepoManager;
+import org.tizen.nativeplatform.views.model.PlatformRootstrap;
+import org.tizen.sdblib.IDevice;
+
+public class PkgMgrInitializer {
+
+ private PkgCommandTarget target = null;
+ private PlatformRootstrap rootstrap = null;
+ private IDevice device = null;
+ private IPkgCommander rtCommander = null;
+ private IPkgCommander dvCommander = null;
+
+ public PkgMgrInitializer(PkgCommandTarget target) {
+ this.target = target;
+
+ if (target.isSetDevice()) {
+ this.device = target.getDevice();
+ this.dvCommander = target.getDeviceCommander();
+ }
+ if (target.isSetRootstrap()) {
+ this.rootstrap = target.getRootstrap();
+ this.rtCommander = target.getRootstrapCommander();
+ }
+ }
+
+ public void initRootstrapRepoInfo() {
+ if (isSetRootstrap()) {
+ // RepoManager.resetReposToRootstrap(rootstrap);
+ RepositoryProvider.INSTANCE.getBuildsystemRepos().clear();
+ LocalRepoMounter.clearMounted(null);
+ // TODO: error handling for clearMounted
+ rtCommander.resetRepo();
+ RepoManager.addReposToRootstrap(target);
+ }
+ }
+
+ public void initDeviceRepoInfo() {
+ if (isSetDevice()) {
+ RepositoryProvider.INSTANCE.getDeviceRepos().clear();
+ Map<String, String> list = dvCommander.getRepoList();
+ if (list == null || list.isEmpty()) {
+ return;
+ }
+ for (Entry<String, String> e : list.entrySet()) {
+ String name = e.getKey();
+ String url = e.getValue();
+ RepositoryProvider.INSTANCE.getDeviceRepos().add(new Repository(name, url));
+ }
+ }
+ }
+
+ public void initRepoInfo() {
+ initRootstrapRepoInfo();
+ initDeviceRepoInfo();
+ }
+
+ public void initRootstrapPkgInfo() {
+ if (isSetRootstrap()) {
+ PackageProvider.INSTANCE.getBuildsystemPkgs().clear();
+ PackageProvider.INSTANCE.getBuildsystemPkgs().addAll(rtCommander.getAllPkgList());
+ }
+ }
+
+ public void initDevicePkgInfo() {
+ if (isSetDevice()) {
+ PackageProvider.INSTANCE.getDevicePkgs().clear();
+ PackageProvider.INSTANCE.getDevicePkgs().addAll(dvCommander.getAllPkgList());
+ }
+ }
+
+ public void initPkgInfo() {
+ initRootstrapPkgInfo();
+ initDevicePkgInfo();
+ }
+
+ private boolean isSetRootstrap() {
+ return (rootstrap != null) ? true : false;
+ }
+
+ private boolean isSetDevice() {
+ return (device != null) ? true : false;
+ }
+
+ public void initData(IProgressMonitor monitor) throws InterruptedException {
+ int totalworks = 2;
+ if (isSetDevice()) {
+ totalworks = 4;
+ }
+ monitor.beginTask("Initializing Package Manager...", totalworks);
+ monitor.subTask("Intializing repositories on build system...");
+ initRootstrapRepoInfo();
+ monitor.worked(1);
+ monitor.subTask("Intializing packages on build system...");
+ initRootstrapPkgInfo();
+ monitor.worked(2);
+ if (isSetDevice()) {
+ monitor.subTask("Intializing repositories on device...");
+ initDeviceRepoInfo();
+ monitor.worked(3);
+ monitor.subTask("Intializing packages on device...");
+ initDevicePkgInfo();
+ monitor.worked(4);
+ }
+ monitor.done();
+ }
+
+}
+++ /dev/null
-/*
- * Native Platform
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Donghyuk Yang <donghyuk.yang@samsung.com>
- * DongHee Yang <donghee.yang@samsung.com>
- * Kangho Kim <kh5325.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.nativeplatform.pkgmgr;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.ResourceBundle;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import java.util.Enumeration;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.ui.console.MessageConsoleStream;
-import org.tizen.common.ui.view.console.ConsoleManager;
-import org.tizen.common.util.FileUtil;
-import org.tizen.nativeplatform.pkgmgr.PackageManagerOuputReceiver;
-import org.tizen.nativeplatform.pkgmgr.model.Package;
-import org.tizen.nativeplatform.util.CommandLauncher;
-import org.tizen.sdblib.IDevice;
-import org.tizen.sdblib.IShellOutputReceiver;
-import org.tizen.sdblib.SdbCommandRejectedException;
-import org.tizen.sdblib.ShellCommandUnresponsiveException;
-import org.tizen.sdblib.SyncService;
-import org.tizen.sdblib.SyncService.SyncResult;
-import org.tizen.sdblib.TimeoutException;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-public class RPMPackageCommander {
-
- private final static int MAX_TIMEOUT = 10000;
- private static String http_proxy = "";
- private static final String REMOVE_PKGS = "rpm-x86-arm";
-
- private static final String BUNDLE_NAME = RPMPackageCommander.class
- .getPackage().getName() + ".RPMPackageCommands";
- private static ResourceBundle resources = ResourceBundle
- .getBundle(BUNDLE_NAME);
-
- public RPMPackageCommander() {
- }
-
- public static void setHttpProxy(String proxy) {
- if (proxy == null) {
- return;
- } else {
- http_proxy = proxy;
- }
- }
-
- public static void DistUpgradeRootstrap(String path,
- IProgressMonitor monitor) throws InterruptedException {
-
- actionBeforeUseZypper(path);
-
- String command = getChrootedCommand(path, String.format("%s;%s;%s",
- getProxyCmd(), getResetDbCmd(), getDistUpgradeCmd()));
-
- CommandLauncher
- .executeSudo(command, null, "Platform Internal", monitor);
- }
-
- public static void InstallLocalPkgToRootstrap(ArrayList<String> fileList,
- String path, IProgressMonitor monitor) throws InterruptedException {
-
- actionBeforeUseZypper(path);
-
- // copy
- ArrayList<String> fileListOnRootstrap = new ArrayList<String>();
- for (String filePath : fileList) {
- String filename = new File(filePath).getName();
- String pathOnRootstrap = "/tmp/" + filename;
- try {
- FileUtil.copyTo(filePath, path + pathOnRootstrap);
- } catch (IOException e) {
- e.printStackTrace();
- continue;
- }
- fileListOnRootstrap.add(pathOnRootstrap);
- }
-
- // install
- String cmd = String.format("%s;%s", getResetDbCmd(),
- getInstallLocalPkgCmd(fileListOnRootstrap));
- String command = getChrootedCommand(path, cmd);
- CommandLauncher
- .executeSudo(command, null, "Platform Internal", monitor);
- }
-
- public static void InstallLocalPkgToDevice(ArrayList<String> fileList,
- IDevice device) {
- actionBeforeUseZypperDevice(device);
-
- // copy
- ArrayList<String> fileListOnDevice = new ArrayList<String>();
- for (String filePath : fileList) {
- String filename = new File(filePath).getName();
- String pathOnDevice = "/tmp/" + filename;
- SyncService syncService;
- try {
- syncService = device.getSyncService();
- } catch (TimeoutException e) {
- e.printStackTrace();
- continue;
- } catch (SdbCommandRejectedException e) {
- e.printStackTrace();
- continue;
- } catch (IOException e) {
- e.printStackTrace();
- continue;
- }
- SyncResult syncResult = syncService.pushFile(filePath,
- pathOnDevice, SyncService.getNullProgressMonitor());
- if (syncResult.getCode() != SyncService.RESULT_OK) {
- continue;
- }
- fileListOnDevice.add(pathOnDevice);
- }
-
- // set update mode
- PackageManagerOuputReceiver rec = getNewOuputReceiverWithConsole();
- //rec.cleanLog();
-
- if (!device.isEmulator()) {
- RPMPackageCommander.changeUpdateModeForDevice(device, rec);
- }
-
- // install
- String command = String.format("%s;%s", getResetDbCmd(),
- getInstallLocalPkgCmdWithRPM(fileListOnDevice));
- executeDeviceShellCommand(device, command, rec);
- }
-
-
- private static void executeDeviceShellCommand( IDevice device,
- String command, IShellOutputReceiver rec ) {
- try {
- device.executeShellCommand(command, rec, MAX_TIMEOUT );
- } catch (TimeoutException e) {
- e.printStackTrace();
- } catch (SdbCommandRejectedException e) {
- e.printStackTrace();
- } catch (ShellCommandUnresponsiveException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
-
- public static Document InstallPkgWithZypperXmlOut(String path, String pkgs,
- boolean refresh, boolean force) {
- String log = "";
- if (refresh) {
- refreshRepositoryForRootstrap(path);
- }
- String basicOp = "--xmlout --non-interactive";
- String additionOp = "";
- if (force) {
- additionOp = "--force";
- }
- String cmd = String.format("%s;%s", getProxyCmd(),
- getInstallPkgWithZypper(basicOp, additionOp, pkgs));
- String command = getChrootedCommand(path, cmd);
-
- log = executeSudoOutputCommand(command, null, true);
-
- if (log.contains("<?xml")) {
- int index = log.indexOf("<?xml");
- log = log.substring(index);
- }
-
- Document doc = null;
- StringReader sr = new StringReader(log);
- InputSource is = new InputSource(sr);
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- DocumentBuilder db;
- try {
- db = dbf.newDocumentBuilder();
- doc = db.parse(is);
- } catch (ParserConfigurationException e) {
- e.printStackTrace();
- } catch (SAXException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- return doc;
- }
-
-
- private static String executeSudoOutputCommand( String command ) {
- try {
- return CommandLauncher.executeSudoOutput(command, null, false, null);
- } catch (InterruptedException e1) {
- return "";
- }
- }
-
-
- private static String executeSudoOutputCommand( String command, String workingDir,
- boolean includeStdErr ) {
- try {
- return CommandLauncher.executeSudoOutput(command, workingDir, includeStdErr, null);
- } catch (InterruptedException e1) {
- return "";
- }
- }
-
-
- public static void uninstallPkgFromRootstrap(
- CopyOnWriteArrayList<Package> pkgList, String path,
- IProgressMonitor monitor) throws InterruptedException {
-
- String cmd = String.format("%s;%s", getResetDbCmd(),
- getUninstallPkgCmd(pkgList));
- String command = getChrootedCommand(path, cmd);
-
- CommandLauncher
- .executeSudo(command, null, "Platform Internal", monitor);
- }
-
- public static void uninstallPkgFromDevice(
- CopyOnWriteArrayList<Package> pkgList, IDevice device) {
- PackageManagerOuputReceiver rec = getNewOuputReceiverWithConsole();
- String command = String.format("%s;%s;%s", getProxyCmd(),
- getResetDbCmd(), getUninstallPkgCmd(pkgList));
- //rec.cleanLog();
- executeDeviceShellCommand(device, command, rec);
- }
-
- public static void UninstallPkgFromRootstrapNoDeps(String fileList,
- String path) {
-
- String cmd = String.format("%s;%s", getResetDbCmd(),
- getUninstallPkgCmdNoDeps(fileList));
- String command = getChrootedCommand(path, cmd);
-
- try {
- CommandLauncher.executeSudo(command, null, "Platform Internal",
- null);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- public static String getArchForFile(String filePath) {
- try {
- return CommandLauncher.executeOutput(getQueryInfoCmd("ARCH",
- filePath));
- } catch (InterruptedException e) {
- return "";
- }
- }
-
- public static String getPkgNameForFile(String filePath) {
- try {
- return CommandLauncher.executeOutput(getQueryInfoCmd("NAME",
- filePath));
- } catch (InterruptedException e) {
- return "";
- }
- }
-
- public static String getPkgVerForFile(String filePath) {
- String version;
- String release;
- try {
- version = CommandLauncher.executeOutput(getQueryInfoCmd("VERSION",
- filePath));
- release = CommandLauncher.executeOutput(getQueryInfoCmd("RELEASE",
- filePath));
- } catch (InterruptedException e) {
- return "";
- }
-
- return version + "-" + release;
- }
-
- public static String getPkgInstalledVerForRootstrap(String pkgName,
- String path) {
- String retStr = "";
- String version = "";
- String release = "";
-
- if (!pkgInstalledSuccessfullyForRootstrap(pkgName, path)) {
- return retStr;
- }
-
- String result = null;
- String cmd = String.format("%s;%s", getResetDbCmd(),
- getShowPkgInfoCmd(pkgName));
- String command = getChrootedCommand(path, cmd);
-
- result = executeSudoOutputCommand(command);
-
- String[] splitResult = result.split("\n");
- for (String r : splitResult) {
- if (r.trim().startsWith("Version")) {
- version = r.split(":")[1].trim();
- } else if (r.trim().startsWith("Release")) {
- release = r.split(":")[1].trim();
- }
- }
-
- retStr = version + "-" + release;
- return retStr;
- }
-
- public static String getPkgInstalledVerForDevice(String pkgName,
- IDevice device, PackageManagerOuputReceiver rec) {
- String retStr = "";
- String version = "";
- String release = "";
-
- if (device != null) {
- if (!pkgInstalledSuccessfullyForDevice(pkgName, device, rec)) {
- return retStr;
- }
-
- String command = String.format("%s;%s", getResetDbCmd(),
- getShowPkgInfoCmd(pkgName));
- rec.cleanLog();
- executeDeviceShellCommand(device, command, rec);
- for (String l : rec.getLog()) {
- if (l.trim().startsWith("Version")) {
- version = l.split(":")[1].trim();
- } else if (l.trim().startsWith("Release")) {
- release = l.split(":")[1].trim();
- }
- }
- }
-
- retStr = version + "-" + release;
- return retStr;
- }
-
- public static boolean pkgInstalledSuccessfullyForRootstrap(String pkgName,
- String path) {
-
- boolean ret = false;
- String result = "";
-
- String cmd = String.format("%s;%s", getResetDbCmd(),
- getShowPkgCmd(pkgName));
- String command = getChrootedCommand(path, cmd);
-
- result = executeSudoOutputCommand(command);
-
- if (!result.isEmpty() && result.contains(pkgName)) {
- ret = true;
- }
-
- return ret;
- }
-
- public static boolean pkgInstalledSuccessfullyForDevice(String pkgName,
- IDevice device, PackageManagerOuputReceiver rec) {
-
- boolean ret = false;
-
- if (device != null) {
- String command = String.format("%s;%s", getResetDbCmd(),
- getShowPkgCmd(pkgName));
- executeDeviceShellCommand(device, command, rec);
- }
-
- if (rec.getLog() == null) {
- return false;
- }
-
- for (String l : rec.getLog()) {
- if (l.contains(pkgName)) {
- ret = true;
- }
- }
-
- return ret;
- }
-
- public static ArrayList<Package> getPackageListForRootstrap(String path,
- IProgressMonitor monitor) throws InterruptedException {
-
- ArrayList<Package> packageList = new ArrayList<Package>();
- Hashtable<String, Package> packageHash = new Hashtable<String, Package>();
-
- // get list using zypper
- String cmd = String.format("%s;%s;%s", getProxyCmd(), getResetDbCmd(),
- getRemotePkgListCmd());
- String command = getChrootedCommand(path, cmd);
- String result = CommandLauncher.executeSudoOutput(command, null, false,
- monitor);
- String[] splitStr = result.split("\n");
- for (String s : splitStr) {
- s = s.replaceAll(" ", "");
- String[] part = s.split("\\|");
- if (part.length == 5 && !part[0].equals("S")) {
- String name = part[2];
- String version = part[3];
- String arch = part[4];
- if (part[0].equals("i")) {
- packageHash.put(name, new Package(name, version, version,
- arch));
- } else if (part[0].equals("v")) {
- Package p = packageHash.get(name);
- if (p != null) {
- if (version.compareTo(p.getNewVersion()) > 0) {
- p.setNewVersion(version);
- }
- } else {
- packageHash.put(name, new Package(name, version,
- version, arch));
- }
- } else {
- packageHash.put(name, new Package(name, "", version, arch));
- }
- }
- }
-
- // get installed packages using rpm
- cmd = String.format("%s;%s", getResetDbCmd(), getInstalledPkgListCmd());
- command = getChrootedCommand(path, cmd);
- result = CommandLauncher.executeSudoOutput(command);
- int firstIndex = result.indexOf("<pkg>");
- int lastIndex = result.lastIndexOf("</pkg>");
- result = result.substring(firstIndex, lastIndex);
- splitStr = result.split("</pkg>");
- for (String s : splitStr) {
- s = s.replaceAll(" ", "").replaceAll("<pkg>", "");
- String[] part = s.split(",");
- if (part.length == 3) {
- String name = part[0];
- String version = part[1];
- String arch = part[2];
- Package pkg = packageHash.get(name);
- if (pkg == null) {
- packageHash.put(name, new Package(name, version, "", arch));
- } else {
- pkg.setInstalledVersion(version);
- }
- }
- }
-
- Enumeration<Package> e = packageHash.elements();
- while (e.hasMoreElements()) {
- packageList.add(e.nextElement());
- }
-
- return packageList;
- }
-
- public static ArrayList<Package> getPackageListForDevice(IDevice device) {
- actionBeforeUseZypperDevice(device);
-
- ArrayList<Package> packageList = new ArrayList<Package>();
- Hashtable<String, Package> packageHash = new Hashtable<String, Package>();
- PackageManagerOuputReceiver rec = getNewOuputReceiver();
- rec.setPrintConsole(false);
-
- // get list using zypper
- String command = String.format("%s;%s;%s", getProxyCmd(),
- getResetDbCmd(), getRemotePkgListCmd());
- rec.cleanLog();
- executeDeviceShellCommand(device, command, rec);
-
- for (String s : rec.getLog()) {
- s = s.replaceAll(" ", "");
- String[] part = s.split("\\|");
- if (part.length == 5 && !part[0].equals("S")) {
- String name = part[2];
- String version = part[3];
- String arch = part[4];
- if (part[0].equals("i")) {
- packageHash.put(name, new Package(name, version,
- version, arch));
- } else if (part[0].equals("v")) {
- Package p = packageHash.get(name);
- if (p != null
- && version.compareTo(p.getNewVersion()) > 0) {
- p.setNewVersion(version);
- } else {
- packageHash.put(name, new Package(name, "",
- version, arch));
- }
- } else {
- packageHash.put(name, new Package(name, "", version,
- arch));
- }
- }
- }
-
- // get installed packages using rpm
- command = String.format("%s;%s", getResetDbCmd(),
- getInstalledPkgListCmdDevice());
- rec.cleanLog();
- executeDeviceShellCommand(device, command, rec);
- String result = rec.getLog()[0];
- int firstIndex = result.indexOf("<pkg>");
- int lastIndex = result.lastIndexOf("</pkg>");
- if (firstIndex >= 0 || lastIndex >= 0 ) {
- result = result.substring(firstIndex, lastIndex);
- String[] splitStr = result.split("</pkg>");
- for (String s : splitStr) {
- s = s.replaceAll(" ", "").replaceAll("<pkg>", "");
- String[] part = s.split(",");
- if (part.length == 3) {
- String name = part[0];
- String version = part[1];
- String arch = part[2];
- Package pkg = packageHash.get(name);
- if (pkg == null) {
- packageHash.put(name, new Package(name, version, "", arch));
- } else {
- pkg.setInstalledVersion(version);
- }
- }
- }
- }
-
-
- Enumeration<Package> e = packageHash.elements();
- while (e.hasMoreElements()) {
- packageList.add(e.nextElement());
- }
-
- return packageList;
- }
-
- public static void resetRepositoryForRootstrap(String path) {
- String cmd = String.format("%s", getRepoResetCmd());
- String command = getChrootedCommand(path, cmd);
-
- executeSudoOutputCommand(command);
- }
-
- public static Hashtable<String, String> getRepositoryListForDevice(
- IDevice device) {
- PackageManagerOuputReceiver rec = getNewOuputReceiverWithConsole();
- Hashtable<String, String> reposHash = new Hashtable<String, String>();
-
- String command = String.format("%s;%s", getResetDbCmd(),
- getRepoListCmd());
- //rec.cleanLog();
- executeDeviceShellCommand(device, command, rec);
-
- for (String reposStr : rec.getLog()) {
- reposStr = reposStr.replaceAll(" ", "");
- String[] part = reposStr.split("\\|");
- if (part.length == 6 && !part[0].equals("#")) {
- reposHash.put(part[1], part[5]);
- }
- }
-
- return reposHash;
- }
-
- public static String refreshRepositoryForRootstrap(String path) {
-
- String result = "";
- String cmd = String.format("%s;%s;%s", getProxyCmd(), getResetDbCmd(),
- getRefreshCmd());
- String command = getChrootedCommand(path, cmd);
-
- try {
- CommandLauncher.executeSudo(command, null, "Platform Internal", null);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- return result;
- }
-
- public static void refreshRepositoryForDevice(IDevice device) {
- PackageManagerOuputReceiver rec = getNewOuputReceiverWithConsole();
- String command = String.format("%s;%s;%s", getProxyCmd(),
- getResetDbCmd(), getRefreshCmd());
- //rec.cleanLog();
- executeDeviceShellCommand(device, command, rec);
- }
-
- public static String addRepositoryForRootstrap(String name, String uri, String path) {
-
- String result = "";
- String cmd = String.format("%s;%s", getResetDbCmd(),
- getAddRepoCmd(uri, name));
- String command = getChrootedCommand(path, cmd);
-
- result = executeSudoOutputCommand(command);
-
- return result;
- }
-
- public static String addLocalRepositoryForRootstrap(String name, String uri, String path) {
-
- String result = "";
- String cmd = String.format("%s;%s", getResetDbCmd(),
- getAddLocalRepoCmd(uri, name));
- String command = getChrootedCommand(path, cmd);
-
- result = executeSudoOutputCommand(command);
-
- return result;
- }
-
- public static void addRepositoryForDevice(String name, String uri,
- IDevice device) {
- PackageManagerOuputReceiver rec = getNewOuputReceiverWithConsole();
- String command = String.format("%s;%s", getResetDbCmd(),
- getAddRepoCmd(uri, name));
- //rec.cleanLog();
- executeDeviceShellCommand(device, command, rec);
- }
-
- public static String removeRepositoryForRootstrap(String name, String path) {
-
- String cmd = String.format("%s;%s", getResetDbCmd(),
- getRemoveRepoCmd(name));
- String command = getChrootedCommand(path, cmd);
-
- return executeSudoOutputCommand(command);
- }
-
- public static void removeRepositoryForDevice(String name, IDevice device) {
-
- PackageManagerOuputReceiver rec = getNewOuputReceiverWithConsole();
- String command = String.format("%s;%s", getResetDbCmd(),
- getRemoveRepoCmd(name));
- //rec.cleanLog();
- executeDeviceShellCommand(device, command, rec);
- }
-
- public static void installRemotePkgForRootstrap(
- CopyOnWriteArrayList<Package> selectedList, String path,
- IProgressMonitor monitor) throws InterruptedException {
-
- actionBeforeUseZypper(path);
-
- String cmd = String.format("%s;%s;%s", getProxyCmd(), getResetDbCmd(),
- getInstallPkgCmd(selectedList));
- String command = getChrootedCommand(path, cmd);
-
- CommandLauncher
- .executeSudo(command, null, "Platform Internal", monitor);
- }
-
- public static void installRemotePkgForDevice(
- CopyOnWriteArrayList<Package> selectedList, IDevice device) {
-
- PackageManagerOuputReceiver rec = getNewOuputReceiverWithConsole();
- String command = String.format("%s;%s;%s", getProxyCmd(),
- getResetDbCmd(), getInstallPkgCmd(selectedList));
- //rec.cleanLog();
- executeDeviceShellCommand(device, command, rec);
- }
-
- private static void changeUpdateModeForDevice(IDevice device,
- PackageManagerOuputReceiver rec) {
-
- String command = resources.getString("Command.Change.Updatemode");
- rec.cleanLog();
- executeDeviceShellCommand(device, command, rec);
- }
-
- private static void actionBeforeUseZypper(String path) {
- if (pkgInstalledSuccessfullyForRootstrap(REMOVE_PKGS, path)) {
- UninstallPkgFromRootstrapNoDeps(REMOVE_PKGS, path);
- }
- }
-
- private static void actionBeforeUseZypperDevice(IDevice device) {
- if (device.isEmulator()) {
- PackageManagerOuputReceiver rec = getNewOuputReceiverWithConsole();
- //rec.cleanLog();
- String command = String
- .format("sed -i \"s/# arch = s390/arch = i686/g\" /etc/zypp/zypp.conf");
- executeDeviceShellCommand(device, command, rec);
- }
- }
-
- private static String getProxyCmd() {
- return String.format(resources.getString("Command.Export.Proxy"),
- http_proxy);
- }
-
- private static String getResetDbCmd() {
- return String.format(resources.getString("Command.Reset.Db"));
- }
-
- private static String getDistUpgradeCmd() {
- return String.format(resources.getString("Command.DistUpgrade"));
- }
-
- private static String getInstallPkgCmd(CopyOnWriteArrayList<Package> pkgList) {
- String pkgListStr = "";
- for (Package pkg : pkgList) {
- pkgListStr = pkgListStr.isEmpty() ? pkg.getName() : pkgListStr
- + " " + pkg.getName();
- }
- return String.format(resources.getString("Command.Install.Remote.Pkg"),
- pkgListStr);
- }
-
- private static String getInstallLocalPkgCmd(ArrayList<String> fileList) {
- String pkgListStr = "";
- for (String filePath : fileList) {
- pkgListStr = pkgListStr.isEmpty() ? filePath : pkgListStr + " "
- + filePath;
- }
- return String.format(resources.getString("Command.Install.Local.Pkg"),
- pkgListStr);
- }
-
- private static String getInstallLocalPkgCmdWithRPM(
- ArrayList<String> fileList) {
- String pkgListStr = "";
- for (String filePath : fileList) {
- pkgListStr = pkgListStr.isEmpty() ? filePath : pkgListStr + " "
- + filePath;
- }
- return String.format(
- resources.getString("Command.Install.Local.Pkg.RPM"),
- pkgListStr);
- }
-
- private static String getUninstallPkgCmd(
- CopyOnWriteArrayList<Package> pkgList) {
- String pkgListStr = "";
- for (Package pkg : pkgList) {
- pkgListStr = pkgListStr.isEmpty() ? pkg.getName() : pkgListStr
- + " " + pkg.getName();
- }
- return String.format(resources.getString("Command.Uninstall.Pkg"),
- pkgListStr);
- }
-
- private static String getUninstallPkgCmdNoDeps(String pkgList) {
- return String.format(
- resources.getString("Command.Uninstall.Pkg.NoDeps"), pkgList);
- }
-
- private static String getRemoveRepoCmd(String name) {
- return String.format(resources.getString("Command.Remove.Repo"), name);
- }
-
- private static String getAddRepoCmd(String uri, String name) {
- return String
- .format(resources.getString("Command.Add.Repo"), uri, name);
- }
-
- private static String getAddLocalRepoCmd(String uri, String name) {
- return String
- .format(resources.getString("Command.Add.Local.Repo"), uri, name);
- }
-
- private static String getRefreshCmd() {
- return resources.getString("Command.Refresh.Repo");
- }
-
- private static String getRepoListCmd() {
- return resources.getString("Command.List.Repo");
- }
-
- private static String getRepoResetCmd() {
- return resources.getString("Command.Reset.Repo");
- }
-
- private static String getRemotePkgListCmd() {
- return resources.getString("Command.List.Remote.Pkg");
- }
-
- private static String getInstalledPkgListCmd() {
- return resources.getString("Command.List.Installed.Pkg");
- }
-
- private static String getInstalledPkgListCmdDevice() {
- return resources.getString("Command.List.Installed.Pkg.Device");
- }
-
- private static String getShowPkgCmd(String name) {
- return String.format(resources.getString("Command.Show.Pkg"), name);
- }
-
- private static String getShowPkgInfoCmd(String name) {
- return String
- .format(resources.getString("Command.Show.Info.Pkg"), name);
- }
-
- private static String getQueryInfoCmd(String tag, String name) {
- return String.format(resources.getString("Command.Info.Pkg.File"), tag,
- name);
- }
-
- private static String getInstallPkgWithZypper(String basicOp,
- String additionOp, String pkgs) {
- return String.format(
- resources.getString("Command.Install.Pkg.WithZypper"), basicOp,
- additionOp, pkgs);
- }
-
- private static String getChrootedCommand(String path, String cmd) {
- return String.format("sudo -S chroot %s sh -c \\\"%s\\\"", path, cmd);
- }
-
- public static int compareVersion(String ver1, String ver2) {
- ArrayList<String> tokList1 = tokenizeVersionString(ver1);
- ArrayList<String> tokList2 = tokenizeVersionString(ver2);
- int maxTokens = tokList1.size() > tokList2.size() ? tokList1.size()
- : tokList2.size();
-
- for (int i = 0; i < maxTokens; i++) {
- // check length
- if (i == tokList1.size()) {
- return -1;
- }
- if (i == tokList2.size()) {
- return 1;
- }
-
- String tok1 = tokList1.get(i);
- String tok2 = tokList2.get(i);
-
- int value1 = -1, value2 = -1;
- try {
- value1 = Integer.parseInt(tok1);
- } catch (NumberFormatException e) {
- // do nothing
- e.printStackTrace();
- }
-
- try {
- value2 = Integer.parseInt(tok2);
- } catch (NumberFormatException e) {
- // do nothing
- e.printStackTrace();
- }
-
- if (value1 > value2) {
- return 1;
- } else if (value1 < value2) {
- return -1;
- } else {
- int result = tok1.compareTo(tok2);
- if (result != 0) {
- return result;
- }
- }
- }
-
- return 0;
- }
-
- private static ArrayList<String> tokenizeVersionString(String ver) {
- ArrayList<String> result = new ArrayList<String>();
- final int NUM = 0;
- final int ALPHA = 1;
- final int NONALPHANUM = 2;
- int oldStatus = NONALPHANUM;
- String buf = "";
- for (int i = 0; i < ver.length(); i++) {
- char c = ver.charAt(i);
- int newStatus;
- if (c >= '0' && c <= '9') {
- newStatus = NUM;
- } else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
- newStatus = ALPHA;
- } else {
- newStatus = NONALPHANUM;
- }
-
- if (oldStatus != newStatus) {
- if (!buf.isEmpty()) {
- result.add(buf);
- }
- if (newStatus != NONALPHANUM) {
- buf = String.valueOf(c);
- } else {
- buf = "";
- }
- oldStatus = newStatus;
- } else {
- if (newStatus != NONALPHANUM) {
- buf += String.valueOf(c);
- }
- }
- }
- if (!buf.isEmpty()) {
- result.add(buf);
- }
-
- return result;
- }
-
- static private PackageManagerOuputReceiver getNewOuputReceiver() {
- PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver();
- return rec;
- }
-
- static private PackageManagerOuputReceiver getNewOuputReceiverWithConsole() {
- return getNewOuputReceiver("Platform Internal");
- }
-
- static private PackageManagerOuputReceiver getNewOuputReceiver(String consoleName) {
- ConsoleManager cm = new ConsoleManager(consoleName, true);
- //cm.clear();
- MessageConsoleStream mcs = cm.getMessageConsoleStream();
- PackageManagerOuputReceiver rec = new PackageManagerOuputReceiver();
- rec.setMessageConsoleStream(mcs);
-
- return rec;
- }
-
-
-}
+++ /dev/null
-Command.Export.Proxy = export http_proxy=%s
-Command.Reset.Db = rm -f /var/lib/rpm/__db*
-Command.Install.Remote.Pkg = zypper --non-interactive in %s
-Command.Install.Local.Pkg = zypper --non-interactive in --force %s
-Command.Install.Local.Pkg.RPM = rpm -ihv %s --ignoreos --force --nodeps --ignorearch
-Command.Uninstall.Pkg.NoDeps = rpm -e %s --nodeps
-Command.Uninstall.Pkg = zypper --non-interactive remove %s
-Command.Remove.Repo = zypper --non-interactive rr %s
-Command.Add.Repo = zypper --non-interactive ar %s %s
-Command.Add.Local.Repo = zypper --non-interactive ar -t plaindir %s %s
-Command.Refresh.Repo = zypper --non-interactive refresh
-Command.List.Repo = zypper lr -u
-Command.Reset.Repo = rm -rf /etc/zypp/repos.d/*
-Command.List.Remote.Pkg = zypper --non-interactive pa
-Command.List.Installed.Pkg = rpm -qa --qf \\\\<pkg\\\\>%{NAME},%{VERSION}-%{RELEASE},%{ARCH}\\\\<\\\\/pkg\\\\>
-Command.List.Installed.Pkg.Device = rpm -qa --qf \\<pkg\\>%{NAME},%{VERSION}-%{RELEASE},%{ARCH}\\<\\/pkg\\>
-Command.Show.Pkg = rpm -qa %s
-Command.Show.Info.Pkg = rpm -qi %s
-Command.Info.Pkg.File = rpm -qp --qf "%%{%s}\n" %s
-Command.Change.Updatemode = /bin/change-booting-mode.sh --update
-Command.DistUpgrade = zypper --non-interactive dup
-Command.Install.Pkg.WithZypper = zypper %s in %s %s
-
-PkgMgr.Error.Noselected.Project = No project selected. Select a Tizen platform project.
-PkgMgr.Error.Not.Platformproject = The selected project is not a Tizen platform project.
-PkgMgr.Error.Not.SupportedRpm = RPM package not supported by the build system.
-PkgMgr.Error.Not.RpmProject = The project is not RPM project.
package org.tizen.nativeplatform.pkgmgr.model;
public class Package {
- public static enum INSTALLINFO
- {
- INSTALLED, NOT_INSTALLED, DIFFERENT_VERSION
- }
-
- public static enum PKGTYPE
- {
- LOCAL, REMOTE
- }
-
- private String name = "";
- private String arch = "";
- private String newVersion = "";
- private String installVersion = "";
- private boolean checkColumn = false;
- private INSTALLINFO installInfo = INSTALLINFO.NOT_INSTALLED;
- private PKGTYPE pkgType = PKGTYPE.LOCAL;
- private boolean isChecked = false;
- private boolean isNewlyChanged = false;
-
- public Package() {
-
- }
-
- public Package(String name, String installedVersion, String remoteVersion, String arch) {
- this.name = name;
- this.installVersion = installedVersion;
- this.newVersion = remoteVersion;
- this.arch = arch;
- }
-
- public PKGTYPE getPkgType()
- {
- return pkgType;
- }
-
- public void setPkgType( PKGTYPE pkgType )
- {
- this.pkgType = pkgType;
- }
-
- public void setArch(String arch)
- {
- this.arch = arch;
- }
-
- public String getArch()
- {
- return arch;
- }
-
- public INSTALLINFO getInstallInfo()
- {
- return installInfo;
- }
-
- public void setInstallInfo( INSTALLINFO installInfo )
- {
- this.installInfo = installInfo;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setInstalledVersion(String ver) {
- this.installVersion = ver;
- }
-
- public String getInstalledVersion() {
- return installVersion;
- }
-
- public void setNewVersion(String ver) {
- this.newVersion = ver;
- }
-
- public String getNewVersion() {
- return newVersion;
- }
-
- public boolean getCheckColumn()
- {
- return checkColumn;
- }
-
- public void setCheckColumn( boolean check )
- {
- this.checkColumn = check;
- }
-
- public void setChecked( boolean value ) {
- this.isChecked = value;
- }
-
- public boolean isChecked() {
- return this.isChecked;
- }
-
- public void setNewlyChanged( boolean value ) {
- this.isNewlyChanged = value;
- }
-
- public boolean isNewlyChanged() {
- return this.isNewlyChanged;
- }
+ public static enum INSTALLINFO {
+ INSTALLED, NOT_INSTALLED, DIFFERENT_VERSION
+ }
+
+ public static enum PKGTYPE {
+ LOCAL, REMOTE
+ }
+
+ private String name = "";
+ private String arch = "";
+ private String newVersion = "";
+ private String installVersion = "";
+ private boolean checkColumn = false;
+ private INSTALLINFO installInfo = INSTALLINFO.NOT_INSTALLED;
+ private PKGTYPE pkgType = PKGTYPE.LOCAL;
+ private boolean isChecked = false;
+ private boolean isNewlyChanged = false;
+
+ public Package() {
+
+ }
+
+ public Package(String name, String installedVersion, String remoteVersion, String arch) {
+ this.name = name;
+ this.installVersion = installedVersion;
+ this.newVersion = remoteVersion;
+ this.arch = arch;
+ }
+
+ public Package(String name, String installedVersion, INSTALLINFO installInfo,
+ String remoteVersion, String arch) {
+ this.name = name;
+ this.installVersion = installedVersion;
+ this.installInfo = installInfo;
+ this.newVersion = remoteVersion;
+ this.arch = arch;
+ }
+
+ public PKGTYPE getPkgType() {
+ return pkgType;
+ }
+
+ public void setPkgType(PKGTYPE pkgType) {
+ this.pkgType = pkgType;
+ }
+
+ public void setArch(String arch) {
+ this.arch = arch;
+ }
+
+ public String getArch() {
+ return arch;
+ }
+
+ public INSTALLINFO getInstallInfo() {
+ return installInfo;
+ }
+
+ public void setInstallInfo(INSTALLINFO installInfo) {
+ this.installInfo = installInfo;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setInstalledVersion(String ver) {
+ this.installVersion = ver;
+ }
+
+ public String getInstalledVersion() {
+ return installVersion;
+ }
+
+ public void setNewVersion(String ver) {
+ this.newVersion = ver;
+ }
+
+ public String getNewVersion() {
+ return newVersion;
+ }
+
+ public boolean getCheckColumn() {
+ return checkColumn;
+ }
+
+ public void setCheckColumn(boolean check) {
+ this.checkColumn = check;
+ }
+
+ public void setChecked(boolean value) {
+ this.isChecked = value;
+ }
+
+ public boolean isChecked() {
+ return this.isChecked;
+ }
+
+ public boolean isInstalled() {
+ return (installInfo == INSTALLINFO.INSTALLED);
+ }
+
+ public void setNewlyChanged(boolean value) {
+ this.isNewlyChanged = value;
+ }
+
+ public boolean isNewlyChanged() {
+ return this.isNewlyChanged;
+ }
}
+++ /dev/null
-/*
- * Native Platform
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Donghyuk Yang <donghyuk.yang@samsung.com>
- * DongHee Yang <donghee.yang@samsung.com>
- * Kangho Kim <kh5325.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.nativeplatform.pkgmgr.ui;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TabFolder;
-import org.tizen.common.util.DialogUtil;
-import org.tizen.nativecommon.build.SmartBuildInterface;
-import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander;
-import org.tizen.nativeplatform.pkgmgr.model.Package;
-import org.tizen.nativeplatform.pkgmgr.model.PackageProvider;
-import org.tizen.nativeplatform.pkgmgr.model.Repository;
-import org.tizen.nativeplatform.pkgmgr.model.RepositoryProvider;
-import org.tizen.nativeplatform.repository.RepoManager;
-import org.tizen.nativeplatform.repository.LocalRepoMounter;
-import org.tizen.nativeplatform.rootstrap.RootstrapManager;
-import org.tizen.nativeplatform.views.model.PlatformRootstrap;
-
-
-public class BuildSystemTab extends CommonTab {
-
- private PlatformRootstrap rootstrap;
- private String rootstrapPath = "";
-
-
- public BuildSystemTab(Shell shell, TabFolder folder, PlatformRootstrap rootstrap) {
- super(shell, folder);
- this.rootstrap = rootstrap;
- this.rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(rootstrap.getPath().toOSString());
- }
-
-
- protected CopyOnWriteArrayList<Repository> getRepositoryList() {
- return RepositoryProvider.INSTANCE.getBuildsystemRepos();
- }
-
-
- public void updateRepositoryInfo() {
- initializeRepositoryInfo(rootstrap);
- }
-
-
- public static void initializeRepositoryInfo(PlatformRootstrap rootstrap) {
- RepoManager.resetReposToRootstrap(rootstrap);
- }
-
-
- public static void initializePackageInfo(PlatformRootstrap rootstrap,
- IProgressMonitor monitor ) throws InterruptedException {
-
- String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(rootstrap.getPath().toOSString());
- PackageProvider.INSTANCE.getBuildsystemPkgs().clear();
- PackageProvider.INSTANCE.getBuildsystemPkgs()
- .addAll(RPMPackageCommander.getPackageListForRootstrap(rootstrapPath, monitor));
- }
-
-
- public void createTab() {
- createCommonTab(folder,
- resources.getString("PkgMgr.Tab.Buildsystem") +" [" + rootstrap.getName() +"]");
- }
-
-
- protected boolean handleAddRepositoryButton(){
- AddRepoDialog dialog = new AddRepoDialog(shell,
- resources.getString("PkgMgr.Tab.Buildsystem"),
- true);
- if ( dialog.open() != AddRepoDialog.OK ) {
- return false;
- }
- //String name = String.format("url%d", repoViewer.getTable().getItemCount());
- String url = dialog.getRepositoryURL();
-
- rootstrap.addRepoURL(url);
-
- return true;
- }
-
-
- protected boolean handleModifyRepositoryButton() {
- int selectedIdx = repoViewer.getTable().getSelectionIndex();
- if ( selectedIdx == -1 ) {
- DialogUtil.openMessageDialog(resources.getString("PkgMgr.Message.Select.OnePackage"));
- return false;
- }
-
- Repository repos = (Repository)repoViewer.getTable().getItem(selectedIdx).getData();
- ModifyRepoDialog dialog = new ModifyRepoDialog(
- shell, resources.getString("PkgMgr.Tab.Buildsystem"),
- repos.getName(),
- repos.getUri(),
- true);
-
- if ( dialog.open() != ModifyRepoDialog.OK ) {
- return false;
- }
-
- if (dialog.isDirty()) {
- rootstrap.changeRepoURL(repos.getUri(), dialog.getRepositoryURL());
- }
-
- return true;
- }
-
-
- protected boolean handleRemoveRepositoryButton() {
- int selectedIdx = repoViewer.getTable().getSelectionIndex();
- if ( selectedIdx == -1 ) {
- DialogUtil.openMessageDialog(resources.getString("PkgMgr.Message.Select.OnePackage"));
- return false;
- }
- Repository repos = (Repository)repoViewer.getTable().getItem(selectedIdx).getData();
-
- rootstrap.removeRepoURL(repos.getUri());
-
- return true;
- }
-
-
- protected void handleRefreshRepositoryButton() {
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
-
- try {
- dialog.run(true, false, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
- monitor.beginTask(resources.getString("PkgMgr.Message.Refreshing"), -1);
- RPMPackageCommander.refreshRepositoryForRootstrap(rootstrapPath);
- monitor.done();
- }
- });
- } catch (InvocationTargetException e) {
- DialogUtil.openErrorDialog(
- resources.getString("PkgMgr.Msg.Error.RefreshFailed")+
- "("+e.toString()+")");
- } catch (InterruptedException e) {
- DialogUtil.openErrorDialog(
- resources.getString("PkgMgr.Msg.Error.RefreshFailed")+
- "("+e.toString()+")");
- }
- }
-
-
- protected void handleUpgradeRootstrapButton() {
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
-
- try {
- dialog.run(true, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
-
- monitor.beginTask(resources.getString("PkgMgr.Message.Upgrade"), -1);
- RPMPackageCommander.DistUpgradeRootstrap(rootstrapPath, monitor);
- monitor.done();
- }
- });
- } catch (InvocationTargetException e) {
- DialogUtil.openErrorDialog(
- resources.getString("PkgMgr.Msg.Error.UpgradeFailed")+
- "("+e.toString()+")");
- } catch (InterruptedException e) {
- DialogUtil.openErrorDialog(
- resources.getString("PkgMgr.Msg.Error.UpgradeFailed")+
- "("+e.toString()+")");
- }
- }
-
-
- protected void handleInstallPackageButton() {
- final CopyOnWriteArrayList<Package> selectedList =
- PackageProvider.INSTANCE.getSelectedBuildsystemPkgs(false);
-
- if(selectedList.isEmpty()) {
- DialogUtil.openErrorDialog( resources.getString("PkgMgr.Error.Noselected.Package"));
- return;
- }
-
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
- try {
- dialog.run(true, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
-
- monitor.beginTask(resources.getString("PkgMgr.Message.Installing.Package"), -1);
- RPMPackageCommander.installRemotePkgForRootstrap(selectedList, rootstrapPath, monitor);
- monitor.done();
- }
- });
- } catch (InvocationTargetException e) {
- DialogUtil.openErrorDialog(
- resources.getString("PkgMgr.Msg.Error.InstallFailed")+
- "("+e.toString()+")");
- } catch (InterruptedException e) {
- DialogUtil.openErrorDialog(
- resources.getString("PkgMgr.Msg.Error.InstallFailed")+
- "("+e.toString()+")");
- }
- }
-
-
- protected void handleInstallLocalPackageButton( final ArrayList<String> selectedFiles ) {
-
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
- try {
- dialog.run(true, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
-
- monitor.beginTask(resources.getString("PkgMgr.Message.Installing.LocalPackage"), -1);
- RPMPackageCommander.InstallLocalPkgToRootstrap(selectedFiles, rootstrapPath, monitor);
- monitor.done();
- }
- });
- } catch (InvocationTargetException e) {
- DialogUtil.openErrorDialog(
- resources.getString("PkgMgr.Msg.Error.InstallFailed")+
- "("+e.toString()+")");
- } catch (InterruptedException e) {
- DialogUtil.openErrorDialog(
- resources.getString("PkgMgr.Msg.Error.InstallFailed")+
- "("+e.toString()+")");
- }
- }
-
-
- protected void handleRemovePackageButton() {
- final CopyOnWriteArrayList<Package> selectedList =
- PackageProvider.INSTANCE.getSelectedBuildsystemPkgs(true);
- if(selectedList.isEmpty()) {
- DialogUtil.openErrorDialog( resources.getString("PkgMgr.Error.Noselected.Package"));
- return;
- }
-
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
- try {
- dialog.run(true, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
-
- monitor.beginTask(resources.getString("PkgMgr.Message.Uninstalling.Package"), -1);
- RPMPackageCommander.uninstallPkgFromRootstrap(selectedList, rootstrapPath, monitor);
- monitor.done();
- }
- });
- } catch (InvocationTargetException e) {
- DialogUtil.openErrorDialog(
- resources.getString("PkgMgr.Msg.Error.UninstallFailed")+
- "("+e.toString()+")");
- } catch (InterruptedException e) {
- DialogUtil.openErrorDialog(
- resources.getString("PkgMgr.Msg.Error.UninstallFailed")+
- "("+e.toString()+")");
- }
- }
-
-
- protected CopyOnWriteArrayList<Package> getPackageList() {
- return PackageProvider.INSTANCE.getBuildsystemPkgs();
- }
-
-
- protected void updatePackageInfo(ArrayList<String> localPackageFileList ) {
- ArrayList<Package> fullList;
- try {
- fullList = RPMPackageCommander.getPackageListForRootstrap(rootstrapPath, null);
- } catch (InterruptedException e) {
- fullList = new ArrayList<Package>();
- }
- ArrayList<Package> removeList = new ArrayList<Package>();
- for( Package pkg: PackageProvider.INSTANCE.getBuildsystemPkgs()) {
- boolean found = false;
- for( Package currPkg: fullList ) {
- if ( currPkg.getName().equals(pkg.getName())) {
- // check newly install
- if( !pkg.getInstalledVersion().equals(currPkg.getInstalledVersion())) {
- pkg.setNewlyChanged(true);
- }
-
- pkg.setInstalledVersion(currPkg.getInstalledVersion());
- found = true;
- break;
- }
- }
- if ( !found ) {
- removeList.add(pkg);
- }
- pkg.setChecked(false);
- }
-
- // remove
- for( Package pkg: removeList ) {
- PackageProvider.INSTANCE.getBuildsystemPkgs().remove(pkg);
- }
-
- // add if there is new package
- for( Package currPkg: fullList ) {
- boolean found = false;
- for( Package pkg: PackageProvider.INSTANCE.getBuildsystemPkgs()) {
- if ( currPkg.getName().equals(pkg.getName())) {
- found = true;
- break;
- }
- }
-
- if ( !found ) {
- PackageProvider.INSTANCE.getBuildsystemPkgs().add(currPkg);
- currPkg.setNewlyChanged(true);
- }
- }
-
- // check local package update
- if ( localPackageFileList != null ) {
- ArrayList<String> localPackageNameList = new ArrayList<String>();
- for( String filePath: localPackageFileList) {
- localPackageNameList.add(RPMPackageCommander.getPkgNameForFile(filePath));
- }
- for( Package pkg: PackageProvider.INSTANCE.getBuildsystemPkgs()) {
- if( localPackageNameList.contains( pkg.getName() ) ) {
- pkg.setNewlyChanged(true);
- }
- }
- }
- }
-}
--- /dev/null
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.pkgmgr.ui;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.tizen.common.util.DialogUtil;
+import org.tizen.nativeplatform.pkg.commander.ICommandStatus;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
+import org.tizen.nativeplatform.pkgmgr.PkgMgrInitializer;
+import org.tizen.nativeplatform.pkgmgr.model.Package;
+import org.tizen.nativeplatform.pkgmgr.model.PackageProvider;
+import org.tizen.nativeplatform.pkgmgr.model.Repository;
+import org.tizen.nativeplatform.pkgmgr.model.RepositoryProvider;
+
+public class BuildsystemTab extends CommonTab {
+
+ private PkgCommandTarget target = null;
+
+ public BuildsystemTab(Shell shell, TabFolder folder, PkgCommandTarget target) {
+ super(shell, folder, target.getRootstrapCommander());
+ this.target = target;
+ }
+
+ protected CopyOnWriteArrayList<Repository> getRepositoryList() {
+ return RepositoryProvider.INSTANCE.getBuildsystemRepos();
+ }
+
+ public void updateRepositoryInfo() {
+ PkgMgrInitializer initializer = new PkgMgrInitializer(target);
+ initializer.initRootstrapRepoInfo();
+ }
+
+ public void createTab() {
+ createCommonTab(resources.getString("PkgMgr.Tab.Buildsystem") + " ["
+ + target.getRootstrap().getName() + "]");
+ }
+
+ protected boolean handleAddRepositoryButton() {
+ AddRepoDialog dialog = new AddRepoDialog(shell,
+ resources.getString("PkgMgr.Tab.Buildsystem"), true);
+ if (dialog.open() != AddRepoDialog.OK) {
+ return false;
+ }
+ String url = dialog.getRepositoryURL();
+ target.getRootstrap().addRepoURL(url);
+ return true;
+ }
+
+ protected boolean handleModifyRepositoryButton() {
+ int selectedIdx = repoViewer.getTable().getSelectionIndex();
+ if (selectedIdx == -1) {
+ DialogUtil.openMessageDialog(resources.getString("PkgMgr.Message.Select.OnePackage"));
+ return false;
+ }
+
+ Repository repos = (Repository) repoViewer.getTable().getItem(selectedIdx).getData();
+ ModifyRepoDialog dialog = new ModifyRepoDialog(shell,
+ resources.getString("PkgMgr.Tab.Buildsystem"), repos.getName(), repos.getUri(),
+ true);
+
+ if (dialog.open() != ModifyRepoDialog.OK) {
+ return false;
+ }
+
+ if (dialog.isDirty()) {
+ target.getRootstrap().changeRepoURL(repos.getUri(), dialog.getRepositoryURL());
+ }
+ return true;
+ }
+
+ protected boolean handleRemoveRepositoryButton() {
+ int selectedIdx = repoViewer.getTable().getSelectionIndex();
+ if (selectedIdx == -1) {
+ DialogUtil.openMessageDialog(resources.getString("PkgMgr.Message.Select.OnePackage"));
+ return false;
+ }
+ Repository repos = (Repository) repoViewer.getTable().getItem(selectedIdx).getData();
+ target.getRootstrap().removeRepoURL(repos.getUri());
+ return true;
+ }
+
+ protected void handleUpgradeButton() {
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
+
+ try {
+ dialog.run(true, true, new IRunnableWithProgress() {
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+ monitor.beginTask(resources.getString("PkgMgr.Message.Upgrade"), -1);
+ ICommandStatus status = commander.upgrade(monitor);
+ if (!status.isOk()) {
+ new InterruptedException();
+ }
+ monitor.done();
+ }
+ });
+ } catch (InvocationTargetException e) {
+ DialogUtil.openErrorDialog(resources.getString("PkgMgr.Msg.Error.UpgradeFailed") + "("
+ + e.toString() + ")");
+ } catch (InterruptedException e) {
+ DialogUtil.openErrorDialog(resources.getString("PkgMgr.Msg.Error.UpgradeFailed") + "("
+ + e.toString() + ")");
+ }
+ }
+
+ protected List<Package> getSelectedPkgList(boolean remove) {
+ List<Package> selectedList = PackageProvider.INSTANCE.getSelectedBuildsystemPkgs(remove);
+ return selectedList;
+ }
+
+ protected List<Package> getPackageList() {
+ return PackageProvider.INSTANCE.getBuildsystemPkgs();
+ }
+}
package org.tizen.nativeplatform.pkgmgr.ui;
import java.io.File;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.List;
import java.util.ResourceBundle;
import java.util.concurrent.CopyOnWriteArrayList;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
-import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander;
+import org.eclipse.ui.console.MessageConsole;
+import org.eclipse.ui.internal.console.IOConsoleViewer;
+import org.tizen.common.util.DialogUtil;
+import org.tizen.nativeplatform.pkg.commander.ICommandStatus;
+import org.tizen.nativeplatform.pkg.commander.IPkgCommander;
+import org.tizen.nativeplatform.pkg.commander.IPkgVersionComparer;
+import org.tizen.nativeplatform.pkg.commander.PkgVersionComparerFactory;
import org.tizen.nativeplatform.pkgmgr.model.Package;
import org.tizen.nativeplatform.pkgmgr.model.Repository;
+import org.tizen.nativeplatform.util.CharacterStripper;
abstract public class CommonTab {
- protected TableViewer repoViewer = null;
- protected CheckboxTableViewer pkgViewer = null;
- protected Combo categoryCombo;
- protected Text filterText;
-
- protected final Shell shell;
- protected TabFolder folder = null;
- protected static final String BUNDLE_NAME = BuildSystemTab.class.getPackage().getName() + ".PkgMgrUIMessages";//$NON-NLS-1$
- protected static final ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
-
-
- public CommonTab(Shell shell, TabFolder folder) {
- this.shell = shell;
- this.folder = folder;
- }
-
- abstract protected CopyOnWriteArrayList<Repository> getRepositoryList();
- abstract public void updateRepositoryInfo();
-
- protected void createCommonTab( TabFolder parent, String title )
- {
- TabItem buildsystemTab = new TabItem( parent, SWT.NULL );
- buildsystemTab.setText(title);
-
- Composite composite = new Composite(folder, SWT.NONE);
- buildsystemTab.setControl(composite);
+ protected TableViewer repoViewer = null;
+ protected CheckboxTableViewer pkgViewer = null;
+ protected Combo categoryCombo;
+ protected Text filterText;
+ protected Text logText;
+ protected IOConsoleViewer logViewer;
+ protected String logs = "";
+
+ protected final Shell shell;
+ protected TabFolder folder = null;
+ protected static final String BUNDLE_NAME = CommonTab.class.getPackage().getName()
+ + ".PkgMgrUIMessages";//$NON-NLS-1$
+ protected static final ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ protected IPkgCommander commander = null;
+
+ public CommonTab(Shell shell, TabFolder folder, IPkgCommander commander) {
+ this.shell = shell;
+ this.folder = folder;
+ this.commander = commander;
+ }
+
+ abstract protected CopyOnWriteArrayList<Repository> getRepositoryList();
+
+ abstract protected List<Package> getSelectedPkgList(boolean remove);
+
+ abstract public void updateRepositoryInfo();
+
+ abstract protected boolean handleAddRepositoryButton();
+
+ abstract protected boolean handleModifyRepositoryButton();
+
+ abstract protected boolean handleRemoveRepositoryButton();
+
+ abstract protected void handleUpgradeButton();
+
+ abstract protected List<Package> getPackageList();
+
+ protected void createCommonTab(String title) {
+ TabItem tab = new TabItem(folder, SWT.NULL);
+ tab.setText(title);
+
+ Composite composite = new Composite(folder, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
composite.setLayout(new GridLayout(1, false));
+ tab.setControl(composite);
+
+ createRepositoryGroup(composite);
+ createPackageGroup(composite);
+ createLogSeparator(composite);
+ createLogViewer(composite);
+ }
+
+ private void createLogSeparator(Composite parent) {
+ Label logLabel = new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR);
+ logLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ }
+
+ private void createLogViewer(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE | SWT.BORDER);
+ GridData log_gd = new GridData(GridData.FILL_BOTH);
+ log_gd.heightHint = 150;
+ composite.setLayoutData(log_gd);
+ composite.setLayout(new FillLayout());
+
+ MessageConsole c = commander.getOutputReceiver().getMsgConsoleStream().getConsole();
+ logViewer = new IOConsoleViewer(composite, c);
+ // Positions the cursor at the end of the log.
+ int line = logViewer.getTextWidget().getLineCount();
+ if (line > 0) {
+ logViewer.getTextWidget().setTopIndex(line);
+ }
+ }
+
+ private void createRepositoryGroup(Composite parent) {
+ Group grpRepo = new Group(parent, SWT.NONE);
+ grpRepo.setText(resources.getString("PkgMgr.Frame.Respository"));
+ GridData repo_gd = new GridData(GridData.FILL_HORIZONTAL);
+ repo_gd.heightHint = 110;
+ grpRepo.setLayoutData(repo_gd);
+ grpRepo.setLayout(new GridLayout(2, false));
+
+ createRepositoryTable(grpRepo);
+ createRepositoryButtons(grpRepo);
+ }
+
+ private void createRepositoryTable(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ composite.setLayoutData(gridData);
+ composite.setLayout(new FillLayout());
+
+ repoViewer = new TableViewer(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ createColumnsForRepoTable(composite);
+ Table reposTable = repoViewer.getTable();
+ reposTable.setHeaderVisible(true);
+ reposTable.setLinesVisible(true);
+ repoViewer.setContentProvider(new ArrayContentProvider());
+ repoViewer.setInput(getRepositoryList());
+ }
+
+ private void createColumnsForRepoTable(Composite parent) {
+ String[] titles = { resources.getString("PkgMgr.Repo.Table.Column.1"),
+ resources.getString("PkgMgr.Repo.Table.Column.2") };
+ int[] bounds = { 100, 600 };
+
+ TableViewerColumn colName = createTableViewerColumn(repoViewer, titles[0], bounds[0],
+ SWT.NONE);
+ colName.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ Repository repo = (Repository) element;
+ return repo.getName();
+ }
+ });
- createRepositoryGroup( composite );
- createPackageGroup( composite );
- }
+ TableViewerColumn colUrl = createTableViewerColumn(repoViewer, titles[1], bounds[1],
+ SWT.NONE);
+ colUrl.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ Repository repo = (Repository) element;
+ return repo.getUri();
+ }
+ });
+ }
+
+ 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(pkgViewer));
+ column.setText(title);
+ column.setWidth(bound);
+ column.setResizable(true);
+ column.setMoveable(true);
+ return viewerColumn;
+ }
+
+ private void createRepositoryButtons(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ RowLayout layout = new RowLayout(SWT.VERTICAL);
+ layout.pack = false;
+ composite.setLayout(layout);
+
+ Button add_bt = new Button(composite, SWT.PUSH);
+ add_bt.setText(resources.getString("PkgMgr.Button.AddRepo"));
+ add_bt.setToolTipText(resources.getString("PkgMgr.Button.AddRepo.Tooltip"));
+ add_bt.addMouseListener(new MouseListener() {
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ if (handleAddRepositoryButton()) {
+ updateRepositoryInfo();
+ repoViewer.refresh();
+ }
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ }
+ });
- private void createRepositoryGroup( Composite parent )
- {
- Group grpRepo = new Group(parent, SWT.NONE);
- grpRepo.setText(resources.getString("PkgMgr.Frame.Respository"));
- GridData repo_gd = new GridData(GridData.FILL_HORIZONTAL);
- repo_gd.heightHint = 110;
- grpRepo.setLayoutData(repo_gd);
- grpRepo.setLayout(new GridLayout(2, false));
-
- createRepositoryTable( grpRepo );
- createRepositoryButtons( grpRepo );
- }
-
-
- private void createRepositoryTable( Composite parent)
- {
- Composite composite = new Composite( parent, SWT.NONE );
- GridData gridData = new GridData(GridData.FILL_BOTH);
- composite.setLayoutData(gridData);
- composite.setLayout(new FillLayout());
-
- repoViewer = new TableViewer( composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL );
- createColumnsForRepoTable( composite );
- Table reposTable = repoViewer.getTable();
- reposTable.setHeaderVisible(true);
- reposTable.setLinesVisible(true);
- repoViewer.setContentProvider(new ArrayContentProvider());
- repoViewer.setInput(getRepositoryList());
- }
-
-
- private void createColumnsForRepoTable( Composite parent )
- {
- String[] titles = {resources.getString("PkgMgr.Repo.Table.Column.1"),
- resources.getString("PkgMgr.Repo.Table.Column.2")};
- int[] bounds = { 100, 600 };
-
- TableViewerColumn colName = createTableViewerColumn( repoViewer, titles[0], bounds[0], SWT.NONE);
- colName.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getText(Object element) {
- Repository repo = (Repository)element;
- return repo.getName();
- }
- });
-
- TableViewerColumn colUrl = createTableViewerColumn( repoViewer, titles[1], bounds[1], SWT.NONE);
- colUrl.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getText(Object element) {
- Repository repo = (Repository)element;
- return repo.getUri();
- }
- });
- }
-
-
- 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(pkgViewer));
- column.setText(title);
- column.setWidth(bound);
- column.setResizable(true);
- column.setMoveable(true);
- return viewerColumn;
- }
-
-
- private void createRepositoryButtons( Composite parent )
- {
- Composite composite = new Composite( parent, SWT.NONE );
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- RowLayout layout = new RowLayout(SWT.VERTICAL);
- layout.pack = false;
- composite.setLayout(layout);
-
-
- Button add_bt = new Button( composite, SWT.PUSH );
- add_bt.setText(resources.getString("PkgMgr.Button.AddRepo"));
- add_bt.setToolTipText(resources.getString("PkgMgr.Button.AddRepo.Tooltip"));
- add_bt.addMouseListener(new MouseListener(){
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- if (handleAddRepositoryButton()) {
- updateRepositoryInfo();
- repoViewer.refresh();
- }
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- }
+ Button modify_bt = new Button(composite, SWT.PUSH);
+ modify_bt.setText(resources.getString("PkgMgr.Button.ModifyRepo"));
+ modify_bt.setToolTipText(resources.getString("PkgMgr.Button.ModifyRepo.Tooltip"));
+ modify_bt.addMouseListener(new MouseListener() {
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ if (handleModifyRepositoryButton()) {
+ updateRepositoryInfo();
+ repoViewer.refresh();
+ }
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ }
+ });
+
+ Button remove_bt = new Button(composite, SWT.PUSH);
+ remove_bt.setText(resources.getString("PkgMgr.Button.RemoveRepo"));
+ remove_bt.setToolTipText(resources.getString("PkgMgr.Button.RemoveRepo.Tooltip"));
+ remove_bt.addMouseListener(new MouseListener() {
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ if (handleRemoveRepositoryButton()) {
+ updateRepositoryInfo();
+ repoViewer.refresh();
+ }
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ }
+ });
+ }
+
+ protected void createPackageGroup(Composite parent) {
+ Group grpPkg = new Group(parent, SWT.NONE);
+ grpPkg.setText(resources.getString("PkgMgr.Frame.Package"));
+ GridData pkgs_gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL);
+ pkgs_gd.heightHint = 300;
+ grpPkg.setLayoutData(pkgs_gd);
+ grpPkg.setLayout(new GridLayout(1, false));
+
+ createPackageButtonsAndFilter(grpPkg);
+ createPackageTable(grpPkg);
+ }
+
+ protected void createPackageButtonsAndFilter(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ composite.setLayout(new GridLayout(2, false));
+
+ createPackageButtons(composite);
+ createPackageFilter(composite);
+ }
+
+ protected void createPackageButtons(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ RowLayout layout = new RowLayout(SWT.HORIZONTAL);
+ layout.pack = false;
+ composite.setLayout(layout);
+
+ Button refresh_bt = new Button(composite, SWT.PUSH);
+ refresh_bt.setText(resources.getString("PkgMgr.Button.RefreshRepo"));
+ refresh_bt.setToolTipText(resources.getString("PkgMgr.Button.RefreshRepo.Tooltip"));
+ refresh_bt.addMouseListener(new MouseListener() {
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ handleRefreshRepositoryButton();
+ updatePackageInfo(null);
+ pkgViewer.refresh();
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ }
+ });
+ Button upgrade_bt = new Button(composite, SWT.PUSH);
+ upgrade_bt.setText(resources.getString("PkgMgr.Button.Upgrade"));
+ upgrade_bt.setToolTipText(resources.getString("PkgMgr.Button.Upgrade.Tooltip"));
+ upgrade_bt.addMouseListener(new MouseListener() {
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ handleUpgradeButton();
+ updatePackageInfo(null);
+ pkgViewer.refresh();
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ }
});
-
- Button modify_bt = new Button( composite, SWT.PUSH );
- modify_bt.setText(resources.getString("PkgMgr.Button.ModifyRepo"));
- modify_bt.setToolTipText(resources.getString("PkgMgr.Button.ModifyRepo.Tooltip"));
- modify_bt.addMouseListener(new MouseListener(){
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- if (handleModifyRepositoryButton()) {
- updateRepositoryInfo();
- repoViewer.refresh();
- }
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- }
+
+ Button install_bt = new Button(composite, SWT.PUSH);
+ install_bt.setText(resources.getString("PkgMgr.Button.Install"));
+ install_bt.setToolTipText(resources.getString("PkgMgr.Button.Install.Tooltip"));
+ install_bt.addMouseListener(new MouseListener() {
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ handleInstallPackageButton();
+ updatePackageInfo(null);
+ pkgViewer.refresh();
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ }
+
});
- Button remove_bt = new Button( composite, SWT.PUSH );
- remove_bt.setText(resources.getString("PkgMgr.Button.RemoveRepo"));
- remove_bt.setToolTipText(resources.getString("PkgMgr.Button.RemoveRepo.Tooltip"));
- remove_bt.addMouseListener(new MouseListener() {
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- if (handleRemoveRepositoryButton()) {
- updateRepositoryInfo();
- repoViewer.refresh();
- }
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- }
- });
- }
-
-
- abstract protected boolean handleAddRepositoryButton();
- abstract protected boolean handleModifyRepositoryButton();
- abstract protected boolean handleRemoveRepositoryButton();
-
-
- protected void createPackageGroup( Composite parent )
- {
- Group grpPkg = new Group(parent, SWT.NONE);
- grpPkg.setText(resources.getString("PkgMgr.Frame.Package"));
- GridData pkgs_gd = new GridData(GridData.FILL_BOTH|GridData.GRAB_VERTICAL);
- grpPkg.setLayoutData(pkgs_gd);
- grpPkg.setLayout(new GridLayout(1, false));
-
- createPackageButtonsAndFilter( grpPkg );
- createPackageTable( grpPkg );
- }
-
-
- protected void createPackageButtonsAndFilter( Composite parent ) {
- Composite composite = new Composite( parent, SWT.NONE );
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- composite.setLayout(new GridLayout(2, false));
-
- createPackageButtons( composite );
- createPackageFilter( composite );
- }
-
-
- protected void createPackageButtons( Composite parent )
- {
- Composite composite = new Composite( parent, SWT.NONE );
- RowLayout layout = new RowLayout(SWT.HORIZONTAL);
- layout.pack = false;
- composite.setLayout(layout);
-
- Button refresh_bt = new Button( composite, SWT.PUSH );
- refresh_bt.setText(resources.getString("PkgMgr.Button.RefreshRepo"));
- refresh_bt.setToolTipText(resources.getString("PkgMgr.Button.RefreshRepo.Tooltip"));
- refresh_bt.addMouseListener(new MouseListener(){
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- handleRefreshRepositoryButton();
- updatePackageInfo(null);
- pkgViewer.refresh();
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- }
- });
-
-
- Button upgrade_bt = new Button( composite, SWT.PUSH );
- upgrade_bt.setText(resources.getString("PkgMgr.Button.Upgrade"));
- upgrade_bt.setToolTipText(resources.getString("PkgMgr.Button.Upgrade.Tooltip"));
- upgrade_bt.addMouseListener(new MouseListener(){
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- handleUpgradeRootstrapButton();
- updatePackageInfo(null);
- pkgViewer.refresh();
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- }
+ Button installLocal_bt = new Button(composite, SWT.PUSH);
+ installLocal_bt.setText(resources.getString("PkgMgr.Button.InstallLocal"));
+ installLocal_bt.setToolTipText(resources.getString("PkgMgr.Button.InstallLocal.Tooltip"));
+ installLocal_bt.addMouseListener(new MouseListener() {
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ FileDialog fd = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
+ fd.setText(resources.getString("FileDlg.Title"));
+ String[] filterExt = { resources.getString("FileDlg.Filter.Ext") };
+ fd.setFilterExtensions(filterExt);
+ String firstFilePath = fd.open();
+ if (firstFilePath == null) {
+ return;
+ }
+
+ String[] fileNames = fd.getFileNames();
+ final List<String> selectedFiles = new ArrayList<String>();
+ for (String fileName : fileNames) {
+ selectedFiles.add(new File(firstFilePath).getParent() + "/" + fileName);
+ }
+
+ handleInstallLocalPackageButton(selectedFiles);
+ updatePackageInfo(selectedFiles);
+ pkgViewer.refresh();
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ }
});
-
- Button install_bt = new Button( composite, SWT.PUSH );
- install_bt.setText(resources.getString("PkgMgr.Button.Install"));
- install_bt.setToolTipText(resources.getString("PkgMgr.Button.Install.Tooltip"));
- install_bt.addMouseListener(new MouseListener(){
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- handleInstallPackageButton();
- updatePackageInfo(null);
- pkgViewer.refresh();
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- }
+ Button removeBt = new Button(composite, SWT.PUSH);
+ removeBt.setText(resources.getString("PkgMgr.Button.Uninstall"));
+ removeBt.setToolTipText(resources.getString("PkgMgr.Button.Uninstall.Tooltip"));
+ removeBt.addMouseListener(new MouseListener() {
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ handleRemovePackageButton();
+ updatePackageInfo(null);
+ pkgViewer.refresh();
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ }
});
-
- Button installLocal_bt = new Button( composite, SWT.PUSH );
- installLocal_bt.setText(resources.getString("PkgMgr.Button.InstallLocal"));
- installLocal_bt.setToolTipText(resources.getString("PkgMgr.Button.InstallLocal.Tooltip"));
- installLocal_bt.addMouseListener(new MouseListener() {
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- FileDialog fd = new FileDialog( shell, SWT.OPEN|SWT.MULTI);
- fd.setText(resources.getString("FileDlg.Title"));
- String[] filterExt = { resources.getString("FileDlg.Filter.Ext") };
- fd.setFilterExtensions(filterExt);
- String firstFilePath = fd.open();
- if ( firstFilePath == null ) { return; }
-
- String[] fileNames = fd.getFileNames();
- final ArrayList<String> selectedFiles = new ArrayList<String>();
- for( String fileName : fileNames ) {
- selectedFiles.add(new File(firstFilePath).getParent()+"/"+fileName);
- }
-
- handleInstallLocalPackageButton(selectedFiles);
- updatePackageInfo(selectedFiles);
- pkgViewer.refresh();
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- }
- });
-
- Button removeBt = new Button( composite, SWT.PUSH );
- removeBt.setText(resources.getString("PkgMgr.Button.Uninstall"));
- removeBt.setToolTipText(resources.getString("PkgMgr.Button.Uninstall.Tooltip"));
- removeBt.addMouseListener(new MouseListener(){
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- handleRemovePackageButton();
- updatePackageInfo(null);
- pkgViewer.refresh();
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- }
+ }
+
+ private void createPackageFilter(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
+ composite.setLayout(new GridLayout(3, false));
+
+ Label filterTextLabel = new Label(composite, SWT.NONE);
+ filterTextLabel.setText(resources.getString("PkgMgr.Label.Filter"));
+
+ categoryCombo = new Combo(composite, SWT.READ_ONLY);
+ String[] items = { "All", "Installed", "Upgradable" };
+ categoryCombo.setItems(items);
+ categoryCombo.addSelectionListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ pkgViewer.refresh();
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
});
- }
-
-
- abstract protected void handleRefreshRepositoryButton();
- abstract protected void handleUpgradeRootstrapButton();
- abstract protected void handleInstallPackageButton();
- abstract protected void handleInstallLocalPackageButton(final ArrayList<String> selectedFiles);
- abstract protected void handleRemovePackageButton();
-
- abstract protected CopyOnWriteArrayList<Package> getPackageList();
- abstract protected void updatePackageInfo(ArrayList<String> localPackageFileList);
-
-
- private void createPackageFilter( Composite parent ) {
- Composite composite = new Composite( parent, SWT.NONE );
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL|GridData.GRAB_HORIZONTAL));
- composite.setLayout(new GridLayout(3,false));
-
- Label filterTextLabel = new Label(composite, SWT.NONE);
- filterTextLabel.setText(resources.getString("PkgMgr.Label.Filter"));
-
- categoryCombo = new Combo(composite, SWT.READ_ONLY);
- String[] items = {"All","Installed","Upgradable"};
- categoryCombo.setItems(items);
- categoryCombo.addSelectionListener( new SelectionListener() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- pkgViewer.refresh();
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
- });
- categoryCombo.select(0);
-
-
- filterText = new Text( composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH);
+ categoryCombo.select(0);
+
+ filterText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
filterText.setLayoutData(gridData);
filterText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- pkgViewer.refresh();
- }
+ @Override
+ public void modifyText(ModifyEvent e) {
+ pkgViewer.refresh();
+ }
});
- }
-
-
-
- private void createPackageTable( Composite parent )
- {
- Composite composite = new Composite( parent, SWT.NONE );
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- composite.setLayout(new FillLayout());
-
- pkgViewer = CheckboxTableViewer.newCheckList( composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK );
- createPackageTableColumns( composite );
+ }
+
+ private void createPackageTable(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ // composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ composite.setLayout(new FillLayout());
+ // composite.setLayout(new GridLayout(1,false));
+
+ pkgViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER | SWT.H_SCROLL
+ | SWT.V_SCROLL | SWT.CHECK);
+ createPackageTableColumns(composite);
Table packageTable = pkgViewer.getTable();
- packageTable.addListener( SWT.Selection, new Listener(){
-
- @Override
- public void handleEvent(Event event) {
- if( event.detail == SWT.CHECK )
- {
- Package pkg = (Package)event.item.getData();
- pkg.setCheckColumn( !pkg.getCheckColumn() );
- }
- }
- });
+ packageTable.addListener(SWT.Selection, new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ if (event.detail == SWT.CHECK) {
+ Package pkg = (Package) event.item.getData();
+ pkg.setCheckColumn(!pkg.getCheckColumn());
+ }
+ }
+ });
packageTable.setHeaderVisible(true);
packageTable.setLinesVisible(true);
pkgViewer.setContentProvider(new ArrayContentProvider());
pkgViewer.setCheckStateProvider(new ICheckStateProvider() {
- @Override
- public boolean isChecked(Object element) {
- Package pkg = (Package) element;
- return pkg.isChecked();
- }
+ @Override
+ public boolean isChecked(Object element) {
+ Package pkg = (Package) element;
+ return pkg.isChecked();
+ }
- @Override
- public boolean isGrayed(Object element) {
- return false;
- }
+ @Override
+ public boolean isGrayed(Object element) {
+ return false;
+ }
});
- pkgViewer.addFilter( new ViewerFilter() {
-
- @Override
- public boolean select(Viewer viewer, Object parentElement,
- Object element) {
- Package pkg = (Package) element;
- if ( categoryCombo != null ) {
- if ( categoryCombo.getText().equals("Installed") &&
- pkg.getInstalledVersion().isEmpty() ) {
- return false;
- }
- if ( categoryCombo.getText().equals("Upgradable") &&
- ( pkg.getInstalledVersion().isEmpty() ||
- pkg.getNewVersion().isEmpty() ||
- RPMPackageCommander.compareVersion(pkg.getInstalledVersion(),pkg.getNewVersion()) >= 0 )) {
- return false;
- }
- }
- if ( filterText != null && !pkg.getName().contains(filterText.getText()) ) {
- return false;
- }
- return true;
- }
-
+ pkgViewer.addFilter(new ViewerFilter() {
+
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ Package pkg = (Package) element;
+ if (categoryCombo != null) {
+ if (categoryCombo.getText().equals("Installed")
+ && pkg.getInstalledVersion().isEmpty()) {
+ return false;
+ }
+ if (categoryCombo.getText().equals("Upgradable")) {
+ IPkgVersionComparer comp = PkgVersionComparerFactory.getComparer();
+ if (pkg.getInstalledVersion().isEmpty()
+ || pkg.getNewVersion().isEmpty()
+ || comp.compare(pkg.getInstalledVersion(), pkg.getNewVersion()) >= 0) {
+ return false;
+ }
+ }
+ }
+ if (filterText != null && !pkg.getName().contains(filterText.getText())) {
+ return false;
+ }
+ return true;
+ }
+
});
- pkgViewer.addCheckStateListener( new ICheckStateListener() {
+ pkgViewer.addCheckStateListener(new ICheckStateListener() {
- @Override
- public void checkStateChanged(CheckStateChangedEvent event) {
- Package pkg = (Package)event.getElement();
- pkg.setChecked(true);
- }
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ Package pkg = (Package) event.getElement();
+ pkg.setChecked(true);
+ }
});
pkgViewer.setInput(getPackageList());
- }
-
-
- private void createPackageTableColumns( Composite parent )
- {
- String[] titles = {"S", "Package Name", "Installed Version", "New Version", "Arch", "Description"};
- int[] bounds = { 24, 200, 150, 150, 60, 150};
-
- TableViewerColumn colSelection = createTableViewerColumn( pkgViewer, titles[0], bounds[0], SWT.NONE);
- colSelection.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getText(Object element) {
- return "";
- }
- });
-
- TableViewerColumn colPackage = createTableViewerColumn( pkgViewer, titles[1], bounds[1], SWT.NONE);
- colPackage.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getText(Object element) {
- Package pkg = (Package)element;
- if ( pkg.isNewlyChanged() ) {
- return "*"+pkg.getName();
- }
- else {
- return pkg.getName();
- }
- }
- });
-
- TableViewerColumn colInsVer = createTableViewerColumn( pkgViewer, titles[2], bounds[2], SWT.NONE);
- colInsVer.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getText(Object element) {
- Package pkg = (Package)element;
- String installedVer = pkg.getInstalledVersion();
- return installedVer;
- }
- });
-
-
- TableViewerColumn colNewVer = createTableViewerColumn( pkgViewer, titles[3], bounds[3], SWT.NONE);
-
- colNewVer.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getText(Object element) {
- Package pkg = (Package)element;
- String newVer = pkg.getNewVersion();
- return newVer;
- }
- });
-
- TableViewerColumn colArch = createTableViewerColumn( pkgViewer, titles[4], bounds[4], SWT.NONE);
-
- colArch.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getText(Object element) {
- Package pkg = (Package)element;
- String arch = pkg.getArch();
- return arch;
- }
- });
-
- TableViewerColumn colDescription = createTableViewerColumn( pkgViewer, titles[5], bounds[5], SWT.NONE);
- colDescription.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getText(Object element) {
- return "";
- }
- });
- }
+ }
+
+ private void createPackageTableColumns(Composite parent) {
+ String[] titles = { "S", "Package Name", "Installed Version", "New Version", "Arch", };
+ int[] bounds = { 24, 250, 200, 200, 60 };
+
+ TableViewerColumn colSelection = createTableViewerColumn(pkgViewer, titles[0], bounds[0],
+ SWT.NONE);
+ colSelection.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ return "";
+ }
+ });
+
+ TableViewerColumn colPackage = createTableViewerColumn(pkgViewer, titles[1], bounds[1],
+ SWT.NONE);
+ colPackage.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ Package pkg = (Package) element;
+ if (pkg.isNewlyChanged()) {
+ return "*" + pkg.getName();
+ } else {
+ return pkg.getName();
+ }
+ }
+ });
+
+ TableViewerColumn colInsVer = createTableViewerColumn(pkgViewer, titles[2], bounds[2],
+ SWT.NONE);
+ colInsVer.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ Package pkg = (Package) element;
+ String installedVer = pkg.getInstalledVersion();
+ return installedVer;
+ }
+ });
+ TableViewerColumn colNewVer = createTableViewerColumn(pkgViewer, titles[3], bounds[3],
+ SWT.NONE);
+
+ colNewVer.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ Package pkg = (Package) element;
+ String newVer = pkg.getNewVersion();
+ return newVer;
+ }
+ });
+
+ TableViewerColumn colArch = createTableViewerColumn(pkgViewer, titles[4], bounds[4],
+ SWT.NONE);
+
+ colArch.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ Package pkg = (Package) element;
+ String arch = pkg.getArch();
+ return arch;
+ }
+ });
+ /*
+ * TableViewerColumn colDescription = createTableViewerColumn(pkgViewer,
+ * titles[5], bounds[5], SWT.NONE); colDescription.setLabelProvider(new
+ * ColumnLabelProvider() {
+ *
+ * @Override public String getText(Object element) { return ""; } });
+ */
+ }
+
+ protected void handleRefreshRepositoryButton() {
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
+
+ try {
+ dialog.run(true, false, new IRunnableWithProgress() {
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+ monitor.beginTask(resources.getString("PkgMgr.Message.Refreshing"), -1);
+ ICommandStatus status = commander.refreshRepoList();
+ if (!status.isOk()) {
+ new InterruptedException();
+ }
+ monitor.done();
+ }
+ });
+ } catch (InvocationTargetException e) {
+ DialogUtil.openErrorDialog(resources.getString("PkgMgr.Msg.Error.RefreshFailed") + "("
+ + e.toString() + ")");
+ } catch (InterruptedException e) {
+ DialogUtil.openErrorDialog(resources.getString("PkgMgr.Msg.Error.RefreshFailed") + "("
+ + e.toString() + ")");
+ }
+ }
+
+ protected void handleInstallPackageButton() {
+ final List<Package> selectedList = getSelectedPkgList(false);
+ if (selectedList.isEmpty()) {
+ DialogUtil.openErrorDialog(resources.getString("PkgMgr.Error.Noselected.Package"));
+ return;
+ }
+
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
+ try {
+ dialog.run(true, false, new IRunnableWithProgress() {
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+ monitor.beginTask(resources.getString("PkgMgr.Message.Installing.Package"), -1);
+ List<String> lists = new ArrayList<String>();
+ for (Package pkg : selectedList) {
+ lists.add(pkg.getName());
+ }
+ ICommandStatus status = commander.installRemotePkg(
+ lists.toArray(new String[0]), monitor);
+ if (!status.isOk()) {
+ new InterruptedException();
+ }
+ monitor.done();
+ }
+ });
+ } catch (InvocationTargetException e) {
+ DialogUtil.openErrorDialog(resources.getString("PkgMgr.Msg.Error.InstallFailed") + "("
+ + e.toString() + ")");
+ } catch (InterruptedException e) {
+ DialogUtil.openErrorDialog(resources.getString("PkgMgr.Msg.Error.InstallFailed") + "("
+ + e.toString() + ")");
+ }
+ }
+
+ protected void handleInstallLocalPackageButton(final List<String> selectedFiles) {
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
+ try {
+ dialog.run(true, false, new IRunnableWithProgress() {
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+
+ monitor.beginTask(
+ resources.getString("PkgMgr.Message.Installing.LocalPackage"), -1);
+ ICommandStatus status = commander.installLocalPkg(
+ selectedFiles.toArray(new String[0]), monitor);
+ if (!status.isOk()) {
+ new InterruptedException();
+ }
+ monitor.done();
+ }
+ });
+ } catch (InvocationTargetException e) {
+ DialogUtil.openErrorDialog(resources.getString("PkgMgr.Msg.Error.InstallFailed") + "("
+ + e.toString() + ")");
+ } catch (InterruptedException e) {
+ DialogUtil.openErrorDialog(resources.getString("PkgMgr.Msg.Error.InstallFailed") + "("
+ + e.toString() + ")");
+ }
+ }
+
+ protected void handleRemovePackageButton() {
+ final List<Package> selectedList = getSelectedPkgList(true);
+
+ if (selectedList.isEmpty()) {
+ DialogUtil.openErrorDialog(resources.getString("PkgMgr.Error.Noselected.Package"));
+ return;
+ }
+
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
+ try {
+ dialog.run(true, false, new IRunnableWithProgress() {
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+ monitor.beginTask(resources.getString("PkgMgr.Message.Uninstalling.Package"),
+ -1);
+ List<String> lists = new ArrayList<String>();
+ for (Package pkg : selectedList) {
+ lists.add(pkg.getName());
+ }
+ ICommandStatus status = commander.uninstallPkg(lists.toArray(new String[0]),
+ monitor);
+ if (!status.isOk()) {
+ new InterruptedException();
+ }
+ monitor.done();
+ }
+ });
+ } catch (InvocationTargetException e) {
+ DialogUtil.openErrorDialog(resources.getString("PkgMgr.Msg.Error.UninstallFailed")
+ + "(" + e.toString() + ")");
+ } catch (InterruptedException e) {
+ DialogUtil.openErrorDialog(resources.getString("PkgMgr.Msg.Error.UninstallFailed")
+ + "(" + e.toString() + ")");
+ }
+ }
+
+ protected void updatePackageInfo(List<String> localPackageFileList) {
+ List<Package> fullList = commander.getAllPkgList();
+ List<Package> removeList = new ArrayList<Package>();
+ for (Package pkg : getPackageList()) {
+ boolean found = false;
+ for (Package currPkg : fullList) {
+ if (currPkg.getName().equals(pkg.getName())) {
+ // check newly install
+ if (!pkg.getInstalledVersion().equals(currPkg.getInstalledVersion())) {
+ pkg.setNewlyChanged(true);
+ }
+ if (!pkg.getNewVersion().equals(currPkg.getNewVersion())) {
+ pkg.setNewVersion(currPkg.getNewVersion());
+ pkg.setNewlyChanged(true);
+ }
+ pkg.setInstalledVersion(currPkg.getInstalledVersion());
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ removeList.add(pkg);
+ }
+ pkg.setChecked(false);
+ }
+
+ // remove
+ for (Package pkg : removeList) {
+ getPackageList().remove(pkg);
+ }
+
+ // add if there is new package
+ for (Package currPkg : fullList) {
+ boolean found = false;
+ for (Package pkg : getPackageList()) {
+ if (currPkg.getName().equals(pkg.getName())) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ getPackageList().add(currPkg);
+ currPkg.setNewlyChanged(true);
+ }
+ }
+
+ // check local package update
+ if (localPackageFileList != null) {
+ List<String> localPackageNameList = new ArrayList<String>();
+ for (String filePath : localPackageFileList) {
+ localPackageNameList.add(commander.getNameFromFile(filePath));
+ }
+ for (Package pkg : getPackageList()) {
+ if (localPackageNameList.contains(pkg.getName())) {
+ pkg.setNewlyChanged(true);
+ }
+ }
+ }
+ }
}
package org.tizen.nativeplatform.pkgmgr.ui;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.concurrent.CopyOnWriteArrayList;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.tizen.common.util.DialogUtil;
-import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander;
+import org.tizen.nativeplatform.pkg.commander.ICommandStatus;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
+import org.tizen.nativeplatform.pkgmgr.PkgMgrInitializer;
import org.tizen.nativeplatform.pkgmgr.model.Package;
import org.tizen.nativeplatform.pkgmgr.model.PackageProvider;
import org.tizen.nativeplatform.pkgmgr.model.Repository;
import org.tizen.nativeplatform.pkgmgr.model.RepositoryProvider;
-import org.tizen.sdblib.IDevice;
-
-public class DeviceTab extends CommonTab{
-
- private final IDevice device;
- private final int URL_MAX_COUNT = 10000;
-
- public DeviceTab(Shell shell, TabFolder folder, IDevice dev) {
- super(shell, folder);
- this.device = dev;
- }
-
-
- protected CopyOnWriteArrayList<Repository> getRepositoryList() {
- return RepositoryProvider.INSTANCE.getDeviceRepos();
- }
-
-
- public void updateRepositoryInfo() {
- initializeRepositoryInfo(device);
- }
-
-
- public static void initializeRepositoryInfo(IDevice device) {
- RepositoryProvider.INSTANCE.getDeviceRepos().clear();
- Hashtable<String,String> reposHash = RPMPackageCommander.getRepositoryListForDevice(device);
- Enumeration<String> e = reposHash.keys();
- while(e.hasMoreElements()) {
- String name = e.nextElement();
- String url = reposHash.get(name);
- RepositoryProvider.INSTANCE.getDeviceRepos().add(new Repository(name, url ));
- }
- }
-
-
- public static void initializePackageInfo(IDevice device) {
-
- PackageProvider.INSTANCE.getDevicePkgs().clear();
- PackageProvider.INSTANCE.getDevicePkgs()
- .addAll(RPMPackageCommander.getPackageListForDevice(device));
- }
-
-
- public void createTab() {
- createCommonTab(folder,
- resources.getString("PkgMgr.Tab.Device")+" ["+device.getSerialNumber()+"]");
- }
-
- private String findUrlName() {
- Hashtable<String,String> reposHash = RPMPackageCommander.getRepositoryListForDevice(device);
- for (int idx = 0 ; idx < URL_MAX_COUNT ; idx++) {
- String name = String.format("url%d", idx);
- if (!reposHash.containsKey(name)) {
- return name;
- }
- }
- return null;
- }
-
- protected boolean handleAddRepositoryButton(){
-
- AddRepoDialog dialog = new AddRepoDialog(shell,
- resources.getString("PkgMgr.Tab.Buildsystem"),
- false);
- if ( dialog.open() != AddRepoDialog.OK ) {
- return false;
- }
-
- String name = findUrlName();
- String url = dialog.getRepositoryURL();
-
- RPMPackageCommander.addRepositoryForDevice(name, url, device);
-
- return true;
- }
-
-
- protected boolean handleModifyRepositoryButton() {
- int selectedIdx = repoViewer.getTable().getSelectionIndex();
- if ( selectedIdx == -1 ) {
- DialogUtil.openMessageDialog(resources.getString("PkgMgr.Message.Select.OnePackage"));
- return false;
- }
-
- Repository repos = (Repository)repoViewer.getTable().getItem(selectedIdx).getData();
- ModifyRepoDialog dialog = new ModifyRepoDialog(
- shell,
- resources.getString("PkgMgr.Tab.Device"),
- repos.getName(),
- repos.getUri(),
- false);
- if ( dialog.open() != ModifyRepoDialog.OK ) {
- return false;
- }
- RPMPackageCommander.removeRepositoryForDevice(repos.getName(), device);
- RPMPackageCommander.addRepositoryForDevice(dialog.getRepositoryName(), dialog.getRepositoryURL(), device);
-
- return true;
- }
-
-
- protected boolean handleRemoveRepositoryButton() {
- int selectedIdx = repoViewer.getTable().getSelectionIndex();
- if ( selectedIdx == -1 ) {
- DialogUtil.openMessageDialog(resources.getString("PkgMgr.Message.Select.OnePackage"));
- return false;
- }
- Repository repos = (Repository)repoViewer.getTable().getItem(selectedIdx).getData();
- RPMPackageCommander.removeRepositoryForDevice(repos.getName(), device);
-
- return true;
- }
-
-
- protected void handleRefreshRepositoryButton() {
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
-
- try {
- dialog.run(true, false, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
- monitor.beginTask(resources.getString("PkgMgr.Message.Refreshing"), -1);
- RPMPackageCommander.refreshRepositoryForDevice(device);
- monitor.done();
- }
- });
- } catch (InvocationTargetException e) {
- DialogUtil.openErrorDialog(
- resources.getString("PkgMgr.Msg.Error.RefreshFailed")+
- "("+e.toString()+")");
- } catch (InterruptedException e) {
- DialogUtil.openErrorDialog(
- resources.getString("PkgMgr.Msg.Error.RefreshFailed")+
- "("+e.toString()+")");
- }
- }
-
-
- protected void handleUpgradeRootstrapButton() {
- }
-
-
- protected void handleInstallPackageButton() {
- final CopyOnWriteArrayList<Package> selectedList =
- PackageProvider.INSTANCE.getSelectedDevicePkgs(false);
-
- if(selectedList.isEmpty()) {
- DialogUtil.openErrorDialog( resources.getString("PkgMgr.Error.Noselected.Package"));
- return;
- }
-
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
- try {
- dialog.run(true, false, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
-
- monitor.beginTask(resources.getString("PkgMgr.Message.Installing.Package"), -1);
- RPMPackageCommander.installRemotePkgForDevice(selectedList, device);
- monitor.done();
- }
- });
- } catch (InvocationTargetException e) {
- DialogUtil.openErrorDialog(
- resources.getString("PkgMgr.Msg.Error.InstallFailed")+
- "("+e.toString()+")");
- } catch (InterruptedException e) {
- DialogUtil.openErrorDialog(
- resources.getString("PkgMgr.Msg.Error.InstallFailed")+
- "("+e.toString()+")");
- }
- }
-
-
- protected void handleInstallLocalPackageButton( final ArrayList<String> selectedFiles ) {
-
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
- try {
- dialog.run(true, false, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
-
- monitor.beginTask(resources.getString("PkgMgr.Message.Installing.LocalPackage"), -1);
- RPMPackageCommander.InstallLocalPkgToDevice(selectedFiles, device);
- monitor.done();
- }
- });
- } catch (InvocationTargetException e) {
- DialogUtil.openErrorDialog(
- resources.getString("PkgMgr.Msg.Error.InstallFailed")+
- "("+e.toString()+")");
- } catch (InterruptedException e) {
- DialogUtil.openErrorDialog(
- resources.getString("PkgMgr.Msg.Error.InstallFailed")+
- "("+e.toString()+")");
- }
- }
-
-
- protected void handleRemovePackageButton() {
- final CopyOnWriteArrayList<Package> selectedList =
- PackageProvider.INSTANCE.getSelectedDevicePkgs(true);
- if(selectedList.isEmpty()) {
- DialogUtil.openErrorDialog( resources.getString("PkgMgr.Error.Noselected.Package"));
- return;
- }
-
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
- try {
- dialog.run(true, false, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
-
- monitor.beginTask(resources.getString("PkgMgr.Message.Uninstalling.Package"), -1);
- RPMPackageCommander.uninstallPkgFromDevice(selectedList, device);
- monitor.done();
- }
- });
- } catch (InvocationTargetException e) {
- DialogUtil.openErrorDialog(
- resources.getString("PkgMgr.Msg.Error.UninstallFailed")+
- "("+e.toString()+")");
- } catch (InterruptedException e) {
- DialogUtil.openErrorDialog(
- resources.getString("PkgMgr.Msg.Error.UninstallFailed")+
- "("+e.toString()+")");
- }
- }
-
-
- protected CopyOnWriteArrayList<Package> getPackageList() {
- return PackageProvider.INSTANCE.getDevicePkgs();
- }
-
-
- protected void updatePackageInfo(ArrayList<String> localPackageFileList ) {
- ArrayList<Package> fullList = RPMPackageCommander.getPackageListForDevice(device);
- ArrayList<Package> removeList = new ArrayList<Package>();
- for( Package pkg: PackageProvider.INSTANCE.getDevicePkgs()) {
- boolean found = false;
- for( Package currPkg: fullList ) {
- if ( currPkg.getName().equals(pkg.getName())) {
- // check newly install
- if( !pkg.getInstalledVersion().equals(currPkg.getInstalledVersion())) {
- pkg.setNewlyChanged(true);
- }
-
- pkg.setInstalledVersion(currPkg.getInstalledVersion());
- found = true;
- break;
- }
- }
- if ( !found ) {
- removeList.add(pkg);
- }
- pkg.setChecked(false);
- }
-
- // remove
- for( Package pkg: removeList ) {
- PackageProvider.INSTANCE.getDevicePkgs().remove(pkg);
- }
-
- // add if there is new package
- for( Package currPkg: fullList ) {
- boolean found = false;
- for( Package pkg: PackageProvider.INSTANCE.getDevicePkgs()) {
- if ( currPkg.getName().equals(pkg.getName())) {
- found = true;
- break;
- }
- }
-
- if ( !found ) {
- PackageProvider.INSTANCE.getDevicePkgs().add(currPkg);
- currPkg.setNewlyChanged(true);
- }
- }
-
- // check local package update
- if ( localPackageFileList != null ) {
- ArrayList<String> localPackageNameList = new ArrayList<String>();
- for( String filePath: localPackageFileList) {
- localPackageNameList.add(RPMPackageCommander.getPkgNameForFile(filePath));
- }
- for( Package pkg: PackageProvider.INSTANCE.getDevicePkgs()) {
- if( localPackageNameList.contains( pkg.getName() ) ) {
- pkg.setNewlyChanged(true);
- }
- }
- }
- }
+public class DeviceTab extends CommonTab {
+
+ private PkgCommandTarget target = null;
+
+ public DeviceTab(Shell shell, TabFolder folder, PkgCommandTarget target) {
+ super(shell, folder, target.getDeviceCommander());
+ this.target = target;
+ }
+
+ protected CopyOnWriteArrayList<Repository> getRepositoryList() {
+ return RepositoryProvider.INSTANCE.getDeviceRepos();
+ }
+
+ public void updateRepositoryInfo() {
+ // initializeRepositoryInfo(device);
+ PkgMgrInitializer initializer = new PkgMgrInitializer(target);
+ initializer.initDeviceRepoInfo();
+ }
+
+ public void createTab() {
+ createCommonTab(resources.getString("PkgMgr.Tab.Device") + " ["
+ + target.getDevice().getSerialNumber() + "]");
+ }
+
+ private String findUrlName() {
+ Map<String, String> list = commander.getRepoList();
+ int idx = 0;
+ for (Entry<String, String> e : list.entrySet()) {
+ String name = String.format("url%d", idx);
+ if (!list.containsKey(name)) {
+ return name;
+ }
+ idx++;
+ }
+ return null;
+ }
+
+ protected boolean handleAddRepositoryButton() {
+
+ AddRepoDialog dialog = new AddRepoDialog(shell,
+ resources.getString("PkgMgr.Tab.Buildsystem"), false);
+ if (dialog.open() != AddRepoDialog.OK) {
+ return false;
+ }
+ String name = findUrlName();
+ String url = dialog.getRepositoryURL();
+ ICommandStatus status = commander.addRepo(name, url);
+ if (!status.isOk()) {
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean handleModifyRepositoryButton() {
+ int selectedIdx = repoViewer.getTable().getSelectionIndex();
+ if (selectedIdx == -1) {
+ DialogUtil.openMessageDialog(resources.getString("PkgMgr.Message.Select.OnePackage"));
+ return false;
+ }
+
+ Repository repos = (Repository) repoViewer.getTable().getItem(selectedIdx).getData();
+ ModifyRepoDialog dialog = new ModifyRepoDialog(shell,
+ resources.getString("PkgMgr.Tab.Device"), repos.getName(), repos.getUri(), false);
+ if (dialog.open() != ModifyRepoDialog.OK) {
+ return false;
+ }
+ ICommandStatus status = commander.removeRepo(repos.getName());
+ if (!status.isOk()) {
+ return false;
+ }
+ status = commander.addRepo(dialog.getRepositoryName(), dialog.getRepositoryURL());
+ if (!status.isOk()) {
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean handleRemoveRepositoryButton() {
+ int selectedIdx = repoViewer.getTable().getSelectionIndex();
+ if (selectedIdx == -1) {
+ DialogUtil.openMessageDialog(resources.getString("PkgMgr.Message.Select.OnePackage"));
+ return false;
+ }
+ Repository repos = (Repository) repoViewer.getTable().getItem(selectedIdx).getData();
+ ICommandStatus status = commander.removeRepo(repos.getName());
+ if (!status.isOk()) {
+ return false;
+ }
+ return true;
+ }
+
+ protected void handleUpgradeButton() {
+ return;
+ }
+
+ protected List<Package> getSelectedPkgList(boolean remove) {
+ List<Package> selectedList = PackageProvider.INSTANCE.getSelectedDevicePkgs(remove);
+ return selectedList;
+ }
+
+ protected List<Package> getPackageList() {
+ return PackageProvider.INSTANCE.getDevicePkgs();
+ }
}
Action.Msg.Progress.Init.BuildSystem.Repo = Intializing repositories on build system...
Action.Msg.Progress.Init.Device.Repo = Intializing repositories on device...
Action.Msg.Progress.Init.BuildSystem.Pkgs = Intializing packages on build system...
-Action.Msg.Progress.Init.Device.Pkgs = Intializing repositories on device...
+Action.Msg.Progress.Init.Device.Pkgs = Intializing packages on device...
AddRepo.Title = Add Package Repository
AddRepo.Label.Name = Name:
import java.util.ResourceBundle;
import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
-
import org.osgi.framework.Bundle;
-import org.tizen.common.connection.ConnectionPlugin;
import org.tizen.nativeplatform.Activator;
-import org.tizen.sdblib.IDevice;
-import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander;
+
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
import org.tizen.nativeplatform.pkgmgr.model.LocalPkgProvider;
import org.tizen.nativeplatform.pkgmgr.model.PackageProvider;
import org.tizen.nativeplatform.pkgmgr.model.RemotePkgProvider;
-import org.tizen.nativeplatform.preferences.PreferencesManager;
-import org.tizen.nativeplatform.views.model.PlatformRootstrap;
-public class RPMPackageDialog extends Dialog {
-
- private IDevice device;
- private TabFolder tabFolder;
-
- private boolean enableRootstrapTab = false;
- private boolean enableTargetTab = false;
- private int tabIndex = 0;
- private String http_proxy = "";
-
- private PlatformRootstrap rootstrap;
-
- private int x = 0;
- private int y = 0;
- private final int width = 900;
- private final int height = 700;
-
- private final String BUNDLE_NAME = RPMPackageDialog.class.getPackage().getName() + ".PkgMgrUIMessages";//$NON-NLS-1$
- private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
-
-
- public RPMPackageDialog(Shell parentShell, PlatformRootstrap rootstrap) {
- super(parentShell);
- //setBlockOnOpen(false);
- this.rootstrap = rootstrap;
- this.enableRootstrapTab = true;
- this.device = ConnectionPlugin.getDefault().getCurrentDevice();
- this.enableTargetTab = this.device == null ? false : true;
-
- Rectangle bounds = parentShell.getBounds();
- x = bounds.x + (bounds.width - width)/2;
- y = bounds.y + (bounds.height - height)/2;
-
- http_proxy = PreferencesManager.getHttpProxyURL();
- RPMPackageCommander.setHttpProxy(PreferencesManager.getHttpProxyURL());
- }
-
-
- public RPMPackageDialog(Shell parentShell, String target, boolean enableRootstrap, boolean enableTarget) {
- super(parentShell);
- //setBlockOnOpen(false);
- this.enableRootstrapTab = enableRootstrap;
- this.enableTargetTab = enableTarget;
-
- Rectangle bounds = parentShell.getBounds();
- x = bounds.x + (bounds.width - width)/2;
- y = bounds.y + (bounds.height - height)/2;
-
- if (enableRootstrap) {
- http_proxy = PreferencesManager.getHttpProxyURL();
- RPMPackageCommander.setHttpProxy(http_proxy);
- }
- if (enableTarget) {
- device = ConnectionPlugin.getDefault().getCurrentDevice();
- }
- }
-
+public class RPMPackageDialog extends Dialog {
+
+ private TabFolder tabFolder;
+ private PkgCommandTarget target = null;
+ private boolean enableRootstrapTab = false;
+ private boolean enableTargetTab = false;
+ private int tabIndex = 0;
+
+ private int x = 0;
+ private int y = 0;
+ private final int width = 900;
+ private final int height = 900;
- private void setImage(Shell parentShell) {
- Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
- try {
- parentShell.setImage(new Image(Display.getCurrent(), FileLocator.toFileURL(bundle.getEntry("icons/package_installer.gif")).getPath()));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
-
- protected void setShellStyle(int newShellStyle) {
- int newStyle = newShellStyle;// & ~SWT.APPLICATION_MODAL;
- //newStyle |= SWT.MODELESS;
- super.setShellStyle(newStyle);
- }
+ private final String BUNDLE_NAME = RPMPackageDialog.class.getPackage().getName()
+ + ".PkgMgrUIMessages";//$NON-NLS-1$
+ private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
-
- @Override
- public boolean close()
- {
- RemotePkgProvider.INSTANCE.clear();
- LocalPkgProvider.INSTANCE.clear();
- PackageProvider.INSTANCE.clear();
- return super.close();
- }
-
- protected void createButtonsForButtonBar(Composite parent)
- {
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, true);
- }
-
-
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(resources.getString("PkgMgr.Title"));
-
- if (!enableRootstrapTab && !enableTargetTab) {
- newShell.setLocation(x, y);
- newShell.setSize(width/2, height/4);
- setImage(newShell);
- } else {
- newShell.setLocation(x, y);
- newShell.setSize(width, height);
- setImage(newShell);
- }
- }
-
-
- @Override
- protected Control createDialogArea(Composite parent) {
-
- Composite container = new Composite( parent, SWT.None );
- container.setLayoutData(new GridData(GridData.FILL_BOTH));
- container.setLayout(new GridLayout(1, false));
+ public RPMPackageDialog(Shell parentShell, PkgCommandTarget target) {
+ super(parentShell);
+ this.target = target;
+ if (target.isSetDevice()) {
+ this.enableTargetTab = true;
+ }
+ if (target.isSetRootstrap()) {
+ this.enableRootstrapTab = true;
+ }
- if (!enableRootstrapTab && !enableTargetTab) {
- createError( container, resources.getString("PkgMgr.Error.Noselected"));
- } else {
- createDialogDescription ( container );
- createTabs ( container );
- }
- return null;
- }
-
-
- private void createError( Composite parent, String message )
- {
- Composite com = new Composite( parent, SWT.NONE );
- com.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
- com.setLayout(new GridLayout(1, false));
-
- Label errorLabel = new Label(com, SWT.NONE);
- errorLabel.setText(message);
- }
-
-
- private void createDialogDescription(Composite composite)
- {
+ Rectangle bounds = parentShell.getBounds();
+ x = bounds.x + (bounds.width - width) / 2;
+ y = bounds.y + (bounds.height - height) / 2;
+ }
+
+ private void setImage(Shell parentShell) {
+ Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
+ try {
+ parentShell.setImage(new Image(Display.getCurrent(), FileLocator.toFileURL(
+ bundle.getEntry("icons/package_installer.gif")).getPath()));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ protected void setShellStyle(int newShellStyle) {
+ int newStyle = newShellStyle;// & ~SWT.APPLICATION_MODAL;
+ newStyle |= SWT.MODELESS;
+ super.setShellStyle(newStyle);
+ }
+
+ @Override
+ public boolean close() {
+ RemotePkgProvider.INSTANCE.clear();
+ LocalPkgProvider.INSTANCE.clear();
+ PackageProvider.INSTANCE.clear();
+ return super.close();
+ }
+
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, true);
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(resources.getString("PkgMgr.Title"));
+
+ if (!enableRootstrapTab && !enableTargetTab) {
+ newShell.setLocation(x, y);
+ newShell.setSize(width / 2, height / 4);
+ setImage(newShell);
+ } else {
+ newShell.setLocation(x, y);
+ newShell.setSize(width, height);
+ setImage(newShell);
+ }
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+
+ Composite container = new Composite(parent, SWT.None);
+ container.setLayoutData(new GridData(GridData.FILL_BOTH));
+ container.setLayout(new GridLayout(1, false));
+
+ if (!enableRootstrapTab && !enableTargetTab) {
+ createError(container, resources.getString("PkgMgr.Error.Noselected"));
+ } else {
+ createDialogDescription(container);
+ createTabs(container);
+ }
+ return null;
+ }
+
+ private void createError(Composite parent, String message) {
+ Composite com = new Composite(parent, SWT.NONE);
+ com.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ com.setLayout(new GridLayout(1, false));
+
+ Label errorLabel = new Label(com, SWT.NONE);
+ errorLabel.setText(message);
+ }
+
+ private void createDialogDescription(Composite composite) {
Composite comp_descrip = new Composite(composite, SWT.NONE);
Color whiteColor = new Color(composite.getDisplay(), 255, 255, 255);
label.setBackground(whiteColor);
}
-
- private void createTabs( Composite parent )
- {
- tabFolder = new TabFolder( parent, SWT.BORDER );
- tabFolder.setLayoutData(new GridData( GridData.FILL_BOTH));
- tabFolder.setLayout(new GridLayout(1, false));
-
- if (enableRootstrapTab) {
- BuildSystemTab tab = new BuildSystemTab(getShell(), tabFolder, rootstrap);
- tab.createTab();
- }
- if (enableTargetTab) {
- DeviceTab tab = new DeviceTab(getShell(), tabFolder, device);
- tab.createTab();
- }
-
- tabFolder.setSelection(tabIndex);
- }
-
-
- public void initializeDialogData(IProgressMonitor monitor) throws InterruptedException {
-
- int totalworks = 2;
- if (device != null) {
- totalworks = 4;
- }
-
- monitor.beginTask(resources.getString("Action.Msg.Progress.Initializing.PkgMgr"), totalworks);
-
- // init data for buildSystem Tab
- monitor.subTask(resources.getString("Action.Msg.Progress.Init.BuildSystem.Repo"));
- BuildSystemTab.initializeRepositoryInfo(rootstrap);
- monitor.worked(1);
- monitor.subTask(resources.getString("Action.Msg.Progress.Init.BuildSystem.Pkgs"));
- BuildSystemTab.initializePackageInfo(rootstrap, monitor);
- monitor.worked(2);
+ private void createTabs(Composite parent) {
+ tabFolder = new TabFolder(parent, SWT.BORDER);
+ tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
+ tabFolder.setLayout(new GridLayout(1, false));
+ if (enableRootstrapTab) {
+ BuildsystemTab tab = new BuildsystemTab(getShell(), tabFolder, target);
+ tab.createTab();
+ }
+ if (enableTargetTab) {
+ DeviceTab tab = new DeviceTab(getShell(), tabFolder, target);
+ tab.createTab();
+ }
+ tabFolder.setSelection(tabIndex);
+ }
- // init data for device Tab if connected
- if ( device != null ) {
- monitor.subTask(resources.getString("Action.Msg.Progress.Init.Device.Repo"));
- DeviceTab.initializeRepositoryInfo(device);
- monitor.worked(3);
- monitor.subTask(resources.getString("Action.Msg.Progress.Init.Device.Pkgs"));
- DeviceTab.initializePackageInfo(device);
- monitor.worked(4);
- }
-
- monitor.done();
- }
+ /*
+ * public void initializeDialogData(IProgressMonitor monitor) throws
+ * InterruptedException {
+ *
+ * int totalworks = 2; if (device != null) { totalworks = 4; }
+ *
+ * monitor.beginTask(resources.getString(
+ * "Action.Msg.Progress.Initializing.PkgMgr"), totalworks);
+ *
+ * // init data for buildSystem Tab monitor.subTask(resources.getString(
+ * "Action.Msg.Progress.Init.BuildSystem.Repo"));
+ * //BuildSystemTab.initializeRepositoryInfo(rootstrap);
+ * TestTab.initializeRepositoryInfo(rootstrap); monitor.worked(1);
+ * monitor.subTask
+ * (resources.getString("Action.Msg.Progress.Init.BuildSystem.Pkgs"));
+ * //BuildSystemTab.initializePackageInfo(rootstrap, monitor);
+ * TestTab.initializePackageInfo(monitor); monitor.worked(2);
+ *
+ * // init data for device Tab if connected if ( device != null ) {
+ * monitor.subTask
+ * (resources.getString("Action.Msg.Progress.Init.Device.Repo"));
+ * DeviceTab.initializeRepositoryInfo(device); monitor.worked(3);
+ * monitor.subTask
+ * (resources.getString("Action.Msg.Progress.Init.Device.Pkgs"));
+ * DeviceTab.initializePackageInfo(device); monitor.worked(4); }
+ *
+ * monitor.done(); }
+ */
}
\ No newline at end of file
import org.eclipse.core.runtime.IPath;
import org.tizen.nativecommon.build.SmartBuildInterface;
-import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
import org.tizen.nativeplatform.pkgmgr.model.Repository;
import org.tizen.nativeplatform.pkgmgr.model.RepositoryProvider;
import org.tizen.nativeplatform.views.model.PlatformRootstrap;
public class RepoManager {
- public static String REMOTE_REPO_TYPE = "remote";
- public static String LOCAL_REPO_TYPE = "local";
-
- public static IRepoValidator getValidator(IPath path) {
- return new LocalRepoValidator(path);
- }
-
- public static IRepoValidator getValidator(String url) {
- if (isLocalUrl(url)) {
- return new LocalRepoValidator(url);
- } else {
- return new RemoteRepoValidator(url);
- }
- }
-
- public static boolean isRemoteUrl(String url) {
- return !isLocalUrl(url);
- }
-
- public static boolean isLocalUrl(String url) {
- if (url.startsWith("/") ||
- url.startsWith("file:/") ||
- url.startsWith("file://") ||
- url.startsWith("dir:/") ||
- url.startsWith("dir://")) {
- return true;
- } else {
- return false;
- }
- }
-
- public static String getURLType(String url) {
- if (isLocalUrl(url)) {
- return RepoManager.LOCAL_REPO_TYPE;
- } else {
- return RepoManager.REMOTE_REPO_TYPE;
- }
- }
-
- public static boolean isLocalType(String type) {
- boolean result = (LOCAL_REPO_TYPE.equals(type.trim())) ? true : false;
- return result;
- }
-
- public static boolean isRemoteType(String type) {
- boolean result = (REMOTE_REPO_TYPE.equals(type.trim())) ? true : false;
- return result;
- }
-
- public static HashMap<String, String> createRepeHashMap(ArrayList<String> repos) {
- HashMap<String, String> map = new HashMap<String, String>();
- for (String repo : repos) {
- repo = repo.trim();
- if (isLocalUrl(repo)) {
- map.put(repo, RepoManager.LOCAL_REPO_TYPE);
- } else {
- map.put(repo, RepoManager.REMOTE_REPO_TYPE);
- }
- }
-
- return map;
- }
-
-
- // Add repositories to rootstrap after cleaning
- public static void resetReposToRootstrap(PlatformRootstrap rootstrap) {
- String rootstrapPath = SmartBuildInterface.getInstance().
- getPlatformRootstrapPath(rootstrap.getPath().toOSString());
-
- RepositoryProvider.INSTANCE.getBuildsystemRepos().clear();
- LocalRepoMounter.clearMounted(null);
- // TODO: error handling for clearMounted
- RPMPackageCommander.resetRepositoryForRootstrap(rootstrapPath);
- addReposToRootstrap(rootstrap);
- }
-
- // Add repositories to rootstrap
- public static void addReposToRootstrap(PlatformRootstrap rootstrap) {
- String rootstrapPath = SmartBuildInterface.getInstance().
- getPlatformRootstrapPath(rootstrap.getPath().toOSString());
-
- HashMap<String, String> reposMap = rootstrap.getRepoMap();
- Iterator<String> keySet = reposMap.keySet().iterator();
-
- int idx = 0;
- while(keySet.hasNext()) {
- String url = keySet.next();
- String type = reposMap.get(url);
- String name = String.format("url%d", idx++);
- if (RepoManager.isLocalType(type) && RepoManager.isLocalUrl(url)) {
- IPath repoPath = LocalRepoMounter.mountLocalRepository(rootstrapPath, url, null);
- if (repoPath != null) {
- RepositoryProvider.INSTANCE.getBuildsystemRepos().add(new Repository(name, url ));
- RPMPackageCommander.addLocalRepositoryForRootstrap(name, repoPath.toOSString(),
- rootstrapPath);
- }
- } else {
- RepositoryProvider.INSTANCE.getBuildsystemRepos().add(new Repository(name, url ));
- RPMPackageCommander.addRepositoryForRootstrap(name, url, rootstrapPath);
- }
- }
- }
-
+ public static String REMOTE_REPO_TYPE = "remote";
+ public static String LOCAL_REPO_TYPE = "local";
+
+ public static IRepoValidator getValidator(IPath path) {
+ return new LocalRepoValidator(path);
+ }
+
+ public static IRepoValidator getValidator(String url) {
+ if (isLocalUrl(url)) {
+ return new LocalRepoValidator(url);
+ } else {
+ return new RemoteRepoValidator(url);
+ }
+ }
+
+ public static boolean isRemoteUrl(String url) {
+ return !isLocalUrl(url);
+ }
+
+ public static boolean isLocalUrl(String url) {
+ if (url.startsWith("/") || url.startsWith("file:/") || url.startsWith("file://")
+ || url.startsWith("dir:/") || url.startsWith("dir://")) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public static String getURLType(String url) {
+ if (isLocalUrl(url)) {
+ return RepoManager.LOCAL_REPO_TYPE;
+ } else {
+ return RepoManager.REMOTE_REPO_TYPE;
+ }
+ }
+
+ public static boolean isLocalType(String type) {
+ boolean result = (LOCAL_REPO_TYPE.equals(type.trim())) ? true : false;
+ return result;
+ }
+
+ public static boolean isRemoteType(String type) {
+ boolean result = (REMOTE_REPO_TYPE.equals(type.trim())) ? true : false;
+ return result;
+ }
+
+ public static HashMap<String, String> createRepeHashMap(ArrayList<String> repos) {
+ HashMap<String, String> map = new HashMap<String, String>();
+ for (String repo : repos) {
+ repo = repo.trim();
+ if (isLocalUrl(repo)) {
+ map.put(repo, RepoManager.LOCAL_REPO_TYPE);
+ } else {
+ map.put(repo, RepoManager.REMOTE_REPO_TYPE);
+ }
+ }
+
+ return map;
+ }
+
+ public static void addReposToRootstrap(PkgCommandTarget target) {
+ PlatformRootstrap rootstrap = target.getRootstrap();
+ String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(
+ rootstrap.getPath().toOSString());
+
+ HashMap<String, String> reposMap = rootstrap.getRepoMap();
+ Iterator<String> keySet = reposMap.keySet().iterator();
+
+ int idx = 0;
+ while (keySet.hasNext()) {
+ String url = keySet.next();
+ String type = reposMap.get(url);
+ String name = String.format("url%d", idx++);
+ if (RepoManager.isLocalType(type) && RepoManager.isLocalUrl(url)) {
+ IPath repoPath = LocalRepoMounter.mountLocalRepository(rootstrapPath, url, null);
+ if (repoPath != null) {
+ RepositoryProvider.INSTANCE.getBuildsystemRepos()
+ .add(new Repository(name, url));
+ target.getRootstrapCommander().addLocalRepo(name, repoPath.toOSString());
+ }
+ } else {
+ RepositoryProvider.INSTANCE.getBuildsystemRepos().add(new Repository(name, url));
+ target.getRootstrapCommander().addRepo(name, url);
+ }
+ }
+ }
+
}
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
-import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.tizen.common.core.application.InstallPathConfig;
import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativecommon.build.exception.SBIException;
import org.tizen.nativecommon.build.model.Rootstrap;
import org.tizen.nativecommon.build.model.SBIModel;
import org.tizen.nativecommon.build.model.Target;
-import org.tizen.nativecommon.templateengine.build.Messages;
import org.tizen.nativeplatform.build.PlatformConfigurationManager;
-import org.tizen.nativeplatform.filefilter.RpmFileFilter;
-import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander;
-import org.tizen.nativeplatform.pkgmgr.model.Repository;
-import org.tizen.nativeplatform.pkgmgr.model.RepositoryProvider;
import org.tizen.nativeplatform.preferences.PreferencesManager;
import org.tizen.nativeplatform.repository.RepoManager;
import org.tizen.nativeplatform.util.CommandLauncher;
+import org.tizen.nativeplatform.util.InstallerUtil;
import org.tizen.nativeplatform.views.model.PlatformRootstrap;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class RootstrapManager {
-
- private static ArrayList<PlatformRootstrap> rootstraps = new ArrayList<PlatformRootstrap>();
- private static PlatformRootstrap selectedRootstrap;
- public static Set<IRootstrapChangedListener> changedListener = new HashSet<IRootstrapChangedListener>();
-
- private static boolean init;
- private static final String URL_SEP = "|";
- private static final String URL_SEP_REGEXP = "[|]";
- private static final String USER_ROOSTRAP_BASE_DIR_NAME = "user-rootstraps";
-
- private RootstrapManager() {
- }
-
- private synchronized static void initialize() {
-
- SmartBuildInterface sbi = SmartBuildInterface.getInstance();
- try {
- ArrayList<String> lists = sbi.getRootstrapList();
- for (String id : lists) {
- String type = sbi.getSupportToolchainTypeFromRootstrapID(id);
- if (!type.equals(PlatformRootstrap.SUPPORTED_TOOLCHAIN_TYPE)) {
- continue;
- }
-
- String rootName = sbi.getRootstrapNameFromRootstrapID(id);
- String arch = sbi.getArchitectureFromRootstrapID(id);
- String path = sbi.getRootstrapPathFromRootstrapID(id);
- HashMap<String, String> reposURLs = new HashMap<String, String>();
- String rootstrapPath = sbi.getRootstrapPropertyValue(id, PlatformRootstrap.PROPERTY_REPO_URLS);
- String confFile = sbi.getRootstrapPropertyValue(id, PlatformRootstrap.PROPERTY_CONFIGURATION_FILE);
- if ( rootstrapPath != null && rootstrapPath.split(URL_SEP_REGEXP).length >= 1 ) {
- for ( String url : rootstrapPath.split(URL_SEP_REGEXP) ) {
- if (RepoManager.isLocalUrl(url)) {
- reposURLs.put(url, RepoManager.LOCAL_REPO_TYPE);
- } else {
- reposURLs.put(url, RepoManager.REMOTE_REPO_TYPE);
- }
- }
- }
- boolean initialized = new File(path).exists() ? true : false;
- addRootstrap( new PlatformRootstrap(id, rootName, arch, path,
- reposURLs, confFile, initialized) );
- }
- } catch (SBIException e) {
- e.printStackTrace();
- }
-
- init = true;
- }
-
-
- public static PlatformRootstrap addRootstrap(PlatformRootstrap rootstrap ) {
- rootstraps.add(rootstrap);
- //SBIModel.addRootstrap(rootstrap, false);
- try {
- SBIModel.reinitialize();
- } catch (SBIException e) {
- // nothing to do
- e.printStackTrace();
- }
- RootstrapManager.notifyChangedRootstrap();
-
- return rootstrap;
- }
-
-
- public static void modifyRootstrap(PlatformRootstrap rootstrap) {
- generateSBIPluginXML(rootstrap.getId(), rootstrap.getName(),
- rootstrap.getArch(), rootstrap.getPath().toOSString(),
- rootstrap.getJustRepoURLs(), rootstrap.getConfFile());
- try {
- SBIModel.reinitialize();
- reinitialize();
- } catch (SBIException e) {
- // nothing to do
- e.printStackTrace();
- }
- RootstrapManager.notifyChangedRootstrap();
- }
-
-
- public static boolean removeRootstrap(String id) {
- PlatformRootstrap rootstrap = getRootstrap( id );
-
- if ( rootstrap != null ) {
- rootstraps.remove( rootstrap );
- removeSBIPluginXML( rootstrap );
- try {
- removeBaseFileSystem( rootstrap.getId() , rootstrap.getArch());
- } catch (InterruptedException e) {
- // nothing to do
- e.printStackTrace();
- }
- try {
- SBIModel.reinitialize();
- } catch (SBIException e) {
- // nothing to do
- e.printStackTrace();
- }
- RootstrapManager.notifyChangedRootstrap();
- return true;
- }
- else {
- return false;
- }
- }
-
-
- public static boolean exportRootstrap(
- PlatformRootstrap rootstrap, String exportFilePath,
- IProgressMonitor monitor) throws InterruptedException {
-
- // make temp directory
- String tempDirPath = makeTempDirectory();
-
- try {
- // zip file-system
- String basePath = rootstrap.getPath().removeLastSegments(1).toOSString();
- File dir = new File(rootstrap.getPath().append("local").toOSString());
- String scratchName = "";
- String list[] = dir.list();
- for (String s : list) {
- if (s.startsWith("scratch.")) {
- scratchName = s;
- }
- }
-
- String rootstrapID = rootstrap.getId();
-
- if( !CommandLauncher.execute( String.format("tar cvzf %s/rootstrap1.tar.gz %s --exclude=local/%s",
- tempDirPath, rootstrapID, scratchName), basePath, "Platform Internal", monitor ) ) {
- return false;
- }
-
- if( !CommandLauncher.executeSudo( String.format("sudo -S tar cvzf %s/rootstrap2.tar.gz %s/local/%s --exclude=home/abuild --exclude=etc/passwd",
- tempDirPath, rootstrapID, scratchName), basePath, "Platform Internal", monitor ) ) {
- return false;
- }
-
- // copy xml
- String pluginFileName = rootstrap.getId() + ".xml";
- String pluginPath = new Path(SmartBuildInterface.getInstance().getPluginPath())
- .append(pluginFileName).toOSString();
- if ( !CommandLauncher.execute( String.format("cp %s %s/", pluginPath, tempDirPath )) ) {
- return false;
- }
-
- // zip them together
- if ( !CommandLauncher.execute( String.format("tar cvf %s rootstrap1.tar.gz rootstrap2.tar.gz %s",
- exportFilePath, pluginFileName), tempDirPath, "Platform Internal", monitor ) ) {
- return false;
- }
-
- return true;
- }
- finally {
- // remove temporary directory
- CommandLauncher.executeSudo( String.format("sudo -S rm -rf %s",tempDirPath) );
- }
- }
-
-
- public static PlatformRootstrap importRootstrap( String importFilePath,
- IProgressMonitor monitor) throws InterruptedException {
-
- PlatformRootstrap result = null;
- String pluginPath = null;
- String rootstrapPath = null;
-
- // make temp directory
- String tempDirPath = makeTempDirectory();
-
- try {
- // extract "tar" archive
- if( !CommandLauncher.execute( String.format("tar xvf %s",
- importFilePath), tempDirPath, "Platform Internal", monitor ) ) {
- cleanUpRootstrap(pluginPath, rootstrapPath);
- throw new InterruptedException("Extracting rootsrap failed!");
- }
-
- // find rootstrap id
- File tempDir = new File(tempDirPath);
- File[] xmlFiles = tempDir.listFiles( new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- if( name.endsWith(".xml") ) {
- return true;
- }
- else {
- return false;
- }
- }
-
- } );
- if ( xmlFiles.length == 0 ) {
- cleanUpRootstrap(pluginPath, rootstrapPath);
- throw new InterruptedException("There is no SBI plugin file(*.xml)");
- }
- String pluginFilePath = xmlFiles[0].getPath().toString();
- String pluginFileName = new File(pluginFilePath).getName();
- String pluginId = pluginFileName.split("\\.xml")[0];
-
- // check already exist?
- if( RootstrapManager.getRootstrap(pluginId) != null ) {
- cleanUpRootstrap(pluginPath, rootstrapPath);
- throw new InterruptedException("There already exists the rootrap with same id!");
- }
-
- // copy xml
- pluginPath = new Path(SmartBuildInterface.getInstance().getPluginPath())
- .append(pluginFileName).toOSString();
- CommandLauncher.execute( String.format("cp %s %s", pluginFilePath, pluginPath));
-
- // reload
- try {
- SBIModel.reinitialize();
- } catch (SBIException e) {
- cleanUpRootstrap(pluginPath, rootstrapPath);
- throw new InterruptedException("SBIModel initialization failed!");
- }
- result = createRootstrapFromSBIPlugin( pluginId );
- if ( result == null ) {
- cleanUpRootstrap(pluginPath, rootstrapPath);
- throw new InterruptedException("Loading SBI plugin failed!");
- }
-
- // extracting file system
- rootstrapPath = result.getPath().toOSString();
- File baseDirDir = new File(rootstrapPath).getParentFile();
- if ( !baseDirDir.exists() ) {
- baseDirDir.mkdir();
- }
- else if ( new File(rootstrapPath).exists() ) {
- CommandLauncher.executeSudo( String.format("sudo -S rm -rf %s", rootstrapPath), null );
- }
-
- if ( !CommandLauncher.execute( String.format("tar xvf %s/rootstrap1.tar.gz",
- tempDirPath), baseDirDir.getPath(), "Platform Internal", monitor ) ) {
- cleanUpRootstrap(pluginPath, rootstrapPath);
- throw new InterruptedException("Extracting rootsrap failed!");
- }
-
- if ( !CommandLauncher.executeSudo( String.format("sudo -S tar xvf %s/rootstrap2.tar.gz",
- tempDirPath), baseDirDir.getPath(), "Platform Internal", monitor ) ) {
- cleanUpRootstrap(pluginPath, rootstrapPath);
- throw new InterruptedException("Extracting rootsrap failed!");
- }
-
- return result;
- }
- finally {
- // remove temporary directory
- CommandLauncher.executeSudo( String.format("sudo -S rm -rf %s",tempDirPath), null );
- }
- }
-
- private static void cleanUpRootstrap(String pluginPath, String rootstrapPath)
- throws InterruptedException{
- if ( pluginPath != null ) {
- CommandLauncher.execute( String.format("rm -rf %s", pluginPath) );
+
+ private static List<PlatformRootstrap> rootstraps = new ArrayList<PlatformRootstrap>();
+ private static PlatformRootstrap selectedRootstrap;
+ public static Set<IRootstrapChangedListener> changedListener = new HashSet<IRootstrapChangedListener>();
+
+ private static boolean init;
+ private static final String URL_SEP = "|";
+ private static final String URL_SEP_REGEXP = "[|]";
+ private static final String USER_ROOSTRAP_BASE_DIR_NAME = "user-rootstraps";
+
+ protected static final Logger logger = LoggerFactory.getLogger(RootstrapManager.class);
+
+ private RootstrapManager() {
+ }
+
+ private synchronized static void initialize() {
+
+ SmartBuildInterface sbi = SmartBuildInterface.getInstance();
+ try {
+ ArrayList<String> lists = sbi.getRootstrapList();
+ for (String id : lists) {
+ String type = sbi.getSupportToolchainTypeFromRootstrapID(id);
+ if (!type.equals(PlatformRootstrap.SUPPORTED_TOOLCHAIN_TYPE)) {
+ continue;
+ }
+
+ String rootName = sbi.getRootstrapNameFromRootstrapID(id);
+ String arch = sbi.getArchitectureFromRootstrapID(id);
+ String path = sbi.getRootstrapPathFromRootstrapID(id);
+ boolean isDefault = sbi.getIsDefaultFromRootstrapID(id);
+ HashMap<String, String> reposURLs = new HashMap<String, String>();
+ String rootstrapPath = sbi.getRootstrapPropertyValue(id,
+ PlatformRootstrap.PROPERTY_REPO_URLS);
+ String confFile = sbi.getRootstrapPropertyValue(id,
+ PlatformRootstrap.PROPERTY_CONFIGURATION_FILE);
+ if (rootstrapPath != null && rootstrapPath.split(URL_SEP_REGEXP).length >= 1) {
+ for (String url : rootstrapPath.split(URL_SEP_REGEXP)) {
+ if (RepoManager.isLocalUrl(url)) {
+ reposURLs.put(url, RepoManager.LOCAL_REPO_TYPE);
+ } else {
+ reposURLs.put(url, RepoManager.REMOTE_REPO_TYPE);
+ }
+ }
+ }
+ boolean initialized = new File(path).exists() ? true : false;
+ addRootstrap(new PlatformRootstrap(id, rootName, arch, path, reposURLs, confFile,
+ initialized, isDefault));
+ }
+ } catch (SBIException e) {
+ logger.error("Failed to initialize rootstraps", e);
+ e.printStackTrace();
+ }
+
+ init = true;
+ }
+
+ public static PlatformRootstrap addRootstrap(PlatformRootstrap rootstrap) {
+ rootstraps.add(rootstrap);
+ SBIModel.addRootstrap(rootstrap, true);
+ RootstrapManager.notifyChangedRootstrap();
+ return rootstrap;
+ }
+
+ public static boolean removeRootstrap(String id) {
+ PlatformRootstrap rootstrap = getRootstrap(id);
+ if (rootstrap != null) {
+ try {
+ removeBaseFileSystem(rootstrap.getId(), rootstrap.getArch());
+ } catch (InterruptedException e) {
+ logger.error(String.format("Failed to rootstrap: [%s]", id), e);
+ e.printStackTrace();
+ return false;
+ }
+ rootstraps.remove(rootstrap);
+ removeSBIPluginXML(rootstrap);
+ SBIModel.removeRootstrap(rootstrap);
+ RootstrapManager.notifyChangedRootstrap();
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public static boolean exportRootstrap(PlatformRootstrap rootstrap, String exportFilePath,
+ IProgressMonitor monitor) throws InterruptedException {
+
+ // make temp directory
+ String tempDirPath = makeTempDirectory();
+
+ try {
+ // rootstrapPath = /home/sdk/tizen-sdk-data/user-rootstraps/latest
+ // workingPath = /home/sdk/tizen-sdk-data/user-rootstraps/
+ // chrootPath =
+ // /home/sdk/tizen-sdk-data/user-rootstraps/latest/local/BUILD-ROOTS/scratch.i586.0
+ String rootstrapPath = rootstrap.getPath().toOSString();
+ String workingPath = rootstrap.getPath().removeLastSegments(1).toOSString();
+ SmartBuildInterface sbi = SmartBuildInterface.getInstance();
+ String chrootPath = sbi.getPlatformRootstrapPath(rootstrapPath);
+ if (chrootPath == null || chrootPath.isEmpty()) {
+ return false;
+ }
+ String scratchName = new Path(chrootPath).lastSegment();
+ if (!scratchName.startsWith("scratch.")) {
+ return false;
+ }
+ String rootstrapID = rootstrap.getId();
+ if (!CommandLauncher.execute(String.format(
+ "tar cvzf %s/rootstrap1.tar.gz %s --exclude=local/BUILD-ROOTS/%s", tempDirPath,
+ rootstrapID, scratchName), workingPath, "Platform Internal", monitor)) {
+ return false;
+ }
+
+ if (!CommandLauncher
+ .executeSudo(
+ String.format(
+ "sudo -S tar cvzf %s/rootstrap2.tar.gz %s/local/BUILD-ROOTS/%s --exclude=home/abuild --exclude=etc/passwd",
+ tempDirPath, rootstrapID, scratchName), workingPath,
+ "Platform Internal", monitor)) {
+ return false;
+ }
+
+ // copy xml
+ String pluginFileName = rootstrap.getId() + ".xml";
+ String pluginPath = new Path(SmartBuildInterface.getInstance().getPluginPath()).append(
+ pluginFileName).toOSString();
+ if (!CommandLauncher.execute(String.format("cp %s %s/", pluginPath, tempDirPath))) {
+ return false;
+ }
+
+ // zip them together
+ if (!CommandLauncher.execute(String.format(
+ "tar cvf %s rootstrap1.tar.gz rootstrap2.tar.gz %s", exportFilePath,
+ pluginFileName), tempDirPath, "Platform Internal", monitor)) {
+ return false;
+ }
+
+ return true;
+ } finally {
+ // remove temporary directory
+ CommandLauncher.executeSudo(String.format("sudo -S rm -rf %s", tempDirPath));
+ }
+ }
+
+ public static PlatformRootstrap importRootstrap(String importFilePath, IProgressMonitor monitor)
+ throws InterruptedException {
+
+ PlatformRootstrap result = null;
+ String pluginPath = null;
+ String rootstrapPath = null;
+
+ // make temp directory
+ String tempDirPath = makeTempDirectory();
+
+ try {
+ // extract "tar" archive
+ if (!CommandLauncher.execute(String.format("tar xvf %s", importFilePath), tempDirPath,
+ "Platform Internal", monitor)) {
+ cleanUpRootstrap(pluginPath, rootstrapPath);
+ throw new InterruptedException("Extracting rootsrap failed!");
+ }
+
+ // find rootstrap id
+ File tempDir = new File(tempDirPath);
+ File[] xmlFiles = tempDir.listFiles(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ if (name.endsWith(".xml")) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ });
+ if (xmlFiles.length == 0) {
+ cleanUpRootstrap(pluginPath, rootstrapPath);
+ throw new InterruptedException("There is no SBI plugin file(*.xml)");
+ }
+ String pluginFilePath = xmlFiles[0].getPath().toString();
+ String pluginFileName = new File(pluginFilePath).getName();
+ String pluginId = pluginFileName.split("\\.xml")[0];
+
+ // check already exist?
+ if (RootstrapManager.getRootstrap(pluginId) != null) {
+ cleanUpRootstrap(pluginPath, rootstrapPath);
+ throw new InterruptedException("There already exists the rootrap with same id!");
+ }
+
+ // copy xml
+ pluginPath = new Path(SmartBuildInterface.getInstance().getPluginPath()).append(
+ pluginFileName).toOSString();
+ CommandLauncher.execute(String.format("cp %s %s", pluginFilePath, pluginPath));
+
+ // reload
+ try {
+ SBIModel.reinitialize();
+ } catch (SBIException e) {
+ cleanUpRootstrap(pluginPath, rootstrapPath);
+ throw new InterruptedException("SBIModel initialization failed!");
+ }
+ result = createRootstrapFromSBIPlugin(pluginId);
+ if (result == null) {
+ cleanUpRootstrap(pluginPath, rootstrapPath);
+ throw new InterruptedException("Loading SBI plugin failed!");
+ }
+
+ // extracting file system
+ rootstrapPath = result.getPath().toOSString();
+ File baseDirDir = new File(rootstrapPath).getParentFile();
+ if (!baseDirDir.exists()) {
+ baseDirDir.mkdir();
+ } else if (new File(rootstrapPath).exists()) {
+ CommandLauncher
+ .executeSudo(String.format("sudo -S rm -rf %s", rootstrapPath), null);
+ }
+
+ if (!CommandLauncher.execute(
+ String.format("tar xvf %s/rootstrap1.tar.gz", tempDirPath),
+ baseDirDir.getPath(), "Platform Internal", monitor)) {
+ cleanUpRootstrap(pluginPath, rootstrapPath);
+ throw new InterruptedException("Extracting rootsrap failed!");
+ }
+
+ if (!CommandLauncher.executeSudo(
+ String.format("sudo -S tar xvf %s/rootstrap2.tar.gz", tempDirPath),
+ baseDirDir.getPath(), "Platform Internal", monitor)) {
+ cleanUpRootstrap(pluginPath, rootstrapPath);
+ throw new InterruptedException("Extracting rootsrap failed!");
+ }
+
+ return result;
+ } finally {
+ // remove temporary directory
+ CommandLauncher.executeSudo(String.format("sudo -S rm -rf %s", tempDirPath), null);
+ }
+ }
+
+ private static void cleanUpRootstrap(String pluginPath, String rootstrapPath)
+ throws InterruptedException {
+ if (pluginPath != null) {
+ CommandLauncher.execute(String.format("rm -rf %s", pluginPath));
try {
SBIModel.reinitialize();
} catch (SBIException e1) {
throw new InterruptedException(e1.getMessage());
}
}
- if ( rootstrapPath != null ) {
- CommandLauncher.executeSudo( String.format("sudo -S rm -rf %s", rootstrapPath), null );
+ if (rootstrapPath != null) {
+ CommandLauncher.executeSudo(String.format("sudo -S rm -rf %s", rootstrapPath), null);
+ }
+ }
+
+ private static String makeTempDirectory() {
+ final File temp;
+
+ try {
+ temp = File.createTempFile("temp", Long.toString(System.nanoTime()));
+ if (!(temp.delete())) {
+ throw new IOException("Could not delete temp file: " + temp.getAbsolutePath());
+ }
+
+ if (!(temp.mkdir())) {
+ throw new IOException("Could not create temp directory: " + temp.getAbsolutePath());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ return temp.getPath();
+ }
+
+ public static List<PlatformRootstrap> getRootstraps() {
+ checkInit();
+ return rootstraps;
+ }
+
+ public static PlatformRootstrap getRootstrap(String id) {
+ checkInit();
+ for (PlatformRootstrap r : rootstraps) {
+ if (r.getId().equals(id)) {
+ return r;
+ }
+ }
+ return null;
+ }
+
+ public static PlatformRootstrap getDefaultRootstrap(String arch) {
+ return findDefaultRootstrap(arch);
+ }
+
+ public static PlatformRootstrap findDefaultRootstrap(String arch) {
+ for (PlatformRootstrap r : rootstraps) {
+ if (r.getArch().equals(arch) && r.isDefault()) {
+ return r;
+ }
+ }
+ return null;
+ }
+
+ public static void reinitialize() {
+ init = false;
+ rootstraps.clear();
+ initialize();
+ }
+
+ public static void updateRootstrap(PlatformRootstrap rootstrap) {
+ if (rootstrap != null) {
+ try {
+ generateSBIPluginXML(rootstrap.getId(), rootstrap.getName(), rootstrap.getArch(),
+ rootstrap.getPath().toOSString(), rootstrap.getJustRepoURLs(),
+ rootstrap.getConfFile());
+ SBIModel.updateRootstrap(rootstrap);
+ RootstrapManager.notifyChangedRootstrap();
+ } catch (SBIException e) {
+ logger.error(String.format("Failed to update rootstrap: [%s]", rootstrap.getId()),
+ e);
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static void setSelectedRootstrap(PlatformRootstrap selected) {
+ for (PlatformRootstrap r : rootstraps) {
+ if (r.isChecked()) {
+ r.setChecked(false);
+ }
+ }
+ selected.setChecked(true);
+ selectedRootstrap = selected;
+ }
+
+ public static void setSelectedRootstrap(String id) {
+ for (PlatformRootstrap r : RootstrapManager.getRootstraps()) {
+ if (id.equals(r.getId())) {
+ setSelectedRootstrap(r);
+ break;
+ }
+ }
+ }
+
+ public static void resetSelectedRootstrap() {
+ for (PlatformRootstrap r : rootstraps) {
+ if (r.isChecked()) {
+ r.setChecked(false);
+ }
+ }
+ }
+
+ public static boolean isInitialized(String rootId) {
+ PlatformRootstrap root = getRootstrap(rootId);
+ if (root != null) {
+ return root.isInitialized();
+ } else {
+ return false;
+ }
+ }
+
+ public static boolean checkInitialized(String rootId) {
+ PlatformRootstrap root = getRootstrap(rootId);
+ return root.checkInitialized();
+ }
+
+ public static PlatformRootstrap getSelectedRootstrap() {
+ return selectedRootstrap;
+ }
+
+ public static synchronized void addListener(IRootstrapChangedListener listener) {
+ changedListener.add(listener);
+ }
+
+ public static synchronized void removeListener(IRootstrapChangedListener listener) {
+ changedListener.remove(listener);
+ }
+
+ public static synchronized void notifyChangedRootstrap() {
+
+ Iterator<IRootstrapChangedListener> ite = changedListener.iterator();
+ while (ite.hasNext()) {
+ IRootstrapChangedListener tl = ite.next();
+ if (tl != null)
+ tl.rootstrapChanged();
+ }
+ }
+
+ public static synchronized void notifyChangedSelectionListener(String rootName) {
+
+ Iterator<IRootstrapChangedListener> ite = changedListener.iterator();
+ while (ite.hasNext()) {
+ IRootstrapChangedListener tl = ite.next();
+ if (tl != null)
+ tl.selectionChanged(rootName);
+ }
+ }
+
+ private static void checkInit() {
+ if (!init) {
+ initialize();
+ }
+ }
+
+ private static boolean isRemoteRepo(String repoType) {
+ return (RepoManager.REMOTE_REPO_TYPE.equals(repoType)) ? true : false;
+ }
+
+ private static boolean isLocalRepo(String repoType) {
+ return (RepoManager.LOCAL_REPO_TYPE.equals(repoType)) ? true : false;
+ }
+
+ public static PlatformRootstrap generate(String name, String arch,
+ HashMap<String, String> reposURLs, boolean immediateGen, IPath confFile,
+ IProgressMonitor monitor) throws InterruptedException {
+
+ boolean initialized = false;
+ String id = name;
+ if (immediateGen) {
+ if (generateBaseFileSystem(getUserRootstrapPath(id), arch, reposURLs, confFile, monitor)) {
+ initialized = true;
+ } else {
+ return null;
+ }
+ }
+
+ // generate SBI plugins
+ if (generateSBIPluginXML(id, name, arch, null, reposURLs, confFile)) {
+ return new PlatformRootstrap(id, name, arch, getUserRootstrapPath(id), reposURLs,
+ confFile, initialized, false);
+ } else {
+ if (immediateGen) {
+ removeBaseFileSystem(id, arch);
+ }
+ return null;
+ }
+ }
+
+ public static boolean generateBaseFileSystem(String rootstrapPath, String arch,
+ ArrayList<String> reposURLs, IPath confFile, IProgressMonitor monitor)
+ throws InterruptedException {
+ File rootstrapDir = new File(rootstrapPath);
+ String id = rootstrapDir.getName();
+ String tempDirPath = null;
+ try {
+ // make temp directory
+ tempDirPath = makeTempDirectory();
+
+ // use rogen
+ String rogen = InstallPathConfig.getSDKPath() + "/tools/rogen/bin/rogen.rb";
+ String baseArch = getBaseArchitecture(arch);
+ String urlData = "";
+ for (String url : reposURLs) {
+ urlData += (urlData.isEmpty() ? url : "," + url);
+ }
+
+ String command;
+ Map<String, String> env = null;
+ if (PreferencesManager.isProxyUsed()) {
+ String protocol = PreferencesManager.getProxyProtocol();
+ String host = PreferencesManager.getProxyHost();
+ int port = PreferencesManager.getProxyPort();
+ SmartBuildInterface sbi = SmartBuildInterface.getInstance();
+ String envKey = String.format("%s_proxy", protocol);
+ String envValue = String.format("%s://%s:%d", protocol, host, port);
+ env = sbi.addEnvironmentVariable(envKey, envValue);
+ }
+
+ command = String.format("%s -n %s -a %s -u %s -p rpm --ctrl GBS -g TizenPlatform",
+ rogen, id, baseArch, urlData);
+
+ if (confFile != null) {
+ command += String.format(" -d %s", confFile.toOSString());
+ }
+
+ if (rootstrapDir.exists()) {
+ if (!CommandLauncher.executeSudo(command, rootstrapDir.getParent(), env,
+ "Platform Internal", monitor)) {
+ return false;
+ }
+ } else {
+ if (!CommandLauncher.executeSudo(command, tempDirPath, env, "Platform Internal",
+ monitor)) {
+ return false;
+ }
+
+ // copy
+ String rootstrapBasePath = rootstrapDir.getParent();
+ CommandLauncher.execute(String.format("mkdir -p %s", rootstrapBasePath));
+ CommandLauncher.executeSudo(String.format("sudo -S mv %s/%s %s/", tempDirPath, id,
+ rootstrapBasePath));
+ }
+ } finally {
+ if (new File(tempDirPath).exists()) {
+ // check sub-directory
+ String checkDir = String.format("%s/%s/local/BUILD-ROOTS/scratch.%s.0/proc",
+ tempDirPath, id, arch);
+ if (new File(checkDir).exists()) {
+ CommandLauncher.executeSudo(String.format("sudo -S umount %s", checkDir));
+ }
+ checkDir = String.format("%s/%s/local/BUILD-ROOTS/scratch.%s.0/dev/pts",
+ tempDirPath, id, arch);
+ if (new File(checkDir).exists()) {
+ CommandLauncher.executeSudo(String.format("sudo -S umount %s", checkDir));
+ }
+
+ // remove
+ CommandLauncher.executeSudo(String.format("sudo -S rm -rf %s", tempDirPath));
+ }
+ }
+
+ return true;
+ }
+
+ public static boolean generateBaseFileSystem(String rootstrapPath, String arch,
+ HashMap<String, String> reposURLs, IPath confFile, IProgressMonitor monitor)
+ throws InterruptedException {
+ ArrayList<String> repos = new ArrayList<String>();
+ Iterator<String> keySet = reposURLs.keySet().iterator();
+
+ while (keySet.hasNext()) {
+ repos.add(keySet.next());
+ }
+
+ return generateBaseFileSystem(rootstrapPath, arch, repos, confFile, monitor);
+ }
+
+ private static void removeBaseFileSystem(String id, String arch) throws InterruptedException {
+ String path = getUserRootstrapPath(id);
+ // check sub-directory
+ String checkDir = String.format("%s/local/BUILD-ROOTS/scratch.%s.0/proc", path, arch);
+ if (new File(checkDir).exists()) {
+ CommandLauncher.executeSudo(String.format("sudo -S umount %s", checkDir));
+ }
+ checkDir = String.format("%s/local/BUILD-ROOTS/scratch.%s.0/dev/pts", path, arch);
+ if (new File(checkDir).exists()) {
+ CommandLauncher.executeSudo(String.format("sudo -S umount %s", checkDir));
+ }
+
+ CommandLauncher.executeSudo(String.format("sudo -S rm -rf %s", path), null);
+ }
+
+ public static String getBaseArchitecture(String arch) {
+ if (arch.contains("arm")) {
+ return "arm";
+ } else {
+ return "i386";
+ }
+ }
+
+ public static boolean generateSBIPluginXML(String id, String name, String arch, String path,
+ ArrayList<String> reposURLs) {
+ return generateSBIPluginXML(id, name, arch, path, reposURLs, null);
+ }
+
+ public static boolean generateSBIPluginXML(String id, String name, String arch, String path,
+ HashMap<String, String> reposURLs, IPath confFile) {
+
+ ArrayList<String> repos = new ArrayList<String>();
+ Iterator<String> keySet = reposURLs.keySet().iterator();
+
+ while (keySet.hasNext()) {
+ repos.add(keySet.next());
+ }
+
+ return generateSBIPluginXML(id, name, arch, path, repos, confFile);
+ }
+
+ public static boolean generateSBIPluginXML(String id, String name, String arch, String path,
+ ArrayList<String> reposURLs, IPath confFile) {
+
+ IPath pluginPath = new Path(SmartBuildInterface.getInstance().getPluginPath());
+ IPath filePath = pluginPath.append(id + ".xml");
+
+ try {
+ DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+
+ // root element
+ Document doc = docBuilder.newDocument();
+ Element rootElement = doc.createElement("extension");
+ doc.appendChild(rootElement);
+
+ Attr attr = doc.createAttribute("point");
+ attr.setValue("rootstrapDefinition");
+ rootElement.setAttributeNode(attr);
+
+ Element firstnode = doc.createElement("rootstrap");
+ rootElement.appendChild(firstnode);
+
+ Attr attrId = doc.createAttribute("id");
+ attrId.setValue(id);
+ Attr attrName = doc.createAttribute("name");
+ attrName.setValue(name);
+ Attr attrArch = doc.createAttribute("architecture");
+ attrArch.setValue(arch);
+ Attr attrPath = doc.createAttribute("path");
+ if (path == null) {
+ attrPath.setValue(getUserRootstrapPathOfXml(name));
+ } else {
+ attrPath.setValue(getRootstrapPathOfXml(path));
+ }
+ Attr attrType = doc.createAttribute("supportToolchainType");
+ attrType.setValue(PlatformRootstrap.SUPPORTED_TOOLCHAIN_TYPE);
+
+ firstnode.setAttributeNode(attrId);
+ firstnode.setAttributeNode(attrName);
+ firstnode.setAttributeNode(attrArch);
+ firstnode.setAttributeNode(attrPath);
+ firstnode.setAttributeNode(attrType);
+
+ String reposURLString = "";
+ for (String URL : reposURLs) {
+ if (!reposURLString.isEmpty()) {
+ reposURLString += URL_SEP;
+ }
+ reposURLString += URL;
+ }
+
+ Element secondnode = doc.createElement("property");
+ firstnode.appendChild(secondnode);
+
+ Attr attrKey = doc.createAttribute("key");
+ attrKey.setValue(PlatformRootstrap.PROPERTY_REPO_URLS);
+ Attr attrValue = doc.createAttribute("value");
+ attrValue.setValue(reposURLString);
+
+ secondnode.setAttributeNode(attrKey);
+ secondnode.setAttributeNode(attrValue);
+
+ Element thirdnode = doc.createElement("property");
+ firstnode.appendChild(thirdnode);
+
+ attrKey = doc.createAttribute("key");
+ attrKey.setValue(PlatformRootstrap.PROPERTY_CONFIGURATION_FILE);
+ attrValue = doc.createAttribute("value");
+ if (confFile == null) {
+ attrValue.setValue("");
+ } else {
+ attrValue.setValue(confFile.toOSString());
+ }
+
+ thirdnode.setAttributeNode(attrKey);
+ thirdnode.setAttributeNode(attrValue);
+
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ Transformer transformer = transformerFactory.newTransformer();
+
+ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+
+ DOMSource source = new DOMSource(doc);
+ StreamResult result = new StreamResult(new FileOutputStream(new File(
+ filePath.toOSString())));
+
+ transformer.transform(source, result);
+
+ } catch (ParserConfigurationException e) {
+ logger.error(String.format("Failed to generate XML file: [%s]", e), e);
+ e.printStackTrace();
+ return false;
+ } catch (TransformerConfigurationException e) {
+ logger.error(String.format("Failed to generate XML file: [%s]", e), e);
+ e.printStackTrace();
+ return false;
+ } catch (FileNotFoundException e) {
+ logger.error(String.format("Failed to generate XML file: [%s]", e), e);
+ e.printStackTrace();
+ return false;
+ } catch (TransformerException e) {
+ logger.error(String.format("Failed to generate XML file: [%s]", e), e);
+ e.printStackTrace();
+ return false;
+ }
+
+ return true;
+ }
+
+ public static void removeSBIPluginXML(PlatformRootstrap rootstrap) {
+ // remove related targets
+ ArrayList<Target> targetList = SBIModel.getTargetList();
+ ArrayList<Target> removeList = new ArrayList<Target>();
+ for (Target target : targetList) {
+ if (target.getRootstrap().getId().equals(rootstrap.getId())) {
+ removeList.add(target);
+ }
+ }
+ for (Target target : removeList) {
+ SBIModel.removeTarget(target);
+ new File(getPluginXML(target.getId())).delete();
+ }
+
+ // remove model/file
+ new File(getPluginXML(rootstrap.getId())).delete();
+ }
+
+ private static PlatformRootstrap createRootstrapFromSBIPlugin(String id) {
+ Rootstrap rootstrap = SBIModel.getRootstrapById(id);
+ if (rootstrap == null) {
+ return null;
+ }
+
+ HashMap<String, String> reposURLs = new HashMap<String, String>();
+ String urlStr = rootstrap.getPropertyValue(PlatformRootstrap.PROPERTY_REPO_URLS);
+ if (urlStr != null) {
+ for (String url : urlStr.split(URL_SEP_REGEXP)) {
+ if (RepoManager.isLocalUrl(url)) {
+ reposURLs.put(url.trim(), RepoManager.LOCAL_REPO_TYPE);
+ } else {
+ reposURLs.put(url.trim(), RepoManager.REMOTE_REPO_TYPE);
+ }
+ }
+ }
+
+ String confFile = rootstrap.getPropertyValue(PlatformRootstrap.PROPERTY_CONFIGURATION_FILE);
+
+ return new PlatformRootstrap(id, rootstrap.getName(), rootstrap.getArch(), rootstrap
+ .getPath().toOSString(), reposURLs, confFile, true, rootstrap.isDefault());
+ }
+
+ private static String getPluginXML(String id) {
+ IPath pluginPath = new Path(SmartBuildInterface.getInstance().getPluginPath());
+ return pluginPath.append(id + ".xml").toOSString();
+ }
+
+ private static String getBaseUserRootstrapPath() {
+ return new Path(InstallPathConfig.getUserDataPath()).append(USER_ROOSTRAP_BASE_DIR_NAME)
+ .toOSString();
+ }
+
+ private static String getUserRootstrapPath(String id) {
+ return new Path(getBaseUserRootstrapPath()).append(id).toOSString();
+ }
+
+ private static String getUserRootstrapPathOfXml(String id) {
+ String rootstrapPath = getUserRootstrapPath(id);
+
+ return getRootstrapPathOfXml(rootstrapPath);
+ }
+
+ private static String getRootstrapPathOfXml(String path) {
+ if (InstallerUtil.isSupportedMultipleSDK()) {
+ return path.replaceAll(String.format("%s/", InstallPathConfig.getSDKPath()),
+ "#{SDK_INSTALLED_PATH}/").replaceAll(
+ String.format("%s/", InstallPathConfig.getUserDataPath()), "#{SDK_DATA_PATH}/");
+ } else {
+ return path.replaceAll(String.format("%s/", InstallPathConfig.getSDKPath()),
+ "#{SBI_HOME}/../../").replaceAll(
+ String.format("%s/", InstallPathConfig.getUserDataPath()),
+ "#{HOME}/tizen-sdk-data/");
}
- }
-
-
- private static String makeTempDirectory() {
- final File temp;
-
- try {
- temp = File.createTempFile("temp", Long.toString(System.nanoTime()));
- if(!(temp.delete()))
- {
- throw new IOException("Could not delete temp file: " + temp.getAbsolutePath());
- }
-
- if(!(temp.mkdir()))
- {
- throw new IOException("Could not create temp directory: " + temp.getAbsolutePath());
- }
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
-
- return temp.getPath();
- }
-
-
- public static ArrayList<PlatformRootstrap> getRootstraps() {
- checkInit();
-
- return rootstraps;
- }
-
-
- public static PlatformRootstrap getRootstrap(String id) {
- checkInit();
-
- for (PlatformRootstrap r : rootstraps) {
- if (r.getId().equals(id)) {
- return r;
- }
- }
-
- return null;
- }
-
-
- public static PlatformRootstrap getDefaultRootstrap( String arch ) {
- String defaultRootstrapID = null;
- if (PlatformConfigurationManager.isEmulatorArch(arch)) {
- defaultRootstrapID = PlatformRootstrap.DEFAULT_ROOTSTRAP_I386_ID;
- } else if (PlatformConfigurationManager.isDeviceArch(arch)) {
- defaultRootstrapID = PlatformRootstrap.DEFAULT_ROOTSTRAP_ARM_ID;
- }
-
- return RootstrapManager.getRootstrap( defaultRootstrapID );
- }
-
-
- public static void reinitialize() {
- init = false;
- rootstraps.clear();
- initialize();
- }
-
-
- public static void setSelectedRootstrap(PlatformRootstrap selected) {
- for (PlatformRootstrap r : rootstraps) {
- if(r.isChecked()) {
- r.setChecked(false);
- }
- }
- selected.setChecked(true);
- selectedRootstrap = selected;
- }
-
-
- public static void setSelectedRootstrap(String id) {
- for(PlatformRootstrap r : RootstrapManager.getRootstraps()) {
- if (id.equals(r.getId())) {
- setSelectedRootstrap(r);
- break;
- }
- }
- }
-
-
- public static void resetSelectedRootstrap() {
- for (PlatformRootstrap r : rootstraps) {
- if(r.isChecked()) {
- r.setChecked(false);
- }
- }
- }
-
- public static boolean isInitialized(String rootId) {
- PlatformRootstrap root = getRootstrap(rootId);
- if (root != null) {
- return root.isInitialized();
- } else {
- return false;
- }
- }
-
-
- public static PlatformRootstrap getSelectedRootstrap() {
- return selectedRootstrap;
- }
-
-
- public static synchronized void addListener(IRootstrapChangedListener listener) {
- changedListener.add(listener);
- }
-
-
- public static synchronized void removeListener(IRootstrapChangedListener listener) {
- changedListener.remove(listener);
- }
-
-
- public static synchronized void notifyChangedRootstrap() {
-
- Iterator<IRootstrapChangedListener> ite = changedListener.iterator();
- while (ite.hasNext()) {
- IRootstrapChangedListener tl = ite.next();
- if(tl!=null)
- tl.rootstrapChanged();
- }
- }
-
-
- public static synchronized void notifyChangedSelectionListener(String rootName) {
-
- Iterator<IRootstrapChangedListener> ite = changedListener.iterator();
- while (ite.hasNext()) {
- IRootstrapChangedListener tl = ite.next();
- if(tl!=null)
- tl.selectionChanged(rootName);
- }
- }
-
-
- private static void checkInit() {
- if (!init) {
- initialize();
- }
- }
-
- private static boolean isRemoteRepo(String repoType) {
- return (RepoManager.REMOTE_REPO_TYPE.equals(repoType)) ? true : false;
- }
-
- private static boolean isLocalRepo(String repoType) {
- return (RepoManager.LOCAL_REPO_TYPE.equals(repoType)) ? true : false;
- }
-
- public static PlatformRootstrap generate(String name, String arch,
- HashMap<String, String> reposURLs, boolean immediateGen,
- IPath confFile, IProgressMonitor monitor) throws InterruptedException {
-
- boolean initialized = false;
- String id = name;
- if ( immediateGen ) {
- if ( generateBaseFileSystem(getUserRootstrapPath(id), arch, reposURLs,
- confFile, monitor) ) {
- initialized = true;
- }
- else {
- return null;
- }
-
- }
-
- // generate SBI plugins
- if ( generateSBIPluginXML(id, name, arch, null, reposURLs, confFile) ) {
- return new PlatformRootstrap(id, name, arch, getUserRootstrapPath(id),
- reposURLs, confFile, initialized);
- }
- else {
- if ( immediateGen ) {
- removeBaseFileSystem(id, arch);
- }
- return null;
- }
- }
-
- public static PlatformRootstrap generate(PlatformRootstrap rootstrap, boolean immediateGen,
- IProgressMonitor monitor) throws InterruptedException {
-
- boolean initialized = false;
- String name = rootstrap.getName();
- String arch = rootstrap.getArch();
- ArrayList<String> repos = rootstrap.getJustRepoURLs();
- IPath confFile = rootstrap.getConfFile();
- String id = name;
- if ( immediateGen ) {
- if ( generateBaseFileSystem(getUserRootstrapPath(id), arch, repos,
- confFile, monitor) ) {
- initialized = true;
- }
- else {
- return null;
- }
-
- }
-
- // generate SBI plugins
- if ( generateSBIPluginXML(id, name, arch, null, repos, confFile) ) {
- return new PlatformRootstrap(id, name, arch, getUserRootstrapPath(id),
- rootstrap.getRepoMap(), confFile, initialized);
- }
- else {
- if ( immediateGen ) {
- removeBaseFileSystem(id, arch);
- }
- return null;
- }
- }
-
-
- public static boolean generateBaseFileSystem(String rootstrapPath, String arch,
- ArrayList<String> reposURLs, IPath confFile, IProgressMonitor monitor) throws InterruptedException {
- String id = new File(rootstrapPath).getName();
- String tempDirPath = null;
- try {
- // make temp directory
- tempDirPath = makeTempDirectory();
-
- // use rogen
- String rogen = InstallPathConfig.getSDKPath()+"/tools/rogen/bin/rogen.rb";
- String baseArch = getBaseArchitecture(arch);
- String urlData = "";
- for( String url: reposURLs ) {
- urlData += (urlData.isEmpty() ? url : "," + url );
- }
-
- String command;
- Map<String, String> env = null;
- if ( PreferencesManager.isProxyUsed() ) {
- String protocol = PreferencesManager.getProxyProtocol();
- String host = PreferencesManager.getProxyHost();
- int port = PreferencesManager.getProxyPort();
- SmartBuildInterface sbi = SmartBuildInterface.getInstance();
- String envKey = String.format("%s_proxy", protocol);
- String envValue = String.format("%s://%s:%d", protocol, host, port);
- env = sbi.addEnvironmentVariable(envKey, envValue);
- }
-
- command = String.format( "%s -n %s -a %s -u %s -p rpm --ctrl GBS -g TizenPlatform",
- rogen, id, baseArch, urlData );
-
- if (confFile != null) {
- command += String.format(" -d %s", confFile.toOSString());
- }
-
- if ( !CommandLauncher.executeSudo( command, tempDirPath, env, "Platform Internal", monitor) ) {
- return false;
- }
-
- // copy
- String rootstrapBasePath = new File(rootstrapPath).getParent();
- CommandLauncher.execute(String.format("mkdir -p %s", rootstrapBasePath));
- CommandLauncher.executeSudo(String.format("sudo -S mv %s/%s %s/", tempDirPath, id, rootstrapBasePath));
- }
- finally {
- if ( new File(tempDirPath).exists() ) {
- // check sub-directory
- String checkDir = String.format("%s/%s/local/scratch.%s.0/proc", tempDirPath, id, arch );
- if ( new File(checkDir).exists() ) {
- CommandLauncher.executeSudo(String.format("sudo -S umount %s", checkDir));
- }
- checkDir = String.format("%s/%s/local/scratch.%s.0/dev/pts", tempDirPath, id, arch );
- if ( new File(checkDir).exists() ) {
- CommandLauncher.executeSudo(String.format("sudo -S umount %s", checkDir));
- }
-
- // remove
- CommandLauncher.executeSudo(String.format("sudo -S rm -rf %s", tempDirPath));
- }
- }
-
- return true;
- }
-
- public static boolean generateBaseFileSystem(String rootstrapPath, String arch,
- HashMap<String, String> reposURLs, IPath confFile, IProgressMonitor monitor) throws InterruptedException {
- ArrayList<String> repos = new ArrayList<String>();
- Iterator<String> keySet = reposURLs.keySet().iterator();
-
- while(keySet.hasNext()) {
- repos.add(keySet.next());
- }
-
- return generateBaseFileSystem(rootstrapPath, arch, repos, confFile, monitor);
- }
-
- private static void removeBaseFileSystem( String id, String arch ) throws InterruptedException {
- String path = getUserRootstrapPath( id );
- // check sub-directory
- String checkDir = String.format("%s/local/scratch.%s.0/proc", path, arch );
- if ( new File(checkDir).exists() ) {
- CommandLauncher.executeSudo(String.format("sudo -S umount %s", checkDir));
- }
- checkDir = String.format("%s/local/scratch.%s.0/dev/pts", path, arch );
- if ( new File(checkDir).exists() ) {
- CommandLauncher.executeSudo(String.format("sudo -S umount %s", checkDir));
- }
-
- CommandLauncher.executeSudo( String.format("sudo -S rm -rf %s", path), null );
- }
-
- public static String getBaseArchitecture( String arch ) {
- if ( arch.contains("arm") ) {
- return "arm";
- }
- else {
- return "i386";
- }
- }
-
- public static boolean generateSBIPluginXML( String id, String name, String arch,
- String path, ArrayList<String> reposURLs) {
- return generateSBIPluginXML(id, name, arch, path, reposURLs, null);
- }
-
- public static boolean generateSBIPluginXML( String id, String name, String arch, String path,
- HashMap<String, String> reposURLs, IPath confFile) {
-
- ArrayList<String> repos = new ArrayList<String>();
- Iterator<String> keySet = reposURLs.keySet().iterator();
-
- while(keySet.hasNext()) {
- repos.add(keySet.next());
- }
-
- return generateSBIPluginXML(id, name, arch, path, repos, confFile);
- }
-
-
- public static boolean generateSBIPluginXML( String id, String name, String arch, String path,
- ArrayList<String> reposURLs, IPath confFile) {
-
- IPath pluginPath = new Path(SmartBuildInterface.getInstance().getPluginPath());
- IPath filePath = pluginPath.append(id + ".xml");
-
- try {
- DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
-
- // root element
- Document doc = docBuilder.newDocument();
- Element rootElement = doc.createElement("extension");
- doc.appendChild(rootElement);
-
- Attr attr = doc.createAttribute("point");
- attr.setValue("rootstrapDefinition");
- rootElement.setAttributeNode(attr);
-
- Element firstnode = doc.createElement("rootstrap");
- rootElement.appendChild(firstnode);
-
- Attr attrId = doc.createAttribute("id");
- attrId.setValue(id);
- Attr attrName = doc.createAttribute("name");
- attrName.setValue(name);
- Attr attrArch = doc.createAttribute("architecture");
- attrArch.setValue(arch);
- Attr attrPath = doc.createAttribute("path");
- if (path == null) {
- attrPath.setValue( getUserRootstrapPathOfXml(name) );
- } else {
- attrPath.setValue( getRootstrapPathOfXml(path) );
- }
- Attr attrType = doc.createAttribute("supportToolchainType");
- attrType.setValue(PlatformRootstrap.SUPPORTED_TOOLCHAIN_TYPE);
-
- firstnode.setAttributeNode(attrId);
- firstnode.setAttributeNode(attrName);
- firstnode.setAttributeNode(attrArch);
- firstnode.setAttributeNode(attrPath);
- firstnode.setAttributeNode(attrType);
-
- String reposURLString = "";
- for ( String URL: reposURLs ) {
- if ( !reposURLString.isEmpty() ) {
- reposURLString += URL_SEP;
- }
- reposURLString += URL;
- }
-
- Element secondnode = doc.createElement("property");
- firstnode.appendChild(secondnode);
-
- Attr attrKey = doc.createAttribute("key");
- attrKey.setValue(PlatformRootstrap.PROPERTY_REPO_URLS);
- Attr attrValue = doc.createAttribute("value");
- attrValue.setValue(reposURLString);
-
- secondnode.setAttributeNode(attrKey);
- secondnode.setAttributeNode(attrValue);
-
- Element thirdnode = doc.createElement("property");
- firstnode.appendChild(thirdnode);
-
- attrKey = doc.createAttribute("key");
- attrKey.setValue(PlatformRootstrap.PROPERTY_CONFIGURATION_FILE);
- attrValue = doc.createAttribute("value");
- if (confFile == null) {
- attrValue.setValue("");
- } else {
- attrValue.setValue(confFile.toOSString());
- }
-
- thirdnode.setAttributeNode(attrKey);
- thirdnode.setAttributeNode(attrValue);
-
- TransformerFactory transformerFactory = TransformerFactory.newInstance();
- Transformer transformer = transformerFactory.newTransformer();
-
- transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
- transformer.setOutputProperty(OutputKeys.INDENT, "yes");
-
-
- DOMSource source = new DOMSource(doc);
- StreamResult result = new StreamResult(new FileOutputStream(new File(filePath.toOSString())));
-
- transformer.transform(source, result);
-
- } catch (ParserConfigurationException e) {
- e.printStackTrace();
- return false;
- } catch (TransformerConfigurationException e) {
- e.printStackTrace();
- return false;
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- return false;
- } catch (TransformerException e) {
- e.printStackTrace();
- return false;
- }
-
- return true;
- }
-
-
- public static void removeSBIPluginXML(PlatformRootstrap rootstrap) {
- // remove related targets
- ArrayList<Target> targetList = SBIModel.getTargetList();
- ArrayList<Target> removeList = new ArrayList<Target>();
- for( Target target : targetList ) {
- if ( target.getRootstrap().getId().equals(rootstrap.getId()) ) {
- removeList.add(target);
- }
- }
- for( Target target : removeList ) {
- SBIModel.removeTarget( target );
- new File(getPluginXML(target.getId())).delete();
- }
-
- // remove model/file
- new File(getPluginXML(rootstrap.getId())).delete();
- }
-
-
- private static PlatformRootstrap createRootstrapFromSBIPlugin( String id ) {
- Rootstrap rootstrap = SBIModel.getRootstrapById(id);
- if ( rootstrap == null ) {
- return null;
- }
-
- HashMap<String, String> reposURLs = new HashMap<String, String>();
- String urlStr = rootstrap.getPropertyValue(PlatformRootstrap.PROPERTY_REPO_URLS);
- if ( urlStr != null ) {
- for( String url : urlStr.split(URL_SEP_REGEXP) ) {
- if (RepoManager.isLocalUrl(url)) {
- reposURLs.put(url.trim(), RepoManager.LOCAL_REPO_TYPE);
- } else {
- reposURLs.put(url.trim(), RepoManager.REMOTE_REPO_TYPE);
- }
- }
- }
-
- String confFile = rootstrap.getPropertyValue(PlatformRootstrap.PROPERTY_CONFIGURATION_FILE);
-
- return new PlatformRootstrap(id, rootstrap.getName(), rootstrap.getArch(),
- rootstrap.getPath().toOSString(), reposURLs, confFile, true);
- }
-
-
- private static String getPluginXML( String id ) {
- IPath pluginPath = new Path(SmartBuildInterface.getInstance().getPluginPath());
- return pluginPath.append(id + ".xml").toOSString();
- }
-
-
- private static String getBaseUserRootstrapPath() {
- return new Path(InstallPathConfig.getUserDataPath())
- .append(USER_ROOSTRAP_BASE_DIR_NAME).toOSString();
- }
-
-
- private static String getUserRootstrapPath(String id) {
- return new Path(getBaseUserRootstrapPath()).append(id).toOSString();
- }
-
-
- private static String getUserRootstrapPathOfXml(String id ) {
- String rootstrapPath = getUserRootstrapPath(id);
-
- return getRootstrapPathOfXml(rootstrapPath);
- }
-
-
- private static String getRootstrapPathOfXml( String path ) {
- return path.replaceAll(String.format("%s/",InstallPathConfig.getSDKPath()), "#{SBI_HOME}/../../").
- replaceAll(String.format("%s/",InstallPathConfig.getUserDataPath()), "#{HOME}/tizen-sdk-data/");
- }
+ }
}
--- /dev/null
+package org.tizen.nativeplatform.util;
+
+public class CharacterStripper {
+ /**
+ * This method ensures that the output String has only
+ * valid XML unicode characters as specified by the
+ * XML 1.0 standard. For reference, please see
+ * <a href="http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char">the
+ * standard</a>. This method will return an empty
+ * String if the input is null or empty.
+ *
+ * @param in The String whose non-valid characters we want to remove.
+ * @return The in String, stripped of non-valid characters.
+ */
+ public static String stripNonValidXMLCharacters(String in) {
+ StringBuffer out = new StringBuffer(); // Used to hold the output.
+ char current; // Used to reference the current character.
+
+ if (in == null || ("".equals(in))) return ""; // vacancy test.
+ for (int i = 0; i < in.length(); i++) {
+ current = in.charAt(i); // NOTE: No IndexOutOfBoundsException caught here; it should not happen.
+ if ((current == 0x9) ||
+ (current == 0xA) ||
+ (current == 0xD) ||
+ ((current >= 0x20) && (current <= 0xD7FF)) ||
+ ((current >= 0xE000) && (current <= 0xFFFD)) ||
+ ((current >= 0x10000) && (current <= 0x10FFFF)))
+ out.append(current);
+ }
+ return out.toString();
+ }
+
+ public static String stripShellEscapseSequence(String in) {
+ return in.replace("[?1034h", "");
+ }
+}
--- /dev/null
+package org.tizen.nativeplatform.util;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.tizen.nativeplatform.pkg.commander.CommandStatus;
+import org.tizen.nativeplatform.pkg.commander.ICommandStatus;
+import org.tizen.nativeplatform.pkgmgr.PackageManagerOuputReceiver;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.exception.SdbCommandRejectedException;
+import org.tizen.sdblib.exception.ShellCommandUnresponsiveException;
+import org.tizen.sdblib.exception.TimeoutException;
+
+public class CommandLauncherOnDevice {
+
+ private final static int MAX_TIMEOUT = 10000;
+
+ public static ICommandStatus execute(IDevice device, String command,
+ PackageManagerOuputReceiver rec) {
+ String[] prevLog = {};
+ if (rec.getLog() != null) {
+ prevLog = rec.getLog();
+ }
+
+ try {
+ device.executeShellCommand(command, rec, MAX_TIMEOUT);
+ } catch (TimeoutException e) {
+ return new CommandStatus(IStatus.ERROR, command, e.getMessage(), e);
+ } catch (SdbCommandRejectedException e) {
+ return new CommandStatus(IStatus.ERROR, command, e.getMessage(), e);
+ } catch (ShellCommandUnresponsiveException e) {
+ return new CommandStatus(IStatus.ERROR, command, e.getMessage(), e);
+ } catch (IOException e) {
+ return new CommandStatus(IStatus.ERROR, command, e.getMessage(), e);
+ }
+
+ CommandStatus status = new CommandStatus(IStatus.OK, command, "", null);
+
+ if (rec.getLog() != null) {
+ String[] nextLog = rec.getLog();
+ List<String> value = new ArrayList<String>();
+ // for (String log : rec.getLog()) {
+ for (int i = prevLog.length; i < nextLog.length; i++) {
+ String log = nextLog[i];
+ value.add(log);
+ }
+ /*
+ * for (String log : nextLog[prevLog.length]) { value.add(log); }
+ */
+ status.setValue(value);
+ }
+
+ return status;
+ }
+}
--- /dev/null
+package org.tizen.nativeplatform.util;
+
+import static org.tizen.common.util.IOUtil.tryClose;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.tizen.common.ui.view.console.ConsoleManager;
+import org.tizen.common.util.HostUtil;
+import org.tizen.nativeplatform.password.SudoPasswdManager;
+import org.tizen.nativeplatform.pkg.commander.CommandStatus;
+import org.tizen.nativeplatform.pkg.commander.ICommandStatus;
+import org.tizen.nativeplatform.pkgmgr.PackageManagerOuputReceiver;
+import org.tizen.nativeplatform.util.CommandLauncher.ProcessMonitorThread;
+
+public class CommandLauncherOnRootstrap {
+
+ public static ICommandStatus executeSudo(String command) {
+ return executeSudo(command, null, "", null);
+ }
+
+ public static ICommandStatus executeSudo(String command, String workingDir) {
+ return executeSudo(command, workingDir, "", null);
+ }
+
+ public static ICommandStatus executeSudo(String command, String workingDir,
+ String consoleViewName, IProgressMonitor monitor) {
+ return executeSudo(command, workingDir, null, consoleViewName, monitor);
+ }
+
+ public static ICommandStatus executeSudo(String command, String workingDir,
+ PackageManagerOuputReceiver rec, IProgressMonitor monitor) {
+ return executeSudo(command, workingDir, null, rec, monitor);
+ }
+
+ public static ICommandStatus executeSudo(String command, String workingDir,
+ Map<String, String> newEnv, String consoleViewName, IProgressMonitor monitor) {
+
+ // generate script
+ String scriptCmd = genSudoExecuteScript(command);
+ if (scriptCmd == null) {
+ ICommandStatus status = new CommandStatus(IStatus.ERROR, command,
+ "Generating execution script failed!", null);
+ return status;
+ }
+ return execute(scriptCmd, workingDir, newEnv, consoleViewName, monitor);
+ }
+
+ public static ICommandStatus executeSudo(String command, String workingDir,
+ Map<String, String> newEnv, PackageManagerOuputReceiver rec, IProgressMonitor monitor) {
+
+ // generate script
+ String scriptCmd = genSudoExecuteScript(command);
+ if (scriptCmd == null) {
+ ICommandStatus status = new CommandStatus(IStatus.ERROR, command,
+ "Generating execution script failed!", null);
+ return status;
+ }
+ return execute(scriptCmd, workingDir, newEnv, rec, monitor);
+ }
+
+ public static ICommandStatus execute(String command) {
+ return execute(command, null, "", null);
+ }
+
+ public static ICommandStatus execute(String command, String workingDir, String consoleViewName,
+ IProgressMonitor monitor) {
+ return execute(command, workingDir, null, consoleViewName, monitor);
+ }
+
+ public static ICommandStatus execute(String command, String workingDir,
+ PackageManagerOuputReceiver rec, IProgressMonitor monitor) {
+ return execute(command, workingDir, null, rec, monitor);
+ }
+
+ public static ICommandStatus execute(String command, String workingDir,
+ Map<String, String> newEnv, String consoleViewName, IProgressMonitor monitor) {
+
+ CommandStatus status = null;
+ Process proc = null;
+ List<String> log = new ArrayList<String>();
+
+ // start process
+ try {
+ proc = createProcess(command, workingDir, newEnv, false);
+ // create monitor process
+ ProcessMonitorThread monitorThread = null;
+ if (monitor != null) {
+ monitorThread = new ProcessMonitorThread(proc, monitor);
+ monitorThread.start();
+ }
+
+ // handle console
+ if (consoleViewName != null && !consoleViewName.isEmpty()) {
+ ConsoleManager cm = new ConsoleManager(consoleViewName, true);
+ cm.clear();
+ BufferedReader input = new BufferedReader(new InputStreamReader(
+ proc.getInputStream()));
+ String line = null;
+ try {
+ while ((line = input.readLine()) != null) {
+ cm.println(line);
+ log.add(line);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ status = new CommandStatus(IStatus.ERROR, command, e.getMessage(), log, e);
+ } finally {
+ if (input != null)
+ tryClose(input);
+ }
+ }
+
+ // wait for process finish
+ proc.waitFor();
+
+ // wait for monitor thread finish
+ if (monitor != null) {
+ monitorThread.join();
+ if (monitor.isCanceled()) {
+ status = new CommandStatus(IStatus.ERROR, command,
+ "Command execution is canceled!", log, null);
+ return status;
+ }
+ }
+ } catch (InterruptedException e) {
+ status = new CommandStatus(IStatus.ERROR, command, e.getMessage(), log, e);
+ return status;
+ }
+
+ status = new CommandStatus(IStatus.OK, proc.exitValue(), command, "Executed command", log,
+ null);
+ return status;
+ }
+
+ public static ICommandStatus execute(String command, String workingDir,
+ Map<String, String> newEnv, PackageManagerOuputReceiver rec, IProgressMonitor monitor) {
+
+ CommandStatus status = null;
+ Process proc = null;
+ List<String> log = new ArrayList<String>();
+
+ // start process
+ try {
+ proc = createProcess(command, workingDir, newEnv, false);
+ // create monitor process
+ ProcessMonitorThread monitorThread = null;
+ if (monitor != null) {
+ monitorThread = new ProcessMonitorThread(proc, monitor);
+ monitorThread.start();
+ }
+
+ BufferedReader input = new BufferedReader(new InputStreamReader(proc.getInputStream()));
+ /*
+ * ProgressMonitorInputStream progressIn = new
+ * ProgressMonitorInputStream( null, "Analysis",
+ * proc.getInputStream()); BufferedReader input = new
+ * BufferedReader(new InputStreamReader(progressIn));
+ */
+ String line = null;
+ try {
+ while ((line = input.readLine()) != null) {
+ log.add(line);
+ if (rec != null && rec.getMsgConsoleStream() != null)
+ rec.processNewLine(line);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ status = new CommandStatus(IStatus.ERROR, command, e.getMessage(), log, e);
+ } finally {
+ if (input != null)
+ tryClose(input);
+ }
+
+ // wait for process finish
+ proc.waitFor();
+
+ // wait for monitor thread finish
+ if (monitor != null) {
+ monitorThread.join();
+ if (monitor.isCanceled()) {
+ status = new CommandStatus(IStatus.ERROR, command,
+ "Command execution is canceled!", log, null);
+ return status;
+ }
+ }
+ } catch (InterruptedException e) {
+ status = new CommandStatus(IStatus.ERROR, command, e.getMessage(), log, e);
+ return status;
+ }
+
+ status = new CommandStatus(IStatus.OK, proc.exitValue(), command, "Executed command", log,
+ null);
+ return status;
+ }
+
+ public static Process createProcess(String command, String workingDir, boolean includeStdErr)
+ throws InterruptedException {
+ // start process
+ return createProcess(command, workingDir, null, includeStdErr);
+ }
+
+ public static Process createProcess(String command, String workingDir,
+ Map<String, String> newEnv, boolean includeStdErr) throws InterruptedException {
+ // start process
+ String[] fullCommand = HostUtil.getCommand(command);
+ ProcessBuilder pb = new ProcessBuilder();
+ pb.redirectErrorStream(includeStdErr);
+ pb.command(fullCommand);
+ if (newEnv != null) {
+ pb.environment().clear();
+ pb.environment().putAll(newEnv);
+ }
+ if (workingDir != null) {
+ pb.directory(new File(workingDir));
+ }
+ Process proc;
+ try {
+ proc = pb.start();
+ } catch (IOException e) {
+ throw new InterruptedException(String.format("Creating process failed! : %s => %s",
+ command, e.getMessage()));
+ }
+
+ return proc;
+ }
+
+ // return generate script and return script path
+ private static String genSudoExecuteScript(String command) {
+ String passwd = SudoPasswdManager.getSudoPassword();
+ File shellScript = null;
+
+ try {
+ // create expect script file
+ File expectScript = new File("/tmp/run_sudo.exp");
+ expectScript.createNewFile();
+ BufferedWriter bw = new BufferedWriter(new FileWriter(expectScript));
+ bw.write("#!/usr/bin/expect --");
+ bw.newLine();
+ bw.write(String.format("spawn sh -c \"%s;echo \\$? > /tmp/exit-status\"", command));
+ bw.newLine();
+ bw.write("while (1) {");
+ bw.newLine();
+ bw.write(" expect {");
+ bw.newLine();
+ bw.write(" \"password for\" {");
+ bw.newLine();
+ bw.write(String.format("send \"%s\\r\"", passwd));
+ bw.newLine();
+ bw.write(" }");
+ bw.newLine();
+ bw.write(" eof {");
+ bw.newLine();
+ bw.write(" return");
+ bw.newLine();
+ bw.write(" }");
+ bw.newLine();
+ bw.write(" }");
+ bw.newLine();
+ bw.write("}");
+ bw.newLine();
+ bw.close();
+ expectScript.setExecutable(true);
+
+ shellScript = new File("/tmp/run_sudo.sh");
+ shellScript.createNewFile();
+ bw = new BufferedWriter(new FileWriter(shellScript));
+ bw.write("#!/bin/sh -ee");
+ bw.newLine();
+ bw.write("/tmp/run_sudo.exp");
+ bw.newLine();
+ bw.write("EXIT_CODE=`cat /tmp/exit-status`");
+ bw.newLine();
+ bw.write("if [ \"$EXIT_CODE\" != \"0\" ]; then");
+ bw.newLine();
+ bw.write(" echo \"EXIT CODE=${EXIT_CODE}\" >&2");
+ bw.newLine();
+ bw.write(" exit 1");
+ bw.newLine();
+ bw.write("fi");
+ bw.newLine();
+ bw.close();
+ shellScript.setExecutable(true);
+ } catch (IOException e) {
+ return null;
+ }
+
+ // execute script
+ return shellScript.getPath();
+ }
+
+ // return generate script and return script path
+ private static String genSudoKillProcessScript(Process process) {
+ String passwd = SudoPasswdManager.getSudoPassword();
+ File shellScript = null;
+
+ try {
+ // get process id
+ Field f = process.getClass().getDeclaredField("pid");
+ f.setAccessible(true);
+ String pid = f.get(process).toString();
+
+ // create killtree script file
+ File killScript = new File("/tmp/killtree.sh");
+ killScript.createNewFile();
+ BufferedWriter bw = new BufferedWriter(new FileWriter(killScript));
+ bw.write("#!/bin/sh");
+ bw.newLine();
+ bw.write("killtree() {");
+ bw.newLine();
+ bw.write(" local _pid=$1");
+ bw.newLine();
+ bw.write(" sudo kill -STOP ${_pid}");
+ bw.newLine();
+ bw.write(" for _child in $(ps -o pid --no-headers --ppid ${_pid}); do");
+ bw.newLine();
+ bw.write(" killtree ${_child}");
+ bw.newLine();
+ bw.write(" done");
+ bw.newLine();
+ bw.write(" sudo kill -KILL ${_pid}");
+ bw.newLine();
+ bw.write("}");
+ bw.newLine();
+ bw.write("killtree $1");
+ bw.newLine();
+ bw.close();
+ killScript.setExecutable(true);
+
+ // create expect script file
+ File expectScript = new File("/tmp/run_sudo2.exp");
+ expectScript.createNewFile();
+ bw = new BufferedWriter(new FileWriter(expectScript));
+ bw.write("#!/usr/bin/expect --");
+ bw.newLine();
+ bw.write(String.format("spawn sh -c \"/tmp/killtree.sh %s\"", pid));
+ bw.newLine();
+ bw.write("while (1) {");
+ bw.newLine();
+ bw.write(" expect {");
+ bw.newLine();
+ bw.write(" \"password for\" {");
+ bw.newLine();
+ bw.write(String.format("send \"%s\\r\"", passwd));
+ bw.newLine();
+ bw.write(" }");
+ bw.newLine();
+ bw.write(" eof {");
+ bw.newLine();
+ bw.write(" return");
+ bw.newLine();
+ bw.write(" }");
+ bw.newLine();
+ bw.write(" }");
+ bw.newLine();
+ bw.write("}");
+ bw.newLine();
+ bw.close();
+ expectScript.setExecutable(true);
+
+ shellScript = new File("/tmp/run_sudo2.sh");
+ shellScript.createNewFile();
+ bw = new BufferedWriter(new FileWriter(shellScript));
+ bw.write("#!/bin/sh -ee");
+ bw.newLine();
+ bw.write("/tmp/run_sudo2.exp");
+ bw.newLine();
+ bw.close();
+ shellScript.setExecutable(true);
+
+ return shellScript.getPath();
+ } catch (SecurityException e) {
+ return null;
+ } catch (NoSuchFieldException e) {
+ return null;
+ } catch (IllegalArgumentException e) {
+ return null;
+ } catch (IllegalAccessException e) {
+ return null;
+ } catch (IOException e) {
+ return null;
+ }
+ }
+}
--- /dev/null
+package org.tizen.nativeplatform.util;
+
+import java.io.File;
+
+import org.tizen.common.core.application.InstallPathConfig;
+
+public class InstallerUtil {
+
+ private final static String SDK_INFO_FILE = "sdk.info";
+
+ public static boolean isSupportedMultipleSDK() {
+ String sdkPath = InstallPathConfig.getSDKPath();
+ String sdkInfoFile = sdkPath + File.separator + SDK_INFO_FILE;
+ File file = new File(sdkInfoFile);
+ return file.exists();
+ }
+}
--- /dev/null
+package org.tizen.nativeplatform.util;
+
+import org.eclipse.core.resources.IProject;
+import org.tizen.nativecommon.ProjectUtil;
+import org.tizen.nativeplatform.IPlatformProject;
+import org.tizen.nativeplatform.IPlatformXMLStore;
+import org.tizen.nativeplatform.manifest.PlatformManifestXMLStore;
+
+public class PlatformProjectUtil {
+ /**
+ * Returns {@link IPlatformProject} object for the project.
+ * @param project
+ * @return {@link IPlatformProject}
+ */
+ public static IPlatformProject getTizenPlatformProject(IProject project, Class adapter) {
+ if (project == null)
+ throw new IllegalArgumentException("Project can not be null");
+ Object obj = project.getAdapter(adapter);
+ if (obj == null || !(obj instanceof IPlatformProject))
+ throw new IllegalArgumentException("Project can not be adapted (obj - " + obj + ", adapter - " + adapter + ")");
+ return (IPlatformProject) obj;
+ }
+
+
+ /**
+ * Checks whether project is for Tizen platform or not.
+ * @param project
+ * @return {@code true} if it is Tizen platform project
+ */
+ public static boolean isTizenPlatformProject(IProject project) {
+ IPlatformProject adapter = getTizenPlatformProject(project, IPlatformProject.class);
+ return (adapter.getTizenProjectType() == null) ? false : adapter.getTizenProjectType().isPlatformProject();
+ }
+
+ public static boolean isEFLApplication(IProject project) {
+ if (isTizenPlatformProject(project)) {
+ IPlatformProject adapter = getTizenPlatformProject(project, IPlatformProject.class);
+ return (adapter.getTizenProjectType() == null) ? false : adapter.isEFLApplication();
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Returns <code>IPlatformXMLStore</code>. This is to get the manifest store in case of Tizen platform project.
+ *
+ * @param project
+ * @return IPlatformXMLStore
+ */
+ public static IPlatformXMLStore getManifestXmlStore(IProject project) {
+ PlatformManifestXMLStore store = new PlatformManifestXMLStore();
+ store.setProject(project);
+ return store;
+ }
+}
package org.tizen.nativeplatform.views.model;
+import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.tizen.nativeplatform.repository.RepoManager;
public class PlatformRootstrap extends Rootstrap implements ICheckTreeItem {
- private String http_proxy;
- private boolean checked;
- private boolean initialized;
-
- private HashMap<String, String> reposURLs = new HashMap<String, String>();
- private IPath confFile = null;
- public static final String PROPERTY_REPO_URLS = "REPOSITORY_URLS";
- public static final String PROPERTY_CONFIGURATION_FILE = "CONFIGURATION_FILE";
-
- public static final String SUPPORTED_TOOLCHAIN_TYPE = "tizen.platform";
- public static final String DEFAULT_ROOTSTRAP_ARM_ID = "tizen-device-2.1.platform";
- public static final String DEFAULT_ROOTSTRAP_I386_ID = "tizen-emulator-2.1.platform";
- private static final String VERSION = "1.0";
-
- public PlatformRootstrap(String id, String name, String arch, String rootstrapPath,
- HashMap<String, String> reposURLs, IPath confFile, boolean initialized) {
- super(id, name, SUPPORTED_TOOLCHAIN_TYPE, VERSION, arch, new Path(rootstrapPath));
- this.reposURLs = reposURLs;
- this.initialized = initialized;
- this.confFile = confFile;
- }
-
- public PlatformRootstrap(String id, String name, String arch, String rootstrapPath,
- HashMap<String, String> reposURLs, String confFile, boolean initialized) {
- super(id, name, SUPPORTED_TOOLCHAIN_TYPE, VERSION, arch, new Path(rootstrapPath));
- this.reposURLs = reposURLs;
- this.initialized = initialized;
- if (confFile != null && !confFile.isEmpty()) {
- this.confFile = new Path(confFile);
- }
- }
-
- public String getText() {
- return name;
- }
-
- public String getProxy() {
- return http_proxy;
- }
-
- public IPath getConfFile() {
- return confFile;
- }
-
- public boolean isChecked() {
- return checked;
- }
-
- public void setChecked(boolean isChecked) {
- checked = isChecked;
- }
-
- public void setConfFile(IPath path) {
- confFile = path;
- }
-
- public void setInitialized(boolean isInitialized) {
- this.initialized = isInitialized;
- }
-
- public boolean isInitialized() {
- return initialized;
- }
-
- public HashMap<String, String> getRepoMap() {
- return reposURLs;
- }
-
- public ArrayList<String> getJustRepoURLs() {
- ArrayList<String> repos = new ArrayList<String>();
- Iterator<String> keySet = reposURLs.keySet().iterator();
-
- while(keySet.hasNext()) {
- repos.add(keySet.next());
- }
-
- return repos;
- }
-
-
- public boolean addRepoURL(String url) {
- if (RepoManager.isLocalUrl(url)) {
- return addRepoURL(url, RepoManager.LOCAL_REPO_TYPE);
- } else {
- return addRepoURL(url, RepoManager.REMOTE_REPO_TYPE);
- }
- }
-
-
- public boolean addRepoURL(String url, String type) {
- boolean result = false;
-
- if (type == null) {
- type = RepoManager.REMOTE_REPO_TYPE;
- }
- if (!reposURLs.containsKey(url)) {
- result = (reposURLs.put(url, type) != null) ? true : false;
- }
-
- return result;
- }
-
- public boolean changeRepoURL(String fromUrl, String toUrl) {
- if (removeRepoURL(fromUrl)) {
- return addRepoURL(toUrl);
- } else {
- return false;
- }
- }
-
- public boolean changeRepoURL(String fromUrl, String fromType, String toUrl, String toType) {
- if (removeRepoURL(fromUrl, fromType)) {
- return addRepoURL(toUrl, toType);
- } else {
- return false;
- }
- }
-
- public boolean changeRepoURL(String fromUrl, String toUrl, String toType) {
- if (removeRepoURL(fromUrl)) {
- return addRepoURL(toUrl, toType);
- } else {
- return false;
- }
- }
-
-
- public boolean removeRepoURL(String url) {
- return removeRepoURL(url, RepoManager.getURLType(url));
- }
-
-
- public boolean removeRepoURL( String url, String type ) {
- boolean result = false;
-
- if (RepoManager.isLocalType(type)) {
- if (LocalRepoMounter.umountLocalRepository(url, null)) {
- result = (reposURLs.remove(url) != null) ? true : false;
- }
- } else {
- result = (reposURLs.remove(url) != null) ? true : false;
- }
- return result;
- }
-
-
- @Override
- public boolean isGrayed() {
- return false;
- }
-
- @Override
- public ArrayList<ICheckTreeItem> getChildren() {
- return null;
- }
-
- @Override
- public boolean hasChildren() {
- return false;
- }
+ private String http_proxy;
+ private boolean checked;
+ private boolean initialized;
+
+ private HashMap<String, String> reposURLs = new HashMap<String, String>();
+ private IPath confFile = null;
+ public static final String PROPERTY_REPO_URLS = "REPOSITORY_URLS";
+ public static final String PROPERTY_CONFIGURATION_FILE = "CONFIGURATION_FILE";
+
+ public static final String SUPPORTED_TOOLCHAIN_TYPE = "tizen.platform";
+ private static final String VERSION = "1.0";
+
+ public PlatformRootstrap(String id, String name, String arch, String rootstrapPath,
+ HashMap<String, String> reposURLs, IPath confFile, boolean initialized,
+ boolean isDefault) {
+ super(id, name, SUPPORTED_TOOLCHAIN_TYPE, VERSION, arch, new Path(rootstrapPath), isDefault);
+ this.reposURLs = reposURLs;
+ this.initialized = initialized;
+ this.confFile = confFile;
+ }
+
+ public PlatformRootstrap(String id, String name, String arch, String rootstrapPath,
+ HashMap<String, String> reposURLs, String confFile, boolean initialized,
+ boolean isDefault) {
+ super(id, name, SUPPORTED_TOOLCHAIN_TYPE, VERSION, arch, new Path(rootstrapPath), isDefault);
+ this.reposURLs = reposURLs;
+ this.initialized = initialized;
+ if (confFile != null && !confFile.isEmpty()) {
+ this.confFile = new Path(confFile);
+ }
+ }
+
+ public PlatformRootstrap(String id, String name, String arch, String rootstrapPath,
+ HashMap<String, String> reposURLs, String confFile, boolean initialized) {
+ super(id, name, SUPPORTED_TOOLCHAIN_TYPE, VERSION, arch, new Path(rootstrapPath), false);
+ this.reposURLs = reposURLs;
+ this.initialized = initialized;
+ if (confFile != null && !confFile.isEmpty()) {
+ this.confFile = new Path(confFile);
+ }
+ }
+
+ public String getText() {
+ return name;
+ }
+
+ public String getProxy() {
+ return http_proxy;
+ }
+
+ public IPath getConfFile() {
+ return confFile;
+ }
+
+ public boolean isChecked() {
+ return checked;
+ }
+
+ public void setChecked(boolean isChecked) {
+ checked = isChecked;
+ }
+
+ public void setConfFile(IPath path) {
+ confFile = path;
+ }
+
+ public void setInitialized(boolean isInitialized) {
+ this.initialized = isInitialized;
+ }
+
+ public boolean isInitialized() {
+ return initialized;
+ }
+
+ public boolean checkInitialized() {
+ boolean exists = new File(getPath().toOSString()).exists() ? true : false;
+ setInitialized(exists);
+ return exists;
+ }
+
+ public HashMap<String, String> getRepoMap() {
+ return reposURLs;
+ }
+
+ public ArrayList<String> getJustRepoURLs() {
+ ArrayList<String> repos = new ArrayList<String>();
+ Iterator<String> keySet = reposURLs.keySet().iterator();
+
+ while (keySet.hasNext()) {
+ repos.add(keySet.next());
+ }
+
+ return repos;
+ }
+
+ public boolean addRepoURL(String url) {
+ if (RepoManager.isLocalUrl(url)) {
+ return addRepoURL(url, RepoManager.LOCAL_REPO_TYPE);
+ } else {
+ return addRepoURL(url, RepoManager.REMOTE_REPO_TYPE);
+ }
+ }
+
+ public boolean addRepoURL(String url, String type) {
+ boolean result = false;
+
+ if (type == null) {
+ type = RepoManager.REMOTE_REPO_TYPE;
+ }
+ if (!reposURLs.containsKey(url)) {
+ result = (reposURLs.put(url, type) != null) ? true : false;
+ }
+
+ return result;
+ }
+
+ public boolean changeRepoURL(String fromUrl, String toUrl) {
+ if (removeRepoURL(fromUrl)) {
+ return addRepoURL(toUrl);
+ } else {
+ return false;
+ }
+ }
+
+ public boolean changeRepoURL(String fromUrl, String fromType, String toUrl, String toType) {
+ if (removeRepoURL(fromUrl, fromType)) {
+ return addRepoURL(toUrl, toType);
+ } else {
+ return false;
+ }
+ }
+
+ public boolean changeRepoURL(String fromUrl, String toUrl, String toType) {
+ if (removeRepoURL(fromUrl)) {
+ return addRepoURL(toUrl, toType);
+ } else {
+ return false;
+ }
+ }
+
+ public boolean removeRepoURL(String url) {
+ return removeRepoURL(url, RepoManager.getURLType(url));
+ }
+
+ public boolean removeRepoURL(String url, String type) {
+ boolean result = false;
+
+ if (RepoManager.isLocalType(type)) {
+ if (LocalRepoMounter.umountLocalRepository(url, null)) {
+ result = (reposURLs.remove(url) != null) ? true : false;
+ }
+ } else {
+ result = (reposURLs.remove(url) != null) ? true : false;
+ }
+ return result;
+ }
+
+ @Override
+ public boolean isGrayed() {
+ return false;
+ }
+
+ @Override
+ public ArrayList<ICheckTreeItem> getChildren() {
+ return null;
+ }
+
+ @Override
+ public boolean hasChildren() {
+ return false;
+ }
}
package org.tizen.nativeplatform.views.ui;
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.ResourceBundle;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ICheckStateProvider;
import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
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.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.tizen.common.util.DialogUtil;
-import org.tizen.common.util.SWTUtil;
-import org.tizen.nativeplatform.filefilter.RpmFileFilter;
-import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander;
-import org.tizen.nativeplatform.pkgmgr.model.Package;
-import org.tizen.nativeplatform.pkgmgr.model.Repository;
import org.tizen.nativeplatform.repository.RepoManager;
-import org.tizen.nativeplatform.rootstrap.RootstrapManager;
-import org.tizen.nativeplatform.rootstrap.SnapshotURLParser;
-import org.tizen.nativeplatform.views.model.ICheckTreeItem;
public class LocalRepoTab implements IRepositoryTab {
- protected TableViewer repoViewer = null;
- protected CheckboxTableViewer pkgViewer = null;
- protected Combo categoryCombo;
- protected Text filterText;
-
- protected final Shell shell;
- protected TabFolder folder = null;
- private Text repoPathText;
- private Text confFilePathText;
- private Combo archCombo;
- private Button generateImmediateBt;
-
- private String architecture;
- private ArrayList<String> repositoryURLs;
- private IPath buildConfFile = null;
- boolean isImmediateGenerateChecked;
-
- protected final String BUNDLE_NAME = RemoteRepoTab.class.getPackage().getName() + ".RootstrapUIMessages";//$NON-NLS-1$
- protected final ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
-
- public LocalRepoTab(Shell shell, TabFolder folder) {
- this.shell = shell;
- this.folder = folder;
- }
-
- public void createTab() {
- TabItem tab = new TabItem( folder, SWT.NULL );
- tab.setText(resources.getString("LocalRepoTab.Title"));
-
- Composite composite = new Composite(folder, SWT.NONE);
- tab.setControl(composite);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
+ protected TableViewer repoViewer = null;
+ protected CheckboxTableViewer pkgViewer = null;
+ protected Combo categoryCombo;
+ protected Text filterText;
+
+ protected final Shell shell;
+ protected TabFolder folder = null;
+ private Text repoPathText;
+ private Text confFilePathText;
+ private Combo archCombo;
+ private Button generateImmediateBt;
+
+ private String architecture;
+ private ArrayList<String> repositoryURLs;
+ private IPath buildConfFile = null;
+ boolean isImmediateGenerateChecked;
+
+ protected final String BUNDLE_NAME = RemoteRepoTab.class.getPackage().getName()
+ + ".RootstrapUIMessages";//$NON-NLS-1$
+ protected final ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ public LocalRepoTab(Shell shell, TabFolder folder) {
+ this.shell = shell;
+ this.folder = folder;
+ }
+
+ public void createTab() {
+ TabItem tab = new TabItem(folder, SWT.NULL);
+ tab.setText(resources.getString("LocalRepoTab.Title"));
+
+ Composite composite = new Composite(folder, SWT.NONE);
+ tab.setControl(composite);
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
+ | GridData.VERTICAL_ALIGN_BEGINNING));
composite.setLayout(new GridLayout(1, false));
createSelectRepoComposite(composite);
createSelectBuildConfFileComposite(composite);
createGenButtonComposite(composite);
- }
-
- private void createSelectRepoComposite(Composite parent) {
-
- Group group = new Group(parent, SWT.NONE);
- group.setLayout(new GridLayout(1, false));
- group.setText(resources.getString("LocalRepoTab.Group.Repos"));
- //GridData gridData = new GridData(GridData.FILL_BOTH);
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
- group.setLayoutData(gridData);
-
- createRepoPathComposite(group);
- createArchitectureComposite(group);
- }
-
- private void createSelectBuildConfFileComposite(Composite parent) {
-
- Group group = new Group(parent, SWT.NONE);
- group.setLayout(new GridLayout(1, false));
- group.setText(resources.getString("LocalRepoTab.Group.BuildConf"));
- //GridData gridData = new GridData(GridData.FILL_BOTH);
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
- group.setLayoutData(gridData);
-
- createConfFilePathComposite(group);
- }
-
- private void createRepoPathComposite(Composite parent) {
- Composite snapshotComp = new Composite(parent, SWT.NONE);
- snapshotComp.setLayout(new GridLayout(3, false));
- GridData gridData = new GridData(GridData.FILL_BOTH);
- snapshotComp.setLayoutData(gridData);
-
- Label snapshotLabel = new Label(snapshotComp, SWT.NONE);
- //gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_BEGINNING);
- gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gridData.widthHint = 105;
- snapshotLabel.setLayoutData(gridData);
- snapshotLabel.setAlignment(SWT.RIGHT);
- snapshotLabel.setText(resources.getString("LocalRepoTab.Label.RepoPath"));
-
- repoPathText = new Text(snapshotComp, SWT.SINGLE | SWT.BORDER);
- gridData = new GridData(GridData.FILL_HORIZONTAL);
- //gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
- repoPathText.setLayoutData(gridData);
- repoPathText.setEditable(false);
-
- Button searchBt = new Button(snapshotComp, SWT.PUSH);
- searchBt.setText(resources.getString("LocalRepoTab.Button.Browse"));
-
- searchBt.addMouseListener(new MouseListener() {
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
-
- DirectoryDialog dialog = new DirectoryDialog(shell);
- dialog.setText(resources.getString("LocalRepoTab.RepoDlg.Title"));
- String repoPath = dialog.open();
-
- if ( repoPath == null ) {
- return;
- } else {
- IPath path = new Path(repoPath);
- if (RepoManager.getValidator(path).validate()) {
- ArrayList<String> archs = RepoManager.getValidator(path).availableArchs();
- if (archs == null) {
- DialogUtil.openErrorDialog(resources.getString("LocalRepoTab.Error.getArch"));
- return;
- }
-
- repoPathText.setText(repoPath);
- archCombo.removeAll();
- archCombo.setItems(archs.toArray(new String[0]));
- archCombo.select(0);
- } else {
- DialogUtil.openErrorDialog(resources.getString("LocalRepoTab.Error.NotLocalRepo"));
- return;
- }
-
- }
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- }
-
- });
- }
-
- private void createGenButtonComposite(Composite parent) {
- Composite composite = new Composite( parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- composite.setLayout(new GridLayout(1, false));
-
- generateImmediateBt = new Button(composite, SWT.CHECK);
- generateImmediateBt.setText(resources.getString("GenRootDlg.Button.GenImmedate"));
- //GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING);
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
- generateImmediateBt.setLayoutData(gridData);
- }
-
- private void createArchitectureComposite(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(2, false));
- GridData gridData = new GridData(GridData.FILL_BOTH);
- composite.setLayoutData(gridData);
-
- Label archLabel = new Label(composite, SWT.NONE);
- gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_BEGINNING);
- gridData.widthHint = 105;
- archLabel.setLayoutData(gridData);
- archLabel.setAlignment(SWT.RIGHT);
+ }
+
+ private void createSelectRepoComposite(Composite parent) {
+
+ Group group = new Group(parent, SWT.NONE);
+ group.setLayout(new GridLayout(1, false));
+ group.setText(resources.getString("LocalRepoTab.Group.Repos"));
+ // GridData gridData = new GridData(GridData.FILL_BOTH);
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL
+ | GridData.VERTICAL_ALIGN_BEGINNING);
+ group.setLayoutData(gridData);
+
+ createRepoPathComposite(group);
+ createArchitectureComposite(group);
+ }
+
+ private void createSelectBuildConfFileComposite(Composite parent) {
+
+ Group group = new Group(parent, SWT.NONE);
+ group.setLayout(new GridLayout(1, false));
+ group.setText(resources.getString("LocalRepoTab.Group.BuildConf"));
+ // GridData gridData = new GridData(GridData.FILL_BOTH);
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL
+ | GridData.VERTICAL_ALIGN_BEGINNING);
+ group.setLayoutData(gridData);
+
+ createConfFilePathComposite(group);
+ }
+
+ private void createRepoPathComposite(Composite parent) {
+ Composite snapshotComp = new Composite(parent, SWT.NONE);
+ snapshotComp.setLayout(new GridLayout(3, false));
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ snapshotComp.setLayoutData(gridData);
+
+ Label snapshotLabel = new Label(snapshotComp, SWT.NONE);
+ // gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL |
+ // GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gridData.widthHint = 105;
+ snapshotLabel.setLayoutData(gridData);
+ snapshotLabel.setAlignment(SWT.RIGHT);
+ snapshotLabel.setText(resources.getString("LocalRepoTab.Label.RepoPath"));
+
+ repoPathText = new Text(snapshotComp, SWT.SINGLE | SWT.BORDER);
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+ // gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL |
+ // GridData.VERTICAL_ALIGN_BEGINNING);
+ repoPathText.setLayoutData(gridData);
+ repoPathText.setEditable(false);
+
+ Button searchBt = new Button(snapshotComp, SWT.PUSH);
+ searchBt.setText(resources.getString("LocalRepoTab.Button.Browse"));
+
+ searchBt.addMouseListener(new MouseListener() {
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+
+ DirectoryDialog dialog = new DirectoryDialog(shell);
+ dialog.setText(resources.getString("LocalRepoTab.RepoDlg.Title"));
+ String repoPath = dialog.open();
+
+ if (repoPath == null) {
+ return;
+ } else {
+ IPath path = new Path(repoPath);
+ if (RepoManager.getValidator(path).validate()) {
+ ArrayList<String> archs = RepoManager.getValidator(path).availableArchs();
+ if (archs == null) {
+ DialogUtil.openErrorDialog(resources
+ .getString("LocalRepoTab.Error.getArch"));
+ return;
+ }
+
+ repoPathText.setText(repoPath);
+ archCombo.removeAll();
+ archCombo.setItems(archs.toArray(new String[0]));
+ archCombo.select(0);
+ } else {
+ DialogUtil.openErrorDialog(resources
+ .getString("LocalRepoTab.Error.NotLocalRepo"));
+ return;
+ }
+
+ }
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ }
+
+ });
+ }
+
+ private void createGenButtonComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ composite.setLayout(new GridLayout(1, false));
+
+ generateImmediateBt = new Button(composite, SWT.CHECK);
+ generateImmediateBt.setText(resources.getString("GenRootDlg.Button.GenImmedate"));
+ // GridData gridData = new GridData(GridData.FILL_HORIZONTAL |
+ // GridData.HORIZONTAL_ALIGN_BEGINNING);
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL
+ | GridData.VERTICAL_ALIGN_BEGINNING);
+ generateImmediateBt.setLayoutData(gridData);
+ }
+
+ private void createArchitectureComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(2, false));
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ composite.setLayoutData(gridData);
+
+ Label archLabel = new Label(composite, SWT.NONE);
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gridData.widthHint = 105;
+ archLabel.setLayoutData(gridData);
+ archLabel.setAlignment(SWT.RIGHT);
archLabel.setText(resources.getString("GenRootDlg.Label.Architecture"));
archCombo = new Combo(composite, SWT.READ_ONLY);
gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
- gridData.minimumHeight = 0;
- archCombo.setLayoutData(gridData);
- archCombo.addSelectionListener( new SelectionListener(){
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- //UpdateRepositoryURL();
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
+ gridData.minimumHeight = 0;
+ archCombo.setLayoutData(gridData);
+ archCombo.addSelectionListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ // UpdateRepositoryURL();
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
});
- //archCombo.setEnabled(false);
- }
-
- private void createConfFilePathComposite(Composite parent) {
- Composite snapshotComp = new Composite(parent, SWT.NONE);
- snapshotComp.setLayout(new GridLayout(3, false));
- GridData gridData = new GridData(GridData.FILL_BOTH);
- snapshotComp.setLayoutData(gridData);
-
- Label snapshotLabel = new Label(snapshotComp, SWT.NONE);
+ // archCombo.setEnabled(false);
+ }
+
+ private void createConfFilePathComposite(Composite parent) {
+ Composite snapshotComp = new Composite(parent, SWT.NONE);
+ snapshotComp.setLayout(new GridLayout(3, false));
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ snapshotComp.setLayoutData(gridData);
+
+ Label snapshotLabel = new Label(snapshotComp, SWT.NONE);
gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gridData.widthHint = 70;
- snapshotLabel.setLayoutData(gridData);
- snapshotLabel.setAlignment(SWT.RIGHT);
- snapshotLabel.setText(resources.getString("LocalRepoTab.Label.FilePath"));
-
- confFilePathText = new Text(snapshotComp, SWT.SINGLE | SWT.BORDER);
- gridData = new GridData(GridData.FILL_HORIZONTAL);
- confFilePathText.setLayoutData(gridData);
- confFilePathText.setEditable(false);
-
- Button searchBt = new Button(snapshotComp, SWT.PUSH);
- searchBt.setText(resources.getString("LocalRepoTab.Button.Browse"));
-
- searchBt.addMouseListener(new MouseListener() {
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- FileDialog fd = new FileDialog( shell, SWT.OPEN);
- fd.setText(resources.getString("LocalRepoTab.ConfFileDlg.Title"));
- String[] filterExt = { resources.getString("LocalRepoTab.ConfFileDlg.Filter.Ext") };
- fd.setFilterExtensions(filterExt);
- String filePath = fd.open();
- if ( filePath == null ) { return; }
-
- buildConfFile = new Path(filePath);
- confFilePathText.setText(buildConfFile.toOSString());
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- }
-
- });
- }
-
- @Override
- public ArrayList<String> getRepositoryURLs() {
- return repositoryURLs;
- }
-
- @Override
- public String getArchitecture() {
- return architecture;
- }
-
- @Override
- public boolean isImmediateGenerateChecked() {
- return isImmediateGenerateChecked;
- }
-
- @Override
- public IPath getBuildConfFile() {
- return buildConfFile;
- }
-
- @Override
- public boolean saveState() {
- String repo = repoPathText.getText();
- if (repo == null || repo.isEmpty()) {
- DialogUtil.openErrorDialog(
- resources.getString("LocalRepoTab.Error.Empty.Repo"));
- return false;
- }
-
- String arch = archCombo.getText();
- if (arch == null || arch.isEmpty()) {
- DialogUtil.openErrorDialog(
- resources.getString("GenRootDlg.Error.Empty.Arch"));
- return false;
- }
-
- if (buildConfFile == null) {
- DialogUtil.openErrorDialog(
- resources.getString("LocalRepoTab.Error.Empty.ConfFile"));
- return false;
- }
-
- architecture = arch.trim();
- repositoryURLs = new ArrayList<String>();
- repositoryURLs.add(repoPathText.getText().trim());
- isImmediateGenerateChecked = generateImmediateBt.getSelection();
-
- return true;
- }
+ gridData.widthHint = 70;
+ snapshotLabel.setLayoutData(gridData);
+ snapshotLabel.setAlignment(SWT.RIGHT);
+ snapshotLabel.setText(resources.getString("LocalRepoTab.Label.FilePath"));
+
+ confFilePathText = new Text(snapshotComp, SWT.SINGLE | SWT.BORDER);
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+ confFilePathText.setLayoutData(gridData);
+ confFilePathText.setEditable(false);
+
+ Button searchBt = new Button(snapshotComp, SWT.PUSH);
+ searchBt.setText(resources.getString("LocalRepoTab.Button.Browse"));
+
+ searchBt.addMouseListener(new MouseListener() {
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ FileDialog fd = new FileDialog(shell, SWT.OPEN);
+ fd.setText(resources.getString("LocalRepoTab.ConfFileDlg.Title"));
+ String[] filterExt = { resources.getString("LocalRepoTab.ConfFileDlg.Filter.Ext") };
+ fd.setFilterExtensions(filterExt);
+ String filePath = fd.open();
+ if (filePath == null) {
+ return;
+ }
+
+ buildConfFile = new Path(filePath);
+ confFilePathText.setText(buildConfFile.toOSString());
+ }
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ }
+
+ });
+ }
+
+ @Override
+ public ArrayList<String> getRepositoryURLs() {
+ return repositoryURLs;
+ }
+
+ @Override
+ public String getArchitecture() {
+ return architecture;
+ }
+
+ @Override
+ public boolean isImmediateGenerateChecked() {
+ return isImmediateGenerateChecked;
+ }
+
+ @Override
+ public IPath getBuildConfFile() {
+ return buildConfFile;
+ }
+
+ @Override
+ public boolean saveState() {
+ String repo = repoPathText.getText();
+ if (repo == null || repo.isEmpty()) {
+ DialogUtil.openErrorDialog(resources.getString("LocalRepoTab.Error.Empty.Repo"));
+ return false;
+ }
+
+ String arch = archCombo.getText();
+ if (arch == null || arch.isEmpty()) {
+ DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.Empty.Arch"));
+ return false;
+ }
+
+ if (buildConfFile == null) {
+ DialogUtil.openErrorDialog(resources.getString("LocalRepoTab.Error.Empty.ConfFile"));
+ return false;
+ }
+
+ architecture = arch.trim();
+ repositoryURLs = new ArrayList<String>();
+ repositoryURLs.add(repoPathText.getText().trim());
+ isImmediateGenerateChecked = generateImmediateBt.getSelection();
+
+ return true;
+ }
}
package org.tizen.nativeplatform.views.ui;
-import java.io.IOException;
import java.util.ResourceBundle;
-import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.Text;
-import org.osgi.framework.Bundle;
-import org.tizen.common.connection.ConnectionPlugin;
import org.tizen.common.util.DialogUtil;
-import org.tizen.nativeplatform.Activator;
-import org.tizen.sdblib.IDevice;
-import org.tizen.nativeplatform.pkgmgr.RPMPackageCommander;
-import org.tizen.nativeplatform.pkgmgr.model.LocalPkgProvider;
-import org.tizen.nativeplatform.pkgmgr.model.PackageProvider;
-import org.tizen.nativeplatform.pkgmgr.model.RemotePkgProvider;
-import org.tizen.nativeplatform.preferences.PreferencesManager;
import org.tizen.nativeplatform.rootstrap.RootstrapManager;
-import org.tizen.nativeplatform.views.model.PlatformRootstrap;
-
-public class RootstrapGenDialog extends Dialog {
-
- private TabFolder tabFolder;
- private int tabIndex = 0;
-
- private int x = 0;
- private int y = 0;
- private final int width = 900;
- private final int height = 600;
-
- private Text rootstrapText;
- private RemoteRepoTab remoteTab;
- private LocalRepoTab localTab;
- private IRepositoryTab selectionTab = null;
- private int selectionIndex = 0;
- private String rootstrapName;
-
- public static final int REMOTE_REPO_TAB = 0;
- public static final int LOCAL_REPO_TAB = 1;
-
- private final String BUNDLE_NAME = RootstrapGenDialog.class.getPackage().getName() + ".RootstrapUIMessages";//$NON-NLS-1$
- private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
-
-
- public RootstrapGenDialog(Shell parentShell) {
- super(parentShell);
-
- Rectangle bounds = parentShell.getBounds();
- x = bounds.x + (bounds.width - width)/2;
- y = bounds.y + (bounds.height - height)/2;
- }
-
-
- protected void setShellStyle(int newShellStyle) {
- int newStyle = newShellStyle;// & ~SWT.APPLICATION_MODAL;
- //newStyle |= SWT.MODELESS;
- super.setShellStyle(newStyle);
- }
-
- @Override
- public boolean close()
- {
- return super.close();
- }
-
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(resources.getString("GenRootDlg.Title"));
-
- newShell.setLocation(x, y);
- newShell.setSize(width, height);
- }
-
-
- @Override
- protected Control createDialogArea(Composite parent) {
-
- Composite container = new Composite( parent, SWT.None );
- container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
- container.setLayout(new GridLayout(1, false));
- createDialogDescription ( container );
- createRootstrapNameComposite(container);
- createTabs ( container );
- return null;
- }
-
- private void createDialogDescription(Composite composite)
- {
+
+public class RootstrapGenDialog extends Dialog {
+
+ private TabFolder tabFolder;
+ private int tabIndex = 0;
+
+ private int x = 0;
+ private int y = 0;
+ private final int width = 900;
+ private final int height = 600;
+
+ private Text rootstrapText;
+ private RemoteRepoTab remoteTab;
+ private LocalRepoTab localTab;
+ private IRepositoryTab selectionTab = null;
+ private int selectionIndex = 0;
+ private String rootstrapName;
+
+ public static final int REMOTE_REPO_TAB = 0;
+ public static final int LOCAL_REPO_TAB = 1;
+
+ private final String BUNDLE_NAME = RootstrapGenDialog.class.getPackage().getName()
+ + ".RootstrapUIMessages";//$NON-NLS-1$
+ private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ public RootstrapGenDialog(Shell parentShell) {
+ super(parentShell);
+
+ Rectangle bounds = parentShell.getBounds();
+ x = bounds.x + (bounds.width - width) / 2;
+ y = bounds.y + (bounds.height - height) / 2;
+ }
+
+ protected void setShellStyle(int newShellStyle) {
+ int newStyle = newShellStyle;// & ~SWT.APPLICATION_MODAL;
+ // newStyle |= SWT.MODELESS;
+ super.setShellStyle(newStyle);
+ }
+
+ @Override
+ public boolean close() {
+ return super.close();
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(resources.getString("GenRootDlg.Title"));
+
+ newShell.setLocation(x, y);
+ newShell.setSize(width, height);
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+
+ Composite container = new Composite(parent, SWT.None);
+ container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL
+ | GridData.VERTICAL_ALIGN_BEGINNING));
+ container.setLayout(new GridLayout(1, false));
+ createDialogDescription(container);
+ createRootstrapNameComposite(container);
+ createTabs(container);
+ return null;
+ }
+
+ private void createDialogDescription(Composite composite) {
Composite comp_descrip = new Composite(composite, SWT.NONE);
Color whiteColor = new Color(composite.getDisplay(), 255, 255, 255);
label.setText(resources.getString("GenRootDlg.Desc"));
label.setBackground(whiteColor);
}
-
- private void createRootstrapNameComposite(Composite parent) {
- Composite composite = new Composite( parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- composite.setLayout(new GridLayout(2, false));
+
+ private void createRootstrapNameComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ composite.setLayout(new GridLayout(2, false));
Label nameLabel = new Label(composite, SWT.NONE);
nameLabel.setText(resources.getString("GenRootDlg.Label.Rootstrapname"));
rootstrapText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH);
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
- gridData.minimumHeight = 0;
- rootstrapText.setLayoutData(gridData);
- }
-
-
- private void createTabs( Composite parent )
- {
- tabFolder = new TabFolder( parent, SWT.BORDER );
- GridData data = new GridData(GridData.FILL_BOTH);
- data.heightHint = 400;
-
- tabFolder.setLayoutData(data);
- tabFolder.setLayout(new GridLayout(1, false));
-
- remoteTab = new RemoteRepoTab(getShell(), tabFolder);
- remoteTab.createTab();
- localTab = new LocalRepoTab(getShell(), tabFolder);
- localTab.createTab();
-
- tabFolder.setSelection(tabIndex);
- }
-
- public IRepositoryTab getSelectionTab() {
- return selectionTab;
- }
-
- public int getTabIndex() {
- return selectionIndex;
- }
-
- public boolean isSelectedRemoteRepo() {
- return (selectionIndex == REMOTE_REPO_TAB) ? true : false;
- }
-
- public boolean isSelectedLocalRepo() {
- return (selectionIndex == LOCAL_REPO_TAB) ? true : false;
- }
-
- public String getRootstrapName() {
- return rootstrapName;
- }
-
- @Override
- protected void okPressed() {
- rootstrapName = rootstrapText.getText().trim();
- if (rootstrapName.isEmpty()) {
- DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.Empty.Rootstrap"));
- return;
- }
-
- if ( RootstrapManager.getRootstrap(rootstrapName ) != null ) {
- DialogUtil.openErrorDialog("Rootstrap name ["+rootstrapName+"] already exists!");
- return;
- }
-
- if (tabFolder.getSelectionIndex() == REMOTE_REPO_TAB) {
- if (!remoteTab.saveState()) {
- //DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.Incorrect.Info"));
- return;
- }
- selectionTab = (IRepositoryTab)remoteTab;
- selectionIndex = REMOTE_REPO_TAB;
- } else if (tabFolder.getSelectionIndex() == LOCAL_REPO_TAB) {
- if (!localTab.saveState()) {
- //DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.Incorrect.Info"));
- return;
- }
- selectionTab = (IRepositoryTab)localTab;
- selectionIndex = LOCAL_REPO_TAB;
- }
- super.okPressed();
- }
-
- public void initializeDialogData(IProgressMonitor monitor) throws InterruptedException {
- // init data for buildSystem Tab
- }
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+ gridData.minimumHeight = 0;
+ rootstrapText.setLayoutData(gridData);
+ }
+
+ private void createTabs(Composite parent) {
+ tabFolder = new TabFolder(parent, SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.heightHint = 400;
+
+ tabFolder.setLayoutData(data);
+ tabFolder.setLayout(new GridLayout(1, false));
+
+ remoteTab = new RemoteRepoTab(getShell(), tabFolder);
+ remoteTab.createTab();
+ localTab = new LocalRepoTab(getShell(), tabFolder);
+ localTab.createTab();
+
+ tabFolder.setSelection(tabIndex);
+ }
+
+ public IRepositoryTab getSelectionTab() {
+ return selectionTab;
+ }
+
+ public int getTabIndex() {
+ return selectionIndex;
+ }
+
+ public boolean isSelectedRemoteRepo() {
+ return (selectionIndex == REMOTE_REPO_TAB) ? true : false;
+ }
+
+ public boolean isSelectedLocalRepo() {
+ return (selectionIndex == LOCAL_REPO_TAB) ? true : false;
+ }
+
+ public String getRootstrapName() {
+ return rootstrapName;
+ }
+
+ @Override
+ protected void okPressed() {
+ rootstrapName = rootstrapText.getText().trim();
+ if (rootstrapName.isEmpty()) {
+ DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.Empty.Rootstrap"));
+ return;
+ }
+
+ if (RootstrapManager.getRootstrap(rootstrapName) != null) {
+ DialogUtil.openErrorDialog("Rootstrap name [" + rootstrapName + "] already exists!");
+ return;
+ }
+
+ if (tabFolder.getSelectionIndex() == REMOTE_REPO_TAB) {
+ if (!remoteTab.saveState()) {
+ // DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.Incorrect.Info"));
+ return;
+ }
+ selectionTab = (IRepositoryTab) remoteTab;
+ selectionIndex = REMOTE_REPO_TAB;
+ } else if (tabFolder.getSelectionIndex() == LOCAL_REPO_TAB) {
+ if (!localTab.saveState()) {
+ // DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.Incorrect.Info"));
+ return;
+ }
+ selectionTab = (IRepositoryTab) localTab;
+ selectionIndex = LOCAL_REPO_TAB;
+ }
+ super.okPressed();
+ }
+
+ public void initializeDialogData(IProgressMonitor monitor) throws InterruptedException {
+ // init data for buildSystem Tab
+ }
}
\ No newline at end of file
package org.tizen.nativeplatform.views.ui;
-import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
+import java.util.List;
import java.util.ResourceBundle;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.part.ViewPart;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.tizen.common.TizenHelpContextIds;
+import org.tizen.common.connection.ConnectionPlugin;
import org.tizen.common.util.DialogUtil;
import org.tizen.common.util.ImageUtil;
-
import org.tizen.nativecommon.ProjectUtil;
import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativecommon.build.exception.SBIException;
import org.tizen.nativeplatform.Activator;
import org.tizen.nativeplatform.build.PlatformConfigurationManager;
+import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
+import org.tizen.nativeplatform.pkgmgr.PkgMgrInitializer;
import org.tizen.nativeplatform.pkgmgr.ui.RPMPackageDialog;
import org.tizen.nativeplatform.repository.LocalRepoMounter;
import org.tizen.nativeplatform.repository.RepoManager;
import org.tizen.nativeplatform.rootstrap.IRootstrapChangedListener;
-import org.tizen.nativeplatform.views.model.PlatformRootstrap;
import org.tizen.nativeplatform.rootstrap.RootstrapManager;
+import org.tizen.nativeplatform.views.model.PlatformRootstrap;
+import org.tizen.sdblib.IDevice;
public class RootstrapView extends ViewPart {
-
- private ToolBar toolBar;
- private TableViewer tableViewer;
- private final int COL_IDX_ROOTNAME = 0;
- private final int COL_IDX_ARCH = 1;
- private Text rootDescText;
-
- private Action actionSetDefault;
- private Action actionChangeConfFile;
- private Action actionPkgMgr;
- private Action actionRemove;
- private Action actionExport;
- private MenuManager menuMgr;
-
- private PlatformRootstrap generatedRootstrap;
- private final int MINIMUM_VIEW_WIDTH = 300;
-
- private IProject project;
- private Shell shell;
-
- private static final String PLATFORM_PERSPECTIVE_ID = "org.tizen.nativeplatform.perspective";
-
- private final String BUNDLE_NAME = AddRootstrapDialog.class.getPackage().getName() + ".RootstrapUIMessages";//$NON-NLS-1$
- private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
-
- private IRootstrapChangedListener cListener = new IRootstrapChangedListener()
- {
- @Override
- public void rootstrapChanged() {
- Display.getDefault().syncExec(new Runnable() {
-
- @Override
- public void run() {
- tableViewer.refresh();
- }
- });
- }
-
- @Override
- public void selectionChanged(String rootName) {
-
- }
- };
+
+ private ToolBar toolBar;
+ private TableViewer tableViewer;
+ private final int COL_IDX_ROOTNAME = 0;
+ private final int COL_IDX_ARCH = 1;
+ private Text rootDescText;
+
+ private Action actionSetDefault;
+ private Action actionChangeConfFile;
+ private Action actionPkgMgr;
+ private Action actionRemove;
+ private Action actionExport;
+ private MenuManager menuMgr;
+
+ private PlatformRootstrap generatedRootstrap;
+ private final int MINIMUM_VIEW_WIDTH = 300;
+
+ private IProject project;
+ private Shell shell;
+
+ private static final String PLATFORM_PERSPECTIVE_ID = "org.tizen.nativeplatform.perspective";
+
+ private final String BUNDLE_NAME = AddRootstrapDialog.class.getPackage().getName()
+ + ".RootstrapUIMessages";//$NON-NLS-1$
+ private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
- private ICProjectDescriptionListener prjListner = new ICProjectDescriptionListener()
- {
+ protected final Logger logger = LoggerFactory.getLogger(RootstrapView.class);
+
+ private IRootstrapChangedListener cListener = new IRootstrapChangedListener() {
+ @Override
+ public void rootstrapChanged() {
+ Display.getDefault().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ tableViewer.refresh();
+ }
+ });
+ }
@Override
- public void handleEvent(CProjectDescriptionEvent event)
- {
+ public void selectionChanged(String rootName) {
+
+ }
+ };
+
+ private ICProjectDescriptionListener prjListner = new ICProjectDescriptionListener() {
+
+ @Override
+ public void handleEvent(CProjectDescriptionEvent event) {
final String appliedConfigName = event.getAppliedCProjectDescription()
.getActiveConfiguration().getName();
-
- project = event.getProject();
+
+ project = event.getProject();
if (project != null) {
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
- IConfiguration config = info.getDefaultConfiguration();
- IManagedProject managedProject = config.getManagedProject();
-
- String projectArtifactType = managedProject.getProjectType() != null ?
- managedProject.getProjectType().getBuildArtefactType().getId() : null;
- if ( projectArtifactType != null &&
- (!projectArtifactType.equals(PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE))) {
- return;
- }
-
- for (IConfiguration c : managedProject.getConfigurations()) {
- if (c.getName().equals(appliedConfigName)) {
- config = c;
- break;
- }
- }
- String targetId = PlatformConfigurationManager.getBuildTargetName(config);
- if (targetId == null) {
- RootstrapManager.resetSelectedRootstrap();
- return;
- }
- SmartBuildInterface sbi = SmartBuildInterface.getInstance();
- String rootId = sbi.getRootstrapIDFromTargetID(targetId);
- RootstrapManager.setSelectedRootstrap(rootId);
- RootstrapManager.notifyChangedRootstrap();
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ IConfiguration config = info.getDefaultConfiguration();
+ IManagedProject managedProject = config.getManagedProject();
+
+ String projectArtifactType = managedProject.getProjectType() != null ? managedProject
+ .getProjectType().getBuildArtefactType().getId()
+ : null;
+ if (projectArtifactType != null
+ && (!projectArtifactType
+ .equals(PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE))) {
+ return;
+ }
+
+ for (IConfiguration c : managedProject.getConfigurations()) {
+ if (c.getName().equals(appliedConfigName)) {
+ config = c;
+ break;
+ }
+ }
+ String targetId = PlatformConfigurationManager.getBuildTargetName(config);
+ if (targetId == null) {
+ RootstrapManager.resetSelectedRootstrap();
+ return;
+ }
+ SmartBuildInterface sbi = SmartBuildInterface.getInstance();
+ String rootId = sbi.getRootstrapIDFromTargetID(targetId);
+ RootstrapManager.setSelectedRootstrap(rootId);
+ RootstrapManager.notifyChangedRootstrap();
} else {
- RootstrapManager.resetSelectedRootstrap();
+ RootstrapManager.resetSelectedRootstrap();
}
-
+
}
};
-
- private ISelectionListener listener = new ISelectionListener()
- {
+
+ private ISelectionListener listener = new ISelectionListener() {
@Override
- public void selectionChanged(IWorkbenchPart sourcepart, ISelection selection)
- {
+ public void selectionChanged(IWorkbenchPart sourcepart, ISelection selection) {
String perspectiveID = sourcepart.getSite().getPage().getPerspective().getId();
if (!perspectiveID.equals(PLATFORM_PERSPECTIVE_ID)) {
return;
project = ProjectUtil.getProject(sourcepart, selection);
- if (project != null) {
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
- IConfiguration config = info.getDefaultConfiguration();
- String targetId = PlatformConfigurationManager.getBuildTargetName(config);
- SmartBuildInterface sbi = SmartBuildInterface.getInstance();
- String rootId = sbi.getRootstrapIDFromTargetID(targetId);
- RootstrapManager.setSelectedRootstrap(rootId);
- RootstrapManager.notifyChangedRootstrap();
+ if (project != null) {
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ IConfiguration config = info.getDefaultConfiguration();
+ String targetId = PlatformConfigurationManager.getBuildTargetName(config);
+ SmartBuildInterface sbi = SmartBuildInterface.getInstance();
+ String rootId = sbi.getRootstrapIDFromTargetID(targetId);
+ RootstrapManager.setSelectedRootstrap(rootId);
+ RootstrapManager.notifyChangedRootstrap();
} else {
- RootstrapManager.resetSelectedRootstrap();
+ RootstrapManager.resetSelectedRootstrap();
}
}
};
-
- @Override
- public void createPartControl(Composite parent) {
-
- shell = this.getViewSite().getShell();
-
- RootstrapManager.addListener(cListener);
+ @Override
+ public void createPartControl(Composite parent) {
+
+ shell = this.getViewSite().getShell();
+
+ RootstrapManager.addListener(cListener);
CoreModel.getDefault().addCProjectDescriptionListener(prjListner,
CProjectDescriptionEvent.DATA_APPLIED);
-
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().addSelectionListener(listener);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, TizenHelpContextIds.HELP_COMMON_CONNECTION_EXPLORER_CONTEXT);
- GridLayout layout = new GridLayout(1,false);
+
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService()
+ .addSelectionListener(listener);
+ PlatformUI.getWorkbench().getHelpSystem()
+ .setHelp(parent, TizenHelpContextIds.HELP_COMMON_CONNECTION_EXPLORER_CONTEXT);
+ GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
parent.setLayout(layout);
createToolBar(parent);
createRootstrapTableComposite(parent);
createRootstrapDescComposite(parent);
-
+
makeActions();
activateContext();
initContextMenu();
- }
-
-
- // This override is for change the default/minimum size of Rootstrap view
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class adapter) {
- if (ISizeProvider.class == adapter) {
- return new ISizeProvider() {
- public int getSizeFlags(boolean width) {
- return SWT.MIN | SWT.MAX | SWT.FILL;
- }
-
- public int computePreferredSize(boolean width, int availableParallel, int availablePerpendicular, int preferredResult) {
- return width ? MINIMUM_VIEW_WIDTH : preferredResult;
- }
- };
- }
- return super.getAdapter(adapter);
- }
-
-
- @Override
- public void setFocus() {
- }
-
- private void createToolBar(Composite composite)
- {
- toolBar = new ToolBar(composite, SWT.NULL);
+ }
+
+ // This override is for change the default/minimum size of Rootstrap view
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Object getAdapter(Class adapter) {
+ if (ISizeProvider.class == adapter) {
+ return new ISizeProvider() {
+ public int getSizeFlags(boolean width) {
+ return SWT.MIN | SWT.MAX | SWT.FILL;
+ }
+
+ public int computePreferredSize(boolean width, int availableParallel,
+ int availablePerpendicular, int preferredResult) {
+ return width ? MINIMUM_VIEW_WIDTH : preferredResult;
+ }
+ };
+ }
+ return super.getAdapter(adapter);
+ }
+
+ @Override
+ public void setFocus() {
+ }
+
+ private void createToolBar(Composite composite) {
+ toolBar = new ToolBar(composite, SWT.NULL);
GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
toolBar.setLayoutData(gridData);
- new ToolItem(toolBar, SWT.SEPARATOR); // Separator
-
- ToolItem addRootstrap = new ToolItem(toolBar, SWT.PUSH);
- Image addIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/add.gif");
+ new ToolItem(toolBar, SWT.SEPARATOR); // Separator
+
+ ToolItem addRootstrap = new ToolItem(toolBar, SWT.PUSH);
+ Image addIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/add.gif");
addRootstrap.setImage(addIcon);
addRootstrap.setToolTipText(resources.getString("View.Add.Rootstrap.ToolTip"));
-
+
addRootstrap.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
- showAddDialog();
+ showAddDialog();
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Nothing to do
}
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // Nothing to do
- }
});
addRootstrap.setEnabled(true);
-
- new ToolItem(toolBar, SWT.SEPARATOR); // Separator
-
+
+ new ToolItem(toolBar, SWT.SEPARATOR); // Separator
+
ToolItem importRootstrap = new ToolItem(toolBar, SWT.PUSH);
Image editIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/import.gif");
importRootstrap.setImage(editIcon);
importRootstrap.setToolTipText(resources.getString("View.Import.Rootstrap.ToolTip"));
- importRootstrap.addSelectionListener( new SelectionListener() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- showImportDialog();
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // Nothing to do
- }
-
+ importRootstrap.addSelectionListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ showImportDialog();
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Nothing to do
+ }
+
});
-
- }
-
- private void createRootstrapTableComposite(Composite parent) {
-
+
+ }
+
+ private void createRootstrapTableComposite(Composite parent) {
+
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout layout = new GridLayout(1,false);
+ GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
composite.setLayout(layout);
-
- tableViewer = new TableViewer(composite, SWT.BORDER|SWT.V_SCROLL);
- Table table = tableViewer.getTable();
- GridData tableGridData = new GridData(GridData.FILL_BOTH|GridData.VERTICAL_ALIGN_BEGINNING);
- table.setLayoutData(tableGridData);
-
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- TableColumn column = new TableColumn(table, SWT.NONE);
+
+ tableViewer = new TableViewer(composite, SWT.BORDER | SWT.V_SCROLL);
+ Table table = tableViewer.getTable();
+ GridData tableGridData = new GridData(GridData.FILL_BOTH
+ | GridData.VERTICAL_ALIGN_BEGINNING);
+ table.setLayoutData(tableGridData);
+
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ TableColumn column = new TableColumn(table, SWT.NONE);
column.setResizable(true);
column.setText(resources.getString("View.Table.Column.Rootstrap"));
- column.setWidth(240);
+ column.setWidth(240);
column.addSelectionListener(new TooltableSelectionAdapter());
- column = new TableColumn(table, SWT.NONE);
+ column = new TableColumn(table, SWT.NONE);
column.setResizable(true);
column.setText(resources.getString("View.Table.Column.Arch"));
- column.setWidth(50);
+ column.setWidth(50);
column.addSelectionListener(new TooltableSelectionAdapter());
- tableViewer.setLabelProvider(new TableViewerProvider());
- tableViewer.setContentProvider(new ArrayContentProvider());
- tableViewer.setInput(RootstrapManager.getRootstraps());
-
- tableViewer.getTable().addSelectionListener(new SelectionListener() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- Table table = tableViewer.getTable();
- TableItem[] item = table.getSelection();
- if ( item.length > 0 ) {
- PlatformRootstrap selected = (PlatformRootstrap)item[0].getData();
- rootDescText.setText( getRootstrapDescription(selected));
- }
- else {
- rootDescText.setText("");
- }
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- });
- }
-
-
- private String getRootstrapDescription( PlatformRootstrap rootstrap ) {
- String archLine = String.format(resources.getString("View.Desc.Arch"),
- getArchitectureCategory(rootstrap.getArch()),
- rootstrap.getArch());
- String statusLine = String.format(resources.getString("View.Desc.Status"), rootstrap.isInitialized()? "OK":"Not Intialized");
- IPath confFile = rootstrap.getConfFile();
- String confFileLine = "";
- if (confFile != null) {
- String f = confFile.toOSString();
- confFileLine = String.format(resources.getString("View.Desc.ConfFile"), f);
- confFileLine = confFileLine + "\n";
- }
-
- String urlLine = resources.getString("View.Desc.Repos");
- for( String url: rootstrap.getJustRepoURLs() ) {
- urlLine += String.format("\n - %s", url);
- }
-
-
- return archLine + "\n" + statusLine + "\n" + confFileLine + urlLine;
- }
-
-
- private void createRootstrapDescComposite(Composite parent) {
+ tableViewer.setLabelProvider(new TableViewerProvider());
+ tableViewer.setContentProvider(new ArrayContentProvider());
+ tableViewer.setInput(RootstrapManager.getRootstraps());
+
+ tableViewer.getTable().addSelectionListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Table table = tableViewer.getTable();
+ TableItem[] item = table.getSelection();
+ if (item.length > 0) {
+ PlatformRootstrap selected = (PlatformRootstrap) item[0].getData();
+ rootDescText.setText(getRootstrapDescription(selected));
+ } else {
+ rootDescText.setText("");
+ }
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ });
+ }
+
+ private String getRootstrapDescription(PlatformRootstrap rootstrap) {
+ String archLine = String.format(resources.getString("View.Desc.Arch"),
+ getArchitectureCategory(rootstrap.getArch()), rootstrap.getArch());
+ String statusLine = String.format(resources.getString("View.Desc.Status"),
+ rootstrap.isInitialized() ? "OK" : "Not Intialized");
+ IPath confFile = rootstrap.getConfFile();
+ String confFileLine = "";
+ if (confFile != null) {
+ String f = confFile.toOSString();
+ confFileLine = String.format(resources.getString("View.Desc.ConfFile"), f);
+ confFileLine = confFileLine + "\n";
+ }
+
+ String urlLine = resources.getString("View.Desc.Repos");
+ for (String url : rootstrap.getJustRepoURLs()) {
+ urlLine += String.format("\n - %s", url);
+ }
+
+ return archLine + "\n" + statusLine + "\n" + confFileLine + urlLine;
+ }
+
+ private void createRootstrapDescComposite(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout layout = new GridLayout(1,false);
+ GridLayout layout = new GridLayout(1, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
composite.setLayout(layout);
-
+
Label descriptionLabel = new Label(composite, SWT.NONE);
GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- descriptionLabel.setLayoutData(gridData);
- descriptionLabel.setText(resources.getString("View.Description.Label"));
+ descriptionLabel.setLayoutData(gridData);
+ descriptionLabel.setText(resources.getString("View.Description.Label"));
- rootDescText = new Text( composite, SWT.MULTI|SWT.READ_ONLY|SWT.BORDER|SWT.H_SCROLL|SWT.V_SCROLL );
+ rootDescText = new Text(composite, SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.H_SCROLL
+ | SWT.V_SCROLL);
gridData = new GridData(GridData.FILL_BOTH);
gridData.heightHint = 50;
- rootDescText.setLayoutData( gridData );
- }
-
-
+ rootDescText.setLayoutData(gridData);
+ }
+
private void initContextMenu() {
// initalize the context menu
menuMgr = new MenuManager(resources.getString("View.Contextmenu.Title")); //$NON-NLS-1$
}
});
}
-
- private void fillContextMenu(IMenuManager manager)
- {
+
+ private void fillContextMenu(IMenuManager manager) {
manager.add(new Separator());
manager.add(actionSetDefault);
manager.add(new Separator());
manager.add(new Separator());
manager.add(actionPkgMgr);
}
-
- private void activateContext()
- {
- IContextService contextService = (IContextService) getSite().getService(IContextService.class);
+
+ private void activateContext() {
+ IContextService contextService = (IContextService) getSite().getService(
+ IContextService.class);
contextService.activateContext("org.tizen.common.rootstrap.setdefault.context");
contextService.activateContext("org.tizen.common.rootstrap.lauchpkgmgr.context");
contextService.activateContext("org.tizen.common.rootstrap.remove.context");
contextService.activateContext("org.tizen.common.rootstrap.export.context");
contextService.activateContext("org.tizen.common.rootstrap.change.conffile.context");
}
-
- private void makeActions()
- {
- actionSetDefault = new Action() {
+
+ private void makeActions() {
+ actionSetDefault = new Action() {
@Override
public void run() {
- selectionBuildRoot();
+ selectionBuildRoot();
}
};
actionSetDefault.setText(resources.getString("View.Contextmenu.Select"));
-
+
actionChangeConfFile = new Action() {
- @Override
+ @Override
public void run() {
- modifyRootstrap();
+ modifyRootstrap();
}
};
actionChangeConfFile.setText(resources.getString("View.Contextmenu.Change.ConfFile"));
-
+
actionPkgMgr = new Action() {
@Override
public void run() {
- selectionPkgMgr();
+ selectionPkgMgr();
}
};
actionPkgMgr.setText(resources.getString("View.Contextmenu.Manage"));
-
+
actionRemove = new Action() {
@Override
public void run() {
- removeRootstrap();
+ removeRootstrap();
}
};
actionRemove.setText(resources.getString("View.Contextmenu.Remove"));
-
+
actionExport = new Action() {
@Override
public void run() {
- exportRootstrap();
+ exportRootstrap();
}
};
actionExport.setText(resources.getString("View.Contextmenu.Export"));
}
-
- private String processArch(String arch) {
- String processedArch = arch;
-
- // GBS does not support ia32 arch
- if ("ia32".equals(arch)) {
- processedArch = "i586";
- }
- return processedArch;
- }
-
-
+
+ private String processArch(String arch) {
+ String processedArch = arch;
+
+ // GBS does not support ia32 arch
+ if ("ia32".equals(arch)) {
+ processedArch = "i586";
+ }
+ return processedArch;
+ }
+
private void showAddDialog() {
- //AddRootstrapDialog dlg = new AddRootstrapDialog(shell);
- RootstrapGenDialog dlg = new RootstrapGenDialog(shell);
- if ( dlg.open() == RootstrapGenDialog.OK ) {
- String rootstrapName = dlg.getRootstrapName();
- String arch = processArch(dlg.getSelectionTab().getArchitecture());
- ArrayList<String> repositoryURLs = dlg.getSelectionTab().getRepositoryURLs();
- HashMap<String, String> repoURLs = RepoManager.createRepeHashMap(repositoryURLs);
-
- boolean immediateGen = dlg.getSelectionTab().isImmediateGenerateChecked();
- IPath buildConfFile = dlg.getSelectionTab().getBuildConfFile();
- genRootstrap(rootstrapName, arch, repoURLs, immediateGen, buildConfFile);
- }
+ // AddRootstrapDialog dlg = new AddRootstrapDialog(shell);
+ RootstrapGenDialog dlg = new RootstrapGenDialog(shell);
+ if (dlg.open() == RootstrapGenDialog.OK) {
+ String rootstrapName = dlg.getRootstrapName();
+ String arch = processArch(dlg.getSelectionTab().getArchitecture());
+ ArrayList<String> repositoryURLs = dlg.getSelectionTab().getRepositoryURLs();
+ HashMap<String, String> repoURLs = RepoManager.createRepeHashMap(repositoryURLs);
+
+ boolean immediateGen = dlg.getSelectionTab().isImmediateGenerateChecked();
+ IPath buildConfFile = dlg.getSelectionTab().getBuildConfFile();
+ genRootstrap(rootstrapName, arch, repoURLs, immediateGen, buildConfFile);
+ }
}
-
- private void genRootstrap(final String name,
- final String arch,
- final HashMap<String, String> repoURLs,
- final boolean immediateGen,
- final IPath buildConfFile) {
-
- // generate rootstrap here
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
- try {
- dialog.run(true, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
- monitor.beginTask(resources.getString("GenRootDlg.Progress.Msg.Generating"), -1);
- generatedRootstrap = null;
- generatedRootstrap = RootstrapManager.generate(name, arch, repoURLs,
- immediateGen, buildConfFile, monitor);
- if ( generatedRootstrap == null ) {
- throw new InterruptedException();
- }
- }
- });
- } catch (InvocationTargetException e) {
- DialogUtil.openErrorDialog(String.format("%s\n * %s",
- resources.getString("GenRootDlg.Error.Gen.Rootstrap.Failed"),
- e.getMessage()));
- return;
- } catch (InterruptedException e) {
- DialogUtil.openErrorDialog(String.format("%s\n * %s",
- resources.getString("GenRootDlg.Error.Gen.Rootstrap.Failed"),
- e.getMessage()));
- return;
- }
-
- RootstrapManager.addRootstrap( generatedRootstrap );
+
+ private void genRootstrap(final String name, final String arch,
+ final HashMap<String, String> repoURLs, final boolean immediateGen,
+ final IPath buildConfFile) {
+
+ // generate rootstrap here
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
+ try {
+ dialog.run(true, true, new IRunnableWithProgress() {
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+ monitor.beginTask(resources.getString("GenRootDlg.Progress.Msg.Generating"), -1);
+ generatedRootstrap = null;
+ generatedRootstrap = RootstrapManager.generate(name, arch, repoURLs,
+ immediateGen, buildConfFile, monitor);
+ if (generatedRootstrap == null) {
+ throw new InterruptedException();
+ }
+ }
+ });
+ } catch (InvocationTargetException e) {
+ logger.error(resources.getString("GenRootDlg.Error.Gen.Rootstrap.Failed"), e);
+ DialogUtil.openErrorDialog(String.format("%s\n * %s",
+ resources.getString("GenRootDlg.Error.Gen.Rootstrap.Failed"), e.getMessage()));
+ return;
+ } catch (InterruptedException e) {
+ logger.error(resources.getString("GenRootDlg.Error.Gen.Rootstrap.Failed"), e);
+ DialogUtil.openErrorDialog(String.format("%s\n * %s",
+ resources.getString("GenRootDlg.Error.Gen.Rootstrap.Failed"), e.getMessage()));
+ return;
+ }
+
+ RootstrapManager.addRootstrap(generatedRootstrap);
}
-
+
private void showImportDialog() {
- FileDialog fd = new FileDialog( shell, SWT.OPEN);
+ FileDialog fd = new FileDialog(shell, SWT.OPEN);
fd.setText(resources.getString("FileDlg.Title.Import"));
- String[] extensions = {"*.tar"};
+ String[] extensions = { "*.tar" };
fd.setFilterExtensions(extensions);
String resultFilePath = fd.open();
generatedRootstrap = null;
if (resultFilePath != null) {
- if ( !resultFilePath.endsWith(".tar")) {
- resultFilePath += ".tar";
+ if (!resultFilePath.endsWith(".tar")) {
+ resultFilePath += ".tar";
+ }
+ final String selectedFilePath = resultFilePath;
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
+ try {
+ dialog.run(true, true, new IRunnableWithProgress() {
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+ monitor.beginTask(resources.getString("Action.Msg.Progress.Importing"), -1);
+ generatedRootstrap = RootstrapManager.importRootstrap(selectedFilePath,
+ monitor);
+ }
+ });
+ } catch (InvocationTargetException e) {
+ logger.error(resources.getString("Action.Msg.Error.ImportFailed"), e);
+ DialogUtil.openErrorDialog(String.format("%s\n * %s",
+ resources.getString("Action.Msg.Error.ImportFailed"), e.getMessage()));
+ return;
+ } catch (InterruptedException e) {
+ logger.error(resources.getString("Action.Msg.Error.ImportFailed"), e);
+ DialogUtil.openErrorDialog(String.format("%s\n * %s",
+ resources.getString("Action.Msg.Error.ImportFailed"), e.getMessage()));
+ return;
}
- final String selectedFilePath = resultFilePath;
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
- try {
- dialog.run(true, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
-
- monitor.beginTask(resources.getString("Action.Msg.Progress.Importing"), -1);
- generatedRootstrap = RootstrapManager.importRootstrap( selectedFilePath, monitor );
- }
- });
- } catch (InvocationTargetException e) {
- DialogUtil.openErrorDialog(
- String.format("%s\n * %s", resources.getString("Action.Msg.Error.ImportFailed"),
- e.getMessage() ) );
- return;
- } catch (InterruptedException e) {
- DialogUtil.openErrorDialog(
- String.format("%s\n * %s", resources.getString("Action.Msg.Error.ImportFailed"),
- e.getMessage() ) );
- return;
- }
}
-
+
if (generatedRootstrap == null) {
- return;
+ return;
}
- RootstrapManager.addRootstrap( generatedRootstrap );
- DialogUtil.openMessageDialog(shell,resources.getString("Action.Msg.Info.ImportOK"));
+ RootstrapManager.addRootstrap(generatedRootstrap);
+ DialogUtil.openMessageDialog(shell, resources.getString("Action.Msg.Info.ImportOK"));
}
-
- public void selectionBuildRoot()
- {
- doActionForEntry(new IActionForEntry()
- {
+ public void selectionBuildRoot() {
+ doActionForEntry(new IActionForEntry() {
@Override
- public void doAction()
- {
- Table table = tableViewer.getTable();
- TableItem[] item = table.getSelection();
- PlatformRootstrap selected = (PlatformRootstrap)item[0].getData();
- if (project != null) {
- if (!verifyActiveRootstrap( project, selected)) {
- showErrorSelectRootstrap(project, selected);
- return;
- }
- setActiveRootstrap( project, selected );
- }
+ public void doAction() {
+ Table table = tableViewer.getTable();
+ TableItem[] item = table.getSelection();
+ PlatformRootstrap selected = (PlatformRootstrap) item[0].getData();
+ if (project != null) {
+ if (!verifyActiveRootstrap(project, selected)) {
+ showErrorSelectRootstrap(project, selected);
+ return;
+ }
+ setActiveRootstrap(project, selected);
+ }
}
@Override
- public boolean doCheckEnable()
- {
+ public boolean doCheckEnable() {
return true;
}
});
}
-
+
private void showErrorSelectRootstrap(IProject project, PlatformRootstrap rootstrap) {
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
- IConfiguration config = info.getDefaultConfiguration();
- String message = String.format(resources.getString("Action.Msg.Error.SelectRootstrap"),
- rootstrap.getId(), config.getName());
- DialogUtil.openErrorDialog(message);
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ IConfiguration config = info.getDefaultConfiguration();
+ String message = String.format(resources.getString("Action.Msg.Error.SelectRootstrap"),
+ rootstrap.getId(), config.getName());
+ DialogUtil.openErrorDialog(message);
}
-
-
- private void setActiveRootstrap(IProject project, PlatformRootstrap rootstrap ) {
- String rootId = rootstrap.getId();
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
- IConfiguration config = info.getDefaultConfiguration();
- String targetId = PlatformConfigurationManager.getBuildTargetName(config);
- SmartBuildInterface sbi = SmartBuildInterface.getInstance();
- String toolId = sbi.getToolchainIDFromTargetID(targetId);
- String newTargetId = SmartBuildInterface.makeTargetID(rootId, toolId);
- try {
- if (!sbi.checkTargetID(newTargetId)) {
- sbi.writeTargetCfgFile(newTargetId);
- }
- } catch (SBIException e) {
- e.printStackTrace();
- }
- PlatformConfigurationManager.setBuildTargetName(config, newTargetId);
- RootstrapManager.setSelectedRootstrap(rootstrap);
- RootstrapManager.notifyChangedRootstrap();
-
- ManagedBuildManager.saveBuildInfo( project, true );
+
+ private void setActiveRootstrap(IProject project, PlatformRootstrap rootstrap) {
+ String rootId = rootstrap.getId();
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ IConfiguration config = info.getDefaultConfiguration();
+ String targetId = PlatformConfigurationManager.getBuildTargetName(config);
+ SmartBuildInterface sbi = SmartBuildInterface.getInstance();
+ String toolId = sbi.getToolchainIDFromTargetID(targetId);
+ String newTargetId = SmartBuildInterface.makeTargetID(rootId, toolId);
+ try {
+ if (!sbi.checkTargetID(newTargetId)) {
+ sbi.writeTargetCfgFile(newTargetId);
+ }
+ } catch (SBIException e) {
+ e.printStackTrace();
+ }
+ PlatformConfigurationManager.setBuildTargetName(config, newTargetId);
+ RootstrapManager.setSelectedRootstrap(rootstrap);
+ RootstrapManager.notifyChangedRootstrap();
+
+ ManagedBuildManager.saveBuildInfo(project, true);
}
-
- private boolean verifyActiveRootstrap(IProject project, PlatformRootstrap rootstrap ) {
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
- IConfiguration config = info.getDefaultConfiguration();
- String rootArch = rootstrap.getArch();
-
- if (PlatformConfigurationManager.isEmulatorConfiguration(config)) {
- if (!PlatformConfigurationManager.isEmulatorArch(rootArch)) {
- return false;
- }
- } else if (PlatformConfigurationManager.isDeviceConfiguration(config)) {
- if (!PlatformConfigurationManager.isDeviceArch(rootArch)) {
- return false;
- }
- }
-
- return true;
+
+ private boolean verifyActiveRootstrap(IProject project, PlatformRootstrap rootstrap) {
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ IConfiguration config = info.getDefaultConfiguration();
+ String rootArch = rootstrap.getArch();
+
+ if (PlatformConfigurationManager.isEmulatorConfiguration(config)) {
+ if (!PlatformConfigurationManager.isEmulatorArch(rootArch)) {
+ return false;
+ }
+ } else if (PlatformConfigurationManager.isDeviceConfiguration(config)) {
+ if (!PlatformConfigurationManager.isDeviceArch(rootArch)) {
+ return false;
+ }
+ }
+
+ return true;
}
-
- public void selectionPkgMgr()
- {
- doActionForEntry(new IActionForEntry()
- {
+
+ public void selectionPkgMgr() {
+ doActionForEntry(new IActionForEntry() {
@Override
- public void doAction()
- {
- Table table = tableViewer.getTable();
- TableItem[] item = table.getSelection();
- final PlatformRootstrap selected = (PlatformRootstrap)item[0].getData();
- //boolean initialized = new File(selected.getPath().toOSString()).exists() ? true : false;
- boolean initialized = selected.isInitialized();
- if (!initialized) {
- // ask whether user want to initialize roootstrap
- int ret = DialogUtil.openQuestionDialog(resources.getString("Action.Msg.Question.NotInit"));
- if ( ret != SWT.YES ) {
- return;
- }
-
- // generate base file system here if "YES"
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
- try {
- dialog.run(true, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
- monitor.beginTask(resources.getString("GenRootDlg.Progress.Msg.Generating"), -1);
- if( !RootstrapManager.generateBaseFileSystem(selected.getPath().toString(),
- selected.getArch(), selected.getJustRepoURLs(),
- selected.getConfFile(), monitor) ) {
- throw new InterruptedException("Generating base file system failed!");
- }
- }
- });
- } catch (InvocationTargetException e) {
- DialogUtil.openErrorDialog(String.format("%s\n * %s",
- resources.getString("GenRootDlg.Error.Gen.Rootstrap.Failed"),
- e.getMessage()));
- return;
- } catch (InterruptedException e) {
- DialogUtil.openErrorDialog(String.format("%s\n * %s",
- resources.getString("GenRootDlg.Error.Gen.Rootstrap.Failed"),
- e.getMessage()));
- return;
- }
-
- selected.setInitialized(true);
- }
-
- // launch package manager
- final RPMPackageDialog dlg = new RPMPackageDialog(shell, selected);
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
- try {
- dialog.run(true, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
- dlg.initializeDialogData(monitor);
- }
- });
- } catch (InvocationTargetException e) {
- DialogUtil.openErrorDialog( String.format("%s\n * %s\n * %s",
- resources.getString("Action.Msg.Error.InitFailed.PkgMgr"),
- e.getMessage(), "If no response for long time, check your proxy setting." ) );
- return;
- } catch (InterruptedException e) {
- DialogUtil.openErrorDialog( String.format("%s\n * %s\n * %s",
- resources.getString("Action.Msg.Error.InitFailed.PkgMgr"),
- e.getMessage(), "If no response for long time, check your proxy setting." ) );
- return;
- }
-
- dlg.open();
-
- dialog = new ProgressMonitorDialog(shell);
- try {
- dialog.run(true, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
-
- monitor.beginTask(resources.getString("Action.Msg.Progress.Finalizing.PkgMgr"), 2);
- monitor.subTask(resources.getString("Action.Msg.Progress.Umount.rootstrap"));
- LocalRepoMounter.clearMounted(monitor);
- // TODO: error handling for umountLocalRepository
- monitor.worked(1);
- monitor.subTask(resources.getString("Action.Msg.Progress.Refresh.rootstrap"));
- RootstrapManager.modifyRootstrap( selected );
- monitor.worked(2);
- monitor.done();
- }
- });
- } catch (InvocationTargetException e) {
- DialogUtil.openErrorDialog( String.format("%s\n * %s",
- resources.getString("Action.Msg.Error.FiniFailed.PkgMgrt"),
- e.getMessage()));
- return;
- } catch (InterruptedException e) {
- DialogUtil.openErrorDialog( String.format("%s\n * %s",
- resources.getString("Action.Msg.Error.FiniFailed.PkgMgr"),
- e.getMessage()));
- return;
- }
+ public void doAction() {
+ Table table = tableViewer.getTable();
+ TableItem[] item = table.getSelection();
+ final PlatformRootstrap selected = (PlatformRootstrap) item[0].getData();
+ // boolean initialized = selected.isInitialized();
+ boolean initialized = selected.checkInitialized();
+ if (!initialized) {
+ // ask whether user want to initialize roootstrap
+ int ret = DialogUtil.openQuestionDialog(resources
+ .getString("Action.Msg.Question.NotInit"));
+ if (ret != SWT.YES) {
+ return;
+ }
+
+ // generate base file system here if "YES"
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
+ try {
+ dialog.run(true, true, new IRunnableWithProgress() {
+ @Override
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ monitor.beginTask(
+ resources.getString("GenRootDlg.Progress.Msg.Generating"),
+ -1);
+ if (!RootstrapManager.generateBaseFileSystem(selected.getPath()
+ .toString(), selected.getArch(),
+ selected.getJustRepoURLs(), selected.getConfFile(), monitor)) {
+ throw new InterruptedException(
+ "Generating base file system failed!");
+ }
+ }
+ });
+ } catch (InvocationTargetException e) {
+ logger.error(resources.getString("GenRootDlg.Error.Gen.Rootstrap.Failed"), e);
+ DialogUtil.openErrorDialog(String.format("%s\n * %s",
+ resources.getString("GenRootDlg.Error.Gen.Rootstrap.Failed"),
+ e.getMessage()));
+ return;
+ } catch (InterruptedException e) {
+ logger.error(resources.getString("GenRootDlg.Error.Gen.Rootstrap.Failed"), e);
+ DialogUtil.openErrorDialog(String.format("%s\n * %s",
+ resources.getString("GenRootDlg.Error.Gen.Rootstrap.Failed"),
+ e.getMessage()));
+ return;
+ }
+ selected.setInitialized(true);
+ }
+
+ // launch package manager
+ IDevice device = ConnectionPlugin.getDefault().getCurrentDevice();
+ final PkgCommandTarget cmdTarget = new PkgCommandTarget(device, selected);
+ final RPMPackageDialog dlg = new RPMPackageDialog(shell, cmdTarget);
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
+ try {
+ dialog.run(true, true, new IRunnableWithProgress() {
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+ PkgMgrInitializer initializer = new PkgMgrInitializer(cmdTarget);
+ initializer.initData(monitor);
+
+ }
+ });
+ } catch (InvocationTargetException e) {
+ logger.error(resources.getString("Action.Msg.Error.InitFailed.PkgMgr"), e);
+ DialogUtil.openErrorDialog(String.format("%s\n * %s\n * %s",
+ resources.getString("Action.Msg.Error.InitFailed.PkgMgr"),
+ e.getMessage(),
+ "If no response for long time, check your proxy setting."));
+ return;
+ } catch (InterruptedException e) {
+ logger.error(resources.getString("Action.Msg.Error.InitFailed.PkgMgr"), e);
+ DialogUtil.openErrorDialog(String.format("%s\n * %s\n * %s",
+ resources.getString("Action.Msg.Error.InitFailed.PkgMgr"),
+ e.getMessage(),
+ "If no response for long time, check your proxy setting."));
+ return;
+ }
+
+ dlg.open();
+
+ dialog = new ProgressMonitorDialog(shell);
+ try {
+ dialog.run(true, true, new IRunnableWithProgress() {
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException,
+ InterruptedException {
+
+ monitor.beginTask(
+ resources.getString("Action.Msg.Progress.Finalizing.PkgMgr"), 2);
+ monitor.subTask(resources
+ .getString("Action.Msg.Progress.Umount.rootstrap"));
+ LocalRepoMounter.clearMounted(monitor);
+ // TODO: error handling for umountLocalRepository
+ monitor.worked(1);
+ monitor.subTask(resources
+ .getString("Action.Msg.Progress.Refresh.rootstrap"));
+ RootstrapManager.updateRootstrap(selected);
+ monitor.worked(2);
+ monitor.done();
+ }
+ });
+ } catch (InvocationTargetException e) {
+ logger.error(resources.getString("Action.Msg.Error.FiniFailed.PkgMgr"), e);
+ DialogUtil.openErrorDialog(String.format("%s\n * %s",
+ resources.getString("Action.Msg.Error.FiniFailed.PkgMgr"),
+ e.getMessage()));
+ return;
+ } catch (InterruptedException e) {
+ logger.error(resources.getString("Action.Msg.Error.FiniFailed.PkgMgr"), e);
+ DialogUtil.openErrorDialog(String.format("%s\n * %s",
+ resources.getString("Action.Msg.Error.FiniFailed.PkgMgr"),
+ e.getMessage()));
+ return;
+ } finally {
+ //RootstrapManager.modifyRootstrap(selected);
+
+ }
}
@Override
- public boolean doCheckEnable()
- {
+ public boolean doCheckEnable() {
return true;
}
});
}
-
- public void modifyRootstrap()
- {
- doActionForEntry(new IActionForEntry()
- {
+
+ public void modifyRootstrap() {
+ doActionForEntry(new IActionForEntry() {
@Override
- public void doAction()
- {
- Table table = tableViewer.getTable();
- TableItem[] item = table.getSelection();
- final PlatformRootstrap selected = (PlatformRootstrap)item[0].getData();
-
- // launch package manager
- final RootstrapChangeConfFileDialog dlg = new RootstrapChangeConfFileDialog(shell, selected);
-
- if ( dlg.open() == RootstrapGenDialog.OK ) {
- IPath filePath = dlg.getBuildConfFile();
- selected.setConfFile(filePath);
- RootstrapManager.modifyRootstrap( selected );
- }
+ public void doAction() {
+ Table table = tableViewer.getTable();
+ TableItem[] item = table.getSelection();
+ final PlatformRootstrap selected = (PlatformRootstrap) item[0].getData();
+
+ // launch package manager
+ final RootstrapChangeConfFileDialog dlg = new RootstrapChangeConfFileDialog(shell,
+ selected);
+
+ if (dlg.open() == RootstrapGenDialog.OK) {
+ IPath filePath = dlg.getBuildConfFile();
+ selected.setConfFile(filePath);
+ RootstrapManager.updateRootstrap(selected);
+ }
}
@Override
- public boolean doCheckEnable()
- {
+ public boolean doCheckEnable() {
return true;
}
});
}
-
-
- public void removeRootstrap()
- {
- doActionForEntry(new IActionForEntry()
- {
+
+ public void removeRootstrap() {
+ doActionForEntry(new IActionForEntry() {
@Override
- public void doAction()
- {
- Table table = tableViewer.getTable();
- TableItem[] item = table.getSelection();
- final PlatformRootstrap selected = (PlatformRootstrap)item[0].getData();
-
- // default rootstrap cannot be removed!
- PlatformRootstrap defaultRootstrap = RootstrapManager.getDefaultRootstrap( selected.getArch() );
- if ( defaultRootstrap.getId().equals(selected.getId()) ) {
- DialogUtil.openErrorDialog(resources.getString("Action.Msg.Error.RemoveDefault"));
- return;
- }
-
- IWorkspace works = ResourcesPlugin.getWorkspace();
- IProject[] projs = works.getRoot().getProjects();
- for (IProject proj : projs) {
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(proj);
- if ( info == null ) continue;
- IConfiguration config = info.getDefaultConfiguration();
- if ( config == null ) continue;
- IManagedProject managedProject = config.getManagedProject();
- String projectArtifactType = managedProject.getProjectType() != null ?
- managedProject.getProjectType().getBuildArtefactType().getId() : null;
- if ( managedProject == null ||
- projectArtifactType != PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE) continue;
-
- setActiveRootstrap( proj, defaultRootstrap );
- }
-
- // umount repository
- ArrayList<IPath> failedPaths = LocalRepoMounter.umountLocalRepository(selected, null);
- if(failedPaths.size() == 0) {
- // remove
- RootstrapManager.removeRootstrap(selected.getId());
- } else {
- DialogUtil.openErrorDialog(resources.getString("Action.Msg.Error.RemoveFailed"));
- }
+ public void doAction() {
+ Table table = tableViewer.getTable();
+ TableItem[] item = table.getSelection();
+ final PlatformRootstrap selected = (PlatformRootstrap) item[0].getData();
+
+ // default rootstrap cannot be removed!
+ PlatformRootstrap defaultRootstrap = RootstrapManager.getDefaultRootstrap(selected
+ .getArch());
+ if (defaultRootstrap.getId().equals(selected.getId())) {
+ DialogUtil.openErrorDialog(resources
+ .getString("Action.Msg.Error.RemoveDefault"));
+ return;
+ }
+
+ IWorkspace works = ResourcesPlugin.getWorkspace();
+ IProject[] projs = works.getRoot().getProjects();
+ for (IProject proj : projs) {
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(proj);
+ if (info == null)
+ continue;
+ IConfiguration config = info.getDefaultConfiguration();
+ if (config == null)
+ continue;
+ IManagedProject managedProject = config.getManagedProject();
+ String projectArtifactType = managedProject.getProjectType() != null ? managedProject
+ .getProjectType().getBuildArtefactType().getId()
+ : null;
+ if (managedProject == null
+ || projectArtifactType != PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE)
+ continue;
+
+ setActiveRootstrap(proj, defaultRootstrap);
+ }
+
+ // umount repository
+ final List<IPath> failedPaths = LocalRepoMounter.umountLocalRepository(selected,
+ null);
+ // generate rootstrap here
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
+ try {
+ dialog.run(true, true, new IRunnableWithProgress() {
+ @Override
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ monitor.beginTask(
+ resources.getString("Action.Msg.Progress.Removing"), -1);
+ if (failedPaths.size() == 0) {
+ // remove
+ RootstrapManager.removeRootstrap(selected.getId());
+ } else {
+ throw new InterruptedException();
+ }
+ }
+ });
+ } catch (InvocationTargetException e) {
+ logger.error(resources.getString("Action.Msg.Error.RemoveFailed"), e);
+ DialogUtil.openErrorDialog(String.format("%s\n * %s",
+ resources.getString("Action.Msg.Error.RemoveFailed"),
+ e.getMessage()));
+ return;
+ } catch (InterruptedException e) {
+ logger.error(resources.getString("Action.Msg.Error.RemoveFailed"), e);
+ DialogUtil.openErrorDialog(String.format("%s\n * %s",
+ resources.getString("Action.Msg.Error.RemoveFailed"),
+ e.getMessage()));
+ return;
+ }
}
@Override
- public boolean doCheckEnable()
- {
+ public boolean doCheckEnable() {
return true;
}
});
}
-
- public void exportRootstrap()
- {
- doActionForEntry(new IActionForEntry()
- {
+ public void exportRootstrap() {
+ doActionForEntry(new IActionForEntry() {
@Override
- public void doAction()
- {
- // get rootstrap
- Table table = tableViewer.getTable();
- TableItem[] item = table.getSelection();
- final PlatformRootstrap selectedRootstrap = (PlatformRootstrap)item[0].getData();
-
- // check whether rootstrap is initialized
- if ( !selectedRootstrap.isInitialized() ) {
- DialogUtil.openErrorDialog(resources.getString("Action.Msg.Error.ExportUninitialzed"));
- return;
- }
-
- FileDialog fd = new FileDialog( shell, SWT.SAVE);
- fd.setText(resources.getString("FileDlg.Title.Export"));
- String[] extensions = {"*.tar"};
- fd.setFilterExtensions(extensions);
- String resultFilePath = fd.open();
- if ( !resultFilePath.endsWith(".tar")) {
- resultFilePath += ".tar";
- }
- final String selectedFilePath = resultFilePath;
- if (selectedFilePath != null) {
- // generate rootstrap here
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
- try {
- dialog.run(true, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
-
- monitor.beginTask(resources.getString("Action.Msg.Progress.Exporting"), -1);
- boolean result = RootstrapManager.exportRootstrap( selectedRootstrap, selectedFilePath, monitor );
- if ( result ) {
- DialogUtil.openMessageDialog(shell,resources.getString("Action.Msg.Info.ExportOK"));
- }
- else {
- DialogUtil.openMessageDialog(shell, resources.getString("Action.Msg.Error.ExportFailed"));
- }
- }
- });
- } catch (InvocationTargetException e) {
- DialogUtil.openErrorDialog( String.format("%s\n * %s",
- resources.getString("Action.Msg.Error.ExportFailed"),
- e.getMessage() ) );
- return;
- } catch (InterruptedException e) {
- DialogUtil.openErrorDialog( String.format("%s\n * %s",
- resources.getString("Action.Msg.Error.ExportFailed"),
- e.getMessage() ) );
- return;
- }
- }
+ public void doAction() {
+ // get rootstrap
+ Table table = tableViewer.getTable();
+ TableItem[] item = table.getSelection();
+ final PlatformRootstrap selectedRootstrap = (PlatformRootstrap) item[0].getData();
+
+ // check whether rootstrap is initialized
+ if (!selectedRootstrap.isInitialized()) {
+ DialogUtil.openErrorDialog(resources
+ .getString("Action.Msg.Error.ExportUninitialzed"));
+ return;
+ }
+
+ FileDialog fd = new FileDialog(shell, SWT.SAVE);
+ fd.setText(resources.getString("FileDlg.Title.Export"));
+ String[] extensions = { "*.tar" };
+ fd.setFilterExtensions(extensions);
+ String resultFilePath = fd.open();
+ if (!resultFilePath.endsWith(".tar")) {
+ resultFilePath += ".tar";
+ }
+ final String selectedFilePath = resultFilePath;
+ if (selectedFilePath != null) {
+ // generate rootstrap here
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
+ try {
+ dialog.run(true, true, new IRunnableWithProgress() {
+ @Override
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+
+ monitor.beginTask(
+ resources.getString("Action.Msg.Progress.Exporting"), -1);
+ boolean result = RootstrapManager.exportRootstrap(
+ selectedRootstrap, selectedFilePath, monitor);
+ if (result) {
+ DialogUtil.openMessageDialog(shell,
+ resources.getString("Action.Msg.Info.ExportOK"));
+ } else {
+ DialogUtil.openMessageDialog(shell,
+ resources.getString("Action.Msg.Error.ExportFailed"));
+ }
+ }
+ });
+ } catch (InvocationTargetException e) {
+ logger.error(resources.getString("Action.Msg.Error.ExportFailed"), e);
+ DialogUtil.openErrorDialog(String.format("%s\n * %s",
+ resources.getString("Action.Msg.Error.ExportFailed"),
+ e.getMessage()));
+ return;
+ } catch (InterruptedException e) {
+ logger.error(resources.getString("Action.Msg.Error.ExportFailed"), e);
+ DialogUtil.openErrorDialog(String.format("%s\n * %s",
+ resources.getString("Action.Msg.Error.ExportFailed"),
+ e.getMessage()));
+ return;
+ }
+ }
}
@Override
- public boolean doCheckEnable()
- {
+ public boolean doCheckEnable() {
return true;
}
});
}
-
- public void doActionForEntry(IActionForEntry action)
- {
- if (action.doCheckEnable())
- {
+ public void doActionForEntry(IActionForEntry action) {
+ if (action.doCheckEnable()) {
action.doAction();
}
}
-
- private interface IActionForEntry
- {
- boolean doCheckEnable();
+
+ private interface IActionForEntry {
+ boolean doCheckEnable();
+
void doAction();
}
+ private class TooltableSelectionAdapter extends SelectionAdapter {
+ public void widgetSelected(SelectionEvent e) {
-
- private class TooltableSelectionAdapter extends SelectionAdapter
- {
- public void widgetSelected(SelectionEvent e) {
-
- final int column = tableViewer.getTable().indexOf((TableColumn) e.widget);
- tableViewer.getTable().setSortColumn((TableColumn)e.widget);
- if (tableViewer.getTable().getSortDirection() == SWT.DOWN) {
- tableViewer.getTable().setSortDirection(SWT.UP);
- } else {
- tableViewer.getTable().setSortDirection(SWT.DOWN);
- }
-
- tableViewer.setSorter(new ViewerSorter() {
- public int compare(Viewer viewer, Object e1, Object e2) {
- PlatformRootstrap entry_1 = (PlatformRootstrap)e1;
- PlatformRootstrap entry_2 = (PlatformRootstrap)e2;
-
- switch (column) {
- case COL_IDX_ROOTNAME:
- if (tableViewer.getTable().getSortDirection() == SWT.DOWN) {
- return entry_1.getText().compareTo(entry_2.getText());
- } else {
- return entry_2.getText().compareTo(entry_1.getText());
- }
- case COL_IDX_ARCH:
- if (tableViewer.getTable().getSortDirection() == SWT.DOWN) {
- return entry_1.getArch().compareTo(entry_2.getArch());
- } else {
- return entry_2.getArch().compareTo(entry_1.getArch());
- }
- default:
- break;
- }
- return entry_1.getText().compareTo(entry_2.getText());
- }
- });
-
- }
- }
-
-
- /* selected package table provider */
- private class TableViewerProvider extends LabelProvider implements ITableLabelProvider
- {
- @Override
- public Image getColumnImage(Object element, int columnIndex) {
- if ( element instanceof PlatformRootstrap) {
- PlatformRootstrap t = (PlatformRootstrap)element;
- boolean checked = t.isChecked();
- if (checked && columnIndex == COL_IDX_ROOTNAME) {
- Image checkIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/successed.png");
- return checkIcon;
- }
- }
- return null;
- }
-
- @Override
- public String getColumnText(Object element, int columnIndex) {
- if ( element instanceof PlatformRootstrap) {
- PlatformRootstrap t = (PlatformRootstrap)element;
- String name = t.getText();
- String arch = t.getArch();
-
- switch(columnIndex) {
- case COL_IDX_ROOTNAME :
- return name;
- case COL_IDX_ARCH:
- return getArchitectureCategory(arch);
- default:
- break;
- }
- }
- return null;
- }
- }
-
-
- private String getArchitectureCategory(String arch) {
- if ( arch.toLowerCase().contains("arm")) {
- return "arm";
- }
- else {
- return "x86";
- }
- }
+ final int column = tableViewer.getTable().indexOf((TableColumn) e.widget);
+ tableViewer.getTable().setSortColumn((TableColumn) e.widget);
+ if (tableViewer.getTable().getSortDirection() == SWT.DOWN) {
+ tableViewer.getTable().setSortDirection(SWT.UP);
+ } else {
+ tableViewer.getTable().setSortDirection(SWT.DOWN);
+ }
+
+ tableViewer.setSorter(new ViewerSorter() {
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ PlatformRootstrap entry_1 = (PlatformRootstrap) e1;
+ PlatformRootstrap entry_2 = (PlatformRootstrap) e2;
+
+ switch (column) {
+ case COL_IDX_ROOTNAME:
+ if (tableViewer.getTable().getSortDirection() == SWT.DOWN) {
+ return entry_1.getText().compareTo(entry_2.getText());
+ } else {
+ return entry_2.getText().compareTo(entry_1.getText());
+ }
+ case COL_IDX_ARCH:
+ if (tableViewer.getTable().getSortDirection() == SWT.DOWN) {
+ return entry_1.getArch().compareTo(entry_2.getArch());
+ } else {
+ return entry_2.getArch().compareTo(entry_1.getArch());
+ }
+ default:
+ break;
+ }
+ return entry_1.getText().compareTo(entry_2.getText());
+ }
+ });
+
+ }
+ }
+
+ /* selected package table provider */
+ private class TableViewerProvider extends LabelProvider implements ITableLabelProvider {
+ @Override
+ public Image getColumnImage(Object element, int columnIndex) {
+ if (element instanceof PlatformRootstrap) {
+ PlatformRootstrap t = (PlatformRootstrap) element;
+ boolean checked = t.isChecked();
+ if (checked && columnIndex == COL_IDX_ROOTNAME) {
+ Image checkIcon = ImageUtil.getImage(Activator.PLUGIN_ID,
+ "icons/rootstrap/successed.png");
+ return checkIcon;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String getColumnText(Object element, int columnIndex) {
+ if (element instanceof PlatformRootstrap) {
+ PlatformRootstrap t = (PlatformRootstrap) element;
+ String name = t.getText();
+ String arch = t.getArch();
+
+ switch (columnIndex) {
+ case COL_IDX_ROOTNAME:
+ return name;
+ case COL_IDX_ARCH:
+ return getArchitectureCategory(arch);
+ default:
+ break;
+ }
+ }
+ return null;
+ }
+ }
+
+ private String getArchitectureCategory(String arch) {
+ if (arch.toLowerCase().contains("arm")) {
+ return "arm";
+ } else {
+ return "x86";
+ }
+ }
}
--- /dev/null
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.wizards;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.ui.wizards.CDTMainWizardPage;
+import org.eclipse.cdt.ui.wizards.EntryDescriptor;
+
+public class PlatformMainWizardPage extends CDTMainWizardPage {
+
+ public PlatformMainWizardPage(String pageName) {
+ super(pageName);
+ // TODO Auto-generated constructor stub
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public List filterItems(List items) {
+ List<Object> result = new ArrayList<Object>();
+
+ for (Object item : items) {
+ if (item instanceof EntryDescriptor) {
+ EntryDescriptor e = (EntryDescriptor) item;
+
+ // remove default empty project
+ if (e.getName() != null && e.getName().equals("Empty Project"))
+ continue;
+
+ if (e.getId().equals("org.tizen.nativeide.buildArtefactType.platform")
+ || (e.getParentId() != null && e.getParentId().equals(
+ "org.tizen.nativeide.buildArtefactType.platform"))) {
+ result.add(item);
+ }
+
+ // Deprecated project type
+ // if(e.getId().equals("com.samsung.slp.buildArtefactType.custom.debian")
+ // ||
+ // (e.getParentId() != null &&
+ // e.getParentId().equals("com.samsung.slp.buildArtefactType.custom.debian")
+ // ) ) {
+ // result.add(item);
+ // }
+ }
+
+ }
+ return result;
+ }
+
+ @Override
+ protected boolean validatePage() {
+ // TODO Auto-generated method stub
+ boolean result = super.validatePage();
+
+ if (result == true && super.getMessage() != null) {
+ if (super.getMessage().equals("Directory with specified name already exists.")) {
+ super.setMessage(null);
+ }
+ }
+
+ return result;
+ }
+}
--- /dev/null
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.wizards;
+
+import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.tizen.nativeplatform.build.PlatformConfigurationManager;
+
+public class PlatformProjectWizard extends CDTCommonProjectWizard {
+
+ public PlatformProjectWizard() {
+ super("Tizen Platform Project", //$NON-NLS-1$
+ "Create a Tizen Platform Project project of selected type"); //$NON-NLS-1$
+ // WizardConstants.isDebian = true;
+ }
+
+ @Override
+ public String[] getNatures() {
+ return new String[] { CProjectNature.C_NATURE_ID, CCProjectNature.CC_NATURE_ID };
+ }
+
+ @Override
+ protected IProject continueCreation(IProject prj) {
+ if (continueCreationMonitor == null) {
+ continueCreationMonitor = new NullProgressMonitor();
+ }
+
+ try {
+ continueCreationMonitor.beginTask("Add C/C++ Project Nature", 1);
+ CProjectNature.addCNature(prj, new SubProgressMonitor(continueCreationMonitor, 1));
+ CCProjectNature.addCCNature(prj, new SubProgressMonitor(continueCreationMonitor, 1));
+ } catch (CoreException e) {
+ // nothing to do
+ e.printStackTrace();
+ } finally {
+ continueCreationMonitor.done();
+ }
+ return prj;
+ }
+
+ @Override
+ public void addPages() {
+ fMainPage = new PlatformMainWizardPage(CUIPlugin.getResourceString("CProjectWizard"));
+ fMainPage.setTitle("Tizen Platform Project");
+ fMainPage.setDescription("Create a Tizen Platform Project project of selected type");
+ addPage(fMainPage);
+ }
+
+ @Override
+ public String[] getContentTypeIDs() {
+ return new String[] { CCorePlugin.CONTENT_TYPE_CXXSOURCE,
+ CCorePlugin.CONTENT_TYPE_CXXHEADER };
+ }
+
+ @Override
+ public IProject getProject(boolean defaults, boolean onFinish) {
+ IProject prj = super.getProject(defaults, onFinish);
+
+ // Marking project version
+ PlatformConfigurationManager.setProjectVersion(prj,
+ PlatformConfigurationManager.CURRENT_SLP_PROJECT_VERSION, true);
+
+ return prj;
+ }
+
+}
+++ /dev/null
-/*
- * Native Platform
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Donghyuk Yang <donghyuk.yang@samsung.com>
- * DongHee Yang <donghee.yang@samsung.com>
- * Kangho Kim <kh5325.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.nativeplatform.wizards;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.ui.wizards.CDTMainWizardPage;
-import org.eclipse.cdt.ui.wizards.EntryDescriptor;
-
-
-public class TizenDebianMainWizardPage extends CDTMainWizardPage {
-
- public TizenDebianMainWizardPage(String pageName) {
- super(pageName);
- // TODO Auto-generated constructor stub
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Override
- public List filterItems(List items) {
- List<Object> result = new ArrayList<Object>();
-
- for(Object item:items) {
- if(item instanceof EntryDescriptor) {
- EntryDescriptor e = (EntryDescriptor)item;
-
- // remove default empty project
- if ( e.getName() != null && e.getName().equals("Empty Project") )
- continue;
-
- if( e.getId().equals("org.tizen.nativeide.buildArtefactType.platform") ||
- (e.getParentId() != null && e.getParentId().equals("org.tizen.nativeide.buildArtefactType.platform")) ) {
- result.add(item);
- }
-
- // Deprecated project type
- //if(e.getId().equals("com.samsung.slp.buildArtefactType.custom.debian") ||
- // (e.getParentId() != null && e.getParentId().equals("com.samsung.slp.buildArtefactType.custom.debian") ) ) {
- // result.add(item);
- //}
- }
-
- }
- return result;
- }
-
- @Override
- protected boolean validatePage() {
- // TODO Auto-generated method stub
- boolean result = super.validatePage();
-
- if(result == true && super.getMessage() != null) {
- if (super.getMessage().equals("Directory with specified name already exists.")) {
- super.setMessage(null);
- }
- }
-
- return result;
- }
-}
+++ /dev/null
-/*
- * Native Platform
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Donghyuk Yang <donghyuk.yang@samsung.com>
- * DongHee Yang <donghee.yang@samsung.com>
- * Kangho Kim <kh5325.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.nativeplatform.wizards;
-
-import org.eclipse.cdt.core.CCProjectNature;
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.CProjectNature;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.tizen.nativeplatform.build.PlatformConfigurationManager;
-
-
-
-
-public class TizenDebianProjectWizard extends CDTCommonProjectWizard{
-
- public TizenDebianProjectWizard() {
- super("Tizen Platform Project", //$NON-NLS-1$
- "Create a Tizen Platform Project project of selected type"); //$NON-NLS-1$
-// WizardConstants.isDebian = true;
- }
-
- @Override
- public String[] getNatures() {
- return new String[] { CProjectNature.C_NATURE_ID, CCProjectNature.CC_NATURE_ID };
- }
-
- @Override
- protected IProject continueCreation(IProject prj) {
- if (continueCreationMonitor == null) {
- continueCreationMonitor = new NullProgressMonitor();
- }
-
- try {
- continueCreationMonitor.beginTask("Add C/C++ Project Nature", 1);
- CProjectNature.addCNature(prj, new SubProgressMonitor(continueCreationMonitor, 1));
- CCProjectNature.addCCNature(prj, new SubProgressMonitor(continueCreationMonitor, 1));
- } catch (CoreException e) {
- // nothing to do
- e.printStackTrace();
- }
- finally {continueCreationMonitor.done();}
- return prj;
- }
-
- @Override
- public void addPages() {
- fMainPage= new TizenDebianMainWizardPage(CUIPlugin.getResourceString("CProjectWizard"));
- fMainPage.setTitle("Tizen Platform Project");
- fMainPage.setDescription("Create a Tizen Platform Project project of selected type");
- addPage(fMainPage);
- }
-
- @Override
- public String[] getContentTypeIDs() {
- return new String[] { CCorePlugin.CONTENT_TYPE_CXXSOURCE, CCorePlugin.CONTENT_TYPE_CXXHEADER };
- }
-
- @Override
- public IProject getProject(boolean defaults, boolean onFinish) {
- IProject prj = super.getProject(defaults, onFinish);
-
- // Marking project version
- PlatformConfigurationManager.setProjectVersion( prj, PlatformConfigurationManager.CURRENT_SLP_PROJECT_VERSION, true);
-
- return prj;
- }
-
-}
return prj;
}
-
- @Override
- public boolean isExpressMode() {
- return false;
- }
@Override
protected AbstractProjectGenerator getBuildFileGenerator() {
+* 2.1.14
+- Applied changing GBS buildroot path
+- Applied changing sdblib
+- Applied changing installer for multi-SDK
+== donghyuk yang <donghyuk.yang@samsung.com> 2013-06-17
+* 2.1.13
+- Refactoring sdblib
+== kh5325.kim <kh5325.kim@samsung.com> 2013-06-05
+* 2.1.12
+- Removed gbs tool setting in plugin.xml (failed to create project)
+== donghyuk yang <donghyuk.yang@samsung.com> 2013-06-03
+* 2.1.11
+- Install package to the device for pkgcmd tool if project is efl
+- Decide what the project is for existing (org.tizen.*).xml file
+- Supported GBS include options
+== donghyuk yang <donghyuk.yang@samsung.com> 2013-06-03
+* 2.1.10
+- Removed express mode (IDE uses only normal CDT wizard mode)
+== kh5325.kim <kh5325.kim@samsung.com> 2013-05-29
+* 2.1.9
+- Refactored to sdblib
+== kh5325.kim <kh5325.kim@samsung.com> 2013-05-23
+* 2.1.8
+- Refactored to sdblib
+== kh5325.kim <kh5325.kim@samsung.com> 2013-05-23
+* 2.1.7
+- Refactored to sdblib
+== kh5325.kim <kh5325.kim@samsung.com> 2013-05-22
+* 2.1.6
+- Added base-ide-product-add-ons dependency for EGit
+== kh5325.kim <kh5325.kim@samsung.com> 2013-05-06
* 2.1.5
- applied new method that get app's installation path.
- Changed version from tizen2.0 to tizen2.1
-Version:2.1.5
+Version:2.1.14
Source:nativeplatform-eplugin
Maintainer:Kangho Kim <kh5325.kim@samsung.com>, Yoonki Park<yoonki.park@samsung.com>, Hyunsik Noh<hyunsik.noh@samsung.com>, Gun Kim<gune.kim@samsung.com>, Ho Namkoong<ho.namkoong@samsung.com>, Taeyoung Son<taeyoung2.son@samsung.com>
Package:nativeplatform-eplugin
OS:ubuntu-32
Build-host-os:ubuntu-32
-Build-dependency:base-ide-product [ubuntu-32], pde-build [ubuntu-32], common-eplugin [ubuntu-32], nativecommon-eplugin [ubuntu-32], nativeappcommon-eplugin [ubuntu-32]
-Install-dependency:base-ide-product [ubuntu-32], common-eplugin [ubuntu-32], nativecommon-eplugin [ubuntu-32]
+Build-dependency:base-ide-product [ubuntu-32], base-ide-product-add-ons [ubuntu-32], pde-build [ubuntu-32], common-eplugin [ubuntu-32], nativecommon-eplugin [ubuntu-32], nativeappcommon-eplugin [ubuntu-32]
+Install-dependency:base-ide-product [ubuntu-32], base-ide-product-add-ons [ubuntu-32], common-eplugin [ubuntu-32], nativecommon-eplugin [ubuntu-32]
Description:Nativeplatform plugin
Package:nativeplatform-eplugin
OS:ubuntu-64
Build-host-os:ubuntu-32
-Build-dependency:base-ide-product [ubuntu-64], pde-build [ubuntu-64], common-eplugin [ubuntu-64], nativecommon-eplugin [ubuntu-64], nativeappcommon-eplugin [ubuntu-64]
-Install-dependency:base-ide-product [ubuntu-64], common-eplugin [ubuntu-64], nativecommon-eplugin [ubuntu-64]
+Build-dependency:base-ide-product [ubuntu-64], base-ide-product-add-ons [ubuntu-64], pde-build [ubuntu-64], common-eplugin [ubuntu-64], nativecommon-eplugin [ubuntu-64], nativeappcommon-eplugin [ubuntu-64]
+Install-dependency:base-ide-product [ubuntu-64], base-ide-product-add-ons [ubuntu-64], common-eplugin [ubuntu-64], nativecommon-eplugin [ubuntu-64]
Description:Nativeplatform plugin