From 4d7cb48fd64f5091f47fca5e3434f65b998b6e6e Mon Sep 17 00:00:00 2001 From: Robert Colton Date: Tue, 21 May 2019 14:28:10 -0400 Subject: [PATCH] Expand Event Tree Preference (#432) Add a preference to expand the object event trees by default, which is enabled by default. Use a simpler method for expanding all JTree rows and apply it to the search tree too. Translations provided by Google Translate. --- org/lateralgm/main/LGM.java | 2 +- org/lateralgm/main/Prefs.java | 2 ++ org/lateralgm/main/PrefsStore.java | 6 ++++++ org/lateralgm/main/Search.java | 18 ++---------------- org/lateralgm/main/preferences.properties | 2 ++ org/lateralgm/messages/messages.properties | 1 + .../messages/messages_da_DK.properties | 1 + org/lateralgm/messages/messages_fr.properties | 3 +++ .../messages/messages_tr_TR.properties | 1 + .../messages/messages_zh_CN.properties | 1 + org/lateralgm/subframes/GmObjectFrame.java | 3 +++ org/lateralgm/subframes/PreferencesFrame.java | 9 +++++++-- 12 files changed, 30 insertions(+), 19 deletions(-) diff --git a/org/lateralgm/main/LGM.java b/org/lateralgm/main/LGM.java index 21937a04b..bdd704418 100644 --- a/org/lateralgm/main/LGM.java +++ b/org/lateralgm/main/LGM.java @@ -134,7 +134,7 @@ public final class LGM { - public static final String version = "1.8.70"; //$NON-NLS-1$ + public static final String version = "1.8.71"; //$NON-NLS-1$ // TODO: This list holds the class loader for any loaded plugins which should be // cleaned up and closed when the application closes. diff --git a/org/lateralgm/main/Prefs.java b/org/lateralgm/main/Prefs.java index 3ead1f113..19c339fa9 100644 --- a/org/lateralgm/main/Prefs.java +++ b/org/lateralgm/main/Prefs.java @@ -104,6 +104,7 @@ public static void loadPrefs() communityURI = getString("communityURI","http://enigma-dev.org/forums"); issueURI = getString("issueURI","http://github.com/IsmAvatar/LateralGM/issues"); enableDragAndDrop = getBoolean("enableDragAndDrop",true); + expandEventTree = getBoolean("expandEventTree",true); rightOrientation = getBoolean("rightOrientation",false); boldPrimaryNodes = getBoolean("boldPrimaryNodes",true); actionLibraryPath = getString("actionLibraryPath","org/lateralgm/resources/library/default"); @@ -212,6 +213,7 @@ public static void createPrefixes(String pref) public static boolean boldPrimaryNodes; public static boolean rightOrientation; public static boolean enableDragAndDrop; + public static boolean expandEventTree; public static String actionLibraryPath; public static String userLibraryPath; public static int actionToolTipColumns; diff --git a/org/lateralgm/main/PrefsStore.java b/org/lateralgm/main/PrefsStore.java index e7d894ea3..ac63ee841 100644 --- a/org/lateralgm/main/PrefsStore.java +++ b/org/lateralgm/main/PrefsStore.java @@ -199,6 +199,12 @@ public static void setDNDEnabled(boolean selected) Prefs.enableDragAndDrop = selected; } + public static void setExpandEventTree(boolean selected) + { + PREFS.putBoolean("expandEventTree",selected); + Prefs.expandEventTree = selected; + } + public static void setDocumentationURI(String uri) { PREFS.put("documentationURI",uri); diff --git a/org/lateralgm/main/Search.java b/org/lateralgm/main/Search.java index f1ee5f953..2cb741a09 100644 --- a/org/lateralgm/main/Search.java +++ b/org/lateralgm/main/Search.java @@ -1470,24 +1470,10 @@ public static JTree createSearchTree() KeyStroke.getKeyStroke(Messages.getKeyboardString("TreeFilter.EXPANDALL"))); expandAllItem.addActionListener(new ActionListener() { - public void expandChildren(JTree tree, DefaultMutableTreeNode node) - { - Enumeration children = node.children(); - DefaultMutableTreeNode it = null; - while (children.hasMoreElements()) - { - it = (DefaultMutableTreeNode) children.nextElement(); - tree.expandPath(new TreePath(it.getPath())); - if (it.getChildCount() > 0) - { - expandChildren(tree,it); - } - } - } - public void actionPerformed(ActionEvent ev) { - expandChildren(tree,(DefaultMutableTreeNode) tree.getModel().getRoot()); + for (int i = 0; i < tree.getRowCount(); ++i) + tree.expandRow(i); } }); searchMenu.add(expandAllItem); diff --git a/org/lateralgm/main/preferences.properties b/org/lateralgm/main/preferences.properties index 8bb811a35..a7d50f47e 100644 --- a/org/lateralgm/main/preferences.properties +++ b/org/lateralgm/main/preferences.properties @@ -17,6 +17,8 @@ boldPrimaryNodes = true showTreeFilter = true # Whether to have edit panels and the tree on the right instead of the left rightOrientation = false +# Whether to expand all the group nodes of the object event tree by default. +expandEventTree = true # These URI's are for locating documentation, a related website for the program, and a place where # they can submit issues. It can be in the form of a local file or a web URL so long as they have diff --git a/org/lateralgm/messages/messages.properties b/org/lateralgm/messages/messages.properties index c6c67bd9a..db0e1701b 100644 --- a/org/lateralgm/messages/messages.properties +++ b/org/lateralgm/messages/messages.properties @@ -719,6 +719,7 @@ PreferencesFrame.SELECTION=Single Selection PreferencesFrame.MULTIPLE_SELECTION=Rectangular Selection PreferencesFrame.SHOW_TREE_FILTER=Show tree filter PreferencesFrame.ENABLE_DND=Enable drag and drop +PreferencesFrame.ENABLE_EXPAND_EVENTS=Expand object event tree by default PreferencesFrame.ENABLE_EXTRA_NODES=Extra hierarchy nodes PreferencesFrame.ENABLE_TREE_RESTRICT=Restrict hierarchy PreferencesFrame.ENABLE_TREE_RESTRICT_HINT=Restrict tree items to resource type groups, and add extra nodes. diff --git a/org/lateralgm/messages/messages_da_DK.properties b/org/lateralgm/messages/messages_da_DK.properties index fece48b93..f431d732d 100644 --- a/org/lateralgm/messages/messages_da_DK.properties +++ b/org/lateralgm/messages/messages_da_DK.properties @@ -406,6 +406,7 @@ PreferencesFrame.APPLY_CHANGES=Apply Changes PreferencesFrame.CLOSE=Close PreferencesFrame.APPLY_CHANGES_NOTICE=You may need to restart the program for some changes to take effect. PreferencesFrame.ENABLE_DND=Enable Drag and Drop +PreferencesFrame.ENABLE_EXPAND_EVENTS=Udvid objektbegivenhedstræ som standard PreferencesFrame.ENABLE_EXTRA_NODES=Extra Hierarchy Nodes PreferencesFrame.ENABLE_TREE_RESTRICT=Restrict Hierarchy PreferencesFrame.ENABLE_TREE_RESTRICT_HINT=Restrict tree items to resource type groups, and add extra nodes. diff --git a/org/lateralgm/messages/messages_fr.properties b/org/lateralgm/messages/messages_fr.properties index 4623dcc92..ac8df5471 100644 --- a/org/lateralgm/messages/messages_fr.properties +++ b/org/lateralgm/messages/messages_fr.properties @@ -417,6 +417,9 @@ Action.HINT_MORE = ... RevertableMDIFrame.KEEPCHANGES={0} a été modifié. Conserver les modifications? RevertableMDIFrame.KEEPCHANGES_TITLE=Conserver les modifications? +#Preferences +PreferencesFrame.ENABLE_EXPAND_EVENTS=Développer l'arborescence d'événements d'objet par défaut + #Main Strings GameSettingFrame.TITLE=Paramètres de jeu GameSettingFrame.BUTTON_SAVE=Enregistrer diff --git a/org/lateralgm/messages/messages_tr_TR.properties b/org/lateralgm/messages/messages_tr_TR.properties index c0ef7ed7a..e6a8f37f8 100644 --- a/org/lateralgm/messages/messages_tr_TR.properties +++ b/org/lateralgm/messages/messages_tr_TR.properties @@ -407,6 +407,7 @@ PreferencesFrame.APPLY_CHANGES=Apply Changes PreferencesFrame.CLOSE=Close PreferencesFrame.APPLY_CHANGES_NOTICE=You may need to restart the program for some changes to take effect. PreferencesFrame.ENABLE_DND=Enable Drag and Drop +PreferencesFrame.ENABLE_EXPAND_EVENTS=Nesne olay a\u011Fac\u0131n\u0131 varsay\u0131lan olarak geni\u015Fletin PreferencesFrame.ENABLE_EXTRA_NODES=Extra Hierarchy Nodes PreferencesFrame.ENABLE_TREE_RESTRICT=Restrict Hierarchy PreferencesFrame.ENABLE_TREE_RESTRICT_HINT=Restrict tree items to resource type groups, and add extra nodes. diff --git a/org/lateralgm/messages/messages_zh_CN.properties b/org/lateralgm/messages/messages_zh_CN.properties index eb3ddb8a5..9de207bcb 100644 --- a/org/lateralgm/messages/messages_zh_CN.properties +++ b/org/lateralgm/messages/messages_zh_CN.properties @@ -639,6 +639,7 @@ PreferencesFrame.SELECTION=\u5355\u6b21\u9009\u62e9 PreferencesFrame.MULTIPLE_SELECTION=\u77e9\u5f62\u9009\u62e9 PreferencesFrame.SHOW_TREE_FILTER=\u663e\u793a\u6811\u7b5b\u9009\u5668 PreferencesFrame.ENABLE_DND=\u542f\u7528\u62d6\u653e\u529f\u80fd +PreferencesFrame.ENABLE_EXPAND_EVENTS=\u9ED8\u8BA4\u60C5\u51B5\u4E0B\u5C55\u5F00\u5BF9\u8C61\u4E8B\u4EF6\u6811 PreferencesFrame.ENABLE_EXTRA_NODES=\u989d\u5916\u5c42\u7ea7\u8282\u70b9 PreferencesFrame.ENABLE_TREE_RESTRICT=\u9650\u5236\u5c42\u6b21\u7ed3\u6784 PreferencesFrame.ENABLE_TREE_RESTRICT_HINT=\u5c06\u6811\u9879\u9650\u5236\u4e3a\u8d44\u6e90\u7c7b\u578b\u7ec4\uff0c\u5e76\u6dfb\u52a0\u989d\u5916\u7684\u8282\u70b9\u3002 diff --git a/org/lateralgm/subframes/GmObjectFrame.java b/org/lateralgm/subframes/GmObjectFrame.java index 4cc593ec4..4e4f0756e 100644 --- a/org/lateralgm/subframes/GmObjectFrame.java +++ b/org/lateralgm/subframes/GmObjectFrame.java @@ -812,6 +812,9 @@ public void makeEventTree(GmObject res) events.addMouseListener(mListener); events.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); events.addTreeSelectionListener(this); + if (Prefs.expandEventTree) + for (int i = 0; i < events.getRowCount(); ++i) + events.expandRow(i); if (LGM.javaVersion >= 10600) { events.setDragEnabled(true); diff --git a/org/lateralgm/subframes/PreferencesFrame.java b/org/lateralgm/subframes/PreferencesFrame.java index aebdc0de4..37bd75a55 100644 --- a/org/lateralgm/subframes/PreferencesFrame.java +++ b/org/lateralgm/subframes/PreferencesFrame.java @@ -108,8 +108,8 @@ public class PreferencesFrame extends JDialog implements ActionListener JComboBox localeCombo; JComboBox themeCombo, iconCombo, actionsCombo; - JCheckBox dndEnable, restrictTreeEnable, extraNodesEnable, showTreeFilter, rightOrientation, - backupsEnable; + JCheckBox dndEnable, expandEventsEnable, restrictTreeEnable, extraNodesEnable, showTreeFilter, + rightOrientation, backupsEnable; JTextField iconPath, themePath, documentationURI, websiteURI, communityURI, issueURI, actionsPath; JTextField soundEditorPath, backgroundEditorPath, spriteEditorPath, codeEditorPath, @@ -156,6 +156,8 @@ private JPanel makeGeneralPrefs() dndEnable = new JCheckBox(Messages.getString("PreferencesFrame.ENABLE_DND")); dndEnable.setSelected(Prefs.enableDragAndDrop); + expandEventsEnable = new JCheckBox(Messages.getString("PreferencesFrame.ENABLE_EXPAND_EVENTS")); + expandEventsEnable.setSelected(Prefs.expandEventTree); restrictTreeEnable = new JCheckBox(Messages.getString("PreferencesFrame.ENABLE_TREE_RESTRICT")); restrictTreeEnable.setSelected(Prefs.restrictHierarchy); extraNodesEnable = new JCheckBox(Messages.getString("PreferencesFrame.ENABLE_EXTRA_NODES")); @@ -283,6 +285,7 @@ public int compare(Locale o1, Locale o2) /* */.addComponent(backupsPanel,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE) /* */.addGroup(gl.createParallelGroup() /* */.addComponent(dndEnable) + /* */.addComponent(expandEventsEnable) /* */.addComponent(rightOrientation) /* */.addComponent(showTreeFilter)))); @@ -311,6 +314,7 @@ public int compare(Locale o1, Locale o2) /* */.addComponent(backupsPanel) /* */.addGroup(gl.createSequentialGroup() /* */.addComponent(dndEnable) + /* */.addComponent(expandEventsEnable) /* */.addComponent(rightOrientation) /* */.addComponent(showTreeFilter)))); @@ -1203,6 +1207,7 @@ public void savePreferences() PrefsStore.setCommunityURI(communityURI.getText()); PrefsStore.setIssueURI(issueURI.getText()); PrefsStore.setDNDEnabled(dndEnable.isSelected()); + PrefsStore.setExpandEventTree(expandEventsEnable.isSelected()); PrefsStore.setExtraNodes(extraNodesEnable.isSelected()); PrefsStore.setShowTreeFilter(showTreeFilter.isSelected()); PrefsStore.setRightOrientation(rightOrientation.isSelected());