use of edu.cmu.cs.hcii.cogtool.util.AlertHandler 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);
}
use of edu.cmu.cs.hcii.cogtool.util.AlertHandler 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);
}
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.AlertHandler 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);
}
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.AlertHandler 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);
}
});
}
use of edu.cmu.cs.hcii.cogtool.util.AlertHandler 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);
}
}
};
}
Aggregations