Search in sources :

Example 1 with SideButton

use of org.openstreetmap.josm.gui.SideButton in project josm by JOSM.

the class SelectionListDialog method buildContentPanel.

/**
 * Builds the content panel for this dialog
 */
protected void buildContentPanel() {
    lstPrimitives = new JList<>(model);
    lstPrimitives.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    lstPrimitives.setSelectionModel(selectionModel);
    lstPrimitives.setCellRenderer(new PrimitiveRenderer());
    lstPrimitives.setTransferHandler(new SelectionTransferHandler());
    if (!GraphicsEnvironment.isHeadless()) {
        lstPrimitives.setDragEnabled(true);
    }
    lstPrimitives.getSelectionModel().addListSelectionListener(actSelect);
    lstPrimitives.getSelectionModel().addListSelectionListener(actShowHistory);
    // the select action
    final SideButton selectButton = new SideButton(actSelect);
    selectButton.createArrow(e -> SelectionHistoryPopup.launch(selectButton, model.getSelectionHistory()));
    // the search button
    final SideButton searchButton = new SideButton(actSearch);
    searchButton.createArrow(e -> SearchPopupMenu.launch(searchButton), true);
    createLayout(lstPrimitives, true, Arrays.asList(selectButton, searchButton, new SideButton(actShowHistory)));
}
Also used : SideButton(org.openstreetmap.josm.gui.SideButton) PrimitiveRenderer(org.openstreetmap.josm.gui.PrimitiveRenderer)

Example 2 with SideButton

use of org.openstreetmap.josm.gui.SideButton in project josm by JOSM.

the class UserListDialog method build.

protected void build() {
    model = new UserTableModel();
    userTable = new JTable(model);
    userTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    userTable.addMouseListener(new DoubleClickAdapter());
    // -- select users primitives action
    // 
    selectionUsersPrimitivesAction = new SelectUsersPrimitivesAction();
    userTable.getSelectionModel().addListSelectionListener(selectionUsersPrimitivesAction);
    // -- info action
    // 
    ShowUserInfoAction showUserInfoAction = new ShowUserInfoAction();
    userTable.getSelectionModel().addListSelectionListener(showUserInfoAction);
    createLayout(userTable, true, Arrays.asList(new SideButton(selectionUsersPrimitivesAction), new SideButton(showUserInfoAction)));
    // -- popup menu
    popupMenu.add(new AbstractAction(tr("Copy")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            ClipboardUtils.copyString(getSelectedUsers().stream().map(User::getName).collect(Collectors.joining(", ")));
        }
    });
    userTable.addMouseListener(new PopupMenuLauncher(popupMenu));
}
Also used : PopupMenuLauncher(org.openstreetmap.josm.gui.widgets.PopupMenuLauncher) ActionEvent(java.awt.event.ActionEvent) JTable(javax.swing.JTable) SideButton(org.openstreetmap.josm.gui.SideButton) AbstractAction(javax.swing.AbstractAction)

Example 3 with SideButton

use of org.openstreetmap.josm.gui.SideButton in project josm by JOSM.

the class ConflictDialog method build.

/**
 * builds the GUI
 */
