testconfigurationdialog.java

来自「cqME :java framework for TCK test.」· Java 代码 · 共 351 行 · 第 1/2 页

JAVA
351
字号
/*
 * $Id$
 *
 * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License version
 * 2 only, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License version 2 for more details (a copy is
 * included at /legal/license.txt).
 *
 * You should have received a copy of the GNU General Public License
 * version 2 along with this work; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
 * Clara, CA 95054 or visit www.sun.com if you need additional
 * information or have any questions.
 *
 */


package com.sun.testme.data.gui;

import com.sun.testme.data.TestConfiguration;
import java.awt.Frame;
import java.io.File;
import java.util.Iterator;
import java.util.Vector;
import javax.swing.JFileChooser;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import org.openide.filesystems.FileObject;
import org.openide.loaders.DataObject;

/**
 *
 * @author  rz155578
 */
public class TestConfigurationDialog extends javax.swing.JDialog {
    
    /** Creates new form TestConfigurationDialog */
    public TestConfigurationDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }
    
    public TestConfigurationDialog(DataObject c) {
        super(new Frame(), true);
        initComponents();
        initData(c);
    }

    private void addDataToJTable(Vector data, JTable table) {
        Iterator i = data.iterator();
        while (i.hasNext()) {
            String path = (String)i.next();
            ((DefaultTableModel)table.getModel()).addRow(new String[] {path});
        }
    }
    
    public void initData(DataObject c) {
        FileObject fob = c.getPrimaryFile();
        jCurTestPkgTextField.setText(fob.getPath());
        initConf = TestConfiguration.tryToLoad(fob);
        if (initConf != null) {
            addDataToJTable(initConf.getPlatformCp(), jTestedPlatformTable);
            addDataToJTable(initConf.getAppCp(), jTestedAppTable);
        }
    }
    
    /** 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.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jOkButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jCurTestPkgTextField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jTestedPlatformScrollPane = new javax.swing.JScrollPane();
        jTestedPlatformTable = new javax.swing.JTable();
        jAddPlatformCpButton = new javax.swing.JButton();
        jRemovePlatformCpButton = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jTestedAppScrollPane = new javax.swing.JScrollPane();
        jTestedAppTable = new javax.swing.JTable();
        jAddAppCpButton = new javax.swing.JButton();
        jRemoveAppCpButton = new javax.swing.JButton();
        jCancelButton = new javax.swing.JButton();

        jTable1.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"
            }
        ));
        jScrollPane1.setViewportView(jTable1);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Test configuration");
        jOkButton.setText("OK");
        jOkButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jOkButtonActionPerformed(evt);
            }
        });

        jLabel1.setText("Current test package:");

        jCurTestPkgTextField.setEnabled(false);

        jLabel2.setText("Tested platform:");

        jTestedPlatformTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Path"
            }
        ));
        jTestedPlatformScrollPane.setViewportView(jTestedPlatformTable);

        jAddPlatformCpButton.setText("Add");
        jAddPlatformCpButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jAddPlatformCpButtonActionPerformed(evt);
            }
        });

        jRemovePlatformCpButton.setLabel("Remove");
        jRemovePlatformCpButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRemovePlatformCpButtonActionPerformed(evt);
            }
        });

        jLabel3.setText("Tested Application:");

        jTestedAppTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Path"
            }
        ));
        jTestedAppScrollPane.setViewportView(jTestedAppTable);

        jAddAppCpButton.setText("Add");
        jAddAppCpButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jAddAppCpButtonActionPerformed(evt);
            }
        });

        jRemoveAppCpButton.setText("Remove");
        jRemoveAppCpButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRemoveAppCpButtonActionPerformed(evt);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?