Search in sources :

Example 16 with AlertHandler

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

the class PERTChartPanel method observeSelectionState.

/**
     * Associate this view with a PERTChartSelectionState so that, when a new
     * operator is selected, this view adds the operator info to the
     * operatorInfoPanel.
     *
     * @param selection
     */
public void observeSelectionState(PERTChartSelectionState selection) {
    chartSelectionState = selection;
    visPanel.observeSelectionState(chartSelectionState);
    scrollBar.observeSelectionState(chartSelectionState);
    AlertHandler handler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            List<ResultStep> selectedStepList = ((PERTChartSelectionState.SelectionChange) alert).selectedSteps;
            String trace = traceText.getText();
            int startPos = -1;
            int endPos = -1;
            operatorInfoText.setText("");
            Iterator<ResultStep> stepIt = selectedStepList.iterator();
            while (stepIt.hasNext()) {
                ResultStep step = stepIt.next();
                operatorInfoText.append(step.toString() + "\n\n\n\n");
                if (startPos < 0) {
                    startPos = Math.max(0, StringUtil.getCharPosFromLineNum(trace, step.traceStart));
                } else {
                    startPos = Math.min(startPos, StringUtil.getCharPosFromLineNum(trace, step.traceStart));
                }
                endPos = Math.max(endPos, StringUtil.getCharPosFromLineNum(trace, step.traceEnd));
            }
            if (selectedStepList.size() == 0) {
                operatorInfoText.setText(NO_OPERATOR_SELECTED);
            }
            if ((startPos > -1) && (endPos > -1)) {
                traceText.setSelection(startPos, endPos);
                traceText.showSelection();
            }
        }
    };
    chartSelectionState.addHandler(this, PERTChartSelectionState.SelectionChange.class, handler);
}
Also used : ResultStep(edu.cmu.cs.hcii.cogtool.model.ResultStep) PERTChartSelectionState(edu.cmu.cs.hcii.cogtool.ui.PERTChartSelectionState) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) EventObject(java.util.EventObject)

Example 17 with AlertHandler

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

the class DesignEditorUI method createFrameRecoveryHandler.

protected AlertHandler createFrameRecoveryHandler() {
    return new AlertHandler() {

        public void handleAlert(EventObject alert) {
            StructureViewUIModel.FrameRecovery evt = (StructureViewUIModel.FrameRecovery) alert;
            if (evt != null) {
                DesignEditorFrame frameFigure = evt.getFrameFigure();
                selection.deselectFrame(frameFigure);
                // If removing the DesignEditorFrame for the
                // rename text editor, cancel the rename
                // operation and clean up.
                cleanupFrameEditor(frameFigure);
            }
        }
    };
}
Also used : StructureViewUIModel(edu.cmu.cs.hcii.cogtool.uimodel.StructureViewUIModel) DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) EventObject(java.util.EventObject)

Example 18 with AlertHandler

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

the class DesignEditorUI method createTransitionSelectionHandler.

// createFrameSelectionHandler
protected AlertHandler createTransitionSelectionHandler() {
    return new AlertHandler() {

        public void handleAlert(EventObject alert) {
            TransitionSelectionChange evt = (TransitionSelectionChange) alert;
            if (evt != null) {
                InteractionDrawingEditor editor = view.getEditor();
                if (evt.changedTransitionFigure != null) {
                    evt.changedTransitionFigure.setSelected(editor, evt.selected);
                } else {
                    Iterator<DesignEditorTransition> transitionFigures = selection.getSelectedTransitionFigures();
                    while (transitionFigures.hasNext()) {
                        DesignEditorTransition transitionFigure = transitionFigures.next();
                        transitionFigure.setSelected(editor, evt.selected);
                    }
                }
                // Repaint the contents
                delayedRepainting.requestRepaint(REPAINT_ALL);
                updateView(evt.changedTransitionFigure == null);
            }
        }
    };
}
Also used : AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) DesignEditorTransition(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorTransition) InteractionDrawingEditor(edu.cmu.cs.hcii.cogtool.view.InteractionDrawingEditor) EventObject(java.util.EventObject) TransitionSelectionChange(edu.cmu.cs.hcii.cogtool.ui.DesignEditorSelectionState.TransitionSelectionChange)

Example 19 with AlertHandler

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

the class DesignEditorUI method setFrameChangeHandlers.

