use of org.apache.cayenne.modeler.pref.FSPath in project cayenne by apache.
the class TemplateCreator method createTemplate.
protected FSPath createTemplate() {
if (canceled) {
return null;
}
String key = view.getTemplateName().getText();
File file = view.getTemplateChooser().getFile();
Preferences newNode = preferences.node(key);
FSPath path = (FSPath) application.getCayenneProjectPreferences().getProjectDetailObject(FSPath.class, newNode);
editor.getAddedNode().add(newNode);
path.setPath(file != null ? file.getAbsolutePath() : null);
return path;
}
use of org.apache.cayenne.modeler.pref.FSPath in project cayenne by apache.
the class TemplateCreator method initBindings.
protected void initBindings() {
BindingBuilder builder = new BindingBuilder(getApplication().getBindingFactory(), this);
builder.bindToAction(view.getCancelButton(), "cancelAction()");
builder.bindToAction(view.getOkButton(), "okAction()");
final FSPath path = getLastTemplateDirectory();
view.getTemplateChooser().setCurrentDirectory(path.getExistingDirectory(false));
view.getTemplateChooser().addPropertyChangeListener(FileChooser.CURRENT_DIRECTORY_PROPERTY, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
File directory = view.getTemplateChooser().getCurrentDirectory();
path.setDirectory(directory);
}
});
}
use of org.apache.cayenne.modeler.pref.FSPath in project cayenne by apache.
the class TemplatePreferences method addTemplateAction.
public void addTemplateAction() {
FSPath path = new TemplateCreator(this).startupAction();
if (path != null) {
int len = templateEntries.size();
templateEntries.add(path);
((AbstractTableModel) view.getTable().getModel()).fireTableRowsInserted(len, len);
}
}
use of org.apache.cayenne.modeler.pref.FSPath in project cayenne by apache.
the class CayenneController method getLastDirectory.
/**
* Returns last file system directory visited by user for this component. If there is
* no such directory set up in the preferences, creates a new object, setting its path
* to the parent last directory or to the user HOME directory.
*/
public FSPath getLastDirectory() {
// find start directory in preferences
FSPath path = (FSPath) application.getCayenneProjectPreferences().getProjectDetailObject(FSPath.class, getViewPreferences().node("lastDir"));
if (path.getPath() == null) {
String pathString = (getParent() != null) ? getParent().getLastDirectory().getPath() : System.getProperty("user.home");
path.setPath(pathString);
}
return path;
}
use of org.apache.cayenne.modeler.pref.FSPath in project cayenne by apache.
the class ImportEOModelAction method getEOModelChooser.
/**
* Returns EOModel chooser.
*/
public JFileChooser getEOModelChooser() {
if (eoModelChooser == null) {
eoModelChooser = new EOModelChooser("Select EOModel");
}
FSPath lastDir = getApplication().getFrameController().getLastEOModelDirectory();
lastDir.updateChooser(eoModelChooser);
return eoModelChooser;
}
Aggregations