Search in sources :

Example 11 with FormAttachment

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

the class ActionPropertySet method layoutHelper.

@Override
public void layoutHelper() {
    actionSettings = new Composite(parent, SWT.BORDER);
    actionSettings.setLayout(actionSettingsLayout);
    propLabel = new Label(parent, SWT.CENTER);
    propLabel.setText(designPropertiesLabel);
    Font labelFont = FontUtils.getAdjustedFont(propLabel.getFont(), SWT.BOLD);
    propLabel.setFont(labelFont);
    actionType = new DisplayLabel(parent, SWT.NONE);
    actionType.setText(actionTypeLabel);
    actionChoices = new ComboWithEnableFix(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
    actionChoices.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent evt) {
            int currentSelection = actionChoices.getSelectionIndex();
            if (currentSelection != chosenActionType) {
                editTransitionParms.useWhichParts = choiceUseIndexes[currentSelection];
                chosenActionType = currentSelection;
                view.performAction(DesignEditorLID.EditTransition, editTransitionParms, true);
            }
        }
    });
    delayLabelLabel = new DisplayLabel(parent, SWT.NONE);
    delayLabelLabel.setText(DELAY_LABEL_LABEL);
    delayLabel = new View.PerformActionText(parent, SWT.SINGLE | SWT.BORDER) {

        @Override
        protected void onFocus() {
            super.onFocus();
            view.getTransmuter().setLIDEnabledState();
        }

        @Override
        protected boolean doChangeAction() {
            Point labelSelection = getSelection();
            if ("".equals(getText())) {
                setText(TransitionDelay.DEFAULT_DELAY_LABEL);
                labelSelection = null;
            }
            if (view.performAction(DesignEditorLID.ChangeDelay)) {
                if (labelSelection != null) {
                    setSelection(labelSelection);
                }
                return true;
            }
            return false;
        }
    };
    delayInSecsLabel = new DisplayLabel(parent, SWT.NONE);
    delayInSecsLabel.setText(DELAY_DURATION_LABEL + ":");
    secondsUnit = new Label(parent, SWT.NONE);
    secondsUnit.setText(SECONDS);
    delayInSecs = new View.PerformActionDouble(parent, SWT.SINGLE | SWT.BORDER) {

        @Override
        protected void onFocus() {
            super.onFocus();
            view.getTransmuter().setLIDEnabledState();
        }

        @Override
        protected void onModify() {
            super.onModify();
            delayLabel.setEnabled(getDoubleValue() > 0.0);
        }

        @Override
        protected boolean doChangeAction() {
            Point delaySelection = getSelection();
            if (getDoubleValue() == 0.0) {
                setText("");
                delaySelection = null;
            }
            if (view.performAction(DesignEditorLID.ChangeDelay)) {
                if (delaySelection != null) {
                    setSelection(delaySelection);
                }
                return true;
            }
            return false;
        }
    };
    delayInSecs.setAllowNegative(false);
    delayInSecs.setDecimalPlaces(3);
    delayInSecs.moveAbove(delayLabel.getOuter());
    FormData data = new FormData();
    data.left = leftAttachment;
    data.right = new FormAttachment(100, -5);
    propLabel.setLayoutData(data);
    data = new FormData();
    data.left = leftAttachment;
    data.top = new FormAttachment(actionChoices, 0, SWT.CENTER);
    actionType.setLayoutData(data);
    data = new FormData();
    data.left = new FormAttachment(actionType, 5, SWT.RIGHT);
    data.right = new FormAttachment(100, -5);
    data.top = new FormAttachment(propLabel, 5, SWT.BOTTOM);
    actionChoices.setLayoutData(data);
    data = new FormData();
    data.left = leftAttachment;
    data.top = new FormAttachment(actionChoices, 5, SWT.BOTTOM);
    data.right = new FormAttachment(100, -5);
    actionSettings.setLayoutData(data);
    data = new FormData();
    data.left = leftAttachment;
    data.top = new FormAttachment(actionSettings, 5, SWT.BOTTOM);
    delayInSecsLabel.setLayoutData(data);
    data = new FormData();
    data.left = leftAttachment;
    data.top = new FormAttachment(delayInSecsLabel, 5, SWT.BOTTOM);
    data.width = 100;
    delayInSecs.setLayoutData(data);
    data = new FormData();
    data.left = new FormAttachment(delayInSecs.getOuter(), 5, SWT.RIGHT);
    data.top = new FormAttachment(delayInSecs.getOuter(), 0, SWT.CENTER);
    secondsUnit.setLayoutData(data);
    data = new FormData();
    data.left = leftAttachment;
    data.top = new FormAttachment(delayInSecs.getOuter(), 5, SWT.BOTTOM);
    delayLabelLabel.setLayoutData(data);
    data = new FormData();
    data.left = leftAttachment;
    data.top = new FormAttachment(delayLabelLabel, 5, SWT.BOTTOM);
    data.right = new FormAttachment(100, -5);
    delayLabel.setLayoutData(data);
    emptyParms = createEmptyComposite();
    layOutEmptyComposite();
    multTransParms = new Composite(actionSettings, SWT.NONE);
    multTransParms.setLayout(new FormLayout());
    Label multTransLabel = new Label(multTransParms, SWT.WRAP);
    multTransLabel.setText(noActionAvailableText);
    data = new FormData();
    data.left = leftAttachment;
    data.top = new FormAttachment(0, 5);
    data.right = new FormAttachment(100, -5);
    multTransLabel.setLayoutData(data);
    frameParms = createFrameComposite();
}
Also used : FormData(org.eclipse.swt.layout.FormData) FormLayout(org.eclipse.swt.layout.FormLayout) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) DisplayLabel(edu.cmu.cs.hcii.cogtool.util.DisplayLabel) Label(org.eclipse.swt.widgets.Label) Point(org.eclipse.swt.graphics.Point) Font(org.eclipse.swt.graphics.Font) DisplayLabel(edu.cmu.cs.hcii.cogtool.util.DisplayLabel) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ComboWithEnableFix(edu.cmu.cs.hcii.cogtool.util.ComboWithEnableFix) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 12 with FormAttachment

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

