Search in sources :

Example 6 with HostList

use of maspack.properties.HostList in project artisynth_core by artisynth.

the class CompositePropertyPanel method updateEditingPropertyForNullCprop.

/**
 * Called when the composite property is set to <code>null</code>.
 * If the property accessing the composite property is an EditingProperty,
 * then its property tree and hostList are updated to reflect the
 * fact that there are no properties associoated with the composite property.
 */
private void updateEditingPropertyForNullCprop(EditingProperty eprop) {
    HostList hostList = eprop.getHostList();
    PropTreeCell cell = eprop.getCell();
    cell.removeAllChildren();
    hostList.setSubHostsFromValue(cell);
    hostList.saveBackupValues(cell);
    // hostList.getCommonValues (cell, /*live=*/true);
    cell.setValue(null);
}
Also used : PropTreeCell(maspack.properties.PropTreeCell) HostList(maspack.properties.HostList)

Example 7 with HostList

use of maspack.properties.HostList in project artisynth_core by artisynth.

the class LabeledComponentPanel method actionPerformed.

public void actionPerformed(ActionEvent e) {
    String command = e.getActionCommand();
    if (command.equals("delete")) {
        LinkedList<JComponent> list = new LinkedList<JComponent>();
        list.addAll(mySelectedWidgets);
        for (JComponent comp : list) {
            removeWidget(comp);
        }
        repackContainingWindow();
    } else if (command.equals("add separator")) {
        JComponent comp = mySelectedWidgets.iterator().next();
        addWidget(new JSeparator(), getComponentIndex(comp) + 1);
        repackContainingWindow();
    } else if (command.equals("set properties")) {
        Window win = SwingUtilities.getWindowAncestor(this);
        if (win != null) {
            LinkedList<HasProperties> hosts = new LinkedList<HasProperties>();
            JComponent lastComp = null;
            for (JComponent comp : mySelectedWidgets) {
                if (comp instanceof HasProperties) {
                    hosts.add((HasProperties) comp);
                }
                lastComp = comp;
            }
            HostList hostList = new HostList(hosts);
            PropertyDialog dialog = PropertyDialog.createDialog(win, "Edit properties", hostList, "OK Cancel");
            // PropertyDialog dialog = PropertyDialog.createDialog (
            // win, "Edit properties", new PropertyPanel (comp), "OK Cancel");
            GuiUtils.locateVertically(dialog, lastComp, GuiUtils.BELOW);
            GuiUtils.locateHorizontally(dialog, this, GuiUtils.CENTER);
            dialog.setModal(true);
            dialog.setVisible(true);
        }
    } else if (command.equals("reset sliderRange")) {
        for (JComponent comp : mySelectedWidgets) {
            if (comp instanceof NumericFieldSlider) {
                // fix this for regular sliders too?
                NumericFieldSlider nslider = (NumericFieldSlider) comp;
                nslider.setSliderRange(SliderRange.estimateBoundsIfNecessary(nslider.getRange(), nslider.getDoubleValue()));
            }
        }
    } else if (mySelectedWidgets.size() == 1) {
        JComponent comp = mySelectedWidgets.iterator().next();
        if (comp instanceof LabeledComponentBase) {
            ((LabeledComponentBase) comp).actionPerformed(e);
        }
    } else {
        throw new InternalErrorException("Unexpected action: " + e);
    }
}
Also used : Window(java.awt.Window) JComponent(javax.swing.JComponent) HasProperties(maspack.properties.HasProperties) HostList(maspack.properties.HostList) InternalErrorException(maspack.util.InternalErrorException) LinkedList(java.util.LinkedList) JSeparator(javax.swing.JSeparator)

Example 8 with HostList

use of maspack.properties.HostList in project artisynth_core by artisynth.

the class ExcitationTargetAgent method createPropertyPanel.

