use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class PackageManager method installPackage.
/**
* Install new package
*/
private void installPackage() {
FileDialog fd = new FileDialog(getSite().getShell(), SWT.OPEN);
fd.setText(Messages.get().PackageManager_SelectFile);
String npiName = fd.open();
if (npiName != null) {
try {
final File npiFile = new File(npiName);
final PackageInfo p = new PackageInfo(npiFile);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().PackageManager_InstallPackage, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(final IProgressMonitor monitor) throws Exception {
final long id = session.installPackage(p, new File(npiFile.getParent(), p.getFileName()), new ProgressListener() {
long prevAmount = 0;
@Override
public void setTotalWorkAmount(long amount) {
monitor.beginTask(Messages.get(getDisplay()).PackageManager_UploadPackage, (int) amount);
}
@Override
public void markProgress(long amount) {
monitor.worked((int) (amount - prevAmount));
prevAmount = amount;
}
});
p.setId(id);
runInUIThread(new Runnable() {
@Override
public void run() {
packageList.add(p);
viewer.setInput(packageList.toArray());
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().PackageManager_InstallError;
}
}.start();
} catch (IOException e) {
MessageDialogHelper.openError(getSite().getShell(), Messages.get().PackageManager_Error, Messages.get().PackageManager_PkgFileOpenError + e.getLocalizedMessage());
}
}
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class PackageManager method deployPackage.
/**
* Deploy package on managed nodes
*/
private void deployPackage() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
final PackageInfo pkg = (PackageInfo) selection.getFirstElement();
ObjectSelectionDialog dlg = new ObjectSelectionDialog(getSite().getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(false));
dlg.enableMultiSelection(true);
if (dlg.open() != Window.OK)
return;
final Set<Long> objects = new HashSet<Long>();
for (AbstractObject o : dlg.getSelectedObjects()) {
objects.add(o.getObjectId());
}
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
ConsoleJob job = new ConsoleJob(Messages.get().PackageManager_DeployAgentPackage, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.deployPackage(pkg.getId(), objects.toArray(new Long[objects.size()]), new PackageDeploymentListener() {
private PackageDeploymentMonitor monitor = null;
@Override
public void statusUpdate(long nodeId, int status, String message) {
if (monitor != null)
monitor.viewStatusUpdate(nodeId, status, message);
}
@Override
public void deploymentStarted() {
final Object sync = new Object();
synchronized (sync) {
runInUIThread(new Runnable() {
@Override
public void run() {
try {
monitor = (PackageDeploymentMonitor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(PackageDeploymentMonitor.ID, toString(), IWorkbenchPage.VIEW_ACTIVATE);
monitor.setPackageId(pkg.getId());
} catch (PartInitException e) {
MessageDialogHelper.openError(getSite().getShell(), Messages.get().PackageManager_Error, Messages.get().PackageManager_ErrorOpenView + e.getLocalizedMessage());
}
synchronized (sync) {
sync.notify();
}
}
});
try {
sync.wait();
} catch (InterruptedException e) {
}
}
}
@Override
public void deploymentComplete() {
runInUIThread(new Runnable() {
@Override
public void run() {
MessageDialogHelper.openInformation(getSite().getShell(), Messages.get().PackageManager_Information, Messages.get().PackageManager_PkgDepCompleted);
}
});
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().PackageManager_DepStartError;
}
};
job.setUser(false);
job.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class ServerStoredAgentConfigEditorView method onSelectionChange.
/**
* @param event
*/
private void onSelectionChange(SelectionChangedEvent event) {
if (reselection) {
reselection = false;
return;
}
if (modified) {
SaveStoredConfigDialog dlg = new SaveStoredConfigDialog(getSite().getShell());
int rc = dlg.open();
if (rc == SaveStoredConfigDialog.SAVE_ID) {
intermediateSave();
modified = false;
firePropertyChange(PROP_DIRTY);
actionSave.setEnabled(false);
return;
}
if (rc == SaveStoredConfigDialog.CANCEL) {
reselection = true;
configList.setSelection(previousSelection);
return;
}
}
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
previousSelection = selection;
if (selection == null)
return;
final ConfigListElement element = (ConfigListElement) selection.getFirstElement();
new ConsoleJob(Messages.get().ServerStoredAgentConfigEditorView_JobTitle_GetContent, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
if (element != null) {
content = session.getConfigContent(element.getId());
runInUIThread(new Runnable() {
@Override
public void run() {
updateContent();
}
});
}
}
@Override
protected String getErrorMessage() {
return Messages.get().ServerStoredAgentConfigEditorView_JobError_GetContent;
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class ServerStoredAgentConfigEditorView method intermediateSave.
/**
*/
public void intermediateSave() {
if (content == null)
return;
content.setConfig(configEditor.getText());
content.setFilter(filterEditor.getText());
content.setName(nameField.getText());
new ConsoleJob(Messages.get().ServerStoredAgentConfigEditorView_JobSave, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.saveAgentConfig(content);
runInUIThread(new Runnable() {
@Override
public void run() {
getConfigList();
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().ServerStoredAgentConfigEditorView_JobError_Save;
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class ServerStoredAgentConfigEditorView method moveDown.
/**
* Move selected item down
*/
private void moveDown() {
IStructuredSelection selection = (IStructuredSelection) configList.getSelection();
if (selection == null)
return;
final ConfigListElement element1 = (ConfigListElement) selection.getFirstElement();
int index = elements.indexOf(element1);
if (index >= (elements.size() - 1))
return;
final ConfigListElement elemen2 = elements.get(index + 1);
new ConsoleJob(Messages.get().ServerStoredAgentConfigEditorView_JobMoveDown, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.swapAgentConfigs(element1.getId(), elemen2.getId());
runInUIThread(new Runnable() {
@Override
public void run() {
getConfigList();
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().ServerStoredAgentConfigEditorView_JobError_MoveDown;
}
}.start();
}
Aggregations