Coverage Report - org.xmlhammer.gui.preferences.ExternalApplicationPreferencesPanel
 
Classes in this File Line Coverage Branch Coverage Complexity
ExternalApplicationPreferencesPanel
98% 
100% 
1
 
 1  
 /*
 2  
  * $Id$
 3  
  *
 4  
  * The contents of this file are subject to the Mozilla Public License 
 5  
  * Version 1.1 (the "License"); you may not use this file except in 
 6  
  * compliance with the License. You may obtain a copy of the License at 
 7  
  * http://www.mozilla.org/MPL/ 
 8  
  *
 9  
  * Software distributed under the License is distributed on an "AS IS" basis, 
 10  
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
 11  
  * for the specific language governing rights and limitations under the License.
 12  
  *
 13  
  * The Original Code is XML Hammer code. (org.xmlhammer.*)
 14  
  *
 15  
  * The Initial Developer of the Original Code is Edwin Dankert. Portions created 
 16  
  * by the Initial Developer are Copyright (C) 2005 - 2006 the Initial Developer. 
 17  
  * All Rights Reserved.
 18  
  *
 19  
  * Contributor(s): Edwin Dankert <edankert@gmail.com>
 20  
  */
 21  
 
 22  
 
 23  
 package org.xmlhammer.gui.preferences;
 24  
 
 25  
 import javax.swing.Box;
 26  
 import javax.swing.ImageIcon;
 27  
 import javax.swing.JLabel;
 28  
 import javax.swing.JPanel;
 29  
 import javax.swing.JTextField;
 30  
 import javax.swing.JTextPane;
 31  
 import javax.swing.border.EmptyBorder;
 32  
 
 33  
 import org.bounce.FormLayout;
 34  
 import org.bounce.image.ImageLoader;
 35  
 import org.xmlhammer.model.preferences.ExternalApplication;
 36  
 
 37  
 /**
 38  
  * Put comment...
 39  
  * 
 40  
  * @version $Revision$, $Date$
 41  
  * @author Edwin Dankert <edankert@gmail.com>
 42  
  */
 43  
 
 44  
 public class ExternalApplicationPreferencesPanel extends PreferencesPanel {
 45  
     private static final long serialVersionUID = -4140066420809363167L;
 46  22
     private static final ImageIcon EDITOR_ICON = ImageLoader.get().getImage("/org/xmlhammer/gui/icons/obj16/write_obj.gif");
 47  22
     private static final ImageIcon OPEN_ICON = ImageLoader.get().getImage("/org/xmlhammer/gui/icons/obj16/file_obj.gif");
 48  
 
 49  22
     private JTextField browserExtensionsField = null;
 50  22
     private JTextField editorCommandField = null;
 51  22
     private JTextField defaultCommandField = null;
 52  
         
 53  
         /**
 54  
          * @param name
 55  
          */
 56  
         public ExternalApplicationPreferencesPanel() {
 57  22
                 this(false);
 58  22
         }
 59  
 
 60  
         /**
 61  
          * @param name
 62  
          */
 63  
         public ExternalApplicationPreferencesPanel(boolean project) {
 64  22
                 super("External Applications", "preferences.external", project);
 65  
 
 66  22
         JPanel preferences = new JPanel( new FormLayout( 5, 2));
 67  
         
 68  22
         browserExtensionsField = new JTextField();
 69  
         
 70  22
         preferences.add(new JLabel("Browser Extensions:"), FormLayout.LEFT);
 71  22
         preferences.add(browserExtensionsField, FormLayout.RIGHT_FILL);
 72  
 
 73  22
         preferences.add(Box.createVerticalStrut(10), FormLayout.FULL);
 74  
 
 75  22
         JTextPane label = new JTextPane();
 76  22
         label.setBorder(new EmptyBorder(5,40,5,20));
 77  22
         label.setText("The following patterns will be replaced when evaluating a command:\n" +
 78  
                       "${file} - replaced with the current selected file\n" +
 79  
                       "${line} - replaced with the line for an error\n" +
 80  
                       "${column} - replaced with the column for an error");
 81  22
         label.setEditable(false);
 82  22
         label.setBackground(this.getBackground());
 83  
 
 84  
 //        preferences.add(new JLabel(), FormLayout.LEFT);
 85  22
         preferences.add(label, FormLayout.FULL);
 86  
 
 87  22
         preferences.add(Box.createVerticalStrut(10), FormLayout.FULL);
 88  
 
 89  22
         editorCommandField = new JTextField();
 90  
 
 91  22
         JLabel editorLabel = new JLabel( "Editor Command:");
 92  22
         editorLabel.setIcon(EDITOR_ICON);
 93  
 //        editorLabel.setHorizontalTextPosition(JLabel.LEFT);
 94  22
         preferences.add(editorLabel, FormLayout.LEFT);
 95  22
         preferences.add(editorCommandField, FormLayout.RIGHT_FILL);
 96  
 
 97  22
         defaultCommandField = new JTextField();
 98  
 
 99  22
         JLabel openLabel = new JLabel( "Open Command:");
 100  22
         openLabel.setIcon(OPEN_ICON);
 101  
 //        openLabel.setHorizontalTextPosition(JLabel.LEFT);
 102  22
         preferences.add(openLabel, FormLayout.LEFT);
 103  22
         preferences.add(defaultCommandField, FormLayout.RIGHT_FILL);
 104  
 
 105  22
         setCenterPane(preferences);
 106  22
     }
 107  
         
 108  
         public void setExternalApplication(ExternalApplication external) {
 109  22
                 browserExtensionsField.setText(external.getBrowserExtensions() == null ? "" : external.getBrowserExtensions());
 110  22
         defaultCommandField.setText(external.getDefaultCommand() == null ? "" : external.getDefaultCommand());
 111  22
         editorCommandField.setText(external.getEditorCommand() == null ? "" : external.getEditorCommand());
 112  22
         }
 113  
         
 114  
         public ExternalApplication getExternalApplication() {
 115  22
         ExternalApplication external = new ExternalApplication();
 116  22
                 external.setBrowserExtensions(browserExtensionsField.getText());
 117  22
         external.setDefaultCommand(defaultCommandField.getText());
 118  22
         external.setEditorCommand(editorCommandField.getText());
 119  
                 
 120  22
                 return external;
 121  
         }
 122  
         
 123  
         public void setEnabled( boolean enabled) {
 124  0
         }
 125  
 }