Search in sources :

Example 51 with TabItem

use of org.eclipse.swt.widgets.TabItem in project xtext-xtend by eclipse.

the class FormatterModifyDialog method createDialogArea.

@Override
@SuppressWarnings("rawtypes")
protected Control createDialogArea(Composite parent) {
    if (isOldAPIVersion()) {
        return super.createDialogArea(parent);
    }
    try {
        // copied from Eclipse Oxygen to support old dialog in Eclipse Photon
        final Composite composite = new Composite(parent, SWT.NONE);
        GridLayout layout = new GridLayout();
        layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
        layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
        layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
        layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
        composite.setLayout(layout);
        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
        applyDialogFont(composite);
        Composite nameComposite = new Composite(composite, SWT.NONE);
        nameComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
        nameComposite.setLayout(new GridLayout(3, false));
        // use reflection to not break API
        Field fProfileNameField = ModifyDialog.class.getDeclaredField("fProfileNameField");
        fProfileNameField.setAccessible(true);
        StringDialogField f = new StringDialogField();
        fProfileNameField.set(this, f);
        f.setLabelText("&Profile name:");
        f.setText(fProfile.getName());
        f.getLabelControl(nameComposite).setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
        f.getTextControl(nameComposite).setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
        f.setDialogFieldListener(new IDialogFieldListener() {

            @Override
            public void dialogFieldChanged(DialogField field) {
                try {
                    Method doValidate = ModifyDialog.class.getDeclaredMethod("doValidate");
                    doValidate.setAccessible(true);
                    doValidate.invoke(FormatterModifyDialog.this);
                } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
                    XtendActivator.getInstance().getLog().log(new Status(IStatus.ERROR, XtendActivator.PLUGIN_ID, e.getMessage(), e));
                }
            }
        });
        // use reflection to not break API
        Field fSaveButton = ModifyDialog.class.getDeclaredField("fSaveButton");
        fSaveButton.setAccessible(true);
        fSaveButton.set(this, createButton(nameComposite, IDialogConstants.CLIENT_ID + 1, "E&xport...", false));
        fTabFolder = new TabFolder(composite, SWT.NONE);
        fTabFolder.setFont(composite.getFont());
        fTabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        // use reflection to not break API
        Field fWorkingValues = ModifyDialog.class.getDeclaredField("fWorkingValues");
        fWorkingValues.setAccessible(true);
        addPages((Map) fWorkingValues.get(this));
        applyDialogFont(composite);
        fTabFolder.addSelectionListener(new SelectionListener() {

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
            }

            @Override
            public void widgetSelected(SelectionEvent e) {
                final TabItem tabItem = (TabItem) e.item;
                final IModifyDialogTabPage page = (IModifyDialogTabPage) tabItem.getData();
                fDialogSettings.put(fKeyLastFocus, fTabPages.indexOf(page));
                page.makeVisible();
            }
        });
        // use reflection to not break API
        Method doValidate = ModifyDialog.class.getDeclaredMethod("doValidate");
        doValidate.setAccessible(true);
        doValidate.invoke(this);
        PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, getHelpContextId());
        return composite;
    } catch (NoSuchMethodException | SecurityException | IllegalArgumentException | IllegalAccessException | InvocationTargetException | NoSuchFieldException e) {
        XtendActivator.getInstance().getLog().log(new Status(IStatus.ERROR, XtendActivator.PLUGIN_ID, e.getMessage(), e));
        return null;
    }
}
Also used : IDialogFieldListener(org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener) ModifyDialog(org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Composite(org.eclipse.swt.widgets.Composite) TabFolder(org.eclipse.swt.widgets.TabFolder) Method(java.lang.reflect.Method) StringDialogField(org.eclipse.jdt.internal.ui.wizards.dialogfields.StringDialogField) InvocationTargetException(java.lang.reflect.InvocationTargetException) StringDialogField(org.eclipse.jdt.internal.ui.wizards.dialogfields.StringDialogField) Field(java.lang.reflect.Field) DialogField(org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField) TabItem(org.eclipse.swt.widgets.TabItem) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) StringDialogField(org.eclipse.jdt.internal.ui.wizards.dialogfields.StringDialogField) DialogField(org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField) IModifyDialogTabPage(org.eclipse.jdt.internal.ui.preferences.formatter.IModifyDialogTabPage) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 52 with TabItem

use of org.eclipse.swt.widgets.TabItem in project linuxtools by eclipse.

the class SystemTapOptionsTab method createControl.

/**
 * This function prepares some space for the various
 * tabs and calls and sets the other create*Option
 * functions to create buttons, text fields and spinners.
 */
