use of org.netxms.ui.eclipse.market.objects.RepositoryElement in project netxms by netxms.
the class RepositoryManager method markForInstallation.
/**
* Mark selected elements for installation
*/
private void markForInstallation(boolean marked) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
for (Object o : selection.toList()) {
if (o instanceof RepositoryElement)
((RepositoryElement) o).setMarked(marked);
}
viewer.refresh();
}
use of org.netxms.ui.eclipse.market.objects.RepositoryElement 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