Browse Source

Pull request #11874: REPORT-90581 设计器添加事件菜单没有充满,存在留白

Merge in DESIGN/design from ~DESTINY.LIN/design:feature/x to feature/x

* commit '5cb91f8270f1590d3b0112aa2aaacfd7c2492e18':
  REPORT-90581 设计器添加事件菜单没有充满,存在留白
  REPORT-90581 设计器添加事件菜单没有充满,存在留白 格式化
  REPORT-90581 设计器添加事件菜单没有充满,存在留白
feature/x
Destiny.Lin-林锦龙 2 years ago
parent
commit
497dcdac3d
  1. 31
      designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java

31
designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java

@ -28,14 +28,7 @@ import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener; import javax.swing.event.ListDataListener;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import java.awt.AlphaComposite; import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
@ -146,7 +139,7 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li
} }
this.checkButtonEnabled(); this.checkButtonEnabled();
refreshEventListWrapperPane(); refreshEventListWrapperPane();
this.checkGroupPaneSize(); this.updateGroupPaneSize(contentPane);
isPopulating = false; isPopulating = false;
} }
@ -214,7 +207,7 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li
nameEdList.addModNameActionListener(new ModNameActionListener() { nameEdList.addModNameActionListener(new ModNameActionListener() {
@Override @Override
public void nameModed(int index, String oldName, String newName) { public void nameModed(int index, String oldName, String newName) {
checkGroupPaneSize(); updateGroupPaneSize(contentPane);
saveSettings(); saveSettings();
} }
}); });
@ -304,24 +297,30 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li
public void onAddItem(NameableCreator creator) { public void onAddItem(NameableCreator creator) {
updateSelectedNameList(creator); updateSelectedNameList(creator);
getCommonHandlers().onAddItem(creator); getCommonHandlers().onAddItem(creator);
checkGroupPaneSize(); updateGroupPaneSize(contentPane);
} }
@Override @Override
public void onRemoveItem() { public void onRemoveItem() {
getCommonHandlers().onRemoveItem(); getCommonHandlers().onRemoveItem();
refreshEventListWrapperPane(); refreshEventListWrapperPane();
checkGroupPaneSize(); updateGroupPaneSize(contentPane);
} }
@Override @Override
public void onCopyItem() { public void onCopyItem() {
getCommonHandlers().onCopyItem(); getCommonHandlers().onCopyItem();
checkGroupPaneSize(); updateGroupPaneSize(contentPane);
} }
private void checkGroupPaneSize() { /**
* 根据父面板更新对应的面板宽度
* 如果小于父面板的宽度就填充到与父面板宽度一致
*
* @param parentPane 父面板
*/
private void updateGroupPaneSize(JPanel parentPane) {
int width = 180; int width = 180;
Iterator<Map.Entry<String, ListWrapperPane>> iterator = nameEdListMap.entrySet().iterator(); Iterator<Map.Entry<String, ListWrapperPane>> iterator = nameEdListMap.entrySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@ -331,7 +330,9 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li
width = Math.max(width, calculateUIListMaxCellWidth(uiList.getModel(), uiList.getFontMetrics(uiList.getFont()))); width = Math.max(width, calculateUIListMaxCellWidth(uiList.getModel(), uiList.getFontMetrics(uiList.getFont())));
} }
iterator = nameEdListMap.entrySet().iterator(); iterator = nameEdListMap.entrySet().iterator();
width += 30; //contentPane是外层的Panel,如果不进行判断的话宽度就可能会小于contentPanel,右侧会有空隙
//所以需要判断一下,如果外层比较宽就取外层的宽度,防止空隙出现
width = Math.max(width + 30, parentPane == null ? 0 : parentPane.getWidth());
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map.Entry<String, ListWrapperPane> entry = iterator.next(); Map.Entry<String, ListWrapperPane> entry = iterator.next();
ListWrapperPane wrapperPane = entry.getValue(); ListWrapperPane wrapperPane = entry.getValue();

Loading…
Cancel
Save