Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordavid_williams2005-04-03 07:05:57 +0000
committerdavid_williams2005-04-03 07:05:57 +0000
commit7af83db9be26c07221aab7ef4cfb1cc3ca0a22bc (patch)
treedb7ef929b1db06e813426f8269744ad4662710a6 /bundles
parentf29b6bf2784fadc8a2ee9792bc6f2179034ac245 (diff)
downloadwebtools.sourceediting-7af83db9be26c07221aab7ef4cfb1cc3ca0a22bc.tar.gz
webtools.sourceediting-7af83db9be26c07221aab7ef4cfb1cc3ca0a22bc.tar.xz
webtools.sourceediting-7af83db9be26c07221aab7ef4cfb1cc3ca0a22bc.zip
minor renames and deleting deprecated junk
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/breakpointproviders/JavascriptLineBreakpoint.java5
-rw-r--r--bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPCompletionProcessor.java2
-rw-r--r--bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/format/FormatProcessorCSS.java7
-rw-r--r--bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CleanupProcessorCSS.java8
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSColorManager.java39
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/style/CSSTextColors.java143
-rw-r--r--bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDSAXParser.java47
-rw-r--r--bundles/org.eclipse.wst.dtd.ui/src/org/eclipse/wst/dtd/ui/views/contentoutline/DTDContentOutlineConfiguration.java6
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/CommonModelPreferenceNames.java47
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/StructuredDocumentToTextAdapter.java6
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/StructuredTextEditor.java12
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/actions/ActiveEditorActionHandler.java5
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/ManageBreakpointAction.java6
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/EveryNodeDebugAdapter.java10
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/XMLCleanupPreferences.java54
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/XMLCleanupPreferencesImpl.java4
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionContainer.java104
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionProxy.java103
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLGenerator.java685
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/contentassist/AbstractContentAssistProcessor.java328
-rw-r--r--bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/NewXSDWizard.java242
21 files changed, 723 insertions, 1140 deletions
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/breakpointproviders/JavascriptLineBreakpoint.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/breakpointproviders/JavascriptLineBreakpoint.java
index 8f77393ada..68580d9c6c 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/breakpointproviders/JavascriptLineBreakpoint.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/breakpointproviders/JavascriptLineBreakpoint.java
@@ -21,7 +21,7 @@ import org.eclipse.core.runtime.CoreException;
/**
* @author davidw
- *
+ *
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
@@ -35,7 +35,7 @@ public class JavascriptLineBreakpoint {
*/
public JavascriptLineBreakpoint(IResource res, int lineNumber, int pos, int pos1) {
- // TODO Auto-generated constructor stub
+ // TODO Should be deleted? Along with calling class?
}
/**
@@ -43,7 +43,6 @@ public class JavascriptLineBreakpoint {
*/
public JavascriptLineBreakpoint() {
super();
- // TODO Auto-generated constructor stub
}
/**
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPCompletionProcessor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPCompletionProcessor.java
index ef4b08a378..f4b2b45d6d 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPCompletionProcessor.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPCompletionProcessor.java
@@ -265,7 +265,7 @@ public class JSPCompletionProcessor implements IContentAssistProcessor, IReleasa
}
public String getErrorMessage() {
- // TODO:
+ // TODO: get appropriate error message
// if (fCollector.getErrorMessage() != null &&
// fCollector.getErrorMessage().length() > 0)
// return fCollector.getErrorMessage();
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/format/FormatProcessorCSS.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/format/FormatProcessorCSS.java
index 3236af6480..c118824648 100644
--- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/format/FormatProcessorCSS.java
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/format/FormatProcessorCSS.java
@@ -29,12 +29,7 @@ import org.w3c.dom.Node;
public class FormatProcessorCSS extends AbstractStructuredFormatProcessor {
- /**
- * @deprecated renamed to getFileExtension() TODO will delete in C5
- */
- protected String getContentType() {
- return "css"; //$NON-NLS-1$
- }
+
protected String getFileExtension() {
return "css"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CleanupProcessorCSS.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CleanupProcessorCSS.java
index 842f06dead..0320f77cf4 100644
--- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CleanupProcessorCSS.java
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/cleanup/CleanupProcessorCSS.java
@@ -84,7 +84,7 @@ public class CleanupProcessorCSS extends AbstractStructuredCleanupProcessor {
* @see com.ibm.sse.model.cleanup.IStructuredCleanupProcessor#cleanupDocument(org.eclipse.jface.text.IDocument)
*/
public void cleanupDocument(IDocument document) throws IOException, CoreException {
- // TODO Auto-generated method stub
+ // TODO should implement, or delete?
}
@@ -95,7 +95,7 @@ public class CleanupProcessorCSS extends AbstractStructuredCleanupProcessor {
* int, int)
*/
public void cleanupDocument(IDocument document, int start, int length) throws IOException, CoreException {
- // TODO Auto-generated method stub
+ // TODO should implement, or delete?
}
@@ -105,7 +105,6 @@ public class CleanupProcessorCSS extends AbstractStructuredCleanupProcessor {
* @see com.ibm.sse.model.cleanup.AbstractStructuredCleanupProcessor#getCleanupHandler(org.w3c.dom.Node)
*/
protected IStructuredCleanupHandler getCleanupHandler(Node node) {
- // TODO Auto-generated method stub
return null;
}
@@ -115,7 +114,6 @@ public class CleanupProcessorCSS extends AbstractStructuredCleanupProcessor {
* @see com.ibm.sse.model.cleanup.AbstractStructuredCleanupProcessor#getFormatProcessor()
*/
protected IStructuredFormatProcessor getFormatProcessor() {
- // TODO Auto-generated method stub
return null;
}
@@ -125,7 +123,5 @@ public class CleanupProcessorCSS extends AbstractStructuredCleanupProcessor {
* @see com.ibm.sse.model.cleanup.AbstractStructuredCleanupProcessor#refreshCleanupPreferences()
*/
protected void refreshCleanupPreferences() {
- // TODO Auto-generated method stub
-
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSColorManager.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSColorManager.java
index 2b68638d96..bdff7c2b4f 100644
--- a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSColorManager.java
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/preferences/ui/CSSColorManager.java
@@ -30,33 +30,7 @@ import org.w3c.dom.NodeList;
public class CSSColorManager extends PreferenceManager {
private static CSSColorManager fInstance = null;
- // highlighting types
- /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
- public static final String NORMAL = "NORMAL";//$NON-NLS-1$
- /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
- public static final String ATMARK_RULE = "ATMARK_RULE";//$NON-NLS-1$
- /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
- public static final String SELECTOR = "SELECTOR";//$NON-NLS-1$
- /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
- public static final String MEDIA = "MEDIA"; //$NON-NLS-1$
- /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
- public static final String COMMENT = "COMMENT";//$NON-NLS-1$
- /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
- public static final String PROPERTY_NAME = "PROPERTY_NAME";//$NON-NLS-1$
- /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
- public static final String PROPERTY_VALUE = "PROPERTY_VALUE";//$NON-NLS-1$
- /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
- public static final String URI = "URI";//$NON-NLS-1$
- /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
- public static final String STRING = "STRING";//$NON-NLS-1$
- /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
- public static final String COLON = "COLON";//$NON-NLS-1$
- /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
- public static final String SEMI_COLON = "SEMI_COLON";//$NON-NLS-1$
- /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
- public static final String CURLY_BRACE = "CURLY_BRACE";//$NON-NLS-1$
- /** @deprecated use IStyleConstantsCSS instead TODO remove in C5 or earlier */
- public static final String ERROR = "ERROR";//$NON-NLS-1$
+
// names for preference elements ... non-NLS
public static final String FOREGROUND = "foreground";//$NON-NLS-1$
public static final String BACKGROUND = "background";//$NON-NLS-1$
@@ -79,7 +53,7 @@ public class CSSColorManager extends PreferenceManager {
* <!ELEMENT colors (color) > <!ELEMENT color EMPTY > <!ATTLIST color name
* CDATA #REQUIRED foreground CDATA #IMPLIED background CDATA #IMPLIED
* bold CDATA #REQUIRED >
- *
+ *
*/
public Document createDefaultPreferences() {
Document prefDocument = super.createDefaultPreferences();
@@ -113,7 +87,8 @@ public class CSSColorManager extends PreferenceManager {
Element element = getColorElement(name);
if (element != null) {
return getRGB(element.getAttribute(BACKGROUND));
- } else {
+ }
+ else {
return new RGB(255, 255, 255);
}
}
@@ -145,7 +120,8 @@ public class CSSColorManager extends PreferenceManager {
Element element = getColorElement(name);
if (element != null) {
return getRGB(element.getAttribute(FOREGROUND));
- } else {
+ }
+ else {
return new RGB(0, 0, 0);
}
}
@@ -173,7 +149,8 @@ public class CSSColorManager extends PreferenceManager {
int g = Integer.valueOf(rgbStr.substring(3, 5), 16).intValue();
int b = Integer.valueOf(rgbStr.substring(5, 7), 16).intValue();
result = new RGB(r, g, b);
- } catch (NumberFormatException e) {
+ }
+ catch (NumberFormatException e) {
Logger.logException("Invalid color string " + rgbStr, e); //$NON-NLS-1$
}
}
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/style/CSSTextColors.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/style/CSSTextColors.java
deleted file mode 100644
index 8bf4594aab..0000000000
--- a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/style/CSSTextColors.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.css.ui.style;
-
-
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.wst.css.ui.preferences.CSSPreferenceManager;
-import org.eclipse.wst.css.ui.preferences.ui.CSSColorManager;
-import org.eclipse.wst.sse.ui.util.EditorUtility;
-
-/**
- * @deprecated Most methods and constants moved to LineStyleProviderForCSS or
- * IStyleConstantsCSS. TODO remove in C5 or earlier
- */
-public class CSSTextColors {
- class TextColors {
-
- TextColors() {
- super();
- }
-
- void setTextAttribute(Object key, RGB foreground, RGB background, int style) {
- TextAttribute attribute = new TextAttribute(EditorUtility.getColor(foreground), EditorUtility.getColor(background), style);
- setTextAttribute(key, attribute);
- }
-
- void setTextAttribute(Object key, TextAttribute attribute) {
- TextAttribute oldAttribute = (TextAttribute) fAttributeTable.get(key);
- if (oldAttribute != null) {
- fAttributeTable.remove(key);
- }
- fAttributeTable.put(key, attribute);
- }
-
- TextAttribute getTextAttribute(Object key) {
- return (TextAttribute) fAttributeTable.get(key);
- }
-
- private Map fAttributeTable = new HashMap();
- }
-
- // color types
- public static final String NORMAL = "NORMAL"; //$NON-NLS-1$
- public static final String ATMARK_RULE = "ATMARK_RULE"; //$NON-NLS-1$
- public static final String SELECTOR = "SELECTOR"; //$NON-NLS-1$
- public static final String MEDIA = "MEDIA"; //$NON-NLS-1$
- public static final String COMMENT = "COMMENT"; //$NON-NLS-1$
- public static final String PROPERTY_NAME = "PROPERTY_NAME"; //$NON-NLS-1$
- public static final String PROPERTY_VALUE = "PROPERTY_VALUE"; //$NON-NLS-1$
- public static final String URI = "URI"; //$NON-NLS-1$
- public static final String STRING = "STRING"; //$NON-NLS-1$
- public static final String COLON = "COLON"; //$NON-NLS-1$
- public static final String SEMI_COLON = "SEMI_COLON"; //$NON-NLS-1$
- public static final String CURLY_BRACE = "CURLY_BRACE"; //$NON-NLS-1$
- public static final String ERROR = "ERROR"; //$NON-NLS-1$
- private static CSSTextColors fInstance = null;
- private TextColors fTextColors = null;
- private Map fPrefToType = null;
-
- protected CSSTextColors() {
- super();
- applyPreference();
- }
-
- public synchronized static CSSTextColors getInstance() {
- if (fInstance == null) {
- fInstance = new CSSTextColors();
- }
- return fInstance;
- }
-
- public void applyPreference() {
- if (fTextColors == null) {
- fTextColors = new TextColors();
- }
-
- if (fPrefToType == null) {
- fPrefToType = new HashMap();
- fPrefToType.put(NORMAL, CSSColorManager.NORMAL);
- fPrefToType.put(ATMARK_RULE, CSSColorManager.ATMARK_RULE);
- fPrefToType.put(SELECTOR, CSSColorManager.SELECTOR);
- fPrefToType.put(MEDIA, CSSColorManager.MEDIA);
- fPrefToType.put(COMMENT, CSSColorManager.COMMENT);
- fPrefToType.put(PROPERTY_NAME, CSSColorManager.PROPERTY_NAME);
- fPrefToType.put(PROPERTY_VALUE, CSSColorManager.PROPERTY_VALUE);
- fPrefToType.put(URI, CSSColorManager.URI);
- fPrefToType.put(STRING, CSSColorManager.STRING);
- fPrefToType.put(COLON, CSSColorManager.COLON);
- fPrefToType.put(SEMI_COLON, CSSColorManager.SEMI_COLON);
- fPrefToType.put(CURLY_BRACE, CSSColorManager.CURLY_BRACE);
- fPrefToType.put(ERROR, CSSColorManager.ERROR);
- }
- boolean bEnabled = CSSPreferenceManager.getInstance().getColorEnabled();
- CSSColorManager pref = CSSColorManager.getInstance();
-
- Iterator i = fPrefToType.keySet().iterator();
- while (i.hasNext()) {
- String key = (String) i.next();
- if (bEnabled) {
- String type = (String) fPrefToType.get(key);
- setTextAttribute(key, pref.getForegroundRGB(type), pref.getBackgroundRGB(type), pref.getStyle(type));
- } else {
- setTextAttribute(key, null);
- }
- }
- }
-
- public void dispose() {
- }
-
- public TextAttribute getTextAttribute(String type) {
- if (fTextColors == null) {
- applyPreference();
- }
- return fTextColors.getTextAttribute(type);
- }
-
- private void setTextAttribute(String type, RGB foreground) {
- setTextAttribute(type, foreground, null, SWT.NORMAL);
- }
-
- private void setTextAttribute(String type, RGB foreground, RGB background, int style) {
- if (fTextColors == null) {
- return;
- }
- fTextColors.setTextAttribute(type, foreground, background, style);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDSAXParser.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDSAXParser.java
index ae272fda08..f758c718fa 100644
--- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDSAXParser.java
+++ b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDSAXParser.java
@@ -49,7 +49,6 @@ public class DTDSAXParser extends SAXParser {
* @see javax.xml.parsers.SAXParser#getParser()
*/
public Parser getParser() throws SAXException {
- // TODO Auto-generated method stub
return null;
}
@@ -59,7 +58,6 @@ public class DTDSAXParser extends SAXParser {
* @see javax.xml.parsers.SAXParser#getProperty(java.lang.String)
*/
public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
- // TODO Auto-generated method stub
return null;
}
@@ -69,50 +67,9 @@ public class DTDSAXParser extends SAXParser {
* @see javax.xml.parsers.SAXParser#getXMLReader()
*/
public XMLReader getXMLReader() throws SAXException {
- // TODO Auto-generated method stub
return null;
}
- //
- // public XMLLocator getLocator()
- // {
- // return locator;
- // }
- //
- // public void startDocument
- // (XMLLocator locator,
- // String encoding,
- // Augmentations augs)
- // {
- // this.locator = locator;
- // super.startDocument(locator,encoding,augs);
- // }
- //
- // public void ignoredCharacters(XMLString text, Augmentations augs)
- // throws XNIException
- // {
- // String s =
- // text.length > 0 ? new String(text.ch,text.offset,text.length) : "";
- // //System.out.println("ignoredCharacters: " + s);
- //
- // StringTokenizer tokenizer = new StringTokenizer(s,";");
- // try
- // {
- // String token = null;
- // while (tokenizer.hasMoreTokens())
- // {
- // token = tokenizer.nextToken();
- // if (isEntityRef(token))
- // registerEntityRef(token);
- // }
- // }
- // catch (NoSuchElementException e)
- // {
- // e.printStackTrace();
- // }
- // }
- //
- // TODO: never used
boolean isEntityRef(String token) {
// Looking for the pattern "nnnn%nnnnn".
if (token.indexOf('%') != -1)
@@ -127,7 +84,6 @@ public class DTDSAXParser extends SAXParser {
* @see javax.xml.parsers.SAXParser#isNamespaceAware()
*/
public boolean isNamespaceAware() {
- // TODO Auto-generated method stub
return false;
}
@@ -137,7 +93,6 @@ public class DTDSAXParser extends SAXParser {
* @see javax.xml.parsers.SAXParser#isValidating()
*/
public boolean isValidating() {
- // TODO Auto-generated method stub
return false;
}
@@ -163,7 +118,7 @@ public class DTDSAXParser extends SAXParser {
* java.lang.Object)
*/
public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {
- // TODO Auto-generated method stub
+ // TODO maybe needs implementing?
}
diff --git a/bundles/org.eclipse.wst.dtd.ui/src/org/eclipse/wst/dtd/ui/views/contentoutline/DTDContentOutlineConfiguration.java b/bundles/org.eclipse.wst.dtd.ui/src/org/eclipse/wst/dtd/ui/views/contentoutline/DTDContentOutlineConfiguration.java
index cc51ff122a..04fd9d4f1e 100644
--- a/bundles/org.eclipse.wst.dtd.ui/src/org/eclipse/wst/dtd/ui/views/contentoutline/DTDContentOutlineConfiguration.java
+++ b/bundles/org.eclipse.wst.dtd.ui/src/org/eclipse/wst/dtd/ui/views/contentoutline/DTDContentOutlineConfiguration.java
@@ -101,7 +101,8 @@ public class DTDContentOutlineConfiguration extends StructuredContentOutlineConf
if (fContentProvider == null) {
fContentProvider = new DTDTreeContentProvider();
}
- return super.getContentProvider(viewer);
+ //return super.getContentProvider(viewer);
+ return fContentProvider;
}
/*
@@ -113,7 +114,8 @@ public class DTDContentOutlineConfiguration extends StructuredContentOutlineConf
if (fLabelProvider == null) {
fLabelProvider = new DTDLabelProvider();
}
- return super.getLabelProvider(viewer);
+ //return super.getLabelProvider(viewer);
+ return fLabelProvider;
}
/*
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/CommonModelPreferenceNames.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/CommonModelPreferenceNames.java
index 4ab798905d..3880b2a13c 100644
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/CommonModelPreferenceNames.java
+++ b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/CommonModelPreferenceNames.java
@@ -12,7 +12,6 @@
*******************************************************************************/
package org.eclipse.wst.sse.core.preferences;
-import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames;
/**
* Here is a description of how each common model file preference is used.
@@ -75,10 +74,6 @@ public interface CommonModelPreferenceNames {
String TASK_TAG_PRIORITIES = "task-tag-priorities"; //$NON-NLS-1$
String TASK_TAG_ENABLE = "task-tags"; //$NON-NLS-1$
- /*
- * @deprecated - use from CommonEncodingPreferenceNames
- */
- String OUTPUT_CODESET = CommonEncodingPreferenceNames.OUTPUT_CODESET;
/**
* these are preferences that should be inherited from the "embedded
@@ -116,46 +111,4 @@ public interface CommonModelPreferenceNames {
// this way, editor does not need to query model's default tab width
// preference
int DEFAULT_TAB_WIDTH = 4;
- /**
- * @deprecated use CommonEncodingPreferenceNames.END_OF_LINE_CODE instead
- * TODO remove
- */
- String END_OF_LINE_CODE = CommonEncodingPreferenceNames.END_OF_LINE_CODE;
- /**
- * @deprecated use CommonEncodingPreferenceNames.NO_TRANSLATION instead
- * TODO remove
- */
- String NO_TRANSLATION = CommonEncodingPreferenceNames.NO_TRANSLATION;
- /**
- * @deprecated use CommonEncodingPreferenceNames.INPUT_CODESET instead
- * TODO remove
- */
- String INPUT_CODESET = CommonEncodingPreferenceNames.INPUT_CODESET;
- /**
- * @deprecated use CommonEncodingPreferenceNames.STRING_CRLF instead TODO
- * remove
- */
- String STRING_CRLF = CommonEncodingPreferenceNames.STRING_CRLF;
- /**
- * @deprecated use CommonEncodingPreferenceNames.STRING_CR instead TODO
- * remove
- */
- String STRING_CR = CommonEncodingPreferenceNames.STRING_CR;
- /**
- * @deprecated use CommonEncodingPreferenceNames.STRING_LF instead TODO
- * remove
- */
- String STRING_LF = CommonEncodingPreferenceNames.STRING_LF;
- /**
- * @deprecated use CommonEncodingPreferenceNames.CRLF instead TODO remove
- */
- String CRLF = CommonEncodingPreferenceNames.CRLF;
- /**
- * @deprecated use CommonEncodingPreferenceNames.LF instead TODO remove
- */
- String LF = CommonEncodingPreferenceNames.LF;
- /**
- * @deprecated use CommonEncodingPreferenceNames.CR instead TODO remove
- */
- String CR = CommonEncodingPreferenceNames.CR;
}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/StructuredDocumentToTextAdapter.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/StructuredDocumentToTextAdapter.java
index e5fbfb2cf9..63f3fc70aa 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/StructuredDocumentToTextAdapter.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/StructuredDocumentToTextAdapter.java
@@ -464,8 +464,7 @@ public class StructuredDocumentToTextAdapter implements IDocumentAdapter, IDocum
originalRegion = fChildDocument.getProjectionMapping().toOriginRegion(region);
}
catch (BadLocationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Logger.logException(e);
}
}
@@ -486,8 +485,7 @@ public class StructuredDocumentToTextAdapter implements IDocumentAdapter, IDocum
originalOffset = fChildDocument.getProjectionMapping().toImageOffset(offset);
}
catch (BadLocationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Logger.logException(e);
}
}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/StructuredTextEditor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/StructuredTextEditor.java
index 79c87177b3..e4aff02005 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/StructuredTextEditor.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/StructuredTextEditor.java
@@ -985,11 +985,6 @@ public class StructuredTextEditor extends TextEditor implements IExtendedMarkupE
System.out.println("Average time per call: " + (adapterTime / adapterRequests)); //$NON-NLS-1$
}
- // just for work around for document memory leak
- // related to last position (stored in plugin!)
- // holding on to 'selection' which holds instance
- // of document
- // caution, this is making use of internal classes
int caretOffset = getCaretPosition();
// safeguard values used in the Position below
@@ -997,13 +992,6 @@ public class StructuredTextEditor extends TextEditor implements IExtendedMarkupE
caretOffset = 0;
}
- // TODO: remove the code for now, need to track down the leak
- // FIXME: this was put in, to overcome memory leak (via the document
- // in the selection).
- // we need to fix the leak and/or find a better way.
- // TextEditorPlugin.getDefault().setLastEditPosition(new
- // EditPosition(getEditorInput(), getEditorSite().getId(),
- // TextSelection.emptySelection(), new Position(caretOffset)));
// dispose of document folding support
if (fProjectionModelUpdater != null) {
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/actions/ActiveEditorActionHandler.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/actions/ActiveEditorActionHandler.java
index 00c5dd44b7..0c34e0169d 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/actions/ActiveEditorActionHandler.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/actions/ActiveEditorActionHandler.java
@@ -156,10 +156,7 @@ public class ActiveEditorActionHandler implements IAction {
*/
public boolean isHandled() {
updateTargetAction();
- // FIXME
- System.out.println("M6 Migration temp disable function");
- return false;
- // return (fTargetAction != null ? fTargetAction.isHandled() : false);
+ return (fTargetAction != null ? fTargetAction.isHandled() : false);
}
/**
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/ManageBreakpointAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/ManageBreakpointAction.java
index f3b928380c..6635a8c8e0 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/ManageBreakpointAction.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/ManageBreakpointAction.java
@@ -44,8 +44,7 @@ public class ManageBreakpointAction extends BreakpointRulerAction {
try {
breakpoints[i].setEnabled(false);
} catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Logger.logException(e);
}
}
}
@@ -55,8 +54,7 @@ public class ManageBreakpointAction extends BreakpointRulerAction {
try {
breakpoints[i].setEnabled(true);
} catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Logger.logException(e);
}
}
}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/EveryNodeDebugAdapter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/EveryNodeDebugAdapter.java
index d7bace4b46..e8a07085c0 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/EveryNodeDebugAdapter.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/EveryNodeDebugAdapter.java
@@ -112,13 +112,13 @@ public class EveryNodeDebugAdapter implements IDebugAdapter {
}
public void modelAboutToBeReinitialized(IStructuredModel structuredModel) {
- // TODO Auto-generated method stub
-
+ Debug.println("modelAboutToBeReinitialized: " + "structuredModel: " + structuredModel);
+
}
public void modelReinitialized(IStructuredModel structuredModel) {
- // TODO Auto-generated method stub
-
+ Debug.println("modelReinitialized: " + "structuredModel: " + structuredModel);
+
}
}
@@ -207,7 +207,7 @@ public class EveryNodeDebugAdapter implements IDebugAdapter {
IStructuredModel fModel;
/**
- *
+ *
*/
public EveryNodeDebugAdapter() {
super();
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/XMLCleanupPreferences.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/XMLCleanupPreferences.java
deleted file mode 100644
index c188d00122..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/XMLCleanupPreferences.java
+++ /dev/null
@@ -1,54 +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
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.cleanup;
-
-import org.eclipse.core.runtime.Preferences;
-
-/**
- * @deprecated renamed to IStructuredCleanupPreferences
- *
- * TODO will delete in C5
- */
-public interface XMLCleanupPreferences {
-
- int getAttrNameCase();
-
- boolean getConvertEOLCodes();
-
- String getEOLCode();
-
- boolean getFormatSource();
-
- boolean getInsertMissingTags();
-
- boolean getQuoteAttrValues();
-
- int getTagNameCase();
-
- void setAttrNameCase(int attrNameCase);
-
- void setConvertEOLCodes(boolean convertEOLCodes);
-
- void setEOLCode(String EOLCode);
-
- void setFormatSource(boolean formatSource);
-
- void setInsertMissingTags(boolean insertMissingTags);
-
- //void setPreferenceStore(IPreferenceStore preferenceStore);
- void setPreferences(Preferences preferences);
-
- void setQuoteAttrValues(boolean quoteAttrValues);
-
- void setTagNameCase(int tagNameCase);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/XMLCleanupPreferencesImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/XMLCleanupPreferencesImpl.java
index 7dbba772f3..4df62c725d 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/XMLCleanupPreferencesImpl.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/cleanup/XMLCleanupPreferencesImpl.java
@@ -21,7 +21,7 @@ import org.eclipse.wst.xml.core.XMLPreferenceNames;
*
* TODO will delete in C5
*/
-public class XMLCleanupPreferencesImpl implements XMLCleanupPreferences {
+public class XMLCleanupPreferencesImpl {
private static XMLCleanupPreferencesImpl fInstance;
@@ -39,7 +39,7 @@ public class XMLCleanupPreferencesImpl implements XMLCleanupPreferences {
private String fEOLCode;
private boolean fFormatSource;
private boolean fInsertMissingTags;
- //private IPreferenceStore fPreferenceStore = null;
+ // private IPreferenceStore fPreferenceStore = null;
private Preferences fPreferences = null;
private boolean fQuoteAttrValues;
private int fTagNameCase;
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionContainer.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionContainer.java
index f492300376..db527faa85 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionContainer.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionContainer.java
@@ -40,7 +40,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#addRegion(com.ibm.sed.structured.text.ITextRegion)
*/
public void addRegion(ITextRegion aRegion) {
- // XXX Auto-generated method stub
+ throw new Error("intentionally not implemented since should never be called");
}
@@ -50,7 +50,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegion#adjust(int)
*/
public void adjust(int i) {
- // XXX Auto-generated method stub
+ throw new Error("intentionally not implemented since should never be called");
}
@@ -60,7 +60,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegion#adjustLengthWith(int)
*/
public void adjustLength(int i) {
- // XXX Auto-generated method stub
+ throw new Error("intentionally not implemented since should never be called");
}
@@ -70,7 +70,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegion#adjustStart(int)
*/
public void adjustStart(int i) {
- // XXX Auto-generated method stub
+ throw new Error("intentionally not implemented since should never be called");
}
@@ -80,7 +80,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegion#adjustTextLength(int)
*/
public void adjustTextLength(int i) {
- // XXX Auto-generated method stub
+ throw new Error("intentionally not implemented since should never be called");
}
@@ -94,7 +94,8 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
if (container.getStructuredDocumentRegionCount() > 0) {
this.flatNodes.addAll(container.flatNodes);
}
- } else {
+ }
+ else {
this.flatNodes.addElement(flatNode);
}
}
@@ -105,8 +106,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegionCollection#containsOffset(int)
*/
public boolean containsOffset(int i) {
- // XXX Auto-generated method stub
- return false;
+ throw new Error("intentionally not implemented since should never be called");
}
/*
@@ -116,8 +116,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* int)
*/
public boolean containsOffset(ITextRegion region, int i) {
- // XXX Auto-generated method stub
- return false;
+ throw new Error("intentionally not implemented since should never be called");
}
/*
@@ -126,7 +125,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegion#equatePositions(com.ibm.sed.structured.text.ITextRegion)
*/
public void equatePositions(ITextRegion region) {
- // XXX Auto-generated method stub
+ throw new Error("intentionally not implemented since should never be called");
}
@@ -136,8 +135,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegionCollection#getDeepestRegionAtCharacterOffset(int)
*/
public ITextRegion getDeepestRegionAtCharacterOffset(int offset) {
- // XXX Auto-generated method stub
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -161,8 +159,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegionCollection#getEndOffset(com.ibm.sed.structured.text.ITextRegion)
*/
public int getEndOffset(ITextRegion containedRegion) {
- // XXX Auto-generated method stub
- return 0;
+ throw new Error("intentionally not implemented since should never be called");
}
/*
@@ -171,8 +168,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegionCollection#getFirstRegion()
*/
public ITextRegion getFirstRegion() {
- // XXX Auto-generated method stub
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -192,15 +188,13 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
/**
*/
public String getFullText(ITextRegion aRegion) {
- // not supported
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
*/
public String getFullText(String context) {
- // not supported
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/*
@@ -209,8 +203,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegionCollection#getLastRegion()
*/
public ITextRegion getLastRegion() {
- // XXX Auto-generated method stub
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -234,15 +227,13 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#getNext()
*/
public IStructuredDocumentRegion getNext() {
- // XXX Auto-generated method stub
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
*/
public int getNumberOfRegions() {
- // not supported
- return 0;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -257,8 +248,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#getParentDocument()
*/
public IStructuredDocument getParentDocument() {
- // XXX Auto-generated method stub
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/*
@@ -267,22 +257,19 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#getPrevious()
*/
public IStructuredDocumentRegion getPrevious() {
- // XXX Auto-generated method stub
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
*/
public ITextRegion getRegionAtCharacterOffset(int offset) {
- // not supported
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
*/
public ITextRegionList getRegions() {
- // not supported
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -306,8 +293,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegionCollection#getStartOffset(com.ibm.sed.structured.text.ITextRegion)
*/
public int getStartOffset(ITextRegion containedRegion) {
- // XXX Auto-generated method stub
- return 0;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -352,15 +338,13 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
/**
*/
public String getText(ITextRegion aRegion) {
- // not supported
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
*/
public String getText(String context) {
- // not supported
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -381,8 +365,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegionCollection#getTextEndOffset(com.ibm.sed.structured.text.ITextRegion)
*/
public int getTextEndOffset(ITextRegion containedRegion) {
- // XXX Auto-generated method stub
- return 0;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -427,8 +410,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#isEnded()
*/
public boolean isEnded() {
- // XXX Auto-generated method stub
- return false;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -476,15 +458,13 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* int)
*/
public boolean sameAs(IStructuredDocumentRegion region, int shift) {
- // XXX Auto-generated method stub
- return false;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
*/
public boolean sameAs(ITextRegion region, int shift) {
- // not support
- return false;
+ throw new Error("intentionally not implemented since should never be called");
}
/*
@@ -495,8 +475,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* com.ibm.sed.structured.text.ITextRegion, int)
*/
public boolean sameAs(ITextRegion oldRegion, IStructuredDocumentRegion documentRegion, ITextRegion newRegion, int shift) {
- // XXX Auto-generated method stub
- return false;
+ throw new Error("intentionally not implemented since should never be called");
}
public void setDeleted(boolean deleted) {
@@ -509,8 +488,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#setEnded(boolean)
*/
public void setEnded(boolean hasEnd) {
- // XXX Auto-generated method stub
-
+ throw new Error("intentionally not implemented since should never be called");
}
/*
@@ -519,8 +497,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#setLength(int)
*/
public void setLength(int newLength) {
- // XXX Auto-generated method stub
-
+ throw new Error("intentionally not implemented since should never be called");
}
/*
@@ -529,8 +506,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#setNext(com.ibm.sed.structured.text.IStructuredDocumentRegion)
*/
public void setNext(IStructuredDocumentRegion newNext) {
- // XXX Auto-generated method stub
-
+ throw new Error("intentionally not implemented since should never be called");
}
/*
@@ -539,8 +515,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#setParentDocument(com.ibm.sed.structured.text.IStructuredDocument)
*/
public void setParentDocument(IStructuredDocument document) {
- // XXX Auto-generated method stub
-
+ throw new Error("intentionally not implemented since should never be called");
}
/*
@@ -549,14 +524,13 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#setPrevious(com.ibm.sed.structured.text.IStructuredDocumentRegion)
*/
public void setPrevious(IStructuredDocumentRegion newPrevious) {
- // XXX Auto-generated method stub
-
+ throw new Error("intentionally not implemented since should never be called");
}
/**
*/
public void setRegions(ITextRegionList embeddedRegions) {
- // not supported
+ throw new Error("intentionally not implemented since should never be called");
}
/*
@@ -565,8 +539,7 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#setStart(int)
*/
public void setStart(int newStart) {
- // XXX Auto-generated method stub
-
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -599,7 +572,6 @@ class StructuredDocumentRegionContainer implements IStructuredDocumentRegion {
* java.lang.String, int, int)
*/
public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion flatnode, String changes, int start, int end) {
- // XXX Auto-generated method stub
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionProxy.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionProxy.java
index f776e05017..5324bd116b 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionProxy.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionProxy.java
@@ -61,7 +61,7 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#addRegion(com.ibm.sed.structured.text.ITextRegion)
*/
public void addRegion(ITextRegion aRegion) {
- // XXX Auto-generated method stub
+ throw new Error("intentionally not implemented since should never be called");
}
@@ -71,7 +71,7 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegion#adjust(int)
*/
public void adjust(int i) {
- // XXX Auto-generated method stub
+ throw new Error("intentionally not implemented since should never be called");
}
@@ -81,7 +81,7 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegion#adjustLengthWith(int)
*/
public void adjustLength(int i) {
- // XXX Auto-generated method stub
+ throw new Error("intentionally not implemented since should never be called");
}
@@ -91,7 +91,7 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegion#adjustStart(int)
*/
public void adjustStart(int i) {
- // XXX Auto-generated method stub
+ throw new Error("intentionally not implemented since should never be called");
}
@@ -101,7 +101,7 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegion#adjustTextLength(int)
*/
public void adjustTextLength(int i) {
- // XXX Auto-generated method stub
+ throw new Error("intentionally not implemented since should never be called");
}
@@ -111,8 +111,7 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegionCollection#containsOffset(int)
*/
public boolean containsOffset(int i) {
- // XXX Auto-generated method stub
- return false;
+ throw new Error("intentionally not implemented since should never be called");
}
/*
@@ -122,8 +121,7 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* int)
*/
public boolean containsOffset(ITextRegion region, int i) {
- // XXX Auto-generated method stub
- return false;
+ throw new Error("intentionally not implemented since should never be called");
}
/*
@@ -132,7 +130,7 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegion#equatePositions(com.ibm.sed.structured.text.ITextRegion)
*/
public void equatePositions(ITextRegion region) {
- // XXX Auto-generated method stub
+ throw new Error("intentionally not implemented since should never be called");
}
@@ -142,8 +140,7 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegionCollection#getDeepestRegionAtCharacterOffset(int)
*/
public ITextRegion getDeepestRegionAtCharacterOffset(int offset) {
- // XXX Auto-generated method stub
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -167,8 +164,7 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegionCollection#getEndOffset(com.ibm.sed.structured.text.ITextRegion)
*/
public int getEndOffset(ITextRegion containedRegion) {
- // XXX Auto-generated method stub
- return 0;
+ throw new Error("intentionally not implemented since should never be called");
}
/*
@@ -177,8 +173,7 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegionCollection#getFirstRegion()
*/
public ITextRegion getFirstRegion() {
- // XXX Auto-generated method stub
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -190,15 +185,13 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
/**
*/
public String getFullText(ITextRegion aRegion) {
- // not supported
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
*/
public String getFullText(String context) {
- // not supported
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/*
@@ -207,8 +200,7 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegionCollection#getLastRegion()
*/
public ITextRegion getLastRegion() {
- // XXX Auto-generated method stub
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -223,15 +215,13 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#getNext()
*/
public IStructuredDocumentRegion getNext() {
- // XXX Auto-generated method stub
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
*/
public int getNumberOfRegions() {
- // not supported
- return 0;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -255,8 +245,9 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#getParentDocument()
*/
public IStructuredDocument getParentDocument() {
- // XXX Auto-generated method stub
return null;
+ // throw new Error("intentionally not implemented since should never
+ // be called");
}
/*
@@ -265,22 +256,19 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#getPrevious()
*/
public IStructuredDocumentRegion getPrevious() {
- // XXX Auto-generated method stub
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
*/
public ITextRegion getRegionAtCharacterOffset(int offset) {
- // not supported
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
*/
public ITextRegionList getRegions() {
- // not supported
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -304,15 +292,13 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegionCollection#getStartOffset(com.ibm.sed.structured.text.ITextRegion)
*/
public int getStartOffset(ITextRegion containedRegion) {
- // XXX Auto-generated method stub
- return 0;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
*/
public IStructuredDocument getStructuredDocument() {
- // not supported
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -336,15 +322,13 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
/**
*/
public String getText(ITextRegion aRegion) {
- // not supported
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
*/
public String getText(String context) {
- // not supported
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -365,8 +349,7 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.ITextRegionCollection#getTextEndOffset(com.ibm.sed.structured.text.ITextRegion)
*/
public int getTextEndOffset(ITextRegion containedRegion) {
- // XXX Auto-generated method stub
- return 0;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -394,8 +377,7 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#isEnded()
*/
public boolean isEnded() {
- // XXX Auto-generated method stub
- return false;
+ throw new Error("intentionally not implemented since should never be called");
}
/*
@@ -405,15 +387,13 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* int)
*/
public boolean sameAs(IStructuredDocumentRegion region, int shift) {
- // XXX Auto-generated method stub
- return false;
+ throw new Error("intentionally not implemented since should never be called");
}
/**
*/
public boolean sameAs(ITextRegion region, int shift) {
- // not supported
- return false;
+ throw new Error("intentionally not implemented since should never be called");
}
/*
@@ -424,12 +404,11 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* com.ibm.sed.structured.text.ITextRegion, int)
*/
public boolean sameAs(ITextRegion oldRegion, IStructuredDocumentRegion documentRegion, ITextRegion newRegion, int shift) {
- // XXX Auto-generated method stub
- return false;
+ throw new Error("intentionally not implemented since should never be called");
}
public void setDeleted(boolean deleted) {
- // I'll assume never really needed here
+ throw new Error("intentionally not implemented since should never be called");
}
/*
@@ -438,8 +417,7 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#setEnded(boolean)
*/
public void setEnded(boolean hasEnd) {
- // XXX Auto-generated method stub
-
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -455,8 +433,7 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#setNext(com.ibm.sed.structured.text.IStructuredDocumentRegion)
*/
public void setNext(IStructuredDocumentRegion newNext) {
- // XXX Auto-generated method stub
-
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -473,8 +450,7 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#setParentDocument(com.ibm.sed.structured.text.IStructuredDocument)
*/
public void setParentDocument(IStructuredDocument document) {
- // XXX Auto-generated method stub
-
+ throw new Error("intentionally not implemented since should never be called");
}
/*
@@ -483,14 +459,13 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#setPrevious(com.ibm.sed.structured.text.IStructuredDocumentRegion)
*/
public void setPrevious(IStructuredDocumentRegion newPrevious) {
- // XXX Auto-generated method stub
-
+ throw new Error("intentionally not implemented since should never be called");
}
/**
*/
public void setRegions(ITextRegionList embeddedRegions) {
- // not supported
+ throw new Error("intentionally not implemented since should never be called");
}
/*
@@ -499,8 +474,7 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* @see com.ibm.sed.structured.text.IStructuredDocumentRegion#setStart(int)
*/
public void setStart(int newStart) {
- // XXX Auto-generated method stub
-
+ throw new Error("intentionally not implemented since should never be called");
}
/**
@@ -542,7 +516,6 @@ class StructuredDocumentRegionProxy implements IStructuredDocumentRegion {
* java.lang.String, int, int)
*/
public StructuredDocumentEvent updateRegion(Object requester, IStructuredDocumentRegion flatnode, String changes, int start, int end) {
- // XXX Auto-generated method stub
- return null;
+ throw new Error("intentionally not implemented since should never be called");
}
}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLGenerator.java b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLGenerator.java
index ea10c119eb..875668d56e 100644
--- a/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLGenerator.java
+++ b/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLGenerator.java
@@ -25,7 +25,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.util.Assert;
-import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
+import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames;
import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
@@ -44,380 +44,325 @@ import org.eclipse.wst.xml.uriresolver.util.URIHelper;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-public class NewXMLGenerator
-{
-
- protected String grammarURI;
- protected CMDocument cmDocument;
- protected int buildPolicy;
- protected String rootElementName;
-
- protected XMLCatalogEntry xmlCatalogEntry;
-
- // info for dtd
- protected String publicId;
- protected String systemId;
- protected String defaultSystemId;
-
- // info for xsd
- public List namespaceInfoList;
-
- public NewXMLGenerator()
- {
- }
-
- public NewXMLGenerator(String grammarURI, CMDocument cmDocument)
- {
- this.grammarURI = grammarURI;
- this.cmDocument = cmDocument;
- }
-
-
- public static CMDocument createCMDocument(String uri, String[] errorInfo)
- {
- String title = null;
- String message = null;
- List errorList = new Vector();
- CMDocument cmDocument = null;
-
- if (URIHelper.isReadableURI(uri,true))
- {
- uri = URIHelper.normalize(uri, null, null);
- cmDocument = ContentModelManager.getInstance().createCMDocument(uri, null);
-
- if (uri.endsWith(".dtd"))
- {
- if (errorList.size() > 0)
- {
- title = XMLWizard.getString("_UI_INVALID_GRAMMAR_ERROR");
- message = XMLWizard.getString("_UI_LABEL_ERROR_DTD_INVALID_INFO");
- }
- }
- else // ".xsd"
- {
- // To be consistent with the schema editor validation
- XMLSchemaValidationChecker validator = new XMLSchemaValidationChecker();
- if (!validator.isValid(uri))
- {
- title = XMLWizard.getString("_UI_INVALID_GRAMMAR_ERROR");
- message = XMLWizard.getString("_UI_LABEL_ERROR_SCHEMA_INVALID_INFO");
- }
- else if (cmDocument != null)
- {
- int globalElementCount = cmDocument.getElements().getLength();
- if (globalElementCount == 0)
- {
- title = XMLWizard.getString("_UI_WARNING_TITLE_NO_ROOT_ELEMENTS");
- message=XMLWizard.getString("_UI_WARNING_MSG_NO_ROOT_ELEMENTS");
- }
- }
- }
- }
- else
- {
- title = XMLWizard.getString("_UI_WARNING_TITLE_NO_ROOT_ELEMENTS");
- message =
- XMLWizard.getString("_UI_WARNING_URI_NOT_FOUND_COLON")
- + " "
- + uri;
- }
- errorInfo[0] = title;
- errorInfo[1] = message;
-
- return cmDocument;
- }
-
-
- public void createEmptyXMLDocument(IFile newFile) throws Exception
- {
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- Preferences preference = XMLCorePlugin.getDefault().getPluginPreferences();
- String charSet = preference.getString(CommonModelPreferenceNames.OUTPUT_CODESET);
-
- PrintWriter writer = new PrintWriter(new OutputStreamWriter(outputStream, charSet));
- writer.println("<?xml version=\"1.0\" encoding=\"" + charSet + "\"?>");
- writer.flush();
- outputStream.close();
-
- ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
- newFile.setContents(inputStream, true, true, null);
- inputStream.close();
- }
-
- public void createXMLDocument(String xmlFileName) throws Exception
- {
- ByteArrayOutputStream outputStream = createXMLDocument(xmlFileName, false);
-
- File file = new File(xmlFileName);
- FileOutputStream fos = new FileOutputStream(file);
- outputStream.writeTo(fos);
- fos.close();
- }
-
-
- public void createXMLDocument(IFile newFile, String xmlFileName) throws Exception
- {
- ByteArrayOutputStream outputStream = createXMLDocument(xmlFileName, false);
-
- ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
- newFile.setContents(inputStream, true, true, null);
- inputStream.close();
- }
-
-
- public ByteArrayOutputStream createXMLDocument(String xmlFileName, boolean junk) throws Exception
- {
- CMDocument cmDocument = getCMDocument();
-
- Assert.isNotNull(cmDocument);
- Assert.isNotNull(getRootElementName());
-
- // create the xml model
- CMNamedNodeMap nameNodeMap = cmDocument.getElements();
- CMElementDeclaration cmElementDeclaration = (CMElementDeclaration)nameNodeMap.getNamedItem(getRootElementName());
-
- Document xmlDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
- DOMContentBuilderImpl contentBuilder = new DOMContentBuilderImpl(xmlDocument);
-
- contentBuilder.setBuildPolicy(buildPolicy);
- contentBuilder.setExternalCMDocumentSupport(new MyExternalCMDocumentSupport(namespaceInfoList, xmlFileName));
- contentBuilder.uglyTempHack = true; // todo... this line should be removed when 169191 is fixed
- contentBuilder.createDefaultRootContent(cmDocument, cmElementDeclaration, namespaceInfoList);
-
- String[] encodingInfo = (String[])cmDocument.getProperty("encodingInfo");
- if (encodingInfo == null)
- {
- encodingInfo = new String[2];
- }
-
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- OutputStreamWriter outputStreamWriter = encodingInfo[0] != null ?
- new OutputStreamWriter(outputStream, encodingInfo[1]) :
- new OutputStreamWriter(outputStream);
-
- DOMWriter domWriter = new DOMWriter(outputStreamWriter);
- domWriter.print(xmlDocument, encodingInfo[1], cmDocument.getNodeName(), getNonWhitespaceString(getPublicId()), getNonWhitespaceString(getSystemId())); // todo... replace with domWriter.print(xmlDocument); when 169191 is fixed
- outputStream.flush();
- outputStream.close();
-
- return outputStream;
- }
-
-
- public void createNamespaceInfoList()
- {
- List result = new Vector();
- XMLCatalog xmlCatalog = XMLCatalogPlugin.getInstance().getDefaultXMLCatalog();
- if (cmDocument != null)
- {
- result = (List)cmDocument.getProperty("http://org.eclipse.wst/cm/properties/namespaceInfo");
- if (result != null)
- {
- int size = result.size();
- for (int i = 0; i < size; i++)
- {
- NamespaceInfo info = (NamespaceInfo)result.get(i);
- if (i == 0)
- {
- String locationInfo = null;
- if (xmlCatalogEntry != null)
- {
- if (xmlCatalogEntry.getType() == XMLCatalogEntry.PUBLIC)
- {
- locationInfo = xmlCatalogEntry.getWebAddress();
- }
- else
- {
- locationInfo = xmlCatalogEntry.getKey();
- }
- }
- if (locationInfo == null)
- {
- locationInfo = defaultSystemId;
- }
- info.locationHint = locationInfo;
- info.setProperty("locationHint-readOnly", "true");
- }
- info.setProperty("uri-readOnly", "true");
- info.setProperty("unremovable", "true");
- }
- }
-
- NamespaceInfoContentBuilder builder = new NamespaceInfoContentBuilder();
- builder.setBuildPolicy(ContentBuilder.BUILD_ONLY_REQUIRED_CONTENT);
- builder.visitCMNode(cmDocument);
- result.addAll(builder.list);
- }
- namespaceInfoList = result;
- }
-
-
- public boolean isMissingNamespaceLocation()
- {
- boolean result = false;
- for (Iterator i = namespaceInfoList.iterator(); i.hasNext(); )
- {
- NamespaceInfo info = (NamespaceInfo)i.next();
- if (info.locationHint == null)
- {
- result = true;
- break;
- }
- }
- return result;
- }
-
-
- public String[] getNamespaceInfoErrors()
- {
- String[] errorList = null;
-
- if (namespaceInfoList != null && isMissingNamespaceLocation())
- {
- String title = XMLWizard.getString("_UI_LABEL_NO_LOCATION_HINT");
- String message = XMLWizard.getString("_UI_WARNING_MSG_NO_LOCATION_HINT_1") + " " +
- XMLWizard.getString("_UI_WARNING_MSG_NO_LOCATION_HINT_2") + "\n\n" +
- XMLWizard.getString("_UI_WARNING_MSG_NO_LOCATION_HINT_3");
-
- errorList = new String[2];
- errorList[0] = title;
- errorList[1] = message;
- }
-
- return errorList;
- }
-
-
- public void setXMLCatalogEntry(XMLCatalogEntry catalogEntry)
- {
- xmlCatalogEntry = catalogEntry;
- }
-
- public XMLCatalogEntry getXMLCatalogEntry()
- {
- return xmlCatalogEntry;
- }
-
-
- public void setBuildPolicy(int policy)
- {
- buildPolicy = policy;
- }
-
-
- public void setDefaultSystemId(String sysId)
- {
- defaultSystemId = sysId;
- }
-
- public String getDefaultSystemId()
- {
- return defaultSystemId;
- }
-
- public void setSystemId(String sysId)
- {
- systemId = sysId;
- }
-
- public String getSystemId()
- {
- return systemId;
- }
-
- public void setPublicId(String pubId)
- {
- publicId = pubId;
- }
-
- public String getPublicId()
- {
- return publicId;
- }
-
- public void setGrammarURI(String gramURI)
- {
- grammarURI = gramURI;
- }
-
- public String getGrammarURI()
- {
- return grammarURI;
- }
-
- public void setCMDocument(CMDocument cmDoc)
- {
- cmDocument = cmDoc;
- }
-
- public CMDocument getCMDocument()
- {
- return cmDocument;
- }
-
- public void setRootElementName(String rootName)
- {
- rootElementName = rootName;
- }
-
- public String getRootElementName()
- {
- return rootElementName;
- }
-
-
- protected class MyExternalCMDocumentSupport implements DOMContentBuilderImpl.ExternalCMDocumentSupport
- {
- protected List namespaceInfoList;
- protected IdResolver idResolver;
-
- protected MyExternalCMDocumentSupport(List namespaceInfoList, String resourceLocation)
- {
- this.namespaceInfoList = namespaceInfoList;
- idResolver = new IdResolverImpl(resourceLocation);
- }
-
- public CMDocument getCMDocument(Element element, String namespaceURI)
- {
- CMDocument result = null;
- if (namespaceURI != null && namespaceURI.trim().length() > 0)
- {
- String locationHint = null;
- for (Iterator i = namespaceInfoList.iterator(); i.hasNext(); )
- {
- NamespaceInfo info = (NamespaceInfo)i.next();
- if (namespaceURI.equals(info.uri))
- {
- locationHint = info.locationHint;
- break;
- }
- }
- if (locationHint != null)
- {
- grammarURI = idResolver.resolveId(locationHint, locationHint);
- result = ContentModelManager.getInstance().createCMDocument(getGrammarURI(), null);
- }
- }
- else
- {
- result = cmDocument;
- }
- return result;
- }
- }
-
- public static String getNonWhitespaceString(String string)
- {
- String result = null;
- if (string != null)
- {
- if (string.trim().length() > 0)
+public class NewXMLGenerator {
+
+ protected String grammarURI;
+ protected CMDocument cmDocument;
+ protected int buildPolicy;
+ protected String rootElementName;
+
+ protected XMLCatalogEntry xmlCatalogEntry;
+
+ // info for dtd
+ protected String publicId;
+ protected String systemId;
+ protected String defaultSystemId;
+
+ // info for xsd
+ public List namespaceInfoList;
+
+ public NewXMLGenerator() {
+ }
+
+ public NewXMLGenerator(String grammarURI, CMDocument cmDocument) {
+ this.grammarURI = grammarURI;
+ this.cmDocument = cmDocument;
+ }
+
+
+ public static CMDocument createCMDocument(String uri, String[] errorInfo) {
+ String title = null;
+ String message = null;
+ List errorList = new Vector();
+ CMDocument cmDocument = null;
+
+ if (URIHelper.isReadableURI(uri, true)) {
+ uri = URIHelper.normalize(uri, null, null);
+ cmDocument = ContentModelManager.getInstance().createCMDocument(uri, null);
+
+ if (uri.endsWith(".dtd")) {
+ if (errorList.size() > 0) {
+ title = XMLWizard.getString("_UI_INVALID_GRAMMAR_ERROR");
+ message = XMLWizard.getString("_UI_LABEL_ERROR_DTD_INVALID_INFO");
+ }
+ }
+ else // ".xsd"
{
+ // To be consistent with the schema editor validation
+ XMLSchemaValidationChecker validator = new XMLSchemaValidationChecker();
+ if (!validator.isValid(uri)) {
+ title = XMLWizard.getString("_UI_INVALID_GRAMMAR_ERROR");
+ message = XMLWizard.getString("_UI_LABEL_ERROR_SCHEMA_INVALID_INFO");
+ }
+ else if (cmDocument != null) {
+ int globalElementCount = cmDocument.getElements().getLength();
+ if (globalElementCount == 0) {
+ title = XMLWizard.getString("_UI_WARNING_TITLE_NO_ROOT_ELEMENTS");
+ message = XMLWizard.getString("_UI_WARNING_MSG_NO_ROOT_ELEMENTS");
+ }
+ }
+ }
+ }
+ else {
+ title = XMLWizard.getString("_UI_WARNING_TITLE_NO_ROOT_ELEMENTS");
+ message = XMLWizard.getString("_UI_WARNING_URI_NOT_FOUND_COLON") + " " + uri;
+ }
+ errorInfo[0] = title;
+ errorInfo[1] = message;
+
+ return cmDocument;
+ }
+
+
+ public void createEmptyXMLDocument(IFile newFile) throws Exception {
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ Preferences preference = XMLCorePlugin.getDefault().getPluginPreferences();
+ String charSet = preference.getString(CommonEncodingPreferenceNames.OUTPUT_CODESET);
+
+ PrintWriter writer = new PrintWriter(new OutputStreamWriter(outputStream, charSet));
+ writer.println("<?xml version=\"1.0\" encoding=\"" + charSet + "\"?>");
+ writer.flush();
+ outputStream.close();
+
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
+ newFile.setContents(inputStream, true, true, null);
+ inputStream.close();
+ }
+
+ public void createXMLDocument(String xmlFileName) throws Exception {
+ ByteArrayOutputStream outputStream = createXMLDocument(xmlFileName, false);
+
+ File file = new File(xmlFileName);
+ FileOutputStream fos = new FileOutputStream(file);
+ outputStream.writeTo(fos);
+ fos.close();
+ }
+
+
+ public void createXMLDocument(IFile newFile, String xmlFileName) throws Exception {
+ ByteArrayOutputStream outputStream = createXMLDocument(xmlFileName, false);
+
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
+ newFile.setContents(inputStream, true, true, null);
+ inputStream.close();
+ }
+
+
+ public ByteArrayOutputStream createXMLDocument(String xmlFileName, boolean junk) throws Exception {
+ CMDocument cmDocument = getCMDocument();
+
+ Assert.isNotNull(cmDocument);
+ Assert.isNotNull(getRootElementName());
+
+ // create the xml model
+ CMNamedNodeMap nameNodeMap = cmDocument.getElements();
+ CMElementDeclaration cmElementDeclaration = (CMElementDeclaration) nameNodeMap.getNamedItem(getRootElementName());
+
+ Document xmlDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+ DOMContentBuilderImpl contentBuilder = new DOMContentBuilderImpl(xmlDocument);
+
+ contentBuilder.setBuildPolicy(buildPolicy);
+ contentBuilder.setExternalCMDocumentSupport(new MyExternalCMDocumentSupport(namespaceInfoList, xmlFileName));
+ contentBuilder.uglyTempHack = true; // todo... this line should be
+ // removed when 169191 is fixed
+ contentBuilder.createDefaultRootContent(cmDocument, cmElementDeclaration, namespaceInfoList);
+
+ String[] encodingInfo = (String[]) cmDocument.getProperty("encodingInfo");
+ if (encodingInfo == null) {
+ encodingInfo = new String[2];
+ }
+
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ OutputStreamWriter outputStreamWriter = encodingInfo[0] != null ? new OutputStreamWriter(outputStream, encodingInfo[1]) : new OutputStreamWriter(outputStream);
+
+ DOMWriter domWriter = new DOMWriter(outputStreamWriter);
+ domWriter.print(xmlDocument, encodingInfo[1], cmDocument.getNodeName(), getNonWhitespaceString(getPublicId()), getNonWhitespaceString(getSystemId())); // todo...
+ // replace
+ // with
+ // domWriter.print(xmlDocument);
+ // when
+ // 169191
+ // is
+ // fixed
+ outputStream.flush();
+ outputStream.close();
+
+ return outputStream;
+ }
+
+
+ public void createNamespaceInfoList() {
+ List result = new Vector();
+ XMLCatalog xmlCatalog = XMLCatalogPlugin.getInstance().getDefaultXMLCatalog();
+ if (cmDocument != null) {
+ result = (List) cmDocument.getProperty("http://org.eclipse.wst/cm/properties/namespaceInfo");
+ if (result != null) {
+ int size = result.size();
+ for (int i = 0; i < size; i++) {
+ NamespaceInfo info = (NamespaceInfo) result.get(i);
+ if (i == 0) {
+ String locationInfo = null;
+ if (xmlCatalogEntry != null) {
+ if (xmlCatalogEntry.getType() == XMLCatalogEntry.PUBLIC) {
+ locationInfo = xmlCatalogEntry.getWebAddress();
+ }
+ else {
+ locationInfo = xmlCatalogEntry.getKey();
+ }
+ }
+ if (locationInfo == null) {
+ locationInfo = defaultSystemId;
+ }
+ info.locationHint = locationInfo;
+ info.setProperty("locationHint-readOnly", "true");
+ }
+ info.setProperty("uri-readOnly", "true");
+ info.setProperty("unremovable", "true");
+ }
+ }
+
+ NamespaceInfoContentBuilder builder = new NamespaceInfoContentBuilder();
+ builder.setBuildPolicy(ContentBuilder.BUILD_ONLY_REQUIRED_CONTENT);
+ builder.visitCMNode(cmDocument);
+ result.addAll(builder.list);
+ }
+ namespaceInfoList = result;
+ }
+
+
+ public boolean isMissingNamespaceLocation() {
+ boolean result = false;
+ for (Iterator i = namespaceInfoList.iterator(); i.hasNext();) {
+ NamespaceInfo info = (NamespaceInfo) i.next();
+ if (info.locationHint == null) {
+ result = true;
+ break;
+ }
+ }
+ return result;
+ }
+
+
+ public String[] getNamespaceInfoErrors() {
+ String[] errorList = null;
+
+ if (namespaceInfoList != null && isMissingNamespaceLocation()) {
+ String title = XMLWizard.getString("_UI_LABEL_NO_LOCATION_HINT");
+ String message = XMLWizard.getString("_UI_WARNING_MSG_NO_LOCATION_HINT_1") + " " + XMLWizard.getString("_UI_WARNING_MSG_NO_LOCATION_HINT_2") + "\n\n" + XMLWizard.getString("_UI_WARNING_MSG_NO_LOCATION_HINT_3");
+
+ errorList = new String[2];
+ errorList[0] = title;
+ errorList[1] = message;
+ }
+
+ return errorList;
+ }
+
+
+ public void setXMLCatalogEntry(XMLCatalogEntry catalogEntry) {
+ xmlCatalogEntry = catalogEntry;
+ }
+
+ public XMLCatalogEntry getXMLCatalogEntry() {
+ return xmlCatalogEntry;
+ }
+
+
+ public void setBuildPolicy(int policy) {
+ buildPolicy = policy;
+ }
+
+
+ public void setDefaultSystemId(String sysId) {
+ defaultSystemId = sysId;
+ }
+
+ public String getDefaultSystemId() {
+ return defaultSystemId;
+ }
+
+ public void setSystemId(String sysId) {
+ systemId = sysId;
+ }
+
+ public String getSystemId() {
+ return systemId;
+ }
+
+ public void setPublicId(String pubId) {
+ publicId = pubId;
+ }
+
+ public String getPublicId() {
+ return publicId;
+ }
+
+ public void setGrammarURI(String gramURI) {
+ grammarURI = gramURI;
+ }
+
+ public String getGrammarURI() {
+ return grammarURI;
+ }
+
+ public void setCMDocument(CMDocument cmDoc) {
+ cmDocument = cmDoc;
+ }
+
+ public CMDocument getCMDocument() {
+ return cmDocument;
+ }
+
+ public void setRootElementName(String rootName) {
+ rootElementName = rootName;
+ }
+
+ public String getRootElementName() {
+ return rootElementName;
+ }
+
+
+ protected class MyExternalCMDocumentSupport implements DOMContentBuilderImpl.ExternalCMDocumentSupport {
+ protected List namespaceInfoList;
+ protected IdResolver idResolver;
+
+ protected MyExternalCMDocumentSupport(List namespaceInfoList, String resourceLocation) {
+ this.namespaceInfoList = namespaceInfoList;
+ idResolver = new IdResolverImpl(resourceLocation);
+ }
+
+ public CMDocument getCMDocument(Element element, String namespaceURI) {
+ CMDocument result = null;
+ if (namespaceURI != null && namespaceURI.trim().length() > 0) {
+ String locationHint = null;
+ for (Iterator i = namespaceInfoList.iterator(); i.hasNext();) {
+ NamespaceInfo info = (NamespaceInfo) i.next();
+ if (namespaceURI.equals(info.uri)) {
+ locationHint = info.locationHint;
+ break;
+ }
+ }
+ if (locationHint != null) {
+ grammarURI = idResolver.resolveId(locationHint, locationHint);
+ result = ContentModelManager.getInstance().createCMDocument(getGrammarURI(), null);
+ }
+ }
+ else {
+ result = cmDocument;
+ }
+ return result;
+ }
+ }
+
+ public static String getNonWhitespaceString(String string) {
+ String result = null;
+ if (string != null) {
+ if (string.trim().length() > 0) {
result = string;
}
}
return result;
}
-
+
}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/contentassist/AbstractContentAssistProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/contentassist/AbstractContentAssistProcessor.java
index 04f968702b..ec9f8b7311 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/contentassist/AbstractContentAssistProcessor.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/contentassist/AbstractContentAssistProcessor.java
@@ -75,10 +75,11 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
abstract public class AbstractContentAssistProcessor implements IContentAssistProcessor, IReleasable {
- /**
- * ISSUE: this is a bit of hidden JSP knowledge that was implemented this
- * way for expedency. Should be evolved in future to depend on "nestedContext".
- */
+ /**
+ * ISSUE: this is a bit of hidden JSP knowledge that was implemented this
+ * way for expedency. Should be evolved in future to depend on
+ * "nestedContext".
+ */
private class DOMJSPRegionContextsPrivateCopy {
private static final String JSP_CLOSE = "JSP_CLOSE"; //$NON-NLS-1$
private static final String JSP_COMMENT_CLOSE = "JSP_COMMENT_CLOSE"; //$NON-NLS-1$
@@ -94,7 +95,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
private static final String JSP_ROOT_TAG_NAME = "JSP_ROOT_TAG_NAME"; //$NON-NLS-1$
private static final String JSP_SCRIPTLET_OPEN = "JSP_SCRIPTLET_OPEN"; //$NON-NLS-1$
-
+
}
protected static final String INTERNALERROR = SSEUIPlugin.getResourceString("%SEVERE_internal_error_occu_UI_"); //$NON-NLS-1$ = "SEVERE internal error occurred "
@@ -107,7 +108,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
protected String fErrorMessage = null;
protected XMLContentModelGenerator fGenerator;
- //protected IResource resource = null;
+ // protected IResource resource = null;
protected MarkupTagInfoProvider fInfoProvider = null;
protected ITextViewer fTextViewer = null;
@@ -127,7 +128,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
CMNamedNodeMap attributes = elementDecl.getAttributes();
String matchString = contentAssistRequest.getMatchString();
- //check whether an attribute really exists for the replacement
+ // check whether an attribute really exists for the replacement
// offsets AND if it possesses a value
boolean attrAtLocationHasValue = false;
NamedNodeMap attrs = node.getAttributes();
@@ -177,7 +178,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
if (attrAtLocationHasValue) {
// only propose the name
proposedText = getRequiredName(node, attrDecl);
- proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), proposedText.length(), attrImage, proposedText, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_NAME + isRequired, true); //CMVC
+ proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), proposedText.length(), attrImage, proposedText, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_NAME + isRequired, true); // CMVC
// 269884
}
// no attribute exists or is elsewhere, generate
@@ -202,8 +203,9 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
}
}
}
- } else {
- setErrorMessage(SSEUIPlugin.getResourceString("%25concat", (new Object[]{node.getNodeName()})));
+ }
+ else {
+ setErrorMessage(SSEUIPlugin.getResourceString("%25concat", (new Object[]{node.getNodeName()})));
}
}
@@ -229,7 +231,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
// Retrieve the declaration
CMElementDeclaration elementDecl = getCMElementDeclaration(node);
- //String attributeName = nameRegion.getText();
+ // String attributeName = nameRegion.getText();
String attributeName = open.getText(nameRegion);
CMAttributeDeclaration attrDecl = null;
@@ -285,12 +287,13 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
currentValid = currentValid || possibleValue.equals(currentValue);
if (matchString.length() == 0 || possibleValue.startsWith(matchString)) {
CustomCompletionProposal proposal = new CustomCompletionProposal("\"" + possibleValue + "\"", //$NON-NLS-2$//$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), possibleValue.length() + 1, image, possibleValue, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
+ contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), possibleValue.length() + 1, image, possibleValue, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
contentAssistRequest.addProposal(proposal);
}
}
}
- } else if ((attrDecl.getUsage() == CMAttributeDeclaration.FIXED || attrDecl.getAttrType().getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED) && attrDecl.getAttrType().getImpliedValue() != null) {
+ }
+ else if ((attrDecl.getUsage() == CMAttributeDeclaration.FIXED || attrDecl.getAttrType().getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED) && attrDecl.getAttrType().getImpliedValue() != null) {
// FIXED values
String value = attrDecl.getAttrType().getImpliedValue();
if (value != null && value.length() > 0) {
@@ -304,7 +307,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
}
}
}
- } else {
+ }
+ else {
// unknown attribute, so supply nice empty values
proposedInfo = getAdditionalInfo(null, elementDecl);
CustomCompletionProposal proposal = null;
@@ -315,7 +319,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
contentAssistRequest.addProposal(proposal);
}
}
- } else
+ }
+ else
setErrorMessage(UNKNOWN_CONTEXT);
}
@@ -340,15 +345,18 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
CMNode child = children.item(i);
if (child.getNodeType() == CMNode.ELEMENT_DECLARATION) {
contentList.add(child);
- } else {
+ }
+ else {
if (child.getNodeType() == CMNode.GROUP) {
addContent(contentList, (CMContent) child);
- } else {
+ }
+ else {
throw new IllegalArgumentException("Unknown content child: " + child); //$NON-NLS-1$
}
}
}
- } else {
+ }
+ else {
contentList.add(content);
}
}
@@ -361,12 +369,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
String proposedText = "<!DOCTYPE " + rootname + " PUBLIC \"//UNKNOWN/\" \"unknown.dtd\">"; //$NON-NLS-1$ //$NON-NLS-2$
ICompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 10, XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_DOCTYPE), "<!DOCTYPE ... >", //$NON-NLS-1$
- null, null, XMLRelevanceConstants.R_DOCTYPE); // TODO
- // provide
- // special
- // documentation
- // on doc
- // type
+ null, null, XMLRelevanceConstants.R_DOCTYPE);
+ // TODO provide special documentation on doc type
contentAssistRequest.addProposal(proposal);
}
@@ -387,7 +391,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 1, XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC), SSEUIPlugin.getResourceString("%9concat", (new Object[]{" '>'"})), //$NON-NLS-1$ = "Close with {0}"//$NON-NLS-2$
null, null, XMLRelevanceConstants.R_END_TAG_NAME);
contentAssistRequest.addProposal(proposal);
- } else {
+ }
+ else {
XMLNode node = (XMLNode) contentAssistRequest.getNode();
ModelQuery modelQuery = ModelQueryUtil.getModelQuery(node.getOwnerDocument());
Node aNode = contentAssistRequest.getNode();
@@ -408,12 +413,13 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
// double check to see if the region acted upon is
// a tag name; replace it if so
Image image = CMImageUtil.getImage(ed);
- if(image == null) {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
+ if (image == null) {
+ image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
}
if (contentAssistRequest.getRegion().getType() == XMLRegionContext.XML_TAG_NAME) {
proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getStartOffset(), contentAssistRequest.getRegion().getTextLength(), proposedText.length(), image, proposedText, null, proposedInfo, XMLRelevanceConstants.R_END_TAG_NAME);
- } else {
+ }
+ else {
proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), proposedText.length(), image, SSEUIPlugin.getResourceString("%9concat", (new Object[]{"'" + proposedText + "'"})), //$NON-NLS-1$ = "Close with {0}"//$NON-NLS-2$ //$NON-NLS-3$
null, proposedInfo, XMLRelevanceConstants.R_END_TAG_NAME);
}
@@ -480,20 +486,21 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
// this is the case for a start tag w/out end tag
// eg:
// <p>
- // <% String test = "test"; %>
+ // <% String test = "test"; %>
// |
if (needsEndTag(xmlEndTagOpen)) {
String tagName = getTagName(xmlEndTagOpen);
xmlEndTagOpen.getTextEndOffset();
replaceLength = 0;
replaceText = "</" + tagName + ">"; //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-2$
- //replaceText = "</" + node.getNodeName() + ">";
+ // replaceText = "</" + node.getNodeName() + ">";
// //$NON-NLS-1$ $NON-NLS-2$
cursorOffset = tagName.length() + 3;
displayString = SSEUIPlugin.getResourceString("%17concat", (new Object[]{tagName})); //$NON-NLS-1$
addProposal = true;
}
- } else if (type == XMLRegionContext.XML_END_TAG_OPEN) {
+ }
+ else if (type == XMLRegionContext.XML_END_TAG_OPEN) {
// this is the case for: <tag> </ |
// possibly <tag> </ |<anotherTag>
// should only be replacing white space...
@@ -503,11 +510,12 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
replaceBegin = xmlEndTagOpen.getTextEndOffset();
displayString = SSEUIPlugin.getResourceString("%15concat", (new Object[]{node.getNodeName()})); //$NON-NLS-1$
addProposal = true;
- } else if (type == XMLRegionContext.XML_TAG_OPEN) {
+ }
+ else if (type == XMLRegionContext.XML_TAG_OPEN) {
// this is the case for: <tag> < |
replaceText = "/" + node.getNodeName() + ">"; //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-2$
cursorOffset = replaceText.length();
- //replaceText = "/" + node.getNodeName() + ">"; //$NON-NLS-1$
+ // replaceText = "/" + node.getNodeName() + ">"; //$NON-NLS-1$
// $NON-NLS-2$
// should only be replacing white space...
replaceLength = (replaceBegin > xmlEndTagOpen.getTextEndOffset()) ? replaceBegin - xmlEndTagOpen.getTextEndOffset() : 0;
@@ -632,7 +640,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
if (!xmlpiFound) {
addXMLProposal(contentAssistRequest);
- } else if (owningDocument.getDoctype() == null && isCursorAfterXMLPI(contentAssistRequest) && insertDoctype) {
+ }
+ else if (owningDocument.getDoctype() == null && isCursorAfterXMLPI(contentAssistRequest) && insertDoctype) {
addDocTypeProposal(contentAssistRequest);
}
}
@@ -652,7 +661,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
boolean endWithSlashBracket = (getXML(node) && contentType != CMElementDeclaration.ELEMENT);
Image image = CMImageUtil.getImage(elementDecl);
- if(image == null){
+ if (image == null) {
image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
}
@@ -670,7 +679,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
0, getContentGenerator().getStartTagClose(node, elementDecl).length(), image, SSEUIPlugin.getResourceString("%3concat", (new Object[]{getContentGenerator().getStartTagClose(node, elementDecl)})), //$NON-NLS-1$ = "Close with '{0}'"
null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
contentAssistRequest.addProposal(proposal);
- } else {
+ }
+ else {
// prompt with a close for the start tag
CustomCompletionProposal proposal = new CustomCompletionProposal(">", //$NON-NLS-1$
contentAssistRequest.getReplacementBeginPosition(),
@@ -719,7 +729,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
contentAssistRequest.addProposal(proposal);
}
}
- } else if (contentAssistRequest.getDocumentRegion() == node.getLastStructuredDocumentRegion() && !node.getLastStructuredDocumentRegion().isEnded()) {
+ }
+ else if (contentAssistRequest.getDocumentRegion() == node.getLastStructuredDocumentRegion() && !node.getLastStructuredDocumentRegion().isEnded()) {
setErrorMessage(null);
// prompt with a closing end character for the end tag
CustomCompletionProposal proposal = new CustomCompletionProposal(">", //$NON-NLS-1$
@@ -731,7 +742,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
contentAssistRequest.addProposal(proposal);
}
- } else if (node.getNodeType() == Node.DOCUMENT_NODE) {
+ }
+ else if (node.getNodeType() == Node.DOCUMENT_NODE) {
setErrorMessage(UNKNOWN_CONTEXT);
}
}
@@ -791,7 +803,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
}
if (parentDecl != null && parentDecl.getContentType() == CMElementDeclaration.PCDATA) {
addPCDATAProposal(parentDecl.getNodeName(), contentAssistRequest);
- } else {
+ }
+ else {
// retrieve the list of children
validActions = getAvailableChildrenAtIndex((Element) parent, childPosition);
cmnodes = getValidCMNodes(childPosition, ModelQueryAction.INSERT, validActions);
@@ -816,7 +829,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
// begin with the matchstring
String tagname = getRequiredName(parent, elementDecl);
Image image = CMImageUtil.getImage(elementDecl);
- if(image == null){
+ if (image == null) {
image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
}
// Account for the &lt; and &gt;. If attributes were
@@ -842,7 +855,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
setErrorMessage(SSEUIPlugin.getResourceString("%14concat", (new Object[]{parent.getNodeName()}))); //$NON-NLS-1$
}
}
- } else if (parent.getNodeType() == Node.DOCUMENT_NODE) {
+ }
+ else if (parent.getNodeType() == Node.DOCUMENT_NODE) {
// Can only prompt with elements if the cursor position is past
// the XML processing
// instruction and DOCTYPE declaration
@@ -869,7 +883,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
CMElementDeclaration ed = (CMElementDeclaration) childDecls.get(i);
if (ed != null) {
Image image = CMImageUtil.getImage(ed);
- if(image == null){
+ if (image == null) {
image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
}
String proposedText = getRequiredText(parent, ed);
@@ -917,7 +931,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
proposedText = getRequiredName(parent, elementDecl);
cursorAdjustment = proposedText.length();
- } else {
+ }
+ else {
proposedText = getRequiredName(parent, elementDecl);
cursorAdjustment = proposedText.length();
if (elementDecl instanceof CMElementDeclaration) {
@@ -925,7 +940,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
if (ed.getContentType() == CMElementDeclaration.EMPTY) {
proposedText += getContentGenerator().getStartTagClose(parent, ed);
cursorAdjustment = proposedText.length();
- } else {
+ }
+ else {
cursorAdjustment = proposedText.length() + 1;
proposedText += "></" + getRequiredName(parent, elementDecl) + ">"; //$NON-NLS-2$//$NON-NLS-1$
}
@@ -933,7 +949,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
}
if (beginsWith(proposedText, matchString)) {
Image image = CMImageUtil.getImage(elementDecl);
- if(image == null){
+ if (image == null) {
image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
}
String proposedInfo = getAdditionalInfo(getCMElementDeclaration(parent), elementDecl);
@@ -951,7 +967,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
else
setErrorMessage(SSEUIPlugin.getResourceString("%28concat", (new Object[]{parent.getNodeName()}))); //$NON-NLS-1$
}
- } else if (parent.getNodeType() == Node.DOCUMENT_NODE) {
+ }
+ else if (parent.getNodeType() == Node.DOCUMENT_NODE) {
List childElements = getAvailableRootChildren((Document) parent, childPosition);
for (int i = 0; i < childElements.size(); i++) {
CMNode ed = (CMNode) childElements.get(i);
@@ -964,14 +981,16 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
continue;
if ((node != null && node.getAttributes() != null && node.getAttributes().getLength() > 0) || ((node.getNodeType() != Node.TEXT_NODE) && node.getFirstStructuredDocumentRegion().isEnded())) {
cursorAdjustment = proposedText.length();
- } else {
+ }
+ else {
cursorAdjustment = proposedText.length();
if (ed instanceof CMElementDeclaration) {
CMElementDeclaration elementDecl = (CMElementDeclaration) ed;
if (elementDecl.getContentType() == CMElementDeclaration.EMPTY) {
proposedText += getContentGenerator().getStartTagClose(parent, elementDecl);
cursorAdjustment = proposedText.length();
- } else {
+ }
+ else {
cursorAdjustment = proposedText.length() + 1;
proposedText += "></" + getRequiredName(parent, elementDecl) + ">"; //$NON-NLS-2$//$NON-NLS-1$
}
@@ -979,7 +998,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
}
String proposedInfo = getAdditionalInfo(null, ed);
Image image = CMImageUtil.getImage(ed);
- if(image == null){
+ if (image == null) {
image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
}
CustomCompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), cursorAdjustment, image, getRequiredName(parent, ed), null, proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
@@ -990,12 +1009,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
protected void addXMLProposal(ContentAssistRequest contentAssistRequest) {
String proposedText = "<?xml version=\"1.0\" encoding=\"" + ContentTypeEncodingPreferences.getUserPreferredCharsetName(ContentTypeIdForXML.ContentTypeID_XML) + "\"?>"; //$NON-NLS-2$//$NON-NLS-1$
- ICompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), proposedText.length(), XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_PROCESSINGINSTRUCTION), proposedText, null, null, XMLRelevanceConstants.R_XML_DECLARATION); // TODO
- // add
- // special
- // XML
- // proposal
- // info
+ ICompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), proposedText.length(), XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_PROCESSINGINSTRUCTION), proposedText, null, null, XMLRelevanceConstants.R_XML_DECLARATION);
+ // TODO add special XML proposal info
contentAssistRequest.addProposal(proposal);
}
@@ -1009,15 +1024,14 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
* are possible for possible Elements at this point
* @param cmnode
* possible element at this point in the document (depending on
- * what 'node' is)
- true if any attributes of 'node' match any possible attributes
- * from 'cmnodes' list.
+ * what 'node' is) true if any attributes of 'node' match any
+ * possible attributes from 'cmnodes' list.
*/
protected boolean attributeInList(XMLNode node, Node parent, CMNode cmnode) {
if (node == null || parent == null || cmnode == null)
return false;
String elementMatchString = node.getNodeName();
- String cmnodeName = getRequiredName(parent, cmnode);//cmnode.getNodeName();
+ String cmnodeName = getRequiredName(parent, cmnode);// cmnode.getNodeName();
if (node instanceof Element) {
NamedNodeMap map = ((Element) node).getAttributes();
String attrMatchString = ""; //$NON-NLS-1$
@@ -1058,7 +1072,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
if (documentPosition < sdRegion.getStartOffset(completionRegion)) {
// setup to insert new attributes
contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition, 0, matchString);
- } else {
+ }
+ else {
// Setup to replace an existing attribute name
contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
}
@@ -1082,14 +1097,16 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
if (actualNode.getFirstStructuredDocumentRegion() != null && !actualNode.getFirstStructuredDocumentRegion().isEnded()) {
addTagCloseProposals(contentAssistRequest);
}
- } else {
+ }
+ else {
// setup to replace the existing value
if (!nodeAtOffset.getFirstStructuredDocumentRegion().isEnded() && documentPosition < sdRegion.getStartOffset(completionRegion)) {
// if the IStructuredDocumentRegion isn't closed and the
// cursor is in front of the value, add
contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition, 0, matchString);
addAttributeNameProposals(contentAssistRequest);
- } else {
+ }
+ else {
contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
addAttributeValueProposals(contentAssistRequest);
}
@@ -1106,26 +1123,34 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
if (xmlnode.getNodeType() == Node.ELEMENT_NODE || xmlnode.getNodeType() == Node.DOCUMENT_NODE) {
if (regionType == XMLRegionContext.XML_TAG_OPEN) {
contentAssistRequest = computeTagOpenProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- } else if (regionType == XMLRegionContext.XML_TAG_NAME) {
+ }
+ else if (regionType == XMLRegionContext.XML_TAG_NAME) {
contentAssistRequest = computeTagNameProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- } else if (regionType == XMLRegionContext.XML_TAG_ATTRIBUTE_NAME) {
+ }
+ else if (regionType == XMLRegionContext.XML_TAG_ATTRIBUTE_NAME) {
contentAssistRequest = computeAttributeProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- } else if (regionType == XMLRegionContext.XML_TAG_ATTRIBUTE_EQUALS) {
+ }
+ else if (regionType == XMLRegionContext.XML_TAG_ATTRIBUTE_EQUALS) {
contentAssistRequest = computeEqualsProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- } else if (regionType == XMLRegionContext.XML_TAG_ATTRIBUTE_VALUE && documentPosition == sdRegion.getTextEndOffset() && (sdRegion.getText(completionRegion).endsWith("\"") || sdRegion.getText(completionRegion).endsWith("\'"))) //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ else if (regionType == XMLRegionContext.XML_TAG_ATTRIBUTE_VALUE && documentPosition == sdRegion.getTextEndOffset() && (sdRegion.getText(completionRegion).endsWith("\"") || sdRegion.getText(completionRegion).endsWith("\'"))) //$NON-NLS-1$ //$NON-NLS-2$
{
// this is for when the cursor is at the end of the closing
// quote for an attribute..
XMLNode actualNode = (XMLNode) xmlnode.getModel().getIndexedRegion(sdRegion.getStartOffset(completionRegion));
contentAssistRequest = newContentAssistRequest(actualNode, actualNode, sdRegion, completionRegion, documentPosition, 0, matchString);
addTagCloseProposals(contentAssistRequest);
- } else if (regionType == XMLRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
+ }
+ else if (regionType == XMLRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
contentAssistRequest = computeAttributeValueProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- } else if ((regionType == XMLRegionContext.XML_TAG_CLOSE) || (regionType == XMLRegionContext.XML_EMPTY_TAG_CLOSE) || (regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_CLOSE))) {
+ }
+ else if ((regionType == XMLRegionContext.XML_TAG_CLOSE) || (regionType == XMLRegionContext.XML_EMPTY_TAG_CLOSE) || (regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_CLOSE))) {
contentAssistRequest = computeTagCloseProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- } else if (regionType == XMLRegionContext.XML_END_TAG_OPEN) {
+ }
+ else if (regionType == XMLRegionContext.XML_END_TAG_OPEN) {
contentAssistRequest = computeEndTagOpenProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- } else if (regionType == XMLRegionContext.XML_CONTENT || regionType == XMLRegionContext.XML_CHAR_REFERENCE || regionType == XMLRegionContext.XML_ENTITY_REFERENCE || regionType == XMLRegionContext.XML_PE_REFERENCE) {
+ }
+ else if (regionType == XMLRegionContext.XML_CONTENT || regionType == XMLRegionContext.XML_CHAR_REFERENCE || regionType == XMLRegionContext.XML_ENTITY_REFERENCE || regionType == XMLRegionContext.XML_PE_REFERENCE) {
contentAssistRequest = computeContentProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
}
@@ -1144,7 +1169,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
addStartDocumentProposals(contentAssistRequest);
if (documentPosition >= sdRegion.getTextEndOffset(completionRegion))
addTagInsertionProposals(contentAssistRequest, getElementPositionForModelQuery(treeNode) + 1);
- } else if (documentPosition == sdRegion.getStartOffset(completionRegion) && (regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_COMMENT_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DECLARATION_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_EXPRESSION_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_SCRIPTLET_OPEN) || regionType == XMLRegionContext.XML_DECLARATION_OPEN || regionType == XMLRegionContext.XML_PI_OPEN || regionType == XMLRegionContext.XML_COMMENT_OPEN || regionType == XMLRegionContext.XML_CDATA_OPEN)) {
+ }
+ else if (documentPosition == sdRegion.getStartOffset(completionRegion) && (regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_COMMENT_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DECLARATION_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_EXPRESSION_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_SCRIPTLET_OPEN) || regionType == XMLRegionContext.XML_DECLARATION_OPEN || regionType == XMLRegionContext.XML_PI_OPEN || regionType == XMLRegionContext.XML_COMMENT_OPEN || regionType == XMLRegionContext.XML_CDATA_OPEN)) {
contentAssistRequest = newContentAssistRequest(treeNode, xmlnode.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
addTagInsertionProposals(contentAssistRequest, getElementPositionForModelQuery(treeNode));
addStartDocumentProposals(contentAssistRequest);
@@ -1163,7 +1189,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
* @param documentPosition -
* the cursor location within the document
*
- an array of ICompletionProposals
+ * an array of ICompletionProposals
*/
public ICompletionProposal[] computeCompletionProposals(ITextViewer textViewer, int documentPosition) {
@@ -1195,7 +1221,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
contentAssistRequest = newContentAssistRequest(docNode, docNode, sdRegion, completionRegion, documentPosition, 0, null);
addEmptyDocumentProposals(contentAssistRequest);
}
- } finally {
+ }
+ finally {
if (sModel != null)
sModel.releaseFromRead();
}
@@ -1243,7 +1270,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
}
// entities?
addEntityProposals(contentAssistRequest, documentPosition, completionRegion, node);
- //addEntityProposals(contentAssistRequest);
+ // addEntityProposals(contentAssistRequest);
return contentAssistRequest;
}
@@ -1254,9 +1281,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
*
* @param viewer
* the viewer whose document is used to compute the possible
- * contexts
- an array of context information objects or <code>null</code>
- * if no context could be found
+ * contexts an array of context information objects or
+ * <code>null</code> if no context could be found
*/
public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
if (fAttributeInfoProvider == null)
@@ -1275,19 +1301,21 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
if (documentPosition != completionRegionStart && regionAtEndOfCompletion != null && regionAtEndOfCompletion.getType() == XMLRegionContext.XML_TAG_NAME) {
ITextRegion nameRegion = regionAtEndOfCompletion;
contentAssistRequest = newContentAssistRequest(nodeAtOffset, nodeAtOffset.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(nameRegion), nameRegion.getTextLength(), matchString);
- } else {
+ }
+ else {
if (nodeAtOffset.getFirstStructuredDocumentRegion() == sdRegion) {
// abnormal case, this unmatched end tag will be a sibling
contentAssistRequest = newContentAssistRequest(nodeAtOffset, nodeAtOffset.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- } else {
+ }
+ else {
// normal case, this end tag is the parent
contentAssistRequest = newContentAssistRequest(nodeAtOffset, nodeAtOffset, sdRegion, completionRegion, documentPosition, 0, matchString);
}
}
- //if (documentPosition >= sdRegion.getStartOffset(completionRegion) +
+ // if (documentPosition >= sdRegion.getStartOffset(completionRegion) +
// completionRegion.getTextLength())
addEndTagProposals(contentAssistRequest);
- //else
+ // else
if (completionRegionStart == documentPosition) {
// positioned at start of end tag
addTagInsertionProposals(contentAssistRequest, node.getChildNodes().getLength());
@@ -1307,7 +1335,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
int nodeOffset = documentPosition - sdRegion.getStartOffset(completionRegion);
String regionText = sdRegion.getFullText(completionRegion);
- //if directly to the right of a &, region will be null, need to
+ // if directly to the right of a &, region will be null, need to
// move to
// the previous region...there might be a better way to do this
if (regionText != null && regionText.trim().equals("") && documentPosition > 0) { //$NON-NLS-1$
@@ -1335,7 +1363,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
}
if (cmmap != null) {
entities = mapToProperties(cmmap);
- } else // 224787 in absence of content model, just use
+ }
+ else // 224787 in absence of content model, just use
// minimal 5 entities
{
entities = new Properties();
@@ -1360,7 +1389,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
if (valueRegion != null && valueRegion.getType() == XMLRegionContext.XML_TAG_ATTRIBUTE_VALUE && sdRegion.getStartOffset(valueRegion) <= documentPosition) {
// replace the adjacent attribute value
contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, valueRegion, sdRegion.getStartOffset(valueRegion), valueRegion.getTextLength(), matchString);
- } else {
+ }
+ else {
// append an attribute value after the '='
contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition, 0, matchString);
}
@@ -1391,7 +1421,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
if (node.getNodeType() != Node.DOCUMENT_NODE && node.getEndStructuredDocumentRegion() == null) {
addEndTagProposals(contentAssistRequest);
}
- } else {
+ }
+ else {
// at the start of the tag's close or within it
ITextRegion closeRegion = sdRegion.getLastRegion();
boolean insideTag = !sdRegion.isEnded() || documentPosition <= sdRegion.getStartOffset(closeRegion);
@@ -1416,7 +1447,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
if (sdRegion != nodeAtOffset.getFirstStructuredDocumentRegion()) {
- //completing the *first* tag in "<tagname1 |<tagname2"
+ // completing the *first* tag in "<tagname1 |<tagname2"
XMLNode actualNode = (XMLNode) node.getModel().getIndexedRegion(sdRegion.getStartOffset(completionRegion));
if (actualNode != null) {
if (actualNode.getFirstStructuredDocumentRegion() == sdRegion) {
@@ -1427,39 +1458,46 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
if (node.getStructuredDocument().getRegionAtCharacterOffset(sdRegion.getStartOffset(completionRegion) - 1).getRegionAtCharacterOffset(sdRegion.getStartOffset(completionRegion) - 1).getType() == XMLRegionContext.XML_TAG_OPEN)
addAttributeNameProposals(contentAssistRequest);
addTagCloseProposals(contentAssistRequest);
- } else {
+ }
+ else {
// it's name
contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, documentPosition - matchString.length(), matchString.length(), matchString);
addTagNameProposals(contentAssistRequest, getElementPositionForModelQuery(actualNode));
}
- } else {
+ }
+ else {
if (documentPosition >= sdRegion.getStartOffset(completionRegion) + completionRegion.getLength()) {
// insert name
contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- } else {
- //replace name
+ }
+ else {
+ // replace name
contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
}
addEndTagNameProposals(contentAssistRequest);
}
}
- } else {
+ }
+ else {
if (documentPosition > sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength()) {
// unclosed tag with only a name; should prompt for attributes
// and a close instead
contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition - matchString.length(), matchString.length(), matchString);
addAttributeNameProposals(contentAssistRequest);
addTagCloseProposals(contentAssistRequest);
- } else {
+ }
+ else {
if (sdRegion.getRegions().get(0).getType() != XMLRegionContext.XML_END_TAG_OPEN) {
contentAssistRequest = newContentAssistRequest(node, node.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
addTagNameProposals(contentAssistRequest, getElementPositionForModelQuery(nodeAtOffset));
- } else {
+ }
+ else {
XMLNode actualNode = (XMLNode) node.getModel().getIndexedRegion(documentPosition);
if (actualNode != null) {
if (documentPosition >= sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength()) {
contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- } else {
+ }
+ else {
contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
}
addEndTagNameProposals(contentAssistRequest);
@@ -1474,35 +1512,39 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
ContentAssistRequest contentAssistRequest = null;
IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
if (sdRegion != nodeAtOffset.getFirstStructuredDocumentRegion()) {
- //completing the *first* XML_TAG_OPEN in "<<tagname"
+ // completing the *first* XML_TAG_OPEN in "<<tagname"
XMLNode actualNode = (XMLNode) node.getModel().getIndexedRegion(sdRegion.getStartOffset(completionRegion));
if (actualNode != null) {
contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
addTagNameProposals(contentAssistRequest, getElementPositionForModelQuery(actualNode));
addEndTagProposals(contentAssistRequest); // (pa) 220850
}
- } else {
+ }
+ else {
if (documentPosition == sdRegion.getStartOffset(completionRegion)) {
if (node.getNodeType() == Node.ELEMENT_NODE) {
// at the start of an existing tag, right before the '<'
contentAssistRequest = newContentAssistRequest(nodeAtOffset, node.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
addTagInsertionProposals(contentAssistRequest, getElementPositionForModelQuery(nodeAtOffset));
addEndTagProposals(contentAssistRequest);
- } else if (node.getNodeType() == Node.DOCUMENT_NODE) {
+ }
+ else if (node.getNodeType() == Node.DOCUMENT_NODE) {
// at the opening of the VERY first tag with a '<'
contentAssistRequest = newContentAssistRequest(nodeAtOffset, node.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
addStartDocumentProposals(contentAssistRequest);
}
- } else {
+ }
+ else {
// within the white space
ITextRegion name = getNameRegion(node.getStartStructuredDocumentRegion());
// (pa) ITextRegion refactor
- //if (name != null && name.containsOffset(documentPosition))
+ // if (name != null && name.containsOffset(documentPosition))
// {
if (name != null && (sdRegion.getStartOffset(name) <= documentPosition && sdRegion.getEndOffset(name) >= documentPosition)) {
// replace the existing name
contentAssistRequest = newContentAssistRequest(node, node.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(name), name.getTextLength(), matchString);
- } else {
+ }
+ else {
// insert a valid new name, or possibly an end tag
contentAssistRequest = newContentAssistRequest(nodeAtOffset, ((Node) nodeAtOffset).getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
addEndTagProposals(contentAssistRequest);
@@ -1520,8 +1562,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
* proposal's additional info. If no documentation exists for cmnode, try
* displaying parentOrOwner's documentation
*
- String any documentation information to display for cmnode.
- * <code>null</code> if there is nothing to display.
+ * String any documentation information to display for cmnode.
+ * <code>null</code> if there is nothing to display.
*/
protected String getAdditionalInfo(CMNode parentOrOwner, CMNode cmnode) {
String addlInfo = null;
@@ -1569,7 +1611,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
return new ArrayList(0);
for (Node child = document.getFirstChild(); child != null; child = child.getNextSibling()) {
- //make sure the "root" Element isn't already present
+ // make sure the "root" Element isn't already present
// is it required to be an Element?
if (child.getNodeType() == Node.ELEMENT_NODE && stringsEqual(child.getNodeName(), rootName)) {
// if the node is missing either the start or end tag, don't
@@ -1592,7 +1634,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
CMElementDeclaration rootDecl = (CMElementDeclaration) cmdoc.getElements().getNamedItem(rootName);
if (rootDecl != null) {
list.add(rootDecl);
- } else {
+ }
+ else {
// supply the given document name anyway, even if it
// is an error
list.add(new SimpleCMElementDeclaration(rootName));
@@ -1607,7 +1650,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
setErrorMessage(SSEUIPlugin.getResourceString("%20concat", (new Object[]{rootName}))); //$NON-NLS-1$ = "No definition was found for element <{0}>"
}
}
- } else {
+ }
+ else {
if (Debug.displayInfo || Debug.displayWarnings)
System.out.println("No content model found."); //$NON-NLS-1$
//$NON-NLS-1$
@@ -1639,8 +1683,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
* Returns the characters which when entered by the user should
* automatically trigger the presentation of possible completions.
*
- the auto activation characters for completion proposal or
- * <code>null</code> if no auto activation is desired
+ * the auto activation characters for completion proposal or
+ * <code>null</code> if no auto activation is desired
*/
public char[] getCompletionProposalAutoActivationCharacters() {
return completionProposalAutoActivationCharacters;
@@ -1658,7 +1702,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
// previous IStructuredDocumentRegion is
// where to look for a useful region.
region = sdRegion.getPrevious().getRegionAtCharacterOffset(offset - 1);
- } else {
+ }
+ else {
// Is there no separating whitespace from the previous region?
// If not,
// then that region is the important one
@@ -1667,7 +1712,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
region = previousRegion;
}
}
- } else {
+ }
+ else {
// The offset is NOT at the beginning of the region
if (offset > sdRegion.getStartOffset(region) + region.getTextLength()) {
// Is the offset within the whitespace after the text in this
@@ -1676,7 +1722,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
ITextRegion nextRegion = sdRegion.getRegionAtCharacterOffset(sdRegion.getStartOffset(region) + region.getLength());
if (nextRegion != null)
region = nextRegion;
- } else {
+ }
+ else {
// Is the offset within the important text for this region?
// If so, then we've already got the right one.
}
@@ -1733,12 +1780,13 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
// the offset is definitely within the start or end tag, continue
// on and find the region
region = getCompletionRegion(offset, flatNode);
- } else {
+ }
+ else {
// the docPosition is neither within the start nor the end, so it
// must be content
flatNode = node.getStructuredDocument().getRegionAtCharacterOffset(offset);
// (pa) ITextRegion refactor
- //if (flatNode.contains(documentPosition)) {
+ // if (flatNode.contains(documentPosition)) {
if (flatNode.getStartOffset() <= documentPosition && flatNode.getEndOffset() >= documentPosition) {
// we're interesting in completing/extending the previous
// IStructuredDocumentRegion if the current
@@ -1749,11 +1797,14 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
// previous IStructuredDocumentRegion is
// where to look for a useful region.
region = flatNode.getPrevious().getLastRegion();
- } else if (flatNode.getEndOffset() == documentPosition) {
+ }
+ else if (flatNode.getEndOffset() == documentPosition) {
region = flatNode.getLastRegion();
- } else
+ }
+ else
region = flatNode.getFirstRegion();
- } else {
+ }
+ else {
// catch end of document positions where the docPosition isn't
// in a IStructuredDocumentRegion
region = flatNode.getLastRegion();
@@ -1779,9 +1830,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
* Returns the characters which when entered by the user should
* automatically trigger the presentation of context information.
*
- the auto activation characters for presenting context
- * information or <code>null</code> if no auto activation is
- * desired
+ * the auto activation characters for presenting context information or
+ * <code>null</code> if no auto activation is desired
*/
public char[] getContextInformationAutoActivationCharacters() {
return contextInformationAutoActivationCharacters;
@@ -1792,8 +1842,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
* information should be dismissed. May only return <code>null</code> if
* the processor is incapable of computing context information.
*
- a context information validator, or <code>null</code> if the
- * processor is incapable of computing context information
+ * a context information validator, or <code>null</code> if the
+ * processor is incapable of computing context information
*/
public IContextInformationValidator getContextInformationValidator() {
if (fContextInformationPresenter == null)
@@ -1823,14 +1873,14 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
private int getElementPositionForModelQuery(Node child) {
return getElementPosition(child);
- // return -1;
+ // return -1;
}
/**
* Return the reason why computeProposals was not able to find any
* completions.
*
- an error message or null if no error occurred
+ * an error message or null if no error occurred
*/
public String getErrorMessage() {
return fErrorMessage;
@@ -1839,14 +1889,14 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
/**
* @param iResource
*/
- // public void initialize(IResource iResource) {
- // this.resource = iResource;
- // }
+ // public void initialize(IResource iResource) {
+ // this.resource = iResource;
+ // }
/**
* Gets the infoProvider.
*
- fInfoProvider and if fInfoProvider was <code>null</code>
- * create a new instance
+ * fInfoProvider and if fInfoProvider was <code>null</code> create a new
+ * instance
*/
public MarkupTagInfoProvider getInfoProvider() {
if (fInfoProvider == null) {
@@ -1862,9 +1912,11 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
String regionType = aRegion.getType();
if (regionType == XMLRegionContext.XML_TAG_ATTRIBUTE_EQUALS || regionType == XMLRegionContext.XML_TAG_OPEN || (offset > parent.getStartOffset(aRegion) + aRegion.getTextLength())) {
matchString = ""; //$NON-NLS-1$
- } else if (regionType == XMLRegionContext.XML_CONTENT) {
+ }
+ else if (regionType == XMLRegionContext.XML_CONTENT) {
matchString = ""; //$NON-NLS-1$
- } else {
+ }
+ else {
if (parent.getText(aRegion).length() > 0 && parent.getStartOffset(aRegion) < offset)
matchString = parent.getText(aRegion).substring(0, offset - parent.getStartOffset(aRegion));
else
@@ -1900,7 +1952,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
ModelQuery modelQuery = ModelQueryUtil.getModelQuery(element.getOwnerDocument());
if (modelQuery != null) {
dataTypeValues = modelQuery.getPossibleDataTypeValues(element, ad);
- } else {
+ }
+ else {
if (ad.getAttrType() != null)
dataTypeValues = ad.getAttrType().getEnumeratedValues();
}
@@ -1926,7 +1979,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
}
return getContentGenerator().getRequiredName(parentOrOwner, cmnode);
}
-
+
protected String getRequiredText(Node parentOrOwner, CMAttributeDeclaration attrDecl) {
if (attrDecl == null) {
if (Debug.displayWarnings) {
@@ -1956,7 +2009,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
*/
public IStructuredDocumentRegion getStructuredDocumentRegion(int pos) {
// (pa) ITextRegion refactor defect 245190
- //return
+ // return
// (IStructuredDocumentRegion)ContentAssistUtils.getNodeAt((StructuredTextViewer)fTextViewer,
// pos);
return ContentAssistUtils.getStructuredDocumentRegion((StructuredTextViewer) fTextViewer, pos);
@@ -1995,7 +2048,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
* tells you if the document is XML type.
*
* @param node
-
+ *
*/
protected boolean getXML(Node node) {
if (node == null)
@@ -2029,7 +2082,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
* Checks if cursor position is after doctype tag...
*
* @param car
-
+ *
*/
protected boolean isCursorAfterDoctype(ContentAssistRequest car) {
Node aNode = car.getNode();
@@ -2056,7 +2109,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
* This method can check if the cursor is after the XMLPI
*
* @param car
-
+ *
*/
protected boolean isCursorAfterXMLPI(ContentAssistRequest car) {
Node aNode = car.getNode();
@@ -2122,7 +2175,7 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
* Gets the corresponding XMLNode, and checks if it's closed.
*
* @param startTag
-
+ *
*/
private boolean needsEndTag(IStructuredDocumentRegion startTag) {
boolean result = false;
@@ -2139,7 +2192,8 @@ abstract public class AbstractContentAssistProcessor implements IContentAssistPr
else
result = xmlNode.getEndStructuredDocumentRegion() == null;
}
- } finally {
+ }
+ finally {
if (sModel != null)
sModel.releaseFromRead();
}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/NewXSDWizard.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/NewXSDWizard.java
index fa8899d897..55ea903884 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/NewXSDWizard.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/wizards/NewXSDWizard.java
@@ -29,140 +29,118 @@ import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.part.ISetSelectionTarget;
-import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
+import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames;
import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
-public class NewXSDWizard extends Wizard implements INewWizard
-{
- private XSDNewFilePage newFilePage;
- private IStructuredSelection selection;
- private IWorkbench workbench;
-
- public NewXSDWizard()
- {
- }
-
- public void init(IWorkbench aWorkbench, IStructuredSelection aSelection)
- {
- this.selection = aSelection;
- this.workbench = aWorkbench;
-
- this.setDefaultPageImageDescriptor(ImageDescriptor.createFromFile(XSDEditorPlugin.class, "icons/NewXSD.gif"));
- this.setWindowTitle(XSDEditorPlugin.getXSDString("_UI_WIZARD_CREATE_XSD_MODEL_TITLE"));
- }
-
- public void addPages()
- {
- newFilePage = new XSDNewFilePage(selection);
- addPage(newFilePage);
- }
-
- public boolean performFinish()
- {
- IFile file = newFilePage.createNewFile();
-
- //
- // Get the xsd schema name from the full path name
- // e.g. f:/b2b/po.xsd => schema name = po
- //
- IPath iPath = file.getFullPath().removeFileExtension();
- // String schemaName = iPath.lastSegment();
- String schemaName = iPath.lastSegment();
- String schemaPrefix = "tns";
- String prefixForSchemaNamespace = "";
- String schemaNamespaceAttribute = "xmlns";
- if (XSDEditorPlugin.getPlugin().isQualifyXMLSchemaLanguage())
- {
- // Added this if check before disallowing blank prefixes in the preferences...
- // Can take this out. See also XSDEditor
- if (XSDEditorPlugin.getPlugin().getXMLSchemaPrefix().trim().length() > 0)
- {
- prefixForSchemaNamespace = XSDEditorPlugin.getPlugin().getXMLSchemaPrefix() + ":";
- schemaNamespaceAttribute += ":" + XSDEditorPlugin.getPlugin().getXMLSchemaPrefix();
- }
- }
-
- Preferences preference = XMLCorePlugin.getDefault().getPluginPreferences();
- String charSet = preference.getString(CommonModelPreferenceNames.OUTPUT_CODESET);
- if (charSet == null || charSet.trim().equals(""))
- {
- charSet = "UTF-8";
- }
-
- String newContents = "<?xml version=\"1.0\" encoding=\"" + charSet + "\"?>\n";
-
- String defaultTargetURI = XSDEditorPlugin.getPlugin().getXMLSchemaTargetNamespace();
- newContents += "<" + prefixForSchemaNamespace + "schema " + schemaNamespaceAttribute + "=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"" + defaultTargetURI + schemaName + "\" xmlns:" + schemaPrefix + "=\""+ defaultTargetURI + schemaName + "\">\n</"+prefixForSchemaNamespace+"schema>";
-
- try
- {
- byte[] bytes = newContents.getBytes(charSet);
- ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
-
- file.setContents(inputStream,true,false,null);
- inputStream.close();
- }
- catch (Exception e)
- {
-// XSDEditorPlugin.getPlugin().getMsgLogger().write("Error writing default content:\n" + newContents);
-// XSDEditorPlugin.getPlugin().getMsgLogger().write(e);
- }
-
- if (file != null)
- {
- revealSelection(new StructuredSelection(file));
- }
-
- openEditor(file);
-
- return true;
- }
-
- private void revealSelection(final ISelection selection)
- {
- if (selection != null)
- {
- IWorkbench workbench = XSDEditorPlugin.getPlugin().getWorkbench();
- final IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
- final IWorkbenchPart focusPart = workbenchWindow.getActivePage().getActivePart();
- if (focusPart instanceof ISetSelectionTarget)
- {
- Display.getCurrent().asyncExec
- (new Runnable()
- {
- public void run()
- {
- ((ISetSelectionTarget)focusPart).selectReveal(selection);
- }
- });
- }
- }
- }
-
- public void openEditor(final IFile iFile)
- {
- if (iFile != null)
- {
- IWorkbench workbench = XSDEditorPlugin.getPlugin().getWorkbench();
- final IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
-
- Display.getDefault().asyncExec
- (new Runnable()
- {
- public void run()
- {
- try
- {
- IEditorPart editorPart = workbenchWindow.getActivePage().openEditor(new FileEditorInput(iFile), XSDEditorPlugin.XSD_EDITOR_ID);
- }
- catch (PartInitException ex)
- {
- }
- }
- });
- }
- }
-
+public class NewXSDWizard extends Wizard implements INewWizard {
+ private XSDNewFilePage newFilePage;
+ private IStructuredSelection selection;
+ private IWorkbench workbench;
+
+ public NewXSDWizard() {
+ }
+
+ public void init(IWorkbench aWorkbench, IStructuredSelection aSelection) {
+ this.selection = aSelection;
+ this.workbench = aWorkbench;
+
+ this.setDefaultPageImageDescriptor(ImageDescriptor.createFromFile(XSDEditorPlugin.class, "icons/NewXSD.gif"));
+ this.setWindowTitle(XSDEditorPlugin.getXSDString("_UI_WIZARD_CREATE_XSD_MODEL_TITLE"));
+ }
+
+ public void addPages() {
+ newFilePage = new XSDNewFilePage(selection);
+ addPage(newFilePage);
+ }
+
+ public boolean performFinish() {
+ IFile file = newFilePage.createNewFile();
+
+ //
+ // Get the xsd schema name from the full path name
+ // e.g. f:/b2b/po.xsd => schema name = po
+ //
+ IPath iPath = file.getFullPath().removeFileExtension();
+ // String schemaName = iPath.lastSegment();
+ String schemaName = iPath.lastSegment();
+ String schemaPrefix = "tns";
+ String prefixForSchemaNamespace = "";
+ String schemaNamespaceAttribute = "xmlns";
+ if (XSDEditorPlugin.getPlugin().isQualifyXMLSchemaLanguage()) {
+ // Added this if check before disallowing blank prefixes in the
+ // preferences...
+ // Can take this out. See also XSDEditor
+ if (XSDEditorPlugin.getPlugin().getXMLSchemaPrefix().trim().length() > 0) {
+ prefixForSchemaNamespace = XSDEditorPlugin.getPlugin().getXMLSchemaPrefix() + ":";
+ schemaNamespaceAttribute += ":" + XSDEditorPlugin.getPlugin().getXMLSchemaPrefix();
+ }
+ }
+
+ Preferences preference = XMLCorePlugin.getDefault().getPluginPreferences();
+ String charSet = preference.getString(CommonEncodingPreferenceNames.OUTPUT_CODESET);
+ if (charSet == null || charSet.trim().equals("")) {
+ charSet = "UTF-8";
+ }
+
+ String newContents = "<?xml version=\"1.0\" encoding=\"" + charSet + "\"?>\n";
+
+ String defaultTargetURI = XSDEditorPlugin.getPlugin().getXMLSchemaTargetNamespace();
+ newContents += "<" + prefixForSchemaNamespace + "schema " + schemaNamespaceAttribute + "=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"" + defaultTargetURI + schemaName + "\" xmlns:" + schemaPrefix + "=\"" + defaultTargetURI + schemaName + "\">\n</" + prefixForSchemaNamespace + "schema>";
+
+ try {
+ byte[] bytes = newContents.getBytes(charSet);
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
+
+ file.setContents(inputStream, true, false, null);
+ inputStream.close();
+ }
+ catch (Exception e) {
+ // XSDEditorPlugin.getPlugin().getMsgLogger().write("Error writing
+ // default content:\n" + newContents);
+ // XSDEditorPlugin.getPlugin().getMsgLogger().write(e);
+ }
+
+ if (file != null) {
+ revealSelection(new StructuredSelection(file));
+ }
+
+ openEditor(file);
+
+ return true;
+ }
+
+ private void revealSelection(final ISelection selection) {
+ if (selection != null) {
+ IWorkbench workbench = XSDEditorPlugin.getPlugin().getWorkbench();
+ final IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+ final IWorkbenchPart focusPart = workbenchWindow.getActivePage().getActivePart();
+ if (focusPart instanceof ISetSelectionTarget) {
+ Display.getCurrent().asyncExec(new Runnable() {
+ public void run() {
+ ((ISetSelectionTarget) focusPart).selectReveal(selection);
+ }
+ });
+ }
+ }
+ }
+
+ public void openEditor(final IFile iFile) {
+ if (iFile != null) {
+ IWorkbench workbench = XSDEditorPlugin.getPlugin().getWorkbench();
+ final IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ try {
+ IEditorPart editorPart = workbenchWindow.getActivePage().openEditor(new FileEditorInput(iFile), XSDEditorPlugin.XSD_EDITOR_ID);
+ }
+ catch (PartInitException ex) {
+ }
+ }
+ });
+ }
+ }
+
}

Back to the top