mirror of
https://github.com/mitb-archive/filebot
synced 2025-03-10 06:20:27 -04:00
* add buttons for all context menus so even noobs can get started easily
This commit is contained in:
parent
3bf1a76773
commit
b7406e54d4
@ -14,16 +14,20 @@ import javax.swing.JButton;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.ListSelectionModel;
|
||||
|
||||
import ca.odell.glazedlists.EventList;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import net.sourceforge.filebot.ResourceManager;
|
||||
import net.sourceforge.filebot.ui.FileBotList;
|
||||
import net.sourceforge.filebot.ui.transfer.LoadAction;
|
||||
import net.sourceforge.filebot.ui.transfer.TransferablePolicy;
|
||||
import ca.odell.glazedlists.EventList;
|
||||
|
||||
|
||||
class RenameList<E> extends FileBotList<E> {
|
||||
|
||||
private JPanel buttonPanel;
|
||||
|
||||
|
||||
public RenameList(EventList<E> model) {
|
||||
// replace default model with given model
|
||||
setModel(model);
|
||||
@ -36,7 +40,7 @@ class RenameList<E> extends FileBotList<E> {
|
||||
|
||||
getRemoveAction().setEnabled(true);
|
||||
|
||||
JPanel buttonPanel = new JPanel(new MigLayout("insets 1.2mm, nogrid, fill", "align center"));
|
||||
buttonPanel = new JPanel(new MigLayout("insets 1.2mm, nogrid, fill", "align center"));
|
||||
|
||||
buttonPanel.add(new JButton(downAction), "gap 10px");
|
||||
buttonPanel.add(new JButton(upAction), "gap 0");
|
||||
@ -47,13 +51,19 @@ class RenameList<E> extends FileBotList<E> {
|
||||
listScrollPane.getViewport().setBackground(list.getBackground());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public JPanel getButtonPanel() {
|
||||
return buttonPanel;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setTransferablePolicy(TransferablePolicy transferablePolicy) {
|
||||
super.setTransferablePolicy(transferablePolicy);
|
||||
loadAction.putValue(LoadAction.TRANSFERABLE_POLICY, transferablePolicy);
|
||||
}
|
||||
|
||||
|
||||
private final LoadAction loadAction = new LoadAction(null);
|
||||
|
||||
private final AbstractAction upAction = new AbstractAction(null, ResourceManager.getIcon("action.up")) {
|
||||
@ -90,7 +100,7 @@ class RenameList<E> extends FileBotList<E> {
|
||||
lastIndex = getListComponent().getSelectedIndex();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent m) {
|
||||
int currentIndex = getListComponent().getSelectedIndex();
|
||||
|
@ -11,6 +11,7 @@ import static net.sourceforge.tuned.ui.TunedUtilities.*;
|
||||
import java.awt.Component;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.File;
|
||||
@ -137,12 +138,30 @@ public class RenamePanel extends JComponent {
|
||||
// create fetch popup
|
||||
ActionPopup fetchPopup = createFetchPopup();
|
||||
|
||||
final Action fetchPopupAction = new ShowPopupAction("Fetch", ResourceManager.getIcon("action.fetch"));
|
||||
JButton fetchButton = createImageButton(fetchPopupAction);
|
||||
namesList.getListComponent().setComponentPopupMenu(fetchPopup);
|
||||
fetchButton.setComponentPopupMenu(fetchPopup);
|
||||
matchButton.setComponentPopupMenu(fetchPopup);
|
||||
matchButton.addActionListener(showPopupAction);
|
||||
namesList.getButtonPanel().add(fetchButton, "gap 0");
|
||||
matchButton.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// show popup on actionPerformed only when names list is empty
|
||||
if (renameModel.size() > 0 && !renameModel.hasComplement(0)) {
|
||||
fetchPopupAction.actionPerformed(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// create settings popup
|
||||
renameButton.setComponentPopupMenu(createSettingsPopup());
|
||||
final Action settingsPopupAction = new ShowPopupAction("Options", ResourceManager.getIcon("action.report"));
|
||||
JButton settingsButton = createImageButton(settingsPopupAction);
|
||||
ActionPopup settingsPopup = createSettingsPopup();
|
||||
settingsButton.setComponentPopupMenu(settingsPopup);
|
||||
renameButton.setComponentPopupMenu(settingsPopup);
|
||||
filesList.getButtonPanel().add(settingsButton, "gap 0");
|
||||
|
||||
setLayout(new MigLayout("fill, insets dialog, gapx 10px", "[fill][align center, pref!][fill]", "align 33%"));
|
||||
|
||||
@ -291,17 +310,18 @@ public class RenamePanel extends JComponent {
|
||||
}
|
||||
|
||||
|
||||
protected final Action showPopupAction = new AbstractAction("Show Popup") {
|
||||
protected static class ShowPopupAction extends AbstractAction {
|
||||
|
||||
public ShowPopupAction(String name, Icon icon) {
|
||||
super(name, icon);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// show popup on actionPerformed only when names list is empty
|
||||
if (renameModel.size() > 0 && !renameModel.hasComplement(0)) {
|
||||
JComponent source = (JComponent) e.getSource();
|
||||
|
||||
// display popup below component
|
||||
source.getComponentPopupMenu().show(source, -3, source.getHeight() + 4);
|
||||
}
|
||||
// display popup below component
|
||||
JComponent source = (JComponent) e.getSource();
|
||||
source.getComponentPopupMenu().show(source, -3, source.getHeight() + 4);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user