merge fixing
This commit is contained in:
parent
d2637f4bbd
commit
e8abfbd306
@ -3,10 +3,10 @@
|
|||||||
*/
|
*/
|
||||||
package net.sf.openrocket.gui.print.components;
|
package net.sf.openrocket.gui.print.components;
|
||||||
|
|
||||||
import net.sf.openrocket.gui.print.OpenRocketPrintable;
|
import java.util.ArrayList;
|
||||||
import net.sf.openrocket.gui.print.PrintableContext;
|
import java.util.Iterator;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import java.util.List;
|
||||||
import net.sf.openrocket.rocketcomponent.Stage;
|
import java.util.Vector;
|
||||||
|
|
||||||
import javax.swing.JTree;
|
import javax.swing.JTree;
|
||||||
import javax.swing.event.TreeExpansionEvent;
|
import javax.swing.event.TreeExpansionEvent;
|
||||||
@ -15,10 +15,11 @@ import javax.swing.tree.DefaultMutableTreeNode;
|
|||||||
import javax.swing.tree.ExpandVetoException;
|
import javax.swing.tree.ExpandVetoException;
|
||||||
import javax.swing.tree.TreePath;
|
import javax.swing.tree.TreePath;
|
||||||
import javax.swing.tree.TreeSelectionModel;
|
import javax.swing.tree.TreeSelectionModel;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
import net.sf.openrocket.gui.print.OpenRocketPrintable;
|
||||||
import java.util.List;
|
import net.sf.openrocket.gui.print.PrintableContext;
|
||||||
import java.util.Vector;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
|
import net.sf.openrocket.rocketcomponent.Stage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized JTree for displaying various rocket items that can be printed.
|
* A specialized JTree for displaying various rocket items that can be printed.
|
||||||
@ -40,7 +41,7 @@ public class RocketPrintTree extends JTree {
|
|||||||
*
|
*
|
||||||
* @param root the vector of check box nodes (rows) to place into the tree
|
* @param root the vector of check box nodes (rows) to place into the tree
|
||||||
*/
|
*/
|
||||||
private RocketPrintTree (Vector root) {
|
private RocketPrintTree(Vector root) {
|
||||||
super(root);
|
super(root);
|
||||||
|
|
||||||
//Remove the little down and sideways arrows. These are not needed because the tree expansion is fixed.
|
//Remove the little down and sideways arrows. These are not needed because the tree expansion is fixed.
|
||||||
@ -58,12 +59,12 @@ public class RocketPrintTree extends JTree {
|
|||||||
*
|
*
|
||||||
* @return an instance of JTree
|
* @return an instance of JTree
|
||||||
*/
|
*/
|
||||||
public static RocketPrintTree create (String rocketName, RocketComponent[] stages) {
|
public static RocketPrintTree create(String rocketName, List<RocketComponent> stages) {
|
||||||
Vector root = new Vector();
|
Vector root = new Vector();
|
||||||
Vector toAddTo = root;
|
Vector toAddTo = root;
|
||||||
|
|
||||||
if (stages != null) {
|
if (stages != null) {
|
||||||
if (stages.length > 1) {
|
if (stages.size() > 1) {
|
||||||
final Vector parent = new NamedVector(rocketName != null ? rocketName : "Rocket");
|
final Vector parent = new NamedVector(rocketName != null ? rocketName : "Rocket");
|
||||||
|
|
||||||
root.add(parent);
|
root.add(parent);
|
||||||
@ -82,10 +83,12 @@ public class RocketPrintTree extends JTree {
|
|||||||
|
|
||||||
tree.addTreeWillExpandListener
|
tree.addTreeWillExpandListener
|
||||||
(new TreeWillExpandListener() {
|
(new TreeWillExpandListener() {
|
||||||
public void treeWillExpand (TreeExpansionEvent e) {
|
@Override
|
||||||
|
public void treeWillExpand(TreeExpansionEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void treeWillCollapse (TreeExpansionEvent e)
|
@Override
|
||||||
|
public void treeWillCollapse(TreeExpansionEvent e)
|
||||||
throws ExpandVetoException {
|
throws ExpandVetoException {
|
||||||
throw new ExpandVetoException(e, "you can't collapse this JTree");
|
throw new ExpandVetoException(e, "you can't collapse this JTree");
|
||||||
}
|
}
|
||||||
@ -101,7 +104,7 @@ public class RocketPrintTree extends JTree {
|
|||||||
*
|
*
|
||||||
* @return an instance of JTree
|
* @return an instance of JTree
|
||||||
*/
|
*/
|
||||||
public static RocketPrintTree create (String rocketName) {
|
public static RocketPrintTree create(String rocketName) {
|
||||||
Vector root = new Vector();
|
Vector root = new Vector();
|
||||||
root.add(new NamedVector(rocketName != null ? rocketName : "Rocket", createPrintTreeNode(false)));
|
root.add(new NamedVector(rocketName != null ? rocketName : "Rocket", createPrintTreeNode(false)));
|
||||||
|
|
||||||
@ -109,10 +112,12 @@ public class RocketPrintTree extends JTree {
|
|||||||
|
|
||||||
tree.addTreeWillExpandListener
|
tree.addTreeWillExpandListener
|
||||||
(new TreeWillExpandListener() {
|
(new TreeWillExpandListener() {
|
||||||
public void treeWillExpand (TreeExpansionEvent e) {
|
@Override
|
||||||
|
public void treeWillExpand(TreeExpansionEvent e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void treeWillCollapse (TreeExpansionEvent e)
|
@Override
|
||||||
|
public void treeWillCollapse(TreeExpansionEvent e)
|
||||||
throws ExpandVetoException {
|
throws ExpandVetoException {
|
||||||
throw new ExpandVetoException(e, "you can't collapse this JTree");
|
throw new ExpandVetoException(e, "you can't collapse this JTree");
|
||||||
}
|
}
|
||||||
@ -131,7 +136,7 @@ public class RocketPrintTree extends JTree {
|
|||||||
*
|
*
|
||||||
* @param checkBoxSelectionModel the selection model used to keep track of the check box state
|
* @param checkBoxSelectionModel the selection model used to keep track of the check box state
|
||||||
*/
|
*/
|
||||||
public void setCheckBoxSelectionModel (TreeSelectionModel checkBoxSelectionModel) {
|
public void setCheckBoxSelectionModel(TreeSelectionModel checkBoxSelectionModel) {
|
||||||
theCheckBoxSelectionModel = checkBoxSelectionModel;
|
theCheckBoxSelectionModel = checkBoxSelectionModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +146,8 @@ public class RocketPrintTree extends JTree {
|
|||||||
*
|
*
|
||||||
* @param path the path (row)
|
* @param path the path (row)
|
||||||
*/
|
*/
|
||||||
public void addSelectionPath (TreePath path) {
|
@Override
|
||||||
|
public void addSelectionPath(TreePath path) {
|
||||||
theCheckBoxSelectionModel.addSelectionPath(path);
|
theCheckBoxSelectionModel.addSelectionPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +160,7 @@ public class RocketPrintTree extends JTree {
|
|||||||
*
|
*
|
||||||
* @return a NamedVector suitable for adding to a JTree
|
* @return a NamedVector suitable for adding to a JTree
|
||||||
*/
|
*/
|
||||||
private static Vector createNamedVector (String name, CheckBoxNode[] nodes, int stage) {
|
private static Vector createNamedVector(String name, CheckBoxNode[] nodes, int stage) {
|
||||||
return new NamedVector(name, nodes, stage);
|
return new NamedVector(name, nodes, stage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,11 +172,11 @@ public class RocketPrintTree extends JTree {
|
|||||||
*
|
*
|
||||||
* @return an array of CheckBoxNode
|
* @return an array of CheckBoxNode
|
||||||
*/
|
*/
|
||||||
private static CheckBoxNode[] createPrintTreeNode (boolean onlyStageSpecific) {
|
private static CheckBoxNode[] createPrintTreeNode(boolean onlyStageSpecific) {
|
||||||
List<CheckBoxNode> nodes = new ArrayList<CheckBoxNode>();
|
List<CheckBoxNode> nodes = new ArrayList<CheckBoxNode>();
|
||||||
OpenRocketPrintable[] printables = OpenRocketPrintable.values();
|
OpenRocketPrintable[] printables = OpenRocketPrintable.values();
|
||||||
for (OpenRocketPrintable openRocketPrintable : printables) {
|
for (OpenRocketPrintable openRocketPrintable : printables) {
|
||||||
if (!onlyStageSpecific || openRocketPrintable.isStageSpecific() ) {
|
if (!onlyStageSpecific || openRocketPrintable.isStageSpecific()) {
|
||||||
nodes.add(new CheckBoxNode(openRocketPrintable.getDescription(),
|
nodes.add(new CheckBoxNode(openRocketPrintable.getDescription(),
|
||||||
INITIAL_CHECKBOX_SELECTED));
|
INITIAL_CHECKBOX_SELECTED));
|
||||||
}
|
}
|
||||||
@ -183,7 +189,7 @@ public class RocketPrintTree extends JTree {
|
|||||||
*
|
*
|
||||||
* @return the things to be printed, returned as an Iterator<PrintableContext>
|
* @return the things to be printed, returned as an Iterator<PrintableContext>
|
||||||
*/
|
*/
|
||||||
public Iterator<PrintableContext> getToBePrinted () {
|
public Iterator<PrintableContext> getToBePrinted() {
|
||||||
final DefaultMutableTreeNode mutableTreeNode = (DefaultMutableTreeNode) getModel().getRoot();
|
final DefaultMutableTreeNode mutableTreeNode = (DefaultMutableTreeNode) getModel().getRoot();
|
||||||
PrintableContext pc = new PrintableContext();
|
PrintableContext pc = new PrintableContext();
|
||||||
add(pc, mutableTreeNode);
|
add(pc, mutableTreeNode);
|
||||||
@ -197,7 +203,7 @@ public class RocketPrintTree extends JTree {
|
|||||||
* @param pc the printable context that aggregates the choices into an iterator
|
* @param pc the printable context that aggregates the choices into an iterator
|
||||||
* @param theMutableTreeNode the root node
|
* @param theMutableTreeNode the root node
|
||||||
*/
|
*/
|
||||||
private void add (final PrintableContext pc, final DefaultMutableTreeNode theMutableTreeNode) {
|
private void add(final PrintableContext pc, final DefaultMutableTreeNode theMutableTreeNode) {
|
||||||
int children = theMutableTreeNode.getChildCount();
|
int children = theMutableTreeNode.getChildCount();
|
||||||
for (int x = 0; x < children; x++) {
|
for (int x = 0; x < children; x++) {
|
||||||
|
|
||||||
@ -226,27 +232,28 @@ class NamedVector extends Vector<CheckBoxNode> {
|
|||||||
|
|
||||||
int stageNumber;
|
int stageNumber;
|
||||||
|
|
||||||
public NamedVector (String theName) {
|
public NamedVector(String theName) {
|
||||||
name = theName;
|
name = theName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NamedVector (String theName, CheckBoxNode elements[], int stage) {
|
public NamedVector(String theName, CheckBoxNode elements[], int stage) {
|
||||||
this(theName, elements);
|
this(theName, elements);
|
||||||
stageNumber = stage;
|
stageNumber = stage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NamedVector (String theName, CheckBoxNode elements[]) {
|
public NamedVector(String theName, CheckBoxNode elements[]) {
|
||||||
name = theName;
|
name = theName;
|
||||||
for (int i = 0, n = elements.length; i < n; i++) {
|
for (int i = 0, n = elements.length; i < n; i++) {
|
||||||
add(elements[i]);
|
add(elements[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString () {
|
@Override
|
||||||
|
public String toString() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStage () {
|
public int getStage() {
|
||||||
return stageNumber;
|
return stageNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user