Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 127911 Details for
Bug 267493
UI creation wizard for Qvto Ant tasks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
UI wizard for Ant Task creation
anttasks-patch (text/plain), 60.75 KB, created by
Sergey Boyko
on 2009-03-07 08:53:42 EST
(
hide
)
Description:
UI wizard for Ant Task creation
Filename:
MIME Type:
Creator:
Sergey Boyko
Created:
2009-03-07 08:53:42 EST
Size:
60.75 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.m2m.qvt.oml.runtime.ui >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.m2m/org.eclipse.m2m.qvt.oml/plugins/org.eclipse.m2m.qvt.oml.runtime.ui/plugin.properties,v >retrieving revision 1.6 >diff -u -r1.6 plugin.properties >--- plugin.properties 6 Feb 2009 15:09:55 -0000 1.6 >+++ plugin.properties 7 Mar 2009 13:47:35 -0000 >@@ -24,4 +24,7 @@ > > RunMenu.label=&Run > runTransformationShow=Transformation... >-runTransformationTooltip=Run QVT Transformation >\ No newline at end of file >+runTransformationTooltip=Run QVT Transformation >+ >+transformationSetWizardName = Operational QVT Transformation Sequence >+transformationSetWizardName.description = Create a new Ant-based QVTO Transformation Sequence >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.m2m/org.eclipse.m2m.qvt.oml/plugins/org.eclipse.m2m.qvt.oml.runtime.ui/plugin.xml,v >retrieving revision 1.8 >diff -u -r1.8 plugin.xml >--- plugin.xml 10 Jul 2008 14:10:14 -0000 1.8 >+++ plugin.xml 7 Mar 2009 13:47:35 -0000 >@@ -106,4 +106,17 @@ > > </extension> > >+ <extension point="org.eclipse.ui.newWizards"> >+ <wizard >+ category="org.eclipse.m2m.qvt.oml.wizardCategory" >+ class="org.eclipse.m2m.internal.qvt.oml.runtime.ui.ant.NewCompositeTransformationWizard" >+ icon="icons/anttasks.gif" >+ id="com.borland.m2m.qvt.common.wizards.NewCompositeTransformationWizard" >+ name="%transformationSetWizardName"> >+ <description> >+ %transformationSetWizardName.description >+ </description> >+ </wizard> >+ </extension> >+ > </plugin> >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.m2m/org.eclipse.m2m.qvt.oml/plugins/org.eclipse.m2m.qvt.oml.runtime.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.17 >diff -u -r1.17 MANIFEST.MF >--- META-INF/MANIFEST.MF 26 Feb 2009 10:42:13 -0000 1.17 >+++ META-INF/MANIFEST.MF 7 Mar 2009 13:47:35 -0000 >@@ -10,6 +10,8 @@ > org.eclipse.emf.ecore.xmi;bundle-version="[2.5.0,3.0.0)", > org.eclipse.debug.ui;bundle-version="[3.4.0,4.0.0)", > org.eclipse.ui.ide;bundle-version="[3.4.0,4.0.0)", >+ org.eclipse.ui.workbench.texteditor;bundle-version="[3.5.0,4.0.0)", >+ org.eclipse.jface.text;bundle-version="[3.4.0,4.0.0)", > org.eclipse.m2m.qvt.oml;bundle-version="[2.0.0,3.0.0)", > org.eclipse.m2m.qvt.oml.common;bundle-version="[1.0.0,2.0.0)", > org.eclipse.m2m.qvt.oml.common.ui;bundle-version="[1.0.0,2.0.0)";visibility:=reexport, >Index: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/NewCompositeTransformationWizard.java >=================================================================== >RCS file: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/NewCompositeTransformationWizard.java >diff -N src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/NewCompositeTransformationWizard.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/NewCompositeTransformationWizard.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,181 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Borland Software Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.m2m.internal.qvt.oml.runtime.ui.ant; >+ >+import java.io.ByteArrayInputStream; >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.UnsupportedEncodingException; >+import java.lang.reflect.InvocationTargetException; >+import java.util.List; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.jface.operation.IRunnableWithProgress; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.wizard.Wizard; >+import org.eclipse.m2m.internal.qvt.oml.runtime.ui.QvtRuntimeUIPlugin; >+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.dialogs.WizardNewFileCreationPage; >+import org.eclipse.ui.ide.IDE; >+ >+public class NewCompositeTransformationWizard extends Wizard implements INewWizard { >+ public NewCompositeTransformationWizard() { >+ setNeedsProgressMonitor(true); >+ } >+ >+ public void init(IWorkbench workbench, IStructuredSelection selection) { >+ mySelection = selection; >+ setWindowTitle(Messages.TransformWizard_windowTitle); >+ } >+ >+ @Override >+ public void addPages() { >+ myNewFilePage = new WizardNewFileCreationPage("newTransformFilePage", mySelection); //$NON-NLS-1$ >+ myNewFilePage.setTitle(Messages.TransformFilePage_title); >+ >+ String defaultFileName = "composite.xml"; //$NON-NLS-1$ >+ if (mySelection.getFirstElement() instanceof IFile) { >+ final IFile file = (IFile) mySelection.getFirstElement(); >+ if (!"xml".equals(file.getFileExtension())) { //$NON-NLS-1$ >+ defaultFileName = file.getProjectRelativePath().removeFileExtension().addFileExtension("xml").lastSegment(); //$NON-NLS-1$ >+ } else { >+ defaultFileName = file.getProjectRelativePath().lastSegment(); >+ } >+ } >+ myNewFilePage.setFileName(defaultFileName); >+ addPage(myNewFilePage); >+ >+ myContentsPage = new CompositeTransformationContentPage(myModel); >+ >+ addPage(myContentsPage); >+ } >+ >+ @Override >+ public boolean performFinish() { >+ final String containerName = myNewFilePage.getContainerFullPath().toPortableString(); >+ final String fileName = myNewFilePage.getFileName(); >+ IRunnableWithProgress op = new IRunnableWithProgress() { >+ public void run(IProgressMonitor monitor) throws InvocationTargetException { >+ try { >+ doFinish(containerName, fileName, monitor); >+ } catch (CoreException e) { >+ throw new InvocationTargetException(e); >+ } finally { >+ monitor.done(); >+ } >+ } >+ }; >+ try { >+ getContainer().run(true, false, op); >+ } catch (InterruptedException e) { >+ return false; >+ } catch (InvocationTargetException e) { >+ Throwable realException = e.getTargetException(); >+ MessageDialog.openError(getShell(), "Error", realException.getMessage()); //$NON-NLS-1$ >+ return false; >+ } >+ return true; >+ } >+ >+ private void doFinish(String containerName, String fileName, IProgressMonitor monitor) throws CoreException { >+ // create a sample file >+ monitor.beginTask("Creating " + fileName, 2); //$NON-NLS-1$ >+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >+ IResource resource = root.findMember(new Path(containerName)); >+ if (!resource.exists() || !(resource instanceof IContainer)) { >+ throwCoreException("Container \"" + containerName + "\" does not exist.", null); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ IContainer container = (IContainer) resource; >+ final IFile file = container.getFile(new Path(fileName)); >+ try { >+ InputStream stream = openContentStream(); >+ if (file.exists()) { >+ file.setContents(stream, true, true, monitor); >+ } else { >+ file.create(stream, true, monitor); >+ } >+ stream.close(); >+ } catch (IOException e) { >+ throwCoreException("Error creating file [" + fileName + "]", e); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ monitor.worked(1); >+ monitor.setTaskName("Opening file for editing..."); //$NON-NLS-1$ >+ getShell().getDisplay().asyncExec(new Runnable() { >+ public void run() { >+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); >+ try { >+ IDE.openEditor(page, file, true); >+ } catch (PartInitException e) { >+ } >+ } >+ }); >+ monitor.worked(1); >+ } >+ >+ private InputStream openContentStream() throws UnsupportedEncodingException, CoreException { >+ String encoding = getCharset(); >+ String result = "<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>\n" + //$NON-NLS-1$//$NON-NLS-2$ >+ "<project name=\"" + myModel.getProjectName() + "\" " + //$NON-NLS-1$//$NON-NLS-2$ >+ "default=\"" + myModel.getTargetName() + "\" xmlns:qvto=\"http://www.eclipse.org/qvt/1.0.0/Operational\">\n"; //$NON-NLS-1$//$NON-NLS-2$ >+ result += " <target name=\"" + myModel.getTargetName() + "\">\n"; //$NON-NLS-1$//$NON-NLS-2$ >+ List<TaskModel> value = myModel.getTaskModels(); >+ for (TaskModel model : value) { >+ result += TaskModel.indentString(model.toString(), " ", "\n") + "\n"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ >+ } >+ result += " </target>\n"; //$NON-NLS-1$ >+ result += "</project>"; //$NON-NLS-1$ >+ return new ByteArrayInputStream(result.getBytes(encoding)); >+ } >+ >+ private String getCharset() throws CoreException { >+// if (mySelection != null) { >+// Object firstElement = mySelection.getFirstElement(); >+// if (firstElement instanceof IResource) { >+// IResource resource = (IResource) firstElement; >+// String charset = resource.getProject().getDefaultCharset(); >+// if ((charset != null) && Charset.isSupported(charset)) { >+// return charset; >+// } >+// } >+// } >+// String charset = ResourcesPlugin.getEncoding(); >+// if (Charset.isSupported(charset)) { >+// return charset; >+// } >+ return "UTF-8"; //$NON-NLS-1$ >+ } >+ >+ private static void throwCoreException(String message, Throwable exception) throws CoreException { >+ IStatus status = new Status(IStatus.ERROR, QvtRuntimeUIPlugin.PLUGIN_ID, IStatus.OK, message, exception); >+ throw new CoreException(status); >+ } >+ >+ private WizardNewFileCreationPage myNewFilePage; >+ private CompositeTransformationContentPage myContentsPage; >+ private IStructuredSelection mySelection; >+ >+ private CompositeTransformationModel myModel = new CompositeTransformationModel(); >+} >Index: icons/anttasks.gif >=================================================================== >RCS file: icons/anttasks.gif >diff -N icons/anttasks.gif >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ icons/anttasks.gif 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,3 @@ >+GIF89aÕqq¹¹¼óõûãêøæìøòõûõ÷ûùúüáé÷èîùìñúïóúßè÷éïùàé÷åíùãë÷ðôú÷ùüõøü÷ùûççÐÜÜÕôóí~vN}uN?wM~uN yL{KCEG?~I±?>ªA¤BàÈ?´?=®??Ô²hÔ²iÚ½|Õ²iÐÐи¸¸BBBÿÿÿ!ù1,?À0v*?ÃäéÀlT§¤ðò+ÖHU`bZ¥PÉ.lh·'$!,Ö²`_(Écv0C`//] >+?? I./0 >+!1k`vj0"I©««C/U/.·.^`0ÁÁ¢01vÏRÓÔ1A; >Index: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/Messages.java >=================================================================== >RCS file: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/Messages.java >diff -N src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/Messages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/Messages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,59 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Borland Software Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.m2m.internal.qvt.oml.runtime.ui.ant; >+ >+import org.eclipse.osgi.util.NLS; >+ >+public class Messages extends NLS { >+ private static final String BUNDLE_NAME = "org.eclipse.m2m.internal.qvt.oml.runtime.ui.ant.messages"; //$NON-NLS-1$ >+ >+ public static String AntTaskWizard_windowTitle; >+ >+ public static String LaunchConfigError_msg; >+ >+ public static String LaunchConfigError_title; >+ >+ public static String SourceTypePage_title; >+ public static String SourceTypePage_descr; >+ public static String SourceTypePage_opt1; >+ public static String SourceTypePage_opt2; >+ >+ public static String SourcePage_title1; >+ public static String SourcePage_descr1; >+ public static String SourcePage_configBtn; >+ >+ public static String ResultPage_title; >+ public static String ResultPage_descr; >+ >+ public static String TransformWizard_windowTitle; >+ public static String TransformFilePage_title; >+ >+ public static String TransformPage_title; >+ public static String TransformPage_descr; >+ public static String TransformPage_task; >+ public static String TransformPage_project; >+ >+ public static String Name; >+ public static String Value; >+ public static String Add; >+ public static String Delete; >+ public static String Up; >+ public static String Down; >+ >+ static { >+ // initialize resource bundle >+ NLS.initializeMessages(BUNDLE_NAME, Messages.class); >+ } >+ >+ private Messages() { >+ } >+} >Index: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/CompositeTransformationContentPage.java >=================================================================== >RCS file: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/CompositeTransformationContentPage.java >diff -N src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/CompositeTransformationContentPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/CompositeTransformationContentPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,308 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Borland Software Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.m2m.internal.qvt.oml.runtime.ui.ant; >+ >+import java.util.HashMap; >+import java.util.Map; >+import java.util.Set; >+import java.util.Map.Entry; >+ >+import org.eclipse.jface.viewers.ColumnWeightData; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.ISelectionChangedListener; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.ITableLabelProvider; >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.jface.viewers.SelectionChangedEvent; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.jface.viewers.TableLayout; >+import org.eclipse.jface.viewers.TreeViewer; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.jface.window.Window; >+import org.eclipse.jface.wizard.WizardDialog; >+import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Text; >+import org.eclipse.swt.widgets.Tree; >+import org.eclipse.swt.widgets.TreeColumn; >+ >+public class CompositeTransformationContentPage extends WizardPage { >+ private final CompositeTransformationModel myModel; >+ >+ private boolean myWasEverShown; >+ private Text myProjectNameText; >+ private Text myTargetNameText; >+ private TreeViewer myTreeViewer; >+ private Button myUp; >+ private Button myDown; >+ private Button myDelete; >+ >+ public CompositeTransformationContentPage(CompositeTransformationModel model) { >+ super("transformationPage"); //$NON-NLS-1$ >+ myModel = model; >+ setTitle(Messages.TransformPage_title); >+ setDescription(Messages.TransformPage_descr); >+ } >+ >+ @Override >+ public boolean isPageComplete() { >+ return myWasEverShown && super.isPageComplete(); >+ } >+ >+ public void createControl(Composite parent) { >+ Composite container = new Composite(parent, SWT.NULL); >+ GridLayout layout = new GridLayout(); >+ container.setLayout(layout); >+ layout.numColumns = 2; >+ layout.verticalSpacing = 9; >+ Label label = new Label(container, SWT.NULL); >+ label.setText(Messages.TransformPage_project); >+ >+ myProjectNameText = new Text(container, SWT.BORDER | SWT.SINGLE); >+ myProjectNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ myProjectNameText.setText(myModel.getProjectName()); >+ myProjectNameText.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ myModel.setProjectName(myProjectNameText.getText()); >+ } >+ }); >+ >+ label = new Label(container, SWT.NULL); >+ label.setText(Messages.TransformPage_task); >+ >+ myTargetNameText = new Text(container, SWT.BORDER | SWT.SINGLE); >+ myTargetNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ myTargetNameText.setText(myModel.getTargetName()); >+ myTargetNameText.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ myModel.setTargetName(myTargetNameText.getText()); >+ } >+ }); >+ >+ Composite composite = new Composite(container, SWT.NONE); >+ GridData data = new GridData(GridData.FILL_BOTH); >+ data.horizontalSpan = 2; >+ composite.setLayoutData(data); >+ layout = new GridLayout(); >+ layout.numColumns = 2; >+ layout.verticalSpacing = 9; >+ layout.marginWidth = 0; >+ layout.marginRight = 0; >+ composite.setLayout(layout); >+ >+ int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION; >+ myTreeViewer = new TreeViewer(composite, style); >+ myTreeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); >+ final DataProvider dp = new DataProvider(); >+ myTreeViewer.setContentProvider(dp); >+ myTreeViewer.setLabelProvider(dp); >+ myTreeViewer.setInput(myModel); >+ >+ myTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { >+ public void selectionChanged(SelectionChangedEvent event) { >+ updateButtons(event.getSelection()); >+ } >+ }); >+ >+ Tree tree = myTreeViewer.getTree(); >+ TableLayout tableLayout = new TableLayout(); >+ >+ TreeColumn col = new TreeColumn(tree, SWT.NONE); >+ tableLayout.addColumnData(new ColumnWeightData(3, true)); >+ col.setText(Messages.Name); >+ >+ col = new TreeColumn(tree, SWT.NONE); >+ tableLayout.addColumnData(new ColumnWeightData(3, true)); >+ col.setText(Messages.Value); >+ >+ tree.setLayout(tableLayout); >+ tree.setLinesVisible(true); >+ tree.setHeaderVisible(true); >+ >+ Composite buttons = new Composite(composite, SWT.NONE); >+ buttons.setLayoutData(new GridData(GridData.FILL_VERTICAL)); >+ layout = new GridLayout(); >+ layout.numColumns = 1; >+ layout.verticalSpacing = 9; >+ layout.marginTop = 0; >+ layout.marginHeight = 0; >+ layout.marginWidth = 0; >+ layout.marginRight = 0; >+ buttons.setLayout(layout); >+ >+ newButton(buttons, Messages.Add, new SelectionAdapter() { >+ @Override >+ public void widgetSelected(SelectionEvent e) { >+ CreateQvtoAntTaskWizard taskWizard = new CreateQvtoAntTaskWizard(); >+ WizardDialog dialog = new WizardDialog(getContainer().getShell(), taskWizard); >+ dialog.create(); >+ if (dialog.open() == Window.OK) { >+ myModel.getTaskModels().add(taskWizard.getResult()); >+ myTreeViewer.refresh(); >+ } >+ } >+ }); >+ >+ myDelete = newButton(buttons, Messages.Delete, new SelectionAdapter() { >+ @Override >+ public void widgetSelected(SelectionEvent e) { >+ Object selectedElement = getSelectedElement(); >+ if (selectedElement instanceof TaskModel) { >+ myModel.getTaskModels().remove(selectedElement); >+ myTreeViewer.refresh(); >+ } >+ } >+ }); >+ myUp = newButton(buttons, Messages.Up, new SelectionAdapter() { >+ @Override >+ public void widgetSelected(SelectionEvent e) { >+ Object selectedElement = getSelectedElement(); >+ if (selectedElement instanceof TaskModel) { >+ int i = myModel.getTaskModels().indexOf(selectedElement); >+ if (i > 0) { >+ TaskModel p = myModel.getTaskModels().get(i - 1); >+ myModel.getTaskModels().set(i - 1, (TaskModel) selectedElement); >+ myModel.getTaskModels().set(i, p); >+ myTreeViewer.refresh(); >+ } >+ } >+ } >+ }); >+ myDown = newButton(buttons, Messages.Down, new SelectionAdapter() { >+ @Override >+ public void widgetSelected(SelectionEvent e) { >+ Object selectedElement = getSelectedElement(); >+ if (selectedElement instanceof TaskModel) { >+ int i = myModel.getTaskModels().indexOf(selectedElement); >+ if (i < myModel.getTaskModels().size() - 1) { >+ TaskModel n = myModel.getTaskModels().get(i + 1); >+ myModel.getTaskModels().set(i + 1, (TaskModel) selectedElement); >+ myModel.getTaskModels().set(i, n); >+ myTreeViewer.refresh(); >+ } >+ } >+ } >+ }); >+ >+ setControl(container); >+ updateButtons(StructuredSelection.EMPTY); >+ } >+ >+ private Object getSelectedElement() { >+ IStructuredSelection sel = (IStructuredSelection) myTreeViewer.getSelection(); >+ return sel.getFirstElement(); >+ } >+ >+ protected void updateButtons(ISelection selection) { >+ IStructuredSelection sel = (IStructuredSelection) selection; >+ Object firstElement = sel.getFirstElement(); >+ boolean up = false; >+ boolean down = false; >+ boolean del = false; >+ if (firstElement instanceof TaskModel) { >+ int i = myModel.getTaskModels().indexOf(firstElement); >+ up = i > 0; >+ down = i < myModel.getTaskModels().size() - 1; >+ del = true; >+ } >+ myDelete.setEnabled(!selection.isEmpty() && del); >+ myUp.setEnabled(!selection.isEmpty() && up); >+ myDown.setEnabled(!selection.isEmpty() && down); >+ } >+ >+ private static Button newButton(Composite buttons, String caption, SelectionListener listener) { >+ Button button = new Button(buttons, SWT.PUSH); >+ button.setText(caption); >+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL); >+ button.setLayoutData(gridData); >+ button.addSelectionListener(listener); >+ return button; >+ } >+ >+ private static class DataProvider extends LabelProvider implements ITableLabelProvider, ITreeContentProvider { >+ >+ public String getColumnText(Object element, int columnIndex) { >+ if (element instanceof TaskModel) { >+ TaskModel value = (TaskModel) element; >+ return columnIndex == 0 ? value.getTaskName() : " < " + value.getName() + " >"; //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ if (element instanceof Map.Entry) { >+ @SuppressWarnings("unchecked") >+ Map.Entry<String, Object> value = (Entry<String, Object>) element; >+ return columnIndex == 0 ? value.getKey() : String.valueOf(value.getValue()); >+ } >+ return element.toString(); >+ } >+ >+ public Image getColumnImage(Object element, int columnIndex) { >+ return null; >+ } >+ >+ // ITreeContentProvider >+ public Object[] getChildren(Object parentElement) { >+ if (parentElement instanceof TaskModel) { >+ TaskModel model = (TaskModel) parentElement; >+ Set<Entry<String, Object>> entrySet = model.getAttributes().entrySet(); >+ for (Entry<String, Object> entry : entrySet) { >+ myParentCache.put(entry, parentElement); >+ } >+ return entrySet.toArray(); >+ } >+ return null; >+ } >+ >+ public Object getParent(Object element) { >+ return myParentCache.get(element); >+ } >+ >+ public boolean hasChildren(Object element) { >+ return element instanceof TaskModel; >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ if (inputElement instanceof CompositeTransformationModel) { >+ CompositeTransformationModel model = (CompositeTransformationModel) inputElement; >+ return model.getTaskModels().toArray(); >+ } >+ return null; >+ } >+ >+ public void dispose() { >+ myParentCache.clear(); >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ } >+ >+ private final Map<Object, Object> myParentCache = new HashMap<Object, Object>(); >+ } >+ >+ @Override >+ public void setVisible(boolean visible) { >+ if (visible) { >+ myWasEverShown = true; >+ } >+ super.setVisible(visible); >+ } >+} >Index: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/CompositeTransformationModel.java >=================================================================== >RCS file: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/CompositeTransformationModel.java >diff -N src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/CompositeTransformationModel.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/CompositeTransformationModel.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,44 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Borland Software Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.m2m.internal.qvt.oml.runtime.ui.ant; >+ >+import java.util.LinkedList; >+import java.util.List; >+ >+class CompositeTransformationModel { >+ >+ private String myProjectName = "project"; //$NON-NLS-1$ >+ >+ private String myTargetName = "default"; //$NON-NLS-1$ >+ >+ private final List<TaskModel> myTaskModels = new LinkedList<TaskModel>(); >+ >+ public String getProjectName() { >+ return myProjectName; >+ } >+ >+ public void setProjectName(String projectName) { >+ myProjectName = projectName; >+ } >+ >+ public String getTargetName() { >+ return myTargetName; >+ } >+ >+ public void setTargetName(String targetName) { >+ myTargetName = targetName; >+ } >+ >+ public List<TaskModel> getTaskModels() { >+ return myTaskModels; >+ } >+} >Index: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/AbstractCompositeWizardPage.java >=================================================================== >RCS file: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/AbstractCompositeWizardPage.java >diff -N src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/AbstractCompositeWizardPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/AbstractCompositeWizardPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,46 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Borland Software Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.m2m.internal.qvt.oml.runtime.ui.ant; >+ >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+ >+abstract class AbstractCompositeWizardPage extends WizardPage { >+ >+ protected AbstractCompositeWizardPage(String pageName) { >+ super(pageName); >+ } >+ >+ public void createControl(Composite parent) { >+ Composite composite = new Composite(parent, SWT.NULL); >+ GridLayout layout = new GridLayout(); >+ setUpLayout(layout); >+ composite.setLayout(layout); >+ >+ initializeDialogUnits(composite); >+ >+ doCreateControl(composite); >+ >+ setControl(composite); >+ Dialog.applyDialogFont(parent); >+ } >+ >+ protected abstract void doCreateControl(Composite parent); >+ >+ protected void setUpLayout(GridLayout layout) { >+ layout.numColumns = 1; >+ } >+ >+} >Index: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/ResultPage.java >=================================================================== >RCS file: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/ResultPage.java >diff -N src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/ResultPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/ResultPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,42 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Borland Software Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.m2m.internal.qvt.oml.runtime.ui.ant; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Text; >+ >+public class ResultPage extends AbstractCompositeWizardPage { >+ >+ protected ResultPage() { >+ super("ResultPage"); //$NON-NLS-1$ >+ } >+ >+ @Override >+ public void doCreateControl(Composite parent) { >+ setTitle(Messages.ResultPage_title); >+ setDescription(Messages.ResultPage_descr); >+ >+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); >+ >+ myTextField = new Text(parent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); >+ myTextField.setEditable(false); >+ myTextField.setLayoutData(data); >+ } >+ >+ public void setTextData(String textData) { >+ myTextField.setText(textData); >+ } >+ >+ private Text myTextField; >+} >Index: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/messages.properties >=================================================================== >RCS file: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/messages.properties >diff -N src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/messages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/messages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,32 @@ >+AntTaskWizard_windowTitle=New Operational QVT Ant Task >+LaunchConfigError_title=Launch configuration error >+LaunchConfigError_msg=An exception occurred while retrieving launch configurations >+ >+SourceTypePage_title=Choose data source type >+SourceTypePage_descr=Decide where to get task data from >+SourceTypePage_opt1=Enter data manually >+SourceTypePage_opt2=Select existing launch configuration >+ >+SourcePage_title1=Select launch configuration >+SourcePage_descr1=Here you need to select a launch configuration or create new launch configuration data >+SourcePage_configBtn=New launch configuration data... >+ >+ResultPage_title=Preview >+ResultPage_descr=Here you may preview the resulting XML before inserting it to your Ant code >+ >+TransformWizard_windowTitle=New Composite Transformation Wizard >+ >+TransformFilePage_title=Operational QVT Composite transformation >+ >+TransformPage_title=Composite transformation content >+TransformPage_descr=Here you can specify transformation parameters and add transformation content >+TransformPage_task=Default &task name: >+TransformPage_project=&Project name: >+ >+Name=Name >+Value=Value >+ >+Add=&Add >+Delete=&Delete >+Up=&Up >+Down=&Down >Index: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/CreateQvtoAntTaskWizard.java >=================================================================== >RCS file: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/CreateQvtoAntTaskWizard.java >diff -N src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/CreateQvtoAntTaskWizard.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/CreateQvtoAntTaskWizard.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,76 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Borland Software Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.m2m.internal.qvt.oml.runtime.ui.ant; >+ >+import org.eclipse.jface.wizard.IWizardPage; >+import org.eclipse.jface.wizard.Wizard; >+ >+public class CreateQvtoAntTaskWizard extends Wizard { >+ >+ public CreateQvtoAntTaskWizard() { >+ setWindowTitle(Messages.AntTaskWizard_windowTitle); >+ } >+ >+ @Override >+ public void addPages() { >+ myChooseDataSourcePage = new ChooseDataSourcePage(); >+ addPage(myChooseDataSourcePage); >+ myResultPage = new ResultPage(); >+ addPage(myResultPage); >+ super.addPages(); >+ } >+ >+ @Override >+ public IWizardPage getNextPage(IWizardPage page) { >+ IWizardPage result = super.getNextPage(page); >+ if (result == myResultPage) { >+ myResultPage.setTextData(getResText()); >+ } >+ return result; >+ } >+ >+ private String getResText() { >+ TaskModel taskModel = myChooseDataSourcePage.getTaskModel(); >+ return taskModel == null ? "" : taskModel.toString(); //$NON-NLS-1$ >+ } >+ >+ @Override >+ public boolean canFinish() { >+ if (getContainer().getCurrentPage() == myResultPage) { >+ return true; >+ } >+ if (getContainer().getCurrentPage() == myChooseDataSourcePage) { >+ return myChooseDataSourcePage.canFlipToNextPage(); >+ } >+ return false; >+ } >+ >+ @Override >+ public boolean performFinish() { >+ myResultText = getResText(); >+ myResult = myChooseDataSourcePage.getTaskModel(); >+ return true; >+ } >+ >+ public String getResultText() { >+ return myResultText; >+ } >+ >+ public TaskModel getResult() { >+ return myResult; >+ } >+ >+ private ChooseDataSourcePage myChooseDataSourcePage; >+ private ResultPage myResultPage; >+ private String myResultText; >+ private TaskModel myResult; >+} >Index: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/TaskModel.java >=================================================================== >RCS file: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/TaskModel.java >diff -N src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/TaskModel.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/TaskModel.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,194 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Borland Software Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.m2m.internal.qvt.oml.runtime.ui.ant; >+ >+import java.util.Collections; >+import java.util.Iterator; >+import java.util.LinkedHashMap; >+import java.util.List; >+import java.util.Map; >+import java.util.Map.Entry; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.m2m.internal.qvt.oml.common.MdaException; >+import org.eclipse.m2m.internal.qvt.oml.common.launch.IQvtLaunchConstants; >+import org.eclipse.m2m.internal.qvt.oml.common.launch.TargetUriData; >+import org.eclipse.m2m.internal.qvt.oml.runtime.launch.QvtLaunchConfigurationDelegateBase; >+import org.eclipse.m2m.internal.qvt.oml.runtime.launch.QvtLaunchUtil; >+import org.eclipse.m2m.internal.qvt.oml.runtime.project.QvtInterpretedTransformation; >+import org.eclipse.m2m.internal.qvt.oml.runtime.project.QvtTransformation; >+import org.eclipse.m2m.internal.qvt.oml.runtime.project.QvtTransformation.TransformationParameter; >+import org.eclipse.m2m.internal.qvt.oml.runtime.project.QvtTransformation.TransformationParameter.DirectionKind; >+ >+/** >+ * A model class for ant Task. toString renders task XML >+ * >+ * @author abreslav >+ * >+ */ >+public class TaskModel { >+ >+ public TaskModel(ILaunchConfiguration config, String name) throws CoreException { >+ myTaskName = name; >+ >+ myModuleUri = config.getAttribute(IQvtLaunchConstants.MODULE, ""); //$NON-NLS-1$ >+ myTraceFile = config.getAttribute(IQvtLaunchConstants.TRACE_FILE, ""); //$NON-NLS-1$ >+ myIsUseTraceFile = config.getAttribute(IQvtLaunchConstants.USE_TRACE_FILE, false); >+ myTargetUris = QvtLaunchUtil.getTargetUris(config); >+ myConfigProps = QvtLaunchUtil.getConfigurationProperty(config); >+ >+ myAttributes = new LinkedHashMap<String, Object>(); >+ myAttributes.put(IQvtLaunchConstants.MODULE.substring(IQvtLaunchConstants.PREFIX.length()), myModuleUri); >+ myAttributes.put(IQvtLaunchConstants.TRACE_FILE.substring(IQvtLaunchConstants.PREFIX.length()), myTraceFile); >+ >+ myTransformation = new QvtInterpretedTransformation(QvtLaunchConfigurationDelegateBase.getQvtModule(config)); >+ } >+ >+ public String getTaskName() { >+ return myTaskName; >+ } >+ >+ public String getName() { >+ try { >+ return myTransformation.getModuleName(); >+ } catch (MdaException e) { >+ } >+ return ""; //$NON-NLS-1$ >+ } >+ >+ public Map<String, Object> getAttributes() { >+ return Collections.unmodifiableMap(myAttributes); >+ } >+ >+ @Override >+ public String toString() { >+ try { >+ return toXMLString(); >+ } catch (MdaException e) { >+ } >+ return ""; //$NON-NLS-1$ >+ } >+ >+ /** >+ * @return Ant XML representation of the task >+ * @throws MdaException >+ */ >+ public String toXMLString() throws MdaException { >+ String result = ""; //$NON-NLS-1$ >+ >+ result += "<" + myTaskName + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ >+ result += INDENT + "uri=\"" + myModuleUri + "\"\n"; >+ result += INDENT + ">\n"; >+ >+ if (!myTargetUris.isEmpty()) { >+ result += "\n"; >+ } >+ Iterator<TargetUriData> itrTargetUri = myTargetUris.iterator(); >+ for (TransformationParameter transfParam : myTransformation.getParameters()) { >+ if (!itrTargetUri.hasNext()) { >+ break; >+ } >+ TargetUriData targetUri = itrTargetUri.next(); >+ >+ if (transfParam.getDirectionKind() == DirectionKind.IN) { >+ result += INDENT + "<in\n"; >+ result += INDENT + INDENT + "uri=\"" + targetUri.getUriString() + "\"\n"; >+ result += INDENT + "/>"; >+ } >+ else if (transfParam.getDirectionKind() == DirectionKind.INOUT) { >+ result += INDENT + "<inout\n"; >+ result += INDENT + INDENT + "uri=\"" + targetUri.getUriString() + "\"\n"; >+ result += INDENT + INDENT + "outuri=\"" + targetUri.getUriString() + "\"\n"; >+ result += INDENT + "/>"; >+ } >+ else if (transfParam.getDirectionKind() == DirectionKind.OUT) { >+ result += INDENT + "<out\n"; >+ result += INDENT + INDENT + "uri=\"" + targetUri.getUriString(); >+ String feature = targetUri.getFeature(); >+ if (feature != null && feature.trim().length() > 0) { >+ result += "\">\n"; >+ result += INDENT + INDENT + "<feature\n"; >+ result += INDENT + INDENT + INDENT + "name=\"" + targetUri.getFeature() + "\"\n"; >+ result += INDENT + INDENT + INDENT + "clearcontents=\"" + Boolean.valueOf(targetUri.isClearContents()).toString() + "\"\n"; >+ result += INDENT + INDENT + "/>\n"; >+ result += INDENT + "</out>"; >+ } >+ else { >+ result += "\"\n"; >+ result += INDENT + "/>"; >+ } >+ } >+ result += "\n"; >+ } >+ >+ if (myIsUseTraceFile && myTraceFile != null && myTraceFile.trim().length() > 0) { >+ result += "\n"; >+ result += INDENT + "<trace\n"; >+ result += INDENT + INDENT + "uri=\"" + myTraceFile + "\"\n"; >+ result += INDENT + "/>\n"; >+ } >+ >+ if (!myConfigProps.isEmpty()) { >+ result += "\n"; >+ result += INDENT + "<configProperty\n"; >+ } >+ for (Entry<String, Object> entry : myConfigProps.entrySet()) { >+ Object value = entry.getValue(); >+ if (value != null && value.toString() != "") { //$NON-NLS-1$ >+ result += INDENT + INDENT + "name=\"" + entry.getKey() + "\"\n"; >+ result += INDENT + INDENT + "value=\"" + value + "\"\n"; //$NON-NLS-1$//$NON-NLS-2$ >+ } >+ } >+ if (!myConfigProps.isEmpty()) { >+ result += INDENT + "/>\n"; >+ } >+ >+ result += "</" + myTaskName + ">\n"; //$NON-NLS-1$ //$NON-NLS-2$ >+ >+ return result; >+ } >+ >+ /** >+ * Indents a given string with given indent string. NOTE: The string must be >+ * separated with '\n' line delimiters >+ * >+ * @param s - >+ * a string to be indented >+ * @param indent - >+ * an indent string to be added to the begining of the each line >+ * in s >+ * @param delim - >+ * line delimiter to separate resulting lines >+ * @return indented string >+ */ >+ public static String indentString(String s, String indent, String delim) { >+ String result = ""; //$NON-NLS-1$ >+ String[] strings = s.split("\\n"); //$NON-NLS-1$ >+ for (int i = 0; i < strings.length; i++) { >+ result += indent + strings[i] + ((i < strings.length - 1) ? delim : ""); //$NON-NLS-1$ >+ } >+ return result; >+ } >+ >+ private final String myTaskName; >+ private final String myModuleUri; >+ private final String myTraceFile; >+ private final boolean myIsUseTraceFile; >+ private final List<TargetUriData> myTargetUris; >+ private final Map<String, Object> myConfigProps; >+ private final QvtTransformation myTransformation; >+ private final Map<String, Object> myAttributes; >+ >+ private static final String INDENT = " "; //$NON-NLS-1$ >+ >+} >Index: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/LaunchConfigurationTreeContentProvider.java >=================================================================== >RCS file: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/LaunchConfigurationTreeContentProvider.java >diff -N src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/LaunchConfigurationTreeContentProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/LaunchConfigurationTreeContentProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,222 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Borland Software Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.m2m.internal.qvt.oml.runtime.ui.ant; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchConfigurationType; >+import org.eclipse.debug.core.ILaunchManager; >+import org.eclipse.jface.dialogs.ErrorDialog; >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.IPluginContribution; >+import org.eclipse.ui.activities.WorkbenchActivityHelper; >+ >+/** >+ * Content provider for representing launch configuration types & launch >+ * configurations in a tree. >+ */ >+class LaunchConfigurationTreeContentProvider implements ITreeContentProvider { >+ >+ /** >+ * Empty Object array >+ */ >+ private static final Object[] EMPTY_ARRAY = new Object[0]; >+ >+ /** >+ * The mode in which the tree is being shown, one of <code>RUN_MODE</code> >+ * or <code>DEBUG_MODE</code> defined in <code>ILaunchManager</code>. >+ * If this is <code>null</code>, then it means both modes are being >+ * shown. >+ */ >+ private String fMode; >+ >+ /** >+ * The Shell context >+ */ >+ private Shell fShell; >+ >+ public LaunchConfigurationTreeContentProvider(String mode, Shell shell) { >+ setMode(mode); >+ setShell(shell); >+ } >+ >+ /** >+ * Actual launch configurations have no children. Launch configuration types >+ * have all configurations of that type as children, minus any >+ * configurations that are marked as private. >+ * <p> >+ * In 2.1, the <code>category</code> attribute was added to launch config >+ * types. The debug UI only displays those configs that do not specify a >+ * category. >+ * </p> >+ * >+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) >+ */ >+ public Object[] getChildren(Object parentElement) { >+ if (parentElement instanceof ILaunchConfiguration) { >+ return EMPTY_ARRAY; >+ } else if (parentElement instanceof ILaunchConfigurationType) { >+ try { >+ ILaunchConfigurationType type = (ILaunchConfigurationType) parentElement; >+ return getLaunchManager().getLaunchConfigurations(type); >+ } catch (CoreException e) { >+ errorDialog(getShell(), e.getStatus()); >+ } >+ } else { >+ return getLaunchManager().getLaunchConfigurationTypes(); >+ } >+ return EMPTY_ARRAY; >+ } >+ >+ public Object getParent(Object element) { >+ if (element instanceof ILaunchConfiguration) { >+ if (!((ILaunchConfiguration) element).exists()) { >+ return null; >+ } >+ try { >+ return ((ILaunchConfiguration) element).getType(); >+ } catch (CoreException e) { >+ errorDialog(getShell(), e.getStatus()); >+ } >+ } else if (element instanceof ILaunchConfigurationType) { >+ return ResourcesPlugin.getWorkspace().getRoot(); >+ } >+ return null; >+ } >+ >+ public boolean hasChildren(Object element) { >+ if (element instanceof ILaunchConfiguration) { >+ return false; >+ } >+ return getChildren(element).length > 0; >+ } >+ >+ /** >+ * Return only the launch configuration types that support the current mode >+ * AND are marked as 'public'. >+ * >+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) >+ */ >+ public Object[] getElements(Object inputElement) { >+ ILaunchConfigurationType[] allTypes = getLaunchManager().getLaunchConfigurationTypes(); >+ return filterTypes(allTypes).toArray(); >+ } >+ >+ /** >+ * Returns a list containing the given types minus any types that should not >+ * be visible. A type should not be visible if it doesn't match the current >+ * mode or if it matches a disabled activity. >+ * >+ * @param allTypes >+ * the types >+ * @return the given types minus any types that should not be visible. >+ */ >+ private List<ILaunchConfigurationType> filterTypes(ILaunchConfigurationType[] allTypes) { >+ List<ILaunchConfigurationType> filteredTypes = new ArrayList<ILaunchConfigurationType>(); >+ String mode = getMode(); >+ LaunchConfigurationTypeContribution contribution; >+ for (int i = 0; i < allTypes.length; i++) { >+ ILaunchConfigurationType type = allTypes[i]; >+ contribution = new LaunchConfigurationTypeContribution(type); >+ if (isVisible(type, mode) && !WorkbenchActivityHelper.filterItem(contribution)) { >+ filteredTypes.add(type); >+ } >+ } >+ return filteredTypes; >+ } >+ >+ public void dispose() { >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ } >+ >+ /** >+ * Return <code>true</code> if the specified launch configuration type >+ * should be visible in the specified mode, <code>false</code> otherwise. >+ */ >+ private boolean isVisible(ILaunchConfigurationType configType, String mode) { >+ if (!configType.isPublic()) { >+ return false; >+ } >+ if (mode == null) { >+ return true; >+ } >+ return configType.supportsMode(mode); >+ } >+ >+ /** >+ * Convenience method to get the singleton launch manager. >+ */ >+ private ILaunchManager getLaunchManager() { >+ return DebugPlugin.getDefault().getLaunchManager(); >+ } >+ >+ private void setMode(String mode) { >+ fMode = mode; >+ } >+ >+ private String getMode() { >+ return fMode; >+ } >+ >+ private void setShell(Shell shell) { >+ fShell = shell; >+ } >+ >+ private Shell getShell() { >+ return fShell; >+ } >+ >+ /** >+ * Utility method with conventions >+ */ >+ private static void errorDialog(Shell shell, IStatus s) { >+ ErrorDialog.openError(shell, Messages.LaunchConfigError_title, Messages.LaunchConfigError_msg, s); >+ } >+ >+ /** >+ * A plug-in contribution (UI element) which contains a launch configuration >+ * type (Core element). Plug-in contributions are passed to the workbench >+ * activity support to filter elements from the UI. >+ */ >+ private static class LaunchConfigurationTypeContribution implements IPluginContribution { >+ >+ protected ILaunchConfigurationType type; >+ >+ /** >+ * Creates a new plug-in contribution for the given type >+ * >+ * @param type >+ * the launch configuration type >+ */ >+ public LaunchConfigurationTypeContribution(ILaunchConfigurationType type) { >+ this.type = type; >+ } >+ >+ public String getLocalId() { >+ return type.getIdentifier(); >+ } >+ >+ public String getPluginId() { >+ return type.getPluginIdentifier(); >+ } >+ } >+} >Index: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/ChooseDataSourcePage.java >=================================================================== >RCS file: src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/ChooseDataSourcePage.java >diff -N src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/ChooseDataSourcePage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/m2m/internal/qvt/oml/runtime/ui/ant/ChooseDataSourcePage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,308 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Borland Software Corporation >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Borland Software Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.m2m.internal.qvt.oml.runtime.ui.ant; >+ >+import java.util.ArrayList; >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchConfigurationType; >+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+import org.eclipse.debug.core.ILaunchManager; >+import org.eclipse.debug.ui.DebugUITools; >+import org.eclipse.debug.ui.IDebugUIConstants; >+import org.eclipse.debug.ui.ILaunchGroup; >+import org.eclipse.jface.viewers.ILabelProvider; >+import org.eclipse.jface.viewers.ILabelProviderListener; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.ISelectionChangedListener; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.ITreeContentProvider; >+import org.eclipse.jface.viewers.SelectionChangedEvent; >+import org.eclipse.jface.viewers.TreeViewer; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.jface.viewers.ViewerFilter; >+import org.eclipse.jface.window.Window; >+import org.eclipse.m2m.internal.qvt.oml.runtime.ant.QvtoAntTransformationTask; >+import org.eclipse.m2m.internal.qvt.oml.runtime.launch.QvtLaunchConfigurationDelegate; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.model.WorkbenchViewerComparator; >+ >+public class ChooseDataSourcePage extends AbstractCompositeWizardPage { >+ >+ protected ChooseDataSourcePage() { >+ super("dataSourcePage"); //$NON-NLS-1$ >+ setTitle(Messages.SourcePage_title1); >+ setDescription(Messages.SourcePage_descr1); >+ } >+ >+ @Override >+ public void setVisible(boolean visible) { >+ if (visible && getSelectedLaunchConfiguration() == null) { >+ myViewer.setSelection(new IStructuredSelection() { >+ >+ public Object getFirstElement() { >+ Object[] array = toArray(); >+ if (array.length == 0) { >+ return null; >+ } >+ return array[0]; >+ } >+ >+ public Iterator<Object> iterator() { >+ return toList().iterator(); >+ } >+ >+ public int size() { >+ return toArray().length; >+ } >+ >+ public Object[] toArray() { >+ return ((ITreeContentProvider) myViewer.getContentProvider()).getElements(null); >+ } >+ >+ public List<Object> toList() { >+ Object[] array = toArray(); >+ List<Object> list = new ArrayList<Object>(array.length); >+ for (Object o : array) { >+ list.add(o); >+ } >+ return list; >+ } >+ >+ public boolean isEmpty() { >+ return toArray().length > 0; >+ } >+ >+ }); >+ } >+ super.setVisible(visible); >+ } >+ >+ @Override >+ protected void doCreateControl(Composite parent) { >+ myViewer = new TreeViewer(parent); >+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); >+ myViewer.getControl().setLayoutData(data); >+ myViewer.setLabelProvider(new TypeNamesWithTaskTypes(DebugUITools.newDebugModelPresentation())); >+ myViewer.setComparator(new WorkbenchViewerComparator()); >+ myViewer.setContentProvider(new LaunchConfigurationTreeContentProvider(ILaunchManager.RUN_MODE, parent.getShell())); >+ myViewer.addFilter(new AntFilter()); >+ myViewer.setInput(ResourcesPlugin.getWorkspace().getRoot()); >+ myViewer.expandAll(); >+ >+ myViewer.addSelectionChangedListener(new ISelectionChangedListener() { >+ public void selectionChanged(SelectionChangedEvent event) { >+ getContainer().updateButtons(); >+ myConfigButton.setEnabled(getSelectedConfigType() != null); >+ } >+ }); >+ >+ myConfigButton = new Button(parent, SWT.NULL); >+ myConfigButton.setText(Messages.SourcePage_configBtn); >+ myConfigButton.setEnabled(false); >+ myConfigButton.addSelectionListener(new SelectionListener() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ ILaunchConfigurationType configType = getSelectedConfigType(); >+ if (configType == null) { >+ return; >+ } >+ try { >+ if ((myCreatedConfig == null) || (!configType.equals(myCreatedConfig.getType()))) { >+ ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, "qvto.antTask.newConfiguration"); //$NON-NLS-1$ >+ wc.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true); >+ myCreatedConfig = wc.doSave(); >+ } >+ ILaunchGroup launchGroup = DebugUITools.getLaunchGroup(myCreatedConfig, ILaunchManager.RUN_MODE); >+ if (DebugUITools.openLaunchConfigurationPropertiesDialog(getShell(), myCreatedConfig, launchGroup.getIdentifier()) == Window.OK) { >+ myConfig = myCreatedConfig; >+ if (canFlipToNextPage()) { >+ getContainer().showPage(getNextPage()); >+ myConfig = null; >+ } >+ } >+ getContainer().updateButtons(); >+ } catch (CoreException e1) { >+ e1.printStackTrace(); >+ } >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ widgetSelected(e); >+ } >+ }); >+ >+ Composite container = new Composite(parent, SWT.NULL); >+ container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ GridLayout layout = new GridLayout(); >+ container.setLayout(layout); >+ layout.numColumns = 2; >+ layout.verticalSpacing = 9; >+ } >+ >+ @Override >+ public boolean canFlipToNextPage() { >+ setErrorMessage(null); >+ myTaskModel = null; >+ >+ ILaunchConfiguration conf = getSelectedLaunchConfiguration(); >+ if (conf == null) { >+ return false; >+ } >+ >+ try { >+ myTaskModel = new TaskModel(conf, QvtoAntTransformationTask.QVTO_ANTTASK_NAME); >+ } >+ catch (Exception e) { >+ setErrorMessage(e.getMessage()); >+ return false; >+ } >+ >+ return true; >+ } >+ >+ public TaskModel getTaskModel() { >+ return myTaskModel; >+ } >+ >+ private ILaunchConfiguration getSelectedLaunchConfiguration() { >+ if (myConfig != null) { >+ return myConfig; >+ } >+ >+ ISelection selection = myViewer.getSelection(); >+ if (selection instanceof IStructuredSelection) { >+ IStructuredSelection ssel = (IStructuredSelection) selection; >+ Object firstElement = ssel.getFirstElement(); >+ if (firstElement instanceof ILaunchConfiguration) { >+ return (ILaunchConfiguration) firstElement; >+ } >+ } >+ return null; >+ } >+ >+ private ILaunchConfigurationType getSelectedConfigType() { >+ ISelection selection = myViewer.getSelection(); >+ if (selection instanceof IStructuredSelection) { >+ IStructuredSelection ssel = (IStructuredSelection) selection; >+ Object firstElement = ssel.getFirstElement(); >+ if (firstElement instanceof ILaunchConfigurationType) { >+ return (ILaunchConfigurationType) firstElement; >+ } >+ if (firstElement instanceof ILaunchConfiguration) { >+ try { >+ return ((ILaunchConfiguration) firstElement).getType(); >+ } catch (CoreException e) { >+ } >+ } >+ } >+ return null; >+ } >+ >+ private class AntFilter extends ViewerFilter { >+ >+ @Override >+ public boolean select(Viewer viewer, Object parentElement, Object element) { >+ if (element instanceof ILaunchConfigurationType) { >+ ILaunchConfigurationType type = (ILaunchConfigurationType) element; >+ return isTypeSupported(type); >+ } >+ if (element instanceof ILaunchConfiguration) { >+ ILaunchConfiguration config = (ILaunchConfiguration) element; >+ boolean priv = false; >+ try { >+ priv = config.getAttribute(IDebugUIConstants.ATTR_PRIVATE, false); >+ } catch (CoreException e) { >+ // Ignored >+ } >+ if (priv) { >+ return false; >+ } >+ ILaunchConfigurationType type = null; >+ try { >+ type = config.getType(); >+ } catch (CoreException e) { >+ return false; >+ } >+ return isTypeSupported(type); >+ } >+ >+ return false; >+ } >+ >+ private boolean isTypeSupported(ILaunchConfigurationType type) { >+ return QvtLaunchConfigurationDelegate.LAUNCH_CONFIGURATION_TYPE_ID.equals(type.getIdentifier()); >+ } >+ >+ } >+ >+ private static class TypeNamesWithTaskTypes implements ILabelProvider { >+ >+ TypeNamesWithTaskTypes(ILabelProvider dmp) { >+ myWrapped = dmp; >+ } >+ >+ public Image getImage(Object element) { >+ return myWrapped.getImage(element); >+ } >+ >+ public String getText(Object element) { >+ String suffix = ""; //$NON-NLS-1$ >+ if (element instanceof ILaunchConfigurationType) { >+ ILaunchConfigurationType type = (ILaunchConfigurationType) element; >+ suffix = " (" + getTaskName(type) + ")"; //$NON-NLS-1$//$NON-NLS-2$ >+ } >+ return myWrapped.getText(element) + suffix; >+ } >+ >+ private String getTaskName(ILaunchConfigurationType type) { >+ return QvtoAntTransformationTask.QVTO_ANTTASK_NAME; >+ } >+ >+ public void addListener(ILabelProviderListener listener) { >+ myWrapped.addListener(listener); >+ } >+ >+ public void dispose() { >+ myWrapped.dispose(); >+ } >+ >+ public boolean isLabelProperty(Object element, String property) { >+ return myWrapped.isLabelProperty(element, property); >+ } >+ >+ public void removeListener(ILabelProviderListener listener) { >+ myWrapped.removeListener(listener); >+ } >+ >+ private final ILabelProvider myWrapped; >+ >+ } >+ >+ private TreeViewer myViewer; >+ private Button myConfigButton; >+ private ILaunchConfiguration myConfig; >+ private ILaunchConfiguration myCreatedConfig; >+ private TaskModel myTaskModel; >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 267493
: 127911