Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ProB Rodin Plugin
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
ProB Rodin Plugin
Commits
75db9368
Commit
75db9368
authored
1 year ago
by
dgelessus
Browse files
Options
Downloads
Patches
Plain Diff
Remove ExportClassicHandler (identical to ExportNewCoreHandler)
parent
bdd87f79
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
de.prob.ui/plugin.xml
+1
-1
1 addition, 1 deletion
de.prob.ui/plugin.xml
de.prob.ui/src/de/prob/ui/eventb/ExportClassicHandler.java
+0
-129
0 additions, 129 deletions
de.prob.ui/src/de/prob/ui/eventb/ExportClassicHandler.java
with
1 addition
and
130 deletions
de.prob.ui/plugin.xml
+
1
−
1
View file @
75db9368
...
...
@@ -744,7 +744,7 @@
<handler
commandId=
"de.prob.ui.newcore.export"
>
<class
class=
"de.prob.ui.eventb.Export
Classic
Handler"
>
class=
"de.prob.ui.eventb.Export
NewCore
Handler"
>
</class>
<enabledWhen>
<with
...
...
This diff is collapsed.
Click to expand it.
de.prob.ui/src/de/prob/ui/eventb/ExportClassicHandler.java
deleted
100644 → 0
+
0
−
129
View file @
bdd87f79
package
de.prob.ui.eventb
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.io.Writer
;
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.runtime.Platform
;
import
org.eclipse.core.runtime.preferences.InstanceScope
;
import
org.eclipse.jface.dialogs.MessageDialog
;
import
org.eclipse.jface.viewers.ISelection
;
import
org.eclipse.jface.viewers.IStructuredSelection
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.widgets.FileDialog
;
import
org.eclipse.swt.widgets.Shell
;
import
org.eclipse.ui.handlers.HandlerUtil
;
import
org.eventb.core.IEventBRoot
;
import
org.eventb.core.IMachineRoot
;
import
org.osgi.service.prefs.BackingStoreException
;
import
org.osgi.service.prefs.Preferences
;
import
de.prob.core.translator.TranslationFailedException
;
import
de.prob.eventb.translator.TranslatorFactory
;
import
de.prob.logging.Logger
;
/**
* @author bendisposto
* @deprecated Use ExpprtNewCoreHandler instead
*/
@Deprecated
public
class
ExportClassicHandler
extends
AbstractHandler
implements
IHandler
{
public
Object
execute
(
final
ExecutionEvent
event
)
throws
ExecutionException
{
final
IEventBRoot
root
=
getSelectedEventBRoot
(
event
);
if
(
root
!=
null
)
{
final
Preferences
prefs
=
Platform
.
getPreferencesService
()
.
getRootNode
().
node
(
InstanceScope
.
SCOPE
)
.
node
(
"prob_export_preferences"
);
final
Shell
shell
=
HandlerUtil
.
getActiveShell
(
event
);
final
String
fileName
=
askForExportFile
(
prefs
,
shell
,
root
);
if
(
fileName
!=
null
)
{
exportToClassic
(
fileName
,
root
);
}
}
return
null
;
}
private
IEventBRoot
getSelectedEventBRoot
(
final
ExecutionEvent
event
)
{
final
ISelection
fSelection
=
HandlerUtil
.
getCurrentSelection
(
event
);
IEventBRoot
root
=
null
;
if
(
fSelection
instanceof
IStructuredSelection
)
{
final
IStructuredSelection
ssel
=
(
IStructuredSelection
)
fSelection
;
if
(
ssel
.
size
()
==
1
&&
ssel
.
getFirstElement
()
instanceof
IEventBRoot
)
{
root
=
(
IEventBRoot
)
ssel
.
getFirstElement
();
}
}
return
root
;
}
private
String
askForExportFile
(
final
Preferences
prefs
,
final
Shell
shell
,
final
IEventBRoot
root
)
{
final
String
path
=
prefs
.
get
(
"dir"
,
System
.
getProperty
(
"user.home"
));
final
FileDialog
dialog
=
new
FileDialog
(
shell
,
SWT
.
SAVE
);
dialog
.
setFilterExtensions
(
new
String
[]
{
"*.eventb"
});
dialog
.
setFilterPath
(
path
);
final
String
subext
=
(
root
instanceof
IMachineRoot
)
?
"_mch"
:
"_ctx"
;
dialog
.
setFileName
(
root
.
getComponentName
()
+
subext
+
".eventb"
);
String
result
=
dialog
.
open
();
if
(
result
!=
null
)
{
final
String
newPath
=
dialog
.
getFilterPath
();
if
(!
path
.
equals
(
newPath
))
{
prefs
.
put
(
"dir"
,
newPath
);
try
{
prefs
.
flush
();
}
catch
(
BackingStoreException
e
)
{
// Ignore, if preferences are not stored correctly we simply
// ignore it (annoying, but not critical)
}
}
if
(!
result
.
endsWith
(
".eventb"
))
{
result
+=
".eventb"
;
}
}
return
result
;
}
public
static
void
exportToClassic
(
final
String
filename
,
final
IEventBRoot
root
)
{
final
boolean
isSafeToWrite
=
isSafeToWrite
(
filename
);
if
(
isSafeToWrite
)
{
Writer
fw
=
null
;
try
{
fw
=
new
FileWriter
(
filename
);
TranslatorFactory
.
translate
(
root
,
new
PrintWriter
(
fw
));
fw
.
append
(
'\n'
);
}
catch
(
TranslationFailedException
e
)
{
e
.
notifyUserOnce
();
}
catch
(
IOException
e
)
{
Logger
.
notifyUser
(
"Unable to create file '"
+
filename
+
"'"
);
}
finally
{
if
(
fw
!=
null
)
{
try
{
fw
.
close
();
}
catch
(
IOException
e
)
{
}
}
}
}
}
private
static
boolean
isSafeToWrite
(
final
String
filename
)
{
if
(
new
File
(
filename
).
exists
())
{
final
MessageDialog
dialog
=
new
MessageDialog
(
null
,
"File exists"
,
null
,
"The file exists. Do you want to overwrite it?"
,
MessageDialog
.
QUESTION
,
new
String
[]
{
"Yes"
,
"No"
},
0
);
return
dialog
.
open
()
==
0
;
}
else
return
true
;
}
}
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