Revision 2910
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/DefaultZoomDialog.java | ||
---|---|---|
31 | 31 |
import java.awt.event.ActionEvent; |
32 | 32 |
import java.awt.event.ActionListener; |
33 | 33 |
import java.awt.event.KeyEvent; |
34 |
import java.util.List; |
|
35 |
import javax.swing.Action; |
|
34 | 36 |
|
35 | 37 |
import javax.swing.BorderFactory; |
36 | 38 |
import javax.swing.JButton; |
... | ... | |
57 | 59 |
private JTextArea text = null; |
58 | 60 |
private int action = WindowManager_v2.BUTTON_CANCEL; |
59 | 61 |
private JButton btnClose; |
62 |
private List<Action> customActions; |
|
60 | 63 |
|
61 | 64 |
public DefaultZoomDialog(Component parent, String title, WindowManager.MODE mode) { |
62 | 65 |
super(getParentWindow(parent), title, mode == WindowManager.MODE.WINDOW ? ModalityType.MODELESS : ModalityType.DOCUMENT_MODAL); |
63 | 66 |
} |
64 | 67 |
|
65 |
public DefaultZoomDialog(Component parent, String title, String value, WindowManager.MODE mode) { |
|
68 |
public DefaultZoomDialog(Component parent, String title, String value, WindowManager.MODE mode, List<Action> customActions) {
|
|
66 | 69 |
this(parent, title, mode); |
67 | 70 |
this.value = value; |
71 |
this.customActions = customActions; |
|
68 | 72 |
initComponents(); |
69 | 73 |
|
70 | 74 |
} |
... | ... | |
124 | 128 |
p.add(this.btnClose, BorderLayout.LINE_END); |
125 | 129 |
|
126 | 130 |
panel.add(p, BorderLayout.PAGE_END); |
127 |
ContextMenuUtils.setDefaultContextMenu(text, false); |
|
131 |
ContextMenuUtils.setDefaultContextMenu(text, false, null, customActions);
|
|
128 | 132 |
|
129 | 133 |
this.setPreferredSize(ToolsSwingUtils.ensureRowsCols(this.getPreferredSize(), 15, 100, 25, 150)); |
130 | 134 |
|
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/ContextMenuUtils.java | ||
---|---|---|
31 | 31 |
public class ContextMenuUtils { |
32 | 32 |
|
33 | 33 |
public static void setDefaultContextMenu(final JComponent component) { |
34 |
ContextMenuUtils.setDefaultContextMenu(component, true, null); |
|
34 |
ContextMenuUtils.setDefaultContextMenu(component, true, null, null);
|
|
35 | 35 |
} |
36 | 36 |
|
37 | 37 |
public static void setDefaultContextMenu(final JComponent component, boolean addEditorDialog) { |
38 |
ContextMenuUtils.setDefaultContextMenu(component, addEditorDialog, null); |
|
38 |
ContextMenuUtils.setDefaultContextMenu(component, addEditorDialog, null, null);
|
|
39 | 39 |
} |
40 | 40 |
|
41 | 41 |
public static void setDefaultContextMenu(final JComponent component, String title) { |
42 |
ContextMenuUtils.setDefaultContextMenu(component, true, title); |
|
42 |
ContextMenuUtils.setDefaultContextMenu(component, true, title, null);
|
|
43 | 43 |
} |
44 | 44 |
|
45 | 45 |
public static void setDefaultContextMenu(final JComponent component, boolean addTextEditor, String title) { |
46 |
ContextMenuUtils.setDefaultContextMenu(component, true, title, null); |
|
47 |
} |
|
48 |
|
|
49 |
public static void setDefaultContextMenu(final JComponent component, boolean addTextEditor, String title, List<Action> customActions) { |
|
46 | 50 |
final JTextComponent text = getTextComponent(component); |
47 | 51 |
JPopupMenu popupMenu = new JPopupMenu(); |
48 | 52 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
... | ... | |
55 | 59 |
text, |
56 | 60 |
StringUtils.isBlank(title)?i18n.getTranslation("text_editor"):title, |
57 | 61 |
text.getText(), |
58 |
WindowManager.MODE.DIALOG |
|
62 |
WindowManager.MODE.DIALOG, |
|
63 |
null |
|
59 | 64 |
); |
60 | 65 |
boolean allowEdit = text.isEditable() && text.isEnabled(); |
61 | 66 |
Object x = this.getValue("EDITABLE"); |
... | ... | |
112 | 117 |
menuCut.setEnabled(false); |
113 | 118 |
menuPaste.setEnabled(false); |
114 | 119 |
} |
120 |
if( customActions!=null && !customActions.isEmpty()) { |
|
121 |
popupMenu.addSeparator(); |
|
122 |
for (Action customAction : customActions) { |
|
123 |
popupMenu.add(customAction); |
|
124 |
} |
|
125 |
} |
|
115 | 126 |
text.addPropertyChangeListener((PropertyChangeEvent evt) -> { |
116 | 127 |
if (evt == null) { |
117 | 128 |
return; |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/DefaultToolsSwingManager.java | ||
---|---|---|
10 | 10 |
import java.lang.reflect.InvocationTargetException; |
11 | 11 |
import java.lang.reflect.Method; |
12 | 12 |
import java.sql.Time; |
13 |
import java.util.List; |
|
13 | 14 |
import java.util.Locale; |
14 | 15 |
import javax.swing.AbstractButton; |
16 |
import javax.swing.Action; |
|
15 | 17 |
import javax.swing.ComboBoxModel; |
16 | 18 |
import javax.swing.Icon; |
17 | 19 |
import javax.swing.ImageIcon; |
... | ... | |
540 | 542 |
|
541 | 543 |
@Override |
542 | 544 |
public String showZoomDialog(Component parent, String title, String text, boolean editable) { |
543 |
return showZoomDialog(parent, title, text, editable, WindowManager.MODE.DIALOG); |
|
545 |
return showZoomDialog(parent, title, text, editable, WindowManager.MODE.DIALOG, null);
|
|
544 | 546 |
|
545 | 547 |
} |
546 | 548 |
@Override |
547 | 549 |
public String showZoomDialog(Component parent, String title, String text, boolean editable, WindowManager.MODE mode) { |
548 |
DefaultZoomDialog dialog = new DefaultZoomDialog(parent, title, text, mode); |
|
550 |
return showZoomDialog(parent, title, text, editable, mode, null); |
|
551 |
} |
|
552 |
|
|
553 |
@Override |
|
554 |
public String showZoomDialog(Component parent, String title, String text, boolean editable, WindowManager.MODE mode, List<Action> customActions) { |
|
555 |
DefaultZoomDialog dialog = new DefaultZoomDialog(parent, title, text, mode, customActions); |
|
549 | 556 |
dialog.setEditable(editable); |
550 | 557 |
dialog.setAlwaysOnTop(true); |
551 | 558 |
dialog.setVisible(true); |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/ToolsSwingManager.java | ||
---|---|---|
8 | 8 |
import java.awt.image.BufferedImage; |
9 | 9 |
import java.io.File; |
10 | 10 |
import java.sql.Time; |
11 |
import java.util.List; |
|
11 | 12 |
import java.util.Locale; |
12 | 13 |
import javax.swing.AbstractButton; |
14 |
import javax.swing.Action; |
|
13 | 15 |
import javax.swing.ComboBoxModel; |
14 | 16 |
import javax.swing.Icon; |
15 | 17 |
import javax.swing.JButton; |
... | ... | |
586 | 588 |
|
587 | 589 |
public String showZoomDialog(java.awt.Component parent, String title, String text, boolean editable, WindowManager.MODE mode); |
588 | 590 |
|
591 |
public String showZoomDialog(java.awt.Component parent, String title, String text, boolean editable, WindowManager.MODE mode, List<Action> customActions); |
|
592 |
|
|
589 | 593 |
public DropDown createDropDownIcon(JLabel lblNull); |
590 | 594 |
|
591 | 595 |
public void putInClipboard(String data); |
Also available in: Unified diff