Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /openetl/src/org/tigris/openetl/ui/

openetl
Discussion topic

Back to topic list

CVS update: /openetl/src/org/tigris/openetl/ui/

Reply

Author ernani_joppert
Full name Ernani Joppert Pontes Martins
Date 2004-08-11 08:26:08 PDT
Message User: ernani_joppert
Date: 04/08/11 08:26:08

Added:
 /openetl/src/org/tig​ris/openetl/ui/
  OpenFileAction.java, SaveFileAction.java

Modified:
 /openetl/src/org/tig​ris/openetl/ui/
  MenuBar.java, ToolBar.java

Log:
 Added JFileChooser events.

File Changes:

Directory: /openetl/src/org/tig​ris/openetl/ui/
====================​====================​======

File [added]: OpenFileAction.java
Url: http://openetl.tigri​s.org/source/browse/​openetl/src/org/tigr​is/openetl/ui/OpenFi​leAction.java?rev=1.​1&content-type=t​ext/vnd.viewcvs-mark​up
Added lines: 68
---------------
/*
 * Created on 11/08/2004
 */
package org.tigris.openetl.ui;

import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.io.File;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.KeyStroke;

/**
 * @author Ernani Joppert Pontes Martins
 *
 * This action creates and shows a modal open-file dialog.
 */
public class OpenFileAction extends AbstractAction {

    /**
     * The frame attribute.
     */
    private JFrame frame = null;

    /**
     * The chooser attribute.
     */
    private JFileChooser chooser;

    /**
     * Default constructor.
     *
     * @param fr
     * The JFrame to set.
     * @param ch
     * The JFileChooser to set.
     */
    public OpenFileAction(JFrame fr, JFileChooser ch, boolean putName) {

        // keyboard shortcut
        this.putValue(Action​.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
                KeyEvent.VK_O, ActionEvent.CTRL_MASK));

        if (putName) {
            this.putValue(Action.NAME, "Open...");
        }

        this.chooser = ch;
        this.frame = fr;
    }

    /*
     * (non-Javadoc)
     *
     * @see java.awt.event.Actio​nListener#actionPerf​ormed(java.awt.event​.ActionEvent)
     */
    public void actionPerformed(ActionEvent evt) {

        // Show dialog; this method does not return until dialog is closed
        chooser.showOpenDialog(frame);

        // Get the selected file
        File file = chooser.getSelectedFile();
    }
}

File [added]: SaveFileAction.java
Url: http://openetl.tigri​s.org/source/browse/​openetl/src/org/tigr​is/openetl/ui/SaveFi​leAction.java?rev=1.​1&content-type=t​ext/vnd.viewcvs-mark​up
Added lines: 68
---------------
/*
 * Created on 11/08/2004
 */
package org.tigris.openetl.ui;

import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.io.File;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.KeyStroke;

/**
 * @author Ernani Joppert Pontes Martins
 *
 * This action creates and shows a modal save-file dialog.
 */
public class SaveFileAction extends AbstractAction {

    /**
     * The chooser attribute.
     */
    private JFileChooser chooser = null;

    /**
     * The frame attribute.
     */
    private JFrame frame = null;

    /**
     * Default constructor.
     *
     * @param fr
     * The JFrame to set.
     * @param ch
     * The JFileChooser to set.
     */
    public SaveFileAction(JFrame fr, JFileChooser ch, boolean putName) {

        // keyboard shortcut.
        this.putValue(Action​.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
                KeyEvent.VK_S, ActionEvent.CTRL_MASK));

        if (putName) {
            this.putValue(Action.NAME, "Save As...");
        }

        this.chooser = ch;
        this.frame = fr;
    }

    /*
     * (non-Javadoc)
     *
     * @see java.awt.event.Actio​nListener#actionPerf​ormed(java.awt.event​.ActionEvent)
     */
    public void actionPerformed(ActionEvent e) {

        // Show dialog; this method does not return until dialog is closed
        chooser.showSaveDialog(frame);

        // Get the selected file
        File file = chooser.getSelectedFile();
    }
}

File [changed]: MenuBar.java
Url: http://openetl.tigri​s.org/source/browse/​openetl/src/org/tigr​is/openetl/ui/MenuBa​r.java?r1=1.4&r2​=1.5
Delta lines: +15 -5
--------------------
--- MenuBar.java 9 Aug 2004 20:20:23 -0000 1.4
+++ MenuBar.java 11 Aug 2004 15:26:08 -0000 1.5
@@ -6,6 +6,7 @@
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
 
+import javax.swing.JFileChooser;
 import javax.swing.JMenu;
 import javax.swing.JMenuBar;
 import javax.swing.JMenuItem;
@@ -29,6 +30,9 @@
      */
     public MenuBar(MainFrame frame) {
 
+ // File chooser handler
+ JFileChooser fc = new JFileChooser("*.etl");
+
         // Set up the application's main menu.
         JMenu menu = new JMenu("File");
         menu.setMnemonic(Key​Event.VK_D);
@@ -37,7 +41,8 @@
         // Set up the new project menu item.
         JMenuItem menuItem = new JMenuItem("New Project");
         menuItem.setMnemonic​(KeyEvent.VK_N);
- menuItem.setAccelera​tor(KeyStroke.getKey​Stroke(KeyEvent.VK_N​, ActionEvent.ALT_MASK));
+ menuItem.setAccelera​tor(KeyStroke.getKey​Stroke(KeyEvent.VK_N​,
+ ActionEvent.CTRL_MASK));
         menuItem.setActionCo​mmand(Application.CO​MMAND_NEW);
         menuItem.addActionLi​stener(frame);
         menu.add(menuItem);
@@ -45,15 +50,20 @@
         // Set up the open project menu item.
         menuItem = new JMenuItem("Open Project");
         menuItem.setMnemonic​(KeyEvent.VK_O);
- menuItem.setAccelera​tor(KeyStroke.getKey​Stroke(KeyEvent.VK_O​, ActionEvent.CTRL_MASK));
- menuItem.setActionCo​mmand(Application.CO​MMAND_OPEN);
- menuItem.addActionLi​stener(frame);
+ menuItem.setAction(new OpenFileAction(frame, fc, true));
+ menu.add(menuItem);
+
+ // Set up the save project menu item.
+ menuItem = new JMenuItem("Save Project");
+ menuItem.setMnemonic​(KeyEvent.VK_S);
+ menuItem.setAction(new SaveFileAction(frame, fc, true));
         menu.add(menuItem);
 
         // Set up the quit menu item.
         menuItem = new JMenuItem("Quit");
         menuItem.setMnemonic​(KeyEvent.VK_Q);
- menuItem.setAccelera​tor(KeyStroke.getKey​Stroke(KeyEvent.VK_Q​, ActionEvent.ALT_MASK));
+ menuItem.setAccelera​tor(KeyStroke.getKey​Stroke(KeyEvent.VK_Q​,
+ ActionEvent.CTRL_MASK));
         menuItem.setActionCo​mmand(Application.CO​MMAND_QUIT);
         menuItem.addActionLi​stener(frame);
         menu.add(menuItem);

File [changed]: ToolBar.java
Url: http://openetl.tigri​s.org/source/browse/​openetl/src/org/tigr​is/openetl/ui/ToolBa​r.java?r1=1.4&r2​=1.5
Delta lines: +8 -6
-------------------
--- ToolBar.java 9 Aug 2004 20:20:23 -0000 1.4
+++ ToolBar.java 11 Aug 2004 15:26:08 -0000 1.5
@@ -3,8 +3,11 @@
  */
 package org.tigris.openetl.ui;
 
+import java.io.File;
+
 import javax.swing.ImageIcon;
 import javax.swing.JButton;
+import javax.swing.JFileChooser;
 import javax.swing.JToolBar;
 import javax.swing.border.BevelBorder;
 
@@ -38,6 +41,7 @@
     protected void addButtons(JToolBar toolBar, MainFrame frame) {
 
         JButton button = null;
+ JFileChooser fc = new JFileChooser(new File("*.etl"));
 
         // new project button
         button = new JButton(new ImageIcon("images/new.gif"));
@@ -47,17 +51,15 @@
         toolBar.add(button);
 
         // open button
- button = new JButton(new ImageIcon("images/open.gif"));
- button.setActionComm​and(Application.COMM​AND_OPEN);
+ button = new JButton(new OpenFileAction(frame, fc, false));
+ button.setIcon(new ImageIcon("images/open.gif"));
         button.setToolTipText("Choose a Project to Open");
- button.addActionList​ener(frame);
         toolBar.add(button);
 
         // save button
- button = new JButton(new ImageIcon("images/save.gif"));
- button.setActionComm​and(Application.COMM​AND_SAVE);
+ button = new JButton(new SaveFileAction(frame, fc, false));
+ button.setIcon(new ImageIcon("images/save.gif"));
         button.setToolTipText("Saves the current project");
- button.addActionList​ener(frame);
         toolBar.add(button);
     }
 }




--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@open​etl.tigris.org
For additional commands, e-mail: cvs-help at openetl dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /openetl/src/org/tigris/openetl/ui/ ernani_joppert Ernani Joppert Pontes Martins 2004-08-11 08:26:08 PDT
Messages per page: