Search in sources :

Example 61 with EventObject

use of java.util.EventObject 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 62 with EventObject

use of java.util.EventObject 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 63 with EventObject

use of java.util.EventObject 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 64 with EventObject

use of java.util.EventObject 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)

Example 65 with EventObject

use of java.util.EventObject in project cogtool by cogtool.

the class FrameEditorUI method addFrameWidgetHandler.

/**
     * Registers a listener that adjusts selection state in response to
     * widget additions or removals
     */
protected void addFrameWidgetHandler() {
    AlertHandler frameWidgetHandler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            Frame.WidgetChange chg = (Frame.WidgetChange) alert;
            IWidget chgWidget = chg.getChangeElement();
            if (chg != null) {
                // Check what action was performed
                switch(chg.action) {
                    // Switch the selection to the newly-added widget
                    case Frame.WidgetChange.ELEMENT_ADD:
                        {
                            GraphicalWidget<?> gw = frameUI.getWidgetFigure(chgWidget);
                            gw.addChangeHandler(widgetChangeHandler, Widget.WidgetChange.class);
                            gw.addChangeHandler(widgetChangeHandler, IAttributed.AttributeChange.class);
                            gw.addChangeHandler(widgetChangeHandler, IAttributed.AuthorityChange.class);
                            delayedWidgetSelection.addToSelection(chgWidget, gw);
                            view.requestRename();
                            break;
                        }
                    // Reflect the change in selection state
                    case Frame.WidgetChange.ELEMENT_DELETE:
                        {
                            // Cannot depend on the frameUI to have removed
                            // this widget's graphical version.
                            // Call deselect with the model itself.
                            selection.deselectElement(chgWidget);
                            delayedWidgetSelection.removeFromSelection(chgWidget);
                            // call to clean up any resize handles.
                            delayedRepainting.requestRepaint(REPAINT_SELECT_HANDLES);
                            break;
                        }
                }
            }
        }
    };
    frame.addHandler(this, Frame.WidgetChange.class, frameWidgetHandler);
    AlertHandler frameEltHandler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            delayedRepainting.requestRepaint(REPAINT_SELECT_HANDLES);
        }
    };
    // Do the above for both widget and association changes!
    frame.addHandler(this, Frame.ElementChange.class, frameEltHandler);
    AlertHandler frameAssocHandler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            Frame.FrameEltGrpChange chg = (Frame.FrameEltGrpChange) alert;
            if (chg.action == Frame.FrameEltGrpChange.ELEMENT_DELETE) {
                selection.deselectElement(chg.getChangeElement());
            } else if (chg.action == Frame.FrameEltGrpChange.ELEMENT_ADD) {
                selection.setSelectedSelnFig(uiModel.getGroupHalo(chg.getChangeElement()));
            }
        }
    };
    frame.addHandler(this, Frame.FrameEltGrpChange.class, frameAssocHandler);
}
Also used : Frame(edu.cmu.cs.hcii.cogtool.model.Frame) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) GraphicalWidget(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalWidget) EventObject(java.util.EventObject) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Aggregations

EventObject (java.util.EventObject)111 EventFactory (org.apache.camel.spi.EventFactory)25 EventNotifier (org.apache.camel.spi.EventNotifier)25 ManagementStrategy (org.apache.camel.spi.ManagementStrategy)25 AlertHandler (edu.cmu.cs.hcii.cogtool.util.AlertHandler)21 EventNotifierSupport (org.apache.camel.support.EventNotifierSupport)15 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)10 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)9 Hashtable (java.util.Hashtable)8 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)7 ProgressDialogListener (org.vcell.util.ProgressDialogListener)7 Test (org.junit.Test)6 MouseEvent (java.awt.event.MouseEvent)4 File (java.io.File)4 ExchangeCompletedEvent (org.apache.camel.management.event.ExchangeCompletedEvent)4 ClientConfig (com.hazelcast.client.config.ClientConfig)3 Design (edu.cmu.cs.hcii.cogtool.model.Design)3 TaskGroup (edu.cmu.cs.hcii.cogtool.model.TaskGroup)3 DesignEditorFrame (edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame)3 PreferencesHandler (jmri.plaf.macosx.PreferencesHandler)3