From b388a85042d384f76b0036ddbaa55fc30c3e70ec Mon Sep 17 00:00:00 2001 From: fr_shine Date: Mon, 27 Feb 2017 09:39:29 +0800 Subject: [PATCH] editlabel not append origin label --- .../mainframe/chart/gui/UIEditLabel.java | 44 ++++++++++++------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/UIEditLabel.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/UIEditLabel.java index ceca4f9dc..c7c3c51c7 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/UIEditLabel.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/UIEditLabel.java @@ -161,35 +161,47 @@ public class UIEditLabel extends JPanel implements UIObserver{ return text; } + protected boolean appendOriginalLabel() { + return true; + } + private void stopEditing(){ isEditingStopped = true; this.removeAll(); - String text =this.showLabel.getText(); - text = StringUtils.cutStringEndWith(text,":"); - text = !ComparatorUtils.equals(text, this.originalLabel) ? - StringUtils.perfectEnd(text, "(" + this.originalLabel + ")"): this.originalLabel; - showLabel.setText(StringUtils.perfectEnd(text,":")); + if(appendOriginalLabel()) { + String text = this.showLabel.getText(); + text = StringUtils.cutStringEndWith(text, ":"); + text = !ComparatorUtils.equals(text, this.originalLabel) ? + StringUtils.perfectEnd(text, "(" + this.originalLabel + ")") : this.originalLabel; + showLabel.setText(StringUtils.perfectEnd(text, ":")); + } this.add(showLabel, BorderLayout.CENTER); this.revalidate(); this.repaint(); } public String getText(){ - String text =this.showLabel.getText(); - text = StringUtils.cutStringEndWith(text,":"); - return StringUtils.cutStringEndWith(text,"("+this.originalLabel+")"); + if(appendOriginalLabel()) { + String text = this.showLabel.getText(); + text = StringUtils.cutStringEndWith(text, ":"); + return StringUtils.cutStringEndWith(text, "(" + this.originalLabel + ")"); + } else { + return this.showLabel.getText(); + } } public void setText(String text){ - if(text == null || StringUtils.isEmpty(text)){ - this.showLabel.setText(this.originalLabel); - return; - } - if(!ComparatorUtils.equals(text,originalLabel)){ - text = StringUtils.cutStringEndWith(text, ":"); - text = StringUtils.perfectEnd(text,"("+originalLabel+")"); + if(appendOriginalLabel()) { + if (text == null || StringUtils.isEmpty(text)) { + this.showLabel.setText(this.originalLabel); + return; + } + if (!ComparatorUtils.equals(text, originalLabel)) { + text = StringUtils.cutStringEndWith(text, ":"); + text = StringUtils.perfectEnd(text, "(" + originalLabel + ")"); + } + text = StringUtils.perfectEnd(text, ":"); } - text = StringUtils.perfectEnd(text,":"); this.showLabel.setText(text); }