initRootstrapRepoInfo(true);
}
+ public void updateRootstrapRepoInfo() {
+ if (isSetRootstrap()) {
+ RepoManager.updateRepoInfoToRootstrap(target);
+ }
+ }
+
+ public void updateRootstrapRepo() {
+ if (isSetRootstrap()) {
+ LocalRepoMounter.clearMounted(null);
+ rtCommander.resetRepo();
+ RepoManager.updateRepoToRootstrap(target);
+ }
+ }
+
+ public void updateDeviceRepoInfo(List<Repository> repos) {
+ if (isSetDevice()) {
+ RepoManager.updateRepoInfoToDevice(repos);
+ }
+ }
+
+ public void updateDeviceRepo() {
+ if (isSetDevice()) {
+ RepoManager.updateRepoToDevice(target);
+ }
+ }
+
public void initRootstrapRepoInfo(boolean resetRepo) {
if (isSetRootstrap()) {
RepositoryProvider.INSTANCE.getBuildsystemRepos().clear();
public void updateRepositoryInfo() {
PkgMgrInitializer initializer = new PkgMgrInitializer(target);
- initializer.initRootstrapRepoInfo();
+ initializer.updateRootstrapRepoInfo();
+ }
+
+ public void updateRepository() {
+ PkgMgrInitializer initializer = new PkgMgrInitializer(target);
+ initializer.updateRootstrapRepo();
}
public void createTab() {
String url = dialog.getRepositoryURL();
Repository repo = target.getRootstrap().getRepository(url);
if (repo != null) {
- DialogUtil.openMessageDialog(
- String.format(resources.getString("PkgMgr.Msg.Repo.Exists"), repo.getName()));
+ DialogUtil.openMessageDialog(String.format(
+ resources.getString("PkgMgr.Msg.Repo.Exists"), repo.getName()));
return false;
}
target.getRootstrap().addRepoURL(url);
String newUrl = dialog.getRepositoryURL();
Repository repo = target.getRootstrap().getRepository(newUrl);
if (repo != null) {
- DialogUtil
- .openMessageDialog(
- String.format(resources.getString("PkgMgr.Msg.Repo.Exists"), repo.getName()));
+ DialogUtil.openMessageDialog(String.format(
+ resources.getString("PkgMgr.Msg.Repo.Exists"), repo.getName()));
return false;
} else {
return target.getRootstrap().modifyRepoURL(selectedRepository.getUri(),
protected void handleUpgradeButton() {
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
-
+ if (isRepoChanged) {
+ DialogUtil.openMessageDialog(resources.getString("PkgMgr.Info.Refresh.First"));
+ return;
+ }
try {
dialog.run(true, false, new IRunnableWithProgress() {
@Override
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
protected Text logText;
protected IOConsoleViewer logViewer;
protected String logs = "";
+ protected boolean isRepoChanged = false;
protected Action actionProperties;
protected MenuManager menuMgr;
abstract public void updateRepositoryInfo();
+ abstract public void updateRepository();
+
abstract protected boolean handleAddRepositoryButton();
abstract protected boolean handleModifyRepositoryButton();
dialog.run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor)
- throws InvocationTargetException,
- InterruptedException {
+ throws InvocationTargetException, InterruptedException {
monitor.beginTask("Add repository", -1);
try {
updateRepositoryInfo();
+ isRepoChanged = true;
} finally {
monitor.done();
}
});
} catch (InvocationTargetException e1) {
DialogUtil.openErrorDialog(resources.getString("PkgMgr.Msg.Error.Addrepo")
- + "("
- + e1.toString() + ")");
+ + "(" + e1.toString() + ")");
} catch (InterruptedException e1) {
DialogUtil.openErrorDialog(resources.getString("PkgMgr.Msg.Error.Addrepo")
- + "("
- + e1.toString() + ")");
+ + "(" + e1.toString() + ")");
}
repoViewer.refresh();
}
dialog.run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor)
- throws InvocationTargetException,
- InterruptedException {
+ throws InvocationTargetException, InterruptedException {
monitor.beginTask("Remove repository", -1);
try {
updateRepositoryInfo();
+ isRepoChanged = true;
} finally {
monitor.done();
}
});
} catch (InvocationTargetException e1) {
DialogUtil.openErrorDialog(resources
- .getString("PkgMgr.Msg.Error.Removerepo") + "("
- + e1.toString() + ")");
+ .getString("PkgMgr.Msg.Error.Removerepo")
+ + "("
+ + e1.toString()
+ + ")");
} catch (InterruptedException e1) {
DialogUtil.openErrorDialog(resources
- .getString("PkgMgr.Msg.Error.Removerepo") + "("
- + e1.toString() + ")");
+ .getString("PkgMgr.Msg.Error.Removerepo")
+ + "("
+ + e1.toString()
+ + ")");
}
repoViewer.refresh();
}
dialog.run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor)
- throws InvocationTargetException,
- InterruptedException {
+ throws InvocationTargetException, InterruptedException {
monitor.beginTask("Modify repository", -1);
try {
updateRepositoryInfo();
+ isRepoChanged = true;
} finally {
monitor.done();
}
});
} catch (InvocationTargetException e1) {
DialogUtil.openErrorDialog(resources
- .getString("PkgMgr.Msg.Error.Modifyrepo") + "("
- + e1.toString() + ")");
+ .getString("PkgMgr.Msg.Error.Modifyrepo")
+ + "("
+ + e1.toString()
+ + ")");
} catch (InterruptedException e1) {
DialogUtil.openErrorDialog(resources
- .getString("PkgMgr.Msg.Error.Modifyrepo") + "("
- + e1.toString() + ")");
+ .getString("PkgMgr.Msg.Error.Modifyrepo")
+ + "("
+ + e1.toString()
+ + ")");
}
repoViewer.refresh();
}
public void mouseDown(MouseEvent e) {
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
if (handleMoveupRepositoryButton()) {
+ int selectedIdx = repoViewer.getTable().getSelectionIndex();
try {
dialog.run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor)
- throws InvocationTargetException,
- InterruptedException {
+ throws InvocationTargetException, InterruptedException {
monitor.beginTask("Move repository up", -1);
try {
updateRepositoryInfo();
+ isRepoChanged = true;
} finally {
monitor.done();
}
});
} catch (InvocationTargetException e1) {
DialogUtil.openErrorDialog(resources
- .getString("PkgMgr.Msg.Error.MoverepoUp") + "("
- + e1.toString() + ")");
+ .getString("PkgMgr.Msg.Error.MoverepoUp")
+ + "("
+ + e1.toString()
+ + ")");
} catch (InterruptedException e1) {
DialogUtil.openErrorDialog(resources
- .getString("PkgMgr.Msg.Error.MoverepoUp") + "("
- + e1.toString() + ")");
+ .getString("PkgMgr.Msg.Error.MoverepoUp")
+ + "("
+ + e1.toString()
+ + ")");
}
repoViewer.refresh();
+ if (selectedIdx >= 1) {
+ repoViewer.getTable().setSelection(selectedIdx - 1);
+ } else {
+ repoViewer.getTable().setSelection(selectedIdx);
+ }
}
}
public void mouseDown(MouseEvent e) {
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
if (handleMovedownRepositoryButton()) {
+ int selectedIdx = repoViewer.getTable().getSelectionIndex();
+ int totalCount = repoViewer.getTable().getItemCount();
try {
dialog.run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor)
- throws InvocationTargetException,
- InterruptedException {
+ throws InvocationTargetException, InterruptedException {
monitor.beginTask("Move repository down", -1);
try {
updateRepositoryInfo();
+ isRepoChanged = true;
} finally {
monitor.done();
}
});
} catch (InvocationTargetException e1) {
DialogUtil.openErrorDialog(resources
- .getString("PkgMgr.Msg.Error.MoverepoDown") + "("
- + e1.toString() + ")");
+ .getString("PkgMgr.Msg.Error.MoverepoDown")
+ + "("
+ + e1.toString()
+ + ")");
} catch (InterruptedException e1) {
DialogUtil.openErrorDialog(resources
- .getString("PkgMgr.Msg.Error.MoverepoDown") + "("
- + e1.toString() + ")");
+ .getString("PkgMgr.Msg.Error.MoverepoDown")
+ + "("
+ + e1.toString()
+ + ")");
}
repoViewer.refresh();
+ if (selectedIdx < totalCount) {
+ repoViewer.getTable().setSelection(selectedIdx + 1);
+ } else {
+ repoViewer.getTable().setSelection(selectedIdx);
+ }
}
}
});
}
+ protected void applyRepoChanges() {
+ updateRepository();
+ isRepoChanged = false;
+ }
+
protected void handleRefreshRepositoryButton() {
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
monitor.beginTask(resources.getString("PkgMgr.Message.Refreshing"), -1);
+ if (isRepoChanged) {
+ applyRepoChanges();
+ }
ICommandStatus status = commander.refreshRepoList();
if (status == null || !status.isOk()) {
throw new InterruptedException();
protected void handleInstallPackageButton() {
final List<PkgStatus> selectedList = getSelectedPkgList(false);
if (selectedList.isEmpty()) {
- DialogUtil.openErrorDialog(resources.getString("PkgMgr.Error.Noselected.Package"));
+ DialogUtil.openErrorDialog(resources.getString("PkgMgr.Error.Noselected.Package")
+ + "\n" + resources.getString("PkgMgr.Info.Check.Pkg.NewVer"));
+ return;
+ }
+ if (isRepoChanged) {
+ DialogUtil.openMessageDialog(resources.getString("PkgMgr.Info.Refresh.First"));
return;
}
}
protected void handleInstallLocalPackageButton(final List<String> selectedFiles) {
+ if (isRepoChanged) {
+ DialogUtil.openMessageDialog(resources.getString("PkgMgr.Info.Refresh.First"));
+ return;
+ }
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
try {
dialog.run(true, false, new IRunnableWithProgress() {
protected void handleRemovePackageButton() {
final List<PkgStatus> selectedList = getSelectedPkgList(true);
if (selectedList.isEmpty()) {
- DialogUtil.openErrorDialog(resources.getString("PkgMgr.Error.Noselected.Package"));
+ DialogUtil.openErrorDialog(resources.getString("PkgMgr.Error.Noselected.Package")
+ + "\n" + resources.getString("PkgMgr.Info.Check.Pkg.Installed"));
+ return;
+ }
+ if (isRepoChanged) {
+ DialogUtil.openMessageDialog(resources.getString("PkgMgr.Info.Refresh.First"));
return;
}
}
}
}
+
+ public void closeTab() {
+ if (isRepoChanged) {
+ applyRepoChanges();
+ }
+ }
}
public void updateRepositoryInfo() {
PkgMgrInitializer initializer = new PkgMgrInitializer(target);
- initializer.initDeviceRepoInfo(repositories);
+ initializer.updateDeviceRepoInfo(repositories);
+ }
+
+ public void updateRepository() {
+ PkgMgrInitializer initializer = new PkgMgrInitializer(target);
+ initializer.updateDeviceRepo();
}
public boolean resetRepositoryInfo() {
// check to exist repository
for (Repository repo : repositories) {
if (repo.getUri().equals(url)) {
- DialogUtil
- .openMessageDialog(
- String.format(resources.getString("PkgMgr.Msg.Repo.Exists"), repo.getName()));
+ DialogUtil.openMessageDialog(String.format(
+ resources.getString("PkgMgr.Msg.Repo.Exists"), repo.getName()));
return false;
}
}
// check to exist repository
for (Repository repo : repositories) {
if (repo.getUri().equals(newUrl)) {
- DialogUtil
- .openMessageDialog(
- String.format(resources.getString("PkgMgr.Msg.Repo.Exists"), repo.getName()));
+ DialogUtil.openMessageDialog(String.format(
+ resources.getString("PkgMgr.Msg.Repo.Exists"), repo.getName()));
return false;
}
}
PkgMgr.Tab.Device = Device
PkgMgr.Console.Name = Package Manager
PkgMgr.Error.Noselected = - No project is selected, no device is connected, or the selected project is not a Tizen project
-PkgMgr.Error.Noselected.Package = No package selected.
+PkgMgr.Info.Check.Pkg.NewVer = Check new version of the package.
+PkgMgr.Info.Check.Pkg.Installed = Check if the package is installed.
+PkgMgr.Error.Noselected.Package = Select package which you want to install.
PkgMgr.Error.Failtransfer.File = Moving the file from %s to %s failed.
-PkgMgr.Warn.Notset.Proxy = (Warning: HTTP Proxy is not set. (Preferences -> Tizen SDK -> Platform -> HTTP Proxy)
-PkgMgr.Info.set.Proxy = (HTTP proxy : %s)
+PkgMgr.Info.Refresh.First = There is a changes for repository.\nRefresh repositories at first.
PkgMgr.Label.Configuration = Selected configuration:
PkgMgr.Label.Connection = Selected connection:
PkgMgr.Button.AddRepo = Add
PkgMgr.Msg.Error.Modifyrepo = Failed to modify repository
PkgMgr.Msg.Error.MoverepoUp = Failed to move repository up
PkgMgr.Msg.Error.MoverepoDown = Failed to move repository down
+PkgMgr.Msg.Apply.Changes = Applying change about repository...
+PkgMgr.Msg.Error.Apply.Changes = Failed to apply change about repository.
Action.Msg.Progress.Initializing.PkgMgr = Initializing Package Manager...
Action.Msg.Progress.Init.BuildSystem.Repo = Intializing repositories on build system...
import java.util.ResourceBundle;
import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.TabFolder;
import org.osgi.framework.Bundle;
import org.tizen.nativeplatform.Activator;
-
import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
import org.tizen.nativeplatform.pkg.model.PackageProvider;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.exception.SdbCommandRejectedException;
+import org.tizen.sdblib.exception.TimeoutException;
public class RPMPackageDialog extends Dialog {
private TabFolder tabFolder;
private PkgCommandTarget target = null;
private boolean enableRootstrapTab = false;
- private boolean enableTargetTab = false;
+ private boolean enableDeviceTab = false;
private int tabIndex = 0;
+ private BuildsystemTab rootstrapTab;
+ private DeviceTab deviceTab;
+
private int x = 0;
private int y = 0;
private final int width = 900;
super(parentShell);
this.target = target;
if (target.isSetDevice()) {
- this.enableTargetTab = true;
+ this.enableDeviceTab = true;
+ setDeviceRootOn();
}
if (target.isSetRootstrap()) {
this.enableRootstrapTab = true;
y = bounds.y + (bounds.height - height) / 2;
}
+ private void setDeviceRootOn() {
+ IDevice device = target.getDevice();
+ if (!device.isRoot()) {
+ try {
+ device.becomeSuperUser(true);
+ } catch (TimeoutException e) {
+ e.printStackTrace();
+ } catch (SdbCommandRejectedException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
private void setImage(Shell parentShell) {
Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
try {
@Override
public boolean close() {
- PackageProvider.INSTANCE.clear();
+ Job job = new Job("Finalizing") {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ int works = 0;
+ if (enableRootstrapTab) {
+ works++;
+ }
+ if (enableDeviceTab) {
+ works++;
+ }
+ monitor.beginTask(resources.getString("PkgMgr.Msg.Apply.Changes"), works);
+ if (enableRootstrapTab) {
+ rootstrapTab.closeTab();
+ monitor.worked(1);
+ }
+ if (enableDeviceTab) {
+ deviceTab.closeTab();
+ monitor.worked(1);
+ }
+ PackageProvider.INSTANCE.clear();
+ monitor.done();
+ return Status.OK_STATUS;
+ }
+ };
+ job.schedule();
return super.close();
}
super.configureShell(newShell);
newShell.setText(resources.getString("PkgMgr.Title"));
- if (!enableRootstrapTab && !enableTargetTab) {
+ if (!enableRootstrapTab && !enableDeviceTab) {
newShell.setLocation(x, y);
newShell.setSize(width / 2, height / 4);
setImage(newShell);
container.setLayoutData(new GridData(GridData.FILL_BOTH));
container.setLayout(new GridLayout(1, false));
- if (!enableRootstrapTab && !enableTargetTab) {
+ if (!enableRootstrapTab && !enableDeviceTab) {
createError(container, resources.getString("PkgMgr.Error.Noselected"));
} else {
createDialogDescription(container);
tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
tabFolder.setLayout(new GridLayout(1, false));
if (enableRootstrapTab) {
- BuildsystemTab tab = new BuildsystemTab(getShell(), tabFolder, target);
- tab.createTab();
+ rootstrapTab = new BuildsystemTab(getShell(), tabFolder, target);
+ rootstrapTab.createTab();
}
- if (enableTargetTab) {
- DeviceTab tab = new DeviceTab(getShell(), tabFolder, target);
- tab.createTab();
+ if (enableDeviceTab) {
+ deviceTab = new DeviceTab(getShell(), tabFolder, target);
+ deviceTab.createTab();
}
tabFolder.setSelection(tabIndex);
}
import org.eclipse.core.runtime.IPath;
import org.tizen.nativecommon.build.SmartBuildInterface;
+import org.tizen.nativeplatform.pkg.commander.IPkgCommander;
import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget;
import org.tizen.nativeplatform.repo.model.Repository;
import org.tizen.nativeplatform.repo.model.RepositoryProvider;
return repoList;
}
+ public static void updateRepoToRootstrap(PkgCommandTarget target) {
+ PlatformRootstrap rootstrap = target.getRootstrap();
+ String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(
+ rootstrap.getPath().toOSString());
+ int idx = 0;
+ List<Repository> repos = rootstrap.getRepoList();
+ for (Repository repo : repos) {
+ String url = repo.getUri();
+ String type = repo.getType();
+ String name = String.format("url%d", idx++);
+ if (RepoManager.isLocalType(type) && RepoManager.isLocalUrl(url)) {
+ IPath repoPath = LocalRepoMounter.mountLocalRepository(rootstrapPath, url, null);
+ if (repoPath != null) {
+ target.getCommander(CmdTargetTypes.ROOTSTRAP).addLocalRepo(name,
+ repoPath.toOSString());
+ }
+ } else {
+ target.getCommander(CmdTargetTypes.ROOTSTRAP).addRepo(name, url);
+ }
+ }
+ }
+
+ public static void updateRepoInfoToRootstrap(PkgCommandTarget target) {
+ RepositoryProvider.INSTANCE.getBuildsystemRepos().clear();
+ PlatformRootstrap rootstrap = target.getRootstrap();
+ int idx = 0;
+ List<Repository> repos = rootstrap.getRepoList();
+ for (Repository repo : repos) {
+ String url = repo.getUri();
+ String name = String.format("url%d", idx++);
+ RepositoryProvider.INSTANCE.getBuildsystemRepos().add(new Repository(name, url));
+ }
+ }
+
+ public static void updateRepoInfoToDevice(List<Repository> repos) {
+ RepositoryProvider.INSTANCE.getDeviceRepos().clear();
+ RepositoryProvider.INSTANCE.getDeviceRepos().addAll(repos);
+ }
+
+ public static void updateRepoToDevice(PkgCommandTarget target) {
+ IPkgCommander commander = target.getDeviceCommander();
+ if (commander != null) {
+ commander.resetRepo();
+ int idx = 0;
+ List<Repository> repos = RepositoryProvider.INSTANCE.getDeviceRepos();
+ for (Repository repo : repos) {
+ String name = String.format("url%d", idx++);
+ commander.addRepo(name, repo.getUri());
+ }
+ }
+ }
+
public static void addReposToRootstrap(PkgCommandTarget target) {
PlatformRootstrap rootstrap = target.getRootstrap();
String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(
if (repoPath != null) {
RepositoryProvider.INSTANCE.getBuildsystemRepos()
.add(new Repository(name, url));
- target.getCommander(CmdTargetTypes.ROOTSTRAP).addLocalRepo(name, repoPath.toOSString());
+ target.getCommander(CmdTargetTypes.ROOTSTRAP).addLocalRepo(name,
+ repoPath.toOSString());
}
} else {
RepositoryProvider.INSTANCE.getBuildsystemRepos().add(new Repository(name, url));