Search in sources :

Example 1 with PropTreeCell

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

the class PropertyDialog method createDialog.

public static PropertyDialog createDialog(String title, Iterable<? extends HasProperties> hosts, String optionStr, Component parentComp, ValueChangeListener globalChangeListener) {
    HostList hostList = new HostList(hosts);
    PropTreeCell tree = hostList.commonProperties(null, /* allowReadonly= */
    true);
    tree.removeDescendant("renderProps");
    if (tree.numChildren() == 0) {
        JOptionPane.showMessageDialog(parentComp, "No common properties for selected components", "no common properties", JOptionPane.INFORMATION_MESSAGE);
        return null;
    } else {
        PropertyDialog dialog = new PropertyDialog("Edit properties", tree, hostList, optionStr);
        dialog.setScrollable(true);
        if (globalChangeListener != null) {
            dialog.addGlobalValueChangeListener(globalChangeListener);
        }
        dialog.locateRight(parentComp);
        dialog.setTitle(title);
        return dialog;
    }
}
Also used : PropTreeCell(maspack.properties.PropTreeCell) HostList(maspack.properties.HostList)

Example 2 with PropTreeCell

use of maspack.properties.PropTreeCell 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 3 with PropTreeCell

use of maspack.properties.PropTreeCell 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 4 with PropTreeCell

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

the class RenderPropsDialog method build.

// public RenderPropsDialog (Frame owner, String title,
// Iterable<? extends HasProperties> renderables) {
// super (owner, title);
// initialize ("Done Reset");
// build (renderables);
// inheritGlobalListeners (owner);
// setDefaultCloseOperation (DISPOSE_ON_CLOSE);
// }
// public RenderPropsDialog (Dialog owner, String title,
// Iterable<? extends HasProperties> renderables) {
// super (owner, title);
// initialize ("Done Reset");
// build (renderables);
// inheritGlobalListeners (owner);
// setDefaultCloseOperation (DISPOSE_ON_CLOSE);
// }
// public static RenderPropsDialog createDialog (
// Window win, String title, Iterable<? extends HasProperties> renderables) {
// RenderPropsDialog dialog;
// if (win instanceof Dialog) {
// dialog = new RenderPropsDialog ((Dialog)win, title, renderables);
// }
// else if (win instanceof Frame) {
// dialog = new RenderPropsDialog ((Frame)win, title, renderables);
// }
// else if (win == null) {
// dialog = new RenderPropsDialog (title, renderables);
// }
// else {
// throw new InternalErrorException ("Unsupported window type " + win);
// }
// return dialog;
// }
private void build(Iterable<? extends HasProperties> renderables) {
    myHostList = new HostList(renderables);
    Iterator<? extends HasProperties> it = renderables.iterator();
    if (!it.hasNext()) {
        throw new IllegalArgumentException("list of renderables is empty");
    }
    HasProperties renderable = it.next();
    PropertyInfo renderInfo = renderable.getAllPropertyInfo().get("renderProps");
    if (renderInfo == null) {
        throw new IllegalArgumentException("renderable '" + renderable.getClass() + "' does not contain property 'renderProps'");
    }
    PropTreeCell tree = new PropTreeCell();
    PropTreeCell renderCell = new PropTreeCell(renderInfo, null);
    tree.addChild(renderCell);
    // need to expand the host list down one level before we
    // can get to the render props
    myHostList.saveBackupValues(tree);
    // null render props will be stored as null here
    myHostList.getCommonValues(tree, /* live= */
    true);
    // values for null render props will be expanded
    // using props returned from createRenderProps
    renderCell.addChildren(myHostList.commonProperties(renderCell, false));
    // backup values will be saved, including the original
    // null values
    myHostList.saveBackupValues(renderCell);
    // null render props will be replaced with the render props
    // that were created during the the call to commonProperties
    myHostList.addSubHostsIfNecessary(renderCell);
    myHostList.getCommonValues(renderCell, /* live= */
    true);
    myNumProps = renderCell.numChildren();
    setPanel(new RenderPropsPanel(EditingProperty.createProperties(renderCell, myHostList, /* isLive= */
    true)));
    setScrollable(true);
    myTree = renderCell;
    // enableAutoRerendering (true);
    // ViewerManager driver = Main.getMain().getViewerManager();
    // driver.setSelectionHighlighting (GLViewer.SelectionHighlighting.None);
    // driver.render();
    // addWindowListener (
    // new PropertyWindowAdapter(this)
    // {
    // public void windowClosing (WindowEvent e)
    // {
    // getWindow().dispose();
    // }
    // public void windowClosed (WindowEvent e)
    // {
    // ViewerManager driver = Main.getMain().getViewerManager();
    // driver.setSelectionHighlighting (
    // GLViewer.SelectionHighlighting.Color);
    // driver.render();
    // }
    // });
    // addWindowListener (new WindowAdapter() {
    // // public void windowClosing (WindowEvent e)
    // // {
    // // e.getSource().dispose();
    // // }
    // 
    // public void windowClosed (WindowEvent e) {
    // ViewerManager driver = Main.getMain().getViewerManager();
    // driver.setSelectionHighlighting (
    // GLViewer.SelectionHighlighting.Color);
    // driver.render();
    // }
    // });
    // initFinish ("Done Reset");
    pack();
}
Also used : PropTreeCell(maspack.properties.PropTreeCell) HasProperties(maspack.properties.HasProperties) HostList(maspack.properties.HostList) PropertyInfo(maspack.properties.PropertyInfo)

Example 5 with PropTreeCell

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

the class CompositePropertyPanel method createWidgetProps.

/**
 * Create properties for the widgets controlling the property values of the
 * current composite property.
 */
private LinkedList<Property> createWidgetProps() {
    if (myCpropProperty instanceof EditingProperty) {
        EditingProperty eprop = (EditingProperty) myCpropProperty;
        HostList hostList = eprop.getHostList();
        PropTreeCell cell = eprop.getCell();
        cell.removeAllChildren();
        CompositeProperty cprop = createCprop(myCpropType);
        LinkedList<Property> props = PropertyUtils.createProperties(cprop);
        for (Property prop : props) {
            cell.addChild(new PropTreeCell(prop.getInfo(), prop.get()));
        }
        hostList.setSubHostsFromValue(cell);
        hostList.saveBackupValues(cell);
        hostList.getCommonValues(cell, /*live=*/
        true);
        cell.setValue(CompositeProperty.class);
        return EditingProperty.createProperties(cell, hostList, /*live=*/
        true);
    } else {
        myCprop = (CompositeProperty) myCpropProperty.get();
        return PropertyUtils.createProperties(myCprop);
    }
}
Also used : EditingProperty(maspack.properties.EditingProperty) PropTreeCell(maspack.properties.PropTreeCell) HostList(maspack.properties.HostList) InheritableProperty(maspack.properties.InheritableProperty) CompositeProperty(maspack.properties.CompositeProperty) Property(maspack.properties.Property) EditingProperty(maspack.properties.EditingProperty) CompositeProperty(maspack.properties.CompositeProperty)

Aggregations

PropTreeCell (maspack.properties.PropTreeCell)9 HostList (maspack.properties.HostList)8 EditingProperty (maspack.properties.EditingProperty)4 CompositeProperty (maspack.properties.CompositeProperty)2 InheritableProperty (maspack.properties.InheritableProperty)2 Property (maspack.properties.Property)2 PropertyInfo (maspack.properties.PropertyInfo)2 PropertyDialog (maspack.widgets.PropertyDialog)2 HasProperties (maspack.properties.HasProperties)1 InternalErrorException (maspack.util.InternalErrorException)1