Skip to content

Commit 93e9681

Browse files
committed
Possible exceptions in the Modeler
1 parent 3ac712d commit 93e9681

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/DbAttributePathComboBoxEditor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.apache.cayenne.modeler.util;
2121

22+
import org.apache.cayenne.exp.path.CayennePath;
2223
import org.apache.cayenne.map.DbAttribute;
2324
import org.apache.cayenne.map.DbEntity;
2425
import org.apache.cayenne.map.DbRelationship;
@@ -81,13 +82,12 @@ protected Object getCurrentNodeToInitializeCombo(ObjAttributeTableModel model, i
8182

8283
@Override
8384
protected String getPathToInitializeCombo(ObjAttributeTableModel model, int row) {
84-
String pathString = model.getAttribute(row).getValue().getDbAttributePath().value();
85-
if (pathString == null) {
85+
CayennePath path = model.getAttribute(row).getValue().getDbAttributePath();
86+
if (path == null || path.isEmpty()) {
8687
return "";
8788
}
88-
String[] pathStrings = pathString.split(Pattern.quote("."));
89-
String lastStringInPath = pathStrings[pathStrings.length - 1];
90-
return pathString.replaceAll(lastStringInPath + '$', "");
89+
return path.parent()
90+
.dot(path.last().value().replaceAll("\\$", "")).value();
9191
}
9292

9393
@Override

modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/PathChooserComboBoxCellEditor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,10 @@ public Component getListCellRendererComponent(JList<?> list, Object value, int i
244244
boolean isSelected, boolean cellHasFocus) {
245245

246246
JPanel panel = new JPanel(new BorderLayout());
247-
JLabel label = new JLabel((String) value);
247+
JLabel label = new JLabel(value.toString());
248248
panel.add(label);
249249

250-
Object currentNode = getCurrentNode((String) value);
250+
Object currentNode = getCurrentNode(value.toString());
251251
if (treeModel.isLeaf(currentNode)) {
252252
ListCellRenderer<Object> leafRenderer = CellRenderers.listRenderer();
253253
return leafRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

0 commit comments

Comments
 (0)