|
@@ -14,11 +14,14 @@ import java.io.IOException;
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import org.eclipse.core.resources.IFile;
|
|
|
import org.eclipse.core.resources.IProject;
|
|
|
+import org.eclipse.core.resources.IResource;
|
|
|
import org.eclipse.core.resources.ResourcesPlugin;
|
|
|
import org.eclipse.core.runtime.CoreException;
|
|
|
import org.eclipse.core.runtime.IPath;
|
|
|
import org.eclipse.core.runtime.IProgressMonitor;
|
|
|
+import org.eclipse.core.runtime.Path;
|
|
|
import org.eclipse.emf.common.util.URI;
|
|
|
import org.eclipse.emf.ecore.resource.Resource;
|
|
|
import org.eclipse.emf.ecore.resource.ResourceSet;
|
|
@@ -27,7 +30,11 @@ import org.eclipse.jface.viewers.IStructuredSelection;
|
|
|
import org.eclipse.jface.wizard.Wizard;
|
|
|
import org.eclipse.ui.INewWizard;
|
|
|
import org.eclipse.ui.IWorkbench;
|
|
|
+import org.eclipse.ui.IWorkbenchPage;
|
|
|
+import org.eclipse.ui.PartInitException;
|
|
|
+import org.eclipse.ui.PlatformUI;
|
|
|
import org.eclipse.ui.actions.WorkspaceModifyOperation;
|
|
|
+import org.eclipse.ui.part.FileEditorInput;
|
|
|
import org.yakindu.sct.builder.nature.SCTNature;
|
|
|
import org.yakindu.sct.builder.nature.ToggleSCTNatureAction;
|
|
|
import org.yakindu.sct.model.sgen.GeneratorModel;
|
|
@@ -42,6 +49,8 @@ import com.google.inject.Inject;
|
|
|
*/
|
|
|
public class SGenNewFileWizard extends Wizard implements INewWizard {
|
|
|
|
|
|
+ private static final String SGEN_EDITOR_ID = "org.yakindu.sct.generator.genmodel.SGen";
|
|
|
+
|
|
|
public static final String ID = "org.yakindu.sct.generator.genmodel.ui.SGenNewFileWizard";
|
|
|
|
|
|
protected SGenWizardPage1 modelFilePage;
|
|
@@ -83,7 +92,8 @@ public class SGenNewFileWizard extends Wizard implements INewWizard {
|
|
|
protected void execute(IProgressMonitor monitor)
|
|
|
throws CoreException, InterruptedException {
|
|
|
ensureSCTNature(getProject(modelFilePage.getContainerFullPath()));
|
|
|
- createDefaultModel(modelFilePage.getURI());
|
|
|
+ Resource resource = createDefaultModel(modelFilePage.getURI());
|
|
|
+ openModel(resource);
|
|
|
}
|
|
|
};
|
|
|
try {
|
|
@@ -94,6 +104,19 @@ public class SGenNewFileWizard extends Wizard implements INewWizard {
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ protected boolean openModel(Resource model) throws PartInitException {
|
|
|
+ String path = model.getURI().toPlatformString(true);
|
|
|
+ IResource workspaceResource = ResourcesPlugin.getWorkspace().getRoot()
|
|
|
+ .findMember(new Path(path));
|
|
|
+ if (workspaceResource instanceof IFile) {
|
|
|
+ IWorkbenchPage page = PlatformUI.getWorkbench()
|
|
|
+ .getActiveWorkbenchWindow().getActivePage();
|
|
|
+ return null != page.openEditor(new FileEditorInput(
|
|
|
+ (IFile) workspaceResource), SGEN_EDITOR_ID);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
protected void ensureSCTNature(IProject project) throws CoreException {
|
|
|
if (project.getNature(SCTNature.NATURE_ID) == null) {
|
|
@@ -109,7 +132,7 @@ public class SGenNewFileWizard extends Wizard implements INewWizard {
|
|
|
.getFolder(containerFullPath).getProject();
|
|
|
}
|
|
|
|
|
|
- private void createDefaultModel(URI uri) {
|
|
|
+ private Resource createDefaultModel(URI uri) {
|
|
|
List<Statechart> statecharts = generatorConfigPage.getStatecharts();
|
|
|
String generatorId = generatorConfigPage.getGeneratorId();
|
|
|
|
|
@@ -123,6 +146,7 @@ public class SGenNewFileWizard extends Wizard implements INewWizard {
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
+ return resource;
|
|
|
}
|
|
|
|
|
|
public IStructuredSelection getSelection() {
|