Search in sources :

Example 56 with EventObject

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

the class StructureViewUIModel method installSourceTransition.

// installFrame
/**
     * Create the visible representation for the given transition
     * emanating from a specific source.
     * <p>
     * Finds the figure for the transition's target frame, creates the
     * visible representation of the transition, adds that representation
     * to the drawing, and registers the new transition figure with the
     * source figure.
     * <p>
     * The figures for the source object and destination frames
     * must be created/installed before attempting to create/install
     * the visible representations for transitions.
     *
     * @param transition   the transition to install
     * @param sourceFigure the figure for the transition's source
     * @author mlh
     */
protected void installSourceTransition(final Transition transition, final GraphicalSource<?> sourceFigure) {
    DesignEditorFrame targetFigure = getFrameFigure(transition.getDestination());
    final DesignEditorTransition transitionFigure = new DesignEditorTransition(transition, sourceFigure, targetFigure, showToolTips);
    if (sourceFigure instanceof GraphicalChildWidget<?, ?>) {
        checkSrcTransitions.add(transitionFigure);
    }
    installedTransitions.put(transition, transitionFigure);
    AlertHandler localDestChangeHandler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            DesignEditorFrame newTargetFigure = installedFrames.get(transition.getDestination());
            if (newTargetFigure != null) {
                sourceFigure.buildToolTip();
                transitionFigure.changeTarget(newTargetFigure);
            }
            if (destinationChangeHandler != null) {
                destinationChangeHandler.handleAlert(alert);
            }
        }
    };
    transitionFigure.addDestinationChangeHandler(localDestChangeHandler);
    if (actionChangeHandler != null) {
        transitionFigure.addActionChangeHandler(actionChangeHandler);
    }
    contents.add(transitionFigure);
    sourceFigure.addTransition(transition, transitionFigure);
    transitionAddRemoveEvent.setTransitionFigure(transitionFigure, true);
    raiseAlert(transitionAddRemoveEvent);
}
Also used : AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) EventObject(java.util.EventObject)

Example 57 with EventObject

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

the class MembershipListenerTest method initialMemberEvents_whenAddedAfterClientStarted.

@Test
public void initialMemberEvents_whenAddedAfterClientStarted() throws InterruptedException {
    hazelcastFactory.newHazelcastInstance();
    hazelcastFactory.newHazelcastInstance();
    ClientConfig clientConfig = new ClientConfig();
    HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
    final InitialMemberShipEventLogger listener = new InitialMemberShipEventLogger();
    client.getCluster().addMembershipListener(listener);
    EventObject eventObject = listener.events.poll(ASSERT_TRUE_EVENTUALLY_TIMEOUT, TimeUnit.SECONDS);
    assertInstanceOf(InitialMembershipEvent.class, eventObject);
    InitialMembershipEvent event = (InitialMembershipEvent) eventObject;
    assertEquals(2, event.getMembers().size());
    assertEquals(0, listener.events.size());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientConfig(com.hazelcast.client.config.ClientConfig) EventObject(java.util.EventObject) InitialMembershipEvent(com.hazelcast.core.InitialMembershipEvent) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 58 with EventObject

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

the class MembershipListenerTest method initialMemberEvents_whenClusterRestarted.

@Test
public void initialMemberEvents_whenClusterRestarted() throws InterruptedException {
    HazelcastInstance instance1 = hazelcastFactory.newHazelcastInstance();
    HazelcastInstance instance2 = hazelcastFactory.newHazelcastInstance();
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.getNetworkConfig().setConnectionAttemptLimit(Integer.MAX_VALUE);
    final InitialMemberShipEventLogger listener = new InitialMemberShipEventLogger();
    clientConfig.addListenerConfig(new ListenerConfig().setImplementation(listener));
    hazelcastFactory.newHazelcastClient(clientConfig);
    EventObject eventObject = listener.events.poll(ASSERT_TRUE_EVENTUALLY_TIMEOUT, TimeUnit.SECONDS);
    assertInstanceOf(InitialMembershipEvent.class, eventObject);
    instance1.getLifecycleService().terminate();
    eventObject = listener.events.poll(ASSERT_TRUE_EVENTUALLY_TIMEOUT, TimeUnit.SECONDS);
    assertInstanceOf(MembershipEvent.class, eventObject);
    assertEquals(MembershipEvent.MEMBER_REMOVED, ((MembershipEvent) eventObject).getEventType());
    instance2.getLifecycleService().terminate();
    hazelcastFactory.newHazelcastInstance();
    eventObject = listener.events.poll(ASSERT_TRUE_EVENTUALLY_TIMEOUT, TimeUnit.SECONDS);
    assertInstanceOf(MembershipEvent.class, eventObject);
    assertEquals(MembershipEvent.MEMBER_REMOVED, ((MembershipEvent) eventObject).getEventType());
    eventObject = listener.events.poll(ASSERT_TRUE_EVENTUALLY_TIMEOUT, TimeUnit.SECONDS);
    assertInstanceOf(MembershipEvent.class, eventObject);
    assertEquals(MembershipEvent.MEMBER_ADDED, ((MembershipEvent) eventObject).getEventType());
}
Also used : ListenerConfig(com.hazelcast.config.ListenerConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientConfig(com.hazelcast.client.config.ClientConfig) EventObject(java.util.EventObject) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 59 with EventObject

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

the class PERTPanel method observeSelectionState.

/**
     * Associates this panel with a PERTChartSelectionState so that when a new
     * operator is selected, this panel will redraw itself accordingly.
     *
     * @param selectionState
     */
public void observeSelectionState(PERTChartSelectionState selectionState) {
    chartSelectionState = selectionState;
    AlertHandler handler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            // TODO: Change this to map or set
            List<ResultStep> selectedSteps = ((PERTChartSelectionState.SelectionChange) alert).selectedSteps;
            // clear selection boxes
            Iterator<SelectionHalo> haloIterator = selectionBoxes.iterator();
            SelectionHalo deadHalo = null;
            while (haloIterator.hasNext()) {
                deadHalo = haloIterator.next();
                contents.remove(deadHalo);
                deadHalo.dispose();
            }
            selectionBoxes.clear();
            Iterator<PERTChartOperatorBar> barIterator = bars.iterator();
            PERTChartOperatorBar bar;
            while (barIterator.hasNext()) {
                bar = barIterator.next();
                if (selectedSteps.contains(bar.getStep())) {
                    bar.setSelected(true);
                    SelectionHalo halo = new SelectionHalo();
                    halo.setTarget(bar);
                    contents.add(halo);
                    selectionBoxes.add(halo);
                } else {
                    bar.setSelected(false);
                }
            }
            //redraw();
            contents.repaint();
        }
    };
    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) PERTChartOperatorBar(edu.cmu.cs.hcii.cogtool.uimodel.PERTChartOperatorBar) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) EventObject(java.util.EventObject)

Example 60 with EventObject

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

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