diff options
Diffstat (limited to 'bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse')
21 files changed, 0 insertions, 2822 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 068e243a6d..0000000000 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/AdvancedOptionsDialog.java +++ /dev/null @@ -1,255 +0,0 @@ -/* -* Copyright (c) 2002 IBM Corporation and others. -* All rights reserved. This program and the accompanying materials -* are made available under the terms of the Common Public License v1.0 -* which accompanies this distribution, and is available at -* http://www.eclipse.org/legal/cpl-v10.html -* -* Contributors: -* IBM - 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 ce4a8d8859..0000000000 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/CatalogFileTypeRegistryReader.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ -package org.eclipse.wst.xml.ui.internal.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); - } - - 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 de0af20fc8..0000000000 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/EditCatalogEntryDialog.java +++ /dev/null @@ -1,950 +0,0 @@ -/* - * Copyright (c) 2002 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM - 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.SelectionAdapter; -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.Point; -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.Menu; -import org.eclipse.swt.widgets.MenuItem; -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.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.INextCatalog; - -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 class CatalogEntryPage extends CatalogElementPage { - - protected Button browseButton; - - 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 void computeErrorMessage() { - errorMessage = null; - - if (errorMessage == 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)) { - 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 && 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(3, false); - group.setLayout(layout); - - Label resourceLocationLabel = new Label(group, SWT.NONE); - resourceLocationLabel.setText(XMLCatalogMessages.UI_LABEL_URI_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(getEntry().getURI())); - // WorkbenchHelp.setHelp(resourceLocationField, - // XMLBuilderContextIds.XMLP_ENTRY_URI); - resourceLocationField.addModifyListener(modifyListener); - - - browseButton = createBrowseButton(group); - // WorkbenchHelp.setHelp(browseButton, - // XMLBuilderContextIds.XMLP_ENTRY_BROWSE); - browseButton.addSelectionListener(new DropDownSelectionListener(resourceLocationField)); - - // Key Type - // - Label keyTypeLabel = new Label(group, SWT.NONE); - keyTypeLabel.setText(XMLCatalogMessages.UI_KEY_TYPE_COLON); - - keyTypeCombo = new Combo(group, SWT.NONE); - 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); - - // a placeholder to fill the 3rd column - Button placeHolder = new Button(group, SWT.NONE); - placeHolder.setVisible(false); - - // 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); - Color color = new Color(errorMessageLabel.getDisplay(), 200, 0, 0); - errorMessageLabel.setForeground(color); - errorMessageLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - updateWidgets(null); - - 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() { - String uri = resourceLocationField.getText(); - if (!URIHelper.hasProtocol(uri)) { - uri = URIHelper.isAbsolute(uri) ? URIHelper.prependFileProtocol(uri) : URIHelper.prependPlatformResourceProtocol(uri); - } - getEntry().setURI(uri); - getEntry().setKey(keyField.getText()); - getEntry().setEntryType(getKeyType()); - getEntry().setAttributeValue(ICatalogEntry.ATTR_WEB_URL, checkboxButton.getSelection() ? webAddressField.getText() : 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 (theFileType.description.equals("XSD Files")) { //$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 (theFileType.description.equals("DTD Files")) { //$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 abstract class CatalogElementPage { - - Control fControl; - - public CatalogElementPage() { - super(); - - } - - 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(); - getShell().setText(XMLCatalogMessages.UI_LABEL_SELECT_FILE); - setBlockOnOpen(true); - 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.NONE); - 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.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 class NextCatalogPage extends CatalogElementPage { - protected Button browseButton; - - protected Text catalogLocationField; - - protected INextCatalog nextCatalog; - - protected Label errorMessageLabel; - - protected void computeErrorMessage() { - errorMessage = null; - - if (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 Control createControl(Composite parent) { - fControl = createNextCatalogPanel(parent); - return fControl; - } - - protected Control createNextCatalogPanel(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(2, false); - group.setLayout(layout); - - Label resourceLocationLabel = new Label(group, SWT.NONE); - resourceLocationLabel.setText(XMLCatalogMessages.UI_LABEL_CATALOG_URI_COLON); - - // filler - new Label(group, SWT.NONE); - - catalogLocationField = new Text(group, SWT.SINGLE | SWT.BORDER); - catalogLocationField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - catalogLocationField.setText(getDisplayValue(getNextCatalog().getCatalogLocation())); - // WorkbenchHelp.setHelp(resourceLocationField, - // XMLBuilderContextIds.XMLP_ENTRY_URI); - catalogLocationField.addModifyListener(modifyListener); - - browseButton = createBrowseButton(group); - browseButton.addSelectionListener(new DropDownSelectionListener(catalogLocationField)); - - errorMessageLabel = new Label(group, SWT.NONE); - Color color = new Color(errorMessageLabel.getDisplay(), 200, 0, 0); - errorMessageLabel.setForeground(color); - errorMessageLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - updateWidgets(null); - return composite; - } - - public ICatalogElement getData() { - return getNextCatalog(); - } - - 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() { - String uri = catalogLocationField.getText(); - if (!URIHelper.hasProtocol(uri)) { - uri = URIHelper.isAbsolute(uri) ? URIHelper.prependFileProtocol(uri) : URIHelper.prependPlatformResourceProtocol(uri); - } - getNextCatalog().setCatalogLocation(uri); - } - - protected void updateWidgets(Widget widget) { - computeErrorMessage(); - updateErrorMessageLabel(errorMessageLabel); - updateOKButtonState(); - } - } - - protected class ToolBarItemSelectionChangeListener implements SelectionListener { - public void widgetDefaultSelected(SelectionEvent e) { - // TODO Auto-generated method stub - - } - - public void widgetSelected(SelectionEvent e) { - Object selection = e.getSource(); - if (selection instanceof ToolItem) { - if (!showPage((CatalogElementPage) ((ToolItem) selection).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 Button okButton; - - protected PageBook pageContainer; - - protected CatalogElementPage selectedPage; - - // protected TreeViewer treeViewer; - - protected ToolBar toolBar; - - public EditCatalogEntryDialog(Shell parentShell, ICatalog aCatalog) { - super(parentShell); - setShellStyle(getShellStyle() | SWT.RESIZE); - this.catalog = aCatalog; - } - - public EditCatalogEntryDialog(Shell parentShell, ICatalogElement catalogElement) { - super(parentShell); - setShellStyle(getShellStyle() | SWT.RESIZE); - 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(); - } - 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 void createCatalogEntryButton() { - CatalogElementPage page = new CatalogEntryPage(); - page.createControl(pageContainer); - ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH); - toolItem.setImage(catalogEntryToolBarImage); - toolItem.setText(XMLCatalogMessages.EditCatalogEntryDialog_catalogEntryLabel); - toolItem.setData(page); - toolItem.addSelectionListener(new ToolBarItemSelectionChangeListener()); - } - - protected Control createDialogArea(Composite parent) { - Composite dialogAreaComposite = (Composite) super.createDialogArea(parent); - GridLayout layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - dialogAreaComposite.setLayout(layout); - GridData gd = new GridData(GridData.FILL_BOTH); - gd.widthHint = 500; - gd.heightHint = 250; - dialogAreaComposite.setLayoutData(gd); - createMainComponent(dialogAreaComposite); - return this.dialogArea; - } - - 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); - } - - 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(); - createNextCatalogButton(); - if (toolBar.getItemCount() > 0) { - ToolItem item = toolBar.getItem(0); - showPage((CatalogElementPage) (item.getData())); - } - return composite1; - } - - protected void createNextCatalogButton() { - CatalogElementPage page = new NextCatalogPage(); - page.createControl(pageContainer); - ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH); - toolItem.setImage(nextCatalogToolBarImage); - toolItem.setText(XMLCatalogMessages.EditCatalogEntryDialog_nextCatalogLabel); - toolItem.setData(page); - toolItem.addSelectionListener(new ToolBarItemSelectionChangeListener()); - - } - - 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(); - return true; - } - - protected void updateErrorMessageLabel(Label errorMessageLabel) { - errorMessageLabel.setText(errorMessage != null ? errorMessage : ""); //$NON-NLS-1$ - } - - protected void updateOKButtonState() { - if (okButton != null) { - okButton.setEnabled(errorMessage == null); - } - } - - protected Button createBrowseButton(Composite composite) { - Button browseButton = new Button(composite, SWT.FLAT); - // 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; - - } - - class DropDownSelectionListener extends SelectionAdapter { - private Menu menu = null; - private Control control; - - public DropDownSelectionListener(Control aControl) { - super(); - this.control = aControl; - } - - public void widgetSelected(SelectionEvent event) { - // Create the menu if it has not already been created - if (menu == null) { - // Lazy create the menu. - menu = new Menu(getShell()); - MenuItem menuItem = new MenuItem(menu, SWT.NONE); - menuItem.setText(XMLCatalogMessages.UI_BUTTON_MENU_BROWSE_WORKSPACE); - /* - * Add a menu selection listener so that the menu is hidden - * when the user selects an item from the drop down menu. - */ - menuItem.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - setMenuVisible(false); - invokeWorkspaceFileSelectionDialog(); - } - }); - - menuItem = new MenuItem(menu, SWT.NONE); - menuItem.setText(XMLCatalogMessages.UI_BUTTON_MENU_BROWSE_FILE_SYSTEM); - /* - * Add a menu selection listener so that the menu is hidden - * when the user selects an item from the drop down menu. - */ - menuItem.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - setMenuVisible(false); - invokeFileSelectionDialog(); - } - }); - - } - - // Position the menu below and vertically aligned with the the - // drop down tool button. - Button button = (Button) event.widget; - - // set location - Point ptBrowse = button.getLocation(); - Rectangle rcBrowse = button.getBounds(); - ptBrowse.y += rcBrowse.height; - ptBrowse = button.getParent().toDisplay(ptBrowse); - menu.setLocation(ptBrowse.x, ptBrowse.y); - - setMenuVisible(true); - - } - - void setMenuVisible(boolean visible) { - menu.setVisible(visible); - // this.visible = visible; - } - - void invokeWorkspaceFileSelectionDialog() { - FilterableSelectSingleFileDialog dialog = new FilterableSelectSingleFileDialog(getShell()); - dialog.createAndOpen(); - - IFile file = dialog.getFile(); - if (file != null) { - // remove leading slash from the value to avoid the - // whole leading slash ambiguity problem - // - String uri = file.getFullPath().toString(); - while (uri.startsWith("/") || uri.startsWith("\\")) { //$NON-NLS-1$ //$NON-NLS-2$ - uri = uri.substring(1); - } - if (control instanceof Text) { - ((Text) control).setText(uri); - } - - } - } - - void invokeFileSelectionDialog() { - FileDialog dialog = new FileDialog(getShell(), SWT.SINGLE); - String file = dialog.open(); - if (control instanceof Text && file != null) { - ((Text) control).setText(file); - } - } - } - -} 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 77a9c40c44..0000000000 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ElementNodePage.java +++ /dev/null @@ -1,27 +0,0 @@ - -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 46cc060e4c..0000000000 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ImageFactory.java +++ /dev/null @@ -1,205 +0,0 @@ -/* -* Copyright (c) 2002, 2005 IBM Corporation and others. -* All rights reserved. This program and the accompanying materials -* are made available under the terms of the Common Public License v1.0 -* which accompanies this distribution, and is available at -* http://www.eclipse.org/legal/cpl-v10.html -* -* Contributors: -* IBM - 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/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 5d0be8c5ff..0000000000 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntriesView.java +++ /dev/null @@ -1,306 +0,0 @@ -/* -* Copyright (c) 2002, 2005 IBM Corporation and others. -* All rights reserved. This program and the accompanying materials -* are made available under the terms of the Common Public License v1.0 -* which accompanies this distribution, and is available at -* http://www.eclipse.org/legal/cpl-v10.html -* -* Contributors: -* IBM - Initial API and implementation -* Jens Lukowski/Innoopract - initial renaming/restructuring -* -*/ -package org.eclipse.wst.xml.ui.internal.catalog; - -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.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(); - this.setLayout(gridLayout); - - tableViewer = createTableViewer(this); - tableViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); - tableViewer.setInput("dummy"); //$NON-NLS-1$ - 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); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 7; - gridLayout.makeColumnsEqualWidth = true; - composite.setLayout(gridLayout); - - GridData 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); - - 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_DELETE); - //WorkbenchHelp.setHelp(deleteButton, XMLBuilderContextIds.XMLP_MAPPING_DELETE); - deleteButton.setLayoutData(gd); - deleteButton.addSelectionListener(selectionListener); - - // 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) - { - Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell(); - EditCatalogEntryDialog dialog = new EditCatalogEntryDialog(shell, entry); - dialog.create(); - dialog.getShell().setText(title); - dialog.setBlockOnOpen(true); - dialog.open(); - return dialog; - } - - protected EditCatalogEntryDialog invokeDialog(String title, ICatalog catalog) - { - Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell(); - EditCatalogEntryDialog dialog = new EditCatalogEntryDialog(shell, catalog); - dialog.create(); - dialog.getShell().setText(title); - dialog.setBlockOnOpen(true); - dialog.open(); - return dialog; - } - - - 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); - 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(); - Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null; - - if (selectedObject instanceof ICatalogElement) - { - ICatalogElement catalogElement = (ICatalogElement) selectedObject; - workingUserCatalog.removeCatalogElement(catalogElement); - } - } - - protected void updateWidgetEnabledState() - { - boolean isEditable = false; - ISelection selection = tableViewer.getSelection(); - Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null; - - 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); - 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 6c5fbc61a6..0000000000 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogEntryDetailsView.java +++ /dev/null @@ -1,105 +0,0 @@ -/* -* Copyright (c) 2002, 2005 IBM Corporation and others. -* All rights reserved. This program and the accompanying materials -* are made available under the terms of the Common Public License v1.0 -* which accompanies this distribution, and is available at -* http://www.eclipse.org/legal/cpl-v10.html -* -* Contributors: -* IBM - 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.xml.core.internal.catalog.provisional.ICatalogEntry; -import org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog; - - - - -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 = 65; - detailsText.setLayoutData(data); - - verticalScroll = detailsText.getVerticalBar(); - //verticalScroll.setVisible(false); - horizontalScroll = detailsText.getHorizontalBar(); - detailsText.setEditable(false); - detailsText.setBackground(color); - } - - public void setCatalogElement(ICatalogEntry entry) - { - String value = getDisplayValue(entry != null ? entry.getURI() : ""); //$NON-NLS-1$ - String line1 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_COLON + "\t\t" + value; //$NON-NLS-1$ - - value = entry != null ? getKeyTypeValue(entry) : ""; //$NON-NLS-1$ - String line2 = XMLCatalogMessages.UI_KEY_TYPE_DETAILS_COLON + "\t" + value; //$NON-NLS-1$ - - value = getDisplayValue(entry != null ? entry.getKey() : ""); //$NON-NLS-1$ - String line3 = XMLCatalogMessages.UI_LABEL_DETAILS_KEY_COLON + "\t\t" + value; //$NON-NLS-1$ - - String entireString = "\n" + line1 + "\n" + line2 + "\n" + line3; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - detailsText.setText(entireString); - } - - public void setCatalogElement(INextCatalog nextCatalog) - { - String value = getDisplayValue(nextCatalog != null ? nextCatalog.getCatalogLocation() : ""); //$NON-NLS-1$ - String line1 = XMLCatalogMessages.UI_LABEL_DETAILS_URI_COLON + "\t\t" + value; //$NON-NLS-1$ - - String entireString = "\n" + line1; //$NON-NLS-1$ - detailsText.setText(entireString); - } - - 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 61fe779076..0000000000 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogFileType.java +++ /dev/null @@ -1,56 +0,0 @@ -/* -* Copyright (c) 2002 IBM Corporation and others. -* All rights reserved. This program and the accompanying materials -* are made available under the terms of the Common Public License v1.0 -* which accompanies this distribution, and is available at -* http://www.eclipse.org/legal/cpl-v10.html -* -* Contributors: -* IBM - 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 java.util.StringTokenizer; - -import org.eclipse.swt.graphics.Image; - - -public class XMLCatalogFileType -{ - public String description; - 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 b1ff199aec..0000000000 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogMessages.java +++ /dev/null @@ -1,128 +0,0 @@ -/********************************************************************** - * Copyright (c) 2005 IBM Corporation and others. All rights reserved. This - * program and the accompanying materials are made available under the terms of - * the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - **********************************************************************/ -package org.eclipse.wst.xml.ui.internal.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_DETAILS_KEY_COLON; - public static String UI_LABEL_URI; - public static String UI_LABEL_URI_COLON; - public static String UI_LABEL_CATALOG_URI_COLON; - public static String UI_LABEL_DETAILS_URI_COLON; - public static String UI_KEY_TYPE_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_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; - - - //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_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; - - // 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 EditCatalogEntryDialog_catalogEntryLabel; - public static String EditCatalogEntryDialog_nextCatalogLabel; - 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; - - - - - 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 f474f57047..0000000000 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogPreferencePage.java +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright (c) 2002, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - */ -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.ICatalogEntry; -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(); - return 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) - .getFirstElement() - : null; - if (selectedObject instanceof ICatalogEntry) - { - ICatalogEntry entry = (ICatalogEntry) selectedObject; - detailsView.setCatalogElement(entry); - } else if (selectedObject instanceof INextCatalog) - { - INextCatalog entry = (INextCatalog) selectedObject; - detailsView.setCatalogElement(entry); - } - - } - }; - 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 08e7ac9b40..0000000000 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogResources.properties +++ /dev/null @@ -1,104 +0,0 @@ -############################################################################### -# Copyright (c) 2004 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -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_DETAILS_KEY_COLON = Key: -UI_LABEL_URI = URI -UI_LABEL_URI_COLON = &URI: -UI_LABEL_CATALOG_URI_COLON = URI 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_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 = Specify &alternative web address -UI_WARNING_URI_MUST_NOT_HAVE_DOTS = URI must not included '.' or '..' - -UI_WARNING_URI_NOT_FOUND_COLON = The specified resource can't be located : -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. - - -!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_LABEL_NEW_DIALOG_TITLE = Add XML Catalog Entry -UI_LABEL_EDIT_DIALOG_TITLE = Edit XML Catalog Entry - - -!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 - -!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 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 - -EditCatalogEntryDialog_catalogEntryLabel=Catalog Entry -EditCatalogEntryDialog_nextCatalogLabel=Next 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 ff39ae2a35..0000000000 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogTreeViewer.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright (c) 2002, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - */ -package org.eclipse.wst.xml.ui.internal.catalog; - -import java.text.Collator; -import java.util.Arrays; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Vector; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuManager; -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.INextCatalog; - - -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.gif"); //$NON-NLS-1$ - protected static Image nextCatalogImage = ImageFactory.INSTANCE.getImage("icons/obj16/nextCatalog_obj.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.NONE); - 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(); - // result = URIHelper.removePlatformResourceProtocol(result); - } - else if (object instanceof INextCatalog) { - INextCatalog nextCatalog = (INextCatalog) object; - result = nextCatalog.getCatalogLocation(); - } - return result != null ? result : object.toString(); - } - - public Image getImage(Object object) { - Image result = null; - Image base = null; - if (object instanceof String) { - result = xmlCatalogImage; - } - else if (object instanceof ICatalogEntry) { - ICatalogEntry catalogEntry = (ICatalogEntry) object; - String uri = catalogEntry.getURI(); - 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) { - if (URIHelper.isReadableURI(uri, false)) { - result = base; - } - else { - result = ImageFactory.INSTANCE.createCompositeImage(base, errorImage, ImageFactory.BOTTOM_LEFT); - } - } - } - else if (object instanceof INextCatalog) { - // TODO: add image to the imageTable and add error overlay if - // next catalog URI is not readable - result = nextCatalogImage; - } - return result; - } - } - - - 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); - } - return result; - } - - protected Object[] getChildrenHelper(ICatalog catalog) { - // TODO add entries from the nested catalogs - - 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)); - 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; - } - } - - - public void menuAboutToShow(IMenuManager menuManager) { - Action action = new Action("hello") { //$NON-NLS-1$ - public void run() { - System.out.println("run!"); //$NON-NLS-1$ - } - }; - menuManager.add(action); - } - - - 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; - } - } - } - 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 d574006fb0..0000000000 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLQuickScan.java +++ /dev/null @@ -1,92 +0,0 @@ -/* -* Copyright (c) 2002, 2005 IBM Corporation and others. -* All rights reserved. This program and the accompanying materials -* are made available under the terms of the Common Public License v1.0 -* which accompanies this distribution, and is available at -* http://www.eclipse.org/legal/cpl-v10.html -* -* Contributors: -* IBM - Initial API and implementation -* Jens Lukowski/Innoopract - initial renaming/restructuring -* -*/ -package org.eclipse.wst.xml.ui.internal.catalog; - -import java.io.InputStream; -import java.net.URL; - -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -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 (Exception e) - { - } - finally - { - Thread.currentThread().setContextClassLoader(prevClassLoader); - } - return handler.targetNamespaceURI; - } - - protected static class TargetNamespaceURIContentHandler extends DefaultHandler - { - public String targetNamespaceURI; - - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException - { - if (localName.equals("schema")) //$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; - } - } - } - // todo there's a nice way to do this I'm sure - // here I intentially cause an exception... - String x = null; - x.length(); - } - } -} 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 Binary files differdeleted 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 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 Binary files differdeleted 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 diff --git a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/entry_obj.gif b/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/entry_obj.gif Binary files differdeleted file mode 100644 index 9a0ff302dc..0000000000 --- a/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/icons/obj16/entry_obj.gif +++ /dev/null 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 Binary files differdeleted 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 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 Binary files differdeleted 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 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 Binary files differdeleted 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 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 Binary files differdeleted 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 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 Binary files differdeleted 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 |