Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
general
stups
ProB Rodin Plugin
Commits
db2ef794
Commit
db2ef794
authored
Dec 14, 2011
by
Jens Bendisposto
Browse files
merged
parents
d6b1a47c
9c18d3c5
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
de.prob.core/prob/macos/lib/cspm
0 → 100755
View file @
db2ef794
File added
de.prob.core/src/de/prob/core/command/LoadCspModelCommand.java
0 → 100644
View file @
db2ef794
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, Heinrich
* Heine Universitaet Duesseldorf This software is licenced under EPL 1.0
* (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package
de.prob.core.command
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.Collection
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Set
;
import
org.eventb.core.IEventBRoot
;
import
org.osgi.service.prefs.BackingStoreException
;
import
org.osgi.service.prefs.Preferences
;
import
de.be4.classicalb.core.parser.BParser
;
import
de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader
;
import
de.be4.classicalb.core.parser.exceptions.BException
;
import
de.be4.classicalb.core.parser.node.Start
;
import
de.prob.core.Animator
;
import
de.prob.core.domainobjects.Operation
;
import
de.prob.core.domainobjects.ProBPreference
;
import
de.prob.core.domainobjects.State
;
import
de.prob.exceptions.ProBException
;
import
de.prob.logging.Logger
;
import
de.prob.parser.ISimplifiedROMap
;
import
de.prob.prolog.output.IPrologTermOutput
;
import
de.prob.prolog.output.StructuredPrologOutput
;
import
de.prob.prolog.term.CompoundPrologTerm
;
import
de.prob.prolog.term.ListPrologTerm
;
import
de.prob.prolog.term.PrologTerm
;
/**
* Command to load a new Event B Model for animation.
*/
public
final
class
LoadCspModelCommand
{
private
static
boolean
preferencesAlreadyCleanedUp
=
false
;
private
LoadCspModelCommand
()
{
throw
new
UnsupportedOperationException
(
"Do not instantiate this class"
);
}
private
LoadCspModelCommand
(
final
IEventBRoot
model
)
{
}
private
static
void
removeObsoletePreferences
(
final
Animator
animator
)
throws
ProBException
{
if
(!
preferencesAlreadyCleanedUp
)
{
// get all preference names from ProB
Collection
<
ProBPreference
>
prefs
=
GetPreferencesCommand
.
getPreferences
(
animator
);
Set
<
String
>
probPrefNames
=
new
HashSet
<
String
>();
for
(
ProBPreference
probpref
:
prefs
)
{
probPrefNames
.
add
(
probpref
.
name
);
}
// now check all stored (in Eclipse's store) preferences
// if they still exist
Preferences
preferences
=
SetPreferencesCommand
.
getPreferences
();
try
{
boolean
foundObsoletePreference
=
false
;
for
(
String
prefname
:
preferences
.
keys
())
{
if
(!
probPrefNames
.
contains
(
prefname
))
{
// preference does not exists anymore
preferences
.
remove
(
prefname
);
foundObsoletePreference
=
true
;
String
message
=
"removed obsolete preference from preferences store: "
+
prefname
;
Logger
.
info
(
message
);
}
}
if
(
foundObsoletePreference
)
{
preferences
.
flush
();
}
}
catch
(
BackingStoreException
e
)
{
Logger
.
notifyUser
(
"Error while accessing ProB Preferences"
,
e
);
}
preferencesAlreadyCleanedUp
=
true
;
}
}
public
static
void
load
(
final
Animator
animator
,
final
File
model
,
String
name
)
throws
ProBException
{
animator
.
resetDirty
();
removeObsoletePreferences
(
animator
);
final
ClearMachineCommand
clear
=
new
ClearMachineCommand
();
final
SetPreferencesCommand
setPrefs
=
SetPreferencesCommand
.
createSetPreferencesCommand
(
animator
);
final
IComposableCommand
load
=
getLoadCommand
(
model
,
name
);
final
StartAnimationCommand
start
=
new
StartAnimationCommand
();
final
ExploreStateCommand
explore
=
new
ExploreStateCommand
(
"root"
);
final
ComposedCommand
composed
=
new
ComposedCommand
(
clear
,
setPrefs
,
load
,
start
,
explore
);
animator
.
execute
(
composed
);
final
State
commandResult
=
explore
.
getState
();
animator
.
announceCurrentStateChanged
(
commandResult
,
Operation
.
NULL_OPERATION
);
}
private
static
IComposableCommand
getLoadCommand
(
final
File
model
,
final
String
name
)
throws
ProBException
{
return
new
IComposableCommand
()
{
@Override
public
void
writeCommand
(
final
IPrologTermOutput
pto
)
throws
CommandException
{
pto
.
openTerm
(
"load_cspm_spec_from_cspm_file"
);
pto
.
printAtom
(
model
.
getAbsolutePath
());
pto
.
closeTerm
();
pto
.
printAtom
(
"start_animation"
);
}
@Override
public
void
processResult
(
final
ISimplifiedROMap
<
String
,
PrologTerm
>
bindings
)
{
Animator
.
getAnimator
().
announceReset
();
}
};
}
}
de.prob.standalone/icons/csp.png
0 → 100644
View file @
db2ef794
2.88 KB
de.prob.standalone/plugin.xml
View file @
db2ef794
...
...
@@ -336,9 +336,65 @@
name=
"ProB Navigation Content Provider"
priority=
"normal"
>
<triggerPoints>
<instanceof
value=
"org.eclipse.core.resources.IResource"
>
</instanceof>
<or>
<and>
<instanceof
value=
"org.eclipse.core.resources.IResource"
>
</instanceof>
<test
forcePluginActivation=
"true"
property=
"org.eclipse.core.resources.extension"
value=
"bum"
>
</test>
</and>
<and>
<instanceof
value=
"org.eclipse.core.resources.IResource"
>
</instanceof>
<test
forcePluginActivation=
"true"
property=
"org.eclipse.core.resources.extension"
value=
"buc"
>
</test>
</and>
<and>
<instanceof
value=
"org.eclipse.core.resources.IResource"
>
</instanceof>
<or>
<test
forcePluginActivation=
"true"
property=
"org.eclipse.core.resources.extension"
value=
"mch"
>
</test>
<test
forcePluginActivation=
"true"
property=
"org.eclipse.core.resources.extension"
value=
"ref"
>
</test>
<test
forcePluginActivation=
"true"
property=
"org.eclipse.core.resources.extension"
value=
"imp"
>
</test>
<test
forcePluginActivation=
"true"
property=
"org.eclipse.core.resources.extension"
value=
"csp"
>
</test>
</or>
</and>
<and>
<instanceof
value=
"org.eclipse.core.resources.IResource"
>
</instanceof>
<test
forcePluginActivation=
"true"
property=
"org.eclipse.core.resources.extension"
value=
"bmso"
>
</test>
</and>
</or>
</triggerPoints>
</navigatorContent>
<commonFilter
...
...
@@ -351,33 +407,90 @@
<instanceof
value=
"org.eclipse.core.resources.IResource"
>
</instanceof>
<or>
<test
forcePluginActivation=
"true"
property=
"org.eclipse.core.resources.extension"
value=
"bcc"
>
</test>
<test
forcePluginActivation=
"true"
property=
"org.eclipse.core.resources.extension"
value=
"bpo"
>
</test>
<test
forcePluginActivation=
"true"
property=
"org.eclipse.core.resources.extension"
value=
"bpr"
>
</test>
<test
forcePluginActivation=
"true"
property=
"org.eclipse.core.resources.extension"
value=
"bps"
>
</test>
<test
forcePluginActivation=
"true"
property=
"org.eclipse.core.resources.extension"
value=
"bcm"
>
</test>
</or>
<not>
<and>
<instanceof
value=
"org.eclipse.core.resources.IFile"
>
</instanceof>
<test
forcePluginActivation=
"true"
property=
"org.eclipse.core.resources.extension"
value=
"buc"
>
</test>
</and>
</not>
<not>
<and>
<instanceof
value=
"org.eclipse.core.resources.IFile"
>
</instanceof>
<test
forcePluginActivation=
"true"
property=
"org.eclipse.core.resources.extension"
value=
"bum"
>
</test>
</and>
</not>
<not>
<and>
<instanceof
value=
"org.eclipse.core.resources.IFile"
>
</instanceof>
<test
forcePluginActivation=
"true"
property=
"org.eclipse.core.resources.extension"
value=
"bmso"
>
</test>
</and>
</not>
<not>
<and>
<instanceof
value=
"org.eclipse.core.resources.IFile"
>
</instanceof>
<test
forcePluginActivation=
"true"
property=
"org.eclipse.core.resources.extension"
value=
"ref"
>
</test>
</and>
</not>
<not>
<and>
<instanceof
value=
"org.eclipse.core.resources.IFile"
>
</instanceof>
<test
forcePluginActivation=
"true"
property=
"org.eclipse.core.resources.extension"
value=
"imp"
>
</test>
</and>
</not>
<not>
<and>
<instanceof
value=
"org.eclipse.core.resources.IFile"
>
</instanceof>
<test
forcePluginActivation=
"true"
property=
"org.eclipse.core.resources.extension"
value=
"csp"
>
</test>
</and>
</not>
<not>
<and>
<instanceof
value=
"org.eclipse.core.resources.IFile"
>
</instanceof>
<test
forcePluginActivation=
"true"
property=
"org.eclipse.core.resources.extension"
value=
"mch"
>
</test>
</and>
</not>
</and>
</or>
</filterExpression>
...
...
@@ -389,6 +502,10 @@
id=
"de.prob.command.startClassicalBAnimation"
name=
"Classical-B Animate / Model Check"
>
</command>
<command
id=
"de.prob.command.startCspAnimation"
name=
"CSP Animate / Model Check"
>
</command>
</extension>
<extension
point=
"org.eclipse.ui.handlers"
>
...
...
@@ -416,6 +533,30 @@
</with>
</enabledWhen>
</handler>
<handler
commandId=
"de.prob.command.startCspAnimation"
>
<class
class=
"de.prob.standalone.handler.StartCspAnimationHandler"
>
</class>
<enabledWhen>
<with
variable=
"selection"
>
<iterate
operator=
"or"
>
<and>
<instanceof
value=
"org.eclipse.core.resources.IResource"
>
</instanceof>
<test
forcePluginActivation=
"true"
property=
"org.eclipse.core.resources.extension"
value=
"csp"
>
</test>
</and>
</iterate>
</with>
</enabledWhen>
</handler>
</extension>
<extension
point=
"de.bmotionstudio.gef.editor.language"
>
...
...
de.prob.standalone/plugin.xml.orig
0 → 100644
View file @
db2ef794
This diff is collapsed.
Click to expand it.
de.prob.standalone/src/de/prob/standalone/handler/StartCspAnimationHandler.java
0 → 100644
View file @
db2ef794
package
de.prob.standalone.handler
;
import
java.io.File
;
import
org.eclipse.core.commands.AbstractHandler
;
import
org.eclipse.core.commands.ExecutionEvent
;
import
org.eclipse.core.commands.ExecutionException
;
import
org.eclipse.core.commands.IHandler
;
import
org.eclipse.core.commands.IHandlerListener
;
import
org.eclipse.core.resources.IFile
;
import
org.eclipse.jface.viewers.ISelection
;
import
org.eclipse.jface.viewers.IStructuredSelection
;
import
org.eclipse.ui.handlers.HandlerUtil
;
import
de.prob.core.Animator
;
import
de.prob.core.command.LoadClassicalBModelCommand
;
import
de.prob.core.command.LoadCspModelCommand
;
import
de.prob.exceptions.ProBException
;
public
class
StartCspAnimationHandler
extends
AbstractHandler
implements
IHandler
{
@Override
public
Object
execute
(
ExecutionEvent
event
)
throws
ExecutionException
{
ISelection
fSelection
=
HandlerUtil
.
getCurrentSelection
(
event
);
if
(
fSelection
instanceof
IStructuredSelection
)
{
final
IStructuredSelection
ssel
=
(
IStructuredSelection
)
fSelection
;
if
(
ssel
.
size
()
==
1
)
{
final
Object
element
=
ssel
.
getFirstElement
();
if
(
element
instanceof
IFile
)
{
IFile
f
=
(
IFile
)
element
;
String
n
=
f
.
getName
();
String
name
=
n
.
substring
(
0
,
n
.
length
()-
4
);
File
file
=
new
File
(
f
.
getLocationURI
());
try
{
LoadCspModelCommand
.
load
(
Animator
.
getAnimator
(),
file
,
name
);
}
catch
(
ProBException
e
)
{
throw
new
ExecutionException
(
e
.
getLocalizedMessage
(),
e
);
}
}
}
}
return
null
;
}
}
de.prob.standalone/src/de/prob/standalone/internal/ProBNavigatorLabelProvider.java
View file @
db2ef794
package
de.prob.standalone.internal
;
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
* Heinrich Heine Universitaet Duesseldorf
* This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
* */
import
org.eclipse.core.resources.IFile
;
import
org.eclipse.jface.viewers.ILabelProvider
;
import
org.eclipse.jface.viewers.ILabelProviderListener
;
import
org.eclipse.swt.graphics.Image
;
public
class
ProBNavigatorLabelProvider
implements
ILabelProvider
{
public
Image
getImage
(
final
Object
element
)
{
return
null
;
}
public
String
getText
(
final
Object
element
)
{
if
(
element
instanceof
IFile
)
{
IFile
file
=
(
IFile
)
element
;
return
file
.
getName
().
replace
(
"."
+
file
.
getFileExtension
(),
""
);
}
return
null
;
}
public
void
addListener
(
final
ILabelProviderListener
listener
)
{
// do nothing
}
public
void
dispose
()
{
// do nothing
}
public
boolean
isLabelProperty
(
final
Object
element
,
final
String
property
)
{
return
false
;
}
public
void
removeListener
(
final
ILabelProviderListener
listener
)
{
// do nothing
}
}
package
de.prob.standalone.internal
;
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
* Heinrich Heine Universitaet Duesseldorf
* This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
* */
import
org.eclipse.core.resources.IFile
;
import
org.eclipse.jface.viewers.ILabelProvider
;
import
org.eclipse.jface.viewers.ILabelProviderListener
;
import
org.eclipse.swt.graphics.Image
;
public
class
ProBNavigatorLabelProvider
implements
ILabelProvider
{
public
Image
getImage
(
final
Object
element
)
{
return
null
;
}
public
String
getText
(
final
Object
element
)
{
if
(
element
instanceof
IFile
)
{
IFile
file
=
(
IFile
)
element
;
return
file
.
getName
().
replace
(
"."
+
file
.
getFileExtension
(),
""
);
}
return
null
;
}
public
void
addListener
(
final
ILabelProviderListener
listener
)
{
// do nothing
}
public
void
dispose
()
{
// do nothing
}
public
boolean
isLabelProperty
(
final
Object
element
,
final
String
property
)
{
return
false
;
}
public
void
removeListener
(
final
ILabelProviderListener
listener
)
{
// do nothing
}
}
de.prob.standalone/src/de/prob/standalone/internal/ProBNavigatorLabelProvider.java.orig
0 → 100644
View file @
db2ef794
<<<<<<<
HEAD
package
de
.
prob
.
standalone
.
internal
;
/**
*
(
c
)
2009
Lehrstuhl
fuer
Softwaretechnik
und
Programmiersprachen
,
*
Heinrich
Heine
Universitaet
Duesseldorf
*
This
software
is
licenced
under
EPL
1.0
(
http
://
www
.
eclipse
.
org
/
org
/
documents
/
epl
-
v10
.
html
)
*
*/
import
org
.
eclipse
.
core
.
resources
.
IFile
;
import
org
.
eclipse
.
jface
.
viewers
.
ILabelProvider
;
import
org
.
eclipse
.
jface
.
viewers
.
ILabelProviderListener
;
import
org
.
eclipse
.
swt
.
graphics
.
Image
;
public
class
ProBNavigatorLabelProvider
implements
ILabelProvider
{
public
Image
getImage
(
final
Object
element
)
{
return
null
;
}
public
String
getText
(
final
Object
element
)
{
if
(
element
instanceof
IFile
)
{
IFile
file
=
(
IFile
)
element
;
return
file
.
getName
().
replace
(
"."
+
file
.
getFileExtension
(),
""
);
}
return
null
;
}
public
void
addListener
(
final
ILabelProviderListener
listener
)
{
//
do
nothing
}
public
void
dispose
()
{
//
do
nothing
}
public
boolean
isLabelProperty
(
final
Object
element
,
final
String
property
)
{
return
false
;
}
public
void
removeListener
(
final
ILabelProviderListener
listener
)
{
//
do
nothing
}
}
=======
package
de
.
prob
.
standalone
.
internal
;
/**
*
(
c
)
2009
Lehrstuhl
fuer
Softwaretechnik
und
Programmiersprachen
,
*
Heinrich
Heine
Universitaet
Duesseldorf
*
This
software
is
licenced
under
EPL
1.0
(
http
://
www
.
eclipse
.
org
/
org
/
documents
/
epl
-
v10
.
html
)
*
*/
import
org
.
eclipse
.
core
.
resources
.
IFile
;
import
org
.
eclipse
.
jface
.
viewers
.
ILabelProvider
;
import
org
.
eclipse
.
jface
.
viewers
.
ILabelProviderListener
;
import
org
.
eclipse
.
swt
.
graphics
.
Image
;
import
de
.
prob
.
standalone
.
Activator
;
public
class
FormalModelLabelProvider
implements
ILabelProvider
{
public
Image
getImage
(
final
Object
element
)
{
if
(
element
instanceof
IFile
)
{
IFile
file
=
(
IFile
)
element
;
if
(
file
.
getFileExtension
().
equals
(
"bum"
))
{
return
Activator
.
getImageDescriptor
(
"icons/eventb/mch_obj.png"
)
.
createImage
();
}
else
if
(
file
.
getFileExtension
().
equals
(
"buc"
))
{
return
Activator
.
getImageDescriptor
(
"icons/eventb/ctx_obj.png"
)
.
createImage
();
}
else
if
(
file
.
getFileExtension
().
equals
(
"csp"
))
{
return
Activator
.
getImageDescriptor
(
"icons/csp.png"
)
.
createImage
();
}
else
{
return
Activator
.
getImageDescriptor
(
"icons/icon16.png"
)
.
createImage
();
}
}
return
null
;
}
public
String
getText
(
final
Object
element
)
{
if
(
element
instanceof
IFile
)
{
IFile
file
=
(
IFile
)
element
;
return
file
.
getName
().
replace
(
"."
+
file
.
getFileExtension
(),
""
);
}
return
null
;
}
public
void
addListener
(
final
ILabelProviderListener
listener
)
{
//
do
nothing