Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scene-builder-plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Ask
scene-builder-plugin
Commits
7fd9f5a9
Commit
7fd9f5a9
authored
7 years ago
by
Tobias Ask
Browse files
Options
Downloads
Patches
Plain Diff
Use field for fxml class name used in annotation checks.
parent
0329f54e
No related branches found
No related tags found
1 merge request
!5
Resolve "Weak connection to controller class"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sb4e/src/no/tobask/sb4e/JavaProjectGlossary.java
+5
-6
5 additions, 6 deletions
sb4e/src/no/tobask/sb4e/JavaProjectGlossary.java
with
5 additions
and
6 deletions
sb4e/src/no/tobask/sb4e/JavaProjectGlossary.java
+
5
−
6
View file @
7fd9f5a9
...
@@ -44,6 +44,7 @@ public class JavaProjectGlossary extends Glossary implements IElementChangedList
...
@@ -44,6 +44,7 @@ public class JavaProjectGlossary extends Glossary implements IElementChangedList
private
String
controllerClassName
;
private
String
controllerClassName
;
private
Map
<
String
,
List
<
String
>>
fxIds
;
private
Map
<
String
,
List
<
String
>>
fxIds
;
private
List
<
String
>
eventHandlers
;
private
List
<
String
>
eventHandlers
;
private
static
final
String
FXML_ANNOTATION
=
FXML
.
class
.
getSimpleName
();
public
JavaProjectGlossary
()
{
public
JavaProjectGlossary
()
{
JavaCore
.
addElementChangedListener
(
this
,
ElementChangedEvent
.
POST_CHANGE
);
JavaCore
.
addElementChangedListener
(
this
,
ElementChangedEvent
.
POST_CHANGE
);
...
@@ -156,14 +157,13 @@ public class JavaProjectGlossary extends Glossary implements IElementChangedList
...
@@ -156,14 +157,13 @@ public class JavaProjectGlossary extends Glossary implements IElementChangedList
}
}
private
boolean
hasFxmlAnnotatedMembers
(
IType
type
)
{
private
boolean
hasFxmlAnnotatedMembers
(
IType
type
)
{
String
fxml
=
FXML
.
class
.
getSimpleName
();
try
{
try
{
List
<
IMethod
>
methods
=
new
ArrayList
<>(
Arrays
.
asList
(
type
.
getMethods
()));
List
<
IMethod
>
methods
=
new
ArrayList
<>(
Arrays
.
asList
(
type
.
getMethods
()));
List
<
IField
>
fields
=
new
ArrayList
<>(
Arrays
.
asList
(
type
.
getFields
()));
List
<
IField
>
fields
=
new
ArrayList
<>(
Arrays
.
asList
(
type
.
getFields
()));
boolean
anyMethodsAnnotated
=
methods
.
stream
().
anyMatch
(
m
->
boolean
anyMethodsAnnotated
=
methods
.
stream
().
anyMatch
(
m
->
m
.
getAnnotation
(
fxml
).
exists
());
m
.
getAnnotation
(
FXML_ANNOTATION
).
exists
());
boolean
anyFieldsAnnotated
=
fields
.
stream
().
anyMatch
(
f
->
boolean
anyFieldsAnnotated
=
fields
.
stream
().
anyMatch
(
f
->
f
.
getAnnotation
(
fxml
).
exists
());
f
.
getAnnotation
(
FXML_ANNOTATION
).
exists
());
return
anyFieldsAnnotated
||
anyMethodsAnnotated
;
return
anyFieldsAnnotated
||
anyMethodsAnnotated
;
}
catch
(
JavaModelException
e
)
{
}
catch
(
JavaModelException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -217,9 +217,8 @@ public class JavaProjectGlossary extends Glossary implements IElementChangedList
...
@@ -217,9 +217,8 @@ public class JavaProjectGlossary extends Glossary implements IElementChangedList
}
}
private
boolean
isEventHandler
(
IMethod
method
)
{
private
boolean
isEventHandler
(
IMethod
method
)
{
String
fxml
=
FXML
.
class
.
getSimpleName
();
try
{
try
{
boolean
isFxmlAnnotated
=
method
.
getAnnotation
(
fxml
).
exists
();
boolean
isFxmlAnnotated
=
method
.
getAnnotation
(
FXML_ANNOTATION
).
exists
();
boolean
returnsVoid
=
method
.
getReturnType
().
equals
(
Signature
.
SIG_VOID
);
boolean
returnsVoid
=
method
.
getReturnType
().
equals
(
Signature
.
SIG_VOID
);
if
(
isFxmlAnnotated
&&
returnsVoid
)
{
if
(
isFxmlAnnotated
&&
returnsVoid
)
{
// valid ones are:
// valid ones are:
...
@@ -254,7 +253,7 @@ public class JavaProjectGlossary extends Glossary implements IElementChangedList
...
@@ -254,7 +253,7 @@ public class JavaProjectGlossary extends Glossary implements IElementChangedList
IType
type
=
controller
.
findPrimaryType
();
IType
type
=
controller
.
findPrimaryType
();
try
{
try
{
for
(
IField
field
:
type
.
getFields
())
{
for
(
IField
field
:
type
.
getFields
())
{
if
(
field
.
getAnnotation
(
"
FXML
"
).
exists
())
{
if
(
field
.
getAnnotation
(
FXML
_ANNOTATION
).
exists
())
{
addToIds
(
ids
,
field
);
addToIds
(
ids
,
field
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment