Skip to main content

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

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornitind2005-04-13 19:12:49 +0000
committernitind2005-04-13 19:12:49 +0000
commit292ded1b4de2f6030e4038b92a37ea5914d3ea7d (patch)
tree44e67d379b97f7e2b353212e4103815636679fec /bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal
parent20cb84d3fe65f82e36498d9946b3b951273a4a4d (diff)
downloadwebtools.sourceediting-292ded1b4de2f6030e4038b92a37ea5914d3ea7d.tar.gz
webtools.sourceediting-292ded1b4de2f6030e4038b92a37ea5914d3ea7d.tar.xz
webtools.sourceediting-292ded1b4de2f6030e4038b92a37ea5914d3ea7d.zip
This commit was manufactured by cvs2svn to create tag 'v20050413_1525'.v20050413_1525
Diffstat (limited to 'bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal')
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserver.java189
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/JobStatusLineHelper.java103
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/Logger.java159
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java289
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPlugin.java111
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties302
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/StructuredAutoEditStrategyXML.java114
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentAssistProcessor.java2241
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentModelGenerator.java86
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformation.java113
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationPresenter.java112
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationProvider.java208
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContentAssistRequest.java269
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContextInfoModelUtil.java65
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/CustomTemplateProposal.java40
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/NoRegionContentAssistProcessor.java263
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/NonValidatingModelQueryAction.java159
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ProposalComparator.java48
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/SimpleCMElementDeclaration.java170
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/SourceEditorImageHelper.java48
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistProcessor.java145
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistUtilities.java492
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentModelGenerator.java135
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLRelevanceConstants.java51
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLTemplateCompletionProcessor.java80
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/BufferedOutlineUpdater.java63
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapter.java344
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapterFactory.java104
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeContentProvider.java104
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeLabelProvider.java136
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshOutlineJob.java189
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshPropertySheetJob.java62
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/XMLNodeActionManager.java52
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/CorrectionProcessorXML.java42
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/InsertRequiredAttrsQuickAssistProposal.java174
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/ProblemIDsXML.java31
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickAssistProcessorXML.java169
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickFixProcessorXML.java147
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RemoveUnknownElementQuickFixProposal.java156
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RenameInFileQuickAssistProposal.java182
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/SurroundWithNewElementQuickAssistProposal.java107
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/DragNodeCommand.java228
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/XMLDragAndDropManager.java48
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/doubleclick/XMLDoubleClickStrategy.java285
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/CMImageUtil.java96
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/IHelpContextIds.java43
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImageHelper.java155
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImages.java53
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileEditorInput.java146
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileHyperlink.java72
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/WorkspaceFileHyperlink.java79
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java472
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/EncodingSettings.java356
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/WorkbenchDefaultEncodingSettings.java137
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLColorPage.java223
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLFilesPreferencePage.java195
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLSourcePreferencePage.java245
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLTemplatePreferencePage.java67
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceInitializer.java104
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceNames.java68
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/ProjectionModelNodeAdapterFactoryXML.java57
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/ProjectionModelNodeAdapterXML.java273
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/StructuredTextFoldingProviderXML.java214
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/EnumeratedStringPropertyDescriptor.java69
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/StringComboBoxCellEditor.java111
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/XMLPropertySourceAdapter.java697
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/XMLPropertySourceAdapterFactory.java39
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/registry/AdapterFactoryProviderForEmbeddedXML.java40
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/registry/AdapterFactoryProviderForXML.java103
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesAction.java51
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/style/IStyleConstantsXML.java41
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/style/LineStyleProviderForXML.java173
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/MarkupTagInfoProvider.java174
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLBestMatchHoverProcessor.java39
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLInformationProvider.java64
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLTagInfoHoverProcessor.java334
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/EncodingTemplateVariableResolverXML.java38
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/TemplateContextTypeIdsXML.java50
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/TemplateContextTypeXML.java35
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/text/XMLDocumentRegionEdgeMatcher.java25
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentoutline/XMLContentOutlineConfiguration.java239
81 files changed, 0 insertions, 13992 deletions
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserver.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserver.java
deleted file mode 100644
index b70f63b2f6..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserver.java
+++ /dev/null
@@ -1,189 +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.ui.internal;
-
-
-import java.util.Timer;
-import java.util.TimerTask;
-
-import org.eclipse.wst.sse.core.INodeAdapter;
-import org.eclipse.wst.sse.core.INodeNotifier;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.xml.core.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.CMDocumentLoader;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.InferredGrammarBuildingCMDocumentLoader;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-/**
- * This class is used to observe changes in the DOM and perform
- * occasional'scans' to deduce information. We use a delay timer mechanism to
- * ensure scans are made every couple of seconds to avoid performance
- * problems. Currently this class is used to keep track of referenced grammar
- * uri's within the document ensure that they are loaded by the
- * CMDocumentManager. We might want to generalize this class to perform other
- * suplimental information gathering that is suitable for 'time delayed'
- * computation (error hints etc.).
- */
-// TODO: Where should this class go?
-public class DOMObserver {
-
-
- // An abstract adapter that ensures that the children of a new Node are
- // also adapted
- //
- abstract class DocumentAdapter implements INodeAdapter {
- public DocumentAdapter(Document document) {
- ((INodeNotifier) document).addAdapter(this);
- adapt(document.getDocumentElement());
- }
-
- public void adapt(Element element) {
- if (element != null) {
- if (((INodeNotifier) element).getExistingAdapter(this) == null) {
- ((INodeNotifier) element).addAdapter(this);
-
- for (Node child = element.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child.getNodeType() == Node.ELEMENT_NODE) {
- adapt((Element) child);
- }
- }
- }
- }
- }
-
- public boolean isAdapterForType(Object type) {
- return type == this;
- }
-
- abstract public void notifyChanged(INodeNotifier notifier, int eventType, Object feature, Object oldValue, Object newValue, int index);
- }
-
- /**
- * This class listens to the changes in the CMDocument and triggers a
- * CMDocument load
- */
- class MyDocumentAdapter extends DocumentAdapter {
- MyDocumentAdapter(Document document) {
- super(document);
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object feature, Object oldValue, Object newValue, int index) {
- switch (eventType) {
- case INodeNotifier.ADD : {
- if (newValue instanceof Element) {
- // System.out.println("ADD (to " +
- // ((Node)notifier).getNodeName() + ") " +
- // ((Element)newValue).getNodeName() + " old " +
- // oldValue);
- adapt((Element) newValue);
- }
- break;
- }
- // case INodeNotifier.REMOVE:
- case INodeNotifier.CHANGE :
- case INodeNotifier.STRUCTURE_CHANGED :
- case INodeNotifier.CONTENT_CHANGED : {
- Node node = (Node) notifier;
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- Element element = (Element) node;
- switch (eventType) {
- case INodeNotifier.CHANGE : {
- invokeDelayedCMDocumentLoad();
- break;
- }
- case INodeNotifier.STRUCTURE_CHANGED : {
- // structure change
- invokeDelayedCMDocumentLoad();
- break;
- }
- case INodeNotifier.CONTENT_CHANGED : {
- // some content changed
- break;
- }
- }
- }
- else if (node.getNodeType() == Node.DOCUMENT_NODE) {
- invokeDelayedCMDocumentLoad();
- }
- break;
- }
- }
- }
- }
-
- class MyTimerTask extends TimerTask {
- public MyTimerTask() {
- super();
- timerTaskCount++;
- }
-
- public void run() {
- timerTaskCount--;
- if (timerTaskCount == 0) {
- invokeCMDocumentLoad();
- }
- }
- }
-
- protected static Timer timer = new Timer(true);
- protected Document document;
- protected boolean isGrammarInferenceEnabled;
- protected IStructuredModel model;
- protected int timerTaskCount = 0;
-
- public DOMObserver(IStructuredModel model) {
- this.document = (model instanceof IDOMModel) ? ((IDOMModel) model).getDocument() : null;
-
- if (document != null) {
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document);
- if (modelQuery != null && modelQuery.getCMDocumentManager() != null) {
- CMDocumentManager cmDocumentManager = modelQuery.getCMDocumentManager();
- cmDocumentManager.setPropertyEnabled(CMDocumentManager.PROPERTY_AUTO_LOAD, false);
- }
-
- MyDocumentAdapter myDocumentAdapter = new MyDocumentAdapter(document);
- }
- }
-
- public void init() {
- // CS: we seem to expose an XSD initialization problem when we do this
- // immediately
- // very nasty... I need to revist this problem with Ed Merks
- //
- // invokeCMDocumentLoad();
- invokeDelayedCMDocumentLoad();
- }
-
- public void invokeCMDocumentLoad() {
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document);
- if (modelQuery != null && modelQuery.getCMDocumentManager() != null) {
- CMDocumentLoader loader = isGrammarInferenceEnabled ? new InferredGrammarBuildingCMDocumentLoader(document, modelQuery) : new CMDocumentLoader(document, modelQuery);
- loader.loadCMDocuments();
- }
- }
-
- public void invokeDelayedCMDocumentLoad() {
- // Display.getCurrent().timerExec(2000, new MyTimerTask());
- timer.schedule(new MyTimerTask(), 2000);
- }
-
- public void setGrammarInferenceEnabled(boolean isEnabled) {
- isGrammarInferenceEnabled = isEnabled;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/JobStatusLineHelper.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/JobStatusLineHelper.java
deleted file mode 100644
index 1e94b7d13b..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/JobStatusLineHelper.java
+++ /dev/null
@@ -1,103 +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.ui.internal;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
-
-
-/**
- * Updates the status line when an appropriate Job is about to be run.
- */
-public class JobStatusLineHelper extends JobChangeAdapter {
- private static JobStatusLineHelper instance;
-
- public static void init() {
- if (instance == null) {
- instance = new JobStatusLineHelper();
- }
- }
-
- private int running = 0;
-
- private JobStatusLineHelper() {
- Platform.getJobManager().addJobChangeListener(this);
- }
-
- public void aboutToRun(IJobChangeEvent event) {
- Job job = event.getJob();
- if (job.belongsTo(CMDocumentManager.class)) {
- running++;
- setStatusLine(event.getJob().getName());
- }
- }
-
- public void done(IJobChangeEvent event) {
- Job job = event.getJob();
- if (job.belongsTo(CMDocumentManager.class)) {
- running--;
- if (running == 0) {
- setStatusLine(""); //$NON-NLS-1$
- }
- }
- }
-
- private Display getDisplay() {
- return PlatformUI.getWorkbench().getDisplay();
- }
-
- private void setStatusLine(final String message) {
- String msgString = message;
- if (message == null) {
- msgString = ""; //$NON-NLS-1$
- }
- final String finalMessageForThread = msgString;
- if (getDisplay() != null) {
- Runnable runnable = new Runnable() {
- public void run() {
- IWorkbench workbench = PlatformUI.getWorkbench();
- if (workbench != null) {
- IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
- if (workbenchWindow != null) {
- IEditorPart part = workbenchWindow.getActivePage().getActiveEditor();
- // part is sometimes null by the time this runs
- // ... must be better way to get actionBars
- // and/or statLineManager?
- if (part != null) {
- IActionBars actionBars = part.getEditorSite().getActionBars();
- if (actionBars != null) {
- IStatusLineManager statusLineManager = actionBars.getStatusLineManager();
- if (statusLineManager != null) {
- statusLineManager.setMessage(finalMessageForThread);
- }
- }
- }
- }
- }
- }
- };
- Display workbenchDefault = PlatformUI.getWorkbench().getDisplay();
- workbenchDefault.asyncExec(runnable);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/Logger.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/Logger.java
deleted file mode 100644
index e427490378..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/Logger.java
+++ /dev/null
@@ -1,159 +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.ui.internal;
-
-
-
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.osgi.framework.Bundle;
-
-/**
- * Small convenience class to log messages to plugin's log file and also, if
- * desired, the console. This class should only be used by classes in this
- * plugin. Other plugins should make their own copy, with appropriate ID.
- */
-public class Logger {
- private static final String PLUGIN_ID = "org.eclipse.wst.xml.ui"; //$NON-NLS-1$
-
- public static final int ERROR = IStatus.ERROR; // 4
- public static final int ERROR_DEBUG = 200 + ERROR;
- public static final int INFO = IStatus.INFO; // 1
- public static final int INFO_DEBUG = 200 + INFO;
-
- public static final int OK = IStatus.OK; // 0
-
- public static final int OK_DEBUG = 200 + OK;
-
- private static final String TRACEFILTER_LOCATION = "/debug/tracefilter"; //$NON-NLS-1$
- public static final int WARNING = IStatus.WARNING; // 2
- public static final int WARNING_DEBUG = 200 + WARNING;
-
- /**
- * Adds message to log.
- *
- * @param level
- * severity level of the message (OK, INFO, WARNING, ERROR,
- * OK_DEBUG, INFO_DEBUG, WARNING_DEBUG, ERROR_DEBUG)
- * @param message
- * text to add to the log
- * @param exception
- * exception thrown
- */
- protected static void _log(int level, String message, Throwable exception) {
- if (level == OK_DEBUG || level == INFO_DEBUG || level == WARNING_DEBUG || level == ERROR_DEBUG) {
- if (!isDebugging())
- return;
- }
-
- int severity = IStatus.OK;
- switch (level) {
- case INFO_DEBUG :
- case INFO :
- severity = IStatus.INFO;
- break;
- case WARNING_DEBUG :
- case WARNING :
- severity = IStatus.WARNING;
- break;
- case ERROR_DEBUG :
- case ERROR :
- severity = IStatus.ERROR;
- }
- message = (message != null) ? message : "null"; //$NON-NLS-1$
- Status statusObj = new Status(severity, PLUGIN_ID, severity, message, exception);
- Bundle bundle = Platform.getBundle(PLUGIN_ID);
- if (bundle != null)
- Platform.getLog(bundle).log(statusObj);
- }
-
- /**
- * Prints message to log if category matches /debug/tracefilter option.
- *
- * @param message
- * text to print
- * @param category
- * category of the message, to be compared with
- * /debug/tracefilter
- */
- protected static void _trace(String category, String message, Throwable exception) {
- if (isTracing(category)) {
- message = (message != null) ? message : "null"; //$NON-NLS-1$
- Status statusObj = new Status(IStatus.OK, PLUGIN_ID, IStatus.OK, message, exception);
- Bundle bundle = Platform.getBundle(PLUGIN_ID);
- if (bundle != null)
- Platform.getLog(bundle).log(statusObj);
- }
- }
-
- /**
- * @return true if the platform is debugging
- */
- public static boolean isDebugging() {
- return Platform.inDebugMode();
- }
-
- /**
- * Determines if currently tracing a category
- *
- * @param category
- * @return true if tracing category, false otherwise
- */
- public static boolean isTracing(String category) {
- if (!isDebugging())
- return false;
-
- String traceFilter = Platform.getDebugOption(PLUGIN_ID + TRACEFILTER_LOCATION);
- if (traceFilter != null) {
- StringTokenizer tokenizer = new StringTokenizer(traceFilter, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String cat = tokenizer.nextToken().trim();
- if (category.equals(cat)) {
- return true;
- }
- }
- }
- return false;
- }
-
- public static void log(int level, String message) {
- _log(level, message, null);
- }
-
- public static void log(int level, String message, Throwable exception) {
- _log(level, message, exception);
- }
-
- public static void logException(String message, Throwable exception) {
- _log(ERROR, message, exception);
- }
-
- public static void logException(Throwable exception) {
- _log(ERROR, exception.getMessage(), exception);
- }
-
- public static void trace(String category, String message) {
- _trace(category, message, null);
- }
-
- public static void traceException(String category, String message, Throwable exception) {
- _trace(category, message, exception);
- }
-
- public static void traceException(String category, Throwable exception) {
- _trace(category, exception.getMessage(), exception);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java
deleted file mode 100644
index 8264ae27bc..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2005 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 - Initial API and implementation
- **********************************************************************/
-package org.eclipse.wst.xml.ui.internal;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Strings used by XML UI
- *
- * @since 1.0
- */
-public class XMLUIMessages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.wst.xml.ui.internal.XMLUIPluginResources";//$NON-NLS-1$
- private static ResourceBundle fResourceBundle;
-
- public static String Sample_XML_doc;
- public static String Comment_Delimiters_UI_;
- public static String Comment_Content_UI_;
- public static String Tag_Delimiters_UI_;
- public static String Tag_Names_UI_;
- public static String Attribute_Names_UI_;
- public static String Attribute_Values_UI_;
- public static String Declaration_Delimiters_UI_;
- public static String Content_UI_;
- public static String CDATA_Delimiters_UI_;
- public static String CDATA_Content_UI_;
- public static String Processing_Instruction_Del_UI_;
- public static String Processing_Instruction_Con_UI__UI_;
- public static String DOCTYPE_Name_UI_;
- public static String DOCTYPE_SYSTEM_PUBLIC_Keyw_UI_;
- public static String DOCTYPE_Public_Reference_UI_;
- public static String DOCTYPE_System_Reference_UI_;
- public static String DELETE;
- public static String ADD_PROCESSING_INSTRUCTION;
- public static String _UI_MENU_ADD_AFTER;
- public static String _UI_MENU_ADD_ATTRIBUTE;
- public static String _UI_MENU_ADD_BEFORE;
- public static String _UI_MENU_ADD_CHILD;
- public static String _UI_MENU_REMOVE;
- public static String _UI_MENU_REPLACE_WITH;
- public static String _UI_MENU_EDIT_DOCTYPE;
- public static String _UI_LABEL_UNDO_REPLACE_DESCRIPTION;
- public static String _UI_LABEL_EDIT_DOCTYPE;
- public static String _UI_INFO_EXPAND_ALL;
- public static String _UI_INFO_COLLAPSE_ALL;
- public static String _UI_MENU_ADD_DTD_INFORMATION;
- public static String _UI_MENU_ADD_SCHEMA_INFORMATION;
- public static String _UI_MENU_EDIT_PROCESSING_INSTRUCTION;
- public static String _UI_MENU_EDIT_NAMESPACES;
- public static String _UI_MENU_ADD_DTD_INFORMATION_TITLE;
- public static String _UI_MENU_EDIT_PROCESSING_INSTRUCTION_TITLE;
- public static String _UI_MENU_EDIT_SCHEMA_INFORMATION_TITLE;
- public static String _UI_MENU_NEW_ATTRIBUTE;
- public static String _UI_MENU_NEW_ATTRIBUTE_TITLE;
- public static String _UI_MENU_EDIT_ATTRIBUTE;
- public static String _UI_MENU_EDIT_ATTRIBUTE_TITLE;
- public static String _UI_MENU_NEW_ELEMENT;
- public static String _UI_MENU_NEW_ELEMENT_TITLE;
- public static String _UI_MENU_RENAME;
- public static String _UI_MENU_RENAME_TITLE;
- public static String _UI_LABEL_ELEMENT_NAME;
- public static String _UI_MENU_ADD_COMMENT;
- public static String _UI_MENU_ADD_PROCESSING_INSTRUCTION;
- public static String _UI_MENU_ADD_CDATA_SECTION;
- public static String _UI_MENU_ADD_PCDATA;
- public static String _UI_MENU_COMMENT;
- public static String _UI_MENU_PROCESSING_INSTRUCTION;
- public static String _UI_MENU_CDATA_SECTION;
- public static String _UI_MENU_PCDATA;
- public static String _UI_MENU_ADD;
- public static String _UI_COMMENT_VALUE;
- public static String _UI_PI_TARGET_VALUE;
- public static String _UI_PI_DATA_VALUE;
- public static String _UI_LABEL_ROOT_ELEMENT_VALUE;
- public static String _UI_LABEL_TARGET_COLON;
- public static String _UI_LABEL_DATA_COLON;
- public static String _UI_LABEL_ROOT_ELEMENT_NAME_COLON;
- public static String _UI_LABEL_PUBLIC_ID_COLON;
- public static String _UI_LABEL_SYSTEM_ID_COLON;
- public static String _UI_LABEL_BROWSE;
- public static String _UI_LABEL_SELECT_XML_CATALOG_ENTRY;
- public static String _UI_LABEL_SPECIFY_SYSTEM_ID;
- public static String _UI_LABEL_SELECT_FILE;
- public static String _UI_LABEL_KEY;
- public static String _UI_LABEL_URI;
- public static String _UI_LABEL_XML_CATALOG_COLON;
- public static String _UI_LABEL_NAMESPACE_NAME;
- public static String _UI_LABEL_LOCATION_HINT;
- public static String _UI_LABEL_PREFIX;
- public static String _UI_LABEL_NAMESPACE_NAME_COLON;
- public static String _UI_LABEL_LOCATION_HINT_COLON;
- public static String _UI_LABEL_PREFIX_COLON;
- public static String _UI_NO_NAMESPACE_NAME;
- public static String _UI_NO_PREFIX;
- public static String _UI_LABEL_XML_SCHEMA_INFORMATION;
- public static String _UI_LABEL_NAME_COLON;
- public static String _UI_LABEL_VALUE_COLON;
- public static String _UI_BUTTON_DELETE;
- public static String _UI_BUTTON_NEW;
- public static String _UI_BUTTON_EDIT;
- public static String _UI_LABEL_NEW_NAMESPACE_INFORMATION;
- public static String _UI_RADIO_BUTTON_SELECT_FROM_WORKSPACE;
- public static String _UI_RADIO_BUTTON_SELECT_FROM_CATALOG;
- public static String _UI_WARNING_MORE_THAN_ONE_NS_WITH_NAME;
- public static String _UI_WARNING_MORE_THAN_ONE_NS_WITHOUT_NAME;
- public static String _UI_WARNING_MORE_THAN_ONE_NS_WITHOUT_PREFIX;
- public static String _UI_WARNING_MORE_THAN_ONE_NS_WITH_PREFIX;
- public static String _UI_WARNING_SCHEMA_CAN_NOT_BE_LOCATED;
- public static String _UI_WARNING_LOCATION_HINT_NOT_SPECIFIED;
- public static String _UI_WARNING_NAMESPACE_NAME_NOT_SPECIFIED;
- public static String _UI_WARNING_PREFIX_NOT_SPECIFIED;
- public static String _UI_WARNING_ROOT_ELEMENT_MUST_BE_SPECIFIED;
- public static String _UI_WARNING_SYSTEM_ID_MUST_BE_SPECIFIED;
- public static String _UI_INVALID_NAME;
- public static String _UI_ENTER_REQ_PREFIX_AND_NAMESPACE;
- public static String _UI_SELECT_REGISTERED_NAMESPACES;
- public static String _UI_SPECIFY_NEW_NAMESPACE;
- public static String _UI_SELECT_NAMESPACE_TO_ADD;
- public static String _UI_ADD_NAMESPACE_DECLARATIONS;
- public static String _UI_NAMESPACE_DECLARATIONS;
- public static String _UI_TARGET_NAMESPACE;
- public static String _ERROR_XML_ATTRIBUTE_ALREADY_EXISTS;
- public static String error_message_goes_here;
- public static String SurroundWithNewElementQuickAssistProposal_0;
- public static String SurroundWithNewElementQuickAssistProposal_1;
- public static String RenameInFileQuickAssistProposal_0;
- public static String RenameInFileQuickAssistProposal_1;
- public static String InsertRequiredAttrsQuickAssistProposal_0;
- public static String InsertRequiredAttrsQuickAssistProposal_1;
- public static String EncodingSettings_0;
- public static String EncodingSettings_1;
- public static String DragNodeCommand_0;
- public static String CommonEditNamespacesDialog_0;
- public static String JFaceNodeAdapter_1;
- public static String QuickFixProcessorXML_0;
- public static String QuickFixProcessorXML_1;
- public static String QuickFixProcessorXML_2;
- public static String QuickFixProcessorXML_3;
- public static String QuickFixProcessorXML_4;
- public static String QuickFixProcessorXML_5;
- public static String QuickFixProcessorXML_6;
- public static String QuickFixProcessorXML_7;
- public static String QuickFixProcessorXML_8;
- public static String QuickFixProcessorXML_9;
- public static String QuickFixProcessorXML_10;
- public static String QuickFixProcessorXML_11;
- public static String QuickFixProcessorXML_12;
- public static String QuickFixProcessorXML_13;
- public static String QuickFixProcessorXML_14;
- public static String QuickFixProcessorXML_15;
- public static String XMLPropertySourceAdapter_0;
- public static String WorkbenchDefaultEncodingSettings_0;
- public static String refreshoutline_0;
- public static String Creating_files_encoding;
- public static String End_tag_has_attributes;
- public static String Attribute__is_missing_a_value;
- public static String Attribute__has_no_value;
- public static String Missing_end_tag_;
- public static String ReconcileStepForMarkup_0;
- public static String ReconcileStepForMarkup_1;
- public static String ReconcileStepForMarkup_2;
- public static String ReconcileStepForMarkup_3;
- public static String ReconcileStepForMarkup_4;
- public static String ReconcileStepForMarkup_5;
- public static String ReconcileStepForMarkup_6;
- public static String End_with_;
- public static String SEVERE_internal_error_occu_UI_;
- public static String No_known_attribute__UI_;
- public static String Content_Assist_not_availab_UI_;
- public static String Element__is_unknown;
- public static String Comment__;
- public static String Close_with__;
- public static String End_with__;
- public static String Close_with___;
- public static String Close_with____;
- public static String _Has_no_available_child;
- public static String No_known_child_tag;
- public static String __Has_no_known_child;
- public static String No_known_child_tag_names;
- public static String The_document_element__;
- public static String No_definition_for_in;
- public static String No_definition_for;
- public static String No_content_model_for;
- public static String No_content_model_found_UI_;
- public static String Cleanup_UI_;
- public static String Compress_empty_element_tags_UI_;
- public static String Insert_required_attributes_UI_;
- public static String Insert_missing_tags_UI_;
- public static String Quote_attribute_values_UI_;
- public static String Format_source_UI_;
- public static String Convert_EOL_codes_UI_;
- public static String EOL_Windows_UI;
- public static String EOL_Unix_UI;
- public static String EOL_Mac_UI;
- public static String Creating_files;
- public static String Encoding_desc;
- public static String Encoding;
- public static String Creating_or_saving_files;
- public static String End_of_line_code_desc;
- public static String End_of_line_code;
- public static String EOL_Windows;
- public static String EOL_Unix;
- public static String EOL_Mac;
- public static String EOL_NoTranslation;
- public static String Content_assist_UI_;
- public static String Automatically_make_suggest_UI_;
- public static String Prompt_when_these_characte_UI_;
- public static String Formatting_UI_;
- public static String Line_width__UI_;
- public static String Split_multiple_attributes;
- public static String Indent_using_tabs;
- public static String Clear_all_blank_lines_UI_;
- public static String Grammar_Constraints;
- public static String Use_inferred_grammar_in_absence_of;
- public static String Element____1;
- public static String Content_Model____2;
- public static String Attribute____3;
- public static String Data_Type____4;
- public static String Enumerated_Values____5;
- public static String FormatMenu_label;
- public static String SourceMenu_label;
- public static String Comment_label; // Resource bundle
- public static String Comment_tooltip; // Resource bundle
- public static String Comment_description; // Resource bundle
- public static String Uncomment_label; // Resource bundle
- public static String Uncomment_tooltip; // Resource bundle
- public static String Uncomment_description; // Resource bundle
- public static String ToggleComment_label; // Resource bundle
- public static String ToggleComment_tooltip; // Resource bundle
- public static String ToggleComment_description; // Resource bundle
- public static String AddBlockComment_label; // Resource bundle
- public static String AddBlockComment_tooltip; // Resource bundle
- public static String AddBlockComment_description; // Resource bundle
- public static String RemoveBlockComment_label; // Resource bundle
- public static String RemoveBlockComment_tooltip; // Resource bundle
- public static String RemoveBlockComment_description; // Resource bundle
- public static String CleanupDocument_label; // Resource bundle
- public static String CleanupDocument_tooltip; // Resource bundle
- public static String CleanupDocument_description; // Resource bundle
- public static String FindOccurrences_label; // Resource bundle
- public static String ShowTooltipDesc_label; // Resource bundle
- public static String ShowTooltipDesc_tooltip; // Resource bundle
- public static String ShowTooltipDesc_description; // Resource bundle
- public static String ContentAssistProposals_label; // Resource bundle
- public static String ContentAssistProposals_tooltip; // Resource bundle
- public static String ContentAssistProposals_description; // Resourcebundle
- public static String QuickFix_label; // Resource bundle
- public static String QuickFix_tooltip; // Resource bundle
- public static String QuickFix_description; // Resource bundle
- public static String FormatDocument_label; // Resource bundle
- public static String FormatDocument_tooltip; // Resource bundle
- public static String FormatDocument_description; // Resource bundle
- public static String FormatActiveElements_label; // Resource bundle
- public static String FormatActiveElements_tooltip; // Resource bundle
- public static String FormatActiveElements_description; // Resource bundle
- public static String OpenFileFromSource_label; // Resource bundle
- public static String OpenFileFromSource_tooltip; // Resource bundle
- public static String OpenFileFromSource_description; // Resource bundle
-
- static {
- // load message values from bundle file
- NLS.initializeMessages(BUNDLE_NAME, XMLUIMessages.class);
- }
-
- private XMLUIMessages() {
- // cannot create new instance
- }
-
- public static ResourceBundle getResourceBundle() {
- try {
- if (fResourceBundle == null)
- fResourceBundle = ResourceBundle.getBundle(BUNDLE_NAME);
- }
- catch (MissingResourceException x) {
- fResourceBundle = null;
- }
- return fResourceBundle;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPlugin.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPlugin.java
deleted file mode 100644
index 094a020d64..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPlugin.java
+++ /dev/null
@@ -1,111 +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.ui.internal;
-
-import java.io.IOException;
-
-import org.eclipse.jface.text.templates.ContextTypeRegistry;
-import org.eclipse.jface.text.templates.persistence.TemplateStore;
-import org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry;
-import org.eclipse.ui.editors.text.templates.ContributionTemplateStore;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.wst.sse.ui.registry.AdapterFactoryRegistry;
-import org.eclipse.wst.sse.ui.registry.AdapterFactoryRegistryImpl;
-import org.eclipse.wst.sse.ui.registry.embedded.EmbeddedAdapterFactoryRegistryImpl;
-import org.eclipse.wst.xml.ui.internal.preferences.XMLUIPreferenceNames;
-import org.eclipse.wst.xml.ui.internal.templates.TemplateContextTypeIdsXML;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class XMLUIPlugin extends AbstractUIPlugin {
- public final static String ID = "org.eclipse.wst.xml.ui"; //$NON-NLS-1$
- protected static XMLUIPlugin instance = null;
-
- public static XMLUIPlugin getDefault() {
- return instance;
- }
-
- public synchronized static XMLUIPlugin getInstance() {
- return instance;
- }
-
- /**
- * The template context type registry for the xml editor.
- *
- * @since 3.0
- */
- private ContextTypeRegistry fContextTypeRegistry;
-
- /**
- * The template store for the xml editor.
- *
- * @since 3.0
- */
- private TemplateStore fTemplateStore;
-
- public XMLUIPlugin() {
- super();
- instance = this;
-
- JobStatusLineHelper.init();
- }
-
- public AdapterFactoryRegistry getAdapterFactoryRegistry() {
- return AdapterFactoryRegistryImpl.getInstance();
-
- }
-
- public AdapterFactoryRegistry getEmbeddedAdapterFactoryRegistry() {
- return EmbeddedAdapterFactoryRegistryImpl.getInstance();
-
- }
-
- /**
- * Returns the template store for the xml editor templates.
- *
- * @return the template store for the xml editor templates
- */
- public TemplateStore getTemplateStore() {
- if (fTemplateStore == null) {
- fTemplateStore = new ContributionTemplateStore(getTemplateContextRegistry(), getPreferenceStore(), XMLUIPreferenceNames.TEMPLATES_KEY);
-
- try {
- fTemplateStore.load();
- } catch (IOException e) {
- Logger.logException(e);
- }
- }
- return fTemplateStore;
- }
-
- /**
- * Returns the template context type registry for the xml plugin.
- *
- * @return the template context type registry for the xml plugin
- */
- public ContextTypeRegistry getTemplateContextRegistry() {
- if (fContextTypeRegistry == null) {
- ContributionContextTypeRegistry registry = new ContributionContextTypeRegistry();
- registry.addContextType(TemplateContextTypeIdsXML.ALL);
- registry.addContextType(TemplateContextTypeIdsXML.NEW);
- registry.addContextType(TemplateContextTypeIdsXML.TAG);
- registry.addContextType(TemplateContextTypeIdsXML.ATTRIBUTE);
- registry.addContextType(TemplateContextTypeIdsXML.ATTRIBUTE_VALUE);
-
- fContextTypeRegistry = registry;
- }
-
- return fContextTypeRegistry;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties
deleted file mode 100644
index 6b69139a67..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties
+++ /dev/null
@@ -1,302 +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
-#
-###############################################################################
-## The following line is a sample XML document. Please translate only the following parts:
-## begin color definitions
-## Normal text content.
-Sample_XML_doc=<?xml version=\"1.0\"?>\n<?customProcessingInstruction\n\tXML processor specific\n\tcontent ?>\n<!DOCTYPE colors\n\tPUBLIC \"//IBM/XML/COLORS/\" \"colors.dtd\">\n<colors>\n\t<!-- begin color definitions -->\n\t<color name=\"plaintext\" foreground=\"#000000\"\n\t\tbackground=\"#D4D0C8\" />\n\t<color name=\"bold\" foreground=\"#000000\"\n\t\tbackground=\"#B3ACA0\" />\n\t<![CDATA[<123456789>]]>\n\tNormal text content.\n\t<color name=\"inverse\" foreground=\"#F0F0F0\"\n\t\tbackground=\"#D4D0C8\" />\n\n</colors>\n
-Comment_Delimiters_UI_=Comment Delimiters
-Comment_Content_UI_=Comment Content
-Tag_Delimiters_UI_=Tag Delimiters
-Tag_Names_UI_=Tag Names
-Attribute_Names_UI_=Attribute Names
-Attribute_Values_UI_=Attribute Values
-Declaration_Delimiters_UI_=Declaration Delimiters
-Content_UI_=Content
-## on the following 2 lines, do not translate CDATA
-CDATA_Delimiters_UI_=CDATA Delimiters
-CDATA_Content_UI_=CDATA Content
-Processing_Instruction_Del_UI_=Processing Instruction Delimiters
-Processing_Instruction_Con_UI__UI_=Processing Instruction Content
-## on the following line solely translate: Name
-DOCTYPE_Name_UI_=DOCTYPE Name
-## on the following line solely translate: Keyword
-DOCTYPE_SYSTEM_PUBLIC_Keyw_UI_=DOCTYPE SYSTEM/PUBLIC Keyword
-## on the following line solely translate: Public Reference
-DOCTYPE_Public_Reference_UI_=DOCTYPE Public Reference
-## on the following line solely translate: System Reference
-DOCTYPE_System_Reference_UI_=DOCTYPE System Reference
-# XML Common UI
-# Constants for strings
-
-DELETE=Remove
-ADD_PROCESSING_INSTRUCTION=Add Processing Instruction
-
-_UI_MENU_ADD_AFTER=Add &After
-_UI_MENU_ADD_ATTRIBUTE=Add A&ttribute
-_UI_MENU_ADD_BEFORE=Add &Before
-_UI_MENU_ADD_CHILD=Add &Child
-_UI_MENU_REMOVE=Re&move
-_UI_MENU_REPLACE_WITH=Re&place With
-_UI_MENU_EDIT_DOCTYPE=Edit DOCTYPE...
-_UI_LABEL_UNDO_REPLACE_DESCRIPTION=Replace
-_UI_LABEL_EDIT_DOCTYPE=Edit DOCTYPE
-_UI_INFO_EXPAND_ALL=Expand All
-_UI_INFO_COLLAPSE_ALL=Collapse All
-
-_UI_MENU_ADD_DTD_INFORMATION=Add DTD Information...
-_UI_MENU_ADD_SCHEMA_INFORMATION=Add Schema Information...
-_UI_MENU_EDIT_PROCESSING_INSTRUCTION=Edit Process&ing Instruction...
-_UI_MENU_EDIT_NAMESPACES=Edit &Namespaces...
-
-_UI_MENU_ADD_DTD_INFORMATION_TITLE=Add DTD Information
-_UI_MENU_EDIT_PROCESSING_INSTRUCTION_TITLE=Edit Processing Instruction
-_UI_MENU_EDIT_SCHEMA_INFORMATION_TITLE=Edit Schema Information
-
-_UI_MENU_NEW_ATTRIBUTE=&New Attribute...
-_UI_MENU_NEW_ATTRIBUTE_TITLE=New Attribute
-_UI_MENU_EDIT_ATTRIBUTE=Edit Attribute...
-_UI_MENU_EDIT_ATTRIBUTE_TITLE=Edit Attribute
-_UI_MENU_NEW_ELEMENT=New &Element...
-_UI_MENU_NEW_ELEMENT_TITLE=New Element
-_UI_MENU_RENAME=R&ename
-_UI_MENU_RENAME_TITLE=Rename
-_UI_LABEL_ELEMENT_NAME=Element name:
-
-_UI_MENU_ADD_COMMENT=Add Comment
-_UI_MENU_ADD_PROCESSING_INSTRUCTION=Add Processing Instruction
-_UI_MENU_ADD_CDATA_SECTION=Add CDATA Section
-_UI_MENU_ADD_PCDATA=Add #PCDATA;
-
-_UI_MENU_COMMENT=C&omment
-_UI_MENU_PROCESSING_INSTRUCTION=P&rocessing Instruction
-_UI_MENU_CDATA_SECTION=CDATA Section
-_UI_MENU_PCDATA=#PC&DATA;
-
-_UI_MENU_ADD=Add
-
-_UI_COMMENT_VALUE=comment
-_UI_PI_TARGET_VALUE=target
-_UI_PI_DATA_VALUE=data
-_UI_LABEL_ROOT_ELEMENT_VALUE=RootElement
-
-_UI_LABEL_TARGET_COLON=Target:
-_UI_LABEL_DATA_COLON=Data:
-_UI_LABEL_ROOT_ELEMENT_NAME_COLON=Root element name:
-_UI_LABEL_PUBLIC_ID_COLON=Public ID:
-_UI_LABEL_SYSTEM_ID_COLON=System ID:
-_UI_LABEL_BROWSE=Browse...
-_UI_LABEL_SELECT_XML_CATALOG_ENTRY=Select XML Catalog Entry
-_UI_LABEL_SPECIFY_SYSTEM_ID=Specify System ID
-_UI_LABEL_SELECT_FILE=Select File
-
-_UI_LABEL_KEY=Key
-_UI_LABEL_URI=URI:
-_UI_LABEL_XML_CATALOG_COLON=XML Catalog
-_UI_LABEL_NAMESPACE_NAME=Namespace Name
-_UI_LABEL_LOCATION_HINT=Location Hint
-_UI_LABEL_PREFIX=Prefix
-_UI_LABEL_NAMESPACE_NAME_COLON=Namespace Name:
-_UI_LABEL_LOCATION_HINT_COLON=Location Hint:
-_UI_LABEL_PREFIX_COLON=Prefix:
-_UI_NO_NAMESPACE_NAME=<no namespace name>
-_UI_NO_PREFIX=<no prefix>
-
-_UI_LABEL_XML_SCHEMA_INFORMATION=XML Schema Information
-
-_UI_LABEL_NAME_COLON=Name:
-_UI_LABEL_VALUE_COLON=Value:
-
-_UI_BUTTON_DELETE=Delete
-_UI_BUTTON_NEW=New...
-_UI_BUTTON_EDIT=Edit...
-
-_UI_LABEL_NEW_NAMESPACE_INFORMATION=New Namespace Information
-
-# SelectFileOrXMLCatalogIdPanel.java
-
-_UI_RADIO_BUTTON_SELECT_FROM_WORKSPACE=Select file from workbench
-_UI_RADIO_BUTTON_SELECT_FROM_CATALOG=Select XML Catalog entry
-
-_UI_WARNING_MORE_THAN_ONE_NS_WITH_NAME=More than one namespace has been specified with the namespace name :
-_UI_WARNING_MORE_THAN_ONE_NS_WITHOUT_NAME=More than one schema has been specified without a namespace name
-_UI_WARNING_MORE_THAN_ONE_NS_WITHOUT_PREFIX=More than one namespace has been specificed without a prefix
-_UI_WARNING_MORE_THAN_ONE_NS_WITH_PREFIX=More than one namespace has been specified with the prefix :
-_UI_WARNING_SCHEMA_CAN_NOT_BE_LOCATED=The specified schema can not be located :
-_UI_WARNING_LOCATION_HINT_NOT_SPECIFIED=A location hint has not been specified for the namespace with name
-_UI_WARNING_NAMESPACE_NAME_NOT_SPECIFIED=A name must be specified for the namespace with prefix :
-_UI_WARNING_PREFIX_NOT_SPECIFIED=A prefix must be specified for the namespace named :
-_UI_WARNING_ROOT_ELEMENT_MUST_BE_SPECIFIED=A root element name must be specified.
-_UI_WARNING_SYSTEM_ID_MUST_BE_SPECIFIED=A system ID must be specified.
-
-_UI_INVALID_NAME=Invalid name
-
-# String used for editing namespaces (org.eclipse.wst.xml.ui.nsedit)
-_UI_ENTER_REQ_PREFIX_AND_NAMESPACE=Enter the required prefix and namespace URI for the namespace declaration.
-_UI_SELECT_REGISTERED_NAMESPACES=Select From Registered Namespaces
-_UI_SPECIFY_NEW_NAMESPACE=Specify New Namespace
-_UI_SELECT_NAMESPACE_TO_ADD=Select the namespace declarations to add.
-_UI_ADD_NAMESPACE_DECLARATIONS=Add Namespace Declarations
-_UI_NAMESPACE_DECLARATIONS=Namespace Declarations
-_UI_TARGET_NAMESPACE=Target Namespace
-
-_ERROR_XML_ATTRIBUTE_ALREADY_EXISTS=The element already has an attribute with this name.
-
-#
-error_message_goes_here=error message goes here
-SurroundWithNewElementQuickAssistProposal_0=Surround with new element
-SurroundWithNewElementQuickAssistProposal_1=Surround with new element
-RenameInFileQuickAssistProposal_0=Link all references for a rename in file (does not change references in other files)
-RenameInFileQuickAssistProposal_1=Rename in file
-InsertRequiredAttrsQuickAssistProposal_0=Insert required attributes
-InsertRequiredAttrsQuickAssistProposal_1=Insert required attributes
-EncodingSettings_0=IANA:
-EncodingSettings_1=Encoding:
-TemplateContextTypeXMLTag_0=XML Tags
-TemplateContextTypeXMLAttributeValue_0=XML Attribute Values
-TemplateContextTypeXMLAttribute_0=XML Attributes
-TemplateContextTypeXML_0=All XML
-DragNodeCommand_0=Move
-CommonEditNamespacesDialog_0=Add...
-JFaceNodeAdapter_1=Refresh Property Sheet
-QuickFixProcessorXML_0=Remove empty tag
-QuickFixProcessorXML_1=Change to empty-element tag
-QuickFixProcessorXML_2=Remove this tag
-QuickFixProcessorXML_3=Insert end tag before first child element
-QuickFixProcessorXML_4=Insert end tag at end of element
-QuickFixProcessorXML_5=Remove attributes in end tag
-QuickFixProcessorXML_6=Insert default attribute value
-QuickFixProcessorXML_7=Remove this attribute
-QuickFixProcessorXML_8=Remove spaces before tag name
-QuickFixProcessorXML_9=Remove spaces before processing instruction
-QuickFixProcessorXML_10=Remove namespace in processing instruction
-QuickFixProcessorXML_11=Remove this element
-QuickFixProcessorXML_12=Remove this attribute value
-QuickFixProcessorXML_13=Insert required attribute
-QuickFixProcessorXML_14=Quote attribute value
-QuickFixProcessorXML_15=Insert closing bracket
-XMLPropertySourceAdapter_0=Attributes
-
-WorkbenchDefaultEncodingSettings_0=Use workbench encoding
-refreshoutline_0=Refreshing Outline
-Creating_files_encoding=Creating files encoding preference
-# ReconcileStepForMarkup
-End_tag_has_attributes=End tag has attributes
-Attribute__is_missing_a_value=Attribute \"{0}\" is missing a value
-Attribute__has_no_value=Attribute \"{0}\" has no value
-Missing_end_tag_=Missing end tag \"{0}\"
-ReconcileStepForMarkup_0=Missing closing quote
-ReconcileStepForMarkup_1=Missing quotes for attribute value
-ReconcileStepForMarkup_2=A tagname cannot start with a space
-ReconcileStepForMarkup_3=Empty tags are not allowed
-ReconcileStepForMarkup_4=Namespaces are not allowed in a Processing Instruction target
-ReconcileStepForMarkup_5=Spaces are not allowed before a Processing Instruction
-ReconcileStepForMarkup_6=Tag missing closing bracket '>'
-# Content Assist
-End_with_=End with {0}>
-SEVERE_internal_error_occu_UI_=SEVERE internal error occurred
-No_known_attribute__UI_=No known attribute
-Content_Assist_not_availab_UI_=Content Assist not available at the current location
-Element__is_unknown=Element <{0}> is unknown.
-Comment__=comment {0}
-Close_with__=Close with {0}
-End_with__=End with \"</{0}>\"
-Close_with___=Close with \"{0}\"
-Close_with____=Close with \"></{0}>\"
-_Has_no_available_child={0} has no available child tags.
-No_known_child_tag=No known child tag names of <{0}> begin with \"{1}\".
-__Has_no_known_child=<{0}> has no known child tags.
-No_known_child_tag_names=No known child tag names of <{0}> begin with \"{1}\"
-The_document_element__=The document element <{0}> is already present.
-No_definition_for_in=No definition was found for element <{0}> in {1}
-No_definition_for=No definition was found for element <{0}>
-No_content_model_for=No content model found for {0}.
-No_content_model_found_UI_=No content model found
-## The following strings are for the XML Cleanup dialog
-Cleanup_UI_=Cleanup
-Compress_empty_element_tags_UI_=&Compress empty element tags
-Insert_required_attributes_UI_=Insert &required attributes
-Insert_missing_tags_UI_=&Insert missing tags
-Quote_attribute_values_UI_=&Quote attribute values
-Format_source_UI_=&Format source
-Convert_EOL_codes_UI_=Convert line &delimiters to
-EOL_Windows_UI=&Windows
-EOL_Unix_UI=U&NIX
-EOL_Mac_UI=&Mac
-## XML Files preference page
-Creating_files=Creating files
-Encoding_desc=The following encoding will apply:
-Encoding=En&coding:
-Creating_or_saving_files=Creating or saving files
-End_of_line_code_desc=The following line delimiter will apply:
-End_of_line_code=&Line delimiter:
-EOL_Windows=Windows
-EOL_Unix=UNIX
-EOL_Mac=Mac
-EOL_NoTranslation=No translation
-## XML Source preference page
-Content_assist_UI_=Content assist
-Automatically_make_suggest_UI_=Automatically ma&ke suggestions
-Prompt_when_these_characte_UI_=P&rompt when these characters are inserted:
-Formatting_UI_=Formatting
-Line_width__UI_=Line &width:
-Split_multiple_attributes=Split &multiple attributes each on a new line
-Indent_using_tabs=&Indent using tabs
-Clear_all_blank_lines_UI_=Clear all &blank lines
-Grammar_Constraints=Grammar Constraints
-Use_inferred_grammar_in_absence_of=Use inferred grammar in absence of DTD/Schema
-## tag info
-Element____1=Element :
-Content_Model____2=Content Model :
-Attribute____3=Attribute :
-Data_Type____4=Data Type :
-Enumerated_Values____5=Enumerated Values :
-## copied from sse.ui
-FormatMenu_label=F&ormat
-SourceMenu_label=&Source
-Comment_label=Co&mment
-Comment_tooltip=Comment
-Comment_description=Comment
-Uncomment_label=&Uncomment
-Uncomment_tooltip=Uncomment
-Uncomment_description=Uncomment
-ToggleComment_label=Togg&le Comment
-ToggleComment_tooltip=Toggle Comment
-ToggleComment_description=Toggle Comment
-AddBlockComment_label=Add &Block Comment
-AddBlockComment_tooltip=Add Block Comment
-AddBlockComment_description=Add Block Comment
-RemoveBlockComment_label=Remove Bloc&k Comment
-RemoveBlockComment_tooltip=Remove Block Comment
-RemoveBlockComment_description=Remove Block Comment
-CleanupDocument_label=C&leanup Document...
-CleanupDocument_tooltip=Cleanup Document
-CleanupDocument_description=Cleanup Document
-FindOccurrences_label=O&ccurrences in File
-ShowTooltipDesc_label=Show &Tooltip Description
-ShowTooltipDesc_tooltip=Displays the hover help for the selected element
-ShowTooltipDesc_description=Displays the hover help for the selected element
-ContentAssistProposals_label=Con&tent Assist
-ContentAssistProposals_tooltip=Content Assist
-ContentAssistProposals_description=Content Assist
-QuickFix_label=&Quick Fix
-QuickFix_tooltip=Quick Fix
-QuickFix_description=Quick Fix
-FormatDocument_label=&Document
-FormatDocument_tooltip=Format Document
-FormatDocument_description=Format Document
-FormatActiveElements_label=Act&ive Elements
-FormatActiveElements_tooltip=Format Active Elements
-FormatActiveElements_description=Format Active Elements
-OpenFileFromSource_label=Op&en Selection
-OpenFileFromSource_tooltip=Open an editor on the selected link
-OpenFileFromSource_description=Open an editor on the selected link \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/StructuredAutoEditStrategyXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/StructuredAutoEditStrategyXML.java
deleted file mode 100644
index e7c7918652..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/StructuredAutoEditStrategyXML.java
+++ /dev/null
@@ -1,114 +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.ui.internal.autoedit;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentCommand;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.ui.texteditor.ITextEditorExtension3;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.ui.internal.StructuredDocumentCommand;
-import org.eclipse.wst.sse.ui.internal.autoedit.BasicAutoEditStrategy;
-import org.eclipse.wst.xml.core.document.IDOMElement;
-import org.eclipse.wst.xml.core.document.IDOMNode;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.w3c.dom.Node;
-
-
-public class StructuredAutoEditStrategyXML extends BasicAutoEditStrategy {
- public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
- StructuredDocumentCommand structuredDocumentCommand = (StructuredDocumentCommand) command;
- Object textEditor = getActiveTextEditor();
- if (!(textEditor instanceof ITextEditorExtension3 && ((ITextEditorExtension3) textEditor).getInsertMode() == ITextEditorExtension3.SMART_INSERT))
- return;
-
- IStructuredModel model = null;
- try {
- model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
- if (model != null) {
- if (structuredDocumentCommand.text != null) {
- smartInsertForComment(structuredDocumentCommand, document, model);
- smartInsertForEndTag(structuredDocumentCommand, document, model);
- }
- }
- } finally {
- if (model != null)
- model.releaseFromRead();
- }
- }
-
- private boolean isCommentNode(IDOMNode node) {
- return (node != null && node instanceof IDOMElement && ((IDOMElement) node).isCommentTag());
- }
-
- private boolean isDocumentNode(IDOMNode node) {
- return (node != null && node.getNodeType() == Node.DOCUMENT_NODE);
- }
-
- protected boolean isEndTagRequired(IDOMNode node) {
-
- if (node == null)
- return false;
- return node.isContainer();
- }
-
- protected boolean prefixedWith(IDocument document, int offset, String string) {
-
- try {
- return document.getLength() >= string.length() && document.get(offset - string.length(), string.length()).equals(string);
- } catch (BadLocationException e) {
- Logger.logException(e);
- return false;
- }
- }
-
- protected void smartInsertForComment(StructuredDocumentCommand structuredDocumentCommand, IDocument document, IStructuredModel model) {
- try {
- if (structuredDocumentCommand.text.equals("-") && document.getLength() >= 3 && document.get(structuredDocumentCommand.offset - 3, 3).equals("<!-")) { //$NON-NLS-1$ //$NON-NLS-2$
- structuredDocumentCommand.text += " "; //$NON-NLS-1$
- structuredDocumentCommand.doit = false;
- structuredDocumentCommand.addCommand(structuredDocumentCommand.offset, 0, " -->", null); //$NON-NLS-1$
- }
- } catch (BadLocationException e) {
- Logger.logException(e);
- }
-
- }
-
- protected void smartInsertForEndTag(StructuredDocumentCommand structuredDocumentCommand, IDocument document, IStructuredModel model) {
- try {
- if (structuredDocumentCommand.text.equals("/") && document.getLength() >= 1 && document.get(structuredDocumentCommand.offset - 1, 1).equals("<")) { //$NON-NLS-1$ //$NON-NLS-2$
- IDOMNode parentNode = (IDOMNode) ((IDOMNode) model.getIndexedRegion(structuredDocumentCommand.offset - 1)).getParentNode();
- if (isCommentNode(parentNode)) {
- // loop and find non comment node parent
- while (parentNode != null && isCommentNode(parentNode)) {
- parentNode = (IDOMNode) parentNode.getParentNode();
- }
- }
-
- if (!isDocumentNode(parentNode)) {
- IStructuredDocumentRegion endTagStructuredDocumentRegion = parentNode.getEndStructuredDocumentRegion();
- if (endTagStructuredDocumentRegion == null) {
- structuredDocumentCommand.text += parentNode.getNodeName();
- structuredDocumentCommand.text += ">"; //$NON-NLS-1$
- }
- }
- }
- } catch (BadLocationException e) {
- Logger.logException(e);
- }
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentAssistProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentAssistProcessor.java
deleted file mode 100644
index c9590f3996..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentAssistProcessor.java
+++ /dev/null
@@ -1,2241 +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.ui.internal.contentassist;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.Vector;
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.IndexedRegion;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.encoding.ContentTypeEncodingPreferences;
-import org.eclipse.wst.sse.core.internal.util.Debug;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionContainer;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.sse.ui.internal.IReleasable;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
-import org.eclipse.wst.xml.core.contenttype.ContentTypeIdForXML;
-import org.eclipse.wst.xml.core.document.IDOMDocument;
-import org.eclipse.wst.xml.core.document.IDOMElement;
-import org.eclipse.wst.xml.core.document.IDOMModel;
-import org.eclipse.wst.xml.core.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMContent;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMEntityDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
-import org.eclipse.wst.xml.core.internal.document.AttrImpl;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.editor.CMImageUtil;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-import org.eclipse.wst.xml.ui.internal.taginfo.MarkupTagInfoProvider;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-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".
- */
- 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$
-
- private static final String JSP_COMMENT_OPEN = "JSP_COMMENT_OPEN"; //$NON-NLS-1$
- private static final String JSP_DECLARATION_OPEN = "JSP_DECLARATION_OPEN"; //$NON-NLS-1$
- private static final String JSP_DIRECTIVE_CLOSE = "JSP_DIRECTIVE_CLOSE"; //$NON-NLS-1$
- private static final String JSP_DIRECTIVE_NAME = "JSP_DIRECTIVE_NAME"; //$NON-NLS-1$
-
- private static final String JSP_DIRECTIVE_OPEN = "JSP_DIRECTIVE_OPEN"; //$NON-NLS-1$
- private static final String JSP_EXPRESSION_OPEN = "JSP_EXPRESSION_OPEN"; //$NON-NLS-1$
-
- 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 = XMLUIMessages.SEVERE_internal_error_occu_UI_;
- protected static final String UNKNOWN_ATTR = XMLUIMessages.No_known_attribute__UI_;
- protected static final String UNKNOWN_CONTEXT = XMLUIMessages.Content_Assist_not_availab_UI_;
- protected char completionProposalAutoActivationCharacters[] = null;
- protected char contextInformationAutoActivationCharacters[] = null;
- private AttributeContextInformationProvider fAttributeInfoProvider = null;
- private AttributeContextInformationPresenter fContextInformationPresenter = null;
-
- protected String fErrorMessage = null;
- protected XMLContentModelGenerator fGenerator;
- // protected IResource resource = null;
- protected MarkupTagInfoProvider fInfoProvider = null;
- protected ITextViewer fTextViewer = null;
-
- private final boolean showValues = true;
-
- public AbstractContentAssistProcessor() {
- super();
- init();
- }
-
- protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest) {
- IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
- IStructuredDocumentRegion sdRegion = contentAssistRequest.getDocumentRegion();
- // retrieve the list of attributes
- CMElementDeclaration elementDecl = getCMElementDeclaration(node);
- if (elementDecl != null) {
- CMNamedNodeMap attributes = elementDecl.getAttributes();
- String matchString = contentAssistRequest.getMatchString();
-
- // check whether an attribute really exists for the replacement
- // offsets AND if it possesses a value
- boolean attrAtLocationHasValue = false;
- NamedNodeMap attrs = node.getAttributes();
- for (int i = 0; i < attrs.getLength(); i++) {
- AttrImpl existingAttr = (AttrImpl) attrs.item(i);
- ITextRegion name = existingAttr.getNameRegion();
-
- if (sdRegion.getStartOffset(name) <= contentAssistRequest.getReplacementBeginPosition() && sdRegion.getStartOffset(name) + name.getLength() >= contentAssistRequest.getReplacementBeginPosition() + contentAssistRequest.getReplacementLength() && existingAttr.getValueRegion() != null) {
- attrAtLocationHasValue = true;
- break;
- }
- }
-
- // only add proposals for the attributes whose names begin with
- // the matchstring
- if (attributes != null) {
- for (int i = 0; i < attributes.getLength(); i++) {
- CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) attributes.item(i);
- // CMVC 246618
- int isRequired = 0;
- if (attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED) {
- isRequired = XMLRelevanceConstants.R_REQUIRED;
- }
-
- boolean showAttribute = true;
- showAttribute = showAttribute && beginsWith(getRequiredName(node, attrDecl), matchString.trim());
- AttrImpl attr = (AttrImpl) node.getAttributes().getNamedItem(getRequiredName(node, attrDecl));
- ITextRegion nameRegion = attr != null ? attr.getNameRegion() : null;
- // nameRegion.getEndOffset() + 1 is required to allow for
- // matches against the full name of an existing Attr
- showAttribute = showAttribute && ((attr == null) || (nameRegion != null && sdRegion.getStartOffset(nameRegion) <= contentAssistRequest.getReplacementBeginPosition() && sdRegion.getStartOffset(nameRegion) + nameRegion.getLength() >= contentAssistRequest.getReplacementBeginPosition() + contentAssistRequest.getReplacementLength()));
- if (showAttribute) {
- Image attrImage = CMImageUtil.getImage(attrDecl);
- if (attrImage == null) {
- if (isRequired > 0) {
- attrImage = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ATT_REQ_OBJ);
- }
- else {
- attrImage = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ATTRIBUTE);
- }
- }
-
- String proposedText = null;
- String proposedInfo = getAdditionalInfo(elementDecl, attrDecl);
- CustomCompletionProposal proposal = null;
- // attribute is at this location and already exists
- 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
- // 269884
- }
- // no attribute exists or is elsewhere, generate
- // minimally
- else {
- Attr existingAttrNode = (Attr) node.getAttributes().getNamedItem(getRequiredName(node, attrDecl));
- String value = null;
- if (existingAttrNode != null)
- value = existingAttrNode.getNodeValue();
- if (value != null && value.length() > 0)
- proposedText = getRequiredName(node, attrDecl);
- else {
- proposedText = getRequiredText(node, attrDecl);
- }
- proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), attrDecl.getNodeName().length() + 2, attrImage,
- // if the value isn't empty (no empty set of
- // quotes), show it
- (showValues && proposedText.indexOf("\"\"") < 0) ? proposedText : getRequiredName(node, attrDecl), //$NON-NLS-1$
- null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_NAME + isRequired);
- }
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- }
- else {
- setErrorMessage(NLS.bind(XMLUIMessages.Element__is_unknown, (new Object[]{node.getNodeName()})));
- }
- }
-
- protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
- IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
-
- // Find the attribute region and name for which this position should
- // have a value proposed
- IStructuredDocumentRegion open = node.getFirstStructuredDocumentRegion();
- ITextRegionList openRegions = open.getRegions();
- int i = openRegions.indexOf(contentAssistRequest.getRegion());
- if (i < 0)
- return;
- ITextRegion nameRegion = null;
- while (i >= 0) {
- nameRegion = openRegions.get(i--);
- if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)
- break;
- }
-
- // the name region is REQUIRED to do anything useful
- if (nameRegion != null) {
- // Retrieve the declaration
- CMElementDeclaration elementDecl = getCMElementDeclaration(node);
-
- // String attributeName = nameRegion.getText();
- String attributeName = open.getText(nameRegion);
-
- CMAttributeDeclaration attrDecl = null;
-
- // No CMElementDeclaration means no attribute metadata, but
- // retrieve the
- // declaration for the attribute otherwise
- if (elementDecl != null) {
- CMNamedNodeMap attributes = elementDecl.getAttributes();
- String noprefixName = DOMNamespaceHelper.getUnprefixedName(attributeName);
- if (attributes != null) {
- attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(noprefixName);
- if (attrDecl == null) {
- attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(attributeName);
- }
- }
- if (attrDecl == null) {
- setErrorMessage(UNKNOWN_ATTR, attributeName);
- }
- }
-
- String currentValue = node.getAttributes().getNamedItem(attributeName).getNodeValue();
- String proposedInfo = null;
- Image image = CMImageUtil.getImage(attrDecl);
- if (image == null) {
- if (attrDecl != null && attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED) {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ATT_REQ_OBJ);
- }
- else {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ATTRIBUTE);
- }
- }
-
- if (attrDecl != null && attrDecl.getAttrType() != null) {
- // attribute is known, prompt with values from the declaration
- proposedInfo = getAdditionalInfo(elementDecl, attrDecl);
- List possibleValues = getPossibleDataTypeValues(node, attrDecl);
- if (possibleValues.size() > 0) {
- // ENUMERATED VALUES
- String matchString = contentAssistRequest.getMatchString();
- if (matchString == null)
- matchString = ""; //$NON-NLS-1$
- if (matchString.length() > 0 && (matchString.startsWith("\"") || matchString.startsWith("'"))) //$NON-NLS-2$//$NON-NLS-1$
- matchString = matchString.substring(1);
- boolean currentValid = false;
-
- // d210858, if the region's a container, don't suggest the
- // enumerated values as they probably won't help
- boolean existingComplicatedValue = contentAssistRequest.getRegion() != null && contentAssistRequest.getRegion() instanceof ITextRegionContainer;
- if (!existingComplicatedValue) {
- for (Iterator j = possibleValues.iterator(); j.hasNext();) {
- String possibleValue = (String) j.next();
- 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.addProposal(proposal);
- }
- }
- }
- }
- 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) {
- CustomCompletionProposal proposal = new CustomCompletionProposal("\"" + value + "\"", //$NON-NLS-2$//$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), value.length() + 1, image, value, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
- contentAssistRequest.addProposal(proposal);
- if (currentValue.length() > 0 && !value.equals(currentValue)) {
- proposal = new CustomCompletionProposal("\"" + currentValue + "\"", //$NON-NLS-2$//$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), currentValue.length() + 1, image, currentValue, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- }
- else {
- // unknown attribute, so supply nice empty values
- proposedInfo = getAdditionalInfo(null, elementDecl);
- CustomCompletionProposal proposal = null;
- if (currentValue != null && currentValue.length() > 0) {
- proposal = new CustomCompletionProposal("\"" + currentValue + "\"", //$NON-NLS-2$//$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 1, image, "\"" + currentValue + "\"", //$NON-NLS-2$//$NON-NLS-1$
- null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- else
- setErrorMessage(UNKNOWN_CONTEXT);
- }
-
- protected void addCommentProposal(ContentAssistRequest contentAssistRequest) {
- contentAssistRequest.addProposal(new CustomCompletionProposal("<!-- -->", //$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 5, XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_COMMENT), NLS.bind(XMLUIMessages.Comment__, (new Object[]{" <!-- -->"})), //$NON-NLS-1$
- null, null, XMLRelevanceConstants.R_COMMENT));
- }
-
- /**
- * Add all of the element declarations int the CMContent object into one
- * big list.
- */
- protected void addContent(List contentList, CMContent content) {
- if (content == null)
- return;
- if (content instanceof CMGroup) {
- CMNodeList children = ((CMGroup) content).getChildNodes();
- if (children == null)
- return;
- for (int i = 0; i < children.getLength(); i++) {
- CMNode child = children.item(i);
- if (child.getNodeType() == CMNode.ELEMENT_DECLARATION) {
- contentList.add(child);
- }
- else {
- if (child.getNodeType() == CMNode.GROUP) {
- addContent(contentList, (CMContent) child);
- }
- else {
- throw new IllegalArgumentException("Unknown content child: " + child); //$NON-NLS-1$
- }
- }
- }
- }
- else {
- contentList.add(content);
- }
- }
-
- protected void addDocTypeProposal(ContentAssistRequest contentAssistRequest) {
- // if a DocumentElement exists, use that for the root Element name
- String rootname = "unspecified"; //$NON-NLS-1$
- if (contentAssistRequest.getNode().getOwnerDocument().getDocumentElement() != null)
- rootname = contentAssistRequest.getNode().getOwnerDocument().getDocumentElement().getNodeName();
-
- 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
- contentAssistRequest.addProposal(proposal);
- }
-
- /**
- * Add the proposals for a completely empty document
- */
- protected void addEmptyDocumentProposals(ContentAssistRequest contentAssistRequest) {
- addXMLProposal(contentAssistRequest);
- }
-
- /**
- * Add the proposals for the name in an end tag
- */
- protected void addEndTagNameProposals(ContentAssistRequest contentAssistRequest) {
-
- if (contentAssistRequest.getStartOffset() + contentAssistRequest.getRegion().getTextLength() < contentAssistRequest.getReplacementBeginPosition()) {
- CustomCompletionProposal proposal = new CustomCompletionProposal(">", //$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 1, XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC), NLS.bind(XMLUIMessages.Close_with__, (new Object[]{" '>'"})), //$NON-NLS-1$
- null, null, XMLRelevanceConstants.R_END_TAG_NAME);
- contentAssistRequest.addProposal(proposal);
- }
- else {
- IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(node.getOwnerDocument());
- Node aNode = contentAssistRequest.getNode();
- String matchString = contentAssistRequest.getMatchString();
- if (matchString.startsWith("</")) //$NON-NLS-1$
- matchString = matchString.substring(2);
- while (aNode != null) {
- if (aNode.getNodeType() == Node.ELEMENT_NODE) {
- if (aNode.getNodeName().startsWith(matchString)) {
- IDOMNode aXMLNode = (IDOMNode) aNode;
- CMElementDeclaration ed = modelQuery.getCMElementDeclaration((Element) aNode);
- if ((aXMLNode.getEndStructuredDocumentRegion() == null) && (ed == null || (ed.getContentType() != CMElementDeclaration.EMPTY))) {
- String proposedText = aNode.getNodeName();
- String proposedInfo = (ed != null) ? getAdditionalInfo(null, ed) : null;
- if (node.getNodeType() == Node.TEXT_NODE && !contentAssistRequest.getDocumentRegion().isEnded())
- proposedText += ">"; //$NON-NLS-1$
- CustomCompletionProposal proposal = null;
- // 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 (contentAssistRequest.getRegion().getType() == DOMRegionContext.XML_TAG_NAME) {
- proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getStartOffset(), contentAssistRequest.getRegion().getTextLength(), proposedText.length(), image, proposedText, null, proposedInfo, XMLRelevanceConstants.R_END_TAG_NAME);
- }
- else {
- proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), proposedText.length(), image, NLS.bind(XMLUIMessages.Close_with__, (new Object[]{"'" + proposedText + "'"})), //$NON-NLS-1$ //$NON-NLS-2$
- null, proposedInfo, XMLRelevanceConstants.R_END_TAG_NAME);
- }
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- aNode = aNode.getParentNode();
- }
- }
- }
-
- /**
- * Prompt for end tags to a non-empty Node that hasn't ended Handles these
- * cases: <br>
- * <tagOpen>| <br>
- * <tagOpen>< |<br>
- * <tagOpen></ |
- *
- * @param contentAssistRequest
- */
- protected void addEndTagProposals(ContentAssistRequest contentAssistRequest) {
- IDOMNode node = (IDOMNode) contentAssistRequest.getParent();
-
- // CMVC 241090 for special meta-info comment tags
- if (isCommentNode(node)) {
- // loop and find non comment node parent
- while (node != null && isCommentNode(node)) {
- node = (IDOMNode) node.getParentNode();
- }
- }
-
- // data to create a CustomCompletionProposal
- String replaceText = node.getNodeName() + ">"; //$NON-NLS-1$
- int replaceBegin = contentAssistRequest.getReplacementBeginPosition();
- int replaceLength = contentAssistRequest.getReplacementLength();
- int cursorOffset = node.getNodeName().length() + 1;
- String displayString = ""; //$NON-NLS-1$
- String proposedInfo = ""; //$NON-NLS-1$
- Image image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
-
- setErrorMessage(null);
- boolean addProposal = false;
-
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- // fix for CMVC 261790
- // ////////////////////////////////////////////////////////////////////////////////////
- IStructuredDocument sDoc = (IStructuredDocument) fTextViewer.getDocument();
- IStructuredDocumentRegion xmlEndTagOpen = sDoc.getRegionAtCharacterOffset(contentAssistRequest.getReplacementBeginPosition());
- // skip backward to "<", "</", or the (unclosed) start tag, null
- // if not found
- String type = ""; //$NON-NLS-1$
- while (xmlEndTagOpen != null && (type = xmlEndTagOpen.getType()) != DOMRegionContext.XML_END_TAG_OPEN && type != DOMRegionContext.XML_TAG_CLOSE && !needsEndTag(xmlEndTagOpen) && type != DOMRegionContext.XML_TAG_OPEN) {
- xmlEndTagOpen = xmlEndTagOpen.getPrevious();
- }
-
- if (xmlEndTagOpen == null)
- return;
-
- node = (IDOMNode) node.getModel().getIndexedRegion(xmlEndTagOpen.getStartOffset());
- node = (IDOMNode) node.getParentNode();
-
- if (isStartTag(xmlEndTagOpen)) {
- // this is the case for a start tag w/out end tag
- // eg:
- // <p>
- // <% 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() + ">";
- // //$NON-NLS-1$ $NON-NLS-2$
- cursorOffset = tagName.length() + 3;
- displayString = NLS.bind(XMLUIMessages.End_with__, (new Object[]{tagName}));
- addProposal = true;
- }
- }
- else if (type == DOMRegionContext.XML_END_TAG_OPEN) {
- // this is the case for: <tag> </ |
- // possibly <tag> </ |<anotherTag>
- // should only be replacing white space...
- replaceLength = (replaceBegin > xmlEndTagOpen.getTextEndOffset()) ? replaceBegin - xmlEndTagOpen.getTextEndOffset() : 0;
- replaceText = node.getNodeName() + ">"; //$NON-NLS-1$
- cursorOffset = replaceText.length();
- replaceBegin = xmlEndTagOpen.getTextEndOffset();
- displayString = NLS.bind(XMLUIMessages.End_with_, (new Object[]{node.getNodeName()}));
- addProposal = true;
- }
- else if (type == DOMRegionContext.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$
- // $NON-NLS-2$
- // should only be replacing white space...
- replaceLength = (replaceBegin > xmlEndTagOpen.getTextEndOffset()) ? replaceBegin - xmlEndTagOpen.getTextEndOffset() : 0;
- replaceBegin = xmlEndTagOpen.getTextEndOffset();
- displayString = NLS.bind(XMLUIMessages.End_with_, (new Object[]{"/" + node.getNodeName()})); //$NON-NLS-1$
- addProposal = true;
- }
- }
- // fix for CMVC 261790
- // ////////////////////////////////////////////////////////////////////////////////////
- // fix for CMVC 263163, sometimes the node is not null, but
- // getNodeValue() is null, put in a null check
- else if (node.getNodeValue() != null && node.getNodeValue().indexOf("</") != -1) { //$NON-NLS-1$
- // the case where "</" is started, but the nodes comes in as a
- // text node (instead of element)
- // like this: <tag> </|
- Node parent = node.getParentNode();
- if (parent != null && parent.getNodeType() != Node.DOCUMENT_NODE) {
- replaceText = parent.getNodeName() + ">"; //$NON-NLS-1$
- cursorOffset = replaceText.length();
- displayString = NLS.bind(XMLUIMessages.End_with__, (new Object[]{parent.getNodeName()}));
- setErrorMessage(null);
- addProposal = true;
- }
- }
- // end fix for CMVC 261790
- // ////////////////////////////////////////////////////////////////////////////////////
- else if (node.getNodeType() == Node.DOCUMENT_NODE) {
- setErrorMessage(UNKNOWN_CONTEXT);
- }
- if (addProposal == true) {
- CustomCompletionProposal proposal = new CustomCompletionProposal(replaceText, replaceBegin, replaceLength, cursorOffset, image, displayString, null, proposedInfo, XMLRelevanceConstants.R_END_TAG);
- contentAssistRequest.addProposal(proposal);
- }
- }
-
- protected void addEntityProposals(ContentAssistRequest contentAssistRequest, int documentPosition, ITextRegion completionRegion, IDOMNode treeNode) {
- ICompletionProposal[] eps = computeEntityReferenceProposals(documentPosition, completionRegion, treeNode);
- for (int i = 0; eps != null && i < eps.length; i++)
- contentAssistRequest.addProposal(eps[i]);
- }
-
- protected void addEntityProposals(Vector proposals, Properties map, String key, int nodeOffset, IStructuredDocumentRegion sdRegion, ITextRegion completionRegion) {
- if (map == null)
- return;
- String entityName = ""; //$NON-NLS-1$
- String entityValue = ""; //$NON-NLS-1$
- Image entityIcon = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ENTITY_REFERENCE);
- String replacementText = ""; //$NON-NLS-1$
- String displayString = ""; //$NON-NLS-1$
- Enumeration keys = map.keys();
-
- while (keys != null && keys.hasMoreElements()) {
- entityName = (String) keys.nextElement();
- entityValue = map.getProperty(entityName);
- // filter based on partial entity string...
- if (entityName.toLowerCase().startsWith(key.toLowerCase()) || key.trim().equals("")) //$NON-NLS-1$
- {
- // figure out selection...if text is selected, add it to
- // selection length
- int selectionLength = nodeOffset;
- if (fTextViewer != null) {
- selectionLength += fTextViewer.getSelectedRange().y;
- }
- // create a new proposal for entity string...
- replacementText = "&" + entityName + ";"; //$NON-NLS-1$ //$NON-NLS-2$
- displayString = "&" + entityName + "; (" + entityValue + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ICompletionProposal cp = new CustomCompletionProposal(replacementText, sdRegion.getStartOffset(completionRegion), selectionLength, replacementText.length(), entityIcon, displayString, null, null, XMLRelevanceConstants.R_ENTITY);
- if (cp != null) {
- proposals.add(cp);
- }
- }
- }
- }
-
- protected void addPCDATAProposal(String nodeName, ContentAssistRequest contentAssistRequest) {
- CustomCompletionProposal proposal = new CustomCompletionProposal("<![CDATA[]]>", //$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 9, XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_CDATASECTION), "CDATA Section", //$NON-NLS-1$
- null, null, XMLRelevanceConstants.R_CDATA);
- contentAssistRequest.addProposal(proposal);
-
- proposal = new CustomCompletionProposal(nodeName, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), nodeName.length(), XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TXTEXT), "#PCDATA", //$NON-NLS-1$
- null, null, XMLRelevanceConstants.R_CDATA);
- contentAssistRequest.addProposal(proposal);
- }
-
- protected void addStartDocumentProposals(ContentAssistRequest contentAssistRequest) {
- Node aNode = contentAssistRequest.getNode();
- boolean xmlpiFound = false;
- Document owningDocument = aNode.getOwnerDocument();
- // ==> // int xmlpiNodePosition = -1;
-
- // make sure xmlpi is root element
- // don't want doctype proposal if XMLPI isn't first element...
- // CMVC 242943
- // CMVC 245532
- Node first = owningDocument.getFirstChild();
- boolean xmlpiIsFirstElement = (first != null && first.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE);
- boolean insertDoctype = xmlpiIsFirstElement;
-
- for (Node child = owningDocument.getFirstChild(); child != null; child = child.getNextSibling()) {
- boolean xmlpi = (child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE && child.getNodeName().equals("xml")); //$NON-NLS-1$
- xmlpiFound = xmlpiFound || xmlpi;
- if (xmlpiFound) {
- if (child instanceof IDOMNode) {
- // ==> // int xmlpiNodePosition =
- // ((XMLNode)child).getEndOffset();
- }
- // skip white space and text
- while ((child = child.getNextSibling()) != null && (child.getNodeType() == Node.TEXT_NODE)) {
- }
- // check if theres a node inbetween XMLPI and cursor position
- if (child != null && child instanceof IDOMNode) {
- // CMVC 257486
- if (contentAssistRequest.getReplacementBeginPosition() >= ((IDOMNode) child).getEndOffset() || !xmlpiIsFirstElement) {
- insertDoctype = false;
- }
- }
- break;
- }
- }
-
- if (!xmlpiFound) {
- addXMLProposal(contentAssistRequest);
- }
- else if (owningDocument.getDoctype() == null && isCursorAfterXMLPI(contentAssistRequest) && insertDoctype) {
- addDocTypeProposal(contentAssistRequest);
- }
- }
-
- /**
- * Close an unclosed start tag
- */
- protected void addTagCloseProposals(ContentAssistRequest contentAssistRequest) {
- IDOMNode node = (IDOMNode) contentAssistRequest.getParent();
- if (node.getNodeType() == Node.ELEMENT_NODE) {
-
- CMElementDeclaration elementDecl = getCMElementDeclaration(node);
- String proposedInfo = (elementDecl != null) ? getAdditionalInfo(null, elementDecl) : null;
- int contentType = (elementDecl != null) ? elementDecl.getContentType() : CMElementDeclaration.ANY;
- // if it's XML and content doesn't HAVE to be element, add "/>"
- // proposal.
- boolean endWithSlashBracket = (getXML(node) && contentType != CMElementDeclaration.ELEMENT);
-
- Image image = CMImageUtil.getImage(elementDecl);
- if (image == null) {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
-
- // is the start tag ended properly?
- if (contentAssistRequest.getDocumentRegion() == node.getFirstStructuredDocumentRegion() && !(node.getFirstStructuredDocumentRegion()).isEnded()) {
- setErrorMessage(null);
- // Is this supposed to be an empty tag? Note that if we can't
- // tell, we assume it's not.
- if (elementDecl != null && elementDecl.getContentType() == CMElementDeclaration.EMPTY) {
- // prompt with a self-closing end character if needed
- CustomCompletionProposal proposal = new CustomCompletionProposal(getContentGenerator().getStartTagClose(node, elementDecl), contentAssistRequest.getReplacementBeginPosition(),
- // this is one of the few times to ignore the length --
- // always insert
- // contentAssistRequest.getReplacementLength(),
- 0, getContentGenerator().getStartTagClose(node, elementDecl).length(), image, NLS.bind(XMLUIMessages.Close_with___, (new Object[]{getContentGenerator().getStartTagClose(node, elementDecl)})),
- null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
- contentAssistRequest.addProposal(proposal);
- }
- else {
- // prompt with a close for the start tag
- CustomCompletionProposal proposal = new CustomCompletionProposal(">", //$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(),
- // this is one of the few times to ignore the
- // length -- always insert
- // contentAssistRequest.getReplacementLength(),
- 0, 1, image, NLS.bind(XMLUIMessages.Close_with__, (new Object[]{" '>'"})), //$NON-NLS-1$
- null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
- contentAssistRequest.addProposal(proposal);
-
- // prompt with the closer for the start tag and an end tag
- // if one is not present
- if (node.getEndStructuredDocumentRegion() == null) {
- // FIX FOR CMVC 247482
- // make sure tag name is actually what it thinks it
- // is...(eg. <%@ vs. <jsp:directive)
- IStructuredDocumentRegion sdr = contentAssistRequest.getDocumentRegion();
- String openingTagText = (sdr != null) ? sdr.getFullText() : ""; //$NON-NLS-1$
- if (openingTagText != null && openingTagText.indexOf(node.getNodeName()) != -1) {
- proposal = new CustomCompletionProposal("></" + node.getNodeName() + ">", //$NON-NLS-2$//$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(),
- // this is one of the few times to
- // ignore the length -- always insert
- // contentAssistRequest.getReplacementLength(),
- 0, 1, image, NLS.bind(XMLUIMessages.Close_with____, (new Object[]{node.getNodeName()})),
- null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
- contentAssistRequest.addProposal(proposal);
- }
- }
- // prompt with slash bracket "/>" incase if it's a self
- // ending tag
- if (endWithSlashBracket) {
- proposal = new CustomCompletionProposal("/>", //$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(),
- // this is one of the few times to ignore
- // the length -- always insert
- // contentAssistRequest.getReplacementLength(),
- 0, 2, image, NLS.bind(XMLUIMessages.Close_with__, (new Object[]{" \"/>\""})), //$NON-NLS-1$
- null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG + 1); // +1
- // to
- // bring
- // to
- // top
- // of
- // list
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- 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$
- contentAssistRequest.getReplacementBeginPosition(),
- // this is one of the few times to ignore the
- // length -- always insert
- // contentAssistRequest.getReplacementLength(),
- 0, 1, image, NLS.bind(XMLUIMessages.Close_with__, (new Object[]{" '>'"})), //$NON-NLS-1$
- null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
- contentAssistRequest.addProposal(proposal);
- }
- }
- else if (node.getNodeType() == Node.DOCUMENT_NODE) {
- setErrorMessage(UNKNOWN_CONTEXT);
- }
- }
-
- protected void addTagInsertionProposals(ContentAssistRequest contentAssistRequest, int childPosition) {
- List cmnodes = null;
- Node parent = contentAssistRequest.getParent();
- List validActions = null;
- String error = null;
-
- // CMVC #242943 shouldn't have proposals before XMLPI
- // (nsd) This is only valid at the document element level
- // only valid if it's XML (check added 2/17/2004)
- if (parent != null && parent.getNodeType() == Node.DOCUMENT_NODE && ((IDOMDocument) parent).isXMLType() && !isCursorAfterXMLPI(contentAssistRequest)) {
- return;
- }
- // only want proposals if cursor is after doctype...
- if (!isCursorAfterDoctype(contentAssistRequest))
- return;
-
- // CMVC 248081
- // fix for meta-info comment nodes.. they currently "hide" other
- // proposals because the don't
- // have a content model (so can't propose any children..)
- if (parent != null && parent instanceof IDOMNode && isCommentNode((IDOMNode) parent)) {
- // loop and find non comment node?
- while (parent != null && isCommentNode((IDOMNode) parent)) {
- parent = (IDOMNode) parent.getParentNode();
- }
- }
-
- if (parent.getNodeType() == Node.ELEMENT_NODE) {
- CMElementDeclaration parentDecl = getCMElementDeclaration(parent);
- if (parentDecl != null) {
- // XSD-specific ability - no filtering
- CMDataType childType = parentDecl.getDataType();
- if (childType != null) {
- String[] childStrings = childType.getEnumeratedValues();
- if (childStrings != null) {
- // the content string is the sole valid child...so
- // replace the rest
- int begin = contentAssistRequest.getReplacementBeginPosition();
- int length = contentAssistRequest.getReplacementLength();
- if (parent instanceof IDOMNode) {
- if (((IDOMNode) parent).getLastStructuredDocumentRegion() != ((IDOMNode) parent).getFirstStructuredDocumentRegion()) {
- begin = ((IDOMNode) parent).getFirstStructuredDocumentRegion().getEndOffset();
- length = ((IDOMNode) parent).getLastStructuredDocumentRegion().getStartOffset() - begin;
- }
- }
- String proposedInfo = getAdditionalInfo(parentDecl, childType);
- for (int i = 0; i < childStrings.length; i++) {
- CustomCompletionProposal textProposal = new CustomCompletionProposal(childStrings[i], begin, length, childStrings[i].length(), XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ENUM), childStrings[i], null, proposedInfo, XMLRelevanceConstants.R_TAG_INSERTION);
- contentAssistRequest.addProposal(textProposal);
- }
- }
- }
- }
- if (parentDecl != null && parentDecl.getContentType() == CMElementDeclaration.PCDATA) {
- addPCDATAProposal(parentDecl.getNodeName(), contentAssistRequest);
- }
- else {
- // retrieve the list of children
- validActions = getAvailableChildrenAtIndex((Element) parent, childPosition);
- cmnodes = getValidCMNodes(childPosition, ModelQueryAction.INSERT, validActions);
- Iterator nodeIterator = cmnodes.iterator();
- if (!nodeIterator.hasNext()) {
- if (getCMElementDeclaration(parent) != null)
- error = NLS.bind(XMLUIMessages._Has_no_available_child, (new Object[]{parent.getNodeName()}));
- else
- error = NLS.bind(XMLUIMessages.Element__is_unknown, (new Object[]{parent.getNodeName()}));
- }
- String matchString = contentAssistRequest.getMatchString();
- // chop off any leading <'s and whitespace from the
- // matchstring
- while ((matchString.length() > 0) && (Character.isWhitespace(matchString.charAt(0)) || beginsWith(matchString, "<"))) //$NON-NLS-1$
- //$NON-NLS-1$
- matchString = matchString.substring(1);
- while (nodeIterator.hasNext()) {
- Object o = nodeIterator.next();
- if (o instanceof CMElementDeclaration) {
- CMElementDeclaration elementDecl = (CMElementDeclaration) o;
- // only add proposals for the child element's that
- // begin with the matchstring
- String tagname = getRequiredName(parent, elementDecl);
- Image image = CMImageUtil.getImage(elementDecl);
- if (image == null) {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
- // Account for the &lt; and &gt;. If attributes were
- // added, the cursor will be placed
- // at the offset before of the first character of the
- // first attribute name.
- int markupAdjustment = getContentGenerator().getMinimalStartTagLength(parent, elementDecl);
- if (beginsWith(tagname, matchString)) {
- String proposedText = getRequiredText(parent, elementDecl);
- String proposedInfo = getAdditionalInfo(parentDecl, elementDecl);
- CustomCompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), markupAdjustment, image, tagname, null, proposedInfo, XMLRelevanceConstants.R_TAG_INSERTION);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- if (contentAssistRequest.getProposals().size() == 0) {
- if (error != null)
- setErrorMessage(error);
- else if (contentAssistRequest.getMatchString() != null && contentAssistRequest.getMatchString().length() > 0)
- setErrorMessage(NLS.bind(XMLUIMessages.No_known_child_tag, (new Object[]{parent.getNodeName(), contentAssistRequest.getMatchString()})));
- //$NON-NLS-1$ = "No known child tag names of <{0}> begin with \"{1}\"."
- else
- setErrorMessage(NLS.bind(XMLUIMessages.__Has_no_known_child, (new Object[]{parent.getNodeName()})));
- }
- }
- }
- 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
- boolean xmlpiFound = false;
- boolean doctypeFound = false;
- int minimumOffset = -1;
-
- for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
-
- boolean xmlpi = (child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE && child.getNodeName().equals("xml")); //$NON-NLS-1$
- boolean doctype = child.getNodeType() == Node.DOCUMENT_TYPE_NODE;
- if (xmlpi || doctype && minimumOffset < 0)
- minimumOffset = ((IDOMNode) child).getFirstStructuredDocumentRegion().getStartOffset() + ((IDOMNode) child).getFirstStructuredDocumentRegion().getTextLength();
- xmlpiFound = xmlpiFound || xmlpi;
- doctypeFound = doctypeFound || doctype;
- }
- if (!xmlpiFound && contentAssistRequest.getReplacementBeginPosition() < minimumOffset) {
- addXMLProposal(contentAssistRequest);
- }
-
- if (contentAssistRequest.getReplacementBeginPosition() >= minimumOffset) {
- List childDecls = getAvailableRootChildren((Document) parent, childPosition);
- for (int i = 0; i < childDecls.size(); i++) {
- CMElementDeclaration ed = (CMElementDeclaration) childDecls.get(i);
- if (ed != null) {
- Image image = CMImageUtil.getImage(ed);
- if (image == null) {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
- String proposedText = getRequiredText(parent, ed);
- String tagname = getRequiredName(parent, ed);
- // account for the &lt; and &gt;
- int markupAdjustment = getContentGenerator().getMinimalStartTagLength(parent, ed);
- String proposedInfo = getAdditionalInfo(null, ed);
- CustomCompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), markupAdjustment, image, tagname, null, proposedInfo, XMLRelevanceConstants.R_TAG_INSERTION);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- }
- }
-
- protected void addTagNameProposals(ContentAssistRequest contentAssistRequest, int childPosition) {
- List cmnodes = null;
- Node parent = contentAssistRequest.getParent();
- IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
- List validActions = null;
- String error = null;
- String matchString = contentAssistRequest.getMatchString();
- if (parent.getNodeType() == Node.ELEMENT_NODE) {
- // retrieve the list of children
- validActions = getAvailableChildrenAtIndex((Element) parent, childPosition);
- cmnodes = getValidCMNodes(childPosition, ModelQueryAction.INSERT, validActions);
- Iterator nodeIterator = cmnodes.iterator();
- // chop off any leading <'s and whitespace from the matchstring
- while ((matchString.length() > 0) && (Character.isWhitespace(matchString.charAt(0)) || beginsWith(matchString, "<"))) //$NON-NLS-1$
- //$NON-NLS-1$
- matchString = matchString.substring(1);
- if (!nodeIterator.hasNext())
- error = NLS.bind(XMLUIMessages.__Has_no_known_child, (new Object[]{parent.getNodeName()}));
- while (nodeIterator.hasNext()) {
- CMNode elementDecl = (CMNode) nodeIterator.next();
- if (elementDecl != null) {
- // only add proposals for the child element's that begin
- // with the matchstring
- String proposedText = null;
- int cursorAdjustment = 0;
-
- // do a check to see if partial attributes of partial tag
- // names are in list
- if ((node != null && node.getAttributes() != null && node.getAttributes().getLength() > 0 && attributeInList(node, parent, elementDecl)) || ((node.getNodeType() != Node.TEXT_NODE) && node.getFirstStructuredDocumentRegion().isEnded())) {
-
- proposedText = getRequiredName(parent, elementDecl);
- cursorAdjustment = proposedText.length();
- }
- else {
- proposedText = getRequiredName(parent, elementDecl);
- cursorAdjustment = proposedText.length();
- if (elementDecl instanceof CMElementDeclaration) {
- CMElementDeclaration ed = (CMElementDeclaration) elementDecl;
- if (ed.getContentType() == CMElementDeclaration.EMPTY) {
- proposedText += getContentGenerator().getStartTagClose(parent, ed);
- cursorAdjustment = proposedText.length();
- }
- else {
- cursorAdjustment = proposedText.length() + 1;
- proposedText += "></" + getRequiredName(parent, elementDecl) + ">"; //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- if (beginsWith(proposedText, matchString)) {
- Image image = CMImageUtil.getImage(elementDecl);
- if (image == null) {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
- String proposedInfo = getAdditionalInfo(getCMElementDeclaration(parent), elementDecl);
- CustomCompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), cursorAdjustment, image, getRequiredName(parent, elementDecl), null, proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- if (contentAssistRequest.getProposals().size() == 0) {
- if (error != null)
- setErrorMessage(error);
- else if (contentAssistRequest.getMatchString() != null && contentAssistRequest.getMatchString().length() > 0)
- setErrorMessage(NLS.bind(XMLUIMessages.No_known_child_tag_names, (new Object[]{parent.getNodeName(), contentAssistRequest.getMatchString()})));
- //$NON-NLS-1$ = "No known child tag names of <{0}> begin with \"{1}\""
- else
- setErrorMessage(NLS.bind(XMLUIMessages.__Has_no_known_child, (new Object[]{parent.getNodeName()})));
- }
- }
- 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);
- if (ed == null)
- continue;
- String proposedText = null;
- int cursorAdjustment = 0;
- proposedText = getRequiredName(parent, ed);
- if (!beginsWith(proposedText, matchString))
- continue;
- if ((node != null && node.getAttributes() != null && node.getAttributes().getLength() > 0) || ((node.getNodeType() != Node.TEXT_NODE) && node.getFirstStructuredDocumentRegion().isEnded())) {
- cursorAdjustment = proposedText.length();
- }
- 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 {
- cursorAdjustment = proposedText.length() + 1;
- proposedText += "></" + getRequiredName(parent, elementDecl) + ">"; //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- String proposedInfo = getAdditionalInfo(null, ed);
- Image image = CMImageUtil.getImage(ed);
- 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);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
-
- 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
- contentAssistRequest.addProposal(proposal);
- }
-
- /**
- * This method determines if any of the attributes in the proposed XMLNode
- * node, are possible values of attributes from possible Elements at this
- * point in the document according to the Content Model.
- *
- * @param node
- * the element with attributes that you would like to test if
- * 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.
- */
- protected boolean attributeInList(IDOMNode 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();
- if (node instanceof Element) {
- NamedNodeMap map = ((Element) node).getAttributes();
- String attrMatchString = ""; //$NON-NLS-1$
- CMNamedNodeMap cmattrMap = null;
- // iterate attribute possibilities for partially started node
- for (int i = 0; map != null && i < map.getLength(); i++) {
- attrMatchString = map.item(i).getNodeName();
- // filter on whatever user typed for element name already
- if (beginsWith(cmnodeName, elementMatchString)) {
- if (cmnode.getNodeType() == CMNode.ELEMENT_DECLARATION) {
- cmattrMap = ((CMElementDeclaration) cmnode).getAttributes();
- // iterate possible attributes from a cmnode in
- // proposal list
- for (int k = 0; cmattrMap != null && k < cmattrMap.getLength(); k++) {
- // check if name matches
- if (cmattrMap.item(k).getNodeName().equals(attrMatchString)) {
- return true;
- }
- }
- }
- }
- }
- }
- return false;
- }
-
- protected boolean beginsWith(String aString, String prefix) {
- if (aString == null || prefix == null)
- return true;
- // (pa) 221190 matching independent of case to be consistant with Java
- // editor CA
- return aString.toLowerCase().startsWith(prefix.toLowerCase());
- }
-
- protected ContentAssistRequest computeAttributeProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- if (documentPosition < sdRegion.getStartOffset(completionRegion)) {
- // setup to insert new attributes
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition, 0, matchString);
- }
- else {
- // Setup to replace an existing attribute name
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
- }
- addAttributeNameProposals(contentAssistRequest);
- contentAssistRequest.setReplacementBeginPosition(documentPosition);
- contentAssistRequest.setReplacementLength(0);
- if (node.getFirstStructuredDocumentRegion() != null && (!node.getFirstStructuredDocumentRegion().isEnded())) {
- addTagCloseProposals(contentAssistRequest);
- }
- return contentAssistRequest;
- }
-
- protected ContentAssistRequest computeAttributeValueProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- if (documentPosition > sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength() && sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength() != sdRegion.getStartOffset(completionRegion) + completionRegion.getLength()) {
- // setup to add a new attribute at the documentPosition
- IDOMNode actualNode = (IDOMNode) node.getModel().getIndexedRegion(sdRegion.getStartOffset(completionRegion));
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode, sdRegion, completionRegion, documentPosition, 0, matchString);
- addAttributeNameProposals(contentAssistRequest);
- if (actualNode.getFirstStructuredDocumentRegion() != null && !actualNode.getFirstStructuredDocumentRegion().isEnded()) {
- addTagCloseProposals(contentAssistRequest);
- }
- }
- 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 {
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
- addAttributeValueProposals(contentAssistRequest);
- }
- }
- return contentAssistRequest;
- }
-
- protected ContentAssistRequest computeCompletionProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode treeNode, IDOMNode xmlnode) {
- ContentAssistRequest contentAssistRequest = null;
- String regionType = completionRegion.getType();
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
-
- // Handle the most common and best supported cases
- if (xmlnode.getNodeType() == Node.ELEMENT_NODE || xmlnode.getNodeType() == Node.DOCUMENT_NODE) {
- if (regionType == DOMRegionContext.XML_TAG_OPEN) {
- contentAssistRequest = computeTagOpenProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- }
- else if (regionType == DOMRegionContext.XML_TAG_NAME) {
- contentAssistRequest = computeTagNameProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- contentAssistRequest = computeAttributeProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) {
- contentAssistRequest = computeEqualsProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- }
- else if (regionType == DOMRegionContext.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..
- IDOMNode actualNode = (IDOMNode) xmlnode.getModel().getIndexedRegion(sdRegion.getStartOffset(completionRegion));
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode, sdRegion, completionRegion, documentPosition, 0, matchString);
- addTagCloseProposals(contentAssistRequest);
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
- contentAssistRequest = computeAttributeValueProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- }
- else if ((regionType == DOMRegionContext.XML_TAG_CLOSE) || (regionType == DOMRegionContext.XML_EMPTY_TAG_CLOSE) || (regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_CLOSE))) {
- contentAssistRequest = computeTagCloseProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- }
- else if (regionType == DOMRegionContext.XML_END_TAG_OPEN) {
- contentAssistRequest = computeEndTagOpenProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- }
- else if (regionType == DOMRegionContext.XML_CONTENT || regionType == DOMRegionContext.XML_CHAR_REFERENCE || regionType == DOMRegionContext.XML_ENTITY_REFERENCE || regionType == DOMRegionContext.XML_PE_REFERENCE) {
- contentAssistRequest = computeContentProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- }
-
- // These ITextRegion types begin DOM Elements as well and although
- // internally harder to assist,
- // text insertions directly before them can be made
- 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 == DOMRegionContext.XML_DECLARATION_OPEN || regionType == DOMRegionContext.XML_PI_OPEN || regionType == DOMRegionContext.XML_COMMENT_OPEN || regionType == DOMRegionContext.XML_CDATA_OPEN)) {
- contentAssistRequest = newContentAssistRequest(treeNode, xmlnode.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- addTagInsertionProposals(contentAssistRequest, getElementPositionForModelQuery(treeNode));
- addStartDocumentProposals(contentAssistRequest);
- }
- }
- // Not a Document or Element? (odd cases go here for now)
- else if (isCloseRegion(completionRegion)) {
- contentAssistRequest = newContentAssistRequest(treeNode, xmlnode.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion) + completionRegion.getLength(), 0, matchString);
- 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 == DOMRegionContext.XML_DECLARATION_OPEN || regionType == DOMRegionContext.XML_PI_OPEN || regionType == DOMRegionContext.XML_COMMENT_OPEN || regionType == DOMRegionContext.XML_CDATA_OPEN)) {
- contentAssistRequest = newContentAssistRequest(treeNode, xmlnode.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- addTagInsertionProposals(contentAssistRequest, getElementPositionForModelQuery(treeNode));
- addStartDocumentProposals(contentAssistRequest);
- }
- return contentAssistRequest;
- }
-
- /**
- * CONTENT ASSIST STARTS HERE
- *
- * Return a list of proposed code completions based on the specified
- * location within the document that corresponds to the current cursor
- * position within the text-editor control.
- *
- * @param textViewer
- * @param documentPosition -
- * the cursor location within the document
- *
- * an array of ICompletionProposals
- */
- public ICompletionProposal[] computeCompletionProposals(ITextViewer textViewer, int documentPosition) {
-
- setErrorMessage(null);
-
- fTextViewer = textViewer;
-
- IndexedRegion treeNode = ContentAssistUtils.getNodeAt((StructuredTextViewer) textViewer, documentPosition);
-
- Node node = (Node) treeNode;
- while (node != null && node.getNodeType() == Node.TEXT_NODE && node.getParentNode() != null)
- node = node.getParentNode();
- IDOMNode xmlnode = (IDOMNode) node;
-
- ContentAssistRequest contentAssistRequest = null;
-
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- ITextRegion completionRegion = getCompletionRegion(documentPosition, node);
-
- String matchString = getMatchString(sdRegion, completionRegion, documentPosition);
-
- // Handle empty Documents
- if (completionRegion == null) {
- if (((treeNode == null) || ((Node) treeNode).getNodeType() == Node.DOCUMENT_NODE) && completionRegion == null && (xmlnode == null || xmlnode.getChildNodes() == null || xmlnode.getChildNodes().getLength() == 0)) {
- IStructuredModel sModel = StructuredModelManager.getModelManager().getExistingModelForRead(textViewer.getDocument());
- try {
- if (sModel != null) {
- IDOMDocument docNode = ((IDOMModel) sModel).getDocument();
- contentAssistRequest = newContentAssistRequest(docNode, docNode, sdRegion, completionRegion, documentPosition, 0, null);
- addEmptyDocumentProposals(contentAssistRequest);
- }
- }
- finally {
- if (sModel != null)
- sModel.releaseFromRead();
- }
- return contentAssistRequest.getCompletionProposals();
- }
- // MASSIVE ERROR CONDITION
- Logger.logException(new IllegalStateException("completion region was null")); //$NON-NLS-1$
- setErrorMessage(INTERNALERROR);
- contentAssistRequest = newContentAssistRequest((Node) treeNode, node.getParentNode(), sdRegion, completionRegion, documentPosition, 0, ""); //$NON-NLS-1$
- return contentAssistRequest.getCompletionProposals();
- }
-
-
- // catch documents where no region can be determined
- if (xmlnode.getNodeType() == Node.DOCUMENT_NODE && (completionRegion == null || xmlnode.getChildNodes() == null || xmlnode.getChildNodes().getLength() == 0)) {
- contentAssistRequest = computeStartDocumentProposals(documentPosition, matchString, completionRegion, (IDOMNode) treeNode, xmlnode);
- return contentAssistRequest.getCompletionProposals();
- }
-
- // compute normal proposals
- contentAssistRequest = computeCompletionProposals(documentPosition, matchString, completionRegion, (IDOMNode) treeNode, xmlnode);
- if (contentAssistRequest == null) {
- contentAssistRequest = newContentAssistRequest((Node) treeNode, node.getParentNode(), sdRegion, completionRegion, documentPosition, 0, ""); //$NON-NLS-1$
- if (Debug.displayWarnings)
- System.out.println(UNKNOWN_CONTEXT + " " + completionRegion.getType() + "@" + documentPosition); //$NON-NLS-2$//$NON-NLS-1$
- setErrorMessage(UNKNOWN_CONTEXT);
- }
-
- if (contentAssistRequest.getProposals().size() == 0)
- setErrorMessage(UNKNOWN_CONTEXT);
-
- return contentAssistRequest.getCompletionProposals();
- }
-
- protected ContentAssistRequest computeContentProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
- ContentAssistRequest contentAssistRequest = null;
-
- // setup to add children at the content node's position
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, getStructuredDocumentRegion(documentPosition), completionRegion, documentPosition, 0, matchString);
- if (node != null && node.getNodeType() == Node.DOCUMENT_NODE && ((Document) node).getDoctype() == null)
- addStartDocumentProposals(contentAssistRequest);
- addTagInsertionProposals(contentAssistRequest, getElementPositionForModelQuery(nodeAtOffset));
- if (node.getNodeType() != Node.DOCUMENT_NODE) {
- addEndTagProposals(contentAssistRequest);
- }
- // entities?
- addEntityProposals(contentAssistRequest, documentPosition, completionRegion, node);
- // addEntityProposals(contentAssistRequest);
- return contentAssistRequest;
- }
-
- /**
- * Returns information about possible contexts based on the specified
- * location within the document that corresponds to the current cursor
- * position within the text viewer.
- *
- * @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
- */
- public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
- if (fAttributeInfoProvider == null)
- fAttributeInfoProvider = new AttributeContextInformationProvider((IStructuredDocument) viewer.getDocument(), (AttributeContextInformationPresenter) getContextInformationValidator());
- return fAttributeInfoProvider.getAttributeInformation(documentOffset);
- }
-
- protected ContentAssistRequest computeEndTagOpenProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- int completionRegionStart = sdRegion.getStartOffset(completionRegion);
- int completionRegionLength = completionRegion.getLength();
- IStructuredDocumentRegion sdRegionAtCompletionOffset = node.getStructuredDocument().getRegionAtCharacterOffset(completionRegionStart + completionRegionLength);
- ITextRegion regionAtEndOfCompletion = sdRegionAtCompletionOffset.getRegionAtCharacterOffset(completionRegionStart + completionRegionLength);
-
- if (documentPosition != completionRegionStart && regionAtEndOfCompletion != null && regionAtEndOfCompletion.getType() == DOMRegionContext.XML_TAG_NAME) {
- ITextRegion nameRegion = regionAtEndOfCompletion;
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, nodeAtOffset.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(nameRegion), nameRegion.getTextLength(), matchString);
- }
- 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 {
- // normal case, this end tag is the parent
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, nodeAtOffset, sdRegion, completionRegion, documentPosition, 0, matchString);
- }
- }
- // if (documentPosition >= sdRegion.getStartOffset(completionRegion) +
- // completionRegion.getTextLength())
- addEndTagProposals(contentAssistRequest);
- // else
- if (completionRegionStart == documentPosition) {
- // positioned at start of end tag
- addTagInsertionProposals(contentAssistRequest, node.getChildNodes().getLength());
- }
- return contentAssistRequest;
- }
-
- /**
- * return all possible EntityReferenceProposals (according to current
- * position in doc)
- */
- protected ICompletionProposal[] computeEntityReferenceProposals(int documentPosition, ITextRegion completionRegion, IDOMNode treeNode) {
- // only handle XML content for now
- Vector proposals = new Vector(); // ICompletionProposals
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- if (completionRegion != null && completionRegion.getType() == DOMRegionContext.XML_CONTENT) {
- int nodeOffset = documentPosition - sdRegion.getStartOffset(completionRegion);
- String regionText = sdRegion.getFullText(completionRegion);
-
- // 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$
- IStructuredDocumentRegion prev = treeNode.getStructuredDocument().getRegionAtCharacterOffset(documentPosition - 1);
- if (prev != null && prev.getFullText().trim().equals("&")) { //$NON-NLS-1$
- completionRegion = prev;
- regionText = prev.getFullText();
- nodeOffset = 1;
- }
- }
-
- // string must start w/ &
- if (regionText != null && regionText.startsWith("&")) { //$NON-NLS-1$
- String key = (nodeOffset > 0) ? regionText.substring(1, nodeOffset) : ""; //$NON-NLS-1$
-
- // get entity proposals, passing in the appropriate start
- // string
- ModelQuery mq = ModelQueryUtil.getModelQuery(((Node) treeNode).getOwnerDocument());
- if (mq != null) {
- CMDocument xmlDoc = mq.getCorrespondingCMDocument(treeNode);
- CMNamedNodeMap cmmap = null;
- Properties entities = null;
- if (xmlDoc != null) {
- cmmap = xmlDoc.getEntities();
- }
- if (cmmap != null) {
- entities = mapToProperties(cmmap);
- }
- else // 224787 in absence of content model, just use
- // minimal 5 entities
- {
- entities = new Properties();
- entities.put("quot", "\""); //$NON-NLS-1$ //$NON-NLS-2$
- entities.put("apos", "'"); //$NON-NLS-1$ //$NON-NLS-2$
- entities.put("amp", "&"); //$NON-NLS-1$ //$NON-NLS-2$
- entities.put("lt", "<"); //$NON-NLS-1$ //$NON-NLS-2$
- entities.put("gt", ">"); //$NON-NLS-1$ //$NON-NLS-2$
- entities.put("nbsp", " "); //$NON-NLS-1$ //$NON-NLS-2$
- }
- addEntityProposals(proposals, entities, key, nodeOffset, sdRegion, completionRegion); //$NON-NLS-1$
- }
- }
- }
- return (ICompletionProposal[]) ((proposals.size() > 0) ? proposals.toArray(new ICompletionProposal[proposals.size()]) : null);
- }
-
- protected ContentAssistRequest computeEqualsProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- ITextRegion valueRegion = node.getStartStructuredDocumentRegion().getRegionAtCharacterOffset(sdRegion.getStartOffset(completionRegion) + completionRegion.getLength());
- if (valueRegion != null && valueRegion.getType() == DOMRegionContext.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 {
- // append an attribute value after the '='
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition, 0, matchString);
- }
- addAttributeValueProposals(contentAssistRequest);
- return contentAssistRequest;
- }
-
- protected ContentAssistRequest computeStartDocumentProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
- // setup for a non-empty document, but one that hasn't been formally
- // started
- ContentAssistRequest contentAssistRequest = null;
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, getStructuredDocumentRegion(documentPosition), completionRegion, documentPosition, 0, matchString);
- addStartDocumentProposals(contentAssistRequest);
- return contentAssistRequest;
- }
-
- protected ContentAssistRequest computeTagCloseProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
-
- if ((node.getNodeType() == Node.DOCUMENT_NODE) || (documentPosition >= sdRegion.getEndOffset())) {
- // this is a content request as the documentPosition is AFTER the
- // end of the closing region
- if (node == nodeAtOffset && node.getParentNode() != null)
- node = (IDOMNode) node.getParentNode();
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition, 0, matchString);
- addTagInsertionProposals(contentAssistRequest, getElementPositionForModelQuery(nodeAtOffset));
- if (node.getNodeType() != Node.DOCUMENT_NODE && node.getEndStructuredDocumentRegion() == null) {
- addEndTagProposals(contentAssistRequest);
- }
- }
- else {
- // at the start of the tag's close or within it
- ITextRegion closeRegion = sdRegion.getLastRegion();
- boolean insideTag = !sdRegion.isEnded() || documentPosition <= sdRegion.getStartOffset(closeRegion);
- if (insideTag) {
- // this is a request for completions within a tag
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition, 0, matchString);
- if (node.getNodeType() != Node.DOCUMENT_NODE && node.getEndStructuredDocumentRegion() != null) {
- addTagCloseProposals(contentAssistRequest);
- }
- if (sdRegion == nodeAtOffset.getFirstStructuredDocumentRegion()) {
- contentAssistRequest.setReplacementBeginPosition(documentPosition);
- contentAssistRequest.setReplacementLength(0);
- addAttributeNameProposals(contentAssistRequest);
- }
- }
- }
- return contentAssistRequest;
- }
-
- protected ContentAssistRequest computeTagNameProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
-
- if (sdRegion != nodeAtOffset.getFirstStructuredDocumentRegion()) {
- // completing the *first* tag in "<tagname1 |<tagname2"
- IDOMNode actualNode = (IDOMNode) node.getModel().getIndexedRegion(sdRegion.getStartOffset(completionRegion));
- if (actualNode != null) {
- if (actualNode.getFirstStructuredDocumentRegion() == sdRegion) {
- // start tag
- if (documentPosition > sdRegion.getStartOffset(completionRegion) + completionRegion.getLength()) {
- // it's attributes
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode, sdRegion, completionRegion, documentPosition - matchString.length(), matchString.length(), matchString);
- if (node.getStructuredDocument().getRegionAtCharacterOffset(sdRegion.getStartOffset(completionRegion) - 1).getRegionAtCharacterOffset(sdRegion.getStartOffset(completionRegion) - 1).getType() == DOMRegionContext.XML_TAG_OPEN)
- addAttributeNameProposals(contentAssistRequest);
- addTagCloseProposals(contentAssistRequest);
- }
- else {
- // it's name
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, documentPosition - matchString.length(), matchString.length(), matchString);
- addTagNameProposals(contentAssistRequest, getElementPositionForModelQuery(actualNode));
- }
- }
- else {
- if (documentPosition >= sdRegion.getStartOffset(completionRegion) + completionRegion.getLength()) {
- // insert name
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- }
- else {
- // replace name
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
- }
- addEndTagNameProposals(contentAssistRequest);
- }
- }
- }
- 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 {
- if (sdRegion.getRegions().get(0).getType() != DOMRegionContext.XML_END_TAG_OPEN) {
- contentAssistRequest = newContentAssistRequest(node, node.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
- addTagNameProposals(contentAssistRequest, getElementPositionForModelQuery(nodeAtOffset));
- }
- else {
- IDOMNode actualNode = (IDOMNode) 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 {
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
- }
- addEndTagNameProposals(contentAssistRequest);
- }
- }
- }
- }
- return contentAssistRequest;
- }
-
- protected ContentAssistRequest computeTagOpenProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- if (sdRegion != nodeAtOffset.getFirstStructuredDocumentRegion()) {
- // completing the *first* XML_TAG_OPEN in "<<tagname"
- IDOMNode actualNode = (IDOMNode) 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 {
- 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) {
- // 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 {
- // within the white space
- ITextRegion name = getNameRegion(node.getStartStructuredDocumentRegion());
- // (pa) ITextRegion refactor
- // 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 {
- // insert a valid new name, or possibly an end tag
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, ((Node) nodeAtOffset).getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- addEndTagProposals(contentAssistRequest);
- contentAssistRequest.setReplacementBeginPosition(documentPosition);
- contentAssistRequest.setReplacementLength(0);
- }
- addTagNameProposals(contentAssistRequest, getElementPositionForModelQuery(nodeAtOffset));
- }
- }
- return contentAssistRequest;
- }
-
- /**
- * Retreives cmnode's documentation to display in the completion
- * 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.
- */
- protected String getAdditionalInfo(CMNode parentOrOwner, CMNode cmnode) {
- String addlInfo = null;
-
- if (cmnode == null) {
- if (Debug.displayWarnings) {
- new IllegalArgumentException("Null declaration!").printStackTrace(); //$NON-NLS-1$
- }
- return null;
- }
-
- addlInfo = getInfoProvider().getInfo(cmnode);
- if (addlInfo == null && parentOrOwner != null)
- addlInfo = getInfoProvider().getInfo(parentOrOwner);
- return addlInfo;
- }
-
- // returns a list of ModelQueryActions
- protected List getAvailableChildrenAtIndex(Element parent, int index) {
- List list = new ArrayList();
- CMElementDeclaration parentDecl = getCMElementDeclaration(parent);
- if (parentDecl != null) {
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(parent.getOwnerDocument());
- // taken from ActionManagers
- // int editMode = modelQuery.getEditMode();
- int editMode = ModelQuery.EDIT_MODE_UNCONSTRAINED;
- int ic = (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) ? ModelQuery.INCLUDE_CHILD_NODES | ModelQuery.INCLUDE_SEQUENCE_GROUPS : ModelQuery.INCLUDE_CHILD_NODES;
- int vc = (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) ? ModelQuery.VALIDITY_STRICT : ModelQuery.VALIDITY_NONE;
- modelQuery.getInsertActions(parent, parentDecl, index, ic, vc, list);
- }
- return list;
- }
-
- // returns a list of CMElementDeclarations
- protected List getAvailableRootChildren(Document document, int childIndex) {
- List list = null;
-
- // extract the valid 'root' node name from the DocumentType Node
- DocumentType docType = document.getDoctype();
- String rootName = null;
- if (docType != null) {
- rootName = docType.getNodeName();
- }
- if (rootName == null)
- return new ArrayList(0);
-
- for (Node child = document.getFirstChild(); child != null; child = child.getNextSibling()) {
- // 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
- // count it as present
- if (child instanceof IDOMNode && (((IDOMNode) child).getStartStructuredDocumentRegion() == null || ((IDOMNode) child).getEndStructuredDocumentRegion() == null))
- continue;
- if (Debug.displayInfo)
- System.out.println(rootName + " already present!"); //$NON-NLS-1$
- setErrorMessage(NLS.bind(XMLUIMessages.The_document_element__, (new Object[]{rootName})));
- return new ArrayList(0);
- }
- }
-
- list = new ArrayList(1);
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document);
- if (modelQuery != null) {
- CMDocument cmdoc = modelQuery.getCorrespondingCMDocument(document);
- if (cmdoc != null) {
- if (rootName != null) {
- CMElementDeclaration rootDecl = (CMElementDeclaration) cmdoc.getElements().getNamedItem(rootName);
- if (rootDecl != null) {
- list.add(rootDecl);
- }
- else {
- // supply the given document name anyway, even if it
- // is an error
- list.add(new SimpleCMElementDeclaration(rootName));
- if (Debug.displayInfo || Debug.displayWarnings)
- System.out.println("No definition found for " + rootName + " in " + docType.getPublicId() + "/" + docType.getSystemId()); //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- String location = "" + (docType.getPublicId() != null ? docType.getPublicId() + "/" : "") + (docType.getSystemId() != null ? docType.getSystemId() : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- //$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- //$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- if (location.length() > 0)
- setErrorMessage(NLS.bind(XMLUIMessages.No_definition_for_in, (new Object[]{rootName, location})));
- else
- setErrorMessage(NLS.bind(XMLUIMessages.No_definition_for, (new Object[]{rootName})));
- }
- }
- }
- else {
- if (Debug.displayInfo || Debug.displayWarnings)
- System.out.println("No content model found."); //$NON-NLS-1$
- //$NON-NLS-1$
- //$NON-NLS-1$
- String location = "" + (docType.getPublicId() != null ? docType.getPublicId() + "/" : "") + (docType.getSystemId() != null ? docType.getSystemId() : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- //$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- //$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- if (location.length() > 0)
- setErrorMessage(NLS.bind(XMLUIMessages.No_content_model_for, (new Object[]{location})));
- else
- setErrorMessage(XMLUIMessages.No_content_model_found_UI_);
- }
- }
-
- return list;
- }
-
- protected CMElementDeclaration getCMElementDeclaration(Node node) {
- CMElementDeclaration result = null;
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(node.getOwnerDocument());
- if (modelQuery != null)
- result = modelQuery.getCMElementDeclaration((Element) node);
- }
- return result;
- }
-
- /**
- * 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
- */
- public char[] getCompletionProposalAutoActivationCharacters() {
- return completionProposalAutoActivationCharacters;
- }
-
- protected ITextRegion getCompletionRegion(int offset, IStructuredDocumentRegion sdRegion) {
- ITextRegion region = sdRegion.getRegionAtCharacterOffset(offset);
- if (region == null)
- return null;
-
- if (sdRegion.getStartOffset(region) == offset) {
- // The offset is at the beginning of the region
- if ((sdRegion.getStartOffset(region) == sdRegion.getStartOffset()) && (sdRegion.getPrevious() != null) && (!sdRegion.getPrevious().isEnded())) {
- // Is the region also the start of the node? If so, the
- // previous IStructuredDocumentRegion is
- // where to look for a useful region.
- region = sdRegion.getPrevious().getRegionAtCharacterOffset(offset - 1);
- }
- else {
- // Is there no separating whitespace from the previous region?
- // If not,
- // then that region is the important one
- ITextRegion previousRegion = sdRegion.getRegionAtCharacterOffset(offset - 1);
- if ((previousRegion != null) && (previousRegion != region) && (previousRegion.getTextLength() == previousRegion.getLength())) {
- region = previousRegion;
- }
- }
- }
- 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
- // region?
- // If so, use the next region
- ITextRegion nextRegion = sdRegion.getRegionAtCharacterOffset(sdRegion.getStartOffset(region) + region.getLength());
- if (nextRegion != null)
- region = nextRegion;
- }
- else {
- // Is the offset within the important text for this region?
- // If so, then we've already got the right one.
- }
- }
-
- // valid WHITE_SPACE region handler (#179924)
- if (region != null && region.getType() == DOMRegionContext.WHITE_SPACE) {
- ITextRegion previousRegion = sdRegion.getRegionAtCharacterOffset(sdRegion.getStartOffset(region) - 1);
- if (previousRegion != null)
- region = previousRegion;
- }
-
- return region;
- }
-
- /**
- * Return the region whose content's require completion. This is something
- * of a misnomer as sometimes the user wants to be prompted for contents
- * of a non-existant ITextRegion, such as for enumerated attribute values
- * following an '=' sign.
- */
- protected ITextRegion getCompletionRegion(int documentPosition, Node domnode) {
- if (domnode == null)
- return null;
-
- ITextRegion region = null;
- int offset = documentPosition;
- IStructuredDocumentRegion flatNode = null;
- IDOMNode node = (IDOMNode) domnode;
-
- if (node.getNodeType() == Node.DOCUMENT_NODE) {
- if (node.getStructuredDocument().getLength() == 0)
- return null;
- ITextRegion result = node.getStructuredDocument().getRegionAtCharacterOffset(offset).getRegionAtCharacterOffset(offset);
- while (result == null) {
- offset--;
- result = node.getStructuredDocument().getRegionAtCharacterOffset(offset).getRegionAtCharacterOffset(offset);
- }
- return result;
- }
-
- IStructuredDocumentRegion startTag = node.getStartStructuredDocumentRegion();
- IStructuredDocumentRegion endTag = node.getEndStructuredDocumentRegion();
-
- // Determine if the offset is within the start
- // IStructuredDocumentRegion, end IStructuredDocumentRegion, or
- // somewhere within the Node's XML content.
- if ((startTag != null) && (startTag.getStartOffset() <= offset) && (offset < startTag.getStartOffset() + startTag.getLength()))
- flatNode = startTag;
- else if ((endTag != null) && (endTag.getStartOffset() <= offset) && (offset < endTag.getStartOffset() + endTag.getLength()))
- flatNode = endTag;
-
- if (flatNode != null) {
- // the offset is definitely within the start or end tag, continue
- // on and find the region
- region = getCompletionRegion(offset, flatNode);
- }
- 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.getStartOffset() <= documentPosition && flatNode.getEndOffset() >= documentPosition) {
- // we're interesting in completing/extending the previous
- // IStructuredDocumentRegion if the current
- // IStructuredDocumentRegion isn't plain content or if it's
- // preceded by an orphan '<'
- if ((offset == flatNode.getStartOffset()) && (flatNode.getPrevious() != null) && (flatNode.getRegionAtCharacterOffset(documentPosition) != null && flatNode.getRegionAtCharacterOffset(documentPosition).getType() != DOMRegionContext.XML_CONTENT || flatNode.getPrevious().getLastRegion().getType() == DOMRegionContext.XML_TAG_OPEN || flatNode.getPrevious().getLastRegion().getType() == DOMRegionContext.XML_END_TAG_OPEN)) {
- // Is the region also the start of the node? If so, the
- // previous IStructuredDocumentRegion is
- // where to look for a useful region.
- region = flatNode.getPrevious().getLastRegion();
- }
- else if (flatNode.getEndOffset() == documentPosition) {
- region = flatNode.getLastRegion();
- }
- else
- region = flatNode.getFirstRegion();
- }
- else {
- // catch end of document positions where the docPosition isn't
- // in a IStructuredDocumentRegion
- region = flatNode.getLastRegion();
- }
- }
-
- return region;
- }
-
- /**
- * Provided by default. Subclasses may override with their own
- * implementations.
- *
- * @see AbstractContentAssistProcessor#getContentGenerator()
- */
- public XMLContentModelGenerator getContentGenerator() {
- if (fGenerator == null)
- fGenerator = new XMLContentModelGenerator();
- return fGenerator;
- }
-
- /**
- * 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
- */
- public char[] getContextInformationAutoActivationCharacters() {
- return contextInformationAutoActivationCharacters;
- }
-
- /**
- * Returns a validator used to determine when displayed context
- * 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
- */
- public IContextInformationValidator getContextInformationValidator() {
- if (fContextInformationPresenter == null)
- fContextInformationPresenter = new AttributeContextInformationPresenter();
- return fContextInformationPresenter;
- }
-
- protected int getElementPosition(Node child) {
- Node parent = child.getParentNode();
- if (parent == null)
- return 0;
-
- NodeList children = parent.getChildNodes();
- if (children == null)
- return 0;
- int count = 0;
-
- for (int i = 0; i < children.getLength(); i++) {
- if (children.item(i) == child)
- return count;
- else
- // if (children.item(i).getNodeType() == Node.ELEMENT_NODE)
- count++;
- }
- return 0;
- }
-
- private int getElementPositionForModelQuery(Node child) {
- return getElementPosition(child);
- // return -1;
- }
-
- /**
- * Return the reason why computeProposals was not able to find any
- * completions.
- *
- * an error message or null if no error occurred
- */
- public String getErrorMessage() {
- return fErrorMessage;
- }
-
- /**
- * @param iResource
- */
- // public void initialize(IResource iResource) {
- // this.resource = iResource;
- // }
- /**
- * Gets the infoProvider.
- *
- * fInfoProvider and if fInfoProvider was <code>null</code> create a new
- * instance
- */
- public MarkupTagInfoProvider getInfoProvider() {
- if (fInfoProvider == null) {
- fInfoProvider = new MarkupTagInfoProvider();
- }
- return fInfoProvider;
- }
-
- protected String getMatchString(IStructuredDocumentRegion parent, ITextRegion aRegion, int offset) {
- if (aRegion == null || isCloseRegion(aRegion))
- return ""; //$NON-NLS-1$
- String matchString = null;
- String regionType = aRegion.getType();
- if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS || regionType == DOMRegionContext.XML_TAG_OPEN || (offset > parent.getStartOffset(aRegion) + aRegion.getTextLength())) {
- matchString = ""; //$NON-NLS-1$
- }
- else if (regionType == DOMRegionContext.XML_CONTENT) {
- matchString = ""; //$NON-NLS-1$
- }
- else {
- if (parent.getText(aRegion).length() > 0 && parent.getStartOffset(aRegion) < offset)
- matchString = parent.getText(aRegion).substring(0, offset - parent.getStartOffset(aRegion));
- else
- matchString = ""; //$NON-NLS-1$
- }
- return matchString;
- }
-
- protected ITextRegion getNameRegion(IStructuredDocumentRegion flatNode) {
- if (flatNode == null)
- return null;
- Iterator regionList = flatNode.getRegions().iterator();
- while (regionList.hasNext()) {
- ITextRegion region = (ITextRegion) regionList.next();
- if (isNameRegion(region))
- return region;
- }
- return null;
- }
-
- /**
- * Retrieves all of the possible valid values for this attribute
- * declaration
- */
- protected List getPossibleDataTypeValues(Node node, CMAttributeDeclaration ad) {
- List list = null;
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- Element element = (Element) node;
- String[] dataTypeValues = null;
- // The ModelQuery may not be available if the corresponding
- // adapter
- // is absent
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(element.getOwnerDocument());
- if (modelQuery != null) {
- dataTypeValues = modelQuery.getPossibleDataTypeValues(element, ad);
- }
- else {
- if (ad.getAttrType() != null)
- dataTypeValues = ad.getAttrType().getEnumeratedValues();
- }
- if (dataTypeValues != null) {
- list = new ArrayList(dataTypeValues.length);
- for (int i = 0; i < dataTypeValues.length; i++) {
- list.add(dataTypeValues[i]);
- }
- }
- }
- if (list == null) {
- list = new ArrayList(0);
- }
- return list;
- }
-
- protected String getRequiredName(Node parentOrOwner, CMNode cmnode) {
- if (cmnode == null || parentOrOwner == null) {
- if (Debug.displayWarnings) {
- new IllegalArgumentException("Null declaration!").printStackTrace(); //$NON-NLS-1$
- }
- return ""; //$NON-NLS-1$
- }
- return getContentGenerator().getRequiredName(parentOrOwner, cmnode);
- }
-
- protected String getRequiredText(Node parentOrOwner, CMAttributeDeclaration attrDecl) {
- if (attrDecl == null) {
- if (Debug.displayWarnings) {
- new IllegalArgumentException("Null attribute declaration!").printStackTrace(); //$NON-NLS-1$
- }
- return ""; //$NON-NLS-1$
- }
- StringBuffer buff = new StringBuffer();
- getContentGenerator().generateRequiredAttribute(parentOrOwner, attrDecl, buff);
- return buff.toString();
- }
-
- protected String getRequiredText(Node parentOrOwner, CMElementDeclaration elementDecl) {
- if (elementDecl == null) {
- if (Debug.displayWarnings) {
- new IllegalArgumentException("Null attribute declaration!").printStackTrace(); //$NON-NLS-1$
- }
- return ""; //$NON-NLS-1$
- }
- StringBuffer buff = new StringBuffer();
- getContentGenerator().generateTag(parentOrOwner, elementDecl, buff);
- return buff.toString();
- }
-
- /**
- * StructuredTextViewer must be set before using this.
- */
- public IStructuredDocumentRegion getStructuredDocumentRegion(int pos) {
- // (pa) ITextRegion refactor defect 245190
- // return
- // (IStructuredDocumentRegion)ContentAssistUtils.getNodeAt((StructuredTextViewer)fTextViewer,
- // pos);
- return ContentAssistUtils.getStructuredDocumentRegion((StructuredTextViewer) fTextViewer, pos);
- }
-
- private String getTagName(IStructuredDocumentRegion sdRegion) {
- ITextRegionList regions = sdRegion.getRegions();
- ITextRegion region = null;
- String name = ""; //$NON-NLS-1$
- for (int i = 0; i < regions.size(); i++) {
- region = regions.get(i);
- if (region.getType() == DOMRegionContext.XML_TAG_NAME) {
- name = sdRegion.getText(region);
- break;
- }
- }
- return name;
- }
-
- protected List getValidCMNodes(int childPosition, int kindOfAction, List modelQueryActions) {
- Iterator iterator = modelQueryActions.iterator();
- List cmnodes = new Vector();
- while (iterator.hasNext()) {
- ModelQueryAction action = (ModelQueryAction) iterator.next();
- if (childPosition < 0 || (action.getStartIndex() <= childPosition && childPosition <= action.getEndIndex()) && action.getKind() == kindOfAction) {
- CMNode actionCMNode = action.getCMNode();
- if (actionCMNode != null && !cmnodes.contains(actionCMNode))
- cmnodes.add(actionCMNode);
- }
- }
- return cmnodes;
- }
-
- /**
- * Similar to the call in HTMLContentAssistProcessor. Pass in a node, it
- * tells you if the document is XML type.
- *
- * @param node
- *
- */
- protected boolean getXML(Node node) {
- if (node == null)
- return false;
-
- Document doc = null;
- doc = (node.getNodeType() != Node.DOCUMENT_NODE) ? node.getOwnerDocument() : ((Document) node);
-
- return (doc instanceof IDOMDocument) && ((IDOMDocument) doc).isXMLType();
- }
-
- // Initialize local settings
- protected void init() {
- // implement in subclasses
- }
-
- protected boolean isCloseRegion(ITextRegion region) {
- String type = region.getType();
- return ((type == DOMRegionContext.XML_PI_CLOSE) || (type == DOMRegionContext.XML_TAG_CLOSE) || (type == DOMRegionContext.XML_EMPTY_TAG_CLOSE) || (type == DOMRegionContext.XML_CDATA_CLOSE) || (type == DOMRegionContext.XML_COMMENT_CLOSE) || (type == DOMRegionContext.XML_ATTLIST_DECL_CLOSE) || (type == DOMRegionContext.XML_ELEMENT_DECL_CLOSE) || (type == DOMRegionContext.XML_DOCTYPE_DECLARATION_CLOSE) || (type == DOMJSPRegionContextsPrivateCopy.JSP_CLOSE) || (type == DOMJSPRegionContextsPrivateCopy.JSP_COMMENT_CLOSE) || (type.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_CLOSE)) || (type == DOMRegionContext.XML_DECLARATION_CLOSE));
- }
-
- /*
- * This is to determine if a tag is a special meta-info comment tag that
- * shows up as an ELEMENT
- */
- private boolean isCommentNode(IDOMNode node) {
- return (node != null && node instanceof IDOMElement && ((IDOMElement) node).isCommentTag());
- }
-
- /**
- * Checks if cursor position is after doctype tag...
- *
- * @param car
- *
- */
- protected boolean isCursorAfterDoctype(ContentAssistRequest car) {
- Node aNode = car.getNode();
- Document parent = aNode.getOwnerDocument();
- int xmldoctypeNodePosition = -1;
- boolean isAfterDoctype = true;
-
- if (parent == null)
- return true; // blank document case
-
- for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child instanceof IDOMNode) {
- if (child.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
- xmldoctypeNodePosition = ((IDOMNode) child).getEndOffset();
- isAfterDoctype = (car.getReplacementBeginPosition() >= xmldoctypeNodePosition);
- break;
- }
- }
- }
- return isAfterDoctype;
- }
-
- /**
- * This method can check if the cursor is after the XMLPI
- *
- * @param car
- *
- */
- protected boolean isCursorAfterXMLPI(ContentAssistRequest car) {
- Node aNode = car.getNode();
- boolean xmlpiFound = false;
- Document parent = aNode.getOwnerDocument();
- int xmlpiNodePosition = -1;
- boolean isAfterXMLPI = false;
-
- if (parent == null)
- return true; // blank document case
-
- for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
- boolean xmlpi = (child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE && child.getNodeName().equals("xml")); //$NON-NLS-1$
- xmlpiFound = xmlpiFound || xmlpi;
- if (xmlpiFound) {
- if (child instanceof IDOMNode) {
- xmlpiNodePosition = ((IDOMNode) child).getEndOffset();
- isAfterXMLPI = (car.getReplacementBeginPosition() >= xmlpiNodePosition);
- }
- break;
- }
- }
- return isAfterXMLPI;
- }
-
- protected boolean isNameRegion(ITextRegion region) {
- String type = region.getType();
- return ((type == DOMRegionContext.XML_TAG_NAME) || (type == DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_NAME) || (type == DOMRegionContext.XML_ELEMENT_DECL_NAME) || (type == DOMRegionContext.XML_DOCTYPE_NAME) || (type == DOMRegionContext.XML_ATTLIST_DECL_NAME) || (type == DOMJSPRegionContextsPrivateCopy.JSP_ROOT_TAG_NAME) || type.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_NAME));
- }
-
- protected boolean isQuote(String string) {
- String trimmed = string.trim();
- if (trimmed.length() > 0) {
- return trimmed.charAt(0) == '\'' || trimmed.charAt(0) == '"';
- }
- return false;
- }
-
- private boolean isSelfClosed(IStructuredDocumentRegion startTag) {
- ITextRegionList regions = startTag.getRegions();
- return regions.get(regions.size() - 1).getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE;
- }
-
- private boolean isStartTag(IStructuredDocumentRegion sdRegion) {
- boolean result = false;
- if (sdRegion.getRegions().size() > 0) {
- ITextRegion r = sdRegion.getRegions().get(0);
- result = r.getType() == DOMRegionContext.XML_TAG_OPEN && sdRegion.isEnded();
- }
- return result;
- }
-
- protected Properties mapToProperties(CMNamedNodeMap map) {
- Properties p = new Properties();
- for (int i = 0; i < map.getLength(); i++) {
- CMEntityDeclaration decl = (CMEntityDeclaration) map.item(i);
- p.put(decl.getName(), decl.getValue());
- }
- return p;
- }
-
- /**
- * Gets the corresponding XMLNode, and checks if it's closed.
- *
- * @param startTag
- *
- */
- private boolean needsEndTag(IStructuredDocumentRegion startTag) {
- boolean result = false;
- IStructuredModel sModel = StructuredModelManager.getModelManager().getExistingModelForRead(fTextViewer.getDocument());
- try {
- if (sModel != null) {
- IDOMNode xmlNode = (IDOMNode) sModel.getIndexedRegion(startTag.getStart());
- if (!isStartTag(startTag))
- result = false;
- else if (isSelfClosed(startTag))
- result = false;
- else if (!xmlNode.isContainer())
- result = false;
- else
- result = xmlNode.getEndStructuredDocumentRegion() == null;
- }
- }
- finally {
- if (sModel != null)
- sModel.releaseFromRead();
- }
- return result;
- }
-
- protected ContentAssistRequest newContentAssistRequest(Node node, Node possibleParent, IStructuredDocumentRegion documentRegion, ITextRegion completionRegion, int begin, int length, String filter) {
- return new ContentAssistRequest(node, possibleParent, documentRegion, completionRegion, begin, length, filter, null);
- }
-
- public void release() {
- fGenerator = null;
- }
-
- /**
- * Set the reason why computeProposals was not able to find any
- * completions.
- */
- public void setErrorMessage(String errorMessage) {
- fErrorMessage = errorMessage;
- }
-
- /**
- * Set the reason why computeProposals was not able to find any
- * completions.
- */
- protected void setErrorMessage(String errorMessage, String append) {
- setErrorMessage(errorMessage + append);
- }
-
- /**
- * Set the reason why computeProposals was not able to find any
- * completions.
- */
- protected void setErrorMessage(String errorMessage, String prepend, String append) {
- setErrorMessage(prepend + errorMessage + append);
- }
-
- protected boolean stringsEqual(String a, String b) {
- // (pa) 221190 matching independent of case to be consistant with Java
- // editor CA
- return a.equalsIgnoreCase(b);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentModelGenerator.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentModelGenerator.java
deleted file mode 100644
index e97ac6c798..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentModelGenerator.java
+++ /dev/null
@@ -1,86 +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.ui.internal.contentassist;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
-import org.w3c.dom.Node;
-
-
-public abstract class AbstractContentModelGenerator {
-
- public static boolean generateChildren = false;
-
- public AbstractContentModelGenerator() {
- super();
- }
-
- public abstract void generateAttribute(CMAttributeDeclaration attrDecl, StringBuffer buffer);
-
- protected void generateAttributes(CMElementDeclaration elementDecl, StringBuffer buffer) {
- CMNamedNodeMap attributes = elementDecl.getAttributes();
- if (attributes == null)
- return;
- for (int i = 0; i < attributes.getLength(); i++) {
- generateAttribute((CMAttributeDeclaration) attributes.item(i), buffer);
- }
- return;
- }
-
- protected abstract void generateEndTag(String tagName, Node parentNode, CMElementDeclaration elementDecl, StringBuffer buffer);
-
- public void generateRequiredChildren(Node parentNode, CMElementDeclaration elementDecl, StringBuffer buffer) {
- if (generateChildren) {
- }
- return;
- }
-
- protected abstract void generateStartTag(String tagName, Node parentNode, CMElementDeclaration elementDecl, StringBuffer buffer);
-
- public void generateTag(Node parent, CMElementDeclaration elementDecl, StringBuffer buffer) {
- if (elementDecl == null || buffer == null)
- return;
-
- String tagName = getRequiredName(parent, elementDecl);
-
- generateStartTag(tagName, parent, elementDecl, buffer);
- generateRequiredChildren(parent, elementDecl, buffer);
- generateEndTag(tagName, parent, elementDecl, buffer);
- return;
- }
-
- public abstract int getMinimalStartTagLength(Node node, CMElementDeclaration elementDecl);
-
- public String getRequiredName(Node ownerNode, CMNode cmnode) {
- if (ownerNode != null) {
- return DOMNamespaceHelper.computeName(cmnode, ownerNode, null);
- }
- return cmnode.getNodeName();
- }
-
- public abstract String getStartTagClose(Node parentNode, CMElementDeclaration elementDecl);
-
- protected boolean requiresAttributes(CMElementDeclaration ed) {
- CMNamedNodeMap attributes = ed.getAttributes();
- if (attributes == null)
- return false;
- for (int i = 0; i < attributes.getLength(); i++) {
- if (((CMAttributeDeclaration) attributes.item(i)).getUsage() == CMAttributeDeclaration.REQUIRED)
- return true;
- }
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformation.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformation.java
deleted file mode 100644
index 0b8ca5018d..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformation.java
+++ /dev/null
@@ -1,113 +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.ui.internal.contentassist;
-
-import java.util.HashMap;
-
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.ui.util.Assert;
-
-
-/**
- * Implementation of IContextInformation. Adds knowledge about the information
- * display string such as required attributes for this context.
- *
- * @author pavery
- */
-public class AttributeContextInformation implements IContextInformation {
- private HashMap fAttr2RangeMap;
- /** The name of the context */
- private String fContextDisplayString;
- /** The image to be displayed */
- private Image fImage;
- /** The information to be displayed */
- private String fInformationDisplayString;
- private int fPosition;
-
- /**
- * Creates a new context information with an image.
- *
- * @param image
- * the image to display when presenting the context information
- * @param contextDisplayString
- * the string to be used when presenting the context
- * @param informationDisplayString
- * the string to be displayed when presenting the context
- * information, may not be <code>null</code>
- */
- public AttributeContextInformation(Image image, String contextDisplayString, String informationDisplayString, HashMap attr2RangeMap) {
- Assert.isNotNull(informationDisplayString);
-
- fImage = image;
- fContextDisplayString = contextDisplayString;
- fInformationDisplayString = informationDisplayString;
- fAttr2RangeMap = attr2RangeMap;
- }
-
- /**
- * Creates a new context information without an image.
- *
- * @param contextDisplayString
- * the string to be used when presenting the context
- * @param informationDisplayString
- * the string to be displayed when presenting the context
- * information
- */
- public AttributeContextInformation(String contextDisplayString, String informationDisplayString, HashMap attr2RangeMap) {
- this(null, contextDisplayString, informationDisplayString, attr2RangeMap);
- }
-
- /**
- * Maps (String -> Position). The attribute name to the Text position.
- *
- *
- */
- public HashMap getAttr2RangeMap() {
- return fAttr2RangeMap;
- }
-
- /**
- * @see org.eclipse.jface.text.contentassist.IContextInformation#getContextDisplayString()
- */
- public String getContextDisplayString() {
- if (fContextDisplayString != null)
- return fContextDisplayString;
- return fInformationDisplayString;
- }
-
- /**
- * @see org.eclipse.jface.text.contentassist.IContextInformationExtension#getContextInformationPosition()
- */
- public int getContextInformationPosition() {
- return fPosition;
- }
-
- /**
- * @see org.eclipse.jface.text.contentassist.IContextInformation#getImage()
- */
- public Image getImage() {
- return fImage;
- }
-
- /**
- * @see org.eclipse.jface.text.contentassist.IContextInformation#getInformationDisplayString()
- */
- public String getInformationDisplayString() {
- return fInformationDisplayString;
- }
-
- public void setContextInformationPosition(int position) {
- fPosition = position;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationPresenter.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationPresenter.java
deleted file mode 100644
index 9acf25b6df..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationPresenter.java
+++ /dev/null
@@ -1,112 +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.ui.internal.contentassist;
-
-import java.util.HashMap;
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformationPresenter;
-import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.xml.core.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-/**
- * Responsible for the presentation of the context info popup. This includes
- * text style, and when the window should close.
- *
- * @author pavery
- */
-public class AttributeContextInformationPresenter implements IContextInformationPresenter, IContextInformationValidator {
- private int fDocumentPosition = -1;
-
- private IContextInformation fInfo = null;
- private ContextInfoModelUtil fModelUtil = null;
- private ITextViewer fViewer = null;
-
- /**
- * @see org.eclipse.jface.text.contentassist.IContextInformationValidator#install(org.eclipse.jface.text.contentassist.IContextInformation,
- * org.eclipse.jface.text.ITextViewer, int)
- */
- public void install(IContextInformation info, ITextViewer viewer, int documentPosition) {
- fInfo = info;
- fViewer = viewer;
- fDocumentPosition = documentPosition;
- fModelUtil = new ContextInfoModelUtil((IStructuredDocument) fViewer.getDocument());
- }
-
- /**
- * @see org.eclipse.jface.text.contentassist.IContextInformationValidator#isContextInformationValid(int)
- */
- public boolean isContextInformationValid(int documentPosition) {
- // determine whether or not this context info should still be
- // showing...
- // if cursor still within the element it's valid...
- IStructuredDocumentRegion startRegion = fModelUtil.getXMLNode(fDocumentPosition).getStartStructuredDocumentRegion();
- int start = startRegion.getStartOffset();
- int end = startRegion.getEndOffset();
- return documentPosition < end && documentPosition > start + 1;
- }
-
- /**
- * @see org.eclipse.jface.text.contentassist.IContextInformationPresenter#updatePresentation(int,
- * org.eclipse.jface.text.TextPresentation)
- */
- public boolean updatePresentation(int documentPosition, TextPresentation presentation) {
- presentation.clear();
-
- if (!(fInfo instanceof AttributeContextInformation))
- return false;
-
- // iterate existing attributes from current node
- IDOMNode xmlNode = fModelUtil.getXMLNode(documentPosition);
- IStructuredDocumentRegion sdRegion = xmlNode.getFirstStructuredDocumentRegion();
- ITextRegionList regions = sdRegion.getRegions();
- ITextRegion r = null;
- String attrName = ""; //$NON-NLS-1$
- Object temp = null;
- Position p = null;
- HashMap map = ((AttributeContextInformation) fInfo).getAttr2RangeMap();
-
- // so we can add ranges in order
- StyleRange[] sorted = new StyleRange[fInfo.getInformationDisplayString().length()];
- for (int i = 0; i < regions.size(); i++) {
- r = regions.get(i);
- if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- attrName = sdRegion.getText(r);
- temp = map.get(attrName);
- if (temp != null) {
- p = (Position) temp;
- sorted[p.offset] = new StyleRange(p.offset, p.length, null, null, SWT.BOLD);
- }
- }
- }
- // style ranges need to be added in order
- StyleRange sr = null;
- for (int i = 0; i < sorted.length; i++) {
- sr = sorted[i];
- if (sr != null)
- presentation.addStyleRange(sr);
- }
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationProvider.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationProvider.java
deleted file mode 100644
index 264a6278ee..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationProvider.java
+++ /dev/null
@@ -1,208 +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.ui.internal.contentassist;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.contentassist.ContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.xml.core.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMContent;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-/**
- * Calculates attribute context information based on a StructuedDocument and
- * document position.
- *
- * @author pavery
- */
-class AttributeContextInformationProvider {
- private final IContextInformation[] EMPTY_CONTEXT_INFO = new IContextInformation[0];
- private Comparator fComparator;
-
- private IStructuredDocument fDocument = null;
- private ContextInfoModelUtil fModelUtil = null;
-
- public AttributeContextInformationProvider(IStructuredDocument doc, AttributeContextInformationPresenter presenter) {
- fDocument = doc;
- fModelUtil = new ContextInfoModelUtil(fDocument);
- }
-
- /**
- * @param sdRegion
-
- */
- private boolean canProposeInfo(IStructuredDocumentRegion sdRegion) {
- if (sdRegion != null && isEndTag(sdRegion))
- return false;
- else
- return true;
- }
-
- public IContextInformation[] getAttributeInformation(int offset) {
- /*
- * need to take care of special cases w/ ambiguous regions <tag>|
- * </tag> also end tags..
- */
- IContextInformation[] results = EMPTY_CONTEXT_INFO;
-
- IStructuredDocumentRegion sdRegion = fModelUtil.getDocument().getRegionAtCharacterOffset(offset);
- if (!canProposeInfo(sdRegion))
- return EMPTY_CONTEXT_INFO;
-
- IDOMNode node = fModelUtil.getXMLNode(offset);
- if (node != null) {
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE :
- results = getInfoForElement(node);
- break;
- // future...
- // case Node.TEXT_NODE :
- // results = getInfoForText(node);
- // break;
- }
- }
- return results;
- }
-
- /**
- * Returns a comparator that compares CMAttributeDeclaration names.
- *
- the comparator
- */
- private Comparator getCMAttributeComparator() {
- if (fComparator == null)
- fComparator = new Comparator() {
- public int compare(Object o1, Object o2) {
- return ((CMAttributeDeclaration) o1).getAttrName().compareTo(((CMAttributeDeclaration) o2).getAttrName());
- }
- };
- return fComparator;
- }
-
- /**
- * @param node
-
- */
- private IContextInformation[] getInfoForElement(IDOMNode node) {
- IContextInformation[] results = EMPTY_CONTEXT_INFO;
- CMElementDeclaration decl = fModelUtil.getModelQuery().getCMElementDeclaration((Element) node);
- if (decl != null) {
- CMNamedNodeMap attributes = decl.getAttributes();
-
- String attrContextString = node.getNodeName();
- StringBuffer attrInfo = new StringBuffer(" "); //$NON-NLS-1$
- String name = ""; //$NON-NLS-1$
- HashMap attrPosMap = new HashMap();
- int pos = 0;
- int length = 0;
- int numPerLine = 8;
-
- CMAttributeDeclaration[] sortedAttrs = getSortedAttributes(attributes);
-
- for (int i = 0; i < sortedAttrs.length; i++) {
- name = sortedAttrs[i].getAttrName();
- length = name.length();
- pos = attrInfo.length();
-
- attrInfo.append(name);
-
- if (sortedAttrs[i].getUsage() == CMAttributeDeclaration.REQUIRED) {
- attrInfo.append("*"); //$NON-NLS-1$
- length++;
- }
- if (i < attributes.getLength() - 1) {
- attrInfo.append(" "); //$NON-NLS-1$
- if (i != 0 && i % numPerLine == 0)
- attrInfo.append("\n "); //$NON-NLS-1$
- }
- attrPosMap.put(name, new Position(pos, length));
- }
- if (!attrInfo.toString().trim().equals("")) //$NON-NLS-1$
- return new IContextInformation[]{new AttributeContextInformation(attrContextString, attrInfo.toString(), attrPosMap)};
- }
- return results;
- }
-
- /**
- * @param node
-
- */
- IContextInformation[] getInfoForText(IDOMNode node) {
- Node parent = node.getParentNode();
- String contextString = node.getNodeName();
- StringBuffer info = new StringBuffer(" "); //$NON-NLS-1$
- if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) {
- CMElementDeclaration decl = fModelUtil.getModelQuery().getCMElementDeclaration((Element) parent);
- CMContent content = decl.getContent();
- if (content instanceof CMGroup) {
- CMGroup cmGroup = (CMGroup) content;
- CMNodeList children = cmGroup.getChildNodes();
- CMNode cmNode = null;
- for (int i = 0; i < children.getLength(); i++) {
- cmNode = children.item(i);
- contextString = cmNode.getNodeName();
- if (contextString != null) {
- info.append("<" + cmNode.getNodeName() + ">"); //$NON-NLS-1$ //$NON-NLS-2$
- if (i < children.getLength() - 1)
- info.append(" "); //$NON-NLS-1$
- }
- }
- }
- }
- if (!info.toString().trim().equals("")) //$NON-NLS-1$
- return new IContextInformation[]{new ContextInformation(contextString, info.toString())};
- else
- return EMPTY_CONTEXT_INFO;
- }
-
- /**
- * Returns sorted array of CMAttributeDeclarations.
- *
- * @param attributes
-
- */
- private CMAttributeDeclaration[] getSortedAttributes(CMNamedNodeMap attributes) {
- List sorted = new ArrayList();
- for (int i = 0; i < attributes.getLength(); i++)
- sorted.add(attributes.item(i));
- Collections.sort(sorted, getCMAttributeComparator());
- return (CMAttributeDeclaration[]) sorted.toArray(new CMAttributeDeclaration[sorted.size()]);
- }
-
- /**
- * @param sdRegion
-
- */
- private boolean isEndTag(IStructuredDocumentRegion sdRegion) {
- ITextRegionList regions = sdRegion.getRegions();
- return regions.get(0).getType() == DOMRegionContext.XML_END_TAG_OPEN;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContentAssistRequest.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContentAssistRequest.java
deleted file mode 100644
index f6a132853b..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContentAssistRequest.java
+++ /dev/null
@@ -1,269 +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.ui.internal.contentassist;
-
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.wst.sse.core.internal.util.StringUtils;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionCollection;
-import org.eclipse.wst.sse.ui.preferences.PreferenceManager;
-import org.w3c.dom.Node;
-
-
-public class ContentAssistRequest {
- protected IStructuredDocumentRegion documentRegion = null;
-
-
- protected PreferenceManager fPreferenceManager = null;
- protected List macros = new ArrayList();
- protected String matchString;
- protected Node node = null;
- protected Node parent = null;
- protected List proposals = new ArrayList();
- protected ITextRegion region = null;
- protected int replacementBeginPosition;
- protected int replacementLength;
-
- // private Boolean separate = null; // (pa) not used
- // private Boolean sort = null; // (pa) not used
- /**
- * XMLContentAssistRequest constructor comment.
- */
- public ContentAssistRequest(Node node, Node parent, IStructuredDocumentRegion documentRegion, ITextRegion completionRegion, int begin, int length, String filter, PreferenceManager preferencesManager) {
- super();
- setNode(node);
- setParent(parent);
- setDocumentRegion(documentRegion);
- setRegion(completionRegion);
- setMatchString(filter);
- setReplacementBeginPosition(begin);
- setReplacementLength(length);
- fPreferenceManager = preferencesManager;
- }
-
- public void addMacro(ICompletionProposal newProposal) {
- macros.add(newProposal);
- }
-
- public void addProposal(ICompletionProposal newProposal) {
- proposals.add(newProposal);
- }
-
- public ICompletionProposal[] getCompletionProposals() {
- ICompletionProposal results[] = null;
- if (getProposals().size() > 0 || getMacros().size() > 0) {
- List allProposals = new ArrayList();
- if (!shouldSeparate()) {
- allProposals.addAll(getProposals());
- // should be empty, as all macros should have gone into the
- // proposal list
- allProposals.addAll(getMacros());
- allProposals = sortProposals(allProposals);
- } else {
- allProposals.addAll(sortProposals(getProposals()));
- allProposals.addAll(sortProposals(getMacros()));
- }
-
- results = new ICompletionProposal[allProposals.size()];
- for (int i = 0; i < allProposals.size(); i++) {
- results[i] = (ICompletionProposal) allProposals.get(i);
- }
- }
- return results;
- }
-
- /**
- *
- * @return com.ibm.sed.structuredDocument.core.IStructuredDocumentRegion
- */
- public IStructuredDocumentRegion getDocumentRegion() {
- return documentRegion;
- }
-
- /**
- *
- * @return java.util.List
- */
- public java.util.List getMacros() {
- return macros;
- }
-
- /**
- *
- * @return java.lang.String
- */
- public java.lang.String getMatchString() {
- return matchString;
- }
-
- /**
- *
- * @return org.w3c.dom.Node
- */
- public org.w3c.dom.Node getNode() {
- return node;
- }
-
- /**
- *
- * @return org.w3c.dom.Node
- */
- public org.w3c.dom.Node getParent() {
- return parent;
- }
-
- /**
- *
- * @return java.util.List
- */
- public java.util.List getProposals() {
- return proposals;
- }
-
- /**
- *
- * @return com.ibm.sed.structuredDocument.core.ITextRegion
- */
- public ITextRegion getRegion() {
- return region;
- }
-
- /**
- *
- * @return int
- */
- public int getReplacementBeginPosition() {
- return replacementBeginPosition;
- }
-
- /**
- * @return int
- */
- public int getReplacementLength() {
- return replacementLength;
- }
-
- public int getStartOffset() {
- if (getDocumentRegion() != null && getRegion() != null)
- return ((ITextRegionCollection) getDocumentRegion()).getStartOffset(getRegion());
- return -1;
- }
-
- public String getText() {
- if (getDocumentRegion() != null && getRegion() != null)
- return ((ITextRegionCollection) getDocumentRegion()).getText(getRegion());
- return ""; //$NON-NLS-1$
- }
-
- public int getTextEndOffset() {
- if (getDocumentRegion() != null && getRegion() != null)
- return ((ITextRegionCollection) getDocumentRegion()).getTextEndOffset(getRegion());
- return -1;
- }
-
- /**
- * @param region
- */
- public void setDocumentRegion(IStructuredDocumentRegion region) {
- documentRegion = region;
- }
-
- /**
- *
- * @param newMatchString
- * java.lang.String
- */
- public void setMatchString(java.lang.String newMatchString) {
- matchString = newMatchString;
- }
-
- /**
- *
- * @param newNode
- * org.w3c.dom.Node
- */
- public void setNode(org.w3c.dom.Node newNode) {
- node = newNode;
- }
-
- /**
- *
- * @param newParent
- * org.w3c.dom.Node
- */
- public void setParent(org.w3c.dom.Node newParent) {
- parent = newParent;
- }
-
- /**
- *
- * @param newRegion
- * com.ibm.sed.structuredDocument.ITextRegion
- */
- public void setRegion(ITextRegion newRegion) {
- region = newRegion;
- }
-
- /**
- *
- * @param newReplacementBeginPosition
- * int
- */
- public void setReplacementBeginPosition(int newReplacementBeginPosition) {
- replacementBeginPosition = newReplacementBeginPosition;
- }
-
-
- public void setReplacementLength(int newReplacementLength) {
- replacementLength = newReplacementLength;
- }
-
- public boolean shouldSeparate() {
- /*
- * if (separate == null) { PreferenceManager manager =
- * getPreferenceManager(); if(manager == null) { separate =
- * Boolean.FALSE; } else { Element caSettings =
- * manager.getElement(PreferenceNames.CONTENT_ASSIST); separate = new
- * Boolean(caSettings.getAttribute(PreferenceNames.SEPARATE).equals(PreferenceNames.TRUE)); } }
- * return separate.booleanValue();
- */
- return false;
- }
-
- protected List sortProposals(List proposalsIn) {
- Collections.sort(proposalsIn, new ProposalComparator());
- return proposalsIn;
-
- }
-
- /**
- *
- * @return java.lang.String
- */
- public java.lang.String toString() {
- return "Node: " + getNode() //$NON-NLS-1$
- + "\nParent: " + getParent() //$NON-NLS-1$
- + "\nStructuredDocumentRegion: " + StringUtils.escape(getDocumentRegion().toString()) //$NON-NLS-1$
- + "\nRegion: " + getRegion() //$NON-NLS-1$
- + "\nMatch string: '" + StringUtils.escape(getMatchString()) + "'" //$NON-NLS-2$//$NON-NLS-1$
- + "\nOffsets: [" + getReplacementBeginPosition() + "-" + (getReplacementBeginPosition() + getReplacementLength()) + "]\n"; //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContextInfoModelUtil.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContextInfoModelUtil.java
deleted file mode 100644
index 583395d422..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContextInfoModelUtil.java
+++ /dev/null
@@ -1,65 +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.ui.internal.contentassist;
-
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.xml.core.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-
-
-/**
- * @author pavery
- */
-public class ContextInfoModelUtil {
- IStructuredDocument fDocument = null;
-
- ContextInfoModelUtil(IStructuredDocument doc) {
- fDocument = doc;
- }
-
- public IStructuredDocument getDocument() {
- return fDocument;
- }
-
- public ModelQuery getModelQuery() {
- ModelQuery mq = null;
-
- IStructuredModel xmlModel = null;
- try {
- xmlModel = StructuredModelManager.getModelManager().getExistingModelForRead(getDocument());
- mq = ModelQueryUtil.getModelQuery(xmlModel);
- }
- finally {
- if (xmlModel != null) {
- xmlModel.releaseFromRead();
- }
- }
- return mq;
- }
-
- public IDOMNode getXMLNode(int offset) {
- IStructuredModel xmlModel = null;
- IDOMNode xmlNode = null;
- try {
- xmlModel = StructuredModelManager.getModelManager().getExistingModelForRead(getDocument());
- xmlNode = (IDOMNode) xmlModel.getIndexedRegion(offset);
- }
- finally {
- xmlModel.releaseFromRead();
- }
- return xmlNode;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/CustomTemplateProposal.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/CustomTemplateProposal.java
deleted file mode 100644
index 79097c7289..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/CustomTemplateProposal.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.xml.ui.internal.contentassist;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.templates.Template;
-import org.eclipse.jface.text.templates.TemplateContext;
-import org.eclipse.jface.text.templates.TemplateProposal;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.core.internal.util.StringUtils;
-import org.eclipse.wst.sse.ui.internal.contentassist.IRelevanceCompletionProposal;
-
-/**
- * Purpose of this class is to make the additional proposal info into content
- * fit for an HTML viewer (by escaping characters)
- */
-class CustomTemplateProposal extends TemplateProposal implements IRelevanceCompletionProposal {
- // copies of this class exist in:
- // org.eclipse.jst.jsp.ui.internal.contentassist
- // org.eclipse.wst.html.ui.internal.contentassist
- // org.eclipse.wst.xml.ui.internal.contentassist
-
- public CustomTemplateProposal(Template template, TemplateContext context, IRegion region, Image image, int relevance) {
- super(template, context, region, image, relevance);
- }
-
- public String getAdditionalProposalInfo() {
- String additionalInfo = super.getAdditionalProposalInfo();
- return StringUtils.convertToHTMLContent(additionalInfo);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/NoRegionContentAssistProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/NoRegionContentAssistProcessor.java
deleted file mode 100644
index 5a7091103e..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/NoRegionContentAssistProcessor.java
+++ /dev/null
@@ -1,263 +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.ui.internal.contentassist;
-
-
-
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.ui.internal.IReleasable;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.sse.ui.internal.contentassist.IResourceDependentProcessor;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.core.text.IXMLPartitions;
-
-
-/**
- * ContentAssistProcessor to handle special cases in content assist where the
- * partitioner cannot determine a partition type at the current cursor
- * position (usually at EOF).
- *
- * @author pavery
- */
-public class NoRegionContentAssistProcessor implements IContentAssistProcessor, IResourceDependentProcessor, IReleasable {
-
- protected char completionProposalAutoActivationCharacters[] = null;
- protected char contextInformationAutoActivationCharacters[] = null;
-
- private final ICompletionProposal[] EMPTY_PROPOSAL_SET = new ICompletionProposal[0];
- protected String fErrorMessage = null;
- protected HashMap fNameToProcessorMap = null;
- protected HashMap fPartitionToProcessorMap = null;
- protected IResource fResource = null;
-
- public NoRegionContentAssistProcessor() {
- super();
- fPartitionToProcessorMap = new HashMap();
- fNameToProcessorMap = new HashMap();
- initNameToProcessorMap();
- initPartitionToProcessorMap();
-
- }
-
- /**
- * Figures out what the correct ICompletionProposalProcessor is and
- * computesCompletionProposals on that.
- *
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer,
- * int)
- */
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
- IContentAssistProcessor p = null;
- ICompletionProposal[] results = EMPTY_PROPOSAL_SET;
-
- p = guessContentAssistProcessor(viewer, documentOffset);
- if (p != null)
- results = p.computeCompletionProposals(viewer, documentOffset);
-
- return (results != null) ? results : EMPTY_PROPOSAL_SET;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer,
- * int)
- */
- public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
- // get context info from processor that we end up using...
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
- */
- public char[] getCompletionProposalAutoActivationCharacters() {
- return completionProposalAutoActivationCharacters;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters()
- */
- public char[] getContextInformationAutoActivationCharacters() {
- return contextInformationAutoActivationCharacters;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator()
- */
- public IContextInformationValidator getContextInformationValidator() {
- // return the validator for the content assist processor that we
- // used...
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage()
- */
- public String getErrorMessage() {
- return fErrorMessage;
- }
-
- /**
- * Gives you the document partition type (String) for the given
- * StructuredTextViewer and documentPosition.
- *
- * @param viewer
- * @param documentPosition
- * @return String
- */
- protected String getPartitionType(StructuredTextViewer viewer, int documentPosition) {
- IDocument document = viewer.getDocument();
- String partitionType = null;
- ITypedRegion partition = null;
- try {
- partition = document.getPartition(documentPosition);
- partitionType = partition.getType();
- } catch (BadLocationException e) {
- partitionType = null;
- }
- return partitionType;
- }
-
- /**
- * Guesses a ContentAssistProcessor based on the TextViewer and
- * documentOffset.
- *
- * @param viewer
- * @param documentOffset
- */
- protected IContentAssistProcessor guessContentAssistProcessor(ITextViewer viewer, int documentOffset) {
- // mapping logic here...
- // look @ previous region
- // look @ previous doc partition type
- // look @ page language
- IContentAssistProcessor p = null;
- IStructuredDocumentRegion sdRegion = ContentAssistUtils.getStructuredDocumentRegion((StructuredTextViewer) viewer, documentOffset);
- if (sdRegion != null) {
- String currentRegionType = sdRegion.getType();
- //System.out.println("current region type is >> " +
- // currentRegionType);
- if (currentRegionType == DOMRegionContext.UNDEFINED) {
- IStructuredDocumentRegion sdPrev = sdRegion.getPrevious();
- if (sdPrev != null) {
- String prevRegionType = sdPrev.getType();
- //System.out.println("previous region type is >> " +
- // prevRegionType);
- }
- }
- }
- // working w/ viewer & document partition
- if (p == null && viewer.getDocument().getLength() > 0) {
- String prevPartitionType = getPartitionType((StructuredTextViewer) viewer, documentOffset - 1);
- //System.out.println("previous partition type is > " +
- // prevPartitionType);
- p = (IContentAssistProcessor) fPartitionToProcessorMap.get(prevPartitionType);
- }
- return p;
- }
-
- /**
- * Necessary for certain content assist processors (such as
- * JSPJavaContentAssistProcessor). This gets set in
- * StructuredTextViewerConfiguration.
- *
- */
- public void initialize(IResource resource) {
- fResource = resource;
- setResourceOnProcessors(resource);
- }
-
- /**
- * Inits map for extra ContentAssistProcessors (useBean, get/setProperty)
- */
- protected void initNameToProcessorMap() {
- }
-
- /**
- * Adds all relevent ContentAssistProcessors to the partition to processor
- * map (just XML here)
- */
- protected void initPartitionToProcessorMap() {
- XMLContentAssistProcessor xmlProcessor = new XMLContentAssistProcessor();
- fPartitionToProcessorMap.put(IXMLPartitions.XML_DEFAULT, xmlProcessor);
- }
-
- public void release() {
- releasePartitionToProcessorMap();
- releaseNameToProcessorMap();
- }
-
- protected void releaseMap(HashMap map) {
- if (map != null && !map.isEmpty()) {
- Iterator it = map.keySet().iterator();
- Object key = null;
- while (it.hasNext()) {
- key = it.next();
- if (map.get(key) instanceof IReleasable)
- ((IReleasable) map.get(key)).release();
- }
- map.clear();
- map = null;
- }
- }
-
- protected void releaseNameToProcessorMap() {
- releaseMap(fNameToProcessorMap);
- }
-
- protected void releasePartitionToProcessorMap() {
- releaseMap(fPartitionToProcessorMap);
- }
-
- private void setResourceOnMap(IResource resource, HashMap map) {
- if (!map.isEmpty()) {
- Iterator keys = map.keySet().iterator();
- Object o = null;
- while (keys.hasNext()) {
- o = fPartitionToProcessorMap.get(keys.next());
- if (o instanceof IResourceDependentProcessor)
- ((IResourceDependentProcessor) o).initialize(resource);
- }
- }
- }
-
- /**
- * @param resource
- */
- private void setResourceOnProcessors(IResource resource) {
- setResourceOnMap(resource, fPartitionToProcessorMap);
- setResourceOnMap(resource, fNameToProcessorMap);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/NonValidatingModelQueryAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/NonValidatingModelQueryAction.java
deleted file mode 100644
index c124016d86..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/NonValidatingModelQueryAction.java
+++ /dev/null
@@ -1,159 +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.ui.internal.contentassist;
-
-
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-
-public class NonValidatingModelQueryAction implements org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction {
-
- protected CMNode cmnode = null;
- protected int endIndex = 0;
- protected int kind = INSERT;
- protected int startIndex = 0;
- protected Object userData = null;
-
- /**
- * NonValidatingModelQueryAction constructor comment.
- */
- protected NonValidatingModelQueryAction() {
- super();
- }
-
- /**
- * NonValidatingModelQueryAction constructor comment.
- */
- public NonValidatingModelQueryAction(CMNode newChild, int newKind, int newStart, int newEnd, Object newUserData) {
- super();
- cmnode = newChild;
- kind = newKind;
- startIndex = newStart;
- endIndex = newEnd;
- userData = newUserData;
- }
-
- /**
- * getCMNode method comment.
- */
- public org.eclipse.wst.xml.core.internal.contentmodel.CMNode getCMNode() {
- return cmnode;
- }
-
- /**
- *
- * @return int
- */
- public int getEndIndex() {
- return endIndex;
- }
-
- /**
- *
- * @return int
- */
- public int getKind() {
- return kind;
- }
-
- /**
- * getParent method comment.
- */
- public org.w3c.dom.Node getParent() {
- return null;
- }
-
- /**
- *
- * @return int
- */
- public int getStartIndex() {
- return startIndex;
- }
-
- /**
- * getUserData method comment.
- */
- public Object getUserData() {
- return null;
- }
-
- /**
- * performAction method comment.
- */
- public void performAction() {
- }
-
- /**
- * setCMNode method comment.
- */
- protected void setCMNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode newNode) {
- cmnode = newNode;
- }
-
- /**
- *
- * @param newEndIndex
- * int
- */
- protected void setEndIndex(int newEndIndex) {
- endIndex = newEndIndex;
- }
-
- /**
- *
- * @param newKind
- * int
- */
- protected void setKind(int newKind) {
- kind = newKind;
- }
-
- /**
- *
- * @param newStartIndex
- * int
- */
- protected void setStartIndex(int newStartIndex) {
- startIndex = newStartIndex;
- }
-
- /**
- * setUserData method comment.
- */
- public void setUserData(Object object) {
- }
-
- /**
- *
- * @return java.lang.String
- */
- public String toString() {
- String actionName = null;
- switch (kind) {
- case INSERT :
- actionName = "INSERT";//$NON-NLS-1$
- break;
- case REMOVE :
- actionName = "REMOVE";//$NON-NLS-1$
- break;
- case REPLACE :
- actionName = "REPLACE";//$NON-NLS-1$
- break;
- default :
- actionName = "UNKNOWN ACTION ";//$NON-NLS-1$
- }
- String nodeName = (cmnode != null) ? getCMNode().getNodeName() : "(unknown)";//$NON-NLS-1$
- return actionName + "=" + nodeName + "(" + startIndex + "..." + endIndex + ")";//$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ProposalComparator.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ProposalComparator.java
deleted file mode 100644
index 28356d3982..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ProposalComparator.java
+++ /dev/null
@@ -1,48 +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.ui.internal.contentassist;
-
-
-
-import java.util.Comparator;
-
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.wst.sse.ui.internal.contentassist.IRelevanceCompletionProposal;
-
-
-public class ProposalComparator implements Comparator {
-
-
- public int compare(Object o1, Object o2) {
- int relevance = 0;
- if (o1 instanceof IRelevanceCompletionProposal && o2 instanceof IRelevanceCompletionProposal) {
- // sort based on relevance
- IRelevanceCompletionProposal cp1 = (IRelevanceCompletionProposal) o1;
- IRelevanceCompletionProposal cp2 = (IRelevanceCompletionProposal) o2;
-
- relevance = cp2.getRelevance() - cp1.getRelevance();
-
- // if same relevance, secondary sort (lexigraphically)
- if (relevance == 0 && o1 instanceof ICompletionProposal && o2 instanceof ICompletionProposal) {
- String displayString1 = ((ICompletionProposal) o1).getDisplayString();
- String displayString2 = ((ICompletionProposal) o2).getDisplayString();
- if (displayString1 != null && displayString2 != null)
- //relevance = displayString1.compareTo(displayString2);
- // // this didn't mix caps w/ lowercase
- relevance = java.text.Collator.getInstance().compare(displayString1, displayString2);
- }
- }
- // otherwise if it's not ISEDRelevanceCompletionProposal, don't sort
- return relevance;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/SimpleCMElementDeclaration.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/SimpleCMElementDeclaration.java
deleted file mode 100644
index 137d6a6637..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/SimpleCMElementDeclaration.java
+++ /dev/null
@@ -1,170 +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.ui.internal.contentassist;
-
-
-
-public class SimpleCMElementDeclaration implements org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration {
-
- String fNodeName;
-
- /**
- * SimpleCMELementDeclaration constructor comment.
- */
- public SimpleCMElementDeclaration() {
- super();
- }
-
- public SimpleCMElementDeclaration(String nodeName) {
- super();
- setNodeName(nodeName);
- }
-
- /**
- * getAttributes method
- *
- * @return CMNamedNodeMap
- *
- * Returns CMNamedNodeMap of AttributeDeclaration
- */
- public org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap getAttributes() {
- return null;
- }
-
- /**
- * getCMContent method
- *
- * @return CMContent
- *
- * Returns the root node of this element's content model. This can be an
- * CMElementDeclaration or a CMGroup
- */
- public org.eclipse.wst.xml.core.internal.contentmodel.CMContent getContent() {
- return null;
- }
-
- /**
- * getContentType method
- *
- * @return int
- *
- * Returns one of : ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA.
- */
- public int getContentType() {
- return 0;
- }
-
- /**
- * getDataType method
- *
- * @return java.lang.String
- */
- public org.eclipse.wst.xml.core.internal.contentmodel.CMDataType getDataType() {
- return null;
- }
-
- /**
- * getElementName method
- *
- * @return java.lang.String
- */
- public String getElementName() {
- return null;
- }
-
- /**
- * getLocalElements method
- *
- * @return CMNamedNodeMap
- *
- * Returns a list of locally defined elements.
- */
- public org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap getLocalElements() {
- return null;
- }
-
- /**
- * getMaxOccur method
- *
- * @return int
- *
- * If -1, it's UNBOUNDED.
- */
- public int getMaxOccur() {
- return 0;
- }
-
- /**
- * getMinOccur method
- *
- * @return int
- *
- * If 0, it's OPTIONAL. If 1, it's REQUIRED.
- */
- public int getMinOccur() {
- return 0;
- }
-
- /**
- *
- * @return java.lang.String
- */
- public java.lang.String getNodeName() {
- return fNodeName;
- }
-
- /**
- * getNodeType method
- *
- * @return int
- *
- * Returns one of :
- *
- */
- public int getNodeType() {
- return 0;
- }
-
- /**
- * getProperty method
- *
- * @return java.lang.Object
- *
- * Returns the object property desciped by the propertyName
- *
- */
- public Object getProperty(String propertyName) {
- return null;
- }
-
- /**
- *
- * @param newNodeName
- * java.lang.String
- */
- public void setNodeName(java.lang.String newNodeName) {
- fNodeName = newNodeName;
- }
-
- /**
- * supports method
- *
- * @return boolean
- *
- * Returns true if the CMNode supports a specified property
- *
- */
- public boolean supports(String propertyName) {
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/SourceEditorImageHelper.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/SourceEditorImageHelper.java
deleted file mode 100644
index 3cbd6982cf..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/SourceEditorImageHelper.java
+++ /dev/null
@@ -1,48 +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.ui.internal.contentassist;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-
-/**
- * @deprecated use internal XMLEditorPluginImageHelper or external
- * SharedXMLEditorPluginImageHelper instead
- */
-public class SourceEditorImageHelper {
-
- public SourceEditorImageHelper() {
- super();
- }
-
- public Image createImage(String resource) {
- ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(XMLUIPlugin.ID, resource);
- Image image = desc.createImage();
- JFaceResources.getImageRegistry().put(resource, image);
- return image;
- }
-
- public Image getImage(String resource) {
- Image image = JFaceResources.getImageRegistry().get(resource);
- if (image == null) {
- image = createImage(resource);
- }
- return image;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistProcessor.java
deleted file mode 100644
index 8ae5c87b0e..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistProcessor.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.xml.core.document.IDOMNode;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.preferences.XMLUIPreferenceNames;
-import org.eclipse.wst.xml.ui.internal.templates.TemplateContextTypeIdsXML;
-
-public class XMLContentAssistProcessor extends AbstractContentAssistProcessor implements IPropertyChangeListener {
-
- protected IPreferenceStore fPreferenceStore = null;
- protected IResource fResource = null;
- private XMLTemplateCompletionProcessor fTemplateProcessor = null;
- private List fTemplateContexts = new ArrayList();
-
- public XMLContentAssistProcessor() {
- super();
- }
-
- protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest) {
- addTemplates(contentAssistRequest, TemplateContextTypeIdsXML.ATTRIBUTE);
- super.addAttributeNameProposals(contentAssistRequest);
- }
-
- protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
- addTemplates(contentAssistRequest, TemplateContextTypeIdsXML.ATTRIBUTE_VALUE);
- super.addAttributeValueProposals(contentAssistRequest);
- }
-
- protected void addEmptyDocumentProposals(ContentAssistRequest contentAssistRequest) {
- addTemplates(contentAssistRequest, TemplateContextTypeIdsXML.NEW);
- super.addEmptyDocumentProposals(contentAssistRequest);
- }
-
- protected void addTagInsertionProposals(ContentAssistRequest contentAssistRequest, int childPosition) {
- addTemplates(contentAssistRequest, TemplateContextTypeIdsXML.TAG);
- super.addTagInsertionProposals(contentAssistRequest, childPosition);
- }
-
- /**
- * Adds templates to the list of proposals
- *
- * @param contentAssistRequest
- * @param context
- */
- private void addTemplates(ContentAssistRequest contentAssistRequest, String context) {
- if (contentAssistRequest == null)
- return;
-
- // if already adding template proposals for a certain context type, do
- // not add again
- if (!fTemplateContexts.contains(context)) {
- fTemplateContexts.add(context);
- boolean useProposalList = !contentAssistRequest.shouldSeparate();
-
- if (getTemplateCompletionProcessor() != null) {
- getTemplateCompletionProcessor().setContextType(context);
- ICompletionProposal[] proposals = getTemplateCompletionProcessor().computeCompletionProposals(fTextViewer, contentAssistRequest.getReplacementBeginPosition());
- for (int i = 0; i < proposals.length; ++i) {
- if (useProposalList)
- contentAssistRequest.addProposal(proposals[i]);
- else
- contentAssistRequest.addMacro(proposals[i]);
- }
- }
- }
- }
-
- protected ContentAssistRequest computeCompletionProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode treeNode, IDOMNode xmlnode) {
- ContentAssistRequest request = super.computeCompletionProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- addTemplates(request, TemplateContextTypeIdsXML.ALL);
- return request;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.xml.ui.contentassist.AbstractContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int)
- */
- public ICompletionProposal[] computeCompletionProposals(ITextViewer textViewer, int documentPosition) {
- fTemplateContexts.clear();
- return super.computeCompletionProposals(textViewer, documentPosition);
- }
-
- protected IPreferenceStore getPreferenceStore() {
- if (fPreferenceStore == null)
- fPreferenceStore = XMLUIPlugin.getDefault().getPreferenceStore();
- return fPreferenceStore;
- }
-
- private XMLTemplateCompletionProcessor getTemplateCompletionProcessor() {
- if (fTemplateProcessor == null) {
- fTemplateProcessor = new XMLTemplateCompletionProcessor();
- }
- return fTemplateProcessor;
- }
-
- protected void init() {
- getPreferenceStore().addPropertyChangeListener(this);
- reinit();
- }
-
- public void propertyChange(PropertyChangeEvent event) {
- String property = event.getProperty();
-
- if (property.compareTo(XMLUIPreferenceNames.AUTO_PROPOSE) == 0 || property.compareTo(XMLUIPreferenceNames.AUTO_PROPOSE_CODE) == 0) {
- reinit();
- }
- }
-
- protected void reinit() {
- String key = XMLUIPreferenceNames.AUTO_PROPOSE;
- boolean doAuto = getPreferenceStore().getBoolean(key);
- if (doAuto) {
- key = XMLUIPreferenceNames.AUTO_PROPOSE_CODE;
- completionProposalAutoActivationCharacters = getPreferenceStore().getString(key).toCharArray();
- } else {
- completionProposalAutoActivationCharacters = null;
- }
- }
-
- public void release() {
- super.release();
- getPreferenceStore().removePropertyChangeListener(this);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistUtilities.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistUtilities.java
deleted file mode 100644
index a6b86f49f4..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistUtilities.java
+++ /dev/null
@@ -1,492 +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.ui.internal.contentassist;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.sse.core.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.util.ScriptLanguageKeys;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionContainer;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
-import org.eclipse.wst.xml.core.document.IDOMElement;
-import org.eclipse.wst.xml.core.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * @author pavery
- */
-public class XMLContentAssistUtilities extends ContentAssistUtils {
-
- /**
- * 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_DECLARATION_OPEN = "JSP_DECLARATION_OPEN"; //$NON-NLS-1$
- private static final String JSP_SCRIPTLET_OPEN = "JSP_SCRIPTLET_OPEN"; //$NON-NLS-1$
- private static final String JSP_EXPRESSION_OPEN = "JSP_EXPRESSION_OPEN"; //$NON-NLS-1$
-
- }
-
-
- public static final String CONTENT = "Content"; //$NON-NLS-1$
- public static final String CONTENT_SCRIPT_TYPE = "Content-Script-Type"; //$NON-NLS-1$
- public static final String HEAD = "HEAD"; //$NON-NLS-1$
- public static final String HTML = "HTML"; //$NON-NLS-1$
- public static final String HTTP_EQUIV = "HTTP-EQUIV"; //$NON-NLS-1$
- public static final String META = "META"; //$NON-NLS-1$
-
- /**
- * A convenience method for getting the closing proposal given the
- * contents (IndexedRegion) of a tag that is started, but possibly not
- * ended
- *
- * @param viewer
- * the text viewer
- * @param documentPosition
- * the cursor position in the viewer
- * @param indexedNode
- * the contents of the tag that is started but possibly not
- * ended
- * @param parentTagName
- * the tag on which you are checkin for an ending tag
- * @param imagePath
- * content assist image path in realation to com.ibm.sed.
- * structured. contentassist. xmlSourceEditorImageHelper
- * @return ICompletionProposal
- */
- public static ICompletionProposal computeJSPEndTagProposal(ITextViewer viewer, int documentPosition, IndexedRegion indexedNode, String parentTagName, String imagePath) {
- ICompletionProposal p = null;
-
- // check if tag is closed
- boolean hasEndTag = true;
- boolean isJSPTag = false;
- IDOMNode xnode = null;
- String tagName = ""; //$NON-NLS-1$
- if (indexedNode instanceof IDOMNode) {
- xnode = ((IDOMNode) indexedNode);
- // it's ended already...
- if (xnode.getEndStructuredDocumentRegion() != null)
- return null;
- IDOMNode openNode = null;
- if (!xnode.getNodeName().equalsIgnoreCase(parentTagName))
- openNode = (IDOMNode) xnode.getParentNode();
- if (openNode != null) {
- if (openNode instanceof IDOMElement) {
- isJSPTag = ((IDOMElement) openNode).isJSPTag();
- }
- tagName = openNode.getNodeName();
- hasEndTag = (openNode.getEndStructuredDocumentRegion() != null);
- }
- }
-
- // it's closed, don't add close tag proposal
- if (!hasEndTag && !isJSPTag) {
-
- // create appropriate close tag text
- String proposedText = proposedText = "</" + tagName; //$NON-NLS-1$
- String viewerText = viewer.getTextWidget().getText();
- if (viewerText.length() >= documentPosition && viewerText.length() >= 2 && documentPosition >= 2) {
- String last2chars = viewerText.substring(documentPosition - 2, documentPosition);
- if (last2chars.endsWith("</")) //$NON-NLS-1$
- proposedText = tagName;
- else if (last2chars.endsWith("<")) //$NON-NLS-1$
- proposedText = "/" + tagName; //$NON-NLS-1$
- }
-
- // create proposal
- p = new CustomCompletionProposal(proposedText + ">", //$NON-NLS-1$
- documentPosition, 0, proposedText.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(imagePath), //$NON-NLS-1$
- NLS.bind(XMLUIMessages.End_with_, (new Object[]{proposedText})),
- null, null, XMLRelevanceConstants.R_END_TAG);
- }
- else if (!hasEndTag && isJSPTag) {
-
- // create appropriate close tag text
- String proposedText = proposedText = "%"; //$NON-NLS-1$
- String viewerText = viewer.getTextWidget().getText();
-
- // TODO (pa) make it smarter to add "%>" or just ">" if % is
- // already there...
- if (viewerText.length() >= documentPosition && viewerText.length() >= 2) {
- String last2chars = viewerText.substring(documentPosition - 2, documentPosition);
- String lastchar = viewerText.substring(documentPosition - 1, documentPosition);
- if (lastchar.equals("%")) //$NON-NLS-1$
- {
- if (last2chars.endsWith("<%")) //$NON-NLS-1$
- proposedText = "%"; //$NON-NLS-1$
- else
- proposedText = ""; //$NON-NLS-1$
- }
- }
-
- // create proposal
- p = new CustomCompletionProposal(proposedText + ">", //$NON-NLS-1$
- documentPosition, 0, proposedText.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(imagePath), //$NON-NLS-1$
- NLS.bind(XMLUIMessages.End_with_, (new Object[]{proposedText})),
- null, null, XMLRelevanceConstants.R_END_TAG);
- }
-
- return p;
- }
-
-
- /**
- * A convenience method for getting the closing proposal given the
- * contents (IndexedRegion) of a tag that is started, but possibly not
- * ended
- *
- * @param viewer
- * the text viewer
- * @param documentPosition
- * the cursor position in the viewer
- * @param indexedNode
- * the contents of the tag that is started but possibly not
- * ended
- * @param parentTagName
- * the tag on which you are checkin for an ending tag
- * @param imagePath
- * content assist image path in realation to com.ibm.sed.
- * structured. contentassist. xmlSourceEditorImageHelper
- * @return ICompletionProposal
- */
- public static ICompletionProposal computeXMLEndTagProposal(ITextViewer viewer, int documentPosition, IndexedRegion indexedNode, String parentTagName, String imagePath) {
- ICompletionProposal p = null;
-
- // check if tag is closed
- boolean hasEndTag = true;
- IDOMNode xnode = null;
- String tagName = ""; //$NON-NLS-1$
- if (indexedNode instanceof IDOMNode) {
- xnode = ((IDOMNode) indexedNode);
- // it's ended already...
- if (xnode.getEndStructuredDocumentRegion() != null)
- return null;
- IDOMNode styleNode = null;
- if (!xnode.getNodeName().equalsIgnoreCase(parentTagName))
- styleNode = (IDOMNode) xnode.getParentNode();
- if (styleNode != null) {
- tagName = styleNode.getNodeName();
- hasEndTag = (styleNode.getEndStructuredDocumentRegion() != null);
- }
- }
-
- // it's closed, don't add close tag proposal
- if (!hasEndTag) {
-
- // create appropriate close tag text
- String proposedText = proposedText = "</" + tagName; //$NON-NLS-1$
- String viewerText = viewer.getTextWidget().getText();
- if (viewerText.length() >= documentPosition && viewerText.length() >= 2 && documentPosition >= 2) {
- String last2chars = viewerText.substring(documentPosition - 2, documentPosition);
- if (last2chars.endsWith("</")) //$NON-NLS-1$
- proposedText = tagName;
- else if (last2chars.endsWith("<")) //$NON-NLS-1$
- proposedText = "/" + tagName; //$NON-NLS-1$
- }
-
- // create proposal
- p = new CustomCompletionProposal(proposedText + ">", //$NON-NLS-1$
- documentPosition, 0, proposedText.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(imagePath), //$NON-NLS-1$
- NLS.bind(XMLUIMessages.End_with_, (new Object[]{proposedText})),
- null, null, XMLRelevanceConstants.R_END_TAG);
- }
- return p;
- }
-
- private static String getMetaScriptType(Document doc) {
- // Can not just do a Document.getElementsByTagName(String) as this
- // needs
- // to be relatively fast.
- List metas = new ArrayList();
- // check for META tags under the Document
- Node html = null;
- Node head = null;
- Node child = null;
- // ----------------------------------------------------------------------
- // (pa) 20021217
- // cmvc defect 235554
- // performance enhancement: using child.getNextSibling() rather than
- // nodeList(item) for O(n) vs. O(n*n)
- // ----------------------------------------------------------------------
-
- for (child = doc.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child.getNodeType() != Node.ELEMENT_NODE)
- continue;
- if (child.getNodeName().equalsIgnoreCase(META))
- metas.add(child);
- else if (child.getNodeName().equalsIgnoreCase(HTML))
- html = child;
- }
- // NodeList children = doc.getChildNodes();
- // for(int i = 0; i < children.getLength(); i++) {
- // child = children.item(i);
- // if(child.getNodeType() != Node.ELEMENT_NODE)
- // continue;
- // if(child.getNodeName().equalsIgnoreCase(META))
- // metas.add(child);
- // else if(child.getNodeName().equalsIgnoreCase(HTML))
- // html = child;
- // }
-
- // check for META tags under HEAD
- if (html != null) {
- for (child = html.getFirstChild(); child != null && head == null; child = child.getNextSibling()) {
- if (child.getNodeType() != Node.ELEMENT_NODE)
- continue;
- if (child.getNodeName().equalsIgnoreCase(HEAD))
- head = child;
- }
- // children = html.getChildNodes();
- // for(int i = 0; i < children.getLength() && head == null; i++) {
- // child = children.item(i);
- // if(child.getNodeType() != Node.ELEMENT_NODE)
- // continue;
- // if(child.getNodeName().equalsIgnoreCase(HEAD))
- // head = child;
- // }
- }
-
- if (head != null) {
- for (head.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child.getNodeType() != Node.ELEMENT_NODE)
- continue;
- if (child.getNodeName().equalsIgnoreCase(META))
- metas.add(child);
- }
- // children = head.getChildNodes();
- // for(int i = 0 ; i < children.getLength(); i++) {
- // child = children.item(i);
- // if(child.getNodeType() != Node.ELEMENT_NODE)
- // continue;
- // if(child.getNodeName().equalsIgnoreCase(META))
- // metas.add(child);
- // }
- }
-
- return getMetaScriptType(metas);
- }
-
- private static String getMetaScriptType(List metaNodeList) {
- Node meta = null;
- NamedNodeMap attributes = null;
- boolean httpEquiv = false;
- String contentScriptType = null;
-
- for (int i = metaNodeList.size() - 1; i >= 0; i--) {
- meta = (Node) metaNodeList.get(i);
- attributes = meta.getAttributes();
- httpEquiv = false;
- contentScriptType = null;
- for (int j = 0; j < attributes.getLength(); j++) {
- if (attributes.item(j).getNodeName().equalsIgnoreCase(HTTP_EQUIV)) {
- httpEquiv = attributes.item(j).getNodeValue().equalsIgnoreCase(CONTENT_SCRIPT_TYPE);
- }
- else if (attributes.item(j).getNodeName().equalsIgnoreCase(CONTENT)) {
- contentScriptType = attributes.item(j).getNodeValue();
- }
- }
- if (httpEquiv && contentScriptType != null)
- return contentScriptType;
- }
- return null;
- }
-
- /**
- * Returns the scripting language the scriptNode is in Currently returns
- * javascript unless some unknown type or language is specified. Then the
- * unknown type/language is returned
- *
- * @param scriptNode
- */
- public static String getScriptLanguage(Node scriptNode) {
- Node attr = null;
-
- boolean specified = false;
- // try to find a scripting adapter for 'type'
- if ((scriptNode == null) || (scriptNode.getAttributes() == null))
- return null;
-
- attr = scriptNode.getAttributes().getNamedItem("type");//$NON-NLS-1$
- if (attr != null) {
- specified = true;
- String type = attr.getNodeValue();
- return lookupScriptType(type);
- }
- // now try to find a scripting adapter for 'language' (deprecated by
- // HTML specifications)
- attr = scriptNode.getAttributes().getNamedItem("language");//$NON-NLS-1$
- if (attr != null) {
- specified = true;
- String language = attr.getNodeValue();
- return lookupScriptLanguage(language);
- }
- // check if one is specified by a META tag at the root level or inside
- // of HEAD
- String type = null;
- if (!specified)
- type = getMetaScriptType(scriptNode.getOwnerDocument());
- if (type != null) {
- specified = true;
- return lookupScriptType(type);
- }
- // return default
- if (!specified)
- return ScriptLanguageKeys.JAVASCRIPT;
- return null;
- }
-
- /**
- * Tells you if the flatnode is the %> delimiter
- *
- * 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".
- */
- public static boolean isJSPCloseDelimiter(IStructuredDocumentRegion fn) {
- if (fn == null)
- return false;
- return isJSPCloseDelimiter(fn.getType());
- }
-
- /**
- * 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".
- */
- public static boolean isJSPCloseDelimiter(String type) {
- if (type == null)
- return false;
- return (type.equals(DOMJSPRegionContextsPrivateCopy.JSP_CLOSE) || type.equals(DOMRegionContext.XML_TAG_CLOSE));
- }
-
- /**
- * Tells you if the flatnode is the JSP region <%%>, <%=%>, <%!%>
- *
- * 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".
- */
- public static boolean isJSPDelimiter(IStructuredDocumentRegion fn) {
- boolean isDelimiter = false;
- String type = fn.getType();
- if (type != null) {
- isDelimiter = isJSPDelimiter(type);
- }
- return isDelimiter;
- }
-
- /**
- * 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".
- */
- public static boolean isJSPDelimiter(String type) {
- if (type == null)
- return false;
- return (isJSPOpenDelimiter(type) || isJSPCloseDelimiter(type));
- }
-
- /**
- * Tells you if the flatnode is <%, <%=, or <%! 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".
- */
- public static boolean isJSPOpenDelimiter(IStructuredDocumentRegion fn) {
- if (fn == null)
- return false;
- return isJSPOpenDelimiter(fn.getType());
- }
-
- /**
- * 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".
- */
- public static boolean isJSPOpenDelimiter(String type) {
- if (type == null)
- return false;
- return (type.equals(DOMJSPRegionContextsPrivateCopy.JSP_SCRIPTLET_OPEN) || type.equals(DOMJSPRegionContextsPrivateCopy.JSP_DECLARATION_OPEN) || type.equals(DOMJSPRegionContextsPrivateCopy.JSP_EXPRESSION_OPEN));
- }
-
- /**
- * Tells you if the flatnode is the <jsp:scriptlet>, <jsp:expression>, or
- * <jsp:declaration>tag
- *
- * 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".
- */
- public static boolean isXMLJSPDelimiter(IStructuredDocumentRegion fn) {
- boolean isDelimiter = false;
- if (fn != null && fn instanceof ITextRegionContainer) {
- Object[] regions = ((ITextRegionContainer) fn).getRegions().toArray();
- ITextRegion temp = null;
- String regionText = ""; //$NON-NLS-1$
- for (int i = 0; i < regions.length; i++) {
- temp = (ITextRegion) regions[i];
- if (temp.getType() == DOMRegionContext.XML_TAG_NAME) {
- regionText = fn.getText(temp);
- if (regionText.equalsIgnoreCase("jsp:scriptlet") || regionText.equalsIgnoreCase("jsp:expression") || regionText.equalsIgnoreCase("jsp:declaration")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- isDelimiter = true;
- }
- }
- }
- return isDelimiter;
- }
-
- /**
- * Returns "javascript" if language attribute is some form of javascript,
- * "java" if language attribute is some form of java. Otherwise, just
- * returns type.
- *
- * @param language
- */
- public static String lookupScriptLanguage(String language) {
- for (int i = 0; i < ScriptLanguageKeys.JAVASCRIPT_LANGUAGE_KEYS.length; i++) {
- if (ScriptLanguageKeys.JAVASCRIPT_LANGUAGE_KEYS[i].equalsIgnoreCase(language))
- return ScriptLanguageKeys.JAVASCRIPT;
- }
- for (int i = 0; i < ScriptLanguageKeys.JAVA_LANGUAGE_KEYS.length; i++) {
- if (ScriptLanguageKeys.JAVA_LANGUAGE_KEYS[i].equalsIgnoreCase(language))
- return ScriptLanguageKeys.JAVA;
- }
- return language;
- }
-
- /**
- * Returns "javascript" if type (used in <script type="xxx"> is actually
- * javascript type. Otherwise, just returns type
- *
- * @param type
- */
- public static String lookupScriptType(String type) {
- for (int i = 0; i < ScriptLanguageKeys.JAVASCRIPT_MIME_TYPE_KEYS.length; i++)
- if (ScriptLanguageKeys.JAVASCRIPT_MIME_TYPE_KEYS[i].equalsIgnoreCase(type))
- return ScriptLanguageKeys.JAVASCRIPT;
- return type;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentModelGenerator.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentModelGenerator.java
deleted file mode 100644
index 71f835231b..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentModelGenerator.java
+++ /dev/null
@@ -1,135 +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.ui.internal.contentassist;
-
-
-
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.xml.core.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.w3c.dom.Node;
-
-
-public class XMLContentModelGenerator extends AbstractContentModelGenerator {
-
- /**
- * 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_DIRECTIVE_OPEN = "JSP_DIRECTIVE_OPEN"; //$NON-NLS-1$
- }
-
- /**
- * XMLContentModelGenerator constructor comment.
- */
- public XMLContentModelGenerator() {
- super();
- }
-
- public void generateAttribute(CMAttributeDeclaration attrDecl, StringBuffer buffer) {
- if (attrDecl == null || buffer == null)
- return;
- int usage = attrDecl.getUsage();
- if (usage == CMAttributeDeclaration.REQUIRED) {
- buffer.append(" "); //$NON-NLS-1$
- generateRequiredAttribute(null, attrDecl, buffer); // todo pass
- // ownerNode as
- // 1st param
- }
- return;
- }
-
- protected void generateEndTag(String tagName, Node parentNode, CMElementDeclaration elementDecl, StringBuffer buffer) {
- if (elementDecl == null)
- return;
- if (elementDecl.getContentType() != CMElementDeclaration.EMPTY)
- buffer.append("</" + tagName + ">");//$NON-NLS-2$//$NON-NLS-1$
- return;
- }
-
- public void generateRequiredAttribute(Node ownerNode, CMAttributeDeclaration attrDecl, StringBuffer buffer) {
- if (attrDecl == null || buffer == null)
- return;
-
- // attribute name
- String attributeName = getRequiredName(ownerNode, attrDecl);
- CMDataType attrType = attrDecl.getAttrType();
- // = sign
- buffer.append(attributeName + "=\""); //$NON-NLS-1$
- // attribute value
- if (attrType != null) {
- // insert any value that is implied
- if (attrType.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE && attrType.getImpliedValue() != null) {
- buffer.append(attrType.getImpliedValue());
- }
- // otherwise, if an enumerated list of values exists, use the
- // first value
- else if (attrType.getEnumeratedValues() != null && attrType.getEnumeratedValues().length > 0) {
- buffer.append(attrType.getEnumeratedValues()[0]);
- }
- }
- buffer.append("\""); //$NON-NLS-1$
- return;
- }
-
- protected void generateStartTag(String tagName, Node parentNode, CMElementDeclaration elementDecl, StringBuffer buffer) {
- if (elementDecl == null || buffer == null)
- return;
- buffer.append("<" + tagName);//$NON-NLS-1$
- generateAttributes(elementDecl, buffer);
- buffer.append(getStartTagClose(parentNode, elementDecl));
- return;
- }
-
- public int getMinimalStartTagLength(Node node, CMElementDeclaration elementDecl) {
- if (elementDecl == null)
- return 0;
- if (requiresAttributes(elementDecl)) {
- return getRequiredName(node, elementDecl).length() + 2; // < +
- // name +
- // space
- }
- else {
- return 1 + getRequiredName(node, elementDecl).length() + getStartTagClose(node, elementDecl).length(); // < +
- // name
- // +
- // appropriate
- // close
- }
- }
-
- protected String getOtherClose(Node notATagNode) {
- if (notATagNode instanceof IDOMNode) {
- IStructuredDocumentRegion node = ((IDOMNode) notATagNode).getStartStructuredDocumentRegion();
- if (node != null && node.getNumberOfRegions() > 1 && node.getRegions().get(0).getType().equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_OPEN)) {
- return "%>"; //$NON-NLS-1$
- }
- }
- return null;
- }
-
- public String getStartTagClose(Node parentNode, CMElementDeclaration elementDecl) {
- String other = getOtherClose(parentNode);
- if (other != null)
- return other;
- if (elementDecl == null)
- return ">";//$NON-NLS-1$
- if (elementDecl.getContentType() == CMElementDeclaration.EMPTY)
- return "/>"; //$NON-NLS-1$
- return ">"; //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLRelevanceConstants.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLRelevanceConstants.java
deleted file mode 100644
index 34896cea95..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLRelevanceConstants.java
+++ /dev/null
@@ -1,51 +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.ui.internal.contentassist;
-
-import org.eclipse.wst.sse.ui.internal.contentassist.IRelevanceConstants;
-
-
-
-/**
- * some relevance constants for content assist higher relevance means it shows
- * up higher on the list
- */
-public interface XMLRelevanceConstants extends IRelevanceConstants {
-
- int R_CDATA = 400;
- int R_CLOSE_TAG = 1500;
-
- int R_COMMENT = 100;
-
- // moved this above macros
- int R_DOCTYPE = 600;
- int R_END_TAG = 1400;
- int R_END_TAG_NAME = 1100;
- int R_ENTITY = 1000;
- int R_JSP = 500;
-
- int R_JSP_ATTRIBUTE_VALUE = 700;
-
- // (pa) make these the same relevance so proposals are same order for V501
- int R_MACRO = 500;
-
- // add this onto "required" attrs, elements, etc to bubble them up on
- // sorting...
- // CMVC 246618
- int R_REQUIRED = 10;
- int R_TAG_INSERTION = 500;
- int R_TAG_NAME = 1200;
- int R_XML_ATTRIBUTE_NAME = 900;
- int R_XML_ATTRIBUTE_VALUE = 800;
- int R_XML_DECLARATION = 1300;
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLTemplateCompletionProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLTemplateCompletionProcessor.java
deleted file mode 100644
index a789a47c45..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLTemplateCompletionProcessor.java
+++ /dev/null
@@ -1,80 +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.ui.internal.contentassist;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.templates.ContextTypeRegistry;
-import org.eclipse.jface.text.templates.Template;
-import org.eclipse.jface.text.templates.TemplateCompletionProcessor;
-import org.eclipse.jface.text.templates.TemplateContext;
-import org.eclipse.jface.text.templates.TemplateContextType;
-import org.eclipse.jface.text.templates.persistence.TemplateStore;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-
-
-/**
- * Completion processor for XML Templates. Most of the work is already done
- * by the XML Content Assist processor, so by the time the
- * XMLTemplateCompletionProcessor is asked for content assist proposals, the
- * XML content assist processor has already set the context type for
- * templates.
- */
-class XMLTemplateCompletionProcessor extends TemplateCompletionProcessor {
- private String fContextTypeId = null;
-
- protected ICompletionProposal createProposal(Template template, TemplateContext context, IRegion region, int relevance) {
- return new CustomTemplateProposal(template, context, region, getImage(template), relevance);
- }
-
- protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) {
- TemplateContextType type = null;
-
- ContextTypeRegistry registry = getTemplateContextRegistry();
- if (registry != null)
- type = registry.getContextType(fContextTypeId);
-
- return type;
- }
-
- protected Image getImage(Template template) {
- // just return the same image for now
- return XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_MACRO);
- }
-
- private ContextTypeRegistry getTemplateContextRegistry() {
- return XMLUIPlugin.getDefault().getTemplateContextRegistry();
- }
-
- protected Template[] getTemplates(String contextTypeId) {
- Template templates[] = null;
-
- TemplateStore store = getTemplateStore();
- if (store != null)
- templates = store.getTemplates(contextTypeId);
-
- return templates;
- }
-
- private TemplateStore getTemplateStore() {
- return XMLUIPlugin.getDefault().getTemplateStore();
- }
-
- void setContextType(String contextTypeId) {
- fContextTypeId = contextTypeId;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/BufferedOutlineUpdater.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/BufferedOutlineUpdater.java
deleted file mode 100644
index d9670cac1b..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/BufferedOutlineUpdater.java
+++ /dev/null
@@ -1,63 +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.ui.internal.contentoutline;
-
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.w3c.dom.Node;
-
-
-/**
- * Can handle multiple subsequent calls to processNode(..) by buffering them
- * w/ a RefreshOutlineJob. Only one refresh is performed (on the UI Thread) on the
- * minimal affected area of the tree at the end of the batch of updates (after
- * the last update is processed).
- *
- * @author pavery
- */
-public class BufferedOutlineUpdater {
-
- private RefreshOutlineJob fRefreshJob = null;
- private StructuredViewer fViewer = null;
-
- /**
- * @param structuredViewer
- * the viewer we are updating
- * @param node
- * the specific node that changed
- */
- public void processNode(final StructuredViewer structuredViewer, Node node) {
-
- // refresh on structural and "unknown" changes
- // it would be nice to not refresh the viewer if it's not visible
- // but only refresh when it's brought back to the front
- if (structuredViewer.getControl() != null) {
- if(getViewer() == null)
- setViewer(structuredViewer);
- getRefreshJob().refresh(node);
- }
- }
-
- private RefreshOutlineJob getRefreshJob() {
- if(fRefreshJob == null)
- fRefreshJob = new RefreshOutlineJob(getViewer());
- return fRefreshJob;
- }
-
- private StructuredViewer getViewer() {
- return fViewer;
- }
-
- private void setViewer(StructuredViewer viewer) {
- fViewer = viewer;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapter.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapter.java
deleted file mode 100644
index c3615de782..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapter.java
+++ /dev/null
@@ -1,344 +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.ui.internal.contentoutline;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.views.properties.PropertySheetPage;
-import org.eclipse.wst.sse.core.INodeAdapterFactory;
-import org.eclipse.wst.sse.core.INodeNotifier;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapterFactory;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManagerListener;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.editor.CMImageUtil;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-import org.w3c.dom.Node;
-
-/**
- * Adapts a DOM node to a JFace viewer.
- */
-public class JFaceNodeAdapter implements IJFaceNodeAdapter {
-
- public class CMDocumentManagerListenerImpl implements CMDocumentManagerListener {
-
- List beingRefreshed = Collections.synchronizedList(new ArrayList());
-
- public void cacheCleared(org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache cache) {
-
- }
-
- public void cacheUpdated(CMDocumentCache cache, final String uri, int oldStatus, int newStatus, CMDocument cmDocument) {
-
- if (newStatus == CMDocumentCache.STATUS_LOADED || newStatus == CMDocumentCache.STATUS_ERROR) {
- refreshViewers();
- }
- }
-
- private Display getDisplay() {
-
- return PlatformUI.getWorkbench().getDisplay();
- }
-
- public void propertyChanged(CMDocumentManager cmDocumentManager, String propertyName) {
-
- if (cmDocumentManager.getPropertyEnabled(CMDocumentManager.PROPERTY_AUTO_LOAD)) {
- refreshViewers();
- }
- }
-
- protected void refreshViewers() {
-
- // we're counting on getListers returning a "copy" of the
- // listeners, so we'll be thread safe.
- Collection listeners = ((IJFaceNodeAdapterFactory) adapterFactory).getListeners();
- Iterator iterator = listeners.iterator();
- while (iterator.hasNext()) {
- Object listener = iterator.next();
- // now that we use aynchExec, we ourselves have to gaurd
- // against
- // agains adding some refreshes when its already being
- // refreshed.
- if (listener instanceof PropertySheetPage && (!beingRefreshed.contains(listener))) {
- final PropertySheetPage propertySheetPage = (PropertySheetPage) listener;
- beingRefreshed.add(propertySheetPage);
- getDisplay().asyncExec(new Runnable() {
-
- public void run() {
-
- if (getDisplay().isDisposed()) {
- return;
- }
- if (propertySheetPage.getControl() != null && !propertySheetPage.getControl().isDisposed()) {
- propertySheetPage.refresh();
- beingRefreshed.remove(propertySheetPage);
- }
- }
- });
- }
- }
- }
- }
-
- final static Class ADAPTER_KEY = IJFaceNodeAdapter.class;
-
- // for debugging
- private static final boolean DEBUG;
- static {
- String value = Platform.getDebugOption("org.eclipse.wst.sse.ui/debug/outline"); //$NON-NLS-1$
- DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
- }
-
- protected INodeAdapterFactory adapterFactory;
- protected CMDocumentManagerListener cmDocumentManagerListener;
- private BufferedOutlineUpdater fUpdater = null;
-
- public JFaceNodeAdapter(INodeAdapterFactory adapterFactory) {
-
- super();
- this.adapterFactory = adapterFactory;
- }
-
- protected Image createImage(Object object) {
-
- Image image = null;
- Node node = (Node) object;
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_ELEMENT);
- break;
- }
- case Node.ATTRIBUTE_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_ATTRIBUTE);
- break;
- }
- case Node.TEXT_NODE : { // actually, TEXT should never be seen in
- // the tree
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_ELEMENT);
- break;
- }
- case Node.CDATA_SECTION_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_CDATASECTION);
- break;
- }
- case Node.ENTITY_REFERENCE_NODE :
- case Node.ENTITY_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_ENTITY);
- break;
- }
- case Node.PROCESSING_INSTRUCTION_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_PROCESSINGINSTRUCTION);
- break;
- }
- case Node.COMMENT_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_COMMENT);
- break;
- }
- case Node.DOCUMENT_TYPE_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_DOCTYPE);
- break;
- }
- case Node.NOTATION_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_NOTATION);
- break;
- }
- default : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_ELEMENT);
- break;
- }
- }
- return image;
- }
-
- protected Image createXMLImageDescriptor(String imageResourceName) {
- return XMLEditorPluginImageHelper.getInstance().getImage(imageResourceName);
- }
-
- public Object[] getChildren(Object object) {
-
- // (pa) 20021217
- // cmvc defect 235554
- // performance enhancement: using child.getNextSibling() rather than
- // nodeList(item) for O(n) vs. O(n*n)
- //
- Node node = (Node) object;
- ArrayList v = new ArrayList(node.getChildNodes().getLength());
- for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
- Node n = child;
- if (n.getNodeType() != Node.TEXT_NODE)
- v.add(n);
- }
- return v.toArray();
- }
-
- /**
- * Returns a CMDocumentManagerListener that can update JFace views when
- * notified of CMDocumentManager events
- */
- public org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManagerListener getCMDocumentManagerListener() {
-
- if (cmDocumentManagerListener == null)
- cmDocumentManagerListener = new CMDocumentManagerListenerImpl();
- return cmDocumentManagerListener;
- }
-
- Display getDisplay() {
-
- // Note: the workbench should always have a display
- // (unless running headless), whereas Display.getCurrent()
- // only returns the display if the currently executing thread
- // has one.
- if (PlatformUI.isWorkbenchRunning())
- return PlatformUI.getWorkbench().getDisplay();
- else
- return null;
- }
-
- /**
- * Returns an enumeration with the elements belonging to the passed
- * element. These are the top level items in a list, tree, table, etc...
- */
- public Object[] getElements(Object node) {
-
- return getChildren(node);
- }
-
- /**
- * Fetches the label image specific to this object instance.
- */
- public Image getLabelImage(Object node) {
-
- Image image = CMImageUtil.getImage(CMImageUtil.getDeclaration((Node) node));
- if (image == null && JFaceResources.getImageRegistry() != null) {
- ImageRegistry imageRegistry = JFaceResources.getImageRegistry();
- String nodeName = getNodeName(node);
- image = imageRegistry.get(nodeName);
- if (image == null) {
- image = createImage(node);
- if (image != null)
- imageRegistry.put(nodeName, image);
- }
- }
- return image;
- }
-
- /**
- * Fetches the label text specific to this object instance.
- */
- public String getLabelText(Object node) {
-
- return getNodeName(node);
- }
-
- private String getNodeName(Object object) {
-
- Node node = (Node) object;
- String nodeName = node.getNodeName();
- if (node.getNodeType() == Node.DOCUMENT_TYPE_NODE)
- nodeName = "DOCTYPE:" + nodeName; //$NON-NLS-1$
- return nodeName;
- }
-
- private BufferedOutlineUpdater getOutlineUpdater() {
- if (fUpdater == null)
- fUpdater = new BufferedOutlineUpdater();
- return fUpdater;
- }
-
- public Object getParent(Object object) {
-
- Node node = (Node) object;
- return node.getParentNode();
- }
-
- public boolean hasChildren(Object object) {
-
- // (pa) 20021217
- // cmvc defect 235554 > use child.getNextSibling() instead of
- // nodeList(item) for O(n) vs. O(n*n)
- Node node = (Node) object;
- for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child.getNodeType() != Node.TEXT_NODE)
- return true;
- }
- return false;
- }
-
- /**
- * Allowing the INodeAdapter to compare itself against the type allows it
- * to return true in more than one case.
- */
- public boolean isAdapterForType(Object type) {
-
- return type.equals(ADAPTER_KEY);
- }
-
- /**
- * Called by the object being adapter (the notifier) when something has
- * changed.
- */
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
-
- // future_TODO: the 'uijobs' used in this method were added to solve
- // threading problems when the dom
- // is updated in the background while the editor is open. They may be
- // a bit overkill and not that useful.
- // (That is, may be be worthy of job manager management). If they are
- // found to be important enough to leave in,
- // there's probably some optimization that can be done.
- Collection listeners = ((JFaceNodeAdapterFactory) adapterFactory).getListeners();
- Iterator iterator = listeners.iterator();
-
- while (iterator.hasNext()) {
- Object listener = iterator.next();
- if (notifier instanceof Node && (listener instanceof StructuredViewer) && (eventType == INodeNotifier.STRUCTURE_CHANGED || (eventType == INodeNotifier.CHANGE && changedFeature == null))) {
-
- if (DEBUG)
- System.out.println("JFaceNodeAdapter notified on event type > " + eventType); //$NON-NLS-1$
-
- // refresh on structural and "unknown" changes
- StructuredViewer structuredViewer = (StructuredViewer) listener;
- // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=5230
- if (structuredViewer.getControl() != null /*
- * &&
- * structuredViewer.getControl().isVisible()
- */)
- getOutlineUpdater().processNode(structuredViewer, (Node) notifier);
- } else if ((listener instanceof PropertySheetPage) && ((eventType == INodeNotifier.CHANGE) || (eventType == INodeNotifier.STRUCTURE_CHANGED))) {
- PropertySheetPage propertySheetPage = (PropertySheetPage) listener;
- if (propertySheetPage.getControl() != null /*
- * &&
- * !propertySheetPage.getControl().isDisposed()
- */) {
- RefreshPropertySheetJob refreshPropertySheetJob = new RefreshPropertySheetJob(getDisplay(), XMLUIMessages.JFaceNodeAdapter_1, propertySheetPage); //$NON-NLS-1$
- refreshPropertySheetJob.schedule();
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapterFactory.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapterFactory.java
deleted file mode 100644
index d2ac99a98f..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapterFactory.java
+++ /dev/null
@@ -1,104 +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.ui.internal.contentoutline;
-
-
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.wst.sse.core.AbstractAdapterFactory;
-import org.eclipse.wst.sse.core.INodeAdapterFactory;
-import org.eclipse.wst.sse.core.INodeAdapter;
-import org.eclipse.wst.sse.core.INodeNotifier;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapterFactory;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter;
-
-
-/**
- * An adapter factory to create JFaceNodeAdapters. Use this adapter factory
- * with a JFaceAdapterContentProvider to display DOM nodes in a tree.
- */
-public class JFaceNodeAdapterFactory extends AbstractAdapterFactory implements IJFaceNodeAdapterFactory {
- protected CMDocumentManager cmDocumentManager;
- /**
- * This keeps track of all the listeners.
- */
- protected ArrayList fListeners = new ArrayList();
-
- protected INodeAdapter singletonAdapter;
-
- public JFaceNodeAdapterFactory() {
- this(IJFaceNodeAdapter.class, true);
- }
-
- public JFaceNodeAdapterFactory(Object adapterKey, boolean registerAdapters) {
- super(adapterKey, registerAdapters);
- }
-
- public synchronized void addListener(Object listener) {
- fListeners.add(listener);
- }
-
- public INodeAdapterFactory copy() {
-
- return new JFaceNodeAdapterFactory(this.adapterKey, this.shouldRegisterAdapter);
- }
-
- /**
- * Create a new JFace adapter for the DOM node passed in
- */
- protected INodeAdapter createAdapter(INodeNotifier node) {
- if (singletonAdapter == null) {
- // create the JFaceNodeAdapter
- singletonAdapter = new JFaceNodeAdapter(this);
- initAdapter(singletonAdapter, node);
- }
- return singletonAdapter;
- }
-
- /**
- * returns "copy" so no one can modify our list. Its is a shallow copy.
- */
- public synchronized Collection getListeners() {
- return (Collection) fListeners.clone();
- }
-
- protected void initAdapter(INodeAdapter adapter, INodeNotifier node) {
- // register for CMDocumentManager events
- if (((JFaceNodeAdapter) adapter).getCMDocumentManagerListener() != null) {
- ModelQueryAdapter mqadapter = (ModelQueryAdapter) node.getAdapterFor(ModelQueryAdapter.class);
- if (mqadapter != null) {
- ModelQuery mquery = mqadapter.getModelQuery();
- if (mquery != null && mquery.getCMDocumentManager() != null) {
- cmDocumentManager = mquery.getCMDocumentManager();
- cmDocumentManager.addListener(((JFaceNodeAdapter) adapter).getCMDocumentManagerListener());
- }
- }
- }
- }
-
- public void release() {
- // deregister from CMDocumentManager events
- if (cmDocumentManager != null && singletonAdapter != null && ((JFaceNodeAdapter) singletonAdapter).getCMDocumentManagerListener() != null) {
- cmDocumentManager.removeListener(((JFaceNodeAdapter) singletonAdapter).getCMDocumentManagerListener());
- }
- }
-
- public synchronized void removeListener(Object listener) {
- fListeners.remove(listener);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeContentProvider.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeContentProvider.java
deleted file mode 100644
index 67a7161f7e..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeContentProvider.java
+++ /dev/null
@@ -1,104 +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.ui.internal.contentoutline;
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.wst.sse.core.INodeAdapterFactory;
-import org.eclipse.wst.sse.core.INodeAdapter;
-import org.eclipse.wst.sse.core.INodeNotifier;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
-import org.eclipse.wst.xml.core.document.IDOMModel;
-
-
-/**
- * An ITreeContentProvider for a TreeViewers used to display DOM nodes. This
- * content provider takes an adapter factory to create JFace adapters for the
- * nodes in the tree.
- */
-public class JFaceNodeContentProvider implements ITreeContentProvider {
- protected INodeAdapterFactory adapterFactory;
-
- public JFaceNodeContentProvider(INodeAdapterFactory jfaceAdapterFactory) {
- super();
- this.adapterFactory = jfaceAdapterFactory;
- }
-
- /**
- * The visual part that is using this content provider is about to be
- * disposed. Deallocate all allocated SWT resources.
- */
- public void dispose() {
- }
-
- /**
- * Returns the JFace adapter for the specified object.
- *
- * @return com.ibm.sed.view.tree.DOMJFaceAdapter The JFace adapter
- * @param adaptable
- * java.lang.Object The object to get the adapter for
- */
- protected IJFaceNodeAdapter getAdapter(Object adaptable) {
- if (adaptable instanceof INodeNotifier) {
- INodeAdapter adapter = adapterFactory.adapt((INodeNotifier) adaptable);
- if (adapter instanceof IJFaceNodeAdapter)
- return (IJFaceNodeAdapter) adapter;
- }
- return null;
- }
-
- public Object[] getChildren(Object object) {
- IJFaceNodeAdapter adapter = getAdapter(object);
-
- if (adapter != null)
- return adapter.getChildren(object);
-
- return new Object[0];
- }
-
- public Object[] getElements(Object object) {
- // The root is usually an instance of an XMLStructuredModel in
- // which case we want to extract the document.
- Object topNode = object;
- if (object instanceof IDOMModel)
- topNode = ((IDOMModel) object).getDocument();
-
- IJFaceNodeAdapter adapter = getAdapter(topNode);
-
- if (adapter != null)
- return adapter.getElements(topNode);
-
- return new Object[0];
- }
-
- public Object getParent(Object object) {
- IJFaceNodeAdapter adapter = getAdapter(object);
-
- if (adapter != null)
- return adapter.getParent(object);
-
- return null;
- }
-
- public boolean hasChildren(Object object) {
- IJFaceNodeAdapter adapter = getAdapter(object);
-
- if (adapter != null)
- return adapter.hasChildren(object);
-
- return false;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeLabelProvider.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeLabelProvider.java
deleted file mode 100644
index 5bcca4c6d4..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeLabelProvider.java
+++ /dev/null
@@ -1,136 +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.ui.internal.contentoutline;
-
-
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.core.INodeAdapterFactory;
-import org.eclipse.wst.sse.core.INodeNotifier;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
-
-
-/**
- * A class that uses a JFaceNodeAdapterFactory to provide adapters to provide
- * the labels and images for DOM nodes.
- */
-public class JFaceNodeLabelProvider implements ILabelProvider {
-
- protected INodeAdapterFactory adapterFactory;
-
- /**
- * JFaceNodeLabelProvider constructor comment.
- */
- public JFaceNodeLabelProvider(INodeAdapterFactory adapterFactory) {
- super();
- this.adapterFactory = adapterFactory;
- }
-
- /**
- * Adds a listener to the label provider. A label provider should inform
- * its listener about state changes that enforces rendering of the visual
- * part that uses this label provider.
- */
- public void addListener(ILabelProviderListener listener) {
- // The label provider state never changes so we do not have
- // to implement this method.
- }
-
- /**
- * The visual part that is using this label provider is about to be
- * disposed. Deallocate all allocated SWT resources.
- */
- public void dispose() {
- // Nothing to dispose
- }
-
- /**
- * Returns the JFace adapter for the specified object.
- *
- * @return com.ibm.sed.view.tree.DOMJFaceAdapter The JFace adapter
- * @param adaptable
- * java.lang.Object The object to get the adapter for
- */
- protected IJFaceNodeAdapter getAdapter(Object adaptable) {
- return (IJFaceNodeAdapter) adapterFactory.adapt((INodeNotifier) adaptable);
- }
-
- /**
- * Returns the image for the label of the given element, for use in the
- * given viewer.
- *
- * @param element
- * The element for which to provide the label image. Element
- * can be <code>null</code> indicating no input object is set
- * to the viewer.
- */
- public Image getImage(Object element) {
- return getAdapter(element).getLabelImage(element);
- }
-
- /**
- * Returns the text for the label of the given element, for use in the
- * given viewer.
- *
- * @param element
- * The element for which to provide the label text. Element can
- * be <code>null</code> indicating no input object is set to
- * the viewer.
- */
- public java.lang.String getText(Object element) {
- // This was returning null, on occasion ... probably should not be,
- // but
- // took the quick and easy way out for now. (dmw 3/8/01)
- String result = getAdapter(element).getLabelText(element);
- if (result == null)
- result = "";//$NON-NLS-1$
- return result;
- }
-
- /**
- * Checks whether this label provider is affected by the given domain
- * event.
- */
- public boolean isAffected(Object dummy) {//DomainEvent event) {
- //return event.isModifier(DomainEvent.NON_STRUCTURE_CHANGE);
- return true;
-
- }
-
- /**
- * Returns whether the label would be affected by a change to the given
- * property of the given element. This can be used to optimize a
- * non-structural viewer update. If the property mentioned in the update
- * does not affect the label, then the viewer need not update the label.
- *
- * @param element
- * the element
- * @param property
- * the property
- * @return <code>true</code> if the label would be affected, and
- * <code>false</code> if it would be unaffected
- */
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- /**
- * Removes a listener from the label provider.
- */
- public void removeListener(ILabelProviderListener listener) {
- // The label provider state never changes so we do not have
- // to implement this method.
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshOutlineJob.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshOutlineJob.java
deleted file mode 100644
index da47a04fef..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshOutlineJob.java
+++ /dev/null
@@ -1,189 +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.ui.internal.contentoutline;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-/**
- * This job holds a queue of updates (affected nodes) for the outline.
- * When a new request comes in, the current run is canceled, the new
- * request is added to the queue, then the job is re-scheduled.
- *
- * @author pavery
- */
-public class RefreshOutlineJob extends Job {
-
- private static final long UPDATE_DELAY = 200;
- /** List of refresh requests (Nodes)*/
- private final List fRequests;
- /** the tree viewer */
- private final StructuredViewer fViewer;
- /** debug flag */
- private static final boolean DEBUG;
- static {
- String value = Platform.getDebugOption("org.eclipse.wst.sse.ui/debug/outline"); //$NON-NLS-1$
- DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
- }
-
- public RefreshOutlineJob(StructuredViewer viewer) {
- super(XMLUIMessages.refreshoutline_0); //$NON-NLS-1$
- setPriority(Job.LONG);
- setSystem(true);
- fRequests = new ArrayList(1);
- fViewer = viewer;
- }
- private synchronized void addRequest(Node node) {
-
- // if we already have a request which contains the new request,
- // discare the new request
- int size = fRequests.size();
- for (int i=0; i<size; i++) {
- if(contains((Node)fRequests.get(i), node))
- return;
- }
- // if new request is contains any existing requests,
- // remove those
- for (Iterator it = fRequests.iterator(); it.hasNext();) {
- if(contains(node, (Node)it.next()))
- it.remove();
- }
- fRequests.add(node);
- }
- /**
- * This method also synchronized because it accesses the fRequests queue
- * @return an array of the currently requested Nodes to refresh
- */
- private synchronized Node[] getRequests() {
-
- Node[] toRefresh = (Node[]) fRequests.toArray(new Node[fRequests.size()]);
- fRequests.clear();
- return toRefresh;
- }
-
- /**
- * Invoke a refresh on the viewer on the given node.
- * @param node
- */
- public void refresh(Node node) {
-
- if (node == null)
- return;
-
- cancel();
- addRequest(node);
- schedule(UPDATE_DELAY);
- }
-
- /**
- * @return if the root is parent of possible, return true, otherwise
- * return false
- */
- private boolean contains(Node root, Node possible) {
-
- if (DEBUG) {
- System.out.println("=============================================================================================================="); //$NON-NLS-1$
- System.out.println("recursive call w/ root: " + root.getNodeName() + " and possible: " + possible); //$NON-NLS-1$ //$NON-NLS-2$
- System.out.println("--------------------------------------------------------------------------------------------------------------"); //$NON-NLS-1$
- }
-
- // the following checks are important
- // #document node will break the algorithm otherwise
-
- // can't contain the parent if it's null
- if (root == null) {
- if (DEBUG) System.out.println("returning false: root is null"); //$NON-NLS-1$
- return false;
- }
- // nothing can be parent of Document node
- if (possible instanceof Document) {
- if (DEBUG) System.out.println("returning false: possible is Document node"); //$NON-NLS-1$
- return false;
- }
- // document contains everything
- if(root instanceof Document) {
- if (DEBUG) System.out.println("returning true: root is Document node"); //$NON-NLS-1$
- return true;
- }
-
- // depth first
- Node current = root;
- // loop siblings
- while (current != null) {
- if (DEBUG) System.out.println(" -> iterating sibling (" + current.getNodeName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- // found it
- if (possible.equals(current)) {
- if (DEBUG) System.out.println(" !!! found: " + possible.getNodeName() + " in subtree for: " + root.getNodeName()); //$NON-NLS-1$ //$NON-NLS-2$
- return true;
- }
- // drop one level deeper if necessary
- if (current.getFirstChild() != null) {
- return contains(current.getFirstChild(), possible);
- }
- current = current.getNextSibling();
- }
- // never found it
- return false;
- }
-
- protected IStatus run(IProgressMonitor monitor) {
- IStatus status = Status.OK_STATUS;
- try {
- Node[] toRefresh = getRequests();
- for (int i = 0; i < toRefresh.length; i++) {
- if (monitor.isCanceled())
- throw new OperationCanceledException();
- doRefresh(toRefresh[i]);
- }
- }
- finally {
- monitor.done();
- }
- return status;
- }
-
- /**
- * Refresh must be on UI thread because it's on a SWT widget.
- * @param node
- */
- private void doRefresh(final Node node) {
- final Display display = PlatformUI.getWorkbench().getDisplay();
- display.asyncExec(new Runnable() {
- public void run() {
-
- if(DEBUG)
- System.out.println("refresh on: [" +node.getNodeName()+ "]"); //$NON-NLS-1$ //$NON-NLS-2$
-
- if(node instanceof Document)
- fViewer.refresh();
- else
- fViewer.refresh(node);
- }
- });
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshPropertySheetJob.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshPropertySheetJob.java
deleted file mode 100644
index d6aabb5676..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshPropertySheetJob.java
+++ /dev/null
@@ -1,62 +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.ui.internal.contentoutline;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.progress.UIJob;
-import org.eclipse.ui.views.properties.PropertySheetPage;
-
-
-public class RefreshPropertySheetJob extends UIJob {
-
-
- private PropertySheetPage fPropertySheetPage;
-
- /**
- * @param jobDisplay
- * @param name
- */
- public RefreshPropertySheetJob(Display jobDisplay, String name, PropertySheetPage propertySheetPage) {
- super(jobDisplay, name);
- setPriority(Job.SHORT);
- fPropertySheetPage = propertySheetPage;
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus runInUIThread(IProgressMonitor monitor) {
- IStatus result = Status.OK_STATUS;
- try {
- Control control = fPropertySheetPage.getControl();
- // we should have check before even scheduling this, but even if
- // ok then, need to check again, right before executing.
- if (control != null && !control.isDisposed()) {
- fPropertySheetPage.refresh();
- }
- } catch (Exception e) {
- result = errorStatus(e);
- } finally {
- monitor.done();
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/XMLNodeActionManager.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/XMLNodeActionManager.java
deleted file mode 100644
index 9626c19b57..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/XMLNodeActionManager.java
+++ /dev/null
@@ -1,52 +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.ui.internal.contentoutline;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML;
-import org.eclipse.wst.xml.ui.actions.AbstractNodeActionManager;
-import org.w3c.dom.Node;
-
-
-public class XMLNodeActionManager extends AbstractNodeActionManager {
- public XMLNodeActionManager(IStructuredModel model, Viewer viewer) {
- super(model, ModelQueryUtil.getModelQuery(model), viewer);
- }
-
- public void reformat(Node newElement, boolean deep) {
- try {
- // tell the model that we are about to make a big model change
- model.aboutToChangeModel();
-
- // format selected node
- IStructuredFormatProcessor formatProcessor = new FormatProcessorXML();
- formatProcessor.formatNode(newElement);
- } finally {
- // tell the model that we are done with the big model change
- model.changedModel();
- }
- }
-
- public void setModel(IStructuredModel newModel) {
- model = newModel;
- setModelQuery(ModelQueryUtil.getModelQuery(newModel));
- }
-
- protected void setModelQuery(ModelQuery newModelQuery) {
- modelQuery = newModelQuery;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/CorrectionProcessorXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/CorrectionProcessorXML.java
deleted file mode 100644
index bfb47cb15d..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/CorrectionProcessorXML.java
+++ /dev/null
@@ -1,42 +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.ui.internal.correction;
-
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.ui.internal.correction.IQuickAssistProcessor;
-import org.eclipse.wst.sse.ui.internal.correction.IQuickFixProcessor;
-import org.eclipse.wst.sse.ui.internal.correction.StructuredCorrectionProcessor;
-
-
-public class CorrectionProcessorXML extends StructuredCorrectionProcessor {
- protected IQuickAssistProcessor fQuickAssistProcessor;
- protected IQuickFixProcessor fQuickFixProcessor;
-
- public CorrectionProcessorXML(ITextEditor editor) {
- super(editor);
- }
-
- protected IQuickAssistProcessor getQuickAssistProcessor() {
- if (fQuickAssistProcessor == null)
- fQuickAssistProcessor = new QuickAssistProcessorXML();
-
- return fQuickAssistProcessor;
- }
-
- protected IQuickFixProcessor getQuickFixProcessor() {
- if (fQuickFixProcessor == null)
- fQuickFixProcessor = new QuickFixProcessorXML();
-
- return fQuickFixProcessor;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/InsertRequiredAttrsQuickAssistProposal.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/InsertRequiredAttrsQuickAssistProposal.java
deleted file mode 100644
index 10b8cb7f30..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/InsertRequiredAttrsQuickAssistProposal.java
+++ /dev/null
@@ -1,174 +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.ui.internal.correction;
-
-import java.util.List;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.text.edits.InsertEdit;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.xml.core.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-
-public class InsertRequiredAttrsQuickAssistProposal implements ICompletionProposal, ICompletionProposalExtension2 {
- private final List fRequiredAttrs;
-
- /**
- * @param requiredAttrs
- */
- public InsertRequiredAttrsQuickAssistProposal(List requiredAttrs) {
- fRequiredAttrs = requiredAttrs;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
- */
- public void apply(IDocument document) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer,
- * char, int, int)
- */
- public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
- IDOMNode node = (IDOMNode) ContentAssistUtils.getNodeAt((StructuredTextViewer) viewer, offset);
- IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
- int index = startStructuredDocumentRegion.getEndOffset();
- ITextRegion lastRegion = startStructuredDocumentRegion.getLastRegion();
- if (lastRegion.getType() == DOMRegionContext.XML_TAG_CLOSE) {
- index--;
- lastRegion = startStructuredDocumentRegion.getRegionAtCharacterOffset(index - 1);
- } else if (lastRegion.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
- index = index - 2;
- lastRegion = startStructuredDocumentRegion.getRegionAtCharacterOffset(index - 1);
- }
- MultiTextEdit multiTextEdit = new MultiTextEdit();
- try {
- for (int i = 0; i < fRequiredAttrs.size(); i++) {
- CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) fRequiredAttrs.get(i);
- String requiredAttributeName = attrDecl.getAttrName();
- String defaultValue = attrDecl.getDefaultValue();
- if (defaultValue == null)
- defaultValue = ""; //$NON-NLS-1$
- String nameAndDefaultValue = " "; //$NON-NLS-1$
- if (i == 0 && lastRegion.getLength() > lastRegion.getTextLength())
- nameAndDefaultValue = ""; //$NON-NLS-1$
- nameAndDefaultValue += requiredAttributeName + "=\"" + defaultValue + "\""; //$NON-NLS-1$//$NON-NLS-2$
- multiTextEdit.addChild(new InsertEdit(index, nameAndDefaultValue));
- // BUG3381: MultiTextEdit applies all child TextEdit's basing
- // on offsets
- // in the document before the first TextEdit, not after each
- // child TextEdit. Therefore, do not need to advance the
- // index.
- //index += nameAndDefaultValue.length();
- }
- multiTextEdit.apply(viewer.getDocument());
- } catch (BadLocationException e) {
- throw new SourceEditingRuntimeException(e);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
- */
- public String getAdditionalProposalInfo() {
- return XMLUIMessages.InsertRequiredAttrsQuickAssistProposal_0; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
- */
- public IContextInformation getContextInformation() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
- */
- public String getDisplayString() {
- return XMLUIMessages.InsertRequiredAttrsQuickAssistProposal_1; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
- */
- public Image getImage() {
- // return JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL);
- return XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ADD_CORRECTION);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
- */
- public Point getSelection(IDocument document) {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#selected(org.eclipse.jface.text.ITextViewer,
- * boolean)
- */
- public void selected(ITextViewer viewer, boolean smartToggle) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#unselected(org.eclipse.jface.text.ITextViewer)
- */
- public void unselected(ITextViewer viewer) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#validate(org.eclipse.jface.text.IDocument,
- * int, org.eclipse.jface.text.DocumentEvent)
- */
- public boolean validate(IDocument document, int offset, DocumentEvent event) {
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/ProblemIDsXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/ProblemIDsXML.java
deleted file mode 100644
index 4d0008bb7a..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/ProblemIDsXML.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.correction;
-
-public interface ProblemIDsXML {
- int AttrsInEndTag = 3;
- int AttrValueNotQuoted = 13;
- int EmptyTag = 1;
- int InvalidAttrValue = 11;
- int MissingAttrValue = 4;
- int MissingClosingBracket = 14;
- int MissingEndTag = 2;
- int MissingRequiredAttr = 12;
- int NamespaceInPI = 8;
- int NoAttrValue = 5;
- int SpacesBeforePI = 7;
- int SpacesBeforeTagName = 6;
- int Unclassified = 0;
- int UnknownAttr = 10;
- int UnknownElement = 9;
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickAssistProcessorXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickAssistProcessorXML.java
deleted file mode 100644
index e93c2e7fd3..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickAssistProcessorXML.java
+++ /dev/null
@@ -1,169 +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.ui.internal.correction;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.sse.ui.internal.correction.IQuickAssistProcessor;
-import org.eclipse.wst.xml.core.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-
-public class QuickAssistProcessorXML implements IQuickAssistProcessor {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.correction.IQuickAssistProcessor#canAssist(org.eclipse.wst.sse.core.text.IStructuredDocument,
- * int)
- */
- public boolean canAssist(StructuredTextViewer viewer, int offset) {
- return true;
- }
-
- /**
- * @param proposals
- * @param viewer
- * @param offset
- */
- protected void getInsertRequiredAttrs(ArrayList proposals, StructuredTextViewer viewer, int offset) {
- IDOMNode node = (IDOMNode) ContentAssistUtils.getNodeAt(viewer, offset);
- if (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
- IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
- if (startStructuredDocumentRegion != null && startStructuredDocumentRegion.containsOffset(offset)) {
- IDOMNode cursorNode = (IDOMNode) ContentAssistUtils.getNodeAt(viewer, offset);
- List requiredAttrs = getRequiredAttrs(cursorNode);
- if (requiredAttrs.size() > 0) {
- NamedNodeMap currentAttrs = node.getAttributes();
- List insertAttrs = new ArrayList();
- if (currentAttrs.getLength() == 0)
- insertAttrs.addAll(requiredAttrs);
- else {
- for (int i = 0; i < requiredAttrs.size(); i++) {
- String requiredAttrName = ((CMAttributeDeclaration) requiredAttrs.get(i)).getAttrName();
- boolean found = false;
- for (int j = 0; j < currentAttrs.getLength(); j++) {
- String currentAttrName = currentAttrs.item(j).getNodeName();
- if (requiredAttrName.compareToIgnoreCase(currentAttrName) == 0) {
- found = true;
- break;
- }
- }
- if (!found)
- insertAttrs.add(requiredAttrs.get(i));
- }
- }
- if (insertAttrs.size() > 0)
- proposals.add(new InsertRequiredAttrsQuickAssistProposal(insertAttrs));
- }
- }
- }
- }
-
- /**
- * @param proposals
- * @param viewer
- * @param offset
- */
- protected void getLocalRenameQuickAssistProposal(ArrayList proposals, StructuredTextViewer viewer, int offset) {
- IDOMNode node = (IDOMNode) ContentAssistUtils.getNodeAt(viewer, offset);
- IStructuredDocumentRegion startStructuredDocumentRegion = node == null ? null : node.getStartStructuredDocumentRegion();
- IStructuredDocumentRegion endStructuredDocumentRegion = node == null ? null : node.getEndStructuredDocumentRegion();
-
- ITextRegion region = null;
- int regionTextEndOffset = 0;
- if (startStructuredDocumentRegion != null && startStructuredDocumentRegion.containsOffset(offset)) {
- region = startStructuredDocumentRegion.getRegionAtCharacterOffset(offset);
- regionTextEndOffset = startStructuredDocumentRegion.getTextEndOffset(region);
- } else if (endStructuredDocumentRegion != null && endStructuredDocumentRegion.containsOffset(offset)) {
- region = endStructuredDocumentRegion.getRegionAtCharacterOffset(offset);
- regionTextEndOffset = endStructuredDocumentRegion.getTextEndOffset(region);
- }
-
- if (region != null && (region.getType() == DOMRegionContext.XML_TAG_NAME || region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) && offset <= regionTextEndOffset)
- proposals.add(new RenameInFileQuickAssistProposal());
- }
-
- protected ModelQuery getModelQuery(Node node) {
- if (node.getNodeType() == Node.DOCUMENT_NODE) {
- return ModelQueryUtil.getModelQuery((Document) node);
- } else {
- return ModelQueryUtil.getModelQuery(node.getOwnerDocument());
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.correction.IQuickAssistProcessor#getProposals(org.eclipse.wst.sse.core.text.IStructuredDocument,
- * int)
- */
- public ICompletionProposal[] getProposals(StructuredTextViewer viewer, int offset) throws CoreException {
- ArrayList proposals = new ArrayList();
-
- getLocalRenameQuickAssistProposal(proposals, viewer, offset);
- getSurroundWithNewElementQuickAssistProposal(proposals, viewer, offset);
- getInsertRequiredAttrs(proposals, viewer, offset);
-
- return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
- }
-
- protected List getRequiredAttrs(Node node) {
- List result = new ArrayList();
-
- ModelQuery modelQuery = getModelQuery(node);
- if (modelQuery != null) {
- CMElementDeclaration elementDecl = modelQuery.getCMElementDeclaration((Element) node);
- if (elementDecl != null) {
- CMNamedNodeMap attrMap = elementDecl.getAttributes();
- Iterator it = attrMap.iterator();
- CMAttributeDeclaration attr = null;
- while (it.hasNext()) {
- attr = (CMAttributeDeclaration) it.next();
- if (attr.getUsage() == CMAttributeDeclaration.REQUIRED) {
- result.add(attr);
- }
- }
- }
- }
-
- return result;
- }
-
- /**
- * @param proposals
- * @param viewer
- * @param offset
- */
- protected void getSurroundWithNewElementQuickAssistProposal(ArrayList proposals, StructuredTextViewer viewer, int offset) {
- IDOMNode node = (IDOMNode) ContentAssistUtils.getNodeAt(viewer, offset);
- if (node != null)
- proposals.add(new SurroundWithNewElementQuickAssistProposal());
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickFixProcessorXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickFixProcessorXML.java
deleted file mode 100644
index 6e65a973cb..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickFixProcessorXML.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.correction;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.contentassist.CompletionProposal;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.ui.internal.correction.IQuickFixProcessor;
-import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-
-public class QuickFixProcessorXML implements IQuickFixProcessor {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.correction.IQuickFixProcessor#canFix(int)
- */
- public boolean canFix(Annotation annotation) {
- boolean result = false;
-
- if (annotation instanceof TemporaryAnnotation) {
- TemporaryAnnotation tempAnnotation = (TemporaryAnnotation) annotation;
- int problemID = tempAnnotation.getProblemID();
- switch (problemID) {
- case ProblemIDsXML.EmptyTag :
- case ProblemIDsXML.MissingEndTag :
- case ProblemIDsXML.AttrsInEndTag :
- case ProblemIDsXML.MissingAttrValue :
- case ProblemIDsXML.NoAttrValue :
- case ProblemIDsXML.SpacesBeforeTagName :
- case ProblemIDsXML.SpacesBeforePI :
- case ProblemIDsXML.NamespaceInPI :
- case ProblemIDsXML.UnknownElement :
- case ProblemIDsXML.UnknownAttr :
- case ProblemIDsXML.InvalidAttrValue :
- case ProblemIDsXML.MissingRequiredAttr :
- case ProblemIDsXML.AttrValueNotQuoted :
- case ProblemIDsXML.MissingClosingBracket :
- result = true;
- }
- }
-
- return result;
- }
-
- public Image getImage() {
- //return
- // JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
- return XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_CORRECTION_CHANGE);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.correction.IQuickFixProcessor#getProposals(org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation)
- */
- public ICompletionProposal[] getProposals(Annotation annotation) throws CoreException {
- ArrayList proposals = new ArrayList();
-
- if (annotation instanceof TemporaryAnnotation) {
- TemporaryAnnotation tempAnnotation = (TemporaryAnnotation) annotation;
- int problemID = tempAnnotation.getProblemID();
- switch (problemID) {
- case ProblemIDsXML.EmptyTag :
- proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_0, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- break;
- case ProblemIDsXML.MissingEndTag :
- String tagName = (String) ((Object[]) tempAnnotation.getAdditionalFixInfo())[0];
- String tagClose = (String) ((Object[]) tempAnnotation.getAdditionalFixInfo())[1];
- int tagCloseOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[2]).intValue();
- int startTagEndOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[3]).intValue();
- int firstChildStartOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[4]).intValue();
- int endOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[5]).intValue();
- proposals.add(new CompletionProposal(tagClose, tagCloseOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_1, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), startTagEndOffset - tempAnnotation.getPosition().getOffset(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_2, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- proposals.add(new CompletionProposal("</" + tagName + ">", firstChildStartOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_3, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- proposals.add(new CompletionProposal("</" + tagName + ">", endOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_4, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- break;
- case ProblemIDsXML.AttrsInEndTag :
- proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_5, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- break;
- case ProblemIDsXML.MissingAttrValue :
- String defaultAttrValue = (String) ((Object[]) tempAnnotation.getAdditionalFixInfo())[0];
- int insertOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[1]).intValue();
- proposals.add(new CompletionProposal("\"" + defaultAttrValue + "\"", tempAnnotation.getPosition().getOffset() + tempAnnotation.getPosition().getLength() + insertOffset, 0, defaultAttrValue.length() + 2, getImage(), XMLUIMessages.QuickFixProcessorXML_6, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_7, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- break;
- case ProblemIDsXML.NoAttrValue :
- defaultAttrValue = (String) tempAnnotation.getAdditionalFixInfo();
- proposals.add(new CompletionProposal("=\"" + defaultAttrValue + "\"", tempAnnotation.getPosition().getOffset() + tempAnnotation.getPosition().getLength(), 0, defaultAttrValue.length() + 3, getImage(), XMLUIMessages.QuickFixProcessorXML_6, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_7, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- break;
- case ProblemIDsXML.SpacesBeforeTagName :
- proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_8, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- break;
- case ProblemIDsXML.SpacesBeforePI :
- proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_9, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- break;
- case ProblemIDsXML.NamespaceInPI :
- proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_10, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- break;
- case ProblemIDsXML.UnknownElement :
- proposals.add(new RemoveUnknownElementQuickFixProposal(tempAnnotation.getAdditionalFixInfo(), getImage(), XMLUIMessages.QuickFixProcessorXML_11)); //$NON-NLS-1$
- proposals.add(new RenameInFileQuickAssistProposal());
- break;
- case ProblemIDsXML.UnknownAttr :
- proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_7, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- proposals.add(new RenameInFileQuickAssistProposal());
- break;
- case ProblemIDsXML.InvalidAttrValue :
- proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_12, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- break;
- case ProblemIDsXML.MissingRequiredAttr :
- String requiredAttr = (String) ((Object[]) tempAnnotation.getAdditionalFixInfo())[0];
- insertOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[1]).intValue();
- proposals.add(new CompletionProposal(requiredAttr, tempAnnotation.getPosition().getOffset() + insertOffset, 0, requiredAttr.length(), getImage(), XMLUIMessages.QuickFixProcessorXML_13, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case ProblemIDsXML.AttrValueNotQuoted :
- String attrValue = (String) tempAnnotation.getAdditionalFixInfo();
- proposals.add(new CompletionProposal("\"" + attrValue + "\"", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), attrValue.length() + 2, getImage(), XMLUIMessages.QuickFixProcessorXML_14, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- break;
- case ProblemIDsXML.MissingClosingBracket :
- proposals.add(new CompletionProposal(">", tempAnnotation.getPosition().getOffset() + tempAnnotation.getPosition().getLength(), 0, 1, getImage(), XMLUIMessages.QuickFixProcessorXML_15, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- break;
- }
- }
-
- return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RemoveUnknownElementQuickFixProposal.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RemoveUnknownElementQuickFixProposal.java
deleted file mode 100644
index 24f391d2d4..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RemoveUnknownElementQuickFixProposal.java
+++ /dev/null
@@ -1,156 +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.ui.internal.correction;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.text.edits.DeleteEdit;
-import org.eclipse.text.edits.MalformedTreeException;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-public class RemoveUnknownElementQuickFixProposal implements ICompletionProposal, ICompletionProposalExtension2 {
- private Object fAdditionalFixInfo = null;
- private String fDisplayString;
- private Image fImage;
- private Point fSelection; // initialized by apply()
-
- public RemoveUnknownElementQuickFixProposal(Object additionalFixInfo, Image image, String displayString) {
- fAdditionalFixInfo = additionalFixInfo;
- fImage = image;
- fDisplayString = displayString;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
- */
- public void apply(IDocument document) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer,
- * char, int, int)
- */
- public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
- int startTagOffset = ((Integer) ((Object[]) fAdditionalFixInfo)[0]).intValue();
- int startTagLength = ((Integer) ((Object[]) fAdditionalFixInfo)[1]).intValue();
- int endTagOffset = ((Integer) ((Object[]) fAdditionalFixInfo)[2]).intValue();
- int endTagLength = ((Integer) ((Object[]) fAdditionalFixInfo)[3]).intValue();
-
- MultiTextEdit multiTextEdit = new MultiTextEdit();
- if (endTagOffset != -1) {
- multiTextEdit.addChild(new DeleteEdit(endTagOffset, endTagLength));
- fSelection = new Point(endTagOffset, 0);
- }
- if (startTagOffset != -1) {
- multiTextEdit.addChild(new DeleteEdit(startTagOffset, startTagLength));
- fSelection = new Point(startTagOffset, 0);
- }
-
- try {
- multiTextEdit.apply(viewer.getDocument());
- } catch (MalformedTreeException e) {
- throw new SourceEditingRuntimeException(e);
- } catch (BadLocationException e) {
- throw new SourceEditingRuntimeException(e);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
- */
- public String getAdditionalProposalInfo() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
- */
- public IContextInformation getContextInformation() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
- */
- public String getDisplayString() {
- if (fDisplayString == null)
- fDisplayString = XMLUIMessages.QuickFixProcessorXML_11; //$NON-NLS-1$
-
- return fDisplayString;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
- */
- public Image getImage() {
- return fImage;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
- */
- public Point getSelection(IDocument document) {
- return fSelection;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#selected(org.eclipse.jface.text.ITextViewer,
- * boolean)
- */
- public void selected(ITextViewer viewer, boolean smartToggle) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#unselected(org.eclipse.jface.text.ITextViewer)
- */
- public void unselected(ITextViewer viewer) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#validate(org.eclipse.jface.text.IDocument,
- * int, org.eclipse.jface.text.DocumentEvent)
- */
- public boolean validate(IDocument document, int offset, DocumentEvent event) {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RenameInFileQuickAssistProposal.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RenameInFileQuickAssistProposal.java
deleted file mode 100644
index 8bf20e60fb..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RenameInFileQuickAssistProposal.java
+++ /dev/null
@@ -1,182 +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.ui.internal.correction;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.link.LinkedModeModel;
-import org.eclipse.jface.text.link.LinkedModeUI;
-import org.eclipse.jface.text.link.LinkedPosition;
-import org.eclipse.jface.text.link.LinkedPositionGroup;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.xml.core.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-
-public class RenameInFileQuickAssistProposal implements ICompletionProposal, ICompletionProposalExtension2 {
- protected IRegion fSelectedRegion; // initialized by apply()
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
- */
- public void apply(IDocument document) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer,
- * char, int, int)
- */
- public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
- IDocument document = viewer.getDocument();
- LinkedPositionGroup group = new LinkedPositionGroup();
- try {
- if (viewer instanceof StructuredTextViewer) {
- IDOMNode node = (IDOMNode) ContentAssistUtils.getNodeAt((StructuredTextViewer) viewer, offset);
- IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
- ITextRegion region = (startStructuredDocumentRegion == null) ? null : startStructuredDocumentRegion.getRegionAtCharacterOffset(offset);
- if (region != null) {
- group.addPosition(new LinkedPosition(document, startStructuredDocumentRegion.getStartOffset() + region.getStart(), region.getTextLength(), 0));
-
- if (region.getType() == DOMRegionContext.XML_TAG_NAME && node.getEndStructuredDocumentRegion() != null) {
- region = node.getEndStructuredDocumentRegion().getRegions().get(1);
- if (region != null)
- group.addPosition(new LinkedPosition(document, node.getEndStructuredDocumentRegion().getStartOffset() + region.getStart(), region.getTextLength(), 1));
- }
- } else {
- IStructuredDocumentRegion endStructuredDocumentRegion = node.getEndStructuredDocumentRegion();
- region = (endStructuredDocumentRegion == null) ? null : endStructuredDocumentRegion.getRegionAtCharacterOffset(offset);
- if (region != null) {
- if (region.getType() == DOMRegionContext.XML_TAG_NAME && node.getStartStructuredDocumentRegion() != null) {
- ITextRegion startTagNameRegion = node.getStartStructuredDocumentRegion().getRegions().get(1);
- if (region != null) {
- group.addPosition(new LinkedPosition(document, node.getStartStructuredDocumentRegion().getStartOffset() + startTagNameRegion.getStart(), startTagNameRegion.getTextLength(), 0));
- group.addPosition(new LinkedPosition(document, endStructuredDocumentRegion.getStartOffset() + region.getStart(), region.getTextLength(), 1));
- }
- } else
- group.addPosition(new LinkedPosition(document, endStructuredDocumentRegion.getStartOffset() + region.getStart(), region.getTextLength(), 0));
- }
- }
-
- // TODO CompletionProposalPopup#insertProposal() calls
- // IRewriteTarget.beginCompoundChange()
- // which disables redraw in ITextViewer. Workaround for now.
- ((StructuredTextViewer) viewer).setRedraw(true);
- }
-
- LinkedModeModel linkedModeModel = new LinkedModeModel();
- linkedModeModel.addGroup(group);
- linkedModeModel.forceInstall();
-
- LinkedModeUI ui = new EditorLinkedModeUI(linkedModeModel, viewer);
- ui.setExitPosition(viewer, offset, 0, LinkedPositionGroup.NO_STOP);
- ui.enter();
-
- fSelectedRegion = ui.getSelectedRegion();
- } catch (BadLocationException e) {
- throw new SourceEditingRuntimeException(e);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
- */
- public String getAdditionalProposalInfo() {
- return XMLUIMessages.RenameInFileQuickAssistProposal_0; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
- */
- public IContextInformation getContextInformation() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
- */
- public String getDisplayString() {
- return XMLUIMessages.RenameInFileQuickAssistProposal_1; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
- */
- public Image getImage() {
- // return JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL);
- return XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_LOCAL_VARIABLE);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
- */
- public Point getSelection(IDocument document) {
- return new Point(fSelectedRegion.getOffset(), fSelectedRegion.getLength());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#selected(org.eclipse.jface.text.ITextViewer,
- * boolean)
- */
- public void selected(ITextViewer viewer, boolean smartToggle) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#unselected(org.eclipse.jface.text.ITextViewer)
- */
- public void unselected(ITextViewer viewer) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#validate(org.eclipse.jface.text.IDocument,
- * int, org.eclipse.jface.text.DocumentEvent)
- */
- public boolean validate(IDocument document, int offset, DocumentEvent event) {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/SurroundWithNewElementQuickAssistProposal.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/SurroundWithNewElementQuickAssistProposal.java
deleted file mode 100644
index e9ca0a4182..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/SurroundWithNewElementQuickAssistProposal.java
+++ /dev/null
@@ -1,107 +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.ui.internal.correction;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.text.edits.InsertEdit;
-import org.eclipse.text.edits.MalformedTreeException;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.xml.core.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-import org.w3c.dom.Node;
-
-public class SurroundWithNewElementQuickAssistProposal extends RenameInFileQuickAssistProposal {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer,
- * char, int, int)
- */
- public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
- try {
- int startTagOffset = offset;
- int endTagOffset = offset + viewer.getSelectedRange().y;
-
- // surround the node if no selection
- if (startTagOffset == endTagOffset) {
- IDOMNode cursorNode = (IDOMNode) ContentAssistUtils.getNodeAt((StructuredTextViewer) viewer, offset);
- // use parent node if text node is empty
- if (cursorNode.getNodeType() == Node.TEXT_NODE && cursorNode.getNodeValue().trim().length() == 0)
- cursorNode = (IDOMNode) cursorNode.getParentNode();
-
- startTagOffset = cursorNode.getStartOffset();
- endTagOffset = cursorNode.getEndOffset();
- }
-
- // insert new element
- MultiTextEdit multiTextEdit = new MultiTextEdit();
- // element tag name cannot be DBCS, do not translate "<element>"
- // and "</element>"
- multiTextEdit.addChild(new InsertEdit(startTagOffset, "<element>")); //$NON-NLS-1$
- multiTextEdit.addChild(new InsertEdit(endTagOffset, "</element>")); //$NON-NLS-1$
- multiTextEdit.apply(viewer.getDocument());
-
- // get new element node
- IDOMNode newElementNode = (IDOMNode) ContentAssistUtils.getNodeAt((StructuredTextViewer) viewer, startTagOffset);
-
- // format new element
- IStructuredFormatProcessor formatProcessor = new FormatProcessorXML();
- formatProcessor.formatNode(newElementNode);
-
- // rename new element
- super.apply(viewer, trigger, stateMask, newElementNode.getStartOffset() + 1);
- } catch (MalformedTreeException e) {
- throw new SourceEditingRuntimeException(e);
- } catch (BadLocationException e) {
- throw new SourceEditingRuntimeException(e);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
- */
- public String getAdditionalProposalInfo() {
- return XMLUIMessages.SurroundWithNewElementQuickAssistProposal_0; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
- */
- public String getDisplayString() {
- return XMLUIMessages.SurroundWithNewElementQuickAssistProposal_1; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
- */
- public Image getImage() {
- // return JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL);
- return XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ADD_CORRECTION);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/DragNodeCommand.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/DragNodeCommand.java
deleted file mode 100644
index e0d8d23ba7..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/DragNodeCommand.java
+++ /dev/null
@@ -1,228 +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.ui.internal.dnd;
-
-import java.util.Collection;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.wst.common.ui.dnd.DefaultDragAndDropCommand;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.xml.core.document.IDOMNode;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-public class DragNodeCommand extends DefaultDragAndDropCommand {
- public DragNodeCommand(Object target, float location, int operations, int operation, Collection sources) {
- super(target, location, operations, operation, sources);
- }
-
- protected void beginModelChange(Node node, boolean batchUpdate) {
- IStructuredModel structuredModel = getStructedModel(node);
- if (structuredModel != null) {
- structuredModel.beginRecording(this, XMLUIMessages.DragNodeCommand_0); //$NON-NLS-1$
- if (batchUpdate) {
- // structuredModel.aboutToChangeModel();
- }
- }
- }
-
- public boolean canExecute() {
- return executeHelper(true);
- }
-
-
- public boolean doMove(Node source, Node parentNode, Node refChild, boolean testOnly) {
- boolean result = false;
- if (source.getNodeType() == Node.ATTRIBUTE_NODE) {
- Attr sourceAttribute = (Attr) source;
- Element sourceAttributeOwnerElement = sourceAttribute.getOwnerElement();
- if (parentNode.getNodeType() == Node.ELEMENT_NODE && sourceAttributeOwnerElement != parentNode) {
- result = true;
- if (!testOnly) {
- try {
- Element targetElement = (Element) parentNode;
- targetElement.setAttribute(sourceAttribute.getName(), sourceAttribute.getValue());
- sourceAttributeOwnerElement.removeAttributeNode(sourceAttribute);
- } catch (Exception e) {
- }
- }
- }
- } else {
- if ((parentNode.getNodeType() == Node.ELEMENT_NODE || parentNode.getNodeType() == Node.DOCUMENT_NODE) && !(refChild instanceof Attr)) {
- result = true;
-
- if (!testOnly) {
- if (isAncestor(source, parentNode)) {
- //System.out.println("can not perform this drag drop
- // operation.... todo... pop up dialog");
- } else {
- // defect 221055 this test is required or else the
- // node will
- // be removed from the tree and the insert will fail
- if (source != refChild) {
- source.getParentNode().removeChild(source);
- parentNode.insertBefore(source, refChild);
- }
- }
- }
- }
- }
- return result;
- }
-
- protected void endModelChange(Node node, boolean batchUpdate) {
- IStructuredModel structuredModel = getStructedModel(node);
- if (structuredModel != null) {
- structuredModel.endRecording(this);
- if (batchUpdate) {
- // structuredModel.changedModel();
- }
- }
- }
-
- public void execute() {
- executeHelper(false);
- }
-
- //
- //
- public boolean executeHelper(boolean testOnly) {
- boolean result = true;
- if (target instanceof Node) {
- Node targetNode = (Node) target;
- Node parentNode = getParentForDropPosition(targetNode);
- Node refChild = getRefChild(targetNode);
-
- Vector sourcesList = new Vector();
- sourcesList.addAll(sources);
-
- removeMemberDescendants(sourcesList);
- boolean performBatchUpdate = sourcesList.size() > 5;
-
- if (!testOnly) {
- beginModelChange(targetNode, performBatchUpdate);
- }
- for (Iterator i = sourcesList.iterator(); i.hasNext();) {
- Object source = i.next();
- if (source instanceof Node) {
- if (!(refChild == null && targetNode instanceof Attr)) {
- result = doMove((Node) source, parentNode, refChild, testOnly);
- } else {
- result = false;
- }
- if (!result) {
- break;
- }
- }
- }
- if (!testOnly) {
- endModelChange(targetNode, performBatchUpdate);
- }
- } else {
- result = false;
- }
- return result;
- }
-
-
- public int getFeedback() {
- int result = DND.FEEDBACK_SELECT;
- if (location > 0.75) {
- result = DND.FEEDBACK_INSERT_AFTER;
- } else if (location < 0.25) {
- result = DND.FEEDBACK_INSERT_BEFORE;
- }
- return result;
- }
-
- protected Node getParentForDropPosition(Node node) {
- Node result = null;
-
- int feedback = getFeedback();
- if (feedback == DND.FEEDBACK_SELECT) {
- result = node;
- } else {
- result = getParentOrOwner(node);
- }
- return result;
- }
-
-
- protected Node getParentOrOwner(Node node) {
- return (node.getNodeType() == Node.ATTRIBUTE_NODE) ? ((Attr) node).getOwnerElement() : node.getParentNode();
- }
-
-
- protected Node getRefChild(Node node) {
- Node result = null;
-
- int feedback = getFeedback();
-
- if (feedback == DND.FEEDBACK_INSERT_BEFORE) {
- result = node;
- } else if (feedback == DND.FEEDBACK_INSERT_AFTER) {
- result = node.getNextSibling();
- }
- return result;
- }
-
- protected IStructuredModel getStructedModel(Node node) {
- IStructuredModel result = null;
- if (node instanceof IDOMNode) {
- result = ((IDOMNode) node).getModel();
- }
- return result;
- }
-
- // returns true if a is an ancestore of b
- //
- protected boolean isAncestor(Node a, Node b) {
- boolean result = false;
- for (Node parent = b; parent != null; parent = parent.getParentNode()) {
- if (parent == a) {
- result = true;
- break;
- }
- }
- return result;
- }
-
-
- /**
- * This method removes members of the list that have ancestors that are
- * also members of the list.
- */
- protected void removeMemberDescendants(List list) {
- Hashtable table = new Hashtable();
- for (Iterator i = list.iterator(); i.hasNext();) {
- Object node = i.next();
- table.put(node, node);
- }
-
- for (int i = list.size() - 1; i >= 0; i--) {
- Node node = (Node) list.get(i);
- for (Node parent = getParentOrOwner(node); parent != null; parent = getParentOrOwner(parent)) {
- if (table.get(parent) != null) {
- list.remove(i);
- break;
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/XMLDragAndDropManager.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/XMLDragAndDropManager.java
deleted file mode 100644
index 5f47c9e25c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/XMLDragAndDropManager.java
+++ /dev/null
@@ -1,48 +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.ui.internal.dnd;
-
-import java.util.Collection;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.wst.common.ui.dnd.DragAndDropCommand;
-import org.eclipse.wst.common.ui.dnd.DragAndDropManager;
-import org.eclipse.wst.common.ui.dnd.ObjectTransfer;
-import org.eclipse.wst.common.ui.dnd.ViewerDragAdapter;
-import org.eclipse.wst.common.ui.dnd.ViewerDropAdapter;
-import org.w3c.dom.Node;
-
-public class XMLDragAndDropManager implements DragAndDropManager {
- public static void addDragAndDropSupport(TreeViewer viewer) {
- int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
- Transfer[] transfers = new Transfer[]{ObjectTransfer.getInstance()};
- viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
- viewer.addDropSupport(dndOperations, transfers, new ViewerDropAdapter(viewer, new XMLDragAndDropManager()));
- }
-
- public XMLDragAndDropManager() {
- }
-
- public DragAndDropCommand createCommand(Object target, float location, int operations, int operation, Collection source) {
- DragAndDropCommand result = null;
- if (target instanceof Node) {
- Node node = (Node) target;
- result = new DragNodeCommand(target, location, operations, operation, source);
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/doubleclick/XMLDoubleClickStrategy.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/doubleclick/XMLDoubleClickStrategy.java
deleted file mode 100644
index 1067d39811..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/doubleclick/XMLDoubleClickStrategy.java
+++ /dev/null
@@ -1,285 +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.ui.internal.doubleclick;
-
-import org.eclipse.jface.text.DefaultTextDoubleClickStrategy;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.Node;
-
-
-public class XMLDoubleClickStrategy extends DefaultTextDoubleClickStrategy {
- protected static final char DOUBLE_QUOTE = '\"';
- protected static final char SINGLE_QUOTE = '\'';
- protected static final char SPACE = ' ';
- protected int fCaretPosition = -1;
- protected int fDoubleClickCount = 0;
- protected Node fNode = null;
- protected IStructuredDocumentRegion fStructuredDocumentRegion = null;
- protected String fStructuredDocumentRegionText = ""; //$NON-NLS-1$
- protected IStructuredModel fStructuredModel = null;
- protected StructuredTextViewer fStructuredTextViewer;
- protected ITextRegion fTextRegion = null;
-
- public void doubleClicked(ITextViewer textViewer) {
- if (textViewer instanceof StructuredTextViewer) {
- fStructuredTextViewer = (StructuredTextViewer) textViewer;
- try {
- fStructuredModel = StructuredModelManager.getModelManager().getExistingModelForRead(fStructuredTextViewer.getDocument());
-
- if (fStructuredModel != null) {
- int caretPosition = textViewer.getSelectedRange().x;
- if (caretPosition < 0)
- return;
-
- fNode = (Node) fStructuredModel.getIndexedRegion(caretPosition);
- if (fNode == null)
- return;
-
- updateDoubleClickCount(caretPosition);
- updateStructuredDocumentRegion();
- updateTextRegion();
-
- if (fNode.getNodeType() == Node.TEXT_NODE)
- processTextDoubleClicked();
- else
- processElementDoubleClicked();
- }
- } finally {
- if (fStructuredModel != null)
- fStructuredModel.releaseFromRead();
- }
- }
- }
-
- protected Point getWord(String string, int cursor) {
- if (string == null)
- return null;
-
- int wordStart = 0;
- int wordEnd = string.length();
-
- wordStart = string.lastIndexOf(SPACE, cursor - 1);
- int temp = string.lastIndexOf(SINGLE_QUOTE, cursor - 1);
- wordStart = Math.max(wordStart, temp);
- temp = string.lastIndexOf(DOUBLE_QUOTE, cursor - 1);
- wordStart = Math.max(wordStart, temp);
- if (wordStart == -1)
- wordStart = cursor;
- else
- wordStart++;
-
- wordEnd = string.indexOf(SPACE, cursor);
- if (wordEnd == -1)
- wordEnd = string.length();
- temp = string.indexOf(SINGLE_QUOTE, cursor);
- if (temp == -1)
- temp = string.length();
- wordEnd = Math.min(wordEnd, temp);
- temp = string.indexOf(DOUBLE_QUOTE, cursor);
- if (temp == -1)
- temp = string.length();
- wordEnd = Math.min(wordEnd, temp);
- if (wordEnd == string.length())
- wordEnd = cursor;
-
- if ((wordStart == wordEnd) && !isQuoted(string)) {
- wordStart = 0;
- wordEnd = string.length();
- }
-
- return new Point(wordStart, wordEnd);
- }
-
- protected boolean isQuoted(String string) {
- if ((string == null) || (string.length() < 2))
- return false;
-
- int lastIndex = string.length() - 1;
- char firstChar = string.charAt(0);
- char lastChar = string.charAt(lastIndex);
-
- return (((firstChar == SINGLE_QUOTE) && (lastChar == SINGLE_QUOTE)) || ((firstChar == DOUBLE_QUOTE) && (lastChar == DOUBLE_QUOTE)));
- }
-
- protected void processElementAttrEqualsDoubleClicked2Times() {
- int prevRegionOffset = fStructuredDocumentRegion.getStartOffset(fTextRegion) - 1;
- ITextRegion prevRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(prevRegionOffset);
- int nextRegionOffset = fStructuredDocumentRegion.getEndOffset(fTextRegion);
- ITextRegion nextRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(nextRegionOffset);
-
- if ((prevRegion != null) && (prevRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) && (nextRegion != null) && (nextRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(prevRegion), nextRegion.getTextEnd() - prevRegion.getStart());
- }
- }
-
- protected void processElementAttrNameDoubleClicked2Times() {
- int nextRegionOffset = fStructuredDocumentRegion.getEndOffset(fTextRegion);
- ITextRegion nextRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(nextRegionOffset);
-
- if (nextRegion != null) {
- nextRegionOffset = fStructuredDocumentRegion.getEndOffset(nextRegion);
- nextRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(nextRegionOffset);
- if ((nextRegion != null) && (nextRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion), nextRegion.getTextEnd() - fTextRegion.getStart());
- } else {
- // attribute has no value
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength());
- fDoubleClickCount = 0;
- }
- }
- }
-
- protected void processElementAttrValueDoubleClicked() {
- String regionText = fStructuredDocumentRegion.getText(fTextRegion);
-
- if (fDoubleClickCount == 1) {
- Point word = getWord(regionText, fCaretPosition - fStructuredDocumentRegion.getStartOffset(fTextRegion));
- if (word.x == word.y) { // no word found; select whole region
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion), regionText.length());
- fDoubleClickCount++;
- } else
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion) + word.x, word.y - word.x);
- } else if (fDoubleClickCount == 2) {
- if (isQuoted(regionText)) {
- // ==> // Point word = getWord(regionText, fCaretPosition -
- // fStructuredDocumentRegion.getStartOffset(fTextRegion));
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion), regionText.length());
- } else
- processElementAttrValueDoubleClicked2Times();
- } else if (fDoubleClickCount == 3) {
- if (isQuoted(regionText))
- processElementAttrValueDoubleClicked2Times();
- else {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength());
- fDoubleClickCount = 0;
- }
- } else { // fDoubleClickCount == 4
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength());
- fDoubleClickCount = 0;
- }
- }
-
- protected void processElementAttrValueDoubleClicked2Times() {
- int prevRegionOffset = fStructuredDocumentRegion.getStartOffset(fTextRegion) - 1;
- ITextRegion prevRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(prevRegionOffset);
-
- if (prevRegion != null) {
- prevRegionOffset = fStructuredDocumentRegion.getStartOffset(prevRegion) - 1;
- prevRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(prevRegionOffset);
- if ((prevRegion != null) && (prevRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)) {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(prevRegion), fTextRegion.getTextEnd() - prevRegion.getStart());
- }
- }
- }
-
- protected void processElementDoubleClicked() {
- if (fTextRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)
- processElementAttrValueDoubleClicked(); // special handling for
- // XML_TAG_ATTRIBUTE_VALUE
- else {
- if (fDoubleClickCount == 1) {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart() + fTextRegion.getStart(), fTextRegion.getTextLength());
- } else if (fDoubleClickCount == 2) {
- if (fTextRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)
- processElementAttrNameDoubleClicked2Times();
- else if (fTextRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS)
- processElementAttrEqualsDoubleClicked2Times();
- else {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength());
- fDoubleClickCount = 0;
- }
- } else { // fDoubleClickCount == 3
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength());
- fDoubleClickCount = 0;
- }
- }
- }
-
- protected void processTextDoubleClicked() {
- if (fDoubleClickCount == 1) {
- super.doubleClicked(fStructuredTextViewer);
-
- Point selectedRange = fStructuredTextViewer.getSelectedRange();
- if ((selectedRange.x == fStructuredDocumentRegion.getStartOffset(fTextRegion)) && (selectedRange.y == fTextRegion.getTextLength()))
- // only one word in region, skip one level of double click
- // selection
- fDoubleClickCount++;
- } else if (fDoubleClickCount == 2) {
- if (fTextRegion.getType() == DOMRegionContext.UNDEFINED) {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength());
- fDoubleClickCount = 0;
- } else {
- if (isQuoted(fStructuredDocumentRegion.getFullText(fTextRegion)))
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion) + 1, fTextRegion.getTextLength() - 2);
- else
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion), fTextRegion.getTextLength());
- }
- } else {
- if ((fDoubleClickCount == 3) && isQuoted(fStructuredDocumentRegion.getFullText(fTextRegion)))
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion), fTextRegion.getTextLength());
- else {
- if ((fDoubleClickCount == 3) && isQuoted(fStructuredDocumentRegionText))
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart() + 1, fStructuredDocumentRegion.getLength() - 2);
- else {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength());
- fDoubleClickCount = 0;
- }
- }
- }
- }
-
- public void setModel(IStructuredModel structuredModel) {
- fStructuredModel = structuredModel;
- }
-
- protected void updateDoubleClickCount(int caretPosition) {
- if (fCaretPosition == caretPosition) {
- if (fStructuredDocumentRegion != null)
- fDoubleClickCount++;
- else
- fDoubleClickCount = 1;
- } else {
- fCaretPosition = caretPosition;
- fDoubleClickCount = 1;
- }
- }
-
- protected void updateStructuredDocumentRegion() {
- fStructuredDocumentRegion = fStructuredModel.getStructuredDocument().getRegionAtCharacterOffset(fCaretPosition);
- if (fStructuredDocumentRegion != null)
- fStructuredDocumentRegionText = fStructuredDocumentRegion.getText();
- else
- fStructuredDocumentRegionText = ""; //$NON-NLS-1$
- }
-
- protected void updateTextRegion() {
- if (fStructuredDocumentRegion != null) {
- fTextRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(fCaretPosition);
- // if fTextRegion is null, it means we are at just past the last
- // fStructuredDocumentRegion,
- // at the very end of the document, so we'll use the last text
- // region in the document
- if (fTextRegion == null) {
- fTextRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(fCaretPosition - 1);
- }
- } else
- fTextRegion = null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/CMImageUtil.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/CMImageUtil.java
deleted file mode 100644
index c90bc447d5..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/CMImageUtil.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.editor;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * @author nsd
- */
-public class CMImageUtil {
-
- public static CMNode getDeclaration(Node node) {
- CMNode decl = null;
- ModelQuery mq = null;
- switch (node.getNodeType()) {
- case Node.ATTRIBUTE_NODE: {
- mq = ModelQueryUtil.getModelQuery(((Attr) node).getOwnerDocument());
- decl = mq.getCMAttributeDeclaration((Attr) node);
- }
- case Node.ELEMENT_NODE: {
- mq = ModelQueryUtil.getModelQuery(node.getOwnerDocument());
- decl = mq.getCMElementDeclaration((Element) node);
- }
- }
- return decl;
- }
-
- public static Image getImage(CMNode cmnode) {
- if (cmnode == null)
- return null;
- Image image = null;
- ImageDescriptor descriptor = getImageDescriptor(cmnode);
- if (descriptor != null) {
- image = descriptor.createImage(false);
- }
- return image;
- }
-
- public static ImageDescriptor getImageDescriptor(CMNode cmnode) {
- if (cmnode == null)
- return null;
- // cache CM-specified images with the XML UI plugin
- String imageURLString = (String) cmnode.getProperty("small-icon"); //$NON-NLS-1$
- ImageDescriptor descriptor = null;
- if (imageURLString != null && imageURLString.length() > 0) {
- descriptor = XMLUIPlugin.getInstance().getImageRegistry()
- .getDescriptor(imageURLString);
- if (descriptor == null) {
- try {
- URL imageURL = new URL(imageURLString);
- URLConnection connection = imageURL.openConnection();
- connection.setUseCaches(false);
- ImageData data = new ImageData(connection.getInputStream());
- descriptor = ImageDescriptor.createFromImageData(data);
- XMLUIPlugin.getInstance().getImageRegistry().put(
- imageURLString, descriptor);
- } catch (MalformedURLException e) {
- descriptor = null;
- } catch (IOException e) {
- descriptor = null;
- }
- }
- }
- return descriptor;
- }
-
- /**
- *
- */
- private CMImageUtil() {
- super();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/IHelpContextIds.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/IHelpContextIds.java
deleted file mode 100644
index 072afcec6d..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/IHelpContextIds.java
+++ /dev/null
@@ -1,43 +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.ui.internal.editor;
-
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-/**
- * Help context ids for the XML Source Editor.
- * <p>
- * This interface contains constants only; it is not intended to be
- * implemented.
- * </p>
- *
- */
-public interface IHelpContextIds {
- // org.eclipse.wst.xml.ui.
- public static final String PREFIX = XMLUIPlugin.ID + "."; //$NON-NLS-1$
-
- // XML Source page editor
- public static final String XML_SOURCEVIEW_HELPID = PREFIX + "exml0000"; //$NON-NLS-1$
-
- // XML Files Preference page
- public static final String XML_PREFWEBX_FILES_HELPID = PREFIX + "webx0060"; //$NON-NLS-1$
- // XML Source Preference page
- public static final String XML_PREFWEBX_SOURCE_HELPID = PREFIX + "webx0061"; //$NON-NLS-1$
- // XML Styles Preference page
- public static final String XML_PREFWEBX_STYLES_HELPID = PREFIX + "webx0062"; //$NON-NLS-1$
- // XML Templates Preference page
- public static final String XML_PREFWEBX_TEMPLATES_HELPID = PREFIX + "webx0063"; //$NON-NLS-1$
-
- // XML Cleanup dialog
- public static final String CLEANUP_XML_HELPID = PREFIX + "xmlm1200"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImageHelper.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImageHelper.java
deleted file mode 100644
index 32338dfba8..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImageHelper.java
+++ /dev/null
@@ -1,155 +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.ui.internal.editor;
-
-import java.util.HashMap;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-
-/**
- * Helper class to handle images provided by this plug-in.
- *
- * NOTE: For internal use only. For images used externally, please use the
- * Shared***ImageHelper class instead.
- *
- * @author amywu
- */
-public class XMLEditorPluginImageHelper {
- private static XMLEditorPluginImageHelper instance = null;
-
- /**
- * Gets the instance.
- *
- * @return Returns a XMLEditorPluginImageHelper
- */
- public synchronized static XMLEditorPluginImageHelper getInstance() {
- if (instance == null)
- instance = new XMLEditorPluginImageHelper();
- return instance;
- }
-
- // save a descriptor for each image
- private HashMap fImageDescRegistry = null;
- private final String PLUGINID = XMLUIPlugin.ID;
-
- /**
- * Creates an image from the given resource and adds the image to the
- * image registry.
- *
- * @param resource
- * @return Image
- */
- private Image createImage(String resource) {
- ImageDescriptor desc = getImageDescriptor(resource);
- Image image = null;
-
- if (desc != null) {
- image = desc.createImage();
- // dont add the missing image descriptor image to the image
- // registry
- if (!desc.equals(ImageDescriptor.getMissingImageDescriptor()))
- getImageRegistry().put(resource, image);
- }
- return image;
- }
-
- /**
- * Creates an image descriptor from the given imageFilePath and adds the
- * image descriptor to the image descriptor registry. If an image
- * descriptor could not be created, the default "missing" image descriptor
- * is returned but not added to the image descriptor registry.
- *
- * @param imageFilePath
- * @return ImageDescriptor image descriptor for imageFilePath or default
- * "missing" image descriptor if resource could not be found
- */
- private ImageDescriptor createImageDescriptor(String imageFilePath) {
- ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(PLUGINID, imageFilePath);
- if (imageDescriptor != null) {
- getImageDescriptorRegistry().put(imageFilePath, imageDescriptor);
- } else {
- imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
- }
-
- return imageDescriptor;
- }
-
- /**
- * Retrieves the image associated with resource from the image registry.
- * If the image cannot be retrieved, attempt to find and load the image at
- * the location specified in resource.
- *
- * @param resource
- * the image to retrieve
- * @return Image the image associated with resource or null if one could
- * not be found
- */
- public Image getImage(String resource) {
- Image image = getImageRegistry().get(resource);
- if (image == null) {
- // create an image
- image = createImage(resource);
- }
- return image;
- }
-
- /**
- * Retrieves the image descriptor associated with resource from the image
- * descriptor registry. If the image descriptor cannot be retrieved,
- * attempt to find and load the image descriptor at the location specified
- * in resource.
- *
- * @param resource
- * the image descriptor to retrieve
- * @return ImageDescriptor the image descriptor assocated with resource or
- * the default "missing" image descriptor if one could not be
- * found
- */
- public ImageDescriptor getImageDescriptor(String resource) {
- ImageDescriptor imageDescriptor = null;
- Object o = getImageDescriptorRegistry().get(resource);
- if (o == null) {
- //create a descriptor
- imageDescriptor = createImageDescriptor(resource);
- } else {
- imageDescriptor = (ImageDescriptor) o;
- }
- return imageDescriptor;
- }
-
- /**
- * Returns the image descriptor registry for this plugin.
- *
- * @return HashMap - image descriptor registry for this plugin
- */
- private HashMap getImageDescriptorRegistry() {
- if (fImageDescRegistry == null)
- fImageDescRegistry = new HashMap();
- return fImageDescRegistry;
- }
-
- /**
- * Returns the image registry for this plugin.
- *
- * @return ImageRegistry - image registry for this plugin
- */
- private ImageRegistry getImageRegistry() {
- return JFaceResources.getImageRegistry();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImages.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImages.java
deleted file mode 100644
index 8160f7781c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImages.java
+++ /dev/null
@@ -1,53 +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.ui.internal.editor;
-
-/**
- * Bundle of most images used by the XML Source Editor plug-in.
- */
-public class XMLEditorPluginImages {
-
- public static final String IMG_DTOOL_CONSTRAINOFF = "icons/full/dtool16/constrainoff.gif"; //$NON-NLS-1$
- public static final String IMG_DTOOL_CONSTRAINON = "icons/full/dtool16/constrainon.gif"; //$NON-NLS-1$
- public static final String IMG_DTOOL_RLDGRMR = "icons/full/dtool16/rldgrmr.gif"; //$NON-NLS-1$
- public static final String IMG_DTOOL_VALIDATE = "icons/full/dtool16/validate.gif"; //$NON-NLS-1$
- public static final String IMG_ETOOL_CONSTRAINOFF = "icons/full/etool16/constrainoff.gif"; //$NON-NLS-1$
- public static final String IMG_ETOOL_CONSTRAINON = "icons/full/etool16/constrainon.gif"; //$NON-NLS-1$
- public static final String IMG_ETOOL_RLDGRMR = "icons/full/etool16/rldgrmr.gif"; //$NON-NLS-1$
- public static final String IMG_ETOOL_VALIDATE = "icons/full/etool16/validate.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_ADD_CORRECTION = "icons/full/obj16/add_correction.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_ATT_REQ_OBJ = "icons/full/obj16/att_req_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJ_ATTRIBUTE = "icons/full/obj16/attribute_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_CDATASECTION = "icons/full/obj16/cdatasection.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_COMMENT = "icons/full/obj16/comment_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_CORRECTION_CHANGE = "icons/full/obj16/correction_change.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_DOCTYPE = "icons/full/obj16/doctype.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_DTDFILE = "icons/full/obj16/dtdfile.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_ELEMENT = "icons/full/obj16/element_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_ENTITY = "icons/full/obj16/entity.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_ENTITY_REFERENCE = "icons/full/obj16/entity_reference.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_ENUM = "icons/full/obj16/enum.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_LOCAL_VARIABLE = "icons/full/obj16/localvariable_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_NOTATION = "icons/full/obj16/notation.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_PROCESSINGINSTRUCTION = "icons/full/obj16/proinst_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_TAG_GENERIC = "icons/full/obj16/tag-generic.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_TAG_MACRO = "icons/full/obj16/tag-macro.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_TXTEXT = "icons/full/obj16/text.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_WARNING_OBJ = "icons/full/obj16/warning_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_XSDFILE = "icons/full/obj16/XSDFile.gif"; //$NON-NLS-1$
-
- public static final String IMG_OVR_ERROR = "icons/full/ovr16/error_ovr.gif"; //$NON-NLS-1$
- public static final String IMG_OVR_STALE_ERROR = "icons/full/ovr16/stale_error_ovr.gif"; //$NON-NLS-1$
- public static final String IMG_OVR_WARN = "icons/full/ovr16/warn_ovr.gif"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileEditorInput.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileEditorInput.java
deleted file mode 100644
index 63e60c35bf..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileEditorInput.java
+++ /dev/null
@@ -1,146 +0,0 @@
-package org.eclipse.wst.xml.ui.internal.hyperlink;
-
-import java.io.File;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IPersistableElement;
-import org.eclipse.ui.editors.text.ILocationProvider;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-
-/**
- * EditorInput for external files. Copied from
- * org.eclipse.ui.internal.editors.text.JavaFileEditorInput
- */
-class ExternalFileEditorInput implements IEditorInput, ILocationProvider {
- // copies of this class exist in:
- // org.eclipse.wst.xml.ui.internal.hyperlink
- // org.eclipse.wst.html.ui.internal.hyperlink
- // org.eclipse.jst.jsp.ui.internal.hyperlink
-
- /**
- * The workbench adapter which simply provides the label.
- *
- * @since 3.1
- */
- private class WorkbenchAdapter implements IWorkbenchAdapter {
- /*
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object o) {
- return null;
- }
-
- /*
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
- */
- public ImageDescriptor getImageDescriptor(Object object) {
- return null;
- }
-
- /*
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
- */
- public String getLabel(Object o) {
- return ((ExternalFileEditorInput) o).getName();
- }
-
- /*
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
- */
- public Object getParent(Object o) {
- return null;
- }
- }
-
- private File fFile;
- private WorkbenchAdapter fWorkbenchAdapter = new WorkbenchAdapter();
-
- public ExternalFileEditorInput(File file) {
- super();
- fFile = file;
- fWorkbenchAdapter = new WorkbenchAdapter();
- }
-
- /*
- * @see org.eclipse.ui.IEditorInput#exists()
- */
- public boolean exists() {
- return fFile.exists();
- }
-
- /*
- * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
- */
- public ImageDescriptor getImageDescriptor() {
- return null;
- }
-
- /*
- * @see org.eclipse.ui.IEditorInput#getName()
- */
- public String getName() {
- return fFile.getName();
- }
-
- /*
- * @see org.eclipse.ui.IEditorInput#getPersistable()
- */
- public IPersistableElement getPersistable() {
- return null;
- }
-
- /*
- * @see org.eclipse.ui.IEditorInput#getToolTipText()
- */
- public String getToolTipText() {
- return fFile.getAbsolutePath();
- }
-
- /*
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class adapter) {
- if (ILocationProvider.class.equals(adapter))
- return this;
- if (IWorkbenchAdapter.class.equals(adapter))
- return fWorkbenchAdapter;
- return Platform.getAdapterManager().getAdapter(this, adapter);
- }
-
- /*
- * @see org.eclipse.ui.editors.text.ILocationProvider#getPath(java.lang.Object)
- */
- public IPath getPath(Object element) {
- if (element instanceof ExternalFileEditorInput) {
- ExternalFileEditorInput input = (ExternalFileEditorInput) element;
- return Path.fromOSString(input.fFile.getAbsolutePath());
- }
- return null;
- }
-
- /*
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object o) {
- if (o == this)
- return true;
-
- if (o instanceof ExternalFileEditorInput) {
- ExternalFileEditorInput input = (ExternalFileEditorInput) o;
- return fFile.equals(input.fFile);
- }
-
- return false;
- }
-
- /*
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return fFile.hashCode();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileHyperlink.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileHyperlink.java
deleted file mode 100644
index b2d1e4db6c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileHyperlink.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.eclipse.wst.xml.ui.internal.hyperlink;
-
-import java.io.File;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-
-/**
- * Hyperlink for external files.
- */
-class ExternalFileHyperlink implements IHyperlink {
- // copies of this class exist in:
- // org.eclipse.wst.xml.ui.internal.hyperlink
- // org.eclipse.wst.html.ui.internal.hyperlink
- // org.eclipse.jst.jsp.ui.internal.hyperlink
-
- private IRegion fHyperlinkRegion;
- private File fHyperlinkFile;
-
- public ExternalFileHyperlink(IRegion region, File file) {
- fHyperlinkFile = file;
- fHyperlinkRegion = region;
- }
-
- public IRegion getHyperlinkRegion() {
- return fHyperlinkRegion;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.hyperlink.IHyperlink#getTypeLabel()
- */
- public String getTypeLabel() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText()
- */
- public String getHyperlinkText() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void open() {
- if (fHyperlinkFile != null) {
- IEditorInput input = new ExternalFileEditorInput(fHyperlinkFile);
- IEditorDescriptor descriptor;
- try {
- descriptor = IDE.getEditorDescriptor(input.getName());
- if (descriptor != null) {
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- IDE.openEditor(page, input, descriptor.getId(), true);
- }
- }
- catch (PartInitException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/WorkspaceFileHyperlink.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/WorkspaceFileHyperlink.java
deleted file mode 100644
index 23fe9cbc51..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/WorkspaceFileHyperlink.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package org.eclipse.wst.xml.ui.internal.hyperlink;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.xml.ui.internal.Logger;
-
-/**
- * Hyperlink for files within the workspace. (As long as there is an IFile,
- * this can be used) Opens the default editor for the file.
- */
-class WorkspaceFileHyperlink implements IHyperlink {
- // copies of this class exist in:
- // org.eclipse.wst.xml.ui.internal.hyperlink
- // org.eclipse.wst.html.ui.internal.hyperlink
- // org.eclipse.jst.jsp.ui.internal.hyperlink
-
- private IRegion fRegion;
- private IFile fFile;
- private IRegion fHighlightRange;
-
- public WorkspaceFileHyperlink(IRegion region, IFile file) {
- fRegion = region;
- fFile = file;
- }
-
- public WorkspaceFileHyperlink(IRegion region, IFile file, IRegion range) {
- fRegion = region;
- fFile = file;
- fHighlightRange = range;
- }
-
- public IRegion getHyperlinkRegion() {
- return fRegion;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.hyperlink.IHyperlink#getTypeLabel()
- */
- public String getTypeLabel() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText()
- */
- public String getHyperlinkText() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void open() {
- if (fFile != null && fFile.exists()) {
- try {
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- IEditorPart editor = IDE.openEditor(page, fFile, true);
- // highlight range in editor if possible
- if (fHighlightRange != null && editor instanceof ITextEditor) {
- ((ITextEditor) editor).setHighlightRange(fHighlightRange.getOffset(), fHighlightRange.getLength(), true);
- }
- }
- catch (PartInitException pie) {
- Logger.log(Logger.WARNING_DEBUG, pie.getMessage(), pie);
- }
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java
deleted file mode 100644
index 6482314673..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java
+++ /dev/null
@@ -1,472 +0,0 @@
-package org.eclipse.wst.xml.ui.internal.hyperlink;
-
-import java.io.File;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
-import org.eclipse.jface.text.hyperlink.URLHyperlink;
-import org.eclipse.wst.common.uriresolver.URIResolverPlugin;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.IndexedRegion;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.util.StringUtils;
-import org.eclipse.wst.xml.core.document.IDOMAttr;
-import org.eclipse.wst.xml.core.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.w3c.dom.Attr;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * Detects hyperlinks in XML tags. Includes detection in DOCTYPE and attribute
- * values. Resolves references to schemas, dtds, etc using the Common URI
- * Resolver.
- *
- */
-public class XMLHyperlinkDetector implements IHyperlinkDetector {
- // copies of this class exist in:
- // org.eclipse.wst.xml.ui.internal.hyperlink
- // org.eclipse.wst.html.ui.internal.hyperlink
- // org.eclipse.jst.jsp.ui.internal.hyperlink
-
- private final String NO_NAMESPACE_SCHEMA_LOCATION = "noNamespaceSchemaLocation"; //$NON-NLS-1$
- private final String SCHEMA_LOCATION = "schemaLocation"; //$NON-NLS-1$
- private final String XMLNS = "xmlns"; //$NON-NLS-1$
- private final String XSI_NAMESPACE_URI = "http://www.w3.org/2001/XMLSchema-instance"; //$NON-NLS-1$
- private final String HTTP_PROTOCOL = "http://";//$NON-NLS-1$
-
- public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
- // for now, only capable of creating 1 hyperlink
- List hyperlinks = new ArrayList(0);
-
- if (region != null && textViewer != null) {
- IDocument document = textViewer.getDocument();
- Node currentNode = getCurrentNode(document, region.getOffset());
- if (currentNode != null) {
- String uriString = null;
- if (currentNode.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
- // doctype nodes
- uriString = getURIString(currentNode, document);
- }
- else if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
- // element nodes
- Attr currentAttr = getCurrentAttrNode(currentNode, region.getOffset());
- if (currentAttr != null) {
- // try to find link for current attribute
- // resolve attribute value
- uriString = getURIString(currentAttr, document);
- // verify validity of uri string
- if (!isValidURI(uriString))
- // reset current attribute
- currentAttr = null;
- }
- if (currentAttr == null) {
- // try to find a linkable attribute within element
- currentAttr = getLinkableAttr((Element) currentNode);
- if (currentAttr != null) {
- uriString = getURIString(currentAttr, document);
- }
- }
- currentNode = currentAttr;
- }
- // try to create hyperlink from information gathered
- if (uriString != null && currentNode != null && isValidURI(uriString)) {
- IRegion hyperlinkRegion = getHyperlinkRegion(currentNode);
- IHyperlink hyperlink = createHyperlink(uriString, hyperlinkRegion, document, currentNode);
- if (hyperlink != null) {
- hyperlinks.add(hyperlink);
- }
- }
- }
- }
- if (hyperlinks.size() == 0)
- return null;
- return (IHyperlink[]) hyperlinks.toArray(new IHyperlink[0]);
- }
-
- /**
- * Create the appropriate hyperlink
- *
- * @param uriString
- * @param hyperlinkRegion
- * @return IHyperlink
- */
- private IHyperlink createHyperlink(String uriString, IRegion hyperlinkRegion, IDocument document, Node node) {
- IHyperlink link = null;
-
- if (uriString != null) {
- String temp = uriString.toLowerCase();
- if (temp.startsWith(HTTP_PROTOCOL)) {
- // this is a URLHyperlink since this is a web address
- link = new URLHyperlink(hyperlinkRegion, uriString);
- }
- else {
- // try to locate the file in the workspace
- IFile file = getFile(uriString);
- if (file != null && file.exists()) {
- // this is a WorkspaceFileHyperlink since file exists in
- // workspace
- link = new WorkspaceFileHyperlink(hyperlinkRegion, file);
- }
- else {
- // this is an ExternalFileHyperlink since file does not
- // exist
- // in workspace
- File externalFile = new File(uriString);
- link = new ExternalFileHyperlink(hyperlinkRegion, externalFile);
- }
- }
- }
-
- return link;
- }
-
- private IRegion getHyperlinkRegion(Node node) {
- IRegion hyperRegion = null;
-
- if (node != null) {
- short nodeType = node.getNodeType();
- if (nodeType == Node.DOCUMENT_TYPE_NODE) {
- // handle doc type node
- IDOMNode docNode = (IDOMNode) node;
- hyperRegion = new Region(docNode.getStartOffset(), docNode.getEndOffset() - docNode.getStartOffset());
- }
- else if (nodeType == Node.ATTRIBUTE_NODE) {
- // handle attribute nodes
- IDOMAttr att = (IDOMAttr) node;
- // do not include quotes in attribute value region
- int regOffset = att.getValueRegionStartOffset();
- int regLength = att.getValueRegion().getTextLength();
- String attValue = att.getValueRegionText();
- if (StringUtils.isQuoted(attValue)) {
- regOffset = ++regOffset;
- regLength = regLength - 2;
- }
- hyperRegion = new Region(regOffset, regLength);
- }
- }
- return hyperRegion;
- }
-
- /**
- * Returns the URI string
- *
- * @param node -
- * assumes not null
- */
- private String getURIString(Node node, IDocument document) {
- String resolvedURI = null;
- // need the base location, publicId, and systemId for URIResolver
- String baseLoc = null;
- String publicId = null;
- String systemId = null;
-
- short nodeType = node.getNodeType();
- // handle doc type node
- if (nodeType == Node.DOCUMENT_TYPE_NODE) {
- baseLoc = getBaseLocation(document);
- publicId = ((DocumentType) node).getPublicId();
- systemId = ((DocumentType) node).getSystemId();
- }
- else if (nodeType == Node.ATTRIBUTE_NODE) {
- // handle attribute node
- Attr attrNode = (Attr) node;
- baseLoc = getBaseLocation(document);
- String attrName = attrNode.getName();
- String attrValue = attrNode.getValue();
- attrValue = StringUtils.strip(attrValue);
-
- // handle schemaLocation attribute
- String prefix = DOMNamespaceHelper.getPrefix(attrName);
- String unprefixedName = DOMNamespaceHelper.getUnprefixedName(attrName);
- if ((XMLNS.equals(prefix)) || (XMLNS.equals(unprefixedName))) {
- publicId = attrValue;
- systemId = getLocationHint(attrNode.getOwnerElement(), publicId);
- }
- else if ((XSI_NAMESPACE_URI.equals(DOMNamespaceHelper.getNamespaceURI(attrNode))) && (SCHEMA_LOCATION.equals(unprefixedName))) {
- // for now just use the first pair
- // need to look into being more precise
- StringTokenizer st = new StringTokenizer(attrValue);
- publicId = st.hasMoreTokens() ? st.nextToken() : null;
- systemId = st.hasMoreTokens() ? st.nextToken() : null;
- // else check if xmlns publicId = value
- }
- else {
- systemId = attrValue;
- }
- }
-
- resolvedURI = resolveURI(baseLoc, publicId, systemId);
- return resolvedURI;
- }
-
- /**
- * Returns an IFile from the given uri if possible, null if cannot find
- * file from uri.
- *
- * @param fileString
- * file system path
- * @return returns IFile if fileString exists in the workspace
- */
- private IFile getFile(String fileString) {
- IFile file = null;
-
- if (fileString != null) {
- IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(fileString));
- for (int i = 0; i < files.length && file == null; i++)
- if (files[i].exists())
- file = files[i];
- }
-
- return file;
- }
-
- /**
- * Checks to see if the given attribute is openable. Attribute is openable
- * if it is a namespace declaration attribute or if the attribute value is
- * of type URI.
- *
- * @param attr
- * cannot be null
- * @param cmElement
- * CMElementDeclaration associated with the attribute (can be
- * null)
- * @return true if this attribute is "openOn-able" false otherwise
- */
- private boolean isLinkableAttr(Attr attr, CMElementDeclaration cmElement) {
- String attrName = attr.getName();
- String prefix = DOMNamespaceHelper.getPrefix(attrName);
- String unprefixedName = DOMNamespaceHelper.getUnprefixedName(attrName);
- // determine if attribute is namespace declaration
- if ((XMLNS.equals(prefix)) || (XMLNS.equals(unprefixedName)))
- return true;
-
- // determine if attribute contains schema location
- if ((XSI_NAMESPACE_URI.equals(DOMNamespaceHelper.getNamespaceURI(attr))) && ((SCHEMA_LOCATION.equals(unprefixedName)) || (NO_NAMESPACE_SCHEMA_LOCATION.equals(unprefixedName))))
- return true;
-
- // determine if attribute value is of type URI
- if (cmElement != null) {
- CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) cmElement.getAttributes().getNamedItem(attrName);
- if ((attrDecl != null) && (attrDecl.getAttrType() != null) && (CMDataType.URI.equals(attrDecl.getAttrType().getDataTypeName()))) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Attempts to find an attribute within element that is openable.
- *
- * @param element -
- * cannot be null
- * @return Attr attribute that can be used for open on, null if no
- * attribute could be found
- */
- private Attr getLinkableAttr(Element element) {
- CMElementDeclaration ed = getCMElementDeclaration(element);
- // get the list of attributes for this node
- NamedNodeMap attrs = element.getAttributes();
- for (int i = 0; i < attrs.getLength(); ++i) {
- // check if this attribute is "openOn-able"
- Attr att = (Attr) attrs.item(i);
- if (isLinkableAttr(att, ed)) {
- return att;
- }
- }
- return null;
- }
-
- /**
- * Get the CMElementDeclaration for an element
- *
- * @param element
- * @return CMElementDeclaration
- */
- private CMElementDeclaration getCMElementDeclaration(Element element) {
- CMElementDeclaration ed = null;
-
- ModelQuery mq = ModelQueryUtil.getModelQuery(element.getOwnerDocument());
- if (mq != null) {
- ed = mq.getCMElementDeclaration(element);
- }
- return ed;
- }
-
- /**
- * Returns the attribute node within node at offset
- *
- * @param node
- * @param offset
- * @return Attr
- */
- private Attr getCurrentAttrNode(Node node, int offset) {
- if ((node instanceof IndexedRegion) && ((IndexedRegion) node).contains(offset) && (node.hasAttributes())) {
- NamedNodeMap attrs = node.getAttributes();
- // go through each attribute in node and if attribute contains
- // offset, return that attribute
- for (int i = 0; i < attrs.getLength(); ++i) {
- // assumption that if parent node is of type IndexedRegion,
- // then its attributes will also be of type IndexedRegion
- IndexedRegion attRegion = (IndexedRegion) attrs.item(i);
- if (attRegion.contains(offset)) {
- return (Attr) attrs.item(i);
- }
- }
- }
- return null;
- }
-
- /**
- * Returns the node the cursor is currently on in the document. null if no
- * node is selected
- *
- * @param offset
- * @return Node either element, doctype, text, or null
- */
- private Node getCurrentNode(IDocument document, int offset) {
- // get the current node at the offset (returns either: element,
- // doctype, text)
- IndexedRegion inode = null;
- IStructuredModel sModel = null;
- try {
- sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document);
- inode = sModel.getIndexedRegion(offset);
- if (inode == null)
- inode = sModel.getIndexedRegion(offset - 1);
- }
- finally {
- if (sModel != null)
- sModel.releaseFromRead();
- }
-
- if (inode instanceof Node) {
- return (Node) inode;
- }
- return null;
- }
-
- /**
- * Get the base location from the current model (local file system)
- */
- private String getBaseLocation(IDocument document) {
- String baseLoc = null;
-
- // get the base location from the current model
- IStructuredModel sModel = null;
- try {
- sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document);
- if (sModel != null) {
- IPath location = new Path(sModel.getBaseLocation());
- if (location.toFile().exists()) {
- baseLoc = location.toString();
- }
- else {
- IPath basePath = new Path(sModel.getBaseLocation());
- if(basePath.segmentCount() > 1)
- baseLoc = ResourcesPlugin.getWorkspace().getRoot().getFile(basePath).getLocation().toString();
- else
- baseLoc = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(basePath).toString();
- }
- }
- }
- finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- return baseLoc;
- }
-
- /**
- * Checks whether the given uriString is really pointing to a file
- *
- * @param uriString
- * @return boolean
- */
- private boolean isValidURI(String uriString) {
- boolean isValid = false;
-
- if (uriString != null) {
- // first do a quick check to see if this is some sort of http://
- String tempString = uriString.toLowerCase();
- if (tempString.startsWith(HTTP_PROTOCOL))
- isValid = true;
- else {
- File file = new File(uriString);
- try {
- URI uri = new URI(uriString);
- file = new File(uri);
- }
- catch (URISyntaxException e) {
- // it is okay that a uri could not be created out of
- // uriString
- }
- catch (IllegalArgumentException e) {
- // it is okay that file could not be created out of uri
- }
- isValid = file.exists();
- }
- }
- return isValid;
- }
-
- /**
- * Resolves the given URI information
- *
- * @param baseLocation
- * @param publicId
- * @param systemId
- * @return String resolved uri.
- */
- private String resolveURI(String baseLocation, String publicId, String systemId) {
- // dont resolve if there's nothing to resolve
- if ((baseLocation == null) && (publicId == null) && (systemId == null))
- return null;
- return URIResolverPlugin.createResolver().resolve(baseLocation, publicId, systemId);
- }
-
- /**
- * Find the location hint for the given namespaceURI if it exists
- *
- * @param elementNode -
- * cannot be null
- * @param namespaceURI -
- * cannot be null
- * @return location hint (systemId) if it was found, null otherwise
- */
- private String getLocationHint(Element elementNode, String namespaceURI) {
- Attr schemaLocNode = elementNode.getAttributeNodeNS(XSI_NAMESPACE_URI, SCHEMA_LOCATION);
- if (schemaLocNode != null) {
- StringTokenizer st = new StringTokenizer(schemaLocNode.getValue());
- while (st.hasMoreTokens()) {
- String publicId = st.hasMoreTokens() ? st.nextToken() : null;
- String systemId = st.hasMoreTokens() ? st.nextToken() : null;
- // found location hint
- if (namespaceURI.equalsIgnoreCase(publicId))
- return systemId;
- }
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/EncodingSettings.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/EncodingSettings.java
deleted file mode 100644
index 54e4f394ed..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/EncodingSettings.java
+++ /dev/null
@@ -1,356 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.preferences;
-
-import java.util.Vector;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.sse.core.internal.encoding.CommonCharsetNames;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-/**
- * EncodingSettings is a composite that can be used to display the set of
- * encoding values that are available to the user. The list of encoding values
- * is based off the SupportedJavaEncoding class. As the user selects an
- * encoding from the combo box, the readonly field below it changes to show
- * the IANA tag for that particular encoding description. The labels for the
- * widgets are configurable and the initial value to display to the user can
- * be set using the setIANATag(). The currently selected entry's IANA tag can
- * be retrieved with getIANATag(). Entries displayed to the user can be added
- * and removed.
- */
-public class EncodingSettings extends Composite {
-
- private class ComboListener implements ModifyListener {
- public void modifyText(ModifyEvent e) {
- int i = encodingCombo.getSelectionIndex();
- if (i >= 0 && i < ianaVector.size())
- ianaText.setText((String) (ianaVector.elementAt(encodingCombo.getSelectionIndex())));
- }
- }
-
- private static String ENCODING_LABEL = XMLUIMessages.EncodingSettings_1; //$NON-NLS-1$
-
- private static String IANA_LABEL = XMLUIMessages.EncodingSettings_0; //$NON-NLS-1$
-
- private ModifyListener comboListener = new ComboListener();
- protected Combo encodingCombo;
- protected Label encodingLabel, ianaLabel;
- protected Text ianaText;
- protected Vector ianaVector;
-
- /**
- * Method EncodingSettings.
- *
- * @param parent
- */
- public EncodingSettings(Composite parent) {
- super(parent, SWT.NONE);
- init(IANA_LABEL, ENCODING_LABEL);
- }
-
- /**
- * Method EncodingSettings.
- *
- * @param parent
- * @param encodingLabel -
- * text label to use beside the locale sensitive description of
- * the currently selected encoding
- */
- public EncodingSettings(Composite parent, String encodingLabel) {
- super(parent, SWT.NONE);
- init(IANA_LABEL, encodingLabel);
- }
-
- /**
- * Method EncodingSettings.
- *
- * @param parent
- * @param ianaLabel =
- * text label to use beside the display only IANA field
- * @param encodingLabel -
- * text label to use beside the locale sensitive description of
- * the currently selected encoding
- */
- public EncodingSettings(Composite parent, String ianaLabel, String encodingLabel) {
- super(parent, SWT.NONE);
- init(ianaLabel, encodingLabel);
- }
-
- /**
- * Method addEntry. Add an entry to the end of the Encoding Combobox
- *
- * @param description -
- * encoding description to display
- * @param ianaTag -
- * IANA tag for the description
- */
- public void addEntry(String description, String ianaTag) {
- encodingCombo.add(description);
- ianaVector.add(ianaTag);
- }
-
- /**
- * Method addEntry. Add an entry to the Encoding Combobox at index index
- *
- * @param description -
- * encoding description to display
- * @param ianaTag -
- * IANA tag for the description
- * @param index -
- * index into the combo to add to
- */
- public void addEntry(String description, String ianaTag, int index) {
- if (index == ianaVector.size()) {
- // just add to the end
- addEntry(description, ianaTag);
- return;
- }
-
- if (0 <= index && index < ianaVector.size()) {
- encodingCombo.add(description, index);
- ianaVector.add(index, ianaTag);
- }
- }
-
- protected Combo createComboBox(Composite parent, boolean isReadOnly) {
- int style = isReadOnly == true ? SWT.READ_ONLY : SWT.DROP_DOWN;
-
- Combo combo = new Combo(parent, style);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- combo.setLayoutData(data);
- return combo;
- }
-
- /**
- * Helper method for creating labels.
- */
- protected Label createLabel(Composite parent, String text) {
- Label label = new Label(parent, SWT.LEFT);
- label.setText(text);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- label.setLayoutData(data);
- return label;
- }
-
- protected Text createTextField(Composite parent, int width) {
- Text text = new Text(parent, SWT.SINGLE | SWT.READ_ONLY);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- data.widthHint = width;
- text.setLayoutData(data);
-
- return text;
- }
-
- /**
- * @see org.eclipse.swt.widgets.Widget#dispose()
- */
- public void dispose() {
- encodingCombo.removeModifyListener(comboListener);
- super.dispose();
- }
-
- private void fillCombo() {
- try {
- String[] ianaTags = CommonCharsetNames.getCommonCharsetNames();
- int totalNum = ianaTags.length;
- for (int i = 0; i < totalNum; i++) {
- String iana = ianaTags[i];
- String enc = CommonCharsetNames.getDisplayString(iana);
-
- if (enc != null) {
- encodingCombo.add(enc);
- } else {
- Logger.log(Logger.WARNING, "CommonCharsetNames.getDisplayString(" + iana + ") returned null"); //$NON-NLS-1$ //$NON-NLS-2$
- encodingCombo.add(iana);
- }
- ianaVector.add(iana);
- }
- } catch (Exception e) {
- //e.printStackTrace();
- //MessageDialog.openError(getShell(), "Resource exception",
- // "Unable to obtain encoding strings. Check resource file");
- //XMLEncodingPlugin.getPlugin().getMsgLogger().write(e.toString());
- //XMLEncodingPlugin.getPlugin().getMsgLogger().writeCurrentThread();
- Logger.log(Logger.ERROR, "Exception", e); //$NON-NLS-1$
- }
- }
-
- /**
- * <code>getEncoding</code> Get the descriptive encoding name that was
- * selected.
- *
- * @return a <code>String</code> value
- */
- public String getEncoding() {
- return encodingCombo.getText();
- }
-
- /**
- * Method getEncodingCombo. Returns the combo used to display the encoding
- * descriptions.
- *
- * @return Combo
- */
- public Combo getEncodingCombo() {
- return encodingCombo;
- }
-
- /**
- * <code>getIANATag</code> Get the IANA tag equivalent of the selected
- * descriptive encoding name
- *
- * @return a <code>String</code> value
- */
- public String getIANATag() {
- int i = encodingCombo.getSelectionIndex();
- if (i >= 0) {
- return (String) (ianaVector.elementAt(i));
- }
- return ""; //$NON-NLS-1$
- }
-
- protected void init(String ianaLabelStr, String encodingLabelStr) {
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- setLayout(layout);
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- setLayoutData(data);
-
- encodingLabel = createLabel(this, encodingLabelStr);
- encodingCombo = createComboBox(this, true);
- ianaLabel = createLabel(this, ianaLabelStr);
- ianaText = createTextField(this, 20);
- ianaVector = new Vector();
-
- fillCombo();
- resetToDefaultEncoding();
- encodingCombo.addModifyListener(comboListener);
- }
-
- /**
- * <code>isEncodingInList</code> Checks whether the encoding name is in
- * the combo
- *
- * @param enc
- * a <code>string</code> value. The encoding name.
- * @return a <code>boolean</code> value. TRUE if encoding is in list.
- * FALSE if encoding is not in list.
- */
- public boolean isEncodingInList(String enc) {
- int i = encodingCombo.indexOf(enc);
- if (i >= 0) {
- return true;
- }
- return false;
- }
-
- /**
- * <code>isIANATagInList</code> Checks whether the IANA tag is in the
- * combo
- *
- * @param ianaTag
- * a <code>string</code> value. The IANA tag.
- * @return a <code>boolean</code> value. TRUE if tag is in list. FALSE
- * if tag is not in list.
- */
- public boolean isIANATagInList(String ianaTag) {
- int i = ianaVector.indexOf(ianaTag);
- if (i >= 0) {
- return true;
- }
- return false;
- }
-
- /**
- * Method removeEntry. Removes both the description and the IANA tag at
- * the specified index
- *
- * @param index
- */
- public void removeEntry(int index) {
- if (0 <= index && index < ianaVector.size()) {
- encodingCombo.remove(index);
- ianaVector.remove(index);
- }
- }
-
- /**
- * Method resetToDefaultEncoding. Reset the control to the default
- * encoding. Currently UTF-8
- */
- public void resetToDefaultEncoding() {
- String defaultIANATag = "UTF-8"; //$NON-NLS-1$
- ianaText.setText(defaultIANATag);
- setIANATag(defaultIANATag);
- }
-
- /**
- * Method setEnabled. Enable/disable the EncodingSettings composite.
- *
- * @param enabled
- */
- public void setEnabled(boolean enabled) {
- encodingCombo.setEnabled(enabled);
- encodingLabel.setEnabled(enabled);
- ianaLabel.setEnabled(enabled);
- ianaText.setEnabled(enabled);
- }
-
- /**
- * <code>setEncoding</code> Set the selection in the combo to the
- * descriptive encoding name.
- *
- * @param enc
- * a <code>string</code> value. Note this is not the IANA
- * tag.
- */
- public void setEncoding(String enc) {
- encodingCombo.setText(enc);
- encodingCombo.select(encodingCombo.indexOf(enc));
- }
-
- /**
- * <code>setIANATag</code> Set the IANA tag for the combo
- *
- * @param ianaTag
- * a <code>string</code> value. The IANA tag.
- */
- public void setIANATag(String ianaTag) {
- int i = ianaVector.indexOf(ianaTag);
- if (i >= 0) {
- encodingCombo.select(i);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/WorkbenchDefaultEncodingSettings.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/WorkbenchDefaultEncodingSettings.java
deleted file mode 100644
index d5019737cd..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/WorkbenchDefaultEncodingSettings.java
+++ /dev/null
@@ -1,137 +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.ui.internal.preferences;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.sse.core.internal.encoding.CommonCharsetNames;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-/**
- * WorkbenchDefaultEncodingSettings is an extension of EncodingSettings. This
- * composite contains EncodingSettings for users to select the encoding they
- * desire as well as a checkbox for users to select to use the default
- * workbench encoding instead.
- *
- * @see org.eclipse.wst.xml.ui.internal.preferences.EncodingSettings
- */
-public class WorkbenchDefaultEncodingSettings extends Composite {
-
- private final static int INDENT = 15;
- private static final String WORKBENCH_DEFAULT = ""; //$NON-NLS-1$
- private EncodingSettings fEncodingSettings;
- private String fNonDefaultIANA = null;
- private Button fUseDefaultButton;
-
- public WorkbenchDefaultEncodingSettings(Composite parent) {
- super(parent, SWT.NONE);
- createControls();
- }
-
- private void createControls() {
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- layout.marginWidth = 0;
- setLayout(layout);
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- setLayoutData(data);
-
- Composite defaultEncodingComposite = new Composite(this, SWT.NONE);
- layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- data = new GridData(GridData.FILL_BOTH);
- defaultEncodingComposite.setLayout(layout);
- defaultEncodingComposite.setLayoutData(data);
-
- fUseDefaultButton = new Button(defaultEncodingComposite, SWT.CHECK);
- fUseDefaultButton.setText(XMLUIMessages.WorkbenchDefaultEncodingSettings_0); //$NON-NLS-1$
-
- fUseDefaultButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleUseDefaultButtonSelected();
- }
- });
-
- fEncodingSettings = new EncodingSettings(this);
- ((GridLayout) fEncodingSettings.getLayout()).marginWidth = 0;
- ((GridData) fEncodingSettings.getLayoutData()).horizontalIndent = INDENT;
-
- }
-
- private Combo getEncodingCombo() {
- return fEncodingSettings.getEncodingCombo();
- }
-
- /**
- * <code>getIANATag</code> Get the IANA tag equivalent of the selected
- * descriptive encoding name. Returns empty string if using workbench
- * encoding.
- *
- * @return a <code>String</code> value
- */
- public String getIANATag() {
- if (!isDefault())
- return fEncodingSettings.getIANATag();
- return WORKBENCH_DEFAULT;
- }
-
- private String getWorkbenchEncoding() {
- return ResourcesPlugin.getEncoding();
- }
-
- private void handleUseDefaultButtonSelected() {
- if (fUseDefaultButton.getSelection()) {
- fNonDefaultIANA = fEncodingSettings.getIANATag();
- String workbenchValue = getWorkbenchEncoding();
- workbenchValue = CommonCharsetNames.getIanaPreferredCharsetName(workbenchValue);
- fEncodingSettings.setIANATag(workbenchValue);
- } else if (fNonDefaultIANA != null) {
- fEncodingSettings.setIANATag(fNonDefaultIANA);
- }
- getEncodingCombo().setEnabled(!fUseDefaultButton.getSelection());
- fEncodingSettings.setEnabled(!fUseDefaultButton.getSelection());
- }
-
- private boolean isDefault() {
- return fUseDefaultButton.getSelection();
- }
-
- /**
- * <code>setEncoding</code> Set the selection in the combo to the
- * descriptive encoding name. Selects use workbench encoding if ianaTag is
- * null or empty string.
- *
- */
- public void setIANATag(String ianaTag) {
- if (ianaTag == null || ianaTag.equals(WORKBENCH_DEFAULT)) {
- fUseDefaultButton.setSelection(true);
- handleUseDefaultButtonSelected();
- } else {
- fUseDefaultButton.setSelection(false);
- handleUseDefaultButtonSelected();
- if (!isDefault())
- fEncodingSettings.setIANATag(ianaTag);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLColorPage.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLColorPage.java
deleted file mode 100644
index b15967b10c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLColorPage.java
+++ /dev/null
@@ -1,223 +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.ui.internal.preferences;
-
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.Iterator;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.ui.internal.SSEUIPlugin;
-import org.eclipse.wst.sse.ui.internal.preferences.OverlayPreferenceStore;
-import org.eclipse.wst.sse.ui.internal.preferences.OverlayPreferenceStore.OverlayKey;
-import org.eclipse.wst.sse.ui.preferences.ui.AbstractColorPage;
-import org.eclipse.wst.sse.ui.preferences.ui.StyledTextColorPicker;
-import org.eclipse.wst.xml.core.contenttype.ContentTypeIdForXML;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.editor.IHelpContextIds;
-import org.eclipse.wst.xml.ui.internal.style.IStyleConstantsXML;
-
-public class XMLColorPage extends AbstractColorPage {
-
- protected Control createContents(Composite parent) {
- Composite pageComponent = createComposite(parent, 1);
- ((GridData) pageComponent.getLayoutData()).horizontalAlignment = GridData.HORIZONTAL_ALIGN_FILL;
-
- super.createContents(pageComponent);
- WorkbenchHelp.setHelp(pageComponent, IHelpContextIds.XML_PREFWEBX_STYLES_HELPID);
- return pageComponent;
- }
-
- /**
- * Set up all the style preference keys in the overlay store
- */
- protected OverlayKey[] createOverlayStoreKeys() {
- ArrayList overlayKeys = new ArrayList();
-
- ArrayList styleList = new ArrayList();
- initStyleList(styleList);
- Iterator i = styleList.iterator();
- while (i.hasNext()) {
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, (String) i.next()));
- }
-
- OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
- overlayKeys.toArray(keys);
- return keys;
- }
-
- protected IPreferenceStore doGetPreferenceStore() {
- return XMLUIPlugin.getDefault().getPreferenceStore();
- }
-
- public String getSampleText() {
- return XMLUIMessages.Sample_XML_doc; //$NON-NLS-1$ = "<?xml version=\"1.0\"?>\n<?customProcessingInstruction\n\tXML processor specific\n\tcontent ?>\n<!DOCTYPE colors\n\tPUBLIC \"//IBM/XML/COLORS/\" \"colors.dtd\">\n<colors>\n\t<!-- begin color definitions -->\n\t<color name=\"plaintext\" foreground=\"#000000\"\n\t\tbackground=\"#D4D0C8\"/>\n\t<color name=\"bold\" foreground=\"#000000\"\n\t\tbackground=\"#B3ACA0\">\n\t<![CDATA[<123456789>]]>\n\tNormal text content.\n\t<color name=\"inverse\" foreground=\"#F0F0F0\"\n\t\tbackground=\"#D4D0C8\"/>\n\n</colors>\n";
- }
-
- protected void initCommonContextStyleMap(Dictionary contextStyleMap) {
-
- contextStyleMap.put(DOMRegionContext.XML_COMMENT_OPEN, IStyleConstantsXML.COMMENT_BORDER);
- contextStyleMap.put(DOMRegionContext.XML_COMMENT_TEXT, IStyleConstantsXML.COMMENT_TEXT);
- contextStyleMap.put(DOMRegionContext.XML_COMMENT_CLOSE, IStyleConstantsXML.COMMENT_BORDER);
-
- contextStyleMap.put(DOMRegionContext.XML_TAG_OPEN, IStyleConstantsXML.TAG_BORDER);
- contextStyleMap.put(DOMRegionContext.XML_END_TAG_OPEN, IStyleConstantsXML.TAG_BORDER);
- contextStyleMap.put(DOMRegionContext.XML_TAG_NAME, IStyleConstantsXML.TAG_NAME);
- contextStyleMap.put(DOMRegionContext.XML_TAG_ATTRIBUTE_NAME, IStyleConstantsXML.TAG_ATTRIBUTE_NAME);
- contextStyleMap.put(DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE, IStyleConstantsXML.TAG_ATTRIBUTE_VALUE);
- contextStyleMap.put(DOMRegionContext.XML_TAG_CLOSE, IStyleConstantsXML.TAG_BORDER);
- contextStyleMap.put(DOMRegionContext.XML_EMPTY_TAG_CLOSE, IStyleConstantsXML.TAG_BORDER);
-
- contextStyleMap.put(DOMRegionContext.XML_DECLARATION_OPEN, IStyleConstantsXML.DECL_BORDER);
- contextStyleMap.put(DOMRegionContext.XML_DECLARATION_CLOSE, IStyleConstantsXML.DECL_BORDER);
- contextStyleMap.put(DOMRegionContext.XML_ELEMENT_DECLARATION, IStyleConstantsXML.DECL_BORDER);
- contextStyleMap.put(DOMRegionContext.XML_ELEMENT_DECL_CLOSE, IStyleConstantsXML.DECL_BORDER);
-
- contextStyleMap.put(DOMRegionContext.XML_CONTENT, IStyleConstantsXML.XML_CONTENT);
- }
-
- protected void initCommonDescriptions(Dictionary descriptions) {
-
- // create descriptions for hilighting types
- descriptions.put(IStyleConstantsXML.COMMENT_BORDER, XMLUIMessages.Comment_Delimiters_UI_); //$NON-NLS-1$ = "Comment Delimiters"
- descriptions.put(IStyleConstantsXML.COMMENT_TEXT, XMLUIMessages.Comment_Content_UI_); //$NON-NLS-1$ = "Comment Content"
- descriptions.put(IStyleConstantsXML.TAG_BORDER, XMLUIMessages.Tag_Delimiters_UI_); //$NON-NLS-1$ = "Tag Delimiters"
- descriptions.put(IStyleConstantsXML.TAG_NAME, XMLUIMessages.Tag_Names_UI_); //$NON-NLS-1$ = "Tag Names"
- descriptions.put(IStyleConstantsXML.TAG_ATTRIBUTE_NAME, XMLUIMessages.Attribute_Names_UI_); //$NON-NLS-1$ = "Attribute Names"
- descriptions.put(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE, XMLUIMessages.Attribute_Values_UI_); //$NON-NLS-1$ = "Attribute Values"
- descriptions.put(IStyleConstantsXML.DECL_BORDER, XMLUIMessages.Declaration_Delimiters_UI_); //$NON-NLS-1$ = "Declaration Delimiters"
- descriptions.put(IStyleConstantsXML.XML_CONTENT, XMLUIMessages.Content_UI_); //$NON-NLS-1$ = "Content"
- }
-
- protected void initCommonStyleList(ArrayList list) {
-
- //list.add(IStyleConstantsXML.CDATA_BORDER);
- //list.add(IStyleConstantsXML.CDATA_TEXT);
- //list.add(IStyleConstantsXML.PI_BORDER);
- //list.add(IStyleConstantsXML.PI_CONTENT);
-
- list.add(IStyleConstantsXML.TAG_BORDER);
- list.add(IStyleConstantsXML.TAG_NAME);
- list.add(IStyleConstantsXML.TAG_ATTRIBUTE_NAME);
- list.add(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE);
- list.add(IStyleConstantsXML.COMMENT_BORDER);
- list.add(IStyleConstantsXML.COMMENT_TEXT);
- list.add(IStyleConstantsXML.DECL_BORDER);
- list.add(IStyleConstantsXML.XML_CONTENT);
- }
-
- protected void initContextStyleMap(Dictionary contextStyleMap) {
-
- initCommonContextStyleMap(contextStyleMap);
- initDocTypeContextStyleMap(contextStyleMap);
- contextStyleMap.put(DOMRegionContext.XML_CDATA_OPEN, IStyleConstantsXML.CDATA_BORDER);
- contextStyleMap.put(DOMRegionContext.XML_CDATA_TEXT, IStyleConstantsXML.CDATA_TEXT);
- contextStyleMap.put(DOMRegionContext.XML_CDATA_CLOSE, IStyleConstantsXML.CDATA_BORDER);
-
- contextStyleMap.put(DOMRegionContext.XML_PI_OPEN, IStyleConstantsXML.PI_BORDER);
- contextStyleMap.put(DOMRegionContext.XML_PI_CONTENT, IStyleConstantsXML.PI_CONTENT);
- contextStyleMap.put(DOMRegionContext.XML_PI_CLOSE, IStyleConstantsXML.PI_BORDER);
-
- }
-
- protected void initDescriptions(Dictionary descriptions) {
-
- initCommonDescriptions(descriptions);
- initDocTypeDescriptions(descriptions);
- descriptions.put(IStyleConstantsXML.CDATA_BORDER, XMLUIMessages.CDATA_Delimiters_UI_); //$NON-NLS-1$ = "CDATA Delimiters"
- descriptions.put(IStyleConstantsXML.CDATA_TEXT, XMLUIMessages.CDATA_Content_UI_); //$NON-NLS-1$ = "CDATA Content"
- descriptions.put(IStyleConstantsXML.PI_BORDER, XMLUIMessages.Processing_Instruction_Del_UI_); //$NON-NLS-1$ = "Processing Instruction Delimiters"
- descriptions.put(IStyleConstantsXML.PI_CONTENT, XMLUIMessages.Processing_Instruction_Con_UI__UI_); //$NON-NLS-1$ = "Processing Instruction Content"
- }
-
- protected void initDocTypeContextStyleMap(Dictionary contextStyleMap) {
-
- contextStyleMap.put(DOMRegionContext.XML_ELEMENT_DECL_NAME, IStyleConstantsXML.DOCTYPE_NAME);
- contextStyleMap.put(DOMRegionContext.XML_DOCTYPE_DECLARATION, IStyleConstantsXML.TAG_NAME);
- contextStyleMap.put(DOMRegionContext.XML_DOCTYPE_DECLARATION_CLOSE, IStyleConstantsXML.DECL_BORDER);
-
- contextStyleMap.put(DOMRegionContext.XML_DOCTYPE_NAME, IStyleConstantsXML.DOCTYPE_NAME);
- contextStyleMap.put(DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_PUBLIC, IStyleConstantsXML.DOCTYPE_EXTERNAL_ID);
- contextStyleMap.put(DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_PUBREF, IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF);
- contextStyleMap.put(DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_SYSTEM, IStyleConstantsXML.DOCTYPE_EXTERNAL_ID);
- contextStyleMap.put(DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_SYSREF, IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF);
- }
-
- protected void initDocTypeDescriptions(Dictionary descriptions) {
-
- // create descriptions for hilighting types for DOCTYPE related items
- descriptions.put(IStyleConstantsXML.DOCTYPE_NAME, XMLUIMessages.DOCTYPE_Name_UI_); //$NON-NLS-1$ = "DOCTYPE Name"
- descriptions.put(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID, XMLUIMessages.DOCTYPE_SYSTEM_PUBLIC_Keyw_UI_); //$NON-NLS-1$ = "DOCTYPE SYSTEM/PUBLIC Keyword"
- descriptions.put(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF, XMLUIMessages.DOCTYPE_Public_Reference_UI_); //$NON-NLS-1$ = "DOCTYPE Public Reference"
- descriptions.put(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF, XMLUIMessages.DOCTYPE_System_Reference_UI_); //$NON-NLS-1$ = "DOCTYPE System Reference"
- }
-
- protected void initDocTypeStyleList(ArrayList list) {
-
- list.add(IStyleConstantsXML.DOCTYPE_NAME);
- list.add(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID);
- list.add(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF);
- list.add(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF);
- }
-
- protected void initStyleList(ArrayList list) {
- initCommonStyleList(list);
- initDocTypeStyleList(list);
- list.add(IStyleConstantsXML.CDATA_BORDER);
- list.add(IStyleConstantsXML.CDATA_TEXT);
- list.add(IStyleConstantsXML.PI_BORDER);
- list.add(IStyleConstantsXML.PI_CONTENT);
- }
-
- public boolean performOk() {
- // required since the superclass *removes* existing preferences before
- // saving its own
- super.performOk();
-
- SSEUIPlugin.getDefault().savePluginPreferences();
- return true;
- }
-
- protected void setupPicker(StyledTextColorPicker picker) {
- IModelManager mmanager = StructuredModelManager.getModelManager();
- picker.setParser(mmanager.createStructuredDocumentFor(ContentTypeIdForXML.ContentTypeID_XML).getParser());
-
- Dictionary descriptions = new Hashtable();
- initDescriptions(descriptions);
-
- Dictionary contextStyleMap = new Hashtable();
- initContextStyleMap(contextStyleMap);
-
- ArrayList styleList = new ArrayList();
- initStyleList(styleList);
-
- picker.setContextStyleMap(contextStyleMap);
- picker.setDescriptions(descriptions);
- picker.setStyleList(styleList);
- }
- /* (non-Javadoc)
- * @see org.eclipse.wst.sse.ui.preferences.ui.AbstractColorPage#savePreferences()
- */
- protected void savePreferences() {
- XMLUIPlugin.getDefault().savePluginPreferences();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLFilesPreferencePage.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLFilesPreferencePage.java
deleted file mode 100644
index 33bf3d25da..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLFilesPreferencePage.java
+++ /dev/null
@@ -1,195 +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.ui.internal.preferences;
-
-import java.util.Vector;
-
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames;
-import org.eclipse.wst.sse.ui.preferences.ui.AbstractPreferencePage;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.editor.IHelpContextIds;
-
-public class XMLFilesPreferencePage extends AbstractPreferencePage {
- protected EncodingSettings fEncodingSettings = null;
-
- protected Combo fEndOfLineCode = null;
- private Vector fEOLCodes = null;
-
- protected Control createContents(Composite parent) {
- Composite composite = (Composite) super.createContents(parent);
- WorkbenchHelp.setHelp(composite, IHelpContextIds.XML_PREFWEBX_FILES_HELPID);
- createContentsForCreatingOrSavingGroup(composite);
- createContentsForCreatingGroup(composite);
-
- setSize(composite);
- loadPreferences();
-
- return composite;
- }
-
- protected void createContentsForCreatingGroup(Composite parent) {
- Group creatingGroup = createGroup(parent, 1);
- creatingGroup.setText(XMLUIMessages.Creating_files);
-
- Label label = createLabel(creatingGroup, XMLUIMessages.Encoding_desc);
-
- fEncodingSettings = new EncodingSettings(creatingGroup, XMLUIMessages.Encoding);
- }
-
- protected void createContentsForCreatingOrSavingGroup(Composite parent) {
- Group creatingOrSavingGroup = createGroup(parent, 2);
- creatingOrSavingGroup.setText(XMLUIMessages.Creating_or_saving_files);
-
- Label label = createLabel(creatingOrSavingGroup, XMLUIMessages.End_of_line_code_desc);
- ((GridData) label.getLayoutData()).horizontalSpan = 2;
- ((GridData) label.getLayoutData()).grabExcessHorizontalSpace = true;
-
- createLabel(creatingOrSavingGroup, XMLUIMessages.End_of_line_code);
- fEndOfLineCode = createDropDownBox(creatingOrSavingGroup);
- populateLineDelimiters();
- }
-
- protected void doSavePreferenceStore() {
- XMLCorePlugin.getDefault().savePluginPreferences(); // model
- }
-
- /**
- * Return the currently selected line delimiter preference
- *
- * @return a line delimiter constant from CommonEncodingPreferenceNames
- */
- private String getCurrentEOLCode() {
- int i = fEndOfLineCode.getSelectionIndex();
- if (i >= 0) {
- return (String) (fEOLCodes.elementAt(i));
- }
- return ""; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.preferences.ui.AbstractPreferencePage#getModelPreferences()
- */
- protected Preferences getModelPreferences() {
- return XMLCorePlugin.getDefault().getPluginPreferences();
- }
-
- protected void initializeValues() {
- initializeValuesForCreatingOrSavingGroup();
- initializeValuesForCreatingGroup();
- }
-
- protected void initializeValuesForCreatingGroup() {
- String encoding = getModelPreferences().getString(CommonEncodingPreferenceNames.OUTPUT_CODESET);
-
- fEncodingSettings.setIANATag(encoding);
- }
-
- protected void initializeValuesForCreatingOrSavingGroup() {
- String endOfLineCode = getModelPreferences().getString(CommonEncodingPreferenceNames.END_OF_LINE_CODE);
-
- if (endOfLineCode.length() > 0)
- setCurrentEOLCode(endOfLineCode);
- else
- setCurrentEOLCode(CommonEncodingPreferenceNames.NO_TRANSLATION);
- }
-
- protected void performDefaults() {
- performDefaultsForCreatingOrSavingGroup();
- performDefaultsForCreatingGroup();
-
- super.performDefaults();
- }
-
- protected void performDefaultsForCreatingGroup() {
- String encoding = getModelPreferences().getDefaultString(CommonEncodingPreferenceNames.OUTPUT_CODESET);
-
- fEncodingSettings.setIANATag(encoding);
- // fEncodingSettings.resetToDefaultEncoding();
- }
-
- protected void performDefaultsForCreatingOrSavingGroup() {
- String endOfLineCode = getModelPreferences().getDefaultString(CommonEncodingPreferenceNames.END_OF_LINE_CODE);
-
- if (endOfLineCode.length() > 0)
- setCurrentEOLCode(endOfLineCode);
- else
- setCurrentEOLCode(CommonEncodingPreferenceNames.NO_TRANSLATION);
- }
-
- public boolean performOk() {
- boolean result = super.performOk();
-
- doSavePreferenceStore();
-
- return result;
- }
-
- /**
- * Populates the vector containing the line delimiter to display string
- * mapping and the combobox displaying line delimiters
- */
- private void populateLineDelimiters() {
- fEOLCodes = new Vector();
- fEndOfLineCode.add(XMLUIMessages.EOL_Unix);
- fEOLCodes.add(CommonEncodingPreferenceNames.LF);
-
- fEndOfLineCode.add(XMLUIMessages.EOL_Mac);
- fEOLCodes.add(CommonEncodingPreferenceNames.CR);
-
- fEndOfLineCode.add(XMLUIMessages.EOL_Windows);
- fEOLCodes.add(CommonEncodingPreferenceNames.CRLF);
-
- fEndOfLineCode.add(XMLUIMessages.EOL_NoTranslation);
- fEOLCodes.add(CommonEncodingPreferenceNames.NO_TRANSLATION);
- }
-
- /**
- * Select the line delimiter in the eol combobox
- *
- */
- private void setCurrentEOLCode(String eolCode) {
- // Clear the current selection.
- fEndOfLineCode.clearSelection();
- fEndOfLineCode.deselectAll();
-
- int i = fEOLCodes.indexOf(eolCode);
- if (i >= 0) {
- fEndOfLineCode.select(i);
- }
- }
-
- protected void storeValues() {
- storeValuesForCreatingOrSavingGroup();
- storeValuesForCreatingGroup();
- }
-
- protected void storeValuesForCreatingGroup() {
- getModelPreferences().setValue(CommonEncodingPreferenceNames.OUTPUT_CODESET, fEncodingSettings.getIANATag());
- }
-
- protected void storeValuesForCreatingOrSavingGroup() {
- String eolCode = getCurrentEOLCode();
- getModelPreferences().setValue(CommonEncodingPreferenceNames.END_OF_LINE_CODE, eolCode);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLSourcePreferencePage.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLSourcePreferencePage.java
deleted file mode 100644
index dd0f937ac5..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLSourcePreferencePage.java
+++ /dev/null
@@ -1,245 +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.ui.internal.preferences;
-
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.wst.sse.core.internal.preferences.CommonModelPreferenceNames;
-import org.eclipse.wst.sse.ui.preferences.ui.AbstractPreferencePage;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.editor.IHelpContextIds;
-
-public class XMLSourcePreferencePage extends AbstractPreferencePage implements ModifyListener, SelectionListener, IWorkbenchPreferencePage {
- // Content Assist
- protected Button fAutoPropose;
- protected Label fAutoProposeLabel;
- protected Text fAutoProposeText;
- protected Button fClearAllBlankLines;
- protected Button fIndentUsingTabs;
- // Formatting
- protected Label fLineWidthLabel;
- protected Text fLineWidthText;
- protected Button fSplitMultiAttrs;
- // grammar constraints
- protected Button fUseInferredGrammar;
-
- protected Control createContents(Composite parent) {
- Composite composite = (Composite) super.createContents(parent);
- WorkbenchHelp.setHelp(composite, IHelpContextIds.XML_PREFWEBX_SOURCE_HELPID);
-
- createContentsForFormattingGroup(composite);
- createContentsForContentAssistGroup(composite);
- createContentsForGrammarConstraintsGroup(composite);
- setSize(composite);
- loadPreferences();
-
- return composite;
- }
-
- protected void createContentsForContentAssistGroup(Composite parent) {
- Group contentAssistGroup = createGroup(parent, 2);
- contentAssistGroup.setText(XMLUIMessages.Content_assist_UI_);
-
- fAutoPropose = createCheckBox(contentAssistGroup, XMLUIMessages.Automatically_make_suggest_UI_);
- ((GridData) fAutoPropose.getLayoutData()).horizontalSpan = 2;
- fAutoPropose.addSelectionListener(this);
-
- fAutoProposeLabel = createLabel(contentAssistGroup, XMLUIMessages.Prompt_when_these_characte_UI_);
- fAutoProposeText = createTextField(contentAssistGroup);
- }
-
- protected void createContentsForFormattingGroup(Composite parent) {
- Group formattingGroup = createGroup(parent, 2);
- formattingGroup.setText(XMLUIMessages.Formatting_UI_);
-
- fLineWidthLabel = createLabel(formattingGroup, XMLUIMessages.Line_width__UI_);
- fLineWidthText = new Text(formattingGroup, SWT.SINGLE | SWT.BORDER);
- GridData gData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.BEGINNING);
- gData.widthHint = 25;
- fLineWidthText.setLayoutData(gData);
- fLineWidthText.addModifyListener(this);
-
- fSplitMultiAttrs = createCheckBox(formattingGroup, XMLUIMessages.Split_multiple_attributes);
- ((GridData) fSplitMultiAttrs.getLayoutData()).horizontalSpan = 2;
-
- fIndentUsingTabs = createCheckBox(formattingGroup, XMLUIMessages.Indent_using_tabs);
- ((GridData) fIndentUsingTabs.getLayoutData()).horizontalSpan = 2;
-
- fClearAllBlankLines = createCheckBox(formattingGroup, XMLUIMessages.Clear_all_blank_lines_UI_);
- ((GridData) fClearAllBlankLines.getLayoutData()).horizontalSpan = 2;
- }
-
- protected void createContentsForGrammarConstraintsGroup(Composite parent) {
- Group grammarConstraintsGroup = createGroup(parent, 1);
- grammarConstraintsGroup.setText(XMLUIMessages.Grammar_Constraints);
- grammarConstraintsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
-
- fUseInferredGrammar = createCheckBox(grammarConstraintsGroup, XMLUIMessages.Use_inferred_grammar_in_absence_of);
- }
-
- protected IPreferenceStore doGetPreferenceStore() {
- return XMLUIPlugin.getDefault().getPreferenceStore();
- }
-
- protected void doSavePreferenceStore() {
- XMLUIPlugin.getDefault().savePluginPreferences(); // editor
- XMLCorePlugin.getDefault().savePluginPreferences(); // model
- }
-
- protected void enableValues() {
- if (fAutoPropose != null) {
- if (fAutoPropose.getSelection()) {
- fAutoProposeLabel.setEnabled(true);
- fAutoProposeText.setEnabled(true);
- } else {
- fAutoProposeLabel.setEnabled(false);
- fAutoProposeText.setEnabled(false);
- }
- }
- }
-
- /**
- * @deprecated key no longer needed (preference should be stored in their own preference store)
- */
- protected String getKey(String key) {
-// String contentTypeId = IContentTypeIdentifier.ContentTypeID_SSEXML;
-// return PreferenceKeyGenerator.generateKey(key, contentTypeId);
- return key;
- }
-
- protected Preferences getModelPreferences() {
- return XMLCorePlugin.getDefault().getPluginPreferences();
- }
-
- protected void initializeValues() {
- initializeValuesForFormattingGroup();
- initializeValuesForContentAssistGroup();
- initializeValuesForGrammarConstraintsGroup();
- }
-
- protected void initializeValuesForContentAssistGroup() {
- // Content Assist
- fAutoPropose.setSelection(getPreferenceStore().getBoolean(XMLUIPreferenceNames.AUTO_PROPOSE));
- fAutoProposeText.setText(getPreferenceStore().getString(XMLUIPreferenceNames.AUTO_PROPOSE_CODE));
- }
-
- protected void initializeValuesForFormattingGroup() {
- // Formatting
- fLineWidthText.setText(getModelPreferences().getString(CommonModelPreferenceNames.LINE_WIDTH));
- fSplitMultiAttrs.setSelection(getModelPreferences().getBoolean(CommonModelPreferenceNames.SPLIT_MULTI_ATTRS));
- fIndentUsingTabs.setSelection(getModelPreferences().getBoolean(CommonModelPreferenceNames.INDENT_USING_TABS));
- fClearAllBlankLines.setSelection(getModelPreferences().getBoolean(CommonModelPreferenceNames.CLEAR_ALL_BLANK_LINES));
- }
-
- protected void initializeValuesForGrammarConstraintsGroup() {
- fUseInferredGrammar.setSelection(getPreferenceStore().getBoolean(XMLUIPreferenceNames.USE_INFERRED_GRAMMAR));
- }
-
- protected void performDefaults() {
- performDefaultsForFormattingGroup();
- performDefaultsForContentAssistGroup();
- performDefaultsForGrammarConstraintsGroup();
-
- validateValues();
- enableValues();
-
- super.performDefaults();
- }
-
- protected void performDefaultsForContentAssistGroup() {
- // Content Assist
- fAutoPropose.setSelection(getPreferenceStore().getDefaultBoolean(XMLUIPreferenceNames.AUTO_PROPOSE));
- fAutoProposeText.setText(getPreferenceStore().getDefaultString(XMLUIPreferenceNames.AUTO_PROPOSE_CODE));
- }
-
- protected void performDefaultsForFormattingGroup() {
- // Formatting
- fLineWidthText.setText(getModelPreferences().getDefaultString(CommonModelPreferenceNames.LINE_WIDTH));
- fSplitMultiAttrs.setSelection(getModelPreferences().getDefaultBoolean(CommonModelPreferenceNames.SPLIT_MULTI_ATTRS));
- fIndentUsingTabs.setSelection(getModelPreferences().getDefaultBoolean(CommonModelPreferenceNames.INDENT_USING_TABS));
- fClearAllBlankLines.setSelection(getModelPreferences().getDefaultBoolean(CommonModelPreferenceNames.CLEAR_ALL_BLANK_LINES));
- }
-
- protected void performDefaultsForGrammarConstraintsGroup() {
- fUseInferredGrammar.setSelection(getPreferenceStore().getDefaultBoolean(XMLUIPreferenceNames.USE_INFERRED_GRAMMAR));
- }
-
- public boolean performOk() {
- boolean result = super.performOk();
-
- doSavePreferenceStore();
-
- return result;
- }
-
- protected void storeValues() {
- storeValuesForFormattingGroup();
- storeValuesForContentAssistGroup();
- storeValuesForGrammarConstraintsGroup();
- }
-
- protected void storeValuesForContentAssistGroup() {
- // Content Assist
- getPreferenceStore().setValue(XMLUIPreferenceNames.AUTO_PROPOSE, fAutoPropose.getSelection());
- getPreferenceStore().setValue(XMLUIPreferenceNames.AUTO_PROPOSE_CODE, fAutoProposeText.getText());
- }
-
- protected void storeValuesForFormattingGroup() {
- // Formatting
- getModelPreferences().setValue(CommonModelPreferenceNames.LINE_WIDTH, fLineWidthText.getText());
- getModelPreferences().setValue(CommonModelPreferenceNames.SPLIT_MULTI_ATTRS, fSplitMultiAttrs.getSelection());
- getModelPreferences().setValue(CommonModelPreferenceNames.INDENT_USING_TABS, fIndentUsingTabs.getSelection());
- getModelPreferences().setValue(CommonModelPreferenceNames.CLEAR_ALL_BLANK_LINES, fClearAllBlankLines.getSelection());
- }
-
- protected void storeValuesForGrammarConstraintsGroup() {
- getPreferenceStore().setValue(XMLUIPreferenceNames.USE_INFERRED_GRAMMAR, fUseInferredGrammar.getSelection());
- }
-
- protected void validateValues() {
- boolean isError = false;
- String widthText = null;
-
- if (fLineWidthText != null) {
- try {
- widthText = fLineWidthText.getText();
- int formattingLineWidth = Integer.parseInt(widthText);
- if ((formattingLineWidth < WIDTH_VALIDATION_LOWER_LIMIT) || (formattingLineWidth > WIDTH_VALIDATION_UPPER_LIMIT))
- throw new NumberFormatException();
- } catch (NumberFormatException nfexc) {
- setInvalidInputMessage(widthText);
- setValid(false);
- isError = true;
- }
- }
-
- if (!isError) {
- setErrorMessage(null);
- setValid(true);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLTemplatePreferencePage.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLTemplatePreferencePage.java
deleted file mode 100644
index f0edb6b1c2..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLTemplatePreferencePage.java
+++ /dev/null
@@ -1,67 +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.ui.internal.preferences;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.texteditor.templates.TemplatePreferencePage;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.editor.IHelpContextIds;
-
-
-/**
- * Preference page for XML templates
- */
-public class XMLTemplatePreferencePage extends TemplatePreferencePage {
-
- public XMLTemplatePreferencePage() {
- XMLUIPlugin xmlEditorPlugin = XMLUIPlugin.getDefault();
-
- setPreferenceStore(xmlEditorPlugin.getPreferenceStore());
- setTemplateStore(xmlEditorPlugin.getTemplateStore());
- setContextTypeRegistry(xmlEditorPlugin.getTemplateContextRegistry());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
- */
- protected Control createContents(Composite ancestor) {
- Control c = super.createContents(ancestor);
- WorkbenchHelp.setHelp(c, IHelpContextIds.XML_PREFWEBX_TEMPLATES_HELPID);
- return c;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#isShowFormatterSetting()
- */
- protected boolean isShowFormatterSetting() {
- // template formatting has not been implemented
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- boolean ok = super.performOk();
- XMLUIPlugin.getDefault().savePluginPreferences();
- return ok;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceInitializer.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceInitializer.java
deleted file mode 100644
index 472ff7e395..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceInitializer.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package org.eclipse.wst.xml.ui.internal.preferences;
-
-import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.wst.sse.ui.preferences.ui.ColorHelper;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.style.IStyleConstantsXML;
-
-/**
- * Sets default values for XML UI preferences
- */
-public class XMLUIPreferenceInitializer extends AbstractPreferenceInitializer {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
- */
- public void initializeDefaultPreferences() {
- IPreferenceStore store = XMLUIPlugin.getDefault().getPreferenceStore();
-
- store.setDefault(XMLUIPreferenceNames.AUTO_PROPOSE, true);
- store.setDefault(XMLUIPreferenceNames.AUTO_PROPOSE_CODE, "<"); //$NON-NLS-1$
-
- store.setDefault(
- XMLUIPreferenceNames.USE_INFERRED_GRAMMAR, true);
-
- // XML Style Preferences
- String NOBACKGROUNDBOLD = " | null | false"; //$NON-NLS-1$
- String styleValue = ColorHelper.getColorString(127, 0, 127)
- + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.TAG_ATTRIBUTE_NAME, styleValue);
-
- styleValue = ColorHelper.getColorString(42, 0, 255) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE, styleValue);
-
- styleValue = "null" + NOBACKGROUNDBOLD; //$NON-NLS-1$
- store.setDefault(IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS, styleValue); // specified
- // value
- // is
- // black;
- // leaving
- // as
- // widget
- // default
-
- styleValue = ColorHelper.getColorString(63, 95, 191) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.COMMENT_BORDER, styleValue);
- store.setDefault(IStyleConstantsXML.COMMENT_TEXT, styleValue);
-
- styleValue = ColorHelper.getColorString(0, 128, 128) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.DECL_BORDER, styleValue);
-
- styleValue = ColorHelper.getColorString(0, 0, 128) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.DOCTYPE_NAME, styleValue);
- store.setDefault(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF,
- styleValue);
-
- styleValue = ColorHelper.getColorString(128, 128, 128)
- + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID, styleValue);
-
- styleValue = ColorHelper.getColorString(63, 127, 95) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF,
- styleValue);
-
- styleValue = "null" + NOBACKGROUNDBOLD; //$NON-NLS-1$
- store.setDefault(IStyleConstantsXML.XML_CONTENT, styleValue); // specified
- // value
- // is
- // black;
- // leaving
- // as
- // widget
- // default
-
- styleValue = ColorHelper.getColorString(0, 128, 128) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.TAG_BORDER, styleValue);
-
- styleValue = ColorHelper.getColorString(63, 127, 127)
- + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.TAG_NAME, styleValue);
-
- styleValue = ColorHelper.getColorString(0, 128, 128) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.PI_BORDER, styleValue);
-
- styleValue = "null" + NOBACKGROUNDBOLD; //$NON-NLS-1$
- store.setDefault(IStyleConstantsXML.PI_CONTENT, styleValue); // specified
- // value
- // is
- // black;
- // leaving
- // as
- // widget
- // default
-
- styleValue = ColorHelper.getColorString(0, 128, 128) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.CDATA_BORDER, styleValue);
-
- styleValue = ColorHelper.getColorString(0, 0, 0) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.CDATA_TEXT, styleValue);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceNames.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceNames.java
deleted file mode 100644
index a4e1e76ab5..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceNames.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.xml.ui.internal.preferences;
-
-/**
- * Preference keys for XML UI
- */
-public class XMLUIPreferenceNames {
- /**
- * A named preference that controls if code assist gets auto activated.
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- */
- public static final String AUTO_PROPOSE = getAutoProposeKey();
-
- private static String getAutoProposeKey() {
- return "autoPropose";//$NON-NLS-1$
- }
-
- /**
- * A named preference that holds the characters that auto activate code
- * assist.
- * <p>
- * Value is of type <code>String</code>. All characters that trigger
- * auto code assist.
- * </p>
- */
- public static final String AUTO_PROPOSE_CODE = getAutoProposeCodeKey();
-
- private static String getAutoProposeCodeKey() {
- return "autoProposeCode";//$NON-NLS-1$
- }
-
- /**
- * The key to store customized templates.
- * <p>
- * Value is of type <code>String</code>.
- * </p>
- */
- public static final String TEMPLATES_KEY = getTemplatesKey();
-
- private static String getTemplatesKey() {
- return "org.eclipse.wst.sse.ui.custom_templates"; //$NON-NLS-1$
- }
-
- /**
- * A named preference that controls whether or grammar should be inferred
- * or not.
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- */
- public static final String USE_INFERRED_GRAMMAR = getUseInferredGrammarKey();
-
- private static String getUseInferredGrammarKey() {
- return "useInferredGrammar"; //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/ProjectionModelNodeAdapterFactoryXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/ProjectionModelNodeAdapterFactoryXML.java
deleted file mode 100644
index edb91c11dc..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/ProjectionModelNodeAdapterFactoryXML.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.xml.ui.internal.projection;
-
-import org.eclipse.jface.text.source.projection.ProjectionViewer;
-import org.eclipse.wst.sse.core.AbstractAdapterFactory;
-import org.eclipse.wst.sse.core.INodeAdapter;
-import org.eclipse.wst.sse.core.INodeNotifier;
-import org.w3c.dom.Node;
-
-public class ProjectionModelNodeAdapterFactoryXML extends AbstractAdapterFactory {
- private ProjectionViewer fProjectionViewer;
-
- public ProjectionModelNodeAdapterFactoryXML() {
- super(ProjectionModelNodeAdapterXML.class, true);
- }
-
- protected INodeAdapter createAdapter(INodeNotifier target) {
- ProjectionModelNodeAdapterXML adapter = null;
-
- // create adapter for every element tag
- if ((fProjectionViewer != null) && (target instanceof Node) && ((Node) target).getNodeType() == Node.ELEMENT_NODE) {
- adapter = new ProjectionModelNodeAdapterXML(this);
- adapter.updateAdapter((Node) target);
- }
-
- return adapter;
- }
-
- ProjectionViewer getProjectionViewer() {
- return fProjectionViewer;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.AbstractAdapterFactory#release()
- */
- public void release() {
- fProjectionViewer = null;
-
- super.release();
- }
-
- void setProjectionViewer(ProjectionViewer viewer) {
- fProjectionViewer = viewer;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/ProjectionModelNodeAdapterXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/ProjectionModelNodeAdapterXML.java
deleted file mode 100644
index 3def0fe057..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/ProjectionModelNodeAdapterXML.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.xml.ui.internal.projection;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.source.projection.ProjectionAnnotation;
-import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel;
-import org.eclipse.jface.text.source.projection.ProjectionViewer;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.wst.sse.core.INodeAdapter;
-import org.eclipse.wst.sse.core.INodeNotifier;
-import org.eclipse.wst.sse.core.IndexedRegion;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.w3c.dom.Node;
-
-/**
- * Updates projection annotation model with projection annotations for this
- * adapter node's children
- */
-public class ProjectionModelNodeAdapterXML implements INodeAdapter {
-
- private class TagProjectionAnnotation extends ProjectionAnnotation {
- private boolean fIsVisible = false; /* workaround for BUG85874 */
- private Node fNode;
-
- public TagProjectionAnnotation(Node node, boolean isCollapsed) {
- super(isCollapsed);
- fNode = node;
- }
-
- public Node getNode() {
- return fNode;
- }
-
- public void setNode(Node node) {
- fNode = node;
- }
-
- /**
- * Does not paint hidden annotations. Annotations are hidden when they
- * only span one line.
- *
- * @see ProjectionAnnotation#paint(org.eclipse.swt.graphics.GC,
- * org.eclipse.swt.widgets.Canvas,
- * org.eclipse.swt.graphics.Rectangle)
- */
- public void paint(GC gc, Canvas canvas, Rectangle rectangle) {
- /* workaround for BUG85874 */
- /*
- * only need to check annotations that are expanded because hidden
- * annotations should never have been given the chance to
- * collapse.
- */
- if (!isCollapsed()) {
- // working with rectangle, so need the styledtext line height
- int lineHeight = fAdapterFactory.getProjectionViewer().getTextWidget().getLineHeight();
-
- // do not draw annotations that only span one line and mark
- // them as not visible
- if ((rectangle.height / lineHeight) <= 1) {
- fIsVisible = false;
- return;
- }
- }
- fIsVisible = true;
- super.paint(gc, canvas, rectangle);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.source.projection.ProjectionAnnotation#markCollapsed()
- */
- public void markCollapsed() {
- /* workaround for BUG85874 */
- // do not mark collapsed if annotation is not visible
- if (fIsVisible)
- super.markCollapsed();
- }
- }
-
- private final static boolean debugProjectionPerf = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.xml.ui/projectionperf")); //$NON-NLS-1$ //$NON-NLS-2$
-
- ProjectionModelNodeAdapterFactoryXML fAdapterFactory;
- private Map fTagAnnotations = new HashMap();
-
- public ProjectionModelNodeAdapterXML(ProjectionModelNodeAdapterFactoryXML factory) {
- fAdapterFactory = factory;
- }
-
- /**
- * Create a projection position from the given node. Able to get
- * projection position if node isNodeProjectable.
- *
- * @param node
- * @return null if no projection position possible, a Position otherwise
- */
- private Position createProjectionPosition(Node node) {
- Position pos = null;
- if (isNodeProjectable(node) && node instanceof IndexedRegion) {
- IDocument document = fAdapterFactory.getProjectionViewer().getDocument();
- if (document != null) {
- IndexedRegion inode = (IndexedRegion) node;
- int start = inode.getStartOffset();
- int end = inode.getEndOffset();
- if (start >= 0 && start < end) {
- try {
-// // region-based
-// // extra line when collapsed, but no region increase when add newline
-// pos = new Position(start, end - start);
-
-// // line-based
-// // extra line when collapsed, but no region increase when add newline
-// IRegion startLineRegion = document.getLineInformationOfOffset(start);
-// IRegion endLineRegion = document.getLineInformationOfOffset(end);
-// int startOffset = startLineRegion.getOffset();
-// int endOffset = endLineRegion.getOffset() + endLineRegion.getLength();
-// if (endOffset > startOffset) {
-// pos = new Position(startOffset, endOffset - startOffset);
-// }
-
- // line-based
- // no extra line when collapsed, but region increase when add newline
- int startLine = document.getLineOfOffset(start);
- int endLine = document.getLineOfOffset(end);
- if (endLine + 1 < document.getNumberOfLines()) {
- int offset = document.getLineOffset(startLine);
- int endOffset = document.getLineOffset(endLine + 1);
- pos = new Position(offset, endOffset - offset);
- }
- } catch (BadLocationException x) {
- Logger.log(Logger.WARNING_DEBUG, null, x);
- }
- }
- }
- }
- return pos;
- }
-
- /**
- * Find TagProjectionAnnotation for node in the current list of projection
- * annotations for this adapter
- *
- * @param node
- * @return TagProjectionAnnotation
- */
- private TagProjectionAnnotation getExistingAnnotation(Node node) {
- TagProjectionAnnotation anno = null;
-
- if ((node != null) && (!fTagAnnotations.isEmpty())) {
- Iterator it = fTagAnnotations.keySet().iterator();
- while (it.hasNext() && anno == null) {
- TagProjectionAnnotation a = (TagProjectionAnnotation) it.next();
- Node n = a.getNode();
- if (node.equals(n)) {
- anno = a;
- }
- }
- }
- return anno;
- }
-
- public boolean isAdapterForType(Object type) {
- return type == ProjectionModelNodeAdapterXML.class;
- }
-
- /**
- * Returns true if node is a node type able to fold
- *
- * @param node
- * @return boolean true if node is projectable, false otherwise
- */
- private boolean isNodeProjectable(Node node) {
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- return true;
- }
- return false;
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- // check if folding is even enabled, if not, just ignore notifyChanged
- // events
- if (fAdapterFactory.getProjectionViewer() == null) {
- return;
- }
-
- if ((eventType == INodeNotifier.STRUCTURE_CHANGED) && (notifier instanceof Node)) {
- updateAdapter((Node) notifier);
- }
- }
-
- /**
- * Update the projection annotation of all the nodes that are children of
- * node
- *
- * @param node
- */
- void updateAdapter(Node node) {
- long start = System.currentTimeMillis();
-
- Map additions = new HashMap();
- Map projectionAnnotations = new HashMap();
-
- // go through immediate child nodes and figure out projection
- // model annotations
- if (node != null) {
- Node childNode = node.getFirstChild();
- while (childNode != null) {
- Position newPos = createProjectionPosition(childNode);
- if (newPos != null) {
- TagProjectionAnnotation newAnnotation = new TagProjectionAnnotation(childNode, false);
- TagProjectionAnnotation existing = getExistingAnnotation(childNode);
- if (existing == null) {
- // add to map containing all annotations for this
- // adapter
- projectionAnnotations.put(newAnnotation, newPos);
- // add to map containing annotations to add
- additions.put(newAnnotation, newPos);
- } else {
- // add to map containing all annotations for this
- // adapter
- projectionAnnotations.put(existing, newPos);
- // remove from map containing annotations to delete
- fTagAnnotations.remove(existing);
- }
- }
- childNode = childNode.getNextSibling();
- }
-
- // in the end, want to delete anything leftover in old list, add
- // everything in additions, and update everything in
- // projectionAnnotations
- ProjectionAnnotation[] oldList = null;
- if (!fTagAnnotations.isEmpty()) {
- oldList = (ProjectionAnnotation[]) fTagAnnotations.keySet().toArray(new ProjectionAnnotation[0]);
- }
- ProjectionAnnotation[] modifyList = null;
- if (!projectionAnnotations.isEmpty()) {
- modifyList = (ProjectionAnnotation[]) projectionAnnotations.keySet().toArray(new ProjectionAnnotation[0]);
- }
- ProjectionViewer viewer = fAdapterFactory.getProjectionViewer();
- ProjectionAnnotationModel annotationModel = viewer.getProjectionAnnotationModel();
- annotationModel.modifyAnnotations(oldList, additions, modifyList);
- }
-
- // save new list of annotations
- fTagAnnotations = projectionAnnotations;
-
- long end = System.currentTimeMillis();
- if (debugProjectionPerf) {
- String nodeName = node != null ? node.getNodeName() : "null"; //$NON-NLS-1$
- System.out.println("ProjectionModelNodeAdapterXML.updateAdapter (" + nodeName + "):" + (end - start)); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/StructuredTextFoldingProviderXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/StructuredTextFoldingProviderXML.java
deleted file mode 100644
index 7240e058d7..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/StructuredTextFoldingProviderXML.java
+++ /dev/null
@@ -1,214 +0,0 @@
-package org.eclipse.wst.xml.ui.internal.projection;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.projection.IProjectionListener;
-import org.eclipse.jface.text.source.projection.ProjectionViewer;
-import org.eclipse.wst.sse.core.INodeNotifier;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.IndexedRegion;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.PropagatingAdapter;
-import org.eclipse.wst.sse.core.internal.model.FactoryRegistry;
-import org.eclipse.wst.sse.ui.internal.projection.IStructuredTextFoldingProvider;
-import org.eclipse.wst.xml.core.document.IDOMModel;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-/**
- * Updates the projection model of a structured model for XML.
- */
-public class StructuredTextFoldingProviderXML implements IStructuredTextFoldingProvider, IProjectionListener {
- private final static boolean debugProjectionPerf = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.xml.ui/projectionperf")); //$NON-NLS-1$ //$NON-NLS-2$
-
- private IDocument fDocument;
- private ProjectionViewer fViewer;
-
- /**
- * Adds an adapter to node and its children
- *
- * @param node
- * @param level
- */
- private void addAdapterToNodeAndChildren(Node node, int level) {
- if (node instanceof INodeNotifier) {
- INodeNotifier notifier = (INodeNotifier) node;
-
- // try and get the adapter for the current node and update the
- // adapter with projection information
- ProjectionModelNodeAdapterXML adapter = (ProjectionModelNodeAdapterXML) notifier.getExistingAdapter(ProjectionModelNodeAdapterXML.class);
- if (adapter != null) {
- adapter.updateAdapter(node);
- }
- else {
- // just call getadapter so the adapter is created and
- // automatically initialized
- notifier.getAdapterFor(ProjectionModelNodeAdapterXML.class);
- }
-
- Node nextChild = node.getFirstChild();
- while (nextChild != null) {
- Node childNode = nextChild;
- nextChild = childNode.getNextSibling();
-
- addAdapterToNodeAndChildren(childNode, level + 1);
- }
- }
- }
-
- /**
- * Goes through every node and adds an adapter onto each for tracking
- * purposes
- */
- private void addAllAdapters() {
- long start = System.currentTimeMillis();
-
- IStructuredModel sModel = null;
- try {
- sModel = StructuredModelManager.getModelManager().getExistingModelForRead(fDocument);
- if (sModel != null) {
- int startOffset = 0;
- IndexedRegion startNode = sModel.getIndexedRegion(startOffset);
- if (startNode instanceof Node) {
- int level = 0;
- Node nextSibling = (Node) startNode;
- while (nextSibling != null) {
- Node currentNode = nextSibling;
- nextSibling = currentNode.getNextSibling();
-
- addAdapterToNodeAndChildren(currentNode, level);
- }
- }
- }
- }
- finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
-
- long end = System.currentTimeMillis();
- if (debugProjectionPerf)
- System.out.println("StructuredTextFoldingProviderXML.addAllAdapters: " + (end - start)); //$NON-NLS-1$
- }
-
- /**
- * Get the ProjectionModelNodeAdapterFactoryXML to use with this provider.
- *
- * @return ProjectionModelNodeAdapterFactoryXML
- */
- private ProjectionModelNodeAdapterFactoryXML getAdapterFactory(boolean createIfNeeded) {
- long start = System.currentTimeMillis();
-
- ProjectionModelNodeAdapterFactoryXML factory = null;
- IStructuredModel sModel = null;
- try {
- sModel = StructuredModelManager.getModelManager().getExistingModelForRead(fDocument);
- if (sModel != null) {
- FactoryRegistry factoryRegistry = sModel.getFactoryRegistry();
-
- // getting the projectionmodelnodeadapter for the first time
- // so do some initializing
- if (!factoryRegistry.contains(ProjectionModelNodeAdapterXML.class) && createIfNeeded) {
- ProjectionModelNodeAdapterFactoryXML newFactory = new ProjectionModelNodeAdapterFactoryXML();
-
- // add factory to factory registry
- factoryRegistry.addFactory(newFactory);
-
- // add factory to propogating adapter
- IDOMModel domModel = (IDOMModel) sModel;
- Document document = domModel.getDocument();
- PropagatingAdapter propagatingAdapter = (PropagatingAdapter) ((INodeNotifier) document).getAdapterFor(PropagatingAdapter.class);
- if (propagatingAdapter != null) {
- propagatingAdapter.addAdaptOnCreateFactory(newFactory);
- }
- }
-
- // try and get the factory
- factory = (ProjectionModelNodeAdapterFactoryXML) factoryRegistry.getFactoryFor(ProjectionModelNodeAdapterXML.class);
- }
- }
- finally {
- if (sModel != null)
- sModel.releaseFromRead();
- }
-
- long end = System.currentTimeMillis();
- if (debugProjectionPerf)
- System.out.println("StructuredTextFoldingProviderXML.getAdapterFactory: " + (end - start)); //$NON-NLS-1$
- return factory;
- }
-
- /**
- * Initialize this provider with the correct document. Assumes projection
- * is enabled. (otherwise, only install would have been called)
- */
- public void initialize() {
- if (!isInstalled())
- return;
-
- // set projection viewer to null on old document's adapter factory
- ProjectionModelNodeAdapterFactoryXML factory = getAdapterFactory(false);
- if (factory != null) {
- factory.setProjectionViewer(null);
- }
- // clear out all annotations
- if (fViewer.getProjectionAnnotationModel() != null)
- fViewer.getProjectionAnnotationModel().removeAllAnnotations();
-
- fDocument = fViewer.getDocument();
-
- if (fDocument != null) {
- // set projection viewer on new document's adapter factory
- factory = getAdapterFactory(true);
- if (factory != null) {
- factory.setProjectionViewer(fViewer);
- }
-
- addAllAdapters();
- }
- }
-
- /**
- * Associate a ProjectionViewer with this IStructuredTextFoldingProvider
- *
- * @param viewer
- */
- public void install(ProjectionViewer viewer) {
- // uninstall before trying to install new viewer
- if (isInstalled()) {
- uninstall();
- }
- fViewer = viewer;
- fViewer.addProjectionListener(this);
- }
-
- private boolean isInstalled() {
- return fViewer != null;
- }
-
- public void projectionDisabled() {
- ProjectionModelNodeAdapterFactoryXML factory = getAdapterFactory(false);
- if (factory != null) {
- factory.setProjectionViewer(null);
- }
-
- fDocument = null;
- }
-
- public void projectionEnabled() {
- initialize();
- }
-
- /**
- * Disconnect this IStructuredTextFoldingProvider from projection viewer
- */
- public void uninstall() {
- if (isInstalled()) {
- projectionDisabled();
-
- fViewer.removeProjectionListener(this);
- fViewer = null;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/EnumeratedStringPropertyDescriptor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/EnumeratedStringPropertyDescriptor.java
deleted file mode 100644
index e302240a46..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/EnumeratedStringPropertyDescriptor.java
+++ /dev/null
@@ -1,69 +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.ui.internal.properties;
-
-
-
-import java.util.Arrays;
-
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-/**
- * This class should be used for properties which require a combo box cell
- * editor and whose values consist of a list of enumerated strings.
- */
-public class EnumeratedStringPropertyDescriptor extends PropertyDescriptor {
- protected StringComboBoxCellEditor fEditor;
- protected Composite fParent;
-
- /**
- * The enumerated possible values for the described property
- */
- protected String fValues[] = null;
-
- public EnumeratedStringPropertyDescriptor(Object id, String newDisplayName, String[] valuesArray) {
- super(id, newDisplayName);
- setDescription((String) id);
- fValues = valuesArray;
- }
-
- /**
- * Creates and returns a new cell editor for editing this property.
- * Returns <code>null</code> if the property is not editable.
- *
- * @param parent
- * the parent widget for the cell editor
- * @return the cell editor for this property, or <code>null</code> if
- * this property cannot be edited
- */
- public CellEditor createPropertyEditor(Composite parent) {
- // Check to see if we already have a Cell Editor with a valid Control
- // under the given parent.
- // If any of that's not true, create and return a new Cell Editor
- if (fEditor == null || fEditor.getControl() == null || fEditor.getControl().isDisposed() || parent != fParent)
- fEditor = new StringComboBoxCellEditor(parent, fValues);
- fParent = parent;
- return fEditor;
- }
-
- public void updateValues(String newValues[]) {
- if (Arrays.equals(fValues, newValues))
- return;
- fValues = newValues;
- if (fEditor != null) {
- fEditor.setItems(newValues);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/StringComboBoxCellEditor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/StringComboBoxCellEditor.java
deleted file mode 100644
index 05f4788a6f..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/StringComboBoxCellEditor.java
+++ /dev/null
@@ -1,111 +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.ui.internal.properties;
-
-
-
-import org.eclipse.jface.viewers.ComboBoxCellEditor;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.sse.ui.internal.Logger;
-
-
-/**
- * An extended ComboBoxCellEditor that selects and returns Strings
- */
-
-public class StringComboBoxCellEditor extends ComboBoxCellEditor {
- private boolean fSettingValue = false;
-
- /**
- *
- */
- public StringComboBoxCellEditor() {
- super();
- }
-
- /**
- * @param parent
- * @param items
- */
- public StringComboBoxCellEditor(Composite parent, String[] items) {
- super(parent, items);
- }
-
- /**
- * @param parent
- * @param items
- * @param style
- */
- public StringComboBoxCellEditor(Composite parent, String[] items, int style) {
- super(parent, items, style);
- }
-
- protected Object doGetValue() {
- // otherwise limits to set of valid values
- Object index = super.doGetValue();
- int selection = -1;
- if (index instanceof Integer)
- selection = ((Integer) index).intValue();
- if (selection >= 0)
- return getItems()[selection];
- else if (getControl() instanceof CCombo) {
- // retrieve the actual text as the list of valid items doesn't
- // contain the value
- return ((CCombo) getControl()).getText();
- }
- return null;
- }
-
- protected void doSetValue(Object value) {
- if (fSettingValue)
- return;
- fSettingValue = true;
- if (value instanceof Integer) {
- super.doSetValue(value);
- } else {
- String stringValue = value.toString();
- int selection = -1;
- for (int i = 0; i < getItems().length; i++)
- if (getItems()[i].equals(stringValue))
- selection = i;
- if (selection >= 0)
- super.doSetValue(new Integer(selection));
- else {
- super.doSetValue(new Integer(-1));
- if (getControl() instanceof CCombo && !stringValue.equals(((CCombo) getControl()).getText())) {
- // update the Text widget
- ((CCombo) getControl()).setText(stringValue);
- }
- }
- }
- fSettingValue = false;
- }
-
- public void setItems(String[] newItems) {
- if (getControl() == null || getControl().isDisposed()) {
- Logger.log(Logger.ERROR, "Attempted to update item list for disposed cell editor"); //$NON-NLS-1$
- return;
- }
-
- // keep selection if possible
- Object previousSelectedValue = getValue();
- super.setItems(newItems);
- if (previousSelectedValue != null && getControl() instanceof CCombo) {
- for (int i = 0; i < newItems.length; i++) {
- if (newItems[i].equals(previousSelectedValue))
- setValue(previousSelectedValue);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/XMLPropertySourceAdapter.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/XMLPropertySourceAdapter.java
deleted file mode 100644
index 69460c01a0..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/XMLPropertySourceAdapter.java
+++ /dev/null
@@ -1,697 +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.ui.internal.properties;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Stack;
-
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySheetEntry;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.IPropertySource2;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.eclipse.wst.sse.core.INodeAdapter;
-import org.eclipse.wst.sse.core.INodeNotifier;
-import org.eclipse.wst.sse.ui.views.properties.IPropertySourceExtension;
-import org.eclipse.wst.xml.core.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.document.DocumentTypeAdapter;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.w3c.dom.Attr;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * An IPropertySource implementation for a JFace viewer used to display
- * properties of DOM nodes. Requires an adapter factory to create JFace
- * adapters for the nodes in the tree.
- */
-public class XMLPropertySourceAdapter implements INodeAdapter, IPropertySource, IPropertySourceExtension, IPropertySource2 {
- protected final static String CATEGORY_ATTRIBUTES = XMLUIMessages.XMLPropertySourceAdapter_0; //$NON-NLS-1$
-
- private static final boolean fSetExpertFilter = false;
-
- // derive categories from CMDataTypes; disabled until display strings can
- // be planned
- private final static boolean fShouldDeriveCategories = false;
-
- private final static boolean fSortEnumeratedValues = true;
- private boolean fCaseSensitive = true;
- private IPropertyDescriptor[] fDescriptors = null;
- private Node fNode = null;
-
- private Stack fValuesBeingSet = new Stack();
-
- public XMLPropertySourceAdapter(INodeNotifier target) {
- super();
- fNode = (Node) target;
- if (fNode instanceof IDOMNode) {
- Document ownerDocument = fNode.getOwnerDocument();
- if (ownerDocument == null) {
- // if ownerDocument is null, then it must be the Document Node
- ownerDocument = (Document) fNode;
- }
- DocumentTypeAdapter adapter = (DocumentTypeAdapter) ((INodeNotifier) ownerDocument).getAdapterFor(DocumentTypeAdapter.class);
- if (adapter != null)
- fCaseSensitive = adapter.getTagNameCase() == DocumentTypeAdapter.STRICT_CASE;
- }
- }
-
- private String[] _getValidFixedStrings(CMAttributeDeclaration attrDecl, CMDataType helper) {
- String attributeName = attrDecl.getAttrName();
- List values = new ArrayList(1);
- String impliedValue = helper.getImpliedValue();
- if (impliedValue != null)
- values.add(impliedValue);
- boolean checkIfCurrentValueIsIncluded = (fNode.getAttributes() != null && fNode.getAttributes().getNamedItem(attributeName) != null && fNode.getAttributes().getNamedItem(attributeName).getNodeValue() != null);
- if (checkIfCurrentValueIsIncluded) {
- String currentValue = null;
- currentValue = fNode.getAttributes().getNamedItem(attributeName).getNodeValue();
- if (!currentValue.equals(impliedValue))
- values.add(currentValue);
- }
- String[] validStrings = new String[values.size()];
- validStrings = (String[]) values.toArray(validStrings);
- return validStrings;
- }
-
- private String[] _getValidStrings(CMAttributeDeclaration attrDecl, CMDataType valuesHelper) {
- String attributeName = attrDecl.getAttrName();
- List values = new ArrayList(1);
- boolean currentValueKnown = false;
- boolean checkIfCurrentValueIsKnown = (fNode.getAttributes() != null && fNode.getAttributes().getNamedItem(attributeName) != null && fNode.getAttributes().getNamedItem(attributeName).getNodeValue() != null);
- String currentValue = null;
- if (checkIfCurrentValueIsKnown)
- currentValue = fNode.getAttributes().getNamedItem(attributeName).getNodeValue();
-
- if (valuesHelper.getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED && valuesHelper.getImpliedValue() != null) {
- // FIXED value
- currentValueKnown = currentValue != null && valuesHelper.getImpliedValue().equals(currentValue);
- values.add(valuesHelper.getImpliedValue());
- }
- else {
- // ENUMERATED values
- String[] valueStrings = null;
- // valueStrings = valuesHelper.getEnumeratedValues();
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(fNode.getOwnerDocument());
- if (modelQuery != null && fNode.getNodeType() == Node.ELEMENT_NODE) {
- valueStrings = modelQuery.getPossibleDataTypeValues((Element) fNode, attrDecl);
- }
- else {
- valueStrings = attrDecl.getAttrType().getEnumeratedValues();
- }
- if (valueStrings != null) {
- for (int i = 0; i < valueStrings.length; i++) {
- if (checkIfCurrentValueIsKnown && valueStrings[i].equals(currentValue))
- currentValueKnown = true;
- values.add(valueStrings[i]);
- }
- }
- }
- if (valuesHelper.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE && valuesHelper.getImpliedValue() != null) {
- if (!values.contains(valuesHelper.getImpliedValue()))
- values.add(valuesHelper.getImpliedValue());
- }
-
- if (checkIfCurrentValueIsKnown && !currentValueKnown && currentValue != null && currentValue.length() > 0)
- values.add(currentValue);
- String[] validStrings = new String[values.size()];
- validStrings = (String[]) values.toArray(validStrings);
- return validStrings;
- }
-
- private IPropertyDescriptor createDefaultPropertyDescriptor(String attributeName) {
- return createDefaultPropertyDescriptor(attributeName, false);
- }
-
- private IPropertyDescriptor createDefaultPropertyDescriptor(String attributeName, boolean hideOnFilter) {
- // The descriptor class used here is also used in
- // updatePropertyDescriptors()
- TextPropertyDescriptor descriptor = new TextPropertyDescriptor(attributeName, attributeName);
- descriptor.setCategory(getCategory(null));
- descriptor.setDescription(attributeName);
- if (hideOnFilter && fSetExpertFilter)
- descriptor.setFilterFlags(new String[]{IPropertySheetEntry.FILTER_ID_EXPERT});
- return descriptor;
- }
-
- /**
- * Creates a property descriptor for an attribute with ENUMERATED values -
- * if the value does not exist, an editable combo box is returned - if the
- * value exists but is not one in the enumerated list of value, a combo
- * box featuring the current and correct values is returned - if the value
- * exists and it is a valid value, a combo box featuring the correct
- * values with the current one visible is returned
- */
- private IPropertyDescriptor createEnumeratedPropertyDescriptor(CMAttributeDeclaration attrDecl, CMDataType valuesHelper) {
- // the displayName MUST be set
- EnumeratedStringPropertyDescriptor descriptor = new EnumeratedStringPropertyDescriptor(attrDecl.getAttrName(), attrDecl.getAttrName(), _getValidStrings(attrDecl, valuesHelper));
- descriptor.setCategory(getCategory(attrDecl));
- descriptor.setDescription(attrDecl.getAttrName());
- if (attrDecl.getUsage() != CMAttributeDeclaration.REQUIRED && fSetExpertFilter)
- descriptor.setFilterFlags(new String[]{IPropertySheetEntry.FILTER_ID_EXPERT});
- return descriptor;
- }
-
- /**
- * Creates a property descriptor for an attribute with a FIXED value - if
- * the value does not exist, an editable combo box is returned - if the
- * value exists but is not the fixed/default value, a combo box featuring
- * the current and correct value is returned - if the value exists and it
- * is the fixed/default value, no cell editor is provided "locking" the
- * value in
- */
- private IPropertyDescriptor createFixedPropertyDescriptor(CMAttributeDeclaration attrDecl, CMDataType helper) {
- // the displayName MUST be set
- EnumeratedStringPropertyDescriptor descriptor = new EnumeratedStringPropertyDescriptor(attrDecl.getNodeName(), attrDecl.getNodeName(), _getValidFixedStrings(attrDecl, helper));
- descriptor.setCategory(getCategory(attrDecl));
- descriptor.setDescription(attrDecl.getAttrName());
- return descriptor;
- }
-
- protected IPropertyDescriptor createPropertyDescriptor(CMAttributeDeclaration attrDecl) {
- IPropertyDescriptor descriptor = null;
- CMDataType attrType = attrDecl.getAttrType();
-
- if (attrType != null) {
- // handle declarations that provide FIXED/ENUMERATED values
- if (attrType.getEnumeratedValues() != null && attrType.getEnumeratedValues().length > 0) {
- descriptor = createEnumeratedPropertyDescriptor(attrDecl, attrType);
- }
- else if ((attrDecl.getUsage() == CMAttributeDeclaration.FIXED || attrType.getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED) && attrType.getImpliedValue() != null) {
- descriptor = createFixedPropertyDescriptor(attrDecl, attrType);
- }
- else {
- // plain text
- descriptor = createTextPropertyDescriptor(attrDecl);
- }
- }
- else {
- // no extra information given
- descriptor = createTextPropertyDescriptor(attrDecl);
- }
- return descriptor;
- }
-
- /**
- * Returns the current collection of property descriptors.
- *
- * @return all valid descriptors.
- */
- private IPropertyDescriptor[] createPropertyDescriptors() {
- CMNamedNodeMap attrMap = null;
- CMElementDeclaration ed = getDeclaration();
- if (ed != null) {
- attrMap = ed.getAttributes();
- }
-
- List descriptorList = new ArrayList();
- List names = new ArrayList();
- IPropertyDescriptor descriptor;
-
- CMAttributeDeclaration attrDecl = null;
-
- // add descriptors for existing attributes
- NamedNodeMap attributes = fNode.getAttributes();
- if (attributes != null) {
- for (int i = 0; i < attributes.getLength(); i++) {
- Attr attr = (Attr) attributes.item(i);
- // if metainfo is present for this attribute, use the
- // CMAttributeDeclaration to derive a descriptor
- if (attrMap != null) {
- String attrName = attr.getName();
- if (fCaseSensitive)
- attrDecl = (CMAttributeDeclaration) attrMap.getNamedItem(attrName);
- else {
- for (int j = 0; j < attrMap.getLength(); j++) {
- if (!fCaseSensitive && attrMap.item(j).getNodeName().equalsIgnoreCase(attrName)) {
- attrDecl = (CMAttributeDeclaration) attrMap.item(j);
- break;
- }
- }
- }
- }
- // be consistent: if there's metainfo, use *that* as the
- // descriptor ID
- if (attrDecl != null) {
- descriptor = createPropertyDescriptor(attrDecl);
- if (descriptor != null)
- names.add(attrDecl.getNodeName());
- }
- else {
- descriptor = createDefaultPropertyDescriptor(attr.getName());
- if (descriptor != null)
- names.add(attr.getName());
- }
- if (descriptor != null)
- descriptorList.add(descriptor);
- }
- }
-
- // add descriptors from the metainfo that are not yet listed
- if (attrMap != null) {
- for (int i = 0; i < attrMap.getLength(); i++) {
- attrDecl = (CMAttributeDeclaration) attrMap.item(i);
- if (!names.contains(attrDecl.getAttrName())) {
- IPropertyDescriptor holdDescriptor = createPropertyDescriptor(attrDecl);
- if (holdDescriptor != null) {
- descriptorList.add(holdDescriptor);
- }
- }
- }
- }
-
- IPropertyDescriptor[] descriptors = new IPropertyDescriptor[descriptorList.size()];
- for (int i = 0; i < descriptors.length; i++)
- descriptors[i] = (IPropertyDescriptor) descriptorList.get(i);
- return descriptors;
- }
-
- private IPropertyDescriptor createTextPropertyDescriptor(CMAttributeDeclaration attrDecl) {
- TextPropertyDescriptor descriptor = new TextPropertyDescriptor(attrDecl.getAttrName(), attrDecl.getAttrName());
- descriptor.setCategory(getCategory(attrDecl));
- descriptor.setDescription(attrDecl.getAttrName());
- if (attrDecl.getUsage() != CMAttributeDeclaration.REQUIRED && fSetExpertFilter)
- descriptor.setFilterFlags(new String[]{IPropertySheetEntry.FILTER_ID_EXPERT});
- return descriptor;
- }
-
- private String getCategory(CMAttributeDeclaration attrDecl) {
- if (attrDecl != null) {
- if (attrDecl.supports("category")) { //$NON-NLS-1$
- return (String) attrDecl.getProperty("category"); //$NON-NLS-1$
- }
- if (fShouldDeriveCategories && attrDecl.getAttrType() != null && attrDecl.getAttrType().getNodeName() != null && attrDecl.getAttrType().getNodeName().length() > 0) {
- return attrDecl.getAttrType().getDataTypeName();
- }
- }
- return CATEGORY_ATTRIBUTES;
- }
-
- private CMElementDeclaration getDeclaration() {
- if (fNode == null || fNode.getNodeType() != Node.ELEMENT_NODE)
- return null;
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(fNode.getOwnerDocument());
- if (modelQuery != null) {
- return modelQuery.getCMElementDeclaration((Element) fNode);
- }
- return null;
- }
-
- private Display getDisplay() {
-
- return PlatformUI.getWorkbench().getDisplay();
- }
-
- /**
- * Returns a value for this Node that can be editted in a property sheet.
- *
- * @return a value that can be editted
- */
- public Object getEditableValue() {
- return null;
- }
-
- /**
- * Returns the current collection of property descriptors.
- *
- * @return all valid descriptors.
- */
- public IPropertyDescriptor[] getPropertyDescriptors() {
- if (fDescriptors == null || fDescriptors.length == 0) {
- fDescriptors = createPropertyDescriptors();
- }
- else {
- updatePropertyDescriptors();
- }
- return fDescriptors;
- }
-
- /**
- * Returns the current value for the named property.
- *
- */
- public Object getPropertyValue(Object nameObject) {
- String name = nameObject.toString();
- String returnedValue = null;
- NamedNodeMap attrMap = fNode.getAttributes();
- if (attrMap != null) {
- Node attribute = attrMap.getNamedItem(name);
- if (attribute != null) {
- if (attribute instanceof IDOMNode)
- returnedValue = ((IDOMNode) attribute).getValueSource();
- else
- returnedValue = attribute.getNodeValue();
- }
- }
- if (returnedValue == null)
- returnedValue = ""; //$NON-NLS-1$
- return returnedValue;
- }
-
- private String[] getValidValues(CMAttributeDeclaration attrDecl) {
- if (attrDecl == null)
- return new String[0];
-
- String[] validValues = null;
- CMDataType attrType = attrDecl.getAttrType();
- if (attrType != null) {
- validValues = _getValidStrings(attrDecl, attrType);
- if (fSortEnumeratedValues)
- Arrays.sort(validValues);
- }
- if (validValues == null)
- validValues = new String[0];
- return validValues;
- }
-
- /**
- * Allowing the INodeAdapter to compare itself against the type allows it
- * to return true in more than one case.
- */
- public boolean isAdapterForType(Object type) {
- return type == IPropertySource.class;
- }
-
- public boolean isPropertyRemovable(Object id) {
- return true;
- }
-
- public boolean isPropertyResettable(Object id) {
- boolean resettable = false;
- String property = id.toString();
- CMNamedNodeMap attrDecls = null;
-
- CMElementDeclaration ed = getDeclaration();
- if (ed != null) {
- attrDecls = ed.getAttributes();
- }
-
- if (attrDecls != null) {
- CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) attrDecls.getNamedItem(property);
- if (attrDecl != null) {
- if (attrDecl.getAttrType() != null) {
- CMDataType helper = attrDecl.getAttrType();
- if (helper.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE && helper.getImpliedValue() != null) {
- resettable = true;
- }
- }
- }
- }
- return resettable;
- }
-
- /**
- * Returns whether the property value has changed from the default.
- *
- * @return <code>true</code> if the value of the specified property has
- * changed from its original default value; <code>false</code>
- * otherwise.
- */
- public boolean isPropertySet(Object propertyObject) {
- String property = propertyObject.toString();
-
- NamedNodeMap attrMap = fNode.getAttributes();
- if (attrMap != null)
- return attrMap.getNamedItem(property) != null;
- return false;
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, java.lang.Object changedFeature, java.lang.Object oldValue, java.lang.Object newValue, int pos) {
- }
-
- /**
- * Remove the given attribute from the Node
- *
- * @param propertyObject
- */
- public void removeProperty(Object propertyObject) {
- NamedNodeMap attrMap = fNode.getAttributes();
- if (attrMap != null) {
- Node attribute = attrMap.getNamedItem(propertyObject.toString());
- if (attribute != null) {
- try {
- attrMap.removeNamedItem(propertyObject.toString());
- }
- catch (DOMException e) {
- if (e.code != DOMException.INVALID_MODIFICATION_ERR) {
- Logger.logException(e);
- }
- }
- }
- }
- }
-
- /**
- * Resets the specified property's value to its default value.
- *
- */
- public void resetPropertyValue(Object propertyObject) {
- String property = propertyObject.toString();
- CMNamedNodeMap attrDecls = null;
-
- CMElementDeclaration ed = getDeclaration();
- if (ed != null) {
- attrDecls = ed.getAttributes();
- }
-
- NamedNodeMap attrMap = fNode.getAttributes();
- if (attrDecls != null) {
- CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) attrDecls.getNamedItem(property);
- String defValue = null;
- if (attrDecl != null) {
- if (attrDecl.getAttrType() != null) {
- CMDataType helper = attrDecl.getAttrType();
- if (helper.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE && helper.getImpliedValue() != null)
- defValue = helper.getImpliedValue();
- }
- }
- if (defValue != null && defValue.length() > 0) {
- ((Attr) attrMap.getNamedItem(property)).setValue(defValue);
- }
- else {
- attrMap.removeNamedItem(property);
- }
- }
- else {
- attrMap.removeNamedItem(property);
- }
- }
-
- /**
- * Sets the named property to the given value.
- *
- */
- public void setPropertyValue(Object nameObject, Object value) {
- // Avoid cycling - can happen if a closing cell editor causes a
- // refresh
- // on the PropertySheet page and the setInput again asks the editor to
- // close; besides, why apply the same value twice?
- if (!fValuesBeingSet.isEmpty() && fValuesBeingSet.peek() == nameObject)
- return;
- fValuesBeingSet.push(nameObject);
- String name = nameObject.toString();
- String valueString = null;
- if (value != null)
- valueString = value.toString();
- NamedNodeMap attrMap = fNode.getAttributes();
- try {
- if (attrMap != null) {
- Attr attr = (Attr) attrMap.getNamedItem(name);
- if (attr != null) {
- // EXISTING VALUE
- // potential out of control loop if updating the value
- // triggers a viewer update, forcing the
- // active cell editor to save its value and causing the
- // loop to continue
- if (attr.getValue() == null || !attr.getValue().equals(valueString)) {
- if (attr instanceof IDOMNode)
- ((IDOMNode) attr).setValueSource(valueString);
- else
- attr.setValue(valueString);
- }
- }
- else {
- // NEW(?) value
- if (value != null) { // never create an empty attribute
- Attr newAttr = fNode.getOwnerDocument().createAttribute(name);
- if (newAttr instanceof IDOMNode)
- ((IDOMNode) newAttr).setValueSource(valueString);
- else
- newAttr.setValue(valueString);
- attrMap.setNamedItem(newAttr);
- }
- }
- }
- else {
- if (fNode instanceof Element) {
- ((Element) fNode).setAttribute(name, valueString);
- }
- }
- }
- catch (DOMException e) {
- Display d = getDisplay();
- if (d != null)
- d.beep();
- }
- fValuesBeingSet.pop();
- }
-
- protected void updatePropertyDescriptors() {
- if (fDescriptors == null || fDescriptors.length == 0)
- // Nothing to update
- return;
-
- // List of all names encountered in the tag and defined by the element
- List declaredNames = new ArrayList();
- // New descriptor list that will become fDescriptors after all
- // processing is done
- List descriptors = new ArrayList();
- // Names of the descriptors in the above List
- List descriptorNames = new ArrayList();
-
- // Update any descriptors derived from the metainfo
- CMElementDeclaration ed = getDeclaration();
- CMNamedNodeMap attrMap = null;
- if (ed != null) {
- attrMap = ed.getAttributes();
- }
- // Update exiting descriptors; not added to the final list here
- if (attrMap != null) {
- // Update existing descriptor types based on metainfo
- CMAttributeDeclaration attrDecl = null;
- for (int i = 0; i < attrMap.getLength(); i++) {
- attrDecl = (CMAttributeDeclaration) attrMap.item(i);
- String attrName = attrDecl.getAttrName();
- if (!declaredNames.contains(attrName)) {
- declaredNames.add(attrName);
- }
- for (int j = 0; j < fDescriptors.length; j++) {
- boolean sameName = (fCaseSensitive && fDescriptors[j].getId().equals(attrDecl.getNodeName())) || (!fCaseSensitive && attrDecl.getNodeName().equals(fDescriptors[j].getId().toString()));
- if (sameName) {
- String[] validValues = getValidValues(attrDecl);
- // Update the descriptor for this
- // CMAttributeDeclaration (only enumerated values get
- // updated for now)
- if (fDescriptors[j] instanceof EnumeratedStringPropertyDescriptor) {
- ((EnumeratedStringPropertyDescriptor) fDescriptors[j]).updateValues(validValues);
- }
- // Replace with better descriptor
- else if (validValues != null && validValues.length > 0) {
- fDescriptors[j] = createPropertyDescriptor(attrDecl);
- }
- }
- }
- }
- }
- else {
- // Update existing descriptors based on not having any metainfo
- for (int j = 0; j < fDescriptors.length; j++) {
- // Replace with basic descriptor
- if (!(fDescriptors[j] instanceof TextPropertyDescriptor)) {
- fDescriptors[j] = createDefaultPropertyDescriptor((String) fDescriptors[j].getId());
- }
- }
- }
-
- NamedNodeMap attributes = fNode.getAttributes();
-
- // Remove descriptors for attributes that aren't present AND aren't
- // known through metainfo,
- // do this by only reusing existing descriptors for attributes that
- // are present or declared
- for (int i = 0; i < fDescriptors.length; i++) {
- if (fDescriptors[i] != null) {
- String descriptorName = fDescriptors[i].getId().toString();
- if ((declaredNames.contains(descriptorName) || (attributes.getNamedItem(descriptorName) != null)) && !descriptorNames.contains(descriptorName)) {
- descriptorNames.add(descriptorName);
- descriptors.add(fDescriptors[i]);
- }
- }
- }
-
- // Add descriptors for declared attributes that don't already have one
- if (attrMap != null) {
- // Update existing descriptor types based on metainfo
- CMAttributeDeclaration attrDecl = null;
- for (int i = 0; i < attrMap.getLength(); i++) {
- attrDecl = (CMAttributeDeclaration) attrMap.item(i);
- String attrName = attrDecl.getAttrName();
- if (fCaseSensitive) {
- if (!descriptorNames.contains(attrName)) {
- IPropertyDescriptor descriptor = createPropertyDescriptor(attrDecl);
- if (descriptor != null) {
- descriptorNames.add(attrName);
- descriptors.add(descriptor);
- }
- }
- }
- else {
- boolean exists = false;
- for (int j = 0; j < descriptorNames.size(); j++)
- exists = (descriptorNames.get(j).toString().equalsIgnoreCase(attrName)) || exists;
- if (!exists) {
- descriptorNames.add(attrName);
- IPropertyDescriptor descriptor = createPropertyDescriptor(attrDecl);
- if (descriptor != null) {
- descriptorNames.add(attrName);
- descriptors.add(descriptor);
- }
- }
- }
- }
- }
-
- // Add descriptors for existing attributes that don't already have one
- if (attributes != null) {
- for (int i = 0; i < attributes.getLength(); i++) {
- Attr attr = (Attr) attributes.item(i);
- String attrName = attr.getName();
- if (fCaseSensitive) {
- if (!descriptorNames.contains(attrName)) {
- descriptorNames.add(attrName);
- descriptors.add(createDefaultPropertyDescriptor(attrName));
- }
- }
- else {
- boolean exists = false;
- for (int j = 0; j < descriptorNames.size(); j++)
- exists = (descriptorNames.get(j).toString().equalsIgnoreCase(attrName)) || exists;
- if (!exists) {
- descriptorNames.add(attrName);
- descriptors.add(createDefaultPropertyDescriptor(attrName));
- }
- }
- }
- }
-
- // Update fDescriptors
- IPropertyDescriptor[] newDescriptors = new IPropertyDescriptor[descriptors.size()];
- for (int i = 0; i < newDescriptors.length; i++)
- newDescriptors[i] = (IPropertyDescriptor) descriptors.get(i);
- fDescriptors = newDescriptors;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/XMLPropertySourceAdapterFactory.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/XMLPropertySourceAdapterFactory.java
deleted file mode 100644
index 00187485e5..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/XMLPropertySourceAdapterFactory.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.properties;
-
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.wst.sse.core.AbstractAdapterFactory;
-import org.eclipse.wst.sse.core.INodeAdapterFactory;
-import org.eclipse.wst.sse.core.INodeAdapter;
-import org.eclipse.wst.sse.core.INodeNotifier;
-
-public class XMLPropertySourceAdapterFactory extends AbstractAdapterFactory {
-
- public XMLPropertySourceAdapterFactory() {
- super(IPropertySource.class, true);
- }
-
- public XMLPropertySourceAdapterFactory(Object adapterType, boolean registerAdapters) {
- super(adapterType, registerAdapters);
- }
-
- public INodeAdapterFactory copy() {
- return new XMLPropertySourceAdapterFactory(this.adapterKey, this.shouldRegisterAdapter);
- }
-
- protected INodeAdapter createAdapter(INodeNotifier target) {
- // at the moment, only one implementation exists
- return new XMLPropertySourceAdapter(target);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/registry/AdapterFactoryProviderForEmbeddedXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/registry/AdapterFactoryProviderForEmbeddedXML.java
deleted file mode 100644
index d40fbec88b..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/registry/AdapterFactoryProviderForEmbeddedXML.java
+++ /dev/null
@@ -1,40 +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.ui.internal.registry;
-
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler;
-import org.eclipse.wst.sse.ui.registry.embedded.EmbeddedAdapterFactoryProvider;
-import org.eclipse.wst.xml.core.document.IDOMDocument;
-import org.eclipse.wst.xml.core.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.modelhandler.EmbeddedXML;
-
-
-public class AdapterFactoryProviderForEmbeddedXML implements EmbeddedAdapterFactoryProvider {
-
- /*
- * @see AdapterFactoryProvider#addAdapterFactories(IStructuredModel)
- */
- public void addAdapterFactories(IStructuredModel structuredModel) {
- if (structuredModel instanceof IDOMModel) {
- IDOMDocument doc = ((IDOMModel) structuredModel).getDocument();
- }
- }
-
- /*
- * @see AdapterFactoryProvider#isFor(ContentTypeDescription)
- */
- public boolean isFor(EmbeddedTypeHandler contentTypeDescription) {
- return (contentTypeDescription instanceof EmbeddedXML);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/registry/AdapterFactoryProviderForXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/registry/AdapterFactoryProviderForXML.java
deleted file mode 100644
index 368304a085..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/registry/AdapterFactoryProviderForXML.java
+++ /dev/null
@@ -1,103 +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.ui.internal.registry;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.wst.sse.core.INodeAdapterFactory;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.ltk.modelhandler.IDocumentTypeHandler;
-import org.eclipse.wst.sse.core.internal.model.FactoryRegistry;
-import org.eclipse.wst.sse.core.internal.util.Assert;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
-import org.eclipse.wst.sse.ui.registry.AdapterFactoryProvider;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelhandler.ModelHandlerForXML;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.ui.internal.DOMObserver;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeAdapterFactory;
-import org.eclipse.wst.xml.ui.internal.preferences.XMLUIPreferenceNames;
-import org.eclipse.wst.xml.ui.internal.properties.XMLPropertySourceAdapterFactory;
-
-/**
- *
- */
-public class AdapterFactoryProviderForXML implements AdapterFactoryProvider {
-
- /*
- * @see AdapterFactoryProvider#addAdapterFactories(IStructuredModel)
- */
- public void addAdapterFactories(IStructuredModel structuredModel) {
-
- // add the normal content based factories to model's registry
- addContentBasedFactories(structuredModel);
- }
-
- protected void addContentBasedFactories(IStructuredModel structuredModel) {
- FactoryRegistry factoryRegistry = structuredModel.getFactoryRegistry();
- Assert.isNotNull(factoryRegistry, "Program Error: client caller must ensure model has factory registry"); //$NON-NLS-1$
- INodeAdapterFactory factory = null;
- // == this list came from the previous "XML only" list
-
- // what was this still here? (6/4/03)
- // I commented out on 6/4/03) but may have been something "extra"
- // initializing
- // old content assist adapter unnecessarily?
- //factory =
- // factoryRegistry.getFactoryFor(com.ibm.sed.edit.adapters.ContentAssistAdapter.class);
-
- factory = factoryRegistry.getFactoryFor(IPropertySource.class);
- if (factory == null) {
- factory = new XMLPropertySourceAdapterFactory();
- factoryRegistry.addFactory(factory);
- }
- factory = factoryRegistry.getFactoryFor(IJFaceNodeAdapter.class);
- if (factory == null) {
- factory = new JFaceNodeAdapterFactory();
- factoryRegistry.addFactory(factory);
- }
-
- // cs... added for inferred grammar support
- //
- if (structuredModel != null) {
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(structuredModel);
- if (modelQuery != null) {
- CMDocumentManager documentManager = modelQuery.getCMDocumentManager();
- if (documentManager != null) {
- IPreferenceStore store = XMLUIPlugin.getDefault().getPreferenceStore();
- boolean useInferredGrammar = (store != null) ? store.getBoolean(XMLUIPreferenceNames.USE_INFERRED_GRAMMAR) : true;
-
- documentManager.setPropertyEnabled(CMDocumentManager.PROPERTY_ASYNC_LOAD, true);
- documentManager.setPropertyEnabled(CMDocumentManager.PROPERTY_AUTO_LOAD, false);
- documentManager.setPropertyEnabled(CMDocumentManager.PROPERTY_USE_CACHED_RESOLVED_URI, true);
- DOMObserver domObserver = new DOMObserver(structuredModel);
- domObserver.setGrammarInferenceEnabled(useInferredGrammar);
- domObserver.init();
- }
- }
- }
- }
-
- /*
- * @see AdapterFactoryProvider#isFor(ContentTypeDescription)
- */
- public boolean isFor(IDocumentTypeHandler contentTypeDescription) {
- return (contentTypeDescription instanceof ModelHandlerForXML);
- }
-
- public void reinitializeFactories(IStructuredModel structuredModel) {
- // nothing to do, since no embedded type
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesAction.java
deleted file mode 100644
index fefe761e78..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesAction.java
+++ /dev/null
@@ -1,51 +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.ui.internal.search;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.ui.internal.search.BasicFindOccurrencesAction;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.core.text.IXMLPartitions;
-
-
-
-/**
- * <p>
- * Configures a BasicFindOccurrencesAction with XML partitions and regions
- * </p>
- *
- * <p>
- * Uses default <code>getSearchQuery()</code>.
- * </p>
- *
- * @author pavery
- */
-public class XMLFindOccurrencesAction extends BasicFindOccurrencesAction {
-
- public XMLFindOccurrencesAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
- super(bundle, prefix, editor);
- }
-
- public String[] getPartitionTypes() {
-
- return new String[]{IXMLPartitions.XML_DEFAULT};
- }
-
- public String[] getRegionTypes() {
-
- return new String[]{DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE};
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/style/IStyleConstantsXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/style/IStyleConstantsXML.java
deleted file mode 100644
index c14086fb80..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/style/IStyleConstantsXML.java
+++ /dev/null
@@ -1,41 +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.ui.internal.style;
-
-/**
- * Contains the symbolic name of styles used by LineStyleProvider,
- * ColorManager, and any others who may be interested
- */
-public interface IStyleConstantsXML {
- public static final String BACKGROUND = "background"; //$NON-NLS-1$
- public static final String CDATA_BORDER = "cdataBorder";//$NON-NLS-1$
- public static final String CDATA_TEXT = "cdataText";//$NON-NLS-1$
- public static final String COMMENT_BORDER = "commentBorder";//$NON-NLS-1$
- public static final String COMMENT_TEXT = "commentText";//$NON-NLS-1$
- public static final String DECL_BORDER = "declBoder";//$NON-NLS-1$
- public static final String DOCTYPE_EXTERNAL_ID = "doctypeExternalId";//$NON-NLS-1$
- public static final String DOCTYPE_EXTERNAL_ID_PUBREF = "doctypeExternalPubref";//$NON-NLS-1$
- public static final String DOCTYPE_EXTERNAL_ID_SYSREF = "doctypeExtrenalSysref";//$NON-NLS-1$
- public static final String DOCTYPE_NAME = "doctypeName";//$NON-NLS-1$
-
- public static final String FOREGROUND = "foreground"; //$NON-NLS-1$
- public static final String PI_BORDER = "piBorder";//$NON-NLS-1$
- public static final String PI_CONTENT = "piContent";//$NON-NLS-1$
-
- public static final String TAG_ATTRIBUTE_EQUALS = "tagAttributeEquals"; //$NON-NLS-1$
- public static final String TAG_ATTRIBUTE_NAME = "tagAttributeName";//$NON-NLS-1$
- public static final String TAG_ATTRIBUTE_VALUE = "tagAttributeValue";//$NON-NLS-1$
- public static final String TAG_BORDER = "tagBorder";//$NON-NLS-1$
- public static final String TAG_NAME = "tagName";//$NON-NLS-1$
- public static final String XML_CONTENT = "xmlContent";//$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/style/LineStyleProviderForXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/style/LineStyleProviderForXML.java
deleted file mode 100644
index 3055e4eea2..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/style/LineStyleProviderForXML.java
+++ /dev/null
@@ -1,173 +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.ui.internal.style;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.ui.style.AbstractLineStyleProvider;
-import org.eclipse.wst.sse.ui.style.LineStyleProvider;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-public class LineStyleProviderForXML extends AbstractLineStyleProvider implements LineStyleProvider {
- public LineStyleProviderForXML() {
- super();
- loadColors();
- }
-
- protected void clearColors() {
- getTextAttributes().clear();
- }
-
- protected TextAttribute getAttributeFor(ITextRegion region) {
- /**
- * a method to centralize all the "format rules" for regions
- * specifically associated for how to "open" the region.
- */
- // not sure why this is coming through null, but just to catch it
- if (region == null) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.CDATA_TEXT);
- }
- String type = region.getType();
- if ((type == DOMRegionContext.XML_CONTENT) || (type == DOMRegionContext.XML_DOCTYPE_INTERNAL_SUBSET)) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.XML_CONTENT);
- } else if ((type == DOMRegionContext.XML_TAG_OPEN) || (type == DOMRegionContext.XML_END_TAG_OPEN) || (type == DOMRegionContext.XML_TAG_CLOSE) || (type == DOMRegionContext.XML_EMPTY_TAG_CLOSE)) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.TAG_BORDER);
- } else if ((type == DOMRegionContext.XML_CDATA_OPEN) || (type == DOMRegionContext.XML_CDATA_CLOSE)) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.CDATA_BORDER);
- } else if (type == DOMRegionContext.XML_CDATA_TEXT) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.CDATA_TEXT);
- } else if (type == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.TAG_ATTRIBUTE_NAME);
- } else if (type == DOMRegionContext.XML_DOCTYPE_DECLARATION) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.TAG_NAME);
- } else if (type == DOMRegionContext.XML_TAG_NAME) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.TAG_NAME);
- } else if ((type == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE);
- } else if (type == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS);
- } else if ((type == DOMRegionContext.XML_COMMENT_OPEN) || (type == DOMRegionContext.XML_COMMENT_CLOSE)) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.COMMENT_BORDER);
- } else if (type == DOMRegionContext.XML_COMMENT_TEXT) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.COMMENT_TEXT);
- } else if (type == DOMRegionContext.XML_DOCTYPE_NAME) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.DOCTYPE_NAME);
- } else if (type == DOMRegionContext.XML_PI_CONTENT) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.PI_CONTENT);
- } else if ((type == DOMRegionContext.XML_PI_OPEN) || (type == DOMRegionContext.XML_PI_CLOSE)) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.PI_BORDER);
- } else if ((type == DOMRegionContext.XML_DECLARATION_OPEN) || (type == DOMRegionContext.XML_DECLARATION_CLOSE)) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.DECL_BORDER);
- } else if (type == DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_SYSREF) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF);
- } else if (type == DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_PUBREF) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF);
- } else if (type == DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_PUBLIC || type == DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_SYSTEM) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID);
- } else if (type == DOMRegionContext.UNDEFINED) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.CDATA_TEXT);
- } else if (type == DOMRegionContext.WHITE_SPACE) {
- // white space is normall not on its own ... but when it is, we'll
- // treat as content
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.XML_CONTENT);
- } else if ((type == DOMRegionContext.XML_CHAR_REFERENCE) || (type == DOMRegionContext.XML_ENTITY_REFERENCE) || (type == DOMRegionContext.XML_PE_REFERENCE)) {
- // we may want to character and entity references to have it own
- // color in future,
- // but for now, we'll make attribute value
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE);
- } else {
- // default, return null to signal "not handled"
- // in which case, other factories should be tried
- return null;
- }
- }
-
- protected IPreferenceStore getColorPreferences() {
- return XMLUIPlugin.getDefault().getPreferenceStore();
- }
-
- protected void handlePropertyChange(PropertyChangeEvent event) {
- String styleKey = null;
-
- if (event != null) {
- String prefKey = event.getProperty();
- // check if preference changed is a style preference
- if (IStyleConstantsXML.TAG_NAME.equals(prefKey)) {
- styleKey = IStyleConstantsXML.TAG_NAME;
- } else if (IStyleConstantsXML.TAG_BORDER.equals(prefKey)) {
- styleKey = IStyleConstantsXML.TAG_BORDER;
- } else if (IStyleConstantsXML.TAG_ATTRIBUTE_NAME.equals(prefKey)) {
- styleKey = IStyleConstantsXML.TAG_ATTRIBUTE_NAME;
- } else if (IStyleConstantsXML.TAG_ATTRIBUTE_VALUE.equals(prefKey)) {
- styleKey = IStyleConstantsXML.TAG_ATTRIBUTE_VALUE;
- } else if (IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS.equals(prefKey)) {
- styleKey = IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS;
- } else if (IStyleConstantsXML.COMMENT_BORDER.equals(prefKey)) {
- styleKey = IStyleConstantsXML.COMMENT_BORDER;
- } else if (IStyleConstantsXML.COMMENT_TEXT.equals(prefKey)) {
- styleKey = IStyleConstantsXML.COMMENT_TEXT;
- } else if (IStyleConstantsXML.CDATA_BORDER.equals(prefKey)) {
- styleKey = IStyleConstantsXML.CDATA_BORDER;
- } else if (IStyleConstantsXML.CDATA_TEXT.equals(prefKey)) {
- styleKey = IStyleConstantsXML.CDATA_TEXT;
- } else if (IStyleConstantsXML.DECL_BORDER.equals(prefKey)) {
- styleKey = IStyleConstantsXML.DECL_BORDER;
- } else if (IStyleConstantsXML.DOCTYPE_EXTERNAL_ID.equals(prefKey)) {
- styleKey = IStyleConstantsXML.DOCTYPE_EXTERNAL_ID;
- } else if (IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF.equals(prefKey)) {
- styleKey = IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF;
- } else if (IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF.equals(prefKey)) {
- styleKey = IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF;
- } else if (IStyleConstantsXML.DOCTYPE_NAME.equals(prefKey)) {
- styleKey = IStyleConstantsXML.DOCTYPE_NAME;
- } else if (IStyleConstantsXML.PI_CONTENT.equals(prefKey)) {
- styleKey = IStyleConstantsXML.PI_CONTENT;
- } else if (IStyleConstantsXML.PI_BORDER.equals(prefKey)) {
- styleKey = IStyleConstantsXML.PI_BORDER;
- } else if (IStyleConstantsXML.XML_CONTENT.equals(prefKey)) {
- styleKey = IStyleConstantsXML.XML_CONTENT;
- }
- }
-
- if (styleKey != null) {
- // overwrite style preference with new value
- addTextAttribute(styleKey);
- super.handlePropertyChange(event);
- }
- }
-
- protected void loadColors() {
- clearColors();
-
- addTextAttribute(IStyleConstantsXML.TAG_NAME);
- addTextAttribute(IStyleConstantsXML.TAG_BORDER);
- addTextAttribute(IStyleConstantsXML.TAG_ATTRIBUTE_NAME);
- addTextAttribute(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE);
- addTextAttribute(IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS);
- addTextAttribute(IStyleConstantsXML.COMMENT_BORDER);
- addTextAttribute(IStyleConstantsXML.COMMENT_TEXT);
- addTextAttribute(IStyleConstantsXML.CDATA_BORDER);
- addTextAttribute(IStyleConstantsXML.CDATA_TEXT);
- addTextAttribute(IStyleConstantsXML.DECL_BORDER);
- addTextAttribute(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID);
- addTextAttribute(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF);
- addTextAttribute(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF);
- addTextAttribute(IStyleConstantsXML.DOCTYPE_NAME);
- addTextAttribute(IStyleConstantsXML.PI_CONTENT);
- addTextAttribute(IStyleConstantsXML.PI_BORDER);
- addTextAttribute(IStyleConstantsXML.XML_CONTENT);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/MarkupTagInfoProvider.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/MarkupTagInfoProvider.java
deleted file mode 100644
index 860a4f9735..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/MarkupTagInfoProvider.java
+++ /dev/null
@@ -1,174 +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.ui.internal.taginfo;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocumentation;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDescriptionBuilder;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-/**
- * Provides basic tag information such as element/attribute name, data type,
- * and tag info/documentation for CMNodes. Uses HTML to enhance presentation.
- */
-public class MarkupTagInfoProvider {
- protected final static String BOLD_END = "</b>"; //$NON-NLS-1$
- protected final static String BOLD_START = "<b>"; //$NON-NLS-1$
- protected final static String HEADING_END = "</h5>"; //$NON-NLS-1$
- protected final static String HEADING_START = "<h5>"; //$NON-NLS-1$
- protected final static String LIST_BEGIN = "<ul>"; //$NON-NLS-1$
- protected final static String LIST_ELEMENT = "<li>"; //$NON-NLS-1$
- protected final static String NEW_LINE = "<dl>"; //$NON-NLS-1$
- protected final static String PARAGRAPH_END = "</p>"; //$NON-NLS-1$
- protected final static String PARAGRAPH_START = "<p>"; //$NON-NLS-1$
- protected final static String SPACE = " "; //$NON-NLS-1$
-
- /**
- * Returns basic tag information for display given a CMNode
- *
- * @return String
- */
- public String getInfo(CMNode node) {
- if (node == null)
- return null;
- StringBuffer sb = new StringBuffer();
- // we assume that if there is tagInfo present, only display tagInfo
- printTagInfo(sb, node);
-
- // no tagInfo present, so try to display tag description
- if (sb.length() == 0) {
- printDescription(sb, node);
- }
-
- // no tag description present either, so display default info
- if (sb.length() == 0) {
- printDefaultInfo(node, sb);
- }
-
- return sb.toString();
- }
-
- /**
- * Adds dataType's data type information, including enumerated type values
- * to string buffer, sb
- *
- */
- protected void printDataTypeInfo(StringBuffer sb, CMDataType dataType) {
- String dataTypeName = dataType.getNodeName();
- if ((dataTypeName != null) && (dataTypeName.length() > 0)) {
- sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Data_Type____4 + SPACE + BOLD_END);
- sb.append(dataTypeName);
- sb.append(PARAGRAPH_END);
- }
- String[] enumeratedValue = dataType.getEnumeratedValues();
- if (enumeratedValue != null && enumeratedValue.length > 0) {
- sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Enumerated_Values____5 + SPACE + BOLD_END);
- sb.append(LIST_BEGIN);
- for (int i = 0; i < enumeratedValue.length; i++) {
- sb.append(LIST_ELEMENT + enumeratedValue[i]);
- }
- sb.append(PARAGRAPH_END);
- }
- }
-
- /**
- * Adds the default info (element name, content model, data type) of
- * CMNode to the string buffer, sb
- *
- */
- protected void printDefaultInfo(CMNode node, StringBuffer sb) {
- {
-
- if (node.getNodeType() == CMNode.ELEMENT_DECLARATION) {
- CMElementDeclaration ed = (CMElementDeclaration) node;
- sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Element____1 + SPACE + BOLD_END);
- sb.append(node.getNodeName());
- sb.append(PARAGRAPH_END);
- if (ed.getContentType() == CMElementDeclaration.PCDATA) {
- CMDataType dataType = ed.getDataType();
- if (dataType != null) {
- printDataTypeInfo(sb, dataType);
- }
- } else {
- CMDescriptionBuilder builder = new CMDescriptionBuilder();
- String description = builder.buildDescription(node);
- if ((description != null) && (description.length() > 0)) {
- sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Content_Model____2 + SPACE + BOLD_END);
- sb.append(description + PARAGRAPH_END);
- }
- }
- printDocumentation(sb, node);
- } else if (node.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
- CMAttributeDeclaration ad = (CMAttributeDeclaration) node;
- sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Attribute____3 + SPACE + BOLD_END);
- sb.append(node.getNodeName());
- sb.append(PARAGRAPH_END);
- CMDataType dataType = ad.getAttrType();
- if (dataType != null) {
- printDataTypeInfo(sb, dataType);
- }
- printDocumentation(sb, node);
- } else if (node.getNodeType() == CMNode.DATA_TYPE) {
- sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Data_Type____4 + SPACE + BOLD_END);
- sb.append(node.getNodeName());
- sb.append(PARAGRAPH_END);
- printDocumentation(sb, node);
- }
- }
- }
-
- /**
- * Adds the description property of the CMNode to the string buffer, sb
- *
- */
- protected void printDescription(StringBuffer sb, CMNode node) {
- String tagInfo = (String) node.getProperty("description"); //$NON-NLS-1$
- if (tagInfo != null) {
- sb.append(PARAGRAPH_START + tagInfo.trim() + PARAGRAPH_END);
- }
- }
-
- /**
- * Adds the tag documentation property of the CMNode to the string buffer,
- * sb
- *
- */
- protected void printDocumentation(StringBuffer sb, CMNode node) {
- CMNodeList nodeList = (CMNodeList) node.getProperty("documentation"); //$NON-NLS-1$
- if ((nodeList != null) && (nodeList.getLength() > 0)) {
- sb.append(NEW_LINE);
- for (int i = 0; i < nodeList.getLength(); i++) {
- CMDocumentation documentation = (CMDocumentation) nodeList.item(i);
- String doc = documentation.getValue();
- if (doc != null) {
- sb.append(PARAGRAPH_START + doc.trim() + PARAGRAPH_END);
- }
- }
- }
- }
-
- /**
- * Adds the tag info property of the CMNode to the string buffer, sb
- *
- */
- protected void printTagInfo(StringBuffer sb, CMNode node) {
- String tagInfo = (String) node.getProperty("tagInfo"); //$NON-NLS-1$
- if (tagInfo != null) {
- sb.append(PARAGRAPH_START + tagInfo.trim() + PARAGRAPH_END);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLBestMatchHoverProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLBestMatchHoverProcessor.java
deleted file mode 100644
index 25e8f0aa0c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLBestMatchHoverProcessor.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.taginfo;
-
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.wst.sse.ui.taginfo.AbstractBestMatchHoverProcessor;
-
-
-/**
- * Provides the best xml hover help documentation (by using other hover help
- * processors) Priority of hover help processors is: ProblemHoverProcessor,
- * XMLTagInfoHoverProcessor, AnnotationHoverProcessor
- */
-public class XMLBestMatchHoverProcessor extends AbstractBestMatchHoverProcessor {
- XMLTagInfoHoverProcessor fTagInfoHover;
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.structured.taginfo.AbstractBestMatchHoverProcessor#getTagInfoHover()
- */
- protected ITextHover getTagInfoHover() {
- if (fTagInfoHover == null) {
- fTagInfoHover = new XMLTagInfoHoverProcessor();
- }
- return fTagInfoHover;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLInformationProvider.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLInformationProvider.java
deleted file mode 100644
index ac4e54d2e4..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLInformationProvider.java
+++ /dev/null
@@ -1,64 +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.ui.internal.taginfo;
-
-
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.information.IInformationProvider;
-import org.eclipse.jface.text.information.IInformationProviderExtension;
-
-/**
- * Provides context information for XML tags (Shows tooltip description)
- *
- * @author amywu
- */
-public class XMLInformationProvider implements IInformationProvider, IInformationProviderExtension {
-
- private XMLBestMatchHoverProcessor fTextHover = null;
-
- public XMLInformationProvider() {
- fTextHover = new XMLBestMatchHoverProcessor();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.information.IInformationProvider#getInformation(org.eclipse.jface.text.ITextViewer,
- * org.eclipse.jface.text.IRegion)
- */
- public String getInformation(ITextViewer textViewer, IRegion subject) {
- return (String) getInformation2(textViewer, subject);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.information.IInformationProviderExtension#getInformation2(org.eclipse.jface.text.ITextViewer,
- * org.eclipse.jface.text.IRegion)
- */
- public Object getInformation2(ITextViewer textViewer, IRegion subject) {
- return fTextHover.getHoverInfo(textViewer, subject);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.information.IInformationProvider#getSubject(org.eclipse.jface.text.ITextViewer,
- * int)
- */
- public IRegion getSubject(ITextViewer textViewer, int offset) {
- return fTextHover.getHoverRegion(textViewer, offset);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLTagInfoHoverProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLTagInfoHoverProcessor.java
deleted file mode 100644
index 9f4e7eece0..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLTagInfoHoverProcessor.java
+++ /dev/null
@@ -1,334 +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.ui.internal.taginfo;
-
-
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Region;
-import org.eclipse.wst.sse.core.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.util.Debug;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.xml.core.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-/**
- * Provides hover help documentation for xml tags
- *
- * @author amywu
- * @see org.eclipse.jface.text.ITextHover
- */
-public class XMLTagInfoHoverProcessor implements ITextHover {
- protected MarkupTagInfoProvider fInfoProvider = null;
-
- /**
- * Constructor for XMLTextHoverProcessor.
- */
- public XMLTagInfoHoverProcessor() {
- }
-
- /**
- * Retreives documentation to display in the hover help popup.
- *
- * @return String any documentation information to display
- * <code>null</code> if there is nothing to display.
- *
- */
- protected String computeHoverHelp(ITextViewer textViewer, int documentPosition) {
- String result = null;
-
- IndexedRegion treeNode = ContentAssistUtils.getNodeAt((StructuredTextViewer) textViewer, documentPosition);
- if (treeNode == null)
- return null;
- Node node = (Node) treeNode;
-
- while (node != null && node.getNodeType() == Node.TEXT_NODE && node.getParentNode() != null)
- node = node.getParentNode();
- IDOMNode parentNode = (IDOMNode) node;
-
- IStructuredDocumentRegion flatNode = ((IStructuredDocument) textViewer.getDocument()).getRegionAtCharacterOffset(documentPosition);
- if (flatNode != null) {
- ITextRegion region = flatNode.getRegionAtCharacterOffset(documentPosition);
- if (region != null) {
- result = computeRegionHelp(treeNode, parentNode, flatNode, region);
- }
- }
-
- return result;
- }
-
- /**
- * Computes the hoverhelp based on region
- *
- * @return String hoverhelp
- */
- protected String computeRegionHelp(IndexedRegion treeNode, IDOMNode parentNode, IStructuredDocumentRegion flatNode, ITextRegion region) {
- String result = null;
- if (region == null)
- return null;
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_TAG_NAME)
- result = computeTagNameHelp((IDOMNode) treeNode, parentNode, flatNode, region);
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)
- result = computeTagAttNameHelp((IDOMNode) treeNode, parentNode, flatNode, region);
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)
- result = computeTagAttValueHelp((IDOMNode) treeNode, parentNode, flatNode, region);
- return result;
- }
-
- /**
- * Computes the hover help for the attribute name
- */
- protected String computeTagAttNameHelp(IDOMNode xmlnode, IDOMNode parentNode, IStructuredDocumentRegion flatNode, ITextRegion region) {
- CMElementDeclaration elementDecl = getCMElementDeclaration(xmlnode);
- String attName = flatNode.getText(region);
- CMAttributeDeclaration attDecl = getCMAttributeDeclaration(elementDecl, attName);
- return getAdditionalInfo(elementDecl, attDecl);
- }
-
- /**
- * Computes the hover help for the attribute value (this is the same as
- * the attribute name's help)
- */
- protected String computeTagAttValueHelp(IDOMNode xmlnode, IDOMNode parentNode, IStructuredDocumentRegion flatNode, ITextRegion region) {
- CMElementDeclaration elementDecl = getCMElementDeclaration(xmlnode);
- ITextRegion attrNameRegion = getAttrNameRegion(xmlnode, region);
-
- String attName = flatNode.getText(attrNameRegion);
- CMAttributeDeclaration attDecl = getCMAttributeDeclaration(elementDecl, attName);
- return getAdditionalInfo(elementDecl, attDecl);
- }
-
- /**
- * Computes the hover help for the tag name
- */
- protected String computeTagNameHelp(IDOMNode xmlnode, IDOMNode parentNode, IStructuredDocumentRegion flatNode, ITextRegion region) {
- CMElementDeclaration elementDecl = getCMElementDeclaration(xmlnode);
- CMElementDeclaration pelementDecl = getCMElementDeclaration(parentNode);
- return getAdditionalInfo(pelementDecl, elementDecl);
- }
-
- /**
- * Retreives cmnode's documentation to display in the hover help popup. If
- * no documentation exists for cmnode, try displaying parentOrOwner's
- * documentation
- *
- * @return 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;
-
- if (cmnode == null) {
- if (Debug.displayWarnings) {
- new IllegalArgumentException("Null declaration!").printStackTrace(); //$NON-NLS-1$
- }
- return null;
- }
-
- addlInfo = getInfoProvider().getInfo(cmnode);
- if (addlInfo == null && parentOrOwner != null)
- addlInfo = getInfoProvider().getInfo(parentOrOwner);
- return addlInfo;
- }
-
- /**
- * Find the region of the attribute name for the given attribute value
- * region
- *
- */
- protected ITextRegion getAttrNameRegion(IDOMNode node, ITextRegion region) {
- // Find the attribute name for which this position should have a value
- IStructuredDocumentRegion open = node.getFirstStructuredDocumentRegion();
- ITextRegionList openRegions = open.getRegions();
- int i = openRegions.indexOf(region);
- if (i < 0)
- return null;
- ITextRegion nameRegion = null;
- while (i >= 0) {
- nameRegion = openRegions.get(i--);
- if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)
- break;
- }
- return nameRegion;
- }
-
- /**
- * Retreives CMAttributeDeclaration indicated by attribute name within
- * elementDecl
- */
- protected CMAttributeDeclaration getCMAttributeDeclaration(CMElementDeclaration elementDecl, String attName) {
- CMAttributeDeclaration attrDecl = null;
-
- if (elementDecl != null) {
- CMNamedNodeMap attributes = elementDecl.getAttributes();
- String noprefixName = DOMNamespaceHelper.getUnprefixedName(attName);
- if (attributes != null) {
- attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(noprefixName);
- if (attrDecl == null) {
- attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(attName);
- }
- }
- }
- return attrDecl;
- }
-
- /**
- * Retreives CMElementDeclaration for given node
- *
- * @return CMElementDeclaration - CMElementDeclaration of node or
- * <code>null</code> if not possible
- */
- protected CMElementDeclaration getCMElementDeclaration(Node node) {
- CMElementDeclaration result = null;
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(node.getOwnerDocument());
- if (modelQuery != null)
- result = modelQuery.getCMElementDeclaration((Element) node);
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer,
- * org.eclipse.jface.text.IRegion)
- */
- public String getHoverInfo(ITextViewer viewer, IRegion hoverRegion) {
- if ((hoverRegion == null) || (viewer == null) || (viewer.getDocument() == null))
- return null;
-
- String displayText = null;
- int documentOffset = hoverRegion.getOffset();
- displayText = computeHoverHelp(viewer, documentOffset);
-
- return displayText;
- }
-
- /**
- * Returns the region to hover the text over based on the offset.
- *
- * @param textViewer
- * @param offset
- *
- * @return IRegion region to hover over if offset is within tag name,
- * attribute name, or attribute value and if offset is not over
- * invalid whitespace. otherwise, returns <code>null</code>
- *
- * @see ITextHover#getHoverRegion(ITextViewer, int)
- */
- public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
- if ((textViewer == null) || (textViewer.getDocument() == null))
- return null;
-
- IStructuredDocumentRegion flatNode = ((IStructuredDocument) textViewer.getDocument()).getRegionAtCharacterOffset(offset);
- ITextRegion region = null;
-
- if (flatNode != null) {
- region = flatNode.getRegionAtCharacterOffset(offset);
- }
-
- if (region != null) {
- // only supply hoverhelp for tag name, attribute name, or
- // attribute value
- String regionType = region.getType();
- if ((regionType == DOMRegionContext.XML_TAG_NAME) || (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) || (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) {
- try {
- // check if we are at whitespace before or after line
- IRegion line = textViewer.getDocument().getLineInformationOfOffset(offset);
- if ((offset > (line.getOffset())) && (offset < (line.getOffset() + line.getLength()))) {
- // check if we are in region's trailing whitespace
- // (whitespace after relevant info)
- if (offset < flatNode.getTextEndOffset(region)) {
- return new Region(flatNode.getStartOffset(region), region.getTextLength());
- }
- }
- } catch (BadLocationException e) {
- Logger.logException(e);
- }
- }
- }
- return null;
- }
-
- /**
- * @deprecated if enabled flag is false, dont call getHoverRegion in the
- * first place if true, use getHoverRegion(ITextViewer, int)
- */
- public IRegion getHoverRegion(ITextViewer textViewer, int offset, boolean enabled) {
- if ((!enabled) || (textViewer == null) || (textViewer.getDocument() == null))
- return null;
-
- IStructuredDocumentRegion flatNode = ((IStructuredDocument) textViewer.getDocument()).getRegionAtCharacterOffset(offset);
- ITextRegion region = null;
-
- if (flatNode != null) {
- region = flatNode.getRegionAtCharacterOffset(offset);
- }
-
- if (region != null) {
- // only supply hoverhelp for tag name, attribute name, or
- // attribute value
- String regionType = region.getType();
- if ((regionType == DOMRegionContext.XML_TAG_NAME) || (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) || (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) {
- try {
- // check if we are at whitespace before or after line
- IRegion line = textViewer.getDocument().getLineInformationOfOffset(offset);
- if ((offset > (line.getOffset())) && (offset < (line.getOffset() + line.getLength()))) {
- // check if we are in region's trailing whitespace
- // (whitespace after relevant info)
- if (offset < flatNode.getTextEndOffset(region)) {
- return new Region(flatNode.getStartOffset(region), region.getTextLength());
- }
- }
- } catch (BadLocationException e) {
- Logger.logException(e);
- }
- }
- }
- return null;
- }
-
- /**
- * Gets the infoProvider.
- *
- * @return Returns fInfoProvider and if fInfoProvider was
- * <code>null</code> set fInfoProvider to DefaultInfoProvider
- */
- public MarkupTagInfoProvider getInfoProvider() {
- if (fInfoProvider == null) {
- fInfoProvider = new MarkupTagInfoProvider();
- }
- return fInfoProvider;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/EncodingTemplateVariableResolverXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/EncodingTemplateVariableResolverXML.java
deleted file mode 100644
index 079b04270c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/EncodingTemplateVariableResolverXML.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.xml.ui.internal.templates;
-
-import org.eclipse.jface.text.templates.SimpleTemplateVariableResolver;
-import org.eclipse.jface.text.templates.TemplateContext;
-import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-
-public class EncodingTemplateVariableResolverXML extends SimpleTemplateVariableResolver {
- private static final String ENCODING_TYPE = getEncodingType();
-
- private static String getEncodingType() {
- return "encoding"; //$NON-NLS-1$
- }
-
- /**
- * Creates a new encoding variable
- */
- public EncodingTemplateVariableResolverXML() {
- super(ENCODING_TYPE, XMLUIMessages.Creating_files_encoding);
- }
-
- protected String resolve(TemplateContext context) {
- return XMLCorePlugin.getDefault().getPluginPreferences().getString(CommonEncodingPreferenceNames.OUTPUT_CODESET);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/TemplateContextTypeIdsXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/TemplateContextTypeIdsXML.java
deleted file mode 100644
index 07b2f781e8..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/TemplateContextTypeIdsXML.java
+++ /dev/null
@@ -1,50 +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.ui.internal.templates;
-
-public class TemplateContextTypeIdsXML {
-
- public static final String ALL = getAll();
-
- public static final String ATTRIBUTE = getAttribute();
-
- public static final String ATTRIBUTE_VALUE = getAttributeValue();
-
- public static final String NEW = getNew();
-
- public static final String TAG = getTag();
-
- private static String getAll() {
- return getPrefix() + "_all"; //$NON-NLS-1$
- }
-
- private static String getAttribute() {
- return getPrefix() + "_attribute"; //$NON-NLS-1$
- }
-
- private static String getAttributeValue() {
- return getPrefix() + "_attribute_value"; //$NON-NLS-1$
- }
-
- private static String getNew() {
- return getPrefix() + "_new"; //$NON-NLS-1$
- }
-
- private static String getPrefix() {
- return "xml"; //$NON-NLS-1$
- }
-
- private static String getTag() {
- return getPrefix() + "_tag"; //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/TemplateContextTypeXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/TemplateContextTypeXML.java
deleted file mode 100644
index 43ccf20924..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/TemplateContextTypeXML.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.xml.ui.internal.templates;
-
-import org.eclipse.jface.text.templates.GlobalTemplateVariables;
-import org.eclipse.jface.text.templates.TemplateContextType;
-
-/**
- * Base class for XML template context types. Templates of this context type
- * apply to any place within XML content type.
- */
-public class TemplateContextTypeXML extends TemplateContextType {
-
- public TemplateContextTypeXML() {
- super();
- addResolver(new GlobalTemplateVariables.Cursor());
- addResolver(new GlobalTemplateVariables.Date());
- addResolver(new GlobalTemplateVariables.Dollar());
- addResolver(new GlobalTemplateVariables.LineSelection());
- addResolver(new GlobalTemplateVariables.Time());
- addResolver(new GlobalTemplateVariables.User());
- addResolver(new GlobalTemplateVariables.WordSelection());
- addResolver(new GlobalTemplateVariables.Year());
- addResolver(new EncodingTemplateVariableResolverXML());
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/text/XMLDocumentRegionEdgeMatcher.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/text/XMLDocumentRegionEdgeMatcher.java
deleted file mode 100644
index 42feaa293f..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/text/XMLDocumentRegionEdgeMatcher.java
+++ /dev/null
@@ -1,25 +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.ui.internal.text;
-
-import org.eclipse.wst.sse.ui.text.DocumentRegionEdgeMatcher;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-public class XMLDocumentRegionEdgeMatcher extends DocumentRegionEdgeMatcher {
-
-
- public XMLDocumentRegionEdgeMatcher() {
- super(new String[]{DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_COMMENT_TEXT, DOMRegionContext.XML_CDATA_TEXT, DOMRegionContext.XML_PI_OPEN, DOMRegionContext.XML_PI_CONTENT}, null);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentoutline/XMLContentOutlineConfiguration.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentoutline/XMLContentOutlineConfiguration.java
deleted file mode 100644
index 282f973632..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentoutline/XMLContentOutlineConfiguration.java
+++ /dev/null
@@ -1,239 +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.ui.internal.views.contentoutline;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.TransferDragSourceListener;
-import org.eclipse.jface.util.TransferDropTargetListener;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.wst.common.ui.dnd.ObjectTransfer;
-import org.eclipse.wst.common.ui.dnd.ViewerDragAdapter;
-import org.eclipse.wst.common.ui.dnd.ViewerDropAdapter;
-import org.eclipse.wst.sse.core.INodeAdapterFactory;
-import org.eclipse.wst.sse.ui.internal.IReleasable;
-import org.eclipse.wst.sse.ui.view.events.NodeSelectionChangedEvent;
-import org.eclipse.wst.sse.ui.views.contentoutline.StructuredContentOutlineConfiguration;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeContentProvider;
-import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeLabelProvider;
-import org.eclipse.wst.xml.ui.internal.contentoutline.XMLNodeActionManager;
-import org.eclipse.wst.xml.ui.internal.dnd.XMLDragAndDropManager;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-
-public class XMLContentOutlineConfiguration extends StructuredContentOutlineConfiguration {
- private IContentProvider fContentProvider = null;
- private ILabelProvider fLabelProvider = null;
-
- private class ActionManagerMenuListener implements IMenuListener, IReleasable {
- private XMLNodeActionManager fActionManager;
- private TreeViewer fTreeViewer;
-
- public ActionManagerMenuListener(TreeViewer viewer) {
- fTreeViewer = viewer;
- fActionManager = createNodeActionManager(fTreeViewer);
- }
-
- public void menuAboutToShow(IMenuManager manager) {
- if (fActionManager != null)
- fActionManager.fillContextMenu(manager, fTreeViewer.getSelection());
- }
-
- public void release() {
- fTreeViewer = null;
- fActionManager.setModel(null);
- }
- }
-
- protected ActionManagerMenuListener fContextMenuFiller = null;
-
- private TransferDragSourceListener[] fTransferDragSourceListeners;
- private TransferDropTargetListener[] fTransferDropTargetListeners;
-
- public XMLContentOutlineConfiguration() {
- super();
- }
-
- protected XMLNodeActionManager createNodeActionManager(TreeViewer treeViewer) {
- return new XMLNodeActionManager(getEditor().getModel(), treeViewer);
- }
-
- public IContentProvider getContentProvider(TreeViewer viewer) {
- if (fContentProvider == null) {
- if (getFactory() != null) {
- fContentProvider = new JFaceNodeContentProvider((INodeAdapterFactory) getFactory());
- } else {
- fContentProvider = super.getContentProvider(viewer);
- }
- }
- return fContentProvider;
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getLabelProvider(org.eclipse.jface.viewers.TreeViewer)
- */
- public ILabelProvider getLabelProvider(TreeViewer viewer) {
- if (fLabelProvider == null) {
- if (getFactory() != null) {
- fLabelProvider = new JFaceNodeLabelProvider((INodeAdapterFactory) getFactory());
- } else {
- fLabelProvider = super.getLabelProvider(viewer);
- }
- }
- return fLabelProvider;
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getMenuListener(org.eclipse.jface.viewers.TreeViewer)
- */
- public IMenuListener getMenuListener(TreeViewer viewer) {
- if (fContextMenuFiller == null) {
- fContextMenuFiller = new ActionManagerMenuListener(viewer);
- }
- return fContextMenuFiller;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getNodes(java.util.List)
- */
- public List getNodes(List nodes) {
- List filteredNodes = new ArrayList(super.getNodes(nodes));
- for (int i = 0; i < filteredNodes.size(); i++) {
- Object selectedNode = filteredNodes.get(i);
- if (selectedNode instanceof Node) {
- Node eachNode = (Node) selectedNode;
- // replace attribute node in selection with its parent
- if (eachNode.getNodeType() == Node.ATTRIBUTE_NODE)
- filteredNodes.set(i, ((Attr) eachNode).getOwnerElement());
- // replace TextNode in selection with its parent
- else if (eachNode.getNodeType() == Node.TEXT_NODE)
- filteredNodes.set(i, eachNode.getParentNode());
- }
- }
- return filteredNodes;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getSelectedNodes(org.eclipse.wst.sse.ui.view.events.NodeSelectionChangedEvent)
- */
- public List getSelectedNodes(NodeSelectionChangedEvent event) {
- return getNodes(super.getSelectedNodes(event));
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getTransferDragSourceListeners(org.eclipse.jface.viewers.TreeViewer)
- */
- public TransferDragSourceListener[] getTransferDragSourceListeners(TreeViewer treeViewer) {
- if (fTransferDragSourceListeners == null) {
- // emulate the XMLDragAndDropManager
- final ViewerDragAdapter dragAdapter = new ViewerDragAdapter(treeViewer);
- fTransferDragSourceListeners = new TransferDragSourceListener[]{new TransferDragSourceListener() {
- public void dragFinished(DragSourceEvent event) {
- dragAdapter.dragFinished(event);
- }
-
- public void dragSetData(DragSourceEvent event) {
- dragAdapter.dragSetData(event);
- }
-
- public void dragStart(DragSourceEvent event) {
- dragAdapter.dragStart(event);
- }
-
- public Transfer getTransfer() {
- return ObjectTransfer.getInstance();
- }
- }};
- }
-
- return fTransferDragSourceListeners;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getTransferDropTargetListeners(org.eclipse.jface.viewers.TreeViewer)
- */
- public TransferDropTargetListener[] getTransferDropTargetListeners(TreeViewer treeViewer) {
- if (fTransferDropTargetListeners == null) {
- // emulate the XMLDragAnDropManager
- final ViewerDropAdapter dropAdapter = new ViewerDropAdapter(treeViewer, new XMLDragAndDropManager());
- fTransferDropTargetListeners = new TransferDropTargetListener[]{new TransferDropTargetListener() {
- public void dragEnter(DropTargetEvent event) {
- dropAdapter.dragEnter(event);
- }
-
- public void dragLeave(DropTargetEvent event) {
- dropAdapter.dragLeave(event);
- }
-
- public void dragOperationChanged(DropTargetEvent event) {
- dropAdapter.dragOperationChanged(event);
- }
-
- public void dragOver(DropTargetEvent event) {
- dropAdapter.dragOver(event);
- }
-
- public void drop(DropTargetEvent event) {
- dropAdapter.drop(event);
- }
-
- public void dropAccept(DropTargetEvent event) {
- dropAdapter.dropAccept(event);
- }
-
- public Transfer getTransfer() {
- return ObjectTransfer.getInstance();
- }
-
- public boolean isEnabled(DropTargetEvent event) {
- return getTransfer().isSupportedType(event.currentDataType);
- }
- }};
- }
- return fTransferDropTargetListeners;
- }
-
- public void unconfigure(TreeViewer viewer) {
- super.unconfigure(viewer);
- fTransferDragSourceListeners = null;
- fTransferDropTargetListeners = null;
- if (fContextMenuFiller != null) {
- fContextMenuFiller.release();
- fContextMenuFiller = null;
- }
- // TODO: Add DnD support
- // XMLDragAndDropManager.addDragAndDropSupport(fTreeViewer);
- }
- /* (non-Javadoc)
- * @see org.eclipse.wst.sse.ui.views.contentoutline.StructuredContentOutlineConfiguration#getPreferenceStore()
- */
- protected IPreferenceStore getPreferenceStore() {
- return XMLUIPlugin.getDefault().getPreferenceStore();
- }
-}

Back to the top