Search in sources :

Example 31 with EventObject

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

the class FrameEditorUI method addBackgroundImageHandler.

/**
     * Registers a listener that enables/disables the
     * "remove background image" menu item as necessary.
     *
     * Also enable or disabled the capture Background button.
     * TODO: when capture background becomes a menu item, add to setEnabled
     */
protected void addBackgroundImageHandler() {
    AlertHandler backgroundEnabler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            // Checks to see if the frame has a background.
            // if so enable remove background and capture background
            // buttons.
            boolean enable = (frame.getBackgroundImage() == null) ? MenuUtil.DISABLED : MenuUtil.ENABLED;
            // Enable or disabled the remove background menu item
            setEnabled(CogToolLID.RemoveBackgroundImage, ListenerIdentifierMap.ALL, enable);
            // Enable or disabled the capture background button
            view.setIsBackgroundAvailable(enable);
        }
    };
    frame.addHandler(this, Frame.BackgroundImageChange.class, backgroundEnabler);
}
Also used : Frame(edu.cmu.cs.hcii.cogtool.model.Frame) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) EventObject(java.util.EventObject)

Example 32 with EventObject

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

the class FrameEditorUI method addWidgetShapeChangeHandler.

/**
     * Registers a listener that redraws the frame in response to changes in
     * the appearance of widgets
     *
     * When this event occurs, resize handles are redrawn, the window's size is
     * recomputed, and the display updated.
     *
     */
protected void addWidgetShapeChangeHandler() {
    AlertHandler widgetTitleChangeHandler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            FrameUIModel.WidgetTitleChange chg = (FrameUIModel.WidgetTitleChange) alert;
            // selected widget
            if (selection.getElementSelectionCount() == 1) {
                FrameElement elt = selection.getSelectedIFrameElements()[0];
                if (chg.widget == elt.getAttribute(WidgetAttributes.REMOTE_LABEL_ATTR)) {
                    view.setRemoteLabelText(chg.widget.getTitle());
                }
            }
        }
    };
    frameUI.addHandler(this, FrameUIModel.WidgetTitleChange.class, widgetTitleChangeHandler);
    AlertHandler widgetShapeChangeHandler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            delayedRepainting.requestRepaint(SHAPE_CHANGE_REPAINT);
        // a FULL repaint is probably not needed
        }
    };
    frameUI.addHandler(this, FrameUIModel.WidgetShapeImageChange.class, widgetShapeChangeHandler);
    AlertHandler widgetGroupChangeHandler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            FrameUIModel.WidgetGroupChange evt = (FrameUIModel.WidgetGroupChange) alert;
            if (evt.isAdd) {
                GraphicalWidget<?> gw = frameUI.getWidgetFigure(evt.widget);
                delayedWidgetSelection.addToSelection(evt.widget, gw);
            } else {
                delayedWidgetSelection.removeFromSelection(evt.widget);
                SimpleWidgetGroup group = evt.widget.getParentGroup();
                if (group.size() == 0) {
                    //evt.widget was the last widget in this group,
                    //so hide the halo for it
                    removeHalo(evt.widget);
                }
            }
        }
    };
    frameUI.addHandler(this, FrameUIModel.WidgetGroupChange.class, widgetGroupChangeHandler);
}
Also used : SimpleWidgetGroup(edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup) FrameUIModel(edu.cmu.cs.hcii.cogtool.uimodel.FrameUIModel) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) FrameElement(edu.cmu.cs.hcii.cogtool.model.FrameElement) EventObject(java.util.EventObject)

Example 33 with EventObject

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

the class FrameEditorUI method init.

/**
     * Set up this object for editing widgets.
     * This method should be called from within the constructor.
     */
