Пример #1
0
  private static void configureFilesystems() {
    // Configure the SMB subsystem (backed by jCIFS) to maintain compatibility with SMB servers that
    // don't support
    // NTLM v2 authentication such as Samba 3.0.x, which still is widely used and comes
    // pre-installed on
    // Mac OS X Leopard.
    // Since jCIFS 1.3.0, the default is to use NTLM v2 authentication and extended security.
    SMBProtocolProvider.setLmCompatibility(
        MuConfigurations.getPreferences()
            .getVariable(
                MuPreference.SMB_LM_COMPATIBILITY, MuPreferences.DEFAULT_SMB_LM_COMPATIBILITY));
    SMBProtocolProvider.setExtendedSecurity(
        MuConfigurations.getPreferences()
            .getVariable(
                MuPreference.SMB_USE_EXTENDED_SECURITY,
                MuPreferences.DEFAULT_SMB_USE_EXTENDED_SECURITY));

    // Use the FTP configuration option that controls whether to force the display of hidden files,
    // or leave it for
    // the servers to decide whether to show them.
    FTPProtocolProvider.setForceHiddenFilesListing(
        MuConfigurations.getPreferences()
            .getVariable(MuPreference.LIST_HIDDEN_FILES, MuPreferences.DEFAULT_LIST_HIDDEN_FILES));

    // Use CredentialsManager for file URL authentication
    FileFactory.setDefaultAuthenticator(CredentialsManager.getAuthenticator());

    // Register the application-specific 'bookmark' protocol.
    FileFactory.registerProtocol(
        BookmarkProtocolProvider.BOOKMARK,
        new com.mucommander.bookmark.file.BookmarkProtocolProvider());
  }
Пример #2
0
 ///////////////////////
 // PrefPanel methods //
 ///////////////////////
 @Override
 protected void commit() {
   MuConfigurations.getPreferences()
       .setVariable(MuPreference.MAIL_SENDER_NAME, nameField.getText());
   MuConfigurations.getPreferences()
       .setVariable(MuPreference.MAIL_SENDER_ADDRESS, emailField.getText());
   MuConfigurations.getPreferences().setVariable(MuPreference.SMTP_SERVER, smtpField.getText());
   MuConfigurations.getPreferences().setVariable(MuPreference.SMTP_PORT, portField.getText());
 }
Пример #3
0
 public boolean hasChanged() {
   return isLeft
       ? !getText()
           .equals(
               MuConfigurations.getPreferences().getVariable(MuPreference.LEFT_CUSTOM_FOLDER))
       : !getText()
           .equals(
               MuConfigurations.getPreferences().getVariable(MuPreference.RIGHT_CUSTOM_FOLDER));
 }
Пример #4
0
    public PrefFilePathFieldWithDefaultValue(boolean isLeft) {
      super(
          isLeft
              ? MuConfigurations.getPreferences().getVariable(MuPreference.LEFT_CUSTOM_FOLDER, "")
              : MuConfigurations.getPreferences()
                  .getVariable(MuPreference.RIGHT_CUSTOM_FOLDER, ""));
      this.isLeft = isLeft;

      //    		setUI(new HintTextFieldUI(HOME_FOLDER_PATH, true));
    }
Пример #5
0
  /**
   * Method used to migrate commands that used to be defined in the configuration but were moved to
   * <code>commands.xml</code>.
   *
   * @param useName name of the <code>use custom command</code> configuration variable.
   * @param commandName name of the <code>custom command</code> configuration variable.
   */
  private static void migrateCommand(String useName, String commandName, String alias) {
    String command;

    if (MuConfigurations.getPreferences().getBooleanVariable(useName)
        && (command = MuConfigurations.getPreferences().getVariable(commandName)) != null) {
      try {
        CommandManager.registerCommand(new Command(alias, command, CommandType.SYSTEM_COMMAND));
      } catch (CommandException e) {
        // Ignore this: the command didn't work in the first place, we might as well get rid of it.
      }
      MuConfigurations.getPreferences().removeVariable(useName);
      MuConfigurations.getPreferences().removeVariable(commandName);
    }
  }
Пример #6
0
 // - ActionListener code -------------------------------------------------------------
 // -----------------------------------------------------------------------------------
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == themeComboBox)
     ThemeManager.setCurrentTheme((Theme) themeComboBox.getSelectedItem());
   else if (e.getSource() == lfComboBox)
     MuConfigurations.getPreferences()
         .setVariable(
             MuPreference.LOOK_AND_FEEL, lfInfo[lfComboBox.getSelectedIndex()].getClassName());
   else if (e.getSource() == okButton) {
     ThemeManager.setCurrentTheme((Theme) themeComboBox.getSelectedItem());
     MuConfigurations.getPreferences()
         .setVariable(
             MuPreference.LOOK_AND_FEEL, lfInfo[lfComboBox.getSelectedIndex()].getClassName());
     dispose();
   }
 }
  @Override
  public void performAction() {
    boolean enabled;

    mainFrame.setAutoSizeColumnsEnabled(enabled = !mainFrame.isAutoSizeColumnsEnabled());
    MuConfigurations.getPreferences().setVariable(MuPreference.AUTO_SIZE_COLUMNS, enabled);
  }
 public ToggleCommandBarAction(MainFrame mainFrame, Map<String, Object> properties) {
   super(mainFrame, properties);
   updateLabel(
       MuConfigurations.getPreferences()
           .getVariable(
               MuPreference.COMMAND_BAR_VISIBLE, MuPreferences.DEFAULT_COMMAND_BAR_VISIBLE));
 }
  private void configureFilters() {
    // Filters out hidden files, null when 'show hidden files' option is enabled
    if (!MuConfigurations.getPreferences()
        .getVariable(MuPreference.SHOW_HIDDEN_FILES, MuPreferences.DEFAULT_SHOW_HIDDEN_FILES)) {
      // This filter is inverted and matches non-hidden files
      addFileFilter(hiddenFileFilter);
    }

    // Filters out Mac OS X .DS_Store files, null when 'show DS_Store files' option is enabled
    if (!MuConfigurations.getPreferences()
        .getVariable(MuPreference.SHOW_DS_STORE_FILES, MuPreferences.DEFAULT_SHOW_DS_STORE_FILES))
      addFileFilter(dsFileFilter);

    /** Filters out Mac OS X system folders, null when 'show system folders' option is enabled */
    if (!MuConfigurations.getPreferences()
        .getVariable(MuPreference.SHOW_SYSTEM_FOLDERS, MuPreferences.DEFAULT_SHOW_SYSTEM_FOLDERS))
      addFileFilter(systemFileFilter);
  }
  static {
    instances = new Vector<>();

    // Retrieve configuration values
    checkPeriod =
        MuConfigurations.getPreferences()
            .getVariable(
                MuPreference.REFRESH_CHECK_PERIOD, MuPreferences.DEFAULT_REFRESH_CHECK_PERIOD);
    waitAfterRefresh =
        MuConfigurations.getPreferences()
            .getVariable(MuPreference.WAIT_AFTER_REFRESH, MuPreferences.DEFAULT_WAIT_AFTER_REFRESH);

    disableAutoRefreshFilter.addFileFilter(
        new AbstractFileFilter() {
          public boolean accept(AbstractFile file) {
            return file.getURL().getScheme().equals(FileProtocols.S3);
          }
        });
  }
Пример #11
0
  @Override
  protected void commit() {
    MuConfigurations.getPreferences()
        .setVariable(
            MuPreference.STARTUP_FOLDERS,
            lastFoldersRadioButton.isSelected()
                ? MuPreferences.STARTUP_FOLDERS_LAST
                : MuPreferences.STARTUP_FOLDERS_CUSTOM);

    MuConfigurations.getPreferences()
        .setVariable(MuPreference.LEFT_CUSTOM_FOLDER, leftCustomFolderTextField.getFilePath());

    MuConfigurations.getPreferences()
        .setVariable(MuPreference.RIGHT_CUSTOM_FOLDER, rightCustomFolderTextField.getFilePath());

    MuConfigurations.getPreferences()
        .setVariable(MuPreference.DISPLAY_COMPACT_FILE_SIZE, compactSizeCheckBox.isSelected());

    MuConfigurations.getPreferences()
        .setVariable(MuPreference.CD_FOLLOWS_SYMLINKS, followSymlinksCheckBox.isSelected());

    MuConfigurations.getPreferences()
        .setVariable(MuPreference.SHOW_TAB_HEADER, showTabHeaderCheckBox.isSelected());

    // If one of the show/hide file filters have changed, refresh current folders of current
    // MainFrame
    boolean refreshFolders =
        MuConfigurations.getPreferences()
            .setVariable(MuPreference.SHOW_HIDDEN_FILES, showHiddenFilesCheckBox.isSelected());

    if (OsFamily.MAC_OS_X.isCurrent()) {
      refreshFolders |=
          MuConfigurations.getPreferences()
              .setVariable(MuPreference.SHOW_DS_STORE_FILES, showDSStoreFilesCheckBox.isSelected());
    }

    if (OsFamily.MAC_OS_X.isCurrent() || OsFamily.WINDOWS.isCurrent()) {
      refreshFolders |=
          MuConfigurations.getPreferences()
              .setVariable(
                  MuPreference.SHOW_SYSTEM_FOLDERS, showSystemFoldersCheckBox.isSelected());
    }

    if (refreshFolders) WindowManager.tryRefreshCurrentFolders();
  }
 @Override
 public void performAction() {
   CommandBar commandBar = mainFrame.getCommandBar();
   boolean visible = !commandBar.isVisible();
   // Save the last command bar visible state in the configuration, this will become the default
   // for new MainFrame windows.
   MuConfigurations.getPreferences().setVariable(MuPreference.COMMAND_BAR_VISIBLE, visible);
   // Change the label to reflect the new command bar state
   updateLabel(visible);
   // Show/hide the command bar
   commandBar.setVisible(visible);
   mainFrame.validate();
 }
