Package org.springframework.ide.eclipse.beans.ui.namespaces

Examples of org.springframework.ide.eclipse.beans.ui.namespaces.INamespaceDefinition


  private boolean namespaceAttributeExistsInList(String attributeName, String namespaceUri,
      List<INamespaceDefinition> namespaces) {
    String namespacePrefix = attributeNameToPrefix(attributeName, namespaceUri);
    for (INamespaceDefinition namespaceDefinition : namespaces) {
      INamespaceDefinition currNamespaceDefinition = namespaceDefinition;
      if ((namespacePrefix != null && namespacePrefix.equals(currNamespaceDefinition
          .getNamespacePrefix(getConfigEditor().getResourceFile())))
          || namespaceUri.equalsIgnoreCase(currNamespaceDefinition.getNamespaceURI())) {
        return true;
      }
    }
    return false;
  }
View Full Code Here


        String currAttributeName = currAttributeNode.getNodeName();
        String uri = currAttributeNode.getNodeValue();
        if (isUnknownNamespace(currAttributeName, uri, namespaceDefinitionList)) {
          String schemaVersion = ConfigCoreUtils.getSelectedSchemaLocation(
              getConfigEditor().getDomDocument(), uri);
          INamespaceDefinition namespaceDefinition = new DefaultNamespaceDefinition(attributeNameToPrefix(
              currAttributeName, uri), uri, schemaVersion, StsUiImages.XML_FILE.createImage());
          if (!"".equals(schemaVersion)) { //$NON-NLS-1$
            this.selectedVersions.put(namespaceDefinition, schemaVersion);
          }
          namespaceDefinitionList.add(namespaceDefinition);
        }
      }
    }
    // Special case
    List<String> schemaInfo = ConfigCoreUtils.parseSchemaLocationAttr(getConfigEditor().getDomDocument());
    if (schemaInfo != null) {
      Iterator<String> iter = schemaInfo.iterator();
      while (iter.hasNext()) {
        String uri = iter.next();
        if (iter.hasNext()) {
          String schemaVersion = iter.next();
          if (!namespaceAttributeExistsInList(ConfigCoreUtils.ATTR_SCHEMA_LOCATION, uri,
              namespaceDefinitionList)) {
            INamespaceDefinition namespaceDefinition = new DefaultNamespaceDefinition(
                attributeNameToPrefix(ConfigCoreUtils.ATTR_SCHEMA_LOCATION, uri), uri, schemaVersion,
                StsUiImages.XML_FILE.createImage());
            if (!"".equals(schemaVersion)) { //$NON-NLS-1$
              this.selectedVersions.put(namespaceDefinition, schemaVersion);
            }
View Full Code Here

  private class CheckStateListener implements ICheckStateListener {

    public void checkStateChanged(CheckStateChangedEvent event) {
      if (event.getElement() != null && event.getElement() instanceof INamespaceDefinition) {
        INamespaceDefinition definition = (INamespaceDefinition) event.getElement();
        updateDefinitionFromCheckState(definition, event.getChecked());
      }
    }
View Full Code Here

    String lineSeparator = SpringCoreUtils.getLineSeparator((String) null, newFileHandle
        .getProject());

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    String charSet = getUserPreferredCharset();
    INamespaceDefinition defaultXsd = NamespaceUtils.getDefaultNamespaceDefinition();
    PrintWriter writer = new PrintWriter(new OutputStreamWriter(outputStream, charSet));
    writer.println("<?xml version=\"1.0\" encoding=\"" + charSet + "\"?>"); //$NON-NLS-1$ //$NON-NLS-2$
    writer.println("<beans xmlns=\"" + defaultXsd.getNamespaceURI() + "\"" + lineSeparator
        + "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + lineSeparator
        + getNamespaceMappings(lineSeparator, newFileHandle) + "\txsi:schemaLocation=\""
        + getSchemaLocations(lineSeparator, newFileHandle) + "\">" + lineSeparator + lineSeparator
        + lineSeparator + "</beans>");
    writer.flush();
View Full Code Here

    }
    return null;
  }

  private String getNamespaceMappings(String lineSeparator, IFile file) {
    INamespaceDefinition defaultXsd = NamespaceUtils.getDefaultNamespaceDefinition();
    StringBuilder builder = new StringBuilder();
    for (INamespaceDefinition def : xmlSchemaDefinitions) {
      if (!def.equals(defaultXsd)) {
        builder.append("\t");
        builder.append("xmlns:");
View Full Code Here

  }

  private String getSchemaLocations(String lineSeparator, IFile file) {
    StringBuilder builder = new StringBuilder();

    INamespaceDefinition defaultXsd = NamespaceUtils.getDefaultNamespaceDefinition();
    builder.append("\t\t");
    builder.append(defaultXsd.getNamespaceURI());
    builder.append(" ");
    if (schemaVersions.containsKey(defaultXsd)) {
      builder.append(schemaVersions.get(defaultXsd));
    }
    else {
      builder.append(defaultXsd.getDefaultSchemaLocation(file));
    }
    builder.append(lineSeparator);

    for (INamespaceDefinition def : xmlSchemaDefinitions) {
      if (def.getDefaultSchemaLocation(file) != null && !def.equals(defaultXsd)) {
View Full Code Here

    xsdViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER);
    xsdViewer.getTable().setLayoutData(gd);
    xsdViewer.setContentProvider(new XsdConfigContentProvider());
    xsdViewer.setLabelProvider(new XsdLabelProvider());
    xsdViewer.setInput(this); // activate content provider
    INamespaceDefinition defaultDefinition = NamespaceUtils.getDefaultNamespaceDefinition();
    if (defaultDefinition != null) {
      xsdViewer.setGrayedElements(new Object[] { defaultDefinition });
      xsdViewer.setCheckedElements(new Object[] { defaultDefinition });
    }
View Full Code Here

  public class XsdLabelProvider extends LabelProvider {

    public Image getImage(Object element) {
      if (element instanceof INamespaceDefinition) {
        INamespaceDefinition xsdDef = (INamespaceDefinition) element;
        return xsdDef.getNamespaceImage();
      }
      return BeansUIImages.getImage(BeansUIImages.IMG_OBJS_XSD);
    }
View Full Code Here

      return BeansUIImages.getImage(BeansUIImages.IMG_OBJS_XSD);
    }

    public String getText(Object element) {
      if (element instanceof INamespaceDefinition) {
        INamespaceDefinition xsdDef = (INamespaceDefinition) element;
        return xsdDef.getDefaultNamespacePrefix() + " - " + xsdDef.getNamespaceURI();
      }
      return "";
    }
View Full Code Here

  public class XsdLabelProvider extends LabelProvider {

    public Image getImage(Object element) {
      if (element instanceof INamespaceDefinition) {
        INamespaceDefinition xsdDef = (INamespaceDefinition) element;
        return xsdDef.getNamespaceImage();
      }
      return BeansUIImages.getImage(BeansUIImages.IMG_OBJS_XSD);
    }
View Full Code Here

TOP

Related Classes of org.springframework.ide.eclipse.beans.ui.namespaces.INamespaceDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.