⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 algorithmmodifydialog.java

📁 数据挖掘的工具代码(包含fp-tree,appriory
💻 JAVA
字号:
/*ARMiner - Association Rules MinerCopyright (C) 2000  UMass/Boston - Computer Science DepartmentThis program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or (atyour option) any later version.This program is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USAThe ARMiner Server was written by Dana Cristofor and LaurentiuCristofor.The ARMiner Client was written by Abdelmajid Karatihy, Xiaoyong Kuang,and Lung-Tsung Li.The ARMiner package is currently maintained by Laurentiu Cristofor(laur@cs.umb.edu).*//*     This file is a part of the ARMiner project.      (P)1999-2000 by ARMiner Client Team:   Abdelmajid Karatihy   Xiaoyong Kuang   Lung-Tsung Li*/import javax.swing.*;import java.util.*;import java.awt.*;import java.awt.event.*;/*  Maintenance log started on November 20th, 2000 by Laurentiu Cristofor  Nov. 20th, 2000   - made some style changes  Nov. 21st, 2000   - resized and repositioned widgets*/ /** * AlgorithmModifyDialog.java<P> *  * Create a dialog to allow the user to be able to change an algorithm's * associated group or delete an algorithm from the system catalog. *  */public class AlgorithmModifyDialog extends CenteredDialog{  /** Initializes the Form */  public AlgorithmModifyDialog(javax.swing.JFrame parent, 			       boolean modal, 			       Vector algorithms, Vector groups)   {    super (parent,"Modify/Delete Algorithms", modal);    this.parent = parent;    setSize(430,300);    this.algorithms = algorithms;    this.groups = groups;    initComponents ();    setLocation(getDialogCenteredLoc(parent));    setResizable(false);  }  /** 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    //setBackground (new java.awt.Color (204, 204, 204));    addWindowListener (new java.awt.event.WindowAdapter () {        public void windowClosing (java.awt.event.WindowEvent evt) {          closeDialog (evt);        }      });    getContentPane ().setLayout (new com.netbeans.developer.awt.AbsoluteLayout ());    getContentPane().add (new javax.swing.JLabel("Algorithms Available:"), 			  new com.netbeans.developer.awt.AbsoluteConstraints (40, 90, 140, 30));        jcbAlgList = new javax.swing.JComboBox (algorithms);    jcbAlgList.setMaximumRowCount(6);    jcbAlgList.addActionListener (new java.awt.event.ActionListener () {        public void actionPerformed (java.awt.event.ActionEvent evt) {          jcbAlgListActionPerformed (evt);        }      });        getContentPane ().add (jcbAlgList, new com.netbeans.developer.awt.AbsoluteConstraints (40, 120, 140, 25));        jbtnDelete = new javax.swing.JButton ("Delete");    jbtnDelete.setMnemonic(KeyEvent.VK_D);    jbtnDelete.addActionListener (new java.awt.event.ActionListener () {        public void actionPerformed (java.awt.event.ActionEvent evt) {          jbtnDeleteActionPerformed (evt);        }      });        getContentPane ().add (jbtnDelete, new com.netbeans.developer.awt.AbsoluteConstraints (40, 20, 85, 25));        jbtnSave = new javax.swing.JButton ("Save");    jbtnSave.setMnemonic(KeyEvent.VK_S);    jbtnSave.addActionListener (new java.awt.event.ActionListener () {        public void actionPerformed (java.awt.event.ActionEvent evt) {          jbtnSaveActionPerformed (evt);        }      });    getContentPane ().add (jbtnSave, new com.netbeans.developer.awt.AbsoluteConstraints (130, 20, 85, 25));        jbtnClose = new javax.swing.JButton ("Close");    jbtnClose.setMnemonic(KeyEvent.VK_C);    jbtnClose.addActionListener (new java.awt.event.ActionListener () {        public void actionPerformed (java.awt.event.ActionEvent evt) {          jbtnCloseActionPerformed (evt);        }      });    getContentPane ().add (jbtnClose, new com.netbeans.developer.awt.AbsoluteConstraints (310, 20, 85, 25));        getContentPane ().add (new javax.swing.JLabel("Group Access:"), new com.netbeans.developer.awt.AbsoluteConstraints (255, 90, 140, 30));        jcbGroupList = new javax.swing.JComboBox (groups);    jcbGroupList.setMaximumRowCount(6);    getContentPane ().add (jcbGroupList, new com.netbeans.developer.awt.AbsoluteConstraints (255, 120, 140, 25));    selectedAlg = (String)algorithms.get(0);    jcbGroupList.setSelectedItem(getAlgGroup(selectedAlg));        jbtnRefresh = new javax.swing.JButton ("Refresh");    jbtnRefresh.setMnemonic(KeyEvent.VK_R);    jbtnRefresh.addActionListener (new java.awt.event.ActionListener () {        public void actionPerformed (java.awt.event.ActionEvent evt) {          jbtnRefreshActionPerformed (evt);        }      });    getContentPane ().add (jbtnRefresh, new com.netbeans.developer.awt.AbsoluteConstraints (220, 20, 85, 25));  }//GEN-END:initComponents    private void jbtnSaveActionPerformed (java.awt.event.ActionEvent evt)   {//GEN-FIRST:event_jbtnSaveActionPerformed    // Add your handling code here:    Vector request = new Vector();    int indexAlg = jcbAlgList.getSelectedIndex();        if(indexAlg < 0 )      {	JOptionPane.showMessageDialog(this, "Must select an algorithm to modify.");	return;      }    int indexGrp = jcbGroupList.getSelectedIndex();    if(indexGrp < 0 )      {	JOptionPane.showMessageDialog(this, "Must select a group to modify.");	return;      }    String alg = (String)jcbAlgList.getSelectedItem();     request.add(alg);    String grp = (String)jcbGroupList.getSelectedItem();     if(grp.equals(selectedGroup) == true)      {	JOptionPane.showMessageDialog(this, "The " + alg + " 's group doesn't get changed. Transaction aborted!");	return;      }    request.add(grp);    try      {	Client.modifyAlgorithms(request);	JOptionPane.showMessageDialog(this, "The " + alg + " 's group access has been successfully modified to " + grp);	refresh();	repaint();      }    catch(ClientErrorException e)      {	JOptionPane.showMessageDialog(this, "AlgorithmModify: Client Error in modifying algorithms from DBConfig:\n " + e.toString() + "\nTransaction aborted!");	return;      }  }//GEN-LAST:event_jbtnSaveActionPerformed    private void jbtnCloseActionPerformed (java.awt.event.ActionEvent evt)   {//GEN-FIRST:event_jbtnCloseActionPerformed    // Add your handling code here:    setVisible(false);    dispose ();    parent.repaint();  }//GEN-LAST:event_jbtnCloseActionPerformed  private void jcbAlgListActionPerformed (java.awt.event.ActionEvent evt)   {//GEN-FIRST:jcbAlgListActionPerformed    if(isReload == true)      return;    selectedAlg = (String)jcbAlgList.getSelectedItem();    if(selectedAlg == null)      return;    String grp = getAlgGroup(selectedAlg);    //if(grp == null)    //  return;    jcbGroupList.setSelectedItem(grp);  }//GEN-LAST:jcbAlgListActionPerformed  private String getAlgGroup(String alg)  {    try      {	//System.out.println("getting group for " + alg);	selectedGroup = Client.dbConfig.getAlgorithmGroup(alg);	return selectedGroup;       }    catch(DBConfigException e)      {	JOptionPane.showMessageDialog(this, "AlgorithmModifyDialog: Error in getting algorithm group from DBConfig: " + e.toString());	return null;      }  }  	  private void refresh()  {    try      {	Client.getDBConfig1();      }    catch(ClientErrorException e)      {	JOptionPane.showMessageDialog(this, "AlgorithmModify: Client Error in getting DBConfig:\n " + e.toString() + "\nTransaction aborted!");	return;      }        try      {	copy(Client.dbConfig.listGroups(Client.userName),groups);	refGroups = (Vector)groups.clone();	//System.out.println("In refresh refGroups after clone " + refGroups.toString());      }    catch(DBConfigException e)      {	JOptionPane.showMessageDialog(this, "AlgorithmModify: Client Error in getting groups from DBConfig:\n " + e.toString() + "\nTransaction aborted!");	return;      }    try      {	Vector v1 = Client.dbConfig.listAlgorithms(Client.userName);	//System.out.println(v1);	copy(Client.dbConfig.listAlgorithms(Client.userName),algorithms);	//System.out.println(algorithms);	refAlgs = (Vector)algorithms.clone();      }    catch(DBConfigException e)      {	JOptionPane.showMessageDialog(this, "AlgorithmModify: Client Error in getting algorithms from DBConfig:\n " + e.toString() + "\nTransaction aborted!");	return;      }  }    private void copy(Vector v1, Vector v2)  {    v2.clear();    for(int i = 0; i < v1.size(); i++)      v2.add(v1.get(i));    return;  }	  private void jbtnDeleteActionPerformed (java.awt.event.ActionEvent evt)   {//GEN-FIRST:event_jbtnDeleteActionPerformed    // Add your handling code here:    Vector request = new Vector();    int index = jcbAlgList.getSelectedIndex();    if(index < 0)      {	JOptionPane.showMessageDialog(this, "Must select an algorithm to delete.");	return;      }        selectedAlg = (String)jcbAlgList.getSelectedItem();    request.add(selectedAlg);    //System.out.println(selectedAlg);    try      {	Client.deleteAlgorithms(request);	JOptionPane.showMessageDialog(this, "The algorithm " + selectedAlg + " has been succesfully deleted.");	algorithms.remove(selectedAlg);	jcbAlgList.setSelectedIndex(0);	repaint();      }    catch(ClientErrorException e)      {	JOptionPane.showMessageDialog(this, "AlgorithmModify: Client Error in deleting algorithms from DBConfig:\n " + e.toString() + "\nTransaction aborted!");	return;      }  }//GEN-LAST:event_jbtnDeleteActionPerformed    private void jbtnRefreshActionPerformed (java.awt.event.ActionEvent evt)   {//GEN-FIRST:event_jbtnRefreshActionPerformed    // Add your handling code here:    refresh();    if(!algorithms.contains(selectedAlg))      {	JOptionPane.showMessageDialog(this, "AlgorithmModify: the selected algorithm " + selectedAlg + " is likely to have been removed by another user.");	jcbAlgList.setSelectedIndex(0);	selectedAlg = (String)jcbAlgList.getSelectedItem();	jcbGroupList.setSelectedItem(getAlgGroup(selectedAlg));	return;      }    isReload = true;    jcbGroupList.removeAllItems();    jcbAlgList.removeAllItems();    for(int i = 0; i < refGroups.size(); i++)      jcbGroupList.addItem(refGroups.get(i));    for(int i = 0; i < refAlgs.size(); i++)      jcbAlgList.addItem(refAlgs.get(i));    jcbAlgList.setSelectedItem(selectedAlg);    jcbGroupList.setSelectedItem(getAlgGroup(selectedAlg));    isReload = false;  }//GEN-LAST:event_jbtnRefreshActionPerformed    /** Closes the dialog */  private void closeDialog(java.awt.event.WindowEvent evt)   {//GEN-FIRST:event_closeDialog    setVisible (false);    dispose ();    parent.repaint();  }//GEN-LAST:event_closeDialog    // Variables declaration - do not modify//GEN-BEGIN:variables  //private javax.swing.JLabel jlbAlgList;  private javax.swing.JComboBox jcbAlgList;  private javax.swing.JButton jbtnDelete;  private javax.swing.JButton jbtnSave;  private javax.swing.JButton jbtnClose;  private javax.swing.JTextField jtxfAlgName;  private javax.swing.JComboBox jcbGroupList;  private javax.swing.JButton jbtnRefresh;  private javax.swing.JFrame parent;  private Vector algorithms = new Vector();  private Vector groups = new Vector();  private Vector refGroups = new Vector();  private Vector refAlgs = new Vector();  private String selectedAlg;  private String selectedGroup;  private boolean isReload = false;  // End of variables declaration//GEN-END:variables}

⌨️ 快捷键说明

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