private void init() {
    // Add listeners to the view
    addEventListeners();
    addSelectionChangeListeners();
    // Add listeners to the model
    addBackgroundImageHandler();
    addFrameWidgetHandler();
    addWidgetShapeChangeHandler();
    project.addHandler(this, Project.DesignChange.class, new AlertHandler() {

        public void handleAlert(EventObject alert) {
            Project.DesignChange chg = (Project.DesignChange) alert;
            if ((!chg.isAdd) && (chg.element == design)) {
                closeOpenController();
            }
        }
    });
    design.addHandler(this, Design.FrameChange.class, new AlertHandler() {

        public void handleAlert(EventObject alert) {
            Design.FrameChange chg = (Design.FrameChange) alert;
            if ((!chg.isAdd) && (chg.element == frame)) {
                closeOpenController();
            }
        }
    });
    design.addHandler(this, Design.DeviceTypeChange.class, new AlertHandler() {

        public void handleAlert(EventObject alert) {
            Set<DeviceType> dts = design.getDeviceTypes();
            int deviceTypes = DeviceType.buildDeviceSet(dts);
            view.resetDeviceTypes(deviceTypes);
        }
    });
    // Add listeners to rename events on project and design
    frame.addHandler(this, NameChangeAlert.class, renameHandler);
    design.addHandler(this, NameChangeAlert.class, renameHandler);
    // Some items should always be enabled.
    // Should be the last call in the constructor
    setInitiallyEnabled(true);
}
Also used : Design(edu.cmu.cs.hcii.cogtool.model.Design) Project(edu.cmu.cs.hcii.cogtool.model.Project) Set(java.util.Set) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) EventObject(java.util.EventObject)

Example 34 with EventObject

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

the class DesignEditorUI method createFrameSelectionHandler.

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

        public void handleAlert(EventObject alert) {
            FrameSelectionChange evt = (FrameSelectionChange) alert;
            ActionPropertySet actionProps = view.getActionPropertySet();
            if (evt != null) {
                if (evt.changedFrameFigure != null) {
                    evt.changedFrameFigure.setSelected(evt.selected);
                    // Handle property sheet selection
                    Frame[] selectedFrames = selection.getSelectedFrames();
                    int selectedFrameCount = selectedFrames.length;
                    if (selectedFrameCount > 0) {
                        actionProps.setComposite(ActionPropertySet.FRAME);
                        if (selectedFrameCount == 1) {
                            actionProps.setFrameName(selectedFrames[0]);
                        }
                    } else {
                        actionProps.setComposite(ActionSet.USE_NONE);
                    }
                    actionProps.enableFrameName(selectedFrameCount == 1);
                } else {
                    actionProps.setComposite(ActionSet.USE_NONE);
                    Iterator<DesignEditorFrame> frameFigures = selection.getSelectedFrameFigures();
                    while (frameFigures.hasNext()) {
                        DesignEditorFrame frameFigure = frameFigures.next();
                        frameFigure.setSelected(evt.selected);
                    }
                }
                // Repaint the frame contents
                delayedRepainting.requestRepaint(REPAINT_ALL);
            }
        }
    };
}
Also used : ActionPropertySet(edu.cmu.cs.hcii.cogtool.view.ActionPropertySet) FrameSelectionChange(edu.cmu.cs.hcii.cogtool.ui.DesignEditorSelectionState.FrameSelectionChange) Frame(edu.cmu.cs.hcii.cogtool.model.Frame) DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) EventObject(java.util.EventObject) Point(org.eclipse.draw2d.geometry.Point)

Example 35 with EventObject

use of java.util.EventObject in project intellij-community by JetBrains.

the class NewErrorTreeEditor method isCellEditable.

@Override
public boolean isCellEditable(EventObject e) {
    Object node;
    if (e instanceof MouseEvent) {
        final Point point = ((MouseEvent) e).getPoint();
        final TreePath location = myTree.getClosestPathForLocation(point.x, point.y);
        node = location.getLastPathComponent();
    } else {
        node = myTree.getLastSelectedPathComponent();
    }
    final ErrorTreeElement element = getElement(node);
    return element instanceof EditableMessageElement;
}
Also used : MouseEvent(java.awt.event.MouseEvent) TreePath(javax.swing.tree.TreePath) EventObject(java.util.EventObject)

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