Menu4j: Difference between revisions

From Commander4j
No edit summary
Updated by push_wiki.py
Line 1: Line 1:
=Getting Started=
Menu4j (JMenuTree) is a desktop command launcher that organises shell commands, scripts, and applications into a hierarchical tree menu. It provides a configurable, script-aware alternative to Finder shortcuts and shell aliases, with support for real-time terminal output, multiple linked menu trees, and optional startup password protection.
*[[Overview Menu4j|Overview]]
*[[User Guide|User Guide]]
*[[Downloads]]
*[[Installation Menu4j|Install]]
*[[Upgrade Menu4j|Upgrade]]
*[[Menu4j Examples|Example Screens]]


[[Category:Menu4j]]
== Purpose ==
 
Menu4j is used to organise the day-to-day development and operational commands for the Commander4j suite in a single, structured interface. Menu items can run shell scripts, open applications, pass parameters, capture output, and link to other menu tree files.
 
== Running Menu4j ==
 
Menu4j is a Java 21 desktop (Swing) application:
 
java -jar JMenu.jar
 
On first launch, if no configuration file is found, Menu4j copies a template configuration from <code>xml/config/init/config.xml</code> and a template menu tree from <code>xml/tree/init/tree.xml</code>.
 
If a startup password has been configured, you are prompted to enter it before the menu is shown. Three failed attempts close the application.
 
== The Menu Tree ==
 
The main window displays a JTree. There are two node types:
 
{| class="wikitable"
|-
! Type !! Purpose
|-
| Branch || A folder that contains other branches or leaves
|-
| Leaf || An executable item — a command, script, or application
|}
 
Double-click a leaf to execute it. Double-click a branch to expand or collapse it.
 
=== Adding and Editing Items ===
 
The right sidebar toolbar provides:
 
* '''Add''' — insert a new branch or leaf under the selected node
* '''Edit''' — open the editor for the selected node
* '''Delete''' — remove the selected node
* '''Duplicate''' — copy the selected node
 
=== Leaf Properties ===
 
When editing a leaf node, the following properties are available:
 
{| class="wikitable"
|-
! Property !! Description
|-
| Description || The label shown in the menu tree
|-
| Directory || The working directory for the command
|-
| Command || The executable or system command to run
|-
| Parameters || A list of arguments to pass to the command
|-
| Shell Script Required || Whether to wrap the command in the configured shell wrapper script
|-
| Terminal Window Required || Whether to open a terminal output window to show command output
|-
| Confirm Execute || Whether to show a confirmation prompt before running
|-
| Link to Menu Tree || Whether this item opens a different tree file instead of running a command
|-
| Hint || A tooltip shown when hovering over the item
|-
| Icon || An image file to display next to the item label
|}
 
== Executing Commands ==
 
When a leaf is executed:
 
# Menu4j validates that the directory and command exist
# If '''Shell Script Required''' is set, the command is wrapped using the script configured in Settings (typically a shell wrapper that sources the user's environment)
# If '''Terminal Window Required''' is set, a terminal output window opens and displays stdout and stderr in real time; otherwise the command runs silently in the background
# Environment variables configured in Settings are injected before execution
 
=== Terminal Output Window ===
 
The terminal window displays command output with configurable foreground and background colours and font (configured in Settings). A '''Respond''' button allows text to be sent to the command's standard input for interactive commands. When the command completes, the return code is displayed.
 
== Multiple Tree Files ==
 
A leaf node can be configured to switch to a different menu tree rather than execute a command. Set '''Link to Menu Tree''' and specify the filename. Double-clicking the leaf saves the current tree's expansion state and loads the linked tree. The application title bar updates to show the active tree filename.
 
== Configuration ==
 
=== config.xml ===
 
Located at <code>xml/config/config.xml</code>. This file stores global settings including the active tree filename, shell script settings, colours, fonts, environment variables, system command whitelist, and the encrypted startup password.
 
=== tree.xml ===
 
Located at <code>xml/tree/tree.xml</code> (or a different filename if you have switched trees). This is the menu structure file. It is written automatically when you save from the application.
 
=== tree.xml.state ===
 
Located alongside the tree file. Records which branches were expanded on the last exit and restores them on next launch.
 
== Settings ==
 
Open Settings from the toolbar to configure:
 
{| class="wikitable"
|-
! Setting !! Description
|-
| Password || Optional startup password (stored AES-encrypted)
|-
| Shell script || Enable/disable the shell wrapper and set the script filename
|-
| Terminal colours || Foreground and background colours for the terminal output window
|-
| Tree colours || Foreground colours for leaf and branch labels
|-
| Fonts || Font choice and size for the terminal window, leaf labels, and branch labels
|-
| Environment variables || Key/value pairs injected into every executed process
|-
| System commands || Whitelist of system commands (such as <code>open</code>) that do not require a file path to be validated
|}
 
