|
|
|
@ -7,12 +7,12 @@ import com.fr.design.gui.ilable.UILabel;
|
|
|
|
|
import com.fr.design.gui.ilist.JNameEdList; |
|
|
|
|
import com.fr.design.gui.ilist.ListModelElement; |
|
|
|
|
import com.fr.design.gui.ilist.ModNameActionListener; |
|
|
|
|
import com.fr.design.gui.ilist.UIList; |
|
|
|
|
import com.fr.design.gui.ilist.UINameEdList; |
|
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
|
import com.fr.design.widget.EventCreator; |
|
|
|
|
import com.fr.form.event.Listener; |
|
|
|
|
import com.fr.form.ui.Widget; |
|
|
|
|
import com.fr.general.FRFont; |
|
|
|
|
import com.fr.general.NameObject; |
|
|
|
|
import com.fr.report.web.util.ReportEngineEventMapping; |
|
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
@ -22,6 +22,7 @@ import com.fr.stable.StringUtils;
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
|
import javax.swing.DefaultListModel; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import javax.swing.ListModel; |
|
|
|
|
import javax.swing.ListSelectionModel; |
|
|
|
|
import javax.swing.event.ListDataEvent; |
|
|
|
|
import javax.swing.event.ListDataListener; |
|
|
|
@ -32,6 +33,7 @@ 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; |
|
|
|
@ -47,7 +49,7 @@ import java.util.Map;
|
|
|
|
|
/** |
|
|
|
|
* Created by kerry on 5/31/21 |
|
|
|
|
*/ |
|
|
|
|
public abstract class UIListGroupControlPane extends UIControlPane implements ListControlPaneProvider { |
|
|
|
|
public abstract class UIListGroupControlPane extends UIControlPane implements ListControlPaneProvider { |
|
|
|
|
private boolean isPopulating = false; |
|
|
|
|
private UINameEdList selectNameEdList; |
|
|
|
|
|
|
|
|
@ -142,6 +144,7 @@ public abstract class UIListGroupControlPane extends UIControlPane implements L
|
|
|
|
|
} |
|
|
|
|
this.checkButtonEnabled(); |
|
|
|
|
refreshEventListWrapperPane(); |
|
|
|
|
this.checkGroupPaneSize(); |
|
|
|
|
isPopulating = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -209,6 +212,7 @@ public abstract class UIListGroupControlPane extends UIControlPane implements L
|
|
|
|
|
nameEdList.addModNameActionListener(new ModNameActionListener() { |
|
|
|
|
@Override |
|
|
|
|
public void nameModed(int index, String oldName, String newName) { |
|
|
|
|
checkGroupPaneSize(); |
|
|
|
|
saveSettings(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -262,7 +266,6 @@ public abstract class UIListGroupControlPane extends UIControlPane implements L
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String switchLang(String eventName) { |
|
|
|
|
// 在 properties 文件中找到相应的 key 值
|
|
|
|
|
String localeKey = ReportEngineEventMapping.getLocaleName(eventName); |
|
|
|
@ -270,7 +273,6 @@ public abstract class UIListGroupControlPane extends UIControlPane implements L
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 生成不重复的名字 |
|
|
|
|
* |
|
|
|
@ -300,19 +302,60 @@ public abstract class UIListGroupControlPane extends UIControlPane implements L
|
|
|
|
|
public void onAddItem(NameableCreator creator) { |
|
|
|
|
updateSelectedNameList(creator); |
|
|
|
|
getCommonHandlers().onAddItem(creator); |
|
|
|
|
checkGroupPaneSize(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onRemoveItem() { |
|
|
|
|
getCommonHandlers().onRemoveItem(); |
|
|
|
|
refreshEventListWrapperPane(); |
|
|
|
|
checkGroupPaneSize(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onCopyItem() { |
|
|
|
|
getCommonHandlers().onCopyItem(); |
|
|
|
|
checkGroupPaneSize(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void checkGroupPaneSize() { |
|
|
|
|
int width = 180; |
|
|
|
|
Iterator<Map.Entry<String, ListWrapperPane>> iterator = nameEdListMap.entrySet().iterator(); |
|
|
|
|
while (iterator.hasNext()) { |
|
|
|
|
Map.Entry<String, ListWrapperPane> entry = iterator.next(); |
|
|
|
|
ListWrapperPane wrapperPane = entry.getValue(); |
|
|
|
|
UIList uiList = wrapperPane.getNameEdList(); |
|
|
|
|
width = Math.max(width, calculateUIListMaxCellWidth(uiList.getModel(), uiList.getFontMetrics(uiList.getFont()))); |
|
|
|
|
} |
|
|
|
|
iterator = nameEdListMap.entrySet().iterator(); |
|
|
|
|
width += 40; |
|
|
|
|
while (iterator.hasNext()) { |
|
|
|
|
Map.Entry<String, ListWrapperPane> entry = iterator.next(); |
|
|
|
|
ListWrapperPane wrapperPane = entry.getValue(); |
|
|
|
|
UIList uiList = wrapperPane.getNameEdList(); |
|
|
|
|
uiList.setFixedCellWidth(width); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private int calculateUIListMaxCellWidth(ListModel model, FontMetrics fontMetrics) { |
|
|
|
|
int width = 0; |
|
|
|
|
for (int i = 0; i < model.getSize(); i++) { |
|
|
|
|
Object element = model.getElementAt(i); |
|
|
|
|
if (element != null) { |
|
|
|
|
String text; |
|
|
|
|
if (element instanceof ListModelElement) { |
|
|
|
|
text = ((ListModelElement) element).wrapper.getName(); |
|
|
|
|
} else { |
|
|
|
|
text = element.toString(); |
|
|
|
|
} |
|
|
|
|
width = Math.max(width, fontMetrics.stringWidth(text)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return width; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onMoveUpItem() { |
|
|
|
|
getCommonHandlers().onMoveUpItem(); |
|
|
|
|