Пример #13
0
  /**
   * Creates a new main frame set to the given initial folders.
   *
   * @param leftInitialFolders the initial folders to display in the left panel's tabs
   * @param rightInitialFolders the initial folders to display in the right panel's tabs
   */
  public MainFrame(
      ConfFileTableTab[] leftTabs,
      int indexOfLeftSelectedTab,
      FileTableConfiguration leftTableConf,
      ConfFileTableTab[] rightTabs,
      int indexOfRightSelectedTab,
      FileTableConfiguration rightTableConf) {
    /*AbstractFile[] leftInitialFolders, AbstractFile[] rightInitialFolders,
    int indexOfLeftSelectedTab, int indexOfRightSelectedTab,
       FileURL[] leftLocationHistory, FileURL[] rightLocationHistory) { */
    init(
        new FolderPanel(this, leftTabs, indexOfLeftSelectedTab, leftTableConf),
        new FolderPanel(this, rightTabs, indexOfRightSelectedTab, rightTableConf));

    for (boolean isLeft = true; ; isLeft = false) {
      FileTable fileTable = isLeft ? leftTable : rightTable;
      fileTable.sortBy(
          Column.valueOf(
              MuConfigurations.getSnapshot()
                  .getVariable(
                      MuSnapshot.getFileTableSortByVariable(0, isLeft), MuSnapshot.DEFAULT_SORT_BY)
                  .toUpperCase()),
          !MuConfigurations.getSnapshot()
              .getVariable(
                  MuSnapshot.getFileTableSortOrderVariable(0, isLeft),
                  MuSnapshot.DEFAULT_SORT_ORDER)
              .equals(MuSnapshot.SORT_ORDER_DESCENDING));

      FolderPanel folderPanel = isLeft ? leftFolderPanel : rightFolderPanel;
      folderPanel.setTreeWidth(
          MuConfigurations.getSnapshot()
              .getVariable(MuSnapshot.getTreeWidthVariable(0, isLeft), 150));
      folderPanel.setTreeVisible(
          MuConfigurations.getSnapshot()
              .getVariable(MuSnapshot.getTreeVisiblityVariable(0, isLeft), false));

      if (!isLeft) break;
    }
  }
Пример #14
0
  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());
  }
 public ConfigurableFolderFilter() {
   configureFilters();
   MuConfigurations.addPreferencesListener(this);
 }
Пример #16
0
  public MailPanel(PreferencesDialog parent) {
    super(parent, Translator.get("prefs_dialog.mail_tab"));

    setLayout(new BorderLayout());

    YBoxPanel mainPanel = new YBoxPanel(5);
    mainPanel.setBorder(
        BorderFactory.createTitledBorder(Translator.get("prefs_dialog.mail_settings")));

    // Text fields panel
    XAlignedComponentPanel compPanel = new XAlignedComponentPanel();

    // Name field
    nameField =
        new PrefTextField(
            MuConfigurations.getPreferences().getVariable(MuPreference.MAIL_SENDER_NAME, "")) {
          public boolean hasChanged() {
            return !nameField
                .getText()
                .equals(
                    MuConfigurations.getPreferences()
                        .getVariable(MuPreference.MAIL_SENDER_NAME, ""));
          }
        };
    compPanel.addRow(Translator.get("prefs_dialog.mail_name"), nameField, 10);

    // Email field
    emailField =
        new PrefTextField(
            MuConfigurations.getPreferences().getVariable(MuPreference.MAIL_SENDER_ADDRESS, "")) {
          public boolean hasChanged() {
            return !emailField
                .getText()
                .equals(
                    MuConfigurations.getPreferences()
                        .getVariable(MuPreference.MAIL_SENDER_ADDRESS, ""));
          }
        };
    compPanel.addRow(Translator.get("prefs_dialog.mail_address"), emailField, 10);

    // SMTP field
    smtpField =
        new PrefTextField(
            MuConfigurations.getPreferences().getVariable(MuPreference.SMTP_SERVER, "")) {
          public boolean hasChanged() {
            return !smtpField
                .getText()
                .equals(
                    MuConfigurations.getPreferences().getVariable(MuPreference.SMTP_SERVER, ""));
          }
        };
    compPanel.addRow(Translator.get("prefs_dialog.mail_server"), smtpField, 10);

    // SMTP port field
    portField =
        new PrefTextField(
            ""
                + MuConfigurations.getPreferences()
                    .getVariable(MuPreference.SMTP_PORT, MuPreferences.DEFAULT_SMTP_PORT)) {
          public boolean hasChanged() {
            return !portField
                .getText()
                .equals(
                    String.valueOf(
                        MuConfigurations.getPreferences()
                            .getVariable(MuPreference.SMTP_PORT, MuPreferences.DEFAULT_SMTP_PORT)));
          }
        };
    compPanel.addRow(Translator.get("server_connect_dialog.port"), portField, 10);

    mainPanel.add(compPanel, BorderLayout.NORTH);
    add(mainPanel, BorderLayout.NORTH);

    nameField.addDialogListener(parent);
    emailField.addDialogListener(parent);
    smtpField.addDialogListener(parent);
    portField.addDialogListener(parent);
  }
