Search in sources :

Example 1 with ActionChangePropertySet

use of edu.cmu.cs.hcii.cogtool.view.ActionChangePropertySet 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)

Aggregations

AAction (edu.cmu.cs.hcii.cogtool.model.AAction)1 Transition (edu.cmu.cs.hcii.cogtool.model.Transition)1 ActionChangePropertySet (edu.cmu.cs.hcii.cogtool.view.ActionChangePropertySet)1 GridData (org.eclipse.swt.layout.GridData)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1