@Override
public void createControl(Composite parent) {
    /*
         * File folder - tab for selecting binary/stp file
         */
    TabFolder fileFolder = new TabFolder(parent, SWT.BORDER);
    fileFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
    setControl(fileFolder);
    TabItem fileTab = new TabItem(fileFolder, SWT.NONE);
    // $NON-NLS-1$
    fileTab.setText(Messages.getString("SystemTapOptionsTab.FilesTab"));
    Composite fileTop = new Composite(fileFolder, SWT.NONE);
    fileTop.setLayout(new GridLayout());
    fileTop.setLayoutData(new GridData(GridData.FILL_BOTH));
    createFileOption(fileTop);
    fileTab.setControl(fileTop);
    /*
         * Commands tab - tab for selecting SystemTap commands
         */
    TabItem commandTab = new TabItem(fileFolder, SWT.NONE);
    // $NON-NLS-1$
    commandTab.setText(Messages.getString("SystemTapOptionsTab.CommandsTab"));
    Composite commandTop = new Composite(fileFolder, SWT.NONE);
    commandTop.setLayout(new GridLayout());
    commandTop.setLayoutData(new GridData(GridData.FILL_BOTH));
    createCommandOption(commandTop);
    commandTab.setControl(commandTop);
    /*
         * Arguments tab - tab for selecting script arguments
         */
    TabItem argumentsTab = new TabItem(fileFolder, SWT.NONE);
    // $NON-NLS-1$
    argumentsTab.setText(Messages.getString("SystemTapOptionsTab.Arguments"));
    Composite argumentsTop = new Composite(fileFolder, SWT.NONE);
    argumentsTop.setLayout(new GridLayout());
    argumentsTop.setLayoutData(new GridData(GridData.FILL_BOTH));
    createArgumentsOption(argumentsTop);
    argumentsTab.setControl(argumentsTop);
    /*
         * Binary Argument tab - tab for supplying arguments for a binary
         */
    TabItem binaryArgumentsTab = new TabItem(fileFolder, SWT.NONE);
    // $NON-NLS-1$
    binaryArgumentsTab.setText(Messages.getString("SystemTapOptionsTab.44"));
    Composite binaryArgumentsTop = new Composite(fileFolder, SWT.NONE);
    binaryArgumentsTop.setLayout(new GridLayout());
    binaryArgumentsTop.setLayoutData(new GridData(GridData.FILL_BOTH));
    createBinaryArgumentsOption(binaryArgumentsTop);
    binaryArgumentsTab.setControl(binaryArgumentsTop);
    /*
         * Parser tab -- Tab for selecting a parser and viewer to use
         */
    TabItem parserTab = new TabItem(fileFolder, SWT.NONE);
    // $NON-NLS-1$
    parserTab.setText("Parser");
    Composite parserTop = new Composite(fileFolder, SWT.NONE);
    parserTop.setLayout(new GridLayout());
    parserTop.setLayoutData(new GridData(GridData.FILL_BOTH));
    createParserOption(parserTop);
    parserTab.setControl(parserTop);
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) TabFolder(org.eclipse.swt.widgets.TabFolder) GridData(org.eclipse.swt.layout.GridData)

Example 53 with TabItem

use of org.eclipse.swt.widgets.TabItem in project linuxtools by eclipse.

the class ValgrindOptionsTab method createControl.

@Override
public void createControl(Composite parent) {
    // Check for exception
    if (ex != null) {
        setErrorMessage(ex.getLocalizedMessage());
    }
    scrollTop = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    scrollTop.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    scrollTop.setExpandVertical(true);
    scrollTop.setExpandHorizontal(true);
    setControl(scrollTop);
    top = new Composite(scrollTop, SWT.NONE);
    top.setLayout(new GridLayout());
    createVerticalSpacer(top, 1);
    // provide the tool combo if it is not excluded
    if (!noToolCombo)
        createToolCombo(top);
    createVerticalSpacer(top, 1);
    optionsFolder = new TabFolder(top, SWT.BORDER);
    optionsFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
    // "general" tab
    TabItem generalTab = new TabItem(optionsFolder, SWT.NONE);
    // $NON-NLS-1$
    generalTab.setText(Messages.getString("ValgrindOptionsTab.General"));
    Composite generalTop = new Composite(optionsFolder, SWT.NONE);
    generalTop.setLayout(new GridLayout());
    generalTop.setLayoutData(new GridData(GridData.FILL_BOTH));
    createBasicOptions(generalTop);
    createVerticalSpacer(generalTop, 1);
    createErrorOptions(generalTop);
    createVerticalSpacer(generalTop, 1);
    createOtherOptions(generalTop);
    generalTab.setControl(generalTop);
    TabItem suppTab = new TabItem(optionsFolder, SWT.NONE);
    // $NON-NLS-1$
    suppTab.setText(Messages.getString("ValgrindOptionsTab.Suppressions"));
    Composite suppTop = new Composite(optionsFolder, SWT.NONE);
    suppTop.setLayout(new GridLayout());
    suppTop.setLayoutData(new GridData(GridData.FILL_BOTH));
    createSuppressionsOption(suppTop);
    suppTab.setControl(suppTop);
    toolTab = new TabItem(optionsFolder, SWT.NONE);
    // $NON-NLS-1$
    toolTab.setText(Messages.getString("ValgrindOptionsTab.Tool"));
    dynamicTabHolder = new Composite(optionsFolder, SWT.NONE);
    dynamicTabHolder.setLayout(new GridLayout());
    dynamicTabHolder.setLayoutData(new GridData(GridData.FILL_BOTH));
    toolTab.setControl(dynamicTabHolder);
    scrollTop.setContent(top);
    recomputeSize();
    updateLaunchConfigurationDialog();
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) GridData(org.eclipse.swt.layout.GridData) TabFolder(org.eclipse.swt.widgets.TabFolder) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite)

