001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/src/org/deegree/tools/legend/LecGUI.java $
002 /*---------------- FILE HEADER ------------------------------------------
003
004 This file is part of deegree.
005 Copyright (C) 2001-2008 by:
006 EXSE, Department of Geography, University of Bonn
007 http://www.giub.uni-bonn.de/deegree/
008 lat/lon GmbH
009 http://www.lat-lon.de
010
011 This library is free software; you can redistribute it and/or
012 modify it under the terms of the GNU Lesser General Public
013 License as published by the Free Software Foundation; either
014 version 2.1 of the License, or (at your option) any later version.
015
016 This library is distributed in the hope that it will be useful,
017 but WITHOUT ANY WARRANTY; without even the implied warranty of
018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019 Lesser General Public License for more details.
020
021 You should have received a copy of the GNU Lesser General Public
022 License along with this library; if not, write to the Free Software
023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024
025 Contact:
026
027 Andreas Poth
028 lat/lon GmbH
029 Aennchenstr. 19
030 53115 Bonn
031 Germany
032 E-Mail: poth@lat-lon.de
033
034 Prof. Dr. Klaus Greve
035 Department of Geography
036 University of Bonn
037 Meckenheimer Allee 166
038 53115 Bonn
039 Germany
040 E-Mail: greve@giub.uni-bonn.de
041
042
043 ---------------------------------------------------------------------------*/
044
045 package org.deegree.tools.legend;
046
047 import java.awt.BorderLayout;
048 import java.awt.Color;
049 import java.awt.Dimension;
050 import java.awt.Font;
051 import java.awt.GridBagConstraints;
052 import java.awt.GridBagLayout;
053 import java.awt.Insets;
054 import java.awt.event.ActionEvent;
055 import java.awt.event.ActionListener;
056 import java.io.File;
057
058 import javax.swing.JButton;
059 import javax.swing.JComboBox;
060 import javax.swing.JDialog;
061 import javax.swing.JFileChooser;
062 import javax.swing.JFrame;
063 import javax.swing.JLabel;
064 import javax.swing.JMenu;
065 import javax.swing.JMenuBar;
066 import javax.swing.JMenuItem;
067 import javax.swing.JOptionPane;
068 import javax.swing.JPanel;
069 import javax.swing.JScrollPane;
070 import javax.swing.JSpinner;
071 import javax.swing.JTextArea;
072 import javax.swing.JTextField;
073 import javax.swing.border.TitledBorder;
074
075 import org.deegree.framework.log.ILogger;
076 import org.deegree.framework.log.LoggerFactory;
077
078 /**
079 * This GUI is for creating Legend Element, which are small thumbnails with textlabel and title
080 * showing the defined styles from a SLD.
081 *
082 * @author <a href="mailto:poth@lat-lon.de">Andreas Poth </a>
083 * @author last edited by: $Author:wanhoff$
084 *
085 * @version $Revision: 9346 $, $Date:26.03.2007$
086 */
087 public class LecGUI extends JPanel {
088
089 private static final ILogger LOG = LoggerFactory.getLogger( LecGUI.class );
090
091 private static String TITLE = "LEC LegendElementCreator GUI - v1.0.1";
092
093 private String lastDir = ".";
094
095 private static String DEFAULTFORMAT = "png";
096
097 private static String DEFAULTCOLOR = "white";
098
099 private static int DEFAULTWIDTH = 40;
100
101 private static int DEFAULTHEIGHT = 40;
102
103 private static String[] POSSIBLE_OUTPUT_FORMAT = { "bmp", "gif", "jpg", "png", "tif" };
104
105 private static String[] POSSIBLE_OUTPUT_COLORS = { "transp.", "black", "blue", "cyan",
106 "dark_gray", "gray", "green", "light_gray",
107 "magenta", "orange", "pink", "red", "white",
108 "yellow" };
109
110 // GUI Variables declaration //
111 private JPanel filePanel;
112
113 private JTextField sourcesld_tf;
114
115 private JTextField targetdir_tf;
116
117 protected static final String BTOPENSOURCE = "opensourcefile";
118
119 protected static final String BTOPENTARGET = "opentargetdir";
120
121 private JPanel optionsPanel;
122
123 private JComboBox formatCBox;
124
125 private JComboBox colorCBox;
126
127 private JSpinner widthspinner;
128
129 private JSpinner heightspinner;
130
131 private JTextField titletextfield;
132
133 private JPanel buttonPanel;
134
135 private JButton startbutton;
136
137 private JButton infobutton;
138
139 private JButton exitbutton;
140
141 protected static final String BTSTART = "START";
142
143 protected static final String BTINFO = "INFO";
144
145 protected static final String BTEXIT = "EXIT";
146
147 private JPanel debugPanel;
148
149 private JTextArea debugTextArea;
150
151 private static final String FILEMENU = "File";
152
153 protected static final String OPENSOURCEMENUITEM = "Open Source SLD";
154
155 protected static final String OPENTARGETMENUITEM = "Open Target Directory";
156
157 protected static final String STARTMENUITEM = "Start";
158
159 protected static final String EXITMENUITEM = "Exit";
160
161 private static final String HELPMENU = "Help";
162
163 protected static final String INFOMENUITEM = "Info";
164
165 // Action Handler
166 LecGUIButtonHandler bel = null;
167
168 LecGUIMenuHandler mel = null;
169
170 /**
171 * Creates new form LecGUI
172 *
173 */
174 private LecGUI() {
175
176 bel = new LecGUIButtonHandler( this );
177 mel = new LecGUIMenuHandler( this );
178 initComponents();
179 }
180
181 /**
182 * initializes the GUI. Calls several methods, which inits the several gui-elements.
183 */
184 private void initComponents() {
185 setLayout( new BorderLayout() );
186
187 JPanel northPanel = new JPanel( new BorderLayout() );
188
189 JPanel menuPanel = new JPanel( new BorderLayout() );
190 JMenuBar menubar = initMenuBar();
191 menuPanel.add( menubar, BorderLayout.BEFORE_FIRST_LINE );
192 northPanel.add( menuPanel, BorderLayout.NORTH );
193
194 JPanel mainPanel = new JPanel( new BorderLayout() );
195
196 filePanel = initFilePanel();
197 filePanel.setBorder( new javax.swing.border.EmptyBorder( new Insets( 10, 10, 10, 10 ) ) );
198 mainPanel.add( filePanel, BorderLayout.NORTH );
199
200 optionsPanel = initOptionsPanel();
201 optionsPanel.setBorder( new javax.swing.border.EmptyBorder( new Insets( 10, 10, 10, 10 ) ) );
202 mainPanel.add( optionsPanel, BorderLayout.WEST );
203
204 buttonPanel = initButtonPanel();
205 buttonPanel.setBorder( new javax.swing.border.EmptyBorder( new Insets( 10, 10, 10, 10 ) ) );
206 mainPanel.add( buttonPanel, BorderLayout.EAST );
207
208 northPanel.add( mainPanel, BorderLayout.CENTER );
209 add( northPanel, BorderLayout.NORTH );
210
211 debugPanel = initDebugPanel();
212 debugPanel.setBorder( new TitledBorder( null, "Debug", TitledBorder.DEFAULT_JUSTIFICATION,
213 TitledBorder.DEFAULT_POSITION,
214 new java.awt.Font( "Dialog", 0, 10 ) ) );
215 add( debugPanel, BorderLayout.CENTER );
216 }
217
218 /**
219 *
220 * @return
221 */
222 private JPanel initDebugPanel() {
223 JPanel panel = new JPanel( new BorderLayout() );
224
225 JScrollPane jScrollPane1 = new JScrollPane();
226 jScrollPane1.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
227 jScrollPane1.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS );
228 this.debugTextArea = new JTextArea();
229 this.debugTextArea.setFont( new java.awt.Font( "Monospaced", 0, 11 ) );
230 this.debugTextArea.setEditable( false );
231 this.debugTextArea.setText( "You can mark this debug-output (per mouse or STRG + A)\n"
232 + "and copy it (STRG + C) to the clipboard.\n" );
233
234 panel.setLayout( new java.awt.BorderLayout() );
235
236 jScrollPane1.setViewportView( debugTextArea );
237
238 panel.add( jScrollPane1, java.awt.BorderLayout.CENTER );
239 panel.setPreferredSize( new Dimension( 150, 150 ) );
240
241 return panel;
242 }
243
244 /**
245 * inits the filepanel, the panel at the top to choose the files.
246 *
247 * @return the JPanel containing the gui-elements to open the file and dir.
248 */
249 private JPanel initFilePanel() {
250 JPanel filePanel = new JPanel();
251 GridBagLayout gridbag = new GridBagLayout();
252 GridBagConstraints c = new GridBagConstraints();
253 filePanel.setLayout( gridbag );
254 c.fill = GridBagConstraints.HORIZONTAL;
255 c.insets = new Insets( 2, 2, 2, 2 );
256
257 JLabel label1 = new JLabel( "Source SLD-File:" );
258 label1.setFont( new Font( "Dialog", 0, 12 ) );
259 c.weightx = 0;
260 c.gridx = 0;
261 c.gridy = 0;
262 gridbag.setConstraints( label1, c );
263 filePanel.add( label1 );
264
265 sourcesld_tf = new JTextField();
266 sourcesld_tf.setColumns( 25 );
267 c.weightx = 0.5;
268 c.gridx = 1;
269 gridbag.setConstraints( sourcesld_tf, c );
270 filePanel.add( sourcesld_tf );
271
272 JButton open1 = new JButton( "open" );
273 open1.setFont( new Font( "Dialog", 0, 12 ) );
274 open1.setActionCommand( BTOPENSOURCE );
275 open1.addActionListener( bel );
276 c.weightx = 0;
277 c.gridx = 3;
278 gridbag.setConstraints( open1, c );
279 filePanel.add( open1 );
280
281 // 2
282
283 JLabel label2 = new JLabel( "Target Directory:" );
284 label2.setFont( new Font( "Dialog", 0, 12 ) );
285 c.weightx = 0;
286 c.gridx = 0;
287 c.gridy = 1;
288 gridbag.setConstraints( label2, c );
289 filePanel.add( label2 );
290
291 targetdir_tf = new JTextField();
292 targetdir_tf.setColumns( 25 );
293 c.weightx = 0.5;
294 c.gridx = 1;
295 gridbag.setConstraints( targetdir_tf, c );
296 filePanel.add( targetdir_tf );
297
298 JButton open2 = new JButton( "open" );
299 open2.setFont( new Font( "Dialog", 0, 12 ) );
300 open2.setActionCommand( BTOPENTARGET );
301 open2.addActionListener( bel );
302 c.weightx = 0;
303 c.gridx = 3;
304 gridbag.setConstraints( open2, c );
305 filePanel.add( open2 );
306
307 return filePanel;
308 }
309
310 /**
311 * inits the option-panel.
312 *
313 * @return the option-panel containing the gui-elements to choose the options
314 */
315 private JPanel initOptionsPanel() {
316 JPanel bp = new JPanel();
317 GridBagLayout gridbag = new GridBagLayout();
318 GridBagConstraints c = new GridBagConstraints();
319 bp.setLayout( gridbag );
320 c.fill = GridBagConstraints.HORIZONTAL;
321 c.insets = new Insets( 2, 2, 2, 2 );
322
323 // FORMAT
324
325 JLabel formatlabel = new JLabel( "output format: " );
326 formatlabel.setFont( new Font( "Dialog", 0, 12 ) );
327 c.weightx = 0;
328 c.gridx = 0;
329 c.gridy = 0;
330 gridbag.setConstraints( formatlabel, c );
331 bp.add( formatlabel );
332
333 formatCBox = new JComboBox( POSSIBLE_OUTPUT_FORMAT );
334 formatCBox.setSelectedItem( DEFAULTFORMAT );
335 formatCBox.setFont( new Font( "Dialog", 0, 12 ) );
336 c.weightx = 0;
337 c.gridx = 1;
338 c.gridy = 0;
339 gridbag.setConstraints( formatCBox, c );
340 bp.add( formatCBox );
341
342 // BGCOLOR
343
344 JLabel colorlabel = new JLabel( "background color: " );
345 colorlabel.setFont( new Font( "Dialog", 0, 12 ) );
346 c.weightx = 0;
347 c.gridx = 0;
348 c.gridy = 1;
349 gridbag.setConstraints( colorlabel, c );
350 bp.add( colorlabel );
351
352 colorCBox = new JComboBox( POSSIBLE_OUTPUT_COLORS );
353 colorCBox.setSelectedItem( DEFAULTCOLOR );
354 colorCBox.setFont( new Font( "Dialog", 0, 12 ) );
355 c.weightx = 0;
356 c.gridx = 1;
357 c.gridy = 1;
358 gridbag.setConstraints( colorCBox, c );
359 bp.add( colorCBox );
360
361 // WIDTH
362
363 JLabel widthlabel = new JLabel( "width:" );
364 widthlabel.setFont( new Font( "Dialog", 0, 12 ) );
365 c.weightx = 0;
366 c.gridx = 0;
367 c.gridy = 2;
368 gridbag.setConstraints( widthlabel, c );
369 bp.add( widthlabel );
370
371 widthspinner = new JSpinner();
372 widthspinner.setValue( new Integer( DEFAULTWIDTH ) );
373 c.weightx = 0;
374 c.gridx = 1;
375 c.gridy = 2;
376 gridbag.setConstraints( widthspinner, c );
377 bp.add( widthspinner );
378
379 // HEIGHT
380
381 JLabel heightlabel = new JLabel( "height:" );
382 heightlabel.setFont( new Font( "Dialog", 0, 12 ) );
383 c.weightx = 0;
384 c.gridx = 0;
385 c.gridy = 3;
386 gridbag.setConstraints( heightlabel, c );
387 bp.add( heightlabel );
388
389 heightspinner = new JSpinner();
390 heightspinner.setValue( new Integer( DEFAULTHEIGHT ) );
391 c.weightx = 0;
392 c.gridx = 1;
393 c.gridy = 3;
394 gridbag.setConstraints( heightspinner, c );
395 bp.add( heightspinner );
396
397 // TITLE
398
399 JLabel titlelabel = new JLabel( "title:" );
400 titlelabel.setFont( new Font( "Dialog", 0, 12 ) );
401 c.weightx = 0;
402 c.gridx = 0;
403 c.gridy = 4;
404 gridbag.setConstraints( titlelabel, c );
405 bp.add( titlelabel );
406
407 titletextfield = new JTextField();
408 c.weightx = 0;
409 c.gridx = 1;
410 c.gridy = 4;
411 gridbag.setConstraints( titletextfield, c );
412 bp.add( titletextfield );
413
414 return bp;
415 }
416
417 /**
418 * inits the button-panel
419 *
420 * @return the button-panel containing the start, info and exit buttons.
421 */
422 private JPanel initButtonPanel() {
423 JPanel bp = new JPanel();
424
425 startbutton = new JButton( "Start" );
426 infobutton = new JButton( "Info" );
427 exitbutton = new JButton( "Exit" );
428
429 startbutton.setFont( new Font( "Dialog", 0, 12 ) );
430 infobutton.setFont( new Font( "Dialog", 0, 12 ) );
431 exitbutton.setFont( new Font( "Dialog", 0, 12 ) );
432
433 startbutton.setActionCommand( BTSTART );
434 startbutton.addActionListener( bel );
435 infobutton.setActionCommand( BTINFO );
436 infobutton.addActionListener( bel );
437 exitbutton.setActionCommand( BTEXIT );
438 exitbutton.addActionListener( bel );
439
440 bp.add( startbutton );
441 bp.add( infobutton );
442 bp.add( exitbutton );
443
444 return bp;
445 }
446
447 /**
448 * creates the menubar. called from the main-method, not the constructor.
449 *
450 * @return the menubar.
451 */
452 private JMenuBar initMenuBar() {
453 JMenuBar menuBar = new JMenuBar();
454
455 // file menu
456 JMenu menu = new JMenu( FILEMENU );
457 appendMenuItem( OPENSOURCEMENUITEM, menu );
458 appendMenuItem( OPENTARGETMENUITEM, menu );
459 menu.addSeparator();
460 appendMenuItem( STARTMENUITEM, menu );
461 menu.addSeparator();
462 appendMenuItem( EXITMENUITEM, menu );
463 menuBar.add( menu );
464
465 // info / help menu
466 menu = new JMenu( HELPMENU );
467 appendMenuItem( INFOMENUITEM, menu );
468 menuBar.add( menu );
469
470 return menuBar;
471
472 }
473
474 /**
475 * help method to init the menu
476 *
477 * @param name
478 * name of the menu-item
479 * @param menu
480 * the menu
481 */
482 private void appendMenuItem( String name, JMenu menu ) {
483 JMenuItem item = menu.add( name );
484 item.addActionListener( mel );
485 }
486
487 /**
488 * returns the content of the open dialog source-textfield
489 *
490 * @return content of the source-textfield
491 */
492 private String getSourceTextfieldContent() {
493 return this.sourcesld_tf.getText();
494 }
495
496 /**
497 * @see #getSourceTextfieldContent()
498 * @param content
499 * the text in the source-textfield
500 */
501 private void setSourceTextfieldContent( String content ) {
502 this.sourcesld_tf.setText( content );
503 }
504
505 /**
506 * returns the content of the open dialog destination/target-textfield
507 *
508 * @return content of the targetdir-textfield
509 */
510 private String getDestDirTextfieldContent() {
511 return this.targetdir_tf.getText();
512 }
513
514 /**
515 * @see #getDestDirTextfieldContent()
516 * @param content
517 * the text in the targetdir-textfield
518 */
519 private void setDestdirTextfieldContent( String content ) {
520 this.targetdir_tf.setText( content );
521 }
522
523 /**
524 *
525 * @return
526 */
527 private String getSelectedFormat() {
528 return (String) this.formatCBox.getSelectedItem();
529 }
530
531 /**
532 *
533 * @return
534 */
535 private String getSelectedColor() {
536 return (String) this.colorCBox.getSelectedItem();
537 }
538
539 /**
540 *
541 * @return
542 */
543 private String getSelectedWidth() {
544 return this.widthspinner.getValue().toString();
545 }
546
547 /**
548 *
549 * @return
550 */
551 private String getSelectedHeight() {
552 return this.heightspinner.getValue().toString();
553 }
554
555 /**
556 *
557 * @return
558 */
559 private String getSelectedTitle() {
560 return this.titletextfield.getText();
561 }
562
563 /**
564 *
565 * @param debuginformation
566 */
567 protected void addDebugInformation( String debuginformation ) {
568 this.debugTextArea.setText( this.debugTextArea.getText() + "\n" + debuginformation );
569 }
570
571 /**
572 *
573 * @param args
574 */
575 public static void main( String[] args ) {
576 // Make sure we have nice window decorations.
577 JFrame.setDefaultLookAndFeelDecorated( true );
578 JDialog.setDefaultLookAndFeelDecorated( true );
579
580 // Create and set up the window.
581 JFrame frame = new JFrame( TITLE );
582 frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
583
584 // Create and set up the content pane.
585 LecGUI lg = new LecGUI();
586 lg.setOpaque( true );
587
588 frame.setContentPane( lg );
589
590 // Display the window.
591 frame.pack();
592 frame.setVisible( true );
593 }
594
595 /**
596 * the funcionality of the program. parses the input from the gui-elements and passes them to
597 * the LegendElementCreator class.
598 */
599 protected void doStart() {
600 if ( getSourceTextfieldContent() == null || getSourceTextfieldContent().length() == 0 ) {
601 JOptionPane.showMessageDialog( this, "No source SLD-file specified.",
602 "no source, no start", JOptionPane.ERROR_MESSAGE );
603 } else if ( getDestDirTextfieldContent() == null
604 || getDestDirTextfieldContent().length() == 0 ) {
605 JOptionPane.showMessageDialog( this, "No target-directory specified.",
606 "no target, no thumbnail", JOptionPane.ERROR_MESSAGE );
607 } else {
608 String sldfile = getSourceTextfieldContent();
609 String directory = getDestDirTextfieldContent();
610 String format = getSelectedFormat();
611 Color color = getColorFromString( getSelectedColor() );
612 int width = Integer.parseInt( getSelectedWidth() );
613 int height = Integer.parseInt( getSelectedHeight() );
614 String title = getSelectedTitle();
615 try {
616 LegendElementCreator lec = new LegendElementCreator( sldfile, directory, format,
617 color, width, height, title,
618 this );
619 if ( lec.getVerboseOutput() != null && lec.getVerboseOutput().length() > 0 ) {
620 addDebugInformation( "Finished!" + "\n" + lec.getVerboseOutput() );
621 JOptionPane.showMessageDialog(
622 this,
623 "Creation of LegendElements successful.\nSee the Debug output for details.",
624 "Finished! Press <SPACE> to suppress this window.",
625 JOptionPane.INFORMATION_MESSAGE );
626 }
627 } catch ( Exception e ) {
628 JOptionPane.showMessageDialog( this, e.getMessage(), "Error",
629 JOptionPane.ERROR_MESSAGE );
630 e.printStackTrace();
631 addDebugInformation( e.getMessage() );
632 }
633
634 }
635 }
636
637 /**
638 * reads out the color from the string and returns the corresponding color.
639 *
640 * @param colorstring
641 * the color as string
642 * @return the color
643 */
644 private Color getColorFromString( String colorstring ) {
645 Color color = Color.WHITE;
646 // BLACK, BLUE, CYAN, DARK_GRAY, GRAY, GREEN, LIGHT_GRAY, MAGENTA, ORANGE, PINK, RED, WHITE,
647 // YELLOW
648 LOG.logInfo( "colorstring: " + colorstring );
649 if ( colorstring.equalsIgnoreCase( "BLACK" ) )
650 color = Color.BLACK;
651 else if ( colorstring.equalsIgnoreCase( "BLUE" ) )
652 color = Color.BLUE;
653 else if ( colorstring.equalsIgnoreCase( "CYAN" ) )
654 color = Color.CYAN;
655 else if ( colorstring.equalsIgnoreCase( "DARK_GRAY" ) )
656 color = Color.DARK_GRAY;
657 else if ( colorstring.equalsIgnoreCase( "GRAY" ) )
658 color = Color.GRAY;
659 else if ( colorstring.equalsIgnoreCase( "GREEN" ) )
660 color = Color.GREEN;
661 else if ( colorstring.equalsIgnoreCase( "LIGHT_GRAY" ) )
662 color = Color.LIGHT_GRAY;
663 else if ( colorstring.equalsIgnoreCase( "MAGENTA" ) )
664 color = Color.MAGENTA;
665 else if ( colorstring.equalsIgnoreCase( "ORANGE" ) )
666 color = Color.ORANGE;
667 else if ( colorstring.equalsIgnoreCase( "PINK" ) )
668 color = Color.PINK;
669 else if ( colorstring.equalsIgnoreCase( "RED" ) )
670 color = Color.RED;
671 else if ( colorstring.equalsIgnoreCase( "WHITE" ) )
672 color = Color.WHITE;
673 else if ( colorstring.equalsIgnoreCase( "YELLOW" ) )
674 color = Color.YELLOW;
675 else if ( colorstring.equalsIgnoreCase( "TRANSP." ) )
676 color = null;
677 else {
678 // try {
679 color = Color.decode( colorstring );
680 }
681 return color;
682 }
683
684 /**
685 * opens the file chooser
686 */
687 protected void openFileChooser() {
688 JFileChooser chooser = new JFileChooser();
689 chooser.setCurrentDirectory( new File( lastDir ) );
690 chooser.setFileFilter( new javax.swing.filechooser.FileFilter() {
691 public boolean accept( File f ) {
692 return f.getName().toLowerCase().endsWith( ".xml" ) || f.isDirectory();
693 }
694
695 public String getDescription() {
696 return "StyledLayerDescriptor (*.xml)";
697 }
698 } );
699
700 int returnVal = chooser.showOpenDialog( this );
701
702 if ( returnVal == JFileChooser.APPROVE_OPTION ) {
703 LOG.logInfo( chooser.getSelectedFile().getPath() );
704 setSourceTextfieldContent( chooser.getSelectedFile().getPath() );
705 }
706 }
707
708 /**
709 * opens the target-dir file chooser. only dirs are available for selection
710 */
711 protected void openDirChooser() {
712 JFileChooser chooser = new JFileChooser();
713 chooser.setCurrentDirectory( new File( lastDir ) );
714 chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
715
716 int returnVal = chooser.showOpenDialog( this );
717
718 if ( returnVal == JFileChooser.APPROVE_OPTION ) {
719 setDestdirTextfieldContent( chooser.getSelectedFile().getPath() );
720 }
721 }
722
723 /**
724 * shows the Info in a JOptionPane
725 *
726 */
727 protected void showInfo() {
728 String text = "This application is part of deegree.\n"
729 + "http://deegree.sourceforge.net\n\n"
730 + "lat/lon GmbH \n"
731 + "e-mail: info@lat-lon.de";
732 JOptionPane.showMessageDialog( this, text, "Information", JOptionPane.INFORMATION_MESSAGE );
733 }
734
735 }
736
737 /**
738 * class for handling button events.
739 * <hr>
740 *
741 * @author <a href="mailto:schaefer@lat-lon.de>Axel Schaefer</a>
742 */
743 class LecGUIButtonHandler implements ActionListener {
744
745 private LecGUI lecgui = null;
746
747 /**
748 * constructor
749 *
750 * @param lecgui
751 * the DeegreeDemoInstallerGUI uses this Button
752 */
753 protected LecGUIButtonHandler( LecGUI lecgui ) {
754 this.lecgui = lecgui;
755 }
756
757 /*
758 * (non-Javadoc)
759 *
760 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
761 */
762 public void actionPerformed( ActionEvent event ) {
763 String ac = event.getActionCommand();
764 if ( ac.equals( LecGUI.BTOPENSOURCE ) ) {
765 this.lecgui.openFileChooser();
766 } else if ( ac.equals( LecGUI.BTOPENTARGET ) ) {
767 this.lecgui.openDirChooser();
768 } else if ( ac.equals( LecGUI.BTEXIT ) ) {
769 System.exit( 0 );
770 } else if ( ac.equals( LecGUI.BTINFO ) ) {
771 this.lecgui.showInfo();
772 } else if ( ac.equals( LecGUI.BTSTART ) ) {
773 this.lecgui.doStart();
774 }
775 }
776 }
777
778 /**
779 * class for handling button events.
780 * <hr>
781 *
782 * @author <a href="mailto:schaefer@lat-lon.de>Axel Schaefer</a>
783 */
784 class LecGUIMenuHandler implements ActionListener {
785
786 private LecGUI lecgui = null;
787
788 /**
789 * constructor
790 *
791 * @param lecgui
792 * the DeegreeDemoInstallerGUI uses this Button
793 */
794 protected LecGUIMenuHandler( LecGUI lecgui ) {
795 this.lecgui = lecgui;
796 }
797
798 /*
799 * (non-Javadoc)
800 *
801 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
802 */
803 public void actionPerformed( ActionEvent event ) {
804 String ac = event.getActionCommand();
805 if ( ac.equals( LecGUI.OPENSOURCEMENUITEM ) ) {
806 this.lecgui.openFileChooser();
807 } else if ( ac.equals( LecGUI.OPENTARGETMENUITEM ) ) {
808 this.lecgui.openDirChooser();
809 } else if ( ac.equals( LecGUI.EXITMENUITEM ) ) {
810 System.exit( 0 );
811 } else if ( ac.equals( LecGUI.INFOMENUITEM ) ) {
812 this.lecgui.showInfo();
813 } else if ( ac.equals( LecGUI.STARTMENUITEM ) ) {
814 this.lecgui.doStart();
815 }
816 }
817 }