1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.dialogs.relation;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
|
---|
5 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
6 |
|
---|
7 | import java.awt.BorderLayout;
|
---|
8 | import java.awt.Dimension;
|
---|
9 | import java.awt.FlowLayout;
|
---|
10 | import java.awt.GraphicsEnvironment;
|
---|
11 | import java.awt.GridBagConstraints;
|
---|
12 | import java.awt.GridBagLayout;
|
---|
13 | import java.awt.event.ActionEvent;
|
---|
14 | import java.awt.event.FocusAdapter;
|
---|
15 | import java.awt.event.FocusEvent;
|
---|
16 | import java.awt.event.InputEvent;
|
---|
17 | import java.awt.event.KeyEvent;
|
---|
18 | import java.awt.event.MouseAdapter;
|
---|
19 | import java.awt.event.MouseEvent;
|
---|
20 | import java.awt.event.WindowAdapter;
|
---|
21 | import java.awt.event.WindowEvent;
|
---|
22 | import java.util.ArrayList;
|
---|
23 | import java.util.Collection;
|
---|
24 | import java.util.Collections;
|
---|
25 | import java.util.EnumSet;
|
---|
26 | import java.util.HashSet;
|
---|
27 | import java.util.List;
|
---|
28 | import java.util.Set;
|
---|
29 |
|
---|
30 | import javax.swing.AbstractAction;
|
---|
31 | import javax.swing.BorderFactory;
|
---|
32 | import javax.swing.InputMap;
|
---|
33 | import javax.swing.JButton;
|
---|
34 | import javax.swing.JComponent;
|
---|
35 | import javax.swing.JLabel;
|
---|
36 | import javax.swing.JMenu;
|
---|
37 | import javax.swing.JMenuItem;
|
---|
38 | import javax.swing.JOptionPane;
|
---|
39 | import javax.swing.JPanel;
|
---|
40 | import javax.swing.JScrollPane;
|
---|
41 | import javax.swing.JSplitPane;
|
---|
42 | import javax.swing.JTabbedPane;
|
---|
43 | import javax.swing.JToolBar;
|
---|
44 | import javax.swing.KeyStroke;
|
---|
45 | import javax.swing.event.ChangeEvent;
|
---|
46 | import javax.swing.event.ChangeListener;
|
---|
47 | import javax.swing.event.ListSelectionEvent;
|
---|
48 | import javax.swing.event.ListSelectionListener;
|
---|
49 |
|
---|
50 | import org.openstreetmap.josm.Main;
|
---|
51 | import org.openstreetmap.josm.actions.ExpertToggleAction;
|
---|
52 | import org.openstreetmap.josm.actions.JosmAction;
|
---|
53 | import org.openstreetmap.josm.command.ChangeCommand;
|
---|
54 | import org.openstreetmap.josm.command.Command;
|
---|
55 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
56 | import org.openstreetmap.josm.data.osm.Relation;
|
---|
57 | import org.openstreetmap.josm.data.osm.RelationMember;
|
---|
58 | import org.openstreetmap.josm.data.osm.Tag;
|
---|
59 | import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
|
---|
60 | import org.openstreetmap.josm.gui.DefaultNameFormatter;
|
---|
61 | import org.openstreetmap.josm.gui.MainMenu;
|
---|
62 | import org.openstreetmap.josm.gui.SideButton;
|
---|
63 | import org.openstreetmap.josm.gui.dialogs.relation.actions.AddSelectedAfterSelection;
|
---|
64 | import org.openstreetmap.josm.gui.dialogs.relation.actions.AddSelectedAtEndAction;
|
---|
65 | import org.openstreetmap.josm.gui.dialogs.relation.actions.AddSelectedAtStartAction;
|
---|
66 | import org.openstreetmap.josm.gui.dialogs.relation.actions.AddSelectedBeforeSelection;
|
---|
67 | import org.openstreetmap.josm.gui.dialogs.relation.actions.ApplyAction;
|
---|
68 | import org.openstreetmap.josm.gui.dialogs.relation.actions.CancelAction;
|
---|
69 | import org.openstreetmap.josm.gui.dialogs.relation.actions.CopyMembersAction;
|
---|
70 | import org.openstreetmap.josm.gui.dialogs.relation.actions.DeleteCurrentRelationAction;
|
---|
71 | import org.openstreetmap.josm.gui.dialogs.relation.actions.DownloadIncompleteMembersAction;
|
---|
72 | import org.openstreetmap.josm.gui.dialogs.relation.actions.DownloadSelectedIncompleteMembersAction;
|
---|
73 | import org.openstreetmap.josm.gui.dialogs.relation.actions.DuplicateRelationAction;
|
---|
74 | import org.openstreetmap.josm.gui.dialogs.relation.actions.EditAction;
|
---|
75 | import org.openstreetmap.josm.gui.dialogs.relation.actions.MoveDownAction;
|
---|
76 | import org.openstreetmap.josm.gui.dialogs.relation.actions.MoveUpAction;
|
---|
77 | import org.openstreetmap.josm.gui.dialogs.relation.actions.OKAction;
|
---|
78 | import org.openstreetmap.josm.gui.dialogs.relation.actions.PasteMembersAction;
|
---|
79 | import org.openstreetmap.josm.gui.dialogs.relation.actions.RemoveAction;
|
---|
80 | import org.openstreetmap.josm.gui.dialogs.relation.actions.RemoveSelectedAction;
|
---|
81 | import org.openstreetmap.josm.gui.dialogs.relation.actions.ReverseAction;
|
---|
82 | import org.openstreetmap.josm.gui.dialogs.relation.actions.SelectPrimitivesForSelectedMembersAction;
|
---|
83 | import org.openstreetmap.josm.gui.dialogs.relation.actions.SelectedMembersForSelectionAction;
|
---|
84 | import org.openstreetmap.josm.gui.dialogs.relation.actions.SetRoleAction;
|
---|
85 | import org.openstreetmap.josm.gui.dialogs.relation.actions.SortAction;
|
---|
86 | import org.openstreetmap.josm.gui.dialogs.relation.actions.SortBelowAction;
|
---|
87 | import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction;
|
---|
88 | import org.openstreetmap.josm.gui.help.HelpUtil;
|
---|
89 | import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
---|
90 | import org.openstreetmap.josm.gui.tagging.TagEditorPanel;
|
---|
91 | import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField;
|
---|
92 | import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList;
|
---|
93 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset;
|
---|
94 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetHandler;
|
---|
95 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType;
|
---|
96 | import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
|
---|
97 | import org.openstreetmap.josm.tools.CheckParameterUtil;
|
---|
98 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
99 | import org.openstreetmap.josm.tools.WindowGeometry;
|
---|
100 |
|
---|
101 | /**
|
---|
102 | * This dialog is for editing relations.
|
---|
103 | * @since 343
|
---|
104 | */
|
---|
105 | public class GenericRelationEditor extends RelationEditor {
|
---|
106 | /** the tag table and its model */
|
---|
107 | private final TagEditorPanel tagEditorPanel;
|
---|
108 | private final ReferringRelationsBrowser referrerBrowser;
|
---|
109 | private final ReferringRelationsBrowserModel referrerModel;
|
---|
110 |
|
---|
111 | /** the member table */
|
---|
112 | private MemberTable memberTable;
|
---|
113 | private final MemberTableModel memberTableModel;
|
---|
114 |
|
---|
115 | /** the model for the selection table */
|
---|
116 | private SelectionTable selectionTable;
|
---|
117 | private final SelectionTableModel selectionTableModel;
|
---|
118 |
|
---|
119 | private AutoCompletingTextField tfRole;
|
---|
120 |
|
---|
121 | /** the menu item in the windows menu. Required to properly
|
---|
122 | * hide on dialog close.
|
---|
123 | */
|
---|
124 | private JMenuItem windowMenuItem;
|
---|
125 | /**
|
---|
126 | * Button for performing the {@link org.openstreetmap.josm.gui.dialogs.relation.actions.SortBelowAction}.
|
---|
127 | */
|
---|
128 | private JButton sortBelowButton;
|
---|
129 | /**
|
---|
130 | * Action for performing the {@link CancelAction}
|
---|
131 | */
|
---|
132 | private CancelAction cancelAction;
|
---|
133 |
|
---|
134 | /**
|
---|
135 | * Creates a new relation editor for the given relation. The relation will be saved if the user
|
---|
136 | * selects "ok" in the editor.
|
---|
137 | *
|
---|
138 | * If no relation is given, will create an editor for a new relation.
|
---|
139 | *
|
---|
140 | * @param layer the {@link OsmDataLayer} the new or edited relation belongs to
|
---|
141 | * @param relation relation to edit, or null to create a new one.
|
---|
142 | * @param selectedMembers a collection of members which shall be selected initially
|
---|
143 | */
|
---|
144 | public GenericRelationEditor(OsmDataLayer layer, Relation relation, Collection<RelationMember> selectedMembers) {
|
---|
145 | super(layer, relation);
|
---|
146 |
|
---|
147 | setRememberWindowGeometry(getClass().getName() + ".geometry",
|
---|
148 | WindowGeometry.centerInWindow(Main.parent, new Dimension(700, 650)));
|
---|
149 |
|
---|
150 | final TaggingPresetHandler presetHandler = new TaggingPresetHandler() {
|
---|
151 |
|
---|
152 | @Override
|
---|
153 | public void updateTags(List<Tag> tags) {
|
---|
154 | tagEditorPanel.getModel().updateTags(tags);
|
---|
155 | }
|
---|
156 |
|
---|
157 | @Override
|
---|
158 | public Collection<OsmPrimitive> getSelection() {
|
---|
159 | Relation relation = new Relation();
|
---|
160 | tagEditorPanel.getModel().applyToPrimitive(relation);
|
---|
161 | return Collections.<OsmPrimitive>singletonList(relation);
|
---|
162 | }
|
---|
163 | };
|
---|
164 |
|
---|
165 | // init the various models
|
---|
166 | //
|
---|
167 | memberTableModel = new MemberTableModel(relation, getLayer(), presetHandler);
|
---|
168 | memberTableModel.register();
|
---|
169 | selectionTableModel = new SelectionTableModel(getLayer());
|
---|
170 | selectionTableModel.register();
|
---|
171 | referrerModel = new ReferringRelationsBrowserModel(relation);
|
---|
172 |
|
---|
173 | tagEditorPanel = new TagEditorPanel(relation, presetHandler);
|
---|
174 |
|
---|
175 | // populate the models
|
---|
176 | //
|
---|
177 | if (relation != null) {
|
---|
178 | tagEditorPanel.getModel().initFromPrimitive(relation);
|
---|
179 | this.memberTableModel.populate(relation);
|
---|
180 | if (!getLayer().data.getRelations().contains(relation)) {
|
---|
181 | // treat it as a new relation if it doesn't exist in the
|
---|
182 | // data set yet.
|
---|
183 | setRelation(null);
|
---|
184 | }
|
---|
185 | } else {
|
---|
186 | tagEditorPanel.getModel().clear();
|
---|
187 | this.memberTableModel.populate(null);
|
---|
188 | }
|
---|
189 | tagEditorPanel.getModel().ensureOneTag();
|
---|
190 |
|
---|
191 | JSplitPane pane = buildSplitPane();
|
---|
192 | pane.setPreferredSize(new Dimension(100, 100));
|
---|
193 |
|
---|
194 | JPanel pnl = new JPanel(new BorderLayout());
|
---|
195 | pnl.add(pane, BorderLayout.CENTER);
|
---|
196 | pnl.setBorder(BorderFactory.createRaisedBevelBorder());
|
---|
197 |
|
---|
198 | getContentPane().setLayout(new BorderLayout());
|
---|
199 | JTabbedPane tabbedPane = new JTabbedPane();
|
---|
200 | tabbedPane.add(tr("Tags and Members"), pnl);
|
---|
201 | referrerBrowser = new ReferringRelationsBrowser(getLayer(), referrerModel);
|
---|
202 | tabbedPane.add(tr("Parent Relations"), referrerBrowser);
|
---|
203 | tabbedPane.add(tr("Child Relations"), new ChildRelationBrowser(getLayer(), relation));
|
---|
204 | tabbedPane.addChangeListener(
|
---|
205 | new ChangeListener() {
|
---|
206 | @Override
|
---|
207 | public void stateChanged(ChangeEvent e) {
|
---|
208 | JTabbedPane sourceTabbedPane = (JTabbedPane) e.getSource();
|
---|
209 | int index = sourceTabbedPane.getSelectedIndex();
|
---|
210 | String title = sourceTabbedPane.getTitleAt(index);
|
---|
211 | if (title.equals(tr("Parent Relations"))) {
|
---|
212 | referrerBrowser.init();
|
---|
213 | }
|
---|
214 | }
|
---|
215 | }
|
---|
216 | );
|
---|
217 |
|
---|
218 | getContentPane().add(buildToolBar(), BorderLayout.NORTH);
|
---|
219 | getContentPane().add(tabbedPane, BorderLayout.CENTER);
|
---|
220 | getContentPane().add(buildOkCancelButtonPanel(), BorderLayout.SOUTH);
|
---|
221 |
|
---|
222 | setSize(findMaxDialogSize());
|
---|
223 |
|
---|
224 | setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
---|
225 | addWindowListener(
|
---|
226 | new WindowAdapter() {
|
---|
227 | @Override
|
---|
228 | public void windowOpened(WindowEvent e) {
|
---|
229 | cleanSelfReferences();
|
---|
230 | }
|
---|
231 |
|
---|
232 | @Override
|
---|
233 | public void windowClosing(WindowEvent e) {
|
---|
234 | cancel();
|
---|
235 | }
|
---|
236 | }
|
---|
237 | );
|
---|
238 | registerCopyPasteAction(tagEditorPanel.getPasteAction(),
|
---|
239 | "PASTE_TAGS",
|
---|
240 | // CHECKSTYLE.OFF: LineLength
|
---|
241 | Shortcut.registerShortcut("system:pastestyle", tr("Edit: {0}", tr("Paste Tags")), KeyEvent.VK_V, Shortcut.CTRL_SHIFT).getKeyStroke());
|
---|
242 | // CHECKSTYLE.ON: LineLength
|
---|
243 |
|
---|
244 | registerCopyPasteAction(new PasteMembersAction(memberTableModel, getLayer(), this) {
|
---|
245 | @Override
|
---|
246 | public void actionPerformed(ActionEvent e) {
|
---|
247 | super.actionPerformed(e);
|
---|
248 | tfRole.requestFocusInWindow();
|
---|
249 | }
|
---|
250 | }, "PASTE_MEMBERS", Shortcut.getPasteKeyStroke());
|
---|
251 |
|
---|
252 | registerCopyPasteAction(new CopyMembersAction(memberTableModel, getLayer(), this),
|
---|
253 | "COPY_MEMBERS", Shortcut.getCopyKeyStroke());
|
---|
254 |
|
---|
255 | tagEditorPanel.setNextFocusComponent(memberTable);
|
---|
256 | selectionTable.setFocusable(false);
|
---|
257 | memberTableModel.setSelectedMembers(selectedMembers);
|
---|
258 | HelpUtil.setHelpContext(getRootPane(), ht("/Dialog/RelationEditor"));
|
---|
259 | }
|
---|
260 |
|
---|
261 | protected void cancel() {
|
---|
262 | cancelAction.actionPerformed(null);
|
---|
263 | }
|
---|
264 |
|
---|
265 | /**
|
---|
266 | * Creates the toolbar
|
---|
267 | *
|
---|
268 | * @return the toolbar
|
---|
269 | */
|
---|
270 | protected JToolBar buildToolBar() {
|
---|
271 | JToolBar tb = new JToolBar();
|
---|
272 | tb.setFloatable(false);
|
---|
273 | tb.add(new ApplyAction(memberTable, memberTableModel, tagEditorPanel.getModel(), getLayer(), this));
|
---|
274 | tb.add(new DuplicateRelationAction(memberTableModel, tagEditorPanel.getModel(), getLayer()));
|
---|
275 | DeleteCurrentRelationAction deleteAction = new DeleteCurrentRelationAction(getLayer(), this);
|
---|
276 | addPropertyChangeListener(deleteAction);
|
---|
277 | tb.add(deleteAction);
|
---|
278 | return tb;
|
---|
279 | }
|
---|
280 |
|
---|
281 | /**
|
---|
282 | * builds the panel with the OK and the Cancel button
|
---|
283 | *
|
---|
284 | * @return the panel with the OK and the Cancel button
|
---|
285 | */
|
---|
286 | protected JPanel buildOkCancelButtonPanel() {
|
---|
287 | JPanel pnl = new JPanel(new FlowLayout(FlowLayout.CENTER));
|
---|
288 | pnl.add(new SideButton(new OKAction(memberTable, memberTableModel, tagEditorPanel.getModel(), getLayer(), this, tfRole)));
|
---|
289 | cancelAction = new CancelAction(memberTable, memberTableModel, tagEditorPanel.getModel(), getLayer(), this, tfRole);
|
---|
290 | pnl.add(new SideButton(cancelAction));
|
---|
291 | pnl.add(new SideButton(new ContextSensitiveHelpAction(ht("/Dialog/RelationEditor"))));
|
---|
292 | return pnl;
|
---|
293 | }
|
---|
294 |
|
---|
295 | /**
|
---|
296 | * builds the panel with the tag editor
|
---|
297 | *
|
---|
298 | * @return the panel with the tag editor
|
---|
299 | */
|
---|
300 | protected JPanel buildTagEditorPanel() {
|
---|
301 | JPanel pnl = new JPanel(new GridBagLayout());
|
---|
302 |
|
---|
303 | GridBagConstraints gc = new GridBagConstraints();
|
---|
304 | gc.gridx = 0;
|
---|
305 | gc.gridy = 0;
|
---|
306 | gc.gridheight = 1;
|
---|
307 | gc.gridwidth = 1;
|
---|
308 | gc.fill = GridBagConstraints.HORIZONTAL;
|
---|
309 | gc.anchor = GridBagConstraints.FIRST_LINE_START;
|
---|
310 | gc.weightx = 1.0;
|
---|
311 | gc.weighty = 0.0;
|
---|
312 | pnl.add(new JLabel(tr("Tags")), gc);
|
---|
313 |
|
---|
314 | gc.gridx = 0;
|
---|
315 | gc.gridy = 1;
|
---|
316 | gc.fill = GridBagConstraints.BOTH;
|
---|
317 | gc.anchor = GridBagConstraints.CENTER;
|
---|
318 | gc.weightx = 1.0;
|
---|
319 | gc.weighty = 1.0;
|
---|
320 | pnl.add(tagEditorPanel, gc);
|
---|
321 | return pnl;
|
---|
322 | }
|
---|
323 |
|
---|
324 | /**
|
---|
325 | * builds the panel for the relation member editor
|
---|
326 | *
|
---|
327 | * @return the panel for the relation member editor
|
---|
328 | */
|
---|
329 | protected JPanel buildMemberEditorPanel() {
|
---|
330 | final JPanel pnl = new JPanel(new GridBagLayout());
|
---|
331 | // setting up the member table
|
---|
332 | memberTable = new MemberTable(getLayer(), getRelation(), memberTableModel);
|
---|
333 | memberTable.addMouseListener(new MemberTableDblClickAdapter());
|
---|
334 | memberTableModel.addMemberModelListener(memberTable);
|
---|
335 |
|
---|
336 | final JScrollPane scrollPane = new JScrollPane(memberTable);
|
---|
337 |
|
---|
338 | GridBagConstraints gc = new GridBagConstraints();
|
---|
339 | gc.gridx = 0;
|
---|
340 | gc.gridy = 0;
|
---|
341 | gc.gridwidth = 2;
|
---|
342 | gc.fill = GridBagConstraints.HORIZONTAL;
|
---|
343 | gc.anchor = GridBagConstraints.FIRST_LINE_START;
|
---|
344 | gc.weightx = 1.0;
|
---|
345 | gc.weighty = 0.0;
|
---|
346 | pnl.add(new JLabel(tr("Members")), gc);
|
---|
347 |
|
---|
348 | gc.gridx = 0;
|
---|
349 | gc.gridy = 1;
|
---|
350 | gc.gridheight = 2;
|
---|
351 | gc.gridwidth = 1;
|
---|
352 | gc.fill = GridBagConstraints.VERTICAL;
|
---|
353 | gc.anchor = GridBagConstraints.NORTHWEST;
|
---|
354 | gc.weightx = 0.0;
|
---|
355 | gc.weighty = 1.0;
|
---|
356 | pnl.add(buildLeftButtonPanel(), gc);
|
---|
357 |
|
---|
358 | gc.gridx = 1;
|
---|
359 | gc.gridy = 1;
|
---|
360 | gc.gridheight = 1;
|
---|
361 | gc.fill = GridBagConstraints.BOTH;
|
---|
362 | gc.anchor = GridBagConstraints.CENTER;
|
---|
363 | gc.weightx = 0.6;
|
---|
364 | gc.weighty = 1.0;
|
---|
365 | pnl.add(scrollPane, gc);
|
---|
366 |
|
---|
367 | // --- role editing
|
---|
368 | JPanel p3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
---|
369 | p3.add(new JLabel(tr("Apply Role:")));
|
---|
370 | tfRole = new AutoCompletingTextField(10);
|
---|
371 | tfRole.setToolTipText(tr("Enter a role and apply it to the selected relation members"));
|
---|
372 | tfRole.addFocusListener(new FocusAdapter() {
|
---|
373 | @Override
|
---|
374 | public void focusGained(FocusEvent e) {
|
---|
375 | tfRole.selectAll();
|
---|
376 | }
|
---|
377 | });
|
---|
378 | tfRole.setAutoCompletionList(new AutoCompletionList());
|
---|
379 | tfRole.addFocusListener(
|
---|
380 | new FocusAdapter() {
|
---|
381 | @Override
|
---|
382 | public void focusGained(FocusEvent e) {
|
---|
383 | AutoCompletionList list = tfRole.getAutoCompletionList();
|
---|
384 | if (list != null) {
|
---|
385 | list.clear();
|
---|
386 | getLayer().data.getAutoCompletionManager().populateWithMemberRoles(list, getRelation());
|
---|
387 | }
|
---|
388 | }
|
---|
389 | }
|
---|
390 | );
|
---|
391 | tfRole.setText(Main.pref.get("relation.editor.generic.lastrole", ""));
|
---|
392 | p3.add(tfRole);
|
---|
393 | SetRoleAction setRoleAction = new SetRoleAction(memberTable, memberTableModel, tfRole);
|
---|
394 | memberTableModel.getSelectionModel().addListSelectionListener(setRoleAction);
|
---|
395 | tfRole.getDocument().addDocumentListener(setRoleAction);
|
---|
396 | tfRole.addActionListener(setRoleAction);
|
---|
397 | memberTableModel.getSelectionModel().addListSelectionListener(
|
---|
398 | new ListSelectionListener() {
|
---|
399 | @Override
|
---|
400 | public void valueChanged(ListSelectionEvent e) {
|
---|
401 | tfRole.setEnabled(memberTable.getSelectedRowCount() > 0);
|
---|
402 | }
|
---|
403 | }
|
---|
404 | );
|
---|
405 | tfRole.setEnabled(memberTable.getSelectedRowCount() > 0);
|
---|
406 | SideButton btnApply = new SideButton(setRoleAction);
|
---|
407 | btnApply.setPreferredSize(new Dimension(20, 20));
|
---|
408 | btnApply.setText("");
|
---|
409 | p3.add(btnApply);
|
---|
410 |
|
---|
411 | gc.gridx = 1;
|
---|
412 | gc.gridy = 2;
|
---|
413 | gc.fill = GridBagConstraints.HORIZONTAL;
|
---|
414 | gc.anchor = GridBagConstraints.LAST_LINE_START;
|
---|
415 | gc.weightx = 1.0;
|
---|
416 | gc.weighty = 0.0;
|
---|
417 | pnl.add(p3, gc);
|
---|
418 |
|
---|
419 | JPanel pnl2 = new JPanel(new GridBagLayout());
|
---|
420 |
|
---|
421 | gc.gridx = 0;
|
---|
422 | gc.gridy = 0;
|
---|
423 | gc.gridheight = 1;
|
---|
424 | gc.gridwidth = 3;
|
---|
425 | gc.fill = GridBagConstraints.HORIZONTAL;
|
---|
426 | gc.anchor = GridBagConstraints.FIRST_LINE_START;
|
---|
427 | gc.weightx = 1.0;
|
---|
428 | gc.weighty = 0.0;
|
---|
429 | pnl2.add(new JLabel(tr("Selection")), gc);
|
---|
430 |
|
---|
431 | gc.gridx = 0;
|
---|
432 | gc.gridy = 1;
|
---|
433 | gc.gridheight = 1;
|
---|
434 | gc.gridwidth = 1;
|
---|
435 | gc.fill = GridBagConstraints.VERTICAL;
|
---|
436 | gc.anchor = GridBagConstraints.NORTHWEST;
|
---|
437 | gc.weightx = 0.0;
|
---|
438 | gc.weighty = 1.0;
|
---|
439 | pnl2.add(buildSelectionControlButtonPanel(), gc);
|
---|
440 |
|
---|
441 | gc.gridx = 1;
|
---|
442 | gc.gridy = 1;
|
---|
443 | gc.weightx = 1.0;
|
---|
444 | gc.weighty = 1.0;
|
---|
445 | gc.fill = GridBagConstraints.BOTH;
|
---|
446 | pnl2.add(buildSelectionTablePanel(), gc);
|
---|
447 |
|
---|
448 | final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
|
---|
449 | splitPane.setLeftComponent(pnl);
|
---|
450 | splitPane.setRightComponent(pnl2);
|
---|
451 | splitPane.setOneTouchExpandable(false);
|
---|
452 | addWindowListener(new WindowAdapter() {
|
---|
453 | @Override
|
---|
454 | public void windowOpened(WindowEvent e) {
|
---|
455 | // has to be called when the window is visible, otherwise
|
---|
456 | // no effect
|
---|
457 | splitPane.setDividerLocation(0.6);
|
---|
458 | }
|
---|
459 | });
|
---|
460 |
|
---|
461 | JPanel pnl3 = new JPanel(new BorderLayout());
|
---|
462 | pnl3.add(splitPane, BorderLayout.CENTER);
|
---|
463 |
|
---|
464 | return pnl3;
|
---|
465 | }
|
---|
466 |
|
---|
467 | /**
|
---|
468 | * builds the panel with the table displaying the currently selected primitives
|
---|
469 | *
|
---|
470 | * @return panel with current selection
|
---|
471 | */
|
---|
472 | protected JPanel buildSelectionTablePanel() {
|
---|
473 | JPanel pnl = new JPanel(new BorderLayout());
|
---|
474 | MemberRoleCellEditor ce = (MemberRoleCellEditor) memberTable.getColumnModel().getColumn(0).getCellEditor();
|
---|
475 | selectionTable = new SelectionTable(selectionTableModel, new SelectionTableColumnModel(memberTableModel));
|
---|
476 | selectionTable.setMemberTableModel(memberTableModel);
|
---|
477 | selectionTable.setRowHeight(ce.getEditor().getPreferredSize().height);
|
---|
478 | pnl.add(new JScrollPane(selectionTable), BorderLayout.CENTER);
|
---|
479 | return pnl;
|
---|
480 | }
|
---|
481 |
|
---|
482 | /**
|
---|
483 | * builds the {@link JSplitPane} which divides the editor in an upper and a lower half
|
---|
484 | *
|
---|
485 | * @return the split panel
|
---|
486 | */
|
---|
487 | protected JSplitPane buildSplitPane() {
|
---|
488 | final JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
---|
489 | pane.setTopComponent(buildTagEditorPanel());
|
---|
490 | pane.setBottomComponent(buildMemberEditorPanel());
|
---|
491 | pane.setOneTouchExpandable(true);
|
---|
492 | addWindowListener(new WindowAdapter() {
|
---|
493 | @Override
|
---|
494 | public void windowOpened(WindowEvent e) {
|
---|
495 | // has to be called when the window is visible, otherwise no effect
|
---|
496 | pane.setDividerLocation(0.3);
|
---|
497 | }
|
---|
498 | });
|
---|
499 | return pane;
|
---|
500 | }
|
---|
501 |
|
---|
502 | /**
|
---|
503 | * build the panel with the buttons on the left
|
---|
504 | *
|
---|
505 | * @return left button panel
|
---|
506 | */
|
---|
507 | protected JToolBar buildLeftButtonPanel() {
|
---|
508 | JToolBar tb = new JToolBar();
|
---|
509 | tb.setOrientation(JToolBar.VERTICAL);
|
---|
510 | tb.setFloatable(false);
|
---|
511 |
|
---|
512 | // -- move up action
|
---|
513 | MoveUpAction moveUpAction = new MoveUpAction(memberTable, memberTableModel, "moveUp");
|
---|
514 | memberTableModel.getSelectionModel().addListSelectionListener(moveUpAction);
|
---|
515 | tb.add(moveUpAction);
|
---|
516 |
|
---|
517 | // -- move down action
|
---|
518 | MoveDownAction moveDownAction = new MoveDownAction(memberTable, memberTableModel, "moveDown");
|
---|
519 | memberTableModel.getSelectionModel().addListSelectionListener(moveDownAction);
|
---|
520 | tb.add(moveDownAction);
|
---|
521 |
|
---|
522 | tb.addSeparator();
|
---|
523 |
|
---|
524 | // -- edit action
|
---|
525 | EditAction editAction = new EditAction(memberTable, memberTableModel, getLayer());
|
---|
526 | memberTableModel.getSelectionModel().addListSelectionListener(editAction);
|
---|
527 | tb.add(editAction);
|
---|
528 |
|
---|
529 | // -- delete action
|
---|
530 | RemoveAction removeSelectedAction = new RemoveAction(memberTable, memberTableModel, "removeSelected");
|
---|
531 | memberTable.getSelectionModel().addListSelectionListener(removeSelectedAction);
|
---|
532 | tb.add(removeSelectedAction);
|
---|
533 |
|
---|
534 | tb.addSeparator();
|
---|
535 | // -- sort action
|
---|
536 | SortAction sortAction = new SortAction(memberTable, memberTableModel);
|
---|
537 | memberTableModel.addTableModelListener(sortAction);
|
---|
538 | tb.add(sortAction);
|
---|
539 | final SortBelowAction sortBelowAction = new SortBelowAction(memberTable, memberTableModel);
|
---|
540 | memberTableModel.addTableModelListener(sortBelowAction);
|
---|
541 | memberTableModel.getSelectionModel().addListSelectionListener(sortBelowAction);
|
---|
542 | sortBelowButton = tb.add(sortBelowAction);
|
---|
543 |
|
---|
544 | // -- reverse action
|
---|
545 | ReverseAction reverseAction = new ReverseAction(memberTable, memberTableModel);
|
---|
546 | memberTableModel.addTableModelListener(reverseAction);
|
---|
547 | tb.add(reverseAction);
|
---|
548 |
|
---|
549 | tb.addSeparator();
|
---|
550 |
|
---|
551 | // -- download action
|
---|
552 | DownloadIncompleteMembersAction downloadIncompleteMembersAction = new DownloadIncompleteMembersAction(
|
---|
553 | memberTable, memberTableModel, "downloadIncomplete", getLayer(), this);
|
---|
554 | memberTable.getModel().addTableModelListener(downloadIncompleteMembersAction);
|
---|
555 | tb.add(downloadIncompleteMembersAction);
|
---|
556 |
|
---|
557 | // -- download selected action
|
---|
558 | DownloadSelectedIncompleteMembersAction downloadSelectedIncompleteMembersAction = new DownloadSelectedIncompleteMembersAction(
|
---|
559 | memberTable, memberTableModel, null, getLayer(), this);
|
---|
560 | memberTable.getModel().addTableModelListener(downloadSelectedIncompleteMembersAction);
|
---|
561 | memberTable.getSelectionModel().addListSelectionListener(downloadSelectedIncompleteMembersAction);
|
---|
562 | tb.add(downloadSelectedIncompleteMembersAction);
|
---|
563 |
|
---|
564 | InputMap inputMap = memberTable.getInputMap(MemberTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
---|
565 | inputMap.put((KeyStroke) removeSelectedAction.getValue(AbstractAction.ACCELERATOR_KEY), "removeSelected");
|
---|
566 | inputMap.put((KeyStroke) moveUpAction.getValue(AbstractAction.ACCELERATOR_KEY), "moveUp");
|
---|
567 | inputMap.put((KeyStroke) moveDownAction.getValue(AbstractAction.ACCELERATOR_KEY), "moveDown");
|
---|
568 | inputMap.put((KeyStroke) downloadIncompleteMembersAction.getValue(AbstractAction.ACCELERATOR_KEY), "downloadIncomplete");
|
---|
569 |
|
---|
570 | return tb;
|
---|
571 | }
|
---|
572 |
|
---|
573 | /**
|
---|
574 | * build the panel with the buttons for adding or removing the current selection
|
---|
575 | *
|
---|
576 | * @return control buttons panel for selection/members
|
---|
577 | */
|
---|
578 | protected JToolBar buildSelectionControlButtonPanel() {
|
---|
579 | JToolBar tb = new JToolBar(JToolBar.VERTICAL);
|
---|
580 | tb.setFloatable(false);
|
---|
581 |
|
---|
582 | // -- add at start action
|
---|
583 | AddSelectedAtStartAction addSelectionAction = new AddSelectedAtStartAction(
|
---|
584 | memberTableModel, selectionTableModel, this);
|
---|
585 | selectionTableModel.addTableModelListener(addSelectionAction);
|
---|
586 | tb.add(addSelectionAction);
|
---|
587 |
|
---|
588 | // -- add before selected action
|
---|
589 | AddSelectedBeforeSelection addSelectedBeforeSelectionAction = new AddSelectedBeforeSelection(
|
---|
590 | memberTableModel, selectionTableModel, this);
|
---|
591 | selectionTableModel.addTableModelListener(addSelectedBeforeSelectionAction);
|
---|
592 | memberTableModel.getSelectionModel().addListSelectionListener(addSelectedBeforeSelectionAction);
|
---|
593 | tb.add(addSelectedBeforeSelectionAction);
|
---|
594 |
|
---|
595 | // -- add after selected action
|
---|
596 | AddSelectedAfterSelection addSelectedAfterSelectionAction = new AddSelectedAfterSelection(
|
---|
597 | memberTableModel, selectionTableModel, this);
|
---|
598 | selectionTableModel.addTableModelListener(addSelectedAfterSelectionAction);
|
---|
599 | memberTableModel.getSelectionModel().addListSelectionListener(addSelectedAfterSelectionAction);
|
---|
600 | tb.add(addSelectedAfterSelectionAction);
|
---|
601 |
|
---|
602 | // -- add at end action
|
---|
603 | AddSelectedAtEndAction addSelectedAtEndAction = new AddSelectedAtEndAction(
|
---|
604 | memberTableModel, selectionTableModel, this);
|
---|
605 | selectionTableModel.addTableModelListener(addSelectedAtEndAction);
|
---|
606 | tb.add(addSelectedAtEndAction);
|
---|
607 |
|
---|
608 | tb.addSeparator();
|
---|
609 |
|
---|
610 | // -- select members action
|
---|
611 | SelectedMembersForSelectionAction selectMembersForSelectionAction = new SelectedMembersForSelectionAction(
|
---|
612 | memberTableModel, selectionTableModel, getLayer());
|
---|
613 | selectionTableModel.addTableModelListener(selectMembersForSelectionAction);
|
---|
614 | memberTableModel.addTableModelListener(selectMembersForSelectionAction);
|
---|
615 | tb.add(selectMembersForSelectionAction);
|
---|
616 |
|
---|
617 | // -- select action
|
---|
618 | SelectPrimitivesForSelectedMembersAction selectAction = new SelectPrimitivesForSelectedMembersAction(
|
---|
619 | memberTable, memberTableModel, getLayer());
|
---|
620 | memberTable.getSelectionModel().addListSelectionListener(selectAction);
|
---|
621 | tb.add(selectAction);
|
---|
622 |
|
---|
623 | tb.addSeparator();
|
---|
624 |
|
---|
625 | // -- remove selected action
|
---|
626 | RemoveSelectedAction removeSelectedAction = new RemoveSelectedAction(memberTableModel, selectionTableModel, getLayer());
|
---|
627 | selectionTableModel.addTableModelListener(removeSelectedAction);
|
---|
628 | tb.add(removeSelectedAction);
|
---|
629 |
|
---|
630 | return tb;
|
---|
631 | }
|
---|
632 |
|
---|
633 | @Override
|
---|
634 | protected Dimension findMaxDialogSize() {
|
---|
635 | return new Dimension(700, 650);
|
---|
636 | }
|
---|
637 |
|
---|
638 | @Override
|
---|
639 | public void setVisible(boolean visible) {
|
---|
640 | if (visible) {
|
---|
641 | tagEditorPanel.initAutoCompletion(getLayer());
|
---|
642 | }
|
---|
643 | super.setVisible(visible);
|
---|
644 | if (visible) {
|
---|
645 | sortBelowButton.setVisible(ExpertToggleAction.isExpert());
|
---|
646 | RelationDialogManager.getRelationDialogManager().positionOnScreen(this);
|
---|
647 | if (windowMenuItem == null) {
|
---|
648 | addToWindowMenu();
|
---|
649 | }
|
---|
650 | tagEditorPanel.requestFocusInWindow();
|
---|
651 | } else {
|
---|
652 | // make sure all registered listeners are unregistered
|
---|
653 | //
|
---|
654 | memberTable.stopHighlighting();
|
---|
655 | selectionTableModel.unregister();
|
---|
656 | memberTableModel.unregister();
|
---|
657 | memberTable.unlinkAsListener();
|
---|
658 | if (windowMenuItem != null) {
|
---|
659 | Main.main.menu.windowMenu.remove(windowMenuItem);
|
---|
660 | windowMenuItem = null;
|
---|
661 | }
|
---|
662 | dispose();
|
---|
663 | }
|
---|
664 | }
|
---|
665 |
|
---|
666 | /** adds current relation editor to the windows menu (in the "volatile" group) o*/
|
---|
667 | protected void addToWindowMenu() {
|
---|
668 | String name = getRelation() == null ? tr("New Relation") : getRelation().getLocalName();
|
---|
669 | final String tt = tr("Focus Relation Editor with relation ''{0}'' in layer ''{1}''",
|
---|
670 | name, getLayer().getName());
|
---|
671 | name = tr("Relation Editor: {0}", name == null ? getRelation().getId() : name);
|
---|
672 | final JMenu wm = Main.main.menu.windowMenu;
|
---|
673 | final JosmAction focusAction = new JosmAction(name, "dialogs/relationlist", tt, null, false, false) {
|
---|
674 | @Override
|
---|
675 | public void actionPerformed(ActionEvent e) {
|
---|
676 | final RelationEditor r = (RelationEditor) getValue("relationEditor");
|
---|
677 | r.setVisible(true);
|
---|
678 | }
|
---|
679 | };
|
---|
680 | focusAction.putValue("relationEditor", this);
|
---|
681 | windowMenuItem = MainMenu.add(wm, focusAction, MainMenu.WINDOW_MENU_GROUP.VOLATILE);
|
---|
682 | }
|
---|
683 |
|
---|
684 | /**
|
---|
685 | * checks whether the current relation has members referring to itself. If so,
|
---|
686 | * warns the users and provides an option for removing these members.
|
---|
687 | *
|
---|
688 | */
|
---|
689 | protected void cleanSelfReferences() {
|
---|
690 | List<OsmPrimitive> toCheck = new ArrayList<>();
|
---|
691 | toCheck.add(getRelation());
|
---|
692 | if (memberTableModel.hasMembersReferringTo(toCheck)) {
|
---|
693 | int ret = ConditionalOptionPaneUtil.showOptionDialog(
|
---|
694 | "clean_relation_self_references",
|
---|
695 | Main.parent,
|
---|
696 | tr("<html>There is at least one member in this relation referring<br>"
|
---|
697 | + "to the relation itself.<br>"
|
---|
698 | + "This creates circular dependencies and is discouraged.<br>"
|
---|
699 | + "How do you want to proceed with circular dependencies?</html>"),
|
---|
700 | tr("Warning"),
|
---|
701 | JOptionPane.YES_NO_OPTION,
|
---|
702 | JOptionPane.WARNING_MESSAGE,
|
---|
703 | new String[]{tr("Remove them, clean up relation"), tr("Ignore them, leave relation as is")},
|
---|
704 | tr("Remove them, clean up relation")
|
---|
705 | );
|
---|
706 | switch(ret) {
|
---|
707 | case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION:
|
---|
708 | case JOptionPane.CLOSED_OPTION:
|
---|
709 | case JOptionPane.NO_OPTION:
|
---|
710 | return;
|
---|
711 | case JOptionPane.YES_OPTION:
|
---|
712 | memberTableModel.removeMembersReferringTo(toCheck);
|
---|
713 | break;
|
---|
714 | }
|
---|
715 | }
|
---|
716 | }
|
---|
717 |
|
---|
718 | private void registerCopyPasteAction(AbstractAction action, Object actionName, KeyStroke shortcut) {
|
---|
719 | int mods = shortcut.getModifiers();
|
---|
720 | int code = shortcut.getKeyCode();
|
---|
721 | if (code != KeyEvent.VK_INSERT && (mods == 0 || mods == InputEvent.SHIFT_DOWN_MASK)) {
|
---|
722 | Main.info(tr("Sorry, shortcut \"{0}\" can not be enabled in Relation editor dialog"), shortcut);
|
---|
723 | return;
|
---|
724 | }
|
---|
725 | getRootPane().getActionMap().put(actionName, action);
|
---|
726 | getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(shortcut, actionName);
|
---|
727 | // Assign also to JTables because they have their own Copy&Paste implementation
|
---|
728 | // (which is disabled in this case but eats key shortcuts anyway)
|
---|
729 | memberTable.getInputMap(JComponent.WHEN_FOCUSED).put(shortcut, actionName);
|
---|
730 | memberTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(shortcut, actionName);
|
---|
731 | memberTable.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(shortcut, actionName);
|
---|
732 | selectionTable.getInputMap(JComponent.WHEN_FOCUSED).put(shortcut, actionName);
|
---|
733 | selectionTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(shortcut, actionName);
|
---|
734 | selectionTable.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(shortcut, actionName);
|
---|
735 | }
|
---|
736 |
|
---|
737 | /**
|
---|
738 | * Exception thrown when user aborts add operation.
|
---|
739 | */
|
---|
740 | public static class AddAbortException extends Exception {
|
---|
741 | }
|
---|
742 |
|
---|
743 | /**
|
---|
744 | * Asks confirmationbefore adding a primitive.
|
---|
745 | * @param primitive primitive to add
|
---|
746 | * @return {@code true} is user confirms the operation, {@code false} otherwise
|
---|
747 | * @throws AddAbortException if user aborts operation
|
---|
748 | */
|
---|
749 | public static boolean confirmAddingPrimitive(OsmPrimitive primitive) throws AddAbortException {
|
---|
750 | String msg = tr("<html>This relation already has one or more members referring to<br>"
|
---|
751 | + "the object ''{0}''<br>"
|
---|
752 | + "<br>"
|
---|
753 | + "Do you really want to add another relation member?</html>",
|
---|
754 | primitive.getDisplayName(DefaultNameFormatter.getInstance())
|
---|
755 | );
|
---|
756 | int ret = ConditionalOptionPaneUtil.showOptionDialog(
|
---|
757 | "add_primitive_to_relation",
|
---|
758 | Main.parent,
|
---|
759 | msg,
|
---|
760 | tr("Multiple members referring to same object."),
|
---|
761 | JOptionPane.YES_NO_CANCEL_OPTION,
|
---|
762 | JOptionPane.WARNING_MESSAGE,
|
---|
763 | null,
|
---|
764 | null
|
---|
765 | );
|
---|
766 | switch(ret) {
|
---|
767 | case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION:
|
---|
768 | case JOptionPane.YES_OPTION:
|
---|
769 | return true;
|
---|
770 | case JOptionPane.NO_OPTION:
|
---|
771 | case JOptionPane.CLOSED_OPTION:
|
---|
772 | return false;
|
---|
773 | case JOptionPane.CANCEL_OPTION:
|
---|
774 | default:
|
---|
775 | throw new AddAbortException();
|
---|
776 | }
|
---|
777 | }
|
---|
778 |
|
---|
779 | /**
|
---|
780 | * Warn about circular references.
|
---|
781 | * @param primitive the concerned primitive
|
---|
782 | */
|
---|
783 | public static void warnOfCircularReferences(OsmPrimitive primitive) {
|
---|
784 | String msg = tr("<html>You are trying to add a relation to itself.<br>"
|
---|
785 | + "<br>"
|
---|
786 | + "This creates circular references and is therefore discouraged.<br>"
|
---|
787 | + "Skipping relation ''{0}''.</html>",
|
---|
788 | primitive.getDisplayName(DefaultNameFormatter.getInstance()));
|
---|
789 | JOptionPane.showMessageDialog(
|
---|
790 | Main.parent,
|
---|
791 | msg,
|
---|
792 | tr("Warning"),
|
---|
793 | JOptionPane.WARNING_MESSAGE);
|
---|
794 | }
|
---|
795 |
|
---|
796 | /**
|
---|
797 | * Adds primitives to a given relation.
|
---|
798 | * @param orig The relation to modify
|
---|
799 | * @param primitivesToAdd The primitives to add as relation members
|
---|
800 | * @return The resulting command
|
---|
801 | * @throws IllegalArgumentException if orig is null
|
---|
802 | */
|
---|
803 | public static Command addPrimitivesToRelation(final Relation orig, Collection<? extends OsmPrimitive> primitivesToAdd) {
|
---|
804 | CheckParameterUtil.ensureParameterNotNull(orig, "orig");
|
---|
805 | try {
|
---|
806 | final Collection<TaggingPreset> presets = TaggingPresets.getMatchingPresets(
|
---|
807 | EnumSet.of(TaggingPresetType.forPrimitive(orig)), orig.getKeys(), false);
|
---|
808 | Relation relation = new Relation(orig);
|
---|
809 | boolean modified = false;
|
---|
810 | for (OsmPrimitive p : primitivesToAdd) {
|
---|
811 | if (p instanceof Relation && orig.equals(p)) {
|
---|
812 | if (!GraphicsEnvironment.isHeadless()) {
|
---|
813 | warnOfCircularReferences(p);
|
---|
814 | }
|
---|
815 | continue;
|
---|
816 | } else if (MemberTableModel.hasMembersReferringTo(relation.getMembers(), Collections.singleton(p))
|
---|
817 | && !confirmAddingPrimitive(p)) {
|
---|
818 | continue;
|
---|
819 | }
|
---|
820 | final Set<String> roles = findSuggestedRoles(presets, p);
|
---|
821 | relation.addMember(new RelationMember(roles.size() == 1 ? roles.iterator().next() : "", p));
|
---|
822 | modified = true;
|
---|
823 | }
|
---|
824 | return modified ? new ChangeCommand(orig, relation) : null;
|
---|
825 | } catch (AddAbortException ign) {
|
---|
826 | return null;
|
---|
827 | }
|
---|
828 | }
|
---|
829 |
|
---|
830 | protected static Set<String> findSuggestedRoles(final Collection<TaggingPreset> presets, OsmPrimitive p) {
|
---|
831 | final Set<String> roles = new HashSet<>();
|
---|
832 | for (TaggingPreset preset : presets) {
|
---|
833 | String role = preset.suggestRoleForOsmPrimitive(p);
|
---|
834 | if (role != null && !role.isEmpty()) {
|
---|
835 | roles.add(role);
|
---|
836 | }
|
---|
837 | }
|
---|
838 | return roles;
|
---|
839 | }
|
---|
840 |
|
---|
841 | class MemberTableDblClickAdapter extends MouseAdapter {
|
---|
842 | @Override
|
---|
843 | public void mouseClicked(MouseEvent e) {
|
---|
844 | if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
|
---|
845 | new EditAction(memberTable, memberTableModel, getLayer()).actionPerformed(null);
|
---|
846 | }
|
---|
847 | }
|
---|
848 | }
|
---|
849 | }
|
---|