X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Ffunction%2FSetLineWidth.java;fp=tim%2Fprune%2Ffunction%2FSetLineWidth.java;h=5ac64ae3e3a78a2f009f98078249f9d5e2b7880c;hb=f35b6d628f68e3b5ef19965ad8988d0dd1eb8efa;hp=0000000000000000000000000000000000000000;hpb=3745d70b1427bb8ac1a085e47cbdc566936784e1;p=GpsPrune.git diff --git a/tim/prune/function/SetLineWidth.java b/tim/prune/function/SetLineWidth.java new file mode 100644 index 0000000..5ac64ae --- /dev/null +++ b/tim/prune/function/SetLineWidth.java @@ -0,0 +1,56 @@ +package tim.prune.function; + +import javax.swing.JOptionPane; + +import tim.prune.App; +import tim.prune.DataSubscriber; +import tim.prune.GenericFunction; +import tim.prune.I18nManager; +import tim.prune.UpdateMessageBroker; +import tim.prune.config.Config; + +public class SetLineWidth extends GenericFunction +{ + + /** + * Constructor + * @param inApp App object + */ + public SetLineWidth(App inApp) { + super(inApp); + } + + /** @return name key */ + public String getNameKey() { + return "function.setlinewidth"; + } + + + /** + * Run function + */ + public void begin() + { + int currLineWidth = Config.getConfigInt(Config.KEY_LINE_WIDTH); + if (currLineWidth < 1 || currLineWidth > 4) { + currLineWidth = 2; + } + Object lineWidthStr = JOptionPane.showInputDialog(_app.getFrame(), + I18nManager.getText("dialog.setlinewidth.text"), + I18nManager.getText(getNameKey()), + JOptionPane.QUESTION_MESSAGE, null, null, "" + currLineWidth); + if (lineWidthStr != null) + { + int lineWidth = 2; + try { + lineWidth = Integer.parseInt(lineWidthStr.toString()); + if (lineWidth >= 1 && lineWidth <= 4 && lineWidth != currLineWidth) + { + Config.setConfigInt(Config.KEY_LINE_WIDTH, lineWidth); + UpdateMessageBroker.informSubscribers(DataSubscriber.SELECTION_CHANGED); + } + } + catch (NumberFormatException nfe) {}; + } + } +}