Browse Source

Merge pull request #467 in BA/design from ~ZHENG/design:dev to dev

* commit '56cb8bbfe281aec061e161688a63ccd20f79e016':
  图表切换button重命名结束事件
master
superman 8 years ago
parent
commit
6bfd3bc9bc
  1. 67
      designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java

67
designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java

@ -1,10 +1,10 @@
package com.fr.design.mainframe.chart.gui;
import com.fr.base.BaseUtils;
import com.fr.chart.base.AttrChangeConfig;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.SwitchState;
import com.fr.chart.base.AttrChangeConfig;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.DialogActionListener;
import com.fr.design.dialog.UIDialog;
@ -53,19 +53,14 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
private ChartTypePane parent = null;
//记录鼠标当前是否在操作添加按钮
private boolean mouseOnChartTypeButtonPane = false;
//配置窗口属性
private UIMenuNameableCreator configCreator;
/**
* 鼠标事件是否在这个面板
* @return 返回是否
*/
public boolean isMouseOnChartTypeButtonPane() {
return this.mouseOnChartTypeButtonPane;
}
//处理 编辑一个button时,选中另一个button的问题.
//stopEditing不能直接relayout,否则click事件不响应了.
//所以:stopEditing--选中其他button则响应click之后relayout;普通失焦则直接relayout.
private boolean pressOtherButtonWhenEditing = false;
// private AWTEventListener awt = new AWTEventListener() {
// public void eventDispatched(AWTEvent event) {
@ -122,7 +117,6 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
private void initAddButton() {
addButton.setPreferredSize(new Dimension(20, 20));
addButton.addActionListener(addListener);
addButton.addMouseListener(mouseListener);
}
private void initConfigButton() {
@ -133,7 +127,6 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
ActionListener addListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
mouseOnChartTypeButtonPane = true;
String name = getNewChartName();
ChartChangeButton button = new ChartChangeButton(name);// some set selected
@ -188,15 +181,6 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
dialog.setVisible(true);
}
};
MouseListener mouseListener = new MouseAdapter() {
@Override
public void mouseExited(MouseEvent e) {
super.mouseExited(e);
mouseOnChartTypeButtonPane = false;
}
};
private String getNewChartName() {
int count = indexList.size() + 1;
@ -352,12 +336,19 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
if (currentEditingEditor != null) {
String newName = currentEditingEditor.getText();
int selectedIndex = editingCollection.getSelectedIndex();
ChartChangeButton button = indexList.get(selectedIndex);
button.isMoveOn = false;
if (!ComparatorUtils.equals(editingCollection.getChartName(selectedIndex), newName)) {
editingCollection.setChartName(selectedIndex, newName);
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().fireTargetModified();
button.changeChartName(newName);
}
buttonPane.remove(currentEditingEditor);
currentEditingEditor = null;
if(!pressOtherButtonWhenEditing) {
layoutPane(buttonPane);
}
}
}
@ -375,11 +366,25 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
buttonName = name;
this.setToolTipText(name);
nameField.addActionListener(new ActionListener() {
nameField.addActionListener(new ActionListener() {//enter
@Override
public void actionPerformed(ActionEvent e) {
pressOtherButtonWhenEditing = false;
stopEditing();
populateBean(editingCollection);
}
});
nameField.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
}
@Override
public void focusLost(FocusEvent e) {//编辑状态lost才走这边
if (currentEditingEditor != null ) {
stopEditing();
}
}
});
}
@ -388,6 +393,11 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
return buttonName;
}
private void changeChartName(String name) {
this.setText(name);
buttonName = name;
}
public Dimension getPreferredSize() {
return new Dimension(B_W, B_H);
}
@ -467,17 +477,20 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
@Override
public void mouseClicked(MouseEvent e) {
mouseClick(e);
mouseOnChartTypeButtonPane = true;
if(pressOtherButtonWhenEditing){
relayoutPane();
pressOtherButtonWhenEditing = false;
}
}
public void mouseEntered(MouseEvent e) {
checkMoveOn(true);
mouseOnChartTypeButtonPane = true;
pressOtherButtonWhenEditing = currentEditingEditor != null;
}
public void mouseExited(MouseEvent e) {
checkMoveOn(false);
mouseOnChartTypeButtonPane = false;
pressOtherButtonWhenEditing = false;
}
};
}

Loading…
Cancel
Save