Search in sources :

Example 1 with ManagedText

use of edu.cmu.cs.hcii.cogtool.util.ManagedText in project cogtool by cogtool.

the class ResearchDialog method buildDialog.

@Override
public void buildDialog() {
    dialog.setLayout(new FormLayout());
    Button okButton = new Button(dialog, SWT.PUSH);
    okButton.setText(L10N.get("PREFDG.OK", "OK"));
    dialog.setDefaultButton(okButton);
    okButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            // TODO: updateValues() can throw IllegalStateException!
            userResponse = (updateValues() ? Boolean.TRUE : null);
            dialog.close();
        }
    });
    Button cancelButton = new Button(dialog, SWT.PUSH);
    cancelButton.setText(L10N.get("PREFDG.Cancel", "Cancel"));
    cancelButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            userResponse = null;
            dialog.close();
        }
    });
    Button restoreDefaultsButton = new Button(dialog, SWT.PUSH);
    restoreDefaultsButton.setText(L10N.get("PREFDG.RestoreDefaultsButton", "Reset to Default Values"));
    restoreDefaultsButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            restoreDefaults();
        }
    });
    allowResearchCmds = new Button(dialog, SWT.CHECK);
    allowResearchCmds.setText(L10N.get("PREFDG.Research", "Enable research commands"));
    allowResearchCmds.setSelection(CogToolPref.RESEARCH.getBoolean());
    allowResearchCmds.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            updateEnabled();
        }
    });
    useKeypad = new Button(dialog, SWT.CHECK);
    useKeypad.setText(L10N.get("FREFDG.UseKeypad", "Allow screen keyboard for text entry"));
    useKeypad.setSelection(CogToolPref.USE_KEYPAD.getBoolean());
    hcipaCheckbox = new Button(dialog, SWT.CHECK);
    hcipaCheckbox.setText(L10N.get("PREFDG.HCIPA", "HCIPA"));
    hcipaCheckbox.setSelection(CogToolPref.HCIPA.getBoolean());
    systemWaitVisionOnlyCheckbox = new Button(dialog, SWT.CHECK);
    systemWaitVisionOnlyCheckbox.setText(L10N.get("PREFDG.SYSWVO", "Mobile phone timings"));
    systemWaitVisionOnlyCheckbox.setSelection(CogToolPref.SYSWVO.getBoolean());
    enableComputeScriptsCheckbox = new Button(dialog, SWT.CHECK);
    enableComputeScriptsCheckbox.setText(L10N.get("PREFDG.COMPSCR", "Compute scripts on XML import"));
    enableComputeScriptsCheckbox.setSelection(CogToolPref.COMPSCR.getBoolean());
    generateThinksOnImportCheckbox = new Button(dialog, SWT.CHECK);
    generateThinksOnImportCheckbox.setText(L10N.get("PREFDG.GENSTEPS", "Generate implied Thinks on Import from XML"));
    generateThinksOnImportCheckbox.setSelection(CogToolPref.GENERATE_THINKS_ON_IMPORT.getBoolean());
    enableTracingCheckbox = new Button(dialog, SWT.CHECK);
    enableTracingCheckbox.setText(L10N.get("PREFDG.TRACE", "Emit ACT-R Traces"));
    enableTracingCheckbox.setSelection(CogToolPref.IS_TRACING.getBoolean());
    enableLoggingCheckbox = new Button(dialog, SWT.CHECK);
    enableLoggingCheckbox.setText(L10N.get("PREFDG.ENABLELOG", "Emit detailed log file"));
    enableLoggingCheckbox.setSelection(CogToolPref.IS_LOGGING.getBoolean());
    Label logDirectoryLabel = new Label(dialog, SWT.NONE);
    logDirectoryLabel.setText(L10N.get("PREFDG.LogDirectory", "Log file Directory:"));
    logDirectoryEntry = new ManagedText(dialog, SWT.BORDER, Keypad.FULL_KEYPAD);
    String directory = CogToolPref.LOG_DIRECTORY.getString();
    if (directory != null) {
        logDirectoryEntry.setText(directory);
    }
    Button logBrowseButton = new Button(dialog, SWT.PUSH);
    logBrowseButton.setText(L10N.get("PREFDG.ChooseLog", "Choose..."));
    logBrowseButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            String dir = interaction.askUserForDirectory("Log Files", "Choose the directory into which to write log files.");
            if (dir != null) {
                logDirectoryEntry.setText(dir);
            }
        }
    });
    useEMMACheckbox = new Button(dialog, SWT.CHECK);
    useEMMACheckbox.setText(L10N.get("PREFDG.EMMA", "Use EMMA to model vision"));
    useEMMACheckbox.setSelection(CogToolPref.USE_EMMA.getBoolean());
    Label actrDebugLevelLabel = new Label(dialog, SWT.NONE);
    actrDebugLevelLabel.setText(L10N.get("PREFDG.DEBUGLVL", "ACT-R debug level:"));
    actrDebugLevelCombo = new Combo(dialog, SWT.READ_ONLY);
    actrDebugLevelCombo.add("0");
    actrDebugLevelCombo.add("1");
    actrDebugLevelCombo.add("2");
    actrDebugLevelCombo.add("3");
    actrDebugLevelCombo.select(CogToolPref.ACTR_DEBUG_LEVEL.getInt());
    Label actrTimeoutLabel = new Label(dialog, SWT.NONE);
    actrTimeoutLabel.setText(L10N.get("PREFDG.ACTRTIMEOUT", "ACT-R timeout:"));
    actrTimeoutEntry = new IntegerEntry(dialog, SWT.BORDER);
    actrTimeoutEntry.setAllowNegative(false);
    actrTimeoutEntry.setValue(CogToolPref.ACTR_TIMEOUT.getInt());
    Label actrTimeoutUnitsLabel = new Label(dialog, SWT.NONE);
    actrTimeoutUnitsLabel.setText("msec");
    alternativeParametersCheckbox = new Button(dialog, SWT.CHECK);
    alternativeParametersCheckbox.setText(L10N.get("PREFDG.ALT_PARM", "Use alternative ACT-R parameters"));
    alternativeParametersCheckbox.setSelection(CogToolPref.ACTR_ALTERNATIVE_PARAMETERS.getBoolean());
    alternativeParametersCheckbox.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            updateEnabled();
        }
    });
    Label visualAttentionLabel = new Label(dialog, SWT.NONE);
    visualAttentionLabel.setText(L10N.get("PREFDG.VISATTN", "ACT-R Visual Attention:"));
    visualAttentionEntry = new IntegerEntry(dialog, SWT.BORDER);
    visualAttentionEntry.setAllowNegative(false);
    visualAttentionEntry.setValue(CogToolPref.VISUAL_ATTENTION.getInt());
    Label visualAttentionUnitsLabel = new Label(dialog, SWT.NONE);
    visualAttentionUnitsLabel.setText(String.format("msec (default %d)", CogToolPref.VISUAL_ATTENTION.getIntDefault()));
    Label motorInitiationLabel = new Label(dialog, SWT.NONE);
    motorInitiationLabel.setText(L10N.get("PREFDG.MOTORINIT", "ACT-R Motor Initiation:"));
    motorInitiationEntry = new IntegerEntry(dialog, SWT.BORDER);
    motorInitiationEntry.setAllowNegative(false);
    motorInitiationEntry.setValue(CogToolPref.MOTOR_INITIATION.getInt());
    Label motorInitiationUnitsLabel = new Label(dialog, SWT.NONE);
    motorInitiationUnitsLabel.setText(String.format("msec (default %d)", CogToolPref.MOTOR_INITIATION.getIntDefault()));
    Label peckFittsCoeffLabel = new Label(dialog, SWT.NONE);
    peckFittsCoeffLabel.setText(L10N.get("PREFDG.PECKFITTSCOEFF", "ACT-R peck Fitts coefficient:"));
    peckFittsCoeffEntry = new IntegerEntry(dialog, SWT.BORDER);
    peckFittsCoeffEntry.setAllowNegative(false);
    peckFittsCoeffEntry.setValue(CogToolPref.PECK_FITTS_COEFF.getInt());
    Label peckFittsCoeffUnitsLabel = new Label(dialog, SWT.NONE);
    peckFittsCoeffUnitsLabel.setText(String.format("msec (default %d)", CogToolPref.PECK_FITTS_COEFF.getIntDefault()));
    Label actrDATLabel = new Label(dialog, SWT.NONE);
    actrDATLabel.setText(L10N.get("PREFDG.DAT", "ACT-R dat:"));
    actrDATEntry = new IntegerEntry(dialog, SWT.BORDER);
    actrDATEntry.setAllowNegative(false);
    actrDATEntry.setValue(CogToolPref.ACTR_DAT.getInt());
    Label actrDATUnitsLabel = new Label(dialog, SWT.NONE);
    actrDATUnitsLabel.setText(String.format("msec (default %d)", CogToolPref.ACTR_DAT.getIntDefault()));
    cteSuppressNoiseCheckbox = new Button(dialog, SWT.CHECK);
    cteSuppressNoiseCheckbox.setText(L10N.get("PREFDG.CTE_SUPPRESS_NOISE", "Suppress noise in CogTool Explorer"));
    cteSuppressNoiseCheckbox.setSelection(CogToolPref.CTE_SUPPRESS_NOISE.getBoolean());
    cteSuppressNoninteractiveCheckbox = new Button(dialog, SWT.CHECK);
    cteSuppressNoninteractiveCheckbox.setText(L10N.get("PREFDG.CTE_SUPPRESS_NONINTERACTIVE", "Ignore non-interactive widgets with no display or auxilliary text in CogTool Explorer"));
    cteSuppressNoninteractiveCheckbox.setSelection(CogToolPref.CTE_SUPPRESS_NONINTERACTIVE.getBoolean());
    cteBackButtonSemantics = new Combo(dialog, SWT.READ_ONLY);
    cteBackButtonSemantics.add("Never go back");
    cteBackButtonSemantics.add("Use back button to go back");
    cteBackButtonSemantics.add("Go back implicitly");
    cteBackButtonSemantics.select(CogToolPref.CTE_BACK_BUTTON_SEMANTICS.getInt());
    Button cteBackButtonHelp = new Button(dialog, SWT.PUSH);
    cteBackButtonHelp.setText("?");
    cteBackButtonHelp.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            WindowUtil.presentInformationDialog(dialog, L10N.get("PREFDG.CTE_BACK_BUTTON_HELP_TITLE", "Back Button Help"), BACK_BUTTON_HELP_TEXT);
        }
    });
    Label cteBackButtonEntryLabel = new Label(dialog, SWT.NONE);
    cteBackButtonEntryLabel.setText(L10N.get("PREFDG.CTEBACKLABEL", "Back button label:"));
    cteBackButtonEntry = new ManagedText(dialog, (SWT.BORDER | SWT.MULTI | SWT.LEFT), Keypad.FULL_KEYPAD);
    cteBackButtonEntry.setText(CogToolPref.CTE_DEFAULT_BACK_LABEL.getString());
    Label pmiGSizeLabel = new Label(dialog, SWT.NONE);
    pmiGSizeLabel.setText(L10N.get("PREFDG.PMIGSIZE", "PMI-G size:"));
    pmiGSizeEntry = new DoubleEntry(dialog, SWT.BORDER);
    pmiGSizeEntry.setAllowNegative(false);
    double pmiGSize = CogToolPref.PMI_G_SIZE.getDouble();
    if (pmiGSize != CachedGoogleSimilarity.PMI_G_SIZE_AUTOMATIC) {
        pmiGSizeEntry.setValue((int) pmiGSize);
    }
    Label converterDirectoryLabel = new Label(dialog, SWT.NONE);
    converterDirectoryLabel.setText(L10N.get("PREFDG.ConverterDirectory", "Converter Directory:"));
    converterDirectoryEntry = new ManagedText(dialog, SWT.BORDER, Keypad.FULL_KEYPAD);
    //Set the text entry to be equal to the current specified directory
    directory = CogToolPref.CONVERTER_DIRECTORY.getString();
    if (directory != null) {
        converterDirectoryEntry.setText(directory);
    }
    Button convertBrowseButton = new Button(dialog, SWT.PUSH);
    convertBrowseButton.setText(L10N.get("PREFDG.ChooseConverter", "Choose..."));
    convertBrowseButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            String dir = interaction.askUserForDirectory("Import Converter Files", "Choose the directory that contains the converter files.");
            if (dir != null) {
                converterDirectoryEntry.setText(dir);
            }
        }
    });
    updateEnabled();
    FormData fd = new FormData();
    if (OSUtils.MACOSX) {
        fd.right = new FormAttachment(100, -18);
        fd.bottom = new FormAttachment(100, -10);
        okButton.setLayoutData(fd);
        fd = new FormData();
        fd.right = new FormAttachment(okButton, -8);
        fd.bottom = new FormAttachment(100, -10);
        cancelButton.setLayoutData(fd);
    } else {
        fd.left = new FormAttachment(50, -40);
        fd.bottom = new FormAttachment(100, -10);
        okButton.setLayoutData(fd);
        fd = new FormData();
        fd.left = new FormAttachment(okButton, 10);
        fd.bottom = new FormAttachment(100, -10);
        cancelButton.setLayoutData(fd);
    }
    fd = new FormData();
    fd.right = new FormAttachment(cancelButton, -108);
    fd.bottom = new FormAttachment(100, -10);
    restoreDefaultsButton.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(0, 20);
    fd.left = new FormAttachment(0, 20);
    allowResearchCmds.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(allowResearchCmds, 10);
    fd.left = new FormAttachment(0, 20);
    fd.right = new FormAttachment(100, -20);
    useKeypad.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(useKeypad, 10);
    fd.left = new FormAttachment(0, 20);
    hcipaCheckbox.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(hcipaCheckbox, 10);
    fd.left = new FormAttachment(0, 20);
    systemWaitVisionOnlyCheckbox.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(systemWaitVisionOnlyCheckbox, 15);
    fd.left = new FormAttachment(systemWaitVisionOnlyCheckbox, 0, SWT.LEFT);
    enableComputeScriptsCheckbox.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(enableComputeScriptsCheckbox, 15);
    fd.left = new FormAttachment(enableComputeScriptsCheckbox, 0, SWT.LEFT);
    generateThinksOnImportCheckbox.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(generateThinksOnImportCheckbox, 15);
    fd.left = new FormAttachment(generateThinksOnImportCheckbox, 0, SWT.LEFT);
    enableTracingCheckbox.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(enableTracingCheckbox, 15);
    fd.left = new FormAttachment(enableTracingCheckbox, 0, SWT.LEFT);
    enableLoggingCheckbox.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(enableLoggingCheckbox, 15);
    fd.left = new FormAttachment(enableLoggingCheckbox, 0, SWT.LEFT);
    logDirectoryLabel.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(logDirectoryLabel, 0, SWT.CENTER);
    fd.left = new FormAttachment(logDirectoryLabel, 5, SWT.RIGHT);
    fd.right = new FormAttachment(logDirectoryLabel, 305, SWT.RIGHT);
    logDirectoryEntry.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(logDirectoryEntry, 0, SWT.CENTER);
    fd.left = new FormAttachment(logDirectoryEntry, 5, SWT.RIGHT);
    logBrowseButton.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(logDirectoryLabel, 15);
    fd.left = new FormAttachment(logDirectoryLabel, 0, SWT.LEFT);
    useEMMACheckbox.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(useEMMACheckbox, 15);
    fd.left = new FormAttachment(useEMMACheckbox, 0, SWT.LEFT);
    actrDebugLevelLabel.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(actrDebugLevelLabel, 0, SWT.CENTER);
    fd.left = new FormAttachment(actrDebugLevelLabel, 5);
    actrDebugLevelCombo.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(actrDebugLevelLabel, 18);
    fd.left = new FormAttachment(actrDebugLevelLabel, 0, SWT.LEFT);
    actrTimeoutLabel.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(actrTimeoutLabel, 0, SWT.CENTER);
    fd.left = new FormAttachment(actrTimeoutLabel, 5);
    fd.right = new FormAttachment(actrTimeoutLabel, 80, SWT.RIGHT);
    actrTimeoutEntry.getOuter().setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(actrTimeoutLabel, 0, SWT.CENTER);
    fd.left = new FormAttachment(actrTimeoutEntry.getOuter(), 5);
    actrTimeoutUnitsLabel.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(actrTimeoutLabel, 18);
    fd.left = new FormAttachment(actrTimeoutLabel, 0, SWT.LEFT);
    alternativeParametersCheckbox.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(alternativeParametersCheckbox, 8);
    fd.left = new FormAttachment(alternativeParametersCheckbox, 215, SWT.LEFT);
    fd.right = new FormAttachment(alternativeParametersCheckbox, 265, SWT.LEFT);
    visualAttentionEntry.getOuter().setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(visualAttentionEntry.getOuter(), 0, SWT.CENTER);
    fd.right = new FormAttachment(visualAttentionEntry.getOuter(), -5, SWT.LEFT);
    visualAttentionLabel.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(visualAttentionEntry.getOuter(), 0, SWT.CENTER);
    fd.left = new FormAttachment(visualAttentionEntry.getOuter(), 5, SWT.RIGHT);
    visualAttentionUnitsLabel.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(visualAttentionEntry.getOuter(), 4);
    fd.left = new FormAttachment(visualAttentionEntry.getOuter(), 0, SWT.LEFT);
    fd.right = new FormAttachment(visualAttentionEntry.getOuter(), 0, SWT.RIGHT);
    motorInitiationEntry.getOuter().setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(motorInitiationEntry.getOuter(), 0, SWT.CENTER);
    fd.right = new FormAttachment(motorInitiationEntry.getOuter(), -5, SWT.LEFT);
    motorInitiationLabel.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(motorInitiationEntry.getOuter(), 0, SWT.CENTER);
    fd.left = new FormAttachment(motorInitiationEntry.getOuter(), 5, SWT.RIGHT);
    motorInitiationUnitsLabel.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(motorInitiationEntry.getOuter(), 4);
    fd.left = new FormAttachment(motorInitiationEntry.getOuter(), 0, SWT.LEFT);
    fd.right = new FormAttachment(motorInitiationEntry.getOuter(), 0, SWT.RIGHT);
    peckFittsCoeffEntry.getOuter().setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(peckFittsCoeffEntry.getOuter(), 0, SWT.CENTER);
    fd.right = new FormAttachment(peckFittsCoeffEntry.getOuter(), -5, SWT.LEFT);
    peckFittsCoeffLabel.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(peckFittsCoeffEntry.getOuter(), 0, SWT.CENTER);
    fd.left = new FormAttachment(peckFittsCoeffEntry.getOuter(), 5, SWT.RIGHT);
    peckFittsCoeffUnitsLabel.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(peckFittsCoeffEntry.getOuter(), 4);
    fd.left = new FormAttachment(peckFittsCoeffEntry.getOuter(), 0, SWT.LEFT);
    fd.right = new FormAttachment(peckFittsCoeffEntry.getOuter(), 0, SWT.RIGHT);
    actrDATEntry.getOuter().setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(actrDATEntry.getOuter(), 0, SWT.CENTER);
    fd.right = new FormAttachment(actrDATEntry.getOuter(), -5, SWT.LEFT);
    actrDATLabel.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(actrDATEntry.getOuter(), 0, SWT.CENTER);
    fd.left = new FormAttachment(actrDATEntry.getOuter(), 5, SWT.RIGHT);
    actrDATUnitsLabel.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(actrDATEntry.getOuter(), 18);
    fd.left = new FormAttachment(alternativeParametersCheckbox, 0, SWT.LEFT);
    cteSuppressNoiseCheckbox.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(cteSuppressNoiseCheckbox, 18);
    fd.left = new FormAttachment(cteSuppressNoiseCheckbox, 0, SWT.LEFT);
    fd.right = new FormAttachment(100, -35);
    cteSuppressNoninteractiveCheckbox.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(cteSuppressNoninteractiveCheckbox, 18);
    fd.left = new FormAttachment(cteSuppressNoninteractiveCheckbox, 0, SWT.LEFT);
    cteBackButtonSemantics.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(cteBackButtonSemantics, 8);
    fd.left = new FormAttachment(cteBackButtonEntryLabel, 5);
    fd.right = new FormAttachment(cteBackButtonEntryLabel, 180, SWT.RIGHT);
    fd.bottom = new FormAttachment(cteBackButtonSemantics, 110);
    cteBackButtonEntry.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(cteBackButtonEntry, 0, SWT.CENTER);
    fd.left = new FormAttachment(cteBackButtonSemantics, 30, SWT.LEFT);
    cteBackButtonEntryLabel.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(cteBackButtonSemantics, 0, SWT.CENTER);
    fd.left = new FormAttachment(cteBackButtonSemantics, 15, SWT.RIGHT);
    cteBackButtonHelp.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(cteBackButtonEntry, 24);
    fd.left = new FormAttachment(cteSuppressNoiseCheckbox, 0, SWT.LEFT);
    pmiGSizeLabel.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(pmiGSizeLabel, 0, SWT.CENTER);
    fd.left = new FormAttachment(pmiGSizeLabel, 5);
    fd.right = new FormAttachment(pmiGSizeLabel, 140, SWT.RIGHT);
    pmiGSizeEntry.getOuter().setLayoutData(fd);
    fd = new FormData();
    fd.left = new FormAttachment(pmiGSizeLabel, 0, SWT.LEFT);
    fd.top = new FormAttachment(pmiGSizeLabel, 18);
    converterDirectoryLabel.setLayoutData(fd);
    fd = new FormData();
    fd.left = new FormAttachment(converterDirectoryLabel, 5, SWT.RIGHT);
    fd.right = new FormAttachment(converterDirectoryLabel, 305, SWT.RIGHT);
    fd.top = new FormAttachment(converterDirectoryLabel, 0, SWT.CENTER);
    converterDirectoryEntry.setLayoutData(fd);
    fd = new FormData();
    fd.top = new FormAttachment(converterDirectoryEntry, 0, SWT.CENTER);
    fd.left = new FormAttachment(converterDirectoryEntry, 5, SWT.RIGHT);
    fd.right = new FormAttachment(okButton, 0, SWT.RIGHT);
    fd.bottom = new FormAttachment(okButton, -30);
    convertBrowseButton.setLayoutData(fd);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Listener(org.eclipse.swt.widgets.Listener) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) DoubleEntry(edu.cmu.cs.hcii.cogtool.util.DoubleEntry) Button(org.eclipse.swt.widgets.Button) ManagedText(edu.cmu.cs.hcii.cogtool.util.ManagedText) Event(org.eclipse.swt.widgets.Event) FormAttachment(org.eclipse.swt.layout.FormAttachment) IntegerEntry(edu.cmu.cs.hcii.cogtool.util.IntegerEntry)

