/** * Swaps the two FolderPanel instances: after a call to this method, the left FolderPanel will be * the right one and vice-versa. */ public void swapFolders() { splitPane.remove(leftFolderPanel); splitPane.remove(rightFolderPanel); // Swaps the folder panels. FolderPanel tempPanel = leftFolderPanel; leftFolderPanel = rightFolderPanel; rightFolderPanel = tempPanel; // swaps folders trees int tempTreeWidth = leftFolderPanel.getTreeWidth(); leftFolderPanel.setTreeWidth(rightFolderPanel.getTreeWidth()); rightFolderPanel.setTreeWidth(tempTreeWidth); boolean tempTreeVisible = leftFolderPanel.isTreeVisible(); leftFolderPanel.setTreeVisible(rightFolderPanel.isTreeVisible()); rightFolderPanel.setTreeVisible(tempTreeVisible); // Resets the tables. FileTable tempTable = leftTable; leftTable = rightTable; rightTable = tempTable; // Preserve the sort order and columns visibility. TableColumnModel model = leftTable.getColumnModel(); leftTable.setColumnModel(rightTable.getColumnModel()); rightTable.setColumnModel(model); SortInfo sortInfo = (SortInfo) leftTable.getSortInfo().clone(); leftTable.sortBy(rightTable.getSortInfo()); leftTable.updateColumnsVisibility(); rightTable.sortBy(sortInfo); rightTable.updateColumnsVisibility(); // Do the swap and update the split pane splitPane.setLeftComponent(leftFolderPanel); splitPane.setRightComponent(rightFolderPanel); splitPane.doLayout(); // Update split pane divider's location splitPane.updateDividerLocation(); activeTable.requestFocus(); }
/** * Specifies how folder panels are split: if true is passed, the folder panels will be split * vertically (default), horizontally otherwise. * * @param vertical if true, the folder panels will be split horizontally (default), vertically * otherwise. */ public void setSplitPaneOrientation(boolean vertical) { // Note: the vertical/horizontal terminology used in muCommander is just the opposite of the one // used // in JSplitPane which is anti-natural / confusing splitPane.setOrientation(vertical ? JSplitPane.HORIZONTAL_SPLIT : JSplitPane.VERTICAL_SPLIT); }
/** * Returns how folder panels are currently split: if <code>true</code> is returned, panels are * split vertically (default), horizontally otherwise. * * @return <code>true</code> if folder panels are split vertically */ public boolean getSplitPaneOrientation() { // Note: the vertical/horizontal terminology used in muCommander is just the opposite of the one // used // in JSplitPane which is anti-natural / confusing return splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT; }
private void init(FolderPanel leftFolderPanel, FolderPanel rightFolderPanel) { // Set the window icon setWindowIcon(); if (OsFamily.MAC_OS_X.isCurrent()) { // Lion Fullscreen support FullScreenUtilities.setWindowCanFullScreen(this, true); } // 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() { return new Insets(0, 3, 3, 3); // No top inset } }; // 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, MuConfigurations.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 intial // active table. fireActivePanelChanged(activeTable.getFolderPanel()); // Set the custom FocusTraversalPolicy that manages focus for both FolderPanel and their // subcomponents. setFocusTraversalPolicy(new CustomFocusTraversalPolicy()); }