Skip to content

Commit

Permalink
Merge branch 'bugfix' (#966, #969) into issue967
Browse files Browse the repository at this point in the history
Solved conflicts:
- src/lu/fisch/structorizer/gui/Diagram.java
- src/lu/fisch/structorizer/gui/changelog.txt
  • Loading branch information
codemanyak committed Apr 15, 2021
2 parents e5f375b + 5304703 commit 0627df9
Show file tree
Hide file tree
Showing 101 changed files with 703 additions and 483 deletions.
4 changes: 2 additions & 2 deletions buildapp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
name="Structorizer"
displayname="Structorizer"
identifier="lu.fisch.Structorizer"
shortversion="3.31-02"
version="3.31-02"
shortversion="3.31-03"
version="3.31-03"
icon="icons/Structorizer.icns"
mainclassname="Structorizer"
copyright="Bob Fisch"
Expand Down
2 changes: 1 addition & 1 deletion src/Structorizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ else if (args[i].equals("-s") && i+1 < args.length)
// END KGU#722 2019-08-06
}
// END KGU#538 2018-07-01
// START KGU#602 2018-10-25: Enh. #416
// START KGU#602 2018-10-25: Enh. #416 - line length constraint
else if (args[i].equals("-l") && parser != null && i+1 < args.length) {
// START KGU#722 2019-08-07: Enh. #741
if (openFound || generator == null && parser == null) {
Expand Down
42 changes: 39 additions & 3 deletions src/lu/fisch/structorizer/arranger/ArrangerIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -100,6 +102,7 @@
import javax.swing.JToggleButton;
import javax.swing.JTree;
import javax.swing.KeyStroke;
import javax.swing.UIManager;
import javax.swing.event.TreeExpansionEvent;
import javax.swing.event.TreeExpansionListener;
import javax.swing.tree.DefaultMutableTreeNode;
Expand Down Expand Up @@ -140,7 +143,12 @@ public class ArrangerIndex extends LangTree implements MouseListener, LangEventL
private final HashSet<DefaultMutableTreeNode> expandedGroupNodes = new HashSet<DefaultMutableTreeNode>();
/** Original (standard) Arranger index background color - may get wrong with an L&F change! */
private Color arrangerIndexBackground = null;
private static final Color ARRANGER_INDEX_UNFOCUSSED_BACKGROUND = Color.LIGHT_GRAY;
// START KGU#964 2021-03-10: Issue #966 Consider dark themes
//private static final Color ARRANGER_INDEX_UNFOCUSSED_BACKGROUND = Color.LIGHT_GRAY;
private static final Color LIGHT_INDEX_UNFOCUSSED_BACKGROUND = Color.LIGHT_GRAY;
private static final Color DARK_INDEX_UNFOCUSSED_BACKGROUND = Color.DARK_GRAY;
private static Color unfocussedBackground = null;
// END KGU#964 2021-03-10

// START KGU#318 2017-01-05: Enh. #319 - context menu for the Arranger index
protected final JPopupMenu popupIndex = new JPopupMenu();
Expand Down Expand Up @@ -497,6 +505,11 @@ public void actionPerformed(ActionEvent evt) {
pnlGroupInfo.add(buttonBar, BorderLayout.SOUTH);

arrangerIndexBackground = this.getBackground();
// START KGU#964 2021-03-10: Issue #966 Decide whether this is a light or dark theme
float[] hsb = new float[3];
Color.RGBtoHSB(arrangerIndexBackground.getRed(), arrangerIndexBackground.getGreen(), arrangerIndexBackground.getBlue(), hsb);
unfocussedBackground = hsb[2] > 0.5 ? LIGHT_INDEX_UNFOCUSSED_BACKGROUND : DARK_INDEX_UNFOCUSSED_BACKGROUND;
// END KGU#964 2021-03-10
this.setRootVisible(false);
this.setCellRenderer(new ArrangerIndexCellRenderer());
this.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
Expand Down Expand Up @@ -526,7 +539,10 @@ public void focusGained(FocusEvent event) {
}
@Override
public void focusLost(FocusEvent event) {
setBackground(ARRANGER_INDEX_UNFOCUSSED_BACKGROUND);
// START KGU#964 2021-03-10: Issue #966
//setBackground(ARRANGER_INDEX_UNFOCUSSED_BACKGROUND);
setBackground(unfocussedBackground);
// END KGU#964 2021-03-10
}});
this.setShowsRootHandles(true);
// START KGU#305 2016-12-15: Enh. #305 - react to space and enter
Expand Down Expand Up @@ -559,13 +575,33 @@ public void focusLost(FocusEvent event) {
actMap.put("SHIFT_ALT_R", new ArrangerIndexAction("RENAME_GROUP"));

if (!this.isFocusOwner()) {
this.setBackground(ARRANGER_INDEX_UNFOCUSSED_BACKGROUND);
// START KGU#964 2021-03-10: Issue #966
//this.setBackground(ARRANGER_INDEX_UNFOCUSSED_BACKGROUND);
setBackground(unfocussedBackground);
// END KGU#964 2021-03-10
}
// END KGU#305 2016-12-15

scrollInfo.setWheelScrollingEnabled(true);

createPopupMenu();

// START KGU#964 2021-03-10: Issue #966
UIManager.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if ("lookAndFeel".equals(evt.getPropertyName())) {
Color bg = UIManager.getColor("Tree.background");
if (bg != null) {
arrangerIndexBackground = bg;
float[] hsb = new float[3];
Color.RGBtoHSB(bg.getRed(), bg.getGreen(), bg.getBlue(), hsb);
unfocussedBackground = hsb[2] > 0.5 ? LIGHT_INDEX_UNFOCUSSED_BACKGROUND : DARK_INDEX_UNFOCUSSED_BACKGROUND;
}
}

}});
// END KGU#964 2021-03-10
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lu/fisch/structorizer/elements/Element.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public String toString()
" - LU: Laurent Zender <[email protected]>\n"+
" - ES: Andres Cabrera <[email protected]>\n"+
" - PT/BR: Theldo Cruz <[email protected]>\n"+
" - IT: Andrea Maiani <[email protected]>\n"+
" - IT: Andrea Maiani <[email protected]>, A. Simonetta (University of Rome Tor Vergata)\n"+
" - ZH-CN: Wang Lei <[email protected]>\n"+
" - ZH-TW: Joe Chem <[email protected]>\n"+
" - CZ: Vladimír Vaščák <[email protected]>\n"+
Expand Down
17 changes: 14 additions & 3 deletions src/lu/fisch/structorizer/executor/Executor.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@
* Kay Gürtzig 2021-02-03 Issue #920: Acceptance of infinity as symbol ∞
* Kay Gürtzig 2021-02-24 Enh. #410: Additional namespace filter applied for callees and includables
* Kay Gürtzig 2021-02-28 Bugfix #947: Detection of cyclic inclusion added.
* Kay Gürtzig 2021-04-14 Bugfix #969: Precaution against relative currentDirectory (caused NPE)
*
******************************************************************************************************
*
Expand Down Expand Up @@ -343,6 +344,7 @@
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -2853,15 +2855,24 @@ private void initInterpreter()
{
try
{
// STRT KGU#384 2017-04-22: Redesign of execution context
// START KGU#384 2017-04-22: Redesign of execution context
//interpreter = new Interpreter();
Interpreter interpreter = this.context.interpreter;
// END KGU#384 2017-04-22

// START KGU 2016-12-18: #314: Support for simple text file API
interpreter.set("executorFileMap", this.openFiles);
interpreter.set("executorCurrentDirectory",
(diagram.currentDirectory.isDirectory() ? diagram.currentDirectory : diagram.currentDirectory.getParentFile()).getAbsolutePath());
// START KGU#969 2021-04-14: Bugfix #969 - beware of relative paths!
//interpreter.set("executorCurrentDirectory",
// (diagram.currentDirectory.isDirectory() ? diagram.currentDirectory : diagram.currentDirectory.getParentFile()).getAbsolutePath());
File currDir = diagram.currentDirectory;
if (currDir != null && currDir.exists() && !currDir.isDirectory()) {
currDir = currDir.getAbsoluteFile().getParentFile();
}
if (currDir != null) {
interpreter.set("executorCurrentDirectory", currDir.getAbsolutePath());
}
// END KGU#969 2021-04-14
// END KGU 2016-12-18

for (int i = 0; i < builtInFunctions.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/lu/fisch/structorizer/generators/CGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ protected void appendBlockTail(Element elem, String _tailText, String _indent)

// START KGU#332 2017-01-27: Enh. #335
/**
* States whether constant definitions or varaible declarations may occur anywhere in
* States whether constant definitions or variable declarations may occur anywhere in
* the code or only at block beginning
* @return true if declarations may be mixed among instructions
*/
Expand Down
3 changes: 2 additions & 1 deletion src/lu/fisch/structorizer/generators/Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -3347,7 +3347,8 @@ protected void appendGlobalDefinitions(Root _root, String _indent, boolean _forc
* @param _root - the diagram the declarations and definitions of which are to be inserted
* @param _indent - the proper indentation as String
* @param _varNames - optionally the StringList of the variable names to be declared (my be null)
* @param _force - true means that the insertion is forced even if option {@link #isInternalDeclarationAllowed()} is set
* @param _force - true means that the insertion is forced even if some adversary option like e.g.
* {@link CGenerator#isInternalDeclarationAllowed()} is set
*/
protected void appendDefinitions(Root _root, String _indent, StringList _varNames, boolean _force) {
// To be overridden by subclasses
Expand Down
Loading

0 comments on commit 0627df9

Please sign in to comment.