Search in sources :

Example 1 with GridData

use of org.eclipse.swt.layout.GridData in project cogtool by cogtool.

the class NewActionChangeDialog method addMoreFields.

@Override
protected void addMoreFields() {
    GridData reqLayout;
    if (complaint != null) {
        reqLayout = new GridData();
        reqLayout.grabExcessHorizontalSpace = true;
        reqLayout.horizontalSpan = 4;
        complaintLabel = new Label(dialog, SWT.NONE);
        complaintLabel.setText(complaint);
        complaintLabel.setLayoutData(reqLayout);
        complaintLabel.setFont(FontUtils.SYMBOL_FONT);
        complaintMode = properties.useWhichParts;
    }
    reqLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    reqLayout.grabExcessHorizontalSpace = true;
    reqLayout.horizontalSpan = 4;
    Composite c = new Composite(dialog, SWT.NONE);
    c.setLayoutData(reqLayout);
    propertySet = new ActionChangePropertySet(deviceTypes, c, this) {

        protected ActionProperties testEnableProps = new ActionProperties(ActionProperties.UNSET);

        @Override
        protected boolean userSelectedMode(int widgetMode) {
            boolean enableOK = super.userSelectedMode(widgetMode);
            if (complaintLabel != null) {
                complaintLabel.setVisible(widgetMode == complaintMode);
            }
            return enableOK;
        }

        @Override
        protected void enableOKButton(boolean enable) {
            // the OK button should be otherwise enabled
            if (enable) {
                if ((transitionSrc != null) && (properties != null)) {
                    propertySet.getProperties(testEnableProps);
                    AAction action = testEnableProps.buildAction();
                    Transition existingTransition = transitionSrc.getTransition(action);
                    if ((action != null) && (existingTransition != null)) {
                        enable = false;
                    }
                }
            }
            super.enableOKButton(enable);
        }
    };
    propertySet.layOutPropertiesPane();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) AAction(edu.cmu.cs.hcii.cogtool.model.AAction) ActionChangePropertySet(edu.cmu.cs.hcii.cogtool.view.ActionChangePropertySet)

Example 2 with GridData

use of org.eclipse.swt.layout.GridData in project cogtool by cogtool.

the class Keypad method makeNumbers.

/**
     * Creates and lays out the buttons for the keypad's number pad.
     *
     * @author Paul Rubritz (ptr@andrew.cmu.edu)
     */
protected void makeNumbers() {
    GridLayout grid = new GridLayout();
    grid.numColumns = 3;
    GridData gridKeysOption = new GridData();
    gridKeysOption.horizontalIndent = (keypadType == FULL_KEYPAD) ? 60 : 0;
    gridKeysOption.verticalAlignment = SWT.TOP;
    Composite numbers = new Composite(dialog, SWT.NONE);
    numbers.setLayoutData(gridKeysOption);
    numbers.setLayout(grid);
    Button keypadButton;
    for (int i = 0; i < numberKeys.length; i++) {
        gridKeysOption = new GridData();
        if (i < numberKeys.length - 1) {
            gridKeysOption.widthHint = 50;
        } else if (keypadType == NUMPAD_ONLY) {
            gridKeysOption.widthHint = 160;
            gridKeysOption.horizontalSpan = 3;
        } else {
            break;
        }
        gridKeysOption.heightHint = 50;
        keypadButton = makeButton(numbers, numberKeys[i], gridKeysOption);
        //       (see IntegerEntry)
        if ((keypadType == NUMPAD_ONLY) && numberKeys[i].equals("-")) {
            keypadButton.setBackground(getDisabledColor());
            keypadButton.setEnabled(false);
        }
    }
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Point(org.eclipse.swt.graphics.Point)

Example 3 with GridData

use of org.eclipse.swt.layout.GridData in project cogtool by cogtool.

the class AboutView method addLink.

// buildDialog
protected void addLink(String label, final String url) {
    Link link = new Link(dialog, SWT.NONE);
    GridData linkLayout = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
    linkLayout.horizontalSpan = 4;
    link.setLayoutData(linkLayout);
    link.setText(label + ": <a href=\"" + url + "\">" + url + "</a>");
    link.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event evt) {
            Program.launch(url);
        }
    });
}
Also used : Listener(org.eclipse.swt.widgets.Listener) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) Link(org.eclipse.swt.widgets.Link)

Example 4 with GridData

use of org.eclipse.swt.layout.GridData in project cogtool by cogtool.

