Search in sources :

Example 51 with EventObject

use of java.util.EventObject in project Payara by payara.

the class CheckMgr method fireAllTestsFinishedEvent.

// call once per test, when all tests for the mgr are done
protected void fireAllTestsFinishedEvent() {
    Object[] listeners;
    synchronized (listenerList) {
        listeners = listenerList.toArray();
    }
    if (listeners == null)
        return;
    // those that are interested in this event
    for (int i = 0; i < listeners.length; i++) {
        if (listeners[i] instanceof VerifierEventsListener) {
            // create the event:
            EventObject event = new EventObject(this);
            ((VerifierEventsListener) listeners[i]).allTestsFinished(event);
        }
    }
}
Also used : EventObject(java.util.EventObject) EventObject(java.util.EventObject)

Example 52 with EventObject

use of java.util.EventObject in project jdk8u_jdk by JetBrains.

the class DefaultTreeCellEditor method isCellEditable.

/**
     * If the <code>realEditor</code> returns true to this
     * message, <code>prepareForEditing</code>
     * is messaged and true is returned.
     */
public boolean isCellEditable(EventObject event) {
    boolean retValue = false;
    boolean editable = false;
    if (event != null) {
        if (event.getSource() instanceof JTree) {
            setTree((JTree) event.getSource());
            if (event instanceof MouseEvent) {
                TreePath path = tree.getPathForLocation(((MouseEvent) event).getX(), ((MouseEvent) event).getY());
                editable = (lastPath != null && path != null && lastPath.equals(path));
                if (path != null) {
                    lastRow = tree.getRowForPath(path);
                    Object value = path.getLastPathComponent();
                    boolean isSelected = tree.isRowSelected(lastRow);
                    boolean expanded = tree.isExpanded(path);
                    TreeModel treeModel = tree.getModel();
                    boolean leaf = treeModel.isLeaf(value);
                    determineOffset(tree, value, isSelected, expanded, leaf, lastRow);
                }
            }
        }
    }
    if (!realEditor.isCellEditable(event))
        return false;
    if (canEditImmediately(event))
        retValue = true;
    else if (editable && shouldStartEditingTimer(event)) {
        startEditingTimer();
    } else if (timer != null && timer.isRunning())
        timer.stop();
    if (retValue)
        prepareForEditing();
    return retValue;
}
Also used : EventObject(java.util.EventObject)

Example 53 with EventObject

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

the class FrameUIModel method addFrameChangeListeners.

/**
     * Add listeners for when things change on the frame.
     */
protected void addFrameChangeListeners() {
    AlertHandler frameChangeHandler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            Frame.WidgetChange chg = (Frame.WidgetChange) alert;
            IWidget chgWidget = chg.getChangeElement();
            if (chg != null) {
                // action dictated by the change.
                switch(chg.action) {
                    // Add the graphical representation of the widget
                    case Frame.WidgetChange.ELEMENT_ADD:
                        createGraphicalWidget(chgWidget);
                        raiseAlert(new FrameUIModel.WidgetShapeImageChange(FrameUIModel.this, chgWidget));
                        break;
                    // Remove the graphical representation of the widget
                    case Frame.WidgetChange.ELEMENT_DELETE:
                        removeWidget(chgWidget);
                        raiseAlert(new FrameUIModel.WidgetShapeImageChange(FrameUIModel.this, chgWidget));
                        break;
                    // Update all existing widgets to the new color
                    case Frame.WidgetChange.WIDGET_COLORS_CHANGED:
                        Iterator<GraphicalWidget<?>> gws = figureList.values().iterator();
                        // Update graphical widgets
                        while (gws.hasNext()) {
                            GraphicalWidget<?> gw = gws.next();
                            gw.setColor(frame.getWidgetColor());
                        //                                    gw.setFastMode(false);
                        }
                        // Update potential temporary widget
                        contents.setWidgetColor(frame.getWidgetColor());
                        break;
                }
            }
            // Draw the viewable widgets.
            // Adds any new items from the lists.. or moves them
            drawWidgets();
        }
    };
    // Add the new handler for frame changes to the list of things to
    // alert to changes on the frame
    frame.addHandler(this, Frame.WidgetChange.class, frameChangeHandler);
    // A separate handler is required to take care of changes of the
    // background on the frame.
    AlertHandler frameBackgroundChangeHandler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            Frame.BackgroundImageChange chg = (Frame.BackgroundImageChange) alert;
            if (chg != null) {
                // Dispose the old background image if there was one
                if (backgroundImage.getImage() != null) {
                    backgroundImage.getImage().dispose();
                }
                byte[] bgImg = frame.getBackgroundImage();
                // If the image is null, don't create it.
                if (bgImg != null) {
                    // the cache is probably out of date
                    try {
                        Image img = new Image(null, new ByteArrayInputStream(bgImg));
                        //                                AUIModel.imageCache.put(frame, img);
                        // set the new image to the background
                        backgroundImage.setImage(img);
                        // get the size of the image
                        org.eclipse.swt.graphics.Rectangle bounds = img.getBounds();
                        // resize background image with the new bounds
                        backgroundImage.setSize(bounds.width, bounds.height);
                    } catch (SWTException ex) {
                        throw new GraphicsUtil.ImageException("Setting frame background image failed", ex);
                    }
                } else {
                    // Clear the background image.
                    backgroundImage.setImage(null);
                    backgroundImage.setSize(0, 0);
                }
            }
            drawWidgets();
            // Need to raise Alert after draw widgets since
            // the alert call seems to reset the "bounds"
            raiseAlert(new FrameUIModel.WidgetShapeImageChange(FrameUIModel.this, null));
        }
    };
    // Add this handler to the list for changes in the background image
    frame.addHandler(this, Frame.BackgroundImageChange.class, frameBackgroundChangeHandler);
}
Also used : Frame(edu.cmu.cs.hcii.cogtool.model.Frame) Image(org.eclipse.swt.graphics.Image) EventObject(java.util.EventObject) SWTException(org.eclipse.swt.SWTException) ByteArrayInputStream(java.io.ByteArrayInputStream) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) GraphicsUtil(edu.cmu.cs.hcii.cogtool.util.GraphicsUtil) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 54 with EventObject

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

the class FrameUIModel method addDesignChangeListeners.

/**
     * Add listeners for when things change on the design.
     */
protected void addDesignChangeListeners() {
    AlertHandler designChangeHandler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            Design.WidgetAppearanceChange chg = (Design.WidgetAppearanceChange) alert;
            if (chg != null) {
                Iterator<GraphicalWidget<?>> gws = figureList.values().iterator();
                // Update graphical widgets
                while (gws.hasNext()) {
                    GraphicalWidget<?> gw = gws.next();
                    gw.updateType();
                }
            }
        }
    };
    // Add the new handler for design changes to the list of things to
    // alert to changes on the design
    frame.getDesign().addHandler(this, Design.WidgetAppearanceChange.class, designChangeHandler);
}
Also used : Design(edu.cmu.cs.hcii.cogtool.model.Design) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) EventObject(java.util.EventObject)

Example 55 with EventObject

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

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