]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/function/SetLineWidth.java
5ac64ae3e3a78a2f009f98078249f9d5e2b7880c
[GpsPrune.git] / tim / prune / function / SetLineWidth.java
1 package tim.prune.function;
2
3 import javax.swing.JOptionPane;
4
5 import tim.prune.App;
6 import tim.prune.DataSubscriber;
7 import tim.prune.GenericFunction;
8 import tim.prune.I18nManager;
9 import tim.prune.UpdateMessageBroker;
10 import tim.prune.config.Config;
11
12 public class SetLineWidth extends GenericFunction
13 {
14
15         /**
16          * Constructor
17          * @param inApp App object
18          */
19         public SetLineWidth(App inApp) {
20                 super(inApp);
21         }
22
23         /** @return name key */
24         public String getNameKey() {
25                 return "function.setlinewidth";
26         }
27
28
29         /**
30          * Run function
31          */
32         public void begin()
33         {
34                 int currLineWidth = Config.getConfigInt(Config.KEY_LINE_WIDTH);
35                 if (currLineWidth < 1 || currLineWidth > 4) {
36                         currLineWidth = 2;
37                 }
38                 Object lineWidthStr = JOptionPane.showInputDialog(_app.getFrame(),
39                         I18nManager.getText("dialog.setlinewidth.text"),
40                         I18nManager.getText(getNameKey()),
41                         JOptionPane.QUESTION_MESSAGE, null, null, "" + currLineWidth);
42                 if (lineWidthStr != null)
43                 {
44                         int lineWidth = 2;
45                         try {
46                                 lineWidth = Integer.parseInt(lineWidthStr.toString());
47                                 if (lineWidth >= 1 && lineWidth <= 4 && lineWidth != currLineWidth)
48                                 {
49                                         Config.setConfigInt(Config.KEY_LINE_WIDTH, lineWidth);
50                                         UpdateMessageBroker.informSubscribers(DataSubscriber.SELECTION_CHANGED);
51                                 }
52                         }
53                         catch (NumberFormatException nfe) {};
54                 }
55         }
56 }