use of edu.cmu.cs.hcii.cogtool.model.FrameElementGroup in project cogtool by cogtool.
the class FrameEditorUI method getSelectedWidgetArea.
public DoubleRectangle getSelectedWidgetArea() {
DoubleRectangle r = null;
Iterator<FrameElement> selectedElts = selection.getSelectedElementsIterator();
while (selectedElts.hasNext()) {
FrameElement elt = selectedElts.next();
DoubleRectangle bds = null;
if (elt instanceof IWidget) {
IWidget w = (IWidget) elt;
SimpleWidgetGroup wg = w.getParentGroup();
bds = (wg != null) ? wg.getGroupBounds() : w.getEltBounds();
} else if (elt instanceof FrameElementGroup) {
bds = ((FrameElementGroup) elt).getGroupBounds();
}
if (bds != null) {
if (r == null) {
r = new DoubleRectangle(bds);
} else {
r = r.union(bds);
}
}
}
return r;
}
use of edu.cmu.cs.hcii.cogtool.model.FrameElementGroup in project cogtool by cogtool.
the class FrameEditorUI method updateView.
/**
* Update the visual contents based on the selected widgets.
*/
public void updateView() {
int selectionCount = selection.getElementSelectionCount();
// text boxes and pull downs with values.
if (selectionCount == 1) {
// preserve selected state if a whole text field is selected
Text text = WindowUtil.getFocusedText();
boolean restoreSel = false;
if ((text != null) && (text.getSelectionCount() == text.getCharCount())) {
restoreSel = true;
}
// get the selected item
Iterator<FrameElement> iter = selection.getSelectedElementsIterator();
// For each selected object, which there is only one.
FrameElement elt = iter.next();
if (elt instanceof IWidget) {
IWidget widget = (IWidget) elt;
view.useParameters(FrameEditorView.USE_SINGLE_SELECT);
view.updateWidgetProperties(widget);
} else if (elt instanceof FrameElementGroup) {
FrameElementGroup eltGroup = (FrameElementGroup) elt;
view.useParameters(FrameEditorView.USE_GROUP_SELECT);
view.updateEltGroupProperties(eltGroup);
}
// Restore the selection state
if (restoreSel) {
text.selectAll();
}
} else if (selectionCount > 1) {
// TODO: on multi selection, some values are left enabled
// We need to set these to something or disable them.
view.useParameters(FrameEditorView.USE_MULTI_SELECT);
} else {
view.useParameters(FrameEditorView.USE_NONE);
view.updateFrameProperties(frame, false);
}
}
Aggregations