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