add action bar to mac os as a separate component

This commit is contained in:
bancika
2020-12-01 15:40:42 +01:00
parent 9294c24684
commit b96b694e87
4 changed files with 43 additions and 12 deletions
@@ -249,25 +249,26 @@ public class MainFrame extends JFrame implements ISwingUI {
Container c = new Container();
c.setLayout(new BorderLayout());
centerPanel = new JPanel(new BorderLayout());
centerPanel = new JPanel();
centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS));
c.add(centerPanel, BorderLayout.CENTER);
topPanel = new JPanel();
topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS));
c.add(topPanel, BorderLayout.NORTH);
leftPanel = new JPanel();
leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.X_AXIS));
c.add(leftPanel, BorderLayout.WEST);
c.add(leftPanel, BorderLayout.WEST);
rightPanel = new JPanel();
rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.X_AXIS));
c.add(rightPanel, BorderLayout.EAST);
topPanel = new JPanel();
topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS));
c.add(topPanel, BorderLayout.NORTH);
bottomPanel = new JPanel();
bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS));
c.add(bottomPanel, BorderLayout.SOUTH);
rightPanel = new JPanel();
rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.X_AXIS));
c.add(rightPanel, BorderLayout.EAST);
setContentPane(c);
}
@@ -32,9 +32,12 @@ import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import org.apache.log4j.Logger;
import org.diylc.appframework.miscutils.Utils;
import org.diylc.common.BadPositionException;
import org.diylc.common.EventType;
import org.diylc.common.IComponentTransformer;
import org.diylc.common.IPlugIn;
@@ -43,6 +46,7 @@ import org.diylc.swing.images.IconLoader;
import org.diylc.lang.LangUtil;
import org.diylc.swing.ActionFactory;
import org.diylc.swing.ISwingUI;
import org.diylc.swing.plugins.canvas.CanvasPlugin;
import org.diylc.swing.plugins.help.HelpMenuPlugin;
/**
@@ -51,6 +55,8 @@ import org.diylc.swing.plugins.help.HelpMenuPlugin;
* @author Branislav Stojkovic
*/
public class ActionBarPlugin implements IPlugIn {
private static final Logger LOG = Logger.getLogger(ActionBarPlugin.class);
private IPlugInPort plugInPort;
private ISwingUI swingUI;
@@ -176,7 +182,15 @@ public class ActionBarPlugin implements IPlugIn {
@Override
public void connect(IPlugInPort plugInPort) {
this.plugInPort = plugInPort;
swingUI.injectMenuComponent(getActionPanel());
if (Utils.isMac()) {
try {
swingUI.injectGUIComponent(getActionPanel(), SwingConstants.CENTER, false);
} catch (BadPositionException e) {
LOG.error("Could not inject action bar plugin", e);
}
}
else
swingUI.injectMenuComponent(getActionPanel());
}
@Override