use of edu.cmu.cs.hcii.cogtool.model.IWidget in project cogtool by cogtool.
the class SEDemoController method performSelfTransition.
protected boolean performSelfTransition(SEDemoSelectionState selection, TransitionSource source, AAction action, double delayInSecs, String delayLabel) {
AScriptStep beforeStep = getDemoStep(selection);
ActionScriptStep selfTransitionStep = new ActionScriptStep(action, source);
selfTransitionStep.setDelay(delayInSecs, delayLabel);
if (source instanceof IWidget) {
IWidget widget = (IWidget) source;
ActionType actionType = action.getType();
WidgetType widgetType = widget.getWidgetType();
if (toggleIfGermane(widget, selfTransitionStep, action)) {
// Do nothing further
} else if ((actionType == ActionType.KeyPress) || (actionType == ActionType.GraffitiStroke)) {
TextAction text = (TextAction) action;
if (widgetType == WidgetType.TextBox) {
selfTransitionStep.overrideAttribute(widget, WidgetAttributes.APPENDED_TEXT_ATTR, text.getText());
}
}
}
return insertStep(selfTransitionStep, beforeStep, SEDemoLID.InsertSelfTransition, INSERT_SELF_TRANSITION);
}
use of edu.cmu.cs.hcii.cogtool.model.IWidget in project cogtool by cogtool.
the class FrameEditorUI method removeHalo.
// addSelectionChangeListeners
// TODO: Currently works only for IWidget
protected void removeHalo(IWidget w) {
MoveHalo halo = halosUIFig.getMoveHalo(w);
if (halo != null) {
SimpleWidgetGroup group = w.getParentGroup();
if (group != null) {
IWidget[] widgets = selection.getSelectedIWidgets();
// Avoid removing if another sibling/cousin is selected
for (IWidget widget : widgets) {
if ((widget.getParentGroup() == group) && (widget != w)) {
return;
}
}
}
halosUIFig.hideHalo(halo);
}
}
use of edu.cmu.cs.hcii.cogtool.model.IWidget in project cogtool by cogtool.
the class FrameEditorUI method initiateRetitleFigure.
public void initiateRetitleFigure(IFigure widgetFigure) {
if (widgetFigure instanceof GraphicalWidget<?>) {
IWidget w = ((GraphicalWidget<?>) widgetFigure).getModel();
Object value = w.getAttribute(WidgetAttributes.IS_SEPARATOR_ATTR);
if (NullSafe.equals(WidgetAttributes.IS_SEPARATOR, value)) {
// don't allow renaming of separators
return;
}
}
// The editor control must be a child of an SWT object (the canvas)
if (editor == null) {
editor = new WidgetTitleEditor();
}
cleanupFigureLabelEditor();
if (widgetFigure != null) {
editor.editTitle(widgetFigure);
}
}
use of edu.cmu.cs.hcii.cogtool.model.IWidget in project cogtool by cogtool.
the class FrameEditorUI method moveHaloUnderXY.
/**
* Find a move halo at x, y
*/
public MoveHalo moveHaloUnderXY(int x, int y) {
MoveHalo halo = view.moveHaloUnderXY(x, y);
if (halo != null) {
GraphicalWidget<?> clickedFigure = widgetLocatedAtXY(x, y);
if (clickedFigure != null) {
SimpleWidgetGroup group;
IWidget haloWidget;
FrameElement data = halo.getData();
if (data instanceof IWidget) {
haloWidget = (IWidget) data;
group = haloWidget.getParentGroup();
} else if (data instanceof SimpleWidgetGroup) {
group = (SimpleWidgetGroup) data;
haloWidget = group.get(0);
} else {
return halo;
}
IWidget clickedWidget = clickedFigure.getModel();
if ((group != null) && (group.contains(clickedWidget))) {
return null;
}
int haloLevel = haloWidget.getLevel();
int clickedLevel = clickedWidget.getLevel();
if (haloLevel < clickedLevel) {
return null;
}
}
return halo;
}
return null;
}
use of edu.cmu.cs.hcii.cogtool.model.IWidget in project cogtool by cogtool.
the class FrameEditorUI method setViewEnabledState.
/**
* Enables or disables LIDs as appropriate
* @param sel the selection state on which to base enabling/disabling
* @param availability NORMAL or CONTEXT
* @see ListenerIdentifierMap
*/
protected void setViewEnabledState(FrameEditorSelectionState sel, Boolean availability) {
String label = "";
int widgetCount = sel.getWidgetSelectionCount();
int elementCount = sel.getElementSelectionCount();
IWidget selectedWidget = null;
FrameElement selectedElement = null;
if ((widgetCount > 0) || (elementCount > 0)) {
if (widgetCount == 1) {
label = " " + WIDGET_LABEL;
selectedWidget = sel.getSelectedIWidgets()[0];
selectedElement = selectedWidget;
} else {
label = " " + WIDGETS_LABEL;
if (elementCount == 1) {
selectedElement = sel.getSelectedIFrameElements()[0];
}
}
}
Text t = WindowUtil.getFocusedText();
boolean editing = ((editor != null) && editor.getVisible());
String cutCopyLabel = (editing || (t != null)) ? "" : label;
// Turn on rename support if selection is exactly 1
boolean enabled = (widgetCount == 1);
String renameString = MenuFactory.RENAME_STRING;
String relabelString = MenuFactory.RELABEL_STRING;
if (enabled) {
renameString += label;
relabelString += label;
}
setEnabled(CogToolLID.Rename, availability, enabled, renameString);
setEnabled(FrameEditorLID.Relabel, availability, enabled, relabelString);
setEnabled(CogToolLID.CopyPath, availability, enabled);
setEnabled(FrameEditorLID.RemoveImageProperty, availability, (selectedWidget != null) && (selectedWidget.getImage() != null));
setEnabled(FrameEditorLID.ToggleRenderSkin, availability, enabled, MenuFactory.RENDER_WIDGET_SKIN_LABEL, (selectedWidget != null) && selectedWidget.isRendered());
if (enabled && (selectedWidget != null)) {
enabled = selectedWidget.getAttribute(WidgetAttributes.REMOTE_LABEL_OWNER_ATTR) != null;
}
setEnabled(FrameEditorLID.SetRemoteLabelType, availability, enabled);
if (elementCount == 1) {
enabled = selectedElement.getRemoteLabelOwner() != null;
}
setEnabled(FrameEditorLID.SetRemoteLabelText, availability, enabled);
// Turn on these LIDs if the selection is > 0
enabled = (widgetCount > 0);
setEnabled(FrameEditorLID.SetImageProperty, availability, enabled);
setEnabled(FrameEditorLID.CaptureImageProperty, availability, enabled && view.isBackgroundAvailable());
enabled = (elementCount > 0);
String deleteString = MenuFactory.DELETE_STRING + label;
setEnabled(CogToolLID.Delete, availability, enabled, deleteString);
String dupString = MenuFactory.DUPLICATE_STRING + label;
setEnabled(CogToolLID.Duplicate, availability, enabled, dupString);
// For these, there must exist a non-IChildWidget selected widget
int nonchildWidgetCount = sel.getNonchildSelectionCount();
enabled = (nonchildWidgetCount > 0);
String cutString = MenuFactory.CUT_STRING + cutCopyLabel;
setEnabled(CogToolLID.Cut, availability, enabled, cutString);
String copyString = MenuFactory.COPY_STRING + cutCopyLabel;
setEnabled(CogToolLID.Copy, availability, enabled, copyString);
setEnabled(CogToolLID.SetFrameTemplate, availability, enabled);
setEnabled(CogToolLID.NudgeLeft, availability, enabled);
setEnabled(CogToolLID.NudgeRight, availability, enabled);
setEnabled(CogToolLID.NudgeDown, availability, enabled);
setEnabled(CogToolLID.NudgeUp, availability, enabled);
setEnabled(CogToolLID.BringToFront, availability, enabled);
setEnabled(CogToolLID.BringForward, availability, enabled);
setEnabled(CogToolLID.SendBackward, availability, enabled);
setEnabled(CogToolLID.SendToBack, availability, enabled);
// Grouping enabled only if multiple unrelated IFrameElements are selected
enabled = false;
FrameElement firstSelectedElt = null;
Iterator<FrameElement> selectedElts = sel.getSelectedElementsIterator();
while (selectedElts.hasNext()) {
FrameElement elt = selectedElts.next();
if (firstSelectedElt == null) {
firstSelectedElt = elt.getRootElement();
} else if (firstSelectedElt != elt.getRootElement()) {
enabled = true;
break;
}
}
setEnabled(CogToolLID.Group, availability, enabled);
enabled = false;
selectedElts = sel.getSelectedElementsIterator();
while (selectedElts.hasNext()) {
FrameElement elt = selectedElts.next();
enabled = enabled || (elt instanceof FrameElementGroup) || (elt.getRootElement().getEltGroups().size() > 0);
}
setEnabled(CogToolLID.Ungroup, availability, enabled);
// don't allow alignment if any of the selected widgets are part of a
// widget group (e.g. menu headers, list box items, grid buttons)
// TODO might want to allow it for grid buttons, with extra work in the
// controller to calculate horizontal and vertical space
boolean groupWidgetSelected = false;
IWidget[] widgets = sel.getSelectedIWidgets();
for (IWidget widget : widgets) {
if (widget.getParentGroup() != null) {
groupWidgetSelected = true;
}
}
// Enable alignment items if multiple non-child widgets are selected
enabled = (nonchildWidgetCount > 1);
setEnabled(CogToolLID.AlignTop, availability, enabled);
setEnabled(CogToolLID.AlignBottom, availability, enabled);
setEnabled(CogToolLID.AlignLeft, availability, enabled);
setEnabled(CogToolLID.AlignRight, availability, enabled);
setEnabled(CogToolLID.AlignCenter, availability, enabled);
setEnabled(CogToolLID.AlignHorizCenter, availability, enabled);
setEnabled(CogToolLID.AlignVertCenter, availability, enabled);
// Enable spacing items if at least 3 non-child widgets are selected
enabled = (nonchildWidgetCount >= 3) && !groupWidgetSelected;
setEnabled(CogToolLID.SpaceVertically, availability, enabled);
setEnabled(CogToolLID.SpaceHorizontally, availability, enabled);
// If there is at least one widget in the model, enable these.
enabled = (frame.getWidgets().size() > 0);
setEnabled(CogToolLID.SelectAll, availability, enabled, SELECT_ALL_WIDGETS);
// Draws the dot to indicate that the correct skin type is selected
setSelected(CogToolLID.SkinNone, availability, false);
setSelected(CogToolLID.SkinWireFrame, availability, false);
setSelected(CogToolLID.SkinMacOSX, availability, false);
setSelected(CogToolLID.SkinWinXP, availability, false);
setSelected(CogToolLID.SkinPalm, availability, false);
SkinType skin = design.getSkin();
CogToolLID id = null;
if (skin == SkinType.None) {
id = CogToolLID.SkinNone;
} else if (skin == SkinType.WireFrame) {
id = CogToolLID.SkinWireFrame;
} else if (skin == SkinType.MacOSX) {
id = CogToolLID.SkinMacOSX;
} else if (skin == SkinType.WinXP) {
id = CogToolLID.SkinWinXP;
} else if (skin == SkinType.Palm) {
id = CogToolLID.SkinPalm;
}
if (id != null) {
setSelected(id, availability, true);
}
setEnabled(CogToolLID.ClearFrameTemplate, ListenerIdentifierMap.ALL, FrameTemplateSupport.hasFrameTemplate(design));
}
Aggregations