the class AboutView method buildDialog.

@Override
public void buildDialog() {
    GridLayout layout = new GridLayout(4, false);
    if (OSUtils.MACOSX) {
        layout.marginLeft = 21;
        layout.marginRight = 21;
        layout.marginTop = 10;
        layout.marginBottom = 15;
    }
    dialog.setLayout(layout);
    // Centered logo, filling width
    Label logo = new Label(dialog, SWT.CENTER);
    logo.setImage(logoImg);
    GridData imgLayout = new GridData();
    imgLayout.horizontalSpan = 4;
    imgLayout.horizontalAlignment = GridData.FILL;
    imgLayout.grabExcessHorizontalSpace = true;
    logo.setLayoutData(imgLayout);
    // Current version, centered
    Text version = new Text(dialog, SWT.CENTER | SWT.READ_ONLY);
    GridData versionLayout = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
    versionLayout.horizontalSpan = 4;
    version.setLayoutData(versionLayout);
    version.setText(CogTool.getVersion());
    // Copyright and URL (as Link), centered
    Label copyright = new Label(dialog, SWT.NONE);
    GridData copyrightLayout = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
    copyrightLayout.horizontalSpan = 4;
    copyright.setLayoutData(copyrightLayout);
    // © is the (c) copyright symbol
    copyright.setText(L10N.get("CT.Copyright", "© 2012 CogTool@Carnegie Mellon University"));
    // Be careful if you modify the following: the SWT Link object seems
    // to behave most bizarrely if you combine a tilde in the middle of
    // a URL with a trailing slash at its end.
    addLink("Download updates from", L10N.get("CT.MainURL", "https://github.com/cogtool/cogtool/releases/latest"));
    addLink("Documentation", L10N.get("CT.UserGuideURL", "https://github.com/cogtool/cogtool/releases/download/1.2.2/CogToolUserGuide_1_2.pdf"));
    Label memory = new Label(dialog, SWT.NONE);
    GridData memoryLayout = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
    memoryLayout.horizontalSpan = 4;
    memory.setLayoutData(memoryLayout);
    memory.setText(CogTool.getMemoryUsage());
    Label props = new Label(dialog, SWT.NONE);
    GridData propsLayout = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
    propsLayout.horizontalSpan = 4;
    props.setLayoutData(propsLayout);
    props.setText(CogTool.getConfigurationProperties());
    addButtons();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text)

Example 5 with GridData

use of org.eclipse.swt.layout.GridData in project cogtool by cogtool.

the class AboutView method addButtons.

protected void addButtons() {
    if (OSUtils.WINDOWS) {
        // Centered OK button for dismissing the dialog box, set as default button
        Button okButton = new Button(dialog, SWT.PUSH);
        okButton.setText(L10N.get("B.OK", "OK"));
        okButton.setFocus();
        dialog.setDefaultButton(okButton);
        //            boolean ignore = okButton.setFocus();
        GridData okLayout = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
        okLayout.horizontalSpan = 4;
        okButton.setLayoutData(okLayout);
        // Dismiss the dialog box when OK button selected
        okButton.addListener(SWT.Selection, new Listener() {

            public void handleEvent(Event evt) {
                dialog.close();
            }
        });
    }
}
Also used : Listener(org.eclipse.swt.widgets.Listener) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event)

Aggregations

GridData (org.eclipse.swt.layout.GridData)1831 GridLayout (org.eclipse.swt.layout.GridLayout)1286 Composite (org.eclipse.swt.widgets.Composite)1136 Label (org.eclipse.swt.widgets.Label)709 SelectionEvent (org.eclipse.swt.events.SelectionEvent)602 Button (org.eclipse.swt.widgets.Button)526 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)512 Text (org.eclipse.swt.widgets.Text)427 Group (org.eclipse.swt.widgets.Group)383 ModifyListener (org.eclipse.swt.events.ModifyListener)184 ModifyEvent (org.eclipse.swt.events.ModifyEvent)181 Combo (org.eclipse.swt.widgets.Combo)171 Table (org.eclipse.swt.widgets.Table)140 TableViewer (org.eclipse.jface.viewers.TableViewer)136 Point (org.eclipse.swt.graphics.Point)107 SelectionListener (org.eclipse.swt.events.SelectionListener)100 FillLayout (org.eclipse.swt.layout.FillLayout)93 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)85 TableColumn (org.eclipse.swt.widgets.TableColumn)80 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)76