Ignore:
Timestamp:
2012-02-26T21:04:29+01:00 (12 years ago)
Author:
malcolmh
Message:

'New release'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/smed/src/smed/tabs/SmedTabAction.java

    r27852 r27943  
    2323public class SmedTabAction extends JosmAction {
    2424
    25     /**
     25        /**
    2626     *
    2727     */
     
    3131        private JFrame frame = null;
    3232        private boolean isOpen = false;
    33         private JMenuItem osmItem =null;
     33        private JMenuItem osmItem = null;
    3434        public static JTextField smedStatusBar = null;
    35         private static String editor =tr("SeaMap Editor");
    36        
    37     public SmedTabAction() {
    38         super( editor, "Smed",editor,
    39             Shortcut.registerShortcut("tools:Seamaps", tr("Tool: {0}", tr("SeaMap Editor")),
    40             KeyEvent.VK_K, Shortcut.SHIFT),
    41             true);  //$NON-NLS-1$ //$NON-NLS-2$
    42     }
     35        private static String editor = tr("SeaMap Editor");
    4336
     37        public SmedTabAction() {
     38//        super( editor, "Smed",editor, Shortcut.registerShortcut("tools:Seamaps", tr("Tool: {0}", tr("SeaMap Editor")), KeyEvent.VK_K, Shortcut.SHIFT), true);  //$NON-NLS-1$ //$NON-NLS-2$
     39        }
    4440
    45     @Override
    46     public void actionPerformed(ActionEvent e) {
    47         SwingUtilities.invokeLater(new Runnable() {
    48             public void run() {
    49                 createAndShowTabs();
    50             }
    51         });
    52        
    53         isOpen = true;
    54                 if (osmItem == null) return;
     41        @Override
     42        public void actionPerformed(ActionEvent e) {
     43                SwingUtilities.invokeLater(new Runnable() {
     44                        public void run() {
     45                                createAndShowTabs();
     46                        }
     47                });
     48
     49                isOpen = true;
     50                if (osmItem == null)
     51                        return;
    5552
    5653                osmItem.setEnabled(false);
    57     }
     54        }
    5855
     56        protected void createAndShowTabs() {
     57                // Create and set up the window.
     58                frame = new JFrame(editor);
     59                smedStatusBar = new JTextField();
     60                frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
     61                frame.setResizable(false);
     62                frame.setAlwaysOnTop(true);
    5963
    60     protected void createAndShowTabs() {
    61         //Create and set up the window.
    62         frame = new JFrame(editor);
    63         smedStatusBar = new JTextField();
    64         frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    65         frame.setResizable(false);
    66         frame.setAlwaysOnTop(true);
     64                // Add content to the window.
     65                frame.setJMenuBar(smedMenu);
     66                frame.add(smedTabs, BorderLayout.CENTER);
     67                frame.add(smedStatusBar, BorderLayout.PAGE_END);
    6768
    68         //Add content to the window.
    69         frame.setJMenuBar(smedMenu);
    70         frame.add(smedTabs, BorderLayout.CENTER);
    71         frame.add(smedStatusBar,BorderLayout.PAGE_END);
     69                // Display the window.
     70                frame.addWindowListener(new java.awt.event.WindowAdapter() {
     71                        public void windowClosing(java.awt.event.WindowEvent e) {
     72                                osmItem.setEnabled(true);
    7273
    73         //Display the window.
    74         frame.addWindowListener(new java.awt.event.WindowAdapter() {
    75                 public void windowClosing(java.awt.event.WindowEvent e) {
    76                         osmItem.setEnabled(true);
    77                        
    78                         closeDialog();
    79                 }
    80         });
    81         frame.setSize(new Dimension(420, 470));
    82         // frame.pack();
    83         frame.setVisible(true);
    84     }
    85 
     74                                closeDialog();
     75                        }
     76                });
     77                frame.setSize(new Dimension(420, 470));
     78                // frame.pack();
     79                frame.setVisible(true);
     80        }
    8681
    8782        public void closeDialog() {
    8883                List<SmedPluggable> plugins = SmedTabbedPane.getPlugins();
    89                
    90                 if(plugins != null) {
    91                         for(SmedPluggable p : plugins) p.stop();
     84
     85                if (plugins != null) {
     86                        for (SmedPluggable p : plugins)
     87                                p.stop();
    9288                }
    93                
    94                 if(isOpen) {
     89
     90                if (isOpen) {
    9591                        frame.setVisible(false);
    9692                        frame.dispose();
    9793                }
    98                
     94
    9995                isOpen = false;
    10096        }
    10197
    102 
    10398        public void setOsmItem(JMenuItem item) {
    104                 osmItem = item;         
     99                osmItem = item;
    105100        }
    106101
Note: See TracChangeset for help on using the changeset viewer.