Skip to main content

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

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.xml.ui/src-catalog/org')
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/AdvancedOptionsDialog.java229
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/CatalogFileTypeRegistryReader.java90
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/EditCatalogEntryDialog.java1816
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ElementNodePage.java38
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ImageFactory.java201
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/URIUtils.java54
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntriesView.java304
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntryDetailsView.java194
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogFileType.java51
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogMessages.java162
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogPreferencePage.java235
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogResources.properties141
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogTreeViewer.java301
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLQuickScan.java107
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/catalogEntry.gifbin1736 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/delegateCatalog.gifbin1783 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/nextCatalog.gifbin1701 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/prefix.gifbin1237 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/rewrite.gifbin1230 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/sufix.gifbin1226 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/catalog_entry.gifbin329 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/delegate_catalog.gifbin596 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/entry_obj.pngbin4129 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/file_expand.gifbin323 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/file_obj.gifbin561 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/nextCatalog_obj.gifbin608 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/next_catalog.gifbin621 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/rewrite_entry.gifbin323 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/suffix_entry.gifbin325 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/xmlcatalog_obj.gifbin598 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/ovr16/error-overlay.gifbin82 -> 0 bytes
31 files changed, 0 insertions, 3923 deletions
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/AdvancedOptionsDialog.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/AdvancedOptionsDialog.java
deleted file mode 100644
index ac1dec6230..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/AdvancedOptionsDialog.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2006 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.catalog;
-
-import java.io.ByteArrayInputStream;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.window.Window;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.dialogs.SaveAsDialog;
-import org.eclipse.wst.common.ui.internal.dialogs.SelectSingleFileDialog;
-import org.eclipse.wst.xml.core.internal.catalog.CatalogSet;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-public class AdvancedOptionsDialog extends Dialog {
- protected ICatalog workingUserCatalog;
-
- public AdvancedOptionsDialog(Shell parentShell, ICatalog workingUserCatalog) {
- super(parentShell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- this.workingUserCatalog = workingUserCatalog;
- }
-
-
- protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- }
-
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogArea = (Composite) super.createDialogArea(parent);
- // WorkbenchHelp.setHelp(dialogArea, new
- // ControlContextComputer(dialogArea,
- // XMLBuilderContextIds.XMLP_PROJECT_DIALOG));
-
- Composite composite = new Composite(dialogArea, SWT.NONE);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- Label label = new Label(composite, SWT.NONE);
- label.setText(XMLCatalogMessages.UI_LABEL_DIALOG_DESCRIPTION);
-
- Composite buttonComposite = new Composite(composite, SWT.NONE);
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 3;
- buttonComposite.setLayout(gridLayout);
- buttonComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Composite placeHolder = new Composite(buttonComposite, SWT.NONE);
- placeHolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Composite buttonGroup = new Composite(buttonComposite, SWT.NONE);
- gridLayout = new GridLayout();
- gridLayout.numColumns = 2;
- gridLayout.makeColumnsEqualWidth = true;
- buttonGroup.setLayout(gridLayout);
- buttonGroup.setLayoutData(createGridData());
-
- Button importButton = new Button(buttonGroup, SWT.PUSH | SWT.CENTER);
- importButton.setText(" " + XMLCatalogMessages.UI_BUTTON_IMPORT + " "); //$NON-NLS-1$ //$NON-NLS-2$
-
- Button exportButton = new Button(buttonGroup, SWT.PUSH | SWT.CENTER);
- exportButton.setText(" " + XMLCatalogMessages.UI_BUTTON_EXPORT + " "); //$NON-NLS-1$ //$NON-NLS-2$
-
- placeHolder = new Composite(buttonComposite, SWT.NONE);
- placeHolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // add importButton listener
- SelectionListener importButtonSelectionListener = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- invokeImportDialog();
- }
- };
- importButton.addSelectionListener(importButtonSelectionListener);
-
- // add exportButton listener
- SelectionListener exportButtonSelectionListener = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- invokeExportDialog();
- }
- };
- exportButton.addSelectionListener(exportButtonSelectionListener);
-
- return dialogArea;
- }
-
- protected GridData createGridData() {
- GridData gd = new GridData(GridData.CENTER);
- gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_CENTER;
- gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
- return gd;
- }
-
-
- protected void invokeImportDialog() {
- SelectSingleFileDialog dialog = new SelectSingleFileDialog(getShell(), null, true);
- String[] extensions = {".xmlcatalog", ".xml"}; //$NON-NLS-1$ //$NON-NLS-2$
- dialog.addFilterExtensions(extensions);
- dialog.create();
- dialog.getShell().setText(XMLCatalogMessages.UI_LABEL_IMPORT_DIALOG_TITLE);
- dialog.setTitle(XMLCatalogMessages.UI_LABEL_IMPORT_DIALOG_HEADING);
- dialog.setMessage(XMLCatalogMessages.UI_LABEL_IMPORT_DIALOG_MESSAGE);
- dialog.setBlockOnOpen(true);
- int rc = dialog.open();
- if (rc == Window.OK) {
- IFile file = dialog.getFile();
- if (file != null) {
- String fileName = file.getLocation().toFile().toURI().toString();
- try {
- CatalogSet tempResourceSet = new CatalogSet();
- ICatalog newCatalog = tempResourceSet.lookupOrCreateCatalog("temp", fileName); //$NON-NLS-1$
- workingUserCatalog.addEntriesFromCatalog(newCatalog);
- }
- catch (Exception e) {
- // TODO... give error message
- }
- }
- close();
- }
- }
-
-
- protected void invokeExportDialog() {
- IPath originalFilePath = null;
- IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- if (projects.length > 0) {
- originalFilePath = projects[0].getFullPath().append(".xmlcatalog"); //$NON-NLS-1$
- }
-
- SaveAsDialog dialog = new SaveAsDialog(getShell());
- if (originalFilePath != null) {
- IFile originalFile = ResourcesPlugin.getWorkspace().getRoot().getFile(originalFilePath);
- dialog.setOriginalFile(originalFile);
- }
- dialog.create();
-
- dialog.getShell().setText(XMLCatalogMessages.UI_LABEL_EXPORT_DIALOG_TITLE);
- dialog.setTitle(XMLCatalogMessages.UI_LABEL_EXPORT_DIALOG_HEADING);
- dialog.setMessage(XMLCatalogMessages.UI_LABEL_EXPORT_DIALOG_MESSAGE);
-
- dialog.setBlockOnOpen(true);
- int rc = dialog.open();
- if (rc == Window.OK) {
- IPath path = dialog.getResult();
- if (path != null) {
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
- String fileName = file.getLocation().toFile().toURI().toString();
-
- // here we save the catalog entries to the selected file
- try {
- createFileIfRequired(file);
- workingUserCatalog.setLocation(fileName);
- workingUserCatalog.save();
- }
- catch (Exception ex) {
- try {
- String title = XMLCatalogMessages.UI_LABEL_CATALOG_SAVE_ERROR;
- String briefMessage = XMLCatalogMessages.UI_LABEL_CATALOG_COULD_NOT_BE_SAVED;
- String reason = file.isReadOnly() ? NLS.bind(XMLCatalogMessages.UI_LABEL_FILE_IS_READ_ONLY, fileName) : NLS.bind(XMLCatalogMessages.ERROR_SAVING_FILE, fileName);
- String details = NLS.bind(XMLCatalogMessages.ERROR_SAVING_FILE, fileName);
-
- ErrorDialog.openError(Display.getCurrent().getActiveShell(), title, briefMessage, createStatus(reason, details));
- }
- catch (Exception ex2) {
- }
- }
- close();
- }
- }
- }
-
- // TODO... This was copied from WindowUtility. Is there an easier way to
- // create a status object?
- // If not, we should open an eclipse bug or add a similar utility to
- // baseExtensionsUI.
- //
- private static IStatus createStatus(String reason, String msg) {
- String pluginId = XMLUIPlugin.getDefault().getBundle().getSymbolicName();
- MultiStatus multiStatus = new MultiStatus(pluginId, 0, reason, null);
- Status status = new Status(IStatus.ERROR, pluginId, 0, msg, null);
- multiStatus.add(status);
- return multiStatus;
- }
-
-
- protected void createFileIfRequired(IFile file) {
- try {
- if ((file != null) && !file.exists()) {
- ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[0]);
- file.create(inputStream, true, null);
- // createEmptyXMLCatalog(file);
- }
- }
- catch (Exception e) {
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/CatalogFileTypeRegistryReader.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/CatalogFileTypeRegistryReader.java
deleted file mode 100644
index 85b57d3344..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/CatalogFileTypeRegistryReader.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 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.catalog;
-
-import java.util.Collection;
-import java.util.HashMap;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-public class CatalogFileTypeRegistryReader {
- private static CatalogFileTypeRegistryReader _instance;
-
- static final String ATT_DESCRIPTION = "description"; //$NON-NLS-1$
-
- static final String ATT_EXTENSIONS = "extensions"; //$NON-NLS-1$
-
- static final String ATT_ICON = "icon"; //$NON-NLS-1$
-
- static final String ATT_ID = "id"; //$NON-NLS-1$
-
- static final String EXTENSION_POINT_ID = "catalogFileType"; //$NON-NLS-1$
-
- static final String TAG_NAME = "fileType"; //$NON-NLS-1$
-
- private static CatalogFileTypeRegistryReader getInstance() {
- if (_instance == null) {
- _instance = new CatalogFileTypeRegistryReader();
- }
- return _instance;
- }
-
- public static Collection getXMLCatalogFileTypes() {
- return getInstance().hashMap.values();
- }
-
- private HashMap hashMap;
-
- public CatalogFileTypeRegistryReader() {
- this.hashMap = new HashMap();
- readRegistry();
- }
-
- private void readElement(IConfigurationElement element) {
- if (element.getName().equals(TAG_NAME)) {
- String id = element.getAttribute(ATT_ID);
- if (id != null) {
- XMLCatalogFileType fileType = (XMLCatalogFileType) hashMap.get(id);
- if (fileType == null) {
- fileType = new XMLCatalogFileType();
- hashMap.put(id, fileType);
- }
- fileType.id = id;
- if (fileType.description == null) {
- String description = element.getAttribute(ATT_DESCRIPTION);
- fileType.description = description;
- }
-
- fileType.addExtensions(element.getAttribute(ATT_EXTENSIONS));
- }
- }
- }
-
- private void readRegistry() {
- readRegistry(EXTENSION_POINT_ID);
- }
-
- private void readRegistry(String extensionPointId) {
- IExtensionRegistry pluginRegistry = Platform.getExtensionRegistry();
- IExtensionPoint point = pluginRegistry.getExtensionPoint(XMLUIPlugin.ID, extensionPointId);
- if (point != null) {
- IConfigurationElement[] elements = point.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- readElement(elements[i]);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/EditCatalogEntryDialog.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/EditCatalogEntryDialog.java
deleted file mode 100644
index 578e8a8050..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/EditCatalogEntryDialog.java
+++ /dev/null
@@ -1,1816 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2010 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.catalog;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.part.PageBook;
-import org.eclipse.wst.common.ui.internal.dialogs.SelectSingleFileDialog;
-import org.eclipse.wst.common.uriresolver.internal.URI;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.IDelegateCatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.IRewriteEntry;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ISuffixEntry;
-
-public class EditCatalogEntryDialog extends Dialog {
- protected static Image borwseImage = ImageFactory.INSTANCE.getImage("icons/obj16/file_expand.gif"); //$NON-NLS-1$
- protected static Image catalogEntryToolBarImage = ImageFactory.INSTANCE.getImage("icons/etool50/catalogEntry.gif"); //$NON-NLS-1$
- protected static Image nextCatalogToolBarImage = ImageFactory.INSTANCE.getImage("icons/etool50/nextCatalog.gif"); //$NON-NLS-1$
- protected static Image delegateCatalogToolBarImage = ImageFactory.INSTANCE.getImage("icons/etool50/delegateCatalog.gif"); //$NON-NLS-1$
- protected static Image rewriteToolBarImage = ImageFactory.INSTANCE.getImage("icons/etool50/rewrite.gif"); //$NON-NLS-1$
- protected static Image prefixToolBarImage = ImageFactory.INSTANCE.getImage("icons/etool50/prefix.gif"); //$NON-NLS-1$
- protected static Image suffixToolBarImage = ImageFactory.INSTANCE.getImage("icons/etool50/sufix.gif"); //$NON-NLS-1$
-
- protected class CatalogEntryPage extends CatalogElementPage {
-
- protected Button browseWorkspaceButton;
-
- protected Button browseFileSystemButton;
-
- protected ICatalogEntry catalogEntry;
-
- protected Button checkboxButton;
-
- protected Label errorMessageLabel;
-
- protected Text keyField;
-
- protected Combo keyTypeCombo;
-
- protected Text resourceLocationField;
-
- protected Combo resourceTypeCombo;
-
- protected Text webAddressField;
-
- protected String key;
-
- protected int type;
-
- public void refresh() {
- computeErrorMessage();
- updateErrorMessageLabel(errorMessageLabel);
- updateOKButtonState();
- }
-
- protected void computeErrorMessage() {
- errorMessage = null;
- warningMessage = null;
-
- String fileName = resourceLocationField.getText();
- if (fileName.trim().length() > 0) {
- if ((fileName.indexOf("..") != -1) || (fileName.indexOf("./") != -1) || (fileName.indexOf("/.") != -1) || (fileName.indexOf(".\\") != -1) || (fileName.indexOf("\\.") != -1)) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- errorMessage = XMLCatalogMessages.UI_WARNING_URI_MUST_NOT_HAVE_DOTS;
- }
-
- String uri = fileName;
- if (!URIHelper.hasProtocol(uri)) {
- URIHelper.isAbsolute(uri);
- uri = (URIHelper.isAbsolute(uri)) ? URIHelper.prependFileProtocol(uri) : URIHelper.prependPlatformResourceProtocol(uri);
- }
-
- if ((errorMessage == null) && !URIHelper.isReadableURI(uri, false)) {
- errorMessage = XMLCatalogMessages.UI_WARNING_URI_NOT_FOUND_COLON + fileName;
- }
- }
- else {
- // this an error that is not actaully
- // reported ... OK is just disabled
- errorMessage = ""; //$NON-NLS-1$
- }
-
- // Make sure the key is a fully qualified URI in the cases
- // where the key type is "System ID" or "Schema location"
- if ((keyField.getText().length() > 0) && (getKeyType() == ICatalogEntry.ENTRY_TYPE_SYSTEM)) {
- URI uri = URI.createURI(keyField.getText());
- if (uri.scheme() == null) {
- warningMessage = XMLCatalogMessages.UI_WARNING_SHOULD_BE_FULLY_QUALIFIED_URI;
- }
- }
-
- if ((errorMessage == null) && checkboxButton.getSelection() && (webAddressField.getText().trim().length() == 0)) {
- // this an error that is not actaully
- // reported ... OK is just disabled
- errorMessage = ""; //$NON-NLS-1$
- }
-
- if ((errorMessage == null) && (keyField.getText().trim().length() == 0)) {
- // this an error that is not actaully
- // reported ... OK is just disabled
- errorMessage = ""; //$NON-NLS-1$
- }
- }
-
- protected Control createCatalogEntryPanel(Composite parent) {
-
- ModifyListener modifyListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- if (e.widget == resourceLocationField) {
- if (keyField.getText().length() == 0) {
- String uri = resourceLocationField.getText();
- if (uri.endsWith("xsd") && !URIHelper.hasProtocol(uri)) { //$NON-NLS-1$
- uri = URIHelper.isAbsolute(uri) ? URIHelper.prependFileProtocol(uri) : URIHelper.prependPlatformResourceProtocol(uri);
- String namespaceURI = XMLQuickScan.getTargetNamespaceURIForSchema(uri);
- if (namespaceURI != null) {
- keyField.setText(namespaceURI);
- }
- }
- }
- }
- updateWidgets(e.widget);
- }
- };
-
-
- Composite composite = new Composite(parent, SWT.NONE);
- GridData gd = new GridData(GridData.FILL_BOTH);
- composite.setLayoutData(gd);
-
- GridLayout layout = new GridLayout();
- composite.setLayout(layout);
-
- Composite group = new Composite(composite, SWT.NONE);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- group.setLayoutData(gd);
-
- layout = new GridLayout(2, false);
- group.setLayout(layout);
-
- Label resourceLocationLabel = new Label(group, SWT.NONE);
- resourceLocationLabel.setText(XMLCatalogMessages.UI_LABEL_LOCATION_COLON);
-
- resourceLocationField = new Text(group, SWT.SINGLE | SWT.BORDER);
- gd = new GridData();
- gd.horizontalAlignment = SWT.FILL;
- gd.grabExcessHorizontalSpace = true;
- resourceLocationField.setLayoutData(gd);
-
- resourceLocationField.setText(getDisplayValue(URIUtils.convertURIToLocation(getEntry().getURI())));
-
- // WorkbenchHelp.setHelp(resourceLocationField,
- // XMLBuilderContextIds.XMLP_ENTRY_URI);
- resourceLocationField.addModifyListener(modifyListener);
-
- // WorkbenchHelp.setHelp(browseButton,
- // XMLBuilderContextIds.XMLP_ENTRY_BROWSE);
-
- Composite browseButtonsComposite = new Composite(group, SWT.NONE);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- gd.horizontalAlignment = GridData.END;
- browseButtonsComposite.setLayoutData(gd);
-
- layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- layout.marginBottom = 5;
- browseButtonsComposite.setLayout(layout);
-
- browseWorkspaceButton = new Button(browseButtonsComposite, SWT.PUSH);
- browseWorkspaceButton.setText(XMLCatalogMessages.UI_BUTTON_MENU_BROWSE_WORKSPACE);
- browseWorkspaceButton.addSelectionListener(new SelectionListener(){
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- String value = invokeWorkspaceFileSelectionDialog();
- if(value != null) {
- resourceLocationField.setText(value);
- }
- }
- });
-
- browseFileSystemButton = new Button(browseButtonsComposite, SWT.PUSH);
- browseFileSystemButton.setText(XMLCatalogMessages.UI_BUTTON_MENU_BROWSE_FILE_SYSTEM);
- browseFileSystemButton.addSelectionListener(new SelectionListener(){
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- String value = invokeFileSelectionDialog();
- if(value != null) {
- resourceLocationField.setText(value);
- }
- }
- });
-
- // Key Type
- //
- Label keyTypeLabel = new Label(group, SWT.NONE);
- keyTypeLabel.setText(XMLCatalogMessages.UI_KEY_TYPE_COLON);
-
- keyTypeCombo = new Combo(group, SWT.READ_ONLY);
- gd = new GridData();
- gd.horizontalAlignment = SWT.FILL;
- gd.grabExcessHorizontalSpace = true;
- keyTypeCombo.setLayoutData(gd);
- updateKeyTypeCombo(getEntry().getEntryType());
- keyTypeCombo.addModifyListener(modifyListener);
- // WorkbenchHelp.setHelp(keyTypeCombo,
- // XMLBuilderContextIds.XMLP_ENTRY_KEY_TYPE);
-
- // Key
- //
- Label keyValueLabel = new Label(group, SWT.NONE);
- keyValueLabel.setText(XMLCatalogMessages.UI_LABEL_KEY_COLON);
- keyField = new Text(group, SWT.SINGLE | SWT.BORDER);
- // WorkbenchHelp.setHelp(keyField,
- // XMLBuilderContextIds.XMLP_ENTRY_KEY);
- keyField.setLayoutData(gd);
- keyField.setText(getDisplayValue(getEntry().getKey()));
- keyField.addModifyListener(modifyListener);
-
- Composite group2 = new Composite(composite, SWT.NONE);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- group2.setLayoutData(gd);
-
- layout = new GridLayout();
- group2.setLayout(layout);
-
- // checkbox -- note parent is dialogArea
- //
- checkboxButton = new Button(group2, SWT.CHECK);
- // WorkbenchHelp.setHelp(checkboxButton,
- // XMLBuilderContextIds.XMLP_ENTRY_SPECIFY_ALTERNATIVE);
- checkboxButton.setText(XMLCatalogMessages.UI_LABEL_SPECIFY_ALTERNATIVE_WEB_URL);
- checkboxButton.setLayoutData(new GridData());
- checkboxButton.setSelection(getEntry().getAttributeValue(ICatalogEntry.ATTR_WEB_URL) != null);
- SelectionListener buttonListener = new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent event) {
- // no impl
- }
-
- public void widgetSelected(SelectionEvent event) {
- if (event.widget == checkboxButton) {
- updateWidgets(checkboxButton);
- }
- }
- };
- checkboxButton.addSelectionListener(buttonListener);
-
- // Web Address field
- //
-
- ModifyListener webAddressFieldListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- computeErrorMessage();
- updateErrorMessageLabel(errorMessageLabel);
- updateOKButtonState();
- }
- };
-
- webAddressField = new Text(group2, SWT.SINGLE | SWT.BORDER);
- // WorkbenchHelp.setHelp(webAddressField,
- // XMLBuilderContextIds.XMLP_ENTRY_WEB_ADDRESS);
- webAddressField.setLayoutData(gd);
- webAddressField.setText(getDisplayValue(getEntry().getAttributeValue(ICatalogEntry.ATTR_WEB_URL)));
- webAddressField.setEnabled(false);
- webAddressField.addModifyListener(webAddressFieldListener);
-
-
- errorMessageLabel = new Label(group2, SWT.NONE);
- errorMessageLabel.setForeground(color);
- errorMessageLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- updateWidgets(null);
-
- key = getEntry().getKey();
- type = getEntry().getEntryType();
-
- return composite;
- }
-
- public Control createControl(Composite parent) {
-
- fControl = createCatalogEntryPanel(parent);
-
- return fControl;
- }
-
-
- public ICatalogElement getData() {
- return getEntry();
- }
-
- protected ICatalogEntry getEntry() {
- if (catalogEntry == null) {
- if ((fCatalogElement != null) && (fCatalogElement.getType() == ICatalogElement.TYPE_ENTRY)) {
- catalogEntry = (ICatalogEntry) fCatalogElement;
- }
- else {
- if (catalog != null) {
- catalogEntry = (ICatalogEntry) catalog.createCatalogElement(ICatalogElement.TYPE_ENTRY);
- }
- }
- }
- return catalogEntry;
- }
-
- protected int getKeyType() {
- switch (keyTypeCombo.getSelectionIndex()) {
- case 0 :
- if ("schema".equals(keyTypeCombo.getData("keyType"))) { //$NON-NLS-1$ //$NON-NLS-2$
- return ICatalogEntry.ENTRY_TYPE_URI; // xsd
- // namespace
- // is URI type
- // key
- }
- return ICatalogEntry.ENTRY_TYPE_PUBLIC;
- case 1 :
- return ICatalogEntry.ENTRY_TYPE_SYSTEM;
- case 2 :
- return ICatalogEntry.ENTRY_TYPE_URI;
- default :
- return ICatalogEntry.ENTRY_TYPE_PUBLIC;
- }
- }
-
- public void saveData() {
- if (validateData()) {
- getEntry().setURI(URIUtils.convertLocationToURI(resourceLocationField.getText()));
- getEntry().setKey(keyField.getText());
- getEntry().setEntryType(getKeyType());
- getEntry().setAttributeValue(ICatalogEntry.ATTR_WEB_URL, checkboxButton.getSelection() ? webAddressField.getText() : null);
- dataSaved = true;
- }
- else {
- errorMessage = XMLCatalogMessages.UI_WARNING_DUPLICATE_ENTRY;
- errorMessageLabel.setText(errorMessage);
- updateOKButtonState();
- dataSaved = false;
- }
- }
-
- /**
- * Validates that the data entered does not conflict with an existing entry in either catalog.
- * @return True if validated, false otherwise.
- */
- protected boolean validateData() {
-
- String result = null;
- if (key == null || !key.equals(keyField.getText()) || type != getKeyType())
- {
- try {
- switch( getKeyType() )
- {
- case ICatalogEntry.ENTRY_TYPE_PUBLIC:
- result = catalog.resolvePublic(keyField.getText(), null);
- break;
- case ICatalogEntry.ENTRY_TYPE_SYSTEM:
- result = catalog.resolveSystem(keyField.getText());
- break;
- case ICatalogEntry.ENTRY_TYPE_URI:
- result = catalog.resolveURI(keyField.getText());
- break;
- }
- }
- catch (Exception e) {
- }
- }
-
- return (result == null);
- }
-
- protected void updateKeyTypeCombo(int type) {
- keyTypeCombo.removeAll();
- for (Iterator i = CatalogFileTypeRegistryReader.getXMLCatalogFileTypes().iterator(); i.hasNext();) {
- XMLCatalogFileType theFileType = (XMLCatalogFileType) i.next();
- if (theFileType.extensions != null) {
- for (Iterator j = theFileType.extensions.iterator(); j.hasNext();) {
- String extension = (String) j.next();
- if (resourceLocationField.getText().endsWith(extension)) {
- if ("org.eclipse.wst.xml.core.ui.catalogFileType.xsd".equals(theFileType.id)) { //$NON-NLS-1$
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_XSD_PUBLIC);
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_XSD_SYSTEM);
- keyTypeCombo.setData("keyType", "schema"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- else if ("org.eclipse.wst.xml.core.ui.catalogFileType.dtd".equals(theFileType.id)) { //$NON-NLS-1$
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_PUBLIC);
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_SYSTEM);
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_URI);
- }
- else {
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_URI);
- }
- }
-
- }
-
- }
- }
- if (keyTypeCombo.getItemCount() == 0) {
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_PUBLIC);
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_SYSTEM);
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_URI);
- }
-
- switch (type) {
- case ICatalogEntry.ENTRY_TYPE_PUBLIC :
- keyTypeCombo.select(0);
- break;
- case ICatalogEntry.ENTRY_TYPE_SYSTEM :
- keyTypeCombo.select(1);
- break;
- case ICatalogEntry.ENTRY_TYPE_URI : // handle XML Schema,
- // where namespace name is
- // mapped to URI situation
- if ("schema".equals(keyTypeCombo.getData("keyType"))) { //$NON-NLS-1$ //$NON-NLS-2$
- keyTypeCombo.select(0); // namespace name as URI key
- // type
- }
- else {
- keyTypeCombo.select(2); // URI key type
- }
- break;
- default :
- if (keyTypeCombo.getItemCount() > 0) {
- keyTypeCombo.select(0);
- }
- break;
- }
-
- }
-
- protected void updateWebAddressWidgets(int keyType) {
- boolean isPublicKeyType = (keyType == ICatalogEntry.ENTRY_TYPE_PUBLIC);
- checkboxButton.setEnabled(isPublicKeyType);
- webAddressField.setEnabled(isPublicKeyType && checkboxButton.getSelection());
- }
-
- protected void updateWidgets(Widget widget) {
- if (widget != keyTypeCombo) {
- updateKeyTypeCombo(getKeyType());
- }
- updateWebAddressWidgets(getKeyType());
- computeErrorMessage();
- updateErrorMessageLabel(errorMessageLabel);
- updateOKButtonState();
- }
-
- }
-
- protected class SuffixEntryPage extends CatalogElementPage {
-
- protected Button browseWorkspaceButton;
-
- protected Button browseFileSystemButton;
-
- protected ISuffixEntry catalogEntry;
-
- protected Label errorMessageLabel;
-
- protected Text suffixField;
-
- protected Combo keyTypeCombo;
-
- protected Text resourceLocationField;
-
- protected Combo resourceTypeCombo;
-
- protected String key;
-
- protected int type;
-
- public void refresh() {
- computeErrorMessage();
- updateErrorMessageLabel(errorMessageLabel);
- updateOKButtonState();
- }
-
- protected void computeErrorMessage() {
- errorMessage = null;
- warningMessage = null;
-
- String fileName = resourceLocationField.getText();
- if (fileName.trim().length() > 0) {
- if ((fileName.indexOf("..") != -1) || (fileName.indexOf("./") != -1) || (fileName.indexOf("/.") != -1) || (fileName.indexOf(".\\") != -1) || (fileName.indexOf("\\.") != -1)) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- errorMessage = XMLCatalogMessages.UI_WARNING_URI_MUST_NOT_HAVE_DOTS;
- }
-
- String uri = fileName;
- if (!URIHelper.hasProtocol(uri)) {
- URIHelper.isAbsolute(uri);
- uri = (URIHelper.isAbsolute(uri)) ? URIHelper.prependFileProtocol(uri) : URIHelper.prependPlatformResourceProtocol(uri);
- }
-
- if ((errorMessage == null) && !URIHelper.isReadableURI(uri, false)) {
- errorMessage = XMLCatalogMessages.UI_WARNING_URI_NOT_FOUND_COLON + fileName;
- }
- }
- else {
- // this an error that is not actaully
- // reported ... OK is just disabled
- errorMessage = ""; //$NON-NLS-1$
- }
-
-
- if ((errorMessage == null) && (suffixField.getText().trim().length() == 0)) {
- // this an error that is not actaully
- // reported ... OK is just disabled
- errorMessage = ""; //$NON-NLS-1$
- }
- }
-
- protected Control createSuffixEntryPanel(Composite parent) {
-
- ModifyListener modifyListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- if (e.widget == resourceLocationField) {
- if (suffixField.getText().length() == 0) {
- String uri = resourceLocationField.getText();
- if (uri.endsWith("xsd") && !URIHelper.hasProtocol(uri)) { //$NON-NLS-1$
- uri = URIHelper.isAbsolute(uri) ? URIHelper.prependFileProtocol(uri) : URIHelper.prependPlatformResourceProtocol(uri);
- String namespaceURI = XMLQuickScan.getTargetNamespaceURIForSchema(uri);
- if (namespaceURI != null) {
- suffixField.setText(namespaceURI);
- }
- }
- }
- }
- updateWidgets(e.widget);
- }
- };
-
- Composite composite = new Composite(parent, SWT.NONE);
- GridData gd = new GridData(GridData.FILL_BOTH);
- composite.setLayoutData(gd);
-
- GridLayout layout = new GridLayout();
- composite.setLayout(layout);
-
- Composite group = new Composite(composite, SWT.NONE);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- group.setLayoutData(gd);
-
- layout = new GridLayout(2, false);
- group.setLayout(layout);
-
- Label resourceLocationLabel = new Label(group, SWT.NONE);
- resourceLocationLabel.setText(XMLCatalogMessages.UI_LABEL_LOCATION_COLON);
-
- resourceLocationField = new Text(group, SWT.SINGLE | SWT.BORDER);
- gd = new GridData();
- gd.horizontalAlignment = SWT.FILL;
- gd.grabExcessHorizontalSpace = true;
- resourceLocationField.setLayoutData(gd);
-
- resourceLocationField.setText(getDisplayValue(URIUtils.convertURIToLocation(getEntry().getURI())));
- resourceLocationField.addModifyListener(modifyListener);
-
- Composite browseButtonsComposite = new Composite(group, SWT.NONE);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- gd.horizontalAlignment = GridData.END;
- browseButtonsComposite.setLayoutData(gd);
-
- layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- layout.marginBottom = 5;
- browseButtonsComposite.setLayout(layout);
-
- browseWorkspaceButton = new Button(browseButtonsComposite, SWT.PUSH);
- browseWorkspaceButton.setText(XMLCatalogMessages.UI_BUTTON_MENU_BROWSE_WORKSPACE);
- browseWorkspaceButton.addSelectionListener(new SelectionListener(){
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- String value = invokeWorkspaceFileSelectionDialog();
- if(value != null) {
- resourceLocationField.setText(value);
- }
- }
- });
-
- browseFileSystemButton = new Button(browseButtonsComposite, SWT.PUSH);
- browseFileSystemButton.setText(XMLCatalogMessages.UI_BUTTON_MENU_BROWSE_FILE_SYSTEM);
- browseFileSystemButton.addSelectionListener(new SelectionListener(){
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- String value = invokeFileSelectionDialog();
- if(value != null) {
- resourceLocationField.setText(value);
- }
- }
- });
-
- // Key Type
- //
- Label keyTypeLabel = new Label(group, SWT.NONE);
- keyTypeLabel.setText(XMLCatalogMessages.UI_KEY_TYPE_COLON);
-
- keyTypeCombo = new Combo(group, SWT.READ_ONLY);
- gd = new GridData();
- gd.horizontalAlignment = SWT.FILL;
- gd.grabExcessHorizontalSpace = true;
- keyTypeCombo.setLayoutData(gd);
- updateKeyTypeCombo(getEntry().getEntryType());
- keyTypeCombo.addModifyListener(modifyListener);
-
- // Suffix
- //
- Label suffixValueLabel = new Label(group, SWT.NONE);
- suffixValueLabel.setText(XMLCatalogMessages.UI_LABEL_SUFFIX_COLON);
- suffixField = new Text(group, SWT.SINGLE | SWT.BORDER);
-
- suffixField.setLayoutData(gd);
- suffixField.setText(getDisplayValue(getEntry().getSuffix()));
- suffixField.addModifyListener(modifyListener);
-
- errorMessageLabel = new Label(composite, SWT.NONE);
- errorMessageLabel.setForeground(color);
- errorMessageLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- updateWidgets(null);
-
- key = getEntry().getSuffix();
- type = getEntry().getEntryType();
-
- return composite;
- }
-
- public Control createControl(Composite parent) {
-
- fControl = createSuffixEntryPanel(parent);
-
- return fControl;
- }
-
-
- public ICatalogElement getData() {
- return getEntry();
- }
-
- protected ISuffixEntry getEntry() {
- if (catalogEntry == null) {
- if ((fCatalogElement != null) && (fCatalogElement.getType() == ICatalogElement.TYPE_SUFFIX)) {
- catalogEntry = (ISuffixEntry) fCatalogElement;
- }
- else {
- if (catalog != null) {
- catalogEntry = (ISuffixEntry) catalog.createCatalogElement(ICatalogElement.TYPE_SUFFIX);
- }
- }
- }
- return catalogEntry;
- }
-
- protected int getKeyType() {
- switch (keyTypeCombo.getSelectionIndex()) {
- case 0 :
- return ISuffixEntry.SUFFIX_TYPE_URI; // xsd namespace is URI type key
- case 1 :
- return ISuffixEntry.SUFFIX_TYPE_SYSTEM;
- default :
- return ISuffixEntry.SUFFIX_TYPE_URI;
- }
- }
-
- public void saveData() {
- if (validateData()) {
- getEntry().setURI(URIUtils.convertLocationToURI(resourceLocationField.getText()));
- getEntry().setSuffix(suffixField.getText());
- getEntry().setEntryType(getKeyType());
- dataSaved = true;
- }
- else {
- errorMessage = XMLCatalogMessages.UI_WARNING_DUPLICATE_SUFFIX;
- errorMessageLabel.setText(errorMessage);
- updateOKButtonState();
- dataSaved = false;
- }
- }
-
- protected boolean validateData() {
- ISuffixEntry entry = getEntry();
- String uri = URIUtils.convertLocationToURI(resourceLocationField.getText());
- if(entry.getEntryType() != getKeyType() || !entry.getSuffix().equals(suffixField.getText()) || !entry.getURI().equals(uri)) {
- ISuffixEntry[] entries = catalog.getSuffixEntries();
- for (int i = 0; i < entries.length; i++) {
- if (entries[i].getSuffix().equals(suffixField.getText()) && entries[i].getEntryType() == getKeyType()) return false;
- }
- }
- return true;
- }
-
- protected void updateKeyTypeCombo(int type) {
- keyTypeCombo.removeAll();
- for (Iterator i = CatalogFileTypeRegistryReader.getXMLCatalogFileTypes().iterator(); i.hasNext();) {
- XMLCatalogFileType theFileType = (XMLCatalogFileType) i.next();
- if (theFileType.extensions != null) {
- for (Iterator j = theFileType.extensions.iterator(); j.hasNext();) {
- String extension = (String) j.next();
- if (resourceLocationField.getText().endsWith(extension)) {
- if ("org.eclipse.wst.xml.core.ui.catalogFileType.xsd".equals(theFileType.id)) { //$NON-NLS-1$
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_XSD_PUBLIC);
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_XSD_SYSTEM);
- }
- else if ("org.eclipse.wst.xml.core.ui.catalogFileType.dtd".equals(theFileType.id)) { //$NON-NLS-1$
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_URI);
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_SYSTEM);
- }
- else {
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_URI);
- }
- }
-
- }
-
- }
- }
- if (keyTypeCombo.getItemCount() == 0) {
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_URI);
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_SYSTEM);
- }
-
- switch (type) {
- case ISuffixEntry.SUFFIX_TYPE_URI: // handle XML Schema,
- keyTypeCombo.select(0); // namespace name as URI key
- break;
-
- case ISuffixEntry.SUFFIX_TYPE_SYSTEM :
- keyTypeCombo.select(1);
- break;
-
- default :
- if (keyTypeCombo.getItemCount() > 0) {
- keyTypeCombo.select(0);
- }
- break;
- }
-
- }
-
- protected void updateWidgets(Widget widget) {
- if (widget != keyTypeCombo) {
- updateKeyTypeCombo(getKeyType());
- }
- computeErrorMessage();
- updateErrorMessageLabel(errorMessageLabel);
- updateOKButtonState();
- }
-
- }
-
- protected abstract class CatalogElementPage {
-
- Control fControl;
-
- public CatalogElementPage() {
- super();
-
- }
-
- public abstract void refresh();
-
- public abstract Control createControl(Composite parent);
-
- public Control getControl() {
- return fControl;
- }
-
- public abstract ICatalogElement getData();
-
- public abstract void saveData();
- }
-
- protected class FilterableSelectSingleFileDialog extends SelectSingleFileDialog implements SelectionListener {
- protected Combo filterControl;
-
- public FilterableSelectSingleFileDialog(Shell parentShell) {
- super(parentShell, null, true);
- setFilters(null);
- }
-
- public void createAndOpen() {
- this.create();
- setBlockOnOpen(true);
- getShell().setText(XMLCatalogMessages.UI_LABEL_FILE_SELECTION);
- this.setTitle(XMLCatalogMessages.UI_LABEL_SELECT_FILE);
- this.setMessage(XMLCatalogMessages.UI_LABEL_CHOOSE_FILE_TO_ADD_TO_CATALOG);
- open();
- }
-
- public void createFilterControl(Composite composite) {
- Label label = new Label(composite, SWT.NONE);
- label.setText(XMLCatalogMessages.UI_LABEL_SELECT_FILE_FILTER_CONTROL);
-
- filterControl = new Combo(composite, SWT.READ_ONLY);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- filterControl.setLayoutData(gd);
-
- filterControl.setText(XMLCatalogMessages.UI_TEXT_SELECT_FILE_FILTER_CONTROL);
- filterControl.add(XMLCatalogMessages.UI_TEXT_SELECT_FILE_FILTER_CONTROL);
-
- for (Iterator i = CatalogFileTypeRegistryReader.getXMLCatalogFileTypes().iterator(); i.hasNext();) {
- XMLCatalogFileType fileType = (XMLCatalogFileType) i.next();
- if (fileType.description != null) {
- filterControl.add(fileType.description);
- }
- }
-
- filterControl.select(0);
- filterControl.addSelectionListener(this);
- }
-
- protected void setFilters(XMLCatalogFileType fileType) {
- if (fileType == null) {
- // compute all the supported file extensions
- List list = new ArrayList();
- for (Iterator i = CatalogFileTypeRegistryReader.getXMLCatalogFileTypes().iterator(); i.hasNext();) {
- XMLCatalogFileType theFileType = (XMLCatalogFileType) i.next();
- if (theFileType.extensions != null) {
- list.addAll(theFileType.extensions);
- }
- }
- // Any files are now supported with Resource URI
- selectSingleFileView.setFilterExtensions(createStringArray(list));
- }
- else {
- if (fileType.extensions != null) {
- selectSingleFileView.setFilterExtensions(createStringArray(fileType.extensions));
- }
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
-
- public void widgetSelected(SelectionEvent e) {
- String text = filterControl.getText();
- XMLCatalogFileType fileType = getMatchingFileType(text);
- setFilters(fileType);
- }
- }
-
- protected abstract class AbstractDelegatePage extends CatalogElementPage {
-
-
- protected Button browseWorkspaceButton;
-
- protected Button browseFileSystemButton;
-
- protected Text catalogLocationField;
-
- protected Label errorMessageLabel;
-
- protected void computeErrorMessage() {
- errorMessage = null;
- String fileName = catalogLocationField.getText();
- if (fileName.trim().length() > 0) {
- if ((fileName.indexOf("..") != -1) || (fileName.indexOf("./") != -1) || (fileName.indexOf("/.") != -1) || (fileName.indexOf(".\\") != -1) || (fileName.indexOf("\\.") != -1)) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- errorMessage = XMLCatalogMessages.UI_WARNING_URI_MUST_NOT_HAVE_DOTS;
- }
-
- String uri = fileName;
- if (!URIHelper.hasProtocol(uri)) {
- uri = URIHelper.isAbsolute(uri) ? URIHelper.prependFileProtocol(uri) : URIHelper.prependPlatformResourceProtocol(uri);
- }
-
- if ((errorMessage == null) && !URIHelper.isReadableURI(uri, false)) {
- errorMessage = XMLCatalogMessages.UI_WARNING_URI_NOT_FOUND_COLON + fileName;
- }
- }
- else {
- // this an error that is not actually
- // reported ... OK is just disabled
- errorMessage = ""; //$NON-NLS-1$
- }
- }
-
- public abstract Control createControl(Composite parent);
-
- protected Control createNextCatalogPanel(Composite parent, String catalogUriLabel) {
- ModifyListener modifyListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateWidgets(e.widget);
- }
- };
-
- Composite composite = new Composite(parent, SWT.NONE);
- GridData gd = new GridData(GridData.FILL_BOTH);
- composite.setLayoutData(gd);
-
- GridLayout layout = new GridLayout();
- composite.setLayout(layout);
-
- Composite group = new Composite(composite, SWT.NONE);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- group.setLayoutData(gd);
-
- layout = new GridLayout();
- group.setLayout(layout);
-
- createSpecificFields(group);
-
- Label resourceLocationLabel = new Label(group, SWT.NONE);
- resourceLocationLabel.setText(catalogUriLabel);
-
- catalogLocationField = new Text(group, SWT.SINGLE | SWT.BORDER);
- catalogLocationField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- catalogLocationField.setText(URIUtils.convertURIToLocation(getDisplayValue(getCatalogLocation())));
- // WorkbenchHelp.setHelp(resourceLocationField,
- // XMLBuilderContextIds.XMLP_ENTRY_URI);
- catalogLocationField.addModifyListener(modifyListener);
-
- Composite browseButtonsComposite = new Composite(group, SWT.FLAT);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- gd.horizontalAlignment = GridData.END;
- browseButtonsComposite.setLayoutData(gd);
-
- layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- layout.marginBottom = 5;
- browseButtonsComposite.setLayout(layout);
-
- browseWorkspaceButton = new Button(browseButtonsComposite, SWT.PUSH);
- browseWorkspaceButton.setText(XMLCatalogMessages.UI_BUTTON_MENU_BROWSE_WORKSPACE);
- browseWorkspaceButton.addSelectionListener(new SelectionListener(){
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- String value = invokeWorkspaceFileSelectionDialog();
- if(value != null) {
- catalogLocationField.setText(value);
- }
- }
- });
-
- browseFileSystemButton = new Button(browseButtonsComposite, SWT.PUSH);
- browseFileSystemButton.setText(XMLCatalogMessages.UI_BUTTON_MENU_BROWSE_FILE_SYSTEM);
- browseFileSystemButton.addSelectionListener(new SelectionListener(){
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- String value = invokeFileSelectionDialog();
- if(value != null) {
- catalogLocationField.setText(value);
- }
- }
- });
-
- errorMessageLabel = new Label(group, SWT.NONE);
- errorMessageLabel.setForeground(color);
- errorMessageLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- updateWidgets(null);
- return composite;
- }
-
- protected void createSpecificFields(Composite group) {
- }
-
- protected abstract String getCatalogLocation();
-
- protected void updateWidgets(Widget widget) {
- computeErrorMessage();
- updateErrorMessageLabel(errorMessageLabel);
- updateOKButtonState();
- }
- }
-
- protected class NextCatalogPage extends AbstractDelegatePage {
- protected INextCatalog nextCatalog;
-
- public ICatalogElement getData() {
- return getNextCatalog();
- }
-
- public void refresh() {
- computeErrorMessage();
- updateErrorMessageLabel(errorMessageLabel);
- updateOKButtonState();
- }
-
- protected INextCatalog getNextCatalog() {
- if (nextCatalog == null) {
- if ((fCatalogElement != null) && (fCatalogElement.getType() == ICatalogElement.TYPE_NEXT_CATALOG)) {
- nextCatalog = (INextCatalog) fCatalogElement;
- }
- else {
- if (catalog != null) {
- nextCatalog = (INextCatalog) catalog.createCatalogElement(ICatalogElement.TYPE_NEXT_CATALOG);
- }
- }
- }
- return nextCatalog;
- }
-
- public void saveData() {
- getNextCatalog().setCatalogLocation(URIUtils.convertLocationToURI(catalogLocationField.getText()));
- dataSaved = true;
- }
-
- protected String getCatalogLocation() {
- return getNextCatalog().getCatalogLocation();
- }
-
- public Control createControl(Composite parent) {
- fControl = createNextCatalogPanel(parent, XMLCatalogMessages.UI_LABEL_CATALOG_URI_COLON);
- return fControl;
- }
- }
-
- protected class DelegateCatalogPage extends AbstractDelegatePage {
- protected IDelegateCatalog delegateCatalog;
- private Text prefixField;
- private Combo keyTypeCombo;
-
- public void refresh() {
- computeErrorMessage();
- updateErrorMessageLabel(errorMessageLabel);
- updateOKButtonState();
- }
-
- protected void computeErrorMessage() {
- errorMessage = null;
- String prefix = prefixField.getText();
- if(prefix.length() > 0) {
- // good
- } else {
- errorMessage = "";
- }
- }
-
- public ICatalogElement getData() {
- return getDelegateCatalog();
- }
-
- protected void createSpecificFields(Composite group) {
-
- Composite prefixComposite = new Composite(group, SWT.NONE);
-
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- layout.marginBottom = 5;
- prefixComposite.setLayout(layout);
-
- // Key Type
- //
- Label keyTypeLabel = new Label(prefixComposite, SWT.NONE);
- keyTypeLabel.setText(XMLCatalogMessages.UI_MATCH_KEY_TYPE_COLON);
-
- keyTypeCombo = new Combo(prefixComposite, SWT.READ_ONLY);
- GridData gd = new GridData();
- gd.horizontalAlignment = SWT.FILL;
- gd.grabExcessHorizontalSpace = true;
- keyTypeCombo.setLayoutData(gd);
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_PUBLIC);
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_SYSTEM);
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_URI);
- switch (getDelegateCatalog().getEntryType()) {
- case IDelegateCatalog.DELEGATE_TYPE_PUBLIC:
- keyTypeCombo.select(0);
- break;
- case IDelegateCatalog.DELEGATE_TYPE_SYSTEM:
- keyTypeCombo.select(1);
- break;
- default:
- case IDelegateCatalog.DELEGATE_TYPE_URI:
- keyTypeCombo.select(2);
- break;
- }
-
- Label prefixLabel = new Label(prefixComposite, SWT.NONE);
- prefixLabel.setText(XMLCatalogMessages.UI_LABEL_START_STRING_COLON);
-
- prefixField = new Text(prefixComposite, SWT.SINGLE | SWT.BORDER);
- prefixField.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
- prefixField.setText(getDisplayValue(getDelegateCatalog().getStartString()));
- ModifyListener modifyListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateWidgets(e.widget);
- }
- };
- prefixField.addModifyListener(modifyListener);
- prefixComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
- }
-
- protected IDelegateCatalog getDelegateCatalog() {
- if (delegateCatalog == null) {
- if ((fCatalogElement != null) && (fCatalogElement.getType() == ICatalogElement.TYPE_DELEGATE)) {
- delegateCatalog = (IDelegateCatalog) fCatalogElement;
- }
- else {
- if (catalog != null) {
- delegateCatalog = (IDelegateCatalog) catalog.createCatalogElement(IDelegateCatalog.DELEGATE_TYPE_URI);
- }
- }
- }
- return delegateCatalog;
- }
-
- public void saveData() {
- if (validateData())
- {
- getDelegateCatalog().setCatalogLocation(URIUtils.convertLocationToURI(catalogLocationField.getText()));
- getDelegateCatalog().setStartString(prefixField.getText());
- getDelegateCatalog().setEntryType(getDelegateType());
- dataSaved = true;
- }
- else {
- errorMessage = XMLCatalogMessages.UI_WARNING_DUPLICATE_DELEGATE;
- errorMessageLabel.setText(errorMessage);
- updateOKButtonState();
- dataSaved = false;
- }
- }
-
- private int getDelegateType() {
- switch (keyTypeCombo.getSelectionIndex()) {
- case 0:
- return IDelegateCatalog.DELEGATE_TYPE_PUBLIC;
-
- case 1:
- return IDelegateCatalog.DELEGATE_TYPE_SYSTEM;
-
- case 2:
- default:
- return IDelegateCatalog.DELEGATE_TYPE_URI;
- }
- }
-
- protected boolean validateData() {
- IDelegateCatalog entry = getDelegateCatalog();
- String prefix = prefixField.getText();
- if(entry.getEntryType() != getDelegateType() || !prefix.equals(entry.getStartString())) {
- IDelegateCatalog[] entries = catalog.getDelegateCatalogs();
- for (int i = 0; i < entries.length; i++) {
- if (entries[i].getStartString().equals(prefixField) && entries[i].getEntryType() == getDelegateType()) return false;
- }
- }
- return true;
- }
-
- protected String getCatalogLocation() {
- return getDelegateCatalog().getCatalogLocation();
- }
-
- public Control createControl(Composite parent) {
- fControl = createNextCatalogPanel(parent, XMLCatalogMessages.UI_LABEL_DELEGATE_CATALOG_URI_COLON);
- return fControl;
- }
- }
-
- protected class RadioItemSelectionChangeListener implements SelectionListener {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- Object selection = e.getSource();
- if (selection instanceof Button) {
- Button button = (Button) selection;
- if (button.getSelection()) {
- if (!showPage((CatalogElementPage) button.getData())) {
- // Page flipping wasn't successful
- // handleError();
- }
- }
- }
- }
-
- }
-
- protected class RewriteEntryPage extends CatalogElementPage {
- protected IRewriteEntry rewriteEntry;
- private Text startStringField;
- private Text prefixField;
- private Combo keyTypeCombo;
-
- public void refresh() {
- computeErrorMessage();
- updateErrorMessageLabel(errorMessageLabel);
- updateOKButtonState();
- }
-
- public ICatalogElement getData() {
- return getRewriteEntry();
- }
-
- protected Label errorMessageLabel;
-
- protected void computeErrorMessage() {
- errorMessage = null;
-
- String start = startStringField.getText();
- String prefix = prefixField.getText();
- if (start.trim().length() > 0 && prefix.trim().length() > 0) {
- // good
- }
- else {
- // this an error that is not actually
- // reported ... OK is just disabled
- errorMessage = ""; //$NON-NLS-1$
- }
- }
-
- protected IRewriteEntry getRewriteEntry() {
- if (rewriteEntry == null) {
- if ((fCatalogElement != null) && (fCatalogElement.getType() == ICatalogElement.TYPE_REWRITE)) {
- rewriteEntry = (IRewriteEntry) fCatalogElement;
- }
- else {
- if (catalog != null) {
- rewriteEntry = (IRewriteEntry) catalog.createCatalogElement(IRewriteEntry.REWRITE_TYPE_SYSTEM);
- }
- }
- }
- return rewriteEntry;
- }
-
- protected void updateWidgets(Widget widget) {
- computeErrorMessage();
- updateErrorMessageLabel(errorMessageLabel);
- updateOKButtonState();
- }
- public void saveData() {
- if (validateData()) {
- getRewriteEntry().setRewritePrefix(prefixField.getText());
- getRewriteEntry().setStartString(startStringField.getText());
- getRewriteEntry().setEntryType(getEntryType());
- dataSaved = true;
- }
- else {
- errorMessage = XMLCatalogMessages.UI_WARNING_DUPLICATE_REWRITE;
- errorMessageLabel.setText(errorMessage);
- updateOKButtonState();
- dataSaved = false;
- }
- }
-
- private int getEntryType() {
- switch (keyTypeCombo.getSelectionIndex()) {
- case 0:
- return IRewriteEntry.REWRITE_TYPE_SYSTEM;
- case 1:
- default:
- return IRewriteEntry.REWRITE_TYPE_URI;
- }
- }
-
- protected boolean validateData() {
- IRewriteEntry entry = getRewriteEntry();
- String startString = startStringField.getText();
- if(entry.getEntryType() != getEntryType() || !entry.getStartString().equals(startString)) {
- IRewriteEntry[] entries = catalog.getRewriteEntries();
- for (int i = 0; i < entries.length; i++) {
- if (entries[i].getStartString().equals(startString) && entries[i].getEntryType() == getEntryType()) return false;
- }
- }
- return true;
- }
-
- public Control createControl(Composite parent) {
-
- fControl = createRewriteEntryPanel(parent);
-
- return fControl;
- }
-
- public Control createRewriteEntryPanel(Composite parent) {
- ModifyListener modifyListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateWidgets(e.widget);
- }
- };
-
- Composite composite = new Composite(parent, SWT.NONE);
- GridData gd = new GridData(GridData.FILL_BOTH);
- composite.setLayoutData(gd);
-
- GridLayout layout = new GridLayout();
- composite.setLayout(layout);
-
- Composite group = new Composite(composite, SWT.NONE);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- group.setLayoutData(gd);
-
- layout = new GridLayout();
- group.setLayout(layout);
-
- Composite prefixComposite = new Composite(group, SWT.NONE);
-
- layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- layout.marginBottom = 5;
- prefixComposite.setLayout(layout);
-
- // Key Type
- //
- Label keyTypeLabel = new Label(prefixComposite, SWT.NONE);
- keyTypeLabel.setText(XMLCatalogMessages.UI_MATCH_KEY_TYPE_COLON);
-
- keyTypeCombo = new Combo(prefixComposite, SWT.READ_ONLY);
- gd = new GridData();
- gd.horizontalAlignment = SWT.FILL;
- gd.grabExcessHorizontalSpace = true;
- keyTypeCombo.setLayoutData(gd);
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_SYSTEM);
- keyTypeCombo.add(XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_URI);
- switch (getRewriteEntry().getEntryType()) {
- case IDelegateCatalog.DELEGATE_TYPE_SYSTEM:
- keyTypeCombo.select(0);
- break;
- default:
- case IDelegateCatalog.DELEGATE_TYPE_URI:
- keyTypeCombo.select(1);
- break;
- }
- Label startStringLabel = new Label(prefixComposite, SWT.NONE);
- startStringLabel.setText(XMLCatalogMessages.UI_LABEL_START_STRING_COLON);
-
- startStringField = new Text(prefixComposite, SWT.SINGLE | SWT.BORDER);
- startStringField.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
- startStringField.setText(getDisplayValue(getRewriteEntry().getStartString()));
- startStringField.addModifyListener(modifyListener);
-
- Label prefixLabel = new Label(prefixComposite, SWT.NONE);
- prefixLabel.setText(XMLCatalogMessages.UI_LABEL_REWRITE_PREFIX_COLON);
-
- prefixField = new Text(prefixComposite, SWT.SINGLE | SWT.BORDER);
- prefixField.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
- prefixField.setText(getDisplayValue(getRewriteEntry().getRewritePrefix()));
- prefixField.addModifyListener(modifyListener);
-
- prefixComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
-
- errorMessageLabel = new Label(group, SWT.NONE);
- errorMessageLabel.setForeground(color);
- errorMessageLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- updateWidgets(null);
- return composite;
- }
- }
-
- protected class ToolBarItemSelectionChangeListener implements SelectionListener {
- public void widgetDefaultSelected(SelectionEvent e) {}
-
- public void widgetSelected(SelectionEvent e) {
- Object selection = e.getSource();
- if (selection instanceof ToolItem) {
- ToolItem toolItem = (ToolItem)selection;
- ToolBar toolbar = toolItem.getParent();
- if(toolbar != null) {
- ToolItem[] items = toolbar.getItems();
- for (int i = 0; i < items.length; i++) {
- items[i].setSelection(items[i] == toolItem);
- }
- }
- if (!showPage((CatalogElementPage) toolItem.getData())) {
- // Page flipping wasn't successful
- // handleError();
- }
- }
- }
- }
-
- public static String[] createStringArray(List list) {
- String[] stringArray = new String[list.size()];
- for (int i = 0; i < stringArray.length; i++) {
- stringArray[i] = (String) list.get(i);
- }
- return stringArray;
- }
-
- public static String removeLeadingSlash(String uri) {
- // remove leading slash from the value to avoid the whole leading
- // slash
- // ambiguity problem
- //
- if (uri != null) {
- while (uri.startsWith("/") || uri.startsWith("\\")) { //$NON-NLS-1$ //$NON-NLS-2$
- uri = uri.substring(1);
- }
- }
- return uri;
- }
-
- protected ICatalog catalog;
-
- protected ICatalogElement fCatalogElement;
-
- protected String errorMessage;
-
- protected String warningMessage;
-
- protected Button okButton;
-
- protected PageBook pageContainer;
-
- protected CatalogElementPage selectedPage;
-
- // protected TreeViewer treeViewer;
-
- protected ToolBar toolBar;
-
- protected Composite elementTypeComposite;
-
- protected Color color;
- protected boolean dataSaved;
-
- public EditCatalogEntryDialog(Shell parentShell, ICatalog aCatalog) {
- super(parentShell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- this.catalog = aCatalog;
- }
-
- public EditCatalogEntryDialog(Shell parentShell, ICatalogElement catalogElement, ICatalog aCatalog) {
- this(parentShell, aCatalog);
- this.fCatalogElement = catalogElement;
- // TODO EB: fix his
- // entry.setURI(URIHelper.removePlatformResourceProtocol(entry.getURI()));
- }
-
- protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.OK_ID) {
- selectedPage.saveData();
- if (!dataSaved) {
- // do not exit edit dialog
- return;
- }
- }
- super.buttonPressed(buttonId);
- }
-
-
-
- protected void createButtonsForButtonBar(Composite parent) {
- okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- okButton.setEnabled(false);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- updateOKButtonState();
- }
-
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogAreaComposite = (Composite) super.createDialogArea(parent);
- color = new Color(dialogAreaComposite.getDisplay(), 200, 0, 0);
- GridLayout layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- dialogAreaComposite.setLayout(layout);
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.widthHint = 550;
- //gd.heightHint = 250;
- dialogAreaComposite.setLayoutData(gd);
- createMainComponent(dialogAreaComposite);
- return this.dialogArea;
- }
-
- public boolean close() {
- if (color != null) {
- color.dispose();
- }
- return super.close();
- }
-
- protected Composite createMainComponent(Composite composite) {
- if (fCatalogElement != null) // "edit" action
- {
- Composite composite1 = new Composite(composite, SWT.NONE);
- GridData data = new GridData(GridData.FILL_BOTH);
- composite1.setLayoutData(data);
- GridLayout layout = new GridLayout();
- composite1.setLayout(layout);
-
- pageContainer = new PageBook(composite1, SWT.NONE);
- pageContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- if (fCatalogElement.getType() == ICatalogElement.TYPE_ENTRY) {
- CatalogElementPage entryPage = new CatalogEntryPage();
- entryPage.createControl(pageContainer);
- showPage(entryPage);
- }
- else if (fCatalogElement.getType() == ICatalogElement.TYPE_NEXT_CATALOG) {
- CatalogElementPage nextCatalogPage = new NextCatalogPage();
- nextCatalogPage.createControl(pageContainer);
- showPage(nextCatalogPage);
- }
- else if (fCatalogElement.getType() == ICatalogElement.TYPE_DELEGATE) {
- DelegateCatalogPage delegateCatalogPage = new DelegateCatalogPage();
- delegateCatalogPage.createControl(pageContainer);
- showPage(delegateCatalogPage);
- }
- else if (fCatalogElement.getType() == ICatalogElement.TYPE_SUFFIX) {
- SuffixEntryPage suffixEntryPage = new SuffixEntryPage();
- suffixEntryPage.createControl(pageContainer);
- showPage(suffixEntryPage);
- }
- else if (fCatalogElement.getType() == ICatalogElement.TYPE_REWRITE) {
- RewriteEntryPage rewriteEntryPage = new RewriteEntryPage();
- rewriteEntryPage.createControl(pageContainer);
- showPage(rewriteEntryPage);
- }
-
- return composite1;
- }
- return createMainComponentWithToolbar(composite);
-
- }
-
-
- protected Composite createMainComponentWithToolbar(Composite composite) {
-
- FormLayout formLayout = new FormLayout();
- formLayout.marginHeight = 5;
- formLayout.marginWidth = 5;
- composite.setLayout(formLayout);
-
- Label label = new Label(composite, SWT.NONE);
- FormData data = new FormData();
- data.top = new FormAttachment(0, 0);
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- label.setLayoutData(data);
-
- toolBar = new ToolBar(composite, SWT.BORDER | SWT.FLAT | SWT.VERTICAL);
-
-
- data = new FormData();
- data.top = new FormAttachment(label, 0);
- data.left = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(100, 0);
- // data.height = 250;
- // data.width = 50;
- toolBar.setLayoutData(data);
-
- Composite composite1 = new Composite(composite, SWT.BORDER);
- data = new FormData();
- data.top = new FormAttachment(label, 0);
- data.left = new FormAttachment(toolBar, 0, SWT.DEFAULT);
- data.right = new FormAttachment(100, 0);
- data.bottom = new FormAttachment(100, 0);
- composite1.setLayoutData(data);
- GridLayout layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- composite1.setLayout(layout);
-
- // createPageBookPanel(composite1);
- pageContainer = new PageBook(composite1, SWT.NONE);
- pageContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- // add pages for each type of catalog element
- createCatalogEntryButton();
- createRewriteButton();
- createSuffixCatalogButton();
- createNextCatalogButton();
- createDelegateCatalogButton();
- if (toolBar.getItemCount() > 0) {
- ToolItem item = toolBar.getItem(0);
- showPage((CatalogElementPage) (item.getData()));
- }
- return composite1;
- }
-
- protected void createCatalogEntryButton() {
- CatalogElementPage page = new CatalogEntryPage();
- page.createControl(pageContainer);
- ToolItem toolItem = new ToolItem(toolBar, SWT.CHECK);
- toolItem.setImage(catalogEntryToolBarImage);
- toolItem.setText(XMLCatalogMessages.EditCatalogEntryDialog_catalogEntryLabel);
- toolItem.setData(page);
- toolItem.addSelectionListener(new ToolBarItemSelectionChangeListener());
- toolItem.setSelection(true);
- }
-
- protected void createNextCatalogButton() {
- CatalogElementPage page = new NextCatalogPage();
- page.createControl(pageContainer);
- ToolItem toolItem = new ToolItem(toolBar, SWT.CHECK);
- toolItem.setImage(nextCatalogToolBarImage);
- toolItem.setText(XMLCatalogMessages.EditCatalogEntryDialog_nextCatalogLabel);
- toolItem.setData(page);
- toolItem.addSelectionListener(new ToolBarItemSelectionChangeListener());
-
- }
-
- protected void createRewriteButton() {
- CatalogElementPage page = new RewriteEntryPage();
- page.createControl(pageContainer);
- ToolItem toolItem = new ToolItem(toolBar, SWT.CHECK);
- toolItem.setImage(rewriteToolBarImage);
- toolItem.setText(XMLCatalogMessages.EditCatalogEntryDialog_rewriteEntryLabel);
- toolItem.setData(page);
- toolItem.addSelectionListener(new ToolBarItemSelectionChangeListener());
- }
-
- protected void createDelegateCatalogButton() {
- CatalogElementPage page = new DelegateCatalogPage();
- page.createControl(pageContainer);
- ToolItem toolItem = new ToolItem(toolBar, SWT.CHECK);
- toolItem.setImage(delegateCatalogToolBarImage);
- toolItem.setText(XMLCatalogMessages.EditCatalogEntryDialog_delegateCatalogLabel);
- toolItem.setData(page);
- toolItem.addSelectionListener(new ToolBarItemSelectionChangeListener());
- }
-
- protected void createSuffixCatalogButton() {
- CatalogElementPage page = new SuffixEntryPage();
- page.createControl(pageContainer);
- ToolItem toolItem = new ToolItem(toolBar, SWT.CHECK);
- toolItem.setImage(suffixToolBarImage);
- toolItem.setText(XMLCatalogMessages.EditCatalogEntryDialog_suffixEntryLabel);
- toolItem.setData(page);
- toolItem.addSelectionListener(new ToolBarItemSelectionChangeListener());
- }
-
-
-
-
-
-
-//
-// protected void createRewriteEntryButton() {
-// CatalogElementPage page = new RewriteEntryPage();
-// page.createControl(pageContainer);
-// Button radioButton = new Button(elementTypeComposite, SWT.RADIO);
-// radioButton.setText(XMLCatalogMessages.EditCatalogEntryDialog_rewriteEntryLabel);
-// radioButton.setData(page);
-// radioButton.addSelectionListener(new RadioItemSelectionChangeListener());
-// }
-//
-// protected void createSuffixEntryButton() {
-// CatalogElementPage page = new SuffixEntryPage();
-// page.createControl(pageContainer);
-// Button radioButton = new Button(elementTypeComposite, SWT.RADIO);
-// radioButton.setText(XMLCatalogMessages.EditCatalogEntryDialog_suffixEntryLabel);
-// radioButton.setData(page);
-// radioButton.addSelectionListener(new RadioItemSelectionChangeListener());
-// }
-//
-// protected void createDelegateCatalogButton() {
-// CatalogElementPage page = new DelegateCatalogPage();
-// page.createControl(pageContainer);
-// Button radioButton = new Button(elementTypeComposite, SWT.RADIO);
-// radioButton.setText(XMLCatalogMessages.EditCatalogEntryDialog_delegateCatalogLabel);
-// radioButton.setData(page);
-// radioButton.addSelectionListener(new RadioItemSelectionChangeListener());
-//
-// }
-
- protected ICatalogElement getCatalogElement() {
- return fCatalogElement;
- }
-
- protected String getDisplayValue(String string) {
- return string != null ? string : ""; //$NON-NLS-1$
- }
-
- protected XMLCatalogFileType getMatchingFileType(String description) {
- XMLCatalogFileType fileType = null;
- for (Iterator i = CatalogFileTypeRegistryReader.getXMLCatalogFileTypes().iterator(); i.hasNext();) {
- XMLCatalogFileType theFileType = (XMLCatalogFileType) i.next();
- if ((theFileType.description != null) && theFileType.description.equals(description)) {
- fileType = theFileType;
- }
- }
- return fileType;
- }
-
- protected boolean showPage(CatalogElementPage page) {
- if (pageContainer.isDisposed()) {
- return false;
- }
- selectedPage = page;
- pageContainer.setVisible(true);
- pageContainer.showPage(selectedPage.getControl());
- fCatalogElement = selectedPage.getData();
- selectedPage.refresh();
- return true;
- }
-
- protected void updateErrorMessageLabel(Label errorMessageLabel) {
- if (errorMessage != null) {
- errorMessageLabel.setText(errorMessage);
- }
- else if (warningMessage != null) {
- errorMessageLabel.setText(warningMessage);
- }
- else {
- errorMessageLabel.setText("");
- }
- }
-
- protected void updateOKButtonState() {
- if (okButton != null) {
- okButton.setEnabled(errorMessage == null);
- }
- }
-
- protected Button createBrowseButton(Composite composite) {
- Button browseButton = new Button(composite, SWT.PUSH);
- // browseButton.setText(XMLCatalogMessages.
- // UI_BUTTON_BROWSE"));
- browseButton.setImage(borwseImage);
- Rectangle r = borwseImage.getBounds();
- GridData gd = new GridData();
- int IMAGE_WIDTH_MARGIN = 6;
- int IMAGE_HEIGHT_MARGIN = 6;
- gd.heightHint = r.height + IMAGE_HEIGHT_MARGIN;
- gd.widthHint = r.width + IMAGE_WIDTH_MARGIN;
- browseButton.setLayoutData(gd);
-
- return browseButton;
-
- }
-
- protected Button createWorkspaceBrowseButton(Composite composite) {
- Button browseWorkspaceButton = new Button(composite, SWT.PUSH);
- browseWorkspaceButton.setText(XMLCatalogMessages.UI_BUTTON_MENU_BROWSE_WORKSPACE);
- return browseWorkspaceButton;
- }
-
- protected Button createFileSystemBrowseButton(Composite composite) {
- Button browseFileSystemButton = new Button(composite, SWT.PUSH);
- browseFileSystemButton.setText(XMLCatalogMessages.UI_BUTTON_MENU_BROWSE_WORKSPACE);
- return browseFileSystemButton;
- }
-
-
- String invokeWorkspaceFileSelectionDialog() {
- FilterableSelectSingleFileDialog dialog = new FilterableSelectSingleFileDialog(getShell());
- dialog.createAndOpen();
- IFile file = dialog.getFile();
- String uri = null;
- if (file != null) {
- // remove leading slash from the value to avoid the
- // whole leading slash ambiguity problem
- //
- uri = file.getFullPath().toString();
- while (uri.startsWith("/") || uri.startsWith("\\")) { //$NON-NLS-1$ //$NON-NLS-2$
- uri = uri.substring(1);
- }
- }
- return uri;
- }
-
- String invokeFileSelectionDialog() {
- FileDialog dialog = new FileDialog(getShell(), SWT.SINGLE);
- return dialog.open();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ElementNodePage.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ElementNodePage.java
deleted file mode 100644
index 0ec61e6234..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ElementNodePage.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2006 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.catalog;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement;
-
-
-public abstract class ElementNodePage {
-
- Control fControl;
-
- public ElementNodePage() {
- super();
-
- }
-
- public abstract Control createControl(Composite parent);
-
- public Control getControl() {
- return fControl;
- }
-
- public abstract void saveData();
-
- public abstract ICatalogElement getData();
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ImageFactory.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ImageFactory.java
deleted file mode 100644
index 3938a7efb1..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ImageFactory.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2006 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.catalog;
-
-import java.util.Hashtable;
-
-import org.eclipse.jface.resource.CompositeImageDescriptor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-public class ImageFactory {
- public static final int TOP_LEFT = 1;
- public static final int TOP_RIGHT = 2;
- public static final int BOTTOM_LEFT = 3;
- public static final int BOTTOM_RIGHT = 4;
-
- protected static final int[][] OVERLAY_COORDINATE = {{0, 0}, {0, 2}, {2, 0}, {2, 2}};
-
- protected static ImageFactory INSTANCE = new ImageFactory();
-
- protected Hashtable compositeImageTable = new Hashtable();
-
- public ImageFactory() {
- super();
- }
-
- public Image getImage(String iconName) {
- ImageRegistry imageRegistry = XMLUIPlugin.getDefault().getImageRegistry();
-
- if (imageRegistry.get(iconName) != null) {
- return imageRegistry.get(iconName);
- }
- else {
- imageRegistry.put(iconName, ImageDescriptor.createFromFile(getClass(), iconName));
- return imageRegistry.get(iconName);
- }
- }
-
- public Image createCompositeImage(Image base, Image overlay, int overlayPosition) {
- String key = base + "*" + overlay + "*" + overlayPosition; //$NON-NLS-1$ //$NON-NLS-2$
- Image result = (Image) compositeImageTable.get(key);
- if (result == null) {
- ImageDescriptor overlays[][] = new ImageDescriptor[3][3];
- int[] coord = OVERLAY_COORDINATE[overlayPosition];
- overlays[coord[1]][coord[0]] = new ImageBasedImageDescriptor(overlay);
- OverlayIcon icon = new OverlayIcon(new ImageBasedImageDescriptor(base), overlays, new Point(16, 16));
- result = icon.createImage();
- compositeImageTable.put(key, result);
- }
- return result;
- }
-
-
- public static ImageDescriptor createImageDescriptorWrapper(Image image) {
- return new ImageBasedImageDescriptor(image);
- }
-
- /**
- * An OverlayIcon consists of a main icon and several adornments.
- */
- class OverlayIcon extends CompositeImageDescriptor {
-
- static final int DEFAULT_WIDTH = 22;
-
- static final int DEFAULT_HEIGHT = 16;
-
- private Point fSize = null;
-
- private ImageDescriptor fBase;
-
- private ImageDescriptor fOverlays[][];
-
- public OverlayIcon(ImageDescriptor base, ImageDescriptor[][] overlays, Point size) {
- fBase = base;
- fOverlays = overlays;
- fSize = size;
- }
-
- protected void drawBottomLeft(ImageDescriptor[] overlays) {
- if (overlays == null) {
- return;
- }
- int length = overlays.length;
- int x = 0;
- for (int i = 0; i < 3; i++) {
- if ((i < length) && (overlays[i] != null)) {
- ImageData id = overlays[i].getImageData();
- drawImage(id, x, getSize().y - id.height);
- x += id.width;
- }
- }
- }
-
- protected void drawBottomRight(ImageDescriptor[] overlays) {
- if (overlays == null) {
- return;
- }
- int length = overlays.length;
- int x = getSize().x;
- for (int i = 2; i >= 0; i--) {
- if ((i < length) && (overlays[i] != null)) {
- ImageData id = overlays[i].getImageData();
- x -= id.width;
- drawImage(id, x, getSize().y - id.height);
- }
- }
- }
-
- /**
- * @see CompositeImageDescriptor#drawCompositeImage(int, int)
- */
- protected void drawCompositeImage(int width, int height) {
- ImageData bg;
- if ((fBase == null) || ((bg = fBase.getImageData()) == null)) {
- bg = DEFAULT_IMAGE_DATA;
- }
- drawImage(bg, 0, 0);
-
- if (fOverlays != null) {
- if (fOverlays.length > 0) {
- drawTopRight(fOverlays[0]);
- }
-
- if (fOverlays.length > 1) {
- drawBottomRight(fOverlays[1]);
- }
-
- if (fOverlays.length > 2) {
- drawBottomLeft(fOverlays[2]);
- }
-
- if (fOverlays.length > 3) {
- drawTopLeft(fOverlays[3]);
- }
- }
- }
-
- protected void drawTopLeft(ImageDescriptor[] overlays) {
- if (overlays == null) {
- return;
- }
- int length = overlays.length;
- int x = 0;
- for (int i = 0; i < 3; i++) {
- if ((i < length) && (overlays[i] != null)) {
- ImageData id = overlays[i].getImageData();
- drawImage(id, x, 0);
- x += id.width;
- }
- }
- }
-
- protected void drawTopRight(ImageDescriptor[] overlays) {
- if (overlays == null) {
- return;
- }
- int length = overlays.length;
- int x = getSize().x;
- for (int i = 2; i >= 0; i--) {
- if ((i < length) && (overlays[i] != null)) {
- ImageData id = overlays[i].getImageData();
- x -= id.width;
- drawImage(id, x, 0);
- }
- }
- }
-
- /**
- * @see CompositeImageDescriptor#getSize()
- */
- protected Point getSize() {
- return fSize;
- }
- }
-
- static class ImageBasedImageDescriptor extends ImageDescriptor {
- protected Image image;
-
- public ImageBasedImageDescriptor(Image image) {
- this.image = image;
- }
-
- public ImageData getImageData() {
- return image.getImageData();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/URIUtils.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/URIUtils.java
deleted file mode 100644
index ea0c2bc802..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/URIUtils.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 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.catalog;
-
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-
-public class URIUtils {
-
- private static final String PROTOCOL_PATTERN = ":";
- private static final String FILE_PROTOCOL = "file:";
- private static final String PLATFORM_RESOURCE_PROTOCOL = "platform:/resource/";
- private static final String LOCAL_FILE_PROTOCOL_FORWARD_SLASH = "\\\\\\";
- private static final String LOCAL_FILE_PROTOCOL_BACK_SLASH = "///";
- private static final char PATH_SEPARATOR_FORWARD_SLASH = '/';
- private static final char PATH_SEPARATOR_BACK_SLASH = '\\';
-
- public static String convertURIToLocation(String uri) {
- String location = uri;
- if (uri != null) {
- if (uri.startsWith(FILE_PROTOCOL)) {
- location = org.eclipse.wst.common.uriresolver.internal.URI.createURI(uri).toFileString();
- if (location != null && (location.startsWith(LOCAL_FILE_PROTOCOL_BACK_SLASH)
- || location.startsWith(LOCAL_FILE_PROTOCOL_FORWARD_SLASH))) {
- location = location.substring(LOCAL_FILE_PROTOCOL_BACK_SLASH.length());
- }
- } else if (uri.startsWith(PLATFORM_RESOURCE_PROTOCOL)) {
- location = uri.substring(PLATFORM_RESOURCE_PROTOCOL.length());
- }
- }
- return location;
- }
-
- public static String convertLocationToURI(String location) {
- String uri = location;
- if (!URIHelper.hasProtocol(location)) {
- uri = URIHelper.isAbsolute(location)? org.eclipse.wst.common.uriresolver.internal.URI.createFileURI(location).toString()
- : URIHelper.prependPlatformResourceProtocol(location);
- }
- if (uri.startsWith(FILE_PROTOCOL) && uri.indexOf(PROTOCOL_PATTERN, FILE_PROTOCOL.length()) != -1) {
- uri = URIHelper.ensureFileURIProtocolFormat(uri);
- }
- uri = uri.replace(PATH_SEPARATOR_BACK_SLASH, PATH_SEPARATOR_FORWARD_SLASH);
- return uri;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntriesView.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntriesView.java
deleted file mode 100644
index 92f8bb5170..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntriesView.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2008 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.catalog;
-
-import java.util.Iterator;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.xml.core.internal.catalog.Catalog;
-import org.eclipse.wst.xml.core.internal.catalog.CatalogElement;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-
-
-public class XMLCatalogEntriesView extends Composite {
- protected Button newButton;
- protected Button editButton;
- protected Button deleteButton;
- protected XMLCatalogTreeViewer tableViewer;
- protected ICatalog workingUserCatalog;
- protected ICatalog systemCatalog;
-
- // protected boolean isPageEnabled = true;
-
- public XMLCatalogEntriesView(Composite parent, ICatalog workingUserCatalog, ICatalog systemCatalog) {
- super(parent, SWT.NONE);
- this.workingUserCatalog = workingUserCatalog;
- this.systemCatalog = systemCatalog;
-
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 2;
- this.setLayout(gridLayout);
-
- tableViewer = createTableViewer(this);
- tableViewer.setInput("dummy"); //$NON-NLS-1$
-
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=202692
- // specifically set size of tree before expanding it
- Point initialSize = tableViewer.getTree().computeSize(SWT.DEFAULT, SWT.DEFAULT);
- GridData gridData = new GridData(GridData.FILL_BOTH);
- gridData.widthHint = initialSize.x;
- gridData.heightHint = initialSize.y;
- tableViewer.getControl().setLayoutData(gridData);
-
- tableViewer.expandToLevel(2);
- tableViewer.reveal(XMLCatalogTreeViewer.USER_SPECIFIED_ENTRIES_OBJECT);
-
- ISelectionChangedListener listener = new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- updateWidgetEnabledState();
- }
- };
- tableViewer.addSelectionChangedListener(listener);
-
- createButtons(this);
- }
-
- public static String removeLeadingSlash(String uri) {
- // remove leading slash from the value to avoid the whole leading
- // slash ambiguity problem
- //
- if (uri != null) {
- while (uri.startsWith("/") || uri.startsWith("\\")) //$NON-NLS-1$ //$NON-NLS-2$
- {
- uri = uri.substring(1);
- }
- }
- return uri;
- }
-
- protected XMLCatalogTreeViewer createTableViewer(Composite parent) {
- String headings[] = new String[2];
- headings[0] = XMLCatalogMessages.UI_LABEL_KEY;
- headings[1] = XMLCatalogMessages.UI_LABEL_URI;
-
- XMLCatalogTreeViewer theTableViewer = new XMLCatalogTreeViewer(parent, workingUserCatalog, systemCatalog);
- return theTableViewer;
- }
-
- protected void createButtons(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridData gd = new GridData();
- gd.verticalAlignment = GridData.BEGINNING;
- composite.setLayoutData(gd);
- GridLayout gridLayout = new GridLayout();
- gridLayout.marginHeight = 0;
- gridLayout.marginWidth = 0;
- gridLayout.marginLeft = 3;
- composite.setLayout(gridLayout);
-
- SelectionListener selectionListener = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (e.widget == newButton) {
- performNew();
- }
- else if (e.widget == editButton) {
- performEdit();
- }
- else if (e.widget == deleteButton) {
- performDelete();
- }
- }
- };
-
- // add the "New..." button
- //
- gd = new GridData();
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = true;
-
- newButton = new Button(composite, SWT.NONE);
- newButton.setText(XMLCatalogMessages.UI_BUTTON_NEW);
- // WorkbenchHelp.setHelp(newButton,
- // XMLBuilderContextIds.XMLP_MAPPING_NEW);
- newButton.setLayoutData(gd);
- newButton.addSelectionListener(selectionListener);
-
- // add the "Edit..." button
- //
- gd = new GridData();
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = true;
- editButton = new Button(composite, SWT.NONE);
- editButton.setText(XMLCatalogMessages.UI_BUTTON_EDIT);
- // WorkbenchHelp.setHelp(editButton,
- // XMLBuilderContextIds.XMLP_MAPPING_EDIT);
- editButton.setLayoutData(gd);
- editButton.addSelectionListener(selectionListener);
-
- // add the "Delete" button
- //
- gd = new GridData();
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = true;
- deleteButton = new Button(composite, SWT.NONE);
- deleteButton.setText(XMLCatalogMessages.UI_BUTTON_REMOVE);
- // WorkbenchHelp.setHelp(deleteButton,
- // XMLBuilderContextIds.XMLP_MAPPING_DELETE);
- deleteButton.setLayoutData(gd);
- deleteButton.addSelectionListener(selectionListener);
-
- gd = new GridData();
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = true;
- gd.horizontalSpan = 4;
-
- Button hiddenButton = new Button(composite, SWT.NONE);
- hiddenButton.setLayoutData(gd);
- hiddenButton.setVisible(false);
- hiddenButton.setEnabled(false);
-
- // a cruddy hack so that the PreferenceDialog doesn't close every time
- // we press 'enter'
- //
- getShell().setDefaultButton(hiddenButton);
- updateWidgetEnabledState();
- }
-
- public void refresh() {
- tableViewer.refresh();// XMLCatalogTreeViewer.USER_SPECIFIED_ENTRIES_OBJECT);
- }
-
- protected EditCatalogEntryDialog invokeDialog(String title, ICatalogElement entry, ICatalog catalog) {
- Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
- EditCatalogEntryDialog dialog = entry != null ? new EditCatalogEntryDialog(shell, entry, catalog) : new EditCatalogEntryDialog(shell, catalog);
- dialog.create();
- dialog.getShell().setText(title);
- dialog.setBlockOnOpen(true);
- dialog.open();
- return dialog;
- }
-
- protected EditCatalogEntryDialog invokeDialog(String title, ICatalog catalog) {
- return invokeDialog(title, null, catalog);
- }
-
-
- protected void performNew() {
-
- // ICatalogEntry newEntry =
- // (ICatalogEntry)workingUserCatalog.createCatalogElement(ICatalogElement.TYPE_ENTRY);
- EditCatalogEntryDialog dialog = invokeDialog(XMLCatalogMessages.UI_LABEL_NEW_DIALOG_TITLE, workingUserCatalog);
- ICatalogElement element = dialog.getCatalogElement();
- if (dialog.getReturnCode() == Window.OK) {
- workingUserCatalog.addCatalogElement(element);
- tableViewer.setSelection(new StructuredSelection(element), true);
- tableViewer.refresh();
- }
- }
-
- protected void performEdit() {
- ISelection selection = tableViewer.getSelection();
- Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null;
-
- if (selectedObject instanceof ICatalogElement) {
- ICatalogElement oldEntry = (ICatalogElement) selectedObject;
- ICatalogElement newEntry = (ICatalogElement) ((CatalogElement) oldEntry).clone();
-
- EditCatalogEntryDialog dialog = invokeDialog(XMLCatalogMessages.UI_LABEL_EDIT_DIALOG_TITLE, newEntry, workingUserCatalog);
- if (dialog.getReturnCode() == Window.OK) {
- // delete the old value if the 'mapFrom' has changed
- //
- workingUserCatalog.removeCatalogElement(oldEntry);
-
- // update the new mapping
- //
- workingUserCatalog.addCatalogElement(newEntry);
- tableViewer.setSelection(new StructuredSelection(newEntry));
- }
- }
- }
-
- protected void performDelete() {
- ISelection selection = tableViewer.getSelection();
- if(selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection)selection;
- Iterator iterator = structuredSelection.iterator();
- while(iterator.hasNext()) {
- Object selectedObject = iterator.next();
- if (selectedObject instanceof ICatalogElement) {
- ICatalogElement catalogElement = (ICatalogElement) selectedObject;
- workingUserCatalog.removeCatalogElement(catalogElement);
- }
- }
- }
- }
-
- protected void updateWidgetEnabledState() {
- boolean isEditable = false;
- ISelection selection = tableViewer.getSelection();
- boolean multipleSelection = false;
- if(selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection)selection;
- if(structuredSelection.size() > 1) {
- multipleSelection = true;
- }
- Object selectedObject = structuredSelection.getFirstElement();
- if (selectedObject instanceof ICatalogElement) {
- ICatalogElement[] elements = ((Catalog) workingUserCatalog).getCatalogElements();
- // dw List entriesList = new ArrayList(elements.length);
- for (int i = 0; i < elements.length; i++) {
- ICatalogElement element = elements[i];
- isEditable = selectedObject.equals(element);
- if (isEditable) {
- break;
- }
- }
- }
- }
-
- // if (isPageEnabled)
- {
- editButton.setEnabled(isEditable & !multipleSelection);
- deleteButton.setEnabled(isEditable);
- }
- }
-
- /*
- * public void setPageEnabled(boolean enabled) { isPageEnabled = enabled;
- *
- * tableViewer.getControl().setEnabled(isPageEnabled);
- *
- * newButton.setEnabled(isPageEnabled);
- * editButton.setEnabled(isPageEnabled);
- * deleteButton.setEnabled(isPageEnabled); }
- */
- public void updatePage() {
- refresh();
- updateWidgetEnabledState();
- }
-
- public Viewer getViewer() {
- return tableViewer;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntryDetailsView.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntryDetailsView.java
deleted file mode 100644
index 054695065d..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntryDetailsView.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2010 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.catalog;
-
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.IDelegateCatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.IRewriteEntry;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ISuffixEntry;
-
-
-
-public class XMLCatalogEntryDetailsView {
- protected Text detailsText;
- protected ScrollBar verticalScroll, horizontalScroll;
-
- public XMLCatalogEntryDetailsView(Composite parent) {
- Color color = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
-
- detailsText = new Text(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
-
- GridData data = new GridData(GridData.FILL_BOTH);
- data.heightHint = 85;
- detailsText.setLayoutData(data);
-
- verticalScroll = detailsText.getVerticalBar();
- // verticalScroll.setVisible(false);
- horizontalScroll = detailsText.getHorizontalBar();
- detailsText.setEditable(false);
- detailsText.setBackground(color);
- }
-
- protected void setCatalogEntry(ICatalogEntry entry) {
- if (entry == null) {
- detailsText.setText(""); //$NON-NLS-1$
- return;
- }
- String value = getDisplayValue(entry != null ? entry.getURI() : ""); //$NON-NLS-1$
- String line0 = XMLCatalogMessages.UI_LABEL_ENTRY_ELEMENT_COLON + "\t\t"; //$NON-NLS-1$
- String line2 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_COLON + "\t\t\t\t" + value; //$NON-NLS-1$
- String line1;
- if (value.startsWith("jar:file:")) { //$NON-NLS-1$
- String jarFile = URIUtils.convertURIToLocation(URIHelper.ensureURIProtocolFormat(value.substring("jar:".length(), value.indexOf('!')))); //$NON-NLS-1$
- String internalFile = URIUtils.convertURIToLocation(URIHelper.ensureURIProtocolFormat("file://" + value.substring(value.indexOf('!') + 1))); //$NON-NLS-1$
- line1 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_LOCATION + "\t\t\t" + internalFile + " " + XMLCatalogMessages.UI_LABEL_DETAILS_IN_JAR_FILE + " " + jarFile; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- else {
- value = URIUtils.convertURIToLocation(value);
- line1 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_LOCATION + "\t\t\t" + value; //$NON-NLS-1$
-
- }
- switch(entry.getEntryType()) {
- case ICatalogEntry.ENTRY_TYPE_PUBLIC: line0 += XMLCatalogMessages.UI_LABEL_PUBLIC; break;
- case ICatalogEntry.ENTRY_TYPE_SYSTEM: line0 += XMLCatalogMessages.UI_LABEL_SYSTEM; break;
- case ICatalogEntry.ENTRY_TYPE_URI: line0 += XMLCatalogMessages.UI_LABEL_URI; break;
- }
- value = entry != null ? getKeyTypeValue(entry) : ""; //$NON-NLS-1$
- String line3 = XMLCatalogMessages.UI_KEY_TYPE_DETAILS_COLON + "\t\t\t" + value; //$NON-NLS-1$
- value = getDisplayValue(entry != null ? entry.getKey() : ""); //$NON-NLS-1$
- String line4 = XMLCatalogMessages.UI_LABEL_DETAILS_KEY_COLON + "\t\t\t\t" + value; //$NON-NLS-1$
- String entireString = line0 + "\n" + line1 + "\n" + line2 + "\n" + line3 + "\n" + line4; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- detailsText.setText(entireString);
- }
-
- protected void setNextCatalog(INextCatalog nextCatalog) {
- String value = getDisplayValue(nextCatalog != null ? nextCatalog.getCatalogLocation() : ""); //$NON-NLS-1$
- String line0 = XMLCatalogMessages.UI_LABEL_ENTRY_ELEMENT_COLON + "\t\t" + XMLCatalogMessages.UI_LABEL_NEXT_CATALOG; //$NON-NLS-1$
- String line1 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_LOCATION + "\t\t\t" + URIUtils.convertURIToLocation(value); //$NON-NLS-1$
- String line2 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_COLON + "\t\t\t\t" + value; //$NON-NLS-1$
- String entireString = line0 + "\n" + line1 + "\n" + line2; //$NON-NLS-1$ //$NON-NLS-2$
- detailsText.setText(entireString);
- }
-
- protected void setSuffixEntry(ISuffixEntry element) {
- String value = getDisplayValue(element != null ? element.getURI() : ""); //$NON-NLS-1$
- String line0 = XMLCatalogMessages.UI_LABEL_ENTRY_ELEMENT_COLON + "\t\t" + XMLCatalogMessages.UI_LABEL_SUFFIX_ENTRY; //$NON-NLS-1$
- String line1 = XMLCatalogMessages.UI_LABEL_DETAILS_SUFFIX_COLON + "\t\t\t\t" + element.getSuffix(); //$NON-NLS-1$
- String line2 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_LOCATION + "\t\t\t" + URIUtils.convertURIToLocation(value); //$NON-NLS-1$
- String line3 = XMLCatalogMessages.UI_KEY_TYPE_DETAILS_COLON + "\t\t\t"; //$NON-NLS-1$
- String uri = element.getURI();
- boolean isSchema = false;
- if(uri != null && uri.endsWith("xsd")) { //$NON-NLS-1$
- isSchema = true;
- }
- switch (element.getEntryType()) {
- case ISuffixEntry.SUFFIX_TYPE_SYSTEM:
- line3 += isSchema? XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_XSD_SYSTEM : XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_SYSTEM;
- break;
- default:
- case ISuffixEntry.SUFFIX_TYPE_URI:
- line3 += isSchema? XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_XSD_PUBLIC : XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_URI;
- break;
- }
- String entireString = line0 + "\n" + line1 +"\n" + line2 + "\n" + line3; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- detailsText.setText(entireString);
- }
-
- protected void setRewriteEntry(IRewriteEntry element) {
- String line0 = XMLCatalogMessages.UI_LABEL_ENTRY_ELEMENT_COLON + "\t\t" + XMLCatalogMessages.UI_LABEL_REWRITE_ENTRY; //$NON-NLS-1$
- String line1 = XMLCatalogMessages.UI_LABEL_START_STRING + "\t\t" + element.getStartString(); //$NON-NLS-1$
- String line2 = XMLCatalogMessages.UI_LABEL_REWRITE_PREFIX + "\t" + element.getRewritePrefix(); //$NON-NLS-1$
- String line3 = XMLCatalogMessages.UI_KEY_TYPE_DETAILS_COLON + "\t\t\t" ; //$NON-NLS-1$
- switch (element.getEntryType()) {
- case IRewriteEntry.REWRITE_TYPE_SYSTEM:
- line3 += XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_SYSTEM;
- break;
- default:
- case IRewriteEntry.REWRITE_TYPE_URI:
- line3 += XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_URI;
- break;
- }
- String entireString = line0 + "\n" + line1 + "\n" + line2 + "\n" + line3; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- detailsText.setText(entireString);
- }
-
- protected void setDelegateCatalog(IDelegateCatalog element) {
- String value = getDisplayValue(element != null ? element.getCatalogLocation() : ""); //$NON-NLS-1$
- String line0 = XMLCatalogMessages.UI_LABEL_ENTRY_ELEMENT_COLON + "\t\t" + XMLCatalogMessages.UI_LABEL_DELEGATE_CATALOG; //$NON-NLS-1$
- String line1 = XMLCatalogMessages.UI_LABEL_START_STRING + "\t\t" + element.getStartString(); //$NON-NLS-1$
- String line2 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_LOCATION + "\t\t\t" + URIUtils.convertURIToLocation(value); //$NON-NLS-1$
- String line3 = XMLCatalogMessages.UI_KEY_TYPE_DETAILS_COLON + "\t\t\t"; //$NON-NLS-1$
- switch (element.getEntryType()) {
- case IDelegateCatalog.DELEGATE_TYPE_PUBLIC:
- line3 += XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_PUBLIC;
- break;
- case IDelegateCatalog.DELEGATE_TYPE_SYSTEM:
- line3 += XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_SYSTEM;
- break;
- default:
- case IDelegateCatalog.DELEGATE_TYPE_URI:
- line3 += XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_URI;
- break;
- }
- String entireString = line0 + "\n" + line1 + "\n" + line2 + "\n" + line3; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- detailsText.setText(entireString);
- }
-
- public void setCatalogElement(ICatalogElement element) {
- // I wish we had a visitor for this kind of mess
- if (element instanceof ICatalogEntry) setCatalogEntry((ICatalogEntry)element);
- else if (element instanceof INextCatalog) setNextCatalog((INextCatalog)element);
- else if (element instanceof IDelegateCatalog) setDelegateCatalog((IDelegateCatalog)element);
- else if (element instanceof IRewriteEntry) setRewriteEntry((IRewriteEntry)element);
- else if (element instanceof ISuffixEntry) setSuffixEntry((ISuffixEntry)element);
- else setCatalogEntry(null); // Gives null text
- }
-
-
- protected String getDisplayValue(String string) {
- return string != null ? string : ""; //$NON-NLS-1$
- }
-
- protected String getKeyTypeValue(ICatalogEntry entry) {
- String result = null;
- if ((entry.getURI() != null) && entry.getURI().endsWith("xsd")) //$NON-NLS-1$
- {
- result = (entry.getEntryType() == ICatalogEntry.ENTRY_TYPE_URI) ? XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_XSD_PUBLIC : XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_XSD_SYSTEM;
- }
- else {
- switch (entry.getEntryType()) {
- case ICatalogEntry.ENTRY_TYPE_PUBLIC :
- result = XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_PUBLIC;
- break;
- case ICatalogEntry.ENTRY_TYPE_SYSTEM :
- result = XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_DTD_SYSTEM;
- break;
- default :
- result = XMLCatalogMessages.UI_KEY_TYPE_DESCRIPTION_URI;
- break;
- }
-
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogFileType.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogFileType.java
deleted file mode 100644
index c3cbbe80ae..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogFileType.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2006 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.catalog;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import com.ibm.icu.util.StringTokenizer;
-
-import org.eclipse.swt.graphics.Image;
-
-
-public class XMLCatalogFileType {
- public String description;
- public String id;
- public List extensions = new ArrayList();
- public String iconFileName;
- public Image icon;
-
- public void addExtensions(String contributedExtensions) {
- List list = parseExtensions(contributedExtensions);
- for (Iterator i = list.iterator(); i.hasNext();) {
- String extension = (String) i.next();
- if (!extensions.contains(extension)) {
- extensions.add(extension);
- }
- }
- }
-
- protected List parseExtensions(String string) {
- List list = new ArrayList();
- for (StringTokenizer st = new StringTokenizer(string, ", "); st.hasMoreTokens();) //$NON-NLS-1$
- {
- String token = st.nextToken();
- if (token != null) {
- list.add(token);
- }
- }
- return list;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogMessages.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogMessages.java
deleted file mode 100644
index fc526b6cc2..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogMessages.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 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.catalog;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Strings used by XML Editor
- *
- * @plannedfor 1.0
- */
-public class XMLCatalogMessages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.wst.xml.ui.internal.catalog.XMLCatalogResources";//$NON-NLS-1$
-
- public static String UI_WIZARD_SCHEMA_AND_NAME_SPACE_INFO;
- public static String UI_LABEL_NAME_SPACE_PREFIX;
- public static String UI_LABEL_NAME_SPACE_URI;
- public static String UI_LABEL_XSD_LOCATION;
- public static String UI_LABEL_DOCTYPE_INFORMATION;
- public static String UI_LABEL_SYSTEM_ID;
- public static String UI_LABEL_PUBLIC_ID;
- public static String UI_LABEL_SELECT_FILE;
- public static String UI_LABEL_KEY;
- public static String UI_LABEL_KEY_COLON;
- public static String UI_LABEL_SUFFIX;
- public static String UI_LABEL_SUFFIX_COLON;
- public static String UI_LABEL_DETAILS_KEY_COLON;
- public static String UI_LABEL_DETAILS_IN_JAR_FILE;
- public static String UI_LABEL_URI;
- public static String UI_LABEL_LOCATION_COLON;
- public static String UI_MATCH_KEY_TYPE_COLON;
- public static String UI_LABEL_ARROW;
- public static String UI_LABEL_CATALOG_URI_COLON;
- public static String UI_LABEL_DETAILS_URI_COLON;
- public static String UI_LABEL_DETAILS_URI_LOCATION;
- public static String UI_KEY_TYPE_COLON;
- public static String UI_ELEMENT_TYPE_COLON;
- public static String UI_LABEL_START_STRING_COLON;
- public static String UI_LABEL_REWRITE_PREFIX_COLON;
- public static String UI_KEY_TYPE_DETAILS_COLON;
- public static String UI_KEY_TYPE_DESCRIPTION_XSD_PUBLIC;
- public static String UI_KEY_TYPE_DESCRIPTION_XSD_SYSTEM;
- public static String UI_KEY_TYPE_DESCRIPTION_DTD_PUBLIC;
- public static String UI_KEY_TYPE_DESCRIPTION_DTD_SYSTEM;
- public static String UI_KEY_TYPE_DESCRIPTION_URI;
- public static String UI_LABEL_SPECIFY_ALTERNATIVE_WEB_URL;
- public static String UI_WARNING_URI_MUST_NOT_HAVE_DOTS;
- public static String UI_LABEL_FILE_SELECTION;
- public static String UI_LABEL_CHOOSE_FILE_TO_ADD_TO_CATALOG;
-
-
- public static String UI_WARNING_URI_NOT_FOUND_COLON;
- public static String UI_WARNING_URI_NOT_FOUND_LONG;
- public static String UI_WARNING_INVALID_FILE;
- public static String UI_WARNING_INVALID_FILE_LONG;
- public static String UI_WARNING_NO_ELEMENT;
- public static String UI_WARNING_NO_ELEMENT_DTD_LONG;
- public static String UI_WARNING_NO_ELEMENT_XSD_LONG;
- public static String UI_WARNING_SHOULD_BE_FULLY_QUALIFIED_URI;
- public static String UI_WARNING_DUPLICATE_ENTRY;
- public static String UI_WARNING_DUPLICATE_SUFFIX;
- public static String UI_WARNING_DUPLICATE_REWRITE;
- public static String UI_WARNING_DUPLICATE_DELEGATE;
-
- // NewModelWizard
- public static String UI_INVALID_GRAMMAR_ERROR;
- public static String UI_BUTTON_BROWSE;
-
- // XMLCatalogIdMappingPage
- public static String UI_LABEL_MAP_TO;
- public static String UI_LABEL_MAP_FROM;
- public static String UI_BUTTON_NEW;
- public static String UI_BUTTON_EDIT;
- public static String UI_BUTTON_DELETE;
- public static String UI_BUTTON_REMOVE;
- public static String UI_LABEL_NEW_DIALOG_TITLE;
- public static String UI_LABEL_EDIT_DIALOG_TITLE;
-
-
- // XMLCatalogPreferencePage
- public static String UI_LABEL_USER_ENTRIES;
- public static String UI_LABEL_USER_ENTRIES_TOOL_TIP;
- public static String UI_LABEL_SYSTEM_ENTRIES;
- public static String UI_LABEL_SYSTEM_ENTRIES_TOOL_TIP;
- public static String UI_BUTTON_CHANGE;
- public static String UI_LABEL_SELECT_PROJECT;
- public static String UI_LABEL_SPECIFY_PROJECT_DESCRIPTION;
- public static String UI_WARNING_NO_PROJECTS_CREATED;
- public static String UI_WARNING_PROJECT_NOT_SPECIFIED;
- public static String UI_WARNING_PROJECT_DOES_NOT_EXIST;
- public static String UI_LABEL_PROJECT_TO_USE;
- public static String UI_LABEL_CATALOG_SAVE_ERROR;
- public static String UI_LABEL_CATALOG_COULD_NOT_BE_SAVED;
- public static String UI_LABEL_ADVANCED;
- public static String UI_LABEL_ADVANCED_XML_CATALOG_PREFS;
- public static String UI_LABEL_SPECIFY_PERSISTENCE_FILE;
- public static String UI_LABEL_SAVE_CATALOG_DIALOG_TITLE;
- public static String UI_LABEL_SAVE_CATALOG_DIALOG_DESC;
- public static String UI_LABEL_BROWSE_CATALOG_FILE_TITLE;
- public static String UI_LABEL_BROWSE_CATALOG_FILE_DESC;
- public static String UI_LABEL_DETAILS;
- public static String UI_LABEL_USER_SPECIFIED_ENTRIES;
- public static String UI_LABEL_PLUGIN_SPECIFIED_ENTRIES;
- public static String UI_LABEL_PLATFORM_RESOURCE;
- public static String UI_LABEL_FILE_SYSTEM_RESOURCE;
- // AdvancedOptionsDialog
- public static String UI_BUTTON_IMPORT;
- public static String UI_BUTTON_EXPORT;
-
- public static String UI_LABEL_IMPORT_DIALOG_TITLE;
- public static String UI_LABEL_IMPORT_DIALOG_HEADING;
- public static String UI_LABEL_IMPORT_DIALOG_MESSAGE;
-
- public static String UI_LABEL_EXPORT_DIALOG_TITLE;
- public static String UI_LABEL_EXPORT_DIALOG_HEADING;
- public static String UI_LABEL_EXPORT_DIALOG_MESSAGE;
- public static String ERROR_SAVING_FILE;
- public static String UI_LABEL_FILE_IS_READ_ONLY;
- public static String UI_LABEL_DIALOG_DESCRIPTION;
-
- public static String UI_LABEL_NEXT_CATALOG;
- public static String UI_LABEL_DELEGATE_CATALOG;
- public static String UI_LABEL_REWRITE_ENTRY;
- public static String UI_LABEL_SUFFIX_ENTRY;
-
- public static String UI_LABEL_DELEGATE_CATALOG_URI_COLON;
- public static String EditCatalogEntryDialog_catalogEntryLabel;
- public static String EditCatalogEntryDialog_nextCatalogLabel;
- public static String EditCatalogEntryDialog_rewriteEntryLabel;
- public static String EditCatalogEntryDialog_suffixEntryLabel;
- public static String EditCatalogEntryDialog_delegateCatalogLabel;
- public static String UI_BUTTON_MENU_BROWSE_WORKSPACE;
- public static String UI_BUTTON_MENU_BROWSE_FILE_SYSTEM;
- public static String UI_LABEL_SELECT_FILE_FILTER_CONTROL;
- public static String UI_TEXT_SELECT_FILE_FILTER_CONTROL;
-
- public static String UI_LABEL_PUBLIC;
- public static String UI_LABEL_SYSTEM;
-
- public static String UI_LABEL_START_STRING;
- public static String UI_LABEL_REWRITE_PREFIX;
- public static String UI_LABEL_ENTRY_ELEMENT_COLON;
-
- public static String UI_LABEL_DETAILS_SUFFIX_COLON;
-
- static {
- // load message values from bundle file
- NLS.initializeMessages(BUNDLE_NAME, XMLCatalogMessages.class);
- }
-
- private XMLCatalogMessages() {
- // cannot create new instance
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogPreferencePage.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogPreferencePage.java
deleted file mode 100644
index e84a82adc5..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogPreferencePage.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2010 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
- * David Carver/STAR Standard - d_a_carver@yahoo.com - bug 192568
- * Removed Advanced button - Functionality is now in the
- * Import/Export XML Catalog Wizards.
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.catalog;
-
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-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.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.catalog.CatalogSet;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEvent;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogListener;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog;
-
-public class XMLCatalogPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, ICatalogListener {
-
- protected XMLCatalogEntriesView catalogEntriesView;
-
- protected ICatalog workingUserCatalog;
-
- protected ICatalog systemCatalog;
-
- protected ICatalog userCatalog;
-
- protected ICatalog defaultCatalog;
-
- protected Button advancedButton;
-
- public XMLCatalogPreferencePage() {
- defaultCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
- INextCatalog[] nextCatalogs = defaultCatalog.getNextCatalogs();
- for (int i = 0; i < nextCatalogs.length; i++) {
- INextCatalog catalog = nextCatalogs[i];
- ICatalog referencedCatalog = catalog.getReferencedCatalog();
- if (referencedCatalog != null) {
- if (XMLCorePlugin.SYSTEM_CATALOG_ID.equals(referencedCatalog.getId())) {
- systemCatalog = referencedCatalog;
- }
- else if (XMLCorePlugin.USER_CATALOG_ID.equals(referencedCatalog.getId())) {
- userCatalog = referencedCatalog;
- }
- }
- }
- }
-
- public void dispose() {
- super.dispose();
- workingUserCatalog.removeListener(this);
- }
-
- /**
- * Refresh the view in responce to an event sent by the Catalog
- */
- public void catalogChanged(ICatalogEvent event) {
- catalogEntriesView.updatePage();
- }
-
- /**
- * Creates preference page controls on demand.
- *
- * @param parent
- * the parent for the preference page
- */
- protected Control createContents(Composite parent) {
- // we create a working copy of the 'User Settings' for the Catalog
- // that we can modify
- CatalogSet tempCatalogSet = new CatalogSet();
- workingUserCatalog = tempCatalogSet.lookupOrCreateCatalog("working", ""); //$NON-NLS-1$ //$NON-NLS-2$
-
- // TODO: add entries from the nested catalogs as well
- workingUserCatalog.addEntriesFromCatalog(userCatalog);
- workingUserCatalog.addListener(this);
- noDefaultAndApplyButton();
- Composite composite = new Composite(parent, SWT.NULL);
- // WorkbenchHelp.setHelp(composite, new
- // ControlContextComputer(composite,
- // XMLBuilderContextIds.XMLP_CATALOG_PAGE));
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- createCatalogEntriesView(composite);
- createCatalogDetailsView(composite);
- //createAdvancedButton(composite);
- // catalogEntriesView.updatePage();
- applyDialogFont(composite);
-
- return composite;
- }
-
- /**
- * @deprecated
- * @param composite
- */
- protected void createAdvancedButton(Composite composite) {
- Composite panel = new Composite(composite, SWT.NONE);
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 3;
- panel.setLayout(gridLayout);
- panel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- // TODO... is there a better way to expand the page width?
- // This invisible label is created to force the width of the page to
- // be
- // wide enough to show
- // the rather long uri and key fields of a catalog entry.
- Label widthFudger = new Label(panel, SWT.NONE);
- String widthFudgerString = ""; //$NON-NLS-1$
- for (int i = 0; i < 55; i++) {
- widthFudgerString += "x"; //$NON-NLS-1$
- }
- widthFudger.setText(widthFudgerString);
- widthFudger.setVisible(false);
- Composite placeHolder = new Composite(panel, SWT.NONE);
- placeHolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- advancedButton = new Button(panel, SWT.NONE);
- advancedButton.setText(XMLCatalogMessages.UI_LABEL_ADVANCED);
- SelectionListener selectionListener = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- AdvancedOptionsDialog dialog = new AdvancedOptionsDialog(getShell(), workingUserCatalog);
- dialog.create();
- dialog.getShell().setText(XMLCatalogMessages.UI_LABEL_ADVANCED_XML_CATALOG_PREFS);
- dialog.setBlockOnOpen(true);
- dialog.open();
- }
- };
- advancedButton.addSelectionListener(selectionListener);
- }
-
- public boolean isSameFileName(String a, String b) {
- boolean result = false;
- if ((a == null) && (b == null)) {
- result = true;
- }
- else if ((a != null) && (b != null)) {
- result = a.equals(b);
- }
- return result;
- }
-
- protected void createCatalogEntriesView(Composite parent) {
- Group group = new Group(parent, SWT.NONE);
- group.setLayout(new GridLayout());
- group.setLayoutData(new GridData(GridData.FILL_BOTH));
- group.setText(XMLCatalogMessages.UI_LABEL_USER_ENTRIES);
- group.setToolTipText(XMLCatalogMessages.UI_LABEL_USER_ENTRIES_TOOL_TIP);
- // WorkbenchHelp.setHelp(userEntriesGroup, new
- // ControlContextComputer(userEntriesGroup,
- // XMLBuilderContextIds.XMLP_CATALOG_USER_GROUP));
- catalogEntriesView = new XMLCatalogEntriesView(group, workingUserCatalog, systemCatalog);
- catalogEntriesView.setLayoutData(new GridData(GridData.FILL_BOTH));
- }
-
- protected void createCatalogDetailsView(Composite parent) {
- Group detailsGroup = new Group(parent, SWT.NONE);
- detailsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- detailsGroup.setLayout(new GridLayout());
- detailsGroup.setText(XMLCatalogMessages.UI_LABEL_DETAILS);
- final XMLCatalogEntryDetailsView detailsView = new XMLCatalogEntryDetailsView(detailsGroup);
- ISelectionChangedListener listener = new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- ISelection selection = event.getSelection();
- Object selectedObject = (selection instanceof IStructuredSelection) && ((IStructuredSelection) selection).size() == 1 ? ((IStructuredSelection) selection).getFirstElement() : null;
- if (selectedObject instanceof ICatalogElement) {
- detailsView.setCatalogElement((ICatalogElement)selectedObject);
- } else {
- detailsView.setCatalogElement(null);
- }
- }
- };
- catalogEntriesView.getViewer().addSelectionChangedListener(listener);
- }
-
- /**
- * Do anything necessary because the OK button has been pressed.
- *
- * @return whether it is okay to close the preference page
- */
- public boolean performOk() {
- return storeValues();
- }
-
- /**
- * @see IWorkbenchPreferencePage
- */
- public void init(IWorkbench workbench) {
- }
-
- /**
- * Stores the values of the controls back to the preference store.
- */
- private boolean storeValues() {
- // dw Object fileObject = null;
- try {
- // update the userCatalog so that its the same as the working
- // catalog
- userCatalog.clear();
- // TODO add entries from the nested catalogs?
- userCatalog.addEntriesFromCatalog(workingUserCatalog);
- // now save the userCatalog
- userCatalog.save();
- }
- catch (Exception e) {
- }
- return true;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogResources.properties b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogResources.properties
deleted file mode 100644
index 9af908ad9e..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogResources.properties
+++ /dev/null
@@ -1,141 +0,0 @@
-###############################################################################
-# Copyright (c) 2004, 2010 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
-# David Carver/STAR Standard, d_a_carver@yahoo.com, bug 192568
-# - Fixed grammar in XML Catalog Import dialog.
-###############################################################################
-UI_WIZARD_SCHEMA_AND_NAME_SPACE_INFO = Schema and Namespace Information
-UI_LABEL_NAME_SPACE_PREFIX = Namespace prefix:
-UI_LABEL_NAME_SPACE_URI = Namespace URI:
-UI_LABEL_XSD_LOCATION = Schema location:
-UI_LABEL_DOCTYPE_INFORMATION = Document type information
-UI_LABEL_SYSTEM_ID = &System ID:
-UI_LABEL_PUBLIC_ID = &Public ID:
-UI_LABEL_SELECT_FILE = Select File
-UI_LABEL_KEY = Key
-UI_LABEL_KEY_COLON = &Key:
-UI_LABEL_SUFFIX = Suffix
-UI_LABEL_SUFFIX_COLON = S&uffix:
-UI_LABEL_DETAILS_KEY_COLON = Key:
-UI_LABEL_DETAILS_IN_JAR_FILE = in jar file
-UI_LABEL_URI = URI
-UI_LABEL_START_STRING_COLON = &Matching start string:
-UI_LABEL_REWRITE_PREFIX_COLON = Rewrite prefi&x:
-UI_LABEL_ARROW = ->
-UI_LABEL_LOCATION_COLON = &Location:
-UI_LABEL_DELEGATE_CATALOG_URI_COLON = D&elegate to this XML Catalog file:
-UI_LABEL_CATALOG_URI_COLON = &Location of another XML Catalog file:
-UI_LABEL_DETAILS_URI_COLON = URI:
-UI_KEY_TYPE_COLON = Key &type:
-UI_KEY_TYPE_DETAILS_COLON = Key type:
-UI_MATCH_KEY_TYPE_COLON = &Key type to match:
-UI_LABEL_DETAILS_URI_LOCATION = Location:
-UI_KEY_TYPE_DESCRIPTION_XSD_PUBLIC = Namespace name
-UI_KEY_TYPE_DESCRIPTION_XSD_SYSTEM = Schema location
-UI_KEY_TYPE_DESCRIPTION_DTD_PUBLIC = Public ID
-UI_KEY_TYPE_DESCRIPTION_DTD_SYSTEM = System ID
-UI_KEY_TYPE_DESCRIPTION_URI = URI
-UI_LABEL_SPECIFY_ALTERNATIVE_WEB_URL = &Alternative web address:
-UI_WARNING_URI_MUST_NOT_HAVE_DOTS = URI must not include '.' or '..'
-UI_LABEL_PLATFORM_RESOURCE = Workspace
-UI_LABEL_FILE_SYSTEM_RESOURCE = File system
-UI_ELEMENT_TYPE_COLON = Catalog element type:
-UI_LABEL_NEXT_CATALOG = Next catalog
-UI_LABEL_DELEGATE_CATALOG = Delegate catalog
-UI_LABEL_REWRITE_ENTRY = Rewrite
-UI_LABEL_SUFFIX_ENTRY = Suffix
-UI_LABEL_ENTRY_ELEMENT_COLON = Entry element:
-UI_LABEL_PUBLIC = Public
-UI_LABEL_SYSTEM = System
-
-UI_WARNING_URI_NOT_FOUND_COLON = The specified resource can't be located :
-UI_WARNING_SHOULD_BE_FULLY_QUALIFIED_URI = Warning: the key value should be a fully qualified URI
-UI_WARNING_URI_NOT_FOUND_LONG = The specified file cannot be found. It may have been moved to a different location. If the file is located remotely, a network connection cannot be established to the remote location.
-UI_WARNING_INVALID_FILE = The specified file is invalid.
-UI_WARNING_INVALID_FILE_LONG = The specified file is invalid. A proper XML file cannot be generated from it. Open the DTD or XML schema file, edit it as necessary, validate it and try again.
-UI_WARNING_NO_ELEMENT = The specified file must contain at least one element declaration.
-UI_WARNING_NO_ELEMENT_DTD_LONG = The specified file must contain at least one element declaration that can be used as the root element in the generated XML file.
-UI_WARNING_NO_ELEMENT_XSD_LONG = The specified file must contain at least one global element declaration that can be used as the root element in the generated XML file.
-UI_WARNING_DUPLICATE_ENTRY = The specified entry is invalid. An existing entry has the same key and key type.
-UI_WARNING_DUPLICATE_SUFFIX = The specified suffix is invalid. An existing entry has the same key type and suffix.
-UI_WARNING_DUPLICATE_REWRITE = The specified rewrite start string is invalid. An existing entry has the same start string.
-UI_WARNING_DUPLICATE_DELEGATE = The specified delegate start string is invalid. An existing entry has the same prefix.
-
-
-!NewModelWizard
-UI_INVALID_GRAMMAR_ERROR = Invalid Grammar
-UI_BUTTON_BROWSE = &Browse...
-
-!XMLCatalogIdMappingPage
-UI_LABEL_MAP_TO = Map to:
-UI_LABEL_MAP_FROM = Map from:
-UI_BUTTON_NEW = &Add...
-UI_BUTTON_EDIT = &Edit...
-UI_BUTTON_DELETE = &Delete
-UI_BUTTON_REMOVE = &Remove
-UI_LABEL_NEW_DIALOG_TITLE = Add XML Catalog Element
-UI_LABEL_EDIT_DIALOG_TITLE = Edit XML Catalog Element
-
-
-!XMLCatalogPreferencePage
-UI_LABEL_USER_ENTRIES = XML Catalog Entries
-UI_LABEL_USER_ENTRIES_TOOL_TIP = XML Catalog entries that have been specified by the user
-UI_LABEL_SYSTEM_ENTRIES = Plug-in specified entries
-UI_LABEL_SYSTEM_ENTRIES_TOOL_TIP = XML Catalog entries that have been specified by a plug-in
-UI_BUTTON_CHANGE = Change...
-UI_LABEL_SELECT_PROJECT = Select Project
-UI_LABEL_SPECIFY_PROJECT_DESCRIPTION = Specify the project to persist the XML Catalog information
-UI_WARNING_NO_PROJECTS_CREATED = No projects have been created yet.
-UI_WARNING_PROJECT_NOT_SPECIFIED = A project name has not been specified.
-UI_WARNING_PROJECT_DOES_NOT_EXIST = The specified project does not exist.
-UI_LABEL_PROJECT_TO_USE = Project to use to persist XML Catalog User Entries:
-UI_LABEL_CATALOG_SAVE_ERROR = XML Catalog Save Error
-UI_LABEL_CATALOG_COULD_NOT_BE_SAVED = The XML Catalog entry could not be saved.
-UI_LABEL_ADVANCED = &Advanced...
-UI_LABEL_ADVANCED_XML_CATALOG_PREFS = Advanced XML Catalog Preferences
-UI_LABEL_SPECIFY_PERSISTENCE_FILE = &Specify a file to use to persist the XML Catalog information.
-UI_LABEL_SAVE_CATALOG_DIALOG_TITLE = Save Changes
-UI_LABEL_SAVE_CATALOG_DIALOG_DESC = You have made unsaved changes to the current XML Catalog settings. Do you wish to save your changes before loading the new XML Catalog settings?
-UI_LABEL_BROWSE_CATALOG_FILE_TITLE = Select Folder
-UI_LABEL_BROWSE_CATALOG_FILE_DESC = Select the folder that contains the '.xmlcatalog' file.
-UI_LABEL_DETAILS = Details
-UI_LABEL_USER_SPECIFIED_ENTRIES = User Specified Entries
-UI_LABEL_PLUGIN_SPECIFIED_ENTRIES = Plugin Specified Entries
-UI_LABEL_FILE_SELECTION = File Selection
-UI_LABEL_CHOOSE_FILE_TO_ADD_TO_CATALOG = Choose a file to add to the XML Catalog
-
-!AdvancedOptionsDialog
-UI_LABEL_DIALOG_DESCRIPTION = Use the buttons below to import or export XML Catalog settings.
-UI_BUTTON_IMPORT = Import...
-UI_BUTTON_EXPORT = Export...
-
-UI_LABEL_IMPORT_DIALOG_TITLE = Import XML Catalog Settings
-UI_LABEL_IMPORT_DIALOG_HEADING = Specify XML Catalog File
-UI_LABEL_IMPORT_DIALOG_MESSAGE = Specify the file that will be used to load the XML Catalog Settings
-
-UI_LABEL_EXPORT_DIALOG_TITLE = Export XML Catalog Settings
-UI_LABEL_EXPORT_DIALOG_HEADING = Specify XML Catalog File
-UI_LABEL_EXPORT_DIALOG_MESSAGE = Specify the file that will used to save the XML Catalog Setting
-ERROR_SAVING_FILE = Error saving file %1
-UI_LABEL_FILE_IS_READ_ONLY = File %1 is read only
-
-UI_LABEL_START_STRING = Start string:
-UI_LABEL_REWRITE_PREFIX = Rewrite prefix:
-
-UI_LABEL_DETAILS_SUFFIX_COLON = Suffix:
-
-EditCatalogEntryDialog_catalogEntryLabel=&Catalog Entry
-EditCatalogEntryDialog_nextCatalogLabel=&Next Catalog
-EditCatalogEntryDialog_rewriteEntryLabel=&Rewrite Entry
-EditCatalogEntryDialog_suffixEntryLabel=&Suffix Entry
-EditCatalogEntryDialog_delegateCatalogLabel=&Delegate Catalog
-UI_BUTTON_MENU_BROWSE_WORKSPACE=&Workspace...
-UI_BUTTON_MENU_BROWSE_FILE_SYSTEM=&File System...
-UI_LABEL_SELECT_FILE_FILTER_CONTROL=Files of type:
-UI_TEXT_SELECT_FILE_FILTER_CONTROL=All Supported Files
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogTreeViewer.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogTreeViewer.java
deleted file mode 100644
index e09b35c77c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogTreeViewer.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2010 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.catalog;
-
-import com.ibm.icu.text.Collator;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IEditorRegistry;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.IDelegateCatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.IRewriteEntry;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ISuffixEntry;
-
-
-public class XMLCatalogTreeViewer extends TreeViewer {
- protected static Image xmlCatalogImage = ImageFactory.INSTANCE.getImage("icons/obj16/xmlcatalog_obj.gif"); //$NON-NLS-1$
- protected static Image errorImage = ImageFactory.INSTANCE.getImage("icons/ovr16/error-overlay.gif"); //$NON-NLS-1$
- protected static Image entryImage = ImageFactory.INSTANCE.getImage("icons/obj16/entry_obj.png"); //$NON-NLS-1$
- protected static Image nextCatalogImage = ImageFactory.INSTANCE.getImage("icons/obj16/nextCatalog_obj.gif"); //$NON-NLS-1$
- protected static Image rewriteEntryImage = ImageFactory.INSTANCE.getImage("icons/obj16/rewrite_entry.gif"); //$NON-NLS-1$
- protected static Image suffixEntryImage = ImageFactory.INSTANCE.getImage("icons/obj16/suffix_entry.gif"); //$NON-NLS-1$
- protected static Image delegateCatalogImage = ImageFactory.INSTANCE.getImage("icons/obj16/delegate_catalog.gif"); //$NON-NLS-1$
-
- protected static String ERROR_STATE_KEY = "errorstatekey"; //$NON-NLS-1$
-
- protected ICatalog fWorkingUserCatalog;
- protected ICatalog fSystemCatalog;
-
- public static String USER_SPECIFIED_ENTRIES_OBJECT = XMLCatalogMessages.UI_LABEL_USER_SPECIFIED_ENTRIES;
- public static String PLUGIN_SPECIFIED_ENTRIES_OBJECT = XMLCatalogMessages.UI_LABEL_PLUGIN_SPECIFIED_ENTRIES;
-
- public XMLCatalogTreeViewer(Composite parent, ICatalog workingUserCatalog, ICatalog systemCatalog) {
- super(parent, SWT.MULTI | SWT.BORDER);
- this.fWorkingUserCatalog = workingUserCatalog;
- this.fSystemCatalog = systemCatalog;
-
- setContentProvider(new CatalogEntryContentProvider());
- setLabelProvider(new CatalogEntryLabelProvider());
- }
-
- public void setFilterExtensions(String[] extensions) {
- resetFilters();
- addFilter(new XMLCatalogTableViewerFilter(extensions));
- }
-
- public class CatalogEntryLabelProvider extends LabelProvider {
- protected HashMap imageTable = new HashMap();
-
- public String getText(Object object) {
- String result = null;
- if (object instanceof ICatalogEntry) {
- ICatalogEntry catalogEntry = (ICatalogEntry) object;
- result = catalogEntry.getKey();
- }
- else if (object instanceof ISuffixEntry) {
- ISuffixEntry entry = (ISuffixEntry) object;
- result = "[...]" + entry.getSuffix() + " " + XMLCatalogMessages.UI_LABEL_ARROW + " " + entry.getURI();
- }
- else if (object instanceof IRewriteEntry) {
- IRewriteEntry entry = (IRewriteEntry) object;
- result = entry.getStartString() + "[...] " + XMLCatalogMessages.UI_LABEL_ARROW + " " + entry.getRewritePrefix() + "[...]";
- }
- else if (object instanceof INextCatalog) {
- INextCatalog nextCatalog = (INextCatalog) object;
- // result = nextCatalog.getCatalogLocation();
- result = URIUtils.convertURIToLocation(nextCatalog.getCatalogLocation());
- if (nextCatalog.getCatalogLocation().startsWith("file:")) {
- result += " (" + XMLCatalogMessages.UI_LABEL_FILE_SYSTEM_RESOURCE + ")";
- }
- else if (nextCatalog.getCatalogLocation().startsWith("platform:")) {
- result += " (" + XMLCatalogMessages.UI_LABEL_PLATFORM_RESOURCE + ")";
- }
- }
- else if (object instanceof IDelegateCatalog) {
- IDelegateCatalog nextCatalog = (IDelegateCatalog) object;
- // result = nextCatalog.getCatalogLocation();
- result = nextCatalog.getStartString() + " " + XMLCatalogMessages.UI_LABEL_ARROW + " " + URIUtils.convertURIToLocation(nextCatalog.getCatalogLocation());
- if (nextCatalog.getCatalogLocation().startsWith("file:")) {
- result += " (" + XMLCatalogMessages.UI_LABEL_FILE_SYSTEM_RESOURCE + ")";
- }
- else if (nextCatalog.getCatalogLocation().startsWith("platform:")) {
- result += " (" + XMLCatalogMessages.UI_LABEL_PLATFORM_RESOURCE + ")";
- }
- }
- return result != null ? result : object.toString();
- }
-
- public Image getImage(Object object) {
- Image result = null;
- if (object instanceof String) {
- result = xmlCatalogImage;
- }
- else if (object instanceof ICatalogEntry) {
- ICatalogEntry catalogEntry = (ICatalogEntry) object;
- String uri = catalogEntry.getURI();
- result = getResourceImage(uri);
- }
- else if (object instanceof INextCatalog) {
- // TODO: add image to the imageTable and add error overlay if
- // next catalog URI is not readable
- result = nextCatalogImage;
- }
- else if (object instanceof IDelegateCatalog) {
- // TODO: add image to the imageTable and add error overlay if
- // next catalog URI is not readable
- result = delegateCatalogImage;
- }
- else if (object instanceof ISuffixEntry) {
- // TODO: add image to the imageTable and add error overlay if
- // next catalog URI is not readable
- result = suffixEntryImage;
- }
- else if (object instanceof IRewriteEntry) {
- // TODO: add image to the imageTable and add error overlay if
- // next catalog URI is not readable
- result = rewriteEntryImage;
- }
- return result;
- }
-
- private Image getResourceImage(String uri) {
- Image result = null;
- Image base = null;
-
- IEditorRegistry er = PlatformUI.getWorkbench().getEditorRegistry();
- ImageDescriptor imageDescriptor = er.getImageDescriptor(uri);
- Image image = (Image) imageTable.get(imageDescriptor);
- if (image == null) {
- image = imageDescriptor.createImage();
- imageTable.put(imageDescriptor, image);
- }
- base = image;
-
- if (base != null) {
- // TODO: This should be moved into the catalog
- if (URIHelper.isReadableURI(uri, false)) {
- result = base;
- }
- else {
- result = ImageFactory.INSTANCE.createCompositeImage(base, errorImage, ImageFactory.BOTTOM_LEFT);
- }
- }
- return result;
- }
-
- public void dispose() {
- super.dispose();
- for (Iterator it = imageTable.values().iterator(); it.hasNext();) {
- ((Image) it.next()).dispose();
- }
- }
- }
-
-
- public class CatalogEntryContentProvider implements ITreeContentProvider {
- protected Object[] roots;
-
- public CatalogEntryContentProvider() {
- roots = new Object[2];
- roots[0] = USER_SPECIFIED_ENTRIES_OBJECT;
- roots[1] = PLUGIN_SPECIFIED_ENTRIES_OBJECT;
- }
-
- public boolean isRoot(Object object) {
- return (object instanceof String) || (object instanceof INextCatalog);
- }
-
- public Object[] getElements(Object element) {
- return roots;
- }
-
- public Object[] getChildren(Object parentElement) {
- Object[] result = new Object[0];
- if (parentElement == roots[0]) {
- result = getChildrenHelper(fWorkingUserCatalog);
- }
- else if (parentElement == roots[1]) {
- result = getChildrenHelper(fSystemCatalog);
- }
- else if (parentElement instanceof INextCatalog) {
- ICatalog nextCatalog = ((INextCatalog) parentElement).getReferencedCatalog();
- result = getChildrenHelper(nextCatalog);
- }
- else if (parentElement instanceof IDelegateCatalog) {
- ICatalog nextCatalog = ((IDelegateCatalog) parentElement).getReferencedCatalog();
- result = getChildrenHelper(nextCatalog);
- }
- return result;
- }
-
- protected Object[] getChildrenHelper(ICatalog catalog) {
-
- ICatalogEntry[] entries = catalog.getCatalogEntries();
- if (entries.length > 0) {
- Comparator comparator = new Comparator() {
- public int compare(Object o1, Object o2) {
- int result = 0;
- if ((o1 instanceof ICatalogEntry) && (o2 instanceof ICatalogEntry)) {
- ICatalogEntry entry1 = (ICatalogEntry) o1;
- ICatalogEntry entry2 = (ICatalogEntry) o2;
- result = Collator.getInstance().compare(entry1.getKey(), entry2.getKey());
- }
- return result;
- }
- };
- Arrays.sort(entries, comparator);
- }
- Vector result = new Vector();
- result.addAll(Arrays.asList(entries));
- result.addAll(Arrays.asList(catalog.getRewriteEntries()));
- result.addAll(Arrays.asList(catalog.getSuffixEntries()));
- result.addAll(Arrays.asList(catalog.getDelegateCatalogs()));
- INextCatalog[] nextCatalogs = catalog.getNextCatalogs();
- List nextCatalogsList = Arrays.asList(nextCatalogs);
- result.addAll(nextCatalogsList);
-
- return result.toArray(new ICatalogElement[result.size()]);
- }
-
- public Object getParent(Object element) {
- return (element instanceof String) ? null : USER_SPECIFIED_ENTRIES_OBJECT;
- }
-
- public boolean hasChildren(Object element) {
- return isRoot(element) ? getChildren(element).length > 0 : false;
- }
-
- public void dispose() {
- // nothing to dispose
- }
-
- public void inputChanged(Viewer viewer, Object old, Object newobj) {
- // ISSUE: seems we should do something here
- }
-
- public boolean isDeleted(Object object) {
- return false;
- }
- }
-
-
- class XMLCatalogTableViewerFilter extends ViewerFilter {
- protected String[] extensions;
-
- public XMLCatalogTableViewerFilter(String[] extensions1) {
- this.extensions = extensions1;
- }
-
- public boolean isFilterProperty(Object element, Object property) {
- return false;
- }
-
- public boolean select(Viewer viewer, Object parent, Object element) {
- boolean result = false;
- if (element instanceof ICatalogEntry) {
- ICatalogEntry catalogEntry = (ICatalogEntry) element;
- for (int i = 0; i < extensions.length; i++) {
- if (catalogEntry.getURI().endsWith(extensions[i])) {
- result = true;
- break;
- }
- }
- }
- else if (element.equals(XMLCatalogTreeViewer.PLUGIN_SPECIFIED_ENTRIES_OBJECT) || element.equals(XMLCatalogTreeViewer.USER_SPECIFIED_ENTRIES_OBJECT)) {
- return true;
- }
- return result;
- }
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLQuickScan.java b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLQuickScan.java
deleted file mode 100644
index 723539d86c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLQuickScan.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2006 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.catalog;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- *
- */
-public class XMLQuickScan {
- public static String getTargetNamespaceURIForSchema(String uri) {
- String result = null;
- try {
- URL url = new URL(uri);
- InputStream inputStream = url.openStream();
- result = XMLQuickScan.getTargetNamespaceURIForSchema(inputStream);
- }
- catch (Exception e) {
- }
- return result;
- }
-
- public static String getTargetNamespaceURIForSchema(InputStream input) {
- TargetNamespaceURIContentHandler handler = new TargetNamespaceURIContentHandler();
- ClassLoader prevClassLoader = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(XMLQuickScan.class.getClassLoader());
- SAXParserFactory factory = SAXParserFactory.newInstance();
- factory.setNamespaceAware(true);
- SAXParser parser = factory.newSAXParser();
- parser.parse(new InputSource(input), handler);
- }
- catch (StopParseException e) {
- // this is a normal exception to stop parsing early,
- // when info is found, so we can safely ignore
- }
- catch (ParserConfigurationException e) {
- Logger.logException(e);
- }
- catch (SAXException e) {
- Logger.logException(e);
- }
- catch (IOException e) {
- Logger.logException(e);
- }
- finally {
- Thread.currentThread().setContextClassLoader(prevClassLoader);
- }
- return handler.targetNamespaceURI;
- }
-
- /**
- * This is a special exception that is used to stop parsing when required
- * information is found.
- */
- static class StopParseException extends org.xml.sax.SAXException {
- static final long serialVersionUID = 1L;
-
- /**
- * Constructor StopParseException.
- */
- StopParseException() {
- super("targetnamespace found, no need to continue the parse");
- }
- }
-
- static class TargetNamespaceURIContentHandler extends DefaultHandler {
- public String targetNamespaceURI;
-
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
- if (localName.equals("schema")) //$NON-NLS-1$
- {
- int nAttributes = attributes.getLength();
- for (int i = 0; i < nAttributes; i++) {
- if (attributes.getLocalName(i).equals("targetNamespace")) //$NON-NLS-1$
- {
- targetNamespaceURI = attributes.getValue(i);
- break;
- }
- }
- }
- throw new StopParseException();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/catalogEntry.gif b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/catalogEntry.gif
deleted file mode 100644
index d65b280297..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/catalogEntry.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/delegateCatalog.gif b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/delegateCatalog.gif
deleted file mode 100644
index c0d85ee54d..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/delegateCatalog.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/nextCatalog.gif b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/nextCatalog.gif
deleted file mode 100644
index 3a934b907c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/nextCatalog.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/prefix.gif b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/prefix.gif
deleted file mode 100644
index 6b87692b88..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/prefix.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/rewrite.gif b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/rewrite.gif
deleted file mode 100644
index f00306433a..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/rewrite.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/sufix.gif b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/sufix.gif
deleted file mode 100644
index 2bd5b41b61..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/etool50/sufix.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/catalog_entry.gif b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/catalog_entry.gif
deleted file mode 100644
index a27e30a6f1..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/catalog_entry.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/delegate_catalog.gif b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/delegate_catalog.gif
deleted file mode 100644
index 11bd2d09c0..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/delegate_catalog.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/entry_obj.png b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/entry_obj.png
deleted file mode 100644
index be7147416b..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/entry_obj.png
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/file_expand.gif b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/file_expand.gif
deleted file mode 100644
index 85f9baaf44..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/file_expand.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/file_obj.gif b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/file_obj.gif
deleted file mode 100644
index 061161ae1c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/file_obj.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/nextCatalog_obj.gif b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/nextCatalog_obj.gif
deleted file mode 100644
index d4bfe79eb9..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/nextCatalog_obj.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/next_catalog.gif b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/next_catalog.gif
deleted file mode 100644
index 976cbc90df..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/next_catalog.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/rewrite_entry.gif b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/rewrite_entry.gif
deleted file mode 100644
index 9cc8ee9168..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/rewrite_entry.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/suffix_entry.gif b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/suffix_entry.gif
deleted file mode 100644
index dc76407557..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/suffix_entry.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/xmlcatalog_obj.gif b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/xmlcatalog_obj.gif
deleted file mode 100644
index a61441f2a8..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/xmlcatalog_obj.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/ovr16/error-overlay.gif b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/ovr16/error-overlay.gif
deleted file mode 100644
index 119dcccd5a..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/ovr16/error-overlay.gif
+++ /dev/null
Binary files differ

Back to the top