Search in sources :

Example 21 with FrameElementGroup

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;
}
Also used : SimpleWidgetGroup(edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup) FrameElementGroup(edu.cmu.cs.hcii.cogtool.model.FrameElementGroup) FrameElement(edu.cmu.cs.hcii.cogtool.model.FrameElement) DoubleRectangle(edu.cmu.cs.hcii.cogtool.model.DoubleRectangle) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 22 with FrameElementGroup

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);
    }
}
Also used : FrameElementGroup(edu.cmu.cs.hcii.cogtool.model.FrameElementGroup) Text(org.eclipse.swt.widgets.Text) FrameElement(edu.cmu.cs.hcii.cogtool.model.FrameElement) Point(org.eclipse.draw2d.geometry.Point) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Aggregations

FrameElementGroup (edu.cmu.cs.hcii.cogtool.model.FrameElementGroup)22 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)15 FrameElement (edu.cmu.cs.hcii.cogtool.model.FrameElement)14 SimpleWidgetGroup (edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup)10 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)8 HashSet (java.util.HashSet)6 IUndoableEdit (edu.cmu.cs.hcii.cogtool.util.IUndoableEdit)5 AUndoableEdit (edu.cmu.cs.hcii.cogtool.util.AUndoableEdit)4 Iterator (java.util.Iterator)4 EmptyIterator (edu.cmu.cs.hcii.cogtool.util.EmptyIterator)3 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)3 IDesignUndoableEdit (edu.cmu.cs.hcii.cogtool.controller.DemoStateManager.IDesignUndoableEdit)2 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)2 GridButton (edu.cmu.cs.hcii.cogtool.model.GridButton)2 GridButtonGroup (edu.cmu.cs.hcii.cogtool.model.GridButtonGroup)2 FrameEditorSelectionState (edu.cmu.cs.hcii.cogtool.ui.FrameEditorSelectionState)2 FrameEditorUI (edu.cmu.cs.hcii.cogtool.ui.FrameEditorUI)2 CompoundUndoableEdit (edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit)2 Point (org.eclipse.draw2d.geometry.Point)2 Text (org.eclipse.swt.widgets.Text)2