use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class ScriptExecutor method getScriptContent.
/**
* Updates content of script editor to selected by user script
*/
protected void getScriptContent() {
final int index = scriptCombo.getSelectionIndex();
if (index == -1)
return;
new ConsoleJob(Messages.get().ScriptExecutor_JobName_Update, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final Script script = session.getScript(library.get(index).getId());
runInUIThread(new Runnable() {
@Override
public void run() {
scriptEditor.setText(script.getSource());
clearDirtyFlags();
form.setText(script.getName());
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().ScriptExecutor_JobError_Update;
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class ScriptEditorView method saveScript.
/**
* Save script
*/
private void saveScript() {
final String source = editor.getText();
editor.getTextWidget().setEditable(false);
new ConsoleJob(Messages.get().ScriptEditorView_SaveJobTitle, this, Activator.PLUGIN_ID, null) {
@Override
protected String getErrorMessage() {
return Messages.get().ScriptEditorView_SaveJobError;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final ScriptCompilationResult result = session.compileScript(source, false);
if (result.success) {
getDisplay().syncExec(new Runnable() {
@Override
public void run() {
editorMessageBar.hideMessage();
}
});
} else {
getDisplay().syncExec(new Runnable() {
@Override
public void run() {
if (MessageDialogHelper.openQuestion(getSite().getShell(), Messages.get().ScriptEditorView_CompilationErrors, String.format(Messages.get().ScriptEditorView_ScriptCompilationFailed, result.errorMessage)))
result.success = true;
editorMessageBar.showMessage(CompositeWithMessageBar.WARNING, result.errorMessage);
}
});
}
if (result.success) {
doScriptSave(source, monitor);
} else {
runInUIThread(new Runnable() {
@Override
public void run() {
editor.getTextWidget().setEditable(true);
}
});
}
}
}.start();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class ScriptLibrary method renameScript.
/**
* Edit script
*/
private void renameScript() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
final Script script = (Script) selection.getFirstElement();
final CreateScriptDialog dlg = new CreateScriptDialog(getSite().getShell(), script.getName());
if (dlg.open() == Window.OK) {
new ConsoleJob(Messages.get().ScriptLibrary_RenameJobTitle, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.renameScript(script.getId(), dlg.getName());
runInUIThread(new Runnable() {
@Override
public void run() {
Object[] input = (Object[]) viewer.getInput();
List<Script> list = new ArrayList<Script>(input.length);
for (Object o : input) {
if (((Script) o).getId() != script.getId())
list.add((Script) o);
}
final Script newScript = new Script(script.getId(), dlg.getName(), script.getSource());
list.add(newScript);
viewer.setInput(list.toArray());
viewer.setSelection(new StructuredSelection(newScript));
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().ScriptLibrary_RenameJobError;
}
}.start();
}
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class PredefinedMap method saveMap.
/**
* Save map on server
*/
private void saveMap() {
updateObjectPositions();
final NXCObjectModificationData md = new NXCObjectModificationData(rootObject.getObjectId());
md.setMapContent(mapPage.getElements(), mapPage.getLinks());
md.setMapLayout(automaticLayoutEnabled ? layoutAlgorithm : MapLayoutAlgorithm.MANUAL);
md.setConnectionRouting(routingAlgorithm);
md.setMapObjectDisplayMode(labelProvider.getObjectFigureType());
int flags = mapObject.getFlags();
if (labelProvider.isShowStatusIcons())
flags |= NetworkMap.MF_SHOW_STATUS_ICON;
else
flags &= ~NetworkMap.MF_SHOW_STATUS_ICON;
if (labelProvider.isShowStatusFrame())
flags |= NetworkMap.MF_SHOW_STATUS_FRAME;
else
flags &= ~NetworkMap.MF_SHOW_STATUS_FRAME;
if (labelProvider.isShowStatusBackground())
flags |= NetworkMap.MF_SHOW_STATUS_BKGND;
else
flags &= ~NetworkMap.MF_SHOW_STATUS_BKGND;
if (labelProvider.isShowLinkDirection())
flags |= NetworkMap.MF_SHOW_LINK_DIRECTION;
else
flags &= ~NetworkMap.MF_SHOW_LINK_DIRECTION;
md.setObjectFlags(flags);
new ConsoleJob(String.format(Messages.get().PredefinedMap_SaveJobTitle, rootObject.getObjectName()), this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(mapPage);
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().PredefinedMap_SaveJobError;
}
}.start();
addDciToRequestList();
}
use of org.netxms.ui.eclipse.jobs.ConsoleJob in project netxms by netxms.
the class MapOptions method applyChanges.
/**
* Apply changes
*
* @param isApply true if update operation caused by "Apply" button
*/
protected boolean applyChanges(final boolean isApply) {
final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
int flags = 0;
if ((checkIncludeEndNodes != null) && checkIncludeEndNodes.getSelection())
flags |= NetworkMap.MF_SHOW_END_NODES;
if (checkShowStatusIcon.getSelection())
flags |= NetworkMap.MF_SHOW_STATUS_ICON;
if (checkShowStatusFrame.getSelection())
flags |= NetworkMap.MF_SHOW_STATUS_FRAME;
if (checkShowStatusBkgnd.getSelection())
flags |= NetworkMap.MF_SHOW_STATUS_BKGND;
if (checkCalculateStatus.getSelection())
flags |= NetworkMap.MF_CALCULATE_STATUS;
if (checkShowLinkDirection.getSelection())
flags |= NetworkMap.MF_SHOW_LINK_DIRECTION;
md.setObjectFlags(flags, 0x5F);
md.setMapObjectDisplayMode(MapObjectDisplayMode.getByValue(objectDisplayMode.getSelectionIndex()));
md.setConnectionRouting(routingAlgorithm.getSelectionIndex() + 1);
if (radioColorCustom.getSelection()) {
md.setLinkColor(ColorConverter.rgbToInt(linkColor.getColorValue()));
} else {
md.setLinkColor(-1);
}
if (checkCustomRadius != null) {
if (checkCustomRadius.getSelection())
md.setDiscoveryRadius(topologyRadius.getSelection());
else
md.setDiscoveryRadius(-1);
}
if (isApply)
setValid(false);
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().MapOptions_JobTitle + object.getObjectName(), null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyObject(md);
}
@Override
protected String getErrorMessage() {
return Messages.get().MapOptions_JobError + object.getObjectName();
}
@Override
protected void jobFinalize() {
if (isApply) {
runInUIThread(new Runnable() {
@Override
public void run() {
MapOptions.this.setValid(true);
}
});
}
}
}.start();
return true;
}
Aggregations