Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   *
   * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
   *
   * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   * Other names may be trademarks of their respective owners.
   *
   * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common
  * Development and Distribution License("CDDL") (collectively, the
  * "License"). You may not use this file except in compliance with the
  * License. You can obtain a copy of the License at
  * http://www.netbeans.org/cddl-gplv2.html
  * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
  * specific language governing permissions and limitations under the
  * License.  When distributing the software, include this License Header
  * Notice in each file and include the License file at
  * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
  * particular file as subject to the "Classpath" exception as provided
  * by Oracle in the GPL Version 2 section of the License file that
  * accompanied this code. If applicable, add the following below the
  * License Header, with the fields enclosed by brackets [] replaced by
  * your own identifying information:
  * "Portions Copyrighted [year] [name of copyright owner]"
  *
  * Contributor(s):
  * The Original Software is NetBeans. The Initial Developer of the Original
  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
  * Microsystems, Inc. All Rights Reserved.
  *
  * If you wish your version of this file to be governed by only the CDDL
  * or only the GPL Version 2, indicate your decision by adding
  * "[Contributor] elects to include this software in this distribution
  * under the [CDDL or GPL Version 2] license." If you do not indicate a
  * single choice of license, a recipient has the option to distribute
  * your version of this file under either the CDDL, the GPL Version 2 or
  * to extend the choice of license to its licensees as provided above.
  * However, if you add GPL Version 2 code and therefore, elected the GPL
  * Version 2 license, then the option applies only if the new code is
  * made subject to such option by the copyright holder.
  */
 
 package org.netbeans.modules.profiler.ppoints.ui;
 
 import java.awt.Font;

