Search in sources :

Example 6 with PropTreeCell

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

the class CompositePropertyPanel method isNullAllowed.

private boolean isNullAllowed(Property prop) {
    if (prop instanceof EditingProperty) {
        // then null values are allowed only if they are permitted
        // on all the hosts
        EditingProperty eprop = (EditingProperty) prop;
        HostList hostList = eprop.getHostList();
        PropTreeCell cell = eprop.getCell();
        PropertyInfo[] infos = hostList.getAllInfos(cell);
        boolean nullAllowed = true;
        for (PropertyInfo info : infos) {
            if (!info.getNullValueOK()) {
                nullAllowed = false;
            }
        }
        return nullAllowed;
    } else {
        return prop.getInfo().getNullValueOK();
    }
}
Also used : EditingProperty(maspack.properties.EditingProperty) PropTreeCell(maspack.properties.PropTreeCell) HostList(maspack.properties.HostList) PropertyInfo(maspack.properties.PropertyInfo)

Example 7 with PropTreeCell

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

the class CompositePropertyPanel method printWidgetProps.

// For debugging only ...
void printWidgetProps(LinkedList<Property> props) {
    if (myCpropProperty instanceof EditingProperty) {
        EditingProperty eprop = (EditingProperty) myCpropProperty;
        // HostList hostList = eprop.getHostList();
        PropTreeCell cell = eprop.getCell();
        System.out.println("parent cell=@" + cell.hashCode());
        for (Property p : props) {
            EditingProperty ep = (EditingProperty) p;
            ep.getCell().getIndex();
            System.out.println(" " + ep.getName() + "=@" + ep.getCell().hashCode());
            if (ep.getCell().getParent() != cell) {
                System.out.println("BAD");
            }
        }
        System.out.println("OK");
    }
}
Also used : EditingProperty(maspack.properties.EditingProperty) PropTreeCell(maspack.properties.PropTreeCell) InheritableProperty(maspack.properties.InheritableProperty) CompositeProperty(maspack.properties.CompositeProperty) Property(maspack.properties.Property) EditingProperty(maspack.properties.EditingProperty)

Example 8 with PropTreeCell

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

the class SelectionPopup method createPropertyDialog.

public void createPropertyDialog(Collection<? extends ModelComponent> selectedItems) {
    HostList hostList = new HostList(selectedItems);
    PropTreeCell tree = hostList.commonProperties(null, /* allowReadonly= */
    true);
    tree.removeDescendant("renderProps");
    if (tree.numChildren() == 0) {
        JOptionPane.showMessageDialog(myParentGUIComponent, "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 (myLocatePropEditClose) {
            GuiUtils.locateRelative(propDialog, myLastBounds, 0.5, 0.5, 0, 0.5);
        } else {
            propDialog.locateRight(myMain.getFrame());
        }
        // propDialog.setSynchronizeObject (myMain.getRootModel());
        myMain.registerWindow(propDialog);
        propDialog.setTitle("Properties for " + getNameForSelection(selectedItems));
        propDialog.setVisible(true);
    }
}
Also used : PropertyDialog(maspack.widgets.PropertyDialog) PropTreeCell(maspack.properties.PropTreeCell) HostList(maspack.properties.HostList)

Example 9 with PropTreeCell

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

the class PropertyWidgetDialog method createEditingProperty.

private EditingProperty createEditingProperty(Property prop) {
    if (prop.getHost() == null) {
        throw new InternalErrorException("Property " + prop.getName() + " does not have host");
    }
    HostList hostList = new HostList(1);
    hostList.addHost(prop.getHost());
    // get single property from host list
    String[] restricted = new String[] { prop.getName() };
    String[] excluded = null;
    PropTreeCell tree = hostList.commonProperties(null, /* allowReadonly= */
    false, restricted, excluded);
    if (tree.numChildren() == 0) {
        throw new InternalErrorException("Property " + prop.getName() + " not found in host");
    }
    // expand save data in hostList down one level ...
    hostList.saveBackupValues(tree);
    return new EditingProperty(tree.getFirstChild(), hostList, /* live= */
    true);
}
Also used : EditingProperty(maspack.properties.EditingProperty) PropTreeCell(maspack.properties.PropTreeCell) HostList(maspack.properties.HostList) InternalErrorException(maspack.util.InternalErrorException)

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