use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.
the class FrameEditorController method createInitiateRelabelAction.
private IListenerAction createInitiateRelabelAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorSelectionState.class;
}
public boolean performAction(Object prms) {
FrameEditorSelectionState selection = (FrameEditorSelectionState) prms;
int selectedWidgetCount = selection.getWidgetSelectionCount();
if (selectedWidgetCount == 1) {
IWidget w = selection.getSelectedIWidgets()[0];
ui.initiateWidgetRetitle(w);
return true;
}
interaction.protestNoSelection();
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.
the class FrameEditorController method createSetRenderSkinAction.
private IListenerAction createSetRenderSkinAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorUI.SetRenderSkinParameters.class;
}
public boolean performAction(Object prms) {
FrameEditorUI.SetRenderSkinParameters p = (FrameEditorUI.SetRenderSkinParameters) prms;
// Iterate through selected objects.
Iterator<IWidget> selected = p.selection.getSelectedWidgetsIterator();
CompoundUndoableEdit editSeq = new CompoundUndoableEdit(CHG_WIDGET_RENDERED, FrameEditorLID.SetRenderSkin);
while (selected.hasNext()) {
IWidget w = selected.next();
if (w instanceof TraversableWidget) {
AParentWidget parent = null;
if (w instanceof MenuItem) {
parent = ((MenuItem) w).getTopHeader();
if (parent == null) {
// parent is a context menu
parent = ((MenuItem) w).getParent();
}
} else if (w instanceof ChildWidget) {
parent = ((ChildWidget) w).getParent();
} else if (w instanceof AParentWidget) {
parent = (AParentWidget) w;
}
if (parent != null) {
SimpleWidgetGroup group = parent.getParentGroup();
if (group != null) {
//menu header
renderGroup(group, p.rendered, parent.isRendered(), editSeq);
} else {
//pull down header
renderWidget(parent, p.rendered, parent.isRendered(), editSeq);
renderChildren(parent, p.rendered, parent.isRendered(), editSeq);
}
} else if (w.getParentGroup() != null) {
//list box item or radio button
renderGroup(w.getParentGroup(), p.rendered, w.isRendered(), editSeq);
}
} else {
renderWidget(w, p.rendered, w.isRendered(), editSeq);
}
}
editSeq.end();
// Only add this edit if it is significant
if (editSeq.isSignificant()) {
undoMgr.addEdit(editSeq);
}
return true;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.
the class FrameEditorController method createChangeTitlePropertyAction.
// changeTitleProperty
private IListenerAction createChangeTitlePropertyAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorUI.ActionStringParameters.class;
}
public boolean performAction(Object prms) {
FrameEditorUI.ActionStringParameters p = (FrameEditorUI.ActionStringParameters) prms;
// While the UI should suppress
// multiple selection for setting
// titles, the selection supports it
Iterator<IWidget> selected = p.selection.getSelectedWidgetsIterator();
CompoundUndoableEdit editSequence = new CompoundUndoableEdit(CHG_DISPLAYED_LABEL, FrameEditorLID.ChangeTitleProperty);
String newTitle = p.newString;
// Loop through each item and set the title
while (selected.hasNext()) {
IWidget widget = selected.next();
changeTitleProperty(FrameEditorLID.ChangeTitleProperty, CHG_DISPLAYED_LABEL, widget, newTitle, p.isSeparator, editSequence);
}
editSequence.end();
// Don't add empty edits!
if (editSequence.isSignificant()) {
undoMgr.addEdit(editSequence);
}
return true;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.
the class FrameEditorController method createCutWidgetAction.
/**
* Set up cut action, tests to ensure a cut is valid, and then
* calls cut method.
* @return
*/
private IListenerAction createCutWidgetAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorSelectionState.class;
}
public boolean performAction(Object prms) {
FrameEditorSelectionState seln = (FrameEditorSelectionState) prms;
// if non zero selected items copy them, then delete.
if (seln.getElementSelectionCount() > 0) {
// Copy the widgets, then delete them to perform a cut
copyElements(seln, DesignEditorCmd.SAVE_TO_CLIPBOARD);
return deleteElements(seln);
}
// Tell the user nothing was selected
interaction.protestNoSelection();
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.IListenerAction in project cogtool by cogtool.
the class DesignEditorController method createRemoveBackgroundImageAction.
/**
* Create a ListenerAction to handle removing frame background image on
* multiple frames
*/
protected IListenerAction createRemoveBackgroundImageAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return FrameSelectionState.class;
}
public boolean performAction(Object prms) {
// Get selected frames from parameters
FrameSelectionState seln = (FrameSelectionState) prms;
Frame[] frames = seln.getSelectedFrames();
setBackgroundImageOnFrames(frames, null, WidgetAttributes.NO_IMAGE, DesignEditorLID.RemoveBackgroundImage);
return true;
}
};
}
Aggregations