Search in sources :

Example 1 with ModuleSaver

use of org.opt4j.core.config.ModuleSaver in project opt4j by felixreimann.

the class FileOperations method save.

/**
 * Saves the current selected modules to the specified file.
 *
 * @param file
 *            the configuration file
 */
public void save(File file) {
    setFile(file);
    ModuleSaver saver = new ModuleSaver();
    Collection<PropertyModule> modules = selectedModules;
    System.out.println(modules);
    saver.save(file, modules);
    System.out.println("Saved configuration to " + file);
}
Also used : ModuleSaver(org.opt4j.core.config.ModuleSaver) PropertyModule(org.opt4j.core.config.PropertyModule)

Example 2 with ModuleSaver

use of org.opt4j.core.config.ModuleSaver in project opt4j by felixreimann.

the class ToolBar method startup.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.opt4j.conf.gui.Startupable#startup()
	 */
@Override
public void startup() {
    execute = new JButton("Run ", Icons.getIcon(Icons.PLAY)) {

        {
            setFocusable(false);
            setMnemonic(KeyEvent.VK_R);
            addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    Set<Module> modules = new HashSet<Module>();
                    modules.addAll(selectedModules);
                    executionEnvironment.execute(modules);
                }
            });
        }
    };
    load = new JButton("Load ... ", Icons.getIcon(Icons.FOLDER)) {

        {
            setFocusable(false);
            setMnemonic(KeyEvent.VK_L);
            addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    fileOperations.load();
                }
            });
        }
    };
    save = new JButton("Save ", Icons.getIcon(Icons.DISK)) {

        {
            setFocusable(false);
            setMnemonic(KeyEvent.VK_S);
            setEnabled(false);
            addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    fileOperations.save();
                }
            });
        }
    };
    saveAs = new JButton("Save As ... ", Icons.getIcon(Icons.DISK)) {

        {
            setFocusable(false);
            setMnemonic(KeyEvent.VK_A);
            addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    fileOperations.saveAs();
                }
            });
        }
    };
    showXML = new JButton("Show configuration", Icons.getIcon(Icons.XML)) {

        {
            setFocusable(false);
            setMnemonic(KeyEvent.VK_X);
            addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    ModuleSaver saver = new ModuleSaver();
                    ClipboardFrame clipboardFrame = new ClipboardFrame(saver.toXMLString(selectedModules));
                    clipboardFrame.pack();
                    clipboardFrame.setVisible(true);
                }
            });
        }
    };
    add(execute);
    addSeparator();
    add(load);
    add(save);
    add(saveAs);
    addSeparator();
    add(showXML);
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) ModuleSaver(org.opt4j.core.config.ModuleSaver) Module(com.google.inject.Module) HashSet(java.util.HashSet)

Aggregations

ModuleSaver (org.opt4j.core.config.ModuleSaver)2 Module (com.google.inject.Module)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 HashSet (java.util.HashSet)1 JButton (javax.swing.JButton)1 PropertyModule (org.opt4j.core.config.PropertyModule)1