Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

SWITCHYARD-762 open switchyard.xml after creating new switchyard project #30

Merged
merged 1 commit into from

2 participants

@rcernich
Collaborator

also added a short cut to the wizard in the project explorer popup and a composite element is now created by default in the generated switchyard.xml

@kcbabo
Owner

processing

@kcbabo kcbabo merged commit e95c51e into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
15 eclipse/plugins/org.switchyard.tools.ui/plugin.xml
@@ -438,6 +438,21 @@
</or>
</enablement>
</commonWizard>
+ <commonWizard
+ menuGroupId="switchyard.group"
+ type="new"
+ wizardId="org.switchyard.tools.ui.wizards.NewSwitchYardProjectWizard">
+ <enablement>
+ <or>
+ <instanceof
+ value="org.eclipse.core.resources.IWorkspaceRoot" />
+ <and>
+ <instanceof value="java.util.Collection"/>
+ <count value="0" />
+ </and>
+ </or>
+ </enablement>
+ </commonWizard>
<actionProvider
class="org.switchyard.tools.ui.actions.SwitchYardActionProvider"
id="org.switchyard.tools.ui.actions.SwitchYardActionProvider">
View
25 ...ins/org.switchyard.tools.ui/src/org/switchyard/tools/ui/operations/CreateSwitchYardProjectOperation.java
@@ -56,6 +56,8 @@
import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.switchyard.config.OutputKey;
+import org.switchyard.config.model.composite.CompositeModel;
+import org.switchyard.config.model.composite.v1.V1CompositeModel;
import org.switchyard.config.model.switchyard.SwitchYardModel;
import org.switchyard.tools.ui.Activator;
import org.switchyard.tools.ui.M2EUtils;
@@ -189,6 +191,7 @@ public void setComponents(Collection<ISwitchYardComponentExtension> components)
private final NewSwitchYardProjectMetaData _projectMetatData;
private final IAdaptable _uiInfo;
+ private IFile _switchYardFile;
/**
* Create a new CreateSwitchYardProjectOperation.
@@ -201,6 +204,13 @@ public CreateSwitchYardProjectOperation(NewSwitchYardProjectMetaData projectMeta
_uiInfo = uiInfo;
}
+ /**
+ * @return the newly created switchyard.xml file.
+ */
+ public IFile getSwitchYardFile() {
+ return _switchYardFile;
+ }
+
@Override
public void run(IProgressMonitor monitor) throws CoreException {
MultiStatus status = new MultiStatus(Activator.PLUGIN_ID, 15, "Errors occurred while creating project", null);
@@ -288,15 +298,15 @@ public void run(IProgressMonitor monitor) throws CoreException {
// create switchyard.xml
try {
monitor.subTask("Creating switchyard.xml file.");
- SwitchYardModel switchYardModel = createSwitchYardModel(
+ SwitchYardModel switchYardModel = newSwitchYardModel(
_projectMetatData.getNewProjectHandle().getName(),
createTargetnamespace(_projectMetatData.getGroupId(), _projectMetatData.getNewProjectHandle()
.getName(), _projectMetatData.getProjectVersion()));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
switchYardModel.getModelConfiguration().write(baos, new OutputKey[0]);
- IFile switchYardFile = _projectMetatData.getNewProjectHandle().getFolder(MAVEN_MAIN_RESOURCES_PATH)
+ _switchYardFile = _projectMetatData.getNewProjectHandle().getFolder(MAVEN_MAIN_RESOURCES_PATH)
.getFolder(M2EUtils.META_INF).getFile(M2EUtils.SWITCHYARD_XML);
- CreateFileOperation op = new CreateFileOperation(switchYardFile, null, new ByteArrayInputStream(
+ CreateFileOperation op = new CreateFileOperation(_switchYardFile, null, new ByteArrayInputStream(
baos.toByteArray()), "Creating switchyard.xml");
subMonitor = new SubProgressMonitor(monitor, 100, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
op.execute(subMonitor, _uiInfo);
@@ -361,6 +371,15 @@ private void mergeStatus(MultiStatus status, String message, Exception e) {
}
}
+ private SwitchYardModel newSwitchYardModel(String name, String targetNamespace) {
+ SwitchYardModel switchYardModel = createSwitchYardModel(name, targetNamespace);
+ CompositeModel composite = new V1CompositeModel();
+ composite.setName(name);
+ composite.setTargetNamespace(targetNamespace);
+ switchYardModel.setComposite(composite);
+ return switchYardModel;
+ }
+
private Model createPom() {
Model model = new Model();
View
26 eclipse/plugins/org.switchyard.tools.ui/src/org/switchyard/tools/ui/wizards/NewSwitchYardProjectWizard.java
@@ -22,9 +22,13 @@
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
+import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
import org.sonatype.aether.version.Version;
import org.switchyard.tools.ui.Activator;
@@ -48,6 +52,7 @@
private WizardNewProjectCreationPage _newProjectPage;
private ProjectConfigurationWizardPage _configurationPage;
private IStructuredSelection _selection;
+ private IWorkbench _workbench;
/**
* Constructor for NewSwitchYardProjectWizard.
@@ -60,7 +65,8 @@ public NewSwitchYardProjectWizard() {
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
- this._selection = selection;
+ _selection = selection;
+ _workbench = workbench;
}
/**
@@ -114,6 +120,8 @@ public boolean performFinish() {
// run the new project creation operation
try {
+ final Display display = _workbench.getDisplay();
+ final IWorkbenchPage activePage = _workbench.getActiveWorkbenchWindow().getActivePage();
getContainer().run(true, true, new IRunnableWithProgress() {
@Override
@@ -123,6 +131,22 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException, Inte
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
+ if (activePage != null) {
+ display.asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ IDE.openEditor(activePage, op.getSwitchYardFile(), true);
+ } catch (PartInitException e) {
+ Activator
+ .getDefault()
+ .getLog()
+ .log(new Status(Status.ERROR, Activator.PLUGIN_ID,
+ "Error opening switchyard.xml.", e));
+ }
+ }
+ });
+ }
}
});
} catch (InterruptedException e) {
Something went wrong with that request. Please try again.