Пример #17
0
  public FoldersPanel(PreferencesDialog parent) {
    super(parent, Translator.get("prefs_dialog.folders_tab"));

    setLayout(new BorderLayout());

    // Startup folders panel
    YBoxPanel startupFolderPanel = new YBoxPanel();
    startupFolderPanel.setBorder(
        BorderFactory.createTitledBorder(Translator.get("prefs_dialog.startup_folders")));

    // Last folders or custom folders selections
    lastFoldersRadioButton =
        new PrefRadioButton(Translator.get("prefs_dialog.last_folder")) {
          public boolean hasChanged() {
            return !(isSelected()
                    ? MuPreferences.STARTUP_FOLDERS_LAST
                    : MuPreferences.STARTUP_FOLDERS_CUSTOM)
                .equals(
                    MuConfigurations.getPreferences().getVariable(MuPreference.STARTUP_FOLDERS));
          }
        };
    customFoldersRadioButton =
        new PrefRadioButton(Translator.get("prefs_dialog.custom_folder")) {
          public boolean hasChanged() {
            return !(isSelected()
                    ? MuPreferences.STARTUP_FOLDERS_CUSTOM
                    : MuPreferences.STARTUP_FOLDERS_LAST)
                .equals(
                    MuConfigurations.getPreferences().getVariable(MuPreference.STARTUP_FOLDERS));
          }
        };
    startupFolderPanel.add(lastFoldersRadioButton);
    startupFolderPanel.addSpace(5);
    startupFolderPanel.add(customFoldersRadioButton);

    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(lastFoldersRadioButton);
    buttonGroup.add(customFoldersRadioButton);

    customFoldersRadioButton.addItemListener(this);

    // Custom folders specification
    JLabel leftFolderLabel = new JLabel(Translator.get("prefs_dialog.left_folder"));
    leftFolderLabel.setAlignmentX(LEFT_ALIGNMENT);

    JLabel rightFolderLabel = new JLabel(Translator.get("prefs_dialog.right_folder"));
    rightFolderLabel.setAlignmentX(LEFT_ALIGNMENT);

    // Panel that contains the text field and button for specifying custom left folder
    XBoxPanel leftCustomFolderSpecifyingPanel = new XBoxPanel(5);
    leftCustomFolderSpecifyingPanel.setAlignmentX(LEFT_ALIGNMENT);

    // Create a path field with auto-completion capabilities
    leftCustomFolderTextField = new PrefFilePathFieldWithDefaultValue(true);
    leftCustomFolderTextField.addKeyListener(this);
    leftCustomFolderSpecifyingPanel.add(leftCustomFolderTextField);

    leftCustomFolderButton = new JButton("...");
    leftCustomFolderButton.addActionListener(this);
    leftCustomFolderSpecifyingPanel.add(leftCustomFolderButton);

    // Panel that contains the text field and button for specifying custom right folder
    XBoxPanel rightCustomFolderSpecifyingPanel = new XBoxPanel(5);
    rightCustomFolderSpecifyingPanel.setAlignmentX(LEFT_ALIGNMENT);

    // Create a path field with auto-completion capabilities
    rightCustomFolderTextField = new PrefFilePathFieldWithDefaultValue(false);
    rightCustomFolderTextField.addKeyListener(this);
    rightCustomFolderSpecifyingPanel.add(rightCustomFolderTextField);

    rightCustomFolderButton = new JButton("...");
    rightCustomFolderButton.addActionListener(this);
    rightCustomFolderSpecifyingPanel.add(rightCustomFolderButton);

    JPanel container = new JPanel(new SpringLayout());
    container.add(leftFolderLabel);
    container.add(leftCustomFolderSpecifyingPanel);
    container.add(rightFolderLabel);
    container.add(rightCustomFolderSpecifyingPanel);

    // Lay out the panel.
    SpringUtilities.makeCompactGrid(
        container, 2, 2, // rows, cols
        20, 6, // initX, initY
        6, 6); // xPad, yPad

    startupFolderPanel.add(container);

    if (MuConfigurations.getPreferences()
        .getVariable(MuPreference.STARTUP_FOLDERS, "")
        .equals(MuPreferences.STARTUP_FOLDERS_LAST)) {
      lastFoldersRadioButton.setSelected(true);
      setCustomFolderComponentsEnabled(false);
    } else customFoldersRadioButton.setSelected(true);

    // --------------------------------------------------------------------------------------------------------------

    YBoxPanel northPanel = new YBoxPanel();
    northPanel.add(startupFolderPanel);
    northPanel.addSpace(5);

    showHiddenFilesCheckBox =
        new PrefCheckBox(Translator.get("prefs_dialog.show_hidden_files")) {
          public boolean hasChanged() {
            return isSelected()
                != MuConfigurations.getPreferences()
                    .getVariable(
                        MuPreference.SHOW_HIDDEN_FILES, MuPreferences.DEFAULT_SHOW_HIDDEN_FILES);
          }
        };
    showHiddenFilesCheckBox.setSelected(
        MuConfigurations.getPreferences()
            .getVariable(MuPreference.SHOW_HIDDEN_FILES, MuPreferences.DEFAULT_SHOW_HIDDEN_FILES));
    northPanel.add(showHiddenFilesCheckBox);

    // Mac OS X-only options
    if (OsFamily.MAC_OS_X.isCurrent()) {
      // Monitor showHiddenFilesCheckBox state to disable 'show .DS_Store files' option
      // when 'Show hidden files' is disabled, as .DS_Store files are hidden files
      showHiddenFilesCheckBox.addItemListener(this);

      showDSStoreFilesCheckBox =
          new PrefCheckBox(Translator.get("prefs_dialog.show_ds_store_files")) {
            public boolean hasChanged() {
              return isSelected()
                  != MuConfigurations.getPreferences()
                      .getVariable(
                          MuPreference.SHOW_DS_STORE_FILES,
                          MuPreferences.DEFAULT_SHOW_DS_STORE_FILES);
            }
          };
      showDSStoreFilesCheckBox.setSelected(
          MuConfigurations.getPreferences()
              .getVariable(
                  MuPreference.SHOW_DS_STORE_FILES, MuPreferences.DEFAULT_SHOW_DS_STORE_FILES));
      showDSStoreFilesCheckBox.setEnabled(showHiddenFilesCheckBox.isSelected());
      // Shift the check box to the right to indicate that it is a sub-option
      northPanel.add(showDSStoreFilesCheckBox, 20);
    }

    if (OsFamily.MAC_OS_X.isCurrent() || OsFamily.WINDOWS.isCurrent()) {
      showSystemFoldersCheckBox =
          new PrefCheckBox(Translator.get("prefs_dialog.show_system_folders")) {
            public boolean hasChanged() {
              return isSelected()
                  != MuConfigurations.getPreferences()
                      .getVariable(
                          MuPreference.SHOW_SYSTEM_FOLDERS,
                          MuPreferences.DEFAULT_SHOW_SYSTEM_FOLDERS);
            }
          };
      showSystemFoldersCheckBox.setSelected(
          MuConfigurations.getPreferences()
              .getVariable(
                  MuPreference.SHOW_SYSTEM_FOLDERS, MuPreferences.DEFAULT_SHOW_SYSTEM_FOLDERS));
      northPanel.add(showSystemFoldersCheckBox);
    }

    compactSizeCheckBox =
        new PrefCheckBox(Translator.get("prefs_dialog.compact_file_size")) {
          public boolean hasChanged() {
            return isSelected()
                != MuConfigurations.getPreferences()
                    .getVariable(
                        MuPreference.DISPLAY_COMPACT_FILE_SIZE,
                        MuPreferences.DEFAULT_DISPLAY_COMPACT_FILE_SIZE);
          }
        };
    compactSizeCheckBox.setSelected(
        MuConfigurations.getPreferences()
            .getVariable(
                MuPreference.DISPLAY_COMPACT_FILE_SIZE,
                MuPreferences.DEFAULT_DISPLAY_COMPACT_FILE_SIZE));
    northPanel.add(compactSizeCheckBox);

    followSymlinksCheckBox =
        new PrefCheckBox(Translator.get("prefs_dialog.follow_symlinks_when_cd")) {
          public boolean hasChanged() {
            return isSelected()
                != MuConfigurations.getPreferences()
                    .getVariable(
                        MuPreference.CD_FOLLOWS_SYMLINKS,
                        MuPreferences.DEFAULT_CD_FOLLOWS_SYMLINKS);
          }
        };
    followSymlinksCheckBox.setSelected(
        MuConfigurations.getPreferences()
            .getVariable(
                MuPreference.CD_FOLLOWS_SYMLINKS, MuPreferences.DEFAULT_CD_FOLLOWS_SYMLINKS));
    northPanel.add(followSymlinksCheckBox);

    showTabHeaderCheckBox =
        new PrefCheckBox(Translator.get("prefs_dialog.show_tab_header")) {
          public boolean hasChanged() {
            return isSelected()
                != MuConfigurations.getPreferences()
                    .getVariable(
                        MuPreference.SHOW_TAB_HEADER, MuPreferences.DEFAULT_SHOW_TAB_HEADER);
          }
        };
    showTabHeaderCheckBox.setSelected(
        MuConfigurations.getPreferences()
            .getVariable(MuPreference.SHOW_TAB_HEADER, MuPreferences.DEFAULT_SHOW_TAB_HEADER));
    northPanel.add(showTabHeaderCheckBox);

    add(northPanel, BorderLayout.NORTH);

    lastFoldersRadioButton.addDialogListener(parent);
    customFoldersRadioButton.addDialogListener(parent);
    rightCustomFolderTextField.addDialogListener(parent);
    leftCustomFolderTextField.addDialogListener(parent);
    showHiddenFilesCheckBox.addDialogListener(parent);
    compactSizeCheckBox.addDialogListener(parent);
    followSymlinksCheckBox.addDialogListener(parent);
    showTabHeaderCheckBox.addDialogListener(parent);
    if (OsFamily.MAC_OS_X.isCurrent()) {
      showDSStoreFilesCheckBox.addDialogListener(parent);
    }
    if (OsFamily.MAC_OS_X.isCurrent() || OsFamily.WINDOWS.isCurrent()) {
      showSystemFoldersCheckBox.addDialogListener(parent);
    }
  }
