use of com.mucommander.ui.main.menu.MainMenuBar in project mucommander by mucommander.
the class MainFrame method init.
private void init(FolderPanel leftFolderPanel, FolderPanel rightFolderPanel) {
// Set the window icon
setWindowIcon();
DesktopManager.customizeMainFrame(this);
// Enable window resize
setResizable(true);
// The toolbar should have no inset, this is why it is left out of the insetsPane
JPanel contentPane = new JPanel(new BorderLayout());
setContentPane(contentPane);
// Initializes the folder panels and file tables.
this.leftFolderPanel = leftFolderPanel;
this.rightFolderPanel = rightFolderPanel;
leftTable = leftFolderPanel.getFileTable();
rightTable = rightFolderPanel.getFileTable();
activeTable = leftTable;
// Create the toolbar and corresponding panel wrapping it, and show it only if it hasn't been disabled in the
// preferences.
// Note: Toolbar.setVisible() has to be called no matter if Toolbar is visible or not, in order for it to be
// properly initialized
this.toolbar = new ToolBar(this);
this.toolbarPanel = ToolbarMoreButton.wrapToolBar(toolbar);
this.toolbarPanel.setVisible(MuConfigurations.getPreferences().getVariable(MuPreference.TOOLBAR_VISIBLE, MuPreferences.DEFAULT_TOOLBAR_VISIBLE));
contentPane.add(toolbarPanel, BorderLayout.NORTH);
JPanel insetsPane = new JPanel(new BorderLayout()) {
// Add an x=3,y=3 gap around content pane
@Override
public Insets getInsets() {
// No top inset
return new Insets(0, 3, 3, 3);
}
};
// Below the toolbar there is the pane with insets
contentPane.add(insetsPane, BorderLayout.CENTER);
// Listen to location change events to display the current folder in the window's title
leftFolderPanel.getLocationManager().addLocationListener(this);
rightFolderPanel.getLocationManager().addLocationListener(this);
// Create menu bar (has to be created after toolbar)
MainMenuBar menuBar = new MainMenuBar(this);
setJMenuBar(menuBar);
// Create the split pane that separates folder panels and allows to resize how much space is allocated to the
// both of them. The split orientation is loaded from and saved to the preferences.
// Note: the vertical/horizontal terminology used in muCommander is just the opposite of the one used
// in JSplitPane which is anti-natural / confusing.
splitPane = new ProportionalSplitPane(this, MuSnapshot.getSnapshot().getVariable(MuSnapshot.getSplitOrientation(0), MuSnapshot.DEFAULT_SPLIT_ORIENTATION).equals(MuSnapshot.VERTICAL_SPLIT_ORIENTATION) ? JSplitPane.HORIZONTAL_SPLIT : JSplitPane.VERTICAL_SPLIT, false, MainFrame.this.leftFolderPanel, MainFrame.this.rightFolderPanel) {
// We don't want any extra space around split pane
@Override
public Insets getInsets() {
return new Insets(0, 0, 0, 0);
}
};
// Remove any default border the split pane has
splitPane.setBorder(null);
// Adds buttons that allow to collapse and expand the split pane in both directions
splitPane.setOneTouchExpandable(true);
// Disable all the JSplitPane accessibility shortcuts that are registered by default, as some of them
// conflict with default mucommander action shortcuts (e.g. F6 and F8)
splitPane.disableAccessibilityShortcuts();
// Split pane will be given any extra space
insetsPane.add(splitPane, BorderLayout.CENTER);
// Add a 2-pixel gap between the file table and status bar
YBoxPanel southPanel = new YBoxPanel();
southPanel.addSpace(2);
// Add status bar
this.statusBar = new StatusBar(this);
southPanel.add(statusBar);
// Show command bar only if it hasn't been disabled in the preferences
this.commandBar = new CommandBar(this);
// Note: CommandBar.setVisible() has to be called no matter if CommandBar is visible or not, in order for it to be properly initialized
this.commandBar.setVisible(MuConfigurations.getPreferences().getVariable(MuPreference.COMMAND_BAR_VISIBLE, MuPreferences.DEFAULT_COMMAND_BAR_VISIBLE));
southPanel.add(commandBar);
insetsPane.add(southPanel, BorderLayout.SOUTH);
// Perform CloseAction when the user asked the window to close
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
ActionManager.performAction(CloseWindowAction.Descriptor.ACTION_ID, MainFrame.this);
}
});
ActionKeymap.registerActions(this);
// Fire table change events on registered ActivePanelListener instances, to notify of the initial active table.
fireActivePanelChanged(activeTable.getFolderPanel());
// Set the custom FocusTraversalPolicy that manages focus for both FolderPanel and their sub components.
setFocusTraversalPolicy(new CustomFocusTraversalPolicy());
}
Aggregations