Changeset 4354 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2011-08-27T14:42:10+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/SideButton.java
r3719 r4354 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Color; 7 import java.awt.BorderLayout; 6 8 import java.awt.Image; 7 9 import java.awt.Insets; … … 9 11 10 12 import javax.swing.Action; 13 import javax.swing.BorderFactory; 11 14 import javax.swing.Icon; 12 15 import javax.swing.ImageIcon; 13 16 import javax.swing.JButton; 17 import javax.swing.SwingConstants; 18 import javax.swing.plaf.basic.BasicArrowButton; 14 19 15 20 import org.openstreetmap.josm.Main; … … 46 51 { 47 52 Image im = ((ImageIcon) i).getImage(); 48 setIcon(new ImageIcon(im.getScaledInstance(20 53 setIcon(new ImageIcon(im.getScaledInstance(20, 20, Image.SCALE_SMOOTH))); 49 54 } 50 55 } … … 52 57 public static ImageIcon makeIcon(String imagename) { 53 58 Image im = ImageProvider.get("dialogs", imagename).getImage(); 54 return new ImageIcon(im.getScaledInstance(20 59 return new ImageIcon(im.getScaledInstance(20, 20, Image.SCALE_SMOOTH)); 55 60 } 56 61 … … 90 95 private void doStyle() 91 96 { 92 set Margin(new Insets(1,1,1,1));97 setLayout(new BorderLayout()); 93 98 setIconTextGap(2); 99 setMargin(new Insets(-1,0,-1,0)); 100 } 101 102 public void createArrow(ActionListener listener) { 103 setMargin(new Insets(0,0,0,0)); 104 BasicArrowButton arrowButton = new BasicArrowButton(SwingConstants.SOUTH, null, null, Color.BLACK, null); 105 arrowButton.setBorder(BorderFactory.createEmptyBorder()); 106 add(arrowButton, BorderLayout.EAST); 107 arrowButton.addActionListener(listener); 94 108 } 95 109 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r4223 r4354 5 5 import static org.openstreetmap.josm.tools.I18n.trn; 6 6 7 import java.awt.BorderLayout;8 import java.awt.Color;9 7 import java.awt.Component; 10 import java.awt.GridLayout;11 8 import java.awt.Rectangle; 12 9 import java.awt.event.ActionEvent; … … 16 13 import java.awt.event.MouseEvent; 17 14 import java.util.ArrayList; 15 import java.util.Arrays; 18 16 import java.util.Collection; 19 17 import java.util.Collections; … … 27 25 import javax.swing.AbstractAction; 28 26 import javax.swing.AbstractListModel; 29 import javax.swing.BorderFactory;30 27 import javax.swing.DefaultListSelectionModel; 31 28 import javax.swing.JButton; 32 29 import javax.swing.JList; 33 30 import javax.swing.JMenuItem; 34 import javax.swing.JPanel;35 31 import javax.swing.JPopupMenu; 36 import javax.swing.JScrollPane;37 32 import javax.swing.ListSelectionModel; 38 import javax.swing.SwingConstants;39 33 import javax.swing.SwingUtilities; 40 34 import javax.swing.event.ListDataEvent; … … 42 36 import javax.swing.event.ListSelectionEvent; 43 37 import javax.swing.event.ListSelectionListener; 44 import javax.swing.plaf.basic.BasicArrowButton;45 38 46 39 import org.openstreetmap.josm.Main; … … 98 91 99 92 /** 100 * Builds the panel with the list of selected OSM primitives 101 * 102 * @return the panel with the list of selected OSM primitives 103 */ 104 protected JPanel buildListPanel() { 105 JPanel pnl = new JPanel(new BorderLayout()); 93 * Builds the content panel for this dialog 94 */ 95 protected void buildContentPanel() { 106 96 DefaultListSelectionModel selectionModel = new DefaultListSelectionModel(); 107 97 model = new SelectionListModel(selectionModel); … … 111 101 lstPrimitives.setCellRenderer(new OsmPrimitivRenderer()); 112 102 lstPrimitives.setTransferHandler(null); // Fix #6290. Drag & Drop is not supported anyway and Copy/Paste is better propagated to main window 113 pnl.add(new JScrollPane(lstPrimitives), BorderLayout.CENTER);114 115 return pnl;116 }117 118 /**119 * Builds the row of action buttons at the bottom of this dialog120 *121 * @return the panel122 */123 protected JPanel buildActionPanel() {124 JPanel pnl = new JPanel(new GridLayout(1,2));125 103 126 104 // the select action 127 final JButton selectButton = new SideButton(actSelect = new SelectAction());105 final SideButton selectButton = new SideButton(actSelect = new SelectAction()); 128 106 lstPrimitives.getSelectionModel().addListSelectionListener(actSelect); 129 pnl.add(selectButton); 130 BasicArrowButton selectionHistoryMenuButton = createArrowButton(selectButton); 131 selectionHistoryMenuButton.addActionListener(new ActionListener() { 107 selectButton.createArrow(new ActionListener() { 132 108 public void actionPerformed(ActionEvent e) { 133 109 SelectionHistoryPopup.launch(selectButton, model.getSelectionHistory()); … … 136 112 137 113 // the search button 138 final JButton searchButton = new SideButton(actSearch = new SearchAction()); 139 pnl.add(searchButton); 140 141 BasicArrowButton searchHistoryMenuButton = createArrowButton(searchButton); 142 searchHistoryMenuButton.addActionListener(new ActionListener() { 114 final SideButton searchButton = new SideButton(actSearch = new SearchAction()); 115 searchButton.createArrow(new ActionListener() { 143 116 public void actionPerformed(ActionEvent e) { 144 117 SearchPopupMenu.launch(searchButton); … … 146 119 }); 147 120 148 return pnl; 149 } 150 151 /** 152 * Builds the content panel for this dialog 153 * 154 * @return the content panel 155 */ 156 protected JPanel buildContentPanel() { 157 JPanel pnl = new JPanel(new BorderLayout()); 158 pnl.add(buildListPanel(), BorderLayout.CENTER); 159 pnl.add(buildActionPanel(), BorderLayout.SOUTH); 160 return pnl; 121 createLayout(lstPrimitives, true, Arrays.asList(new SideButton[] { 122 selectButton, searchButton 123 })); 161 124 } 162 125 … … 168 131 ); 169 132 170 add(buildContentPanel(), BorderLayout.CENTER);133 buildContentPanel(); 171 134 model.addListDataListener(new TitleUpdater()); 172 135 actZoomToJOSMSelection = new ZoomToJOSMSelectionAction(); … … 213 176 DatasetEventManager.getInstance().removeDatasetListener(model); 214 177 } 215 216 private BasicArrowButton createArrowButton(JButton parentButton) {217 BasicArrowButton arrowButton = new BasicArrowButton(SwingConstants.SOUTH, null, null, Color.BLACK, null);218 arrowButton.setBorder(BorderFactory.createEmptyBorder());219 parentButton.setLayout(new BorderLayout());220 parentButton.add(arrowButton, BorderLayout.EAST);221 return arrowButton;222 }223 224 178 225 179 /** -
trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r4353 r4354 671 671 add(data, BorderLayout.CENTER); 672 672 if(buttons != null && buttons.size() != 0) { 673 JPanel buttonsPanel = new JPanel(); 674 buttonsPanel.setLayout(Main.pref.getBoolean("dialog.align.left", false) 673 JPanel buttonsPanel = new JPanel(Main.pref.getBoolean("dialog.align.left", false) 675 674 ? new FlowLayout(FlowLayout.LEFT) : new GridLayout(1,buttons.size())); 676 675 for(SideButton button : buttons)
Note:
See TracChangeset
for help on using the changeset viewer.