Пример #18
0
  /**
   * Main method used to startup muCommander.
   *
   * @param args command line arguments.
   * @throws IOException if an unrecoverable error occurred during startup
   */
  public static void main(String args[]) throws IOException {
    try {
      int i; // Index in the command line arguments.

      // Initialises fields.
      // Whether or not to ignore warnings when booting.
      boolean fatalWarnings = false;
      verbose = true;

      // - Command line parsing -------------------------------------
      // ------------------------------------------------------------
      for (i = 0; i < args.length; i++) {
        // Print version.
        if (args[i].equals("-v") || args[i].equals("--version")) printVersion();

        // Print help.
        else if (args[i].equals("-h") || args[i].equals("--help")) printUsage();

        // Associations handling.
        else if (args[i].equals("-a") || args[i].equals("--assoc")) {
          if (i >= args.length - 1) printError("Missing FILE parameter to " + args[i], null, true);
          try {
            com.mucommander.command.CommandManager.setAssociationFile(args[++i]);
          } catch (Exception e) {
            printError("Could not set association files", e, fatalWarnings);
          }
        }

        // Custom commands handling.
        else if (args[i].equals("-f") || args[i].equals("--commands")) {
          if (i >= args.length - 1) printError("Missing FILE parameter to " + args[i], null, true);
          try {
            com.mucommander.command.CommandManager.setCommandFile(args[++i]);
          } catch (Exception e) {
            printError("Could not set commands file", e, fatalWarnings);
          }
        }

        // Bookmarks handling.
        else if (args[i].equals("-b") || args[i].equals("--bookmarks")) {
          if (i >= args.length - 1) printError("Missing FILE parameter to " + args[i], null, true);
          try {
            com.mucommander.bookmark.BookmarkManager.setBookmarksFile(args[++i]);
          } catch (Exception e) {
            printError("Could not set bookmarks file", e, fatalWarnings);
          }
        }

        // Configuration handling.
        else if (args[i].equals("-c") || args[i].equals("--configuration")) {
          if (i >= args.length - 1) printError("Missing FILE parameter to " + args[i], null, true);
          try {
            MuConfigurations.setPreferencesFile(args[++i]);
          } catch (Exception e) {
            printError("Could not set configuration file", e, fatalWarnings);
          }
        }

        // Shell history.
        else if (args[i].equals("-s") || args[i].equals("--shell-history")) {
          if (i >= args.length - 1) printError("Missing FILE parameter to " + args[i], null, true);
          try {
            ShellHistoryManager.setHistoryFile(args[++i]);
          } catch (Exception e) {
            printError("Could not set shell history file", e, fatalWarnings);
          }
        }

        // Keymap file.
        else if (args[i].equals("-k") || args[i].equals("--keymap")) {
          if (i >= args.length - 1) printError("Missing FILE parameter to " + args[i], null, true);
          try {
            com.mucommander.ui.action.ActionKeymapIO.setActionsFile(args[++i]);
          } catch (Exception e) {
            printError("Could not set keymap file", e, fatalWarnings);
          }
        }

        // Toolbar file.
        else if (args[i].equals("-t") || args[i].equals("--toolbar")) {
          if (i >= args.length - 1) printError("Missing FILE parameter to " + args[i], null, true);
          try {
            ToolBarIO.setDescriptionFile(args[++i]);
          } catch (Exception e) {
            printError("Could not set keymap file", e, fatalWarnings);
          }
        }

        // Commandbar file.
        else if (args[i].equals("-C") || args[i].equals("--commandbar")) {
          if (i >= args.length - 1) printError("Missing FILE parameter to " + args[i], null, true);
          try {
            CommandBarIO.setDescriptionFile(args[++i]);
          } catch (Exception e) {
            printError("Could not set commandbar description file", e, fatalWarnings);
          }
        }

        // Credentials file.
        else if (args[i].equals("-U") || args[i].equals("--credentials")) {
          if (i >= args.length - 1) printError("Missing FILE parameter to " + args[i], null, true);
          try {
            com.mucommander.auth.CredentialsManager.setCredentialsFile(args[++i]);
          } catch (Exception e) {
            printError("Could not set credentials file", e, fatalWarnings);
          }
        }

        // Preference folder.
        else if ((args[i].equals("-p") || args[i].equals("--preferences"))) {
          if (i >= args.length - 1)
            printError("Missing FOLDER parameter to " + args[i], null, true);
          try {
            PlatformManager.setPreferencesFolder(args[++i]);
          } catch (Exception e) {
            printError("Could not set preferences folder", e, fatalWarnings);
          }
        }

        // Extensions folder.
        else if ((args[i].equals("-e") || args[i].equals("--extensions"))) {
          if (i >= args.length - 1)
            printError("Missing FOLDER parameter to " + args[i], null, true);
          try {
            ExtensionManager.setExtensionsFolder(args[++i]);
          } catch (Exception e) {
            printError("Could not set extensions folder", e, fatalWarnings);
          }
        }

        // Ignore warnings.
        else if (args[i].equals("-i") || args[i].equals("--ignore-warnings")) fatalWarnings = false;

        // Fail on warnings.
        else if (args[i].equals("-w") || args[i].equals("--fail-on-warnings")) fatalWarnings = true;

        // Silent mode.
        else if (args[i].equals("-S") || args[i].equals("--silent")) verbose = false;

        // Verbose mode.
        else if (args[i].equals("-V") || args[i].equals("--verbose")) verbose = true;

        // Illegal argument.
        else break;
      }

      // - Configuration init ---------------------------------------
      // ------------------------------------------------------------

      // Ensure that a graphics environment is available, exit otherwise.
      checkHeadless();

      // Attempts to guess whether this is the first time muCommander is booted or not.
      boolean isFirstBoot;
      try {
        isFirstBoot = !MuConfigurations.isPreferencesFileExists();
      } catch (IOException e) {
        isFirstBoot = true;
      }

      // Load snapshot data before loading configuration as until version 0.9 the snapshot
      // properties
      // were stored as preferences so when loading such preferences they could overload snapshot
      // properties
      try {
        MuConfigurations.loadSnapshot();
      } catch (Exception e) {
        printFileError("Could not load snapshot", e, fatalWarnings);
      }

      // Configuration needs to be loaded before any sort of GUI creation is performed : under Mac
      // OS X, if we're
      // to use the metal look, we need to know about it right about now.
      try {
        MuConfigurations.loadPreferences();
      } catch (Exception e) {
        printFileError("Could not load configuration", e, fatalWarnings);
      }

      // - Logging configuration ------------------------------------
      // ------------------------------------------------------------
      MuLogging.configureLogging();

      // - MAC OS X specific init -----------------------------------
      // ------------------------------------------------------------
      // If muCommander is running under Mac OS X (how lucky!), add some glue for the main menu bar
      // and other OS X
      // specifics.
      if (OsFamilies.MAC_OS_X.isCurrent()) {
        // Use reflection to create an OSXIntegration instance so that ClassLoader
        // doesn't throw an NoClassDefFoundException under platforms other than Mac OS X
        try {
          Class<?> osxIntegrationClass = Class.forName("com.mucommander.ui.macosx.OSXIntegration");
          Constructor<?> constructor = osxIntegrationClass.getConstructor(new Class[] {});
          constructor.newInstance();
        } catch (Exception e) {
          LOGGER.debug("Exception thrown while initializing Mac OS X integration", e);
        }
      }

      // - muCommander boot -----------------------------------------
      // ------------------------------------------------------------
      // Adds all extensions to the classpath.
      try {
        ExtensionManager.addExtensionsToClasspath();
      } catch (Exception e) {
        LOGGER.debug("Failed to add extensions to the classpath", e);
      }

      // This the property is supposed to have the java.net package use the proxy defined in the
      // system settings
      // to establish HTTP connections. This property is supported only under Java 1.5 and up.
      // Note that Mac OS X already uses the system HTTP proxy, with or without this property being
      // set.
      System.setProperty("java.net.useSystemProxies", "true");

      // Shows the splash screen, if enabled in the preferences
      useSplash =
          MuConfigurations.getPreferences()
              .getVariable(
                  MuPreference.SHOW_SPLASH_SCREEN, MuPreferences.DEFAULT_SHOW_SPLASH_SCREEN);
      if (useSplash) {
        splashScreen = new SplashScreen(RuntimeConstants.VERSION, "Loading preferences...");
      }

      boolean showSetup;
      showSetup = MuConfigurations.getPreferences().getVariable(MuPreference.THEME_TYPE) == null;

      // Traps VM shutdown
      Runtime.getRuntime().addShutdownHook(new ShutdownHook());

      // Configure filesystems
      configureFilesystems();

      // Initializes the desktop.
      try {
        com.mucommander.desktop.DesktopManager.init(isFirstBoot);
      } catch (Exception e) {
        printError("Could not initialize desktop", e, true);
      }

      // Loads dictionary
      printStartupMessage("Loading dictionary...");
      try {
        com.mucommander.text.Translator.loadDictionaryFile();
      } catch (Exception e) {
        printError("Could not load dictionary", e, true);
      }

      // Loads custom commands
      printStartupMessage("Loading file associations...");
      try {
        com.mucommander.command.CommandManager.loadCommands();
      } catch (Exception e) {
        printFileError("Could not load custom commands", e, fatalWarnings);
      }

      // Migrates the custom editor and custom viewer if necessary.
      migrateCommand("viewer.use_custom", "viewer.custom_command", CommandManager.VIEWER_ALIAS);
      migrateCommand("editor.use_custom", "editor.custom_command", CommandManager.EDITOR_ALIAS);
      try {
        CommandManager.writeCommands();
      } catch (Exception e) {
        System.out.println("###############################");
        LOGGER.debug("Caught exception", e);
        // There's really nothing we can do about this...
      }

      try {
        com.mucommander.command.CommandManager.loadAssociations();
      } catch (Exception e) {
        printFileError("Could not load custom associations", e, fatalWarnings);
      }

      // Loads bookmarks
      printStartupMessage("Loading bookmarks...");
      try {
        com.mucommander.bookmark.BookmarkManager.loadBookmarks();
      } catch (Exception e) {
        printFileError("Could not load bookmarks", e, fatalWarnings);
      }

      // Loads credentials
      printStartupMessage("Loading credentials...");
      try {
        com.mucommander.auth.CredentialsManager.loadCredentials();
      } catch (Exception e) {
        printFileError("Could not load credentials", e, fatalWarnings);
      }

      // Loads shell history
      printStartupMessage("Loading shell history...");
      try {
        ShellHistoryManager.loadHistory();
      } catch (Exception e) {
        printFileError("Could not load shell history", e, fatalWarnings);
      }

      // Inits CustomDateFormat to make sure that its ConfigurationListener is added
      // before FileTable, so CustomDateFormat gets notified of date format changes first
      com.mucommander.text.CustomDateFormat.init();

      // Initialize file icons
      printStartupMessage("Loading icons...");
      // Initialize the SwingFileIconProvider from the main thread, see method Javadoc for an
      // explanation on why we do this now
      SwingFileIconProvider.forceInit();
      // The math.max(1.0f, ...) part is to workaround a bug which cause(d) this value to be set to
      // 0.0 in the configuration file.
      com.mucommander.ui.icon.FileIcons.setScaleFactor(
          Math.max(
              1.0f,
              MuConfigurations.getPreferences()
                  .getVariable(
                      MuPreference.TABLE_ICON_SCALE, MuPreferences.DEFAULT_TABLE_ICON_SCALE)));
      com.mucommander.ui.icon.FileIcons.setSystemIconsPolicy(
          MuConfigurations.getPreferences()
              .getVariable(
                  MuPreference.USE_SYSTEM_FILE_ICONS, MuPreferences.DEFAULT_USE_SYSTEM_FILE_ICONS));

      // Register actions
      printStartupMessage("Registering actions...");
      ActionManager.registerActions();

      // Loads the ActionKeymap file
      printStartupMessage("Loading actions shortcuts...");
      try {
        com.mucommander.ui.action.ActionKeymapIO.loadActionKeymap();
      } catch (Exception e) {
        printFileError("Could not load actions shortcuts", e, fatalWarnings);
      }

      // Loads the ToolBar's description file
      printStartupMessage("Loading toolbar description...");
      try {
        ToolBarIO.loadDescriptionFile();
      } catch (Exception e) {
        printFileError("Could not load toolbar description", e, fatalWarnings);
      }

      // Loads the CommandBar's description file
      printStartupMessage("Loading command bar description...");
      try {
        CommandBarIO.loadCommandBar();
      } catch (Exception e) {
        printFileError("Could not load commandbar description", e, fatalWarnings);
      }

      // Loads the themes.
      printStartupMessage("Loading theme...");
      com.mucommander.ui.theme.ThemeManager.loadCurrentTheme();

      // Starts Bonjour services discovery (only if enabled in prefs)
      printStartupMessage("Starting Bonjour services discovery...");
      com.mucommander.bonjour.BonjourDirectory.setActive(
          MuConfigurations.getPreferences()
              .getVariable(
                  MuPreference.ENABLE_BONJOUR_DISCOVERY,
                  MuPreferences.DEFAULT_ENABLE_BONJOUR_DISCOVERY));

      // Creates the initial main frame using any initial path specified by the command line.
      printStartupMessage("Initializing window...");
      String[] folders = new String[args.length - i];
      System.arraycopy(args, i, folders, 0, folders.length);
      WindowManager.createNewMainFrame(new CommandLineMainFrameBuilder(folders));

      // If no initial path was specified, start a default main window.
      if (WindowManager.getCurrentMainFrame() == null)
        WindowManager.createNewMainFrame(new DefaultMainFramesBuilder());

      // Done launching, wake up threads waiting for the application being launched.
      // Important: this must be done before disposing the splash screen, as this would otherwise
      // create a deadlock
      // if the AWT event thread were waiting in #waitUntilLaunched .
      synchronized (LAUNCH_LOCK) {
        isLaunching = false;
        LAUNCH_LOCK.notifyAll();
      }

      // Enable system notifications, only after MainFrame is created as SystemTrayNotifier needs to
      // retrieve
      // a MainFrame instance
      if (MuConfigurations.getPreferences()
          .getVariable(
              MuPreference.ENABLE_SYSTEM_NOTIFICATIONS,
              MuPreferences.DEFAULT_ENABLE_SYSTEM_NOTIFICATIONS)) {
        printStartupMessage("Enabling system notifications...");
        if (com.mucommander.ui.notifier.AbstractNotifier.isAvailable())
          com.mucommander.ui.notifier.AbstractNotifier.getNotifier().setEnabled(true);
      }

      // Dispose splash screen.
      if (splashScreen != null) splashScreen.dispose();

      // Check for newer version unless it was disabled
      if (MuConfigurations.getPreferences()
          .getVariable(MuPreference.CHECK_FOR_UPDATE, MuPreferences.DEFAULT_CHECK_FOR_UPDATE))
        new CheckVersionDialog(WindowManager.getCurrentMainFrame(), false);

      // If no theme is configured in the preferences, ask for an initial theme.
      if (showSetup) new InitialSetupDialog(WindowManager.getCurrentMainFrame()).showDialog();
    } catch (Throwable t) {
      // Startup failed, dispose the splash screen
      if (splashScreen != null) splashScreen.dispose();

      LOGGER.error("Startup failed", t);

      // Display an error dialog with a proper message and error details
      InformationDialog.showErrorDialog(null, null, Translator.get("startup_error"), null, t);

      // Quit the application
      WindowManager.quit();
    }
  }
