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