== Tree Navigation ==
 
The top toolbar provides four buttons for expanding and collapsing the tree:
 
* Expand All
* Expand Selected Branch
* Collapse Selected Branch
* Collapse All
 
== Saving ==
 
Changes to the tree structure are saved using the '''Save''' button in the sidebar toolbar. You are prompted to save if you close the application with unsaved changes.
 
See also: [[LaunchPad]], [[Downloads]]
 
[[Category:Commander4j]]

Revision as of 13:29, 1 April 2026

Menu4j (JMenuTree) is a desktop command launcher that organises shell commands, scripts, and applications into a hierarchical tree menu. It provides a configurable, script-aware alternative to Finder shortcuts and shell aliases, with support for real-time terminal output, multiple linked menu trees, and optional startup password protection.

Purpose

Menu4j is used to organise the day-to-day development and operational commands for the Commander4j suite in a single, structured interface. Menu items can run shell scripts, open applications, pass parameters, capture output, and link to other menu tree files.

Running Menu4j

Menu4j is a Java 21 desktop (Swing) application:

java -jar JMenu.jar

On first launch, if no configuration file is found, Menu4j copies a template configuration from xml/config/init/config.xml and a template menu tree from xml/tree/init/tree.xml.

If a startup password has been configured, you are prompted to enter it before the menu is shown. Three failed attempts close the application.

The Menu Tree

The main window displays a JTree. There are two node types:

Type Purpose
Branch A folder that contains other branches or leaves
Leaf An executable item — a command, script, or application

Double-click a leaf to execute it. Double-click a branch to expand or collapse it.

Adding and Editing Items

The right sidebar toolbar provides:

  • Add — insert a new branch or leaf under the selected node
  • Edit — open the editor for the selected node
  • Delete — remove the selected node
  • Duplicate — copy the selected node

Leaf Properties

When editing a leaf node, the following properties are available:

Property Description
Description The label shown in the menu tree
Directory The working directory for the command
Command The executable or system command to run
Parameters A list of arguments to pass to the command
Shell Script Required Whether to wrap the command in the configured shell wrapper script
Terminal Window Required Whether to open a terminal output window to show command output
Confirm Execute Whether to show a confirmation prompt before running
Link to Menu Tree Whether this item opens a different tree file instead of running a command
Hint A tooltip shown when hovering over the item
Icon An image file to display next to the item label

Executing Commands

When a leaf is executed:

  1. Menu4j validates that the directory and command exist
  2. If Shell Script Required is set, the command is wrapped using the script configured in Settings (typically a shell wrapper that sources the user's environment)
  3. If Terminal Window Required is set, a terminal output window opens and displays stdout and stderr in real time; otherwise the command runs silently in the background
  4. Environment variables configured in Settings are injected before execution

Terminal Output Window

The terminal window displays command output with configurable foreground and background colours and font (configured in Settings). A Respond button allows text to be sent to the command's standard input for interactive commands. When the command completes, the return code is displayed.

Multiple Tree Files

A leaf node can be configured to switch to a different menu tree rather than execute a command. Set Link to Menu Tree and specify the filename. Double-clicking the leaf saves the current tree's expansion state and loads the linked tree. The application title bar updates to show the active tree filename.

Configuration

config.xml

Located at xml/config/config.xml. This file stores global settings including the active tree filename, shell script settings, colours, fonts, environment variables, system command whitelist, and the encrypted startup password.

tree.xml

Located at xml/tree/tree.xml (or a different filename if you have switched trees). This is the menu structure file. It is written automatically when you save from the application.

tree.xml.state

Located alongside the tree file. Records which branches were expanded on the last exit and restores them on next launch.

Settings

Open Settings from the toolbar to configure:

Setting Description
Password Optional startup password (stored AES-encrypted)
Shell script Enable/disable the shell wrapper and set the script filename
Terminal colours Foreground and background colours for the terminal output window
Tree colours Foreground colours for leaf and branch labels
Fonts Font choice and size for the terminal window, leaf labels, and branch labels
Environment variables Key/value pairs injected into every executed process
System commands Whitelist of system commands (such as open) that do not require a file path to be validated

Tree Navigation

The top toolbar provides four buttons for expanding and collapsing the tree:

  • Expand All
  • Expand Selected Branch
  • Collapse Selected Branch
  • Collapse All

Saving

Changes to the tree structure are saved using the Save button in the sidebar toolbar. You are prompted to save if you close the application with unsaved changes.

See also: LaunchPad, Downloads