Search in sources :

Example 1 with TextConsole

use of org.netxms.ui.eclipse.widgets.TextConsole 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 2 with TextConsole

use of org.netxms.ui.eclipse.widgets.TextConsole in project netxms by netxms.

the class AbstractCommandResults method createPartControl.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    console = new TextConsole(parent, SWT.NONE);
    console.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            actionCopy.setEnabled(console.canCopy());
        }
    });
    createActions();
    contributeToActionBars();
    createPopupMenu();
    activateContext();
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) TextConsole(org.netxms.ui.eclipse.widgets.TextConsole) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Aggregations

TextConsole (org.netxms.ui.eclipse.widgets.TextConsole)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 SashForm (org.eclipse.swt.custom.SashForm)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)1 Section (org.eclipse.ui.forms.widgets.Section)1 ScriptEditor (org.netxms.ui.eclipse.nxsl.widgets.ScriptEditor)1