Search in sources :

Example 1 with ConfFileTableTab

use of com.mucommander.ui.main.tabs.ConfFileTableTab in project mucommander by mucommander.

the class DefaultMainFramesBuilder method build.

@Override
public Collection<MainFrame> build() {
    int nbFrames = snapshot.getIntegerVariable(MuSnapshot.getWindowsCount());
    // if last configuration is requested and exists in the snapshot file, restore it
    if (nbFrames > 0 && MuConfigurations.getPreferences().getVariable(MuPreference.STARTUP_FOLDERS).equals(MuPreferences.STARTUP_FOLDERS_LAST)) {
        return IntStream.range(0, nbFrames).mapToObj(this::createMainFrame).collect(Collectors.toList());
    } else {
        int index = getSelectedFrame();
        MainFrame mainFrame = new MainFrame(new ConfFileTableTab(getInitialPath(FolderPanelType.LEFT)), getFileTableConfiguration(FolderPanelType.LEFT, index), new ConfFileTableTab(getInitialPath(FolderPanelType.RIGHT)), getFileTableConfiguration(FolderPanelType.RIGHT, index));
        // if there is no window saved in the snapshot file, use default settings
        if (nbFrames == 0) {
            mainFrame.setBounds(getDefaultSize());
        } else // otherwise, use the settings of the selected window
        {
            int x = snapshot.getIntegerVariable(MuSnapshot.getX(index));
            int y = snapshot.getIntegerVariable(MuSnapshot.getY(index));
            int width = snapshot.getIntegerVariable(MuSnapshot.getWidth(index));
            int height = snapshot.getIntegerVariable(MuSnapshot.getHeight(index));
            mainFrame.setBounds(new Rectangle(x, y, width, height));
        }
        return Collections.singleton(mainFrame);
    }
}
Also used : Rectangle(java.awt.Rectangle) MainFrame(com.mucommander.ui.main.MainFrame) ConfFileTableTab(com.mucommander.ui.main.tabs.ConfFileTableTab)

Example 2 with ConfFileTableTab

use of com.mucommander.ui.main.tabs.ConfFileTableTab in project mucommander by mucommander.

the class DefaultMainFramesBuilder method createMainFrame.

private MainFrame createMainFrame(int index) {
    int nbTabsInLeftPanel = snapshot.getIntegerVariable(MuSnapshot.getTabsCountVariable(index, true));
    ConfFileTableTab[] leftTabs = new ConfFileTableTab[nbTabsInLeftPanel];
    for (int i = 0; i < nbTabsInLeftPanel; ++i) leftTabs[i] = new ConfFileTableTab(snapshot.getBooleanVariable(MuSnapshot.getTabLockedVariable(index, true, i)), restoreFileURL(snapshot.getVariable(MuSnapshot.getTabLocationVariable(index, true, i))), snapshot.getVariable(MuSnapshot.getTabTitleVariable(index, true, i)));
    int nbTabsInRightPanel = snapshot.getIntegerVariable(MuSnapshot.getTabsCountVariable(index, false));
    ConfFileTableTab[] rightTabs = new ConfFileTableTab[nbTabsInRightPanel];
    for (int i = 0; i < nbTabsInRightPanel; ++i) rightTabs[i] = new ConfFileTableTab(snapshot.getBooleanVariable(MuSnapshot.getTabLockedVariable(index, false, i)), restoreFileURL(snapshot.getVariable(MuSnapshot.getTabLocationVariable(index, false, i))), snapshot.getVariable(MuSnapshot.getTabTitleVariable(index, false, i)));
    MainFrame mainFrame = new MainFrame(leftTabs, getInitialSelectedTab(FolderPanelType.LEFT, index), getFileTableConfiguration(FolderPanelType.LEFT, index), rightTabs, getInitialSelectedTab(FolderPanelType.RIGHT, index), getFileTableConfiguration(FolderPanelType.RIGHT, index));
    // Retrieve last saved window bounds
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    int x = MuSnapshot.getSnapshot().getIntegerVariable(MuSnapshot.getX(index));
    int y = MuSnapshot.getSnapshot().getIntegerVariable(MuSnapshot.getY(index));
    int width = MuSnapshot.getSnapshot().getIntegerVariable(MuSnapshot.getWidth(index));
    int height = MuSnapshot.getSnapshot().getIntegerVariable(MuSnapshot.getHeight(index));
    // Retrieves the last known size of the screen.
    int lastScreenWidth = MuSnapshot.getSnapshot().getIntegerVariable(MuSnapshot.SCREEN_WIDTH);
    int lastScreenHeight = MuSnapshot.getSnapshot().getIntegerVariable(MuSnapshot.SCREEN_HEIGHT);
    // reset the window's dimensions to their default values.
    if (x == -1 || y == -1 || width == -1 || height == -1 || screenSize.width != lastScreenWidth || screenSize.height != lastScreenHeight || width + x > screenSize.width + 5 || height + y > screenSize.height + 5) {
        // Full screen bounds are not reliable enough, in particular under Linux+Gnome
        // so we simply make the initial window 4/5 of screen's size, and center it.
        // This should fit under any window manager / platform
        x = screenSize.width / 10;
        y = screenSize.height / 10;
        width = (int) (screenSize.width * 0.8);
        height = (int) (screenSize.height * 0.8);
    }
    mainFrame.setBounds(new Rectangle(x, y, width, height));
    // Retrieve the Frame's SinglePanelView toggle state...
    if (MuSnapshot.getSnapshot().getBooleanVariable(MuSnapshot.getSinglePanelViewToggleState(index))) {
        ActionManager.performAction(ToggleUseSinglePanelAction.Descriptor.ACTION_ID, mainFrame);
    }
    return mainFrame;
}
Also used : Rectangle(java.awt.Rectangle) Dimension(java.awt.Dimension) MainFrame(com.mucommander.ui.main.MainFrame) ConfFileTableTab(com.mucommander.ui.main.tabs.ConfFileTableTab)

Example 3 with ConfFileTableTab

use of com.mucommander.ui.main.tabs.ConfFileTableTab in project mucommander by mucommander.

the class CommandLineMainFrameBuilder method build.

@Override
public Collection<MainFrame> build() {
    final List<MainFrame> mainFrames = new LinkedList<>();
    Iterator<String> iterator = folders.iterator();
    while (iterator.hasNext()) {
        int nbMainFrames = mainFrames.size();
        MainFrame newMainFrame = new MainFrame(new ConfFileTableTab(iterator.next()), getFileTableConfiguration(FolderPanelType.LEFT, nbMainFrames), new ConfFileTableTab(iterator.hasNext() ? iterator.next() : null), getFileTableConfiguration(FolderPanelType.RIGHT, nbMainFrames));
        newMainFrame.setBounds(getDefaultSize());
        mainFrames.add(newMainFrame);
    }
    return mainFrames;
}
Also used : MainFrame(com.mucommander.ui.main.MainFrame) LinkedList(java.util.LinkedList) ConfFileTableTab(com.mucommander.ui.main.tabs.ConfFileTableTab)

Aggregations

MainFrame (com.mucommander.ui.main.MainFrame)3 ConfFileTableTab (com.mucommander.ui.main.tabs.ConfFileTableTab)3 Rectangle (java.awt.Rectangle)2 Dimension (java.awt.Dimension)1 LinkedList (java.util.LinkedList)1