private void build() {
    synchronized (this) {
        model = new ConflictListModel();
        lstConflicts = new JList<>(model);
        lstConflicts.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        lstConflicts.setCellRenderer(new PrimitiveRenderer());
        lstConflicts.addMouseListener(new MouseEventHandler());
    }
    addListSelectionListener(e -> MainApplication.getMap().mapView.repaint());
    SideButton btnResolve = new SideButton(actResolve);
    addListSelectionListener(actResolve);
    SideButton btnSelect = new SideButton(actSelect);
    addListSelectionListener(actSelect);
    createLayout(lstConflicts, true, Arrays.asList(btnResolve, btnSelect));
    popupMenuHandler.addAction(MainApplication.getMenu().autoScaleActions.get(AutoScaleAction.AutoScaleMode.CONFLICT));
    ResolveToMyVersionAction resolveToMyVersionAction = new ResolveToMyVersionAction();
    ResolveToTheirVersionAction resolveToTheirVersionAction = new ResolveToTheirVersionAction();
    addListSelectionListener(resolveToMyVersionAction);
    addListSelectionListener(resolveToTheirVersionAction);
    JMenuItem btnResolveMy = popupMenuHandler.addAction(resolveToMyVersionAction);
    JMenuItem btnResolveTheir = popupMenuHandler.addAction(resolveToTheirVersionAction);
    popupMenuHandler.addListener(new ResolveButtonsPopupMenuListener(btnResolveTheir, btnResolveMy));
}
Also used : SideButton(org.openstreetmap.josm.gui.SideButton) JMenuItem(javax.swing.JMenuItem) PrimitiveRenderer(org.openstreetmap.josm.gui.PrimitiveRenderer)

Example 4 with SideButton

use of org.openstreetmap.josm.gui.SideButton in project Mapillary by JOSM.

the class MapillaryExpertFilterDialog method build.

/**
 * Builds the GUI.
 */
private void build() {
    userTable = new UserTable(filterModel);
    userTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    userTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    userTable.setSelectionModel(filterModel.getSelectionModel());
    TableHelper.adjustColumnWidth(userTable, 0, false);
    TableHelper.adjustColumnWidth(userTable, 1, false);
    TableHelper.adjustColumnWidth(userTable, 3, false);
    TableHelper.adjustColumnWidth(userTable, 4, false);
    userTable.setDefaultRenderer(Boolean.class, new BooleanRenderer());
    userTable.setDefaultRenderer(String.class, new StringRenderer());
    userTable.setDefaultEditor(String.class, new DefaultCellEditor(new DisableShortcutsOnFocusGainedTextField()));
    // Toggle filter "enabled" on Enter
    InputMapUtils.addEnterAction(userTable, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int index = userTable.getSelectedRow();
            if (index >= 0) {
                Filter filter = filterModel.getValue(index);
                filterModel.setValueAt(!filter.enable, index, MapillaryFilterTableModel.COL_ENABLED);
            }
        }
    });
    // Toggle filter "hiding" on Spacebar
    InputMapUtils.addSpacebarAction(userTable, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int index = userTable.getSelectedRow();
            if (index >= 0) {
                Filter filter = filterModel.getValue(index);
                filterModel.setValueAt(!filter.hiding, index, MapillaryFilterTableModel.COL_HIDING);
            }
        }
    });
    List<FilterAction> actions = Arrays.asList(addAction, editAction, deleteAction, moveUpAction, moveDownAction, sortAction, reverseAction);
    for (FilterAction action : actions) {
        TableHelper.adaptTo(action, filterModel);
        TableHelper.adaptTo(action, filterModel.getSelectionModel());
        action.updateEnabledState();
    }
    createLayout(userTable, true, actions.stream().map(a -> new SideButton(a, false)).collect(Collectors.toList()));
}
Also used : DisableShortcutsOnFocusGainedTextField(org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField) Filter(org.openstreetmap.josm.data.osm.Filter) ActionEvent(java.awt.event.ActionEvent) SideButton(org.openstreetmap.josm.gui.SideButton) AbstractAction(javax.swing.AbstractAction) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 5 with SideButton

use of org.openstreetmap.josm.gui.SideButton in project josm by openstreetmap.

the class MapPaintDialog method build.