Example 2 with ManagedText

use of edu.cmu.cs.hcii.cogtool.util.ManagedText in project cogtool by cogtool.

the class ProjectUI method initiateTaskRename.

// initiateTaskRename
/**
     * Triggers the task-renaming functionality in the UI on the given
     * TreeItem's AUndertaking.
     */
public void initiateTaskRename(TreeItem taskToRenameItem, boolean selectAll) {
    // Can progress only if no other rename is already in progress
    if ((editor.getEditor() == null) && (taskToRenameItem != null)) {
        // Ensure the selection is set properly so it looks right when done
        selection.setSelectedItem(taskToRenameItem);
        final AUndertaking task = (AUndertaking) taskToRenameItem.getData();
        // The editor must have the same size as the cell.
        editor.horizontalAlignment = SWT.LEFT;
        editor.grabHorizontal = true;
        // The control that will be the editor must be a child of the Tree
        ManagedText newEditor = new ManagedText(tree, SWT.SINGLE | SWT.LEFT, Keypad.FULL_KEYPAD) {

            @Override
            public boolean confirm(int focusRule) {
                return commitRenameTask(true);
            }

            @Override
            public void cancel() {
                cleanupTaskEditor();
            }
        };
        newEditor.setFocus();
        String taskName = task.getName();
        int nameLength = taskName.length();
        newEditor.setText(taskName);
        if (selectAll) {
            newEditor.selectAll();
        } else {
            newEditor.setSelection(nameLength, nameLength);
        }
        editor.setEditor(newEditor, taskToRenameItem);
        setViewEnabledState(selection, ListenerIdentifierMap.NORMAL);
    }
}
Also used : AUndertaking(edu.cmu.cs.hcii.cogtool.model.AUndertaking) ManagedText(edu.cmu.cs.hcii.cogtool.util.ManagedText) Point(org.eclipse.swt.graphics.Point)

