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);
}
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());
}
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());
}
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);
}
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);
}
Aggregations