use of maspack.widgets.ExpandablePropertyPanel in project artisynth_core by artisynth.
the class AddComponentAgent method setComponentType.
/**
* Called whenever the specific class type of the components being added by
* this agent is changed.
*/
public void setComponentType(Class type) {
if (type == myComponentType) {
return;
}
myComponentType = type;
if (myPrototype != null) {
setProperties(myPrototype, myPrototype);
}
myPrototype = getPrototypeComponent(type);
if (myPrototype != null) {
myHostList = new HostList(new HasProperties[] { myPrototype });
myPropTree = myHostList.commonProperties(null, false);
// remove properties which are to be excluded
String[] excludedPropNames = getExcludedPropNames(type);
for (int i = 0; i < excludedPropNames.length; i++) {
myPropTree.removeDescendant(excludedPropNames[i]);
}
myHostList.saveBackupValues(myPropTree);
myHostList.getCommonValues(myPropTree, /* live= */
true);
if (myPropertyPanelIdx != -1) {
myDefaultProps = EditingProperty.createProperties(myPropTree, myHostList, /* isLive= */
true);
LinkedList<Property> basicProps = getBasicProps(type, myDefaultProps);
if (basicProps.size() > 0) {
LinkedList<Property> extraProps = new LinkedList<Property>();
extraProps.addAll(myDefaultProps);
extraProps.removeAll(basicProps);
myPropertyPanel = new ExpandablePropertyPanel(basicProps, extraProps);
} else {
myPropertyPanel = new PropertyPanel(myDefaultProps);
}
if (myPropertyPanelBorderTitle != null) {
String title = myPropertyPanelBorderTitle;
if (title.indexOf("TYPE") != -1) {
title = title.replaceAll("TYPE", (String) myTypeSelector.getValue());
}
myPropertyPanel.setBorder(GuiUtils.createTitledPanelBorder(title));
}
resetDefaultProperties();
myPropertyPanel.updateWidgetValues(/* updateFromSource= */
false);
myPropertyPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
myContentPane.removeWidget(myPropertyPanelIdx);
myContentPane.addWidget(myPropertyPanel, myPropertyPanelIdx);
myContentPane.validate();
// myContentPane.resetLabelAlignment();
if (myDisplay.isVisible()) {
myDisplay.pack();
}
}
}
}
Aggregations