Пример #19
0
  /**
   * Performs tasks before shut down, such as writing the configuration file. This method can only
   * be called once, any further call will be ignored (no-op).
   */
  private static synchronized void performShutdownTasks() {
    // Return if shutdown tasks have already been performed
    if (shutdownTasksPerformed) return;

    TreeIOThreadManager.getInstance().interrupt();

    // Save snapshot
    try {
      MuConfigurations.saveSnapshot();
    } catch (Exception e) {
      LOGGER.warn("Failed to save snapshot", e);
    }

    // Save preferences
    try {
      MuConfigurations.savePreferences();
    } catch (Exception e) {
      LOGGER.warn("Failed to save configuration", e);
    }

    // Save shell history
    try {
      ShellHistoryManager.writeHistory();
    } catch (Exception e) {
      LOGGER.warn("Failed to save shell history", e);
    }

    // Write credentials file to disk, only if changes were made
    try {
      CredentialsManager.writeCredentials(false);
    } catch (Exception e) {
      LOGGER.warn("Failed to save credentials", e);
    }

    // Write bookmarks file to disk, only if changes were made
    try {
      BookmarkManager.writeBookmarks(false);
    } catch (Exception e) {
      LOGGER.warn("Failed to save bookmarks", e);
    }

    // Saves the current theme.
    try {
      ThemeManager.saveCurrentTheme();
    } catch (Exception e) {
      LOGGER.warn("Failed to save user theme", e);
    }

    // Saves the file associations.
    try {
      CommandManager.writeCommands();
    } catch (Exception e) {
      LOGGER.warn("Failed to save commands", e);
    }
    try {
      CommandManager.writeAssociations();
    } catch (Exception e) {
      LOGGER.warn("Failed to save associations", e);
    }

    // Saves the action keymap.
    try {
      ActionKeymapIO.saveActionKeymap();
    } catch (Exception e) {
      LOGGER.warn("Failed to save action keymap", e);
    }

    // Saves the command bar.
    try {
      CommandBarIO.saveCommandBar();
    } catch (Exception e) {
      LOGGER.warn("Failed to save command bar", e);
    }

    // Saves the tool bar.
    try {
      ToolBarIO.saveToolBar();
    } catch (Exception e) {
      LOGGER.warn("Failed to save toolbar", e);
    }

    // Shutdown tasks should only be performed once
    shutdownTasksPerformed = true;
  }