Search in sources :

Example 1 with CogToolPref

use of edu.cmu.cs.hcii.cogtool.CogToolPref in project cogtool by cogtool.

the class ProjectUIModel method installTreeColumn.

protected void installTreeColumn(final TreeColumn designColumn, Design design) {
    designColumn.addListener(SWT.Dispose, onDisposeColumn);
    designColumn.setText(design.getName());
    designColumn.setResizable(true);
    designColumn.setWidth(CogToolPref.KLM_RESULT_RANGE.getBoolean() ? COL_WIDTH_WITH_RANGE : COL_WIDTH_NO_RANGE);
    designColumn.setMoveable(true);
    designColumn.addListener(SWT.Move, onColumnReorder);
    CogToolPref.ALERTER.addHandler(this, CogToolPref.PreferencesChange.class, new AlertHandler() {

        public void handleAlert(EventObject evt) {
            if (evt == null) {
                return;
            }
            Set<CogToolPref> changed = ((CogToolPref.PreferencesChange) evt).getPrefs();
            if (changed.contains(CogToolPref.KLM_RESULT_RANGE)) {
                if (CogToolPref.KLM_RESULT_RANGE.getBoolean()) {
                    if (designColumn.getWidth() < COL_WIDTH_WITH_RANGE) {
                        designColumn.setWidth(COL_WIDTH_WITH_RANGE);
                    }
                } else {
                    if (designColumn.getWidth() > COL_WIDTH_NO_RANGE) {
                        designColumn.setWidth(COL_WIDTH_NO_RANGE);
                    }
                }
                redisplayAllResults();
            } else if (changed.contains(CogToolPref.DISPLAY_DIGITS)) {
                redisplayAllResults();
            }
        }
    });
    AlertHandler handler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            Design design = (Design) designColumn.getData();
            designColumn.setText(design.getName());
            designColumn.setToolTipText(design.getName() + "\n" + selectDesignHelp + "\n" + editDesignHelp);
        }
    };
    designColumn.setData(design);
    designColumn.setToolTipText(design.getName() + "\n" + selectDesignHelp + "\n" + editDesignHelp);
    design.addHandler(this, NameChangeAlert.class, handler);
    design.addHandler(this, Demonstration.StatusChange.class, updateStateHandler);
    // Update data cells when a change happens
    design.addHandler(this, TaskApplication.TaskApplicationResultChange.class, taskApplicationResultHandler);
    if (columnHook != null) {
        columnHook.onColumnCreation(designColumn);
    }
}
Also used : Design(edu.cmu.cs.hcii.cogtool.model.Design) Set(java.util.Set) CogToolPref(edu.cmu.cs.hcii.cogtool.CogToolPref) TaskApplication(edu.cmu.cs.hcii.cogtool.model.TaskApplication) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) Demonstration(edu.cmu.cs.hcii.cogtool.model.Demonstration) EventObject(java.util.EventObject)

Aggregations

CogToolPref (edu.cmu.cs.hcii.cogtool.CogToolPref)1 Demonstration (edu.cmu.cs.hcii.cogtool.model.Demonstration)1 Design (edu.cmu.cs.hcii.cogtool.model.Design)1 TaskApplication (edu.cmu.cs.hcii.cogtool.model.TaskApplication)1 AlertHandler (edu.cmu.cs.hcii.cogtool.util.AlertHandler)1 EventObject (java.util.EventObject)1 Set (java.util.Set)1