Changeset 8516 in josm for trunk/src/org
- Timestamp:
- 2015-06-21T12:36:09+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/SplashScreen.java
r8513 r8516 6 6 import java.awt.Color; 7 7 import java.awt.Component; 8 import java.awt. Graphics;8 import java.awt.Dimension; 9 9 import java.awt.GridBagConstraints; 10 10 import java.awt.GridBagLayout; … … 18 18 import java.util.Objects; 19 19 20 import javax.swing.BorderFactory; 20 21 import javax.swing.ImageIcon; 21 22 import javax.swing.JFrame; … … 23 24 import javax.swing.JPanel; 24 25 import javax.swing.JProgressBar; 26 import javax.swing.JScrollPane; 25 27 import javax.swing.JSeparator; 28 import javax.swing.ScrollPaneConstants; 26 29 import javax.swing.border.Border; 27 30 import javax.swing.border.EmptyBorder; … … 35 38 import org.openstreetmap.josm.gui.progress.ProgressTaskId; 36 39 import org.openstreetmap.josm.gui.util.GuiHelper; 40 import org.openstreetmap.josm.gui.widgets.JosmEditorPane; 41 import org.openstreetmap.josm.tools.GBC; 37 42 import org.openstreetmap.josm.tools.ImageProvider; 38 43 import org.openstreetmap.josm.tools.Predicates; … … 118 123 @Override 119 124 public void stateChanged(ChangeEvent ignore) { 120 progressRenderer.setTasks(progressMonitor.toString()); 125 GuiHelper.runInEDT(new Runnable() { 126 @Override 127 public void run() { 128 progressRenderer.setTasks(progressMonitor.toString()); 129 } 130 }); 121 131 } 122 132 … … 129 139 * Returns a HTML representation for this task. 130 140 */ 131 public abstract String toHtml();141 public abstract StringBuilder toHtml(StringBuilder sb); 132 142 133 143 @Override 134 144 public final String toString() { 135 return toHtml( );145 return toHtml(new StringBuilder(1024)).toString(); 136 146 } 137 147 } … … 159 169 160 170 @Override 161 public String toHtml() {162 return name + "<i style='color: #666666;'>" + duration + "</i>";171 public StringBuilder toHtml(StringBuilder sb) { 172 return sb.append(name).append("<i style='color: #666666;'>").append(duration).append("</i>"); 163 173 } 164 174 … … 193 203 194 204 @Override 195 public String toHtml() {205 public StringBuilder toHtml(StringBuilder sb) { 196 206 synchronized (tasks) { 197 return Utils.firstNonNull(name, "") + (tasks.isEmpty() ? "" : Utils.joinAsHtmlUnorderedList(tasks)); 207 sb.append(Utils.firstNonNull(name, "")); 208 if (!tasks.isEmpty()) { 209 sb.append("<ul>"); 210 for (Task i : tasks) { 211 sb.append("<li>"); 212 i.toHtml(sb); 213 sb.append("</li>"); 214 } 215 sb.append("</ul>"); 216 } 217 return sb; 198 218 } 199 219 } … … 328 348 329 349 private static class SplashScreenProgressRenderer extends JPanel { 330 private JLabel lblTaskTitle;331 private JProgressBar progressBar;350 private final JosmEditorPane lblTaskTitle = new JosmEditorPane(); 351 private final JProgressBar progressBar = new JProgressBar(JProgressBar.HORIZONTAL); 332 352 private static final String labelHtml = "<html>" 333 + "<style>ul {margin-top: 0; margin-bottom: 0; padding: 0;} li {margin: 0; padding: 0;}</style>" 334 + "<body height='320'>"; 353 + "<style>ul {margin-top: 0; margin-bottom: 0; padding: 0;} li {margin: 0; padding: 0;}</style>"; 335 354 336 355 protected void build() { 337 356 setLayout(new GridBagLayout()); 338 GridBagConstraints gc = new GridBagConstraints(); 339 gc.gridx = 0; 340 gc.gridy = 0; 341 gc.fill = GridBagConstraints.HORIZONTAL; 342 gc.weightx = 1.0; 343 gc.weighty = 0.0; 344 gc.insets = new Insets(5, 0, 0, 0); 345 add(lblTaskTitle = new JLabel(labelHtml), gc); 346 347 gc.gridy = 1; 348 gc.insets = new Insets(15, 0, 0, 0); 349 add(progressBar = new JProgressBar(JProgressBar.HORIZONTAL), gc); 357 358 JosmEditorPane.makeJLabelLike(lblTaskTitle, false); 359 lblTaskTitle.setText(labelHtml); 360 final JScrollPane scrollPane = new JScrollPane(lblTaskTitle, 361 ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); 362 scrollPane.setPreferredSize(new Dimension(0, 320)); 363 scrollPane.setBorder(BorderFactory.createEmptyBorder()); 364 add(scrollPane, GBC.eol().insets(5, 5, 0, 0).fill(GridBagConstraints.HORIZONTAL)); 365 350 366 progressBar.setIndeterminate(true); 367 add(progressBar, GBC.eol().insets(5, 15, 0, 0).fill(GridBagConstraints.HORIZONTAL)); 351 368 } 352 369 … … 355 372 } 356 373 357 @Override358 public void paint(Graphics g) {359 try {360 super.paint(g);361 } catch (NullPointerException ignore) {362 // NullPointerException at javax.swing.text.html.StyleSheet$ListPainter.paint363 if (Main.isTraceEnabled()) {364 Main.trace(ignore.getMessage());365 }366 }367 }368 369 374 public void setTasks(String tasks) { 370 lblTaskTitle.setText(labelHtml + tasks); 375 synchronized (lblTaskTitle) { 376 lblTaskTitle.setText(labelHtml + tasks); 377 lblTaskTitle.setCaretPosition(lblTaskTitle.getDocument().getLength()); 378 } 371 379 repaint(); 372 380 }
Note:
See TracChangeset
for help on using the changeset viewer.