Example 3 with ManagedText

use of edu.cmu.cs.hcii.cogtool.util.ManagedText in project cogtool by cogtool.

the class SWTMouseState method dealWithEvent.

// Force subclasses to implement the "dealWith" versions
protected void dealWithEvent(Event evt) {
    // if on Windows, handle contextual menu key
    if (evt.type == SWT.MenuDetect) {
        // isMenuClick true means a right-click; need location!
        if (OSUtils.MACOSX || isMenuClick) {
            Control c = (Control) evt.widget;
            Text focusedText = WindowUtil.getFocusedText();
            if (focusedText != null) {
                if (focusedText instanceof ManagedText) {
                    ManagedText txt = (ManagedText) focusedText;
                    if (!txt.confirm(ManagedText.LOSE_FOCUS)) {
                        return;
                    }
                }
                c.forceFocus();
            }
            Combo focusedCombo = WindowUtil.getFocusedCombo();
            if (focusedCombo != null) {
                if (focusedCombo instanceof ManagedCombo) {
                    ManagedCombo combo = (ManagedCombo) focusedCombo;
                    if (!combo.confirm(ManagedCombo.LOSE_FOCUS)) {
                        return;
                    }
                }
                c.forceFocus();
            }
            Point p = c.toControl(evt.x, evt.y);
            menuUI.showContextMenu(p.x, p.y);
        } else {
            menuUI.showContextMenu();
        }
    }
}
Also used : Control(org.eclipse.swt.widgets.Control) ManagedCombo(edu.cmu.cs.hcii.cogtool.util.ManagedCombo) ManagedText(edu.cmu.cs.hcii.cogtool.util.ManagedText) Text(org.eclipse.swt.widgets.Text) ManagedText(edu.cmu.cs.hcii.cogtool.util.ManagedText) Combo(org.eclipse.swt.widgets.Combo) ManagedCombo(edu.cmu.cs.hcii.cogtool.util.ManagedCombo) Point(org.eclipse.swt.graphics.Point)

