use of edu.cmu.cs.hcii.cogtool.ui.FrameEditorSelectionState in project cogtool by cogtool.
the class FrameEditorController method createInitiateRenameAction.
private IListenerAction createInitiateRenameAction() {
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.initiateWidgetRename(w);
return true;
}
interaction.protestNoSelection();
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.ui.FrameEditorSelectionState in project cogtool by cogtool.
the class FrameEditorController method createGroupElementsAction.
private IListenerAction createGroupElementsAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorSelectionState.class;
}
public boolean performAction(Object prms) {
FrameEditorSelectionState selection = (FrameEditorSelectionState) prms;
int selectedEltCount = selection.getElementSelectionCount();
if (selectedEltCount > 1) {
final FrameElementGroup newGroup = new FrameElementGroup();
assignUniqueEltGroupName(newGroup);
Iterator<FrameElement> selectedElts = selection.getSelectedElementsIterator();
while (selectedElts.hasNext()) {
FrameElement rootElt = selectedElts.next().getRootElement();
// that the element is a member of the group
if (!newGroup.contains(rootElt)) {
newGroup.add(rootElt);
}
}
model.addEltGroup(newGroup);
IUndoableEdit edit = new AUndoableEdit(FrameEditorLID.Group) {
@Override
public String getPresentationName() {
return GROUP_ELEMENTS;
}
@Override
public void redo() {
super.redo();
Iterator<FrameElement> groupElts = newGroup.iterator();
// back to the frame
while (groupElts.hasNext()) {
groupElts.next().addToEltGroup(newGroup);
}
model.addEltGroup(newGroup);
}
@Override
public void undo() {
super.undo();
model.removeEltGroup(newGroup);
Iterator<FrameElement> groupElts = newGroup.iterator();
// association from the element.
while (groupElts.hasNext()) {
groupElts.next().removeFromEltGroup(newGroup);
}
}
};
undoMgr.addEdit(edit);
return true;
}
if (selectedEltCount == 1) {
interaction.protestTooFewWidgets();
} else {
interaction.protestNoSelection();
}
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.ui.FrameEditorSelectionState 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.ui.FrameEditorSelectionState 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.ui.FrameEditorSelectionState in project cogtool by cogtool.
the class FrameEditorController method createSetFrameTemplateAction.
/**
* Record the Widgets in the clipboard as the template to use
* when creating new Frames.
*/
private IListenerAction createSetFrameTemplateAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return FrameEditorSelectionState.class;
}
public boolean performAction(Object prms) {
FrameEditorSelectionState seln = (FrameEditorSelectionState) prms;
// If selection is non zero, copy widgets
if (seln.getElementSelectionCount() > 0) {
copyElements(seln, DesignEditorCmd.SAVE_TO_TEMPLATE);
interaction.setStatusMessage(templateCreated);
return true;
}
// tell user to select something.
interaction.setStatusMessage(noTemplateWidgets);
interaction.protestNoSelection();
return false;
}
};
}
Aggregations