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;
}
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);
}
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;
}
Aggregations