2 Commits
Author SHA1 Message Date
Waverunner 5bd7469b00 Old changes never committed yet 2015-04-06 18:38:38 -04:00
Waverunner e781292fba Refactored conversation node to use inheritance 2014-10-17 15:16:39 -04:00
47 changed files with 1576 additions and 338 deletions
+3 -1
View File
@@ -17,4 +17,6 @@ hs_err_pid*
/dist/ /dist/
/nbproject/private/ /nbproject/private/
/ConversationEditor/nbproject/private/ /ConversationEditor/nbproject/private/
/ConversationCompiler/nbproject/private/ /ConversationCompiler/nbproject/private/
/mina-core/build/
/mina-core/nbproject/private/
@@ -1,8 +1,8 @@
build.xml.data.CRC32=87962ed9 build.xml.data.CRC32=c55d3ba8
build.xml.script.CRC32=af729615 build.xml.script.CRC32=af729615
build.xml.stylesheet.CRC32=[email protected] build.xml.stylesheet.CRC32=[email protected]
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=87962ed9 nbproject/build-impl.xml.data.CRC32=c55d3ba8
nbproject/build-impl.xml.script.CRC32=b2a11926 nbproject/build-impl.xml.script.CRC32=b2a11926
nbproject/build-impl.xml.stylesheet.CRC32=[email protected] nbproject/build-impl.xml.stylesheet.CRC32=[email protected]
+8
View File
@@ -6,6 +6,14 @@
<code-name-base>com.projectswg.tools.csc.conversationeditor</code-name-base> <code-name-base>com.projectswg.tools.csc.conversationeditor</code-name-base>
<suite-component/> <suite-component/>
<module-dependencies> <module-dependencies>
<dependency>
<code-name-base>com.projectswg.minacore</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency> <dependency>
<code-name-base>org.netbeans.api.visual</code-name-base> <code-name-base>org.netbeans.api.visual</code-name-base>
<build-prerequisite/> <build-prerequisite/>
@@ -1,8 +1,8 @@
package com.projectswg.tools.csc.conversationeditor; package com.projectswg.tools.csc.conversationeditor;
import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode; import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent; import com.projectswg.tools.csc.conversationeditor.nodes.OptionNode;
import com.projectswg.tools.csc.conversationeditor.SceneView;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
@@ -48,7 +48,7 @@ public class Compiler {
LinkedHashMap<ConversationNode, ArrayList<ConversationNode>> conversationLinks = scene.getConversationLinks(); LinkedHashMap<ConversationNode, ArrayList<ConversationNode>> conversationLinks = scene.getConversationLinks();
for (Map.Entry<ConversationNode, ArrayList<ConversationNode>> entry : conversationLinks.entrySet()) { for (Map.Entry<ConversationNode, ArrayList<ConversationNode>> entry : conversationLinks.entrySet()) {
if (entry.getKey().isStartNode()) { if (entry.getKey().getType().equals(ConversationNode.BEGIN)) {
createOptionsAndHandler(bw, entry.getKey(), entry.getValue(), 1, conversationLinks); createOptionsAndHandler(bw, entry.getKey(), entry.getValue(), 1, conversationLinks);
break; break;
} }
@@ -82,28 +82,39 @@ public class Compiler {
int count = handleNum + 1; int count = handleNum + 1;
for (ConversationNode selectedOption : options) { for (ConversationNode selectedOption : options) {
bw.write(indent4 + (options.indexOf(selectedOption) > 0 ? "elif" : "if") + " selection == " + options.indexOf(selectedOption) + ":\n"); if (!(selectedOption instanceof OptionNode))
if (conversationLinks.containsKey(selectedOption)) { continue;
if (comments) bw.write(indent8 + "# " + (selectedOption.getDisplayText().equals("") ? selectedOption.getStf() : selectedOption.getDisplayText()) + "\n");
OptionNode option = (OptionNode) selectedOption;
bw.write(indent4 + (options.indexOf(option) > 0 ? "elif" : "if") + " selection == " + options.indexOf(option) + ":\n");
if (conversationLinks.containsKey(option)) {
if (comments) bw.write(indent8 + "# " + (option.getDisplayText().equals("") ? option.getStf() : option.getDisplayText()) + "\n");
for (ConversationNode handleNode : conversationLinks.get(selectedOption)) { for (ConversationNode handleNode : conversationLinks.get(selectedOption)) {
if (!handleNode.isOption() && !handleNode.isEndNode()) { switch(handleNode.getType()) {
if (conversationLinks.get(handleNode) == null) {
bw.write(indent8 + "# NULL Error printing out handle for " + handleNode.getStf()); case ConversationNode.RESPONSE:
} else { if (conversationLinks.get(handleNode) == null) {
createOptions(bw, conversationLinks.get(handleNode), count++, indent8); bw.write(indent8 + "# NULL Error printing out handle for " + handleNode.getStf());
bw.write(indent8 + "core.conversationService.sendConversationMessage(actor, npc, OutOfBand.ProsePackage('@conversation/" } else {
+ handleNode.getStf() + "')\n"); createOptions(bw, conversationLinks.get(handleNode), count++, indent8);
handleFuncs.put(handleNode, conversationLinks.get(handleNode)); // Put these nodes in list so we can create the handlers later. bw.write(indent8 + "core.conversationService.sendConversationMessage(actor, npc, OutOfBand.ProsePackage('@conversation/"
} + handleNode.getStf() + "')\n");
} else if (handleNode.isEndNode()) { handleFuncs.put(handleNode, conversationLinks.get(handleNode)); // Put these nodes in list so we can create the handlers later.
if (handleNode.getStf().contains(":")) { }
String[] split = handleNode.getStf().split(":"); break;
case ConversationNode.END:
String[] split = handleNode.getStf().toString().split(":");
bw.write(indent8 + "core.conversationService.sendStopConversation(actor, npc, 'conversation/" + split[0] + "', '" + split[1] + "')\n"); bw.write(indent8 + "core.conversationService.sendStopConversation(actor, npc, 'conversation/" + split[0] + "', '" + split[1] + "')\n");
} else { break;
bw.write(indent8 + "# Couldn't write end response because of bad format!");
}
} }
} }
} }
bw.write(indent8 + "return\n"); bw.write(indent8 + "return\n");
bw.newLine(); bw.newLine();
@@ -129,7 +140,7 @@ public class Compiler {
if (options.size() > 1) { if (options.size() > 1) {
for (ConversationNode option : options) { for (ConversationNode option : options) {
bw.write(indent4 + "options.add(ConversationOption(OutOfBand.ProsePackage('@conversation/" + option.getStf() +"'), " bw.write(indent4 + "options.add(ConversationOption(OutOfBand.ProsePackage('@conversation/" + option.getStf() +"'), "
+ String.valueOf(option.getOptionId()) + ")\n"); + String.valueOf(((OptionNode)option).getNumber()) + ")\n");
} }
} else { } else {
for (ConversationNode option : options) { for (ConversationNode option : options) {
@@ -151,7 +162,7 @@ public class Compiler {
if (options.size() > 1) { if (options.size() > 1) {
ArrayList<ConversationNode> orderedOptions = new ArrayList<>(); ArrayList<ConversationNode> orderedOptions = new ArrayList<>();
for (ConversationNode unOrdered : options) { for (ConversationNode unOrdered : options) {
orderedOptions.add(unOrdered.getOptionId(), unOrdered); orderedOptions.add(((OptionNode)unOrdered).getNumber(), unOrdered);
} }
for (ConversationNode option : orderedOptions) { for (ConversationNode option : orderedOptions) {
bw.write(space + "options.add(ConversationOption(OutOfBand.ProsePackage('@conversation/" + option.getStf() +"'), " + options.indexOf(option) + ")\n"); bw.write(space + "options.add(ConversationOption(OutOfBand.ProsePackage('@conversation/" + option.getStf() +"'), " + options.indexOf(option) + ")\n");
@@ -1,6 +1,8 @@
package com.projectswg.tools.csc.conversationeditor; package com.projectswg.tools.csc.conversationeditor;
import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode; import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
import com.projectswg.tools.csc.conversationeditor.nodes.EndNode;
import java.awt.Point; import java.awt.Point;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import org.netbeans.api.visual.action.ConnectProvider; import org.netbeans.api.visual.action.ConnectProvider;
@@ -42,34 +44,17 @@ public class ConversationConnectProvider implements ConnectProvider {
@Override @Override
public void createConnection(Widget source, Widget target) { public void createConnection(Widget source, Widget target) {
if (source instanceof ConversationWidget && target instanceof ConversationWidget) { if (source instanceof ConversationWidget && target instanceof ConversationWidget) {
if (((ConversationWidget)source).getAttachedNode().isEndNode()) { if (((ConversationWidget)source).getAttachedNode() instanceof EndNode) {
JOptionPane.showMessageDialog(null, "Cannot attach end conversation node to responses/options!", "Conversation Script Creator", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, "Cannot attach end conversation node to responses/options!", "Conversation Script Creator", JOptionPane.INFORMATION_MESSAGE);
return; return;
} }
ConversationNode cSource = ((ConversationWidget) source).getAttachedNode(); ConversationNode cSource = ((ConversationWidget) source).getAttachedNode();
ConversationNode cTarget = ((ConversationWidget) target).getAttachedNode(); ConversationNode cTarget = ((ConversationWidget) target).getAttachedNode();
if (cSource.isOption()) { // TODO: messages for each linking type
if (cTarget.isOption()) if (!cSource.doesLink(cTarget))
return;
else if (cTarget.isStartNode())
return;
} else if (cSource.isStartNode()) {
if (cTarget.isEndNode())
return;
} else if (cSource.isEndNode()) {
return; return;
} else { // Response nodes
if (cTarget.isEndNode())
return;
else if (cTarget.isStartNode())
return;
}
/* This won't work for preventing linking to same node 2x's. Need to find another way :( /* This won't work for preventing linking to same node 2x's. Need to find another way :(
if (scene.getConnectionLayer().getChildren().size() > 0) { if (scene.getConnectionLayer().getChildren().size() > 0) {
for (Widget widget : scene.getConnectionLayer().getChildren()) { for (Widget widget : scene.getConnectionLayer().getChildren()) {
@@ -1,5 +1,6 @@
package com.projectswg.tools.csc.conversationeditor; package com.projectswg.tools.csc.conversationeditor;
import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode; import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
import java.awt.Point; import java.awt.Point;
import java.beans.PropertyVetoException; import java.beans.PropertyVetoException;
@@ -21,25 +22,14 @@ public class ConversationWidget extends IconNodeWidget implements LookupListener
private final ExplorerManager mgr; private final ExplorerManager mgr;
private boolean selected; private boolean selected;
public ConversationWidget(SceneView scene, final ExplorerManager mgr, final ConversationNode node, boolean endConversation) { public ConversationWidget(SceneView scene, final ExplorerManager mgr, final ConversationNode node) {
super(scene.getScene()); super(scene.getScene());
this.attachedNode = node; this.attachedNode = node;
this.mgr = mgr; this.mgr = mgr;
if (node.isEndNode()) { setLabel(node.getStf().toString());
setLabel(node.getStf()); setImage(ImageUtilities.loadImage(node.getImageStr()));
setImage(ImageUtilities.loadImage("com/projectswg/tools/csc/conversationeditor/conversation_end.png"));
} else {
setLabel(node.getStf());
if (node.isStartNode()) {
setImage(ImageUtilities.loadImage("com/projectswg/tools/csc/conversationeditor/conversation_begin.png"));
} else {
setImage(node.isOption() ? ImageUtilities.loadImage("com/projectswg/tools/csc/conversationeditor/conversation_option.png")
: ImageUtilities.loadImage("com/projectswg/tools/csc/conversationeditor/conversation_response.png"));
}
}
// Alignment/pos/ori // Alignment/pos/ori
getLabelWidget().setAlignment(LabelWidget.Alignment.CENTER); getLabelWidget().setAlignment(LabelWidget.Alignment.CENTER);
@@ -1,7 +1,9 @@
package com.projectswg.tools.csc.conversationeditor; package com.projectswg.tools.csc.conversationeditor;
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode; import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
import com.projectswg.tools.csc.conversationeditor.actions.OpenConversation; import com.projectswg.tools.csc.conversationeditor.actions.OpenConversation;
import com.projectswg.tools.csc.conversationeditor.nodes.BeginNode;
import com.projectswg.tools.csc.conversationeditor.nodes.EndNode;
import java.io.File; import java.io.File;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import org.netbeans.api.settings.ConvertAsProperties; import org.netbeans.api.settings.ConvertAsProperties;
@@ -122,7 +124,7 @@ public final class EditorTopComponent extends TopComponent implements ExplorerMa
} }
public void blankSlate() { public void blankSlate() {
scene.addNode(new ConversationNode("Begin Conversation", false, 0, false, true, 0)); scene.addNode(new BeginNode(scene.getStfFile(), 0));
scene.addNode(new ConversationNode("End Conversation", false, 1, true, false, 0)); scene.addNode(new EndNode(scene.getStfFile(), 1));
} }
} }
@@ -5,9 +5,9 @@
*/ */
package com.projectswg.tools.csc.conversationeditor.actions; package com.projectswg.tools.csc.conversationeditor.actions;
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent; import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
import com.projectswg.tools.csc.conversationeditor.SceneView; import com.projectswg.tools.csc.conversationeditor.nodes.EndNode;
import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import org.openide.awt.ActionID; import org.openide.awt.ActionID;
@@ -45,7 +45,7 @@ public final class NewConvEnd implements ActionListener {
return; return;
int id = scene.getNextId(); int id = scene.getNextId();
scene.addNode(new ConversationNode("New End Conversation " + String.valueOf(id), false, id, true, false, 0)); scene.addNode(new EndNode(scene.getStfFile(), id));
scene.validate(); scene.validate();
} }
@@ -1,8 +1,8 @@
package com.projectswg.tools.csc.conversationeditor.actions; package com.projectswg.tools.csc.conversationeditor.actions;
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent; import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
import com.projectswg.tools.csc.conversationeditor.SceneView; import com.projectswg.tools.csc.conversationeditor.nodes.OptionNode;
import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import org.openide.awt.ActionID; import org.openide.awt.ActionID;
@@ -40,7 +40,7 @@ public final class NewConvOption implements ActionListener {
return; return;
int id = scene.getNextId(); int id = scene.getNextId();
scene.addNode(new ConversationNode("New Conversation Option " + String.valueOf(id), true, id, false, false, 0)); scene.addNode(new OptionNode(scene.getStfFile(), id));
scene.validate(); scene.validate();
} }
@@ -5,9 +5,9 @@
*/ */
package com.projectswg.tools.csc.conversationeditor.actions; package com.projectswg.tools.csc.conversationeditor.actions;
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent; import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
import com.projectswg.tools.csc.conversationeditor.SceneView; import com.projectswg.tools.csc.conversationeditor.nodes.ResponseNode;
import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import org.openide.awt.ActionID; import org.openide.awt.ActionID;
@@ -45,7 +45,7 @@ public final class NewConvResponse implements ActionListener {
return; return;
int id = scene.getNextId(); int id = scene.getNextId();
scene.addNode(new ConversationNode("New Conversation Response " + String.valueOf(id), false, id, false, false, 0)); scene.addNode(new ResponseNode(scene.getStfFile(), id));
scene.validate(); scene.validate();
} }
} }
@@ -1,39 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.projectswg.tools.csc.conversationeditor.actions;
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
import org.openide.awt.ActionRegistration;
import org.openide.util.NbBundle.Messages;
@ActionID(
category = "File",
id = "com.projectswg.tools.csc.conversationeditor.actions.NewConversation"
)
@ActionRegistration(
iconBase = "com/projectswg/tools/csc/conversationeditor/actions/conversation_tb_new.png",
displayName = "New Conversation"
)
@ActionReferences({
@ActionReference(path = "Menu/File", position = 2),
@ActionReference(path = "Toolbars/File", position = 400),
@ActionReference(path = "Shortcuts", name = "D-N")
})
@Messages("CTL_NewConversation=New Conversation")
public final class NewConversation implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
EditorTopComponent newEditor = new EditorTopComponent();
newEditor.open();
newEditor.requestActive();
}
}
@@ -1,8 +1,8 @@
package com.projectswg.tools.csc.conversationeditor.actions; package com.projectswg.tools.csc.conversationeditor.actions;
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent; import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
import com.projectswg.tools.csc.conversationeditor.SceneSaver; import com.projectswg.tools.csc.conversationeditor.scene.SceneSaver;
import com.projectswg.tools.csc.conversationeditor.SceneView; import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
import com.projectswg.tools.csc.conversationeditor.wizard.CompileWizardAction; import com.projectswg.tools.csc.conversationeditor.wizard.CompileWizardAction;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@@ -6,8 +6,8 @@
package com.projectswg.tools.csc.conversationeditor.actions; package com.projectswg.tools.csc.conversationeditor.actions;
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent; import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
import com.projectswg.tools.csc.conversationeditor.SceneSaver; import com.projectswg.tools.csc.conversationeditor.scene.SceneSaver;
import com.projectswg.tools.csc.conversationeditor.SceneView; import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File; import java.io.File;
@@ -5,16 +5,14 @@
*/ */
package com.projectswg.tools.csc.conversationeditor.actions; package com.projectswg.tools.csc.conversationeditor.actions;
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
import com.projectswg.tools.csc.conversationeditor.ConversationWidget; import com.projectswg.tools.csc.conversationeditor.ConversationWidget;
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent; import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
import com.projectswg.tools.csc.conversationeditor.SceneView; import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import org.netbeans.api.visual.widget.ConnectionWidget; import org.netbeans.api.visual.widget.ConnectionWidget;
import org.netbeans.api.visual.widget.Widget; import org.netbeans.api.visual.widget.Widget;
@@ -0,0 +1,23 @@
package com.projectswg.tools.csc.conversationeditor.nodes;
public class BeginNode extends ConversationNode {
public BeginNode(String stf, int id) {
super(getImgDirectory() + "conversation_begin.png", ConversationNode.BEGIN, stf, id);
}
@Override
public boolean doesLink(ConversationNode target) {
switch (target.getType()) {
case ConversationNode.OPTION:
return true;
case ConversationNode.RESPONSE:
return false;
case ConversationNode.END:
return false;
case ConversationNode.BEGIN:
return false;
}
return true;
}
}
@@ -1,237 +1,121 @@
package com.projectswg.tools.csc.conversationeditor.nodes; package com.projectswg.tools.csc.conversationeditor.nodes;
import com.projectswg.tools.csc.conversationeditor.nodes.editors.StfEditor;
import com.projectswg.tools.csc.conversationeditor.stf.Stf;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import org.openide.nodes.AbstractNode; import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children; import org.openide.nodes.Children;
import org.openide.nodes.PropertySupport; import org.openide.nodes.PropertySupport;
import org.openide.nodes.Sheet; import org.openide.nodes.Sheet;
import org.openide.util.Exceptions;
import org.openide.util.Lookup; import org.openide.util.Lookup;
public class ConversationNode extends AbstractNode implements Lookup.Provider { public class ConversationNode extends AbstractNode implements Lookup.Provider {
private int id;
private int optionId; private final int id;
private String displayText;
private String stf; private Stf stf;
private boolean option;
private boolean locked;
private boolean compiled;
private boolean endNode;
private boolean startNode;
public ConversationNode(String stf, boolean isOption, int id, boolean isEndNode, boolean isStartNode, int optionId) { private boolean locked;
private final Sheet sheet;
private final String imageStr;
private final String type;
public static final String OPTION = "Option";
public static final String RESPONSE = "Response";
public static final String END = "End";
public static final String BEGIN = "Begin";
HashMap<String, Object> specificAttrs = new HashMap<>();
public ConversationNode(String imageStr, String type, String stf, int id) {
super(Children.LEAF); super(Children.LEAF);
this.stf = stf;
this.option = isOption;
this.displayText = "";
this.endNode = isEndNode;
this.startNode = isStartNode;
this.optionId = optionId;
this.id = id; this.id = id;
this.stf = new Stf(stf);
this.imageStr = imageStr;
this.sheet = super.createSheet();
// Properties Window Sheet.Set properties = Sheet.createPropertiesSet();
if (!isStartNode)
setDisplayName("Conversation " + ((isOption) ? "Option " + String.valueOf(id) : ((isEndNode) ? "End" : "Response " + String.valueOf(id)))); properties.setDisplayName("General");
else properties.setShortDescription("Basic properties for all conversation nodes.");
setDisplayName("Begin Conversation Node");
setShortDescription("Properties for this Conversation Node"); properties.put(new IdProperty(this));
} try {
properties.put(new StfProperty(this));
public String getStf() { } catch (NoSuchMethodException ex) {
return stf; Exceptions.printStackTrace(ex);
} }
properties.put(new LockedProperty(this));
public void setStf(String stf) {
firePropertyChange("stf", this.stf, stf); sheet.put(properties);
this.stf = stf;
} this.type = type;
public String getDisplayText() { //this.setDisplayName("New Node"); Controls name shown in properties window
return displayText;
}
public void setDisplayText(String displayText) {
firePropertyChange("display", this.displayText, displayText);
this.displayText = displayText;
} }
public boolean isOption() { public final int getId() {
return option;
}
public void setOption(boolean option) {
this.option = option;
}
public boolean isLocked() {
return locked;
}
public void setLocked(boolean locked) {
this.locked = locked;
}
public int getId() {
return id; return id;
} }
public void setId(int id) { public Stf getStf() {
this.id = id; firePropertyChange("stf", stf, stf); // setStf is never used when changing property, so using getStf instead
return stf;
} }
public boolean isCompiled() { public void setStf(Stf stf) {
return compiled; //firePropertyChange("Stf", this.stf.toString(), stf.toString());
} this.stf = stf;
public void setCompiled(boolean compiled) {
this.compiled = compiled;
} }
public boolean isEndNode() { public final boolean isLocked() {
return endNode; return locked;
}
public final void setLocked(boolean isLocked) {
firePropertyChange("locked", this.locked, isLocked);
this.locked = isLocked;
}
public final String getImageStr() {
return imageStr;
}
public final String getType() {
return type;
}
public final void addNodeProperties(Sheet.Set properties) {
sheet.put(properties);
} }
public void setEndNode(boolean endNode) { public boolean doesLink(ConversationNode target) {
this.endNode = endNode; return true;
}
public boolean isStartNode() {
return this.startNode;
}
public void setStartNode(boolean startNode) {
this.startNode = startNode;
}
public int getOptionId() {
return this.optionId;
}
public void setOptionId(int optionId) {
this.optionId = optionId;
} }
@Override @Override
protected Sheet createSheet() { protected final Sheet createSheet() {
Sheet sheet = super.createSheet();
Sheet.Set set = Sheet.createPropertiesSet();
set.put(new IdProperty(this));
set.put(new StfProperty(this));
set.put(new DisplayProperty(this));
if (!endNode) {
set.put(new TypeProperty(this));
if (option) {
set.put(new OptionIdProperty(this));
}
}
set.put(new LockedProperty(this));
sheet.put(set);
return sheet; return sheet;
} }
}
class OptionIdProperty extends PropertySupport.ReadWrite<Integer> {
private final ConversationNode node;
public OptionIdProperty(ConversationNode node) { public final static String getImgDirectory() {
super("optionId", Integer.class, "Option ID", "ID used for displaying the order of this option in relation to the response (what option should show first in" return "com/projectswg/tools/csc/conversationeditor/nodes/imgs/";
+ "list of options)");
this.node = node;
} }
@Override public final Object addSpecificAttribute(String name, Object value) {
public Integer getValue() throws IllegalAccessException, InvocationTargetException { return specificAttrs.put(name, value);
return node.getOptionId();
}
@Override
public void setValue(Integer val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
node.setOptionId(val);
} }
} public HashMap<String, Object> getAttributes() {
return specificAttrs;
class IdProperty extends PropertySupport.ReadOnly<Integer> {
private final ConversationNode node;
public IdProperty(ConversationNode node) {
super("id", Integer.class, "Id", "Conversation Node Id");
this.node = node;
}
@Override
public Integer getValue() throws IllegalAccessException, InvocationTargetException {
return node.getId();
}
}
class StfProperty extends PropertySupport.ReadWrite<String> {
private final ConversationNode node;
public StfProperty(ConversationNode node) {
super("stf", String.class, "STF", "STF file for this conversation node, excluding conversation/. Ex: conversation/c_newbie_mentor:s_109 would be c_newbie_mentor:s_109");
this.setValue("oneline", true);
this.node = node;
}
@Override
public String getValue() throws IllegalAccessException, InvocationTargetException {
return node.getStf();
}
@Override
public void setValue(String val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
node.setStf(String.valueOf(val));
} }
} }
class TypeProperty extends PropertySupport.ReadOnly<Boolean> { final class LockedProperty extends PropertySupport.ReadWrite<Boolean> {
private final ConversationNode node;
public TypeProperty(ConversationNode node) {
super("option", Boolean.class, "Option", "The conversation node is a response or a option");
this.node = node;
}
@Override
public Boolean getValue() throws IllegalAccessException, InvocationTargetException {
return node.isOption();
}
@Override
public void setValue(Boolean val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
node.setOption(val);
}
}
class DisplayProperty extends PropertySupport.ReadWrite<String> {
private final ConversationNode node;
public DisplayProperty(ConversationNode node) {
super ("display", String.class, "Text", "Optional text. This won't affect anything and can be left blank.\n" +
"You can use this for entering the value of a key from the coresponding STF for quick reference.");
this.node = node;
}
@Override
public String getValue() throws IllegalAccessException, InvocationTargetException {
return node.getDisplayText();
}
@Override
public void setValue(String val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
node.setDisplayText(val);
}
}
class LockedProperty extends PropertySupport.ReadWrite<Boolean> {
private final ConversationNode node; private final ConversationNode node;
public LockedProperty(ConversationNode node) { public LockedProperty(ConversationNode node) {
@@ -250,3 +134,41 @@ class LockedProperty extends PropertySupport.ReadWrite<Boolean> {
} }
} }
final class StfProperty extends PropertySupport.Reflection<Stf> {
private final ConversationNode node;
public StfProperty(ConversationNode node) throws NoSuchMethodException {
super(node, Stf.class, "Stf");
//super("stf", String.class, "STF", "STF file for this conversation node, excluding conversation/. Ex: conversation/c_newbie_mentor:s_109 would be c_newbie_mentor:s_109");
//this.setValue("oneline", true);
this.setPropertyEditorClass(StfEditor.class);
this.node = node;
}
/* @Override
public String getValue() throws IllegalAccessException, InvocationTargetException {
return node.getStf();
}
@Override
public void setValue(String val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
node.setStf(String.valueOf(val));
}*/
}
final class IdProperty extends PropertySupport.ReadOnly<Integer> {
private final ConversationNode node;
public IdProperty(ConversationNode node) {
super("id", Integer.class, "Id", "Conversation Node Id");
this.node = node;
}
@Override
public Integer getValue() throws IllegalAccessException, InvocationTargetException {
return node.getId();
}
}
@@ -0,0 +1,23 @@
package com.projectswg.tools.csc.conversationeditor.nodes;
public class EndNode extends ConversationNode {
public EndNode(String stf, int id) {
super(getImgDirectory() + "conversation_end.png", ConversationNode.END, stf, id);
}
@Override
public boolean doesLink(ConversationNode target) {
switch (target.getType()) {
case ConversationNode.OPTION:
return true;
case ConversationNode.RESPONSE:
return false;
case ConversationNode.END:
return false;
case ConversationNode.BEGIN:
return false;
}
return true;
}
}
@@ -0,0 +1,104 @@
package com.projectswg.tools.csc.conversationeditor.nodes;
import java.lang.reflect.InvocationTargetException;
import org.openide.nodes.PropertySupport;
import org.openide.nodes.Sheet;
public class OptionNode extends ConversationNode {
private int number;
private String displayText = "";
public OptionNode(String stf, int id, int optionNumber) {
super(getImgDirectory() + "conversation_option.png", ConversationNode.OPTION, stf, id);
Sheet.Set properties = Sheet.createPropertiesSet();
properties.setName("optionNode"); // Name must be set or properties will not show properly
properties.setDisplayName("Conversation Option");
properties.setShortDescription("Properties specific to Option Node");
properties.put(new OptionIdProperty(this));
properties.put(new DisplayTextProperty(this));
addNodeProperties(properties);
this.number = optionNumber;
}
public OptionNode(String stf, int id) {
this(stf, id, 0);
}
public void setNumber(int num) {
this.number = num;
}
public int getNumber() {
return number;
}
public void setDisplayText(String txt) {
this.displayText = txt;
}
public String getDisplayText() {
return displayText;
}
@Override
public boolean doesLink(ConversationNode target) {
switch (target.getType()) {
case ConversationNode.OPTION:
return false;
case ConversationNode.RESPONSE:
return true;
case ConversationNode.END:
return true;
case ConversationNode.BEGIN:
return false;
}
return true;
}
}
class OptionIdProperty extends PropertySupport.ReadWrite<Integer> {
private final OptionNode node;
public OptionIdProperty(OptionNode node) {
super("optionId", Integer.class, "Option ID", "ID used for displaying the order of this option in relation to the response (what option should show first in"
+ "list of options)");
this.node = node;
}
@Override
public Integer getValue() throws IllegalAccessException, InvocationTargetException {
return node.getNumber();
}
@Override
public void setValue(Integer val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
node.setNumber(val);
}
}
class DisplayTextProperty extends PropertySupport.ReadWrite<String> {
private final OptionNode node;
public DisplayTextProperty(OptionNode node) {
super("displayTxt", String.class, "Display Text", "Text displayed in comment for this node at compile time");
this.node = node;
}
@Override
public String getValue() throws IllegalAccessException, InvocationTargetException {
return node.getDisplayText();
}
@Override
public void setValue(String val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
node.setDisplayText(val);
}
}
@@ -0,0 +1,23 @@
package com.projectswg.tools.csc.conversationeditor.nodes;
public class ResponseNode extends ConversationNode {
public ResponseNode(String stf, int id) {
super(getImgDirectory() + "conversation_response.png", ConversationNode.RESPONSE, stf, id);
}
@Override
public boolean doesLink(ConversationNode target) {
switch (target.getType()) {
case ConversationNode.OPTION:
return true;
case ConversationNode.RESPONSE:
return false;
case ConversationNode.END:
return false;
case ConversationNode.BEGIN:
return false;
}
return true;
}
}
@@ -0,0 +1,5 @@
StfEditorVisual.jLabel1.text=STF File:
StfEditorVisual.jLabel1.toolTipText=
StfEditorVisual.jLabel2.text=STF Key:
StfEditorVisual.tfStfKey.text=None
StfEditorVisual.tfStfFile.text=None
@@ -0,0 +1,115 @@
package com.projectswg.tools.csc.conversationeditor.nodes.editors;
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
import com.projectswg.tools.csc.conversationeditor.scene.SceneView;
import com.projectswg.tools.csc.conversationeditor.stf.Stf;
import java.awt.Component;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyEditorSupport;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
import java.util.Set;
import org.openide.explorer.propertysheet.ExPropertyEditor;
import org.openide.explorer.propertysheet.PropertyEnv;
import org.openide.windows.TopComponent;
public class StfEditor extends PropertyEditorSupport implements ExPropertyEditor, VetoableChangeListener {
private StfEditorVisual editor;
private PropertyEnv env;
public StfEditor() {
editor = new StfEditorVisual();
}
@Override
public Object getValue() {
if (super.getValue() == null) {
//System.out.println("NULL VALUE");
setValue(null);
}
Stf val = (Stf) super.getValue();
val.setKey(editor.getTfStfKey().getText());
val.setFile(editor.tfStfFile.getText());
//val.setValue((String) editor.stfValues.getModel().getElementAt(editor.stfValues.getSelectedIndex()));
return super.getValue(); //To change body of generated methods, choose Tools | Templates.
}
@Override
public boolean supportsCustomEditor() {
return true;
}
@Override
public void setAsText(String text) throws IllegalArgumentException {
//System.out.println("Setting as text.");
super.setAsText(text); //To change body of generated methods, choose Tools | Templates.
}
@Override
public String getAsText() {
Stf val = (Stf) super.getValue();
//System.out.println("Getting as text.");
return val.toString(); //To change body of generated methods, choose Tools | Templates.
}
@Override
public Component getCustomEditor() {
//editor.addPropertyChangeListener(StfEditorVisual.);
env.addVetoableChangeListener(this);
return editor; //To change body of generated methods, choose Tools | Templates.
}
@Override
public void setValue(Object stf) {
if (stf != null) {
super.setValue(stf);
return;
}
TopComponent component = TopComponent.getRegistry().getActivated();
if (component == null || !(component instanceof EditorTopComponent)) {
Set<TopComponent> components = TopComponent.getRegistry().getOpened();
boolean success = false;
for (TopComponent comp : components) {
if (comp instanceof EditorTopComponent) {
component = comp;
success = true;
break;
}
}
if (!success)
return;
}
EditorTopComponent editorComp = (EditorTopComponent) component;
SceneView scene = editorComp.getScene();
if (scene == null)
return;
if(stf==null){
stf = new Stf(scene.getStfFile());
}
editor.tfStfFile.setText(((Stf)stf).getFile());
editor.getTfStfKey().setText(((Stf)stf).getKey());
editor.stfValues.setListData(((Stf)stf).getEntries());
super.setValue(stf);
//System.out.println("Value set (setValue): " + ((Stf)stf).getKey());
}
@Override
public void attachEnv(PropertyEnv env) {
this.env = env;
editor.env = env;
editor.env.setState(PropertyEnv.STATE_NEEDS_VALIDATION);
}
@Override
public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
// Only thrown when OK is pressed.
Stf val = (Stf) getValue();
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="tfStfFile" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="tfStfKey" pref="333" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="tfStfFile" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="tfStfKey" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="209" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/projectswg/tools/csc/conversationeditor/nodes/editors/Bundle.properties" key="StfEditorVisual.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/projectswg/tools/csc/conversationeditor/nodes/editors/Bundle.properties" key="StfEditorVisual.jLabel1.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="tfStfFile">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/projectswg/tools/csc/conversationeditor/nodes/editors/Bundle.properties" key="StfEditorVisual.tfStfFile.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/projectswg/tools/csc/conversationeditor/nodes/editors/Bundle.properties" key="StfEditorVisual.jLabel2.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="tfStfKey">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/projectswg/tools/csc/conversationeditor/nodes/editors/Bundle.properties" key="StfEditorVisual.tfStfKey.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JList" name="stfValues">
<Properties>
<Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
<StringArray count="1">
<StringItem index="0" value="NULL"/>
</StringArray>
</Property>
</Properties>
<Events>
<EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="stfValuesValueChanged"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>
@@ -0,0 +1,121 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.projectswg.tools.csc.conversationeditor.nodes.editors;
import javax.swing.JTextField;
import org.openide.explorer.propertysheet.PropertyEnv;
/**
*
* @author Wave
*/
public class StfEditorVisual extends javax.swing.JPanel {
public PropertyEnv env;
/**
* Creates new form StfEditorVisual
*/
public StfEditorVisual() {
initComponents();
}
public StfEditorVisual(PropertyEnv env) {
initComponents();
env.setState(PropertyEnv.STATE_NEEDS_VALIDATION);
}
/**
* 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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
tfStfFile = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
tfStfKey = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
stfValues = new javax.swing.JList();
org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(StfEditorVisual.class, "StfEditorVisual.jLabel1.text")); // NOI18N
jLabel1.setToolTipText(org.openide.util.NbBundle.getMessage(StfEditorVisual.class, "StfEditorVisual.jLabel1.toolTipText")); // NOI18N
tfStfFile.setText(org.openide.util.NbBundle.getMessage(StfEditorVisual.class, "StfEditorVisual.tfStfFile.text")); // NOI18N
tfStfFile.setEnabled(false);
org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(StfEditorVisual.class, "StfEditorVisual.jLabel2.text")); // NOI18N
tfStfKey.setEditable(false);
tfStfKey.setText(org.openide.util.NbBundle.getMessage(StfEditorVisual.class, "StfEditorVisual.tfStfKey.text")); // NOI18N
stfValues.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "NULL" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
stfValues.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
stfValuesValueChanged(evt);
}
});
jScrollPane1.setViewportView(stfValues);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(tfStfFile))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(tfStfKey, javax.swing.GroupLayout.DEFAULT_SIZE, 333, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(tfStfFile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(tfStfKey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 209, Short.MAX_VALUE)
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
private void stfValuesValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_stfValuesValueChanged
tfStfKey.setText(stfValues.getSelectedValue().toString().split(" | ")[0]);
}//GEN-LAST:event_stfValuesValueChanged
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JScrollPane jScrollPane1;
public javax.swing.JList stfValues;
public javax.swing.JTextField tfStfFile;
private javax.swing.JTextField tfStfKey;
// End of variables declaration//GEN-END:variables
public JTextField getTfStfKey() {
return tfStfKey;
}
}
@@ -1,6 +1,11 @@
package com.projectswg.tools.csc.conversationeditor; package com.projectswg.tools.csc.conversationeditor.scene;
import com.projectswg.tools.csc.conversationeditor.ConversationWidget;
import com.projectswg.tools.csc.conversationeditor.nodes.BeginNode;
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode; import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
import com.projectswg.tools.csc.conversationeditor.nodes.EndNode;
import com.projectswg.tools.csc.conversationeditor.nodes.OptionNode;
import com.projectswg.tools.csc.conversationeditor.nodes.ResponseNode;
import java.awt.Point; import java.awt.Point;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@@ -33,6 +38,7 @@ public class SceneSaver {
private static final String LOCKED = "locked"; private static final String LOCKED = "locked";
private static final String STF = "stf"; private static final String STF = "stf";
private static final String OPTION_ID = "optionId"; private static final String OPTION_ID = "optionId";
private static final String TEXT = "txt";
private static final String VERSION_VALUE_1 = "1.0"; // NOI18N private static final String VERSION_VALUE_1 = "1.0"; // NOI18N
@@ -60,14 +66,7 @@ public class SceneSaver {
if (location != null) { if (location != null) {
Node dataXMLNode = file.createElement(NODE_NODE); Node dataXMLNode = file.createElement(NODE_NODE);
if (node.isOption()) setAttribute(file, dataXMLNode, TYPE, node.getType());
setAttribute(file, dataXMLNode, TYPE, "option");
else if (!node.isEndNode() && !node.isStartNode())
setAttribute(file, dataXMLNode, TYPE, "response");
else if (node.isEndNode())
setAttribute(file, dataXMLNode, TYPE, "end");
else
setAttribute(file, dataXMLNode, TYPE, "begin");
setAttribute(file, dataXMLNode, TARGETS, getTargets(conversationLinks, node)); setAttribute(file, dataXMLNode, TARGETS, getTargets(conversationLinks, node));
@@ -75,8 +74,11 @@ public class SceneSaver {
setAttribute(file, dataXMLNode, X_NODE, Integer.toString(location.x)); setAttribute(file, dataXMLNode, X_NODE, Integer.toString(location.x));
setAttribute(file, dataXMLNode, Y_NODE, Integer.toString(location.y)); setAttribute(file, dataXMLNode, Y_NODE, Integer.toString(location.y));
setAttribute(file, dataXMLNode, LOCKED, Boolean.toString(node.isLocked())); setAttribute(file, dataXMLNode, LOCKED, Boolean.toString(node.isLocked()));
setAttribute(file, dataXMLNode, STF, node.getStf()); setAttribute(file, dataXMLNode, STF, node.getDisplayName());
setAttribute(file, dataXMLNode, OPTION_ID, Integer.toString(node.getOptionId()));
for (HashMap.Entry<String, Object> entry : node.getAttributes().entrySet()) {
setAttribute(file, dataXMLNode, entry.getKey(), entry.getValue().toString());
}
sceneXMLNode.appendChild(dataXMLNode); sceneXMLNode.appendChild(dataXMLNode);
} }
@@ -135,21 +137,22 @@ public class SceneSaver {
String targets = getAttributeValue(node, TARGETS); String targets = getAttributeValue(node, TARGETS);
String stf = getAttributeValue(node, STF); String stf = getAttributeValue(node, STF);
String type = getAttributeValue(node, TYPE); String type = getAttributeValue(node, TYPE);
String txt = getAttributeValue(node, TEXT);
ConversationWidget widget = null; ConversationWidget widget = null;
// ConversationNode(String stf, boolean isOption, int id, boolean isEndNode, boolean isStartNode, int optionId) // ConversationNode(String stf, boolean isOption, int id, boolean isEndNode, boolean isStartNode, int optionId)
switch (type) { switch (type) {
case "option": case ConversationNode.OPTION:
widget = (ConversationWidget) scene.addNode(new ConversationNode(stf, true, nodeID, false, false, optionId)); widget = (ConversationWidget) scene.addNode(new OptionNode(stf, nodeID, optionId));
break; break;
case "response": case ConversationNode.RESPONSE:
widget = (ConversationWidget) scene.addNode(new ConversationNode(stf, false, nodeID, false, false, optionId)); widget = (ConversationWidget) scene.addNode(new ResponseNode(stf, nodeID));
break; break;
case "begin": case ConversationNode.BEGIN:
widget = (ConversationWidget) scene.addNode(new ConversationNode(stf, false, nodeID, false, true, optionId)); widget = (ConversationWidget) scene.addNode(new BeginNode(stf, nodeID));
break; break;
case "end": case ConversationNode.END:
widget = (ConversationWidget) scene.addNode(new ConversationNode(stf, false, nodeID, true, false, optionId)); widget = (ConversationWidget) scene.addNode(new EndNode(stf, nodeID));
break; break;
} }
@@ -1,8 +1,13 @@
package com.projectswg.tools.csc.conversationeditor; package com.projectswg.tools.csc.conversationeditor.scene;
import com.projectswg.tools.csc.conversationeditor.ConversationLookFeel;
import com.projectswg.tools.csc.conversationeditor.ConversationWidget;
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode; import com.projectswg.tools.csc.conversationeditor.nodes.ConversationNode;
import com.projectswg.tools.csc.conversationeditor.stf.StfTable;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@@ -13,6 +18,7 @@ import org.netbeans.api.visual.widget.ConnectionWidget;
import org.netbeans.api.visual.widget.LayerWidget; import org.netbeans.api.visual.widget.LayerWidget;
import org.netbeans.api.visual.widget.Widget; import org.netbeans.api.visual.widget.Widget;
import org.openide.explorer.ExplorerManager; import org.openide.explorer.ExplorerManager;
import org.openide.util.Exceptions;
import org.openide.windows.TopComponent; import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager; import org.openide.windows.WindowManager;
@@ -26,6 +32,10 @@ public class SceneView extends GraphScene<ConversationNode, String>{
private String scenePath = ""; private String scenePath = "";
private boolean loaded = false; private boolean loaded = false;
private String stfFile = "None";
private StfTable stfTable;
private int id = 1; private int id = 1;
public SceneView(ExplorerManager mgr) { public SceneView(ExplorerManager mgr) {
@@ -47,15 +57,16 @@ public class SceneView extends GraphScene<ConversationNode, String>{
} }
@Override @Override
protected Widget attachNodeWidget(ConversationNode n) { protected Widget attachNodeWidget(final ConversationNode n) {
final ConversationWidget widget = new ConversationWidget(this, mgr, n, n.isEndNode()); final ConversationWidget widget = new ConversationWidget(this, mgr, n);
widget.getActions().addAction(createObjectHoverAction()); widget.getActions().addAction(createObjectHoverAction());
n.addPropertyChangeListener(new PropertyChangeListener() { n.addPropertyChangeListener(new PropertyChangeListener() {
@Override @Override
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
TopComponent component = WindowManager.getDefault().findTopComponent("EditorTopComponent"); TopComponent component = WindowManager.getDefault().findTopComponent("EditorTopComponent");
if (component == null || !(component instanceof EditorTopComponent)) if (component == null || !(component instanceof EditorTopComponent))
return; return;
@@ -66,9 +77,13 @@ public class SceneView extends GraphScene<ConversationNode, String>{
if (scene == null) if (scene == null)
return; return;
widget.getLabelWidget().setLabel(n.getStf().toString());
widget.repaint();
scene.validate();
switch(evt.getPropertyName()) { switch(evt.getPropertyName()) {
case "stf": case "stf":
widget.getLabelWidget().setLabel((String) evt.getNewValue()); widget.getLabelWidget().setLabel(evt.getNewValue().toString());
widget.repaint(); widget.repaint();
scene.validate(); scene.validate();
@@ -76,6 +91,7 @@ public class SceneView extends GraphScene<ConversationNode, String>{
} }
} }
}); });
mainLayer.addChild(widget); mainLayer.addChild(widget);
return widget; return widget;
} }
@@ -140,6 +156,25 @@ public class SceneView extends GraphScene<ConversationNode, String>{
return loaded; return loaded;
} }
public String getStfFile() {
return stfFile;
}
public void setStfFile(String stfFile) {
this.stfFile = stfFile;
StfTable stfTable = new StfTable();
try {
stfTable.readFile(stfFile);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
this.stfTable = stfTable;
}
public StfTable getStfTable() {
return stfTable;
}
public LinkedHashMap<ConversationNode, ArrayList<ConversationNode>> getConversationLinks() { public LinkedHashMap<ConversationNode, ArrayList<ConversationNode>> getConversationLinks() {
List<Widget> connectedNodes = connectionLayer.getChildren(); List<Widget> connectedNodes = connectionLayer.getChildren();
LinkedHashMap<ConversationNode, ArrayList<ConversationNode>> conversationLinks = new LinkedHashMap<>(); LinkedHashMap<ConversationNode, ArrayList<ConversationNode>> conversationLinks = new LinkedHashMap<>();
@@ -0,0 +1,4 @@
SceneVisualPanel1.jLabel1.text=Conversation STF file
SceneVisualPanel1.jButton1.text=Browse
SceneVisualPanel1.jLabel2.text=Select directory for STF file. This is used for displaying conversation entries for nodes.
SceneVisualPanel1.directory.text=None Specified
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="directory" min="-2" pref="199" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="32" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="directory" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="220" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/projectswg/tools/csc/conversationeditor/scenewizard/Bundle.properties" key="SceneVisualPanel1.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="directory">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/projectswg/tools/csc/conversationeditor/scenewizard/Bundle.properties" key="SceneVisualPanel1.directory.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/projectswg/tools/csc/conversationeditor/scenewizard/Bundle.properties" key="SceneVisualPanel1.jButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/projectswg/tools/csc/conversationeditor/scenewizard/Bundle.properties" key="SceneVisualPanel1.jLabel2.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Form>
@@ -0,0 +1,112 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.projectswg.tools.csc.conversationeditor.scenewizard;
import java.io.File;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.openide.filesystems.FileChooserBuilder;
public final class SceneVisualPanel1 extends JPanel {
/**
* Creates new form SceneVisualPanel1
*/
public SceneVisualPanel1() {
initComponents();
}
@Override
public String getName() {
return "Properties";
}
/**
* 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() {
jLabel1 = new javax.swing.JLabel();
directory = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(SceneVisualPanel1.class, "SceneVisualPanel1.jLabel1.text")); // NOI18N
directory.setText(org.openide.util.NbBundle.getMessage(SceneVisualPanel1.class, "SceneVisualPanel1.directory.text")); // NOI18N
directory.setEnabled(false);
org.openide.awt.Mnemonics.setLocalizedText(jButton1, org.openide.util.NbBundle.getMessage(SceneVisualPanel1.class, "SceneVisualPanel1.jButton1.text")); // NOI18N
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(SceneVisualPanel1.class, "SceneVisualPanel1.jLabel2.text")); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(directory, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton1))
.addComponent(jLabel2))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(32, 32, 32)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(directory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addContainerGap(220, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
File home = new File(System.getProperty("user.home"));
File selection = new FileChooserBuilder("user-dir").setTitle("Select Directory").
setDefaultWorkingDirectory(home).setApproveText("Select").setDirectoriesOnly(false).showOpenDialog();
if (selection != null) {
String path = selection.getAbsolutePath();
if (!path.endsWith(".stf")) {
JOptionPane.showConfirmDialog(null, path + " is not a STF", "Error", JOptionPane.OK_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE);
return;
}
directory.setText(path);
}
}//GEN-LAST:event_jButton1ActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField directory;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
// End of variables declaration//GEN-END:variables
public JTextField getDirectory() {
return directory;
}
}
@@ -0,0 +1,70 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.projectswg.tools.csc.conversationeditor.scenewizard;
import com.projectswg.tools.csc.conversationeditor.EditorTopComponent;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JComponent;
import org.openide.DialogDisplayer;
import org.openide.WizardDescriptor;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
import org.openide.awt.ActionRegistration;
import org.openide.util.NbBundle;
@ActionID(
category = "File",
id = "com.projectswg.tools.csc.conversationeditor.scenewizard.SceneWizardAction"
)
@ActionRegistration(
iconBase = "com/projectswg/tools/csc/conversationeditor/actions/conversation_tb_new.png",
displayName = "New Conversation"
)
@ActionReferences({
@ActionReference(path = "Menu/File", position = 2),
@ActionReference(path = "Toolbars/File", position = 400),
@ActionReference(path = "Shortcuts", name = "D-N")
})
@NbBundle.Messages("CTL_NewConversation=New Conversation")
public final class SceneWizardAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
List<WizardDescriptor.Panel<WizardDescriptor>> panels = new ArrayList<WizardDescriptor.Panel<WizardDescriptor>>();
panels.add(new SceneWizardPanel1());
String[] steps = new String[panels.size()];
for (int i = 0; i < panels.size(); i++) {
Component c = panels.get(i).getComponent();
// Default step name to component name of panel.
steps[i] = c.getName();
if (c instanceof JComponent) { // assume Swing components
JComponent jc = (JComponent) c;
jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true);
jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true);
jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true);
}
}
WizardDescriptor wiz = new WizardDescriptor(new WizardDescriptor.ArrayIterator<WizardDescriptor>(panels));
// {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
wiz.setTitleFormat(new MessageFormat("{0}"));
wiz.setTitle("New Conversation");
if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) {
EditorTopComponent newEditor = new EditorTopComponent();
newEditor.open();
newEditor.requestActive();
newEditor.getScene().setStfFile((String) wiz.getProperty("directory"));
}
}
}
@@ -0,0 +1,68 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.projectswg.tools.csc.conversationeditor.scenewizard;
import javax.swing.event.ChangeListener;
import org.openide.WizardDescriptor;
import org.openide.util.HelpCtx;
public class SceneWizardPanel1 implements WizardDescriptor.Panel<WizardDescriptor> {
/**
* The visual component that displays this panel. If you need to access the
* component from this class, just use getComponent().
*/
private SceneVisualPanel1 component;
// Get the visual component for the panel. In this template, the component
// is kept separate. This can be more efficient: if the wizard is created
// but never displayed, or not all panels are displayed, it is better to
// create only those which really need to be visible.
@Override
public SceneVisualPanel1 getComponent() {
if (component == null) {
component = new SceneVisualPanel1();
}
return component;
}
@Override
public HelpCtx getHelp() {
// Show no Help button for this panel:
return HelpCtx.DEFAULT_HELP;
// If you have context help:
// return new HelpCtx("help.key.here");
}
@Override
public boolean isValid() {
// If it is always OK to press Next or Finish, then:
return true;
// If it depends on some condition (form filled out...) and
// this condition changes (last form field filled in...) then
// use ChangeSupport to implement add/removeChangeListener below.
// WizardDescriptor.ERROR/WARNING/INFORMATION_MESSAGE will also be useful.
}
@Override
public void addChangeListener(ChangeListener l) {
}
@Override
public void removeChangeListener(ChangeListener l) {
}
@Override
public void readSettings(WizardDescriptor wiz) {
// use wiz.getProperty to retrieve previous panel state
}
@Override
public void storeSettings(WizardDescriptor wiz) {
wiz.putProperty("directory", component.getDirectory().getText());
}
}
@@ -0,0 +1,91 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.projectswg.tools.csc.conversationeditor.stf;
import com.projectswg.tools.csc.conversationeditor.stf.StfTable.Pair;
import java.io.IOException;
import java.util.Vector;
import org.openide.util.Exceptions;
public class Stf {
private String file;
private String key = "None";
private String value = "";
private Vector<String> entries = new Vector<>();
public Stf(String file) {
this.file = file;
if (!getFilename().equals("None")) {
StfTable table = new StfTable();
try {
table.readFile(file);
for (Pair<String, String> pair : table.disorderedTable) {
if (pair.getKey().equals("do_not_edit"))
continue;
entries.add(pair.getKey() + " | " + pair.getValue());
}
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
}
public String getFile() {
return file;
}
public void setFile(String file) {
this.file = file;
}
public final String getFilename() {
String r2;
try {
String[] base = file.split("conversation");
r2 = base[1].replace("\\", "").replace(".stf", "");
} catch (ArrayIndexOutOfBoundsException exc) {
r2 = "None";
}
return r2;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public Vector<String> getEntries() {
return entries;
}
public void setEntries(Vector<String> entries) {
this.entries = entries;
}
@Override
public String toString() {
return getFilename() + ":" + getKey();
}
}
@@ -0,0 +1,153 @@
/*******************************************************************************
* Part of NGECore2
* Copyright (c) 2013 <Project SWG>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
package com.projectswg.tools.csc.conversationeditor.stf;
import java.io.IOException;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.List;
import org.apache.mina.core.buffer.IoBuffer;
/*
* Stf files don't appear to use the IFF format.
*
* ID 0 will probably always be null because they start at 1.
*/
public class StfTable {
private String[][] orderedTable;
public List<Pair<String, String>> disorderedTable;
public class Pair<K, V> {
private K key;
private V value;
public Pair(K key, V value) {
this.key = key;
this.value = value;
}
public K getKey() {
return key;
}
public V getValue() {
return value;
}
}
public StfTable() {
}
public StfTable(String filePath) throws IOException {
readFile(filePath);
}
public void readFile(String filePath) throws IOException {
java.io.FileInputStream stf = new java.io.FileInputStream(filePath);
IoBuffer buffer = IoBuffer.allocate(stf.available(), false);
buffer.setAutoExpand(true);
buffer.order(ByteOrder.LITTLE_ENDIAN);
byte[] buf = new byte[1024];
for (int i = stf.read(buf); i != -1; i = stf.read(buf)) {
buffer.put(buf, 0, i);
}
buffer.flip();
buffer.getInt(); // Size?
buffer.get(); // isMore?
int arrayCount = buffer.getInt();
int rowCount = buffer.getInt();
orderedTable = new String[arrayCount][2];
disorderedTable = new ArrayList<Pair<String, String>>();
for (int i = 0; i < rowCount; i++) {
int id = buffer.getInt();
buffer.getInt();
String value = "";
value = StringUtilities.getUnicodeString(buffer, true);
orderedTable[id][0] = null;
orderedTable[id][1] = value;
}
for (int i = 0; i < rowCount; i++) {
int id = buffer.getInt();
String name = StringUtilities.getAsciiString(buffer, true);
orderedTable[id][0] = name;
disorderedTable.add(new Pair<String, String>(name, orderedTable[id][1]));
}
stf.close();
}
public int getRowCount() {
return ((orderedTable == null) ? 0 : orderedTable.length);
}
public int getColumnCount() {
return ((orderedTable == null) ? 0 : 3);
}
/*
* @param id Iteration number
*
* @returns String's key-value pair from an alphanumeric list
*/
public Pair<String, String> getString(int id) {
return disorderedTable.get(id);
}
/*
* @param id Identifying number of the string from the .stf file, unlike above
*
* @returns String's key-value pair from an unordered list
*/
public Pair<String, String> getStringById(int id) {
return new Pair<String, String>(orderedTable[id][0], orderedTable[id][1]);
}
/*
* @param name Name of the string to return
*
* @returns The value for this key, or null if the key is not found
*/
public String getString(String name) {
for (String[] columns : orderedTable) {
if (columns[0].equals(name)) {
return columns[1];
}
}
return null;
}
}
@@ -0,0 +1,67 @@
/*******************************************************************************
* Part of NGECore2
* Copyright (c) 2013 <Project SWG>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
package com.projectswg.tools.csc.conversationeditor.stf;
import java.io.UnsupportedEncodingException;
import java.nio.ByteOrder;
import org.apache.mina.core.buffer.IoBuffer;
public class StringUtilities {
public static String getUnicodeString(IoBuffer buffer, boolean integer) {
return getString(buffer, "UTF-16LE", integer);
}
public static String getAsciiString(IoBuffer buffer, boolean integer) {
return getString(buffer, "US-ASCII", integer);
}
private static String getString(IoBuffer buffer, String charFormat, boolean integer) {
String result;
int length;
if (charFormat.equals("UTF-16LE")) {
if (integer) {
length = buffer.order(ByteOrder.LITTLE_ENDIAN).getInt() * 2;
} else {
length = buffer.order(ByteOrder.LITTLE_ENDIAN).getInt();
}
} else {
if (integer) {
length = buffer.order(ByteOrder.LITTLE_ENDIAN).getInt();
} else {
length = buffer.order(ByteOrder.LITTLE_ENDIAN).getShort();
}
}
int bufferPosition = buffer.position();
try {
result = new String(buffer.array(), bufferPosition, length, charFormat);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return "";
}
buffer.position(bufferPosition + length);
return result;
}
}
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
<!-- for some information on what you could do (e.g. targets to override). -->
<!-- If you delete this file and reopen the project it will be recreated. -->
<project name="com.projectswg.minacore" default="netbeans" basedir=".">
<description>Builds, tests, and runs the project com.projectswg.minacore.</description>
<import file="nbproject/build-impl.xml"/>
</project>
+6
View File
@@ -0,0 +1,6 @@
Manifest-Version: 1.0
AutoUpdate-Show-In-Client: true
OpenIDE-Module: com.projectswg.minacore
OpenIDE-Module-Localizing-Bundle: com/projectswg/minacore/Bundle.properties
OpenIDE-Module-Specification-Version: 1.0
+45
View File
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
*** GENERATED FROM project.xml - DO NOT EDIT ***
*** EDIT ../build.xml INSTEAD ***
-->
<project name="com.projectswg.minacore-impl" basedir="..">
<fail message="Please build using Ant 1.7.1 or higher.">
<condition>
<not>
<antversion atleast="1.7.1"/>
</not>
</condition>
</fail>
<property file="nbproject/private/suite-private.properties"/>
<property file="nbproject/suite.properties"/>
<fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
<property file="${suite.dir}/nbproject/private/platform-private.properties"/>
<property file="${suite.dir}/nbproject/platform.properties"/>
<macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
<attribute name="name"/>
<attribute name="value"/>
<sequential>
<property name="@{name}" value="${@{value}}"/>
</sequential>
</macrodef>
<macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
<attribute name="property"/>
<attribute name="value"/>
<sequential>
<property name="@{property}" value="@{value}"/>
</sequential>
</macrodef>
<property file="${user.properties.file}"/>
<nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
<nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
<nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
<fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
<condition>
<not>
<contains string="${cluster.path.evaluated}" substring="platform"/>
</not>
</condition>
</fail>
<import file="${harness.dir}/build.xml"/>
</project>
+8
View File
@@ -0,0 +1,8 @@
build.xml.data.CRC32=4841ee18
build.xml.script.CRC32=c0ea07ec
build.xml.stylesheet.CRC32=[email protected]
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=4841ee18
nbproject/build-impl.xml.script.CRC32=78cc321f
nbproject/build-impl.xml.stylesheet.CRC32=[email protected]
+1
View File
@@ -0,0 +1 @@
is.autoload=true
+65
View File
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.apisupport.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
<code-name-base>com.projectswg.minacore</code-name-base>
<suite-component/>
<module-dependencies/>
<public-packages>
<package>org.apache.mina.core</package>
<package>org.apache.mina.core.buffer</package>
<package>org.apache.mina.core.file</package>
<package>org.apache.mina.core.filterchain</package>
<package>org.apache.mina.core.future</package>
<package>org.apache.mina.core.polling</package>
<package>org.apache.mina.core.service</package>
<package>org.apache.mina.core.session</package>
<package>org.apache.mina.core.write</package>
<package>org.apache.mina.filter.buffer</package>
<package>org.apache.mina.filter.codec</package>
<package>org.apache.mina.filter.codec.demux</package>
<package>org.apache.mina.filter.codec.prefixedstring</package>
<package>org.apache.mina.filter.codec.serialization</package>
<package>org.apache.mina.filter.codec.statemachine</package>
<package>org.apache.mina.filter.codec.textline</package>
<package>org.apache.mina.filter.errorgenerating</package>
<package>org.apache.mina.filter.executor</package>
<package>org.apache.mina.filter.firewall</package>
<package>org.apache.mina.filter.keepalive</package>
<package>org.apache.mina.filter.logging</package>
<package>org.apache.mina.filter.reqres</package>
<package>org.apache.mina.filter.ssl</package>
<package>org.apache.mina.filter.statistic</package>
<package>org.apache.mina.filter.stream</package>
<package>org.apache.mina.filter.util</package>
<package>org.apache.mina.handler.chain</package>
<package>org.apache.mina.handler.demux</package>
<package>org.apache.mina.handler.multiton</package>
<package>org.apache.mina.handler.stream</package>
<package>org.apache.mina.proxy</package>
<package>org.apache.mina.proxy.event</package>
<package>org.apache.mina.proxy.filter</package>
<package>org.apache.mina.proxy.handlers</package>
<package>org.apache.mina.proxy.handlers.http</package>
<package>org.apache.mina.proxy.handlers.http.basic</package>
<package>org.apache.mina.proxy.handlers.http.digest</package>
<package>org.apache.mina.proxy.handlers.http.ntlm</package>
<package>org.apache.mina.proxy.handlers.socks</package>
<package>org.apache.mina.proxy.session</package>
<package>org.apache.mina.proxy.utils</package>
<package>org.apache.mina.transport</package>
<package>org.apache.mina.transport.socket</package>
<package>org.apache.mina.transport.socket.nio</package>
<package>org.apache.mina.transport.vmpipe</package>
<package>org.apache.mina.util</package>
<package>org.apache.mina.util.byteaccess</package>
<package>testcase</package>
</public-packages>
<class-path-extension>
<runtime-relative-path>ext/mina-core-2.0.4.jar</runtime-relative-path>
<binary-origin>release/modules/ext/mina-core-2.0.4.jar</binary-origin>
</class-path-extension>
</data>
</configuration>
</project>
+1
View File
@@ -0,0 +1 @@
suite.dir=${basedir}/..
Binary file not shown.
@@ -0,0 +1 @@
OpenIDE-Module-Name=mina-core
+3 -1
View File
@@ -9,5 +9,7 @@ auxiliary.org-netbeans-modules-apisupport-installer.os-windows=true
auxiliary.org-netbeans-modules-apisupport-installer.pack200-enabled=false auxiliary.org-netbeans-modules-apisupport-installer.pack200-enabled=false
auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml
modules=\ modules=\
${project.com.projectswg.tools.csc.conversationeditor} ${project.com.projectswg.tools.csc.conversationeditor}:\
${project.com.projectswg.minacore}
project.com.projectswg.minacore=mina-core
project.com.projectswg.tools.csc.conversationeditor=ConversationEditor project.com.projectswg.tools.csc.conversationeditor=ConversationEditor