Skip to content

Commit

Permalink
Expand Event Tree Preference (#432)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RobertBColton authored May 21, 2019
1 parent 9d27aa6 commit 4d7cb48
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 19 deletions.
2 changes: 1 addition & 1 deletion org/lateralgm/main/LGM.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions org/lateralgm/main/Prefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions org/lateralgm/main/PrefsStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 2 additions & 16 deletions org/lateralgm/main/Search.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions org/lateralgm/main/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions org/lateralgm/messages/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions org/lateralgm/messages/messages_da_DK.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions org/lateralgm/messages/messages_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,9 @@ Action.HINT_MORE = ... <Plus>
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
Expand Down
1 change: 1 addition & 0 deletions org/lateralgm/messages/messages_tr_TR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions org/lateralgm/messages/messages_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions org/lateralgm/subframes/GmObjectFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 7 additions & 2 deletions org/lateralgm/subframes/PreferencesFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ public class PreferencesFrame extends JDialog implements ActionListener

JComboBox<Locale> localeCombo;
JComboBox<String> 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,
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -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))));

Expand Down Expand Up @@ -311,6 +314,7 @@ public int compare(Locale o1, Locale o2)
/* */.addComponent(backupsPanel)
/* */.addGroup(gl.createSequentialGroup()
/* */.addComponent(dndEnable)
/* */.addComponent(expandEventsEnable)
/* */.addComponent(rightOrientation)
/* */.addComponent(showTreeFilter))));

Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 4d7cb48

Please sign in to comment.