From e062dc92df7b0b7dc70865705fbba6dc11311802 Mon Sep 17 00:00:00 2001 From: "donghyuk.yang" Date: Tue, 9 Jul 2013 19:02:04 +0900 Subject: [PATCH] [Title] Launch refactoring --- .../build/PlatformBuildPackageObjectAction.java | 36 +- .../git/{ => parser}/FileGitIndexParser.java | 2 +- .../git/{ => parser}/GitIndexParserFactory.java | 2 +- .../git/{ => parser}/IGitIndexParser.java | 2 +- .../git/{ => parser}/WebGitIndexParser.java | 2 +- .../launch/PlatformLaunchDelegate.java | 189 ++---- .../launch/PlatformLaunchDelegateForAttach.java | 100 +--- .../launch/PlatformMIProcessAdapter.java | 5 +- .../launch/ui/PlatformCommonTab.java | 186 ++++++ .../launch/ui/PlatformMainAttachTab.java | 265 +-------- .../nativeplatform/launch/ui/PlatformMainTab.java | 370 ++---------- .../PlatformProjectAttachLaunchShortcut.java | 24 +- .../PlatformProjectCommonLaunchShortcut.java | 77 ++- .../ui/shortcut/PlatformProjectLaunchShortcut.java | 36 +- .../wizard/pages/PlatformLaunchCommonPage.java | 85 +++ .../wizard/pages/PlatformLaunchSettingAppPage.java | 241 ++------ .../wizard/pages/PlatformLaunchSettingBinPage.java | 3 +- .../pages/PlatformLaunchSettingProcPage.java | 129 +---- .../launch/wizards/PlatformAttachLaunchWizard.java | 61 +- .../launch/wizards/PlatformLaunchWizard.java | 73 +-- .../pkg/commander/CommandStatus.java | 29 +- .../pkg/commander/IChangedLogListener.java | 27 + .../pkg/commander/ICommandStatus.java | 29 +- .../nativeplatform/pkg/commander/IPackager.java | 27 + .../nativeplatform/pkg/commander/IPkgFilter.java | 27 + .../nativeplatform/pkg/commander/IPkgLauncher.java | 40 ++ .../pkg/commander/IPkgModelMaker.java | 27 + .../pkg/commander/IPkgStatusUpdater.java | 27 + .../pkg/commander/IPkgVersionComparer.java | 27 + .../pkg/commander/PkgCommandTarget.java | 4 + .../pkg/commander/factories/PackagerFactory.java | 19 - .../pkg/commander/factories/PkgFilterFactory.java | 15 - .../commander/factories/PkgModelMakerFactory.java | 15 - .../factories/PkgStatusUpdaterFactory.java | 16 - .../factories/PkgVersionComparerFactory.java | 16 - .../pkg/commander/factory/PackagerFactory.java | 46 ++ .../pkg/commander/factory/PkgFilterFactory.java | 42 ++ .../pkg/commander/factory/PkgLauncherFactory.java | 50 ++ .../commander/factory/PkgModelMakerFactory.java | 42 ++ .../commander/factory/PkgStatusUpdaterFactory.java | 44 ++ .../factory/PkgVersionComparerFactory.java | 43 ++ .../pkg/commander/rpm/RpmCommanderDevice.java | 27 + .../pkg/commander/rpm/RpmCommanderHost.java | 27 + .../pkg/commander/rpm/RpmCommanderRootstrap.java | 27 + .../pkg/commander/rpm/RpmModelMaker.java | 27 + .../pkg/commander/rpm/RpmPackageFilter.java | 27 + .../pkg/commander/rpm/RpmPackageLauncher.java | 268 +++++++++ .../pkg/commander/rpm/RpmPackager.java | 27 + .../pkg/commander/rpm/RpmStatusUpdater.java | 27 + .../pkg/commander/rpm/RpmVersionComparer.java | 27 + .../tizen/nativeplatform/pkg/model/IPackage.java | 27 + .../tizen/nativeplatform/pkg/model/Package.java | 28 + .../tizen/nativeplatform/pkg/model/PkgStatus.java | 27 + .../nativeplatform/pkgmgr/PkgMgrInitializer.java | 28 +- .../nativeplatform/pkgmgr/ui/AddRepoDialog.java | 285 ++------- .../tizen/nativeplatform/pkgmgr/ui/CommonTab.java | 4 +- .../tizen/nativeplatform/pkgmgr/ui/DeviceTab.java | 9 +- .../nativeplatform/pkgmgr/ui/ModifyRepoDialog.java | 393 ++++--------- .../nativeplatform/pkgmgr/ui/RepoCommonDialog.java | 212 +++++++ .../tizen/nativeplatform/types/CmdTargetTypes.java | 27 + .../tizen/nativeplatform/types/LaunchTypes.java | 43 ++ .../nativeplatform/types/PkgInstallTypes.java | 27 + .../org/tizen/nativeplatform/types/PkgTypes.java | 27 + .../ui/adapter/ExtraPkgTableViewerAdapter.java | 81 +++ .../adapter}/PackageTableSelectionAdapter.java | 2 +- .../adapter}/RepoTableSelectionAdapter.java | 2 +- .../ui/listener/ExtraPkgAddListener.java | 56 ++ .../ui/listener/ExtraPkgTableHoverListener.java | 122 ++++ .../ui/provider/ExtraPkgTableViewerProvider.java | 58 ++ .../ui/provider/RepoTableViewerProvider.java | 57 ++ .../nativeplatform/util/CharacterStripper.java | 27 + .../tizen/nativeplatform/util/CommandLauncher.java | 244 +------- .../util/CommandLauncherOnDevice.java | 27 + .../util/CommandLauncherOnRootstrap.java | 329 +---------- .../nativeplatform/util/CommandLauncherUtil.java | 232 ++++++++ .../util/CommandProcessMonitorThread.java | 60 ++ .../org/tizen/nativeplatform/util/FileUtil.java | 53 ++ .../tizen/nativeplatform/util/InstallerUtil.java | 27 + .../org/tizen/nativeplatform/util/PackageUtil.java | 60 ++ .../nativeplatform/util/PlatformLaunchUtil.java | 201 +++++++ .../nativeplatform/util/PlatformLaunchUtils.java | 356 ------------ .../nativeplatform/util/PlatformProjectUtil.java | 65 +++ .../tizen/nativeplatform/util/ProcessSelector.java | 28 + .../tizen/nativeplatform/util/RootstrapUtil.java | 27 + .../views/ui/AddRootstrapDialog.java | 645 ++++++++++----------- .../nativeplatform/views/ui/IRepositoryTab.java | 27 + .../nativeplatform/views/ui/LocalRepoTab.java | 7 - .../nativeplatform/views/ui/RemoteRepoTab.java | 583 +++++++++---------- .../views/ui/RootstrapChangeConfFileDialog.java | 281 +++++---- .../wizards/TemplateTizenPlatformNewWizard.java | 151 ++--- .../wizards/TizenPlatformMainWizardPage.java | 1 - .../wizards/TizenPlatformProjectWizard.java | 8 +- 92 files changed, 4240 insertions(+), 3698 deletions(-) rename org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/{ => parser}/FileGitIndexParser.java (97%) rename org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/{ => parser}/GitIndexParserFactory.java (96%) rename org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/{ => parser}/IGitIndexParser.java (96%) rename org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/{ => parser}/WebGitIndexParser.java (98%) create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformCommonTab.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchCommonPage.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgLauncher.java delete mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factories/PackagerFactory.java delete mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factories/PkgFilterFactory.java delete mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factories/PkgModelMakerFactory.java delete mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factories/PkgStatusUpdaterFactory.java delete mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factories/PkgVersionComparerFactory.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PackagerFactory.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgFilterFactory.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgLauncherFactory.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgModelMakerFactory.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgStatusUpdaterFactory.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgVersionComparerFactory.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmPackageLauncher.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RepoCommonDialog.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/types/LaunchTypes.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/adapter/ExtraPkgTableViewerAdapter.java rename org.tizen.nativeplatform/src/org/tizen/nativeplatform/{pkgmgr/ui => ui/adapter}/PackageTableSelectionAdapter.java (99%) rename org.tizen.nativeplatform/src/org/tizen/nativeplatform/{pkgmgr/ui => ui/adapter}/RepoTableSelectionAdapter.java (98%) create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/listener/ExtraPkgAddListener.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/listener/ExtraPkgTableHoverListener.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/provider/ExtraPkgTableViewerProvider.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/provider/RepoTableViewerProvider.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncherUtil.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandProcessMonitorThread.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/FileUtil.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PackageUtil.java create mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PlatformLaunchUtil.java delete mode 100644 org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PlatformLaunchUtils.java diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformBuildPackageObjectAction.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformBuildPackageObjectAction.java index 5c1d25d..1a5d958 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformBuildPackageObjectAction.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformBuildPackageObjectAction.java @@ -27,8 +27,6 @@ package org.tizen.nativeplatform.build; -import java.io.File; -import java.io.FilenameFilter; import java.lang.reflect.InvocationTargetException; import org.eclipse.cdt.managedbuilder.core.IConfiguration; @@ -49,9 +47,7 @@ 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.factories.PackagerFactory; +import org.tizen.nativeplatform.util.PackageUtil; import org.tizen.nativeplatform.util.PlatformProjectUtil; public class PlatformBuildPackageObjectAction implements IWorkbenchWindowActionDelegate, @@ -59,7 +55,7 @@ public class PlatformBuildPackageObjectAction implements IWorkbenchWindowActionD protected IProject project; protected IWorkbenchWindow window; private boolean packagingResult = false; - private final String PKGTYPE = "RPM"; + //private final String PKGTYPE = "RPM"; public PlatformBuildPackageObjectAction() { } @@ -71,7 +67,7 @@ public class PlatformBuildPackageObjectAction implements IWorkbenchWindowActionD @Override public void run(IAction action) { - CommonBuildPackageFile.setPackageType(project, PKGTYPE); + //CommonBuildPackageFile.setPackageType(project, PKGTYPE); window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(window.getShell()); @@ -82,10 +78,8 @@ public class PlatformBuildPackageObjectAction implements IWorkbenchWindowActionD InterruptedException { IConfiguration config = ManagedBuildManager.getBuildInfo(project) .getDefaultConfiguration(); - IPackager packager = PackagerFactory.getPackager( - PlatformProjectUtil.getPkgType(), project, config); - packagingResult = packager.packaging(monitor); - + PackageUtil pkgUtil = new PackageUtil(PlatformProjectUtil.getPkgType()); + packagingResult = pkgUtil.pakaging(project, config, monitor); } }); } catch (InvocationTargetException e1) { @@ -110,26 +104,6 @@ public class PlatformBuildPackageObjectAction implements IWorkbenchWindowActionD } } - protected File findFirstFilebyExtension(File searchPath, String ext) { - File[] allFiles = searchPath.listFiles(new ExtFilter(ext)); - if (allFiles == null || allFiles.length == 0) { - return null; - } - return allFiles[0]; - } - - protected class ExtFilter implements FilenameFilter { - protected String ext; - - public ExtFilter(String ext) { - this.ext = ext; - } - - public boolean accept(File dir, String name) { - return name.endsWith(ext); - } - } - @Override public void selectionChanged(IAction action, ISelection selection) { Object obj = null; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/FileGitIndexParser.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/parser/FileGitIndexParser.java similarity index 97% rename from org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/FileGitIndexParser.java rename to org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/parser/FileGitIndexParser.java index e183fc3..7419c3b 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/FileGitIndexParser.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/parser/FileGitIndexParser.java @@ -25,7 +25,7 @@ * */ -package org.tizen.nativeplatform.git; +package org.tizen.nativeplatform.git.parser; import java.io.BufferedReader; import java.io.FileNotFoundException; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/GitIndexParserFactory.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/parser/GitIndexParserFactory.java similarity index 96% rename from org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/GitIndexParserFactory.java rename to org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/parser/GitIndexParserFactory.java index 7b90fdf..29415bf 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/GitIndexParserFactory.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/parser/GitIndexParserFactory.java @@ -25,7 +25,7 @@ * */ -package org.tizen.nativeplatform.git; +package org.tizen.nativeplatform.git.parser; import org.tizen.nativeplatform.preferences.PreferencesManager; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/IGitIndexParser.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/parser/IGitIndexParser.java similarity index 96% rename from org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/IGitIndexParser.java rename to org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/parser/IGitIndexParser.java index 11a7012..0ae8f3d 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/IGitIndexParser.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/parser/IGitIndexParser.java @@ -25,7 +25,7 @@ * */ -package org.tizen.nativeplatform.git; +package org.tizen.nativeplatform.git.parser; import java.util.ArrayList; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/WebGitIndexParser.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/parser/WebGitIndexParser.java similarity index 98% rename from org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/WebGitIndexParser.java rename to org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/parser/WebGitIndexParser.java index 9f3198c..1aa5c3d 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/WebGitIndexParser.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/git/parser/WebGitIndexParser.java @@ -25,7 +25,7 @@ * */ -package org.tizen.nativeplatform.git; +package org.tizen.nativeplatform.git.parser; import java.io.BufferedReader; import java.io.File; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegate.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegate.java index 5c77dff..628e83e 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegate.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegate.java @@ -30,7 +30,6 @@ 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; @@ -97,21 +96,17 @@ import org.tizen.nativecommon.launch.TizenUIThreadForConfirmMessage; import org.tizen.nativeplatform.Activator; import org.tizen.nativeplatform.build.PlatformConfigurationManager; 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.IPkgFilter; +import org.tizen.nativeplatform.pkg.commander.IPkgLauncher; import org.tizen.nativeplatform.pkg.commander.IPkgModelMaker; -import org.tizen.nativeplatform.pkg.commander.IPkgStatusUpdater; import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget; -import org.tizen.nativeplatform.pkg.commander.factories.PackagerFactory; -import org.tizen.nativeplatform.pkg.commander.factories.PkgFilterFactory; -import org.tizen.nativeplatform.pkg.commander.factories.PkgModelMakerFactory; -import org.tizen.nativeplatform.pkg.commander.factories.PkgStatusUpdaterFactory; +import org.tizen.nativeplatform.pkg.commander.factory.PkgLauncherFactory; +import org.tizen.nativeplatform.pkg.commander.factory.PkgModelMakerFactory; import org.tizen.nativeplatform.pkg.model.IPackage; import org.tizen.nativeplatform.pkg.model.PkgStatus; import org.tizen.nativeplatform.rootstrap.RootstrapManager; -import org.tizen.nativeplatform.types.CmdTargetTypes; -import org.tizen.nativeplatform.util.PlatformLaunchUtils; +import org.tizen.nativeplatform.types.LaunchTypes; +import org.tizen.nativeplatform.util.PackageUtil; +import org.tizen.nativeplatform.util.PlatformLaunchUtil; import org.tizen.nativeplatform.util.PlatformProjectUtil; import org.tizen.nativeplatform.views.model.PlatformRootstrap; import org.tizen.sdblib.Arch; @@ -134,6 +129,7 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate { protected Shell shell; private boolean result; protected TizenLaunchCommand tizenCommand = null; + protected PackageUtil pkgUtil = new PackageUtil(PlatformProjectUtil.getPkgType()); protected String getPluginID() { return Activator.PLUGIN_ID; @@ -194,7 +190,7 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate { installPackages(config, mode, monitor); } - private boolean fromShortcut(ILaunchConfiguration config) { + protected boolean fromShortcut(ILaunchConfiguration config) { boolean result = false; try { ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy(); @@ -247,11 +243,7 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate { protected boolean packagingProject(IProject targetProj, IConfiguration config, IProgressMonitor monitor) { - boolean packagingResult = false; - IPackager packager = PackagerFactory.getPackager(PlatformProjectUtil.getPkgType(), - targetProj, config); - packagingResult = packager.packaging(monitor); - + boolean packagingResult = pkgUtil.pakaging(targetProj, config, monitor); if (packagingResult) { DialogUtil.openMessageDialog(shell, CommonBuildMessages.BUILD_RESULT, CommonBuildMessages.SUCCESS_TO_BUILD_PACKAGE); @@ -259,21 +251,12 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate { 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(target); - final IPkgModelMaker modelMaker = PkgModelMakerFactory.getMaker(PlatformProjectUtil - .getPkgType()); - final IPkgFilter pkgFilter = PkgFilterFactory.getFilter(PlatformProjectUtil.getPkgType()); - final IPkgStatusUpdater pkgUpdater = PkgStatusUpdaterFactory.getUpdater( - PlatformProjectUtil.getPkgType(), target); - boolean reinstallOp = config.getAttribute( ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, true); boolean selectPkgOp = config.getAttribute( @@ -284,120 +267,32 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate { List extraPkgs = (ArrayList) config .getAttribute(ITizenLaunchConfigurationConstants.ATTR_EXTRA_PACKAGE_LIST, new ArrayList()); - - List appPkgs = null; List packages = new ArrayList(); String buildConfigName = getBuildConfigName(config); IConfiguration buildConfig = getBuildConfiguration(buildConfigName, platformProject); - IPackager packager = PackagerFactory.getPackager(PlatformProjectUtil.getPkgType(), - platformProject, buildConfig); - List pkgPaths = packager.getProjectPackages(); - final List platformPkgs = modelMaker.makeModels(pkgPaths); - - 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))) { - pkgPaths = packager.getProjectPackages(); - platformPkgs.addAll(modelMaker.makeModels(pkgPaths)); - } else { - if (64 != DialogUtil - .openQuestionDialog(PlatformLaunchMessages.QUESTION_CONTINUE)) { - newCoreException(PlatformLaunchMessages.CANCELED_LAUNCH, null); - } - } - } - } - + List platformPkgs = getPackages(platformProject, buildConfig, monitor); packages.addAll(platformPkgs); - if (!appProjectName.isEmpty()) { - appProject = launchUtils.getProjectInstance(appProjectName); - IPackager appPackager = PackagerFactory.getPackager(PlatformProjectUtil.getPkgType(), - appProject, buildConfig); - List appPkgPaths = appPackager.getProjectPackages(); - appPkgs = modelMaker.makeModels(appPkgPaths); - - 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))) { - appPkgPaths = appPackager.getProjectPackages(); - appPkgs.addAll(modelMaker.makeModels(appPkgPaths)); - } else { - if (64 != DialogUtil - .openQuestionDialog(PlatformLaunchMessages.QUESTION_CONTINUE)) { - newCoreException(PlatformLaunchMessages.CANCELED_LAUNCH, null); - } - } - } - } - + IProject appProject = PlatformProjectUtil.getProjectInstance(appProjectName); + List appPkgs = getPackages(appProject, buildConfig, monitor); packages.addAll(appPkgs); } - if (!extraPkgs.isEmpty()) { + IPkgModelMaker modelMaker = PkgModelMakerFactory.getMaker(target.getPkgType()); List extra = modelMaker.makeModels(extraPkgs); packages.addAll(extra); - // packages.addAll(launchUtils.getLocalPackages(extraPkgs)); - } - - List buildSystemPkgStatus = new ArrayList(); - List devicePkgStatus = new ArrayList(); - - if (mode.equals(ILaunchManager.DEBUG_MODE)) { - if (!launchUtils.validateRootstrap(rootstrap.getId())) { - String msg = String.format(PlatformLaunchMessages.IS_NOT_INITIALIZED_ROOTSTRAP, - rootstrap.getId()); - newCoreException(msg, null); - } - List buildSystemPkgs = pkgFilter.filter(CmdTargetTypes.ROOTSTRAP, packages); - buildSystemPkgStatus = pkgUpdater.updateStatus(CmdTargetTypes.ROOTSTRAP, - buildSystemPkgs); - launchUtils.applyReinstallOp(buildSystemPkgStatus, reinstallOp); } - List devicePkgs = pkgFilter.filter(CmdTargetTypes.DEVICE, packages); - devicePkgStatus = pkgUpdater.updateStatus(CmdTargetTypes.DEVICE, devicePkgs); - launchUtils.applyReinstallOp(devicePkgStatus, reinstallOp); + IPkgLauncher pkgLauncher = PkgLauncherFactory.getLauncher(platformProject, target, + packages, reinstallOp, selectPkgOp); try { - monitor.beginTask(PlatformLaunchMessages.INSTALL_PACKAGE, 4); - monitor.subTask(PlatformLaunchMessages.CHECK_PKG_STATUS); - - if (selectPkgOp) { - if (!openPkgStatusDialog(buildSystemPkgStatus, devicePkgStatus)) { - newCoreException(PlatformLaunchMessages.CANCELED_LAUNCH, null); - } - } - - List selecteBsPkgs = launchUtils.getSelectedPackages(buildSystemPkgStatus); - List selecteDvPkgs = launchUtils.getSelectedPackages(devicePkgStatus); - - 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); - } + if (mode.equals(ILaunchManager.DEBUG_MODE)) { + pkgLauncher.debugLaunchPkgs(LaunchTypes.NONE, shell, monitor); + } else { + pkgLauncher.launchPkgs(shell, 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); } } @@ -492,8 +387,9 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate { List adaptableConfigs = new ArrayList(0); for (IConfiguration c : configurations) { String buildTargetArchitecture = CommonConfigurationManager.getArchitecture(c); - if (buildTargetArchitecture.equals(arch)) + if (buildTargetArchitecture.equals(arch)) { adaptableConfigs.add(c); + } } dlg.setElements(adaptableConfigs.toArray()); @@ -617,8 +513,7 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate { 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); + PlatformLaunchUtil.readyGdbServer(currentDevice, tizenCommand, path); String gdbserverRunCommand = getGdbserverRunCommand(config); String resultCommand = null; @@ -797,26 +692,6 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate { }); } - protected File findFirstFilebyExtension(File searchPath, String ext) { - File[] allFiles = searchPath.listFiles(new ExtFilter(ext)); - if (allFiles == null || allFiles.length == 0) { - return null; - } - return allFiles[0]; - } - - protected class ExtFilter implements FilenameFilter { - protected String ext; - - public ExtFilter(String ext) { - this.ext = ext; - } - - public boolean accept(File dir, String name) { - 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); @@ -886,14 +761,32 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate { } protected boolean needsSetConfiguration(ILaunchConfiguration config) throws CoreException { + // If the project is EFL app or launching is not from shorcut, need set + // configurations. IProject project = getProject(config); boolean isEflApp = PlatformProjectUtil.isEFLApplication(project); boolean isNotFromShortcut = !fromShortcut(config); - return (isEflApp | isNotFromShortcut); } protected void setPkgCommandTarget() { target = new PkgCommandTarget(PlatformProjectUtil.getPkgType(), currentDevice, rootstrap); } + + protected List getPackages(IProject project, IConfiguration config, + IProgressMonitor monitor) throws CoreException { + List pkgs = pkgUtil.getPackages(project, config); + if (pkgs.isEmpty()) { + if (PlatformLaunchUtil.questionPackaging(project)) { + if (packagingProject(project, config, new SubProgressMonitor(monitor, 1))) { + pkgs = pkgUtil.getPackages(project, config); + } else { + if (!PlatformLaunchUtil.questionContinue()) { + newCoreException(PlatformLaunchMessages.CANCELED_LAUNCH, null); + } + } + } + } + return pkgs; + } } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegateForAttach.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegateForAttach.java index d4d7090..74fe67e 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegateForAttach.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegateForAttach.java @@ -46,32 +46,22 @@ 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.launch.TizenLaunchConfigurationConstants; import org.tizen.nativecommon.launch.TizenLaunchMessages; import org.tizen.nativeplatform.build.PlatformConfigurationManager; -import org.tizen.nativeplatform.pkg.commander.IPackager; -import org.tizen.nativeplatform.pkg.commander.IPkgFilter; -import org.tizen.nativeplatform.pkg.commander.IPkgModelMaker; -import org.tizen.nativeplatform.pkg.commander.IPkgStatusUpdater; -import org.tizen.nativeplatform.pkg.commander.factories.PackagerFactory; -import org.tizen.nativeplatform.pkg.commander.factories.PkgFilterFactory; -import org.tizen.nativeplatform.pkg.commander.factories.PkgModelMakerFactory; -import org.tizen.nativeplatform.pkg.commander.factories.PkgStatusUpdaterFactory; +import org.tizen.nativeplatform.pkg.commander.IPkgLauncher; +import org.tizen.nativeplatform.pkg.commander.factory.PkgLauncherFactory; import org.tizen.nativeplatform.pkg.model.IPackage; -import org.tizen.nativeplatform.pkg.model.PkgStatus; -import org.tizen.nativeplatform.types.CmdTargetTypes; -import org.tizen.nativeplatform.util.PlatformLaunchUtils; -import org.tizen.nativeplatform.util.PlatformProjectUtil; +import org.tizen.nativeplatform.types.LaunchTypes; +import org.tizen.nativeplatform.util.PlatformLaunchUtil; import org.tizen.nativeplatform.util.ProcessSelector; import org.tizen.sdblib.exception.SdbCommandRejectedException; import org.tizen.sdblib.exception.TimeoutException; @@ -198,8 +188,7 @@ public class PlatformLaunchDelegateForAttach extends PlatformLaunchDelegate { 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); + PlatformLaunchUtil.readyGdbServer(currentDevice, tizenCommand, path); if (pid.equals(Integer.valueOf(-1)) || pid.equals(Integer.valueOf(0))) { newCoreException(TizenLaunchMessages.CANNOT_LAUNCH_APPLICATION_WITH_GDBSERVER @@ -274,11 +263,6 @@ public class PlatformLaunchDelegateForAttach extends PlatformLaunchDelegate { protected void installPackages(ILaunchConfiguration config, String mode, IProgressMonitor monitor) throws CoreException { IProject platformProject = getProject(config); - final PlatformLaunchUtils launchUtils = new PlatformLaunchUtils(target); - final IPkgModelMaker modelMaker = PkgModelMakerFactory.getMaker(PlatformProjectUtil.getPkgType()); - final IPkgFilter pkgFilter = PkgFilterFactory.getFilter(PlatformProjectUtil.getPkgType()); - final IPkgStatusUpdater pkgUpdater = PkgStatusUpdaterFactory.getUpdater(PlatformProjectUtil.getPkgType(), target); - boolean reinstallOp = config.getAttribute( ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, true); boolean selectPkgOp = config.getAttribute( @@ -288,73 +272,16 @@ public class PlatformLaunchDelegateForAttach extends PlatformLaunchDelegate { String buildConfigName = getBuildConfigName(config); IConfiguration buildConfig = getBuildConfiguration(buildConfigName, platformProject); - String targetID = PlatformConfigurationManager.getBuildTargetName(buildConfig); - String rootstrapId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetID); - IPackager packager = PackagerFactory.getPackager(PlatformProjectUtil.getPkgType(), - platformProject, buildConfig); - List pkgPaths = packager.getProjectPackages(); - final List platformPkgs = modelMaker.makeModels(pkgPaths); - //final List platformPkgs = packager.getProjectPackages(); - /* - final List 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))) { - pkgPaths = packager.getProjectPackages(); - platformPkgs.addAll(modelMaker.makeModels(pkgPaths)); - } else { - if (64 != DialogUtil - .openQuestionDialog(PlatformLaunchMessages.QUESTION_CONTINUE)) { - newCoreException(PlatformLaunchMessages.CANCELED_LAUNCH, null); - } - } - } - } - + List platformPkgs = getPackages(platformProject, buildConfig, monitor); packages.addAll(platformPkgs); - - List buildSystemPkgStatus = new ArrayList(); - List devicePkgStatus = new ArrayList(); - - 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, reinstallOp); - List buildSystemPkgs = pkgFilter.filter(CmdTargetTypes.ROOTSTRAP, packages); - buildSystemPkgStatus = pkgUpdater.updateStatus(CmdTargetTypes.ROOTSTRAP, buildSystemPkgs); - launchUtils.applyReinstallOp(buildSystemPkgStatus, reinstallOp); - } - + IPkgLauncher pkgLauncher = PkgLauncherFactory.getLauncher(platformProject, target, + packages, reinstallOp, selectPkgOp); try { - monitor.beginTask(PlatformLaunchMessages.INSTALL_PACKAGE, 4); - monitor.subTask(PlatformLaunchMessages.CHECK_PKG_STATUS); - - if (selectPkgOp) { - if (!openPkgStatusDialog(buildSystemPkgStatus, devicePkgStatus)) { - newCoreException(PlatformLaunchMessages.CANCELED_LAUNCH, null); - } + if (mode.equals(ILaunchManager.DEBUG_MODE)) { + pkgLauncher.debugLaunchPkgs(LaunchTypes.ATTACH, shell, monitor); } - - List selectedBsPkgs = launchUtils.getSelectedPackages(buildSystemPkgStatus); - - monitor.worked(1); - monitor.subTask(PlatformLaunchMessages.INSTALL_PACKAGES_TO_BUILDSYSTEM); - if (selectedBsPkgs != null && !selectedBsPkgs.isEmpty()) { - launchUtils.installPkgsToRootstrap(selectedBsPkgs, monitor); - } - monitor.subTask(PlatformLaunchMessages.INSTALL_PACKAGES_TO_DEVICE); - // Nothing to do for device - monitor.done(); } catch (InterruptedException e) { - e.printStackTrace(); + newCoreException(PlatformLaunchMessages.FAILED_INSTALL_PKGS, e); } } @@ -367,4 +294,9 @@ public class PlatformLaunchDelegateForAttach extends PlatformLaunchDelegate { // 3) set solib-search-path return null; } + + protected boolean needsSetConfiguration(ILaunchConfiguration config) throws CoreException { + // If launching is not from shorcut, need set configurations. + return !fromShortcut(config); + } } \ No newline at end of file diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformMIProcessAdapter.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformMIProcessAdapter.java index 7d18672..07caf50 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformMIProcessAdapter.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformMIProcessAdapter.java @@ -46,6 +46,7 @@ import org.eclipse.core.runtime.Path; import org.tizen.nativecommon.build.CommonProjectDependentBuilder; import org.tizen.nativecommon.build.ProjectTypeManager; import org.tizen.nativeplatform.util.CommandLauncher; +import org.tizen.nativeplatform.util.CommandLauncherUtil; public class PlatformMIProcessAdapter extends MIProcessAdapter { @@ -71,10 +72,10 @@ public class PlatformMIProcessAdapter extends MIProcessAdapter { @Override public void interrupt(MIInferior inferior) { if (gdbProcess instanceof Spawner) { - String interruptCmd = CommandLauncher.genDebugginInterruptScript(gdbProcess); + String interruptCmd = CommandLauncherUtil.genDebugginInterruptScript(gdbProcess); Process shellProcess; try { - shellProcess = CommandLauncher.createProcess( interruptCmd, null, false ); + shellProcess = CommandLauncherUtil.createProcess( interruptCmd, null, false ); shellProcess.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformCommonTab.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformCommonTab.java new file mode 100644 index 0000000..fbf063f --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformCommonTab.java @@ -0,0 +1,186 @@ +package org.tizen.nativeplatform.launch.ui; + +import java.util.ResourceBundle; + +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; +import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants; +import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin; +import org.eclipse.cdt.launch.ui.CMainTab; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.FileDialog; +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.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.sdblib.IDevice; +import org.tizen.sdblib.service.FileEntry; + +@SuppressWarnings({ "restriction" }) +public class PlatformCommonTab extends CMainTab { + + protected final String BUNDLE_NAME = PlatformMainAttachTab.class.getPackage().getName() + + ".LaunchTabUIMessages";//$NON-NLS-1$ + protected ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + + protected Text fBinPathText; + protected Button fReinstallOp; + protected Button fSelectPkgOp; + protected String filePath = ""; + + @Override + protected String handleBrowseButtonSelected() { + FileDialog fileDialog = new FileDialog(getShell(), SWT.NONE); + if (fBinPathText != null) { + fileDialog.setFileName(fBinPathText.getText()); + } else if (fCoreText != null) { + fileDialog.setFileName(fCoreText.getText()); + } + return fileDialog.open(); + } + + protected 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(); + } + }); + } + + 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(); + fBinPathText.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); + } + } + + 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); + } + + @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 (fBinPathText != null) { + String programName = EMPTY_STRING; + try { + + programName = config.getAttribute( + ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, EMPTY_STRING); + } catch (CoreException ce) { + LaunchUIPlugin.log(ce); + } + fBinPathText.setText(programName); + } + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformMainAttachTab.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformMainAttachTab.java index c55bfc2..beeea17 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformMainAttachTab.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformMainAttachTab.java @@ -27,30 +27,16 @@ 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.window.Window; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; @@ -60,45 +46,26 @@ 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.util.ProcessSelector; import org.tizen.sdblib.IDevice; -import org.tizen.sdblib.service.FileEntry; -public class PlatformMainAttachTab extends CMainTab { +@SuppressWarnings({ "restriction" }) +public class PlatformMainAttachTab extends PlatformCommonTab { 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 boolean fSpecifyCoreFile; private IDevice device; - private String filePath = ""; public PlatformMainAttachTab() { - this(false); - } - - public PlatformMainAttachTab(boolean specifyCoreFile) { - fSpecifyCoreFile = specifyCoreFile; device = ConnectionPlugin.getDefault().getCurrentDevice(); } @@ -106,61 +73,15 @@ public class PlatformMainAttachTab extends CMainTab { 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 createProcessGroup(Composite parent, int colSpan) { Composite projComp = new Composite(parent, SWT.NONE); GridLayout projLayout = new GridLayout(); @@ -208,158 +129,12 @@ public class PlatformMainAttachTab extends CMainTab { }); } - protected ICProject chooseCAppProject(String currentProjectName) { - - try { - ICProject[] projects = getCProjects(currentProjectName); - - ILabelProvider labelProvider = new CElementLabelProvider(); - ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), - labelProvider); - dialog.setTitle(LaunchMessages.CMainTab_Project_Selection); - dialog.setMessage(LaunchMessages.CMainTab_Choose_project_to_constrain_search_for_program); - dialog.setElements(projects); - - ICProject cProject = getCProject(); - if (cProject != null) { - dialog.setInitialSelections(new Object[] { cProject }); - } - if (dialog.open() == Window.OK) { - return (ICProject) dialog.getFirstResult(); - } - } catch (CModelException e) { - LaunchUIPlugin.errorDialog("Launch UI internal error", e); //$NON-NLS-1$ - } - return null; - } - - protected ICProject[] getCProjects(String currentProjectName) throws CModelException { - ICProject cproject[] = CoreModel.getDefault().getCModel().getCProjects(); - ArrayList list = new ArrayList(cproject.length); - - for (int i = 0; i < cproject.length; i++) { - if (currentProjectName.length() != 0 - && cproject[i].getProject().getName().equals(currentProjectName)) { - continue; - } - ICDescriptor cdesciptor = null; - try { - cdesciptor = CCorePlugin.getDefault().getCProjectDescription( - (IProject) cproject[i].getResource(), false); - if (cdesciptor != null) { - String projectPlatform = cdesciptor.getPlatform(); - if (filterPlatform.equals("*") //$NON-NLS-1$ - || projectPlatform.equals("*") //$NON-NLS-1$ - || filterPlatform.equalsIgnoreCase(projectPlatform) == true) { - list.add(cproject[i]); - } - } else { - list.add(cproject[i]); - } - } catch (CoreException e) { - list.add(cproject[i]); - } - } - return list.toArray(new ICProject[list.size()]); - } - - private void createExeFileField(Composite parent, int colSpan) { - Composite mainComp = new Composite(parent, SWT.NONE); - GridLayout mainLayout = new GridLayout(); - mainLayout.numColumns = 3; - mainLayout.marginHeight = 0; - mainLayout.marginWidth = 0; - mainComp.setLayout(mainLayout); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = colSpan; - mainComp.setLayoutData(gd); - fProgLabel = new Label(mainComp, SWT.NONE); - fProgLabel.setText(resources.getString("Label.App.Path")); // $NON-NLS-1$ - gd = new GridData(); - gd.horizontalSpan = 3; - fProgLabel.setLayoutData(gd); - fProgText = new Text(mainComp, SWT.SINGLE | SWT.BORDER); - gd = new GridData(GridData.FILL_HORIZONTAL); - fProgText.setLayoutData(gd); - fProgText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent evt) { - updateLaunchConfigurationDialog(); - } - }); - - Button fBrowseForBinaryButton; - fBrowseForBinaryButton = createPushButton(mainComp, - resources.getString("Button.Browse"), null); //$NON-NLS-1$ - fBrowseForBinaryButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent evt) { - handleRemoteBrowseButtonSelected(); - updateLaunchConfigurationDialog(); - } - }); - } - - protected void handleRemoteBrowseButtonSelected() { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) { - IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows(); - window = windows[0]; - } - - final Shell shell = window.getShell(); - if (shell != null) { - IDevice device = ConnectionPlugin.getDefault().getCurrentDevice(); - if (device == null) { - MessageBox msgBox = new MessageBox(shell, SWT.ICON_INFORMATION); - msgBox.setMessage(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE); - msgBox.open(); - return; - } - - shell.getDisplay().syncExec(new Runnable() { - public void run() { - IDevice device = ConnectionPlugin.getDefault().getCurrentDevice(); - TizenRemoteFileDialog dlg = new TizenRemoteFileDialog(shell, resources - .getString("Remote.Dialog.Title"), device, false, 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 @@ -376,7 +151,7 @@ public class PlatformMainAttachTab extends CMainTab { */ @Override public void performApply(ILaunchConfigurationWorkingCopy config) { - // String programPath = fProgText.getText().trim(); + // String programPath = fBinPathText.getText().trim(); String name = fProjText.getText().trim(); String procName = fProcText.getText().trim(); boolean reinstallOp = fReinstallOp.getSelection(); @@ -388,18 +163,6 @@ public class PlatformMainAttachTab extends CMainTab { 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 { @@ -410,26 +173,4 @@ public class PlatformMainAttachTab extends CMainTab { } fProcText.setText(procName); } - - protected void updateReinstallOpFromConfig(ILaunchConfiguration config) { - boolean option = true; - try { - option = config.getAttribute(ITizenLaunchConfigurationConstants.ATTR_REINSTALL_OPTION, - true); - } catch (CoreException ce) { - LaunchUIPlugin.log(ce); - } - fReinstallOp.setSelection(option); - } - - protected void updateSelectPkgOpFromConfig(ILaunchConfiguration config) { - boolean option = true; - try { - option = config.getAttribute(ITizenLaunchConfigurationConstants.ATTR_SELECTPKG_OPTION, - true); - } catch (CoreException ce) { - LaunchUIPlugin.log(ce); - } - fSelectPkgOp.setSelection(option); - } } \ No newline at end of file diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformMainTab.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformMainTab.java index a142c6f..36678b8 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformMainTab.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformMainTab.java @@ -35,13 +35,10 @@ 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; @@ -50,11 +47,7 @@ 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; @@ -65,58 +58,43 @@ 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.pkg.commander.IPkgModelMaker; -import org.tizen.nativeplatform.pkg.commander.factories.PkgModelMakerFactory; +import org.tizen.nativeplatform.pkg.commander.factory.PkgModelMakerFactory; import org.tizen.nativeplatform.pkg.model.IPackage; import org.tizen.nativeplatform.rootstrap.RootstrapManager; +import org.tizen.nativeplatform.ui.adapter.ExtraPkgTableViewerAdapter; +import org.tizen.nativeplatform.ui.listener.ExtraPkgTableHoverListener; +import org.tizen.nativeplatform.ui.provider.ExtraPkgTableViewerProvider; import org.tizen.nativeplatform.util.PlatformProjectUtil; -import org.tizen.sdblib.IDevice; -import org.tizen.sdblib.service.FileEntry; @SuppressWarnings({ "deprecation", "restriction" }) -public class PlatformMainTab extends CMainTab { +public class PlatformMainTab extends PlatformCommonTab { 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 packages = new ArrayList(); - private String filePath = ""; private String selectedFileList = ""; public PlatformMainTab() { @@ -148,46 +126,6 @@ public class PlatformMainTab extends CMainTab { 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")); @@ -226,32 +164,23 @@ public class PlatformMainTab extends CMainTab { 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()); + ExtraPkgTableViewerAdapter adapter = new ExtraPkgTableViewerAdapter(tableViewer); + tableColumn.addSelectionListener(adapter); } - tableViewer.setLabelProvider(new TableViewerProvider()); + tableViewer.setLabelProvider(new ExtraPkgTableViewerProvider()); 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); + ExtraPkgTableHoverListener hoverListener = new ExtraPkgTableHoverListener(getShell(), + tableViewer); + table.addListener(SWT.Dispose, hoverListener); + table.addListener(SWT.KeyDown, hoverListener); + table.addListener(SWT.MouseMove, hoverListener); + table.addListener(SWT.MouseHover, hoverListener); } private void createTableButtonComposite(Composite parent) { @@ -280,9 +209,6 @@ public class PlatformMainTab extends CMainTab { 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(); @@ -310,6 +236,31 @@ public class PlatformMainTab extends CMainTab { Button removeBt = new Button(composite, SWT.PUSH); Image removeIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/remove.gif"); removeBt.setImage(removeIcon); + + removeBt.addMouseListener(new MouseListener() { + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + TableItem[] items = tableViewer.getTable().getSelection(); + for (TableItem item : items) { + Object data = item.getData(); + if (data instanceof IPackage) { + IPackage pkg = (IPackage) data; + if (packages.contains(pkg)) { + packages.remove(pkg); + tableViewer.refresh(); + } + } + } + } + + @Override + public void mouseUp(MouseEvent e) { + } + }); } private void createExtraTableGroup(Composite parent) { @@ -459,10 +410,10 @@ public class PlatformMainTab extends CMainTab { gd = new GridData(); gd.horizontalSpan = 3; fProgLabel.setLayoutData(gd); - fProgText = new Text(mainComp, SWT.SINGLE | SWT.BORDER); + fBinPathText = new Text(mainComp, SWT.SINGLE | SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); - fProgText.setLayoutData(gd); - fProgText.addModifyListener(new ModifyListener() { + fBinPathText.setLayoutData(gd); + fBinPathText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent evt) { updateLaunchConfigurationDialog(); } @@ -480,58 +431,6 @@ public class PlatformMainTab extends CMainTab { }); } - 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); @@ -559,7 +458,7 @@ public class PlatformMainTab extends CMainTab { */ @Override public void performApply(ILaunchConfigurationWorkingCopy config) { - String programPath = fProgText.getText().trim(); + String programPath = fBinPathText.getText().trim(); String name = fProjText.getText().trim(); String appProj = fAppProjText.getText().trim(); boolean reinstallOp = fReinstallOp.getSelection(); @@ -578,33 +477,6 @@ public class PlatformMainTab extends CMainTab { 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 { @@ -630,160 +502,4 @@ public class PlatformMainTab extends CMainTab { packages = maker.makeModels(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) { - IPackage pkg_1 = (IPackage) e1; - IPackage pkg_2 = (IPackage) 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 IPackage) { - IPackage pkg = (IPackage) 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); - IPackage pkg = (IPackage) 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 diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectAttachLaunchShortcut.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectAttachLaunchShortcut.java index b658451..e8556d9 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectAttachLaunchShortcut.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectAttachLaunchShortcut.java @@ -35,8 +35,6 @@ 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; @@ -45,14 +43,12 @@ import org.eclipse.debug.core.ILaunchConfigurationType; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.jface.window.Window; import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; 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.PlatformLaunchWizardDialog; - @SuppressWarnings("restriction") public class PlatformProjectAttachLaunchShortcut extends PlatformProjectCommonLaunchShortcut { @@ -68,6 +64,10 @@ public class PlatformProjectAttachLaunchShortcut extends PlatformProjectCommonLa ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager() .generateLaunchConfigurationName(project.getName())); + if (!checkPackaging(project)) { + return null; + } + if (!setLaunchConfiguration(project, mode)) { return null; } @@ -116,18 +116,10 @@ public class PlatformProjectAttachLaunchShortcut extends PlatformProjectCommonLa } 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(); - + IConfiguration config = PlatformConfigurationManager.getDefaultConfiguration(project); + final Shell shell = getAvaiableShell(); PlatformAttachLaunchWizard wizard = new PlatformAttachLaunchWizard(shell, project, - defaultConfig, target, mode); + config, target, mode); PlatformLaunchWizardDialog dlg = new PlatformLaunchWizardDialog(shell, wizard); dlg.create(); if (Window.OK == dlg.open()) { diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectCommonLaunchShortcut.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectCommonLaunchShortcut.java index 2b34b82..51ee025 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectCommonLaunchShortcut.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectCommonLaunchShortcut.java @@ -27,6 +27,7 @@ package org.tizen.nativeplatform.launch.ui.shortcut; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; @@ -40,12 +41,11 @@ 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.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.IProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; @@ -55,23 +55,31 @@ 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.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; 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.CommonBuildMessages; 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.PlatformLaunchMessages; import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget; +import org.tizen.nativeplatform.pkg.model.IPackage; import org.tizen.nativeplatform.rootstrap.RootstrapManager; -import org.tizen.nativeplatform.util.PlatformLaunchUtils; +import org.tizen.nativeplatform.util.PackageUtil; +import org.tizen.nativeplatform.util.PlatformLaunchUtil; import org.tizen.nativeplatform.util.PlatformProjectUtil; import org.tizen.nativeplatform.views.model.PlatformRootstrap; import org.tizen.sdblib.IDevice; @@ -84,6 +92,8 @@ abstract public class PlatformProjectCommonLaunchShortcut extends CApplicationLa protected boolean selectPkgOp = true; protected IDevice device = null; protected PkgCommandTarget target = null; + private PackageUtil pkgUtil = null; + private boolean result; protected ISourceLookupDirector fLocator; @@ -113,7 +123,7 @@ abstract public class PlatformProjectCommonLaunchShortcut extends CApplicationLa DialogUtil.openErrorDialog(PlatformLaunchMessages.DEVICE_IS_NOT_ROOT_ON); return; } - + pkgUtil = new PackageUtil(PlatformProjectUtil.getPkgType()); if (elements != null && elements.length > 0) { int nElements = elements.length; for (int i = 0; i < nElements; i++) { @@ -210,9 +220,8 @@ abstract public class PlatformProjectCommonLaunchShortcut extends CApplicationLa } protected void setPkgCommandTarget(IProject project) { - IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); - IConfiguration defaultConfig = info.getDefaultConfiguration(); - String targetId = PlatformConfigurationManager.getBuildTargetName(defaultConfig); + IConfiguration config = PlatformConfigurationManager.getDefaultConfiguration(project); + String targetId = PlatformConfigurationManager.getBuildTargetName(config); String rootId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetId); PlatformRootstrap rootstrap = RootstrapManager.getRootstrap(rootId); target = new PkgCommandTarget(PlatformProjectUtil.getPkgType(), device, rootstrap); @@ -224,15 +233,13 @@ abstract public class PlatformProjectCommonLaunchShortcut extends CApplicationLa protected 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[] infos = PlatformLaunchUtil.getProjectInfo(project); String backend = String.format("/usr/src/debug/%s-%s", infos[0], infos[1]); String local = project.getLocation().toOSString(); @@ -307,4 +314,54 @@ abstract public class PlatformProjectCommonLaunchShortcut extends CApplicationLa e.printStackTrace(); } } + + protected boolean checkPackaging(IProject project) { + IConfiguration config = PlatformConfigurationManager.getDefaultConfiguration(project); + List pkgs = pkgUtil.getPackages(project, config); + if (pkgs.isEmpty()) { + if (PlatformLaunchUtil.questionPackaging(project)) { + if (!packagingProject(project, config)) { + DialogUtil.openErrorDialog(CommonBuildMessages.FAIL_TO_BUILD_PACKAGE); + if (PlatformLaunchUtil.questionContinue()) { + return true; + } else { + return false; + } + } + } + } + return true; + } + + protected boolean packagingProject(final IProject project, final IConfiguration config) { + Shell shell = getAvaiableShell(); + ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); + try { + dialog.run(true, true, new IRunnableWithProgress() { + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, + InterruptedException { + result = pkgUtil.pakaging(project, config, monitor); + } + }); + } catch (InvocationTargetException e) { + return false; + } catch (InterruptedException e) { + return false; + } + return result; + } + + protected Shell getAvaiableShell() { + Shell shell = getShell(); + if (shell == null) { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) { + IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows(); + window = windows[0]; + } + shell = window.getShell(); + } + return shell; + } } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectLaunchShortcut.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectLaunchShortcut.java index 26ca3af..1058bb2 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectLaunchShortcut.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectLaunchShortcut.java @@ -27,6 +27,7 @@ package org.tizen.nativeplatform.launch.ui.shortcut; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; @@ -43,20 +44,29 @@ 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.IProgressMonitor; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationType; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.window.Window; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.internal.WorkbenchWindow; +import org.tizen.common.util.DialogUtil; +import org.tizen.nativecommon.build.CommonBuildMessages; import org.tizen.nativecommon.launch.TizenLaunchConfigurationConstants; +import org.tizen.nativeplatform.build.PlatformConfigurationManager; import org.tizen.nativeplatform.launch.ITizenLaunchConfigurationConstants; +import org.tizen.nativeplatform.launch.PlatformLaunchMessages; 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.model.IPackage; -import org.tizen.nativeplatform.util.PlatformLaunchUtils; +import org.tizen.nativeplatform.util.PackageUtil; +import org.tizen.nativeplatform.util.PlatformLaunchUtil; import org.tizen.nativeplatform.util.PlatformProjectUtil; @SuppressWarnings("restriction") @@ -71,12 +81,17 @@ public class PlatformProjectLaunchShortcut extends PlatformProjectCommonLaunchSh ICDebugConfiguration debugConfig, String mode) { ILaunchConfiguration config = null; + try { setPkgCommandTarget(project); ILaunchConfigurationType configType = getCLaunchConfigType(); ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager() .generateLaunchConfigurationName(project.getName())); + if (!checkPackaging(project)) { + return null; + } + if (!setLaunchConfiguration(project, mode)) { return null; } @@ -139,20 +154,13 @@ public class PlatformProjectLaunchShortcut extends PlatformProjectCommonLaunchSh } 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(); + IConfiguration config = PlatformConfigurationManager.getDefaultConfiguration(project); + final Shell shell = getAvaiableShell(); boolean isEflApp = PlatformProjectUtil.isEFLApplication(project); + // If the project is EFL app, do not need to run launch wizard. if (isEflApp) { - PlatformLaunchUtils launchUtil = new PlatformLaunchUtils(target); appProjectName = null; - String[] files = launchUtil.getProgramPath(project); + String[] files = PlatformLaunchUtil.getProgramPath(project); if (files != null) { if (files.length > 1) { SelectItemDialog dlg = new SelectItemDialog(shell, files); @@ -173,8 +181,8 @@ public class PlatformProjectLaunchShortcut extends PlatformProjectCommonLaunchSh selectPkgOp = false; return true; } else { - PlatformLaunchWizard wizard = new PlatformLaunchWizard(shell, project, defaultConfig, - target, mode); + PlatformLaunchWizard wizard = new PlatformLaunchWizard(shell, project, config, target, + mode); PlatformLaunchWizardDialog dlg = new PlatformLaunchWizardDialog(shell, wizard); dlg.create(); if (Window.OK == dlg.open()) { diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchCommonPage.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchCommonPage.java new file mode 100644 index 0000000..ad0383c --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchCommonPage.java @@ -0,0 +1,85 @@ +package org.tizen.nativeplatform.launch.wizard.pages; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.core.resources.IProject; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Shell; +import org.tizen.nativecommon.build.SmartBuildInterface; +import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget; +import org.tizen.nativeplatform.pkg.model.IPackage; +import org.tizen.nativeplatform.util.PackageUtil; +import org.tizen.nativeplatform.util.PlatformProjectUtil; +import org.tizen.nativeplatform.views.model.PlatformRootstrap; + +public class PlatformLaunchCommonPage extends WizardPage { + + protected Button reinstallOp; + protected Button selectPkgOp; + + protected IProject platformProject; + protected IConfiguration config; + protected List platformPackages = new ArrayList(); + protected List packages = new ArrayList(); + protected PkgCommandTarget target = null; + protected PlatformRootstrap rootstrap; + protected String rootPath = ""; + protected Shell shell; + protected PackageUtil pkgUtil = new PackageUtil(PlatformProjectUtil.getPkgType()); + + protected PlatformLaunchCommonPage(String pageName) { + super(pageName); + } + + protected PlatformLaunchCommonPage(String pageName, Shell shell, IProject project, + IConfiguration config, PkgCommandTarget target) { + super(pageName); + + this.platformProject = project; + this.config = config; + this.shell = shell; + this.target = target; + this.rootstrap = target.getRootstrap(); + this.rootPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath( + rootstrap.getPath().toOSString()); + } + + @Override + public void createControl(Composite parent) { + + } + + protected List getPackages(IProject project, IConfiguration config) { + return pkgUtil.getPackages(project, config); + } + + protected void setPlatformPackages() { + platformPackages.clear(); + platformPackages = getPackages(platformProject, config); + // Do not try packaging because it is already tried previous step. + // (PlatformProjectLaunchShortcut) + if (!platformPackages.isEmpty()) { + packages.addAll(platformPackages); + } + } + + public List getPackages() { + return packages; + } + + public boolean getReinstallOp() { + return reinstallOp.getSelection(); + } + + public boolean getSelectPkgOp() { + return selectPkgOp.getSelection(); + } + + public String getRootstrapPath() { + return rootPath; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingAppPage.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingAppPage.java index 37f55ed..db3cf79 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingAppPage.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingAppPage.java @@ -47,10 +47,7 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; @@ -73,23 +70,21 @@ 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.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.build.PlatformConfigurationManager; -import org.tizen.nativeplatform.launch.PlatformLaunchMessages; -import org.tizen.nativeplatform.pkg.commander.IPackager; import org.tizen.nativeplatform.pkg.commander.IPkgModelMaker; import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget; -import org.tizen.nativeplatform.pkg.commander.factories.PackagerFactory; -import org.tizen.nativeplatform.pkg.commander.factories.PkgModelMakerFactory; +import org.tizen.nativeplatform.pkg.commander.factory.PkgModelMakerFactory; import org.tizen.nativeplatform.pkg.model.IPackage; +import org.tizen.nativeplatform.ui.adapter.ExtraPkgTableViewerAdapter; +import org.tizen.nativeplatform.ui.listener.ExtraPkgTableHoverListener; +import org.tizen.nativeplatform.ui.provider.ExtraPkgTableViewerProvider; +import org.tizen.nativeplatform.util.PlatformLaunchUtil; import org.tizen.nativeplatform.util.PlatformProjectUtil; -import org.tizen.nativeplatform.views.model.PlatformRootstrap; -public class PlatformLaunchSettingAppPage extends WizardPage { +public class PlatformLaunchSettingAppPage extends PlatformLaunchCommonPage { private final String BUNDLE_NAME = PlatformLaunchSettingAppPage.class.getPackage().getName() + ".LaunchWizardPageUIMessages";//$NON-NLS-1$ @@ -98,21 +93,10 @@ public class PlatformLaunchSettingAppPage extends WizardPage { 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 platformPackages = new ArrayList(); private List appPackages = new ArrayList(); private List extraPackages = new ArrayList(); - private List packages = new ArrayList(); private List projectNames = new ArrayList(); private Map projectMap = new HashMap(); private IPkgModelMaker modelMaker = PkgModelMakerFactory.getMaker(PlatformProjectUtil @@ -122,53 +106,20 @@ public class PlatformLaunchSettingAppPage extends WizardPage { public PlatformLaunchSettingAppPage(Shell shell, String pageName, IProject project, IConfiguration config, PkgCommandTarget target) { - super(pageName); + super(pageName, shell, project, config, target); setTitle(resources.getString("AppPage.Title")); setDescription(resources.getString("AppPage.Desc")); setPageComplete(true); - - this.platformProject = project; - this.config = config; - this.shell = shell; - this.target = target; - this.rootstrap = target.getRootstrap(); - this.rootPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath( - rootstrap.getPath().toOSString()); - setProjectMap(); setPlatformPackages(); } - public void setPlatformPackages() { - platformPackages.clear(); - IPackager packager = PackagerFactory.getPackager(PlatformProjectUtil.getPkgType(), - platformProject, config); - List pkgPaths = packager.getProjectPackages(); - platformPackages = modelMaker.makeModels(pkgPaths); - if (platformPackages.isEmpty()) { - 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(); - IPackager packager = PackagerFactory.getPackager(PlatformProjectUtil.getPkgType(), appProj, - config); - List pkgPaths = packager.getProjectPackages(); - appPackages = modelMaker.makeModels(pkgPaths); + appPackages = pkgUtil.getPackages(appProj, config); if (appPackages.isEmpty()) { - String msg = String - .format(PlatformLaunchMessages.QUESTION_PACKAGING, appProj.getName()); - if (64 == DialogUtil.openQuestionDialog(msg)) { + if (PlatformLaunchUtil.questionPackaging(appProj)) { if (packagingProject(appProj)) { setAppPackages(appProj); } @@ -320,28 +271,21 @@ public class PlatformLaunchSettingAppPage extends WizardPage { tableColumn.setText(columnNames[i]); tableColumn.setWidth(columnWidths[i]); tableColumn.setResizable(true); + ExtraPkgTableViewerAdapter adapter = new ExtraPkgTableViewerAdapter(tableViewer); + tableColumn.addSelectionListener(adapter); } - tableViewer.setLabelProvider(new TableViewerProvider()); + tableViewer.setLabelProvider(new ExtraPkgTableViewerProvider()); 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); + + ExtraPkgTableHoverListener hoverListener = new ExtraPkgTableHoverListener(getShell(), + tableViewer); + table.addListener(SWT.Dispose, hoverListener); + table.addListener(SWT.KeyDown, hoverListener); + table.addListener(SWT.MouseMove, hoverListener); + table.addListener(SWT.MouseHover, hoverListener); } private void createTableButtonsComposite(Composite parent) { @@ -395,6 +339,31 @@ public class PlatformLaunchSettingAppPage extends WizardPage { Button removeBt = new Button(composite, SWT.PUSH); Image removeIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/remove.gif"); removeBt.setImage(removeIcon); + removeBt.addMouseListener(new MouseListener() { + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + TableItem[] items = tableViewer.getTable().getSelection(); + for (TableItem item : items) { + Object data = item.getData(); + if (data instanceof IPackage) { + IPackage pkg = (IPackage)data; + if (packages.contains(pkg)) { + packages.remove(pkg); + tableViewer.refresh(); + } + } + } + } + + @Override + public void mouseUp(MouseEvent e) { + } + }); } private void createTableGroupComposite(Composite parent) { @@ -421,18 +390,14 @@ public class PlatformLaunchSettingAppPage extends WizardPage { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - IPackager packager = PackagerFactory.getPackager( - PlatformProjectUtil.getPkgType(), targetProj, config); - packagingResult = packager.packaging(monitor); + packagingResult = pkgUtil.pakaging(targetProj, config, monitor); } }); } else { getContainer().run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - IPackager packager = PackagerFactory.getPackager( - PlatformProjectUtil.getPkgType(), targetProj, config); - packagingResult = packager.packaging(monitor); + packagingResult = pkgUtil.pakaging(targetProj, config, monitor); } }); } @@ -459,125 +424,11 @@ public class PlatformLaunchSettingAppPage extends WizardPage { 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 IPackage) { - IPackage p = (IPackage) element; - String name = new Path(p.getPath()).lastSegment(); - - switch (columnIndex) { - case 0: - return name; - default: - break; - } - } - return null; - } - } - - public List getPackages() { - return packages; - } - public List 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); - IPackage pkg = (IPackage) 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; - } - } - }; - } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingBinPage.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingBinPage.java index 2c9348e..faeac67 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingBinPage.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingBinPage.java @@ -50,7 +50,7 @@ import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizard; import org.tizen.sdblib.IDevice; import org.tizen.sdblib.service.FileEntry; -public class PlatformLaunchSettingBinPage extends WizardPage { +public class PlatformLaunchSettingBinPage extends PlatformLaunchCommonPage { private final String BUNDLE_NAME = PlatformLaunchSettingBinPage.class.getPackage().getName() + ".LaunchWizardPageUIMessages";//$NON-NLS-1$ @@ -62,6 +62,7 @@ public class PlatformLaunchSettingBinPage extends WizardPage { public PlatformLaunchSettingBinPage(PlatformLaunchWizard wizard, String pageName) { super(pageName); + this.wizard = wizard; setTitle(resources.getString("BinPage.Title")); setDescription(resources.getString("BinPage.Desc")); diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingProcPage.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingProcPage.java index 36bc2b8..9a1dfe6 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingProcPage.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizard/pages/PlatformLaunchSettingProcPage.java @@ -27,21 +27,13 @@ package org.tizen.nativeplatform.launch.wizard.pages; -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.cdt.managedbuilder.core.IConfiguration; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -52,90 +44,38 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -import org.tizen.common.util.DialogUtil; -import org.tizen.nativecommon.build.CommonBuildMessages; -import org.tizen.nativecommon.build.SmartBuildInterface; -import org.tizen.nativeplatform.launch.PlatformLaunchMessages; import org.tizen.nativeplatform.launch.wizards.PlatformLaunchWizard; -import org.tizen.nativeplatform.pkg.commander.IPackager; -import org.tizen.nativeplatform.pkg.commander.IPkgModelMaker; import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget; -import org.tizen.nativeplatform.pkg.commander.factories.PackagerFactory; -import org.tizen.nativeplatform.pkg.commander.factories.PkgModelMakerFactory; -import org.tizen.nativeplatform.pkg.model.IPackage; -import org.tizen.nativeplatform.util.PlatformProjectUtil; import org.tizen.nativeplatform.util.ProcessSelector; -import org.tizen.nativeplatform.views.model.PlatformRootstrap; import org.tizen.sdblib.IDevice; -public class PlatformLaunchSettingProcPage extends WizardPage { +public class PlatformLaunchSettingProcPage extends PlatformLaunchCommonPage { 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 platformPackages = new ArrayList(); - private List packages = new ArrayList(); - private IPkgModelMaker modelMaker = PkgModelMakerFactory.getMaker(PlatformProjectUtil - .getPkgType()); public PlatformLaunchSettingProcPage(PlatformLaunchWizard wizard, Shell shell, String pageName, IProject project, IConfiguration config, PkgCommandTarget target) { - super(pageName); + super(pageName, shell, project, config, target); 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.target = target; this.device = target.getDevice(); - this.rootstrap = target.getRootstrap(); - this.rootPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath( - rootstrap.getPath().toOSString()); - setPlatformPackages(); } - public void setPlatformPackages() { - platformPackages.clear(); - IPackager packager = PackagerFactory.getPackager(PlatformProjectUtil.getPkgType(), - platformProject, config); - List pkgPaths = packager.getProjectPackages(); - platformPackages = modelMaker.makeModels(pkgPaths); - if (platformPackages.isEmpty()) { - 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); @@ -234,72 +174,7 @@ public class PlatformLaunchSettingProcPage extends WizardPage { return pid; } - public String getRootstrapPath() { - return rootPath; - } - public String getProcName() { return procName; } - - public List getPackages() { - return packages; - } - - public boolean getReinstallOp() { - return reinstallOp.getSelection(); - } - - public boolean getSelectPkgOp() { - return selectPkgOp.getSelection(); - } - - private boolean packagingProject(final IProject targetProj) { - boolean result = false; - - try { - if (getContainer() == null) { - ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); - - dialog.run(true, true, new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - IPackager packager = PackagerFactory.getPackager( - PlatformProjectUtil.getPkgType(), targetProj, config); - packagingResult = packager.packaging(monitor); - } - }); - } else { - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InvocationTargetException, - InterruptedException { - IPackager packager = PackagerFactory.getPackager( - PlatformProjectUtil.getPkgType(), 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); - result = false; - } - - return result; - } } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformAttachLaunchWizard.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformAttachLaunchWizard.java index 7abd194..c8a99f7 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformAttachLaunchWizard.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformAttachLaunchWizard.java @@ -28,32 +28,23 @@ package org.tizen.nativeplatform.launch.wizards; 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.debug.core.ILaunchManager; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.wizard.IWizardContainer; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.swt.widgets.Shell; import org.tizen.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.PlatformLaunchMessages; import org.tizen.nativeplatform.launch.wizard.pages.PlatformLaunchSettingProcPage; -import org.tizen.nativeplatform.pkg.commander.IPkgFilter; -import org.tizen.nativeplatform.pkg.commander.IPkgStatusUpdater; +import org.tizen.nativeplatform.pkg.commander.IPkgLauncher; import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget; -import org.tizen.nativeplatform.pkg.commander.factories.PkgFilterFactory; -import org.tizen.nativeplatform.pkg.commander.factories.PkgStatusUpdaterFactory; -import org.tizen.nativeplatform.pkg.model.IPackage; -import org.tizen.nativeplatform.pkg.model.PkgStatus; -import org.tizen.nativeplatform.types.CmdTargetTypes; -import org.tizen.nativeplatform.util.PlatformLaunchUtils; -import org.tizen.nativeplatform.util.PlatformProjectUtil; +import org.tizen.nativeplatform.pkg.commander.factory.PkgLauncherFactory; +import org.tizen.nativeplatform.types.LaunchTypes; public class PlatformAttachLaunchWizard extends PlatformLaunchWizard { @@ -96,58 +87,22 @@ public class PlatformAttachLaunchWizard extends PlatformLaunchWizard { pid = page.getPid(); packages = page.getPackages(); IWizardContainer container = getContainer(); - final PlatformLaunchUtils launchUtil = new PlatformLaunchUtils(target); - final IPkgFilter pkgFilter = PkgFilterFactory.getFilter(PlatformProjectUtil.getPkgType()); - final IPkgStatusUpdater pkgUpdater = PkgStatusUpdaterFactory.getUpdater( - PlatformProjectUtil.getPkgType(), 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); - - List buildSystemPkgStatus = new ArrayList(); - List devicePkgStatus = new ArrayList(); - - if (!launchUtil.validateRootstrap(rootstrapId)) { - String msg = String.format( - PlatformLaunchMessages.IS_NOT_INITIALIZED_ROOTSTRAP, rootstrapId); - openErrorDialog(msg); - return; - } - List buildSystemPkgs = pkgFilter.filter(CmdTargetTypes.ROOTSTRAP, - packages); - buildSystemPkgStatus = pkgUpdater.updateStatus(CmdTargetTypes.ROOTSTRAP, - buildSystemPkgs); - launchUtil.applyReinstallOp(buildSystemPkgStatus, reinstallOp); - if (selectPkgOp) { - if (!openPkgStatusDialog(buildSystemPkgStatus, devicePkgStatus)) { - return; - } + + IPkgLauncher pkgLauncher = PkgLauncherFactory.getLauncher(project, target, packages, reinstallOp, selectPkgOp); + if (mode.equals(ILaunchManager.DEBUG_MODE)) { + pkgLauncher.debugLaunchPkgs(LaunchTypes.ATTACH, shell, monitor); } - - List selecteBsPkgs = launchUtil - .getSelectedPackages(buildSystemPkgStatus); - - monitor.worked(1); - monitor.subTask(PlatformLaunchMessages.INSTALL_PACKAGES_TO_BUILDSYSTEM); - - if (selecteBsPkgs != null && !selecteBsPkgs.isEmpty()) { - launchUtil.installPkgsToRootstrap(selecteBsPkgs, monitor); - } - monitor.done(); } }); diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizard.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizard.java index 67facef..3a8c9db 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizard.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/wizards/PlatformLaunchWizard.java @@ -48,22 +48,15 @@ import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.widgets.Shell; 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.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.IPkgFilter; -import org.tizen.nativeplatform.pkg.commander.IPkgStatusUpdater; +import org.tizen.nativeplatform.pkg.commander.IPkgLauncher; import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget; -import org.tizen.nativeplatform.pkg.commander.factories.PkgFilterFactory; -import org.tizen.nativeplatform.pkg.commander.factories.PkgStatusUpdaterFactory; +import org.tizen.nativeplatform.pkg.commander.factory.PkgLauncherFactory; import org.tizen.nativeplatform.pkg.model.IPackage; import org.tizen.nativeplatform.pkg.model.PkgStatus; -import org.tizen.nativeplatform.types.CmdTargetTypes; -import org.tizen.nativeplatform.util.PlatformLaunchUtils; -import org.tizen.nativeplatform.util.PlatformProjectUtil; +import org.tizen.nativeplatform.types.LaunchTypes; import org.tizen.sdblib.IDevice; public class PlatformLaunchWizard extends Wizard implements IPageChangingListener, @@ -176,72 +169,22 @@ public class PlatformLaunchWizard extends Wizard implements IPageChangingListene 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); - final IPkgFilter pkgFilter = PkgFilterFactory.getFilter(PlatformProjectUtil.getPkgType()); - final IPkgStatusUpdater pkgUpdater = PkgStatusUpdaterFactory.getUpdater(PlatformProjectUtil.getPkgType(), target); + packages = page.getPackages(); 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); - - List buildSystemPkgStatus = new ArrayList(); - List devicePkgStatus = new ArrayList(); - + IPkgLauncher pkgLauncher = PkgLauncherFactory.getLauncher(project, target, packages, reinstallOp, selectPkgOp); 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; - } - List buildSystemPkgs = pkgFilter.filter(CmdTargetTypes.ROOTSTRAP, packages); - buildSystemPkgStatus = pkgUpdater.updateStatus(CmdTargetTypes.ROOTSTRAP, buildSystemPkgs); - launchUtil.applyReinstallOp(buildSystemPkgStatus, reinstallOp); - } - List devicePkgs = pkgFilter.filter(CmdTargetTypes.DEVICE, packages); - devicePkgStatus = pkgUpdater.updateStatus(CmdTargetTypes.DEVICE, devicePkgs); - launchUtil.applyReinstallOp(devicePkgStatus, reinstallOp); - - if (selectPkgOp) { - if (!openPkgStatusDialog(buildSystemPkgStatus, devicePkgStatus)) { - cancelChanging(event); - return; - } - } - - List selecteBsPkgs = launchUtil.getSelectedPackages(buildSystemPkgStatus); - List selecteDvPkgs = launchUtil.getSelectedPackages(devicePkgStatus); - - 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); - } + pkgLauncher.debugLaunchPkgs(LaunchTypes.NONE, shell, monitor); + } else { + pkgLauncher.launchPkgs(shell, monitor); } monitor.done(); } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/CommandStatus.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/CommandStatus.java index 47d885f..45eb97f 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/CommandStatus.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/CommandStatus.java @@ -1,9 +1,34 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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 org.eclipse.core.runtime.IStatus; - public class CommandStatus implements ICommandStatus { private int severity = OK; private String command = ""; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IChangedLogListener.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IChangedLogListener.java index 6f15fb9..dda09e6 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IChangedLogListener.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IChangedLogListener.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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; public interface IChangedLogListener { diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/ICommandStatus.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/ICommandStatus.java index 63b9bc8..0a3a0f0 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/ICommandStatus.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/ICommandStatus.java @@ -1,9 +1,34 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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 org.eclipse.core.runtime.IStatus; - public interface ICommandStatus { // Status severity constant (value 0) indicating this status represents the // nominal case. diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPackager.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPackager.java index 7373cf6..afe466c 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPackager.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPackager.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgFilter.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgFilter.java index ccbf381..ed5548e 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgFilter.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgFilter.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgLauncher.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgLauncher.java new file mode 100644 index 0000000..6906a15 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgLauncher.java @@ -0,0 +1,40 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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 org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.swt.widgets.Shell; +import org.tizen.nativeplatform.types.LaunchTypes; + +public interface IPkgLauncher { + + void debugLaunchPkgs(LaunchTypes type, Shell shell, IProgressMonitor monitor) + throws InterruptedException; + + void launchPkgs(Shell shell, IProgressMonitor monitor) throws InterruptedException; +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgModelMaker.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgModelMaker.java index c81c368..3c61b8c 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgModelMaker.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgModelMaker.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgStatusUpdater.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgStatusUpdater.java index 956d729..9d21fbc 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgStatusUpdater.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgStatusUpdater.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgVersionComparer.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgVersionComparer.java index c10b7b3..306974b 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgVersionComparer.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgVersionComparer.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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; public interface IPkgVersionComparer { diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/PkgCommandTarget.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/PkgCommandTarget.java index e919480..451d024 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/PkgCommandTarget.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/PkgCommandTarget.java @@ -65,6 +65,10 @@ public class PkgCommandTarget { return rootstrap; } + public PkgTypes getPkgType() { + return type; + } + public IPkgCommander getCommander(CmdTargetTypes type) { if (type.equals(CmdTargetTypes.HOST)) { return getHostCommander(); diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factories/PackagerFactory.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factories/PackagerFactory.java deleted file mode 100644 index 1bd668e..0000000 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factories/PackagerFactory.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.tizen.nativeplatform.pkg.commander.factories; - -import org.eclipse.cdt.managedbuilder.core.IConfiguration; -import org.eclipse.core.resources.IProject; -import org.tizen.nativeplatform.pkg.commander.IPackager; -import org.tizen.nativeplatform.pkg.commander.rpm.RpmPackager; -import org.tizen.nativeplatform.types.PkgTypes; - -public class PackagerFactory { - - public static IPackager getPackager(PkgTypes type, IProject project, - IConfiguration config) { - if (type.equals(PkgTypes.RPM)) { - return new RpmPackager(project, config); - } else { - return null; - } - } -} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factories/PkgFilterFactory.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factories/PkgFilterFactory.java deleted file mode 100644 index c82d19b..0000000 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factories/PkgFilterFactory.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.tizen.nativeplatform.pkg.commander.factories; - -import org.tizen.nativeplatform.pkg.commander.IPkgFilter; -import org.tizen.nativeplatform.pkg.commander.rpm.RpmPackageFilter; -import org.tizen.nativeplatform.types.PkgTypes; - -public class PkgFilterFactory { - public static IPkgFilter getFilter(PkgTypes type) { - if (type.equals(PkgTypes.RPM)) { - IPkgFilter filter = new RpmPackageFilter(); - return filter; - } - return null; - } -} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factories/PkgModelMakerFactory.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factories/PkgModelMakerFactory.java deleted file mode 100644 index e9e46f3..0000000 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factories/PkgModelMakerFactory.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.tizen.nativeplatform.pkg.commander.factories; - -import org.tizen.nativeplatform.pkg.commander.IPkgModelMaker; -import org.tizen.nativeplatform.pkg.commander.rpm.RpmModelMaker; -import org.tizen.nativeplatform.types.PkgTypes; - -public class PkgModelMakerFactory { - public static IPkgModelMaker getMaker(PkgTypes type) { - if (type.equals(PkgTypes.RPM)) { - IPkgModelMaker maker = new RpmModelMaker(); - return maker; - } - return null; - } -} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factories/PkgStatusUpdaterFactory.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factories/PkgStatusUpdaterFactory.java deleted file mode 100644 index 7ed62fa..0000000 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factories/PkgStatusUpdaterFactory.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.tizen.nativeplatform.pkg.commander.factories; - -import org.tizen.nativeplatform.pkg.commander.IPkgStatusUpdater; -import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget; -import org.tizen.nativeplatform.pkg.commander.rpm.RpmStatusUpdater; -import org.tizen.nativeplatform.types.PkgTypes; - -public class PkgStatusUpdaterFactory { - public static IPkgStatusUpdater getUpdater(PkgTypes type, PkgCommandTarget target) { - if (type.equals(PkgTypes.RPM)) { - IPkgStatusUpdater updater = new RpmStatusUpdater(target); - return updater; - } - return null; - } -} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factories/PkgVersionComparerFactory.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factories/PkgVersionComparerFactory.java deleted file mode 100644 index 5f8cfbc..0000000 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factories/PkgVersionComparerFactory.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.tizen.nativeplatform.pkg.commander.factories; - -import org.tizen.nativeplatform.pkg.commander.IPkgVersionComparer; -import org.tizen.nativeplatform.pkg.commander.rpm.RpmVersionComparer; -import org.tizen.nativeplatform.types.PkgTypes; - -public class PkgVersionComparerFactory { - - public static IPkgVersionComparer getComparer(PkgTypes type) { - if (type.equals(PkgTypes.RPM)) { - return new RpmVersionComparer(); - } else { - return null; - } - } -} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PackagerFactory.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PackagerFactory.java new file mode 100644 index 0000000..57c2832 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PackagerFactory.java @@ -0,0 +1,46 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.factory; + +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.core.resources.IProject; +import org.tizen.nativeplatform.pkg.commander.IPackager; +import org.tizen.nativeplatform.pkg.commander.rpm.RpmPackager; +import org.tizen.nativeplatform.types.PkgTypes; + +public class PackagerFactory { + + public static IPackager getPackager(PkgTypes type, IProject project, + IConfiguration config) { + if (type.equals(PkgTypes.RPM)) { + return new RpmPackager(project, config); + } else { + return null; + } + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgFilterFactory.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgFilterFactory.java new file mode 100644 index 0000000..848918e --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgFilterFactory.java @@ -0,0 +1,42 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.factory; + +import org.tizen.nativeplatform.pkg.commander.IPkgFilter; +import org.tizen.nativeplatform.pkg.commander.rpm.RpmPackageFilter; +import org.tizen.nativeplatform.types.PkgTypes; + +public class PkgFilterFactory { + public static IPkgFilter getFilter(PkgTypes type) { + if (type.equals(PkgTypes.RPM)) { + IPkgFilter filter = new RpmPackageFilter(); + return filter; + } + return null; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgLauncherFactory.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgLauncherFactory.java new file mode 100644 index 0000000..f35a7c8 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgLauncherFactory.java @@ -0,0 +1,50 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.factory; + +import java.util.List; + +import org.eclipse.core.resources.IProject; +import org.tizen.nativeplatform.pkg.commander.IPkgLauncher; +import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget; +import org.tizen.nativeplatform.pkg.commander.rpm.RpmPackageLauncher; +import org.tizen.nativeplatform.pkg.model.IPackage; +import org.tizen.nativeplatform.types.PkgTypes; + +public class PkgLauncherFactory { + public static IPkgLauncher getLauncher(IProject project, PkgCommandTarget target, + List packages, boolean reinstallOp, boolean selectPkgOp) { + PkgTypes type = target.getPkgType(); + if (type.equals(PkgTypes.RPM)) { + IPkgLauncher launcher = new RpmPackageLauncher(project, target, packages, reinstallOp, + selectPkgOp); + return launcher; + } + return null; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgModelMakerFactory.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgModelMakerFactory.java new file mode 100644 index 0000000..1d40424 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgModelMakerFactory.java @@ -0,0 +1,42 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.factory; + +import org.tizen.nativeplatform.pkg.commander.IPkgModelMaker; +import org.tizen.nativeplatform.pkg.commander.rpm.RpmModelMaker; +import org.tizen.nativeplatform.types.PkgTypes; + +public class PkgModelMakerFactory { + public static IPkgModelMaker getMaker(PkgTypes type) { + if (type.equals(PkgTypes.RPM)) { + IPkgModelMaker maker = new RpmModelMaker(); + return maker; + } + return null; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgStatusUpdaterFactory.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgStatusUpdaterFactory.java new file mode 100644 index 0000000..b4bbea2 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgStatusUpdaterFactory.java @@ -0,0 +1,44 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.factory; + +import org.tizen.nativeplatform.pkg.commander.IPkgStatusUpdater; +import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget; +import org.tizen.nativeplatform.pkg.commander.rpm.RpmStatusUpdater; +import org.tizen.nativeplatform.types.PkgTypes; + +public class PkgStatusUpdaterFactory { + public static IPkgStatusUpdater getUpdater(PkgCommandTarget target) { + PkgTypes type = target.getPkgType(); + if (type.equals(PkgTypes.RPM)) { + IPkgStatusUpdater updater = new RpmStatusUpdater(target); + return updater; + } + return null; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgVersionComparerFactory.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgVersionComparerFactory.java new file mode 100644 index 0000000..13adf99 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PkgVersionComparerFactory.java @@ -0,0 +1,43 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.factory; + +import org.tizen.nativeplatform.pkg.commander.IPkgVersionComparer; +import org.tizen.nativeplatform.pkg.commander.rpm.RpmVersionComparer; +import org.tizen.nativeplatform.types.PkgTypes; + +public class PkgVersionComparerFactory { + + public static IPkgVersionComparer getComparer(PkgTypes type) { + if (type.equals(PkgTypes.RPM)) { + return new RpmVersionComparer(); + } else { + return null; + } + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderDevice.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderDevice.java index 5b88cb8..5c30ebb 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderDevice.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderDevice.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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 static org.tizen.sdblib.service.SyncServiceConstants.RESULT_OK; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderHost.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderHost.java index 453b8fa..a9e433a 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderHost.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderHost.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.util.Map; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderRootstrap.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderRootstrap.java index d21a785..4a2dc02 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderRootstrap.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderRootstrap.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmModelMaker.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmModelMaker.java index ed40597..4eeb589 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmModelMaker.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmModelMaker.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmPackageFilter.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmPackageFilter.java index c396886..b65da03 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmPackageFilter.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmPackageFilter.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.util.ArrayList; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmPackageLauncher.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmPackageLauncher.java new file mode 100644 index 0000000..2cd8323 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmPackageLauncher.java @@ -0,0 +1,268 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.util.ArrayList; +import java.util.List; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.widgets.Shell; +import org.tizen.common.util.SWTUtil; +import org.tizen.nativecommon.launch.TizenLaunchMessages; +import org.tizen.nativeplatform.launch.PlatformLaunchMessages; +import org.tizen.nativeplatform.launch.wizards.ShowPackageStatusDialog; +import org.tizen.nativeplatform.pkg.commander.ICommandStatus; +import org.tizen.nativeplatform.pkg.commander.IPkgCommander; +import org.tizen.nativeplatform.pkg.commander.IPkgFilter; +import org.tizen.nativeplatform.pkg.commander.IPkgLauncher; +import org.tizen.nativeplatform.pkg.commander.IPkgStatusUpdater; +import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget; +import org.tizen.nativeplatform.pkg.commander.factory.PkgFilterFactory; +import org.tizen.nativeplatform.pkg.commander.factory.PkgStatusUpdaterFactory; +import org.tizen.nativeplatform.pkg.model.IPackage; +import org.tizen.nativeplatform.pkg.model.PkgStatus; +import org.tizen.nativeplatform.pkgmgr.PkgMgrInitializer; +import org.tizen.nativeplatform.rootstrap.RootstrapManager; +import org.tizen.nativeplatform.types.CmdTargetTypes; +import org.tizen.nativeplatform.types.LaunchTypes; +import org.tizen.nativeplatform.types.PkgInstallTypes; +import org.tizen.nativeplatform.util.PlatformProjectUtil; +import org.tizen.sdblib.util.DeviceUtil; + +public class RpmPackageLauncher implements IPkgLauncher { + private IProject project; + private PkgCommandTarget target; + private IPkgFilter pkgFilter; + private IPkgStatusUpdater pkgUpdater; + private boolean selectPkgOp; + private boolean reinstallOp; + private List packages; + private boolean result = false; + + public RpmPackageLauncher(IProject project, PkgCommandTarget target, List packages, + boolean reinstallOp, boolean selectPkgOp) { + this.packages = packages; + this.selectPkgOp = selectPkgOp; + this.reinstallOp = reinstallOp; + this.project = project; + this.target = target; + this.pkgFilter = PkgFilterFactory.getFilter(target.getPkgType()); + this.pkgUpdater = PkgStatusUpdaterFactory.getUpdater(target); + } + + @Override + public void debugLaunchPkgs(LaunchTypes type, Shell shell, IProgressMonitor monitor) + throws InterruptedException { + validateRootstrap(target.getRootstrap().getId()); + List buildSystemPkgStatus = new ArrayList(); + List devicePkgStatus = new ArrayList(); + buildSystemPkgStatus = filterAndUpdatePkgs(CmdTargetTypes.ROOTSTRAP); + if (!type.equals(LaunchTypes.ATTACH)) { + devicePkgStatus = filterAndUpdatePkgs(CmdTargetTypes.DEVICE); + } + internalLaunchPkgs(buildSystemPkgStatus, devicePkgStatus, shell, monitor); + } + + @Override + public void launchPkgs(Shell shell, IProgressMonitor monitor) throws InterruptedException { + List buildSystemPkgStatus = new ArrayList(); + List devicePkgStatus = new ArrayList(); + devicePkgStatus = filterAndUpdatePkgs(CmdTargetTypes.DEVICE); + internalLaunchPkgs(buildSystemPkgStatus, devicePkgStatus, shell, monitor); + } + + private void internalLaunchPkgs(List buildSystemPkgStatus, + List devicePkgStatus, Shell shell, IProgressMonitor monitor) + throws InterruptedException { + monitor.beginTask(PlatformLaunchMessages.INSTALL_PACKAGE, 4); + monitor.subTask(PlatformLaunchMessages.CHECK_PKG_STATUS); + + boolean isEflApp = PlatformProjectUtil.isEFLApplication(project); + + //if (!isEflApp && selectPkgOp) { + if (selectPkgOp) { + if (!openPkgStatusDialog(shell, buildSystemPkgStatus, devicePkgStatus)) { + newInterruptedException(PlatformLaunchMessages.CANCELED_LAUNCH); + } + } + + List selecteBsPkgs = getSelectedPackages(buildSystemPkgStatus); + List selecteDvPkgs = getSelectedPackages(devicePkgStatus); + + monitor.worked(1); + monitor.subTask(PlatformLaunchMessages.INSTALL_PACKAGES_TO_BUILDSYSTEM); + if (selecteBsPkgs != null && !selecteBsPkgs.isEmpty()) { + installPkgsToRootstrap(selecteBsPkgs, IPkgCommander.TOOL.ZYPPER, monitor); + } + + monitor.subTask(PlatformLaunchMessages.INSTALL_PACKAGES_TO_DEVICE); + if (selecteDvPkgs != null && !selecteDvPkgs.isEmpty()) { + if (isEflApp) { + installPkgsToDevice(selecteDvPkgs, IPkgCommander.TOOL.PKGCMD, monitor); + } else { + installPkgsToDevice(selecteDvPkgs, IPkgCommander.TOOL.ZYPPER, monitor); + } + } + monitor.done(); + } + + private List filterAndUpdatePkgs(CmdTargetTypes cmdTarget) { + List pkgStatus = new ArrayList(); + List pkgs = pkgFilter.filter(cmdTarget, packages); + pkgStatus = pkgUpdater.updateStatus(cmdTarget, pkgs); + applyReinstallOp(pkgStatus, reinstallOp); + + return pkgStatus; + } + + private void applyReinstallOp(List list, boolean reinstallOp) { + for (PkgStatus status : list) { + //status.setChecked(false); + + if (status.getInstallInfo().equals(PkgInstallTypes.INSTALLED) && !reinstallOp) { + status.setChecked(false); + } + } + } + + private void validateRootstrap(String rootstrapId) throws InterruptedException { + if (!RootstrapManager.checkInitialized(rootstrapId)) { + String msg = String.format(PlatformLaunchMessages.IS_NOT_INITIALIZED_ROOTSTRAP, + rootstrapId); + newInterruptedException(msg); + } + } + + private void newInterruptedException(String message) throws InterruptedException { + throw new InterruptedException(message); + } + + private boolean openPkgStatusDialog(final Shell shell, + final List buildSystemPkgStatus, final List devicePkgStatus) { + + SWTUtil.syncExec(new Runnable() { + public void run() { + ShowPackageStatusDialog statusDlg = new ShowPackageStatusDialog(shell, + buildSystemPkgStatus, devicePkgStatus); + if (Window.OK == statusDlg.open()) { + result = true; + } else { + result = false; + } + } + }); + + return result; + } + + private List getSelectedPackages(List pkgStatus) { + List selectedPkgs = new ArrayList(); + for (PkgStatus status : pkgStatus) { + if (status.isChecked()) { + selectedPkgs.add(status.getPackage()); + } + } + return selectedPkgs; + } + + private boolean installPkgsToRootstrap(List packages, IPkgCommander.TOOL type, + IProgressMonitor monitor) throws InterruptedException { + if (!target.getRootstrap().checkInitialized()) { + newInterruptedException(String.format( + PlatformLaunchMessages.IS_NOT_INITIALIZED_ROOTSTRAP, target.getRootstrap() + .getId())); + } else { + PkgMgrInitializer initializer = new PkgMgrInitializer(target); + initializer.initRootstrapRepoInfo(); + } + return installPkgs(target.getCommander(CmdTargetTypes.ROOTSTRAP), type, packages, monitor); + } + + private boolean installPkgsToDevice(List packages, IPkgCommander.TOOL type, + IProgressMonitor monitor) throws InterruptedException { + if (!DeviceUtil.isOnline(target.getDevice())) { + newInterruptedException(TizenLaunchMessages.CANNOT_CONNECT_TO_DEVICE); + } else if (!target.getDevice().isRoot()) { + newInterruptedException(PlatformLaunchMessages.DEVICE_IS_NOT_ROOT_ON); + } else { + PkgMgrInitializer initializer = new PkgMgrInitializer(target); + initializer.initDeviceRepoInfo(); + } + return installPkgs(target.getCommander(CmdTargetTypes.DEVICE), type, packages, monitor); + } + + private boolean installPkgs(IPkgCommander commander, IPkgCommander.TOOL type, + List packages, IProgressMonitor monitor) throws InterruptedException { + monitor.beginTask("Installing packages to rootstrap", 2); + + List paths = new ArrayList(); + + for (IPackage p : packages) { + String filePath = p.getPath(); + paths.add(filePath.trim()); + } + + ICommandStatus status = commander.installLocalPkg(paths.toArray(new String[0]), type, + monitor); + monitor.worked(1); + + if (!status.isOk()) { + newInterruptedException(status.getMessage()); + } + + List 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 (IPackage p : packages) { + String name = p.getName(); + if (!commander.checkPkgInstalled(name)) { + failedInstallPkgs = failedInstallPkgs + " - " + name + newline(); + } + } + monitor.worked(2); + + if (!failedInstallPkgs.isEmpty()) { + newInterruptedException(log); + } + + return true; + } + + private String newline() { + return "\n"; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmPackager.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmPackager.java index 14820e7..a2ac4bc 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmPackager.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmPackager.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmStatusUpdater.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmStatusUpdater.java index 916283f..ff113df 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmStatusUpdater.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmStatusUpdater.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.util.ArrayList; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmVersionComparer.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmVersionComparer.java index 97e652c..348b27e 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmVersionComparer.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmVersionComparer.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.util.ArrayList; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/model/IPackage.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/model/IPackage.java index 5dab4e2..7e0ac25 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/model/IPackage.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/model/IPackage.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.model; import org.tizen.nativeplatform.types.PkgTypes; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/model/Package.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/model/Package.java index a2f3411..f1dc550 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/model/Package.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/model/Package.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.model; import org.tizen.nativeplatform.types.PkgTypes; @@ -62,6 +89,7 @@ public class Package implements IPackage { @Override public PkgTypes getType() { + // return default type return PkgTypes.RPM; } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/model/PkgStatus.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/model/PkgStatus.java index 8cfaee3..be89b41 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/model/PkgStatus.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/model/PkgStatus.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.model; import org.tizen.nativeplatform.types.PkgInstallTypes; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/PkgMgrInitializer.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/PkgMgrInitializer.java index 4bb8c96..733cb47 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/PkgMgrInitializer.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/PkgMgrInitializer.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.Map; @@ -12,7 +39,6 @@ import org.tizen.nativeplatform.repo.commander.RepoManager; import org.tizen.nativeplatform.repo.model.Repository; import org.tizen.nativeplatform.repo.model.RepositoryProvider; import org.tizen.nativeplatform.types.CmdTargetTypes; -import org.tizen.nativeplatform.types.PkgTypes; import org.tizen.nativeplatform.views.model.PlatformRootstrap; import org.tizen.sdblib.IDevice; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/AddRepoDialog.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/AddRepoDialog.java index dc1307d..658f355 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/AddRepoDialog.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/AddRepoDialog.java @@ -27,240 +27,83 @@ package org.tizen.nativeplatform.pkgmgr.ui; -import java.util.ArrayList; -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.dialogs.Dialog; import org.eclipse.swt.SWT; -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.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.DirectoryDialog; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; import org.tizen.common.util.DialogUtil; -import org.tizen.nativeplatform.build.PlatformConfigurationManager; import org.tizen.nativeplatform.repo.commander.RepoManager; -public class AddRepoDialog extends Dialog { - - private Text remoteText; - private Text localText; - private Button remoteCheckBt; - private Button localCheckBt; - private Button browseBt; - private String url = null; - private String type = null; - private boolean supportLocalRepo = false; - - - private int x = 0; - private int y = 0; - private final int width = 600; - private final int height = 250; - - private final String BUNDLE_NAME = AddRepoDialog.class.getPackage().getName() + ".PkgMgrUIMessages";//$NON-NLS-1$ - private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); +public class AddRepoDialog extends RepoCommonDialog { + + private String url = null; + + protected AddRepoDialog(Shell parentShell) { + super(parentShell); + } + + public AddRepoDialog(Shell parentShell, String tab, boolean supportLocalRepo) { + super(parentShell); + this.supportLocalRepo = supportLocalRepo; + 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, resources.getString("AddRepo.Title")); + } - - protected AddRepoDialog(Shell parentShell) { - super(parentShell); - } - - - public AddRepoDialog(Shell parentShell, String tab, boolean supportLocalRepo) { - super(parentShell); - this.supportLocalRepo = supportLocalRepo; - 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(resources.getString("AddRepo.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.VERTICAL_ALIGN_BEGINNING | - GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); - composite.setLayout(new GridLayout(1, false)); - - createRepoComposite(parent); - - return composite; - } - - private void createRepoComposite(Composite parent) { - Composite composite = new Composite( parent, SWT.NONE); - composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | - GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); - composite.setLayout(new GridLayout(3, false)); - - remoteCheckBt = new Button(composite, SWT.RADIO); - GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); - gridData.horizontalSpan = 3; - remoteCheckBt.setLayoutData(gridData); - remoteCheckBt.setText(resources.getString("AddRepo.Button.Check.Remote")); - remoteCheckBt.addSelectionListener( new SelectionListener(){ + @Override + protected Control createDialogArea(Composite parent) { - @Override - public void widgetSelected(SelectionEvent event) { - Button button = (Button) event.widget; - if (button.getSelection()) { - remoteText.setEnabled(true); - } else { - remoteText.setEnabled(false); - } - } + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING + | GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); + composite.setLayout(new GridLayout(1, false)); - @Override - public void widgetDefaultSelected(SelectionEvent event) { - } - - }); - - Label urlLabel = new Label(composite, SWT.NONE); - urlLabel.setText(resources.getString("AddRepo.Label.Uri")); - remoteText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH); - gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); - gridData.horizontalSpan = 2; - remoteText.setLayoutData(gridData); - + createRepoComposite(parent); + + return composite; + } + + protected void initControls() { + remoteCheckBt.setSelection(true); + remoteText.setEnabled(true); if (supportLocalRepo) { - localCheckBt = new Button(composite, SWT.RADIO); - gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); - gridData.horizontalSpan = 3; - localCheckBt.setLayoutData(gridData); - localCheckBt.setText(resources.getString("AddRepo.Button.Check.Local")); - localCheckBt.addSelectionListener( new SelectionListener(){ - - @Override - public void widgetSelected(SelectionEvent event) { - Button button = (Button) event.widget; - if (button.getSelection()) { - localText.setEnabled(true); - browseBt.setEnabled(true); - - } else { - localText.setEnabled(false); - browseBt.setEnabled(false); - } - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - } - - }); - - Label pathLabel = new Label(composite, SWT.NONE); - pathLabel.setText(resources.getString("AddRepo.Local.Label.Path")); - localText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH); - gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); - localText.setLayoutData(gridData); - localText.setEditable(false); - - browseBt = new Button(composite, SWT.NONE); - browseBt.setText(resources.getString("AddRepo.Button.Browse")); - browseBt.addMouseListener(new MouseListener() { - - @Override - public void mouseDoubleClick(MouseEvent e) { - } - - @Override - public void mouseDown(MouseEvent e) { - DirectoryDialog dialog = new DirectoryDialog(getShell()); - dialog.setText(resources.getString("AddRepo.DirDlg.Title")); - String repoPath = dialog.open(); - - if ( repoPath == null ) { - return; - } else { - IPath path = new Path(repoPath); - if (RepoManager.getValidator(path).validate()) { - ArrayList archs = RepoManager.getValidator(path).availableArchs(); - if (archs == null) { - DialogUtil.openErrorDialog(resources.getString("AddRepo.Msg.Error.getArch")); - return; - } - - localText.setText(repoPath); - } else { - DialogUtil.openErrorDialog(resources.getString("AddRepo.Msg.Error.NotLocalRepo")); - return; - } - } - } - - @Override - public void mouseUp(MouseEvent e) { - } - - }); - } - initControls(); - } - - private void initControls() { - remoteCheckBt.setSelection(true); - remoteText.setEnabled(true); - if (supportLocalRepo) { - localCheckBt.setSelection(false); - localText.setEnabled(false); - browseBt.setEnabled(false); - } - } - - @Override - protected void okPressed() { - if (remoteCheckBt.getSelection()) { - url = remoteText.getText(); - if (url == null || url.isEmpty()) { - DialogUtil.openErrorDialog(resources.getString("AddRepo.Msg.Error.URLEmpty")); - return; - } - type = RepoManager.REMOTE_REPO_TYPE; - } else if (localCheckBt.getSelection()) { - url = localText.getText(); - if (url == null || url.isEmpty()) { - DialogUtil.openErrorDialog(resources.getString("AddRepo.Msg.Error.URLEmpty")); - return; - } - type = RepoManager.LOCAL_REPO_TYPE; - } + localCheckBt.setSelection(false); + localText.setEnabled(false); + browseBt.setEnabled(false); + } + } + + @Override + protected void okPressed() { + if (remoteCheckBt.getSelection()) { + url = remoteText.getText(); + if (url == null || url.isEmpty()) { + DialogUtil.openErrorDialog(resources.getString("AddRepo.Msg.Error.URLEmpty")); + return; + } + type = RepoManager.REMOTE_REPO_TYPE; + } else if (localCheckBt.getSelection()) { + url = localText.getText(); + if (url == null || url.isEmpty()) { + DialogUtil.openErrorDialog(resources.getString("AddRepo.Msg.Error.URLEmpty")); + return; + } + type = RepoManager.LOCAL_REPO_TYPE; + } + + url = url.trim(); + super.okPressed(); + } - url = url.trim(); - super.okPressed(); - } - - - public String getRepositoryURL() { - return url; - } - - public String getRepoType() { - return type; - } + public String getRepositoryURL() { + return url; + } } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/CommonTab.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/CommonTab.java index d554262..67f0370 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/CommonTab.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/CommonTab.java @@ -77,9 +77,11 @@ 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.factories.PkgVersionComparerFactory; +import org.tizen.nativeplatform.pkg.commander.factory.PkgVersionComparerFactory; import org.tizen.nativeplatform.pkg.model.PkgStatus; import org.tizen.nativeplatform.repo.model.Repository; +import org.tizen.nativeplatform.ui.adapter.PackageTableSelectionAdapter; +import org.tizen.nativeplatform.ui.adapter.RepoTableSelectionAdapter; import org.tizen.nativeplatform.util.PlatformProjectUtil; @SuppressWarnings("restriction") diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/DeviceTab.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/DeviceTab.java index ccc9f6c..80cb18d 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/DeviceTab.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/DeviceTab.java @@ -71,14 +71,15 @@ public class DeviceTab extends CommonTab { private String findUrlName() { Map list = commander.getRepoList(); int idx = 0; - for (Entry e : list.entrySet()) { - String name = String.format("url%d", idx); + String name = ""; + for (idx = 0; idx < list.size(); idx++) { + name = String.format("url%d", idx); if (!list.containsKey(name)) { return name; } - idx++; } - return null; + name = String.format("url%d", idx); + return name; } protected boolean handleAddRepositoryButton() { diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/ModifyRepoDialog.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/ModifyRepoDialog.java index 050d3f2..42c39c1 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/ModifyRepoDialog.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/ModifyRepoDialog.java @@ -27,313 +27,138 @@ package org.tizen.nativeplatform.pkgmgr.ui; -import java.util.ArrayList; -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.dialogs.Dialog; import org.eclipse.swt.SWT; -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.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.DirectoryDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; + import org.tizen.common.util.DialogUtil; import org.tizen.nativeplatform.repo.commander.RepoManager; +public class ModifyRepoDialog extends RepoCommonDialog { + + private String name = ""; + private String prevUrl = ""; + private boolean isDirty = false; + private String newUrl = null; + + protected ModifyRepoDialog(Shell parentShell) { + super(parentShell); + } + + public ModifyRepoDialog(Shell parentShell, String tab) { + super(parentShell); + Rectangle bounds = parentShell.getBounds(); + x = bounds.x + (bounds.width - width) / 2; + y = bounds.y + (bounds.height - height) / 2; + } -public class ModifyRepoDialog extends Dialog { - - //private String newName = ""; - //private String prevName = ""; - private String name = ""; - private String prevUrl = ""; - //private Text nameText; - private boolean isDirty = false; - private boolean supportLocalRepo = false; - - private Text remoteText; - private Text localText; - private Button remoteCheckBt; - private Button localCheckBt; - private Button browseBt; - private String newUrl = null; - private String type = null; - - private int x = 0; - private int y = 0; - private final int width = 600; - private final int height = 300; - - private final String BUNDLE_NAME = ModifyRepoDialog.class.getPackage().getName() + ".PkgMgrUIMessages";//$NON-NLS-1$ - private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + public ModifyRepoDialog(Shell parentShell, String tab, String name, String url, + boolean supportLocalRepo) { + super(parentShell); + this.prevUrl = url; + this.name = name; + this.type = RepoManager.getURLType(url); + this.supportLocalRepo = supportLocalRepo; + 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, resources.getString("ModifyRepo.Title")); + } - protected ModifyRepoDialog(Shell parentShell) { - super(parentShell); - } - - public ModifyRepoDialog(Shell parentShell, String tab) { - super(parentShell); - Rectangle bounds = parentShell.getBounds(); - x = bounds.x + (bounds.width - width)/2; - y = bounds.y + (bounds.height - height)/2; - } + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING + | GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); + composite.setLayout(new GridLayout(1, false)); - - public ModifyRepoDialog(Shell parentShell, - String tab, - String name, - String url, - boolean supportLocalRepo) { - super(parentShell); - this.prevUrl = url; - this.name = name; - this.type = RepoManager.getURLType(url); - this.supportLocalRepo = supportLocalRepo; - - 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(resources.getString("ModifyRepo.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.VERTICAL_ALIGN_BEGINNING | - GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); - composite.setLayout(new GridLayout(1, false)); - - createNameComposite(composite); - createRepoComposite(composite); - - return composite; + createNameComposite(composite); + createRepoComposite(composite); + + return composite; + + } + + private void createNameComposite(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING + | GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); + composite.setLayout(new GridLayout(2, false)); - } - - private void createNameComposite(Composite parent) { - Composite composite = new Composite( parent, SWT.NONE); - composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | - GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); - composite.setLayout(new GridLayout(2, false)); - Label nameLabel = new Label(composite, SWT.NONE); nameLabel.setText(resources.getString("ModifyRepo.Label.Name")); - + Label nameValue = new Label(composite, SWT.NONE); nameValue.setText(name); - /* - if ( canEditName ) { - nameText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH); + } + + protected void initControls() { + if (supportLocalRepo) { + if (RepoManager.isLocalType(type)) { + localCheckBt.setSelection(true); + localText.setText(prevUrl); + browseBt.setEnabled(true); + remoteText.setEnabled(false); + } else { + remoteCheckBt.setSelection(true); + remoteText.setText(prevUrl); + localText.setEnabled(false); + browseBt.setEnabled(false); + } + } else { + remoteCheckBt.setSelection(true); + remoteText.setText(prevUrl); } - else { - nameText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.READ_ONLY); + + } + + @Override + protected void okPressed() { + if (remoteCheckBt.getSelection()) { + newUrl = remoteText.getText(); + if (newUrl == null || newUrl.isEmpty()) { + DialogUtil.openErrorDialog(resources.getString("AddRepo.Msg.Error.URLEmpty")); + return; + } + type = RepoManager.REMOTE_REPO_TYPE; + } else if (localCheckBt.getSelection()) { + newUrl = localText.getText(); + if (newUrl == null || newUrl.isEmpty()) { + DialogUtil.openErrorDialog(resources.getString("AddRepo.Msg.Error.URLEmpty")); + return; + } + type = RepoManager.LOCAL_REPO_TYPE; } - GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING); - gridData.widthHint = 100; - nameText.setLayoutData(gridData); - nameText.setText(prevName); - */ - } - - - private void createRepoComposite(Composite parent) { - Composite composite = new Composite( parent, SWT.NONE); - composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | - GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); - composite.setLayout(new GridLayout(3, false)); - - remoteCheckBt = new Button(composite, SWT.RADIO); - GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); - gridData.horizontalSpan = 3; - remoteCheckBt.setLayoutData(gridData); - remoteCheckBt.setText(resources.getString("AddRepo.Button.Check.Remote")); - remoteCheckBt.addSelectionListener( new SelectionListener(){ - @Override - public void widgetSelected(SelectionEvent event) { - Button button = (Button) event.widget; - if (button.getSelection()) { - remoteText.setEnabled(true); - } else { - remoteText.setEnabled(false); - } - } + newUrl = newUrl.trim(); - @Override - public void widgetDefaultSelected(SelectionEvent event) { - } - - }); - - Label urlLabel = new Label(composite, SWT.NONE); - urlLabel.setText(resources.getString("AddRepo.Label.Uri")); - remoteText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH); - gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); - gridData.horizontalSpan = 2; - remoteText.setLayoutData(gridData); - - if (supportLocalRepo) { - localCheckBt = new Button(composite, SWT.RADIO); - gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); - gridData.horizontalSpan = 3; - localCheckBt.setLayoutData(gridData); - localCheckBt.setText(resources.getString("AddRepo.Button.Check.Local")); - localCheckBt.addSelectionListener( new SelectionListener(){ - - @Override - public void widgetSelected(SelectionEvent event) { - Button button = (Button) event.widget; - if (button.getSelection()) { - localText.setEnabled(true); - browseBt.setEnabled(true); - - } else { - localText.setEnabled(false); - browseBt.setEnabled(false); - } - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - } - - }); - - Label pathLabel = new Label(composite, SWT.NONE); - pathLabel.setText(resources.getString("AddRepo.Local.Label.Path")); - localText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH); - gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); - localText.setLayoutData(gridData); - localText.setEditable(false); - - browseBt = new Button(composite, SWT.NONE); - browseBt.setText(resources.getString("AddRepo.Button.Browse")); - browseBt.addMouseListener(new MouseListener() { - - @Override - public void mouseDoubleClick(MouseEvent e) { - } - - @Override - public void mouseDown(MouseEvent e) { - DirectoryDialog dialog = new DirectoryDialog(getShell()); - dialog.setText(resources.getString("AddRepo.DirDlg.Title")); - String repoPath = dialog.open(); - - if ( repoPath == null ) { - return; - } else { - IPath path = new Path(repoPath); - if (RepoManager.getValidator(path).validate()) { - ArrayList archs = RepoManager.getValidator(path).availableArchs(); - if (archs == null) { - DialogUtil.openErrorDialog(resources.getString("AddRepo.Msg.Error.getArch")); - return; - } - - localText.setText(repoPath); - } else { - DialogUtil.openErrorDialog(resources.getString("AddRepo.Msg.Error.NotLocalRepo")); - return; - } - } - } - - @Override - public void mouseUp(MouseEvent e) { - } - - }); + if (newUrl.equals(prevUrl)) { + isDirty = false; + } else { + isDirty = true; } - initControls(); - } - - private void initControls() { - if (supportLocalRepo) { - if (RepoManager.isLocalType(type)) { - localCheckBt.setSelection(true); - localText.setText(prevUrl); - browseBt.setEnabled(true); - remoteText.setEnabled(false); - } else { - remoteCheckBt.setSelection(true); - remoteText.setText(prevUrl); - localText.setEnabled(false); - browseBt.setEnabled(false); - } - } else { - remoteCheckBt.setSelection(true); - remoteText.setText(prevUrl); - } - - } - - @Override - protected void okPressed() { - /* - newName = nameText.getText().trim(); - if ( newName.isEmpty() ) { - return; - } - */ - - if (remoteCheckBt.getSelection()) { - newUrl = remoteText.getText(); - if (newUrl == null || newUrl.isEmpty()) { - DialogUtil.openErrorDialog(resources.getString("AddRepo.Msg.Error.URLEmpty")); - return; - } - type = RepoManager.REMOTE_REPO_TYPE; - } else if (localCheckBt.getSelection()) { - newUrl = localText.getText(); - if (newUrl == null || newUrl.isEmpty()) { - DialogUtil.openErrorDialog(resources.getString("AddRepo.Msg.Error.URLEmpty")); - return; - } - type = RepoManager.LOCAL_REPO_TYPE; - } + super.okPressed(); + } + + public String getRepositoryName() { + return name; + } + + public String getRepositoryURL() { + return newUrl; + } + + public boolean isDirty() { + return isDirty; + } - newUrl = newUrl.trim(); - - if (newUrl.equals(prevUrl)) { - isDirty = false; - } else { - isDirty = true; - } - super.okPressed(); - } - - - public String getRepositoryName() { - return name; - } - - public String getRepositoryURL() { - return newUrl; - } - - public boolean isDirty() { - return isDirty; - } - } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RepoCommonDialog.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RepoCommonDialog.java new file mode 100644 index 0000000..e71935d --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RepoCommonDialog.java @@ -0,0 +1,212 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.util.ArrayList; +import java.util.ResourceBundle; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.swt.SWT; +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.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.tizen.common.util.DialogUtil; +import org.tizen.nativeplatform.repo.commander.RepoManager; + +public abstract class RepoCommonDialog extends Dialog { + + protected Text remoteText; + protected Text localText; + protected Button remoteCheckBt; + protected Button localCheckBt; + protected Button browseBt; + + protected boolean supportLocalRepo = false; + protected String newUrl = null; + protected String type = null; + + protected int x = 0; + protected int y = 0; + protected final int width = 600; + protected final int height = 300; + + protected final String BUNDLE_NAME = ModifyRepoDialog.class.getPackage().getName() + + ".PkgMgrUIMessages";//$NON-NLS-1$ + protected ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + + protected RepoCommonDialog(Shell parentShell) { + super(parentShell); + } + + protected abstract void initControls(); + + protected void configureShell(Shell newShell, String title) { + super.configureShell(newShell); + newShell.setText(title); + newShell.setLocation(x, y); + newShell.setSize(width, height); + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText(resources.getString("ModifyRepo.Title")); + newShell.setLocation(x, y); + newShell.setSize(width, height); + } + + protected void createRepoComposite(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING + | GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); + composite.setLayout(new GridLayout(3, false)); + + remoteCheckBt = new Button(composite, SWT.RADIO); + GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); + gridData.horizontalSpan = 3; + remoteCheckBt.setLayoutData(gridData); + remoteCheckBt.setText(resources.getString("AddRepo.Button.Check.Remote")); + remoteCheckBt.addSelectionListener(new SelectionListener() { + + @Override + public void widgetSelected(SelectionEvent event) { + Button button = (Button) event.widget; + if (button.getSelection()) { + remoteText.setEnabled(true); + } else { + remoteText.setEnabled(false); + } + } + + @Override + public void widgetDefaultSelected(SelectionEvent event) { + } + + }); + + Label urlLabel = new Label(composite, SWT.NONE); + urlLabel.setText(resources.getString("AddRepo.Label.Uri")); + remoteText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH); + gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); + gridData.horizontalSpan = 2; + remoteText.setLayoutData(gridData); + + if (supportLocalRepo) { + localCheckBt = new Button(composite, SWT.RADIO); + gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); + gridData.horizontalSpan = 3; + localCheckBt.setLayoutData(gridData); + localCheckBt.setText(resources.getString("AddRepo.Button.Check.Local")); + localCheckBt.addSelectionListener(new SelectionListener() { + + @Override + public void widgetSelected(SelectionEvent event) { + Button button = (Button) event.widget; + if (button.getSelection()) { + localText.setEnabled(true); + browseBt.setEnabled(true); + + } else { + localText.setEnabled(false); + browseBt.setEnabled(false); + } + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + + }); + + Label pathLabel = new Label(composite, SWT.NONE); + pathLabel.setText(resources.getString("AddRepo.Local.Label.Path")); + localText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH); + gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); + localText.setLayoutData(gridData); + localText.setEditable(false); + + browseBt = new Button(composite, SWT.NONE); + browseBt.setText(resources.getString("AddRepo.Button.Browse")); + browseBt.addMouseListener(new MouseListener() { + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + DirectoryDialog dialog = new DirectoryDialog(getShell()); + dialog.setText(resources.getString("AddRepo.DirDlg.Title")); + String repoPath = dialog.open(); + + if (repoPath == null) { + return; + } else { + IPath path = new Path(repoPath); + if (RepoManager.getValidator(path).validate()) { + ArrayList archs = RepoManager.getValidator(path) + .availableArchs(); + if (archs == null) { + DialogUtil.openErrorDialog(resources + .getString("AddRepo.Msg.Error.getArch")); + return; + } + + localText.setText(repoPath); + } else { + DialogUtil.openErrorDialog(resources + .getString("AddRepo.Msg.Error.NotLocalRepo")); + return; + } + } + } + + @Override + public void mouseUp(MouseEvent e) { + } + + }); + } + initControls(); + } + + protected String getRepoType() { + return type; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/types/CmdTargetTypes.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/types/CmdTargetTypes.java index fd15f0e..21c4412 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/types/CmdTargetTypes.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/types/CmdTargetTypes.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.types; public enum CmdTargetTypes { diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/types/LaunchTypes.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/types/LaunchTypes.java new file mode 100644 index 0000000..dd2cc10 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/types/LaunchTypes.java @@ -0,0 +1,43 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.types; + +public enum LaunchTypes { + NONE(""), + ATTACH("attach"); + + final String type; + + private LaunchTypes(String type) { + this.type = type; + } + + public String getType() { + return type; + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/types/PkgInstallTypes.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/types/PkgInstallTypes.java index 85ec945..96719e7 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/types/PkgInstallTypes.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/types/PkgInstallTypes.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.types; public enum PkgInstallTypes { diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/types/PkgTypes.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/types/PkgTypes.java index 12b496b..953d45b 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/types/PkgTypes.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/types/PkgTypes.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.types; public enum PkgTypes { diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/adapter/ExtraPkgTableViewerAdapter.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/adapter/ExtraPkgTableViewerAdapter.java new file mode 100644 index 0000000..f8602ce --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/adapter/ExtraPkgTableViewerAdapter.java @@ -0,0 +1,81 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.ui.adapter; + +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerSorter; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.widgets.TableColumn; +import org.tizen.nativeplatform.pkg.model.IPackage; + +public class ExtraPkgTableViewerAdapter extends SelectionAdapter { + + private TableViewer tableViewer; + + public ExtraPkgTableViewerAdapter(TableViewer viewer) { + this.tableViewer = viewer; + } + + 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) { + IPackage pkg_1 = (IPackage) e1; + IPackage pkg_2 = (IPackage) e2; + + String fileName_1 = new Path(pkg_1.getPath()).lastSegment(); + String fileName_2 = new Path(pkg_2.getPath()).lastSegment(); + + switch (column) { + case 0: + 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); + } + }); + + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/PackageTableSelectionAdapter.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/adapter/PackageTableSelectionAdapter.java similarity index 99% rename from org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/PackageTableSelectionAdapter.java rename to org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/adapter/PackageTableSelectionAdapter.java index fb4302a..9d7ef47 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/PackageTableSelectionAdapter.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/adapter/PackageTableSelectionAdapter.java @@ -25,7 +25,7 @@ * */ -package org.tizen.nativeplatform.pkgmgr.ui; +package org.tizen.nativeplatform.ui.adapter; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.Viewer; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RepoTableSelectionAdapter.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/adapter/RepoTableSelectionAdapter.java similarity index 98% rename from org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RepoTableSelectionAdapter.java rename to org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/adapter/RepoTableSelectionAdapter.java index 5beec84..043fb2b 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkgmgr/ui/RepoTableSelectionAdapter.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/adapter/RepoTableSelectionAdapter.java @@ -25,7 +25,7 @@ * */ -package org.tizen.nativeplatform.pkgmgr.ui; +package org.tizen.nativeplatform.ui.adapter; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.Viewer; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/listener/ExtraPkgAddListener.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/listener/ExtraPkgAddListener.java new file mode 100644 index 0000000..cfdc622 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/listener/ExtraPkgAddListener.java @@ -0,0 +1,56 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.ui.listener; + +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; + +public class ExtraPkgAddListener implements MouseListener { + + public ExtraPkgAddListener() { + + } + @Override + public void mouseDoubleClick(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseDown(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseUp(MouseEvent e) { + // TODO Auto-generated method stub + + } + +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/listener/ExtraPkgTableHoverListener.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/listener/ExtraPkgTableHoverListener.java new file mode 100644 index 0000000..b16d0f7 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/listener/ExtraPkgTableHoverListener.java @@ -0,0 +1,122 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.ui.listener; + +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.TableItem; +import org.tizen.nativeplatform.pkg.model.IPackage; + +public class ExtraPkgTableHoverListener implements Listener { + + private TableViewer tableViewer; + private Shell shell; + Shell tip = null; + Label label = null; + + public ExtraPkgTableHoverListener(Shell shell, TableViewer viewer) { + this.shell = shell; + this.tableViewer = viewer; + } + + @Override + 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(shell, SWT.ON_TOP | SWT.TOOL); + tip.setLayout(new FillLayout()); + label = new Label(tip, SWT.NONE); + IPackage pkg = (IPackage) item.getData(); + + label.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); + label.setBackground(shell.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; + } + } + }; + +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/provider/ExtraPkgTableViewerProvider.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/provider/ExtraPkgTableViewerProvider.java new file mode 100644 index 0000000..62be6e5 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/provider/ExtraPkgTableViewerProvider.java @@ -0,0 +1,58 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.ui.provider; + +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; +import org.tizen.nativeplatform.pkg.model.IPackage; + +public class ExtraPkgTableViewerProvider 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 IPackage) { + IPackage pkg = (IPackage) element; + String name = new Path(pkg.getPath()).lastSegment(); + switch (columnIndex) { + case 0: + return name; + default: + break; + } + } + return null; + } + +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/provider/RepoTableViewerProvider.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/provider/RepoTableViewerProvider.java new file mode 100644 index 0000000..0abeb63 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/ui/provider/RepoTableViewerProvider.java @@ -0,0 +1,57 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.ui.provider; + +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; + +public class RepoTableViewerProvider extends LabelProvider implements ITableLabelProvider { + private final static int COL_REPOS_NAME = 0; + private final static int COL_REPOS_URL = 1; + + @Override + public Image getColumnImage(Object element, int columnIndex) { + return null; + } + + @Override + public String getColumnText(Object element, int columnIndex) { + String strData = (String) element; + + switch (columnIndex) { + case COL_REPOS_NAME: + return strData.split("[|]")[COL_REPOS_NAME]; + case COL_REPOS_URL: + return strData.split("[|]")[COL_REPOS_URL]; + default: + return ""; + } + } + +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CharacterStripper.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CharacterStripper.java index be6bfbb..394bc3c 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CharacterStripper.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CharacterStripper.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.util; public class CharacterStripper { diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncher.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncher.java index 88db135..f687556 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncher.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncher.java @@ -30,18 +30,12 @@ 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.Map; import org.eclipse.core.runtime.IProgressMonitor; import org.tizen.common.ui.view.console.ConsoleManager; -import org.tizen.common.util.HostUtil; -import org.tizen.nativeplatform.password.SudoPasswdManager; public class CommandLauncher { public static final String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$ @@ -66,7 +60,7 @@ public class CommandLauncher { String consoleViewName, IProgressMonitor monitor ) throws InterruptedException { // generate script - String scriptCmd = genSudoExecuteScript(command); + String scriptCmd = CommandLauncherUtil.genSudoExecuteScript(command); if ( scriptCmd == null ) { throw new InterruptedException("Generating execution script failed!"); } @@ -89,12 +83,12 @@ public class CommandLauncher { String consoleViewName, IProgressMonitor monitor ) throws InterruptedException { // start process - Process proc = createProcess( command, workingDir, newEnv, false ); + Process proc = CommandLauncherUtil.createProcess( command, workingDir, newEnv, false ); // create monitor process - ProcessMonitorThread monitorThread = null; + CommandProcessMonitorThread monitorThread = null; if ( monitor != null ) { - monitorThread = new ProcessMonitorThread(proc, monitor); + monitorThread = new CommandProcessMonitorThread(proc, monitor); monitorThread.start(); } @@ -139,38 +133,6 @@ public class CommandLauncher { } } - - public static Process createProcess(String command, String workingDir, - boolean includeStdErr ) throws InterruptedException { - // start process - return createProcess(command, workingDir, null, includeStdErr); - } - - public static synchronized Process createProcess(String command, String workingDir, - Map 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; - } - - public static String executeSudoOutput(String command ) throws InterruptedException { return executeSudoOutput( command, null, false, null ); } @@ -186,7 +148,7 @@ public class CommandLauncher { boolean includeStdErr, IProgressMonitor monitor ) throws InterruptedException { // generate script - String scriptCmd = genSudoExecuteScript(command); + String scriptCmd = CommandLauncherUtil.genSudoExecuteScript(command); if ( scriptCmd == null ) { throw new InterruptedException("Generating execution script failed!"); } @@ -208,12 +170,12 @@ public class CommandLauncher { BufferedReader input = null; StringBuilder contents = null; try { - proc = createProcess( command, workingDir, includeStdErr ); + proc = CommandLauncherUtil.createProcess( command, workingDir, includeStdErr ); // create monitor process - ProcessMonitorThread monitorThread = null; + CommandProcessMonitorThread monitorThread = null; if ( monitor != null ) { - monitorThread = new ProcessMonitorThread(proc, monitor); + monitorThread = new CommandProcessMonitorThread(proc, monitor); monitorThread.start(); } @@ -247,195 +209,5 @@ public class CommandLauncher { return contents.toString().trim(); } - - // return generate script and return script path - private static synchronized 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 synchronized 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; - } - } - - // generate interrupt script for platform debugging and return script path - public static synchronized String genDebugginInterruptScript(Process process) { - String passwd = SudoPasswdManager.getSudoPassword(); - - try { - // get process id - Field f = process.getClass().getDeclaredField("pid"); - f.setAccessible(true); - String pid = f.get(process).toString(); - - // create interrupt script file - File interruptScript = new File("/tmp/interruptProc.sh"); - interruptScript.createNewFile(); - BufferedWriter bw = new BufferedWriter(new FileWriter(interruptScript)); - bw.write("#!/bin/sh");bw.newLine(); - bw.write("proctree() {");bw.newLine(); - bw.write(" local _pid=$1");bw.newLine(); - bw.write(" for _child in $(ps -o pid --no-headers --ppid ${_pid}); do");bw.newLine(); - bw.write(" proctree ${_child}");bw.newLine(); - bw.write(" done");bw.newLine(); - bw.write(" user=`ps -o user --no-headers --pid ${_pid}`");bw.newLine(); - bw.write(" if [ \"x${user}\" = \"xroot\" ]; then");bw.newLine(); - bw.write(String.format(" echo \"%s\" | sudo -S kill -SIGINT ${_pid}", passwd));bw.newLine(); - bw.write(" exit 0");bw.newLine(); - bw.write(" fi");bw.newLine(); - bw.write("}");bw.newLine(); - bw.write(String.format("proctree %s", pid));bw.newLine(); - bw.write("exit -1");bw.newLine(); - bw.close(); - interruptScript.setExecutable(true); - - return interruptScript.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; - } - } - - - static class ProcessMonitorThread extends Thread { - private Process process; - private IProgressMonitor monitor; - public ProcessMonitorThread(Process process, IProgressMonitor monitor) { - this.process = process; - this.monitor = monitor; - } - - - public void run() { - boolean sendSignal = false; - while( true ) { - try { - Thread.sleep(1000); // wait 1 sec - if ( !sendSignal && monitor.isCanceled() ) { - String killCmd = genSudoKillProcessScript( process ); - Process killProcess = createProcess( killCmd, null, false ); - killProcess.waitFor(); - sendSignal = true; - } - break; - } - catch(InterruptedException e) { - continue; - } - } - } - } } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncherOnDevice.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncherOnDevice.java index 30caff3..6d4ad82 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncherOnDevice.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncherOnDevice.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.util; import java.io.IOException; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncherOnRootstrap.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncherOnRootstrap.java index 2cac480..3ab3acc 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncherOnRootstrap.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncherOnRootstrap.java @@ -1,66 +1,59 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.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 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 newEnv, PackageManagerOuputReceiver rec, IProgressMonitor monitor) { // generate script - String scriptCmd = genSudoExecuteScript(command); + String scriptCmd = CommandLauncherUtil.genSudoExecuteScript(command); if (scriptCmd == null) { ICommandStatus status = new CommandStatus(IStatus.ERROR, command, "Generating execution script failed!", null); @@ -69,82 +62,12 @@ public class CommandLauncherOnRootstrap { 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 synchronized ICommandStatus execute(String command, String workingDir, - Map newEnv, String consoleViewName, IProgressMonitor monitor) { - - CommandStatus status = null; - Process proc = null; - List log = new ArrayList(); - - // 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 synchronized ICommandStatus execute(String command, String workingDir, Map newEnv, PackageManagerOuputReceiver rec, IProgressMonitor monitor) { CommandStatus status = null; @@ -153,11 +76,11 @@ public class CommandLauncherOnRootstrap { // start process try { - proc = createProcess(command, workingDir, newEnv, false); + proc = CommandLauncherUtil.createProcess(command, workingDir, newEnv, false); // create monitor process - ProcessMonitorThread monitorThread = null; + CommandProcessMonitorThread monitorThread = null; if (monitor != null) { - monitorThread = new ProcessMonitorThread(proc, monitor); + monitorThread = new CommandProcessMonitorThread(proc, monitor); monitorThread.start(); } @@ -199,193 +122,5 @@ public class CommandLauncherOnRootstrap { 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 synchronized Process createProcess(String command, String workingDir, - Map 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 synchronized 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 synchronized 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; - } - } + } } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncherUtil.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncherUtil.java new file mode 100644 index 0000000..d19f476 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandLauncherUtil.java @@ -0,0 +1,232 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.util; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.lang.reflect.Field; +import java.util.Map; + +import org.tizen.common.util.HostUtil; +import org.tizen.nativeplatform.password.SudoPasswdManager; + +public class CommandLauncherUtil { + + public static Process createProcess(String command, String workingDir, + boolean includeStdErr ) throws InterruptedException { + // start process + return createProcess(command, workingDir, null, includeStdErr); + } + + public static synchronized Process createProcess(String command, String workingDir, + Map 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 + public static synchronized 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 + public static synchronized 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; + } + } + + // generate interrupt script for platform debugging and return script path + public static synchronized String genDebugginInterruptScript(Process process) { + String passwd = SudoPasswdManager.getSudoPassword(); + + try { + // get process id + Field f = process.getClass().getDeclaredField("pid"); + f.setAccessible(true); + String pid = f.get(process).toString(); + + // create interrupt script file + File interruptScript = new File("/tmp/interruptProc.sh"); + interruptScript.createNewFile(); + BufferedWriter bw = new BufferedWriter(new FileWriter(interruptScript)); + bw.write("#!/bin/sh");bw.newLine(); + bw.write("proctree() {");bw.newLine(); + bw.write(" local _pid=$1");bw.newLine(); + bw.write(" for _child in $(ps -o pid --no-headers --ppid ${_pid}); do");bw.newLine(); + bw.write(" proctree ${_child}");bw.newLine(); + bw.write(" done");bw.newLine(); + bw.write(" user=`ps -o user --no-headers --pid ${_pid}`");bw.newLine(); + bw.write(" if [ \"x${user}\" = \"xroot\" ]; then");bw.newLine(); + bw.write(String.format(" echo \"%s\" | sudo -S kill -SIGINT ${_pid}", passwd));bw.newLine(); + bw.write(" exit 0");bw.newLine(); + bw.write(" fi");bw.newLine(); + bw.write("}");bw.newLine(); + bw.write(String.format("proctree %s", pid));bw.newLine(); + bw.write("exit -1");bw.newLine(); + bw.close(); + interruptScript.setExecutable(true); + + return interruptScript.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; + } + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandProcessMonitorThread.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandProcessMonitorThread.java new file mode 100644 index 0000000..009245a --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/CommandProcessMonitorThread.java @@ -0,0 +1,60 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.util; + +import org.eclipse.core.runtime.IProgressMonitor; + +public class CommandProcessMonitorThread extends Thread { + + private Process process; + private IProgressMonitor monitor; + + public CommandProcessMonitorThread(Process process, IProgressMonitor monitor) { + this.process = process; + this.monitor = monitor; + } + + @Override + public void run() { + boolean sendSignal = false; + while (true) { + try { + Thread.sleep(1000); // wait 1 sec + if (!sendSignal && monitor.isCanceled()) { + String killCmd = CommandLauncherUtil.genSudoKillProcessScript(process); + Process killProcess = CommandLauncherUtil.createProcess(killCmd, null, false); + killProcess.waitFor(); + sendSignal = true; + } + break; + } catch (InterruptedException e) { + continue; + } + } + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/FileUtil.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/FileUtil.java new file mode 100644 index 0000000..a04bf07 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/FileUtil.java @@ -0,0 +1,53 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.util; + +import java.io.File; +import java.io.FilenameFilter; + +public class FileUtil { + public static File findFirstFilebyExtension(File searchPath, String ext) { + File[] allFiles = searchPath.listFiles(new ExtFilter(ext)); + if (allFiles == null || allFiles.length == 0) { + return null; + } + return allFiles[0]; + } + + public static class ExtFilter implements FilenameFilter { + protected String ext; + + public ExtFilter(String ext) { + this.ext = ext; + } + + public boolean accept(File dir, String name) { + return name.endsWith(ext); + } + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/InstallerUtil.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/InstallerUtil.java index 9c8d7a7..5e71b07 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/InstallerUtil.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/InstallerUtil.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.util; import java.io.File; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PackageUtil.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PackageUtil.java new file mode 100644 index 0000000..0043710 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PackageUtil.java @@ -0,0 +1,60 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.util; + +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.tizen.nativeplatform.pkg.commander.IPackager; +import org.tizen.nativeplatform.pkg.commander.IPkgModelMaker; +import org.tizen.nativeplatform.pkg.commander.factory.PackagerFactory; +import org.tizen.nativeplatform.pkg.commander.factory.PkgModelMakerFactory; +import org.tizen.nativeplatform.pkg.model.IPackage; +import org.tizen.nativeplatform.types.PkgTypes; + +public class PackageUtil { + + private PkgTypes type; + private IPkgModelMaker modelMaker; + + public PackageUtil(PkgTypes type) { + this.type = type; + this.modelMaker = PkgModelMakerFactory.getMaker(type); + } + public boolean pakaging(IProject project, IConfiguration config, IProgressMonitor monitor) { + IPackager packager = PackagerFactory.getPackager(type, project, config); + return packager.packaging(monitor); + } + public List getPackages(IProject project, IConfiguration config) { + IPackager packager = PackagerFactory.getPackager(type, project, config); + List pkgPaths = packager.getProjectPackages(); + return modelMaker.makeModels(pkgPaths); + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PlatformLaunchUtil.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PlatformLaunchUtil.java new file mode 100644 index 0000000..71721c3 --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PlatformLaunchUtil.java @@ -0,0 +1,201 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.util; + +import static org.tizen.sdblib.service.SyncServiceConstants.RESULT_OK; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.List; + +import org.eclipse.core.resources.IFolder; +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.osgi.util.NLS; +import org.tizen.common.TizenPlatformConstants; +import org.tizen.common.util.DialogUtil; +import org.tizen.nativecommon.TizenNativeException; +import org.tizen.nativecommon.launch.LaunchUtils; +import org.tizen.nativecommon.launch.TizenLaunchCommand; +import org.tizen.nativecommon.launch.TizenLaunchMessages; +import org.tizen.nativeplatform.IPlatformXMLStore; +import org.tizen.nativeplatform.launch.PlatformLaunchMessages; +import org.tizen.sdblib.IDevice; +import org.tizen.sdblib.exception.SdbCommandRejectedException; +import org.tizen.sdblib.exception.TimeoutException; +import org.tizen.sdblib.service.SyncResult; + +public class PlatformLaunchUtil { + + public static 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 static 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; + } catch (Exception e) { + return false; + } + + return true; + } + + public static 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 static 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 static 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 static String[] getProgramPath(IProject project) { + IPlatformXMLStore store = PlatformProjectUtil.getManifestXmlStore(project); + if (store.loadXml()) { + return getProgramPath(store); + } else { + return null; + } + } + + public static String[] getProgramPath(IPlatformXMLStore store) { + List files = store.getExecutableFiles(); + if (files != null && files.size() > 0) { + // return files.get(0); + return files.toArray(new String[0]); + } else { + return null; + } + } + + public static boolean questionPackaging(IProject project) { + String msg = String.format(PlatformLaunchMessages.QUESTION_PACKAGING, project.getName()); + if (64 == DialogUtil.openQuestionDialog(msg)) { + return true; + } else { + return false; + } + } + + public static boolean questionContinue() { + if (64 == DialogUtil.openQuestionDialog(PlatformLaunchMessages.QUESTION_CONTINUE)) { + return true; + } else { + return false; + } + } +} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PlatformLaunchUtils.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PlatformLaunchUtils.java deleted file mode 100644 index 4ebc83b..0000000 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PlatformLaunchUtils.java +++ /dev/null @@ -1,356 +0,0 @@ -/* - * Native Platform - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * Donghyuk Yang - * DongHee Yang - * Kangho Kim - * - * 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.util; - -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.managedbuilder.core.IConfiguration; -import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; -import org.eclipse.cdt.managedbuilder.core.IManagedProject; -import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.osgi.util.NLS; -import org.tizen.common.TizenPlatformConstants; -import org.tizen.nativecommon.TizenNativeException; -import org.tizen.nativecommon.launch.LaunchUtils; -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.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.pkg.model.IPackage; -import org.tizen.nativeplatform.pkg.model.PkgStatus; -import org.tizen.nativeplatform.pkgmgr.PkgMgrInitializer; -import org.tizen.nativeplatform.rootstrap.RootstrapManager; -import org.tizen.nativeplatform.types.CmdTargetTypes; -import org.tizen.nativeplatform.types.PkgInstallTypes; -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.util.DeviceUtil; - -public class PlatformLaunchUtils { - - private PkgCommandTarget target; - - public PlatformLaunchUtils(PkgCommandTarget target) { - this.target = target; - } - - public boolean installPkgsToRootstrap(List 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.getCommander(CmdTargetTypes.ROOTSTRAP), IPkgCommander.TOOL.ZYPPER, packages, - monitor); - } - - public boolean installPkgsToDevice(List 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.getCommander(CmdTargetTypes.DEVICE), IPkgCommander.TOOL.ZYPPER, packages, - monitor); - } - - public boolean installPkgsToDevice(List 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.getCommander(CmdTargetTypes.DEVICE), type, packages, monitor); - } - - private boolean installPkgs(IPkgCommander commander, IPkgCommander.TOOL type, - List packages, IProgressMonitor monitor) throws InterruptedException { - monitor.beginTask("Installing packages to rootstrap", 2); - - List paths = new ArrayList(); - - for (IPackage p : packages) { - String filePath = p.getPath(); - paths.add(filePath.trim()); - } - - ICommandStatus status = commander.installLocalPkg(paths.toArray(new String[0]), type, - monitor); - monitor.worked(1); - - if (!status.isOk()) { - newException(status.getMessage()); - } - - List 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 (IPackage 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 { - 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; - } - - public List getSelectedPackages(List pkgStatus) { - List selectedPkgs = new ArrayList(); - for (PkgStatus status : pkgStatus) { - if (status.isChecked()) { - selectedPkgs.add(status.getPackage()); - } - } - return selectedPkgs; - } - - 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; - } catch (Exception e) { - 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 { - 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); - 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 files = store.getExecutableFiles(); - if (files != null && files.size() > 0) { - // return files.get(0); - return files.toArray(new String[0]); - } else { - return null; - } - } - - public void applyReinstallOp(List list, boolean reinstallOp) { - for (PkgStatus status : list) { - if (status.getInstallInfo().equals(PkgInstallTypes.INSTALLED) && - !reinstallOp) { - status.setChecked(false); - } - } - } -} diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PlatformProjectUtil.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PlatformProjectUtil.java index 43e09e6..9f076c8 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PlatformProjectUtil.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PlatformProjectUtil.java @@ -1,8 +1,42 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.util; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; +import org.eclipse.cdt.managedbuilder.core.IManagedProject; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; import org.tizen.nativeplatform.IPlatformProject; import org.tizen.nativeplatform.IPlatformXMLStore; +import org.tizen.nativeplatform.build.PlatformConfigurationManager; import org.tizen.nativeplatform.manifest.PlatformManifestXMLStore; import org.tizen.nativeplatform.types.PkgTypes; @@ -61,4 +95,35 @@ public class PlatformProjectUtil { public static PkgTypes getPkgType() { return PkgTypes.RPM; } + + public static 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; + } } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/ProcessSelector.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/ProcessSelector.java index 6113a49..229ea53 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/ProcessSelector.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/ProcessSelector.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.util; import org.eclipse.cdt.core.IProcessInfo; @@ -15,6 +42,7 @@ import org.eclipse.ui.dialogs.TwoPaneElementSelector; import org.tizen.nativecommon.launch.TizenDeviceProcessList; import org.tizen.sdblib.IDevice; +@SuppressWarnings("restriction") public class ProcessSelector { private IDevice device; private IProcessInfo procInfo; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/RootstrapUtil.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/RootstrapUtil.java index 234cddc..9e58c66 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/RootstrapUtil.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/RootstrapUtil.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.util; import java.io.File; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/AddRootstrapDialog.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/AddRootstrapDialog.java index f611eb9..fdc953b 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/AddRootstrapDialog.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/AddRootstrapDialog.java @@ -37,12 +37,12 @@ import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.TableViewer; - import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; +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.graphics.Rectangle; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -57,371 +57,336 @@ 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.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; import org.tizen.common.util.DialogUtil; import org.tizen.common.util.SWTUtil; -import org.tizen.nativeplatform.rootstrap.SnapshotURLParser; import org.tizen.nativeplatform.rootstrap.RootstrapManager; +import org.tizen.nativeplatform.rootstrap.SnapshotURLParser; +import org.tizen.nativeplatform.ui.provider.RepoTableViewerProvider; import org.tizen.nativeplatform.views.model.ICheckTreeItem; import org.tizen.nativeplatform.views.model.PlatformRootstrap; public class AddRootstrapDialog extends Dialog { - - private Text rootstrapText; - private Text snapshotUrlText; - private TableViewer reposURLViewer; - private Combo archCombo; - private Button generateImmediateBt; - - ArrayList snapshotInfos; - private PlatformRootstrap generatedRootstrap; - private String rootstrapName; - private String architecture; - private ArrayList repositoryURLs; - boolean isImmediateGenerateChecked; - - private final static int COL_REPOS_NAME = 0; - private final static int COL_REPOS_URL = 1; - - private int x = 0; - private int y = 0; - private final int width = 800; - private final int height = 550; - private Shell shell; - - private final String BUNDLE_NAME = AddRootstrapDialog.class.getPackage().getName() + ".RootstrapUIMessages";//$NON-NLS-1$ - private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); - - /* Not used this class */ - public AddRootstrapDialog(Shell parentShell) { - super(parentShell); - this.shell = parentShell; - 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(resources.getString("GenRootDlg.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_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); - composite.setLayout(new GridLayout(1, false)); - - createRootstrapNameComposite(composite); - createSelectSnapshotComposite(composite); + + private Text rootstrapText; + private Text snapshotUrlText; + private TableViewer reposURLViewer; + private Combo archCombo; + private Button generateImmediateBt; + + ArrayList snapshotInfos; + private PlatformRootstrap generatedRootstrap; + private String rootstrapName; + private String architecture; + private ArrayList repositoryURLs; + boolean isImmediateGenerateChecked; + + private final static int COL_REPOS_NAME = 0; + private final static int COL_REPOS_URL = 1; + + private int x = 0; + private int y = 0; + private final int width = 800; + private final int height = 550; + private Shell shell; + + private final String BUNDLE_NAME = AddRootstrapDialog.class.getPackage().getName() + + ".RootstrapUIMessages";//$NON-NLS-1$ + private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + + /* Not used this class */ + public AddRootstrapDialog(Shell parentShell) { + super(parentShell); + this.shell = parentShell; + 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(resources.getString("GenRootDlg.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_HORIZONTAL + | GridData.VERTICAL_ALIGN_BEGINNING)); + composite.setLayout(new GridLayout(1, false)); + + createRootstrapNameComposite(composite); + createSelectSnapshotComposite(composite); createSettingRepoComposite(composite); - - createGenButtonComposite(composite); - return null; - } - - 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)); + + createGenButtonComposite(composite); + return null; + } + + 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 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); - generateImmediateBt.setLayoutData(gridData); - } - - - private void createSelectSnapshotComposite(Composite parent) { - - Group group = new Group(parent, SWT.NONE); - group.setLayout(new GridLayout(1, false)); - group.setText(resources.getString("GenRootDlg.Group.Snapshot")); - GridData gridData = new GridData(GridData.FILL_BOTH); - group.setLayoutData(gridData); - - createSnapshotUrlComposite(group); - createArchitectureComposite(group); - } - - - private void createSettingRepoComposite(Composite parent) { - - Group group = new Group(parent, SWT.NONE); - group.setLayout(new GridLayout(1, false)); - group.setText(resources.getString("GenRootDlg.Group.Repos")); - GridData gridData = new GridData(GridData.FILL_BOTH); - group.setLayoutData(gridData); - - createTreeViewer(group); - } - - - private void createSnapshotUrlComposite(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.minimumHeight = 0; + rootstrapText.setLayoutData(gridData); + } + + 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); + generateImmediateBt.setLayoutData(gridData); + } + + private void createSelectSnapshotComposite(Composite parent) { + + Group group = new Group(parent, SWT.NONE); + group.setLayout(new GridLayout(1, false)); + group.setText(resources.getString("GenRootDlg.Group.Snapshot")); + GridData gridData = new GridData(GridData.FILL_BOTH); + group.setLayoutData(gridData); + + createSnapshotUrlComposite(group); + createArchitectureComposite(group); + } + + private void createSettingRepoComposite(Composite parent) { + + Group group = new Group(parent, SWT.NONE); + group.setLayout(new GridLayout(1, false)); + group.setText(resources.getString("GenRootDlg.Group.Repos")); + GridData gridData = new GridData(GridData.FILL_BOTH); + group.setLayoutData(gridData); + + createTreeViewer(group); + } + + private void createSnapshotUrlComposite(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 = 100; - snapshotLabel.setLayoutData(gridData); - snapshotLabel.setAlignment(SWT.RIGHT); - snapshotLabel.setText(resources.getString("GenRootDlg.Label.SnapshotURL")); - - snapshotUrlText = new Text(snapshotComp, SWT.SINGLE | SWT.BORDER); - gridData = new GridData(GridData.FILL_HORIZONTAL); - snapshotUrlText.setLayoutData(gridData); - - Button searchBt = new Button(snapshotComp, SWT.PUSH); - searchBt.setText(resources.getString("GenRootDlg.Button.Search")); - - searchBt.addMouseListener(new MouseListener() { - - @Override - public void mouseDoubleClick(MouseEvent e) { - } - - @Override - public void mouseDown(MouseEvent e) { - - final String snapshotUrl = snapshotUrlText.getText().trim(); - - if (snapshotUrl.isEmpty()) { - DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.Empty.Snapshot")); - 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("GenRootDlg.Progress.Msg.Searching"), -1); - try { - final SnapshotURLParser c = new SnapshotURLParser(); - snapshotInfos = null; - snapshotInfos = c.parse(snapshotUrl); - } catch (final IOException e) { - e.printStackTrace(); - SWTUtil.getDisplay().asyncExec( new Runnable() { - @Override - public void run() { - DialogUtil.openErrorDialog( - resources.getString("GenRootDlg.Error.Snapshot.Failed")+ - "("+e.toString()+")"); - } - }); - } - } - }); - } catch (InvocationTargetException e1) { - e1.printStackTrace(); - DialogUtil.openErrorDialog(e.toString()); - return; - } catch (InterruptedException e1) { - e1.printStackTrace(); - DialogUtil.openErrorDialog(e.toString()); - return; - } - - archCombo.removeAll(); - if (snapshotInfos == null || snapshotInfos.size() == 0 ) { - UpdateRepositoryURL(); - return; - } - - // add architecture list - for ( ICheckTreeItem item: snapshotInfos ) { - archCombo.add(item.getText()); - } - archCombo.setEnabled(true); - archCombo.select(0); - - // Update repository table - UpdateRepositoryURL(); - } - - @Override - public void mouseUp(MouseEvent e) { - } - - }); - } - - - 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.widthHint = 100; + snapshotLabel.setLayoutData(gridData); + snapshotLabel.setAlignment(SWT.RIGHT); + snapshotLabel.setText(resources.getString("GenRootDlg.Label.SnapshotURL")); + + snapshotUrlText = new Text(snapshotComp, SWT.SINGLE | SWT.BORDER); + gridData = new GridData(GridData.FILL_HORIZONTAL); + snapshotUrlText.setLayoutData(gridData); + + Button searchBt = new Button(snapshotComp, SWT.PUSH); + searchBt.setText(resources.getString("GenRootDlg.Button.Search")); + + searchBt.addMouseListener(new MouseListener() { + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + + final String snapshotUrl = snapshotUrlText.getText().trim(); + + if (snapshotUrl.isEmpty()) { + DialogUtil.openErrorDialog(resources + .getString("GenRootDlg.Error.Empty.Snapshot")); + 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("GenRootDlg.Progress.Msg.Searching"), -1); + try { + final SnapshotURLParser c = new SnapshotURLParser(); + snapshotInfos = null; + snapshotInfos = c.parse(snapshotUrl); + } catch (final IOException e) { + e.printStackTrace(); + SWTUtil.getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + DialogUtil.openErrorDialog(resources + .getString("GenRootDlg.Error.Snapshot.Failed") + + "(" + e.toString() + ")"); + } + }); + } + } + }); + } catch (InvocationTargetException e1) { + e1.printStackTrace(); + DialogUtil.openErrorDialog(e.toString()); + return; + } catch (InterruptedException e1) { + e1.printStackTrace(); + DialogUtil.openErrorDialog(e.toString()); + return; + } + + archCombo.removeAll(); + if (snapshotInfos == null || snapshotInfos.size() == 0) { + UpdateRepositoryURL(); + return; + } + + // add architecture list + for (ICheckTreeItem item : snapshotInfos) { + archCombo.add(item.getText()); + } + archCombo.setEnabled(true); + archCombo.select(0); + + // Update repository table + UpdateRepositoryURL(); + } + + @Override + public void mouseUp(MouseEvent e) { + } + + }); + } + + 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.widthHint = 100; - archLabel.setLayoutData(gridData); - archLabel.setAlignment(SWT.RIGHT); + gridData.widthHint = 100; + 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 UpdateRepositoryURL() { - int selectIdx = archCombo.getSelectionIndex(); - // show repository URLs - ArrayList data = new ArrayList(); - if ( selectIdx >= 0 ) { - ArrayList children = snapshotInfos.get(selectIdx).getChildren(); - for ( int idx = 0; idx < children.size(); idx++ ) { - data.add(String.format("url%d|%s", idx, children.get(idx).getText() ) ); - } - } - reposURLViewer.setInput(data); - } - - + archCombo.setEnabled(false); + } + + private void UpdateRepositoryURL() { + int selectIdx = archCombo.getSelectionIndex(); + // show repository URLs + ArrayList data = new ArrayList(); + if (selectIdx >= 0) { + ArrayList children = snapshotInfos.get(selectIdx).getChildren(); + for (int idx = 0; idx < children.size(); idx++) { + data.add(String.format("url%d|%s", idx, children.get(idx).getText())); + } + } + reposURLViewer.setInput(data); + } + private void createTreeViewer(Composite parent) { - - reposURLViewer = new TableViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); + + reposURLViewer = new TableViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); Table table = reposURLViewer.getTable(); - table.setHeaderVisible(true); - table.setLinesVisible(true); - - reposURLViewer.setLabelProvider(new TableViewerProvider()); - reposURLViewer.setContentProvider(new ArrayContentProvider()); - - TableColumn column = new TableColumn(table, SWT.NONE); + table.setHeaderVisible(true); + table.setLinesVisible(true); + + reposURLViewer.setLabelProvider(new RepoTableViewerProvider()); + reposURLViewer.setContentProvider(new ArrayContentProvider()); + + TableColumn column = new TableColumn(table, SWT.NONE); column.setResizable(true); column.setText(resources.getString("GenRootDlg.Tree.Column.Name")); - column.setWidth(50); - - column = new TableColumn(table, SWT.NONE); + column.setWidth(50); + + column = new TableColumn(table, SWT.NONE); column.setResizable(true); column.setText(resources.getString("GenRootDlg.Tree.Column.URL")); column.setWidth(300); - - GridData tableGridData = new GridData(GridData.FILL_HORIZONTAL|GridData.VERTICAL_ALIGN_BEGINNING); + + GridData tableGridData = new GridData(GridData.FILL_HORIZONTAL + | GridData.VERTICAL_ALIGN_BEGINNING); tableGridData.heightHint = 200; - table.setLayoutData(tableGridData); - + table.setLayoutData(tableGridData); + reposURLViewer.setInput(new ArrayList()); } - - - @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; - } - architecture = archCombo.getText().trim(); - repositoryURLs = new ArrayList(); - for ( TableItem item: reposURLViewer.getTable().getItems() ) { - repositoryURLs.add(item.getText(COL_REPOS_URL)); - } - - if (repositoryURLs.isEmpty()) { - DialogUtil.openErrorDialog( - resources.getString("GenRootDlg.Error.NoAnyRepos")); - return; - } - - isImmediateGenerateChecked = generateImmediateBt.getSelection(); - super.okPressed(); - } - - - public PlatformRootstrap getGeneratedRootstrap() { - return generatedRootstrap; - } - - - public String getRootstrapName() { - return rootstrapName; - } - - - - public String getArchitecture() { - return architecture; - } - - - public ArrayList getRepositoryURLs() { - return repositoryURLs; - } - - public boolean isImmediateGenerateChecked() { - return isImmediateGenerateChecked; - } - - - 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) { - String strData = (String)element; - - switch(columnIndex) { - case COL_REPOS_NAME: - return strData.split("[|]")[COL_REPOS_NAME]; - case COL_REPOS_URL: - return strData.split("[|]")[COL_REPOS_URL]; - default: - return ""; - } - } - } + @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; + } + architecture = archCombo.getText().trim(); + repositoryURLs = new ArrayList(); + for (TableItem item : reposURLViewer.getTable().getItems()) { + repositoryURLs.add(item.getText(COL_REPOS_URL)); + } + + if (repositoryURLs.isEmpty()) { + DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.NoAnyRepos")); + return; + } + + isImmediateGenerateChecked = generateImmediateBt.getSelection(); + super.okPressed(); + } + + public PlatformRootstrap getGeneratedRootstrap() { + return generatedRootstrap; + } + + public String getRootstrapName() { + return rootstrapName; + } + + public String getArchitecture() { + return architecture; + } + + public ArrayList getRepositoryURLs() { + return repositoryURLs; + } + + public boolean isImmediateGenerateChecked() { + return isImmediateGenerateChecked; + } } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/IRepositoryTab.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/IRepositoryTab.java index 4e26f20..54bc6da 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/IRepositoryTab.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/IRepositoryTab.java @@ -1,3 +1,30 @@ +/* + * Native Platform + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Donghyuk Yang + * DongHee Yang + * Kangho Kim + * + * 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.views.ui; import java.util.ArrayList; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/LocalRepoTab.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/LocalRepoTab.java index cef9474..1fca9d8 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/LocalRepoTab.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/LocalRepoTab.java @@ -103,7 +103,6 @@ public class LocalRepoTab implements IRepositoryTab { 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); @@ -132,8 +131,6 @@ public class LocalRepoTab implements IRepositoryTab { 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); @@ -142,8 +139,6 @@ public class LocalRepoTab implements IRepositoryTab { 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); @@ -202,8 +197,6 @@ public class LocalRepoTab implements IRepositoryTab { 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); diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/RemoteRepoTab.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/RemoteRepoTab.java index d33dbea..7bf9488 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/RemoteRepoTab.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/RemoteRepoTab.java @@ -38,15 +38,12 @@ import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.SWT; 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.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -63,329 +60,307 @@ import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.Text; import org.tizen.common.util.DialogUtil; import org.tizen.common.util.SWTUtil; -import org.tizen.nativeplatform.rootstrap.RootstrapManager; import org.tizen.nativeplatform.rootstrap.SnapshotURLParser; +import org.tizen.nativeplatform.ui.provider.RepoTableViewerProvider; import org.tizen.nativeplatform.views.model.ICheckTreeItem; -import org.tizen.nativeplatform.views.model.PlatformRootstrap; public class RemoteRepoTab 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 snapshotUrlText; - private TableViewer reposURLViewer; - private Combo archCombo; - private Button generateImmediateBt; - - ArrayList snapshotInfos; - private String rootstrapName; - private String architecture; - private ArrayList repositoryURLs; - boolean isImmediateGenerateChecked; - - private final static int COL_REPOS_NAME = 0; - private final static int COL_REPOS_URL = 1; - - protected final String BUNDLE_NAME = RemoteRepoTab.class.getPackage().getName() + ".RootstrapUIMessages";//$NON-NLS-1$ - protected final ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); - - - public RemoteRepoTab(Shell shell, TabFolder folder) { - this.shell = shell; - this.folder = folder; - } - - public void createTab() { - TabItem tab = new TabItem( folder, SWT.NULL ); - tab.setText(resources.getString("RemoteRepoTab.Title")); - - Composite composite = new Composite(folder, SWT.NONE); - tab.setControl(composite); - //composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); - 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 snapshotUrlText; + private TableViewer reposURLViewer; + private Combo archCombo; + private Button generateImmediateBt; + + ArrayList snapshotInfos; + private String architecture; + private ArrayList repositoryURLs; + boolean isImmediateGenerateChecked; + + private final static int COL_REPOS_NAME = 0; + private final static int COL_REPOS_URL = 1; + + protected final String BUNDLE_NAME = RemoteRepoTab.class.getPackage().getName() + + ".RootstrapUIMessages";//$NON-NLS-1$ + protected final ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + + public RemoteRepoTab(Shell shell, TabFolder folder) { + this.shell = shell; + this.folder = folder; + } + + public void createTab() { + TabItem tab = new TabItem(folder, SWT.NULL); + tab.setText(resources.getString("RemoteRepoTab.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)); - - createSelectSnapshotComposite(composite); - createSettingRepoComposite(composite); + + createSelectSnapshotComposite(composite); + createSettingRepoComposite(composite); createGenButtonComposite(composite); - } - - private void createSelectSnapshotComposite(Composite parent) { - - Group group = new Group(parent, SWT.NONE); - group.setLayout(new GridLayout(1, false)); - group.setText(resources.getString("GenRootDlg.Group.Snapshot")); - //GridData gridData = new GridData(GridData.FILL_BOTH); - GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); - group.setLayoutData(gridData); - - createSnapshotUrlComposite(group); - createArchitectureComposite(group); - } - - private void createSnapshotUrlComposite(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); + } + + private void createSelectSnapshotComposite(Composite parent) { + + Group group = new Group(parent, SWT.NONE); + group.setLayout(new GridLayout(1, false)); + group.setText(resources.getString("GenRootDlg.Group.Snapshot")); + // GridData gridData = new GridData(GridData.FILL_BOTH); + GridData gridData = new GridData(GridData.FILL_HORIZONTAL + | GridData.VERTICAL_ALIGN_BEGINNING); + group.setLayoutData(gridData); + + createSnapshotUrlComposite(group); + createArchitectureComposite(group); + } + + private void createSnapshotUrlComposite(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 = 100; - snapshotLabel.setLayoutData(gridData); - snapshotLabel.setAlignment(SWT.RIGHT); - snapshotLabel.setText(resources.getString("GenRootDlg.Label.SnapshotURL")); - - snapshotUrlText = new Text(snapshotComp, SWT.SINGLE | SWT.BORDER); - gridData = new GridData(GridData.FILL_HORIZONTAL); - snapshotUrlText.setLayoutData(gridData); - - Button searchBt = new Button(snapshotComp, SWT.PUSH); - searchBt.setText(resources.getString("GenRootDlg.Button.Search")); - - searchBt.addMouseListener(new MouseListener() { - - @Override - public void mouseDoubleClick(MouseEvent e) { - } - - @Override - public void mouseDown(MouseEvent e) { - - final String snapshotUrl = snapshotUrlText.getText().trim(); - - if (snapshotUrl.isEmpty()) { - DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.Empty.Snapshot")); - 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("GenRootDlg.Progress.Msg.Searching"), -1); - try { - final SnapshotURLParser c = new SnapshotURLParser(); - snapshotInfos = null; - snapshotInfos = c.parse(snapshotUrl); - } catch (final IOException e) { - e.printStackTrace(); - SWTUtil.getDisplay().asyncExec( new Runnable() { - @Override - public void run() { - DialogUtil.openErrorDialog( - resources.getString("GenRootDlg.Error.Snapshot.Failed")+ - "("+e.toString()+")"); - } - }); - } - } - }); - } catch (InvocationTargetException e1) { - e1.printStackTrace(); - DialogUtil.openErrorDialog(e.toString()); - return; - } catch (InterruptedException e1) { - e1.printStackTrace(); - DialogUtil.openErrorDialog(e.toString()); - return; - } - - archCombo.removeAll(); - if (snapshotInfos == null || snapshotInfos.size() == 0 ) { - UpdateRepositoryURL(); - return; - } - - // add architecture list - for ( ICheckTreeItem item: snapshotInfos ) { - archCombo.add(item.getText()); - } - archCombo.setEnabled(true); - archCombo.select(0); - - // Update repository table - UpdateRepositoryURL(); - } - - @Override - public void mouseUp(MouseEvent e) { - } - - }); - } - - private void createSettingRepoComposite(Composite parent) { - - Group group = new Group(parent, SWT.NONE); - group.setLayout(new GridLayout(1, false)); - group.setText(resources.getString("GenRootDlg.Group.Repos")); - //GridData gridData = new GridData(GridData.FILL_BOTH); - GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); - group.setLayoutData(gridData); - - createTreeViewer(group); - } - - 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.widthHint = 100; + snapshotLabel.setLayoutData(gridData); + snapshotLabel.setAlignment(SWT.RIGHT); + snapshotLabel.setText(resources.getString("GenRootDlg.Label.SnapshotURL")); + + snapshotUrlText = new Text(snapshotComp, SWT.SINGLE | SWT.BORDER); + gridData = new GridData(GridData.FILL_HORIZONTAL); + snapshotUrlText.setLayoutData(gridData); + + Button searchBt = new Button(snapshotComp, SWT.PUSH); + searchBt.setText(resources.getString("GenRootDlg.Button.Search")); + + searchBt.addMouseListener(new MouseListener() { + + @Override + public void mouseDoubleClick(MouseEvent e) { + } + + @Override + public void mouseDown(MouseEvent e) { + + final String snapshotUrl = snapshotUrlText.getText().trim(); + + if (snapshotUrl.isEmpty()) { + DialogUtil.openErrorDialog(resources + .getString("GenRootDlg.Error.Empty.Snapshot")); + 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("GenRootDlg.Progress.Msg.Searching"), -1); + try { + final SnapshotURLParser c = new SnapshotURLParser(); + snapshotInfos = null; + snapshotInfos = c.parse(snapshotUrl); + } catch (final IOException e) { + e.printStackTrace(); + SWTUtil.getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + DialogUtil.openErrorDialog(resources + .getString("GenRootDlg.Error.Snapshot.Failed") + + "(" + e.toString() + ")"); + } + }); + } + } + }); + } catch (InvocationTargetException e1) { + e1.printStackTrace(); + DialogUtil.openErrorDialog(e.toString()); + return; + } catch (InterruptedException e1) { + e1.printStackTrace(); + DialogUtil.openErrorDialog(e.toString()); + return; + } + + archCombo.removeAll(); + if (snapshotInfos == null || snapshotInfos.size() == 0) { + UpdateRepositoryURL(); + return; + } + + // add architecture list + for (ICheckTreeItem item : snapshotInfos) { + archCombo.add(item.getText()); + } + archCombo.setEnabled(true); + archCombo.select(0); + + // Update repository table + UpdateRepositoryURL(); + } + + @Override + public void mouseUp(MouseEvent e) { + } + + }); + } + + private void createSettingRepoComposite(Composite parent) { + + Group group = new Group(parent, SWT.NONE); + group.setLayout(new GridLayout(1, false)); + group.setText(resources.getString("GenRootDlg.Group.Repos")); + GridData gridData = new GridData(GridData.FILL_HORIZONTAL + | GridData.VERTICAL_ALIGN_BEGINNING); + group.setLayoutData(gridData); + + createTreeViewer(group); + } + + 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.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.widthHint = 100; - archLabel.setLayoutData(gridData); - archLabel.setAlignment(SWT.RIGHT); + gridData.widthHint = 100; + 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 UpdateRepositoryURL() { - int selectIdx = archCombo.getSelectionIndex(); - // show repository URLs - ArrayList data = new ArrayList(); - if ( selectIdx >= 0 ) { - ArrayList children = snapshotInfos.get(selectIdx).getChildren(); - for ( int idx = 0; idx < children.size(); idx++ ) { - data.add(String.format("url%d|%s", idx, children.get(idx).getText() ) ); - } - } - reposURLViewer.setInput(data); - } - + archCombo.setEnabled(false); + } + + private void UpdateRepositoryURL() { + int selectIdx = archCombo.getSelectionIndex(); + // show repository URLs + ArrayList data = new ArrayList(); + if (selectIdx >= 0) { + ArrayList children = snapshotInfos.get(selectIdx).getChildren(); + for (int idx = 0; idx < children.size(); idx++) { + data.add(String.format("url%d|%s", idx, children.get(idx).getText())); + } + } + reposURLViewer.setInput(data); + } + private void createTreeViewer(Composite parent) { - - reposURLViewer = new TableViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); + + reposURLViewer = new TableViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); Table table = reposURLViewer.getTable(); - table.setHeaderVisible(true); - table.setLinesVisible(true); - - reposURLViewer.setLabelProvider(new TableViewerProvider()); - reposURLViewer.setContentProvider(new ArrayContentProvider()); - - TableColumn column = new TableColumn(table, SWT.NONE); + table.setHeaderVisible(true); + table.setLinesVisible(true); + + reposURLViewer.setLabelProvider(new RepoTableViewerProvider()); + reposURLViewer.setContentProvider(new ArrayContentProvider()); + + TableColumn column = new TableColumn(table, SWT.NONE); column.setResizable(true); column.setText(resources.getString("GenRootDlg.Tree.Column.Name")); - column.setWidth(50); - - column = new TableColumn(table, SWT.NONE); + column.setWidth(50); + + column = new TableColumn(table, SWT.NONE); column.setResizable(true); column.setText(resources.getString("GenRootDlg.Tree.Column.URL")); column.setWidth(300); - - GridData tableGridData = new GridData(GridData.FILL_HORIZONTAL|GridData.VERTICAL_ALIGN_BEGINNING); + + GridData tableGridData = new GridData(GridData.FILL_HORIZONTAL + | GridData.VERTICAL_ALIGN_BEGINNING); tableGridData.heightHint = 200; - table.setLayoutData(tableGridData); - + table.setLayoutData(tableGridData); + reposURLViewer.setInput(new ArrayList()); } - - 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) { - String strData = (String)element; - - switch(columnIndex) { - case COL_REPOS_NAME: - return strData.split("[|]")[COL_REPOS_NAME]; - case COL_REPOS_URL: - return strData.split("[|]")[COL_REPOS_URL]; - default: - return ""; - } - } - } - - @Override - public String getArchitecture() { - return architecture; - } - - @Override - public ArrayList getRepositoryURLs() { - return repositoryURLs; - } - - @Override - public boolean isImmediateGenerateChecked() { - return isImmediateGenerateChecked; - } - - @Override - public boolean saveState() { - - TableItem[] repos = reposURLViewer.getTable().getItems(); - if (repos.length == 0) { - DialogUtil.openErrorDialog( - resources.getString("GenRootDlg.Error.NoAnyRepos")); - return false; - } - - String arch = archCombo.getText(); - if (arch == null || arch.isEmpty()) { - DialogUtil.openErrorDialog( - resources.getString("GenRootDlg.Error.Empty.Arch")); - return false; - } - - architecture = arch.trim(); - repositoryURLs = new ArrayList(); - for ( TableItem item: repos ) { - repositoryURLs.add(item.getText(COL_REPOS_URL)); - } - - isImmediateGenerateChecked = generateImmediateBt.getSelection(); - - return true; - } - - @Override - public IPath getBuildConfFile() { - // Nothing to do - return null; - } + + @Override + public String getArchitecture() { + return architecture; + } + + @Override + public ArrayList getRepositoryURLs() { + return repositoryURLs; + } + + @Override + public boolean isImmediateGenerateChecked() { + return isImmediateGenerateChecked; + } + + @Override + public boolean saveState() { + + TableItem[] repos = reposURLViewer.getTable().getItems(); + if (repos.length == 0) { + DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.NoAnyRepos")); + return false; + } + + String arch = archCombo.getText(); + if (arch == null || arch.isEmpty()) { + DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.Empty.Arch")); + return false; + } + + architecture = arch.trim(); + repositoryURLs = new ArrayList(); + for (TableItem item : repos) { + repositoryURLs.add(item.getText(COL_REPOS_URL)); + } + + isImmediateGenerateChecked = generateImmediateBt.getSelection(); + + return true; + } + + @Override + public IPath getBuildConfFile() { + // Nothing to do + return null; + } } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/RootstrapChangeConfFileDialog.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/RootstrapChangeConfFileDialog.java index 91d2e9d..4ab4c51 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/RootstrapChangeConfFileDialog.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/RootstrapChangeConfFileDialog.java @@ -27,13 +27,8 @@ package org.tizen.nativeplatform.views.ui; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map.Entry; import java.util.ResourceBundle; -import org.eclipse.cdt.managedbuilder.core.IConfiguration; -import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.jface.dialogs.Dialog; @@ -43,162 +38,152 @@ import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -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.tizen.nativecommon.build.SmartBuildInterface; -import org.tizen.nativeplatform.build.PlatformConfigurationManager; import org.tizen.nativeplatform.views.model.PlatformRootstrap; public class RootstrapChangeConfFileDialog extends Dialog { - private PlatformRootstrap rootstrap; - private IPath buildConfFile = null; - private IPath initialConfFile = null; - private boolean initialChecked = false; - private boolean dirty = false; - private Shell shell; - - private Text nameText; - private Text confFilePathText; - private Button confFileBt; - private Button searchBt; - - private int x = 0; - private int y = 0; - private final int width = 600; - private final int height = 180; - - private final int labelSize = 100; - - private final String BUNDLE_NAME = AddRootstrapDialog.class.getPackage().getName() + ".RootstrapUIMessages";//$NON-NLS-1$ - private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); - - public RootstrapChangeConfFileDialog(Shell parentShell, PlatformRootstrap rootstrap) { - super(parentShell); - this.shell = parentShell; - this.rootstrap = rootstrap; - this.initialConfFile = rootstrap.getConfFile(); - initialChecked = (initialConfFile != null) ? true : false; - - 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(resources.getString("ChangeConfFileDlg.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_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); - composite.setLayout(new GridLayout(1, false)); - - //createNameComposite(composite); - createConfFilePathComposite(composite); + private IPath buildConfFile = null; + private IPath initialConfFile = null; + private boolean initialChecked = false; + private Shell shell; + + private Text confFilePathText; + private Button confFileBt; + private Button searchBt; + + private int x = 0; + private int y = 0; + private final int width = 600; + private final int height = 180; + + private final String BUNDLE_NAME = AddRootstrapDialog.class.getPackage().getName() + + ".RootstrapUIMessages";//$NON-NLS-1$ + private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME); + + public RootstrapChangeConfFileDialog(Shell parentShell, PlatformRootstrap rootstrap) { + super(parentShell); + this.shell = parentShell; + this.initialConfFile = rootstrap.getConfFile(); + initialChecked = (initialConfFile != null) ? true : false; + + 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(resources.getString("ChangeConfFileDlg.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_HORIZONTAL + | GridData.VERTICAL_ALIGN_BEGINNING)); + composite.setLayout(new GridLayout(1, false)); + + // createNameComposite(composite); + createConfFilePathComposite(composite); return null; - } - - private void createConfFilePathComposite(Composite parent) { - Composite snapshotComp = new Composite(parent, SWT.NONE); - snapshotComp.setLayout(new GridLayout(2, false)); - GridData gridData = new GridData(GridData.FILL_BOTH); - snapshotComp.setLayoutData(gridData); - - confFileBt = new Button(snapshotComp, SWT.CHECK); + } + + private void createConfFilePathComposite(Composite parent) { + Composite snapshotComp = new Composite(parent, SWT.NONE); + snapshotComp.setLayout(new GridLayout(2, false)); + GridData gridData = new GridData(GridData.FILL_BOTH); + snapshotComp.setLayoutData(gridData); + + confFileBt = new Button(snapshotComp, SWT.CHECK); gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - gridData.horizontalSpan = 2; - confFileBt.setLayoutData(gridData); - confFileBt.setText(resources.getString("MofifyRootDlg.Button.ConfFile.Check")); - - confFileBt.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - Button button = (Button) event.widget; - if (button.getSelection()) { - confFilePathText.setEnabled(true); - searchBt.setEnabled(true); - } else { - confFilePathText.setEnabled(false); - searchBt.setEnabled(false); - } - } - }); - - confFilePathText = new Text(snapshotComp, SWT.SINGLE | SWT.BORDER); - gridData = new GridData(GridData.FILL_HORIZONTAL); - gridData.minimumHeight = 0; - confFilePathText.setLayoutData(gridData); - - 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); - String confFile = buildConfFile.toOSString().trim(); - confFilePathText.setText(confFile); - } - - @Override - public void mouseUp(MouseEvent e) { - } - }); - - - // initial setting - confFileBt.setSelection(initialChecked); - if (initialChecked) { - confFilePathText.setText(initialConfFile.toOSString()); - } else { - confFilePathText.setEnabled(false); - searchBt.setEnabled(false); - } - } - - public IPath getBuildConfFile() { - return buildConfFile; - } - - @Override - protected void okPressed() { - - if (!confFileBt.getSelection()) { - buildConfFile = null; - } - - super.okPressed(); - } + gridData.horizontalSpan = 2; + confFileBt.setLayoutData(gridData); + confFileBt.setText(resources.getString("MofifyRootDlg.Button.ConfFile.Check")); + + confFileBt.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + Button button = (Button) event.widget; + if (button.getSelection()) { + confFilePathText.setEnabled(true); + searchBt.setEnabled(true); + } else { + confFilePathText.setEnabled(false); + searchBt.setEnabled(false); + } + } + }); + + confFilePathText = new Text(snapshotComp, SWT.SINGLE | SWT.BORDER); + gridData = new GridData(GridData.FILL_HORIZONTAL); + gridData.minimumHeight = 0; + confFilePathText.setLayoutData(gridData); + + 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); + String confFile = buildConfFile.toOSString().trim(); + confFilePathText.setText(confFile); + } + + @Override + public void mouseUp(MouseEvent e) { + } + }); + + // initial setting + confFileBt.setSelection(initialChecked); + if (initialChecked) { + confFilePathText.setText(initialConfFile.toOSString()); + } else { + confFilePathText.setEnabled(false); + searchBt.setEnabled(false); + } + } + + public IPath getBuildConfFile() { + return buildConfFile; + } + + @Override + protected void okPressed() { + + if (!confFileBt.getSelection()) { + buildConfFile = null; + } + + super.okPressed(); + } } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/wizards/TemplateTizenPlatformNewWizard.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/wizards/TemplateTizenPlatformNewWizard.java index 2fa218d..c4469fb 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/wizards/TemplateTizenPlatformNewWizard.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/wizards/TemplateTizenPlatformNewWizard.java @@ -38,125 +38,136 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.jface.wizard.IWizard; import org.eclipse.osgi.util.NLS; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.tizen.common.core.application.InstallPathConfig; -import org.tizen.common.util.log.Logger; import org.tizen.nativeappcommon.templateengine.TizenTemplateProcessParser; import org.tizen.nativeappcommon.wizards.Messages; import org.tizen.nativeappcommon.wizards.TemplateTizenNewWizard; import org.tizen.nativecommon.templateengine.TizenTemplateEngine; import org.tizen.nativeplatform.build.PlatformConfigurationManager; import org.tizen.nativeplatform.git.GitDescManager; -import org.tizen.nativeplatform.git.GitIndexParserFactory; -import org.tizen.nativeplatform.git.IGitIndexParser; import org.tizen.nativeplatform.git.model.GitDescription; +import org.tizen.nativeplatform.git.parser.GitIndexParserFactory; +import org.tizen.nativeplatform.git.parser.IGitIndexParser; import org.tizen.nativeplatform.preferences.PreferencesManager; import org.w3c.dom.Element; public class TemplateTizenPlatformNewWizard extends TemplateTizenNewWizard { - public static final String DIR_RPM = "rpm"; - public static final String DIR_PLATFORM = "platform"; - public static final String DIR_GIT = "Git"; - public static final String DIR_DELIMITER = "/"; - public static final String[] ID_TEMPLATE = {"PlatformProject"}; - public static final String[] ID_PROJTYPE = {PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE}; //$NON-NLS-1$ //$NON-NLS-2$ + public static final String DIR_RPM = "rpm"; + public static final String DIR_PLATFORM = "platform"; + public static final String DIR_GIT = "Git"; + public static final String DIR_DELIMITER = "/"; + public static final String[] ID_TEMPLATE = { "PlatformProject" }; + public static final String[] ID_PROJTYPE = { PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE }; //$NON-NLS-1$ //$NON-NLS-2$ + + public static final IPath templatePath = new Path(InstallPathConfig.getSamplesPath()).append( + DIR_PLATFORM).append(DIR_RPM); + + public static final Logger logger = LoggerFactory + .getLogger(TemplateTizenPlatformNewWizard.class); - public static final IPath templatePath = new Path(InstallPathConfig.getSamplesPath()). - append(DIR_PLATFORM).append(DIR_RPM); - @Override public EntryDescriptor[] createItems(boolean supportedOnly, IWizard wizard) { List items = new ArrayList(); - + Stack fileStack = new Stack(); IPath rootPath = this.getTemplatePath(); - + fileStack.push(rootPath); boolean found = false; - - while(!fileStack.isEmpty()) { + + while (!fileStack.isEmpty()) { IPath templatePath = fileStack.pop(); - + File templateFile = templatePath.toFile(); - - if(templateFile.exists()) { - - File sampleFile = templatePath.append(TizenTemplateEngine.FILE_NAME_SAMPLE).toFile(); - if(sampleFile.exists() && sampleFile.isFile()) { + + if (templateFile.exists()) { + + File sampleFile = templatePath.append(TizenTemplateEngine.FILE_NAME_SAMPLE) + .toFile(); + if (sampleFile.exists() && sampleFile.isFile()) { found = true; - EntryDescriptor entryDes = getEntryDesc(TizenTemplateProcessParser.createTemplateDesc(sampleFile), templatePath.lastSegment()); + EntryDescriptor entryDes = getEntryDesc( + TizenTemplateProcessParser.createTemplateDesc(sampleFile), + templatePath.lastSegment()); IPath sourcePath = templatePath.removeLastSegments(1); - if(sourcePath.segmentCount() != rootPath.segmentCount()) { - entryDes.setPath(templatePath.removeLastSegments(1).makeRelativeTo(rootPath).toString()); - } - else { + if (sourcePath.segmentCount() != rootPath.segmentCount()) { + entryDes.setPath(templatePath.removeLastSegments(1) + .makeRelativeTo(rootPath).toString()); + } else { entryDes.setPath(null); } items.add(entryDes); - } - else { - for(File subFile: templateFile.listFiles()) { - if(subFile.isDirectory()) { + } else { + for (File subFile : templateFile.listFiles()) { + if (subFile.isDirectory()) { fileStack.push(new Path(subFile.getPath())); } } } } } - - if(found == false) { - Logger.error(NLS.bind(Messages.EXCEPTION_WHILE_PROJECT_CREATION_3, rootPath)); + + if (found == false) { + logger.error(NLS.bind(Messages.EXCEPTION_WHILE_PROJECT_CREATION_3, rootPath)); } - + /* create git items */ String projTypeName = PlatformConfigurationManager.TIZEN_PLATFORM_ARTIFACT_TYPE; - PreferencesManager.SiteConfiguration config = PreferencesManager.loadActiveSiteConfiguration(); - - if (config != null ) { - EntryDescriptor gitEntryDes = null; - ArrayList gitDescs = null; - - IGitIndexParser parser = GitIndexParserFactory.getIndexParser(config); - gitDescs = parser.parse(config); - if (gitDescs != null) { - GitDescManager.setDescs(gitDescs); - } - - if (gitDescs != null) { - for (GitDescription n : gitDescs) { - Path gitPath = new Path(n.getProject()); - String name = gitPath.lastSegment(); - String dir = gitPath.removeLastSegments(1).toString(); - dir = DIR_GIT + DIR_DELIMITER + dir; - gitEntryDes = new EntryDescriptor(getTemplateID(projTypeName), projTypeName, name, false, null, null); - gitEntryDes.setPath(dir); - items.add(gitEntryDes); - } - } + PreferencesManager.SiteConfiguration config = PreferencesManager + .loadActiveSiteConfiguration(); + + if (config != null) { + EntryDescriptor gitEntryDes = null; + ArrayList gitDescs = null; + + IGitIndexParser parser = GitIndexParserFactory.getIndexParser(config); + gitDescs = parser.parse(config); + if (gitDescs != null) { + GitDescManager.setDescs(gitDescs); + } + + if (gitDescs != null) { + for (GitDescription n : gitDescs) { + Path gitPath = new Path(n.getProject()); + String name = gitPath.lastSegment(); + String dir = gitPath.removeLastSegments(1).toString(); + dir = DIR_GIT + DIR_DELIMITER + dir; + gitEntryDes = new EntryDescriptor(getTemplateID(projTypeName), projTypeName, + name, false, null, null); + gitEntryDes.setPath(dir); + items.add(gitEntryDes); + } + } } return items.toArray(new EntryDescriptor[items.size()]); } - - private EntryDescriptor getEntryDesc(TemplateDescriptor descriptor, - String label) { + + private EntryDescriptor getEntryDesc(TemplateDescriptor descriptor, String label) { String projTypeName; Element root = descriptor.getRootElement(); - Element slpPropertyElement = TizenTemplateProcessParser.getElementFromTag(root, TizenTemplateProcessParser.TAG_SLPPROPERTY); - slpPropertyElement = TizenTemplateProcessParser.getElementFromTag(slpPropertyElement, TizenTemplateProcessParser.TAG_PROPERTYGROUP); - projTypeName = TizenTemplateProcessParser.getTextContextFromElement(slpPropertyElement, TizenTemplateProcessParser.TAG_PROJTYPE); - return new EntryDescriptor(getTemplateID(projTypeName), projTypeName, label, false, null, null); + Element slpPropertyElement = TizenTemplateProcessParser.getElementFromTag(root, + TizenTemplateProcessParser.TAG_SLPPROPERTY); + slpPropertyElement = TizenTemplateProcessParser.getElementFromTag(slpPropertyElement, + TizenTemplateProcessParser.TAG_PROPERTYGROUP); + projTypeName = TizenTemplateProcessParser.getTextContextFromElement(slpPropertyElement, + TizenTemplateProcessParser.TAG_PROJTYPE); + return new EntryDescriptor(getTemplateID(projTypeName), projTypeName, label, false, null, + null); } - + public IPath getTemplatePath() { return templatePath; } - + public String getTemplateID(String projTypeName) { - - for(int i=0; i