Changeset 2021 in josm for trunk/src/org
- Timestamp:
- 2009-08-31T12:33:32+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapFrame.java
r2017 r2021 164 164 */ 165 165 public void setVisibleDialogs() { 166 for (Component c : toggleDialogs.getComponents()) { 167 if (c instanceof ToggleDialog) { 168 ToggleDialog td = (ToggleDialog)c; 169 if (Main.pref.getBoolean(td.getPreferencePrefix()+".visible")) { 170 td.showDialog(); 171 } 166 toggleDialogs.removeAll(); 167 for (ToggleDialog dialog: allDialogs) { 168 dialog.setVisible(false); 169 toggleDialogs.add(dialog); 170 dialog.setParent(toggleDialogs); 171 if (Main.pref.getBoolean(dialog.getPreferencePrefix()+".visible")) { 172 dialog.showDialog(); 173 } else { 174 dialog.hideDialog(); 172 175 } 173 176 } … … 180 183 public IconToggleButton addToggleDialog(ToggleDialog dlg) { 181 184 IconToggleButton button = new IconToggleButton(dlg.getToggleAction()); 182 dlg.setParent(toggleDialogs);183 185 toolBarToggle.add(button); 184 toggleDialogs.add(dlg);185 186 allDialogs.add(dlg); 186 187 return button; -
trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r2010 r2021 6 6 import java.awt.Component; 7 7 import java.awt.Dimension; 8 import java.awt.EventQueue;9 8 import java.awt.GridBagLayout; 10 9 import java.awt.Image; … … 152 151 153 152 docked = Main.pref.getBoolean(preferencePrefix+".docked", true); 154 if (!docked) {155 EventQueue.invokeLater(new Runnable(){156 public void run() {157 detach();158 }159 });160 }161 153 collapsed = Main.pref.getBoolean(preferencePrefix+".minimized", false); 162 if (collapsed) {163 EventQueue.invokeLater(new Runnable(){164 public void run() {165 collapse();166 }167 });168 }169 154 } 170 155 … … 203 188 */ 204 189 protected int getDialogPosition() { 190 if (parent == null) return -1; 205 191 for (int i=0; i< parent.getComponentCount(); i++) { 206 192 String name = parent.getComponent(i).getName(); … … 218 204 protected void dock() { 219 205 detachedDialog = null; 206 if (parent == null) return; 220 207 221 208 // check whether the toggle dialog view contains a placeholder … … 225 212 if (idx > -1) { 226 213 parent.remove(idx); 227 parent.add(ToggleDialog.this,idx); 214 if (idx >= parent.getComponentCount()) { 215 parent.add(ToggleDialog.this); 216 } else { 217 parent.add(ToggleDialog.this,idx); 218 } 228 219 } else { 229 220 parent.add(ToggleDialog.this); 230 221 } 222 parent.validate(); 231 223 232 224 if(Main.pref.getBoolean(preferencePrefix+".visible")) { … … 281 273 */ 282 274 public void hideDialog() { 283 if (!isShowing) return;284 275 if (detachedDialog != null) { 285 276 detachedDialog.setVisible(false); … … 289 280 setVisible(false); 290 281 isShowing = false; 282 Main.pref.put(preferencePrefix+".visible", false); 291 283 refreshToggleDialogsView(); 292 284 toggleAction.putValue("selected", false); … … 304 296 */ 305 297 public void showDialog() { 306 if (isShowing) return;307 298 if (!docked) { 308 299 detach(); 309 } else if (!collapsed) {310 expand();311 setVisible(true);312 refreshToggleDialogsView();313 300 } else { 314 setVisible(true); 315 refreshToggleDialogsView(); 301 dock(); 302 if (!collapsed) { 303 expand(); 304 setVisible(true); 305 refreshToggleDialogsView(); 306 } else { 307 setVisible(true); 308 refreshToggleDialogsView(); 309 } 316 310 } 317 311 isShowing = true; 312 // toggling the selected value in order to enforce PropertyChangeEvents 313 // 314 toggleAction.putValue("selected", false); 318 315 toggleAction.putValue("selected", true); 316 Main.pref.put(preferencePrefix+".visible", true); 319 317 } 320 318 … … 349 347 if (detachedDialog != null) { 350 348 detachedDialog.setVisible(false); 349 detachedDialog.removeAll(); 350 detachedDialog.dispose(); 351 351 } 352 352 } … … 494 494 } else { 495 495 pack(); 496 496 497 } 497 498 setTitle(titleBar.getTitle());
Note:
See TracChangeset
for help on using the changeset viewer.