mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
added export trace
improved status message on selection
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
package org.diylc.gui;
|
||||
|
||||
import javax.swing.Action;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
import org.diylc.common.BadPositionException;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
|
||||
|
||||
/**
|
||||
* Base interface for the main GUI component.
|
||||
*
|
||||
@@ -38,4 +38,13 @@ public interface IView {
|
||||
* @see IPlugInPort#injectMenuAction
|
||||
*/
|
||||
void addMenuAction(Action action, String menuName);
|
||||
|
||||
/**
|
||||
* Adds a submenu to an existing menu.
|
||||
*
|
||||
* @param name
|
||||
* @param icon
|
||||
* @param parentMenuName
|
||||
*/
|
||||
void addSubmenu(String name, Icon icon, String parentMenuName);
|
||||
}
|
||||
|
||||
+19
-5
@@ -12,6 +12,7 @@ import java.util.Map;
|
||||
|
||||
import javax.swing.Action;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
@@ -177,6 +178,23 @@ public class MainFrame extends JFrame implements IView {
|
||||
|
||||
@Override
|
||||
public void addMenuAction(Action action, String menuName) {
|
||||
JMenu menu = findOrCreateMenu(menuName);
|
||||
if (action == null) {
|
||||
menu.addSeparator();
|
||||
} else {
|
||||
menu.add(action);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSubmenu(String name, Icon icon, String parentMenuName) {
|
||||
JMenu menu = findOrCreateMenu(parentMenuName);
|
||||
JMenu submenu = new JMenu(name);
|
||||
menu.add(submenu);
|
||||
menuMap.put(name, submenu);
|
||||
}
|
||||
|
||||
private JMenu findOrCreateMenu(String menuName) {
|
||||
JMenu menu;
|
||||
if (menuMap.containsKey(menuName)) {
|
||||
menu = menuMap.get(menuName);
|
||||
@@ -185,10 +203,6 @@ public class MainFrame extends JFrame implements IView {
|
||||
menuMap.put(menuName, menu);
|
||||
getMainMenuBar().add(menu);
|
||||
}
|
||||
if (action == null) {
|
||||
menu.addSeparator();
|
||||
} else {
|
||||
menu.add(action);
|
||||
}
|
||||
return menu;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user