Search in sources :

Example 6 with ScriptEditor

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;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) ScriptEditor(org.netxms.ui.eclipse.nxsl.widgets.ScriptEditor)

Example 7 with ScriptEditor

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();
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) CompositeWithMessageBar(org.netxms.ui.eclipse.widgets.CompositeWithMessageBar) FillLayout(org.eclipse.swt.layout.FillLayout) ScriptEditor(org.netxms.ui.eclipse.nxsl.widgets.ScriptEditor)

Example 8 with ScriptEditor

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);
}
Also used : FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) FillLayout(org.eclipse.swt.layout.FillLayout) Section(org.eclipse.ui.forms.widgets.Section) ScriptEditor(org.netxms.ui.eclipse.nxsl.widgets.ScriptEditor) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) TextConsole(org.netxms.ui.eclipse.widgets.TextConsole) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 9 with ScriptEditor

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;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) SelectionListener(org.eclipse.swt.events.SelectionListener) ScriptEditor(org.netxms.ui.eclipse.nxsl.widgets.ScriptEditor)

Example 10 with ScriptEditor

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();
}
Also used : AgentConfigEditor(org.netxms.ui.eclipse.agentmanager.widgets.AgentConfigEditor) Composite(org.eclipse.swt.widgets.Composite) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) ModifyListener(org.eclipse.swt.events.ModifyListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Text(org.eclipse.swt.widgets.Text) FillLayout(org.eclipse.swt.layout.FillLayout) Section(org.eclipse.ui.forms.widgets.Section) ScriptEditor(org.netxms.ui.eclipse.nxsl.widgets.ScriptEditor) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

ScriptEditor (org.netxms.ui.eclipse.nxsl.widgets.ScriptEditor)15 Composite (org.eclipse.swt.widgets.Composite)14 GridData (org.eclipse.swt.layout.GridData)13 GridLayout (org.eclipse.swt.layout.GridLayout)12 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 SelectionListener (org.eclipse.swt.events.SelectionListener)7 Label (org.eclipse.swt.widgets.Label)7 Button (org.eclipse.swt.widgets.Button)5 FillLayout (org.eclipse.swt.layout.FillLayout)4 ModifyEvent (org.eclipse.swt.events.ModifyEvent)3 ModifyListener (org.eclipse.swt.events.ModifyListener)3 WidgetFactory (org.netxms.ui.eclipse.tools.WidgetFactory)3 SashForm (org.eclipse.swt.custom.SashForm)2 FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)2 Section (org.eclipse.ui.forms.widgets.Section)2 ArrayList (java.util.ArrayList)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1