Example 4 with ManagedText

use of edu.cmu.cs.hcii.cogtool.util.ManagedText in project cogtool by cogtool.

the class ActionChangePropertySet method layoutHelper.

@Override
public void layoutHelper() {
    actionComposite = new Composite(parent, SWT.NONE);
    actionComposite.setLayout(new RowLayout(SWT.HORIZONTAL));
    FormData data = new FormData();
    data.left = leftAttachment;
    data.top = new FormAttachment(0, 5);
    actionComposite.setLayoutData(data);
    actionSettings = new Composite(parent, SWT.BORDER);
    actionSettings.setLayout(actionSettingsLayout);
    data = new FormData();
    data.left = leftAttachment;
    data.top = new FormAttachment(actionComposite, 5, SWT.BOTTOM);
    data.right = new FormAttachment(100, -5);
    actionSettings.setLayoutData(data);
    Label delayLabelLabel = new DisplayLabel(parent, SWT.NONE);
    delayLabelLabel.setText(DELAY_LABEL_LABEL);
    delayLabel = new ManagedText(parent, SWT.SINGLE | SWT.BORDER, Keypad.FULL_KEYPAD) {

        @Override
        public boolean confirm(int focusRule) {
            if ("".equals(getText())) {
                setText(TransitionDelay.DEFAULT_DELAY_LABEL);
            }
            return super.confirm(focusRule);
        }
    };
    Label delayInSecsLabel = new DisplayLabel(parent, SWT.NONE);
    delayInSecsLabel.setText(DELAY_DURATION_LABEL + ":");
    delayInSecs = new DoubleEntry(parent, SWT.SINGLE | SWT.BORDER) {

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

        @Override
        public boolean confirm(int focusRule) {
            boolean success = super.confirm(focusRule);
            if (getDoubleValue() == 0.0) {
                setText("");
            }
            return success;
        }
    };
    delayInSecs.setAllowNegative(false);
    delayInSecs.setDecimalPlaces(3);
    delayInSecs.setUnits("s");
    delayInSecs.moveAbove(delayLabel.getOuter());
    data = new FormData();
    data.left = new FormAttachment(actionSettings, 5, SWT.LEFT);
    data.top = new FormAttachment(delayInSecs.getOuter(), 0, SWT.CENTER);
    delayInSecsLabel.setLayoutData(data);
    data = new FormData();
    data.left = new FormAttachment(delayInSecsLabel, 5, SWT.RIGHT);
    data.width = 100;
    data.top = new FormAttachment(actionSettings, 5, SWT.BOTTOM);
    delayInSecs.setLayoutData(data);
    data = new FormData();
    data.left = new FormAttachment(delayInSecs.getOuter(), 5, SWT.RIGHT);
    data.top = new FormAttachment(delayInSecs.getOuter(), 0, SWT.CENTER);
    delayLabelLabel.setLayoutData(data);
    data = new FormData();
    data.left = new FormAttachment(delayLabelLabel, 5, SWT.RIGHT);
    data.top = new FormAttachment(delayInSecs.getOuter(), 0, SWT.CENTER);
    data.right = new FormAttachment(actionSettings, -5, SWT.RIGHT);
    delayLabel.setLayoutData(data);
}
Also used : FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) RowLayout(org.eclipse.swt.layout.RowLayout) ManagedText(edu.cmu.cs.hcii.cogtool.util.ManagedText) DisplayLabel(edu.cmu.cs.hcii.cogtool.util.DisplayLabel) Label(org.eclipse.swt.widgets.Label) DoubleEntry(edu.cmu.cs.hcii.cogtool.util.DoubleEntry) FormAttachment(org.eclipse.swt.layout.FormAttachment) DisplayLabel(edu.cmu.cs.hcii.cogtool.util.DisplayLabel)

