Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNitin Dahyabhai2021-01-07 06:48:35 +0000
committerNitin Dahyabhai2021-01-07 06:48:35 +0000
commit9f2e35f794a2950e4cf1f7e5b86ecdca34e53023 (patch)
tree821d3206011d588f8e9836e9960025c97bef7625
parent7302e224d16f290536d094ef10e3b10960bcc546 (diff)
downloadwebtools.sourceediting-9f2e35f794a2950e4cf1f7e5b86ecdca34e53023.tar.gz
webtools.sourceediting-9f2e35f794a2950e4cf1f7e5b86ecdca34e53023.tar.xz
webtools.sourceediting-9f2e35f794a2950e4cf1f7e5b86ecdca34e53023.zip
[570162] Simplify the New XML File wizard
-rw-r--r--xml/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ImageFactory.java4
-rw-r--r--xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewModelWizard.java32
-rw-r--r--xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLWizard.java44
-rw-r--r--xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLWizardsMessages.java8
-rw-r--r--xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/wizardResource.properties9
-rw-r--r--xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdPanel.java10
-rw-r--r--xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdDialog.java11
-rw-r--r--xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdPanel.java121
-rw-r--r--xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogEntryContentProvider.java139
-rw-r--r--xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogEntryLabelProvider.java76
-rw-r--r--xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogTableViewer.java142
-rw-r--r--xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogViewerFilter.java51
12 files changed, 405 insertions, 242 deletions
diff --git a/xml/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ImageFactory.java b/xml/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ImageFactory.java
index ba1d3cf89c..9c89e4438e 100644
--- a/xml/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ImageFactory.java
+++ b/xml/bundles/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/ImageFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation and others.
+ * Copyright (c) 2002, 2021 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -32,7 +32,7 @@ public class ImageFactory {
protected static final int[][] OVERLAY_COORDINATE = {{0, 0}, {0, 2}, {2, 0}, {2, 2}};
- protected static ImageFactory INSTANCE = new ImageFactory();
+ public static ImageFactory INSTANCE = new ImageFactory();
protected Hashtable compositeImageTable = new Hashtable();
diff --git a/xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewModelWizard.java b/xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewModelWizard.java
index 197068427b..afe152c7f7 100644
--- a/xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewModelWizard.java
+++ b/xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewModelWizard.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2010 IBM Corporation and others.
+ * Copyright (c) 2001, 2021 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -32,16 +32,21 @@ import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardPage;
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.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.Event;
import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.dialogs.PreferencesUtil;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
@@ -122,6 +127,8 @@ public class NewModelWizard extends Wizard implements INewWizard {
protected int selectedButton;
protected String[] radioButtonLabel;
protected Button[] radioButton;
+ private String preferenceMessage;
+ private String[] preferencePageIds;
public StartPage(String pageName, String[] radioButtonLabel) {
super(pageName);
@@ -129,6 +136,14 @@ public class NewModelWizard extends Wizard implements INewWizard {
radioButton = new Button[radioButtonLabel.length];
}
+ public StartPage(String pageName, String[] radioButtonLabel, String[] preferencePageIds, String message) {
+ super(pageName);
+ this.radioButtonLabel = radioButtonLabel;
+ radioButton = new Button[radioButtonLabel.length];
+ this.preferencePageIds = preferencePageIds;
+ this.preferenceMessage = message;
+ }
+
public Button getRadioButtonAtIndex(int i) {
Button result = null;
if ((i >= 0) && (i < radioButton.length)) {
@@ -148,7 +163,7 @@ public class NewModelWizard extends Wizard implements INewWizard {
}
public void createControl(Composite parent) {
- Composite base = new Composite(parent, SWT.NONE);
+ final Composite base = new Composite(parent, SWT.NONE);
base.setLayout(new GridLayout());
// radio buttons' container
@@ -159,8 +174,7 @@ public class NewModelWizard extends Wizard implements INewWizard {
layout.marginWidth = 0;
radioButtonsGroup.setLayout(layout);
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.heightHint = 300;
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = 400;
radioButtonsGroup.setLayoutData(gd);
@@ -170,6 +184,16 @@ public class NewModelWizard extends Wizard implements INewWizard {
radioButton[i].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// radioButton[i].addListener(SWT.Modify, this);
}
+ if (preferenceMessage != null && preferencePageIds != null) {
+ new Label(base, SWT.NONE).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ Link link = new Link(base, SWT.NONE);
+ link.setText(preferenceMessage);
+ link.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ PreferencesUtil.createPreferenceDialogOn(null, preferencePageIds[0], preferencePageIds, null).open();
+ }
+ });
+ }
setControl(base);
setPageComplete(isPageComplete());
Dialog.applyDialogFont(parent);
diff --git a/xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLWizard.java b/xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLWizard.java
index 4244145d74..09d82d9fa5 100644
--- a/xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLWizard.java
+++ b/xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLWizard.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2020 IBM Corporation and others.
+ * Copyright (c) 2001, 2021 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -81,15 +81,13 @@ import org.eclipse.wst.xml.ui.internal.nsedit.CommonEditNamespacesDialog;
import com.ibm.icu.text.Collator;
public class NewXMLWizard extends NewModelWizard {
- protected static final int CREATE_FROM_DTD = 0;
- protected static final int CREATE_FROM_XSD = 1;
- protected static final int CREATE_FROM_SCRATCH = 2;
+ protected static final int CREATE_FROM_GRAMMAR = 0;
+ protected static final int CREATE_FROM_SCRATCH = 1;
- protected static final String[] createFromRadioButtonLabel = {XMLWizardsMessages._UI_RADIO_XML_FROM_DTD, XMLWizardsMessages._UI_RADIO_XML_FROM_SCHEMA, XMLWizardsMessages._UI_RADIO_XML_FROM_SCRATCH};
+ protected static final String[] createFromRadioButtonLabel = {XMLWizardsMessages._UI_RADIO_XML_FROM_DTD_OR_SCHEMA, XMLWizardsMessages._UI_RADIO_XML_FROM_SCRATCH};
protected static final String[] filePageFilterExtensions = {".xml"}; //$NON-NLS-1$
- protected static final String[] browseXSDFilterExtensions = {".xsd"}; //$NON-NLS-1$
- protected static final String[] browseDTDFilterExtensions = {".dtd"}; //$NON-NLS-1$
+ protected static String[] browseGrammarFilterExtensions = {".xsd", ".dtd", ".ent", ".mod"}; //$NON-NLS-1$
protected static final int OPTIONAL_ELEMENT_DEPTH_LIMIT_DEFAULT_VALUE = 2;
@@ -163,7 +161,7 @@ public class NewXMLWizard extends NewModelWizard {
if (grammarURI == null) {
// create xml from page
- fCreateXMLFromWizardPage = new StartPage("StartPage", createFromRadioButtonLabel) //$NON-NLS-1$
+ fCreateXMLFromWizardPage = new StartPage("StartPage", createFromRadioButtonLabel, new String[]{"org.eclipse.wst.sse.ui.preferences.xml.templates"}, XMLWizardsMessages.NewXMLTemplatesWizardPage_6) //$NON-NLS-1$
{
public void createControl(Composite parent) {
super.createControl(parent);
@@ -175,9 +173,8 @@ public class NewXMLWizard extends NewModelWizard {
getRadioButtonAtIndex(getCreateMode()).setFocus();
// Set the help context for each button
- PlatformUI.getWorkbench().getHelpSystem().setHelp(fCreateXMLFromWizardPage.getRadioButtonAtIndex(0), IXMLWizardHelpContextIds.XML_NEWWIZARD_CREATEXML1_HELPID);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(fCreateXMLFromWizardPage.getRadioButtonAtIndex(1), IXMLWizardHelpContextIds.XML_NEWWIZARD_CREATEXML2_HELPID);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(fCreateXMLFromWizardPage.getRadioButtonAtIndex(2), IXMLWizardHelpContextIds.XML_NEWWIZARD_CREATEXML3_HELPID);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(fCreateXMLFromWizardPage.getRadioButtonAtIndex(0), IXMLWizardHelpContextIds.XML_NEWWIZARD_CREATEXML2_HELPID);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(fCreateXMLFromWizardPage.getRadioButtonAtIndex(1), IXMLWizardHelpContextIds.XML_NEWWIZARD_CREATEXML3_HELPID);
}
};
@@ -220,14 +217,7 @@ public class NewXMLWizard extends NewModelWizard {
int result = CREATE_FROM_SCRATCH;
if (grammarURI != null) {
- if (grammarURI.endsWith(".dtd")) //$NON-NLS-1$
- {
- result = CREATE_FROM_DTD;
- }
- else if (grammarURI.endsWith(".xsd")) //$NON-NLS-1$
- {
- result = CREATE_FROM_XSD;
- }
+ result = CREATE_FROM_GRAMMAR;
}
else if (fCreateXMLFromWizardPage != null) {
int selectedIndex = fCreateXMLFromWizardPage.getSelectedRadioButtonIndex();
@@ -251,7 +241,8 @@ public class NewXMLWizard extends NewModelWizard {
nextPage = selectRootElementPage;
}
else if (currentPage == fCreateXMLFromWizardPage) {
- if (getCreateMode() == CREATE_FROM_SCRATCH) {
+ int createMode = getCreateMode();
+ if (createMode == CREATE_FROM_SCRATCH) {
nextPage = fNewXMLTemplatesWizardPage;
}
else if (generator.getGrammarURI() == null) {
@@ -416,15 +407,10 @@ public class NewXMLWizard extends NewModelWizard {
public void setVisible(boolean visible) {
super.setVisible(visible);
if (visible) {
- if (getCreateMode() == CREATE_FROM_DTD) {
- setTitle(XMLWizardsMessages._UI_WIZARD_SELECT_DTD_FILE_TITLE);
- setDescription(XMLWizardsMessages._UI_WIZARD_SELECT_DTD_FILE_DESC);
- panel.setFilterExtensions(browseDTDFilterExtensions);
- }
- else {
- setTitle(XMLWizardsMessages._UI_WIZARD_SELECT_XSD_FILE_TITLE);
- setDescription(XMLWizardsMessages._UI_WIZARD_SELECT_XSD_FILE_DESC);
- panel.setFilterExtensions(browseXSDFilterExtensions);
+ if (getCreateMode() == CREATE_FROM_GRAMMAR) {
+ setTitle(XMLWizardsMessages._UI_WIZARD_SELECT_GRAMMAR_FILE_TITLE);
+ setDescription(XMLWizardsMessages._UI_WIZARD_SELECT_GRAMMAR_FILE_DESC);
+ panel.setFilterExtensions(browseGrammarFilterExtensions);
}
generator.setGrammarURI(null);
generator.setCMDocument(null);
diff --git a/xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLWizardsMessages.java b/xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLWizardsMessages.java
index f5fe712e9d..86d27cecfd 100644
--- a/xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLWizardsMessages.java
+++ b/xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/XMLWizardsMessages.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2005, 2010 IBM Corporation and others. All rights reserved. This
+ * Copyright (c) 2005, 2021 IBM Corporation and others. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Eclipse Public License 2.0 which accompanies this distribution, and is
* available at https://www.eclipse.org/legal/epl-2.0/
@@ -16,18 +16,18 @@ import org.eclipse.osgi.util.NLS;
/**
* Strings used by XML Wizards
- *
- * @plannedfor 1.0
*/
public class XMLWizardsMessages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.wst.xml.ui.internal.wizards.wizardResource";//$NON-NLS-1$
+
public static String _UI_DIALOG_NEW_TITLE;
public static String _UI_DIALOG_TITLE_INVALID_GRAMMAR;
public static String _UI_DIALOG_MESSAGE_INVALID_GRAMMAR;
public static String _UI_WIZARD_CREATE_NEW_TITLE;
public static String _UI_RADIO_XML_FROM_DTD;
public static String _UI_RADIO_XML_FROM_SCHEMA;
+ public static String _UI_RADIO_XML_FROM_DTD_OR_SCHEMA;
public static String _UI_RADIO_XML_FROM_SCRATCH;
public static String _UI_WIZARD_CREATE_XML_HEADING;
public static String _UI_WIZARD_CREATE_XML_EXPL;
@@ -37,6 +37,8 @@ public class XMLWizardsMessages extends NLS {
public static String _UI_WIZARD_SELECT_DTD_FILE_TITLE;
public static String _UI_WIZARD_SELECT_XSD_FILE_DESC;
public static String _UI_WIZARD_SELECT_XSD_FILE_TITLE;
+ public static String _UI_WIZARD_SELECT_GRAMMAR_FILE_DESC;
+ public static String _UI_WIZARD_SELECT_GRAMMAR_FILE_TITLE;
public static String _UI_WIZARD_SELECT_ROOT_HEADING;
public static String _UI_WIZARD_SELECT_ROOT_EXPL;
public static String _UI_LABEL_ROOT_ELEMENT;
diff --git a/xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/wizardResource.properties b/xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/wizardResource.properties
index 4fc398786f..ad2d161994 100644
--- a/xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/wizardResource.properties
+++ b/xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/wizardResource.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2001, 2010 IBM Corporation and others.
+# Copyright (c) 2001, 2021 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
# which accompanies this distribution, and is available at
@@ -23,7 +23,8 @@ _UI_DIALOG_MESSAGE_INVALID_GRAMMAR = The grammar file contains errors. If you pr
_UI_WIZARD_CREATE_NEW_TITLE = New XML File
_UI_RADIO_XML_FROM_DTD = Create XML file from a &DTD file
_UI_RADIO_XML_FROM_SCHEMA = Create XML file from an &XML schema file
-_UI_RADIO_XML_FROM_SCRATCH = Create XML file from an XML &template
+_UI_RADIO_XML_FROM_DTD_OR_SCHEMA = Create file using a &DTD or &XML Schema file
+_UI_RADIO_XML_FROM_SCRATCH = Create file from a &template
_UI_WIZARD_CREATE_XML_HEADING = Create XML File From
_UI_WIZARD_CREATE_XML_EXPL = Select how you would like to create your XML file.
_UI_WIZARD_CREATE_XML_FILE_HEADING = XML
@@ -32,6 +33,8 @@ _UI_WIZARD_SELECT_DTD_FILE_DESC = Select the DTD file to create the XML fi
_UI_WIZARD_SELECT_DTD_FILE_TITLE = Select DTD File
_UI_WIZARD_SELECT_XSD_FILE_DESC = Select the schema file to create the XML file.
_UI_WIZARD_SELECT_XSD_FILE_TITLE = Select XML Schema File
+_UI_WIZARD_SELECT_GRAMMAR_FILE_DESC = Select the DTD or Schema file to create the XML file.
+_UI_WIZARD_SELECT_GRAMMAR_FILE_TITLE = Select DTD or XML Schema File
_UI_WIZARD_SELECT_ROOT_HEADING = Select Root Element
_UI_WIZARD_SELECT_ROOT_EXPL = Select the root element of the XML file.
_UI_LABEL_ROOT_ELEMENT = Root element:
@@ -100,5 +103,5 @@ NewXMLTemplatesWizardPage_2=Name
NewXMLTemplatesWizardPage_3=Description
NewXMLTemplatesWizardPage_4=&Use XML Template
NewXMLTemplatesWizardPage_5=&Preview:
-NewXMLTemplatesWizardPage_6=Templates are 'New XML' templates found in the <a>XML Templates</a> preference page.
+NewXMLTemplatesWizardPage_6=Configure 'New XML' templates <a>here</a>
NewXMLTemplatesWizardPage_7=&Templates:
diff --git a/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdPanel.java b/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdPanel.java
index 8fe519ade7..4d9c6e327a 100644
--- a/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdPanel.java
+++ b/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdPanel.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2021 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -104,7 +104,7 @@ public class SelectFileOrXMLCatalogIdPanel extends Composite implements Selectio
ICatalog xmlCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
selectXMLCatalogIdPanel = new SelectXMLCatalogIdPanel(pageBook, xmlCatalog);
- selectXMLCatalogIdPanel.getTableViewer().addSelectionChangedListener(new ISelectionChangedListener() {
+ selectXMLCatalogIdPanel.getCatalogViewer().addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
updateCompletionStateChange();
}
@@ -151,10 +151,8 @@ public class SelectFileOrXMLCatalogIdPanel extends Composite implements Selectio
}
public void setFilterExtensions(String[] filterExtensions) {
- selectSingleFileView.resetFilters();
- selectSingleFileView.addFilterExtensions(filterExtensions);
-
- selectXMLCatalogIdPanel.getTableViewer().setFilterExtensions(filterExtensions);
+ selectSingleFileView.setFilterExtensions(filterExtensions);
+ selectXMLCatalogIdPanel.setFilterExtensions(filterExtensions);
}
public void setListener(Listener listener) {
diff --git a/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdDialog.java b/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdDialog.java
index ee9bf2e9f1..3b3daa2652 100644
--- a/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdDialog.java
+++ b/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 2021 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -13,7 +13,6 @@
*
*******************************************************************************/
-
package org.eclipse.wst.xml.ui.internal.dialogs;
import org.eclipse.jface.dialogs.Dialog;
@@ -51,7 +50,7 @@ public class SelectXMLCatalogIdDialog extends Dialog {
protected void buttonPressed(int buttonId) {
if (buttonId == IDialogConstants.OK_ID) {
- ISelection selection = panel.getTableViewer().getSelection();
+ ISelection selection = panel.getCatalogViewer().getSelection();
Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null;
if (selectedObject instanceof ICatalogEntry) {
@@ -91,8 +90,8 @@ public class SelectXMLCatalogIdDialog extends Dialog {
updateButtonState();
}
};
- panel.getTableViewer().setFilterExtensions(extensions);
- panel.getTableViewer().addSelectionChangedListener(listener);
+ panel.setFilterExtensions(extensions);
+ panel.getCatalogViewer().addSelectionChangedListener(listener);
return dialogArea;
}
@@ -107,7 +106,7 @@ public class SelectXMLCatalogIdDialog extends Dialog {
}
protected void updateButtonState() {
- ISelection selection = panel.getTableViewer().getSelection();
+ ISelection selection = panel.getCatalogViewer().getSelection();
okButton.setEnabled(!selection.isEmpty());
}
}
diff --git a/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdPanel.java b/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdPanel.java
index b2bb83418b..55d435f94d 100644
--- a/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdPanel.java
+++ b/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdPanel.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2011 IBM Corporation and others.
+ * Copyright (c) 2001, 2021 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -14,17 +14,22 @@
*******************************************************************************/
package org.eclipse.wst.xml.ui.internal.dialogs;
-import java.util.Collection;
import java.util.List;
-import java.util.Vector;
+import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.ui.dialogs.FilteredTree;
+import org.eclipse.ui.dialogs.PatternFilter;
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.INextCatalog;
@@ -35,8 +40,9 @@ public class SelectXMLCatalogIdPanel extends Composite {
protected int catalogEntryType;
protected boolean doTableSizeHack = false;
- protected XMLCatalogTableViewer tableViewer;
+ protected StructuredViewer tableViewer;
protected ICatalog fXmlCatalog;
+ private ViewerFilter fExtensionsFilter;
public SelectXMLCatalogIdPanel(Composite parent, ICatalog xmlCatalog) {
super(parent, SWT.NONE);
@@ -52,72 +58,67 @@ public class SelectXMLCatalogIdPanel extends Composite {
Label label = new Label(this, SWT.NONE);
label.setText(XMLUIMessages._UI_LABEL_XML_CATALOG_COLON);
- tableViewer = createTableViewer(this);
+ tableViewer = createCatalogViewer(this);
+ tableViewer.setInput("dummy");
+
tableViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
- tableViewer.setInput("dummy"); //$NON-NLS-1$
}
- protected XMLCatalogTableViewer createTableViewer(Composite parent) {
- String headings[] = new String[2];
- headings[0] = XMLUIMessages._UI_LABEL_KEY;
- headings[1] = XMLUIMessages._UI_LABEL_URI;
-
- XMLCatalogTableViewer theTableViewer = new XMLCatalogTableViewer(parent, headings) {
-
- protected void addXMLCatalogEntries(List list, ICatalogEntry[] entries) {
- for (int i = 0; i < entries.length; i++) {
- ICatalogEntry entry = entries[i];
- if (catalogEntryType == 0) {
- list.add(entry);
- }
- else if (catalogEntryType == entry.getEntryType()) {
- list.add(entry);
- }
- }
- }
-
- public Collection getXMLCatalogEntries() {
- List result = null;
-
- if ((fXmlCatalog == null) || doTableSizeHack) {
- // this lets us create a table with an initial height of
- // 10 rows
- // otherwise we get stuck with 0 row heigh table... that's
- // too small
- doTableSizeHack = false;
- result = new Vector();
- for (int i = 0; i < 6; i++) {
- result.add(""); //$NON-NLS-1$
- }
- }
- else {
- result = new Vector();
- processCatalog(result, fXmlCatalog);
- }
- return result;
+ void addXMLCatalogEntries(List<ICatalogEntry> list, ICatalogEntry[] entries) {
+ for (int i = 0; i < entries.length; i++) {
+ ICatalogEntry entry = entries[i];
+ if (catalogEntryType == 0) {
+ list.add(entry);
}
-
- private void processCatalog(List result, ICatalog catalog) {
- addXMLCatalogEntries(result, catalog.getCatalogEntries());
- INextCatalog[] nextCatalogs = catalog.getNextCatalogs();
- for (int i = 0; i < nextCatalogs.length; i++) {
- ICatalog nextCatalog = nextCatalogs[i].getReferencedCatalog();
- if (nextCatalog != null) {
- processCatalog(result, nextCatalog);
- }
- }
+ else if (catalogEntryType == entry.getEntryType()) {
+ list.add(entry);
}
- };
- return theTableViewer;
+ }
+ }
+
+ void processCatalog(List<ICatalogEntry> result, ICatalog catalog) {
+ addXMLCatalogEntries(result, catalog.getCatalogEntries());
+ INextCatalog[] nextCatalogs = catalog.getNextCatalogs();
+ for (int i = 0; i < nextCatalogs.length; i++) {
+ ICatalog nextCatalog = nextCatalogs[i].getReferencedCatalog();
+ if (nextCatalog != null) {
+ processCatalog(result, nextCatalog);
+ }
+ }
}
+ protected StructuredViewer createCatalogViewer(Composite parent) {
+ String columnProperties[] = new String[2];
+ columnProperties[0] = XMLUIMessages._UI_LABEL_KEY;
+ columnProperties[1] = XMLUIMessages._UI_LABEL_URI;
+
+ FilteredTree viewerCreator = new FilteredTree(parent, SWT.FULL_SELECTION | SWT.BORDER, new PatternFilter(), true, true);
+ viewerCreator.getViewer().setContentProvider(new XMLCatalogEntryContentProvider());
+ viewerCreator.getViewer().setLabelProvider(new XMLCatalogEntryLabelProvider());
+
+ viewerCreator.getViewer().getTree().setLinesVisible(true);
+ viewerCreator.getViewer().getTree().setHeaderVisible(true);
+ viewerCreator.getViewer().getTree().setLinesVisible(true);
+
+ TableLayout layout = new TableLayout();
+ for (int i = 0; i < columnProperties.length; i++) {
+ TreeColumn column = new TreeColumn(viewerCreator.getViewer().getTree(), i);
+ column.setText(columnProperties[i]);
+ column.setAlignment(SWT.LEFT);
+ layout.addColumnData(new ColumnWeightData(50, true));
+ }
+ viewerCreator.getViewer().getTree().setLayout(layout);
+ viewerCreator.getViewer().getTree().setLinesVisible(false);
+ viewerCreator.getViewer().setColumnProperties(columnProperties);
+ return viewerCreator.getViewer();
+ }
public String getId() {
ICatalogEntry entry = getXMLCatalogEntry();
return entry != null ? entry.getKey() : null;
}
- public XMLCatalogTableViewer getTableViewer() {
+ public StructuredViewer getCatalogViewer() {
return tableViewer;
}
@@ -140,4 +141,10 @@ public class SelectXMLCatalogIdPanel extends Composite {
this.catalogEntryType = catalogEntryType;
tableViewer.refresh();
}
+ void setFilterExtensions(String[] extensions) {
+ if (fExtensionsFilter != null) {
+ getCatalogViewer().removeFilter(fExtensionsFilter);
+ }
+ getCatalogViewer().addFilter(fExtensionsFilter = new XMLCatalogViewerFilter(extensions));
+ }
}
diff --git a/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogEntryContentProvider.java b/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogEntryContentProvider.java
new file mode 100644
index 0000000000..c92cd7d579
--- /dev/null
+++ b/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogEntryContentProvider.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2021 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *
+ *******************************************************************************/
+package org.eclipse.wst.xml.ui.internal.dialogs;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
+import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
+import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement;
+import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
+import org.eclipse.wst.xml.core.internal.catalog.provisional.IDelegateCatalog;
+import org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog;
+import org.eclipse.wst.xml.ui.internal.catalog.XMLCatalogMessages;
+
+import com.ibm.icu.text.Collator;
+
+public class XMLCatalogEntryContentProvider implements ITreeContentProvider {
+
+ protected Object[] roots;
+ private ICatalog fWorkingUserCatalog;
+ private ICatalog fSystemCatalog;
+ static final String USER_SPECIFIED_ENTRIES_OBJECT = XMLCatalogMessages.UI_LABEL_USER_SPECIFIED_ENTRIES;
+ static final String PLUGIN_SPECIFIED_ENTRIES_OBJECT = XMLCatalogMessages.UI_LABEL_PLUGIN_SPECIFIED_ENTRIES;
+
+ public XMLCatalogEntryContentProvider() {
+ roots = new Object[2];
+
+ roots[0] = USER_SPECIFIED_ENTRIES_OBJECT;
+ roots[1] = PLUGIN_SPECIFIED_ENTRIES_OBJECT;
+
+ ICatalog 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())) {
+ fSystemCatalog = referencedCatalog;
+ }
+ else if (XMLCorePlugin.USER_CATALOG_ID.equals(referencedCatalog.getId())) {
+ fWorkingUserCatalog = referencedCatalog;
+ }
+ }
+ }
+ }
+
+ public boolean isRoot(Object object) {
+ return (object instanceof String) || (object instanceof INextCatalog);
+ }
+
+ public Object[] getElements(Object element) {
+ return roots;
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ Object[] result = new Object[0];
+ if (parentElement == roots[0]) {
+ result = getChildrenHelper(fWorkingUserCatalog);
+ }
+ else if (parentElement == roots[1]) {
+ result = getChildrenHelper(fSystemCatalog);
+ }
+ else if (parentElement instanceof INextCatalog) {
+ ICatalog nextCatalog = ((INextCatalog) parentElement).getReferencedCatalog();
+ result = getChildrenHelper(nextCatalog);
+ }
+ else if (parentElement instanceof IDelegateCatalog) {
+ ICatalog nextCatalog = ((IDelegateCatalog) parentElement).getReferencedCatalog();
+ result = getChildrenHelper(nextCatalog);
+ }
+ return result;
+ }
+
+ protected Object[] getChildrenHelper(ICatalog catalog) {
+
+ ICatalogEntry[] entries = catalog.getCatalogEntries();
+ if (entries.length > 0) {
+ Comparator comparator = new Comparator() {
+ public int compare(Object o1, Object o2) {
+ int result = 0;
+ if ((o1 instanceof ICatalogEntry) && (o2 instanceof ICatalogEntry)) {
+ ICatalogEntry entry1 = (ICatalogEntry) o1;
+ ICatalogEntry entry2 = (ICatalogEntry) o2;
+ result = Collator.getInstance().compare(entry1.getKey(), entry2.getKey());
+ }
+ return result;
+ }
+ };
+ Arrays.sort(entries, comparator);
+ }
+ Vector result = new Vector();
+ result.addAll(Arrays.asList(entries));
+ result.addAll(Arrays.asList(catalog.getRewriteEntries()));
+ result.addAll(Arrays.asList(catalog.getSuffixEntries()));
+ result.addAll(Arrays.asList(catalog.getDelegateCatalogs()));
+ INextCatalog[] nextCatalogs = catalog.getNextCatalogs();
+ List nextCatalogsList = Arrays.asList(nextCatalogs);
+ result.addAll(nextCatalogsList);
+
+ return result.toArray(new ICatalogElement[result.size()]);
+ }
+
+ public Object getParent(Object element) {
+ return (element instanceof String) ? null : USER_SPECIFIED_ENTRIES_OBJECT;
+ }
+
+ public boolean hasChildren(Object element) {
+ return isRoot(element) ? getChildren(element).length > 0 : false;
+ }
+
+ public void dispose() {
+ // nothing to dispose
+ }
+
+ public void inputChanged(Viewer viewer, Object old, Object newobj) {
+ // ISSUE: seems we should do something here
+ }
+
+ public boolean isDeleted(Object object) {
+ return false;
+ }
+
+} \ No newline at end of file
diff --git a/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogEntryLabelProvider.java b/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogEntryLabelProvider.java
new file mode 100644
index 0000000000..b4d2d542ec
--- /dev/null
+++ b/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogEntryLabelProvider.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2021 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Jens Lukowski/Innoopract - initial renaming/restructuring
+ *
+ *******************************************************************************/
+
+package org.eclipse.wst.xml.ui.internal.dialogs;
+
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
+import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
+import org.eclipse.wst.xml.ui.internal.catalog.ImageFactory;
+
+public class XMLCatalogEntryLabelProvider extends LabelProvider implements ITableLabelProvider {
+
+ public Image getColumnImage(Object object, int columnIndex) {
+ Image result = null;
+ if (columnIndex == 0) {
+ Image base = null;
+ if (object instanceof ICatalogEntry) {
+ ICatalogEntry catalogEntry = (ICatalogEntry) object;
+ String uri = catalogEntry.getURI();
+ if (uri.endsWith("dtd")) { //$NON-NLS-1$
+ base = XMLCatalogTableViewer.dtdFileImage;
+ }
+ else if (uri.endsWith("xsd")) { //$NON-NLS-1$
+ base = XMLCatalogTableViewer.xsdFileImage;
+ }
+ else {
+ base = XMLCatalogTableViewer.unknownFileImage;
+ }
+
+ if (base != null) {
+ if (URIHelper.isReadableURI(uri, false)) {
+ result = base;
+ }
+ else {
+ // TODO... SSE port
+ result = base;// imageFactory.createCompositeImage(base,
+ // errorImage,
+ // ImageFactory.BOTTOM_LEFT);
+ }
+ }
+ }
+ else if (object instanceof String) {
+ result = ImageFactory.INSTANCE.getImage("icons/obj16/xmlcatalog_obj.gif");
+ }
+ }
+ return result;
+ }
+ @Override
+ public String getText(Object element) {
+ return getColumnText(element, 0);
+ }
+
+ public String getColumnText(Object object, int columnIndex) {
+ String result = null;
+ if (object instanceof ICatalogEntry) {
+ ICatalogEntry catalogEntry = (ICatalogEntry) object;
+ result = columnIndex == 0 ? catalogEntry.getKey() : catalogEntry.getURI();
+ result = URIHelper.removePlatformResourceProtocol(result);
+ }
+ return result != null ? result : (columnIndex == 0 ? object.toString() : ""); //$NON-NLS-1$
+ }
+} \ No newline at end of file
diff --git a/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogTableViewer.java b/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogTableViewer.java
index 37d31ddecf..401f8bf546 100644
--- a/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogTableViewer.java
+++ b/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogTableViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2010 IBM Corporation and others.
+ * Copyright (c) 2001, 2021 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -13,141 +13,25 @@
*
*******************************************************************************/
-
package org.eclipse.wst.xml.ui.internal.dialogs;
-import com.ibm.icu.text.Collator;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.Comparator;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
-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.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-
+@Deprecated
public class XMLCatalogTableViewer extends TableViewer {
- public class CatalogEntryContentProvider implements IStructuredContentProvider {
-
- public void dispose() {
- }
-
- public Object[] getElements(Object element) {
- Object[] array = getXMLCatalogEntries().toArray();
- Comparator comparator = new Comparator() {
- public int compare(Object o1, Object o2) {
- int result = 0;
- if ((o1 instanceof ICatalogEntry) && (o2 instanceof ICatalogEntry)) {
- ICatalogEntry mappingInfo1 = (ICatalogEntry) o1;
- ICatalogEntry mappingInfo2 = (ICatalogEntry) o2;
- result = Collator.getInstance().compare(mappingInfo1.getKey(), mappingInfo2.getKey());
- }
- return result;
- }
- };
- Arrays.sort(array, comparator);
- return array;
- }
-
- public void inputChanged(Viewer viewer, Object old, Object newobj) {
- }
-
- public boolean isDeleted(Object object) {
- return false;
- }
- }
-
- public class CatalogEntryLabelProvider extends LabelProvider implements ITableLabelProvider {
-
- public Image getColumnImage(Object object, int columnIndex) {
- Image result = null;
- if (columnIndex == 0) {
- Image base = null;
- if (object instanceof ICatalogEntry) {
- ICatalogEntry catalogEntry = (ICatalogEntry) object;
- String uri = catalogEntry.getURI();
- if (uri.endsWith("dtd")) { //$NON-NLS-1$
- base = dtdFileImage;
- }
- else if (uri.endsWith("xsd")) { //$NON-NLS-1$
- base = xsdFileImage;
- }
- else {
- base = unknownFileImage;
- }
-
- if (base != null) {
- if (URIHelper.isReadableURI(uri, false)) {
- result = base;
- }
- else {
- // TODO... SSE port
- result = base;// imageFactory.createCompositeImage(base,
- // errorImage,
- // ImageFactory.BOTTOM_LEFT);
- }
- }
- }
- }
- return result;
- }
-
- public String getColumnText(Object object, int columnIndex) {
- String result = null;
- if (object instanceof ICatalogEntry) {
- ICatalogEntry catalogEntry = (ICatalogEntry) object;
- result = columnIndex == 0 ? catalogEntry.getKey() : catalogEntry.getURI();
- result = URIHelper.removePlatformResourceProtocol(result);
- }
- return result != null ? result : ""; //$NON-NLS-1$
- }
- }
-
-
- class XMLCatalogTableViewerFilter extends ViewerFilter {
- protected String[] extensions;
-
- public XMLCatalogTableViewerFilter(String[] extensions) {
- this.extensions = extensions;
- }
-
- 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;
- }
- }
-
protected static Image dtdFileImage = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_DTDFILE);
protected static String ERROR_STATE_KEY = "errorstatekey"; //$NON-NLS-1$
@@ -156,6 +40,8 @@ public class XMLCatalogTableViewer extends TableViewer {
protected static Image unknownFileImage = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TXTEXT);
protected static Image xsdFileImage = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_XSDFILE);
+ private XMLCatalogViewerFilter fExtensionsFilter;
+
// protected ImageFactory imageFactory = new ImageFactory();
public XMLCatalogTableViewer(Composite parent, String[] columnProperties) {
@@ -178,26 +64,18 @@ public class XMLCatalogTableViewer extends TableViewer {
setColumnProperties(columnProperties);
- setContentProvider(new CatalogEntryContentProvider());
- setLabelProvider(new CatalogEntryLabelProvider());
+ setContentProvider(new XMLCatalogEntryContentProvider());
+ setLabelProvider(new XMLCatalogEntryLabelProvider());
}
public Collection getXMLCatalogEntries() {
return null;
}
-
- 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);
- }
-
public void setFilterExtensions(String[] extensions) {
- resetFilters();
- addFilter(new XMLCatalogTableViewerFilter(extensions));
+ if (fExtensionsFilter != null) {
+ removeFilter(fExtensionsFilter);
+ }
+ addFilter(fExtensionsFilter = new XMLCatalogViewerFilter(extensions));
}
}
diff --git a/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogViewerFilter.java b/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogViewerFilter.java
new file mode 100644
index 0000000000..3d72e8fd18
--- /dev/null
+++ b/xml/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogViewerFilter.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2021 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *
+ *******************************************************************************/
+package org.eclipse.wst.xml.ui.internal.dialogs;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
+
+public class XMLCatalogViewerFilter extends ViewerFilter {
+
+ protected String[] extensions;
+
+ public XMLCatalogViewerFilter() {
+ }
+
+
+ public XMLCatalogViewerFilter(String[] extensions) {
+ this.extensions = extensions;
+ }
+
+ public boolean isFilterProperty(Object element, Object property) {
+ return false;
+ }
+
+ @Override
+ public boolean select(Viewer viewer, Object parent, Object element) {
+ boolean isCatalogEntry = (element instanceof ICatalogEntry);
+ boolean result = !isCatalogEntry;
+ if (isCatalogEntry) {
+ ICatalogEntry catalogEntry = (ICatalogEntry) element;
+ for (int i = 0; i < extensions.length; i++) {
+ if (catalogEntry.getURI().endsWith(extensions[i])) {
+ result = true;
+ break;
+ }
+ }
+ }
+ return result;
+ }
+}

Back to the top