Skip to content
Snippets Groups Projects
Commit eb96870a authored by Tobias Ask's avatar Tobias Ask
Browse files

Use helper methods where applicable.

parent 7fd9f5a9
Branches
No related tags found
1 merge request!5Resolve "Weak connection to controller class"
Pipeline #
...@@ -2,9 +2,13 @@ package no.tobask.sb4e.examples; ...@@ -2,9 +2,13 @@ package no.tobask.sb4e.examples;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.Button;
public class GreatFxmlController { public class GreatFxmlController {
@FXML
Button button;
@FXML @FXML
private void onSomething(ActionEvent event) { private void onSomething(ActionEvent event) {
......
...@@ -70,7 +70,7 @@ public class JavaProjectGlossary extends Glossary implements IElementChangedList ...@@ -70,7 +70,7 @@ public class JavaProjectGlossary extends Glossary implements IElementChangedList
ICompilationUnit controller = discoverController(fxmlLocation, controllerClass); ICompilationUnit controller = discoverController(fxmlLocation, controllerClass);
fxIds = controller == null ? new HashMap<>() : getFxIds(controller); fxIds = controller == null ? new HashMap<>() : getFxIds(controller);
} }
return fxIds.getOrDefault(getClassName(targetType), new ArrayList<>()); return fxIds.getOrDefault(Signature.getSimpleName(targetType.getName()), new ArrayList<>());
} }
@Override @Override
...@@ -196,11 +196,6 @@ public class JavaProjectGlossary extends Glossary implements IElementChangedList ...@@ -196,11 +196,6 @@ public class JavaProjectGlossary extends Glossary implements IElementChangedList
return null; return null;
} }
private String getClassName(Class<?> clas) {
int classNameStartIdx = clas.getName().lastIndexOf(".") + 1;
return clas.getName().substring(classNameStartIdx);
}
private List<String> getEventHandlers(ICompilationUnit controller) { private List<String> getEventHandlers(ICompilationUnit controller) {
List<String> eventHandlers = new ArrayList<>(); List<String> eventHandlers = new ArrayList<>();
IType type = controller.findPrimaryType(); IType type = controller.findPrimaryType();
...@@ -265,8 +260,7 @@ public class JavaProjectGlossary extends Glossary implements IElementChangedList ...@@ -265,8 +260,7 @@ public class JavaProjectGlossary extends Glossary implements IElementChangedList
private void addToIds(Map<String, List<String>> ids, IField field) { private void addToIds(Map<String, List<String>> ids, IField field) {
try { try {
String typeName = field.getTypeSignature(); String typeName = Signature.getSignatureSimpleName(field.getTypeSignature());
typeName = typeName.substring(1, typeName.length()-1);
String fieldName = field.getElementName(); String fieldName = field.getElementName();
List<String> existingIds = ids.putIfAbsent(typeName, List<String> existingIds = ids.putIfAbsent(typeName,
new ArrayList<>(Arrays.asList(fieldName))); new ArrayList<>(Arrays.asList(fieldName)));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment