?? wizard.java
字號:
/*
* Created by IntelliJ IDEA.
* User: dbradford
* Date: Sep 23, 2002
* Time: 10:20:37 AM
* To change template for new class use
* Code Style | Class Templates options (Tools | IDE Options).
*/
package cdt.projects.tree.nodes;
import javax.swing.*;
import java.io.OutputStream;
import java.util.LinkedList;
import cdt.projects.tree.wizards.quiz.QuizWizard;
import cdt.projects.tree.wizards.diffdx.DifferentialWizard;
import cdt.projects.tree.wizards.treatment.TreatmentWizard;
import cdt.Frame1;
public class Wizard extends Node {
/** Identifier indicating that this wizard launches a quiz wizard. */
public static final String QUIZ_WIZARD = new String("Quiz Wizard");
/**
* Identifier indicating that this wizard launches a differential diagnosis wizard.
*/
public static final String DIFFDX_WIZARD = new String("Differential Diagnosis Wizard");
/** Identifier indicating that this wizard launches the treatment wizard. */
public static final String TREATMENT_WIZARD = new String("Treatment Wizard");
/** Identifier indicating what kind of wizard this node represents. */
private String wizardType;
/**
* Initializes a Wizard node.
*/
public Wizard() {
this.wizardType = null;
}
/**
* Not used.
*
* @return null.
*/
public String getData() {
return null;
}
/**
* Not used.
*
* @param s unused.
*/
public void setData(String s) {
}
/**
* Assigns what type of wizard this is.
*
* @param wizardType The type of wizard this node represents.
*/
public void setWizardType(String wizardType) {
this.wizardType = wizardType;
}
/**
* Tells what kind of wizard this node represents.
*
* @return The type of wizard this node represents.
*/
public String getWizardType() {
return this.wizardType;
}
/**
* Runs the wizard represented by a given wizard node.
*
* @param wiz The wizard that need to be run.
*/
public static void runWizard(Wizard wiz) {
final String wizardType = wiz.getWizardType();
if(null == wizardType) { return; }
// This is needed to prevent NullPointerException's modifying the project tree
Runnable doWork = new Runnable() {
public void run() {
if(wizardType.equals(QUIZ_WIZARD)) {
new QuizWizard(Frame1.frame);
} else if(wizardType.equals(DIFFDX_WIZARD)) {
new DifferentialWizard(Frame1.frame);
} else if(wizardType.equals(TREATMENT_WIZARD)) {
new TreatmentWizard(Frame1.frame);
}
}
};
SwingUtilities.invokeLater(doWork);
}
/**
* Cannot add nodes into this one, so this is left blank.
*
* @param into Not used.
*/
public void addNodeInto(Node into) {
LinkedList list = getSiblings();
list.remove(this);
}
/**
* Makes a copy of this node. Needed for saving.
*
* @return copy of this node.
*/
public Node copy() {
Wizard ret = new Wizard();
ret.setWizardType(this.getWizardType());
ret.setName(this.getName());
return ret;
}
/**
* Whether or not this node is visible in the {@link cdt.projects.tree.ProjectTree ProjectTree}.
*
* @return true.
*/
public boolean isVisible() {
return true;
}
/**
* Writes the project data to an OutputStream.
*
* @param out OutputStream to send project data to.
* @param dir Indicates the directory of the file this {@link Node Node} represents.
*/
public void writeProject(OutputStream out, String dir) {
try {
String tag = "<wizard name=\"" +getName()+ "\" wizardType=\"" +this.getWizardType()+ "\"/>\n";
out.write(tag.getBytes());
} catch(Exception e) {
cdt.ErrorD.ErrorDlg.ErrorMsg("Error writing project -> " +dir+getFile());
}
}
/**
* Wizards cannot have children, as that makes them appear as folders
* defaultly in the tree.
*
* @return false.
*/
public boolean getAllowsChildren() {
return false;
}
/**
* a node has been dropped into this one so add it above this one.
*
* @param n node dropped.
*/
public void dropInto(Node n) {
addNodeAbove(n);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -