Skip to content

Commit

Permalink
Changes in Idea Editor to include scope and categories
Browse files Browse the repository at this point in the history
  • Loading branch information
rgudwin committed Jun 14, 2022
1 parent 5c6e930 commit af5f673
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 28 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = "CST-Desktop"

sourceCompatibility = 1.8
targetCompatibility = 1.8
version = '1.0.3'
version = '1.0.4'

repositories {
flatDir {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="34" max="-2" attributes="0"/>
Expand All @@ -34,21 +34,29 @@
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jCategory" max="32767" attributes="0"/>
<Component id="jType" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jOK" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="131" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jCancel" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jName" alignment="0" max="32767" attributes="0"/>
<Component id="jValue" alignment="0" max="32767" attributes="0"/>
<Component id="jScope" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="46" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jTypeEnable" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="15" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand All @@ -66,11 +74,24 @@
<Component id="jValue" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jTypeEnable" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jCategory" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="23" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jScope" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="37" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jOK" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jCancel" alignment="3" min="-2" max="-2" attributes="0"/>
Expand Down Expand Up @@ -127,5 +148,43 @@
<Property name="text" type="java.lang.String" value="Type:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="jCategory">
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jCategoryActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="text" type="java.lang.String" value="Category:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="text" type="java.lang.String" value="Scope:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="jScope">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="3">
<StringItem index="0" value="Possibility"/>
<StringItem index="1" value="Existence"/>
<StringItem index="2" value="Law"/>
</StringArray>
</Property>
<Property name="selectedIndex" type="int" value="1"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jScopeActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Component class="javax.swing.JCheckBox" name="jTypeEnable">
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jTypeEnableActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ private void initComponents() {
jCancel = new javax.swing.JButton();
jType = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jCategory = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jScope = new javax.swing.JComboBox<>();
jTypeEnable = new javax.swing.JCheckBox();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

Expand Down Expand Up @@ -98,6 +103,30 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {

jLabel1.setText("Type:");

jCategory.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCategoryActionPerformed(evt);
}
});

jLabel4.setText("Category:");

jLabel5.setText("Scope:");

jScope.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Possibility", "Existence", "Law" }));
jScope.setSelectedIndex(1);
jScope.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jScopeActionPerformed(evt);
}
});

jTypeEnable.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTypeEnableActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
Expand All @@ -111,17 +140,24 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(jLabel3)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jCategory)
.addComponent(jType)
.addGroup(layout.createSequentialGroup()
.addComponent(jOK)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 131, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jCancel))
.addComponent(jName)
.addComponent(jValue))
.addGap(46, 46, 46))
.addComponent(jValue)
.addComponent(jScope, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jTypeEnable)
.addGap(15, 15, 15))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
Expand All @@ -135,10 +171,20 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(jLabel3)
.addComponent(jValue, 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.TRAILING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addComponent(jTypeEnable))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
.addComponent(jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(jScope, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jOK)
.addComponent(jCancel))
Expand Down Expand Up @@ -171,6 +217,19 @@ private void jCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST
private void jTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTypeActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jTypeActionPerformed

private void jCategoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCategoryActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jCategoryActionPerformed

private void jScopeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jScopeActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jScopeActionPerformed

private void jTypeEnableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTypeEnableActionPerformed
jType.setEditable(jTypeEnable.isSelected());
jType.setEnabled(jTypeEnable.isSelected());
}//GEN-LAST:event_jTypeEnableActionPerformed

