|
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-2000 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.core; import java.awt.GridBagConstraints; import java.awt.Insets; import java.util.*; import javax.swing.Action; import javax.swing.KeyStroke; import javax.swing.event.*; import org.openide.filesystems.*; import org.openide.util.HelpCtx; /** * * @author Ian Formanek */ public class ShortcutsEditor extends javax.swing.JPanel { private static final java.util.ResourceBundle bundle = org.openide.util.NbBundle.getBundle(ShortcutsEditor.class); private ShortcutsPanel shortcutsPanel; private ActionsPanel actionsPanel; private java.awt.Component currentPanel; private boolean modified = false; private List changes; /** Creates new form ShortcutsEditor */ public ShortcutsEditor() { actionsPanel = new ActionsPanel (true, this); shortcutsPanel = new ShortcutsPanel (this); initComponents (); initAccessibility (); viewByLabel.setLabelFor(actionsButton); actionsButton.setMnemonic(bundle.getString ("ShortcutsEditor.actionsButton.text_Mnemonic").charAt(0)); shortcutsButton.setMnemonic(bundle.getString ("ShortcutsEditor.shortcutsButton.text_Mnemonic").charAt(0)); javax.swing.ButtonGroup group = new javax.swing.ButtonGroup (); group.add(actionsButton); group.add(shortcutsButton); actionsButton.setSelected (true); updateDynamicContent (); requestFocus (); radioPanel.requestFocus(); actionsButton.requestFocus(); } void setModified (boolean value) { modified = value; } public boolean isModified () { return modified; } /** 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 radioPanel = new javax.swing.JPanel(); actionsButton = new javax.swing.JRadioButton(); shortcutsButton = new javax.swing.JRadioButton(); viewByLabel = new javax.swing.JLabel(); setLayout(new java.awt.GridBagLayout()); java.awt.GridBagConstraints gridBagConstraints1; setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(12, 12, 0, 11))); radioPanel.setLayout(new java.awt.GridBagLayout()); java.awt.GridBagConstraints gridBagConstraints2; actionsButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/core/Bundle").getString("ShortcutsEditor.actionsButton.text")); actionsButton.setContentAreaFilled(actionsButton.isContentAreaFilled()); actionsButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { actionsButtonActionPerformed(evt); } }); gridBagConstraints2 = new java.awt.GridBagConstraints(); gridBagConstraints2.gridx = 1; gridBagConstraints2.gridy = 0; gridBagConstraints2.insets = new java.awt.Insets(0, 12, 0, 0); radioPanel.add(actionsButton, gridBagConstraints2); shortcutsButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/core/Bundle").getString("ShortcutsEditor.shortcutsButton.text")); shortcutsButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { shortcutsButtonActionPerformed(evt); } }); gridBagConstraints2 = new java.awt.GridBagConstraints(); gridBagConstraints2.gridx = 2; gridBagConstraints2.gridy = 0; gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints2.insets = new java.awt.Insets(0, 12, 0, 0); gridBagConstraints2.weightx = 1.0; radioPanel.add(shortcutsButton, gridBagConstraints2); viewByLabel.setText(java.util.ResourceBundle.getBundle("org/netbeans/core/Bundle").getString("ShortcutsEditor.viewByLabel")); gridBagConstraints2 = new java.awt.GridBagConstraints(); gridBagConstraints2.gridx = 0; gridBagConstraints2.gridy = 0; radioPanel.add(viewByLabel, gridBagConstraints2); gridBagConstraints1 = new java.awt.GridBagConstraints(); gridBagConstraints1.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints1.weightx = 1.0; add(radioPanel, gridBagConstraints1); }//GEN-END:initComponents private void shortcutsButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_shortcutsButtonActionPerformed updateDynamicContent (); }//GEN-LAST:event_shortcutsButtonActionPerformed private void actionsButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_actionsButtonActionPerformed updateDynamicContent (); }//GEN-LAST:event_actionsButtonActionPerformed public java.awt.Dimension getPreferredSize() { java.awt.Dimension size = new java.awt.Dimension(super.getPreferredSize()); size.height = size.width; return size; } private void updateDynamicContent () { GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 1; constraints.insets = new Insets(6, 0, 0, 0); constraints.weightx = 1.0; constraints.weighty = 1.0; constraints.fill = GridBagConstraints.BOTH; if (actionsButton.isSelected()) { if (currentPanel != actionsPanel) { if (currentPanel != null) remove (currentPanel); currentPanel = actionsPanel; actionsPanel.updateTree (); add(currentPanel, constraints); actionsPanel.setFocusDefault(); revalidate (); repaint (); } } else { if (currentPanel != shortcutsPanel) { if (currentPanel != null) remove (currentPanel); currentPanel = shortcutsPanel; add(currentPanel, constraints); shortcutsPanel.setFocusDefault(); revalidate (); repaint (); } } } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel radioPanel; private javax.swing.JRadioButton actionsButton; private javax.swing.JRadioButton shortcutsButton; private javax.swing.JLabel viewByLabel; // End of variables declaration//GEN-END:variables /** Adds given shortcut to the list changes. */ void addShortcut(KeyStroke key, Action action) { if (changes == null) { changes = new ArrayList(); } changes.add(new ShortcutsFolder.ChangeRequest(key, action, true)); } /** Adds removing request to the changes. */ void removeShortcut(KeyStroke key, Action action) { if (changes == null) { changes = new ArrayList(); } changes.add(new ShortcutsFolder.ChangeRequest(key, action, false)); } private void initAccessibility() { ResourceBundle bundle = org.openide.util.NbBundle.getBundle(ShortcutsEditor.class); this.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_ShortcutsEditor.DialogDesc")); actionsButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_ShortcutsEditor.actionsButton.text.a11yDesc")); shortcutsButton.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_ShortcutsEditor.shortcutsButton.text.a11yDesc")); } /** Stores the changes permanently.*/ public void flushChanges() { if (changes != null) { ShortcutsFolder.applyChanges(changes); } // resetChanges(); } /** Forget about all changes.*/ public void resetChanges() { changes = null; ShortcutsFolder.refreshGlobalMap(); } } |
... 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.