Author(s):
Jiri Sedlacek
 
     "TimedTakeSnapshotCustomizer_NameLabelText=&Name:",
     "TimedTakeSnapshotCustomizer_SettingsLabelText=Settings",
     "TimedTakeSnapshotCustomizer_TimeLabelText=Time"
 })
                                                                                HelpCtx.Provider {
     //~ Static fields/initializers -----------------------------------------------------------------------------------------------
 
     private static final String HELP_CTX_KEY = "TimedTakeSnapshotCustomizer.HelpCtx"// NOI18N
     private static final HelpCtx HELP_CTX = new HelpCtx();
     private static int defaultTextComponentHeight = -1;
 
     //~ Instance fields ----------------------------------------------------------------------------------------------------------
 
     private JLabel captionLabel;
     private JLabel nameLabel;
     private JLabel settingsHeaderLabel;
     private JLabel timeHeaderLabel;
     private JPanel captionPanel;
     private JSeparator timeHeaderSeparator;
     private JTextField nameTextField;
     private TimeCustomizer timeCustomizer;
 
    //~ Constructors -------------------------------------------------------------------------------------------------------------
    public TimedTakeSnapshotCustomizer(String captionIcon icon) {
        initComponents(captionicon);
        normalizeCaptionAreaWidth();
    }
    //~ Methods ------------------------------------------------------------------------------------------------------------------
    public HelpCtx getHelpCtx() {
        return ;
    }
    public Component getInitialFocusTarget() {
        return ;
    }
    public void setPPFile(String fileName) {
        .setPPFile(fileName);
    }
    public String getPPFile() {
        return .getPPFile();
    }
    public void setPPName(String name) {
        .setText(name);
    }
    public String getPPName() {
        return .getText();
    }
    public void setPPResetResults(boolean resetResults) {
        .setPPResetResults(resetResults);
    }
    public boolean getPPResetResults() {
        return .getPPResetResults();
    }
    public void setPPTarget(boolean target) {
        .setPPTarget(target);
    }
    public boolean getPPTarget() {
        return .getPPTarget();
    }
    public void setPPType(boolean type) {
        .setPPType(type);
    }
    public boolean getPPType() {
        return .getPPType();
    }
    public int getPreferredCaptionAreaWidth() {
        // Not used for this customizer
        return -1;
    }
    public void setTimeCondition(TimedGlobalProfilingPoint.TimeCondition condition) {
        .setTimeCondition(condition);
    }
        return .getTimeCondition();
    }
    public void changedUpdate(DocumentEvent e) {
        updateValidity();
    }
    //  private int getDefaultTextComponentHeight() {
    //    if (defaultTextComponentHeight == -1) defaultTextComponentHeight = new JComboBox().getPreferredSize().height;
    //    return defaultTextComponentHeight;
    //  }
    public void initComponents(String captionIcon icon) {
        setLayout(new GridBagLayout());
        GridBagConstraints constraints;
        // captionPanel
         = new JPanel(new BorderLayout(0, 0));
        .setOpaque(true);
        // captionLabel
         = new JLabel(captionicon.);
        .setOpaque(false);
        .setBorder(BorderFactory.createEmptyBorder(6, 8, 6, 6));
        constraints = new GridBagConstraints();
        constraints.gridx = 0;
        constraints.gridy = 0;
        constraints.gridwidth = .;
        constraints.anchor = .;
        constraints.fill = .;
        constraints.insets = new Insets(0, 0, 16, 0);
        add(constraints);
        // --- next row ----------------------------------------------------------
        // nameLabel
         = new JLabel();
        org.openide.awt.Mnemonics.setLocalizedText(, Bundle.TimedTakeSnapshotCustomizer_NameLabelText());
        constraints = new GridBagConstraints();
        constraints.gridx = 0;
        constraints.gridy = 1;
        constraints.anchor = .;
        constraints.fill = .;
        constraints.insets = new Insets(0, 8, 10, 5);
        add(constraints);
        // nameTextField
         = new JTextField("") { // NOI18N
                public Dimension getPreferredSize() {
                    return (TimedTakeSnapshotCustomizer.this.getParent() instanceof JViewport) ? getMinimumSize()
                                                                                               : new Dimension(400,
                                                                                                               super
                                                                                                                                                                                                                                       .getPreferredSize().);
                }
                public Dimension getMinimumSize() {
                    return new Dimension(super.getMinimumSize().super.getPreferredSize().);
                }
            };
        constraints = new GridBagConstraints();
        constraints.gridx = 1;
        constraints.gridy = 1;
        constraints.gridwidth = .;
        constraints.weightx = 1;
        constraints.anchor = .;
        constraints.fill = .;
        constraints.insets = new Insets(0, 0, 10, 13);
        add(constraints);
        // --- next row ----------------------------------------------------------
        JPanel settingsHeaderContainer = new JPanel(new GridBagLayout());
        // settingsHeaderLabel
        constraints = new GridBagConstraints();
        constraints.gridx = 0;
        constraints.gridy = 0;
        constraints.anchor = .;
        constraints.fill = .;
        constraints.insets = new Insets(0, 0, 0, 5);
        settingsHeaderContainer.add(constraints);
        // settingsHeaderSeparator
         = new JSeparator() {
                public Dimension getMinimumSize() {
                    return getPreferredSize();
                }
            };
        constraints = new GridBagConstraints();
        constraints.gridx = 1;
        constraints.gridy = 0;
        constraints.weightx = 1;
        constraints.anchor = .;
        constraints.fill = .;
        constraints.insets = new Insets(0, 0, 0, 0);
        settingsHeaderContainer.add(constraints);
        // locationHeaderContainer
        constraints = new GridBagConstraints();
        constraints.gridx = 0;
        constraints.gridy = 2;
        constraints.gridwidth = .;
        constraints.anchor = .;
        constraints.fill = .;
        constraints.insets = new Insets(0, 8, 5, 8);
        add(settingsHeaderContainerconstraints);
        // --- next row ----------------------------------------------------------
        // snapshotCustomizer
         = new SnapshotCustomizer();
        constraints = new GridBagConstraints();
        constraints.gridx = 0;
        constraints.gridy = 3;
        constraints.gridwidth = .;
        constraints.anchor = .;
        constraints.fill = .;
        constraints.insets = new Insets(0, 20, 12, 13);
        add(constraints);
        // --- next row ----------------------------------------------------------
        JPanel triggerHeaderContainer = new JPanel(new GridBagLayout());
        // timeHeaderLabel
        constraints = new GridBagConstraints();
        constraints.gridx = 0;
        constraints.gridy = 0;
        constraints.anchor = .;
        constraints.fill = .;
        constraints.insets = new Insets(0, 0, 0, 5);
        triggerHeaderContainer.add(constraints);
        // timeHeaderSeparator
         = new JSeparator() {
                public Dimension getMinimumSize() {
                    return getPreferredSize();
                }
            };
        constraints = new GridBagConstraints();
        constraints.gridx = 1;
        constraints.gridy = 0;
        constraints.weightx = 1;
        constraints.anchor = .;
        constraints.fill = .;
        constraints.insets = new Insets(0, 0, 0, 0);
        triggerHeaderContainer.add(constraints);
        // triggerHeaderContainer
        constraints = new GridBagConstraints();
        constraints.gridx = 0;
        constraints.gridy = 4;
        constraints.gridwidth = .;
        constraints.anchor = .;
        constraints.fill = .;
        constraints.insets = new Insets(0, 8, 5, 8);
        add(triggerHeaderContainerconstraints);
        // --- next row ----------------------------------------------------------
        // timeCustomizer
         = new TimeCustomizer();
        .addValidityListener(this);
        constraints = new GridBagConstraints();
        constraints.gridx = 0;
        constraints.gridy = 5;
        constraints.gridwidth = .;
        constraints.anchor = .;
        constraints.fill = .;
        constraints.insets = new Insets(0, 20, 5, 13);
        add(constraints);
        // --- next row ----------------------------------------------------------
        JPanel fillerPanel = new JPanel(new FlowLayout(., 0, 0));
        constraints = new GridBagConstraints();
        constraints.gridx = 0;
        constraints.gridy = 7;
        constraints.weighty = 1;
        constraints.anchor = .;
        constraints.fill = .;
        constraints.insets = new Insets(0, 0, 0, 0);
        add(fillerPanelconstraints);
    }
    public void insertUpdate(DocumentEvent e) {
        updateValidity();
    }

    

Parameters:
args the command line arguments
    public static void main(String[] args) {
        //    try {
        //      UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); //NOI18N
        ////      UIManager.setLookAndFeel("plaf.metal.MetalLookAndFeel"); //NOI18N
        ////      UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); //NOI18N
        ////      UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); //NOI18N
        //    } catch (Exception e){};
        //    
        //    TimedTakeSnapshotCustomizer main = new TimedTakeSnapshotCustomizer();
        //    main.addValidityListener(new ValidityListener() {
        //      public void validityChanged(boolean isValid) { System.err.println(">>> Validity changed to " + isValid); }
        //    });
        //    
        //    JFrame frame = new JFrame("Customize Profiling Point");
        //    frame.getContentPane().add(main);
        //    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //    frame.pack();
        //    frame.setVisible(true);
    }
    public void normalizeCaptionAreaWidth() {
        // Not used for this customizer
    }
    public void removeUpdate(DocumentEvent e) {
        updateValidity();
    }
    public void validityChanged(boolean isValid) {
        updateValidity();
    }
    private boolean isNameEmpty() {
        return .getText().trim().length() == 0;
    }
    private void updateValidity() {
        boolean isValid = !isNameEmpty() && .areSettingsValid() && .areSettingsValid();
        if (isValid != areSettingsValid()) {
            fireValidityChanged(isValid);
        }
    }
New to GrepCode? Check out our FAQ X