the class FrameEditorView method layOutPropertiesPane.

/**
     * Layout the properties pane, with the specific list of device types
     * and the parent to lay them out in.
     */
protected void layOutPropertiesPane(int deviceTypes, Composite pane) {
    pane.setLayout(new FormLayout());
    actionSettings = new Composite(pane, SWT.BORDER);
    actionSettings.setLayout(actionSettingsLayout);
    frameParms = new FramePropertiesPane(actionSettings, SWT.NONE, this);
    widgetParms = new WidgetPropertiesPane(actionSettings, SWT.NONE, this);
    eltGroupParms = new EltGroupPropertiesPane(actionSettings, SWT.NONE, this);
    propLabel = new Label(pane, SWT.CENTER);
    propLabel.setText(FRAME_PROPERTIES);
    Font labelFont = FontUtils.getAdjustedFont(propLabel.getFont(), SWT.BOLD);
    propLabel.setFont(labelFont);
    FormData data = new FormData();
    data.right = new FormAttachment(100, -5);
    data.left = new FormAttachment(0, 5);
    data.top = new FormAttachment(0, 5);
    propLabel.setLayoutData(data);
    data = new FormData();
    data.left = new FormAttachment(0, 5);
    data.top = new FormAttachment(propLabel, 5, SWT.BOTTOM);
    data.right = new FormAttachment(100, -5);
    actionSettings.setLayoutData(data);
    // To get N/A set
    setWidgetName(null);
    // To get N/A set
    setWidgetTitle(null);
    // To get N/A set
    setWidgetAuxText(null);
    widgetParms.hideAttributeWidgets();
    widgetParms.setParameterChoices(deviceTypes);
    actionSettingsLayout.topControl = frameParms;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Font(org.eclipse.swt.graphics.Font) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 13 with FormAttachment

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

the class FramePropertiesPane method layOutWidgets.

protected void layOutWidgets() {
    FormAttachment leftAttachment = new FormAttachment(0, 5);
    FormData data = new FormData();
    data.top = new FormAttachment(0, 5);
    data.left = leftAttachment;
    frameNameLabel.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(frameNameLabel, 5, SWT.BOTTOM);
    data.left = leftAttachment;
    data.right = new FormAttachment(100, -5);
    frameName.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(frameName.getOuter(), 5);
    data.left = leftAttachment;
    imagePath.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(imagePath, 5);
    data.left = leftAttachment;
    data.right = new FormAttachment(100, -5);
    imagePathText.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(imagePathText, 5, SWT.BOTTOM);
    data.left = leftAttachment;
    widgetTreeLabel.setLayoutData(data);
    int rowCount = (eltGroupTreeLabel != null) ? 12 : 16;
    data = new FormData();
    data.top = new FormAttachment(widgetTreeLabel, 5, SWT.BOTTOM);
    data.left = leftAttachment;
    data.right = new FormAttachment(frameName.getOuter(), 0, SWT.RIGHT);
    data.height = (rowCount * 19) - 1;
    widgetTree.setLayoutData(data);
    if (eltGroupTreeLabel != null) {
        data = new FormData();
        data.top = new FormAttachment(widgetTree, 5, SWT.BOTTOM);
        data.left = leftAttachment;
        eltGroupTreeLabel.setLayoutData(data);
        data = new FormData();
        data.top = new FormAttachment(eltGroupTreeLabel, 5, SWT.BOTTOM);
        data.left = leftAttachment;
        data.right = new FormAttachment(frameName.getOuter(), 0, SWT.RIGHT);
        data.height = 68;
        eltGroupTree.setLayoutData(data);
        data = new FormData();
        data.top = new FormAttachment(eltGroupTree, 5, SWT.BOTTOM);
        data.left = leftAttachment;
        implicitGroupTreeLabel.setLayoutData(data);
        data = new FormData();
        data.top = new FormAttachment(implicitGroupTreeLabel, 5, SWT.BOTTOM);
        data.left = leftAttachment;
        data.right = new FormAttachment(frameName.getOuter(), 0, SWT.RIGHT);
        data.height = 68;
        implicitGroupTree.setLayoutData(data);
    }
}
Also used : FormData(org.eclipse.swt.layout.FormData) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 14 with FormAttachment

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

the class ActionPropertySet method layOutKeyboardComposite.

@Override
public void layOutKeyboardComposite() {
    // Align checkbox 5 pixels from the left edge
    FormData data = new FormData();
    data.top = new FormAttachment(keyboardText.getOuter(), 5);
    data.left = leftAttachment;
    keyboardIsCmd.setLayoutData(data);
    // Attach label to 5 pixels from the properties left
    data = new FormData();
    data.top = new FormAttachment(0, 5);
    data.left = leftAttachment;
    keyboardTextLabel.setLayoutData(data);
    // Attach device command text to 5 pixels below the text label
    // Attach right of combo to 5 before the edge
    // Align left with the acceptable key label
    data = new FormData();
    data.top = new FormAttachment(keyboardTextLabel, 5);
    data.left = new FormAttachment(keyboardTextLabel, 0, SWT.LEFT);
    data.right = new FormAttachment(100, -5);
    keyboardText.setLayoutData(data);
    data = new FormData();
    data.left = leftAttachment;
    data.top = new FormAttachment(transitionDestinationNameKeyboard, 0, SWT.CENTER);
    transitionDestinationLabelKeyboard.setLayoutData(data);
    data = new FormData();
    data.left = new FormAttachment(transitionDestinationLabelKeyboard, 5, SWT.RIGHT);
    data.right = new FormAttachment(100, -5);
    data.top = new FormAttachment(keyboardIsCmd, 5);
    transitionDestinationNameKeyboard.setLayoutData(data);
    transitionDestinationNameKeyboard.setVisible(true);
    if (keyboardActionCombo != null) {
        // Attach key action label to 5 pixels from the properties left
        // Add some extra white space between this label and the checkbox
        data = new FormData();
        data.top = new FormAttachment(transitionDestinationNameKeyboard, 20);
        data.left = new FormAttachment(keyboardTextLabel, 0, SWT.LEFT);
        keyboardActionLabel.setLayoutData(data);
        // Attach key action combo with device command text
        // Attach key action combo to 5 pixels below the action label
        // Attach right of combo to end of the properties space
        data = new FormData();
        data.top = new FormAttachment(keyboardActionLabel, 5);
        data.left = new FormAttachment(keyboardTextLabel, 0, SWT.LEFT);
        data.right = new FormAttachment(100, -5);
        keyboardActionCombo.setLayoutData(data);
    }
    SelectionListener setResetListener = new SetResetDefaultsListener(setAsDefaultKeyboard, restoreDefaultsKeyboard) {

        @Override
        protected boolean haveValuesChanged() {
            return isKeyboardChanged(originalProperties);
        }

        @Override
        protected void enableDefaultButtons(boolean isReset) {
            boolean defaultChanged = isKeyboardChanged(defaultProperties);
            setAsDefaults.setEnabled(defaultChanged);
            resetDefaults.setEnabled((!isReset) && haveValuesChanged());
        }

        @Override
        protected void setDefaults(boolean isReset) {
            String cmd = isReset ? originalProperties.keyboardString : getKeyboardString();
            setKeyboardDefaults(getKeyboardPressType(), cmd, isKeyboardCmd());
        }

        @Override
        protected void resetDefaults() {
            resetKeyboard();
        }
    };
    addDefaultButtons(keyboardParms, keyboardSpecials.DOWN, setAsDefaultKeyboard, restoreDefaultsKeyboard, setResetListener);
}
Also used : FormData(org.eclipse.swt.layout.FormData) FormAttachment(org.eclipse.swt.layout.FormAttachment) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 15 with FormAttachment

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

the class ActionPropertySet method layOutTouchComposite.

@Override
public void layOutTouchComposite() {
    // Attach button action label to 5 pixels from the properties left
    FormData data = new FormData();
    data.top = new FormAttachment(touchActionCombo, 0, SWT.CENTER);
    data.left = leftAttachment;
    touchActionLabel.setLayoutData(data);
    // Attach button action combo 5 below the label
    data = new FormData();
    data.top = new FormAttachment(0, 5);
    data.left = new FormAttachment(touchActionLabel, 5, SWT.RIGHT);
    data.right = new FormAttachment(100, -5);
    touchActionCombo.setLayoutData(data);
    SelectionListener setResetListener = new SetResetDefaultsListener(setAsDefaultTouch, restoreDefaultsTouch) {

        @Override
        protected boolean haveValuesChanged() {
            return isTouchChanged(originalProperties);
        }

        @Override
        protected void setDefaults(boolean isReset) {
            setTouchDefaults(getTapPressType());
        }

        @Override
        protected void resetDefaults() {
            resetTouch();
        }
    };
    data = new FormData();
    data.left = leftAttachment;
    data.top = new FormAttachment(transitionSourceNameTouch, 0, SWT.CENTER);
    transitionSourceLabelTouch.setLayoutData(data);
    transitionSourceLabelTouch.setVisible(true);
    data = new FormData();
    data.left = new FormAttachment(transitionDestinationLabelTouch, 5, SWT.RIGHT);
    data.right = new FormAttachment(100, -5);
    data.top = new FormAttachment(touchActionCombo, 5);
    transitionSourceNameTouch.setLayoutData(data);
    transitionSourceNameTouch.setVisible(true);
    data = new FormData();
    data.left = leftAttachment;
    data.top = new FormAttachment(transitionDestinationNameTouch, 0, SWT.CENTER);
    transitionDestinationLabelTouch.setLayoutData(data);
    transitionDestinationLabelTouch.setVisible(true);
    data = new FormData();
    data.left = new FormAttachment(transitionDestinationLabelTouch, 5, SWT.RIGHT);
    data.right = new FormAttachment(100, -5);
    data.top = new FormAttachment(transitionSourceNameTouch, 5);
    transitionDestinationNameTouch.setLayoutData(data);
    transitionDestinationNameTouch.setVisible(true);
    addDefaultButtons(touchParms, transitionDestinationNameTouch, setAsDefaultTouch, restoreDefaultsTouch, setResetListener);
}
Also used : FormData(org.eclipse.swt.layout.FormData) FormAttachment(org.eclipse.swt.layout.FormAttachment) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

FormAttachment (org.eclipse.swt.layout.FormAttachment)228 FormData (org.eclipse.swt.layout.FormData)228 Point (org.eclipse.swt.graphics.Point)87 Button (org.eclipse.swt.widgets.Button)85 Composite (org.eclipse.swt.widgets.Composite)83 FormLayout (org.eclipse.swt.layout.FormLayout)78 Control (org.eclipse.swt.widgets.Control)57 CLabel (org.eclipse.swt.custom.CLabel)56 SelectionEvent (org.eclipse.swt.events.SelectionEvent)55 Node (org.talend.designer.core.ui.editor.nodes.Node)49 Label (org.eclipse.swt.widgets.Label)47 GC (org.eclipse.swt.graphics.GC)46 Text (org.eclipse.swt.widgets.Text)39 DecoratedField (org.eclipse.jface.fieldassist.DecoratedField)36 SelectionListener (org.eclipse.swt.events.SelectionListener)36 FieldDecoration (org.eclipse.jface.fieldassist.FieldDecoration)34 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)32 GridData (org.eclipse.swt.layout.GridData)32 GridLayout (org.eclipse.swt.layout.GridLayout)28 Group (org.eclipse.swt.widgets.Group)26