|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2002 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.xml.catalog.impl; import java.beans.*; import java.io.File; import java.net.MalformedURLException; /** * XML catalog customizer. It allows to customize catalog location. * * @author Petr Kuzel * @version */ public class XCatalogCustomizer extends javax.swing.JPanel implements Customizer { /** Serial Version UID */ private static final long serialVersionUID =-1437233290256708363L; XCatalog model = null; /** Creates new customizer XCatalogCustomizer */ public XCatalogCustomizer() { initComponents (); this.getAccessibleContext().setAccessibleDescription(Util.THIS.getString("ACSD_XCatalogCustomizer")); locationLabel.setDisplayedMnemonic((Util.THIS.getString("XCatalogCustomizer.locationLabel.mne")).charAt(0)); locationTextField.getAccessibleContext().setAccessibleDescription(Util.THIS.getString("ACSD_locationTextField")); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the FormEditor. */ private void initComponents() {//GEN-BEGIN:initComponents java.awt.GridBagConstraints gridBagConstraints; locationLabel = new javax.swing.JLabel(); locationTextField = new javax.swing.JTextField(); descTextArea = new javax.swing.JTextArea(); selectButton = new javax.swing.JButton(); setLayout(new java.awt.GridBagLayout()); locationLabel.setLabelFor(locationTextField); locationLabel.setText(Util.THIS.getString ("XCatalogCustomizer.locationLabel.text")); add(locationLabel, new java.awt.GridBagConstraints()); locationTextField.setColumns(20); locationTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { locationTextFieldActionPerformed(evt); } }); locationTextField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { locationTextFieldFocusLost(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0); gridBagConstraints.weightx = 1.0; add(locationTextField, gridBagConstraints); descTextArea.setEditable(false); descTextArea.setFont(javax.swing.UIManager.getFont ("Label.font")); descTextArea.setForeground(new java.awt.Color(102, 102, 153)); descTextArea.setLineWrap(true); descTextArea.setText(Util.THIS.getString("DESC_xcatalog_fmts")); descTextArea.setWrapStyleWord(true); descTextArea.setDisabledTextColor(javax.swing.UIManager.getColor ("Label.foreground")); descTextArea.setEnabled(false); descTextArea.setOpaque(false); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 3; gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0); gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; add(descTextArea, gridBagConstraints); selectButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/xml/catalog/impl/Bundle").getString("PROP_choose_file")); selectButton.setMaximumSize(new java.awt.Dimension(89, 25)); selectButton.setMinimumSize(new java.awt.Dimension(89, 25)); selectButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { selectButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0); add(selectButton, gridBagConstraints); }//GEN-END:initComponents private void selectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectButtonActionPerformed File f = org.netbeans.modules.xml.catalog.lib.Util.selectCatalogFile("txt xml cat catalog"); // NOI18N if (f == null) return; try { String location = f.toURL().toExternalForm(); locationTextField.setText(location); model.setLocation(location); } catch (MalformedURLException ex) { // ignore } }//GEN-LAST:event_selectButtonActionPerformed //!!! find out whether action performed is not enought private void locationTextFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_locationTextFieldFocusLost if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug("FocusLost-setting location: " + locationTextField.getText()); // NOI18N model.setSource(locationTextField.getText()); }//GEN-LAST:event_locationTextFieldFocusLost private void locationTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_locationTextFieldActionPerformed if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug("ActionPerformed-setting location: " + locationTextField.getText()); // NOI18N model.setSource(locationTextField.getText()); }//GEN-LAST:event_locationTextFieldActionPerformed /** * Set model for this customizer. */ public void setObject(java.lang.Object peer) { if ((peer instanceof XCatalog) == false) { throw new IllegalArgumentException("XCatalog instance expected (" + peer.getClass() + ")."); // NOI18N } model = (XCatalog) peer; locationTextField.setText(model.getSource()); } public void addPropertyChangeListener(java.beans.PropertyChangeListener p1) { } public void removePropertyChangeListener(java.beans.PropertyChangeListener p1) { } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextArea descTextArea; private javax.swing.JLabel locationLabel; private javax.swing.JTextField locationTextField; private javax.swing.JButton selectButton; // End of variables declaration//GEN-END:variables } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.