Search in sources :

Example 31 with Control

use of org.eclipse.swt.widgets.Control in project translationstudio8 by heartsome.

the class MultiCellEditDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite panel = new Composite(parent, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(panel);
    GridLayout panelLayout = new GridLayout(allowIncrementDecrement ? 2 : 1, false);
    panel.setLayout(panelLayout);
    if (allowIncrementDecrement) {
        createUpdateCombo(panel);
    }
    ActiveCellEditor.close();
    ActiveCellEditor.activate(cellEditor, panel, originalCanonicalValue, initialEditValue, dataTypeConverter, cellStyle, dataValidator, new MultiEditHandler(), 0, 0, 0, 0);
    Control editorControl = ActiveCellEditor.getControl();
    // propagate the ESC event from the editor to the dialog
    editorControl.addKeyListener(getEscKeyListener());
    final GridDataFactory layoutData = GridDataFactory.fillDefaults().grab(true, false).hint(100, 20);
    if (allowIncrementDecrement) {
        layoutData.indent(5, 0);
    }
    layoutData.applyTo(editorControl);
    return panel;
}
Also used : GridDataFactory(org.eclipse.jface.layout.GridDataFactory) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite)

Example 32 with Control

use of org.eclipse.swt.widgets.Control in project cogtool by cogtool.

the class ActionSet method createKeyComposite.

protected Composite createKeyComposite() {
    Composite keyComp = new Composite(actionSettings, SWT.NONE);
    keyComp.setLayout(new FormLayout());
    keyboardTextLabel = new DisplayLabel(keyComp, SWT.NONE);
    keyboardTextLabel.setText(L10N.get("DE.KeyboardTextCaption", "Text") + ":");
    keyboardText = createKeyboardText(keyComp);
    keyboardText.setFont(FontUtils.SYMBOL_FONT);
    keyboardIsCmd = new Button(keyComp, SWT.CHECK);
    keyboardIsCmd.setText(L10N.get("DE.IsCommand", "Is Command"));
    keyboardIsCmd.addSelectionListener(deviceActionChange);
    // TODO Why is this here rather than in its natural home in the
    //      overridden method in ActionPropertySet?
    transitionDestinationLabelKeyboard = createTransitionDestinationLabel(keyComp);
    transitionDestinationNameKeyboard = createTransitionDestinationName(keyComp);
    /* TODO: add back in when single character stuff is straightened out
        this.keyboardActionLabel = new DisplayLabel(keyComp, SWT.NONE);
        this.keyboardActionLabel.setText(L10N.get("DE.KeyActionCaption",
                                                  "Action")
                                            + ":");

        this.keyboardActionCombo =
            new ComboWithEnableFix(keyComp,
                                   SWT.DROP_DOWN | SWT.READ_ONLY);

        for (int i = 0; i < KeyPressType.DISPLAY.length; i++) {
            this.keyboardActionCombo.add(KeyPressType.DISPLAY[i].toString());
        }

        this.keyboardActionCombo.select(0);
        this.keyboardActionCombo.addSelectionListener(this.deviceActionChange);
*/
    SelectionListener insertSpecial = new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            Control source = (Control) e.getSource();
            keyboardText.insert((String) source.getData());
            Point selection = keyboardText.getSelection();
            keyboardText.setFocus();
            keyboardText.setSelection(selection);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    };
    // TODO: replace alignTo with this.keyboardActionCombo when the above TODO is done!
    // can't assign using ?: because Java is stupid
    Control alignTo;
    if (vertical) {
        alignTo = transitionDestinationNameKeyboard;
    } else {
        alignTo = keyboardText.getOuter();
    }
    keyboardSpecials = new KeyboardSpecialChars(alignTo, insertSpecial, vertical);
    return keyComp;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Point(org.eclipse.swt.graphics.Point) DisplayLabel(edu.cmu.cs.hcii.cogtool.util.DisplayLabel) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 33 with Control

use of org.eclipse.swt.widgets.Control in project cogtool by cogtool.

the class ProjectUI method cleanupTaskEditor.

/**
     * Removes stale Text control and selection listener.
     */
protected void cleanupTaskEditor() {
    // Remove and dispose the text box
    Control oldEditor = editor.getEditor();
    if (oldEditor != null) {
        // We defer this disposal until the main event loop as otherwise
        // we crash mysteriously in Leopard (OS X 10.5). The oldEditor
        // is actually a subclass (suspect for SWT controls!), and my
        // conjecture is that some method in the superclass is still
        // depending upon the object not having been disposed at it is
        // unwinding the stack. Anyway, this appears to fix the problem,
        // and certainly should make the patient no worse.
        WindowUtil.deferDisposal(oldEditor);
        editor.setEditor(null);
        setViewEnabledState(selection, ListenerIdentifierMap.NORMAL);
    }
}
Also used : Control(org.eclipse.swt.widgets.Control)

