Skip to content

Commit

Permalink
Saving recode is now a button, no longer irritating messages.
Browse files Browse the repository at this point in the history
Cleaned cplex dll's
  • Loading branch information
Peter-Paul authored and Peter-Paul committed Aug 14, 2024
1 parent b9d34e7 commit 5d35274
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 53 deletions.
Binary file modified Intervalle.exe
Binary file not shown.
17 changes: 14 additions & 3 deletions _TauChanges.txt
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,19 @@ Parameter calculation GHMIter for Large Model corrected, now consistent with gen
Scrollbar added to info window (e.g. when calculating Intervalle)

date : Jan 15, 2024
summary : LOWERMARG and UPPERMARG can be set in solveroption dialog (Anco option) => TauArgusJava.dll version 1.1.4.12
summary : Improved reading hst-file

date : Jan 19, 2024
summary : improved speed of processAprioriFile in TableSet
summary : cleaned some code
summary : cleaned some code

date : Apr 25, 2024
summary : Select Table bug fixed (issue #277)

date : May 2, 2024
summary : Corrected percentage info with Optimal

date : May 6, 2024
summary : LOWERMARG and UPPERMARG can be set in Modular Options Dialog (when Anco option = TRUE) and in batch

above to be released in 4.2.5
--------------------------------------------------------------
Binary file removed cplex121.dll
Binary file not shown.
Binary file removed cplex122.dll
Binary file not shown.
Binary file removed cplex75.dll
Binary file not shown.
30 changes: 22 additions & 8 deletions src/tauargus/gui/DialogGlobalRecode.form
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<Form version="1.6" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<NonVisualComponents>
<Component class="javax.swing.JFileChooser" name="fileChooser">
<Properties>
<Property name="dialogType" type="int" value="1"/>
</Properties>
</Component>
</NonVisualComponents>
<Properties>
Expand Down Expand Up @@ -30,15 +33,15 @@
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="scrollPaneVariables" min="-2" pref="221" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="panelRecode" alignment="0" max="32767" attributes="0"/>
<Component id="panelClose" alignment="0" max="32767" attributes="0"/>
<Component id="panelMissing" alignment="1" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelRecodeData" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelTree" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
Expand Down Expand Up @@ -122,12 +125,13 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="buttonRead" min="-2" pref="84" max="-2" attributes="0"/>
<Component id="buttonApply" alignment="0" min="-2" pref="84" max="-2" attributes="0"/>
<Component id="buttonUndo" alignment="0" min="-2" pref="84" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="buttonRead" pref="84" max="32767" attributes="0"/>
<Component id="buttonApply" alignment="0" pref="84" max="32767" attributes="0"/>
<Component id="buttonUndo" alignment="0" pref="84" max="32767" attributes="0"/>
<Component id="buttonSave" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
Expand All @@ -140,9 +144,11 @@
<Component id="buttonRead" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonApply" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonUndo" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonSave" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand Down Expand Up @@ -172,6 +178,14 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonUndoActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonSave">
<Properties>
<Property name="text" type="java.lang.String" value="Save"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonSaveActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelClose">
Expand Down
123 changes: 82 additions & 41 deletions src/tauargus/gui/DialogGlobalRecode.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import tauargus.utils.TreeUtils;
import java.io.BufferedReader;
import java.io.FileReader;
import org.apache.commons.io.FilenameUtils;

public class DialogGlobalRecode extends DialogBase {

Expand Down Expand Up @@ -238,7 +239,8 @@ else if (variable.truncLevels > 0)
public void valueChanged(ListSelectionEvent e) {
if (documentListener.isChanged()) {
documentListener.setChanged(false);
saveRecodeInfo(false);
saveTempRecodeFile(new RecodeInfo(textAreaRecodeData.getText(), textFieldMissing1.getText(), textFieldMissing2.getText(), textFieldCodelist.getText()));
//saveRecodeInfo(false);
}
int selectedRow = tableVariables.getSelectedRow();
if (selectedRow != -1) {
Expand All @@ -249,6 +251,7 @@ public void valueChanged(ListSelectionEvent e) {
panelTree.setVisible(fromTree);
treeCode.setVisible(fromTree);
buttonUndo.setEnabled(variable.recoded);
buttonSave.setEnabled(variable.recoded);
buttonApply.setEnabled(!variable.recoded);
buttonRead.setEnabled(true);
if (fromTree) {
Expand Down Expand Up @@ -285,10 +288,10 @@ public void valueChanged(ListSelectionEvent e) {
else{
labelRecodeData.setText("Edit box for global recode");
labelRecodeData.setToolTipText(null);
textAreaRecodeData.setText("");
textFieldMissing1.setText("");
textFieldMissing2.setText("");
textFieldCodelist.setText("");
//textAreaRecodeData.setText("");
//textFieldMissing1.setText("");
//textFieldMissing2.setText("");
//textFieldCodelist.setText("");
}
textAreaWarning.setText("");
}
Expand Down Expand Up @@ -363,7 +366,7 @@ public void showDialog(TableSet tableSet) {
public void windowClosing(WindowEvent e) {
if (documentListener.isChanged()) {
documentListener.setChanged(false);
saveRecodeInfo(false);
//saveRecodeInfo(false);
}

tauArgus.ApplyRecode();
Expand Down Expand Up @@ -393,6 +396,7 @@ private void initComponents() {
buttonRead = new javax.swing.JButton();
buttonApply = new javax.swing.JButton();
buttonUndo = new javax.swing.JButton();
buttonSave = new javax.swing.JButton();
panelClose = new javax.swing.JPanel();
buttonClose = new javax.swing.JButton();
panelMissing = new javax.swing.JPanel();
Expand All @@ -417,6 +421,8 @@ private void initComponents() {
treeCode = new javax.swing.JTree();
labelTreeResult = new javax.swing.JLabel();

fileChooser.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG);

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

tableVariables.setModel(new javax.swing.table.DefaultTableModel(
Expand Down Expand Up @@ -462,16 +468,24 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
}
});

buttonSave.setText("Save");
buttonSave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonSaveActionPerformed(evt);
}
});

javax.swing.GroupLayout panelRecodeLayout = new javax.swing.GroupLayout(panelRecode);
panelRecode.setLayout(panelRecodeLayout);
panelRecodeLayout.setHorizontalGroup(
panelRecodeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelRecodeLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelRecodeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(buttonRead, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonApply, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonUndo, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(panelRecodeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(buttonRead, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE)
.addComponent(buttonApply, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE)
.addComponent(buttonUndo, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE)
.addComponent(buttonSave, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
panelRecodeLayout.setVerticalGroup(
Expand All @@ -481,9 +495,11 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(buttonRead)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonApply)
.addGap(18, 18, 18)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonUndo)
.addContainerGap())
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonSave)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

panelClose.setBorder(javax.swing.BorderFactory.createEtchedBorder());
Expand Down Expand Up @@ -678,7 +694,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(panelMissing, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelRecodeData, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelTree, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
Expand Down Expand Up @@ -715,7 +731,6 @@ private void buttonUndoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI
variable.recoded = false;
variable.truncLevels = 0;
((AbstractTableModel)tableVariables.getModel()).fireTableDataChanged();
buttonUndo.setEnabled(false);
if (fromTree) {
buildTree();
}
Expand All @@ -728,6 +743,7 @@ private void buttonUndoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI
SystemUtils.writeLogbook("Recode for var: " + variable.name + " has been reversed");
buttonApply.setEnabled(true);
buttonUndo.setEnabled(false);
buttonSave.setEnabled(false);
buttonRead.setEnabled(!fromTree);
textAreaWarning.setText("");
}
Expand All @@ -738,7 +754,7 @@ private void buttonCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
setVisible(false);
if (documentListener.isChanged()) {
documentListener.setChanged(false);
saveRecodeInfo(false);
//saveRecodeInfo(false);
}

tauArgus.ApplyRecode();
Expand Down Expand Up @@ -783,9 +799,9 @@ private void buttonApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
LOGGER.log(Level.INFO, "Var: {0} has been recoded\n", variable.name);
SystemUtils.writeLogbook("Var: " + variable.name + " has been recoded");
buildTree();
int i = JOptionPane.showConfirmDialog(this, "Do you want to save the recoding of the tree", "ARGUS-recodefiles", JOptionPane.YES_NO_OPTION);
if (i == JOptionPane.YES_OPTION)
saveRecodeInfo(true); // true = for treebased recoding
//int i = JOptionPane.showConfirmDialog(this, "Do you want to save the recoding of the tree", "ARGUS-recodefiles", JOptionPane.YES_NO_OPTION);
//if (i == JOptionPane.YES_OPTION)
// saveRecodeInfo(true); // true = for treebased recoding
} else {
JOptionPane.showMessageDialog(this, "This hierarchical recoding could not be applied");
labelTreeResult.setText("Tree recode could not be applied");
Expand Down Expand Up @@ -937,16 +953,32 @@ private void buttonReadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI
tableVariables.setRowSelectionInterval(rowIndex, rowIndex);
}//GEN-LAST:event_buttonReadActionPerformed

private void saveRecodeInfo(Boolean forTreeRecode) {
RecodeInfo recodeInfo = new RecodeInfo(textAreaRecodeData.getText(), textFieldMissing1.getText(), textFieldMissing2.getText(), textFieldCodelist.getText());
int i;
if (forTreeRecode){ // You only get here when you want to save the tree recode
i = JOptionPane.YES_OPTION;
}
else{
i = JOptionPane.showConfirmDialog(this, "Recode information has been changed.\nSave recodefile?", "ARGUS-recodefiles", JOptionPane.YES_NO_OPTION);
private void buttonSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSaveActionPerformed
buttonSave.setEnabled(!saveRecodeInfo(fromTree));
}//GEN-LAST:event_buttonSaveActionPerformed

private void saveTempRecodeFile(RecodeInfo recodeInfo){
String tempDir = Application.getTempDir();
File f = new File(tempDir, "Argus" + variable.index + ".grc");
variable.currentRecodeFile = f.getAbsolutePath();
try {
variable.writeRecodeFile(variable.currentRecodeFile, recodeInfo);
} catch (IOException ex) {
JOptionPane.showMessageDialog(DialogGlobalRecode.this, ex.getMessage());
}
if (i == JOptionPane.YES_OPTION) {
}

private boolean saveRecodeInfo(Boolean forTreeRecode) {
RecodeInfo recodeInfo = new RecodeInfo(textAreaRecodeData.getText(), textFieldMissing1.getText(), textFieldMissing2.getText(), textFieldCodelist.getText());
//int i;
//if (forTreeRecode){ // You only get here when you want to save the tree recode
// i = JOptionPane.YES_OPTION;
//}
//else{
// i = JOptionPane.showConfirmDialog(this, "Recode information has been changed.\nSave recodefile?", "ARGUS-recodefiles", JOptionPane.YES_NO_OPTION);
//}
// You should only get here when you want to save the recoding
//if (i == JOptionPane.YES_OPTION) {
// String hs = SystemUtils.getRegString("general", "datadir", "");
// if (!hs.equals("")){
// File file = new File(hs);
Expand All @@ -956,38 +988,46 @@ private void saveRecodeInfo(Boolean forTreeRecode) {
fileChooser.setDialogTitle("Save global recode file");
fileChooser.setSelectedFile(new File(variable.currentRecodeFile));
fileChooser.setFileFilter(new FileNameExtensionFilter("Recode files (*.grc)", "grc"));
if (fileChooser.showOpenDialog(this) == javax.swing.JFileChooser.APPROVE_OPTION) {
if (fileChooser.showSaveDialog(this) == javax.swing.JFileChooser.APPROVE_OPTION) {
variable.currentRecodeFile = fileChooser.getSelectedFile().toString();
// Add default ".grc" if no extension is given
if (FilenameUtils.getExtension(variable.currentRecodeFile).equals("")){
variable.currentRecodeFile = variable.currentRecodeFile + ".grc";
}
TauArgusUtils.putDataDirInRegistry(variable.currentRecodeFile);
if (!forTreeRecode){
try {
variable.writeRecodeFile(variable.currentRecodeFile, recodeInfo);
textAreaWarning.setText("Recoding saved");
} catch (IOException ex) {
JOptionPane.showMessageDialog(DialogGlobalRecode.this, ex.getMessage());
}
return;
//return;
}
else // Save a real tree
{
try{
variable.writeRecodeTreeFile(variable.currentRecodeFile);
textAreaWarning.setText("Recoding saved");
} catch (IOException ex) {
JOptionPane.showMessageDialog(DialogGlobalRecode.this, ex.getMessage());
}
return;
//return;
}
return true; // actually saved
}
}
if(forTreeRecode){return;}
// we do not need a temp recode file for a hierarchical recode
String tempDir = Application.getTempDir();
File f = new File(tempDir, "Argus" + variable.index + ".grc");
variable.currentRecodeFile = f.getAbsolutePath();
try {
variable.writeRecodeFile(variable.currentRecodeFile, recodeInfo);
} catch (IOException ex) {
JOptionPane.showMessageDialog(DialogGlobalRecode.this, ex.getMessage());
}
else return false; // actually not saved
//}
//if(!forTreeRecode){ // we do not need a temp recode file for a hierarchical recode
//String tempDir = Application.getTempDir();
//File f = new File(tempDir, "Argus" + variable.index + ".grc");
//variable.currentRecodeFile = f.getAbsolutePath();
//try {
// variable.writeRecodeFile(variable.currentRecodeFile, recodeInfo);
//} catch (IOException ex) {
// JOptionPane.showMessageDialog(DialogGlobalRecode.this, ex.getMessage());
//}
//}
}

private int addChildren(DefaultMutableTreeNode parentNode, VarCodeProperties parentProperties, int codeIndex) {
Expand Down Expand Up @@ -1074,6 +1114,7 @@ private int expand(int depth) {
private javax.swing.JButton buttonClose;
private javax.swing.JButton buttonCodelist;
private javax.swing.JButton buttonRead;
private javax.swing.JButton buttonSave;
private javax.swing.JButton buttonUndo;
private javax.swing.JComboBox<String> comboBoxMaxLevel;
private javax.swing.JFileChooser fileChooser;
Expand Down
Loading

0 comments on commit 5d35274

Please sign in to comment.