public static IdeaTreeNode getIdea(IdeaTreeNode baseNode) {

Expand All @@ -182,18 +241,27 @@ public static IdeaTreeNode getIdea(IdeaTreeNode baseNode) {
dialog.jName.setEnabled(true);
dialog.jValue.setEditable(true);
dialog.jValue.setEnabled(true);
dialog.jType.setEditable(true);
dialog.jType.setEnabled(true);
dialog.jType.setEditable(false);
dialog.jType.setEnabled(false);
//RefineryUtilities.centerFrameOnScreen(dialog);
dialog.setVisible(true);
dialog.dispose();
if (dialog.ok == true) {
String newname = dialog.jName.getText();
String newvalue = dialog.jValue.getText();
int newtype;
try {newtype = Integer.parseInt(dialog.jType.getText());
} catch (Exception e) {newtype = 0;}
Idea newwmnode = new Idea(newname,newvalue,newtype);
String newcategory = dialog.jCategory.getText();
int newscope;
newscope = dialog.jScope.getSelectedIndex();
Idea newwmnode;
if (!dialog.jType.isEditable()) {
newwmnode = new Idea(newname,newvalue,newcategory,newscope);
}
else {
int newtype;
try {newtype = Integer.parseInt(dialog.jType.getText());
} catch (Exception e) {newtype = 0;}
newwmnode = new Idea(newname,newvalue,newtype,newcategory,newscope);
}
IdeaTreeNode newnode = baseNode.addIdeaNode(newwmnode);
newnode.representIdea(newwmnode);
return(newnode);
Expand All @@ -208,23 +276,32 @@ public static String editIdea(IdeaTreeNode node) {
dialog.setTitle("Edit Idea data ...");
dialog.jValue.setEditable(true);
dialog.jValue.setEnabled(true);
dialog.jType.setEnabled(true);
dialog.jType.setEnabled(false);
dialog.jType.setEditable(false);
TreeElement te = (TreeElement) node.getUserObject();
Idea idea = (Idea) te.getElement();
String text = te.getName();
dialog.jName.setText(idea.getName());
dialog.jValue.setText(String.valueOf(idea.getValue()));
dialog.jType.setText(String.valueOf(idea.getType()));
dialog.jCategory.setText(idea.getCategory());
dialog.jScope.setSelectedIndex(idea.getScope());
//RefineryUtilities.centerFrameOnScreen(dialog);
dialog.setVisible(true);
dialog.dispose();
if (dialog.ok == true) {
Idea id = (Idea) te.getElement();
id.setName(dialog.jName.getText());
id.setValue(dialog.jValue.getText());
id.setCategory(dialog.jCategory.getText());
id.setScope(dialog.jScope.getSelectedIndex());
int type;
try {type = Integer.parseInt(dialog.jType.getText());
} catch (Exception e) {type = 0;}
if (dialog.jType.isEditable()) {
try {type = Integer.parseInt(dialog.jType.getText());
} catch (Exception e) {type = id.guessType(id.getCategory(),id.getScope());}
}
else
type = id.guessType(id.getCategory(),id.getScope());
id.setType(type);
node.representIdea(id);
return(dialog.jName.getText());
Expand All @@ -234,12 +311,17 @@ public static String editIdea(IdeaTreeNode node) {

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jCancel;
private javax.swing.JTextField jCategory;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JTextField jName;
private javax.swing.JButton jOK;
private javax.swing.JComboBox<String> jScope;
private javax.swing.JTextField jType;
private javax.swing.JCheckBox jTypeEnable;
private javax.swing.JTextField jValue;
// End of variables declaration//GEN-END:variables
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import java.util.List;

import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
*
Expand All @@ -25,7 +27,7 @@ public class IdeaEditor extends javax.swing.JFrame {
IdeaPanel wmp;
Idea root;
List<IdeaEditorListener> listeners;
public boolean finished = false;
public boolean finished;

/**
* Creates new form IdeaEditor
Expand All @@ -49,6 +51,12 @@ public IdeaEditor(Idea rootId, boolean editable) {
}

pack();
finished = false;
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
finished = true;
}
});
}

public void addListener(IdeaEditorListener listener) {
Expand Down Expand Up @@ -198,10 +206,9 @@ private void mSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:e

private void mCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mCloseActionPerformed
// TODO add your handling code here:
finished = true;
System.out.println("Setting finished to "+finished);
this.finished = true;
//this.dispose();
//this.setVisible(false);
this.setVisible(false);
}//GEN-LAST:event_mCloseActionPerformed

private void mLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mLoadActionPerformed
Expand Down

0 comments on commit af5f673

Please sign in to comment.