use of org.netxms.ui.eclipse.nxsl.dialogs.CreateScriptDialog 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.nxsl.dialogs.CreateScriptDialog in project netxms by netxms.
the class ScriptLibrary method createNewScript.
/**
* Create new script
*/
private void createNewScript() {
final CreateScriptDialog dlg = new CreateScriptDialog(getSite().getShell(), null);
if (dlg.open() == Window.OK) {
new ConsoleJob(Messages.get().ScriptLibrary_CreateJobTitle, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
// $NON-NLS-1$
final long id = session.modifyScript(0, 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) list.add((Script) o);
// $NON-NLS-1$
final Script script = new Script(id, dlg.getName(), "");
list.add(script);
viewer.setInput(list.toArray());
viewer.setSelection(new StructuredSelection(script));
actionEdit.run();
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().ScriptLibrary_CreateJobError;
}
}.start();
}
}
use of org.netxms.ui.eclipse.nxsl.dialogs.CreateScriptDialog in project netxms by netxms.
the class ScriptExecutor method createNewScript.
/**
* Create new script
*/
private void createNewScript(final boolean saveOnSelectionChange) {
final CreateScriptDialog dlg = new CreateScriptDialog(getSite().getShell(), null);
if (dlg.open() == Window.OK) {
final String scriptSource = scriptEditor.getText();
new ConsoleJob(Messages.get().ScriptExecutor_JobName_Create, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.modifyScript(0, dlg.getName(), scriptSource);
runInUIThread(new Runnable() {
@Override
public void run() {
Runnable run = new Runnable() {
@Override
public void run() {
scriptCombo.select(scriptCombo.indexOf(dlg.getName()));
}
};
updateScriptList(saveOnSelectionChange ? null : run);
clearDirtyFlags();
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().ScriptExecutor_JobError_Create;
}
}.start();
}
}
Aggregations