Search in sources :

Example 1 with FSPath

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;
}
Also used : FSPath(org.apache.cayenne.modeler.pref.FSPath) Preferences(java.util.prefs.Preferences) File(java.io.File)

Example 2 with FSPath

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);
        }
    });
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) BindingBuilder(org.apache.cayenne.swing.BindingBuilder) FSPath(org.apache.cayenne.modeler.pref.FSPath) File(java.io.File)

Example 3 with FSPath

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);
    }
}
Also used : FSPath(org.apache.cayenne.modeler.pref.FSPath) AbstractTableModel(javax.swing.table.AbstractTableModel)

Example 4 with FSPath

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;
}
Also used : FSPath(org.apache.cayenne.modeler.pref.FSPath)

Example 5 with FSPath

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;
}
Also used : FSPath(org.apache.cayenne.modeler.pref.FSPath)

Aggregations

FSPath (org.apache.cayenne.modeler.pref.FSPath)11 File (java.io.File)7 JFileChooser (javax.swing.JFileChooser)2 BufferedImage (java.awt.image.BufferedImage)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 URL (java.net.URL)1 BackingStoreException (java.util.prefs.BackingStoreException)1 Preferences (java.util.prefs.Preferences)1 JTextField (javax.swing.JTextField)1 AbstractTableModel (javax.swing.table.AbstractTableModel)1 DataMap (org.apache.cayenne.map.DataMap)1 BindingBuilder (org.apache.cayenne.swing.BindingBuilder)1 EOModelProcessor (org.apache.cayenne.wocompat.EOModelProcessor)1 JGraph (org.jgraph.JGraph)1