protected void createPropertyPanel() {
    HostList hostList = new HostList(new HasProperties[] { myExciter });
    myPropTree = hostList.commonProperties(null, false);
    // remove properties which are to be excluded
    String[] excludedProps = new String[] { "excitation" };
    for (int i = 0; i < excludedProps.length; i++) {
        myPropTree.removeDescendant(excludedProps[i]);
    }
    hostList.saveBackupValues(myPropTree);
    hostList.getCommonValues(myPropTree, /* live= */
    true);
    myPropertyPanel = new PropertyPanel(EditingProperty.createProperties(myPropTree, hostList, /* isLive= */
    false));
    myPropertyPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    addWidget(myPropertyPanel);
}
Also used : HostList(maspack.properties.HostList) PropertyPanel(maspack.widgets.PropertyPanel)

Example 9 with HostList

use of maspack.properties.HostList in project artisynth_core by artisynth.

the class IsRenderableEditor method createPropertyDialog.

public void createPropertyDialog(Collection<? extends HasProperties> selectedItems, boolean locateClose, Rectangle popupBounds) {
    HostList hostList = new HostList(selectedItems);
    PropTreeCell tree = hostList.commonProperties(null, /* allowReadonly= */
    true);
    if (tree.numChildren() == 0) {
        JOptionPane.showMessageDialog(null, "No common properties for selected components", "no common properties", JOptionPane.INFORMATION_MESSAGE);
    } else {
        PropertyDialog propDialog = new PropertyDialog("Edit properties", tree, hostList, "OK Cancel LiveUpdate");
        propDialog.setScrollable(true);
        if (locateClose) {
            GuiUtils.locateRelative(propDialog, popupBounds, 0.5, 0.5, 0, 0.5);
        } else {
            propDialog.locateRight(myMain.getFrame());
        }
        // propDialog.setSynchronizeObject (myMain.getRootModel());
        myMain.registerWindow(propDialog);
        propDialog.setTitle("Properties for selected IsRenderables");
        propDialog.setVisible(true);
    }
}
Also used : PropertyDialog(maspack.widgets.PropertyDialog) PropTreeCell(maspack.properties.PropTreeCell) HostList(maspack.properties.HostList)

Example 10 with HostList

use of maspack.properties.HostList in project artisynth_core by artisynth.

the class MotionTargetComponentAgent method createPropertyPanel.

protected void createPropertyPanel() {
    HostList hostList = new HostList(new HasProperties[] { myController });
    myPropTree = hostList.commonProperties(null, false);
    // remove properties which are to be excluded
    String[] excludedProps = new String[] { "excitation" };
    for (int i = 0; i < excludedProps.length; i++) {
        myPropTree.removeDescendant(excludedProps[i]);
    }
    hostList.saveBackupValues(myPropTree);
    hostList.getCommonValues(myPropTree, /* live= */
    true);
    myPropertyPanel = new PropertyPanel(EditingProperty.createProperties(myPropTree, hostList, /* isLive= */
    false));
    myPropertyPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    addWidget(myPropertyPanel);
}
Also used : HostList(maspack.properties.HostList) PropertyPanel(maspack.widgets.PropertyPanel)

Aggregations

HostList (maspack.properties.HostList)18 EditingProperty (maspack.properties.EditingProperty)8 PropTreeCell (maspack.properties.PropTreeCell)8 HasProperties (maspack.properties.HasProperties)4 InternalErrorException (maspack.util.InternalErrorException)3 PropertyDialog (maspack.widgets.PropertyDialog)3 PropertyPanel (maspack.widgets.PropertyPanel)3 LinkedList (java.util.LinkedList)2 CompositeProperty (maspack.properties.CompositeProperty)2 Property (maspack.properties.Property)2 PropertyInfo (maspack.properties.PropertyInfo)2 Window (java.awt.Window)1 JComponent (javax.swing.JComponent)1 JSeparator (javax.swing.JSeparator)1 InheritableProperty (maspack.properties.InheritableProperty)1 TestHierarchy (maspack.properties.TestHierarchy)1 TestNode (maspack.properties.TestNode)1 Clonable (maspack.util.Clonable)1 ExpandablePropertyPanel (maspack.widgets.ExpandablePropertyPanel)1