Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util')
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ComponentReferenceUtil.java957
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/CreateWSDLElementHelper.java351
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/NameUtil.java427
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/NodeAssociationManager.java147
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/OpenOnSelectionHelper.java284
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ReferenceManager.java363
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/SelectionAdapter.java84
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ValidateHelper.java405
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLEditorUtil.java215
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLModelLocatorAdapterFactory.java46
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLNodeAssociationProvider.java81
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLPreferencePage.java91
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLResourceUtil.java145
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XMLQuickScan.java91
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XSDSchemaLocationResolverAdapterFactory.java31
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XSDSchemaLocationResolverImpl.java39
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/FlatPageHeader.java356
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/FlatPageSection.java408
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/HyperlinkAdapter.java22
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/HyperlinkHandler.java203
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/IHyperlinkListener.java21
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/ToggleControl.java266
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/WidgetFactory.java347
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/BaseDesignWindow.java233
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/BorderPainter.java93
-rw-r--r--bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/FlatViewUtility.java902
26 files changed, 0 insertions, 6608 deletions
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ComponentReferenceUtil.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ComponentReferenceUtil.java
deleted file mode 100644
index cbf51ae69..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ComponentReferenceUtil.java
+++ /dev/null
@@ -1,957 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.wst.wsdl.Binding;
-import org.eclipse.wst.wsdl.BindingFault;
-import org.eclipse.wst.wsdl.BindingInput;
-import org.eclipse.wst.wsdl.BindingOperation;
-import org.eclipse.wst.wsdl.BindingOutput;
-import org.eclipse.wst.wsdl.Definition;
-import org.eclipse.wst.wsdl.Fault;
-import org.eclipse.wst.wsdl.Input;
-import org.eclipse.wst.wsdl.Message;
-import org.eclipse.wst.wsdl.Operation;
-import org.eclipse.wst.wsdl.Output;
-import org.eclipse.wst.wsdl.Part;
-import org.eclipse.wst.wsdl.Port;
-import org.eclipse.wst.wsdl.PortType;
-import org.eclipse.wst.wsdl.Service;
-import org.eclipse.wst.wsdl.WSDLElement;
-import org.eclipse.wst.wsdl.internal.impl.ImportImpl;
-import org.eclipse.wst.wsdl.internal.impl.WSDLElementImpl;
-import org.eclipse.wst.wsdl.ui.internal.extension.ITypeSystemProvider;
-import org.eclipse.wst.wsdl.util.WSDLConstants;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-public class ComponentReferenceUtil
-{
- protected Definition rootDefinition;
-
- public ComponentReferenceUtil(Definition rootDefinition)
- {
- this.rootDefinition = rootDefinition;
- }
-
- protected static boolean isEqual(String a, String b)
- {
- boolean result = false;
- if (a != null)
- {
- result = a.equals(b) || (a.length() == 0 && b == null);
- }
- else
- {
- result = (b == null || b.length() == 0);
- }
- return result;
- }
-
- protected static boolean isEqualInputName(Operation operation, BindingOperation bindingOperation)
- {
- boolean result = false;
- Input operationInput = operation.getEInput();
- BindingInput bindingOperationInput = bindingOperation.getEBindingInput();
-
- if (operationInput != null && bindingOperationInput != null)
- {
- result = isEqual(operationInput.getName(), bindingOperationInput.getName());
- }
- else if (operationInput == null && bindingOperationInput == null)
- {
- result = true;
- }
- return result;
- }
-
- protected static boolean isEqualOutputName(Operation operation, BindingOperation bindingOperation)
- {
- boolean result = false;
- Output operationOutput = operation.getEOutput();
- BindingOutput bindingOperationOutput = bindingOperation.getEBindingOutput();
-
- if (operationOutput != null && bindingOperationOutput != null)
- {
- result = isEqual(operationOutput.getName(), bindingOperationOutput.getName());
- }
- else if (operationOutput == null && bindingOperationOutput == null)
- {
- result = true;
- }
- return result;
- }
-
- protected static boolean isMatchingBinding(Operation operation, BindingOperation bindingOperation)
- {
- return isEqual(operation.getName(), bindingOperation.getName()) && isEqualInputName(operation, bindingOperation) && isEqualOutputName(operation, bindingOperation);
- }
-
- public List getPortsForPortType(PortType portType)
- {
- List list = new ArrayList();
- for (Iterator i = getServices().iterator(); i.hasNext();)
- {
- Service service = (Service) i.next();
- for (Iterator j = service.getEPorts().iterator(); j.hasNext();)
- {
- Port port = (Port) j.next();
- Binding binding = port.getEBinding();
- if (binding != null && binding.getEPortType() == portType)
- {
- list.add(port);
- }
- }
- }
- return list;
- }
-
- public List getPortsForBinding(Binding binding)
- {
- List list = new ArrayList();
- for (Iterator i = getServices().iterator(); i.hasNext();)
- {
- Service service = (Service) i.next();
- for (Iterator j = service.getEPorts().iterator(); j.hasNext();)
- {
- Port port = (Port) j.next();
- if (port.getEBinding() == binding)
- {
- list.add(port);
- }
- }
- }
- return list;
- }
-
- public List getBindingOperations(Operation operation)
- {
- List list = new ArrayList();
- String operationName = operation.getName();
-
- if (operationName != null)
- {
- PortType portType = getEnclosingPortType(operation);
- for (Iterator i = getBindings(portType).iterator(); i.hasNext();)
- {
- Binding binding = (Binding) i.next();
- BindingOperation bindingOperation = getBindingOperation(operation, binding);
- if (bindingOperation != null)
- {
- list.add(bindingOperation);
- }
- }
- }
- return list;
- }
-
- public BindingOperation getBindingOperation(Operation operation, Binding binding)
- {
- BindingOperation result = null;
- for (Iterator j = binding.getBindingOperations().iterator(); j.hasNext();)
- {
- BindingOperation bindingOperation = (BindingOperation) j.next();
- if (isMatchingBinding(operation, bindingOperation))
- {
- result = bindingOperation;
- break;
- }
- }
- return result;
- }
-
- public BindingInput getBindingInput(Input input, Binding binding)
- {
- BindingOperation bindingOperation = getBindingOperation((Operation) input.eContainer(), binding);
- return bindingOperation != null ? bindingOperation.getEBindingInput() : null;
- }
-
- public BindingOutput getBindingOutput(Output output, Binding binding)
- {
- BindingOperation bindingOperation = getBindingOperation((Operation) output.eContainer(), binding);
- return bindingOperation != null ? bindingOperation.getEBindingOutput() : null;
- }
-
- public BindingFault getBindingFault(Fault fault, Binding binding)
- {
- BindingFault result = null;
- String faultName = fault.getName();
- if (faultName != null)
- {
- BindingOperation bindingOperation = getBindingOperation((Operation) fault.eContainer(), binding);
- if (bindingOperation != null)
- {
- result = (BindingFault) bindingOperation.getBindingFault(faultName);
- }
- }
- return result;
- }
-
- public EObject getBindingObject(EObject interfaceObject, Binding binding)
- {
- EObject result = null;
- if (interfaceObject instanceof Input)
- {
- result = getBindingInput((Input) interfaceObject, binding);
- }
- else if (interfaceObject instanceof Output)
- {
- result = getBindingOutput((Output) interfaceObject, binding);
- }
- else if (interfaceObject instanceof Fault)
- {
- result = getBindingFault((Fault) interfaceObject, binding);
- }
- else if (interfaceObject instanceof Operation)
- {
- result = getBindingOperation((Operation) interfaceObject, binding);
- }
- else if (interfaceObject instanceof PortType)
- {
- result = binding;
- }
- return result;
- }
-
- public List getBindingInputs(Input input)
- {
- List list = new ArrayList();
- List operations = getBindingOperations((Operation) input.eContainer());
- for (Iterator i = operations.iterator(); i.hasNext();)
- {
- BindingOperation bindingOperation = (BindingOperation) i.next();
- if (bindingOperation.getBindingInput() != null)
- {
- list.add(bindingOperation.getBindingInput());
- }
- }
- return list;
- }
-
- public List getBindingOutputs(Output output)
- {
- List list = new ArrayList();
- Operation operation = (Operation) output.eContainer();
- if (operation != null)
- {
- List operations = getBindingOperations(operation);
- for (Iterator i = operations.iterator(); i.hasNext();)
- {
- BindingOperation bindingOperation = (BindingOperation) i.next();
- if (bindingOperation.getBindingOutput() != null)
- {
- list.add(bindingOperation.getBindingOutput());
- }
- }
- }
- return list;
- }
-
- public List getBindingFaults(Fault fault)
- {
- List list = new ArrayList();
- String faultName = fault.getName();
- if (faultName != null)
- {
- Operation operation = (Operation) fault.eContainer();
- if (operation != null)
- {
- List operations = getBindingOperations(operation);
- for (Iterator i = operations.iterator(); i.hasNext();)
- {
- BindingOperation bindingOperation = (BindingOperation) i.next();
- BindingFault bindingFault = (BindingFault) bindingOperation.getBindingFault(faultName);
- if (bindingFault != null)
- {
- list.add(bindingFault);
- }
- }
- }
- }
- return list;
- }
-
- protected PortType getEnclosingPortType(Operation operation)
- {
- return (PortType) operation.eContainer();
- }
-
- public List getBindings(Operation operation)
- {
- return getBindings(getEnclosingPortType(operation));
- }
-
- public List getBindings(PortType portType)
- {
- List list = new ArrayList();
- for (Iterator i = getDefinitions().iterator(); i.hasNext();)
- {
- Definition definition = (Definition) i.next();
- for (Iterator j = definition.getBindings().values().iterator(); j.hasNext();)
- {
- Binding binding = (Binding) j.next();
- if (portType == null || binding.getPortType() == portType)
- {
- list.add(binding);
- }
- }
- }
- return list;
- }
-
- public List getBindingsWithoutOperation(PortType portType, String operationName)
- {
- List result = new ArrayList();
- if (operationName != null)
- {
- List bindings = getBindings(portType);
- for (Iterator i = bindings.iterator(); i.hasNext();)
- {
- Binding binding = (Binding) i.next();
- boolean hasName = false;
- for (Iterator j = binding.getBindingOperations().iterator(); j.hasNext();)
- {
- BindingOperation bindingOperation = (BindingOperation) j.next();
- if (operationName.equals(bindingOperation.getName()))
- {
- hasName = true;
- break;
- }
- }
- if (!hasName)
- {
- result.add(binding);
- }
- }
- }
- return result;
- }
-
- public List getBindings()
- {
- return getBindings((PortType) null);
- }
-
- public List getBindingNames()
- {
- List list = new ArrayList();
- for (Iterator i = getBindings().iterator(); i.hasNext();)
- {
- Binding binding = (Binding) i.next();
- list.addAll(getPrefixedNames(binding.getQName()));
- }
- return list;
- }
-
- public List getPortTypeNames()
- {
- List list = new ArrayList();
- for (Iterator i = getDefinitions().iterator(); i.hasNext();)
- {
- Definition definition = (Definition) i.next();
- for (Iterator j = definition.getPortTypes().values().iterator(); j.hasNext();)
- {
- PortType portType = (PortType) j.next();
- list.addAll(getPrefixedNames(portType.getQName()));
- }
- }
- return list;
- }
-
- public List getServices()
- {
- List list = new ArrayList();
- for (Iterator i = getDefinitions().iterator(); i.hasNext();)
- {
- Definition definition = (Definition) i.next();
- list.addAll(definition.getEServices());
- }
- return list;
- }
-
- public List getPortTypes()
- {
- List list = new ArrayList();
- for (Iterator i = getDefinitions().iterator(); i.hasNext();)
- {
- Definition definition = (Definition) i.next();
- list.addAll(definition.getEPortTypes());
- }
- return list;
- }
-
- public List getMessages()
- {
- List list = new ArrayList();
- for (Iterator i = getDefinitions().iterator(); i.hasNext();)
- {
- Definition definition = (Definition) i.next();
- list.addAll(definition.getEMessages());
- }
- return list;
- }
-
- public List getTypes()
- {
- List list = new ArrayList();
- for (Iterator i = getDefinitions().iterator(); i.hasNext();)
- {
- Definition definition = (Definition) i.next();
- if (definition.getETypes() != null)
- {
- list.add(definition.getETypes());
- }
- }
- return list;
- }
-
- public List getMessageNames()
- {
- List list = new ArrayList();
- for (Iterator i = getDefinitions().iterator(); i.hasNext();)
- {
- Definition definition = (Definition) i.next();
- for (Iterator j = definition.getMessages().values().iterator(); j.hasNext();)
- {
- Message message = (Message) j.next();
- list.addAll(getPrefixedNames(message.getQName()));
- }
- }
- return list;
- }
-
- public List getDefinitions()
- {
- List list = new ArrayList();
- addDefinition(rootDefinition, list);
- return list;
- }
-
- /**
- * @deprecated -- we should always use getPrefixedNames
- */
- public String getPrefixedName(QName qname)
- {
- String name = null;
- if (qname != null)
- {
- String prefix = rootDefinition.getPrefix(qname.getNamespaceURI());
- if (prefix != null)
- {
- name = prefix + ":" + qname.getLocalPart();
- }
- }
- return name;
- }
-
- public List getPrefixedNames(QName qname)
- {
- List list = new ArrayList();
- if (qname != null)
- {
- Map map = rootDefinition.getNamespaces();
- for (Iterator i = map.keySet().iterator(); i.hasNext();)
- {
- String prefix = (String) i.next();
- String namespace = (String) map.get(prefix);
- if (namespace != null && namespace.equals(qname.getNamespaceURI()))
- {
- String name = prefix.length() > 0 ? prefix + ":" + qname.getLocalPart() :
- qname.getLocalPart();
- list.add(name);
- }
- }
- }
- return list;
- }
-
- protected void addDefinition(Definition definition, List list)
- {
- if (definition != null)
- {
- list.add(definition);
- for (Iterator i = definition.getEImports().iterator(); i.hasNext();)
- {
- ImportImpl theImport = (ImportImpl) i.next();
- if (theImport.getLocationURI() != null && !theImport.getLocationURI().endsWith("xsd"))
- {
- theImport.importDefinitionOrSchema();
- Definition importedDefinition = (Definition) theImport.getEDefinition();
- if (importedDefinition != null && !list.contains(importedDefinition))
- {
- addDefinition(importedDefinition, list);
- }
- }
- }
- }
- }
-
- public static String getPortTypeReference(Binding binding)
- {
- String result = null;
- Element element = WSDLEditorUtil.getInstance().getElementForObject(binding);
- if (element != null)
- {
- result = element.getAttribute("type");
- }
- return result;
- }
-
- public static void setPortTypeReference(Binding binding, String portType)
- {
- Element element = WSDLEditorUtil.getInstance().getElementForObject(binding);
- if (element != null)
- {
- element.setAttribute("type", portType);
- }
- }
-
- public static String getBindingReference(Port port)
- {
- String result = null;
- Element element = WSDLEditorUtil.getInstance().getElementForObject(port);
- if (element != null)
- {
- result = element.getAttribute("binding");
- }
- return result;
- }
-
- public static String getName(Binding binding)
- {
- String result = null;
- Element element = WSDLEditorUtil.getInstance().getElementForObject(binding);
- if (element != null)
- {
- result = element.getAttribute("name");
- }
- return result;
- }
-
- public static QName getPortTypeReferenceQName(Binding binding)
- {
- QName result = null;
- Definition definition = binding.getEnclosingDefinition();
- String prefixedName = getPortTypeReference(binding);
- if (prefixedName != null)
- {
- result = WSDLEditorUtil.createQName(definition, prefixedName);
- }
- return result;
- }
-
- public static QName getBindingReferenceQName(Port port)
- {
- QName result = null;
- Definition definition = port.getEnclosingDefinition();
- String prefixedName = getBindingReference(port);
- if (prefixedName != null)
- {
- result = WSDLEditorUtil.createQName(definition, prefixedName);
- }
- return result;
- }
-
- public static String getMessageReference(Input input)
- {
- return getMessageReferenceHelper(input);
- }
-
- public static String getMessageReference(Output output)
- {
- return getMessageReferenceHelper(output);
- }
-
- public static String getMessageReference(Fault fault)
- {
- return getMessageReferenceHelper(fault);
- }
-
- public static QName getMessageReferenceQName(Input input)
- {
- return getMessageReferenceQNameHelper(input);
- }
-
- public static QName getMessageReferenceQName(Output output)
- {
- return getMessageReferenceQNameHelper(output);
- }
-
- public static QName getMessageReferenceQName(Fault fault)
- {
- return getMessageReferenceQNameHelper(fault);
- }
-
- protected static String getMessageReferenceHelper(WSDLElement o)
- {
- String result = null;
- Element element = WSDLEditorUtil.getInstance().getElementForObject(o);
- if (element != null)
- {
- result = element.getAttribute("message");
- }
- return result;
- }
-
- public static QName getMessageReferenceQNameHelper(WSDLElement o)
- {
- QName result = null;
- Definition definition = o.getEnclosingDefinition();
- String prefixedName = getMessageReferenceHelper(o);
- if (prefixedName != null)
- {
- result = WSDLEditorUtil.createQName(definition, prefixedName);
- }
- return result;
- }
-
- public static void updatePortTypeReferences(Definition definition)
- {
- for (Iterator i = definition.getBindings().values().iterator(); i.hasNext();)
- {
- Binding binding = (Binding) i.next();
- QName qname = ComponentReferenceUtil.getPortTypeReferenceQName(binding);
-
- PortType portType = (qname != null) ? (PortType) definition.getPortType(qname) : null;
-
- if (binding.getPortType() != portType)
- {
- binding.setPortType(portType);
- }
- }
- }
-
- public static void updateBindingReferences(Definition definition)
- {
- for (Iterator i = definition.getServices().values().iterator(); i.hasNext();)
- {
- Service service = (Service) i.next();
- for (Iterator j = service.getEPorts().iterator(); j.hasNext();)
- {
- Port port = (Port) j.next();
- QName qname = ComponentReferenceUtil.getBindingReferenceQName(port);
-
- Binding binding = (qname != null) ? (Binding) definition.getBinding(qname) : null;
-
- if (port.getBinding() != binding)
- {
- port.setBinding(binding);
- }
- }
- }
- }
-
- public static void updateMessageReferences(Definition definition)
- {
- // for each port type
- //
- for (Iterator i = definition.getPortTypes().values().iterator(); i.hasNext();)
- {
- PortType portType = (PortType) i.next();
-
- // for each operation
- //
- for (Iterator j = portType.getEOperations().iterator(); j.hasNext();)
- {
- Operation operation = (Operation) j.next();
-
- // handle Input
- //
- Input input = (Input) operation.getInput();
- if (input != null)
- {
- QName qname = ComponentReferenceUtil.getMessageReferenceQName(input);
- Message message = (qname != null) ? (Message) definition.getMessage(qname) : null;
- if (input.getMessage() != message)
- {
- input.setMessage(message);
- }
- }
-
- // handle Output
- //
- Output output = (Output) operation.getOutput();
- if (output != null)
- {
- QName qname = ComponentReferenceUtil.getMessageReferenceQName(output);
- Message message = (qname != null) ? (Message) definition.getMessage(qname) : null;
- if (output.getMessage() != message)
- {
- output.setMessage(message);
- }
- }
-
- // handle Faults
- //
- for (Iterator k = operation.getEFaults().iterator(); k.hasNext();)
- {
- Fault fault = (Fault) k.next();
-
- QName qname = ComponentReferenceUtil.getMessageReferenceQName(fault);
- Message message = (qname != null) ? (Message) definition.getMessage(qname) : null;
- if (fault.getMessage() != message)
- {
- fault.setMessage(message);
- }
- }
- }
- }
- }
-
- public static void updateSchemaReferences(Definition definition)
- {
- for (Iterator i = definition.getEMessages().iterator(); i.hasNext();)
- {
- Message message = (Message) i.next();
- for (Iterator j = message.getEParts().iterator(); j.hasNext();)
- {
- Part part = (Part) j.next();
- Element element = WSDLEditorUtil.getInstance().getElementForObject(part);
- if (element != null)
- {
- ((WSDLElementImpl)part).elementChanged(element);
- }
- }
- }
- }
-
- public static Operation getOperation(PortType portType, BindingOperation bindingOperation)
- {
- Operation result = null;
- for (Iterator i = portType.getEOperations().iterator(); i.hasNext();)
- {
- Operation operation = (Operation) i.next();
- if (isMatchingBinding(operation, bindingOperation))
- {
- result = operation;
- break;
- }
- }
- return result;
- }
-
- public static void updateOperationReference(BindingOperation bindingOperation)
- {
- Operation operation = computeOperation(bindingOperation);
- if (operation != bindingOperation.getOperation())
- {
- bindingOperation.setOperation(operation);
- }
- }
-
- public List getComponentNameList(boolean isType)
- {
- List result = Collections.EMPTY_LIST;
- ITypeSystemProvider typeSystemProvider = WSDLEditorUtil.getInstance().getTypeSystemProvider(rootDefinition);
- if (typeSystemProvider != null)
- {
- result = isType ? typeSystemProvider.getAvailableTypeNames(rootDefinition, 0) : typeSystemProvider.getAvailableElementNames(rootDefinition);
- }
- return result;
- }
-
- public static List getComponentNameList(Part part, boolean isType)
- {
- List result = Collections.EMPTY_LIST;
- Definition definition = part.getEnclosingDefinition();
- ITypeSystemProvider typeSystemProvider = WSDLEditorUtil.getInstance().getTypeSystemProvider(definition);
- if (typeSystemProvider != null)
- {
- result = isType ? typeSystemProvider.getAvailableTypeNames(definition, 0) : typeSystemProvider.getAvailableElementNames(definition);
- }
- return result;
- }
-
- public static boolean isType(Part part)
- {
- //Element element = WSDLEditorUtil.getInstance().getElementForObject(part);
- Element element = part.getElement();
- return !element.hasAttribute("element");
- }
-
- public static String getPartComponentReference(Part part)
- {
- //Element element = WSDLEditorUtil.getInstance().getElementForObject(part);
- Element element = part.getElement();
- String result = null;
- if (element.hasAttribute("type"))
- {
- result = element.getAttribute("type");
- }
- else if (element.hasAttribute("element"))
- {
- result = element.getAttribute("element");
- }
- return result;
- }
-
- public static void setComponentReference(Part part, boolean isType, String componentName)
- {
- Element element = WSDLEditorUtil.getInstance().getElementForObject(part);
- String newAttribute = isType ? "type" : "element";
- String oldAttribute = isType ? "element" : "type";
- element.removeAttribute(oldAttribute);
-
- String value = componentName != null ? componentName : element.getAttribute(newAttribute);
-
- if (value == null)
- {
- if (isType)
- {
- String xsdPrefix = part.getEnclosingDefinition().getPrefix(WSDLConstants.XSD_NAMESPACE_URI);
- value = "string";
- if (xsdPrefix != null && xsdPrefix.length() > 0)
- {
- value = xsdPrefix + ":" + value;
- }
- }
- else
- {
- List list = getComponentNameList(part, isType);
- value = list.size() > 0 ? (String) list.get(0) : "some-element-name";
- }
- }
- element.setAttribute(newAttribute, value);
- }
-
- public static Operation computeOperation(BindingOperation bindingOperation)
- {
- Operation result = null;
- Binding binding = (Binding) bindingOperation.eContainer();
- PortType portType = (PortType) binding.getPortType();
- if (portType != null)
- {
- result = getOperation(portType, bindingOperation);
- }
- return result;
- }
-
- public static Input computeInput(BindingInput bindingInput)
- {
- Operation operation = computeOperation((BindingOperation) bindingInput.eContainer());
- return operation != null ? operation.getEInput() : null;
- }
-
- public static Output computeOutput(BindingOutput bindingOutput)
- {
- Operation operation = computeOperation((BindingOperation) bindingOutput.eContainer());
- return operation != null ? operation.getEOutput() : null;
- }
-
- public static Fault computeFault(BindingFault bindingFault)
- {
- Fault result = null;
- Operation operation = computeOperation((BindingOperation) bindingFault.eContainer());
- if (operation != null)
- {
- for (Iterator i = operation.getEFaults().iterator(); i.hasNext();)
- {
- Fault fault = (Fault) i.next();
- String faultName = fault.getName();
- if (faultName != null && faultName.equals(bindingFault.getName()))
- {
- result = fault;
- break;
- }
- }
- }
- return result;
- }
-
- public static String getPartReferenceValue(Part part)
- {
- Element element = WSDLEditorUtil.getInstance().getElementForObject(part);
- String value = null;
- if (element != null)
- {
- if (element.hasAttribute("type"))
- {
- value = element.getAttribute("type");
- }
- else if (element.hasAttribute("element"))
- {
- value = element.getAttribute("element");
- }
- }
- return value != null ? value : "";
- }
-
- public Operation getBindingOperation(Element bindingOperationContent)
- {
- Operation operation = null;
- Node parent = bindingOperationContent.getParentNode();
- if (parent instanceof Element)
- {
- Object object = WSDLEditorUtil.getInstance().findModelObjectForElement(rootDefinition, (Element) parent);
- if (object instanceof BindingOperation)
- {
- operation = ComponentReferenceUtil.computeOperation((BindingOperation) object);
- }
- }
- return operation;
- }
-
- public Message getBindingOperationInputMessage(Element bindingOperationContent)
- {
- Message message = null;
- Operation operation = getBindingOperation(bindingOperationContent);
- if (operation != null)
- {
- Input input = operation.getEInput();
- if (input != null)
- {
- message = input.getEMessage();
- }
- }
- return message;
- }
-
- public Message getBindingOperationOutputMessage(Element bindingOperationContent)
- {
- Message message = null;
- Operation operation = getBindingOperation(bindingOperationContent);
- if (operation != null)
- {
- Output output = operation.getEOutput();
- if (output != null)
- {
- message = output.getEMessage();
- }
- }
- return message;
- }
-
- public static String computeRelativeURI(IFile referencedLocation, IFile baseLocation, boolean enableIEStyleReferences)
- {
- // TODO... we need some extension to allow IE folks to plugin logic to create an 'IE' style path
- // TODO... consider using URI class in EMF
- return URIHelper.getRelativeURI(referencedLocation.getLocation(), baseLocation.getLocation());
- }
-
- public static String computeRelativeURI(String referencedLocation, String baseLocation, boolean enableIEStyleReferences)
- {
- // TODO... we need some extension to allow IE folks to plugin logic to create an 'IE' style path
- // TODO... consider using URI class in EMF
- return URIHelper.getRelativeURI(referencedLocation, baseLocation);
- }
-}
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/CreateWSDLElementHelper.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/CreateWSDLElementHelper.java
deleted file mode 100644
index 5e4eb0218..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/CreateWSDLElementHelper.java
+++ /dev/null
@@ -1,351 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.wsdl.Binding;
-import org.eclipse.wst.wsdl.Definition;
-import org.eclipse.wst.wsdl.Fault;
-import org.eclipse.wst.wsdl.Input;
-import org.eclipse.wst.wsdl.Message;
-import org.eclipse.wst.wsdl.MessageReference;
-import org.eclipse.wst.wsdl.Operation;
-import org.eclipse.wst.wsdl.Output;
-import org.eclipse.wst.wsdl.Part;
-import org.eclipse.wst.wsdl.Port;
-import org.eclipse.wst.wsdl.PortType;
-import org.eclipse.wst.wsdl.Service;
-import org.eclipse.wst.wsdl.WSDLElement;
-import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement;
-import org.eclipse.wst.wsdl.internal.impl.MessageReferenceImpl;
-import org.eclipse.wst.wsdl.internal.impl.WSDLElementImpl;
-import org.eclipse.wst.wsdl.ui.internal.commands.AddBindingCommand;
-import org.eclipse.wst.wsdl.ui.internal.commands.AddFaultCommand;
-import org.eclipse.wst.wsdl.ui.internal.commands.AddInputCommand;
-import org.eclipse.wst.wsdl.ui.internal.commands.AddMessageCommand;
-import org.eclipse.wst.wsdl.ui.internal.commands.AddOperationCommand;
-import org.eclipse.wst.wsdl.ui.internal.commands.AddOutputCommand;
-import org.eclipse.wst.wsdl.ui.internal.commands.AddPartCommand;
-import org.eclipse.wst.wsdl.ui.internal.commands.AddPortCommand;
-import org.eclipse.wst.wsdl.ui.internal.commands.AddPortTypeCommand;
-import org.eclipse.wst.wsdl.ui.internal.commands.AddServiceCommand;
-import org.eclipse.wst.wsdl.ui.internal.commands.AddXSDElementDeclarationCommand;
-import org.eclipse.wst.wsdl.util.WSDLConstants;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDSchema;
-import org.w3c.dom.Element;
-
-public class CreateWSDLElementHelper {
- // Constants used for getting Part information
- public static final String PART_INFO_ELEMENT_DECLARATION = "ELEMENT_DECLARATION";
- public static final String PART_INFO_TYPE_DEFINITION = "TYPE_DEFINITION";
-
- // The following variables should be set if a name other than the computed name is to be used.
- public static String serviceName = null;
- public static String portName = null;
- public static String bindingName = null;
- public static String portTypeName = null;
- public static String operationName = null;
- public static String inputName = null;
- public static String outputName = null;
- public static String faultName = null;
- public static String messageName = null;
- public static String partName = null;
-
- public static String PART_TYPE_OR_DEFINITION = PART_INFO_TYPE_DEFINITION;
- public static boolean CREATE_DOWN_TO_PART = true;
-
-/*
- * The following methods creates the 'specified' (by calling a certain method) WSDLElement
- * and it's 'children' all the way to the PortType level.
- */
- public static Service createService(Definition definition) {
- if (serviceName == null || serviceName.trim().equals(""))
- serviceName = NameUtil.buildUniqueServiceName(definition);
-
- CreateWSDLElementHelper.portTypeName = serviceName;
-
- AddServiceCommand addService = new AddServiceCommand(definition, serviceName, false);
- addService.run();
- Service service = (Service) addService.getWSDLElement();
- CreateWSDLElementHelper.createPort(service);
-
- return service;
- }
-
- public static Port createPort(Service service) {
- if (portName == null || portName.trim().equals(""))
- portName = NameUtil.buildUniquePortName(service, null);
-
- AddPortCommand addPort = new AddPortCommand(service, portName);
- addPort.run();
- Port port = (Port) addPort.getWSDLElement();
- Binding binding = CreateWSDLElementHelper.createBinding(port.getEnclosingDefinition(), port);
-
- port.setBinding(binding);
-
- return port;
- }
-
- public static Binding createBinding(Definition definition, Port port) {
- bindingName = port.getName();
- if (bindingName == null || bindingName.trim().equals(""))
- bindingName = NameUtil.buildUniqueBindingName(definition, null);
-
- AddBindingCommand addBinding = new AddBindingCommand(definition, bindingName);
- addBinding.run();
- Binding binding = (Binding) addBinding.getWSDLElement();
- PortType portType = CreateWSDLElementHelper.createPortType(binding.getEnclosingDefinition());
-
- binding.setPortType(portType);
-
- return binding;
- }
-
- public static PortType createPortType(Definition definition) {
- if (portTypeName == null || portTypeName.trim().equals(""))
- portTypeName = NameUtil.buildUniquePortTypeName(definition, "PortType");
-
- AddPortTypeCommand addPortTypeCommand = new AddPortTypeCommand(definition, portTypeName);
- addPortTypeCommand.run();
- PortType portType = (PortType) addPortTypeCommand.getWSDLElement();
-
- if (CREATE_DOWN_TO_PART) {
- CreateWSDLElementHelper.createOperation(portType);
- }
-
- return portType;
- }
-
-
-/*
- * The following methods creates the 'specified' (by calling a certain method) WSDLElement
- * and it's 'children' all the way to the Part level.
- */
- public static Operation createOperation(PortType portType) {
- if (operationName == null || operationName.trim().equals(""))
- operationName = NameUtil.buildUniqueOperationName(portType);
-
- AddOperationCommand action = new AddOperationCommand(portType, operationName);
- action.run();
- Operation operation = (Operation) action.getWSDLElement();
- CreateWSDLElementHelper.createOutput(portType, operation);
- CreateWSDLElementHelper.createInput(portType, operation, null);
-
-// ((PortTypeImpl) portType).updateElement(false);
- return operation;
- }
-
- public static Input createInput(PortType portType, Operation operation, String inputName) {
- if (inputName == null || inputName.trim().equals(""))
- inputName = NameUtil.buildUniqueInputName(portType, operation.getName(), "");
-
- AddInputCommand action = new AddInputCommand(operation, inputName);
- action.run();
- Input input = (Input) action.getWSDLElement();
- Message mess = CreateWSDLElementHelper.createMessage(input);
- input.setMessage(mess);
-
- return input;
- }
-
- public static Output createOutput(PortType portType, Operation operation) {
- if (outputName == null || outputName.trim().equals(""))
- outputName = NameUtil.buildUniqueOutputName(portType, operation.getName(), "");
-
- AddOutputCommand action = new AddOutputCommand(operation, outputName);
- action.run();
- Output output = (Output) action.getWSDLElement();
- Message mess = CreateWSDLElementHelper.createMessage(output);
- output.setMessage(mess);
-
- return output;
- }
-
- public static Fault createFault(Operation operation) {
- if (faultName == null || faultName.trim().equals(""))
- faultName = NameUtil.buildUniqueFaultName(operation);
-
- AddFaultCommand action = new AddFaultCommand(operation, faultName);
- action.run();
- Fault fault = (Fault) action.getWSDLElement();
- Message mess = CreateWSDLElementHelper.createMessage(fault);
- fault.setMessage(mess);
-
- return fault;
- }
-
- public static Message createMessage(MessageReference iof) {
- if (messageName == null || messageName.trim().equals(""))
- messageName = NameUtil.buildUniqueMessageName(iof.getEnclosingDefinition(), iof);
-// messageName = NameUtil.buildMessageName(iof.getName());
-
- Definition def = iof.getEnclosingDefinition();
- AddMessageCommand action = new AddMessageCommand(def, messageName);
- action.run();
- Message message = (Message) action.getWSDLElement();
- CreateWSDLElementHelper.createPart(message);
- Element parentNode = message.getElement();
- if (parentNode instanceof IDOMNode)
- {
- // format selected node
- FormatProcessorXML formatProcessorXML = new FormatProcessorXML();
- formatProcessorXML.formatNode((IDOMNode)parentNode);
- }
-
- messageName = null;
- return message;
- }
-
- public static Part createPart(Message message) {
- Definition def = message.getEnclosingDefinition();
- String name = NameUtil.buildUniquePartName(message, message.getQName().getLocalPart());
- AddPartCommand action = null;
-
- if (PART_TYPE_OR_DEFINITION == PART_INFO_TYPE_DEFINITION) {
- action = new AddPartCommand(message, name, WSDLConstants.SCHEMA_FOR_SCHEMA_URI_2001, "string", true);
- }
- else if (PART_TYPE_OR_DEFINITION == PART_INFO_ELEMENT_DECLARATION) {
- //action = new AddPartCommand(message, name, WSDLConstants.SCHEMA_FOR_SCHEMA_URI_2001, "string", true);
- String elementName = getNewNameHelper(name, def, false);
- AddXSDElementDeclarationCommand elementAction = new AddXSDElementDeclarationCommand(def, elementName);
- elementAction.run();
- action = new AddPartCommand(message, name, def.getTargetNamespace(), elementName, false);
- }
-
- action.run();
-
- return (Part) action.getWSDLElement();
- }
-
- /*
- * Used to determine a name for an Element
- */
- private static String getNewNameHelper(String base, Definition def, boolean isType)
- {
- String name = base;
- int count = 0;
-
- // Ugly.... Redo this...
- // Get a list of Elements...
- List elementList = null;
- if (def.getETypes() != null) {
- List xsdsList = def.getETypes().getEExtensibilityElements();
- if (xsdsList != null) {
- Iterator xsdsIterator = xsdsList.iterator();
- XSDSchemaExtensibilityElement xsdElement = (XSDSchemaExtensibilityElement) xsdsIterator.next();
- XSDSchema schema = xsdElement.getSchema();
- if (schema != null) {
- elementList = schema.getElementDeclarations();
- }
- }
- }
-
- if (elementList != null) {
- int index = 0;
- while (index < elementList.size()) {
- XSDElementDeclaration elementDeclaration = (XSDElementDeclaration) elementList.get(index);
-
- if (name.equals(elementDeclaration.getName())) {
- count++;
- name = name + count;
- index = 0;
- }
- else {
- index++;
- }
- }
- }
-
- return name;
- }
-
- /*
- * Return the type of Part this WSDLElement should have (Element vs Type). To determine this, we filter up to the 'parent' PortType
- * and go down to the first Part we encounter and check the type it has. If this fails, default to Type.
- */
- public static String getPartInfo(WSDLElement element) {
- String partInfo = null;
-
- if (element instanceof PortType) {
- partInfo = getPartInfo((PortType) element);
- }
- else if (element instanceof Operation) {
- partInfo = getPartInfo(((WSDLElementImpl) element).getContainer());
- }
- else if (element instanceof MessageReferenceImpl) {
- partInfo = getPartInfo(((WSDLElementImpl) element).getContainer());
- }
-
- if (partInfo == null) {
- partInfo = CreateWSDLElementHelper.PART_INFO_TYPE_DEFINITION;
- }
-
- return partInfo;
- }
-
- private static String getPartInfo(PortType portType) {
- String partInfo = null;
-
- if (portType.getOperations() != null) {
- Iterator operationIt = portType.getOperations().iterator();
- while (operationIt.hasNext()) {
- Operation op = (Operation) operationIt.next();
-
- if (op.getEInput() != null) {
- partInfo = getMessageRefPartInfo((MessageReferenceImpl) op.getEInput());
- }
-
- if (partInfo == null && op.getEOutput() != null) {
- partInfo = getMessageRefPartInfo((MessageReferenceImpl) op.getEOutput());
- }
-
- if (op.getEFaults() != null) {
- Iterator faultIt = op.getEFaults().iterator();
- while (partInfo == null && faultIt.hasNext()) {
- Fault fault = (Fault) faultIt.next();
- partInfo = getMessageRefPartInfo((MessageReferenceImpl) fault);
- }
- }
-
- if (partInfo != null)
- break;
- }
- }
-
- return partInfo;
- }
-
- private static String getMessageRefPartInfo(MessageReferenceImpl iof) {
- String partInfo = null;
-
- if (iof.getEMessage() != null && iof.getEMessage().getEParts() != null) {
- Iterator partIt = iof.getEMessage().getEParts().iterator();
-
- while (partInfo == null && partIt.hasNext()) {
- Part part = (Part) partIt.next();
-
- if (part.getTypeDefinition() != null) {
- partInfo = CreateWSDLElementHelper.PART_INFO_TYPE_DEFINITION;
- }
- else if (part.getElementDeclaration() != null) {
- partInfo = CreateWSDLElementHelper.PART_INFO_ELEMENT_DECLARATION;
- }
- }
- }
-
- return partInfo;
- }
-}
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/NameUtil.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/NameUtil.java
deleted file mode 100644
index 1778c8c9d..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/NameUtil.java
+++ /dev/null
@@ -1,427 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.wst.wsdl.Binding;
-import org.eclipse.wst.wsdl.Definition;
-import org.eclipse.wst.wsdl.Fault;
-import org.eclipse.wst.wsdl.Input;
-import org.eclipse.wst.wsdl.Message;
-import org.eclipse.wst.wsdl.MessageReference;
-import org.eclipse.wst.wsdl.Operation;
-import org.eclipse.wst.wsdl.Output;
-import org.eclipse.wst.wsdl.Part;
-import org.eclipse.wst.wsdl.Port;
-import org.eclipse.wst.wsdl.PortType;
-import org.eclipse.wst.wsdl.Service;
-
-public class NameUtil
-{
- /**
- * Return a name which is not used by any other fault in the operation.
- * @return String
- */
- public static String buildUniqueFaultName(Operation operation)
- {
- return buildUniqueFaultName(operation, "NewFault");
- }
-
- public static String buildUniqueFaultName(Operation operation, String baseName) {
- if (baseName == null)
- baseName = "NewFault";
-
- List names = getUsedFaultNames(operation);
-
- // Now search the list until we find an unused name
- return getUniqueNameHelper(baseName, names);
- }
-
- /**
- * Return a name which is not used by any other input in the portType. Returned name will be of the form:
- * <operationName> + <ending> [+ unique Integer]
- * @return String
- */
- public static String buildUniqueInputName(PortType portType, String operationName, String ending)
- {
- String name = null;
- String candidate = operationName + ending;
-
- int i = 0;
-
- // loop until we find a unique name (the name will consist of the operationName + ending + an integer)
- while (name == null)
- {
- boolean unique = true;
-
- // determine if this combination is unique within the current porttype
- for (Iterator it = portType.getEOperations().iterator(); it.hasNext() && unique;)
- {
- Operation current = (Operation) it.next();
- // TODO : port check
- // old if(current.isSetEInput() && current.getEInput().isSetName()) {
- if (current.getEInput() != null && current.getEInput().getName() != null)
- {
- if (current.getEInput().getName().equals(candidate))
- unique = false;
- }
- }
- if (unique)
- name = candidate;
- else
- candidate = operationName + ending + i;
- i++;
- }
- return name;
- }
-
- /**
- * Return a name which is not used by any other message in the definition.
- * @return String
- */
- public static String buildUniqueMessageName(Definition definition, String baseName)
- {
- if (baseName == null)
- {
- baseName = "NewMessage";
- }
-
- List names = getUsedMessageNames(definition);
-
- // Now search the list until we find an unused name
- return getUniqueNameHelper(baseName, names);
- }
-
- /**
- * Return a name which is not used by any other operation in the port type.
- * @return String
- */
- public static String buildUniqueOperationName(PortType portType)
- {
- return buildUniqueOperationName(portType, "NewOperation");
- }
-
- public static String buildUniqueOperationName(PortType portType, String baseName)
- {
- if (baseName == null) {
- baseName = "NewOperation";
- }
-
- List names = getUsedOperationNames(portType);
-
- // Now search the list until we find an unused name
- return getUniqueNameHelper(baseName, names);
- }
-
- /**
- * Return a name which is not used by any other output in the portType. Returned name will be of the form:
- * <operationName> + <ending> [+ unique Integer]
- * @return String
- */
- public static String buildUniqueOutputName(PortType portType, String operationName, String ending)
- {
- String name = null;
- String candidate = operationName + ending;
-
- int i = 0;
-
- // loop until we find a unique name (the name will consist of the operationName + ending + an integer)
- while (name == null)
- {
- boolean unique = true;
-
- // determine if this combination is unique within the current porttype
- for (Iterator it = portType.getEOperations().iterator(); it.hasNext() && unique;)
- {
- Operation current = (Operation) it.next();
- // TODO: port check
- // old if(current.isSetEOutput() && current.getEOutput().isSetName()) {
- if (current.getEOutput() != null && current.getEOutput().getName() != null)
- {
- if (current.getEOutput().getName().equals(candidate))
- unique = false;
- }
- }
- if (unique)
- name = candidate;
- else
- candidate = operationName + ending + i;
- i++;
- }
- return name;
- }
-
- /**
- * Return a name which is not used by any other part in the message.
- * @return String
- */
- public static String buildUniquePartName(Message message)
- {
- List names = getUsedPartNames(message);
-
- // Now search the list until we find an unused name
- return getUniqueNameHelper("NewPart", names);
- }
-
- public static String buildUniquePartName(Message message, String baseName)
- {
- if (baseName == null)
- {
- baseName = "NewPart";
- }
-
- List names = getUsedPartNames(message);
-
- // Now search the list until we find an unused name
- return getUniqueNameHelper(baseName, names);
- }
-
- /**
- * Return a name which is not used by any other port type in the definition.
- * @return String
- */
- public static String buildUniquePortTypeName(Definition definition, String baseName)
- {
- if (baseName == null)
- {
- baseName = "NewPortType";
- }
-
- List names = getUsedPortTypeNames(definition);
-
- // Now search the list until we find an unused name
- return getUniqueNameHelper(baseName, names);
- }
-
- public static String getUniqueNameHelper(String baseName, List names)
- {
- int i = 0;
-
- String name = baseName;
- while (true)
- {
- if (!names.contains(name))
- {
- break;
- }
- i++;
- name = baseName + i;
- }
-
- return name;
- }
-
- /**
- * Return a name which is not used by any other service in the definition.
- * @return String
- */
- public static String buildUniqueServiceName(Definition definition)
- {
- List names = getUsedServiceNames(definition);
-
- // Now search the list until we find an unused name
- return getUniqueNameHelper("NewService", names);
- }
-
- /**
- * Return a name which is not used by any other binding in the definition.
- * @return String
- */
- public static String buildUniqueBindingName(Definition definition, String baseName)
- {
- if (baseName == null)
- {
- baseName = "NewBinding";
- }
-
- List names = getUsedBindingNames(definition);
-
- return getUniqueNameHelper(baseName, names);
- }
-
- public static String buildUniquePrefix(Definition definition, String basePrefix)
- {
- String prefix = basePrefix;
- for (int i = 1; definition.getNamespace(prefix) != null; i++)
- {
- prefix = basePrefix + i;
- }
- return prefix;
- }
-
- public static String buildUniquePortName(Service service, String baseName)
- {
- if (baseName == null)
- {
- baseName = "NewPort";
- }
-
- List names = getUsedPortNames(service);
-
- return getUniqueNameHelper(baseName, names);
- }
-
- public static String buildUniqueMessageName(Definition definition, MessageReference messRef)
- {
- String name = null;
- if (messRef instanceof Input)
- {
- name = createOperationName(messRef, "Request");
- }
- else if (messRef instanceof Output)
- {
- name = createOperationName(messRef, "Response");
- }
- else if (messRef instanceof Fault)
- {
- String faultName = ((Fault) messRef).getName();
- if (faultName == null || faultName.length() == 0)
- {
- faultName = "Fault";
- }
- name = createOperationName(messRef, faultName);
- }
-
- return NameUtil.buildUniqueMessageName(definition, name);
- }
-
-
- public static List getUsedFaultNames(Operation operation) {
- ArrayList names = new ArrayList();
- for (Iterator i = operation.getEFaults().iterator(); i.hasNext();)
- {
- Fault fault = (Fault) i.next();
- names.add(fault.getName());
- }
-
- return names;
- }
-
- public static List getUsedOperationNames(PortType portType) {
- ArrayList names = new ArrayList();
- for (Iterator i = portType.getEOperations().iterator(); i.hasNext();)
- {
- Operation op = (Operation) i.next();
- names.add(op.getName());
- }
-
- return names;
- }
-
- public static List getUsedPartNames(Message message) {
- ArrayList names = new ArrayList();
- for (Iterator i = message.getEParts().iterator(); i.hasNext();)
- {
- Part part = (Part) i.next();
- names.add(part.getName());
- }
- return names;
- }
-
- public static List getUsedPortTypeNames(Definition definition) {
- ArrayList names = new ArrayList();
- for (Iterator i = definition.getEPortTypes().iterator(); i.hasNext();)
- {
- PortType portType = (PortType) i.next();
- // TODO: port check
- // if (portType.isSetQName())
- if (portType.getQName() != null)
- {
- names.add(portType.getQName().getLocalPart());
- }
- }
-
- return names;
-
- }
- public static List getUsedServiceNames(Definition definition) {
- // First build a list of names already used
- ArrayList names = new ArrayList();
- for (Iterator i = definition.getEServices().iterator(); i.hasNext();)
- {
- Service service = (Service) i.next();
- // TODO: port check
- // if(service.isSetQName())
- if (service.getQName() != null)
- names.add(service.getQName().getLocalPart());
- }
-
- return names;
- }
-
- public static List getUsedMessageNames(Definition definition) {
- ArrayList names = new ArrayList();
- for (Iterator i = definition.getEMessages().iterator(); i.hasNext();)
- {
- Message msg = (Message) i.next();
- // TODO: port check
- if (msg.getQName() != null)
- // if(msg.isSetQName())
- names.add(msg.getQName().getLocalPart());
- }
-
- return names;
- }
-
- public static List getUsedBindingNames(Definition definition) {
- ArrayList names = new ArrayList();
- for (Iterator i = definition.getEBindings().iterator(); i.hasNext();)
- {
- Binding binding = (Binding) i.next();
- // TODO: port check
- // if (binding.isSetQName())
- if (binding.getQName() != null)
- {
- names.add(binding.getQName().getLocalPart());
- }
- }
-
- return names;
- }
-
- public static List getUsedPortNames(Service service) {
- // First build a list of names already used
- ArrayList names = new ArrayList();
- for (Iterator i = service.getEPorts().iterator(); i.hasNext();)
- {
- Port port = (Port) i.next();
-
- if (port.getName() != null)
- {
- names.add(port.getName());
- }
- }
-
- return names;
- }
-
- private static String createOperationName(Object object, String suffix)
- {
- String result = null;
- if (object instanceof EObject)
- {
- EObject parent = ((EObject)object).eContainer();
- if (parent instanceof Operation)
- {
- result = ((Operation)parent).getName();
- }
- }
- if (result != null)
- {
- result += suffix;
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/NodeAssociationManager.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/NodeAssociationManager.java
deleted file mode 100644
index 144c9ad3d..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/NodeAssociationManager.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin;
-import org.eclipse.wst.wsdl.ui.internal.extension.INodeAssociationProvider;
-import org.eclipse.wst.wsdl.ui.internal.extension.WSDLEditorExtension;
-import org.eclipse.wst.wsdl.ui.internal.extension.WSDLEditorExtensionRegistry;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-public class NodeAssociationManager
-{
- protected WSDLEditorExtension[] extensions;
- protected INodeAssociationProvider[] providers;
-
- public NodeAssociationManager()
- {
- WSDLEditorExtensionRegistry registry = WSDLEditorPlugin.getInstance().getWSDLEditorExtensionRegistry();
- extensions = registry.getRegisteredExtensions(WSDLEditorExtension.NODE_ASSOCIATION_PROVIDER);
- providers = new INodeAssociationProvider[extensions.length];
- for (int i = 0; i < extensions.length; i++)
- {
- providers[i] = (INodeAssociationProvider)extensions[i].createExtensionObject(WSDLEditorExtension.NODE_ASSOCIATION_PROVIDER, null);
- }
- }
-
- protected INodeAssociationProvider getAppicableProvider(Object object)
- {
- INodeAssociationProvider provider = null;
- for (int i = 0; i < extensions.length; i++)
- {
- if (extensions[i].isApplicable(object))
- {
- provider = providers[i];
- if (provider != null)
- {
- break;
- }
- }
- }
- return provider;
- }
-
-
- public Object getModelObjectForNode(Object rootObject, Element targetNode)
- {
- int currentIndex = 0;
-
- Element[] elementChain = getParentElementChain((Element)targetNode);
-
- INodeAssociationProvider p = getAppicableProvider(rootObject);
- if (p != null)
- {
- Node rootObjectNode = p.getNode(rootObject);
-
- while (currentIndex < elementChain.length)
- {
- Element e = elementChain[currentIndex];
- if (e == rootObjectNode)
- {
- currentIndex++;
- break;
- }
- currentIndex++;
- }
- }
-
- Object currentObject = rootObject;
- int end[] = new int[1];
-
- while (currentIndex < elementChain.length)
- {
- p = getAppicableProvider(currentObject);
- if (p != null)
- {
- end[0] = elementChain.length;
- currentObject = p.getModelObject(currentObject, elementChain, currentIndex, end);
-
- if (currentObject == null)
- {
- // failure
- break;
- }
- else
- {
- currentIndex = Math.max(end[0], currentIndex + 1);
- }
- }
- else
- {
- break;
- }
- }
-
- return (currentIndex == elementChain.length) ? currentObject : null;
- }
-
-
- public Node getNode(Object modelObject)
- {
- Node result = null;
- if (modelObject instanceof Node)
- {
- result = (Node)modelObject;
- }
- else
- {
- INodeAssociationProvider p = getAppicableProvider(modelObject);
- if (p != null)
- {
- result = p.getNode(modelObject);
- }
- }
- return result;
- }
-
- protected Element[] getParentElementChain(Element element)
- {
- List list = new ArrayList();
- while (element != null)
- {
- list.add(0, element);
- Node node = element.getParentNode();
- element = (node != null && node.getNodeType() == Node.ELEMENT_NODE) ? (Element)node : null;
- }
-
- int listSize = list.size();
- Element[] result = new Element[listSize];
- for (int i = 0; i < listSize; i++)
- {
- result[i] = (Element)list.get(i);
- }
- return result;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/OpenOnSelectionHelper.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/OpenOnSelectionHelper.java
deleted file mode 100644
index 8a0256c20..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/OpenOnSelectionHelper.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util;
-
-import java.lang.reflect.Method;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.wst.wsdl.Binding;
-import org.eclipse.wst.wsdl.Definition;
-import org.eclipse.wst.wsdl.Fault;
-import org.eclipse.wst.wsdl.Import;
-import org.eclipse.wst.wsdl.Input;
-import org.eclipse.wst.wsdl.Output;
-import org.eclipse.wst.wsdl.Part;
-import org.eclipse.wst.wsdl.Port;
-import org.eclipse.wst.wsdl.WSDLElement;
-import org.eclipse.wst.wsdl.internal.impl.ImportImpl;
-import org.eclipse.wst.wsdl.internal.util.WSDLSwitch;
-import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin;
-import org.eclipse.wst.wsdl.util.WSDLConstants;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-public class OpenOnSelectionHelper extends WSDLSwitch
-{
- Definition definition;
- Attr attr = null;
- Element element = null;
-
- public OpenOnSelectionHelper(Definition definition)
- {
- this.definition = definition;
- }
-
- public void openEditor(EObject eObject)
- {
- String[] array = computeSpecification(eObject);
- if (array != null)
- {
- openEditor(array[0], array[1]);
- }
- }
-
- public void openEditor(Node node)
- {
- String[] array = computeSpecification(node);
- if (array != null)
- {
- openEditor(array[0], array[1]);
- }
- }
-
- protected void openEditor(String resource, String spec)
- {
- String pattern = "platform:/resource";
- if (resource != null && resource.startsWith(pattern))
- {
- try
- {
- Path path = new Path(resource.substring(pattern.length()));
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
-
- IWorkbenchPage workbenchPage = WSDLEditorPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getActivePage();
- IEditorPart editorPart = workbenchPage.getActiveEditor();
-
- if (editorPart.getEditorInput() instanceof IFileEditorInput &&
- ((IFileEditorInput)editorPart.getEditorInput()).getFile().equals(file))
- {
- workbenchPage.getNavigationHistory().markLocation(editorPart);
- }
- else
- {
- try
- {
- if (resource.endsWith("xsd"))
- {
- editorPart = workbenchPage.openEditor(new FileEditorInput(file), WSDLEditorPlugin.XSD_EDITOR_ID);
- }
- else
- {
- // Since we are already in the wsdleditor
- editorPart = workbenchPage.openEditor(new FileEditorInput(file), editorPart.getEditorSite().getId());
- }
- }
- catch (PartInitException initEx)
- {
- }
- }
-
- Class theClass = editorPart.getClass();
- Class[] methodArgs = { String.class };
- Method method = theClass.getMethod("openOnSelection", methodArgs);
- Object args[] = { spec };
- method.invoke(editorPart, args);
- workbenchPage.getNavigationHistory().markLocation(editorPart);
- }
- catch (Exception e)
- {
- }
- }
- }
-
- public String[] computeSpecification(EObject eObject)
- {
- String[] result = null;
- Object referencedObject = doSwitch(eObject);
- if (referencedObject instanceof EObject)
- {
- EObject referencedEObject = (EObject)referencedObject;
- if (referencedEObject != eObject ||
- referencedEObject.eResource() != definition.eResource())
- {
-
- Resource resource = referencedEObject.eResource();
- if (resource != null)
- {
- result = new String[2];
- result[0] = resource.getURI().toString();
- result[1] = resource.getURIFragment(referencedEObject);
- }
- }
- }
- return result;
- }
-
- public String[] computeSpecification(Node node)
- {
- String[] result = null;
- switch (node.getNodeType())
- {
- case Node.ELEMENT_NODE :
- {
- element = (Element)node;
- break;
- }
- case Node.ATTRIBUTE_NODE :
- {
- attr = (Attr)node;
- element = attr.getOwnerElement();
- break;
- }
- case Node.TEXT_NODE :
- {
- Node parent = node.getParentNode();
- element = (parent instanceof Element) ? (Element)parent : null;
- break;
- }
- }
- if (element != null)
- {
- Object object = WSDLEditorUtil.getInstance().findModelObjectForElement(definition, element);
- if (object instanceof EObject)
- {
- result = computeSpecification((EObject)object);
- }
- }
- return result;
- }
-
- public Object caseBinding(Binding binding)
- {
- Object result = binding;
- if (isMatchingAttribute(WSDLConstants.TYPE_ATTRIBUTE))
- {
- result = binding.getEPortType();
- }
- return result;
- }
-
- public Object caseDefinition(Definition definition)
- {
- return definition;
- }
-
- public Object casePart(Part part)
- {
- Object result = part;
- if (attr != null)
- {
- if (isMatchingAttribute(WSDLConstants.TYPE_ATTRIBUTE))
- {
- result = part.getTypeDefinition();
- }
- else if (isMatchingAttribute(WSDLConstants.ELEMENT_ATTRIBUTE))
- {
- result = part.getElement();
- }
- }
- else if (part.getEnclosingDefinition() == definition)
- {
- result = part.getTypeDefinition() != null ? (Object)part.getTypeDefinition() : (Object)part.getElement();
- }
- return result;
- }
-
- public Object casePort(Port port)
- {
- Object result = port;
- if (isMatchingAttribute(WSDLConstants.BINDING_ATTRIBUTE))
- {
- result = port.getEBinding();
-
- }
- return result;
- }
-
- public Object caseFault(Fault fault)
- {
- Object result = fault;
- if (isMatchingAttribute(WSDLConstants.MESSAGE_ATTRIBUTE))
- {
- result = fault.getMessage();
- }
- return result;
- }
-
- public Object caseInput(Input input)
- {
- Object result = input;
- if (isMatchingAttribute(WSDLConstants.MESSAGE_ATTRIBUTE))
- {
- result = input.getMessage();
- }
- return result;
- }
-
- public Object caseOutput(Output output)
- {
- Object result = output;
-
- if (isMatchingAttribute(WSDLConstants.MESSAGE_ATTRIBUTE))
- {
- result = output.getMessage();
- }
- return result;
- }
-
- public Object caseImport(Import theImport)
- {
- Object result = theImport.getEDefinition();
- if (result == null)
- {
- result = theImport.getESchema();
- if (result == null)
- {
- // Need to resolve imports because the model doesn't automatically
- // do it for us
- ((ImportImpl)theImport).importDefinitionOrSchema();
- result = theImport.getESchema();
- }
- }
- return result;
- }
-
- public Object caseWSDLElement(WSDLElement wsdlElement)
- {
- return wsdlElement;
- }
-
- private boolean isMatchingAttribute(String value)
- {
- return attr != null && value.equals(attr.getName());
- }
-
-}
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ReferenceManager.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ReferenceManager.java
deleted file mode 100644
index 8f4153964..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ReferenceManager.java
+++ /dev/null
@@ -1,363 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.wst.wsdl.Binding;
-import org.eclipse.wst.wsdl.BindingFault;
-import org.eclipse.wst.wsdl.BindingOperation;
-import org.eclipse.wst.wsdl.Definition;
-import org.eclipse.wst.wsdl.Operation;
-import org.eclipse.wst.wsdl.PortType;
-import org.eclipse.wst.wsdl.WSDLPackage;
-import org.eclipse.wst.wsdl.internal.util.WSDLSwitch;
-
-
-public class ReferenceManager
-{
- protected static InternalAdapterFactory internalAdapterFactory = new InternalAdapterFactory();
-
-
- public interface Listener
- {
- public void bindingsChanged( Operation operation);
- }
-
-
- public static void adaptDefinition(Definition definition)
- {
- internalAdapterFactory.adapt(definition);
- for (Iterator i = definition.getEBindings().iterator(); i.hasNext(); )
- {
- Binding binding = (Binding)i.next();
- internalAdapterFactory.adaptBinding(binding);
- }
- }
-
-
- public static void addBindingListener(Operation operation, Listener listener)
- {
- OperationAdapter adapter = (OperationAdapter)internalAdapterFactory.adapt(operation);
- if (adapter != null)
- {
- adapter.addListener(listener);
- }
- }
-
-
- public static void removeBindingListener(Operation operation, Listener listener)
- {
- OperationAdapter adapter = (OperationAdapter)internalAdapterFactory.adapt(operation);
- if (adapter != null)
- {
- adapter.removeListener(listener);
- }
- }
-
- protected static void fireNotificationForPortType(PortType portType)
- {
- // get the adapter for each operation and notify listeners
- if (portType != null)
- {
- for (Iterator i = portType.getEOperations().iterator(); i.hasNext(); )
- {
- fireNotificationForOperation((Operation)i.next());
- }
- }
- }
-
-
- protected static void fireNotificationForOperation(Operation operation)
- {
- if (operation != null)
- {
- OperationAdapter adapter = (OperationAdapter)internalAdapterFactory.adapt(operation);
- adapter.fireBindingsChanged();
- }
- }
-
-
- public static class InternalAdapterFactory extends AdapterFactoryImpl
- {
- public Adapter createAdapter(Notifier target)
- {
- WSDLSwitch wsdlSwitch = new WSDLSwitch()
- {
- public Object caseBinding(Binding binding)
- {
- return createBindingAdapter();
- }
-
- public Object caseBindingFault(BindingFault bindingFault)
- {
- return createBindingFaultAdapter();
- }
-
- public Object caseBindingOperation(BindingOperation bindingOperation)
- {
- return createBindingOperationAdapter();
- }
-
- public Object caseDefinition(Definition definition)
- {
- return createDefinitionAdapter();
- }
-
- public Object caseOperation(Operation operation)
- {
- return createOperationAdapter();
- }
- };
-
- Object o = wsdlSwitch.doSwitch((EObject)target);
-
- Adapter result = null;
- if (o instanceof Adapter)
- {
- result = (Adapter)o;
- }
- else
- {
- System.out.println("did not create adapter for target : " + target);
- Thread.dumpStack();
- }
- //System.out.println("createAdapter(" + target + ") " + result);
- return result;
- }
-
-
- public Adapter createBindingAdapter()
- {
- return new BindingAdapter();
- }
-
- public Adapter createBindingFaultAdapter()
- {
- return new BindingFaultAdapter();
- }
-
- public Adapter createBindingOperationAdapter()
- {
- return new BindingOperationAdapter();
- }
-
- public Adapter createDefinitionAdapter()
- {
- return new DefinitionAdapter();
- }
-
- public Adapter createOperationAdapter()
- {
- return new OperationAdapter();
- }
-
- public Adapter adapt(Notifier target)
- {
- return target != null ? adapt(target, internalAdapterFactory) : null;
- }
-
- protected void adaptBinding(Binding binding)
- {
- adapt(binding);
- for (Iterator i = binding.getEBindingOperations().iterator(); i.hasNext(); )
- {
- BindingOperation bindingOperation = (BindingOperation)i.next();
- adapt(bindingOperation);
- for (Iterator j = bindingOperation.getEBindingFaults().iterator(); j.hasNext(); )
- {
- BindingFault bindingFault = (BindingFault)j.next();
- adapt(bindingFault);
- }
- }
- }
- }
-
-
- protected static abstract class BaseAdapter extends AdapterImpl
- {
- public boolean isAdapterForType(Object type)
- {
- return type == internalAdapterFactory;
- }
-
- public WSDLPackage getPackage()
- {
- return WSDLPackage.eINSTANCE;
- }
- }
-
-
- // DefinitionAdapter
- //
- protected static class DefinitionAdapter extends BaseAdapter
- {
- public void notifyChanged(Notification msg)
- {
- if ((EStructuralFeature)msg.getFeature() == getPackage().getDefinition_EBindings())
- {
- Object newValue = msg.getNewValue();
- switch (msg.getEventType())
- {
- case Notification.ADD:
- {
- handleAdd((Binding)newValue);
- break;
- }
- case Notification.ADD_MANY:
- {
- for (Iterator newValues = ((Collection)newValue).iterator(); newValues.hasNext(); )
- {
- handleAdd((Binding)newValues.next());
- }
- break;
- }
- }
- }
- }
-
- protected void handleAdd(Binding binding)
- {
- internalAdapterFactory.adaptBinding(binding);
- PortType portType = binding.getEPortType();
- if (portType != null)
- {
- fireNotificationForPortType(portType);
- }
- }
- }
-
-
- protected static class BindingAdapter extends BaseAdapter
- {
- public void notifyChanged(Notification msg)
- {
- if ((EStructuralFeature)msg.getFeature() == getPackage().getBinding_EPortType())
- {
- // fireNotifcation for all of the operation of the old and new portType
- fireNotificationForPortType((PortType)msg.getNewValue());
- fireNotificationForPortType((PortType)msg.getOldValue());
- }
- else if ((EStructuralFeature)msg.getFeature() == getPackage().getBinding_EBindingOperations())
- {
- // fireNotifcation for all operations that were added or removed
- Object newValue = msg.getNewValue();
- Object oldValue = msg.getNewValue();
- switch (msg.getEventType())
- {
- case Notification.ADD:
- {
- handleAdd((BindingOperation)newValue);
- break;
- }
- case Notification.ADD_MANY:
- {
- for (Iterator newValues = ((Collection)newValue).iterator(); newValues.hasNext(); )
- {
- handleAdd((BindingOperation)newValues.next());
- }
- break;
- }
- case Notification.REMOVE:
- {
- handleRemove((BindingOperation)oldValue);
- break;
- }
- case Notification.REMOVE_MANY:
- {
- for (Iterator oldValues = ((Collection)oldValue).iterator(); oldValues.hasNext(); )
- {
- handleRemove((BindingOperation)oldValues.next());
- }
- break;
- }
- }
- }
- }
-
- protected void handleAdd(BindingOperation bindingOperation)
- {
- internalAdapterFactory.adapt(bindingOperation);
- Operation operation = ComponentReferenceUtil.computeOperation(bindingOperation);
- fireNotificationForOperation(operation);
- }
-
- protected void handleRemove(BindingOperation bindingOperation)
- {
- if (bindingOperation != null)
- {
- Operation operation = ComponentReferenceUtil.computeOperation(bindingOperation);
- fireNotificationForOperation(operation);
- }
- }
- }
-
-
-
- protected static class BindingOperationAdapter extends BaseAdapter
- {
- public void notifyChanged(Notification msg)
- {
- BindingOperation bindingOperation = (BindingOperation)getTarget();
- Operation operation = ComponentReferenceUtil.computeOperation(bindingOperation);
- fireNotificationForOperation(operation);
- }
- }
-
-
- protected static class BindingFaultAdapter extends BaseAdapter
- {
- public void notifyChanged(Notification msg)
- {
- BindingFault bindingFault = (BindingFault)getTarget();
- BindingOperation bindingOperation = (BindingOperation)bindingFault.eContainer();
- Operation operation = ComponentReferenceUtil.computeOperation(bindingOperation);
- fireNotificationForOperation(operation);
- }
- }
-
-
- protected static class OperationAdapter extends BaseAdapter
- {
- protected Definition definition;
- protected List listeners = new ArrayList();
-
- public void addListener(Listener listener)
- {
- listeners.add(listener);
- }
-
- public void removeListener(Listener listener)
- {
- listeners.remove(listener);
- }
-
- public void fireBindingsChanged()
- {
- Operation operation = (Operation)getTarget();
- for (Iterator i = listeners.iterator(); i.hasNext(); )
- {
- Listener listener = (Listener)i.next();
- listener.bindingsChanged(operation);
- }
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/SelectionAdapter.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/SelectionAdapter.java
deleted file mode 100644
index 9f1fda475..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/SelectionAdapter.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-
-// This class is used to help syncronize selections between two models.
-//
-public abstract class SelectionAdapter implements ISelectionProvider
-{
- protected List listenerList = new ArrayList();
- protected ISelection selection = new StructuredSelection();
- protected ISelectionProvider eventSource;
-
- public void setEventSource(ISelectionProvider eventSource)
- {
- this.eventSource = eventSource;
- }
-
- public void addSelectionChangedListener(ISelectionChangedListener listener)
- {
- listenerList.add(listener);
- }
-
- public void removeSelectionChangedListener(ISelectionChangedListener listener)
- {
- listenerList.remove(listener);
- }
-
- public ISelection getSelection()
- {
- return selection;
- }
-
- /**
- * This method should be specialized to return the correct object that corresponds to the 'other' model
- */
- abstract protected Object getObjectForOtherModel(Object object);
-
-
- public void setSelection(ISelection modelSelection)
- {
- List otherModelObjectList = new ArrayList();
- if (modelSelection instanceof IStructuredSelection)
- {
- for (Iterator i = ((IStructuredSelection)modelSelection).iterator(); i.hasNext(); )
- {
- Object modelObject = i.next();
- Object otherModelObject = getObjectForOtherModel(modelObject);
- if (otherModelObject != null)
- {
- otherModelObjectList.add(otherModelObject);
- }
- }
- }
-
- StructuredSelection nodeSelection = new StructuredSelection(otherModelObjectList);
- selection = nodeSelection;
- SelectionChangedEvent event = new SelectionChangedEvent(eventSource != null ? eventSource : this, nodeSelection);
-
- for (Iterator i = listenerList.iterator(); i.hasNext(); )
- {
- ISelectionChangedListener listener = (ISelectionChangedListener)i.next();
- listener.selectionChanged(event);
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ValidateHelper.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ValidateHelper.java
deleted file mode 100644
index 677932219..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ValidateHelper.java
+++ /dev/null
@@ -1,405 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util;
-
-import org.eclipse.wst.common.ui.internal.UIPlugin;
-import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin;
-
-public class ValidateHelper
-{
- // XML Lang can have many different valid formats
- // 1) xx ie. en, fr, de
- // 2) xx-xx ie. en-US, en-FR
- // 3) I-xx ie. I-en
- // 4) X-xx ie. X-en
- public static String checkXMLLang(String lang)
- {
- if (lang.length() == 0)
- return null;
-
- if (lang.length() == 1)
- {
- char ch0 = lang.charAt(0);
- if ((ch0 >= 'a' && ch0 <= 'z') || (ch0 >= 'A' && ch0 <= 'Z'))
- return UIPlugin.getResourceString("_WARN_LANG_TOO_SHORT");
- else
- return UIPlugin.getResourceString("_WARN_NAME_INVALID_CHAR") + ch0 +
- UIPlugin.getResourceString("_UI_NAME_INVALID_CHAR_END");
- }
-
- int offset;
-
- char ch0 = lang.charAt(0);
- if (lang.charAt(1) == '-')
- {
- if (ch0 == 'i' || ch0 == 'I' || ch0 == 'x' || ch0 == 'X')
- offset = 1;
- else
- return UIPlugin.getResourceString("_WARN_NAME_INVALID_CHAR") + ch0 +
- UIPlugin.getResourceString("_UI_NAME_INVALID_CHAR_END");
- }
- else
- {
- char ch1 = lang.charAt(1);
- if ((ch0 >= 'a' && ch0 <= 'z') || (ch0 >= 'A' && ch0 <= 'Z'))
- if ((ch1 >= 'a' && ch1 <= 'z') || (ch1 >= 'A' && ch1 <= 'Z'))
- offset = 2;
- else
- return UIPlugin.getResourceString("_WARN_NAME_INVALID_CHAR") + ch1 +
- UIPlugin.getResourceString("_UI_NAME_INVALID_CHAR_END");
- else
- return UIPlugin.getResourceString("_WARN_NAME_INVALID_CHAR") + ch0 +
- UIPlugin.getResourceString("_UI_NAME_INVALID_CHAR_END");
- }
-
- if (lang.length() > offset)
- {
- char ch = lang.charAt(offset++);
- if (ch != '-')
- return UIPlugin.getResourceString("_WARN_HYPHEN_NEEDED") + Integer.toString(offset-1);
- else
- {
- while (true)
- {
- if (ch == '-')
- {
- if (lang.length() == offset)
- return UIPlugin.getResourceString("_WARN_HYPHEN_ENDING");
-
- ch = lang.charAt(offset++);
- if ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))
- return UIPlugin.getResourceString("_WARN_NAME_INVALID_CHAR") + ch +
- UIPlugin.getResourceString("_UI_NAME_INVALID_CHAR_END");
-
- if (lang.length() == offset)
- return null;
- }
- else if ((ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))
- return UIPlugin.getResourceString("_WARN_NAME_INVALID_CHAR") + ch +
- UIPlugin.getResourceString("_UI_NAME_INVALID_CHAR_END");
- else if (lang.length() == offset)
- return null;
- ch = lang.charAt(offset++);
- }
- }
- }
-
- return null;
- }
-
- /**
- * Check to see if the min value is correct.
- * A minimum value must be non-negative and < maxValue
- */
- public static String isValidMinValue(String minValue, String maxValue)
- {
- int min;
-
- if (minValue == null || minValue.equals(""))
- {
- // Nothing to check
- return null;
- }
-
- try
- {
- min = Integer.parseInt(minValue);
- }
- catch (NumberFormatException ex)
- {
- return UIPlugin.getResourceString("_ERROR_MIN_NOT_POSITIVE");
- }
-
- if (min < 0)
- {
- return UIPlugin.getResourceString("_ERROR_MIN_NOT_POSITIVE");
- }
-
- try
- {
- int max = Integer.parseInt(maxValue);
- if (min > max)
- {
- return UIPlugin.getResourceString("_ERROR_MIN_VALUE");
- }
- }
- catch (NumberFormatException ex)
- {
- // Max is not accurate. Don't compare it.
- }
- return null;
- }
-
- /**
- * Check to see if the max value is correct.
- * A maximum value must be non-negative and > minValue
- *
- * It can also be set the string "unbounded"
- */
- public static String isValidMaxValue(String maxValue, String minValue)
- {
- int max;
-
- if (maxValue == null || maxValue.equals(""))
- {
- // Nothing to check
- return null;
- }
-
- if (maxValue.equals("unbounded"))
- {
- return null;
- }
-
- try
- {
- max = Integer.parseInt(maxValue);
- }
- catch (NumberFormatException ex)
- {
- return UIPlugin.getResourceString("_ERROR_MAX_NOT_POSITIVE");
- }
-
- if (max < 0)
- {
- return UIPlugin.getResourceString("_ERROR_MAX_NOT_POSITIVE");
- }
-
- try
- {
- int min = Integer.parseInt(minValue);
- if (max < min)
- {
- return UIPlugin.getResourceString("_ERROR_MAX_VALUE");
- }
- }
- catch (NumberFormatException ex)
- {
- // Min is not accurate. Don't compare it.
- }
- return null;
- }
-
- /**
- * Validate the name conforms to the XML spec
- */
- public static String checkXMLName(String name, boolean allowEntityRef)
- {
- int length = name.length();
- char character;
-
- if (length == 0)
- {
- return WSDLEditorPlugin.getWSDLString("_WARN_NAME_MUST_CONTAIN_AT_LEAST_ONE_CHAR");
- }
-
- if (name.indexOf(" ") >= 0)
- {
- return(WSDLEditorPlugin.getWSDLString("_WARN_NAME_HAS_SPACE"));
- }
-
- int index = 0;
- if (length > 0 &&
- name.charAt(0) == '%')
- {
- if (allowEntityRef)
- {
- // skip over the first character
- index++;
- } // end of if ()
- else
- {
- return WSDLEditorPlugin.getWSDLString("_WARN_NAME_INVALID_FIRST");
- } // end of else
- }
-
- for(; index < length; index++)
- {
- character = name.charAt(index);
-
- if(index == 0)
- {
- if( !isXMLNameStart(character) )
- {
- return WSDLEditorPlugin.getWSDLString("_WARN_NAME_INVALID_FIRST");
- }
- }
- else
- {
- if(!isXMLNameChar(character))
- {
- if ((index == length - 1) && //check if the last character is a ';'
- allowEntityRef &&
- character == ';')
- {
- // we're still ok then
- continue;
- } // end of if ()
- else
- {
- return WSDLEditorPlugin.getWSDLString("_WARN_NAME_INVALID_CHAR") + character +
- WSDLEditorPlugin.getWSDLString("_UI_NAME_INVALID_CHAR_END");
- } // end of else
- }
- }
- }
- return null;
- }
-
- /**
- * Validate the name conforms to the XML spec
- */
- public static String checkXMLName(String name)
- {
- return checkXMLName(name, false);
- }
-
- /**
- * isXMLNameStart
- **/
- private static boolean isXMLNameStart(char ch)
- {
- return (ch == '_' || ch == ':' || Character.isLetter(ch) );
- }
-
- /**
- * isXMLNameChar
- **/
- private static boolean isXMLNameChar(char ch)
- {
- return (Character.isLetterOrDigit(ch) || ch == '.' || ch == '-' || ch == '_' || ch == ':');
- }
-
- /**
- * isXMLPrefixStart
- **/
-// private static boolean isXMLPrefixStart(char ch)
-// {
-// return (ch == '_' || Character.isLetter(ch) );
-// }
-
- /**
- * isXMLPrefixChar
- **/
- private static boolean isXMLPrefixChar(char ch)
- {
- return (Character.isLetterOrDigit(ch) || ch == '.' || ch == '-' || ch == '_');
- }
-
- /**
- * parseElementText
- */
- public static String parseElementText(String text)
- {
- if (text.indexOf('<') != -1 || text.indexOf('>') != -1)
- {
- return UIPlugin.getResourceString("_WARN_ELEMENT_INVALID_CHAR");
- }
- return null;
- }
-
- /**
- * parseAttributeValue
- */
- public static String parseAttributeValue(String value)
- {
- if (value.indexOf('"') != -1 || value.indexOf('<') != -1 || value.indexOf('>') != -1)
- {
- return UIPlugin.getResourceString("_WARN_ATTRIBUTE_INVALID_CHAR");
-
- }
- return null;
- }
-
- /**
- * parseADATASection
- */
- public static String parseCDATASection(String section)
- {
- if (section.indexOf("]]>") != -1)
- {
- return UIPlugin.getResourceString("_WARN_CDATA_INVALID_STRING");
-
- }
- return null;
- }
-
- /**
- * parseProcessiingInstruction
- */
- public static String parseProcessingInstructionData(String data)
- {
- if (data.indexOf("?>") != -1)
- {
- return UIPlugin.getResourceString("_WARN_PROCESSING_INVALID_STRING");
-
- }
- return null;
- }
-
- /**
- * parseProcessingInstructionTarget
- */
- public static String parseProcessingInstructionTarget(String target)
- {
- if (target.length() == 3 && (target.indexOf("XML") != -1 || target.indexOf("XMl") != -1 || target.indexOf("XmL") != -1 ||
- target.indexOf("xML") != -1 || target.indexOf("Xml") != -1 || target.indexOf("xMl") != -1 ||
- target.indexOf("xmL") != -1 || target.indexOf("xml") != -1))
- {
- return UIPlugin.getResourceString("_WARN_PROCESSING_TARGET_INVALID_STRING");
-
- }
- return checkXMLName(target);
- }
-
- /**
- * parsComment
- */
- public static String parseComment(String comment)
- {
- if (comment.indexOf("--") != -1)
- {
- return UIPlugin.getResourceString("_WARN_COMMENT_INVALID_STRING");
- }
- return null;
- }
-
- /**
- * Validate the prefix conforms to the XML spec
- */
- public static String checkXMLPrefix(String prefix)
- {
- int length = prefix.length();
- if (length == 0)
- {
- return null;
- }
- char character;
-
- if (prefix.indexOf(" ") >= 0)
- {
- return(UIPlugin.getResourceString("_WARN_PREFIX_HAS_SPACE"));
- }
-
- for(int index = 0; index < length; index++)
- {
- character = prefix.charAt(index);
-
- if(!isXMLPrefixChar(character))
- {
- return UIPlugin.getString("_WARN_PREFIX_INVALID_CHAR", String.valueOf(character));
- }
- }
- return null;
- }
-
-}
-
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLEditorUtil.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLEditorUtil.java
deleted file mode 100644
index e821b9547..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLEditorUtil.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.eclipse.wst.wsdl.Definition;
-import org.eclipse.wst.wsdl.ExtensibleElement;
-import org.eclipse.wst.wsdl.MessageReference;
-import org.eclipse.wst.wsdl.Operation;
-import org.eclipse.wst.wsdl.PortType;
-import org.eclipse.wst.wsdl.Types;
-import org.eclipse.wst.wsdl.ui.internal.extension.ITypeSystemProvider;
-import org.eclipse.wst.wsdl.util.WSDLConstants;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-public class WSDLEditorUtil extends WSDLConstants
-{
- protected static WSDLEditorUtil instance;
- protected NodeAssociationManager nodeAssociationManager = new NodeAssociationManager();
-
- protected HashMap elementNameToTypeMap = new HashMap();
-
- public static WSDLEditorUtil getInstance()
- {
- if (instance == null)
- {
- instance = new WSDLEditorUtil();
- }
- return instance;
- }
-
- public WSDLEditorUtil()
- {
- elementNameToTypeMap.put(BINDING_ELEMENT_TAG, new Integer(BINDING));
- elementNameToTypeMap.put(DEFINITION_ELEMENT_TAG, new Integer(DEFINITION));
- elementNameToTypeMap.put(DOCUMENTATION_ELEMENT_TAG, new Integer(DOCUMENTATION));
- elementNameToTypeMap.put(FAULT_ELEMENT_TAG, new Integer(FAULT));
- elementNameToTypeMap.put(IMPORT_ELEMENT_TAG, new Integer(IMPORT));
- elementNameToTypeMap.put(INPUT_ELEMENT_TAG, new Integer(INPUT));
- elementNameToTypeMap.put(MESSAGE_ELEMENT_TAG, new Integer(MESSAGE));
- elementNameToTypeMap.put(OPERATION_ELEMENT_TAG, new Integer(OPERATION));
- elementNameToTypeMap.put(OUTPUT_ELEMENT_TAG, new Integer(OUTPUT));
- elementNameToTypeMap.put(PART_ELEMENT_TAG, new Integer(PART));
- elementNameToTypeMap.put(PORT_ELEMENT_TAG, new Integer(PORT));
- elementNameToTypeMap.put(PORT_TYPE_ELEMENT_TAG, new Integer(PORT_TYPE));
- elementNameToTypeMap.put(SERVICE_ELEMENT_TAG, new Integer(SERVICE));
- elementNameToTypeMap.put(TYPES_ELEMENT_TAG, new Integer(TYPES));
- }
-
- public int getWSDLType(Element element)
- {
- int result = -1;
-
- Integer integer = (Integer)elementNameToTypeMap.get(element.getLocalName());
- if (integer != null)
- {
- result = integer.intValue();
- }
- return result;
- }
-
- protected List getParentElementChain(Element element)
- {
- List list = new ArrayList();
- while (element != null)
- {
- list.add(0, element);
- Node node = element.getParentNode();
- element = (node != null && node.getNodeType() == Node.ELEMENT_NODE) ? (Element)node : null;
- }
- return list;
- }
-
- public Object findModelObjectForElement(Definition definition, Element targetElement)
- {
- Object o = nodeAssociationManager.getModelObjectForNode(definition, targetElement);
- return o;
- }
-
- public Element getElementForObject(Object o)
- {
- return ((org.eclipse.wst.wsdl.WSDLElement)o).getElement();
- }
-
- public Node getNodeForObject(Object o)
- {
- return nodeAssociationManager.getNode(o);
- }
-
- // Provide a mapping between Definitions and ITypeSystemProviders
- private Hashtable typeSystemProviders = new Hashtable();
-
- public ITypeSystemProvider getTypeSystemProvider(Definition definition)
- {
- return (ITypeSystemProvider)typeSystemProviders.get(definition);
- }
-
- public void setTypeSystemProvider(Definition definition, ITypeSystemProvider typeSystemProvider)
- {
- typeSystemProviders.put(definition,typeSystemProvider);
- }
-
- public static QName createQName(Definition definition, String prefixedName)
- {
- QName qname = null;
- if (prefixedName != null)
- {
- int index = prefixedName.indexOf(":");
- String prefix = (index == -1) ? null : prefixedName.substring(0, index);
- if (prefix != null)
- {
- String namespace = definition.getNamespace(prefix);
- if (namespace != null)
- {
- String localPart = prefixedName.substring(index + 1);
- qname = new QName(namespace, localPart);
- }
- }
- }
- return qname;
- }
-
- public List getExtensibilityElementNodes(ExtensibleElement extensibleElement)
- {
- // For Types, I need to get all the schemas
- if (extensibleElement instanceof Types)
- {
- Types xsdEE = (Types)extensibleElement;
- return xsdEE.getSchemas();
- }
- /*
- List childList = new ArrayList();
-
- Element parentElement = getElementForObject(extensibleElement);
- if (parentElement != null)
- {
-
- NodeList nodeList = parentElement.getChildNodes();
- int nodeListLength = nodeList.getLength();
- for (int i = 0; i < nodeListLength; i++)
- {
- childList.add(nodeList.item(i));
- }
- HashMap extensibleElementTable = new HashMap();
- for (Iterator i = extensibleElement.getEExtensibilityElements().iterator(); i.hasNext();)
- {
- ExtensibilityElement extensibilityElement = (ExtensibilityElement)i.next();
- if (extensibilityElement != null)
- {
- Element element = getElementForObject(extensibilityElement);
- if (element != null)
- {
- extensibleElementTable.put(element, element);
- }
- }
- }
-
- for (Iterator i = childList.iterator(); i.hasNext();)
- {
- Object o = i.next();
- if (extensibleElementTable.get(o) == null)
- {
- i.remove();
- }
- }
- }
- return childList;
- */
- return extensibleElement.getEExtensibilityElements();
- }
-
- /*
- * Returns a list of 'children' of the given object model (WSDLElement).
- */
- public static List getModelGraphViewChildren(Object object) {
- List childList = new ArrayList();
-
- if (object instanceof PortType) {
- PortType portType = (PortType) object;
- childList.addAll(portType.getOperations());
- }
- else if (object instanceof Operation) {
- Operation operation = (Operation) object;
-
- if (operation.getEInput() != null) {
- childList.add(operation.getEInput());
- }
- if (operation.getEOutput() != null) {
- childList.add(operation.getEOutput());
- }
- childList.addAll(operation.getFaults().values());
- }
- else if (object instanceof MessageReference) {
- MessageReference messageReference = (MessageReference) object;
- childList.add(messageReference.getEMessage());
- }
-
- return childList;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLModelLocatorAdapterFactory.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLModelLocatorAdapterFactory.java
deleted file mode 100644
index 60724abad..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLModelLocatorAdapterFactory.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
-import org.eclipse.wst.wsdl.internal.util.WSDLModelLocator;
-
-public class WSDLModelLocatorAdapterFactory extends AdapterFactoryImpl
-{
- protected CustomWSDLModelLocator customWSDLModelLocator = new CustomWSDLModelLocator();
-
- class CustomWSDLModelLocator extends AdapterImpl implements WSDLModelLocator
- {
- public String resolveURI(String baseLocation, String namespace, String location)
- {
- return URIResolverPlugin.createResolver().resolve(baseLocation, namespace, location);
- }
-
- public boolean isAdatperForType(Object type)
- {
- return type == WSDLModelLocator.class;
- }
- }
-
- public boolean isFactoryForType(Object type)
- {
- return type == WSDLModelLocator.class;
- }
-
- public Adapter adaptNew(Notifier target, Object type)
- {
- return customWSDLModelLocator;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLNodeAssociationProvider.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLNodeAssociationProvider.java
deleted file mode 100644
index ddc335303..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLNodeAssociationProvider.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.wst.wsdl.WSDLElement;
-import org.eclipse.wst.wsdl.internal.impl.WSDLElementImpl;
-import org.eclipse.wst.wsdl.ui.internal.extension.INodeAssociationProvider;
-import org.eclipse.xsd.impl.XSDComponentImpl;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-public class WSDLNodeAssociationProvider implements INodeAssociationProvider
-{
- public Object getModelObject(Object parentModelObject, Element[] elementChain, int start, int[] end)
- {
- Object currentObject = parentModelObject;
- for (int i = start; i < elementChain.length; i++)
- {
- Object o = getModelObjectHelper(currentObject, elementChain[i]);
- if (o == null)
- {
- end[0] = i;
- break;
- }
- else
- {
- currentObject = o;
- }
- }
- return currentObject != parentModelObject ? currentObject : null;
- }
-
- public Node getNode(Object modelObject)
- {
- if (modelObject instanceof WSDLElement)
- return ((WSDLElementImpl)modelObject).getElement();
- else
- return null;
- }
-
- protected Object getModelObjectHelper(Object parentObject, Element elementNode)
- {
- Object result = null;
- Collection childComponentList = ((WSDLElementImpl) parentObject).getWSDLContents();
- for (Iterator i = childComponentList.iterator(); i.hasNext();)
- {
- Object o = i.next();
- Element element = null;
-
- if (o != null)
- {
- if (o instanceof WSDLElementImpl)
- {
- element = ((WSDLElementImpl)o).getElement();
- }
- else if (o instanceof XSDComponentImpl)
- {
- element = ((XSDComponentImpl)o).getElement();
- }
- }
-
- if (element == elementNode)
- {
- result = o;
- break;
- }
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLPreferencePage.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLPreferencePage.java
deleted file mode 100644
index a51b5e8a9..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLPreferencePage.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util;
-
-import org.eclipse.jface.preference.BooleanFieldEditor;
-import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.jface.preference.StringFieldEditor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin;
-
-public class WSDLPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
-
- public WSDLPreferencePage()
- {
- super(FieldEditorPreferencePage.FLAT);
- setPreferenceStore(WSDLEditorPlugin.getInstance().getPreferenceStore());
- }
-
- public void init(IWorkbench workbench)
- {
- }
-
- protected void createFieldEditors()
- {
- Composite parent = getFieldEditorParent();
- GridLayout parentLayout = new GridLayout();
- parentLayout.marginWidth = 0;
- parent.setLayout(parentLayout);
-
-// WorkbenchHelp.setHelp(getControl(), some context id here);
-
- Group group = new Group(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.numColumns = 2;
- group.setLayout(layout);
- group.setText(WSDLEditorPlugin.getWSDLString("_UI_PREF_PAGE_CREATING_FILES"));
-
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- group.setLayoutData(data);
-
- Composite composite = new Composite(group, SWT.NULL);
- GridData data1 = new GridData();
- data1.verticalAlignment = GridData.FILL;
- data1.horizontalAlignment = GridData.FILL;
- data1.grabExcessHorizontalSpace = true;
- composite.setLayoutData(data1);
-
- String namespaceLabel = WSDLEditorPlugin.getWSDLString("_UI_PREF_PAGE_DEFAULT_TARGET_NAMESPACE");
- StringFieldEditor targetNamespace = new StringFieldEditor(namespaceLabel, namespaceLabel, composite); // Externalize
- GridLayout compositeLayout = (GridLayout)composite.getLayout();
- compositeLayout.marginWidth = 5; // Default value
- compositeLayout.numColumns = 2;
- addField(targetNamespace);
- targetNamespace.setFocus();
-
- String generateLabel = WSDLEditorPlugin.getWSDLString("_UI_PREF_PAGE_AUTO_REGENERATE_BINDING");
- BooleanFieldEditor generateBindingOnSave = new BooleanFieldEditor(generateLabel, generateLabel, parent);
- addField(generateBindingOnSave);
-
- String showGenerateDialogLabel = "Prompt Regenerate Binding on save"; // TODO: Externalize
- BooleanFieldEditor showGenerateDialog = new BooleanFieldEditor(showGenerateDialogLabel, showGenerateDialogLabel, parent);
- addField(showGenerateDialog);
-
- /* Do we need this preference below? If so, change WSDLEditorPlugin.java and use this preference in:
- HttpContentGenerator.java
- SoapContentGenerator.java
- SoapPortOptionsPage.java
- */
-// HttpPortOptionsPage.java StringFieldEditor location = new StringFieldEditor("Defualt Location:", "Default Location:", editorGroup1); // Externalize
-// addField(location);
-
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLResourceUtil.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLResourceUtil.java
deleted file mode 100644
index 8b1dd18db..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/WSDLResourceUtil.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util;
-
-import java.util.Iterator;
-
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.wst.wsdl.Definition;
-import org.eclipse.wst.wsdl.Import;
-import org.eclipse.wst.wsdl.Types;
-import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement;
-import org.eclipse.wst.wsdl.internal.impl.WSDLElementImpl;
-import org.eclipse.wst.wsdl.internal.util.WSDLModelLocator;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSchemaDirective;
-import org.w3c.dom.Element;
-
-
-public class WSDLResourceUtil
-{
- public static void reloadDirectives(Definition definition)
- {
- Resource rootResource = definition.eResource();
- ResourceSet resourceSet = rootResource.getResourceSet();
-
- for (Iterator i = resourceSet.getResources().iterator(); i.hasNext();)
- {
- Resource resource = (Resource) i.next();
- if (resource != rootResource)
- {
- // TODO... consider unloading the resources
- // resource.unload();
- i.remove();
- }
- }
- ReloadDirectiveVisitor visitor = new ReloadDirectiveVisitor();
- visitor.visitDefinition(definition);
- }
-
- static class ReloadDirectiveVisitor
- {
-
- public void visitImport(Import theImport)
- {
- // force the import to reload
- Element element = WSDLEditorUtil.getInstance().getElementForObject(theImport);
- if (element != null)
- {
- ((WSDLElementImpl)theImport).elementChanged(element);
- }
- }
-
- public void visitXSDSchemaDirective(XSDSchemaDirective directive)
- {
- // force the schema directive to reload
- Element element = directive.getElement();
- if (element != null)
- {
- directive.elementAttributesChanged(element);
- }
- }
-
- public void visitDefinition(Definition definition)
- {
- if (definition != null)
- {
- for (Iterator i = definition.getEImports().iterator(); i.hasNext();)
- {
- visitImport((Import) i.next());
- }
- Types types = definition.getETypes();
- if (types != null)
- {
-
- for (Iterator i = types.getEExtensibilityElements().iterator(); i.hasNext();)
- {
- Object o = i.next();
- if (o instanceof XSDSchemaExtensibilityElement)
- {
- XSDSchemaExtensibilityElement e = (XSDSchemaExtensibilityElement) o;
- if (e.getSchema() != null)
- {
- visitSchema(e.getSchema());
- }
- }
- }
- }
- }
- }
-
- public void visitSchema(XSDSchema schema)
- {
- for (Iterator i = schema.getContents().iterator(); i.hasNext();)
- {
- Object o = i.next();
- if (o instanceof XSDSchemaDirective)
- {
- visitXSDSchemaDirective((XSDSchemaDirective) o);
- }
- }
- }
- }
-
-
- public static class InternalURIResolver implements WSDLModelLocator
- {
- //IdResolver idResolver = new IdResolverImpl(null, true);
- org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver resolver = URIResolverPlugin.createResolver();
-
- InternalURIResolver()
- {
- }
-
- public String resolveURI(String baseLocation, String namespace, String location)
- {
- String resolvedLocation = resolver.resolve(baseLocation, namespace, location);
-
- // here's an ugly hack... Platform.resolve() returns Windows files with the pattern "file:D:/hello.xsd"
- // but EMF's URI class expects a pattern like this "file:///D:/hello.xsd"
- //
- if (resolvedLocation != null)
- {
- String fileProtocol = "file:";
- if (resolvedLocation.startsWith(fileProtocol) && !resolvedLocation.startsWith(fileProtocol + "/"))
- {
- resolvedLocation = resolvedLocation.substring(fileProtocol.length());
- }
- resolvedLocation = URIHelper.addImpliedFileProtocol(resolvedLocation);
- }
- // end ugly hack
- return resolvedLocation;
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XMLQuickScan.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XMLQuickScan.java
deleted file mode 100644
index 7f338b73e..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XMLQuickScan.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util;
-
-import java.io.InputStream;
-import java.net.URL;
-
-import javax.xml.transform.TransformerFactory;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- *
- */
-public class XMLQuickScan
-{
- public static String getTargetNamespaceURIForSchema(String uri)
- {
- String result = null;
- try
- {
- URL url = new URL(uri);
- InputStream inputStream = url.openStream();
- result = XMLQuickScan.getTargetNamespaceURIForSchema(inputStream);
- }
- catch (Exception e)
- {
- }
- return result;
- }
-
- public static String getTargetNamespaceURIForSchema(InputStream input)
- {
- TargetNamespaceURIContentHandler handler = new TargetNamespaceURIContentHandler();
- ClassLoader prevClassLoader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(XMLQuickScan.class.getClassLoader());
- // Line below is a hack to get XMLReader working
- TransformerFactory transformerFactory = TransformerFactory.newInstance();
- try
- {
- XMLReader reader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
- reader.setContentHandler(handler);
- reader.parse(new InputSource(input));
- }
- catch (Exception e)
- {
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(prevClassLoader);
- }
- return handler.targetNamespaceURI;
- }
-
- protected static class TargetNamespaceURIContentHandler extends DefaultHandler
- {
- public String targetNamespaceURI;
-
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
- {
- if (localName.equals("schema") || localName.equals("definitions"))
- {
- int nAttributes = attributes.getLength();
- for (int i = 0; i < nAttributes; i++)
- {
- if (attributes.getLocalName(i).equals("targetNamespace"))
- {
- targetNamespaceURI = attributes.getValue(i);
- break;
- }
- }
- }
- // todo there's a ice way to do this I'm sure
- // here I intentially cause an exception...
- String x = null;
- x.length();
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XSDSchemaLocationResolverAdapterFactory.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XSDSchemaLocationResolverAdapterFactory.java
deleted file mode 100644
index 64b9ae85c..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XSDSchemaLocationResolverAdapterFactory.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
-import org.eclipse.xsd.util.XSDSchemaLocationResolver;
-
-public class XSDSchemaLocationResolverAdapterFactory extends AdapterFactoryImpl
-{
- protected XSDSchemaLocationResolverImpl schemaLocator = new XSDSchemaLocationResolverImpl();
-
- public boolean isFactoryForType(Object type)
- {
- return type == XSDSchemaLocationResolver.class;
- }
-
- public Adapter adaptNew(Notifier target, Object type)
- {
- return schemaLocator;
- }
-}
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XSDSchemaLocationResolverImpl.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XSDSchemaLocationResolverImpl.java
deleted file mode 100644
index 306a2e80d..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/XSDSchemaLocationResolverImpl.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util;
-
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDSchemaLocationResolver;
-import org.eclipse.xsd.util.XSDSchemaLocator;
-
-public class XSDSchemaLocationResolverImpl extends AdapterImpl implements XSDSchemaLocationResolver
-{
- public String resolveSchemaLocation(XSDSchema xsdSchema, String namespaceURI, String schemaLocationURI)
- {
- String baseLocation = xsdSchema.getSchemaLocation();
- String result = URIResolverPlugin.createResolver().resolve(baseLocation, namespaceURI, schemaLocationURI);
- if (result == null) {
- result = namespaceURI;
- }
- if (result == null) {
- result = "";
- }
-
- return result;
- }
-
- public boolean isAdatperForType(Object type)
- {
- return type == XSDSchemaLocator.class;
- }
-}
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/FlatPageHeader.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/FlatPageHeader.java
deleted file mode 100644
index b4793549d..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/FlatPageHeader.java
+++ /dev/null
@@ -1,356 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util.flatui;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontMetrics;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-
-public class FlatPageHeader extends Canvas implements IPropertyChangeListener
-{
- private Image backgroundImage;
- private String text;
- private Image buttonImage;
- private Color imageBackgroundColor;
- private Color textForegroundColor;
- private int textHMargin = 10;
- private int textVMargin = 5;
- private Font headerFont;
-
- private List listeners;
- private int buttonImageX;
- private int buttonImageY;
-
- // Usage:
- // See org.eclipse.wst.common.ui.FlatViewUtility.createFlatPageHeader()
- // methods.
- //
- // Ex)
- // Composite parent = ... ;
- // Image image = ... ;
- // Layout layout = ... ;
- // String title = ... ;
- // WidgetFactory factory = ... ;
- //
- // header = new FlatPageHeader(parent,SWT.NONE);
- // header.setLayout(layout);
- // header.setBackgroundImage(image);
- // header.setText(title);
- // Composite formParent = factory.createComposite(header);
- //
- // GridLayout gl = new GridLayout();
- // gl.numColumns = 1;
- // formParent.setLayout(gl);
- // formParent.setLayoutData(new GridData(GridData.FILL_BOTH));
- //
- public FlatPageHeader(Composite parent, int style)
- {
- super(parent, style);
-
- // The default image background color is white
- // The default text forekground color is black
- imageBackgroundColor = new Color(null, 255, 255, 255);
- textForegroundColor = new Color(null, 0, 0, 0);
- setBackground(imageBackgroundColor);
-
- // The default text font is Header font
- headerFont = JFaceResources.getHeaderFont();
-
- // Need to dispose the Color
- addDisposeListener
- (new DisposeListener()
- {
- public void widgetDisposed(DisposeEvent e)
- {
- FlatPageHeader.this.widgetDisposed(e);
- }
- }
- );
-
- // need to paint
- addPaintListener
- (new PaintListener()
- {
- public void paintControl(PaintEvent e)
- {
- FlatPageHeader.this.paintControl(e);
- }
- }
- );
-
- // create a list of listeners
- listeners = new ArrayList();
-
- // add a mouse listener
- this.addMouseListener
- (new MouseAdapter()
- {
- public void mouseDown(MouseEvent event)
- {
- handleMouseDown(event);
- }
- }
- );
-
- JFaceResources.getFontRegistry().addListener(this);
- }
-
- // Compute size of the widget
- public Point computeSize(int wHint, int hHint, boolean changed)
- {
- int width = getParent().getClientArea().width;
- int height = 0;
- if (backgroundImage != null)
- {
- Rectangle bounds = backgroundImage.getBounds();
- height = bounds.height;
- }
- if (text != null)
- {
- GC gc = new GC(this);
- int textHeight = getTextHeight(gc);
- gc.dispose();
- height = Math.max(height, textHeight);
- }
- if (buttonImage != null)
- {
- Rectangle bounds = buttonImage.getBounds();
- if (height < bounds.height)
- height = bounds.height;
- }
- if (wHint != SWT.DEFAULT) width = wHint;
- if (hHint != SWT.DEFAULT) height = hHint;
- return new Point(width + 2, height + 2);
- }
-
- protected void paintControl(PaintEvent e)
- {
- GC gc = e.gc;
- if (backgroundImage != null)
- {
- Rectangle imageBounds = backgroundImage.getBounds();
- int y = 0;
- int x = 0;
-
- if (imageBackgroundColor != null)
- {
- gc.setBackground(imageBackgroundColor);
- gc.fillRectangle(0, 0, imageBounds.width, imageBounds.height);
- }
-
- if (SWT.getPlatform().equals("motif")==false)
- {
- gc.drawImage(backgroundImage, x, y);
- }
- if (textForegroundColor != null)
- gc.setForeground(textForegroundColor);
- gc.setFont(headerFont);
-// gc.setFont(getFont());
- gc.drawText(text, textHMargin, textVMargin, true);
- if (buttonImage != null)
- {
- Rectangle parentBounds = getParent().getClientArea();
- Rectangle buttonBounds = buttonImage.getBounds();
- int p = parentBounds.x + parentBounds.width;
- buttonImageX = p - buttonBounds.width - 4;
- buttonImageY = 4;
- gc.drawImage(buttonImage, buttonImageX, buttonImageY);
- }
- }
- }
-
- public void addSelectionListener(SelectionListener listener)
- {
- listeners.add(listener);
- }
-
- public void removeSelectionListener(SelectionListener listener)
- {
- listeners.remove(listener);
- }
-
- protected void handleMouseDown(MouseEvent event)
- {
- if (buttonImage == null)
- return;
- // chekc if the Button image is clicked
- int x = event.x;
- int y = event.y;
- if (x < buttonImageX || x > buttonImageX + buttonImage.getBounds().width)
- {
- return;
- }
- if (y < buttonImageY || y > buttonImageY + buttonImage.getBounds().height)
- {
- return;
- }
-
- int size = listeners.size();
- for (int i = 0; i < size; i++)
- {
- SelectionListener listener = (SelectionListener)listeners.get(i);
- listener.widgetSelected(null);
- }
- }
-
- protected void widgetDisposed(DisposeEvent e)
- {
- if (imageBackgroundColor != null) imageBackgroundColor.dispose();
- if (textForegroundColor != null) textForegroundColor.dispose();
- if (backgroundImage != null) backgroundImage.dispose();
- }
-
- // getters and setters
- public Image getBackgroundImage()
- {
- return backgroundImage;
- }
-
- public void setBackgroundImage(Image backgroundImage)
- {
- this.backgroundImage = backgroundImage;
- redraw();
- }
-
- public Image getButtonImage()
- {
- return buttonImage;
- }
-
- public void setButtonImage(Image buttonImage)
- {
- this.buttonImage = buttonImage;
- redraw();
- }
-
- public String getText()
- {
- return text;
- }
-
- public void setText(String text)
- {
- this.text = text;
- redraw();
- }
-
- public int getTextHMargin()
- {
- return textHMargin;
- }
-
- public void setTextHMargin(int textHMargin)
- {
- this.textHMargin = textHMargin;
- }
-
- public int getTextVMargin()
- {
- return textVMargin;
- }
-
- public void setTextVMargin(int textVMargin)
- {
- this.textVMargin = textVMargin;
- }
-
- public Color getImageBackgroundColor()
- {
- return imageBackgroundColor;
- }
-
- public void setImageBackgroundColor(Color imageBackgroundColor)
- {
- if (imageBackgroundColor == null)
- return;
- this.imageBackgroundColor = imageBackgroundColor;
- redraw();
- }
-
- public Color getTextForegroundColor()
- {
- return textForegroundColor;
- }
-
- public void setTextForegroundColor(Color textForegroundColor)
- {
- if (textForegroundColor == null)
- return;
- this.textForegroundColor = textForegroundColor;
- redraw();
- }
-
- private int getTextHeight(GC gc)
- {
- int imageHeight = 0;
- if (backgroundImage!= null && SWT.getPlatform().equals("motif")==false)
- {
- imageHeight = backgroundImage.getBounds().height;
- }
- gc.setFont(headerFont);
-// gc.setFont(getFont());
- FontMetrics fm = gc.getFontMetrics();
- int fontHeight = fm.getHeight();
- int height = fontHeight + textVMargin + textVMargin;
- return Math.max(height, imageHeight);
- }
-
-// private int getTextWidth(GC gc)
-// {
-// int imageWidth = 0;
-// if (backgroundImage!= null && SWT.getPlatform().equals("motif")==false)
-// {
-// imageWidth = backgroundImage.getBounds().width;
-// }
-// gc.setFont(headerFont);
-//// gc.setFont(getFont());
-// FontMetrics fm = gc.getFontMetrics();
-// int fontWidth = fm.getAverageCharWidth() + 5;
-// int width = fontWidth * text.length() + textHMargin + textHMargin;
-// return Math.max(width, imageWidth);
-// }
-
- public void handleEvent(Event e)
- {
-// Widget source = e.widget;
- }
-
- public void propertyChange(PropertyChangeEvent event)
- {
- if(event.getProperty() == JFaceResources.HEADER_FONT && this.isDisposed() == false)
- {
- headerFont = JFaceResources.getFontRegistry().get(JFaceResources.HEADER_FONT);
- this.layout(true);
- this.redraw();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/FlatPageSection.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/FlatPageSection.java
deleted file mode 100644
index 7ef2e6ced..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/FlatPageSection.java
+++ /dev/null
@@ -1,408 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util.flatui;
-
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ViewForm;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Widget;
-
-//public abstract class FormSection implements IPropertyChangeListener, IModelChangedListener {
-public abstract class FlatPageSection extends ViewForm implements IPropertyChangeListener {
- public static final int SELECTION = 1;
-// private PDEFormPage formPage;
- private String headerColorKey = WidgetFactory.DEFAULT_HEADER_COLOR;
- private String headerText;
- private Control client;
- protected Label header;
- protected Control separator;
-// private SectionChangeManager sectionManager;
- private java.lang.String description;
- private boolean dirty;
- protected Label descriptionLabel;
- private ToggleControl toggle;
- private boolean readOnly;
- private boolean titleAsHyperlink;
- private boolean addSeparator=true;
- private boolean descriptionPainted=true;
- private boolean headerPainted=true;
- private boolean collapsable=false;
- private Composite control;
-
-
-/*
- * This is a special layout for the section. Both the
- * header and the description labels will wrap and
- * they will use client's size to calculate needed
- * height. This kind of behaviour is not possible
- * with stock grid layout.
- */
-class SectionLayout extends Layout {
- int vspacing = 3;
- int sepHeight = 2;
-
-
- protected Point computeSize(Composite parent, int wHint, int hHint, boolean flush) {
- int width = 0;
- int height = 0;
- int cwidth = 0;
- int collapsedHeight = 0;
-
- if (wHint != SWT.DEFAULT)
- width = wHint;
- if (hHint != SWT.DEFAULT)
- height = hHint;
-
- cwidth = width;
-
- if (client != null) {
- Point csize = client.computeSize(SWT.DEFAULT, SWT.DEFAULT, flush);
- if (width == 0) {
- width = csize.x;
- cwidth = width;
- }
- if (height==0) height = csize.y;
- }
-
- Point toggleSize = null;
-
- if (collapsable && toggle!=null)
- toggleSize = toggle.computeSize(SWT.DEFAULT, SWT.DEFAULT, flush);
-
- if (hHint== SWT.DEFAULT && headerPainted && header!=null) {
- int hwidth = cwidth;
- if (toggleSize!=null)
- hwidth = cwidth - toggleSize.x - 5;
- Point hsize = header.computeSize(hwidth, SWT.DEFAULT, flush);
- height += hsize.y;
- collapsedHeight = hsize.y;
- height += vspacing;
- }
-
- if (hHint==SWT.DEFAULT && addSeparator) {
- height += sepHeight;
- height += vspacing;
- collapsedHeight += vspacing + sepHeight;
- }
- if (hHint == SWT.DEFAULT && descriptionPainted && descriptionLabel!=null) {
- Point dsize = descriptionLabel.computeSize(cwidth, SWT.DEFAULT, flush);
- height += dsize.y;
- height += vspacing;
- }
- if (toggle!=null && toggle.getSelection()) {
- // collapsed state
- height = collapsedHeight;
- }
- return new Point(width, height);
- }
- protected void layout(Composite parent, boolean flush) {
- int width = parent.getClientArea().width;
- int height = parent.getClientArea().height;
- int y = 0;
- Point toggleSize=null;
-
- if (collapsable) {
- toggleSize = toggle.computeSize(SWT.DEFAULT, SWT.DEFAULT, flush);
- }
-
- if (headerPainted && header!=null) {
- Point hsize;
-
- if (titleAsHyperlink) {
- hsize = header.computeSize(SWT.DEFAULT, SWT.DEFAULT, flush);
- header.setBounds(0, y, hsize.x, hsize.y);
- }
- else {
- int availableWidth = width;
- if (toggleSize!=null)
- availableWidth = width - toggleSize.x - 5;
- hsize = header.computeSize(availableWidth, SWT.DEFAULT, flush);
-
- int hx = 0;
- if (toggle!=null) {
- int ty = y + hsize.y - toggleSize.y; // + vspacing;
- toggle.setBounds(0, ty, toggleSize.x, toggleSize.y);
- hx = toggleSize.x;
- }
- header.setBounds(hx, y, availableWidth, hsize.y);
- }
- y += hsize.y + vspacing;
- }
- if (addSeparator && separator!=null) {
- separator.setBounds(0, y, width, 2);
- y += sepHeight + vspacing;
- }
- if (toggle!=null && toggle.getSelection()) {
- return;
- }
- if (descriptionPainted && descriptionLabel!=null) {
- Point dsize = descriptionLabel.computeSize(width, SWT.DEFAULT, flush);
- descriptionLabel.setBounds(0, y, width, dsize.y);
- y += dsize.y + vspacing;
- }
- if (client!=null) {
- client.setBounds(0, y, width, height - y);
- }
- }
-}
-
-
-public FlatPageSection(Composite parent) {
- // Description causes problems re word wrapping
- // and causes bad layout in schema and
- // component editors when in Motif - turning off
-
- super(parent, SWT.FLAT);
- if (SWT.getPlatform().equals("motif")) {
- descriptionPainted = false;
- }
- JFaceResources.getFontRegistry().addListener(this);
-}
-public void commitChanges(boolean onSave) {
-}
-public abstract Composite createClient(Composite parent, WidgetFactory factory);
-public final Control createControl(
- Composite parent,
- WidgetFactory factory) {
- Composite section = factory.createComposite(parent);
- SectionLayout slayout = new SectionLayout();
- section.setLayout(slayout);
- section.setData(this);
-
- if (headerPainted) {
- Color headerColor = factory.getColor(getHeaderColorKey());
- header = factory.createHeadingLabel(section, getHeaderText(), headerColor, SWT.WRAP);
- if (titleAsHyperlink) {
- factory.turnIntoHyperlink(header, new HyperlinkAdapter() {
- public void linkActivated(Control label) {
- titleActivated();
- }
- });
- }
- if (collapsable) {
- toggle = new ToggleControl(section, SWT.NULL);
- toggle.setBackground(factory.getBackgroundColor());
- toggle.setActiveDecorationColor(factory.getHyperlinkColor());
- toggle.setDecorationColor(factory.getColor(WidgetFactory.COLOR_COMPOSITE_SEPARATOR));
- toggle.setActiveCursor(factory.getHyperlinkCursor());
- toggle.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
-
- boolean collapsed = toggle.getSelection();
- reflow();
- if (descriptionLabel!=null)
- descriptionLabel.setVisible(!collapsed);
- if (client!=null)
- client.setVisible(!collapsed);
- }
- });
- }
- }
-
-
- if (addSeparator) {
- //separator = factory.createSeparator(section, SWT.HORIZONTAL);
- separator = factory.createCompositeSeparator(section);
- }
-
- if (descriptionPainted && description != null) {
- descriptionLabel = factory.createLabel(section, description, SWT.WRAP);
- }
- client = createClient(section, factory);
- section.setData(this);
- control = section;
- return section;
-}
-
-protected void reflow() {
- control.layout(true);
- control.getParent().layout(true);
-
- Widget grandParent = control.getParent().getParent();
- if (grandParent != null && grandParent instanceof Composite)
- ((Composite)grandParent).layout(true);
-/*
- SectionForm form = formPage.getForm();
- if (form instanceof ScrollableSectionForm) {
- ((ScrollableSectionForm)form).updateScrollBars();
- }
-*/
-}
-
-protected Text createText(Composite parent, String label, WidgetFactory factory) {
- return createText(parent, label, factory, 1);
-}
-protected Text createText(Composite parent, String label, WidgetFactory factory, int span) {
- factory.createLabel(parent, label);
- Text text = factory.createText(parent, "");
- GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
- gd.grabExcessHorizontalSpace = true;
- gd.horizontalSpan=span;
- text.setLayoutData(gd);
- return text;
-}
-protected Text createText(Composite parent, WidgetFactory factory, int span) {
- Text text = factory.createText(parent, "");
- GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
- gd.grabExcessHorizontalSpace = true;
- gd.horizontalSpan=span;
- text.setLayoutData(gd);
- return text;
-}
-public void dispose() {
- JFaceResources.getFontRegistry().removeListener(this);
- super.dispose();
-}
-public void doGlobalAction(String actionId) {}
-public void expandTo(Object object) {}
-/*
-public final void fireChangeNotification(int changeType, Object changeObject) {
- if (sectionManager == null)
- return;
- sectionManager.dispatchNotification(this, changeType, changeObject);
-}
-public final void fireSelectionNotification(Object changeObject) {
- fireChangeNotification(SELECTION, changeObject);
-}
-*/
-public java.lang.String getDescription() {
- return description;
-}
-/*
-public PDEFormPage getFormPage() {
- return formPage;
-}
-*/
-
-public java.lang.String getHeaderColorKey() {
- return headerColorKey;
-}
-public java.lang.String getHeaderText() {
- return headerText;
-}
-public void initialize(Object input) {}
-
-public boolean isDirty() {
- return dirty;
-}
-
-public boolean isReadOnly() {
- return readOnly;
-}
-public boolean isTitleAsHyperlink() {
- return titleAsHyperlink;
-}
-/*
-public void modelChanged(IModelChangedEvent e) {
-}
-*/
-public void sectionChanged(FlatPageSection source, int changeType, Object changeObject) {}
-public void setAddSeparator(boolean newAddSeparator) {
- addSeparator = newAddSeparator;
-}
-
-
-private String trimNewLines(String text) {
- StringBuffer buff = new StringBuffer();
- for (int i=0; i<text.length(); i++) {
- char c = text.charAt(i);
- if (c=='\n')
- buff.append(' ');
- else
- buff.append(c);
- }
- return buff.toString();
-}
-
-public void setDescription(java.lang.String newDescription) {
- // we will trim the new lines so that we can
- // use layout-based word wrapping instead
- // of hard-coded one
- description = trimNewLines(newDescription);
- //description = newDescription;
- if (descriptionLabel!=null) descriptionLabel.setText(newDescription);
-}
-public void setDescriptionPainted(boolean newDescriptionPainted) {
- descriptionPainted = newDescriptionPainted;
-}
-public void setDirty(boolean newDirty) {
- dirty = newDirty;
-}
-/*
-public void setFocus() {
-}
-*/
-public void setHeaderColorKey(java.lang.String newHeaderColorKey) {
- headerColorKey = newHeaderColorKey;
-}
-public void setHeaderPainted(boolean newHeaderPainted) {
- headerPainted = newHeaderPainted;
-}
-public void setHeaderText(java.lang.String newHeaderText) {
- headerText = newHeaderText;
- if (header!=null) header.setText(headerText);
-}
-/*
-void setManager(SectionChangeManager manager) {
- this.sectionManager = manager;
-}
-*/
-public void setReadOnly(boolean newReadOnly) {
- readOnly = newReadOnly;
-}
-public void setTitleAsHyperlink(boolean newTitleAsHyperlink) {
- titleAsHyperlink = newTitleAsHyperlink;
-}
-public void titleActivated() {
-}
-/*
-public void update() {}
-*/
-
-public void propertyChange(PropertyChangeEvent arg0) {
- if (control!=null && header!=null) {
- if (!header.isDisposed())
- header.setFont(JFaceResources.getBannerFont());
- if (!control.isDisposed())
- control.layout(true);
- }
-}
-
-
- /**
- * Gets the collapsable.
- * @return Returns a boolean
- */
- public boolean getCollapsable() {
- return collapsable;
- }
-
- /**
- * Sets the collapsable.
- * @param collapsable The collapsable to set
- */
- public void setCollapsable(boolean collapsable) {
- this.collapsable = collapsable;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/HyperlinkAdapter.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/HyperlinkAdapter.java
deleted file mode 100644
index 4e52bb988..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/HyperlinkAdapter.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util.flatui;
-
-public class HyperlinkAdapter implements IHyperlinkListener{
-
-public HyperlinkAdapter() {
- super();
-}
-public void linkActivated(org.eclipse.swt.widgets.Control linkLabel) {}
-public void linkEntered(org.eclipse.swt.widgets.Control linkLabel) {}
-public void linkExited(org.eclipse.swt.widgets.Control linkLabel) {}
-}
-
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/HyperlinkHandler.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/HyperlinkHandler.java
deleted file mode 100644
index bcd3c338d..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/HyperlinkHandler.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util.flatui;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseTrackListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-
-public class HyperlinkHandler implements MouseListener, MouseTrackListener, PaintListener {
-
- public static final int UNDERLINE_NEVER = 1;
- public static final int UNDERLINE_ROLLOVER = 2;
- public static final int UNDERLINE_ALWAYS = 3;
-
- private static Cursor hyperlinkCursor;
- private static Cursor busyCursor;
- private boolean hyperlinkCursorUsed=true;
- private int hyperlinkUnderlineMode=UNDERLINE_ALWAYS;
- private Color background;
- private Color foreground;
- private Color activeBackground;
- private Color activeForeground;
- private Hashtable hyperlinkListeners;
- private Control lastLink;
-
-public HyperlinkHandler() {
- hyperlinkListeners = new Hashtable();
- if (hyperlinkCursor == null)
- {
- hyperlinkCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
- busyCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_WAIT);
- }
-}
-public void dispose() {
- hyperlinkCursor.dispose();
- busyCursor.dispose();
-}
-public org.eclipse.swt.graphics.Color getActiveBackground() {
- return activeBackground;
-}
-public org.eclipse.swt.graphics.Color getActiveForeground() {
- return activeForeground;
-}
-public org.eclipse.swt.graphics.Color getBackground() {
- return background;
-}
-public org.eclipse.swt.graphics.Cursor getBusyCursor() {
- return busyCursor;
-}
-public org.eclipse.swt.graphics.Color getForeground() {
- return foreground;
-}
-public org.eclipse.swt.graphics.Cursor getHyperlinkCursor() {
- return hyperlinkCursor;
-}
-public int getHyperlinkUnderlineMode() {
- return hyperlinkUnderlineMode;
-}
-public org.eclipse.swt.widgets.Control getLastLink() {
- return lastLink;
-}
-public boolean isHyperlinkCursorUsed() {
- return hyperlinkCursorUsed;
-}
- public void mouseDoubleClick(MouseEvent e) {
- }
-public void mouseDown(MouseEvent e) {
- if (e.button == 1)
- return;
- lastLink = (Control)e.widget;
-}
-public void mouseEnter(MouseEvent e) {
- Control control = (Control) e.widget;
- if (isHyperlinkCursorUsed())
- control.setCursor(hyperlinkCursor);
- if (activeBackground != null)
- control.setBackground(activeBackground);
- if (activeForeground != null)
- control.setForeground(activeForeground);
- if (hyperlinkUnderlineMode==UNDERLINE_ROLLOVER) underline(control, true);
-
- IHyperlinkListener action =
- (IHyperlinkListener) hyperlinkListeners.get(control);
- if (action != null)
- action.linkEntered(control);
-}
-public void mouseExit(MouseEvent e) {
- Control control = (Control) e.widget;
- if (isHyperlinkCursorUsed())
- control.setCursor(null);
- if (hyperlinkUnderlineMode==UNDERLINE_ROLLOVER)
- underline(control, false);
- if (background != null)
- control.setBackground(background);
- if (foreground != null)
- control.setForeground(foreground);
- IHyperlinkListener action =
- (IHyperlinkListener) hyperlinkListeners.get(control);
- if (action != null)
- action.linkExited(control);
-}
- public void mouseHover(MouseEvent e) {
- }
-public void mouseUp(MouseEvent e) {
- if (e.button != 1)
- return;
- IHyperlinkListener action =
- (IHyperlinkListener) hyperlinkListeners.get(e.widget);
- if (action != null) {
- Control c = (Control) e.widget;
- c.setCursor(busyCursor);
- action.linkActivated(c);
- if (!c.isDisposed())
- c.setCursor(isHyperlinkCursorUsed()?hyperlinkCursor:null);
- }
-}
-public void paintControl(PaintEvent e) {
- Control label = (Control) e.widget;
- if (hyperlinkUnderlineMode == UNDERLINE_ALWAYS)
- HyperlinkHandler.underline(label, true);
-}
-public void registerHyperlink(Control control, IHyperlinkListener listener) {
- if (background != null)
- control.setBackground(background);
- if (foreground != null)
- control.setForeground(foreground);
- control.addMouseListener(this);
- control.addMouseTrackListener(this);
- if (hyperlinkUnderlineMode == UNDERLINE_ALWAYS)
- control.addPaintListener(this);
- hyperlinkListeners.put(control, listener);
- removeDisposedLinks();
-}
-private void removeDisposedLinks() {
- for (Enumeration keys = hyperlinkListeners.keys(); keys.hasMoreElements();) {
- Control control = (Control)keys.nextElement();
- if (control.isDisposed()) {
- hyperlinkListeners.remove(control);
- }
- }
-}
-public void reset() {
- hyperlinkListeners.clear();
-}
-public void setActiveBackground(org.eclipse.swt.graphics.Color newActiveBackground) {
- activeBackground = newActiveBackground;
-}
-public void setActiveForeground(org.eclipse.swt.graphics.Color newActiveForeground) {
- activeForeground = newActiveForeground;
-}
-public void setBackground(org.eclipse.swt.graphics.Color newBackground) {
- background = newBackground;
-}
-public void setForeground(org.eclipse.swt.graphics.Color newForeground) {
- foreground = newForeground;
-}
-public void setHyperlinkCursorUsed(boolean newHyperlinkCursorUsed) {
- hyperlinkCursorUsed = newHyperlinkCursorUsed;
-}
-public void setHyperlinkUnderlineMode(int newHyperlinkUnderlineMode) {
- hyperlinkUnderlineMode = newHyperlinkUnderlineMode;
-}
-public static void underline(Control control, boolean inside) {
- if (!(control instanceof Label))
- return;
- Composite parent = control.getParent();
- Rectangle bounds = control.getBounds();
- GC gc = new GC(parent);
- Color color = inside? control.getForeground() : control.getBackground();
- gc.setForeground(color);
- int y = bounds.y + bounds.height;
- gc.drawLine(bounds.x, y, bounds.x+bounds.width, y);
- gc.dispose();
-}
-}
-
-
-
-
-
-
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/IHyperlinkListener.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/IHyperlinkListener.java
deleted file mode 100644
index 03dfbadcf..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/IHyperlinkListener.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util.flatui;
-
-import org.eclipse.swt.widgets.Control;
-
-public interface IHyperlinkListener {
-
- public void linkActivated(Control linkLabel);
- public void linkEntered(Control linkLabel);
- public void linkExited(Control linkLabel);
-}
-
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/ToggleControl.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/ToggleControl.java
deleted file mode 100644
index 3149fef88..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/ToggleControl.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util.flatui;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.ACC;
-import org.eclipse.swt.accessibility.AccessibleAdapter;
-import org.eclipse.swt.accessibility.AccessibleControlAdapter;
-import org.eclipse.swt.accessibility.AccessibleControlEvent;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseTrackAdapter;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.TypedListener;
-
-public class ToggleControl extends Canvas {
- private boolean fCollapsed;
- private Color fDecorationColor;
- private Color fActiveColor;
- private Cursor fActiveCursor;
- private boolean fHasFocus;
- private boolean fHover = false;
- private static final int MARGIN_WIDTH = 2;
- private static final int MARGIN_HEIGHT = 2;
-
- private static final int DEFAULT_HEIGHT = 8;
- private static final int[] EXPANDED_POINTS = { 0, 2, 8, 2, 4, 6 };
- private static final int[] COLLAPSED_POINTS = { 2, 0, 2, 8, 6, 4 };
- private int fHeight = DEFAULT_HEIGHT;
-
- /* accessibility */
- private String fName;
- private String fDescription;
-
- public ToggleControl(Composite parent, int style) {
- super(parent, style);
- initAccessible();
-
- addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent e) {
- paint(e);
- }
- });
- addMouseListener(new MouseAdapter() {
- public void mouseDown(MouseEvent e) {
- notifyListeners(SWT.Selection);
- }
- });
- addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- if (e.character == '\r' || e.character == ' ') {
- // Activation
- notifyListeners(SWT.Selection);
- }
- }
- });
- addListener(SWT.Traverse, new Listener() {
- public void handleEvent(Event e) {
- if (e.detail != SWT.TRAVERSE_RETURN)
- e.doit = true;
- }
- });
- addFocusListener(new FocusListener() {
- public void focusGained(FocusEvent e) {
- if (!fHasFocus) {
- fHasFocus = true;
- redraw();
- }
- }
- public void focusLost(FocusEvent e) {
- if (fHasFocus) {
- fHasFocus = false;
- redraw();
- }
- }
- });
-
- addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fCollapsed = !fCollapsed;
- redraw();
- }
- });
-
- addMouseTrackListener(new MouseTrackAdapter() {
- public void mouseEnter(MouseEvent e) {
- fHover = true;
- if (fActiveCursor != null)
- setCursor(fActiveCursor);
- redraw();
- }
- public void mouseExit(MouseEvent e) {
- fHover = false;
- if (fActiveCursor != null)
- setCursor(null);
- redraw();
- }
- });
- }
-
- public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener != null)
- addListener(SWT.Selection, new TypedListener(listener));
- }
-
- public void setDecorationColor(Color decorationColor) {
- this.fDecorationColor = decorationColor;
- }
-
- public Color getDecorationColor() {
- return fDecorationColor;
- }
-
- public void setActiveDecorationColor(Color activeColor) {
- this.fActiveColor = activeColor;
- }
-
- public void removeSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener != null)
- removeListener(SWT.Selection, listener);
- }
-
- public void setActiveCursor(Cursor activeCursor) {
- this.fActiveCursor = activeCursor;
- }
-
- public Color getActiveDecorationColor() {
- return fActiveColor;
- }
-
- public Point computeSize(int wHint, int hHint, boolean changed) {
-
- return new Point((wHint != SWT.DEFAULT ? wHint : fHeight + 2 * MARGIN_WIDTH), (hHint != SWT.DEFAULT ? hHint : fHeight + 2 * MARGIN_HEIGHT));
- }
-
- protected void paint(PaintEvent e) {
- GC gc = e.gc;
- Point size = getSize();
- gc.setFont(getFont());
- paint(gc);
- if (fHasFocus) {
- gc.setForeground(getForeground());
- gc.drawFocus(0, 0, size.x, size.y);
- }
- }
-
- /*
- * @see SelectableControl#paint(GC)
- */
- protected void paint(GC gc) {
- if (fHover && fActiveColor != null)
- gc.setBackground(fActiveColor);
- else if (fDecorationColor != null)
- gc.setBackground(fDecorationColor);
- else
- gc.setBackground(getForeground());
- Point size = getSize();
- gc.fillPolygon(translate((fCollapsed ? COLLAPSED_POINTS : EXPANDED_POINTS), ((size.x - fHeight) / 2), ((size.y - fHeight) / 2)));
- gc.setBackground(getBackground());
- }
-
- private int[] translate(int[] data, int x, int y) {
- int[] target = new int[data.length];
- for (int i = 0; i < data.length; i += 2) {
- target[i] = data[i]*fHeight/DEFAULT_HEIGHT + x;
- }
- for (int i = 1; i < data.length; i += 2) {
- target[i] = data[i]*fHeight/DEFAULT_HEIGHT + y;
- }
- return target;
- }
-
- public void setHeight(int y) {
- fHeight = y;
- }
-
- private void notifyListeners(int eventType) {
- Event event = new Event();
- event.type = eventType;
- event.widget = this;
- notifyListeners(eventType, event);
- }
-
- public boolean getSelection() {
- return fCollapsed;
- }
-
- public void setSelection(boolean selection) {
- this.fCollapsed = selection;
- }
-
- public void setName(String name) {
- fName = name;
- }
-
- public void setDescription(String description) {
- fDescription = description;
- }
-
- private void initAccessible() {
- getAccessible().addAccessibleListener(new AccessibleAdapter() {
-
- public void getName(AccessibleEvent e) {
- e.result = fName;
- }
-
- public void getDescription(AccessibleEvent e) {
- e.result = fDescription;
- }
- });
-
- getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {
-
- public void getLocation(AccessibleControlEvent e) {
- Rectangle location = getBounds();
- Point pt = toDisplay(new Point(location.x, location.y));
- e.x = pt.x;
- e.y = pt.y;
- e.width = location.width;
- e.height = location.height;
- }
-
- public void getChildCount(AccessibleControlEvent e) {
- e.detail = 0;
- }
-
- public void getRole(AccessibleControlEvent e) {
- e.detail = ACC.ROLE_TREE;
- }
-
- public void getState(AccessibleControlEvent e) {
- e.detail = fCollapsed ? ACC.STATE_COLLAPSED : ACC.STATE_EXPANDED;
- }
-
- });
- }
-
-}
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/WidgetFactory.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/WidgetFactory.java
deleted file mode 100644
index c09998212..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/flatui/WidgetFactory.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util.flatui;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.custom.TableTree;
-import org.eclipse.swt.custom.ViewForm;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin;
-
-
-public class WidgetFactory {
- public static final String DEFAULT_HEADER_COLOR = "__default__header__";
- public static final String COLOR_BACKGROUND = "__bg";
- public static final String COLOR_BORDER = "__border";
- public static final String COLOR_COMPOSITE_SEPARATOR = "__compSep";
- public static final String COLOR_HYPERLINK="__hyperlink";
-
- private Hashtable colorRegistry = new Hashtable();
- private Color backgroundColor;
- private Color clientAreaColor;
- private Color foregroundColor;
- private Color fReadOnlyColor;
- private Display fDisplay;
- public static final int BORDER_STYLE = SWT.NONE;
- private BorderPainter borderPainter;
- private Color borderColor;
- private HyperlinkHandler hyperlinkHandler;
- private static Image fBanner;
-
-
- class BorderPainter implements PaintListener {
- public void paintControl(PaintEvent event) {
- Composite composite = (Composite) event.widget;
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; i++) {
- Control c = children[i];
- //if (c.isEnabled()==false) continue;
- if (c instanceof Text
- || c instanceof Canvas
- || c instanceof CCombo) {
- Rectangle b = c.getBounds();
- GC gc = event.gc;
- gc.setForeground(c.getBackground());
- gc.drawRectangle(b.x - 1, b.y - 1, b.width + 1, b.height + 1);
- gc.setForeground(foregroundColor);
- gc.drawRectangle(b.x - 2, b.y - 2, b.width + 3, b.height + 3);
- }
- else if (c instanceof Table
- || c instanceof Tree
- || c instanceof TableTree) {
- Rectangle b = c.getBounds();
- GC gc = event.gc;
- gc.setForeground(borderColor);
- //gc.drawRectangle(b.x - 2, b.y - 2, b.width + 3, b.height + 3);
- gc.drawRectangle(b.x-1, b.y-1, b.width+2, b.height+2);
- }
- }
- }
- }
-
-
-public WidgetFactory() {
- fDisplay = Display.getDefault();
- initialize();
-}
-
-public Button createButton(Composite parent, String text, int style) {
- int flatStyle = BORDER_STYLE == SWT.BORDER ? SWT.NULL : SWT.FLAT;
- //int flatStyle = SWT.NULL;
- Button button = new Button(parent, style | flatStyle);
- button.setBackground(backgroundColor);
- button.setForeground(foregroundColor);
- if (text!=null) button.setText(text);
- return button;
-}
-public Composite createComposite(Composite parent) {
- return createComposite(parent, SWT.NULL);
-}
-public Composite createComposite(Composite parent, int style) {
- Composite composite = new Composite(parent, style);
- composite.setBackground(backgroundColor);
- return composite;
-}
-public Composite createCompositeSeparator(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setBackground(getColor(COLOR_COMPOSITE_SEPARATOR));
- return composite;
-}
-public Group createGroup(Composite parent, String text) {
- Group group = new Group(parent, SWT.SHADOW_NONE);
- group.setText(text);
- group.setBackground(backgroundColor);
- group.setForeground(foregroundColor);
- return group;
-}
-public Label createHeadingLabel(Composite parent, String text, Color bg) {
- return createHeadingLabel(parent, text, bg, SWT.NONE);
-}
-public Label createHeadingLabel(Composite parent, String text, Color bg, int style) {
- Label label = new Label(parent, style);
- label.setText(text);
- label.setBackground(backgroundColor);
- label.setForeground(foregroundColor);
- label.setFont(JFaceResources.getFontRegistry().get(JFaceResources.BANNER_FONT));
- return label;
-}
-public Label createHyperlinkLabel(Composite parent, String text, IHyperlinkListener listener) {
- return createHyperlinkLabel(parent, text, listener, SWT.NULL);
-}
-public Label createHyperlinkLabel(Composite parent, String text, IHyperlinkListener listener, int style) {
- Label label = createLabel(parent, text, style);
- turnIntoHyperlink(label, listener);
- return label;
-}
-public Label createLabel(Composite parent, String text) {
- return createLabel(parent, text, SWT.NONE);
-}
-public Label createLabel(Composite parent, String text, int style) {
- Label label = new Label(parent, style);
- if (text!=null) label.setText(text);
- label.setBackground(backgroundColor);
- label.setForeground(foregroundColor);
- return label;
-}
-public Label createSeparator(Composite parent, int style) {
- Label label = new Label(parent, SWT.SEPARATOR | style);
- label.setBackground(backgroundColor);
- label.setForeground(borderColor);
- return label;
-}
-public ScrolledComposite createScrolledComposite (Composite parent) {
- ScrolledComposite scrolledcomposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
- scrolledcomposite.setBackground(backgroundColor);
- scrolledcomposite.setForeground(foregroundColor);
- return scrolledcomposite;
-}
-public Table createTable(Composite parent, int style) {
- Table table = new Table(parent, BORDER_STYLE | style);
- table.setBackground(backgroundColor);
- table.setForeground(foregroundColor);
- //hookDeleteListener(table);
- return table;
-}
-public Text createText(Composite parent, String value) {
- return createText(parent, value, BORDER_STYLE | SWT.SINGLE);
-}
-public Text createText(Composite parent, String value, int style) {
- Text text = new Text(parent, style);
- text.setText(value);
- text.setBackground(clientAreaColor);
- text.setForeground(foregroundColor);
- if ((style & SWT.READ_ONLY) != 0)
- text.setForeground(fReadOnlyColor);
- return text;
-}
-public Tree createTree(Composite parent, int style) {
- Tree tree = new Tree(parent, BORDER_STYLE | style);
- tree.setBackground(backgroundColor);
- tree.setForeground(foregroundColor);
- //hookDeleteListener(tree);
- return tree;
-}
-/*
-private void deleteKeyPressed(Widget widget) {
- if (!(widget instanceof Control)) return;
- Control control = (Control)widget;
- for (Control parent = control.getParent();
- parent != null;
- parent = parent.getParent()) {
- if (parent.getData() instanceof FormSection) {
- FormSection section = (FormSection) parent.getData();
- section.doGlobalAction(IWorkbenchActionConstants.DELETE);
- break;
- }
- }
-}
-*/
-public ViewForm createViewForm(Composite parent) {
- ViewForm viewForm = new ViewForm(parent, SWT.NULL);
- viewForm.setBackground(clientAreaColor);
- viewForm.setForeground(foregroundColor);
- return viewForm;
-}
-public void dispose() {
- Enumeration colors= colorRegistry.elements();
- while (colors.hasMoreElements()) {
- Color c = (Color)colors.nextElement();
- c.dispose();
- }
- hyperlinkHandler.dispose();
- colorRegistry=null;
- if (fBanner != null)
- {
- fBanner.dispose();
- fBanner = null;
- }
-}
-public Color getBackgroundColor() {
- return backgroundColor;
-}
-public Image getBanner() {
- if (fBanner == null)
- {
- try {
- fBanner = (ImageDescriptor.createFromURL(new URL((WSDLEditorPlugin.getInstance().getDescriptor().getInstallURL()), "icons\form_banner.gif"))).createImage();
- System.out.println("Created Image!!!! ");
- } catch (MalformedURLException e) {
- System.out.println("Exception!!!! " + e);
- }
- }
- return fBanner;
-}
-public Color getBorderColor() {
- return borderColor;
-}
-public Cursor getBusyCursor() {
- return hyperlinkHandler.getBusyCursor();
-}
-public Color getClientAreaColor() {
- return clientAreaColor;
-}
-public Color getColor(String key) {
- return (Color)colorRegistry.get(key);
-}
-public Color getForegroundColor() {
- return foregroundColor;
-}
-public Color getHyperlinkColor() {
- return hyperlinkHandler.getForeground();
-}
-public Cursor getHyperlinkCursor() {
- return hyperlinkHandler.getHyperlinkCursor();
-}
-public Color getHyperlinkHoverColor() {
- return hyperlinkHandler.getActiveForeground();
-}
-public int getHyperlinkUnderlineMode() {
- return hyperlinkHandler.getHyperlinkUnderlineMode();
-}
-/*
-public void hookDeleteListener(Control control) {
- if (deleteListener == null) {
- deleteListener = new KeyAdapter() {
- public void keyPressed(KeyEvent event) {
- if (event.character == SWT.DEL && event.stateMask == 0) {
- deleteKeyPressed(event.widget);
- }
- }
- };
- }
- control.addKeyListener(deleteListener);
-}
-*/
- private void initStaticColors()
- {
- if (colorRegistry == null)
- {
- colorRegistry = new Hashtable();
- registerColor(COLOR_BACKGROUND, 0xff, 0xfe, 0xf9);
- registerColor(COLOR_BORDER, 195, 191, 179);
- registerColor(COLOR_COMPOSITE_SEPARATOR, 152, 170, 203);
- registerColor(DEFAULT_HEADER_COLOR, 0x48, 0x70, 0x98);
- registerColor(COLOR_HYPERLINK, 0, 0, 153);
- }
- }
-
-private void initialize() {
- clientAreaColor = fDisplay.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- fReadOnlyColor = fDisplay.getSystemColor(SWT.COLOR_DARK_GRAY);
- initStaticColors();
- backgroundColor = clientAreaColor;
- borderColor = getColor(COLOR_BORDER);
- foregroundColor = fDisplay.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
- hyperlinkHandler = new HyperlinkHandler();
- hyperlinkHandler.setForeground(getColor(COLOR_HYPERLINK));
- hyperlinkHandler.setBackground(backgroundColor);
-}
-public void paintBordersFor(Composite parent) {
- if (BORDER_STYLE == SWT.BORDER) return;
- if (borderPainter==null) borderPainter = new BorderPainter();
- parent.addPaintListener(borderPainter);
-}
-public Color registerColor(String key, int r, int g, int b) {
- Color c = new Color(fDisplay, r, g, b);
- colorRegistry.put(key, c);
- return c;
-}
-
-public void setClientAreaColor(Color color)
-{
- clientAreaColor = color;
- backgroundColor = clientAreaColor;
-}
-
-public void setHyperlinkColor(Color color) {
- hyperlinkHandler.setForeground(color);
-}
-public void setHyperlinkHoverColor(org.eclipse.swt.graphics.Color hoverColor) {
- hyperlinkHandler.setActiveForeground(hoverColor);
-}
-public void setHyperlinkUnderlineMode(int newHyperlinkUnderlineMode) {
- hyperlinkHandler.setHyperlinkUnderlineMode(newHyperlinkUnderlineMode);
-}
-public void turnIntoHyperlink(Control control, IHyperlinkListener listener) {
- hyperlinkHandler.registerHyperlink(control, listener);
-}
-
-}
-
-
-
-
-
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/BaseDesignWindow.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/BaseDesignWindow.java
deleted file mode 100644
index 4d30cf1ca..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/BaseDesignWindow.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util.ui;
-
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.part.EditorActionBarContributor;
-import org.eclipse.wst.common.ui.internal.UIPlugin;
-
-abstract public class BaseDesignWindow extends Viewer
-{
- protected ScrolledComposite mainUIComponent;
- protected Composite controlsContainer;
-
- protected boolean pageComplete = true;
- protected Object input;
-
- private IStatusLineManager statusLine;
-
- public BaseDesignWindow(IStatusLineManager statusLine)
- {
- this.statusLine = statusLine;
- }
-
- protected void setStatusLine(IStatusLineManager statusLine)
- {
- this.statusLine = statusLine;
- }
-
- protected IStatusLineManager getStatusLine()
- {
- if (statusLine == null)
- {
- //statusLine = WorkbenchUtility.getStatusLineManager();
-
- IWorkbench workbench = UIPlugin.getDefault().getWorkbench();
- IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
- IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor();
-
- try
- {
- EditorActionBarContributor contributor = (EditorActionBarContributor)editorPart.getEditorSite().getActionBarContributor();
- statusLine = contributor.getActionBars().getStatusLineManager();
- }
- catch (Exception e)
- {
- }
- }
- return statusLine;
- }
-
- public Object getInput()
- {
- return input;
- }
-
- public void setInput(Object input)
- {
- if (this.input != input)
- {
- setErrorMessage("");
- }
-
- this.input = input;
- }
-
- public ISelection getSelection()
- {
- return null;
- }
-
- public void setSelection(ISelection selection, boolean reveal)
- {
- }
-
- public void refresh()
- {
- }
-
- /**
- * A design view that has a main area for controls, and a message line at
- * the bottom
- */
- protected Control createDesignPane(Composite parent, int numColumns)
- {
- // Create the main UI container
- mainUIComponent= new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL)
- {
- public void setVisible(boolean visible)
- {
- super.setVisible(visible);
- if (visible == false && !currentMessage.equals(""))
- {
- showMessageInStatusLine(visible == true);
- }
- }
- };
-
-// mainUIComponent.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- controlsContainer = new Composite(mainUIComponent, SWT.NONE);
-
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- controlsContainer.setLayout(layout);
-
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- controlsContainer.setLayoutData(data);
-
- // TODO: Remove above line and uncomment the following two when XSDEditor views
- // are rewritten. Also refer do related TODO in DTDEditor's BaseWindow.
- // FlatViewUtility flatViewUtility = new FlatViewUtility();
- // controlsContainer = flatViewUtility.createComposite(mainUIComponent, numColumns);
-
- mainUIComponent.setContent(controlsContainer);
-
- return mainUIComponent;
- }
-
- public void setScrollComposite()
- {
- Point p = controlsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- mainUIComponent.setExpandHorizontal(true);
- mainUIComponent.setExpandVertical(true);
- mainUIComponent.setMinSize(p);
- }
-
- public Composite getControlsContainer()
- {
- return controlsContainer;
- }
-
- /**
- * Sets the complete state of the page.
- * If false, then client is not allowed to move to next page
- */
- public void setPageComplete(boolean complete)
- {
- pageComplete= complete;
- }
-
- /**
- * Returns whether the page is complete or not.
- */
- public boolean isPageComplete()
- {
- return pageComplete;
- }
-
- private String currentMessage = "";
- protected void showMessageInStatusLine(boolean show)
- {
- if (getStatusLine() == null)
- return;
-
- if (show)
- {
- getStatusLine().setErrorMessage(currentMessage);
- }
- else
- {
- getStatusLine().setErrorMessage("");
- }
-
-
- getStatusLine().update(false);
- }
-
- /**
- * Sets the message line
- */
- public void setMessage(String message)
- {
- currentMessage = message;
- if (getStatusLine() != null)
- {
- getStatusLine().setErrorMessage(currentMessage);
- getStatusLine().update(false);
- }
- }
-
- /**
- * Clears a message.
- */
- public void clearMessage()
- {
- currentMessage = "";
- if (getStatusLine() != null)
- {
- getStatusLine().setErrorMessage(currentMessage);
- getStatusLine().update(false);
- }
- }
-
- public void setErrorMessage(String message)
- {
- setMessage(message);
- setPageComplete(false);
- }
-
- public void clearErrorMessage()
- {
- clearMessage();
- setPageComplete(true);
- }
-
- public String getErrorMessage()
- {
- return currentMessage;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/BorderPainter.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/BorderPainter.java
deleted file mode 100644
index 47bdeb5f3..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/BorderPainter.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util.ui;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.custom.TableTree;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Tree;
-
-public class BorderPainter implements PaintListener
-{
- Color backgroundColor, foregroundColor;
- static Color borderColor;
-
- public BorderPainter()
- {
- Display display = Display.getCurrent();
- if (borderColor == null)
- {
- borderColor = new Color(Display.getCurrent(), 195, 191, 179);
- }
- backgroundColor = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- foregroundColor = display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
- }
-
- public void paintControl(PaintEvent event)
- {
- Composite composite = (Composite) event.widget;
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; i++)
- {
- Control c = children[i];
- if (c.isEnabled()==false)
- {
- if (c instanceof Text
- || c instanceof Canvas
- || c instanceof List
- || c instanceof CCombo)
- {
- Rectangle b = c.getBounds();
- GC gc = event.gc;
- gc.setForeground(backgroundColor);
-// gc.drawRectangle(b.x - 1, b.y - 1, b.width + 1, b.height + 1);
- gc.setForeground(borderColor);
- gc.drawRectangle(b.x - 2, b.y - 2, b.width + 3, b.height + 3);
- }
- continue;
- }
- if (c instanceof Text
-// || c instanceof Canvas
- || c instanceof List
- || c instanceof CCombo)
- {
- Rectangle b = c.getBounds();
- GC gc = event.gc;
- gc.setForeground(backgroundColor);
- gc.drawRectangle(b.x - 1, b.y - 1, b.width + 1, b.height + 1);
- gc.setForeground(foregroundColor);
- gc.drawRectangle(b.x - 2, b.y - 2, b.width + 3, b.height + 3);
- }
- else if (c instanceof Table
- || c instanceof Tree
- || c instanceof TableTree) {
- Rectangle b = c.getBounds();
- GC gc = event.gc;
- gc.setForeground(foregroundColor);
- //gc.drawRectangle(b.x - 2, b.y - 2, b.width + 3, b.height + 3);
- gc.drawRectangle(b.x-1, b.y-1, b.width+2, b.height+2);
- }
- }
- }
-}
-
diff --git a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/FlatViewUtility.java b/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/FlatViewUtility.java
deleted file mode 100644
index f0b9fb552..000000000
--- a/bundles/org.eclipse.wst.wsdl.ui/src/org/eclipse/wst/wsdl/ui/internal/util/ui/FlatViewUtility.java
+++ /dev/null
@@ -1,902 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.ui.internal.util.ui;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.FontMetrics;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.part.PageBook;
-import org.eclipse.wst.wsdl.ui.internal.WSDLEditorPlugin;
-import org.eclipse.wst.wsdl.ui.internal.util.flatui.FlatPageHeader;
-import org.eclipse.wst.wsdl.ui.internal.util.flatui.WidgetFactory;
-
-public class FlatViewUtility implements PaintListener
-{
- Color backgroundColor, foregroundColor;
- Color comboBackgroundColor, comboDisabledColor;
- static Color borderColor;
-
- // Added for createFlatPageHeader()
- private boolean headingVisible=true;
- private Image headingImage = null;
- private Composite headerControl = null;
- private int TITLE_VMARGIN = 5;
-
- private KeyboardHandler keyboardHandler;
-
- public static final int H_SCROLL_INCREMENT = 5;
- public static final int V_SCROLL_INCREMENT = 64;
-
- // this defaults to the flat style, but users can change it if they wish
- private int flatStyle = SWT.FLAT;
- private int border = 0;
-
- public FlatViewUtility()
- {
- Display display = Display.getCurrent();
- if (borderColor == null)
- {
- borderColor = new Color(Display.getCurrent(), 195, 191, 179);
- }
- backgroundColor = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- foregroundColor = display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
- comboBackgroundColor = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- comboDisabledColor = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
- keyboardHandler = new KeyboardHandler();
- }
-
- public FlatViewUtility(boolean isFlat)
- {
- this();
-
- setFlat(isFlat);
- }
-
- public void setFlat(boolean flat)
- {
- Display display = Display.getCurrent();
- if (flat)
- {
- flatStyle = SWT.FLAT;
- backgroundColor = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- foregroundColor = display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
- }
- else
- {
- flatStyle = 0;
- border = SWT.BORDER;
- backgroundColor = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
- foregroundColor = display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND);
- }
- }
-
- public void setColor(Control c)
- {
- if (flatStyle == SWT.FLAT)
- {
- c.setBackground(backgroundColor);
- }
- }
-
- public void paintControl(PaintEvent event)
- {
- Control c = (Control) event.widget;
- if (c.isEnabled()==false)
- {
- if (c instanceof Text
-// || c instanceof Canvas
- || c instanceof List
- || c instanceof CCombo)
- {
- GC gc = event.gc;
- gc.setForeground(backgroundColor);
-// gc.drawRectangle(b.x - 1, b.y - 1, b.width + 1, b.height + 1);
- gc.setForeground(borderColor);
-// gc.drawRectangle(b.x - 2, b.y - 2, b.width + 3, b.height + 3);
- }
- }
-
- // Defect 252891 : this causes some major problems on Linux GTK
- // This looks rather dodgy in any case since an cyclic painting behaviour
- // is likely occuring here
- //if (c.getParent() != null)
- //{
- // c.getParent().redraw();
- //}
- }
-
- private static Font font;
-
- public static Font getFont()
- {
- if (font == null)
- {
- font = new Font(Display.getCurrent(), "ms sans serif", 8, SWT.NORMAL);
- }
- return font;
- }
-
- public static void setFont(Font newFont)
- {
- font = newFont;
- }
-
- public static void setComposite(Composite comp)
- {
- // deprecated. Remove later
- }
-
- public Composite createSimpleComposite(Composite parent, int style)
- {
- Composite composite = new Composite(parent, style | flatStyle);
- composite.setFont(getFont());
- setColor(composite);
-
- GridLayout layout = new GridLayout();
- composite.setLayout(layout);
- return composite;
- }
-
- public Composite createComposite(Composite parent, int numColumns)
- {
- Composite composite = new Composite(parent, SWT.NONE | flatStyle);
- composite.setFont(getFont());
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- composite.setLayout(layout);
-
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- composite.setLayoutData(data);
- setColor(composite);
- if (flatStyle == SWT.FLAT)
- {
- composite.addPaintListener(new BorderPainter());
- }
- return composite;
- }
-
- public Composite createComposite(Composite parent, int numColumns, boolean horizontalFill)
- {
- if (!horizontalFill)
- {
- createComposite(parent, numColumns);
- }
-
- Composite composite = new Composite(parent, SWT.NONE | flatStyle);
- composite.setFont(getFont());
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- composite.setLayout(layout);
-
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- composite.setLayoutData(data);
- setColor(composite);
- if (flatStyle == SWT.FLAT)
- {
- composite.addPaintListener(new BorderPainter());
- }
- return composite;
- }
-
- public Composite createComposite(Composite parent, int numColumns, boolean horizontalFill, boolean verticalFill)
- {
- if (!horizontalFill && !verticalFill)
- {
- createComposite(parent, numColumns);
- }
-
- Composite composite = new Composite(parent, SWT.NONE | flatStyle);
- composite.setFont(getFont());
-
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- composite.setLayout(layout);
-
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- data.grabExcessVerticalSpace = true;
- composite.setLayoutData(data);
- setColor(composite);
- if (flatStyle == SWT.FLAT)
- {
- composite.addPaintListener(new BorderPainter());
- }
- return composite;
- }
-
- public SashForm createSashForm(Composite parent, int style)
- {
- SashForm sashForm = new SashForm(parent, style | flatStyle);
- setColor(sashForm);
- return sashForm;
- }
-
- public PageBook createPageBook(Composite parent, int style)
- {
- PageBook pageBook = new PageBook(parent, style | flatStyle);
- setColor(pageBook);
- if (flatStyle == SWT.FLAT)
- {
- pageBook.addPaintListener(new BorderPainter());
- }
- return pageBook;
- }
-
- public Label createHeadingLabel(Composite parent, String text, Color bg) {
- return createHeadingLabel(parent, text, bg, SWT.NONE);
- }
- public Label createHeadingLabel(Composite parent, String text, Color bg, int style) {
- Label label = new Label(parent, style);
- label.setText(text);
- setColor(label);
- if (flatStyle == SWT.FLAT)
- {
- label.setForeground(foregroundColor);
- }
- label.setFont(JFaceResources.getFontRegistry().get(JFaceResources.BANNER_FONT));
- return label;
- }
-
- public Label createHorizontalFiller(Composite parent, int horizontalSpan)
- {
- Label label = new Label(parent, SWT.LEFT | flatStyle);
- setColor(label);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.horizontalSpan = horizontalSpan;
- label.setLayoutData(data);
- return label;
- }
-
- /**
- * Helper method for creating labels.
- */
- public Label createLabel(Composite parent, int style, String text)
- {
- Label label = new Label(parent, style | flatStyle);
- setColor(label);
- label.setText(text);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- label.setLayoutData(data);
- return label;
- }
-
- public Label createLabel(Composite parent, String text)
- {
- Label label = new Label(parent, SWT.LEFT | flatStyle);
- setColor(label);
- label.setText(text);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- label.setLayoutData(data);
- return label;
- }
-
- public Label createLabel(Composite parent, String text, int alignment)
- {
- Label label = new Label(parent, SWT.LEFT | flatStyle);
- label.setText(text);
- setColor(label);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.verticalAlignment = alignment;
- label.setLayoutData(data);
- return label;
- }
-
- /**
- * Helper method for creating buttons.
- */
- public Button createPushButton(Composite parent, String label)
- {
- Button button = new Button(parent, SWT.PUSH | flatStyle);
- button.setText(label);
- setColor(button);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- button.setLayoutData(data);
- button.addKeyListener(keyboardHandler);
-
- return button;
- }
-
- public Table createTable(Composite parent)
- {
- Table table = new Table(parent, SWT.SINGLE | SWT.BORDER | flatStyle);
- setColor(table);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- table.setLayoutData(data);
- return table;
- }
-
- /**
- * Create radio button
- */
- public Button createRadioButton(Composite parent, String label)
- {
- Button button = new Button(parent, SWT.RADIO | flatStyle);
- button.setText(label);
- setColor(button);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- button.setLayoutData(data);
- button.addKeyListener(keyboardHandler);
-
- return button;
- }
-
- /**
- * Helper method for creating check box
- */
- public Button createCheckBox(Composite parent, String label)
- {
- Button button = new Button(parent, SWT.CHECK | flatStyle);
- button.setText(label);
- setColor(button);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- button.setLayoutData(data);
- return button;
- }
-
- public Combo createComboBox(Composite parent)
- {
- return createComboBox(parent, true);
- }
-
- public Combo createComboBox(Composite parent, boolean isReadOnly)
- {
- int style = isReadOnly == true ? SWT.READ_ONLY : SWT.DROP_DOWN;
-
- Combo combo = new Combo(parent, style | flatStyle | border);
- setColor(combo);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- combo.setLayoutData(data);
- return combo;
- }
-
- public CCombo createCComboBox(Composite parent)
- {
- return createCComboBox(parent, true);
- }
-
- public CCombo createCComboBox(Composite parent, boolean isReadOnly)
- {
- int style = isReadOnly == true ? SWT.READ_ONLY : SWT.DROP_DOWN;
-
- CCombo combo = new CCombo(parent, style | flatStyle | border);
- // setColor(combo);
- // Always use List Background
- combo.setBackground(comboBackgroundColor);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.verticalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- combo.setLayoutData(data);
- if (flatStyle == SWT.FLAT)
- {
- combo.addPaintListener(this);
- }
- else
- {
- /*
- // Defect 252891 : I'm not sure if this code will also cause problems on Linux GTK
- // But since its potentially cyclic ... I'm commenting it out for now
- combo.addPaintListener(new PaintListener()
- {
- public void paintControl(PaintEvent event)
- {
- Control c = (Control) event.widget;
- if (c.isEnabled()==true)
- {
- c.setBackground(comboBackgroundColor);
- }
- else
- {
- c.setBackground(comboDisabledColor);
- }
- final Control con = c;
- Runnable delayedUpdate = new Runnable()
- {
- public void run()
- {
- if (con != null)
- {
- if (!con.isDisposed()) // it gets disposed
- {
- con.redraw();
- }
- }
- }
- };
- Display.getCurrent().asyncExec(delayedUpdate);
- }
- });*/
- }
- return combo;
- }
-
- public List createListBox(Composite parent, int width, boolean isMultiSelect)
- {
- int style = isMultiSelect ? SWT.MULTI : SWT.SINGLE;
- List list = new List(parent, style | flatStyle | border);
- setColor(list);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- data.widthHint = width;
- list.setLayoutData(data);
- if (flatStyle == SWT.FLAT)
- {
- list.addPaintListener(this);
- }
- return list;
- }
-
- public List createListBox(Composite parent, int width, boolean isMultiSelect, boolean verticalFill)
- {
- int style = isMultiSelect ? SWT.MULTI : SWT.SINGLE;
- List list = new List(parent, style | flatStyle | border);
- setColor(list);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.verticalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- data.grabExcessVerticalSpace = verticalFill;
- data.widthHint = width;
- list.setLayoutData(data);
- if (flatStyle == SWT.FLAT)
- {
- list.addPaintListener(this);
- }
- return list;
- }
-
- public List createListBox(Composite parent, int style)
- {
- List list = new List(parent, style | flatStyle | border);
- setColor(list);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.verticalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- data.grabExcessVerticalSpace = true;
- list.setLayoutData(data);
- if (flatStyle == SWT.FLAT)
- {
- list.addPaintListener(this);
- }
- return list;
- }
-
- public Text createTextField(Composite parent)
- {
- Text text = new Text(parent, SWT.SINGLE | flatStyle | border);
- setColor(text);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.verticalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- text.setLayoutData(data);
- if (flatStyle == SWT.FLAT)
- {
- text.addPaintListener(this);
- }
- text.addKeyListener(keyboardHandler);
- return text;
- }
-
- public Text createTextField(Composite parent, int width)
- {
- Text text = new Text(parent, SWT.SINGLE | flatStyle | border);
- setColor(text);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.verticalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- data.widthHint = width;
- text.setLayoutData(data);
- if (flatStyle == SWT.FLAT)
- {
- text.addPaintListener(this);
- }
- text.addKeyListener(keyboardHandler);
- return text;
- }
-
- public Text createTextField(Composite parent, int width, int style)
- {
- Text text = new Text(parent, style | SWT.SINGLE | flatStyle | border);
- setColor(text);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.verticalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- data.widthHint = width;
- text.setLayoutData(data);
- if (flatStyle == SWT.FLAT)
- {
- text.addPaintListener(this);
- }
- return text;
- }
-
- /**
- * <code>createWrappedMultiTextField</code> creates a wrapped multitext field
- *
- * @param parent a <code>Composite</code> value
- * @param width an <code>int</code> value
- * @param numLines an <code>int</code> value representing number of characters in height
- * @param verticalFill a <code>boolean</code> value
- * @return a <code>Text</code> value
- */
- public Text createWrappedMultiTextField(Composite parent, int width, int numLines, boolean verticalFill)
- {
- Text text = new Text(parent, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | flatStyle | border);
- setColor(text);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- if (verticalFill)
- {
- data.verticalAlignment = GridData.FILL;
- data.grabExcessVerticalSpace = true;
- }
- data.widthHint = width;
- FontData[] fontData = getFont().getFontData();
- // hack for now where on Windows, only 1 fontdata exists
- data.heightHint = numLines * fontData[0].getHeight();
- text.setLayoutData(data);
- if (flatStyle == SWT.FLAT)
- {
- text.addPaintListener(this);
- }
- return text;
- }
-
- public Text createMultiTextField(Composite parent, int width, int height, boolean verticalFill)
- {
- Text text = new Text(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | flatStyle | border);
- setColor(text);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- if (verticalFill)
- {
- data.verticalAlignment = GridData.FILL;
- data.grabExcessVerticalSpace = true;
- }
- data.widthHint = width;
- data.heightHint = height;
- text.setLayoutData(data);
- if (flatStyle == SWT.FLAT)
- {
- text.addPaintListener(this);
- }
- return text;
- }
-
- public Text createMultiTextField(Composite parent, boolean verticalFill)
- {
- Text text = new Text(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | flatStyle | border);
- setColor(text);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- if (verticalFill)
- {
- data.verticalAlignment = GridData.FILL;
- data.grabExcessVerticalSpace = true;
- }
- text.setLayoutData(data);
- if (flatStyle == SWT.FLAT)
- {
- text.addPaintListener(this);
- }
- return text;
- }
-
- public Group createGroup(Composite parent, int numColumns, String text, boolean verticalFill)
- {
- Group group = new Group(parent, SWT.SHADOW_ETCHED_IN | flatStyle);
- group.setText(text);
- setColor(group);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- if (verticalFill)
- {
- data.verticalAlignment = GridData.FILL;
- data.grabExcessVerticalSpace = true;
- }
- group.setLayoutData(data);
-
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- group.setLayout(layout);
- if (flatStyle == SWT.FLAT)
- {
- group.addPaintListener(new BorderPainter());
- }
- return group;
- }
-
- public Group createGroup(Composite parent, int numColumns, String text, boolean verticalFill, int alignment)
- {
- Group group = new Group(parent, SWT.SHADOW_ETCHED_IN | flatStyle);
- group.setText(text);
- setColor(group);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- data.verticalAlignment = alignment;
- if (verticalFill)
- {
- data.verticalAlignment = GridData.FILL;
- data.grabExcessVerticalSpace = true;
- }
- group.setLayoutData(data);
-
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- group.setLayout(layout);
- if (flatStyle == SWT.FLAT)
- {
- group.addPaintListener(new BorderPainter());
- }
- return group;
- }
-
- public Label createVerticalFiller(Composite parent, int verticalSpan)
- {
- Label label = new Label(parent, SWT.LEFT | flatStyle);
- label.setFont(getFont());
- setColor(label);
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.verticalSpan = verticalSpan;
- label.setLayoutData(data);
-
- return label;
- }
-
- //
- // FlatPageHeader
- //
-
- // This will use the default background image.
- public Composite createFlatPageHeader
- (Composite parent,
- String title)
- {
- Image bgImage = createDefaultImage();
- return createFlatPageHeader(parent,bgImage,title);
- }
-
- // Provide your own background image.
- public Composite createFlatPageHeader
- (Composite parent,
- Image bgImage,
- String title)
- {
- FlatPageHeader header = new FlatPageHeader(parent,SWT.NONE);
- header.setLayout(new PageLayout());
- header.setBackgroundImage(bgImage);
- header.setText(title);
- WidgetFactory factory = new WidgetFactory();
- Composite formParent = factory.createComposite(header);
- //Composite formParent = createComposite(header,1);
- createPageContent(formParent);
- headerControl = header; // this is used in getTitleHeight()
- return formParent;
- }
-
- public void updateFlatPageHeaderTitle(String title)
- {
- ((FlatPageHeader)headerControl).setText(title);
- }
-
- private void createPageContent(Composite parent)
- {
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- parent.setLayout(layout);
- parent.setLayoutData(new GridData(GridData.FILL_BOTH));
- }
-
- class PageLayout extends Layout
- {
- protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache)
- {
- if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT)
- return new Point(wHint, hHint);
-
- Control client = composite.getChildren()[0];
- Point csize = client.computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
- if (headingVisible) csize.y += getTitleHeight();
-
- return csize;
- }
-
- protected void layout(Composite composite, boolean flushCache)
- {
- Rectangle clientArea = composite.getClientArea();
- Control client = composite.getChildren()[0];
- int theight = headingVisible ? getTitleHeight() : 0;
- client.setBounds(clientArea.x, clientArea.y + theight, clientArea.width, clientArea.height - theight);
- }
- }
-
- private int getTitleHeight()
- {
- int imageHeight = 0;
- // Note - Find out why headingImage is always null.
- if (headingImage != null && SWT.getPlatform().equals("motif") == false)
- imageHeight = headingImage.getBounds().height;
-
- GC gc = new GC(headerControl);
- gc.setFont(JFaceResources.getHeaderFont());
- FontMetrics fm = gc.getFontMetrics();
- int fontHeight = fm.getHeight();
- gc.dispose();
-
- int height = fontHeight + TITLE_VMARGIN + TITLE_VMARGIN;
- return Math.max(height,imageHeight);
- }
-
-
- private Image createDefaultImage()
- {
- return ImageDescriptor.createFromFile
- (WSDLEditorPlugin.class,
- "icons/page_banner.gif").createImage();
- }
- /**
- * Returns the backgroundColor.
- * @return Color
- */
- public Color getBackgroundColor()
- {
- return backgroundColor;
- }
-
- public class KeyboardHandler extends KeyAdapter
- {
- public void keyPressed(KeyEvent e)
- {
- Widget w = e.widget;
- if (w instanceof Control)
- {
- processKey(e.keyCode, (Control) w);
- }
- }
-
- private void scrollVertical(ScrolledComposite scomp, boolean up)
- {
- scroll(scomp, 0, up ? -V_SCROLL_INCREMENT : V_SCROLL_INCREMENT);
- }
-
- private void scrollHorizontal(ScrolledComposite scomp, boolean left)
- {
- scroll(scomp, left ? -H_SCROLL_INCREMENT : H_SCROLL_INCREMENT, 0);
- }
-
- private void scrollPage(ScrolledComposite scomp, boolean up)
- {
- Rectangle clientArea = scomp.getClientArea();
- int increment = up ? -clientArea.height : clientArea.height;
- scroll(scomp, 0, increment);
- }
-
- private void scroll(ScrolledComposite scomp, int xoffset, int yoffset)
- {
- Point origin = scomp.getOrigin();
- Point contentSize = scomp.getContent().getSize();
- int xorigin = origin.x + xoffset;
- int yorigin = origin.y + yoffset;
- xorigin = Math.max(xorigin, 0);
- xorigin = Math.min(xorigin, contentSize.x - 1);
- yorigin = Math.max(yorigin, 0);
- yorigin = Math.min(yorigin, contentSize.y - 1);
- scomp.setOrigin(xorigin, yorigin);
- }
-
- protected ScrolledComposite getScrolledComposite(Control c)
- {
- Composite parent = c.getParent();
-
- while (parent != null)
- {
- if (parent instanceof ScrolledComposite)
- {
- return (ScrolledComposite) parent;
- }
- parent = parent.getParent();
- }
- return null;
- }
-
- protected void processKey(int keyCode, Control c)
- {
- ScrolledComposite scomp = getScrolledComposite(c);
- if (scomp != null)
- {
- switch (keyCode)
- {
- case SWT.ARROW_DOWN :
- scrollVertical(scomp, false);
- break;
- case SWT.ARROW_UP :
- scrollVertical(scomp, true);
- break;
- case SWT.ARROW_LEFT :
- scrollHorizontal(scomp, true);
- break;
- case SWT.ARROW_RIGHT :
- scrollHorizontal(scomp, false);
- break;
- case SWT.PAGE_UP :
- scrollPage(scomp, true);
- break;
- case SWT.PAGE_DOWN :
- scrollPage(scomp, false);
- break;
- }
- }
- }
- }
-}

Back to the top