1 19 20 package org.apache.tools.ant.module.wizards.shortcut; 21 22 import java.awt.Component ; 23 import javax.swing.JEditorPane ; 24 import javax.swing.event.ChangeListener ; 25 import javax.swing.text.EditorKit ; 26 import org.openide.WizardDescriptor; 27 import org.openide.util.HelpCtx; 28 import org.openide.util.NbBundle; 29 30 final class CustomizeScriptPanel extends javax.swing.JPanel { 31 32 33 public CustomizeScriptPanel (CustomizeScriptWizardPanel wiz) { 34 initComponents (); 35 initAccessibility (); 36 setName (NbBundle.getMessage (CustomizeScriptPanel.class, "CSP_LBL_cust_gend_ant_script")); 38 scriptPane.setContentType ("text/xml"); EditorKit kit = scriptPane.getEditorKit (); 42 String clazz = kit.getClass ().getName (); 43 if (clazz.equals ("javax.swing.text.DefaultEditorKit") || clazz.equals ("javax.swing.JEditorPane$PlainEditorKit")) { scriptPane.setEditorKit (JEditorPane.createEditorKitForContentType ("text/plain")); } 47 } 48 49 51 @Override 52 public void requestFocus () { 53 super.requestFocus (); 54 scriptPane.requestFocus (); 55 } 56 57 private void initAccessibility () { 58 scriptPane.getAccessibleContext().setAccessibleName(NbBundle.getMessage (CustomizeScriptPanel.class, "ACSN_TEXT_you_may_customize_gend2")); 59 scriptPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (CustomizeScriptPanel.class, "ACSD_TEXT_you_may_customize_gend2")); 60 this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizeScriptPanel.class, "CSP_TEXT_you_may_customize_gend2")); 61 } 62 63 68 private void initComponents() { scrollPane = new javax.swing.JScrollPane (); 70 scriptPane = new javax.swing.JEditorPane (); 71 hintsArea = new javax.swing.JTextArea (); 72 73 setLayout(new java.awt.BorderLayout (0, 11)); 74 75 scrollPane.setPreferredSize(new java.awt.Dimension (100, 100)); 76 scrollPane.setViewportView(scriptPane); 77 78 add(scrollPane, java.awt.BorderLayout.CENTER); 79 80 hintsArea.setBackground(new java.awt.Color (204, 204, 204)); 81 hintsArea.setEditable(false); 82 hintsArea.setFont(javax.swing.UIManager.getFont ("Label.font")); 83 hintsArea.setForeground(new java.awt.Color (102, 102, 153)); 84 hintsArea.setLineWrap(true); 85 hintsArea.setText(NbBundle.getMessage(CustomizeScriptPanel.class, "CSP_TEXT_you_may_customize_gend2")); 86 hintsArea.setWrapStyleWord(true); 87 hintsArea.setDisabledTextColor(javax.swing.UIManager.getColor ("Label.foreground")); 88 hintsArea.setEnabled(false); 89 hintsArea.setOpaque(false); 90 add(hintsArea, java.awt.BorderLayout.NORTH); 91 92 } 94 private javax.swing.JTextArea hintsArea; 96 private javax.swing.JScrollPane scrollPane; 97 private javax.swing.JEditorPane scriptPane; 98 100 101 public static class CustomizeScriptWizardPanel implements WizardDescriptor.Panel { 102 103 private CustomizeScriptPanel panel = null; 104 105 public Component getComponent () { 106 return getPanel(); 107 } 108 109 private CustomizeScriptPanel getPanel() { 110 if (panel == null) { 111 panel = new CustomizeScriptPanel(this); 112 } 113 return panel; 114 } 115 116 public HelpCtx getHelp () { 117 return HelpCtx.DEFAULT_HELP; 118 } 119 120 public boolean isValid () { 121 return true; 122 } 126 127 public final void addChangeListener (ChangeListener l) {} 128 public final void removeChangeListener (ChangeListener l) {} 129 152 153 public void readSettings (Object settings) { 154 ShortcutWizard wiz = (ShortcutWizard) settings; 155 String contents = wiz.getContents(); 156 getPanel().scriptPane.setText(contents); 157 } 158 public void storeSettings (Object settings) { 159 ShortcutWizard wiz = (ShortcutWizard) settings; 160 wiz.putContents(getPanel().scriptPane.getText()); 161 } 162 } 163 164 } 165 | Popular Tags |