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);
}
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);
}
}
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);
}
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);
}
}
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);
}
Aggregations