01: package com.umlet.control;
02:
03: import java.util.Vector;
04: import java.util.regex.*;
05:
06: public class HelpPanelChanged extends Command {
07: private String changed_to;
08: private String changed_from;
09:
10: public HelpPanelChanged(String text) {
11: this .changed_to = text;
12: }
13:
14: private Integer getFontsize(String text) {
15: if (text == null)
16: return null;
17: Pattern p = Pattern.compile("(\\s)*fontsize\\=([0-9]+)(\\s)*");
18: Vector<String> txt = Constants.decomposeStrings(text, "\n");
19: for (String t : txt) {
20: Matcher m = p.matcher(t);
21: if (m.matches())
22: return Integer.parseInt(m.group(2));
23: }
24: return null;
25: }
26:
27: public void execute() {
28: super .execute();
29: this .changed_from = Constants.getHelpText();
30: Constants.setHelpText(changed_to);
31: Constants.setFontsize(this .getFontsize(changed_to));
32: Umlet.getInstance().repaint();
33: }
34:
35: public void undo() {
36: super.undo();
37: Constants.setHelpText(changed_from);
38: Constants.setFontsize(this.getFontsize(changed_from));
39: Umlet.getInstance().repaint();
40: }
41: }
|