Changeset 2944 in osm for applications


Ignore:
Timestamp:
2007-05-19T23:48:54+02:00 (17 years ago)
Author:
christofd
Message:

removed test code
move surveyor frame to front after action execution

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/MetaAction.java

    r2936 r2944  
    66import java.awt.BorderLayout;
    77import java.awt.event.ActionEvent;
     8import java.awt.event.KeyEvent;
     9import java.awt.event.KeyListener;
    810import java.beans.PropertyChangeEvent;
    911import java.beans.PropertyChangeListener;
     
    1921import javax.swing.JLabel;
    2022import javax.swing.JOptionPane;
     23import javax.swing.JTextField;
    2124
    22 import at.dallermassl.josm.plugin.surveyor.action.DialogClosingThread;
     25import test.DialogClosingThread;
     26
    2327
    2428import livegps.LiveGpsData;
     
    111115            System.out.println("Surveyor: no gps data available!");
    112116        }
    113     }
    114 
    115     public void openDialog(JFrame frame) {
    116         final JOptionPane optionPane = new JOptionPane("The only way to close this dialog is by\n"
    117                         + "pressing one of the following buttons.\n" + "Do you understand?",
    118             JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);
    119 
    120         final JDialog dialog = new JDialog(frame, "Click a button", true);
    121         dialog.setContentPane(optionPane);
    122         optionPane.addPropertyChangeListener(new PropertyChangeListener() {
    123             public void propertyChange(PropertyChangeEvent e) {
    124                 String prop = e.getPropertyName();
    125 
    126                 if (dialog.isVisible() && (e.getSource() == optionPane)
    127                                 && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
    128                     // If you were going to check something
    129                     // before closing the window, you'd do
    130                     // it here.
    131                     dialog.setVisible(false);
    132                 }
    133             }
    134         });
    135         Thread closer = new DialogClosingThread(dialog);
    136         closer.start();
    137         dialog.pack();
    138         dialog.setVisible(true);
    139        
    140 
    141         System.out.println("value: " + optionPane.getValue().getClass());
    142 
    143 //        int value = ((Integer) optionPane.getValue()).intValue();
    144 //        if (value == JOptionPane.YES_OPTION) {
    145 //            System.out.println("yes");
    146 //        } else if (value == JOptionPane.NO_OPTION) {
    147 //            System.out.println("no");
    148 //        }
    149 
     117        JFrame frame = SurveyorPlugin.getSurveyorFrame();
     118        if(frame != null && frame.isVisible()) {
     119            frame.toFront();
     120        }
    150121    }
    151122
     
    156127        this.gpsDataSource = gpsDataSource;
    157128    }
    158    
    159     public static void main(String[] args) {
    160       //1. Create the frame.
    161         JFrame frame = new JFrame("FrameDemo");
    162 
    163         //2. Optional: What happens when the frame closes?
    164         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    165 
    166         //3. Create components and put them in the frame.
    167         //...create emptyLabel...
    168         frame.getContentPane().add(new JLabel("test"), BorderLayout.CENTER);
    169 
    170         //4. Size the frame.
    171         frame.pack();
    172         frame.setSize(600,400);
    173         frame.setLocation(0,0);
    174 
    175         //5. Show it.
    176         frame.setVisible(true);
    177         System.out.println("after visible");
    178         new MetaAction().openDialog(frame);
    179     }
    180 
    181129}
Note: See TracChangeset for help on using the changeset viewer.