Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CUP Eclipse Plugin
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dr. Michael Petter
CUP Eclipse Plugin
Commits
c8a7aebe
Commit
c8a7aebe
authored
Nov 28, 2014
by
Johannes Roith
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:jroith/cup-eclipse
parents
8083baf1
b01744c9
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
172 additions
and
69 deletions
+172
-69
CupPlugin/src/de/tum/in/www2/cupplugin/editors/CupConflictGraphView.java
...e/tum/in/www2/cupplugin/editors/CupConflictGraphView.java
+91
-49
CupPlugin/src/de/tum/in/www2/cupplugin/editors/CupReduceGraphView.java
.../de/tum/in/www2/cupplugin/editors/CupReduceGraphView.java
+80
-19
CupPlugin/src/de/tum/in/www2/cupplugin/editors/MultiPageEditor.java
...src/de/tum/in/www2/cupplugin/editors/MultiPageEditor.java
+1
-1
No files found.
CupPlugin/src/de/tum/in/www2/cupplugin/editors/CupConflictGraphView.java
View file @
c8a7aebe
This diff is collapsed.
Click to expand it.
CupPlugin/src/de/tum/in/www2/cupplugin/editors/CupReduceGraphView.java
View file @
c8a7aebe
...
...
@@ -3,6 +3,7 @@ package de.tum.in.www2.cupplugin.editors;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.util.ArrayList
;
import
java.util.EnumSet
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
...
...
@@ -73,14 +74,19 @@ import de.in.tum.www2.cup.internal.lalr_state;
import
de.in.tum.www2.cup.internal.lalr_transition
;
import
de.in.tum.www2.cup.internal.parse_reduce_row
;
import
de.in.tum.www2.cup.internal.parse_reduce_table
;
import
de.tum.in.www2.cupplugin.controller.Controller.JobsToDo
;
import
de.tum.in.www2.cupplugin.controller.Controller
;
import
de.tum.in.www2.cupplugin.controller.RegisterForControllerChanges
;
import
de.tum.in.www2.cupplugin.model.CupParserLaLrChangeObserver
;
import
de.tum.in.www2.cupplugin.model.Model
;
public
class
CupReduceGraphView
implements
CupParserLaLrChangeObserver
,
IZoomableWorkbenchPart
,
CupEditorPageVisibility
{
IZoomableWorkbenchPart
,
CupEditorPageVisibility
,
RegisterForControllerChanges
{
// Some Constants
private
static
final
int
BUTTON_WIDTH
=
120
;
private
static
final
int
LABEL_WIDTH
=
40
;
public
static
final
Object
modelBuildLock
=
new
Object
();
public
GraphViewer
graphViewer
;
...
...
@@ -94,17 +100,24 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
private
boolean
isVisible
=
false
;
private
boolean
shouldRebuildWhenVisible
=
false
;
public
CupReduceGraphView
(
Composite
parent
,
IDocument
doc
)
{
private
CupTextEditor
editor
;
public
CupReduceGraphView
(
Composite
parent
,
CupTextEditor
editor
)
{
this
.
editor
=
editor
;
Controller
.
getInstance
(
editor
).
registerObserver
(
this
);
IDocument
doc
=
editor
.
getDocumentProvider
().
getDocument
(
editor
.
getEditorInput
());
this
.
parseModel
=
Model
.
getInstanceForDocument
(
doc
);
this
.
parseModel
.
registerModelObserver
(
this
);
this
.
parentComposite
=
parent
;
GridLayout
parentLayout
=
new
GridLayout
(
4
,
false
);
GridLayout
parentLayout
=
new
GridLayout
(
5
,
false
);
this
.
parentComposite
.
setLayout
(
parentLayout
);
this
.
graphComposite
=
new
Composite
(
parent
,
SWT
.
NONE
);
this
.
graphComposite
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
true
,
true
,
4
,
1
));
true
,
true
,
5
,
1
));
this
.
graphComposite
.
setLayout
(
new
FillLayout
());
nodeModel
=
new
ParserNodeModelContentProvider
();
...
...
@@ -114,9 +127,9 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
ParserReduceLabelProvider
labelProvider
=
new
ParserReduceLabelProvider
(
nodeModel
.
getConnections
());
graphViewer
.
setLabelProvider
(
labelProvider
);
//graphViewer.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED);
//
graphViewer.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED);
graphViewer
.
setInput
(
nodeModel
.
getNodes
());
LayoutAlgorithm
layout
=
new
CompositeLayoutAlgorithm
(
...
...
@@ -204,17 +217,21 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
e1
.
printStackTrace
();
}
if
(
zoomManager
!=
null
)
{
org
.
eclipse
.
swt
.
widgets
.
Label
zoomLabel
=
new
org
.
eclipse
.
swt
.
widgets
.
Label
(
this
.
parentComposite
,
SWT
.
WRAP
);
zoomLabel
.
setLayoutData
(
new
GridData
(
LABEL_WIDTH
,
20
));
zoomLabel
.
setText
(
"Zoom:"
);
Combo
combo
=
new
Combo
(
this
.
parentComposite
,
SWT
.
READ_ONLY
);
combo
.
setLayoutData
(
new
GridData
(
BUTTON_WIDTH
,
20
));
String
[]
levels
=
zoomManager
.
getZoomLevelsAsText
();
String
[]
levels
=
zoomManager
.
getZoomLevelsAsText
();
combo
.
setItems
(
levels
);
combo
.
select
(
0
);
combo
.
addListener
(
SWT
.
Selection
,
new
Listener
()
{
@Override
public
void
handleEvent
(
Event
e
)
{
if
(
e
.
widget
instanceof
Combo
)
{
Combo
c
=
(
Combo
)
e
.
widget
;
Combo
c
=
(
Combo
)
e
.
widget
;
int
idx
=
c
.
getSelectionIndex
();
String
s
=
levels
[
idx
];
zoomManager
.
setZoomAsText
(
levels
[
idx
]);
...
...
@@ -229,21 +246,29 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
public
void
willBecomeVisible
()
{
System
.
out
.
println
(
"CupGraphView will become visible."
);
isVisible
=
true
;
if
(!
Controller
.
getInstance
(
editor
).
requestJobRun
())
{
// TODO: Handle no rerun!!
IDocument
doc
=
editor
.
getDocumentProvider
().
getDocument
(
editor
.
getEditorInput
());
ModelChange
(
Model
.
getInstanceForDocument
(
doc
));
}
}
public
void
reloadGraph
()
{
LayoutAlgorithm
layout
=
new
CompositeLayoutAlgorithm
(
LayoutStyles
.
NO_LAYOUT_NODE_RESIZING
,
new
LayoutAlgorithm
[]
{
new
GridLayoutAlgorithm
(
LayoutStyles
.
NO_LAYOUT_NODE_RESIZING
),
new
HorizontalShift
(
LayoutStyles
.
NO_LAYOUT_NODE_RESIZING
)
//
,
//
new GridLayoutAlgorithm(
// LayoutStyles.NO_LAYOUT_NODE_RESIZING)
});
LayoutStyles
.
NO_LAYOUT_NODE_RESIZING
)
//
,
//
new GridLayoutAlgorithm(
// LayoutStyles.NO_LAYOUT_NODE_RESIZING)
});
graphViewer
.
setLayoutAlgorithm
(
layout
,
true
);
graphViewer
.
applyLayout
();
synchronized
(
CupReduceGraphView
.
modelBuildLock
)
{
graphViewer
.
refresh
();
}
}
}
@Override
...
...
@@ -254,9 +279,12 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
@Override
public
void
ModelChange
(
Model
model
)
{
if
(!
isVisible
)
{
return
;
}
LALRResult
lalrResult
=
model
.
getLaLrResult
();
CupContext
lalrContext
=
model
.
getLaLrContext
();
nodeModel
.
rebuildModel
(
model
,
lalrResult
,
lalrContext
);
nodeModel
.
rebuildModel
(
model
,
lalrResult
,
lalrContext
,
this
);
}
public
AbstractZoomableViewer
getGraphViewer
()
{
...
...
@@ -353,7 +381,7 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
}
public
void
rebuildModel
(
Model
model
,
LALRResult
lalrResult
,
CupContext
lalrContext
)
{
CupContext
lalrContext
,
CupReduceGraphView
reduceGraphView
)
{
this
.
lalrContext
=
lalrContext
;
this
.
lalrResult
=
lalrResult
;
...
...
@@ -362,7 +390,7 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
rebuildJob
.
cancel
();
}
rebuildJob
=
new
ModelRebuildJob
(
model
,
lalrResult
,
lalrContext
,
connections
,
nodes
,
nodeMap
);
lalrContext
,
connections
,
nodes
,
nodeMap
,
reduceGraphView
);
rebuildJob
.
setSystem
(
true
);
rebuildJob
.
schedule
();
}
...
...
@@ -435,12 +463,14 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
private
List
<
ParserReduceConnection
>
connections
;
private
List
<
ParserReduceNode
>
nodes
;
private
HashMap
<
Integer
,
ParserReduceNode
>
nodeMap
;
private
CupReduceGraphView
reduceGraphView
;
public
ModelRebuildJob
(
Model
model
,
LALRResult
lalrResult
,
CupContext
lalrContext
,
List
<
ParserReduceConnection
>
connections
,
List
<
ParserReduceNode
>
nodes
,
HashMap
<
Integer
,
ParserReduceNode
>
nodeMap
)
{
HashMap
<
Integer
,
ParserReduceNode
>
nodeMap
,
CupReduceGraphView
reduceGraphView
)
{
super
(
"Model Rebuild Job"
);
this
.
model
=
model
;
...
...
@@ -449,6 +479,7 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
this
.
connections
=
connections
;
this
.
nodes
=
nodes
;
this
.
nodeMap
=
nodeMap
;
this
.
reduceGraphView
=
reduceGraphView
;
}
@Override
...
...
@@ -502,6 +533,27 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
}
}
}
ModelRebuildJobFinished
job
=
new
ModelRebuildJobFinished
(
reduceGraphView
);
job
.
setSystem
(
true
);
job
.
schedule
();
return
Status
.
OK_STATUS
;
}
}
static
class
ModelRebuildJobFinished
extends
UIJob
{
private
CupReduceGraphView
reduceGraphView
;
public
ModelRebuildJobFinished
(
CupReduceGraphView
reduceGraphView
)
{
super
(
"Model Rebuild Job Finished UI Job"
);
this
.
reduceGraphView
=
reduceGraphView
;
}
@Override
public
IStatus
runInUIThread
(
IProgressMonitor
monitor
)
{
reduceGraphView
.
reloadGraph
();
return
Status
.
OK_STATUS
;
}
...
...
@@ -806,4 +858,13 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
public
AbstractZoomableViewer
getZoomableViewer
()
{
return
getGraphViewer
();
}
@Override
public
EnumSet
<
JobsToDo
>
getRequiredJobs
()
{
EnumSet
<
JobsToDo
>
requestedJobs
=
EnumSet
.
noneOf
(
JobsToDo
.
class
);
if
(
isVisible
)
{
requestedJobs
=
EnumSet
.
of
(
JobsToDo
.
buildTable
,
JobsToDo
.
parseCode
);
}
return
requestedJobs
;
}
}
CupPlugin/src/de/tum/in/www2/cupplugin/editors/MultiPageEditor.java
View file @
c8a7aebe
...
...
@@ -85,7 +85,7 @@ public class MultiPageEditor extends MultiPageEditorPart implements
Composite
composite
=
new
Composite
(
getContainer
(),
SWT
.
NONE
);
IDocument
doc
=
editor
.
getDocumentProvider
().
getDocument
(
editor
.
getEditorInput
());
graphReduceView
=
new
CupReduceGraphView
(
composite
,
doc
);
graphReduceView
=
new
CupReduceGraphView
(
composite
,
getEditor
()
);
int
index
=
addPage
(
composite
);
setPageText
(
index
,
"Automaton View (costly)"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment