use of com.mucommander.ui.theme.Theme in project mucommander by mucommander.
the class InitialSetupDialog method createThemePanel.
// - Initialisation ------------------------------------------------------------------
// -----------------------------------------------------------------------------------
/**
* Creates the dialog's theme panel.
* @return the dialog's theme panel.
*/
private JPanel createThemePanel() {
// Initialises the theme panel.
// Theme panel.
JPanel themePanel = new YBoxPanel();
themePanel.setAlignmentX(LEFT_ALIGNMENT);
themePanel.setBorder(BorderFactory.createTitledBorder(Translator.get("prefs_dialog.themes")));
// Adds the panel description.
// Temporary panel used to hold the dialog's description.
JPanel tempPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
tempPanel.add(new JLabel(Translator.get("setup.theme") + ':'));
themePanel.add(tempPanel);
// Adds the theme combo box.
themeComboBox = new JComboBox<>();
// All available themes.
Iterator<Theme> themes = ThemeManager.availableThemes();
// Index of the currently analyzed theme.
int index = 0;
// Index of the current theme in the combo box.
int selectedIndex = 0;
// Adds all themes to the combo box.
while (themes.hasNext()) {
Theme theme = themes.next();
themeComboBox.addItem(theme);
if (ThemeManager.isCurrentTheme(theme))
selectedIndex = index;
index++;
}
// Selects the current theme.
themeComboBox.setSelectedIndex(selectedIndex);
themeComboBox.addActionListener(this);
themePanel.add(themeComboBox);
return themePanel;
}
use of com.mucommander.ui.theme.Theme in project mucommander by mucommander.
the class AppearancePanel method commit.
// /////////////////////
// PrefPanel methods //
// /////////////////////
@Override
protected void commit() {
// Look and Feel
if (MuConfigurations.getPreferences().setVariable(MuPreference.LOOK_AND_FEEL, lookAndFeels[lookAndFeelComboBox.getSelectedIndex()].getClassName())) {
resetLookAndFeelButtons();
SwingUtilities.updateComponentTreeUI(parent);
}
// Set ToolBar's icon size
float scaleFactor = ICON_SCALE_FACTORS[toolbarIconsSizeComboBox.getSelectedIndex()];
MuConfigurations.getPreferences().setVariable(MuPreference.TOOLBAR_ICON_SCALE, scaleFactor);
// Set CommandBar's icon size
scaleFactor = ICON_SCALE_FACTORS[commandBarIconsSizeComboBox.getSelectedIndex()];
MuConfigurations.getPreferences().setVariable(MuPreference.COMMAND_BAR_ICON_SCALE, scaleFactor);
// Set file icon size
scaleFactor = ICON_SCALE_FACTORS[fileIconsSizeComboBox.getSelectedIndex()];
// Set scale factor in FileIcons first so that it has the new value when ConfigurationListener instances call it
FileIcons.setScaleFactor(scaleFactor);
MuConfigurations.getPreferences().setVariable(MuPreference.TABLE_ICON_SCALE, scaleFactor);
// Sets the current theme.
if (!ThemeManager.isCurrentTheme((Theme) themeComboBox.getSelectedItem())) {
ThemeManager.setCurrentTheme((Theme) themeComboBox.getSelectedItem());
resetThemeButtons((Theme) themeComboBox.getSelectedItem());
themeComboBox.repaint();
}
// Set system icons policy
SystemIconsPolicy systemIconsPolicy;
switch(useSystemFileIconsComboBox.getSelectedIndex()) {
case 0:
systemIconsPolicy = SystemIconsPolicy.NEVER;
break;
case 1:
systemIconsPolicy = SystemIconsPolicy.APPLICATIONS_ONLY;
break;
case 2:
systemIconsPolicy = SystemIconsPolicy.FOLDERS_ONLY;
break;
case 3:
default:
systemIconsPolicy = SystemIconsPolicy.ALWAYS;
}
FileIcons.setSystemIconsPolicy(systemIconsPolicy);
MuConfigurations.getPreferences().setVariable(MuPreference.USE_SYSTEM_FILE_ICONS, systemIconsPolicy.toString());
}
use of com.mucommander.ui.theme.Theme in project mucommander by mucommander.
the class AppearancePanel method actionPerformed.
// - Listener code ----------------------------------------------------------
// --------------------------------------------------------------------------
/**
* Called when a button is pressed.
*/
public void actionPerformed(ActionEvent e) {
Theme theme;
theme = (Theme) themeComboBox.getSelectedItem();
// Theme combobox selection changed.
if (e.getSource() == themeComboBox)
resetThemeButtons(theme);
else // Look and feel combobox selection changed.
if (e.getSource() == lookAndFeelComboBox)
resetLookAndFeelButtons();
else // Delete look and feel button has been pressed.
if (e.getSource() == deleteLookAndFeelButton)
deleteSelectedLookAndFeel();
else // Import look and feel button has been pressed.
if (e.getSource() == importLookAndFeelButton)
importLookAndFeel();
else // Rename button was pressed.
if (e.getSource() == renameThemeButton)
renameTheme(theme);
else // Delete button was pressed.
if (e.getSource() == deleteThemeButton)
deleteTheme(theme);
else // Edit button was pressed.
if (e.getSource() == editThemeButton)
editTheme(theme);
else // Import button was pressed.
if (e.getSource() == importThemeButton)
importTheme();
else // Export button was pressed.
if (e.getSource() == exportThemeButton)
exportTheme(theme);
else // Export button was pressed.
if (e.getSource() == duplicateThemeButton)
duplicateTheme(theme);
}
use of com.mucommander.ui.theme.Theme in project mucommander by mucommander.
the class MainMenuBar method menuSelected.
// ////////////////////////
// MenuListener methods //
// ////////////////////////
public void menuSelected(MenuEvent e) {
Object source = e.getSource();
if (source == viewMenu) {
FileTable activeTable = mainFrame.getActiveTable();
// Select the 'sort by' criterion currently in use in the active table
sortByItems[activeTable.getSortInfo().getCriterion().ordinal()].setSelected(true);
toggleShowFoldersFirstItem.setSelected(activeTable.getSortInfo().getFoldersFirst());
toggleShowHiddenFilesItem.setSelected(MuConfigurations.getPreferences().getVariable(MuPreference.SHOW_HIDDEN_FILES, MuPreferences.DEFAULT_SHOW_HIDDEN_FILES));
toggleTreeItem.setSelected(activeTable.getFolderPanel().isTreeVisible());
toggleToggleAutoSizeItem.setSelected(mainFrame.isAutoSizeColumnsEnabled());
toggleUseSinglePanel.setSelected(mainFrame.isSinglePanel());
/* TODO branch toggleBranchView.setSelected(activeTable.getFolderPanel().isBranchView()); */
} else if (source == columnsMenu) {
// Update the selected and enabled state of each column menu item.
FileTable activeTable = mainFrame.getActiveTable();
for (Column c : Column.values()) {
if (// Name column doesn't have a menu item as it cannot be disabled
c == Column.NAME)
continue;
JCheckBoxMenuItem item = toggleColumnItems[c.ordinal()];
item.setSelected(activeTable.isColumnEnabled(c));
item.setEnabled(activeTable.isColumnDisplayable(c));
// Override the action's label to a shorter one
item.setText(c.getLabel());
}
} else if (source == goMenu) {
// as they might have changed since menu was last selected
for (int i = goMenu.getItemCount(); i > volumeOffset; i--) goMenu.remove(volumeOffset);
AbstractFile[] volumes = LocalFile.getVolumes();
int nbFolders = volumes.length;
for (int i = 0; i < nbFolders; i++) goMenu.add(new OpenLocationAction(mainFrame, new Hashtable<String, Object>(), volumes[i]));
} else if (source == bookmarksMenu) {
// as bookmarks might have changed since menu was last selected
for (int i = bookmarksMenu.getItemCount(); i > bookmarksOffset; i--) bookmarksMenu.remove(bookmarksOffset);
// Add bookmarks menu items
java.util.List<Bookmark> bookmarks = BookmarkManager.getBookmarks();
int nbBookmarks = bookmarks.size();
if (nbBookmarks > 0) {
for (int i = 0; i < nbBookmarks; i++) MenuToolkit.addMenuItem(bookmarksMenu, new OpenLocationAction(mainFrame, new Hashtable<String, Object>(), bookmarks.get(i)), null);
} else {
// Show 'No bookmark' as a disabled menu item instead showing nothing
JMenuItem noBookmarkItem = MenuToolkit.addMenuItem(bookmarksMenu, Translator.get("bookmarks_menu.no_bookmark"), null, null, null);
noBookmarkItem.setEnabled(false);
}
} else if (source == windowMenu) {
// Select the split orientation currently in use
if (mainFrame.getSplitPaneOrientation())
splitVerticallyItem.setSelected(true);
else
splitHorizontallyItem.setSelected(true);
// menu has been deselected.
for (int i = windowMenu.getItemCount(); i > windowOffset; i--) windowMenu.remove(windowOffset);
// This WeakHashMap maps menu items to frame instances. It has to be a weakly referenced hash map
// and not a regular hash map, since it will not (and cannot) be emptied when the menu has been deselected
// and we really do not want this hash map to prevent the frames to be GCed
windowMenuFrames = new WeakHashMap<JMenuItem, Frame>();
// Create a menu item for each of the MainFrame instances, that displays the MainFrame's path
// and a keyboard accelerator to recall the frame (for the first 10 frames only).
java.util.List<MainFrame> mainFrames = WindowManager.getMainFrames();
MainFrame mainFrame;
JCheckBoxMenuItem checkBoxMenuItem;
int nbFrames = mainFrames.size();
for (int i = 0; i < nbFrames; i++) {
mainFrame = mainFrames.get(i);
checkBoxMenuItem = new JCheckBoxMenuItem();
// If frame number is less than 10, use the corresponding action class (accelerator will be displayed in the menu item)
MuAction recallWindowAction;
if (i < 10) {
recallWindowAction = ActionManager.getActionInstance(RECALL_WINDOW_ACTION_IDS[i], this.mainFrame);
} else // Else use the generic RecallWindowAction
{
Hashtable<String, Object> actionProps = new Hashtable<String, Object>();
// Specify the window number using the dedicated property
actionProps.put(RecallWindowAction.WINDOW_NUMBER_PROPERTY_KEY, "" + (i + 1));
recallWindowAction = ActionManager.getActionInstance(new ActionParameters(RecallWindowAction.Descriptor.ACTION_ID, actionProps), this.mainFrame);
}
checkBoxMenuItem.setAction(recallWindowAction);
// Replace the action's label and use the MainFrame's current folder path instead
checkBoxMenuItem.setText((i + 1) + " " + mainFrame.getActiveTable().getFolderPanel().getCurrentFolder().getAbsolutePath());
// Use the action's label as a tooltip
checkBoxMenuItem.setToolTipText(recallWindowAction.getLabel());
// Check current MainFrame (the one this menu bar belongs to)
checkBoxMenuItem.setSelected(mainFrame == this.mainFrame);
windowMenu.add(checkBoxMenuItem);
}
// Add 'other' (non-MainFrame) windows : viewer and editor frames, no associated accelerator
Frame[] frames = Frame.getFrames();
nbFrames = frames.length;
Frame frame;
JMenuItem menuItem;
boolean firstFrame = true;
for (int i = 0; i < nbFrames; i++) {
frame = frames[i];
// Test if Frame is not hidden (disposed), Frame.getFrames() returns both active and disposed frames
if (frame.isShowing() && (frame instanceof FileFrame)) {
// and other frames
if (firstFrame) {
windowMenu.add(new JSeparator());
firstFrame = false;
}
// Use frame's window title
menuItem = new JMenuItem(frame.getTitle());
menuItem.addActionListener(this);
windowMenu.add(menuItem);
windowMenuFrames.put(menuItem, frame);
}
}
} else if (source == themesMenu) {
// Remove all previous theme items, create new ones for each available theme and select the current theme
themesMenu.removeAll();
ButtonGroup buttonGroup = new ButtonGroup();
Iterator<Theme> themes = ThemeManager.availableThemes();
Theme theme;
JCheckBoxMenuItem item;
themesMenu.add(new JMenuItem(new EditCurrentThemeAction()));
themesMenu.add(new JSeparator());
while (themes.hasNext()) {
theme = themes.next();
item = new JCheckBoxMenuItem(new ChangeCurrentThemeAction(theme));
buttonGroup.add(item);
if (ThemeManager.isCurrentTheme(theme))
item.setSelected(true);
themesMenu.add(item);
}
}
}
use of com.mucommander.ui.theme.Theme in project mucommander by mucommander.
the class AppearancePanel method createThemesPanel.
/**
* Creates the themes panel.
*
* @return the themes panel.
*/
private JPanel createThemesPanel() {
JPanel gridPanel = new ProportionalGridPanel(4);
// Creates the various panel's buttons.
editThemeButton = new JButton(Translator.get("edit") + "...");
importThemeButton = new JButton(Translator.get("prefs_dialog.import") + "...");
exportThemeButton = new JButton(Translator.get("prefs_dialog.export") + "...");
renameThemeButton = new JButton(Translator.get("rename"));
deleteThemeButton = new JButton(Translator.get("delete"));
duplicateThemeButton = new JButton(Translator.get("duplicate"));
editThemeButton.addActionListener(this);
importThemeButton.addActionListener(this);
exportThemeButton.addActionListener(this);
renameThemeButton.addActionListener(this);
deleteThemeButton.addActionListener(this);
duplicateThemeButton.addActionListener(this);
// Creates the panel's 'type label'.
typeLabel = new JLabel("");
// Creates the theme combo box.
themeComboBox = new PrefComboBox() {
public boolean hasChanged() {
return !ThemeManager.isCurrentTheme((Theme) getSelectedItem());
}
};
themeComboBox.addActionListener(this);
// Sets the combobox's renderer.
lockIcon = IconManager.getIcon(IconManager.PREFERENCES_ICON_SET, "lock.png");
transparentIcon = new ImageIcon(new BufferedImage(lockIcon.getIconWidth(), lockIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB));
themeComboBox.setRenderer(new BasicComboBoxRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel label;
Theme theme;
label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
theme = (Theme) value;
if (ThemeManager.isCurrentTheme(theme))
label.setText(theme.getName() + " (" + Translator.get("theme.current") + ")");
else
label.setText(theme.getName());
if (theme.getType() != Theme.CUSTOM_THEME)
label.setIcon(lockIcon);
else
label.setIcon(transparentIcon);
return label;
}
});
// Initialises the content of the combo box.
populateThemes(ThemeManager.getCurrentTheme());
gridPanel.add(themeComboBox);
gridPanel.add(editThemeButton);
gridPanel.add(importThemeButton);
gridPanel.add(exportThemeButton);
gridPanel.add(typeLabel);
gridPanel.add(renameThemeButton);
gridPanel.add(deleteThemeButton);
gridPanel.add(duplicateThemeButton);
JPanel flowPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));
flowPanel.setBorder(BorderFactory.createTitledBorder(Translator.get("prefs_dialog.themes")));
flowPanel.add(gridPanel);
return flowPanel;
}
Aggregations