|
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.checkout; /** * * @author mkleint * @version */ import java.util.Collection; import java.util.List; import java.util.LinkedList; import java.util.Iterator; import java.awt.Dialog; import javax.swing.table.*; import javax.accessibility.*; import java.util.*; import org.netbeans.modules.javacvs.commands.FileSystemCommand; import org.netbeans.lib.cvsclient.command.checkout.ModuleListInformation; import java.lang.reflect.Method; import org.netbeans.modules.javacvs.events.CommandDisplayerListener; import org.netbeans.modules.cvsclient.FsCommandFactory; import org.netbeans.modules.vcscore.util.table.*; import org.openide.util.NbBundle; public class ModulesListPanel extends javax.swing.JPanel implements CommandDisplayerListener { protected TableInfoModel model; private List resultList; /** Creates new form ModulesListPanel */ public ModulesListPanel() { initComponents (); initAccessibility(); JTableHeader head = tblModules.getTableHeader(); head.setUpdateTableInRealTime(true); ColumnSortListener listen = new ColumnSortListener(tblModules); head.addMouseListener(listen); // setting the model.... model = new TableInfoModel(); Class classa = ModuleListInformation.class; String column1 = NbBundle.getBundle(ModulesListPanel.class).getString("ModulesTableInfoModel.module"); //NOI18N String column2 = NbBundle.getBundle(ModulesListPanel.class).getString("ModulesTableInfoModel.moduleType"); //NOI18N String column3 = NbBundle.getBundle(ModulesListPanel.class).getString("ModulesTableInfoModel.moduleStatus"); //NOI18N String column4 = NbBundle.getBundle(ModulesListPanel.class).getString("ModulesTableInfoModel.modulePaths"); //NOI18N try { Method method1 = classa.getMethod("getModuleName", null); //NOI18N Method method2 = classa.getMethod("getType", null); //NOI18N Method method3 = classa.getMethod("getModuleStatus", null); //NOI18N Method method4 = classa.getMethod("getPaths", null); //NOI18N model.setColumnDefinition(0, column1, method1, true, null); model.setColumnDefinition(1, column2, method2, true, null); model.setColumnDefinition(2, column3, method3, true, null); model.setColumnDefinition(3, column4, method4, false, null); } catch (NoSuchMethodException exc) { Thread.dumpStack(); } catch (SecurityException exc2) { Thread.dumpStack(); } tblModules.setModel(model); taPaths.setText(""); //NOI18N tblModules.getSelectionModel().addListSelectionListener( new javax.swing.event.ListSelectionListener() { public void valueChanged(javax.swing.event.ListSelectionEvent e) { changePaths(e); } }); } public void changePaths(javax.swing.event.ListSelectionEvent event) { if (tblModules.getSelectedRowCount() != 1) { taPaths.setText(""); //NOI18N return; } int first = tblModules.getSelectedRow(); ModuleListInformation info = (ModuleListInformation)model.getElementAt(first); if (info != null) { taPaths.setText(info.getPaths().replace(' ', '\n')); } } /** 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 java.awt.GridBagConstraints gridBagConstraints; spModules = new javax.swing.JScrollPane(); tblModules = new javax.swing.JTable(); spPaths = new javax.swing.JScrollPane(); taPaths = new javax.swing.JTextArea(); setLayout(new java.awt.GridBagLayout()); spModules.setPreferredSize(new java.awt.Dimension(400, 150)); spModules.setMinimumSize(new java.awt.Dimension(300, 100)); tblModules.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null}, {null, null, null, null}, {null, null, null, null}, {null, null, null, null} }, new String [] { "Title 1", "Title 2", "Title 3", "Title 4" } )); spModules.setViewportView(tblModules); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.5; gridBagConstraints.weighty = 0.5; gridBagConstraints.insets = new java.awt.Insets(12, 12, 6, 12); add(spModules, gridBagConstraints); spPaths.setPreferredSize(new java.awt.Dimension(400, 70)); spPaths.setMinimumSize(new java.awt.Dimension(300, 50)); taPaths.setEditable(false); spPaths.setViewportView(taPaths); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.5; gridBagConstraints.weighty = 0.5; gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 12); add(spPaths, gridBagConstraints); }//GEN-END:initComponents /** in this method the displayer should use the data returned by the command to * produce it's own data structures/ fill in UI components * @param resultList - the data from the command. It is assumed the Displayer * knows what command the data comes from and most important in what format. * (which FileInfoContainer class is used). */ public void setDataToDisplay(Collection resultList) { List results = (List)resultList; Iterator it = results.iterator(); while (it.hasNext()) { model.addElement(it.next()); } TableColumn col = tblModules.getColumnModel().getColumn(1); col.setPreferredWidth(40); col = tblModules.getColumnModel().getColumn(0); col.setPreferredWidth(120); col = tblModules.getColumnModel().getColumn(2); col.setPreferredWidth(80); } /** Does the actual display - docking into the javacvs Mode, * displaying as single Dialog.. whatever. */ public void displayOutputData() { Dialog dial = FsCommandFactory.createDialog(this, NbBundle.getBundle(ModulesListPanel.class).getString("CvsCheckout.modulesListTitle")); //NOI18N dial.show(); } /** * this method is called before any of the library's commands * that is stored in the queue in FileSystemCommand, is run. * @param currentCommand shows the command that will be executed. */ public void showBeforeEachExecute(org.netbeans.lib.cvsclient.command.Command currentCommand) { } /** * This is the last method to be called in the displayer. * Is called when the execution finishes. Any filan touchups can be made here. */ public void showFinishedCommand() { setDataToDisplay(resultList); displayOutputData(); } /** * This method is the first one that is called during execution. * Here any initial setup of the displayer can be made. */ public void showStartCommand() { resultList = new LinkedList(); } /** * this method is called after library's commands execution */ public void showAfterEachExecute() { } /** * When the server generates a line of output/error, the displayer is notified. * @param message - the string to be displayed, be it error/message (E/M response) */ public void messageGenerated(org.netbeans.lib.cvsclient.event.MessageEvent message) { } /** * this one is called when the command's execution fails for any reason. */ public void showExecutionFailed(Exception exception) { } /** * When the library command's builder generates a FileInfoContainer object, the * Displayer is notified. * @param info - the generated information object */ public void showFileInfoGenerated(org.netbeans.lib.cvsclient.command.FileInfoContainer info) { if (info instanceof ModuleListInformation) { ModuleListInformation mInfo = (ModuleListInformation)info; Iterator it = resultList.iterator(); String modName = mInfo.getModuleName(); while (it.hasNext()) { ModuleListInformation listInfo = (ModuleListInformation)it.next(); if (modName.equals(listInfo.getModuleName())) { listInfo.setModuleStatus(mInfo.getModuleStatus()); return; } } resultList.add(info); } } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JScrollPane spPaths; private javax.swing.JTextArea taPaths; protected javax.swing.JTable tblModules; private javax.swing.JScrollPane spModules; // End of variables declaration//GEN-END:variables private void initAccessibility() { ResourceBundle bundle = NbBundle.getBundle(ModulesListPanel.class); //NOI18N AccessibleContext context = this.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_ModuleListPanel")); context = tblModules.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_ModuleListPanel.tblModules")); context.setAccessibleName(bundle.getString("ACSD_ModuleListPanel.tblModules")); context = taPaths.getAccessibleContext(); context.setAccessibleDescription(bundle.getString("ACSD_ModuleListPanel.taPaths")); context.setAccessibleName(bundle.getString("ACSD_ModuleListPanel.taPaths")); } } |
... 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.