Example 34 with Control

use of org.eclipse.swt.widgets.Control in project cogtool by cogtool.

the class DefaultSEUIModel method updateDeviceDisplay.

public void updateDeviceDisplay() {
    if ((currentFrame != null) && (devicesFooter != null)) {
        Control[] deviceLabels = devicesFooter.getChildren();
        double midIndex = 0.5 * (deviceLabels.length - 1);
        for (int i = 0; i < deviceLabels.length; i++) {
            DeviceType deviceType = (DeviceType) deviceLabels[i].getData(DEVICE_TYPE_KEY);
            if (deviceType != null) {
                Frame currentFrameModel = currentFrame.getFrame();
                InputDevice inputDevice = currentFrameModel.getInputDevice(deviceType);
                String text = AbstractGraphicalSource.buildToolTipText(inputDevice, deviceType.toString());
                text = KeyDisplayUtil.convertActionToMenuText(text);
                deviceLabels[i].setToolTipText(" " + text + " ");
                deviceLabels[i].setData(inputDevice);
                FormData formData = new FormData();
                formData.top = new FormAttachment(0, 0);
                formData.bottom = new FormAttachment(100, 0);
                formData.width = DesignUtil.DEVICE_WIDTH;
                double ii = i;
                if (ii == (midIndex - 0.5)) {
                    formData.right = new FormAttachment(50, -(DEVICE_MARGIN / 2));
                } else if (ii < midIndex) {
                    formData.right = new FormAttachment(deviceLabels[i + 1], -DEVICE_MARGIN, SWT.LEFT);
                } else if (ii == midIndex) {
                    formData.left = new FormAttachment(50, -(DesignUtil.DEVICE_WIDTH / 2));
                } else if (ii == (midIndex + 0.5)) {
                    formData.left = new FormAttachment(50, DEVICE_MARGIN / 2);
                } else {
                    // ii > midIndex
                    formData.left = new FormAttachment(deviceLabels[i - 1], DEVICE_MARGIN, SWT.RIGHT);
                }
                deviceLabels[i].setLayoutData(formData);
            }
        }
        devicesFooter.layout();
    }
}
Also used : FormData(org.eclipse.swt.layout.FormData) DeviceType(edu.cmu.cs.hcii.cogtool.model.DeviceType) Control(org.eclipse.swt.widgets.Control) Frame(edu.cmu.cs.hcii.cogtool.model.Frame) InputDevice(edu.cmu.cs.hcii.cogtool.model.InputDevice) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 35 with Control

use of org.eclipse.swt.widgets.Control in project cogtool by cogtool.

the class DictionaryEditorUI method cleanupEditor.

/**
     * Removes stale Text control and selection listener.
     */
protected void cleanupEditor() {
    // Remove and dispose the text box
    Control oldEditor = editor.getEditor();
    if (oldEditor != null) {
        oldEditor.dispose();
        editor.setEditor(null);
    }
}
Also used : Control(org.eclipse.swt.widgets.Control)

Aggregations

Control (org.eclipse.swt.widgets.Control)475 Point (org.eclipse.swt.graphics.Point)149 Composite (org.eclipse.swt.widgets.Composite)141 GridData (org.eclipse.swt.layout.GridData)102 Button (org.eclipse.swt.widgets.Button)93 Label (org.eclipse.swt.widgets.Label)73 GridLayout (org.eclipse.swt.layout.GridLayout)71 Text (org.eclipse.swt.widgets.Text)70 FormData (org.eclipse.swt.layout.FormData)62 FormAttachment (org.eclipse.swt.layout.FormAttachment)61 Node (org.talend.designer.core.ui.editor.nodes.Node)46 DecoratedField (org.eclipse.jface.fieldassist.DecoratedField)45 SelectionEvent (org.eclipse.swt.events.SelectionEvent)44 StyledText (org.eclipse.swt.custom.StyledText)42 GC (org.eclipse.swt.graphics.GC)41 CLabel (org.eclipse.swt.custom.CLabel)38 ArrayList (java.util.ArrayList)36 Shell (org.eclipse.swt.widgets.Shell)35 FieldDecoration (org.eclipse.jface.fieldassist.FieldDecoration)33 CCombo (org.eclipse.swt.custom.CCombo)32