Example 54 with TabItem

use of org.eclipse.swt.widgets.TabItem in project yamcs-studio by yamcs.

the class ScriptsInputDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    final Composite parent_Composite = (Composite) super.createDialogArea(parent);
    // Parent composite has GridLayout with 1 columns.
    // Create embedded composite w/ 2 columns
    final Composite mainComposite = new Composite(parent_Composite, SWT.None);
    mainComposite.setLayout(new GridLayout(2, false));
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData.heightHint = 250;
    mainComposite.setLayoutData(gridData);
    // Left Panel: List of scripts
    final Composite leftComposite = new Composite(mainComposite, SWT.NONE);
    leftComposite.setLayout(new GridLayout(1, false));
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = 350;
    leftComposite.setLayoutData(gd);
    createLabel(leftComposite, "Scripts");
    Composite toolBarComposite = new Composite(leftComposite, SWT.BORDER);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.marginLeft = 0;
    gridLayout.marginRight = 0;
    gridLayout.marginBottom = 0;
    gridLayout.marginTop = 0;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    toolBarComposite.setLayout(gridLayout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    toolBarComposite.setLayoutData(gd);
    ToolBarManager toolbarManager = new ToolBarManager(SWT.FLAT);
    ToolBar toolBar = toolbarManager.createControl(toolBarComposite);
    GridData grid = new GridData();
    grid.horizontalAlignment = GridData.FILL;
    grid.verticalAlignment = GridData.BEGINNING;
    toolBar.setLayoutData(grid);
    createActions();
    toolbarManager.add(addAction);
    toolbarManager.add(editAction);
    toolbarManager.add(removeAction);
    toolbarManager.add(moveUpAction);
    toolbarManager.add(moveDownAction);
    toolbarManager.add(convertToEmbedAction);
    toolbarManager.update(true);
    scriptsViewer = createScriptsTableViewer(toolBarComposite);
    scriptsViewer.setInput(scriptDataList);
    // Right panel: Input PVs for selected script
    final Composite rightComposite = new Composite(mainComposite, SWT.NONE);
    gridLayout = new GridLayout(1, false);
    rightComposite.setLayout(gridLayout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    // Account for the StringTableEditor's minimum size
    gd.minimumWidth = 250;
    rightComposite.setLayoutData(gd);
    this.createLabel(rightComposite, "");
    TabFolder tabFolder = new TabFolder(rightComposite, SWT.None);
    tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    TabItem pvTab = new TabItem(tabFolder, SWT.NONE);
    pvTab.setText("Input PVs");
    TabItem optionTab = new TabItem(tabFolder, SWT.NONE);
    optionTab.setText("Options");
    pvsEditor = new PVTupleTableEditor(tabFolder, new ArrayList<PVTuple>(), SWT.NONE);
    pvsEditor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    pvsEditor.setEnabled(false);
    pvTab.setControl(pvsEditor);
    final Composite optionTabComposite = new Composite(tabFolder, SWT.None);
    optionTabComposite.setLayout(new GridLayout(1, false));
    optionTab.setControl(optionTabComposite);
    skipFirstExecutionButton = new Button(optionTabComposite, SWT.CHECK | SWT.WRAP);
    skipFirstExecutionButton.setText("Skip executions triggered by PVs' first value.");
    skipFirstExecutionButton.setToolTipText("Skip the script executions triggered by PVs' first connections during OPI startup.\n" + "This is useful if you want to trigger a script from user inputs only.");
    skipFirstExecutionButton.setSelection(false);
    skipFirstExecutionButton.setEnabled(false);
    skipFirstExecutionButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) scriptsViewer.getSelection();
            if (!selection.isEmpty()) {
                ((ScriptData) selection.getFirstElement()).setSkipPVsFirstConnection(skipFirstExecutionButton.getSelection());
            }
        }
    });
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    Point preferredSize = skipFirstExecutionButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    gd.widthHint = preferredSize.x;
    gd.minimumHeight = preferredSize.y;
    skipFirstExecutionButton.setLayoutData(gd);
    checkConnectivityButton = new Button(optionTabComposite, SWT.CHECK | SWT.WRAP);
    checkConnectivityButton.setSelection(false);
    checkConnectivityButton.setText("Execute anyway even if some PVs are disconnected.");
    checkConnectivityButton.setToolTipText("This is only useful if you want to handle PVs' disconnection in script.\nOtherwise, please keep it unchecked.");
    checkConnectivityButton.setEnabled(false);
    checkConnectivityButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) scriptsViewer.getSelection();
            if (!selection.isEmpty()) {
                ((ScriptData) selection.getFirstElement()).setCheckConnectivity(!checkConnectivityButton.getSelection());
            }
            if (checkConnectivityButton.getSelection()) {
                MessageDialog.openWarning(getShell(), "Warning", "If this option is checked, " + "the script itself is responsible for checking PV's connectivity before using that PV in the script.\n" + "Otherwise, you will probably get an error message with java.lang.NullPointerException. \n" + "PV's connectivity can be checked via this method: pvArray[#].isConnected()");
            }
        }
    });
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    preferredSize = checkConnectivityButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    gd.widthHint = preferredSize.x;
    gd.minimumHeight = preferredSize.y;
    checkConnectivityButton.setLayoutData(gd);
    stopExecuteOnErrorButton = new Button(optionTabComposite, SWT.CHECK | SWT.WRAP);
    stopExecuteOnErrorButton.setSelection(false);
    stopExecuteOnErrorButton.setText("Do not execute the script if error was detected.");
    stopExecuteOnErrorButton.setToolTipText("If this option is selected, the script will not be executed \n" + "on next trigger if error was detected in the script.");
    stopExecuteOnErrorButton.setEnabled(false);
    stopExecuteOnErrorButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) scriptsViewer.getSelection();
            if (!selection.isEmpty()) {
                ((ScriptData) selection.getFirstElement()).setStopExecuteOnError(stopExecuteOnErrorButton.getSelection());
            }
        }
    });
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    preferredSize = stopExecuteOnErrorButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    gd.widthHint = preferredSize.x;
    gd.minimumHeight = preferredSize.y;
    stopExecuteOnErrorButton.setLayoutData(gd);
    if (scriptDataList.size() > 0) {
        setScriptsViewerSelection(scriptDataList.get(0));
        checkConnectivityButton.setSelection(!scriptDataList.get(0).isCheckConnectivity());
        skipFirstExecutionButton.setSelection(scriptDataList.get(0).isSkipPVsFirstConnection());
        stopExecuteOnErrorButton.setSelection(scriptDataList.get(0).isStopExecuteOnError());
    }
    return parent_Composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TabFolder(org.eclipse.swt.widgets.TabFolder) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Point(org.eclipse.swt.graphics.Point) ToolBarManager(org.eclipse.jface.action.ToolBarManager) TabItem(org.eclipse.swt.widgets.TabItem) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

TabItem (org.eclipse.swt.widgets.TabItem)54 Composite (org.eclipse.swt.widgets.Composite)35 GridData (org.eclipse.swt.layout.GridData)33 GridLayout (org.eclipse.swt.layout.GridLayout)33 TabFolder (org.eclipse.swt.widgets.TabFolder)33 SelectionEvent (org.eclipse.swt.events.SelectionEvent)19 Button (org.eclipse.swt.widgets.Button)17 Label (org.eclipse.swt.widgets.Label)17 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)16 Text (org.eclipse.swt.widgets.Text)15 Combo (org.eclipse.swt.widgets.Combo)8 Group (org.eclipse.swt.widgets.Group)7 Test (org.junit.Test)7 FillLayout (org.eclipse.swt.layout.FillLayout)6 TableColumn (org.eclipse.swt.widgets.TableColumn)6 ArrayList (java.util.ArrayList)5 StyledText (org.eclipse.swt.custom.StyledText)5 TableItem (org.eclipse.swt.widgets.TableItem)5 TableViewer (org.eclipse.jface.viewers.TableViewer)4 SelectionListener (org.eclipse.swt.events.SelectionListener)4