use of edu.cmu.cs.hcii.cogtool.model.SkinType in project cogtool by cogtool.
the class ActionPropertySet method updateEmptyComposite.
public void updateEmptyComposite(Design design, boolean selectFirst) {
designName.setData(design);
designName.setText(design.getName());
Set<DeviceType> devices = design.getDeviceTypes();
for (int i = 0; i < DeviceType.DISPLAY_ORDER.length; i++) {
if (DeviceType.Display.equals(DeviceType.DISPLAY_ORDER[i]) || devices.contains(DeviceType.DISPLAY_ORDER[i])) {
deviceButtons[i].setSelection(true);
}
}
SkinType skin = design.getSkin();
if (SkinType.WireFrame.equals(skin)) {
skinCombo.select(0);
} else if (SkinType.MacOSX.equals(skin)) {
skinCombo.select(1);
} else if (SkinType.WinXP.equals(skin)) {
skinCombo.select(2);
}
updateTree(design);
if (selectFirst && frameTree.getItemCount() > 0) {
frameTree.setSelection(frameTree.getItem(0));
}
}
use of edu.cmu.cs.hcii.cogtool.model.SkinType 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));
}
use of edu.cmu.cs.hcii.cogtool.model.SkinType in project cogtool by cogtool.
the class DesignEditorController method createSetSkinAction.
protected IListenerAction createSetSkinAction(final SkinType newSkin, final CogToolLID lid) {
return new AListenerAction() {
public boolean performAction(Object prms) {
final SkinType oldSkin = design.getSkin();
design.setSkin(newSkin);
undoMgr.addEdit(new AUndoableEdit(lid) {
@Override
public String getPresentationName() {
return changeSkin;
}
@Override
public void redo() {
super.redo();
design.setSkin(newSkin);
}
@Override
public void undo() {
super.undo();
design.setSkin(oldSkin);
}
});
return true;
}
};
}
use of edu.cmu.cs.hcii.cogtool.model.SkinType in project cogtool by cogtool.
the class FrameEditorController method createSetSkinAction.
private AListenerAction createSetSkinAction(final SkinType newSkin, final CogToolLID lid) {
return new AListenerAction() {
public boolean performAction(Object prms) {
final SkinType oldSkin = design.getSkin();
design.setSkin(newSkin);
IUndoableEdit edit = new AUndoableEdit(lid) {
@Override
public String getPresentationName() {
return CHANGE_SKIN;
}
@Override
public void redo() {
super.redo();
design.setSkin(newSkin);
}
@Override
public void undo() {
super.undo();
design.setSkin(oldSkin);
}
};
UndoManager designUndoMgr = UndoManager.getUndoManager(design, project);
designUndoMgr.addEdit(edit);
undoMgr.addEdit(edit);
return true;
}
};
}
use of edu.cmu.cs.hcii.cogtool.model.SkinType in project cogtool by cogtool.
the class DesignEditorUI 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(DesignEditorSelectionState sel, Boolean availability) {
String label = "";
int frameCount = sel.getSelectedFrameCount();
if (frameCount > 0) {
if (frameCount > 1) {
label = " " + FRAMES_LABEL;
} else {
label = " " + FRAME_LABEL;
}
}
int transitionCount = sel.getSelectedTransitionCount();
if (transitionCount > 0) {
if (transitionCount > 1) {
label = " " + TRANSITIONS_LABEL;
} else {
label = " " + TRANSITION_LABEL;
}
}
Text t = WindowUtil.getFocusedText();
boolean editing = ((editor != null) && editor.getVisible());
String cutCopyLabel = (editing || (t != null)) ? "" : label;
boolean enabled = (frameCount > 0) || (transitionCount == 1);
String editString = MenuFactory.EDIT_STRING;
if (enabled) {
editString += label;
}
setEnabled(CogToolLID.Edit, availability, enabled, editString);
enabled = (frameCount > 0) || (transitionCount > 0);
String deleteString = MenuFactory.DELETE_STRING + label;
setEnabled(CogToolLID.Delete, availability, enabled, deleteString);
// Enable move/reorder items if any frames are selected
enabled = (frameCount > 0);
String cutString = MenuFactory.CUT_STRING;
if (enabled) {
cutString += cutCopyLabel;
}
setEnabled(CogToolLID.Cut, availability, enabled, cutString);
String copyString = MenuFactory.COPY_STRING;
if (enabled) {
copyString += cutCopyLabel;
}
setEnabled(CogToolLID.Copy, availability, enabled, copyString);
setEnabled(CogToolLID.NudgeLeft, availability, enabled);
setEnabled(CogToolLID.NudgeRight, availability, enabled);
setEnabled(CogToolLID.NudgeDown, availability, enabled);
setEnabled(CogToolLID.NudgeUp, availability, enabled);
// TODO: For now, don't allow duplication of transitions
String dupString = MenuFactory.DUPLICATE_STRING;
if (enabled) {
dupString += label;
}
setEnabled(CogToolLID.Duplicate, availability, enabled, dupString);
// the following 3 menu items involve code snippets copied from
// FrameEditor classes
setEnabled(CogToolLID.SetBackgroundImage, availability, enabled, SET_FRAME_BKG_IMAGE);
setEnabled(CogToolLID.SetWidgetColor, availability, enabled);
// only enable RemoveBackgroundImage if there are selected frames
if (enabled) {
// and at least one of those frames has a background image
boolean foundBackgroundImage = false;
Frame[] selFrames = sel.getSelectedFrames();
for (Frame selFrame : selFrames) {
if (selFrame.getBackgroundImage() != null) {
foundBackgroundImage = true;
break;
}
}
setEnabled(CogToolLID.RemoveBackgroundImage, availability, foundBackgroundImage, REMOVE_FRAME_BKG_IMAGE);
} else {
setEnabled(CogToolLID.RemoveBackgroundImage, availability, enabled, REMOVE_FRAME_BKG_IMAGE);
}
// setEnabled(CogToolLID.BringToFront, availability, enabled);
// setEnabled(CogToolLID.BringForward, availability, enabled);
// setEnabled(CogToolLID.SendBackward, availability, enabled);
// setEnabled(CogToolLID.SendToBack, availability, enabled);
// Enable alignment items if multiple frames are selected
enabled = (frameCount > 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 frames are selected
enabled = (frameCount >= 3);
setEnabled(CogToolLID.SpaceVertically, availability, enabled);
setEnabled(CogToolLID.SpaceHorizontally, availability, enabled);
// Edit and Rename enabled if a single selection
enabled = (frameCount == 1);
String renameString = MenuFactory.RENAME_STRING;
if (enabled) {
renameString += label;
}
setEnabled(CogToolLID.Rename, availability, enabled, renameString);
Design modelDesign = uiModel.getDesign();
enabled = (modelDesign.getFrames().size() > 0);
setEnabled(CogToolLID.SelectAll, availability, enabled, SELECT_ALL_FRAMES);
// 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 = modelDesign.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