use of org.netxms.ui.eclipse.market.objects.RepositoryRuntimeInfo in project netxms by netxms.
the class RepositoryManager method addRepository.
/**
* Add repository
*/
private void addRepository() {
RepositoryPropertiesDlg dlg = new RepositoryPropertiesDlg(getSite().getShell(), null);
if (dlg.open() != Window.OK)
return;
final Repository repository = new Repository(dlg.getUrl(), dlg.getToken(), dlg.getDescription());
new ConsoleJob("Add repository", this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.addRepository(repository);
runInUIThread(new Runnable() {
@SuppressWarnings("unchecked")
@Override
public void run() {
ArrayList<RepositoryRuntimeInfo> repositories = (ArrayList<RepositoryRuntimeInfo>) viewer.getInput();
repositories.add(new RepositoryRuntimeInfo(repository));
viewer.refresh();
}
});
}
@Override
protected String getErrorMessage() {
return "Cannot add repository";
}
}.start();
}
use of org.netxms.ui.eclipse.market.objects.RepositoryRuntimeInfo in project netxms by netxms.
the class RepositoryManager method deleteRepository.
/**
* Delete repository
*/
private void deleteRepository() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if ((selection.size() != 1) || !(selection.getFirstElement() instanceof RepositoryRuntimeInfo))
return;
final RepositoryRuntimeInfo repository = (RepositoryRuntimeInfo) selection.getFirstElement();
if (!MessageDialogHelper.openQuestion(getSite().getShell(), "Confirm Delete", String.format("Repository %s will be deleted. Are you sure?", repository.getName())))
return;
new ConsoleJob("Delete repository", this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.deleteRepository(repository.getRepositoryId());
runInUIThread(new Runnable() {
@SuppressWarnings("unchecked")
@Override
public void run() {
ArrayList<RepositoryRuntimeInfo> repositories = (ArrayList<RepositoryRuntimeInfo>) viewer.getInput();
repositories.remove(repository);
viewer.refresh();
}
});
}
@Override
protected String getErrorMessage() {
return "Cannot delete repository";
}
}.start();
}
use of org.netxms.ui.eclipse.market.objects.RepositoryRuntimeInfo in project netxms by netxms.
the class RepositoryManager method install.
/**
* Install selected elements
*/
@SuppressWarnings("unchecked")
private void install() {
final List<InstallData> installData = new ArrayList<InstallData>();
ArrayList<RepositoryRuntimeInfo> repositories = (ArrayList<RepositoryRuntimeInfo>) viewer.getInput();
for (RepositoryRuntimeInfo r : repositories) {
List<RepositoryElement> markedElements = r.getMarkedElements();
if (markedElements.isEmpty())
continue;
StringBuilder sb = new StringBuilder();
for (RepositoryElement e : markedElements) {
if (sb.length() == 0)
sb.append("{ \"get-items\":[ ");
else
sb.append(", ");
sb.append("{ \"guid\":\"");
sb.append(e.getGuid().toString());
sb.append("\", \"version\":");
sb.append(e.getActualVersion());
sb.append(" }");
}
sb.append(" ] }");
installData.add(new InstallData(r, sb.toString()));
}
if (installData.isEmpty())
return;
actionInstall.setEnabled(false);
new ConsoleJob("Install items from repository", this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (final InstallData d : installData) {
importFromRepository(d.repository, d.request);
runInUIThread(new Runnable() {
@Override
public void run() {
d.repository.setAllMarked(false);
viewer.refresh();
}
});
}
}
@Override
protected void jobFinalize() {
runInUIThread(new Runnable() {
@Override
public void run() {
actionInstall.setEnabled(true);
}
});
}
@Override
protected String getErrorMessage() {
return "Import failed";
}
}.start();
}
Aggregations