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

📄 conceptapl2.java

📁 《Java网络程序设计.rar》包括三个网络程序的源代码。
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
package org.impact.stars.appclient.concept;

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.tree.*;
import java.util.*;
import java.io.*;
import java.net.*;
import java.sql.Date;

import org.impact.stars.appclient.concept.model.Concept;
import org.impact.stars.appclient.concept.model.ConceptTree;
import org.impact.stars.appclient.concept.model.ConceptTreeModel;
import org.impact.stars.appclient.concept.model.Conceptnode;
import org.impact.stars.appclient.util.ClientUtil;


import org.impact.stars.conceptmd.concept.model.*;
import org.impact.stars.conceptmd.conceptstr.model.*;
import org.impact.stars.control.event.ConceptEvent;
import org.impact.stars.control.event.ConceptstrEvent;
import org.impact.stars.control.event.StarsEventSupport;

/**
 * Insert the type's description here.
 * Creation date: (7/22/00 2:32:56 PM)
 * Modified 10/8/2001
 * @author: 
 */


public class Conceptapl2 extends javax.swing.JApplet implements MouseListener, MouseMotionListener {
	private javax.swing.JButton ivjEditButton = null;
	private javax.swing.JButton ivjHelpButton = null;
	private javax.swing.JButton ivjInfoButton = null;
	private javax.swing.JPanel ivjJAppletContentPane = null;
	private javax.swing.JPanel ivjJPanel1 = null;
	private javax.swing.JPanel ivjJPanel2 = null;
	private javax.swing.JPanel ivjJPanel3 = null;
	private javax.swing.JScrollPane ivjJScrollPane1 = null;
	private javax.swing.JTabbedPane ivjJTabbedPane1 = null;
	private javax.swing.JTextArea statusTextArea = null;
	private javax.swing.JToolBar ivjJToolBar1 = null;
	private javax.swing.JButton ivjLoadButton = null;
	private javax.swing.JButton ivjNewButton = null;
	private javax.swing.JPanel ivjPage1 = null;
	private javax.swing.JButton ivjSaveButton = null;
	private javax.swing.JTree ivjCstree = null;
	private javax.swing.JScrollPane ivjJScrollPane2 = null;
	private javax.swing.JPanel ivjPage2 = null;
	private GridLayout ivjPage2GridLayout = null;
	private javax.swing.JPanel ivjPage3 = null;
	private Conceptnode holetreenode = null;

	private Addconceptdlg addconceptdlg_ = null;
	//the right click handle dialog
	
	//private javax.swing.JTextArea statusTextArea = new javax.swing.JTextArea();
	//
	//private Vector conceptvector = null;
	private java.awt.List conceptList = null;

	private String webServerControlStr = null;
	private String webServerConceptStr = null;
	private String webServerConceptstrStr = null;

	private String webServerReadStr = null;
        
        private Eventgenerator eventgr = null;
	
	//private String hostName = "localhost";
        private String hostName;
	private int port = 8080;

	private String servletreadPath = "/stars/ReadConceptstr?conceptstrID=1";
        private String servletcontrolPath = "/stars/control/concept";
        private String servletconceptPath = "/stars/control/concept";
        private String servletconceptstrPath = "/stars/control/conceptstr";

	
	private final int COLUMN_WIDTH = 35;

	private String lastID = "0";

	boolean reload = false;
	
//***********************************************added
//
	
	/**
	 *  When the display button is pressed, we simply get the
	 *  concept list and display the concepts in the GUI.
	 */


	 
	/*class NewButtonActionListener implements java.awt.event.ActionListener {
		public void actionPerformed(java.awt.event.ActionEvent e) {
			if (e.getSource() == Conceptapl.this.getEditButton()) 
				Addconceptdlg(e);
		};
	}; */


	class ivjNewButtonActionListener implements ActionListener
	{
		public void actionPerformed(ActionEvent event)
		{
			registerConcept("1");
		}
	}
	
	class ivjLoadButtonActionListener implements ActionListener
	{
		public void actionPerformed(ActionEvent event)
		{
			try
			{
				// Get a list of the concepts
				//Vector conceptVector = getConceptList();

				// Display the list of concepts
				//displayConcepts(conceptVector);
				//
				reload = true;
				
				displayConceptTree();
			}
			catch (Exception e)
			{
				System.out.println("Error: " + e);
			}
		}
	}



	class ivjEditButtonActionListener implements ActionListener
	{
		public void actionPerformed(ActionEvent event)
		{
			try
			{
			//getJTabbedPane1().setSelectedComponent(getPage2());
			getJTabbedPane1().setSelectedComponent(ivjPage2);
			// user code begin {2}
			// user code end
				
				}
			catch (Exception e)
			{
				System.out.println("Error: " + e);
			}
		}
	}


//boolean fComponentsAdjusted;


	public void addnewconcept(ActionEvent event)
	{
		try {
		// user code begin {1}
		// user code end
		getJTabbedPane1().setSelectedComponent(getPage2());
		// user code begin {2}
		// user code end
			} catch (java.lang.Throwable ivjExc) {
		// user code begin {3}
		// user code end
		handleException(ivjExc);
			}
	}
/**
 * Insert the method's description here.
 * Creation date: (8/5/00 2:27:28 AM)
 */
public void addPerspective() {
	 Addperspectivedlg registerDialog = new Addperspectivedlg(new javax.swing.JFrame(), true);
	    registerDialog.setVisible(true);
	}
	/**
	 *  Create a row w/ the conceptname, discription and proposestakeholder.  Format this row such that
	 *  the items are equally spaced.
	 */
	protected String createRow(String conceptname, String discription, String proposestakeholder, String concepttype, String status)
	{
		StringBuffer row = new StringBuffer();
		String temp = null;
		
		temp = padString(conceptname);
		row.append(temp + "     ");

		temp = padString(discription);
		row.append(temp + "     ");

		temp = padString(proposestakeholder);
		row.append(temp + "     ");
		
		temp = padString(concepttype);
		row.append(temp + "     ");
		
		temp = padString(status);
		row.append(temp + "     ");
		

		return row.toString();		
	}
	/**
	 * Display the list of concepts in a table<br>
	 *
	 * Iterate over the vector of concepts and display
	 * the name, e-mail and company in the multi-column list.
	 */
        
	protected void displayConcepts(Vector conceptVector)
	{
		Enumeration enum = conceptVector.elements();
		
		ConceptModel aConcept = null;
		String Name = null;
		String proposestakeholder = null;
		String discription = null;
		
		//--
		String concepttype= null;
	   
		String status=null;
		//--

		// clear out the list first
		conceptList.removeAll();
		
		///String headings = createRow("Name", "Description", "PROPSTAKEHOLDER");
		String headings = createRow("Name", "DISCRIPTION", "PROPSTAKEHOLDER","TYPE","STATUS");
		conceptList.add(headings);
		log("only one element");
		
		while (enum.hasMoreElements())
		{
			log("more elements");
			aConcept = (ConceptModel) enum.nextElement();
		
			// get concept's Name, e-mail address and proposestakeholder Name
			Name = aConcept.getName();
			discription = aConcept.getDescription();
			proposestakeholder = aConcept.getPstakeholder();
			concepttype = aConcept.getType();
			status = aConcept.getShared();
			
			// display this concept's info as a row 
			String row = createRow(Name, discription, proposestakeholder, concepttype, status);
			conceptList.add(row);
		}
		
	}
	protected void displayConceptTree()
	{
		getJScrollPane2().setViewportView(getCstree());
	}
	protected void displayConceptTree( Vector aconceptVector)
	{
		getJScrollPane2().setViewportView(getCstree());
	}
/**
 * Returns information about this applet.
 * @return a string of information about this applet
 */
public String getAppletInfo() {
	return "conceptapl\n" + 
		"\n" + 
		"The concept structure view applet\n" + 
		"Creation date: (7/22/00 2:32:36 PM)\n" + 
		"@author: Jian Cai\n" + 
		"";
}
	//added
	protected Vector getConceptList()
	{

		ObjectInputStream inputFromServlet = null;
		Vector conceptVector = null;
		
	    try
	    {     
	        // build a GET url string w/ encoded name/value pairs
	        //
	        // Send over UserOption=AppletDisplay.  The servlet will interpret
	        // the user option and send back the concept list as a serialized vector
	        // of concept objects.
	        //
                /*
	        String servletGET = webServerStr + "?" 
	                            + URLEncoder.encode("UserOption") + "=" 
	                            + URLEncoder.encode("AppletDisplay");
	        */
                String servletGET = webServerReadStr;
			// connect to the servlet
			log("Connecting...");
			URL conceptDBservlet = new URL( servletGET );
			URLConnection servletConnection = conceptDBservlet.openConnection();  
	        	/*servletConnection.setDoInput(true);          
                          servletConnection.setDoOutput(true);
                        */
			
	        	
	        // Read the input from the servlet.  
	        //
	        // The servlet will return a serialized vector containing
	        // concept entries.
	        //
			log("Getting input stream");
	        inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());

	        conceptVector = readConceptVector(inputFromServlet);
	        
	    }
	    catch (Exception e)
	    {
	        log(e.toString());
	    }

		return conceptVector;
			
	}
	//added
        /*
	protected Vector getConceptList1()
	{

		ObjectInputStream inputFromServlet = null;
		Vector conceptVector = new Vector();
		ConceptModel aconcept = null;

		aconcept = new ConceptModel("1","da1","1","dfafa","dfa","dfa", (new Date(2001,1,20)),"1","1");
		conceptVector.addElement(aconcept);
                aconcept = new ConceptModel("2","da1","1","dfafa","dfa","dfa", (new Date(2001,1,20)),"1","1");
		conceptVector.addElement(aconcept);
                aconcept = new ConceptModel("3","da1","1","dfafa","dfa","dfa", (new Date(2001,1,20)),"1","1");
		conceptVector.addElement(aconcept);
                aconcept = new ConceptModel("4","da1","1","dfafa","dfa","dfa", (new Date(2001,1,20)),"1","1");
		conceptVector.addElement(aconcept);
                aconcept = new ConceptModel("5","da1","1","dfafa","dfa","dfa", (new Date(2001,1,20)),"1","1");
		conceptVector.addElement(aconcept);
                aconcept = new ConceptModel("6","da1","1","dfafa","dfa","dfa", (new Date(2001,1,20)),"1","1");
		conceptVector.addElement(aconcept);
                aconcept = new ConceptModel("7","da1","1","dfafa","dfa","dfa", (new Date(2001,1,20)),"1","1");
		conceptVector.addElement(aconcept);
                aconcept = new ConceptModel("8","da1","1","dfafa","dfa","dfa", (new Date(2001,1,20)),"1","1");
		conceptVector.addElement(aconcept);
                

		
		
		

		return conceptVector;
			
	}
         */
/**
 * Return the Cstree property value.
 * @return javax.swing.JTree
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */

private javax.swing.JTree getCstree() {
	if ((ivjCstree == null)||reload) {
		try {
			
			//ivjCstree = new ConceptTree(getroot());

⌨️ 快捷键说明

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