use of org.netxms.ui.eclipse.nxsl.widgets.ScriptEditor in project netxms by netxms.
the class ServiceCheckScript method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite dialogArea = new Composite(parent, SWT.NONE);
object = (ServiceCheck) getElement().getAdapter(ServiceCheck.class);
if (// Paranoid check
object == null)
return dialogArea;
initialScript = object.getScript();
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.INNER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
// Script
Label label = new Label(dialogArea, SWT.NONE);
label.setText(Messages.get().ServiceCheckScript_CheckScript);
filterSource = new ScriptEditor(dialogArea, SWT.BORDER, SWT.H_SCROLL | SWT.V_SCROLL, false, "Variables:\r\n\t$node\tnode object for node links, null for other checks\r\n\r\nReturn value: OK/FAIL to indicate check result.");
filterSource.setText(object.getScript());
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.widthHint = 0;
gd.heightHint = 0;
filterSource.setLayoutData(gd);
return dialogArea;
}
use of org.netxms.ui.eclipse.nxsl.widgets.ScriptEditor in project netxms by netxms.
the class ScriptEditorView method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
parent.setLayout(new FillLayout());
editorMessageBar = new CompositeWithMessageBar(parent, SWT.NONE);
editor = new ScriptEditor(editorMessageBar, SWT.NONE, SWT.H_SCROLL | SWT.V_SCROLL, showLineNumbers);
editorMessageBar.setContent(editor);
editor.getTextWidget().addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (!modified) {
modified = true;
firePropertyChange(PROP_DIRTY);
actionSave.setEnabled(true);
}
}
});
activateContext();
createActions();
contributeToActionBars();
// createPopupMenu();
reloadScript();
}
use of org.netxms.ui.eclipse.nxsl.widgets.ScriptEditor in project netxms by netxms.
the class ScriptExecutor method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
parent.setLayout(new FillLayout());
/**
** Script executor form ***
*/
FormToolkit toolkit = new FormToolkit(getSite().getShell().getDisplay());
Composite formContainer = new Composite(parent, SWT.NONE);
formContainer.setLayout(new FillLayout());
form = toolkit.createForm(formContainer);
form.setText(Messages.get().ScriptExecutor_Noname);
GridLayout layout = new GridLayout();
layout.verticalSpacing = 8;
form.getBody().setLayout(layout);
/**
** Script list dropdown ***
*/
scriptCombo = WidgetHelper.createLabeledCombo(form.getBody(), SWT.READ_ONLY, Messages.get().ScriptExecutor_LibScript, WidgetHelper.DEFAULT_LAYOUT_DATA, toolkit);
updateScriptList(null);
scriptCombo.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
if (modified) {
if (saveIfRequired(true))
return;
}
getScriptContent();
previousSelection = scriptCombo.getSelectionIndex();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
SashForm splitter = new SashForm(form.getBody(), SWT.VERTICAL);
splitter.setSashWidth(3);
GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.verticalAlignment = SWT.FILL;
gridData.grabExcessVerticalSpace = true;
splitter.setLayoutData(gridData);
/**
** Script editor ***
*/
Composite container = toolkit.createComposite(splitter);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.marginBottom = 4;
container.setLayout(layout);
Section section = toolkit.createSection(container, Section.TITLE_BAR);
section.setText(Messages.get().ScriptExecutor_Source);
gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.verticalAlignment = SWT.FILL;
gridData.grabExcessVerticalSpace = true;
section.setLayoutData(gridData);
scriptEditor = new ScriptEditor(section, SWT.BORDER, SWT.H_SCROLL | SWT.V_SCROLL, true);
section.setClient(scriptEditor);
// $NON-NLS-1$
scriptEditor.setText("");
scriptEditor.getTextWidget().addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
onTextModify();
}
});
/**
** Execution result ***
*/
container = toolkit.createComposite(splitter);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.marginTop = 4;
container.setLayout(layout);
section = toolkit.createSection(container, Section.TITLE_BAR);
section.setText(Messages.get().ScriptExecutor_Output);
gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.verticalAlignment = SWT.FILL;
gridData.grabExcessVerticalSpace = true;
section.setLayoutData(gridData);
output = new TextConsole(section, SWT.BORDER);
section.setClient(output);
/*executionResult.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e)
{
actionCopy.setEnabled(executionResult.getSelectionCount() > 0);
}
});*/
// TODO: Think how to split copy action between 2 editors
activateContext();
createActions();
contributeToActionBars();
actionSave.setEnabled(false);
}
use of org.netxms.ui.eclipse.nxsl.widgets.ScriptEditor in project netxms by netxms.
the class MapObjectFilter method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite dialogArea = new Composite(parent, SWT.NONE);
object = (NetworkMap) getElement().getAdapter(NetworkMap.class);
if (// Paranoid check
object == null)
return dialogArea;
initialFilter = object.getFilter();
initialEnable = (object.getFlags() & NetworkMap.MF_FILTER_OBJECTS) != 0;
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
// Enable/disable check box
checkboxEnableFilter = new Button(dialogArea, SWT.CHECK);
checkboxEnableFilter.setText(Messages.get().MapObjectFilter_FilterObjects);
checkboxEnableFilter.setSelection(initialEnable);
checkboxEnableFilter.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
if (checkboxEnableFilter.getSelection()) {
filterSource.setEnabled(true);
filterSource.setFocus();
} else {
filterSource.setEnabled(false);
}
}
});
// Filtering script
Label label = new Label(dialogArea, SWT.NONE);
label.setText(Messages.get().MapObjectFilter_FilteringScript);
GridData gd = new GridData();
gd.verticalIndent = WidgetHelper.DIALOG_SPACING;
label.setLayoutData(gd);
filterSource = new ScriptEditor(dialogArea, SWT.BORDER, SWT.H_SCROLL | SWT.V_SCROLL, false, "Variables:\r\n\t$object\tcurrent object\r\n\t$node\tcurrent object if it's class is Node\r\n\r\nReturn value: true to include current object into this map");
filterSource.setText(initialFilter);
filterSource.setEnabled(initialEnable);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.widthHint = 0;
gd.heightHint = 0;
filterSource.setLayoutData(gd);
return dialogArea;
}
use of org.netxms.ui.eclipse.nxsl.widgets.ScriptEditor in project netxms by netxms.
the class ServerStoredAgentConfigEditorView method createPartControl.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
parent.setLayout(new FillLayout());
SashForm splitter = new SashForm(parent, SWT.HORIZONTAL);
splitter.setSashWidth(3);
Composite listContainer = new Composite(splitter, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 2;
layout.horizontalSpacing = 0;
listContainer.setLayout(layout);
configList = new TableViewer(listContainer, SWT.FULL_SELECTION | SWT.SINGLE);
configList.setContentProvider(new ArrayContentProvider());
configList.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
onSelectionChange(event);
}
});
configList.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
new Label(listContainer, SWT.SEPARATOR | SWT.VERTICAL).setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, true));
/**
** editor section ***
*/
FormToolkit toolkit = new FormToolkit(getSite().getShell().getDisplay());
Composite formContainer = new Composite(splitter, SWT.NONE);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 2;
layout.horizontalSpacing = 0;
formContainer.setLayout(layout);
new Label(formContainer, SWT.SEPARATOR | SWT.VERTICAL).setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, true));
form = toolkit.createScrolledForm(formContainer);
form.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
form.setText(Messages.get().ServerStoredAgentConfigEditorView_Noname);
layout = new GridLayout();
form.getBody().setLayout(layout);
GridData gridData = new GridData();
gridData.horizontalAlignment = SWT.FILL;
gridData.grabExcessHorizontalSpace = true;
form.getBody().setLayoutData(gridData);
splitter.setWeights(new int[] { 20, 80 });
Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
section.setText(Messages.get().ServerStoredAgentConfigEditorView_Name);
layout = new GridLayout();
section.setLayout(layout);
gridData = new GridData();
gridData.horizontalAlignment = SWT.FILL;
gridData.grabExcessHorizontalSpace = true;
section.setLayoutData(gridData);
/**
** Name ***
*/
nameField = new Text(section, SWT.BORDER);
section.setClient(nameField);
gridData = new GridData();
gridData.horizontalAlignment = SWT.FILL;
gridData.grabExcessHorizontalSpace = true;
nameField.setLayoutData(gridData);
nameField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
onTextModify();
}
});
/**
** Filter ***
*/
section = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
section.setText(Messages.get().ServerStoredAgentConfigEditorView_Filter);
section.setLayout(layout);
gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.verticalAlignment = SWT.FILL;
gridData.grabExcessVerticalSpace = true;
section.setLayoutData(gridData);
filterEditor = new ScriptEditor(section, SWT.BORDER, SWT.H_SCROLL | SWT.V_SCROLL, true, "Variables:\r\n\t$1\tIP address\r\n\t$2\tplatform name\r\n\t$3\tmajor agent version number\r\n\t$4\tminor agent version number\r\n\t$5\trelease number\r\n\r\nReturn value: true if this configuration should be sent to agent");
section.setClient(filterEditor);
filterEditor.getTextWidget().addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
onTextModify();
}
});
gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.verticalAlignment = SWT.FILL;
gridData.grabExcessVerticalSpace = true;
filterEditor.setLayoutData(gridData);
/**
** Config ***
*/
section = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
section.setText(Messages.get().ServerStoredAgentConfigEditorView_ConfigFile);
gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.verticalAlignment = SWT.FILL;
gridData.grabExcessVerticalSpace = true;
section.setLayoutData(gridData);
configEditor = new AgentConfigEditor(section, SWT.BORDER, SWT.H_SCROLL | SWT.V_SCROLL, 0);
section.setClient(configEditor);
configEditor.getTextWidget().addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
onTextModify();
}
});
gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.verticalAlignment = SWT.FILL;
gridData.grabExcessVerticalSpace = true;
configEditor.setLayoutData(gridData);
createActions();
contributeToActionBars();
createPopupMenu();
actionSave.setEnabled(false);
getConfigList();
}
Aggregations