|
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-2004 Sun * Microsystems, Inc. All Rights Reserved. */ package org.openide.loaders; import java.io.IOException; import java.lang.ref.Reference; import java.lang.ref.WeakReference; import java.awt.event.KeyEvent; import java.beans.PropertyDescriptor; import java.lang.reflect.Method; import java.util.Enumeration; import javax.swing.KeyStroke; import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import org.openide.ErrorManager; import org.openide.explorer.propertysheet.DefaultPropertyModel; import org.openide.explorer.propertysheet.PropertyPanel; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileSystem; import org.openide.util.NbBundle; /** Dialog that can be used in create from template. * * @author Jaroslav Tulach, Jiri Rechtacek */ final class TemplateWizard2 extends javax.swing.JPanel implements DocumentListener { /** listener to changes in the wizard */ private ChangeListener listener; private static final String PROP_LOCATION_FOLDER = "locationFolder"; // NOI18N private DataFolder locationFolder; private Reference fileSystemRef = new WeakReference (null); private DefaultPropertyModel locationFolderModel; /** File extension of the template and of the created file - * it is used to test whether file already exists. */ private String extension; /** Creates new form TemplateWizard2 */ public TemplateWizard2() { initLocationFolder (); initComponents (); setName (DataObject.getString("LAB_TargetLocationPanelName")); // NOI18N // registers itself to listen to changes in the content of document java.util.ResourceBundle bundle = org.openide.util.NbBundle.getBundle(TemplateWizard2.class); newObjectName.getDocument().addDocumentListener(this); newObjectName.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)); newObjectName.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_NewObjectName")); // NOI18N } /** This method is called from within the constructor to * initialize the location folder and make it accessible. * The getter/setter methods must be accessible for purposes introspection. * Because this class is not public then these methods are made accessible explicitly. */ private void initLocationFolder () { PropertyDescriptor pd = null; try { Method getterMethod = this.getClass ().getDeclaredMethod("getLocationFolder", new Class[] {}); // NOI18N getterMethod.setAccessible (true); Method setterMethod = this.getClass ().getDeclaredMethod("setLocationFolder", new Class[] {DataFolder.class}); // NOI18N setterMethod.setAccessible (true); pd = new PropertyDescriptor (PROP_LOCATION_FOLDER, getterMethod, setterMethod); } catch (java.beans.IntrospectionException ie) { ErrorManager.getDefault ().notify (ie); } catch (NoSuchMethodException nsme) { ErrorManager.getDefault ().notify (nsme); } locationFolderModel = new DefaultPropertyModel (this, pd); } /** Getter for default name of a new object. * @return the default name. */ private static String defaultNewObjectName () { return DataObject.getString ("FMT_DefaultNewObjectName"); // NOI18N } /** 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 Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents namePanel = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); newObjectName = new javax.swing.JTextField(); dataFolderPanel = dataFolderPanel = new PropertyPanel (locationFolderModel, PropertyPanel.PREF_CUSTOM_EDITOR); setLayout(new java.awt.BorderLayout()); namePanel.setLayout(new java.awt.BorderLayout(12, 0)); jLabel1.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/openide/loaders/Bundle").getString("CTL_NewObjectName_Mnemonic").charAt(0)); jLabel1.setLabelFor(newObjectName); jLabel1.setText(java.util.ResourceBundle.getBundle("org/openide/loaders/Bundle").getString("CTL_NewObjectName")); namePanel.add(jLabel1, java.awt.BorderLayout.WEST); newObjectName.addFocusListener(new java.awt.event.FocusAdapter() { public void focusGained(java.awt.event.FocusEvent evt) { TemplateWizard2.this.newObjectNameFocusGained(evt); } }); namePanel.add(newObjectName, java.awt.BorderLayout.CENTER); add(namePanel, java.awt.BorderLayout.NORTH); add(dataFolderPanel, java.awt.BorderLayout.CENTER); }//GEN-END:initComponents private void newObjectNameFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_newObjectNameFocusGained //Code below works perfectly on Solaris with JDK 1.3 or 1.4. The //lines below show up in CVS annotate as by jglick, Apr 25, 2000, which //is the major reformat/SPL addition for open sourcing NB. I'm //guessing this was some 1.2 bug that is irrelevant now, but leaving //it in place in case of a problem. -TDB /* if ( Utilities.getOperatingSystem() == Utilities.OS_SOLARIS | Utilities.getOperatingSystem() == Utilities.OS_SUNOS ) { // does not work on CDE window manager, so better do nothin return; } */ newObjectName.selectAll (); }//GEN-LAST:event_newObjectNameFocusGained /** Add a listener to changes of the panel's validity. * @param l the listener to add * @see #isValid * */ void addChangeListener(ChangeListener l) { if (listener != null) throw new IllegalStateException (); listener = l; } public void addNotify () { super.addNotify(); //Fix for issue 31086, initial focus on Back button newObjectName.requestFocus(); getAccessibleContext().setAccessibleDescription( NbBundle.getBundle(TemplateWizard2.class).getString ("ACSD_TemplateWizard2") // NOI18N ); } /** Helper implementation of WizardDescription.Panel for TemplateWizard.Panel2. * Provides the wizard panel with the current data--either * the default data or already-modified settings, if the user used the previous and/or next buttons. * This method can be called multiple times on one instance of |
... 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.