Changeset 6 in josm for src/org/openstreetmap/josm/gui/PreferenceDialog.java
- Timestamp:
- 2005-10-01T04:01:45+02:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/gui/PreferenceDialog.java
r1 r6 1 1 package org.openstreetmap.josm.gui; 2 2 3 import java.awt.BorderLayout;4 3 import java.awt.Component; 5 import java.awt.Container;6 4 import java.awt.Dimension; 5 import java.awt.Font; 6 import java.awt.GridBagLayout; 7 7 import java.awt.event.ActionEvent; 8 8 import java.awt.event.ActionListener; … … 11 11 12 12 import javax.swing.AbstractAction; 13 import javax.swing.BorderFactory;14 13 import javax.swing.Box; 15 14 import javax.swing.DefaultListCellRenderer; 16 15 import javax.swing.ImageIcon; 17 16 import javax.swing.JButton; 17 import javax.swing.JCheckBox; 18 18 import javax.swing.JComboBox; 19 19 import javax.swing.JDialog; … … 50 50 pref.laf = (LookAndFeelInfo)lafCombo.getSelectedItem(); 51 51 pref.projection = (Projection)projectionCombo.getSelectedItem(); 52 pref.mergeNodes = mergeNodes.isSelected(); 52 53 Main.pref.projection = pref.projection; 53 54 try { … … 85 86 private JComboBox lafCombo = new JComboBox(UIManager.getInstalledLookAndFeels()); 86 87 /** 87 * The tabbed pane to add tabulars to.88 */89 private JTabbedPane tabPanel = new JTabbedPane();90 /**91 88 * Combobox with all projections available 92 89 */ 93 private JComboBox projectionCombo = new JComboBox(Preferences.allProjections); 90 private JComboBox projectionCombo = new JComboBox(Preferences.allProjections.clone()); 91 /** 92 * The main tab panel. 93 */ 94 private JTabbedPane tabPane = new JTabbedPane(JTabbedPane.LEFT); 95 /** 96 * The checkbox stating whether nodes should be merged together. 97 */ 98 private JCheckBox mergeNodes = new JCheckBox("Merge nodes with equal latitude/longitude."); 94 99 95 100 … … 113 118 } 114 119 115 getContentPane().setLayout(new BorderLayout()); 116 getContentPane().add(tabPanel, BorderLayout.CENTER); 117 118 newTab("Display"); 119 // laf 120 JPanel p = newPanelLine(); 121 p.add(new JLabel("Look and Feel")); 120 // look and feel combo box 122 121 final ListCellRenderer oldRenderer = lafCombo.getRenderer(); 123 122 lafCombo.setRenderer(new DefaultListCellRenderer(){ 123 @Override 124 124 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 125 125 return oldRenderer.getListCellRendererComponent(list, ((LookAndFeelInfo)value).getName(), index, isSelected, cellHasFocus); … … 130 130 setRequiresRestart(); 131 131 }}); 132 p.add(lafCombo); 133 134 newTab("Projection"); 135 p = newPanelLine(); 136 p.add(new JLabel("Projection System")); 137 p.add(projectionCombo); 138 for (int i = 0; i < projectionCombo.getItemCount(); ++i) 132 133 // projection method combo box 134 for (int i = 0; i < projectionCombo.getItemCount(); ++i) { 139 135 if (projectionCombo.getItemAt(i).getClass().equals(pref.projection.getClass())) { 140 136 projectionCombo.setSelectedIndex(i); 141 137 break; 142 138 } 143 144 // OK/Cancel 145 JPanel okPanel = new JPanel(); 146 okPanel.add(new JButton(new OkAction())); 147 okPanel.add(new JButton(new CancelAction())); 148 getContentPane().add(okPanel, BorderLayout.SOUTH); 139 } 140 141 // Display tab 142 JPanel display = createPreferenceTab("display", "Display Settings", "Various settings than influence the visual representation of the whole Program."); 143 display.add(new JLabel("Look and Feel"), GBC.std()); 144 display.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); 145 display.add(lafCombo, GBC.eol().fill(GBC.HORIZONTAL)); 146 display.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL)); 147 148 // Map tab 149 JPanel map = createPreferenceTab("map", "Map Settings", "Settings for the map projection and data interpretation."); 150 map.add(new JLabel("Projection method"), GBC.std()); 151 map.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); 152 map.add(projectionCombo, GBC.eol().fill(GBC.HORIZONTAL)); 153 JLabel labelNoteProjection = new JLabel( 154 "<html>Note: This is the default projection method used for files, " + 155 "where the correct projection could not be determined. " + 156 "The actual used projection can be changed in the property " + 157 "settings of each map.</html>"); 158 labelNoteProjection.setMinimumSize(new Dimension(550, 50)); 159 labelNoteProjection.setPreferredSize(new Dimension(550, 50)); 160 map.add(labelNoteProjection, GBC.eol().insets(0,5,0,20)); 161 map.add(new JLabel("GPX import / export"), GBC.eol()); 162 mergeNodes.setSelected(pref.mergeNodes); 163 map.add(mergeNodes, GBC.eol()); 164 map.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL)); 165 166 167 tabPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); 168 169 // OK/Cancel panel at bottom 170 JPanel okPanel = new JPanel(new GridBagLayout()); 171 okPanel.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL)); 172 okPanel.add(new JButton(new OkAction()), GBC.std()); 173 okPanel.add(new JButton(new CancelAction()), GBC.std()); 174 175 // merging all in the content pane 176 getContentPane().setLayout(new GridBagLayout()); 177 getContentPane().add(tabPane, GBC.eol().fill()); 178 getContentPane().add(okPanel, GBC.eol().fill(GBC.HORIZONTAL)); 149 179 150 180 setModal(true); … … 155 185 156 186 /** 157 * Start a new tab with the given name 158 * @param tabName The name of the new tab. 159 */ 160 private void newTab(String tabName) { 161 Box tab = Box.createVerticalBox(); 162 tab.setBorder(BorderFactory.createEmptyBorder(10,10,10,10)); 163 tabPanel.addTab(tabName, tab); 164 } 165 187 * Construct a JPanel for the preference settings. Layout is GridBagLayout 188 * and a centered title label and the description are added. 189 * @param icon The name of the icon. 190 * @param title The title of this preference tab. 191 * @param desc A description in one sentence for this tab. Will be displayed 192 * italic under the title. 193 * @return The created panel ready to add other controls. 194 */ 195 private JPanel createPreferenceTab(String icon, String title, String desc) { 196 JPanel p = new JPanel(new GridBagLayout()); 197 p.add(new JLabel(title), GBC.eol().anchor(GBC.CENTER).insets(0,5,0,10)); 198 JLabel descLabel = new JLabel(desc); 199 descLabel.setFont(descLabel.getFont().deriveFont(Font.ITALIC)); 200 p.add(descLabel, GBC.eol().insets(5,0,5,20)); 201 202 tabPane.addTab(null, new ImageIcon("images/preferences/"+icon+".png"), p); 203 return p; 204 } 205 166 206 /** 167 207 * Remember, that the settings made requires a restart of the application. … … 171 211 requiresRestart = true; 172 212 } 173 174 private JPanel newPanelLine() {175 JPanel p;176 p = new JPanel();177 p.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));178 ((Container)tabPanel.getComponent(tabPanel.getTabCount()-1)).add(p);179 return p;180 }181 213 }
Note:
See TracChangeset
for help on using the changeset viewer.