Search in sources :

Example 31 with FrameElement

use of edu.cmu.cs.hcii.cogtool.model.FrameElement 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

FrameElement (edu.cmu.cs.hcii.cogtool.model.FrameElement)31 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)20 SimpleWidgetGroup (edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup)16 FrameElementGroup (edu.cmu.cs.hcii.cogtool.model.FrameElementGroup)14 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)9 CompoundUndoableEdit (edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit)7 HashSet (java.util.HashSet)6 ChildWidget (edu.cmu.cs.hcii.cogtool.model.ChildWidget)5 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)5 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)5 Iterator (java.util.Iterator)5 AParentWidget (edu.cmu.cs.hcii.cogtool.model.AParentWidget)4 Point (org.eclipse.draw2d.geometry.Point)4 IDesignUndoableEdit (edu.cmu.cs.hcii.cogtool.controller.DemoStateManager.IDesignUndoableEdit)3 GridButton (edu.cmu.cs.hcii.cogtool.model.GridButton)3 GridButtonGroup (edu.cmu.cs.hcii.cogtool.model.GridButtonGroup)3 FrameEditorUI (edu.cmu.cs.hcii.cogtool.ui.FrameEditorUI)3 EmptyIterator (edu.cmu.cs.hcii.cogtool.util.EmptyIterator)3 MoveHalo (edu.cmu.cs.hcii.cogtool.view.MoveHalo)3 CogToolLID (edu.cmu.cs.hcii.cogtool.CogToolLID)2