Example 5 with ManagedText

use of edu.cmu.cs.hcii.cogtool.util.ManagedText in project cogtool by cogtool.

the class WidgetPropertiesPane method layOutWidgets.

protected void layOutWidgets() {
    // Set up the layouts
    // lay out the area using a form layout.
    // name and type are on the same line
    // label and shape are on the same line
    // since display label is longer then widget name, align text boxes to it.
    // have buttons appear in a column on the bottom.
    FormData data = new FormData();
    data.left = new FormAttachment(0, 5);
    data.top = new FormAttachment(0, 5);
    widgetName.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(widgetName, 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    data.right = new FormAttachment(100, -10);
    widgetNameText.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(widgetNameText.getOuter(), 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    widgetTitle.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(widgetTitle, 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    data.right = new FormAttachment(100, -10);
    widgetTitleText.setLayoutData(data);
    ManagedText lastText = widgetTitleText;
    if (CogToolPref.RESEARCH.getBoolean()) {
        data = new FormData();
        data.top = new FormAttachment(widgetTitleText.getOuter(), 5);
        data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
        widgetAux.setLayoutData(data);
        data = new FormData();
        data.top = new FormAttachment(widgetAux, 5);
        data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
        data.right = new FormAttachment(100, -10);
        widgetAuxText.setLayoutData(data);
        lastText = widgetAuxText;
    } else {
        widgetAux.setVisible(false);
        widgetAuxText.setVisible(false);
    }
    data = new FormData();
    data.top = new FormAttachment(widgetTypeLabel, 0, SWT.CENTER);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    widgetType.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(lastText.getOuter(), 5);
    data.left = new FormAttachment(widgetType, 3);
    data.right = new FormAttachment(100, -5);
    widgetTypeLabel.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(widgetModeValue, 0, SWT.CENTER);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    widgetMode.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(widgetTypeLabel, 5);
    data.left = new FormAttachment(widgetMode, 5, SWT.RIGHT);
    data.right = new FormAttachment(100, 0);
    widgetModeValue.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(widgetModeValue, 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    widgetRender.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(widgetRender, 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    remoteLabel.setLayoutData(data);
    data = new FormData();
    data.bottom = new FormAttachment(remoteLabel, -3, SWT.BOTTOM);
    data.left = new FormAttachment(remoteLabel, 5, SWT.RIGHT);
    data.right = new FormAttachment(100, -10);
    remoteLabelFind.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(remoteLabel, 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    data.right = new FormAttachment(100, -10);
    remoteLabelText.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(widgetRender, 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    remoteLabelOwner.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(remoteLabelOwner, 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    data.right = new FormAttachment(100, -10);
    remoteLabelOwnerName.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(remoteLabelOwnerName, 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    remoteLabelType.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(remoteLabelType, 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    data.right = new FormAttachment(100, -10);
    remoteLabelTypeCombo.setLayoutData(data);
    noRemoteLabelAlign = new FormData();
    noRemoteLabelAlign.top = new FormAttachment(widgetRender, 5, SWT.BOTTOM);
    noRemoteLabelAlign.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    imagePath.setLayoutData(noRemoteLabelAlign);
    hasRemoteLabelAlign = new FormData();
    hasRemoteLabelAlign.top = new FormAttachment(remoteLabelText.getOuter(), 5, SWT.BOTTOM);
    hasRemoteLabelAlign.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    isRemoteLabelAlign = new FormData();
    isRemoteLabelAlign.top = new FormAttachment(remoteLabelTypeCombo, 5, SWT.BOTTOM);
    isRemoteLabelAlign.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    data = new FormData();
    data.top = new FormAttachment(imagePath, 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    data.right = new FormAttachment(100, -5);
    imagePathText.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(imagePathText, 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    data.right = new FormAttachment(imagePathText, 0, SWT.RIGHT);
    isInitiallySelected.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(imagePathText, 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    data.right = new FormAttachment(imagePathText, 0, SWT.RIGHT);
    isToggleable.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(isToggleable, 5);
    data.left = new FormAttachment(widgetName, 10, SWT.LEFT);
    data.right = new FormAttachment(isToggleable, 0, SWT.RIGHT);
    isButtonSelected.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(imagePathText, 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    data.right = new FormAttachment(imagePathText, 0, SWT.RIGHT);
    selectLabel.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(selectLabel, 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    data.right = new FormAttachment(selectLabel, 0, SWT.RIGHT);
    initiallySelected.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(lastText.getOuter(), 5);
    data.left = new FormAttachment(100, -85);
    data.right = new FormAttachment(100, 0);
    isSeparator.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(imagePathText, 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    data.right = new FormAttachment(widgetNameText.getOuter(), 0, SWT.RIGHT);
    submenuActionLabel.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(submenuActionLabel, 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    data.right = new FormAttachment(widgetNameText.getOuter(), 0, SWT.RIGHT);
    submenuAction.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(submenuAction, 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    data.right = new FormAttachment(widgetNameText.getOuter(), 0, SWT.RIGHT);
    submenuDelayLabel.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(submenuDelayLabel, 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    data.right = new FormAttachment(widgetNameText.getOuter(), 0, SWT.RIGHT);
    submenuDelay.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(submenuDelay, 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    data.right = new FormAttachment(widgetNameText.getOuter(), 0, SWT.RIGHT);
    contextMenuActionLabel.setLayoutData(data);
    data = new FormData();
    data.top = new FormAttachment(contextMenuActionLabel, 5);
    data.left = new FormAttachment(widgetName, 0, SWT.LEFT);
    data.right = new FormAttachment(widgetNameText.getOuter(), 0, SWT.RIGHT);
    contextMenuAction.setLayoutData(data);
}
Also used : FormData(org.eclipse.swt.layout.FormData) ManagedText(edu.cmu.cs.hcii.cogtool.util.ManagedText) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

ManagedText (edu.cmu.cs.hcii.cogtool.util.ManagedText)6 Point (org.eclipse.swt.graphics.Point)3 FormAttachment (org.eclipse.swt.layout.FormAttachment)3 FormData (org.eclipse.swt.layout.FormData)3 Combo (org.eclipse.swt.widgets.Combo)3 DoubleEntry (edu.cmu.cs.hcii.cogtool.util.DoubleEntry)2 ManagedCombo (edu.cmu.cs.hcii.cogtool.util.ManagedCombo)2 Label (org.eclipse.swt.widgets.Label)2 Text (org.eclipse.swt.widgets.Text)2 AUndertaking (edu.cmu.cs.hcii.cogtool.model.AUndertaking)1 DisplayLabel (edu.cmu.cs.hcii.cogtool.util.DisplayLabel)1 IntegerEntry (edu.cmu.cs.hcii.cogtool.util.IntegerEntry)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 RowLayout (org.eclipse.swt.layout.RowLayout)1 Button (org.eclipse.swt.widgets.Button)1 Canvas (org.eclipse.swt.widgets.Canvas)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1