protected void build() {
    model = new StylesModel();
    cbWireframe = new JCheckBox();
    JLabel wfLabel = new JLabel(tr("Wireframe View"), ImageProvider.get("dialogs/mappaint", "wireframe_small"), JLabel.HORIZONTAL);
    wfLabel.setFont(wfLabel.getFont().deriveFont(Font.PLAIN));
    wfLabel.setLabelFor(cbWireframe);
    cbWireframe.setModel(new ToggleButtonModel() {

        @Override
        public void setSelected(boolean b) {
            super.setSelected(b);
            tblStyles.setEnabled(!b);
            onoffAction.updateEnabledState();
            upAction.updateEnabledState();
            downAction.updateEnabledState();
        }
    });
    cbWireframe.addActionListener(e -> MainApplication.getMenu().wireFrameToggleAction.actionPerformed(null));
    cbWireframe.setBorder(new EmptyBorder(new Insets(1, 1, 1, 1)));
    tblStyles = new ScrollableTable(model);
    tblStyles.setSelectionModel(selectionModel);
    tblStyles.addMouseListener(new PopupMenuHandler());
    tblStyles.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    tblStyles.setBackground(UIManager.getColor("Panel.background"));
    tblStyles.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    tblStyles.setTableHeader(null);
    tblStyles.getColumnModel().getColumn(0).setMaxWidth(1);
    tblStyles.getColumnModel().getColumn(0).setResizable(false);
    tblStyles.getColumnModel().getColumn(0).setCellRenderer(new MyCheckBoxRenderer());
    tblStyles.getColumnModel().getColumn(1).setCellRenderer(new StyleSourceRenderer());
    tblStyles.setShowGrid(false);
    tblStyles.setIntercellSpacing(new Dimension(0, 0));
    JPanel p = new JPanel(new GridBagLayout());
    p.add(cbWireframe, GBC.std(0, 0));
    p.add(wfLabel, GBC.std(1, 0).weight(1, 0));
    p.add(tblStyles, GBC.std(0, 1).span(2).fill());
    reloadAction = new ReloadAction();
    onoffAction = new OnOffAction();
    upAction = new MoveUpDownAction(false);
    downAction = new MoveUpDownAction(true);
    selectionModel.addListSelectionListener(onoffAction);
    selectionModel.addListSelectionListener(reloadAction);
    selectionModel.addListSelectionListener(upAction);
    selectionModel.addListSelectionListener(downAction);
    // Toggle style on Enter and Spacebar
    InputMapUtils.addEnterAction(tblStyles, onoffAction);
    InputMapUtils.addSpacebarAction(tblStyles, onoffAction);
    createLayout(p, true, Arrays.asList(new SideButton(onoffAction, false), new SideButton(upAction, false), new SideButton(downAction, false), new SideButton(PREFERENCE_ACTION, false)));
}
Also used : JPanel(javax.swing.JPanel) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel) ToggleButtonModel(javax.swing.JToggleButton.ToggleButtonModel) Dimension(java.awt.Dimension) ScrollableTable(org.openstreetmap.josm.gui.widgets.ScrollableTable) JCheckBox(javax.swing.JCheckBox) SideButton(org.openstreetmap.josm.gui.SideButton) EmptyBorder(javax.swing.border.EmptyBorder)

Aggregations

SideButton (org.openstreetmap.josm.gui.SideButton)19 JPanel (javax.swing.JPanel)10 ActionEvent (java.awt.event.ActionEvent)5 AbstractAction (javax.swing.AbstractAction)5 BorderLayout (java.awt.BorderLayout)4 FlowLayout (java.awt.FlowLayout)4 JScrollPane (javax.swing.JScrollPane)4 PrimitiveRenderer (org.openstreetmap.josm.gui.PrimitiveRenderer)4 PopupMenuLauncher (org.openstreetmap.josm.gui.widgets.PopupMenuLauncher)4 DefaultCellEditor (javax.swing.DefaultCellEditor)3 Filter (org.openstreetmap.josm.data.osm.Filter)3 DisableShortcutsOnFocusGainedTextField (org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField)3 Dimension (java.awt.Dimension)2 GridBagLayout (java.awt.GridBagLayout)2 GridLayout (java.awt.GridLayout)2 Insets (java.awt.Insets)2 MouseAdapter (java.awt.event.MouseAdapter)2 MouseEvent (java.awt.event.MouseEvent)2 Collection (java.util.Collection)2 LinkedList (java.util.LinkedList)2