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
38da25dc
There was a problem fetching the pipeline summary.
Commit
38da25dc
authored
7 years ago
by
Tobias Ask
Browse files
Options
Downloads
Plain Diff
Merge branch '8-link-scene-builder-editor-and-java-editor-selection' into 'master'
Resolve "Link scene builder editor and java editor selection" Closes
#8
See merge request
!6
parents
b28a1e84
155d469f
No related branches found
No related tags found
1 merge request
!6
Resolve "Link scene builder editor and java editor selection"
Pipeline
#
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
sb4e.examples/resources/no/tobask/sb4e/examples/GreatFxml.fxml
+1
-1
1 addition, 1 deletion
...examples/resources/no/tobask/sb4e/examples/GreatFxml.fxml
sb4e/src/no/tobask/sb4e/editors/FXMLEditor.java
+83
-1
83 additions, 1 deletion
sb4e/src/no/tobask/sb4e/editors/FXMLEditor.java
with
84 additions
and
2 deletions
sb4e.examples/resources/no/tobask/sb4e/examples/GreatFxml.fxml
+
1
−
1
View file @
38da25dc
...
...
@@ -6,7 +6,7 @@
<AnchorPane
maxHeight=
"-Infinity"
maxWidth=
"-Infinity"
minHeight=
"-Infinity"
minWidth=
"-Infinity"
prefHeight=
"400.0"
prefWidth=
"600.0"
xmlns=
"http://javafx.com/javafx/8.0.151"
xmlns:fx=
"http://javafx.com/fxml/1"
fx:controller=
"GreatFxmlController.java"
>
<children>
<Button
layoutX=
"58.0"
layoutY=
"296.0"
mnemonicParsing=
"false"
text=
"Button"
/>
<Button
layoutX=
"58.0"
layoutY=
"296.0"
mnemonicParsing=
"false"
text=
"Button"
fx:id=
"button"
/>
<Label
layoutX=
"350.0"
layoutY=
"200.0"
text=
"Label"
/>
</children>
</AnchorPane>
This diff is collapsed.
Click to expand it.
sb4e/src/no/tobask/sb4e/editors/FXMLEditor.java
+
83
−
1
View file @
38da25dc
...
...
@@ -11,15 +11,24 @@ import org.eclipse.core.commands.operations.IUndoContext;
import
org.eclipse.core.commands.operations.ObjectUndoContext
;
import
org.eclipse.core.commands.operations.OperationHistoryFactory
;
import
org.eclipse.core.resources.IFile
;
import
org.eclipse.core.resources.IMarker
;
import
org.eclipse.core.resources.IResource
;
import
org.eclipse.core.runtime.CoreException
;
import
org.eclipse.core.runtime.IProgressMonitor
;
import
org.eclipse.jdt.core.ICompilationUnit
;
import
org.eclipse.jdt.core.IField
;
import
org.eclipse.jdt.core.ISourceRange
;
import
org.eclipse.jdt.core.IType
;
import
org.eclipse.jdt.core.JavaModelException
;
import
org.eclipse.jface.action.IAction
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.ui.IEditorInput
;
import
org.eclipse.ui.IEditorPart
;
import
org.eclipse.ui.IEditorReference
;
import
org.eclipse.ui.IEditorSite
;
import
org.eclipse.ui.PartInitException
;
import
org.eclipse.ui.ide.IDE
;
import
org.eclipse.ui.operations.RedoActionHandler
;
import
org.eclipse.ui.operations.UndoActionHandler
;
import
org.eclipse.ui.part.EditorPart
;
...
...
@@ -29,11 +38,14 @@ import com.oracle.javafx.scenebuilder.kit.editor.EditorController;
import
com.oracle.javafx.scenebuilder.kit.editor.JobManager
;
import
com.oracle.javafx.scenebuilder.kit.editor.job.Job
;
import
com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument
;
import
com.oracle.javafx.scenebuilder.kit.fxom.FXOMObject
;
import
javafx.beans.value.ChangeListener
;
import
javafx.embed.swt.FXCanvas
;
import
no.tobask.sb4e.CustomClassLoaderLibrary
;
import
no.tobask.sb4e.EclipseProjectsClassLoader
;
import
no.tobask.sb4e.EditorWindowController
;
import
no.tobask.sb4e.JavaModelUtils
;
import
no.tobask.sb4e.JavaProjectGlossary
;
public
class
FXMLEditor
extends
EditorPart
{
...
...
@@ -45,6 +57,7 @@ public class FXMLEditor extends EditorPart {
private
RedoActionHandler
redoActionHandler
;
private
IUndoContext
undoContext
;
private
IOperationHistory
operationHistory
;
private
ICompilationUnit
controllerClass
;
public
IAction
getUndoActionHandler
()
{
return
undoActionHandler
;
...
...
@@ -124,6 +137,75 @@ public class FXMLEditor extends EditorPart {
e
.
printStackTrace
();
}
canvas
.
setScene
(
editorWindowController
.
getScene
());
editorController
.
getSelection
().
revisionProperty
().
addListener
(
editorSelectionListener
);
}
private
ChangeListener
<
Number
>
editorSelectionListener
=
(
oV
,
oldNum
,
newNum
)
->
{
String
controllerName
=
editorController
.
getFxomDocument
().
getFxomRoot
().
getFxController
();
if
(
controllerName
==
null
)
{
return
;
}
if
(
controllerClass
==
null
||
!
controllerClass
.
getElementName
().
equals
(
controllerName
))
{
controllerClass
=
JavaModelUtils
.
getClass
(
fxmlUrl
,
controllerName
);
if
(
controllerClass
==
null
)
{
return
;
}
}
IEditorPart
editor
=
getEditorEditingController
();
if
(
editor
!=
null
)
{
try
{
FXOMObject
selectedObject
=
editorController
.
getSelection
().
getHitItem
();
if
(
selectedObject
!=
null
)
{
String
fxId
=
selectedObject
.
getFxId
();
if
(
fxId
!=
null
)
{
int
[]
location
=
getLocation
(
fxId
,
controllerClass
);
if
(
location
!=
null
)
{
IFile
file
=
((
FileEditorInput
)
editor
.
getEditorInput
())
.
getFile
();
IDE
.
gotoMarker
(
editor
,
createMarker
(
file
,
location
));
}
}
}
}
catch
(
CoreException
e
)
{
e
.
printStackTrace
();
}
}
};
private
IMarker
createMarker
(
IFile
file
,
int
[]
location
)
throws
CoreException
{
IMarker
marker
=
file
.
createMarker
(
IMarker
.
TEXT
);
marker
.
setAttribute
(
IMarker
.
CHAR_START
,
location
[
0
]);
marker
.
setAttribute
(
IMarker
.
CHAR_END
,
location
[
1
]);
return
marker
;
}
private
IEditorPart
getEditorEditingController
()
{
for
(
IEditorReference
editorRef
:
getSite
().
getPage
().
getEditorReferences
())
{
IEditorPart
editor
=
editorRef
.
getEditor
(
false
);
if
(
editor
.
getEditorInput
()
instanceof
FileEditorInput
)
{
IFile
file
=
((
FileEditorInput
)
editor
.
getEditorInput
()).
getFile
();
if
(
file
.
getName
().
equals
(
controllerClass
.
getElementName
()))
{
return
editor
;
}
}
}
return
null
;
}
private
int
[]
getLocation
(
String
fxId
,
ICompilationUnit
controllerClass
)
{
IType
type
=
controllerClass
.
findPrimaryType
();
IField
field
=
type
.
getField
(
fxId
);
if
(
field
.
exists
())
{
try
{
ISourceRange
sourceRange
=
field
.
getSourceRange
();
int
end
=
sourceRange
.
getOffset
()
+
sourceRange
.
getLength
();
int
start
=
end
-
fxId
.
length
();
return
new
int
[]
{
start
-
1
,
end
-
1
};
}
catch
(
JavaModelException
e
)
{
e
.
printStackTrace
();
}
}
return
null
;
}
private
boolean
isFreshJob
(
Job
job
)
{
...
...
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