protected void setFrameChangeHandlers(final Design design) {
    design.addHandler(this, NameChangeAlert.class, renameHandler);
    AlertHandler frameChangeHandler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            Design.FrameChange chg = (Design.FrameChange) alert;
            if (chg != null) {
                updateView(false);
                Frame frame = (Frame) chg.element;
                if (chg.isAdd) {
                    DesignEditorFrame frameFigure = structureView.getFrameFigure(frame);
                    // A newly created frame should be selected.
                    delayedFrameSelection.addToSelection(frame, frameFigure);
                } else {
                    delayedFrameSelection.removeFromSelection(frame);
                }
                delayedRepainting.requestRepaint(REPAINT_ALL);
            }
        }
    };
    design.addHandler(this, Design.FrameChange.class, frameChangeHandler);
    frameChangeHandler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            Design.FrameSetChange chg = (Design.FrameSetChange) alert;
            if (chg != null) {
                updateView(false);
                if (chg.isAdd) {
                    for (Frame frame : chg.frames) {
                        DesignEditorFrame frameFigure = structureView.getFrameFigure(frame);
                        // A newly created frame should be selected.
                        delayedFrameSelection.addToSelection(frameFigure.getFrame(), frameFigure);
                    }
                    delayedRepainting.requestRepaint(REPAINT_ALL);
                } else {
                    for (Frame frame : chg.frames) {
                        delayedFrameSelection.removeFromSelection(frame);
                    }
                }
            }
        }
    };
    design.addHandler(this, Design.FrameSetChange.class, frameChangeHandler);
    design.addHandler(this, Design.DeviceTypeChange.class, new AlertHandler() {

        public void handleAlert(EventObject alert) {
            Set<DeviceType> deviceTypeSet = design.getDeviceTypes();
            int deviceTypes = DeviceType.buildDeviceSet(deviceTypeSet);
            view.resetDeviceTypes(deviceTypes);
        }
    });
}
Also used : Design(edu.cmu.cs.hcii.cogtool.model.Design) Frame(edu.cmu.cs.hcii.cogtool.model.Frame) DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) Set(java.util.Set) ActionSet(edu.cmu.cs.hcii.cogtool.view.ActionSet) ActionPropertySet(edu.cmu.cs.hcii.cogtool.view.ActionPropertySet) DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) EventObject(java.util.EventObject)

Example 20 with AlertHandler

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

the class DesignEditorUI method createFrameNameChangeHandler.

protected AlertHandler createFrameNameChangeHandler() {
    return new AlertHandler() {

        public void handleAlert(EventObject alert) {
            StructureViewUIModel.FrameNameChange evt = (StructureViewUIModel.FrameNameChange) alert;
            Frame f = evt.getFrame();
            if (selection.isFrameSelected(f)) {
                view.getActionPropertySet().setFrameName(f);
            }
        }
    };
}
Also used : Frame(edu.cmu.cs.hcii.cogtool.model.Frame) DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) StructureViewUIModel(edu.cmu.cs.hcii.cogtool.uimodel.StructureViewUIModel) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) EventObject(java.util.EventObject)

Aggregations

AlertHandler (edu.cmu.cs.hcii.cogtool.util.AlertHandler)21 EventObject (java.util.EventObject)21 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)9 Design (edu.cmu.cs.hcii.cogtool.model.Design)4 DesignEditorFrame (edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame)4 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)3 TaskGroup (edu.cmu.cs.hcii.cogtool.model.TaskGroup)3 GraphicsUtil (edu.cmu.cs.hcii.cogtool.util.GraphicsUtil)3 Set (java.util.Set)3 AUndertaking (edu.cmu.cs.hcii.cogtool.model.AUndertaking)2 DefaultModelGeneratorState (edu.cmu.cs.hcii.cogtool.model.DefaultModelGeneratorState)2 ResultStep (edu.cmu.cs.hcii.cogtool.model.ResultStep)2 TaskApplication (edu.cmu.cs.hcii.cogtool.model.TaskApplication)2 PERTChartSelectionState (edu.cmu.cs.hcii.cogtool.ui.PERTChartSelectionState)2 GraphicalWidget (edu.cmu.cs.hcii.cogtool.uimodel.GraphicalWidget)2 StructureViewUIModel (edu.cmu.cs.hcii.cogtool.uimodel.StructureViewUIModel)2 RcvrImageException (edu.cmu.cs.hcii.cogtool.util.RcvrImageException)2 ActionPropertySet (edu.cmu.cs.hcii.cogtool.view.ActionPropertySet)2 SWTList (edu.cmu.cs.hcii.cogtool.view.SWTList)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2