|
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.modules.cvsclient.commands.diff;
import org.openide.util.NbBundle;
import javax.accessibility.*;
import java.util.ResourceBundle;
/**
*
* @author tzezula
*/
public class BinaryFilesWarning extends javax.swing.JPanel {
private static class SimpleListModel extends javax.swing.AbstractListModel {
private java.util.ArrayList items;
public SimpleListModel () {
this.items = new java.util.ArrayList ();
}
public synchronized Object getElementAt (int index) {
if (index < 0 || index >= items.size())
return null;
else
return this.items.get (index);
}
public synchronized int getSize () {
return this.items.size();
}
public synchronized void addAll (java.util.Iterator it) {
if (it == null || !it.hasNext())
return;
int newLower = this.items.size();
while (it.hasNext()) {
this.items.add (it.next());
}
this.fireIntervalAdded (this,newLower,this.items.size()-1);
}
public synchronized void add (Object obj) {
this.items.add (obj);
int newIndex = this.items.size()-1;
this.fireIntervalAdded (this,newIndex,newIndex);
}
public synchronized void removeAllItems () {
int indexUpper = Math.max(this.items.size()-1,0);
this.items.clear();
this.fireIntervalRemoved (this,0,indexUpper);
}
}
public BinaryFilesWarning () {
this(null, null);
}
/** Creates new form JPanel */
public BinaryFilesWarning(java.util.Set binaryFiles, java.util.Set noDiffFiles) {
initComponents();
initAccessibility();
this.message.setDisplayedMnemonic (NbBundle.getBundle(BinaryFilesWarning.class).getString("TXT_BinaryFiles_mnemonic").charAt (0)); // NOI18N
this.message2.setLabelFor (this.binaryFiles);
this.message.setDisplayedMnemonic (NbBundle.getBundle(BinaryFilesWarning.class).getString("TXT_NoDiffFiles_mnemonic").charAt (0)); // NOI18N
this.message2.setLabelFor (this.noDiffFiles);
this.message.setVisible(false);
this.message2.setVisible(false);
this.jScrollPane1.setVisible(false);
this.jScrollPane2.setVisible(false);
this.binaryFiles.setModel (new SimpleListModel());
boolean hasBinaries = false;
boolean hasNoDiffs = false;
if (binaryFiles != null && binaryFiles.size() > 0) {
this.addBinaryFiles (binaryFiles);
hasBinaries = true;
}
this.noDiffFiles.setModel (new SimpleListModel());
if (noDiffFiles != null && noDiffFiles.size() > 0) {
this.addNoDiffFiles(noDiffFiles);
hasNoDiffs = true;
}
//accessibility stuff..
AccessibleContext context = this.getAccessibleContext();
String description = NbBundle.getBundle(BinaryFilesWarning.class).getString("ACSD_BinaryFilesWarning_first_part");
if (hasBinaries && hasNoDiffs) {
description = description + NbBundle.getBundle(BinaryFilesWarning.class).getString("ACSD_BinaryFilesWarning_NoDiffsAndBinaries");
}
if (hasBinaries && !hasNoDiffs) {
description = description + NbBundle.getBundle(BinaryFilesWarning.class).getString("ACSD_BinaryFilesWarning_Binaries");
}
if (!hasBinaries && hasNoDiffs) {
description = description + NbBundle.getBundle(BinaryFilesWarning.class).getString("ACSD_BinaryFilesWarning_NoDiffs");
}
context.setAccessibleDescription(description);
}
/** 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
java.awt.GridBagConstraints gridBagConstraints;
message = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
binaryFiles = new javax.swing.JList();
message2 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
noDiffFiles = new javax.swing.JList();
setLayout(new java.awt.GridBagLayout());
message.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/diff/Bundle").getString("TXT_BinaryFiles"));
message.setLabelFor(binaryFiles);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new java.awt.Insets(12, 12, 2, 11);
add(message, gridBagConstraints);
jScrollPane1.setViewportView(binaryFiles);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 11);
add(jScrollPane1, gridBagConstraints);
message2.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/commands/diff/Bundle").getString("TXT_NoDiffFiles"));
message2.setLabelFor(noDiffFiles);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 12, 2, 11);
add(message2, gridBagConstraints);
jScrollPane2.setViewportView(noDiffFiles);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(0, 12, 11, 11);
add(jScrollPane2, gridBagConstraints);
}//GEN-END:initComponents
private void initAccessibility() {
ResourceBundle bundle = NbBundle.getBundle(BinaryFilesWarning.class); //NOI18N
AccessibleContext context = this.getAccessibleContext();
context.setAccessibleName(bundle.getString("ACSN_BinaryFilesWarning"));
context = binaryFiles.getAccessibleContext();
context.setAccessibleDescription(bundle.getString("ACSD_BinaryFilesWarning.binaryFiles"));
context.setAccessibleName(bundle.getString("ACSN_BinaryFilesWarning.binaryFiles"));
context = noDiffFiles.getAccessibleContext();
context.setAccessibleDescription(bundle.getString("ACSD_BinaryFilesWarning.noDiffFiles"));
context.setAccessibleName(bundle.getString("ACSN_BinaryFilesWarning.noDiffFiles"));
}
public void addBinaryFiles (java.util.Set files) {
this.message.setVisible(true);
this.jScrollPane1.setVisible(true);
((SimpleListModel)this.binaryFiles.getModel()).addAll (files.iterator());
}
public void clearBinaryFileList () {
this.message.setVisible(false);
this.jScrollPane1.setVisible(false);
((SimpleListModel)this.binaryFiles.getModel()).removeAllItems();
}
public void addNoDiffFiles (java.util.Set files) {
this.message2.setVisible(true);
this.jScrollPane2.setVisible(true);
((SimpleListModel)this.noDiffFiles.getModel()).addAll (files.iterator());
}
public void clearNoDiffFileList () {
this.message2.setVisible(false);
this.jScrollPane2.setVisible(false);
((SimpleListModel)this.noDiffFiles.getModel()).removeAllItems();
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel message2;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel message;
private javax.swing.JList binaryFiles;
private javax.swing.JList noDiffFiles;
// End of variables declaration//GEN-END:variables
}
|
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 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.