Search in sources :

Example 1 with CompositeComparator

use of org.wikipediacleaner.api.data.CompositeComparator in project wpcleaner by WPCleaner.

the class DisambiguationWindow method createSortMenu.

/**
 * @return Sort menu.
 */
private JMenu createSortMenu() {
    JMenu menu = Utilities.createJMenu(GT._T("Sort"));
    List<CompositeComparator<Page>> comparators = PageComparator.getComparators();
    for (CompositeComparator<Page> comparator : comparators) {
        JMenuItem menuItem = Utilities.createJMenuItem(comparator.getName(), true);
        menuItem.addActionListener(new SetComparatorAction(modelLinks, comparator));
        menu.add(menuItem);
    }
    return menu;
}
Also used : Page(org.wikipediacleaner.api.data.Page) ActionWatchPage(org.wikipediacleaner.gui.swing.action.ActionWatchPage) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) CompositeComparator(org.wikipediacleaner.api.data.CompositeComparator) SetComparatorAction(org.wikipediacleaner.gui.swing.action.SetComparatorAction)

Example 2 with CompositeComparator

use of org.wikipediacleaner.api.data.CompositeComparator in project wpcleaner by WPCleaner.

the class SortingOptionsPanel method initialize.

/**
 * Initialize the panel.
 */
private void initialize() {
    // Initialize constraints
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridheight = 1;
    constraints.gridwidth = 1;
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.insets = new Insets(0, 0, 0, 0);
    constraints.ipadx = 0;
    constraints.ipady = 0;
    constraints.weightx = 1;
    constraints.weighty = 0;
    // Sort orders
    JPanel panelSortOrders = new JPanel(new GridBagLayout());
    panelSortOrders.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), GT._T("Sort orders")));
    constraints.fill = GridBagConstraints.BOTH;
    constraints.weighty = 1;
    modelSort = new DefaultListModel<>();
    List<CompositeComparator<Page>> comparators = PageComparator.getComparators();
    for (CompositeComparator<Page> comparator : comparators) {
        modelSort.addElement(comparator);
    }
    listSort = new JList<>(modelSort);
    listSort.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listSort.addListSelectionListener(this);
    JScrollPane scrollSort = new JScrollPane(listSort);
    scrollSort.setMinimumSize(new Dimension(100, 100));
    scrollSort.setPreferredSize(new Dimension(150, 200));
    scrollSort.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    panelSortOrders.add(scrollSort, constraints);
    JToolBar toolbarButtons = new JToolBar(SwingConstants.HORIZONTAL);
    toolbarButtons.setFloatable(false);
    buttonSortAdd = Utilities.createJButton("gnome-list-add.png", EnumImageSize.NORMAL, GT._T("Add"), false, null);
    buttonSortAdd.addActionListener(EventHandler.create(ActionListener.class, this, "actionSortAdd"));
    toolbarButtons.add(buttonSortAdd);
    buttonSortDelete = Utilities.createJButton("gnome-list-remove.png", EnumImageSize.NORMAL, GT._T("Delete"), false, null);
    buttonSortDelete.addActionListener(EventHandler.create(ActionListener.class, this, "actionSortDelete"));
    toolbarButtons.add(buttonSortDelete);
    constraints.gridy++;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weighty = 0;
    panelSortOrders.add(toolbarButtons, constraints);
    constraints.gridy++;
    // Sort description
    JPanel panelSortDescription = new JPanel(new GridBagLayout());
    panelSortDescription.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), GT._T("Details")));
    constraints.gridy = 0;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.weighty = 1;
    modelSortItem = new DefaultListModel<>();
    listSortItem = new JList<>(modelSortItem);
    listSortItem.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane scrollSortItem = new JScrollPane(listSortItem);
    scrollSortItem.setMinimumSize(new Dimension(100, 100));
    scrollSortItem.setPreferredSize(new Dimension(150, 200));
    scrollSortItem.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    panelSortDescription.add(scrollSortItem, constraints);
    constraints.gridy++;
    toolbarButtons = new JToolBar(SwingConstants.HORIZONTAL);
    toolbarButtons.setFloatable(false);
    buttonSortUp = Utilities.createJButton("gnome-go-up.png", EnumImageSize.NORMAL, GT._T("Up"), false, null);
    buttonSortUp.addActionListener(EventHandler.create(ActionListener.class, this, "actionSortMoveUp"));
    toolbarButtons.add(buttonSortUp);
    buttonSortDown = Utilities.createJButton("gnome-go-down.png", EnumImageSize.NORMAL, GT._T("Down"), false, null);
    buttonSortDown.addActionListener(EventHandler.create(ActionListener.class, this, "actionSortMoveDown"));
    toolbarButtons.add(buttonSortDown);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weighty = 0;
    panelSortDescription.add(toolbarButtons, constraints);
    constraints.gridy++;
    if (modelSort.getSize() > 0) {
        listSort.setSelectedIndex(0);
    }
    // Adding panels
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridheight = 1;
    constraints.gridwidth = 1;
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.weightx = 1;
    constraints.weighty = 1;
    add(panelSortOrders, constraints);
    constraints.gridx++;
    add(panelSortDescription, constraints);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) Page(org.wikipediacleaner.api.data.Page) Dimension(java.awt.Dimension) JToolBar(javax.swing.JToolBar) CompositeComparator(org.wikipediacleaner.api.data.CompositeComparator) ActionListener(java.awt.event.ActionListener)

Example 3 with CompositeComparator

use of org.wikipediacleaner.api.data.CompositeComparator in project wpcleaner by WPCleaner.

the class OnePageAnalysisWindow method createSortMenu.

/**
 * @return Sort menu.
 */
private JMenu createSortMenu() {
    JMenu menu = Utilities.createJMenu(GT._T("Sort"));
    List<CompositeComparator<Page>> comparators = PageComparator.getComparators();
    for (CompositeComparator<Page> comparator : comparators) {
        JMenuItem menuItem = Utilities.createJMenuItem(comparator.getName(), true);
        menuItem.addActionListener(new SetComparatorAction(modelLinks, comparator));
        menu.add(menuItem);
    }
    return menu;
}
Also used : Page(org.wikipediacleaner.api.data.Page) CheckErrorPage(org.wikipediacleaner.api.check.CheckErrorPage) ActionDeletePage(org.wikipediacleaner.gui.swing.action.ActionDeletePage) ActionWatchPage(org.wikipediacleaner.gui.swing.action.ActionWatchPage) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) CompositeComparator(org.wikipediacleaner.api.data.CompositeComparator) SetComparatorAction(org.wikipediacleaner.gui.swing.action.SetComparatorAction)

Aggregations

CompositeComparator (org.wikipediacleaner.api.data.CompositeComparator)3 Page (org.wikipediacleaner.api.data.Page)3 JMenu (javax.swing.JMenu)2 JMenuItem (javax.swing.JMenuItem)2 ActionWatchPage (org.wikipediacleaner.gui.swing.action.ActionWatchPage)2 SetComparatorAction (org.wikipediacleaner.gui.swing.action.SetComparatorAction)2 Dimension (java.awt.Dimension)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 ActionListener (java.awt.event.ActionListener)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 JToolBar (javax.swing.JToolBar)1 CheckErrorPage (org.wikipediacleaner.api.check.CheckErrorPage)1 ActionDeletePage (org.wikipediacleaner.gui.swing.action.ActionDeletePage)1