/***************************************************
*
* cismet GmbH, Saarbruecken, Germany
*
* ... and it just works.
*
****************************************************/
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package de.cismet.cismap.commons.drophandler.builtin;
import java.awt.Component;
import java.io.File;
import java.util.Collection;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
/**
* DOCUMENT ME!
*
* @author jruiz
* @version $Revision$, $Date$
*/
public class MappingComponentUnknownFileDropHandlerDialog extends javax.swing.JDialog {
//~ Instance fields --------------------------------------------------------
private Collection<File> unknownFiles;
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
private javax.swing.JList<File> jList1;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration//GEN-END:variables
//~ Constructors -----------------------------------------------------------
/**
* Creates new form MappingComponentUnknownFileDropHandlerDialog.
*/
private MappingComponentUnknownFileDropHandlerDialog() {
super((JFrame)null, true);
initComponents();
}
//~ Methods ----------------------------------------------------------------
/**
* DOCUMENT ME!
*
* @param unknownFiles DOCUMENT ME!
*/
public void setUnknownFiles(final Collection<File> unknownFiles) {
this.unknownFiles = unknownFiles;
((DefaultListModel<File>)jList1.getModel()).clear();
for (final File unknownFile : this.unknownFiles) {
((DefaultListModel<File>)jList1.getModel()).addElement(unknownFile);
}
}
/**
* 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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jList1 = new javax.swing.JList<File>();
setTitle(org.openide.util.NbBundle.getMessage(
MappingComponentUnknownFileDropHandlerDialog.class,
"MappingComponentUnknownFileDropHandlerDialog.title")); // NOI18N
getContentPane().setLayout(new java.awt.GridBagLayout());
jPanel1.setLayout(new java.awt.GridBagLayout());
org.openide.awt.Mnemonics.setLocalizedText(
jLabel1,
org.openide.util.NbBundle.getMessage(
MappingComponentUnknownFileDropHandlerDialog.class,
"MappingComponentUnknownFileDropHandlerDialog.jLabel1.text")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
jPanel1.add(jLabel1, gridBagConstraints);
jList1.setModel(new DefaultListModel<File>());
jList1.setCellRenderer(new ListCellRenderer());
jScrollPane1.setViewportView(jList1);
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(5, 0, 0, 0);
jPanel1.add(jScrollPane1, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
getContentPane().add(jPanel1, gridBagConstraints);
pack();
} // </editor-fold>//GEN-END:initComponents
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public static MappingComponentUnknownFileDropHandlerDialog getInstance() {
return LazyInitialiser.INSTANCE;
}
//~ Inner Classes ----------------------------------------------------------
/**
* DOCUMENT ME!
*
* @version $Revision$, $Date$
*/
private static final class LazyInitialiser {
//~ Static fields/initializers -----------------------------------------
private static final MappingComponentUnknownFileDropHandlerDialog INSTANCE =
new MappingComponentUnknownFileDropHandlerDialog();
//~ Constructors -------------------------------------------------------
/**
* Creates a new LazyInitialiser object.
*/
private LazyInitialiser() {
}
}
/**
* DOCUMENT ME!
*
* @version $Revision$, $Date$
*/
private class ListCellRenderer extends DefaultListCellRenderer {
//~ Methods ------------------------------------------------------------
@Override
public Component getListCellRendererComponent(final JList<?> list,
final Object value,
final int index,
final boolean isSelected,
final boolean cellHasFocus) {
final JLabel component = (JLabel)super.getListCellRendererComponent(
list,
value,
index,
isSelected,
cellHasFocus);
component.setToolTipText(((File)value).getAbsolutePath());
component.setText(((File)value).getName());
return component;
}
}
}