Ticket #11981: 11981-alpha.patch
| File 11981-alpha.patch, 5.3 KB (added by , 11 years ago) |
|---|
-
src/org/openstreetmap/josm/gui/GettingStarted.java
diff --git a/src/org/openstreetmap/josm/gui/GettingStarted.java b/src/org/openstreetmap/josm/gui/GettingStarted.java index 5ca8b19..a694a64 100644
a b 6 6 import java.awt.BorderLayout; 7 7 import java.awt.EventQueue; 8 8 import java.awt.GraphicsEnvironment; 9 import java.awt.GridBagLayout; 9 10 import java.awt.event.InputEvent; 10 11 import java.awt.event.KeyEvent; 11 12 import java.io.IOException; … … 14 15 import java.util.regex.Matcher; 15 16 import java.util.regex.Pattern; 16 17 18 import javax.swing.Action; 19 import javax.swing.JButton; 17 20 import javax.swing.JComponent; 21 import javax.swing.JLabel; 18 22 import javax.swing.JPanel; 19 23 import javax.swing.JScrollPane; 20 24 import javax.swing.KeyStroke; 25 import javax.swing.SwingConstants; 21 26 import javax.swing.border.EmptyBorder; 22 27 import javax.swing.event.HyperlinkEvent; 23 28 import javax.swing.event.HyperlinkListener; 24 29 25 30 import org.openstreetmap.josm.Main; 31 import org.openstreetmap.josm.actions.DownloadAction; 32 import org.openstreetmap.josm.actions.DownloadPrimitiveAction; 33 import org.openstreetmap.josm.actions.OverpassDownloadAction; 26 34 import org.openstreetmap.josm.data.Version; 35 import org.openstreetmap.josm.gui.io.RecentlyOpenedFilesMenu; 27 36 import org.openstreetmap.josm.gui.preferences.server.ProxyPreference; 28 37 import org.openstreetmap.josm.gui.preferences.server.ProxyPreferenceListener; 29 38 import org.openstreetmap.josm.gui.widgets.JosmEditorPane; 30 39 import org.openstreetmap.josm.io.CacheCustomContent; 31 40 import org.openstreetmap.josm.io.OnlineResource; 41 import org.openstreetmap.josm.tools.GBC; 32 42 import org.openstreetmap.josm.tools.LanguageInfo; 33 43 import org.openstreetmap.josm.tools.OpenBrowser; 44 import org.openstreetmap.josm.tools.Utils; 34 45 import org.openstreetmap.josm.tools.WikiReader; 35 46 36 47 public final class GettingStarted extends JPanel implements ProxyPreferenceListener { … … public GettingStarted() { 129 140 scroller.setViewportBorder(new EmptyBorder(10, 100, 10, 100)); 130 141 add(scroller, BorderLayout.CENTER); 131 142 143 final JPanel commands = new JPanel(new GridBagLayout()); 144 add(commands, BorderLayout.WEST); 145 146 for (Action action: new Action[]{ 147 new DownloadAction(), 148 new OverpassDownloadAction(), 149 new DownloadPrimitiveAction(), 150 }) { 151 final JButton button = new JButton(action); 152 button.setHorizontalAlignment(SwingConstants.LEFT); 153 commands.add(button, GBC.eop().fill(GBC.HORIZONTAL )); 154 } 155 156 //todo refresh list every time the GettingStarted panel is being displayed 157 commands.add(new JLabel(tr("Open Recent")), GBC.eol()); 158 for (Action recentAction : RecentlyOpenedFilesMenu.getActions()) { 159 final JButton button = new JButton(recentAction); 160 button.setToolTipText(button.getText()); 161 button.setText(Utils.shortenString(button.getText(), 32)); 162 button.setHorizontalAlignment(SwingConstants.LEFT); 163 commands.add(button, GBC.eol().fill(GBC.HORIZONTAL)); 164 } 165 166 commands.add(new JPanel(), GBC.std().fill()); 167 132 168 getMOTD(); 133 169 134 170 if (!GraphicsEnvironment.isHeadless()) { -
src/org/openstreetmap/josm/gui/io/RecentlyOpenedFilesMenu.java
diff --git a/src/org/openstreetmap/josm/gui/io/RecentlyOpenedFilesMenu.java b/src/org/openstreetmap/josm/gui/io/RecentlyOpenedFilesMenu.java index 9093f0e..a129b58 100644
a b 6 6 7 7 import java.awt.event.ActionEvent; 8 8 import java.io.File; 9 import java.util.ArrayList; 9 10 import java.util.Collection; 10 11 import java.util.Collections; 12 import java.util.List; 11 13 12 14 import javax.swing.AbstractAction; 15 import javax.swing.Action; 13 16 import javax.swing.JMenu; 14 17 import javax.swing.JMenuItem; 15 18 import javax.swing.JSeparator; … … 25 28 */ 26 29 public class RecentlyOpenedFilesMenu extends JMenu { 27 30 private ClearAction clearAction; 31 private static final Collection<String> fileHistory = Main.pref.getCollection("file-open.history"); 28 32 29 33 public RecentlyOpenedFilesMenu() { 30 34 super(tr("Open Recent")); … … public void menuCanceled(MenuEvent e) { 49 53 }); 50 54 } 51 55 52 private void rebuild() { 53 removeAll(); 54 Collection<String> fileHistory = Main.pref.getCollection("file-open.history"); 55 56 public static List<Action> getActions() { 57 final List<Action> actions = new ArrayList<>(fileHistory.size()); 56 58 for (final String file : fileHistory) { 57 a dd(new AbstractAction() {59 actions.add(new AbstractAction() { 58 60 { 59 61 putValue(NAME, file); 60 62 putValue("help", ht("/Action/OpenRecent")); 61 63 putValue("toolbar", Boolean.FALSE); 62 64 } 65 63 66 @Override 64 67 public void actionPerformed(ActionEvent e) { 65 68 File f = new File(file); … … public void actionPerformed(ActionEvent e) { 69 72 } 70 73 }); 71 74 } 75 return actions; 76 } 77 78 private void rebuild() { 79 removeAll(); 80 for (Action action : getActions()) { 81 add(action); 82 } 72 83 add(new JSeparator()); 73 84 if (clearAction == null) { 74 85 clearAction = new ClearAction();
