[jbosstools-commits] JBoss Tools SVN: r24159 - in trunk/bpel/plugins/org.eclipse.bpel.ui: src/org/eclipse/bpel/ui and 1 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Fri Aug 13 13:25:13 EDT 2010
Author: bbrodt
Date: 2010-08-13 13:25:12 -0400 (Fri, 13 Aug 2010)
New Revision: 24159
Added:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/NamespacePrefixElement.java
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/NamespacePrefixesProvider.java
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/NamespacePrefixesSection.java
Modified:
trunk/bpel/plugins/org.eclipse.bpel.ui/plugin.properties
trunk/bpel/plugins/org.eclipse.bpel.ui/plugin.xml
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/IHelpContextIds.java
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/Messages.java
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/messages.properties
Log:
https://jira.jboss.org/browse/JBIDE-6765
Added a Namespaces tab to the Property sheet
Modified: trunk/bpel/plugins/org.eclipse.bpel.ui/plugin.properties
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.ui/plugin.properties 2010-08-13 17:22:10 UTC (rev 24158)
+++ trunk/bpel/plugins/org.eclipse.bpel.ui/plugin.properties 2010-08-13 17:25:12 UTC (rev 24159)
@@ -29,6 +29,8 @@
DETAILS_PAGES_INITIALIZATION_LABEL=Initialization
DETAILS_PAGES_DOCUMENTATION_LABEL=Documentation
DETAILS_PAGES_MESSAGE_EXCHANGE_LABEL=Message Exchange
+# https://jira.jboss.org/browse/JBIDE-6765
+DETAILS_PAGES_NAMESPACEPREFIXES_LABEL=Namespaces
XPATH_LABEL=XPath 1.0
XPATH_LABEL20 = XPath 1.0 in BPEL 2.0
Modified: trunk/bpel/plugins/org.eclipse.bpel.ui/plugin.xml
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.ui/plugin.xml 2010-08-13 17:22:10 UTC (rev 24158)
+++ trunk/bpel/plugins/org.eclipse.bpel.ui/plugin.xml 2010-08-13 17:25:12 UTC (rev 24159)
@@ -187,7 +187,13 @@
afterTab="org.eclipse.bpel.ui.tabs.details"
category="implementation"
id="org.eclipse.bpel.ui.tabs.imports"/>
+ <!-- https://jira.jboss.org/browse/JBIDE-6765 -->
<propertyTab
+ label="%DETAILS_PAGES_NAMESPACEPREFIXES_LABEL"
+ afterTab="org.eclipse.bpel.ui.tabs.imports"
+ category="implementation"
+ id="org.eclipse.bpel.ui.tabs.namespacePrefixes"/>
+ <propertyTab
label="%DETAILS_PAGES_EXPIRATION_LABEL"
afterTab="org.eclipse.bpel.ui.tabs.details"
category="implementation"
@@ -250,7 +256,15 @@
id="org.eclipse.bpel.ui.sections.Imports">
<input type="org.eclipse.bpel.model.Process"/>
</propertySection>
+ <!-- https://jira.jboss.org/browse/JBIDE-6765 -->
<propertySection
+ tab="org.eclipse.bpel.ui.tabs.namespacePrefixes"
+ class="org.eclipse.bpel.ui.properties.NamespacePrefixesSection"
+ id="org.eclipse.bpel.ui.sections.NamespacePrefixes">
+ <input type="org.eclipse.bpel.model.Activity"/>
+ <input type="org.eclipse.bpel.model.Process"/>
+ </propertySection>
+ <propertySection
afterSection="org.eclipse.bpel.ui.sections.JoinCondition"
tab="org.eclipse.bpel.ui.tabs.joinBehaviour"
class="org.eclipse.bpel.ui.properties.JoinFailureSection"
Modified: trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/IHelpContextIds.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/IHelpContextIds.java 2010-08-13 17:22:10 UTC (rev 24158)
+++ trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/IHelpContextIds.java 2010-08-13 17:25:12 UTC (rev 24159)
@@ -37,6 +37,8 @@
public static final String PROPERTY_PAGE_COMPENSATE_IMPLEMENTATION = PREFIX + "IMP090"; //$NON-NLS-1$
public static final String PROPERTY_PAGE_ONEVENT_IMPLEMENTATION = PREFIX + "IMP100"; //$NON-NLS-1$
public static final String PROPERTY_PAGE_BPEL_IMPORTS = PREFIX + "IMT010"; //$NON-NLS-1$
+ // https://jira.jboss.org/browse/JBIDE-6765
+ public static final String PROPERTY_PAGE_BPEL_NAMESPACE_PREFIXES = PREFIX + "NST010"; //$NON-NLS-1$
public static final String PROPERTY_PAGE_REPEAT_ALARM = PREFIX + "RPT010"; //$NON-NLS-1$
public static final String PROPERTY_PAGE_WAIT_DATE = PREFIX + "WAT010"; //$NON-NLS-1$
public static final String PROPERTY_PAGE_WAIT_DURATION = PREFIX + "WAT020"; //$NON-NLS-1$
Modified: trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/Messages.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/Messages.java 2010-08-13 17:22:10 UTC (rev 24158)
+++ trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/Messages.java 2010-08-13 17:25:12 UTC (rev 24159)
@@ -47,6 +47,13 @@
public static String ImportsSection_1;
public static String ImportsSection_2;
public static String ImportsSection_3;
+ // https://jira.jboss.org/browse/JBIDE-6765
+ public static String NamespacePrefixesSection;
+ public static String NamespacePrefixesSection_0;
+ public static String NamespacePrefixesSection_1;
+ public static String NamespacePrefixesSection_2;
+ public static String NamespacePrefixesSection_3;
+ public static String NamespacePrefixesSection_4;
public static String InputMessageAdapter_0;
public static String InvokeImplSection_0;
public static String InvokeImplSection_1;
Modified: trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/messages.properties
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/messages.properties 2010-08-13 17:22:10 UTC (rev 24158)
+++ trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/messages.properties 2010-08-13 17:25:12 UTC (rev 24159)
@@ -638,6 +638,13 @@
ImportsSection_1=Import an &XSD ...
ImportsSection_2=&Remove
ImportsSection_3=Import Type
+# https://jira.jboss.org/browse/JBIDE-6765
+NamespacePrefixesSection=Namespace Prefixes
+NamespacePrefixesSection_0=Prefix
+NamespacePrefixesSection_1=Namespace
+NamespacePrefixesSection_2=Scope
+NamespacePrefixesSection_3=Location
+NamespacePrefixesSection_4=Assign Prefix
BrowseSelectorDialog_0=Name (* and ? are wildcards):
BrowseSelectorDialog_1=Matches:
BrowseSelectorDialog_2=Browse Source
Added: trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/NamespacePrefixElement.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/NamespacePrefixElement.java (rev 0)
+++ trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/NamespacePrefixElement.java 2010-08-13 17:25:12 UTC (rev 24159)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+ package org.eclipse.bpel.ui.properties;
+
+import org.eclipse.emf.ecore.EObject;
+
+/*
+ * This represents an entry in the NamespacesPrefixesSection table in the Namespaces Property Tab.
+ * The NamespacesPrefixesProvider builds a list of these to be displayed in the table.
+ *
+ * @see https://jira.jboss.org/browse/JBIDE-6765
+ * @author Bob Brodt
+ * @date Aug 13, 2010
+ */
+public class NamespacePrefixElement {
+
+ public String prefix;
+ public String namespace;
+ public EObject context;
+ public String location;
+
+ public NamespacePrefixElement(String prefix, String namespace, EObject context, String location)
+ {
+ this.prefix = prefix;
+ this.namespace = namespace;
+ this.context = context;
+ this.location = location;
+ }
+}
\ No newline at end of file
Added: trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/NamespacePrefixesProvider.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/NamespacePrefixesProvider.java (rev 0)
+++ trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/NamespacePrefixesProvider.java 2010-08-13 17:25:12 UTC (rev 24159)
@@ -0,0 +1,216 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.eclipse.bpel.ui.properties;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+//import org.eclipse.bpel.model.Import;
+import org.eclipse.bpel.model.Process;
+import org.eclipse.bpel.model.util.BPELConstants;
+import org.eclipse.bpel.model.util.BPELUtils;
+import org.eclipse.bpel.model.util.ImportResolver;
+import org.eclipse.bpel.model.util.ImportResolverRegistry;
+import org.eclipse.bpel.ui.details.providers.AbstractContentProvider;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.wst.wsdl.Definition;
+//import org.eclipse.wst.wsdl.Import;
+import org.eclipse.wst.wsdl.util.WSDLConstants;
+
+/*
+ * Content provider for the NamespacesPrefixesSection table in the Namespaces Property Tab.
+ * Input is the BPEL Activity or Process object currently selected in the editor canvas.
+ * The provider collects all of the namespaces in scope for the input EObject and tries
+ * to correlate them with imported artifacts. The result, a list of NamespacePrefixesElement,
+ * is displayed in the table Namespaces Property Tab.
+ *
+ * @see https://jira.jboss.org/browse/JBIDE-6765
+ * @author Bob Brodt
+ * @date Aug 13, 2010
+ */
+public class NamespacePrefixesProvider extends AbstractContentProvider {
+
+ /**
+ * @see org.eclipse.bpel.ui.details.providers.AbstractContentProvider#collectElements(java.lang.Object, java.util.List)
+ */
+ @Override
+ public void collectElements(Object input, List<Object> list) {
+
+ List<NamespacePrefixElement> elements = new ArrayList<NamespacePrefixElement>();
+
+ // build the list of elements
+ // find the process for this BPEL model object
+ Process process = null;
+ if (input instanceof EObject)
+ {
+ EObject context = (EObject)input;
+ process = BPELUtils.getProcess(input);
+ // walk up the BPEL activity ancestry starting at the input element
+ // and collect all in-scope namespace info
+ while (context!=null)
+ {
+ Map<String, String> map = BPELUtils.getNamespaceMap(context);
+ for (Map.Entry e : map.entrySet())
+ {
+ String ns = e.getValue().toString();
+ NamespacePrefixElement elem = new NamespacePrefixElement((String)e.getKey(), ns, context,null);
+ elements.add(elem);
+ if( BPELConstants.NAMESPACE_2007.equals(ns) ||
+ process.getTargetNamespace().equals(ns))
+ {
+ elem.location = process.eResource().getURI().lastSegment();
+ }
+ }
+ context = context.eContainer();
+ }
+ }
+
+ // get the list of imports from the Process and try to correlate
+ // the namespaces to the imported artifact in which it's defined
+ List<Object> imports = new ArrayList<Object>();
+ if ( process!=null )
+ {
+ for (org.eclipse.bpel.model.Import imp : process.getImports())
+ {
+ imports.add(imp);
+
+ if ( imp.getImportType().equals(WSDLConstants.WSDL_NAMESPACE_URI) )
+ {
+ // yikes! don't load WSDLs from WS sites - this takes forever!
+ if (!imp.getLocation().startsWith("http://") && !imp.getLocation().startsWith("https://"))
+ {
+ ImportResolver r = ImportResolverRegistry.INSTANCE.getResolvers(imp.getImportType())[0];
+ Definition wsdl = (Definition) r.resolve(imp, ImportResolver.RESOLVE_DEFINITION).get(0);
+ recurseImports(wsdl.getImports(), imports, elements);
+ }
+ }
+ }
+ }
+
+ // now match up the namespaces from the imports to the local namespace maps in elements
+ for (Object o : imports)
+ {
+ String namespace = "";
+ String location = "";
+ if (o instanceof org.eclipse.wst.wsdl.Import)
+ {
+ location = ((org.eclipse.wst.wsdl.Import)o).getLocationURI();
+ namespace = ((org.eclipse.wst.wsdl.Import)o).getNamespaceURI();
+ }
+ else if (o instanceof org.eclipse.bpel.model.Import)
+ {
+ location = ((org.eclipse.bpel.model.Import)o).getLocation();
+ namespace = ((org.eclipse.bpel.model.Import)o).getNamespace();
+ }
+ else
+ continue;
+
+ boolean found = false;
+ for (NamespacePrefixElement elem : elements)
+ {
+ if (namespace.equals(elem.namespace))
+ {
+ if (elem.location==null)
+ elem.location = location;
+ found = true;
+ }
+ }
+ if (!found)
+ {
+ // here's a namespace that wasn't found in any BPEL activity scope
+ // let's add it to our list with an empty ns prefix and context.
+ elements.add(new NamespacePrefixElement("", namespace, null, location));
+ }
+ }
+
+ list.addAll(elements);
+ // sort list alphabetically on prefix name
+ Collections.sort(list,new Comparator()
+ {
+ @Override
+ public int compare(Object o1, Object o2) {
+ return ((NamespacePrefixElement)o1).prefix.compareTo(((NamespacePrefixElement)o2).prefix);
+ }
+ });
+ }
+
+ private void recurseImports(Map<Object,Object> m, List<Object> imports, List<NamespacePrefixElement>elements)
+ {
+ for (Map.Entry e : m.entrySet())
+ {
+ ArrayList<org.eclipse.wst.wsdl.Import> v = (ArrayList<org.eclipse.wst.wsdl.Import>)e.getValue();
+ for (org.eclipse.wst.wsdl.Import wsdlImp : v)
+ {
+ boolean foundNew = true;
+ for (Object o : imports)
+ {
+ if (o instanceof org.eclipse.wst.wsdl.Import)
+ {
+ Definition wsdl = ((org.eclipse.wst.wsdl.Import)o).getEDefinition();
+
+ if ( ((org.eclipse.wst.wsdl.Import)o).getLocationURI().equals(wsdlImp.getLocationURI()) )
+ foundNew = false;
+
+ Object ns = wsdl.getNamespaces().entrySet();
+ System.out.println("ns="+ns);
+ }
+ else if (o instanceof org.eclipse.bpel.model.Import)
+ {
+ if ( ((org.eclipse.bpel.model.Import)o).getLocation().equals(wsdlImp.getLocationURI()) )
+ foundNew = false;
+ }
+ }
+ if (foundNew)
+ imports.add(wsdlImp);
+
+ if (!wsdlImp.getLocationURI().startsWith("http://"))
+ {
+ if (wsdlImp.getDefinition()!=null)
+ {
+ // let's see if this WSDL defines a namespace for which we're missing a location
+ for (NamespacePrefixElement elem : elements)
+ {
+ if (elem.location==null)
+ {
+ Map<Object,Object> ns = wsdlImp.getDefinition().getNamespaces();
+ for (Map.Entry ens : ns.entrySet())
+ {
+ if (ens.getValue().equals(elem.namespace))
+ {
+ elem.location = wsdlImp.getLocationURI();
+ break;
+ }
+ }
+
+ }
+ }
+ recurseImports(wsdlImp.getDefinition().getImports(), imports, elements);
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/NamespacePrefixesSection.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/NamespacePrefixesSection.java (rev 0)
+++ trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/properties/NamespacePrefixesSection.java 2010-08-13 17:25:12 UTC (rev 24159)
@@ -0,0 +1,418 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.eclipse.bpel.ui.properties;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.bpel.common.ui.details.IDetailsAreaConstants;
+import org.eclipse.bpel.common.ui.flatui.FlatFormAttachment;
+import org.eclipse.bpel.common.ui.flatui.FlatFormData;
+import org.eclipse.bpel.model.Activity;
+import org.eclipse.bpel.model.Import;
+import org.eclipse.bpel.model.Process;
+import org.eclipse.bpel.model.util.BPELUtils;
+import org.eclipse.bpel.ui.IBPELUIConstants;
+import org.eclipse.bpel.ui.IHelpContextIds;
+import org.eclipse.bpel.ui.Messages;
+import org.eclipse.bpel.ui.commands.AddImportCommand;
+import org.eclipse.bpel.ui.commands.RemoveImportCommand;
+import org.eclipse.bpel.ui.details.providers.ColumnTableProvider;
+import org.eclipse.bpel.ui.dialogs.NamespaceMappingDialog;
+import org.eclipse.bpel.ui.dialogs.SchemaImportDialog;
+import org.eclipse.bpel.ui.util.BPELUtil;
+import org.eclipse.bpel.ui.util.MultiObjectAdapter;
+import org.eclipse.bpel.ui.util.NamespaceUtils;
+import org.eclipse.bpel.ui.util.TableCursor;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.wsdl.internal.impl.ImportImpl;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * The Namespaces Property Tab contains a table of namespaces in scope for the currently
+ * selected BPEL activity or the process. The table has the following columns:
+ *
+ * Prefix - the namespace prefix. This could be empty if the namespace was defined in
+ * an imported artifact (WSDL or XSD)
+ * Namespace - the namespace definition
+ * Context - the Activity or Process in which the namespace prefix was defined
+ * Location - the resource artifact that defines the namespace
+ *
+ * A button with the label "Assign Prefix" will be enabled if the current selection in
+ * the able has no namespace prefix. This will allow the user to assign a prefix.
+ *
+ * @see https://jira.jboss.org/browse/JBIDE-6765
+ * @author Bob Brodt
+ * @date Aug 13, 2010
+ */
+public class NamespacePrefixesSection extends BPELPropertySection {
+
+ protected Composite parentComposite;
+
+ protected Composite activityComposite;
+
+ protected Label tabLabel;
+
+ protected Table prefixesTable;
+
+ protected TableViewer prefixesViewer;
+
+ protected ColumnTableProvider tableProvider;
+
+ protected TableCursor tableCursor = null;
+
+ /**
+ * Make this section use all the vertical space it can get.
+ *
+ */
+ @Override
+ public boolean shouldUseExtraSpace() {
+ return true;
+ }
+
+ /**
+ * Bug 290085 - Override the super-class because the input is Process not Import
+ * If use super-class's directly, when change the import attributes
+ * the properties section do not change. Grid Qian
+ */
+ @Override
+ protected void addAllAdapters() {
+ super.addAllAdapters();
+ if (fAdapters.length > 0) {
+ if (getModel() != null) {
+ EObject obj = getModel();
+ if (obj instanceof Process) {
+ List<Import> list = ((Process) obj).getImports();
+ for (int i = 0; i < list.size(); i++) {
+ fAdapters[0].addToObject((Import) list.get(i));
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ protected MultiObjectAdapter[] createAdapters() {
+ return new MultiObjectAdapter[] { new MultiObjectAdapter() {
+ @Override
+ public void notify(Notification n) {
+ prefixesViewer.setInput(getInput());
+ }
+ }, };
+ }
+
+ protected void createWidgets(Composite parent) {
+
+ FlatFormData data;
+
+ final Button assignPrefixButton = fWidgetFactory.createButton(parent,
+ Messages.NamespacePrefixesSection_4, SWT.PUSH);
+ assignPrefixButton.setEnabled(false);
+
+ assignPrefixButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ assignPrefix();
+ }
+ });
+
+ data = new FlatFormData();
+ data.right = new FlatFormAttachment(100, -5
+ * IDetailsAreaConstants.HSPACE);
+ data.top = new FlatFormAttachment(0, IDetailsAreaConstants.VSPACE);
+ assignPrefixButton.setLayoutData(data);
+
+ tabLabel = fWidgetFactory.createLabel(parent,
+ Messages.NamespacePrefixesSection);
+ data = new FlatFormData();
+ data.left = new FlatFormAttachment(0, IDetailsAreaConstants.HSPACE);
+ data.top = new FlatFormAttachment(assignPrefixButton,
+ IDetailsAreaConstants.VSPACE);
+ tabLabel.setLayoutData(data);
+
+ // create table
+ prefixesTable = fWidgetFactory.createTable(parent, SWT.FULL_SELECTION | SWT.V_SCROLL
+ | SWT.READ_ONLY);
+
+ data = new FlatFormData();
+ data.left = new FlatFormAttachment(0, IDetailsAreaConstants.HSPACE);
+ data.right = new FlatFormAttachment(100, -5
+ * IDetailsAreaConstants.HSPACE);
+ data.top = new FlatFormAttachment(tabLabel,
+ IDetailsAreaConstants.VSPACE);
+ data.bottom = new FlatFormAttachment(100, -IDetailsAreaConstants.HSPACE);
+ prefixesTable.setLayoutData(data);
+
+ // set up table
+ prefixesTable.setLinesVisible(true);
+ prefixesTable.setHeaderVisible(true);
+
+ tableProvider = new ColumnTableProvider();
+ tableProvider.add(new PrefixColumn());
+ tableProvider.add(new NamespaceColumn());
+ tableProvider.add(new ContextColumn());
+ tableProvider.add(new LocationColumn());
+
+ prefixesViewer = new TableViewer(prefixesTable);
+ tableProvider.createTableLayout(prefixesTable);
+ prefixesViewer.setLabelProvider(tableProvider);
+ prefixesViewer.setCellModifier(tableProvider);
+ prefixesViewer.setContentProvider(new NamespacePrefixesProvider());
+ prefixesViewer.setColumnProperties(tableProvider.getColumnProperties());
+ prefixesViewer.setCellEditors(tableProvider.createCellEditors(prefixesTable));
+
+ prefixesViewer
+ .addPostSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ if (event.getSelection() instanceof StructuredSelection)
+ {
+ StructuredSelection sel = (StructuredSelection)event.getSelection();
+ NamespacePrefixElement elem = (NamespacePrefixElement)sel.getFirstElement();
+ if (elem!=null && (elem.prefix==null || elem.prefix.length()==0))
+ assignPrefixButton.setEnabled(true);
+ else
+ assignPrefixButton.setEnabled(false);
+ }
+ }
+ });
+
+ tableCursor = BPELUtil.createTableCursor(prefixesTable, prefixesViewer);
+ }
+
+ public class PrefixColumn extends ColumnTableProvider.Column implements
+ ILabelProvider {
+
+ @Override
+ public String getHeaderText() {
+ return Messages.NamespacePrefixesSection_0;
+ }
+
+ @Override
+ public String getProperty() {
+ return "NamespacePrefix"; //$NON-NLS-1$
+ }
+
+ @Override
+ public int getInitialWeight() {
+ return 10;
+ }
+
+ public String getText(Object element) {
+
+ String s = ((NamespacePrefixElement)element).prefix;
+ return (s == null) ? "" : s; //$NON-NLS-1$
+ }
+ }
+
+ public class NamespaceColumn extends ColumnTableProvider.Column implements
+ ILabelProvider {
+ @Override
+ public String getHeaderText() {
+ return Messages.NamespacePrefixesSection_1;
+ }
+
+ @Override
+ public String getProperty() {
+ return "Namespace"; //$NON-NLS-1$
+ }
+
+ @Override
+ public int getInitialWeight() {
+ return 40;
+ }
+
+ public String getText(Object element) {
+
+ String s = ((NamespacePrefixElement)element).namespace;
+ return (s == null) ? "" : s; //$NON-NLS-1$
+ }
+ }
+
+ public class ContextColumn extends ColumnTableProvider.Column implements
+ ILabelProvider {
+
+ @Override
+ public String getHeaderText() {
+ return Messages.NamespacePrefixesSection_2;
+ }
+
+ @Override
+ public String getProperty() {
+ return "Context"; //$NON-NLS-1$
+ }
+
+ @Override
+ public int getInitialWeight() {
+ return 10;
+ }
+
+ public String getText(Object element) {
+
+ String s = null;
+ EObject obj = ((NamespacePrefixElement)element).context;
+ if (obj instanceof Process)
+ s = "Process " + ((Process)obj).getName();
+ else if (obj instanceof Activity)
+ s = "Activity " + ((Activity)obj).getName();
+ return (s == null) ? "" : s; //$NON-NLS-1$
+ }
+ }
+
+ public class LocationColumn extends ColumnTableProvider.Column implements
+ ILabelProvider {
+ @Override
+ public String getHeaderText() {
+ return Messages.NamespacePrefixesSection_3;
+ }
+
+ @Override
+ public String getProperty() {
+ return "Location"; //$NON-NLS-1$
+ }
+
+ @Override
+ public int getInitialWeight() {
+ return 40;
+ }
+
+ public String getText(Object element) {
+
+ String s = ((NamespacePrefixElement)element).location;
+ return (s == null) ? "" : s; //$NON-NLS-1$
+ }
+ }
+
+
+
+ @Override
+ protected void basicSetInput(EObject newInput) {
+ super.basicSetInput(newInput);
+
+ if (getInput() != null) {
+ prefixesViewer.setInput(getInput());
+ }
+ }
+
+
+ @Override
+ protected void createClient(Composite parent) {
+ Composite composite = parentComposite = createFlatFormComposite(parent);
+
+ createWidgets(composite);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parentComposite,
+ IHelpContextIds.PROPERTY_PAGE_BPEL_NAMESPACE_PREFIXES);
+ }
+
+ @Override
+ public Object getUserContext() {
+ return ((StructuredSelection) prefixesViewer.getSelection())
+ .getFirstElement();
+ }
+
+ @Override
+ public void restoreUserContext(Object userContext) {
+ prefixesTable.setFocus();
+ if (userContext != null) {
+ prefixesViewer.setSelection(new StructuredSelection(userContext));
+ }
+ }
+
+ void assignPrefix () {
+
+ ISelection selection = prefixesViewer.getSelection();
+ if (selection.isEmpty()) {
+ return ;
+ }
+ IStructuredSelection ssel = null;
+ if ( (selection instanceof IStructuredSelection) == false) {
+ return;
+ }
+
+ ssel = (IStructuredSelection) selection;
+ NamespacePrefixElement elem = (NamespacePrefixElement)ssel.getFirstElement();
+
+ EObject modelObject = elem.context;
+ if (modelObject==null)
+ modelObject = this.fModelObject;
+
+ // We have to map the namespace to a prefix.
+ NamespaceMappingDialog dialog = new NamespaceMappingDialog(tabLabel.getShell(),modelObject);
+ dialog.setNamespace( elem.namespace );
+
+ if (dialog.open() == Window.CANCEL) {
+ return;
+ }
+
+ // define the prefix
+ BPELUtils.setPrefix( modelObject, elem.namespace, dialog.getPrefix());
+ elem.prefix = dialog.getPrefix();
+ elem.context = modelObject;
+
+ prefixesViewer.refresh();
+ }
+
+
+
+ @Override
+ public void gotoMarker(IMarker marker) {
+ // TODO Auto-generated method stub
+ super.gotoMarker(marker);
+ }
+
+ /**
+ *
+ */
+
+
+ @Override
+ public boolean isValidMarker(IMarker marker) {
+ return super.isValidMarker(marker);
+ }
+
+
+
+}
More information about the jbosstools-commits
mailing list