use of artisynth.core.workspace.RootModel in project artisynth_core by artisynth.
the class ControlPanel method setName.
public void setName(String name) {
super.setName(name);
if (myFrame != null) {
myFrame.setTitle(name == null ? "panel " + getNumber() : name);
RootModel root = Main.getMain().getRootModel();
if (root != null) {
JTabbedPane tabbedPane = root.getControlPanelTabs();
if (tabbedPane != null) {
int tabIdx = tabbedPane.indexOfComponent(myFrame.getContentPane());
if (tabIdx > -1) {
tabbedPane.setTitleAt(tabIdx, myFrame.getTitle());
}
}
}
}
}
use of artisynth.core.workspace.RootModel in project artisynth_core by artisynth.
the class ControlPanel method actionPerformed.
public void actionPerformed(ActionEvent e) {
String actionCmd = e.getActionCommand();
if (actionCmd.equals("add widget")) {
myPanel.actionPerformed(e);
} else if (actionCmd.equals("set name")) {
WidgetDialog dialog = WidgetDialog.createDialog(myFrame, "set name", "Set");
StringField widget = new StringField("name:", getName(), 20);
widget.addValueCheckListener(new ValueCheckListener() {
public Object validateValue(ValueChangeEvent e, StringHolder errMsg) {
String name = (String) e.getValue();
if (name != null && name.length() == 0) {
return null;
}
errMsg.value = ModelComponentBase.checkName(name, null);
if (errMsg.value != null) {
return Property.IllegalValue;
} else {
return name;
}
}
});
dialog.addWidget(widget);
GuiUtils.locateVertically(dialog, myFrame, GuiUtils.BELOW);
GuiUtils.locateHorizontally(dialog, myFrame, GuiUtils.CENTER);
dialog.setVisible(true);
if (dialog.getReturnValue() == OptionPanel.OK_OPTION) {
String name = (String) widget.getValue();
setName(name);
}
} else if (actionCmd.equals("save as ...")) {
Main main = Main.getMain();
RootModel root = main.getRootModel();
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(main.getModelDirectory());
int retVal = chooser.showSaveDialog(myFrame);
if (retVal == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
try {
ComponentUtils.saveComponent(file, this, new NumberFormat("%.6g"), root);
} catch (Exception ex) {
JOptionPane.showMessageDialog(myFrame, "Error saving file: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}
main.setModelDirectory(chooser.getCurrentDirectory());
}
} else if (actionCmd.equals("merge panel")) {
Main main = Main.getMain();
main.getRootModel().mergeControlPanel(true, this);
} else if (actionCmd.equals("separate panel")) {
Main main = Main.getMain();
main.getRootModel().mergeControlPanel(false, this);
} else {
throw new InternalErrorException("Unknown action: " + actionCmd);
}
}
use of artisynth.core.workspace.RootModel in project artisynth_core by artisynth.
the class Fem3dMarkerAgent method getPrototypeMap.
protected HashMap<Class, ModelComponent> getPrototypeMap() {
RootModel root = myMain.getRootModel();
if (root != null && root != myLastRootModel) {
myPrototypeMap = new HashMap<Class, ModelComponent>();
myLastRootModel = root;
}
return myPrototypeMap;
}
use of artisynth.core.workspace.RootModel in project artisynth_core by artisynth.
the class MuscleElementDescListWidget method getPrototypeMap.
protected HashMap<Class, ModelComponent> getPrototypeMap() {
RootModel root = myMain.getRootModel();
if (root != null && root != myLastRootModel) {
myPrototypeMap = new HashMap<Class, ModelComponent>();
myLastRootModel = root;
}
return myPrototypeMap;
}
use of artisynth.core.workspace.RootModel in project artisynth_core by artisynth.
the class UndoManager method getModelState.
public CompositeState getModelState() {
CompositeState state = null;
RootModel rootModel = Main.getMain().getRootModel();
if (rootModel != null) {
state = (CompositeState) rootModel.createState(null);
rootModel.getState(state);
}
return state;
}
Aggregations