Skip to main content

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

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit')
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit/CommonAddNamespacesControl.java265
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit/CommonAddNamespacesDialog.java188
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit/CommonEditNamespacesDialog.java319
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit/CommonEditNamespacesTargetFieldDialog.java104
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit/CommonNamespaceInfoTable.java340
5 files changed, 0 insertions, 1216 deletions
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit/CommonAddNamespacesControl.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit/CommonAddNamespacesControl.java
deleted file mode 100644
index 063d580f20..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit/CommonAddNamespacesControl.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.nsedit;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
-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.Label;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.part.PageBook;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
-import org.eclipse.wst.xml.ui.dialogs.SelectFileOrXMLCatalogIdDialog;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.uriresolver.util.IdResolver;
-import org.eclipse.wst.xml.uriresolver.util.IdResolverImpl;
-import org.eclipse.wst.xml.uriresolver.util.URIHelper;
-
-public class CommonAddNamespacesControl extends Composite implements SelectionListener {
-
- class EditNamespaceControl extends Composite {
- protected Button browseButton;
- Text locationHintField;
- Text prefixField;
- Text uriField;
-
- //protected NamespaceInfo info;
-
- public EditNamespaceControl(Composite parent) {
- super(parent, SWT.NONE); //BORDER);
- setLayout(new GridLayout());
- setLayoutData(new GridData(GridData.FILL_BOTH));
-
- Label label = new Label(this, SWT.NONE);
- label.setText(XMLUIMessages._UI_ENTER_REQ_PREFIX_AND_NAMESPACE); //$NON-NLS-1$
-
- Composite composite = new Composite(this, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 3;
- layout.marginWidth = 0;
- layout.verticalSpacing = 1;
- composite.setLayout(layout);
-
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint = 350;
- composite.setLayoutData(gd);
-
- // row 1
- //
- Label prefixLabel = new Label(composite, SWT.NONE);
- prefixLabel.setText(XMLUIMessages._UI_LABEL_PREFIX_COLON); //$NON-NLS-1$
-
- prefixField = new Text(composite, SWT.SINGLE | SWT.BORDER);
- prefixField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- //prefixField.setText(getDisplayValue(info.prefix));
- //prefixField.addModifyListener(modifyListener);
- //prefixField.setEnabled(info.getProperty("prefix-readOnly") ==
- // null);
- Label placeHolder1 = new Label(composite, SWT.NONE);
-
- // row 2
- //
- Label uriLabel = new Label(composite, SWT.NONE);
- uriLabel.setText(XMLUIMessages._UI_LABEL_NAMESPACE_NAME_COLON); //$NON-NLS-1$
-
- uriField = new Text(composite, SWT.SINGLE | SWT.BORDER);
- uriField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- //uriField.setText(getDisplayValue(info.uri));
- //uriField.addModifyListener(modifyListener);
- //uriField.setEnabled(info.getProperty("uri-readOnly") == null);
-
- Label placeHolder2 = new Label(composite, SWT.NONE);
-
- // row 3
- //
- Label locationHintLabel = new Label(composite, SWT.NONE);
- locationHintLabel.setText(XMLUIMessages._UI_LABEL_LOCATION_HINT_COLON); //$NON-NLS-1$
-
- locationHintField = new Text(composite, SWT.SINGLE | SWT.BORDER);
- locationHintField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- //locationHintField.setText(getDisplayValue(info.locationHint));
- //locationHintField.addModifyListener(modifyListener);
- //locationHintField.setEnabled(info.getProperty("locationHint-readOnly")
- // == null);
-
- SelectionListener selectionListener = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- performBrowse();
- }
- };
-
- browseButton = new Button(composite, SWT.NONE);
- browseButton.setText(XMLUIMessages._UI_LABEL_BROWSE); //$NON-NLS-1$
- browseButton.addSelectionListener(selectionListener);
- browseButton.setEnabled(locationHintField.getEnabled());
- }
-
- protected void performBrowse() {
- String[] extensions = {".xsd"}; //$NON-NLS-1$
- SelectFileOrXMLCatalogIdDialog dialog = new SelectFileOrXMLCatalogIdDialog(getShell(), extensions);
- dialog.create();
- dialog.getShell().setText(XMLUIMessages._UI_LABEL_SELECT_FILE); //$NON-NLS-1$
- dialog.setBlockOnOpen(true);
- dialog.open();
-
- if (dialog.getReturnCode() == Window.OK) {
- String grammarURI = null;
- IFile file = dialog.getFile();
- String id = dialog.getId();
- if (file != null) {
- String uri = null;
- if (resourceLocation != null) {
- uri = URIHelper.getRelativeURI(file.getLocation(), resourceLocation);
- grammarURI = file.getLocation().toOSString();
- } else {
- uri = file.getLocation().toOSString();
- grammarURI = uri;
- }
- locationHintField.setText(uri);
- } else if (id != null) {
- locationHintField.setText(id);
- IdResolver resolver = new IdResolverImpl(null);
- grammarURI = resolver.resolveId(id, id);
- }
-
- try {
- //TODO CMDocument document =
- // CMDocumentBuilderRegistry.getInstance().buildCMDocument(grammarURI);
- // List namespaceInfoList =
- // (List)document.getProperty("http://org.eclipse.wst/cm/properties/namespaceInfo");
- // NamespaceInfo info =
- // (NamespaceInfo)namespaceInfoList.get(0);
- // if (uriField.getText().trim().length() == 0 && info.uri
- // != null)
- // {
- // uriField.setText(info.uri);
- // }
- // if (prefixField.getText().trim().length() == 0 &&
- // info.prefix != null)
- // {
- // prefixField.setText(info.prefix);
- // }
- } catch (Exception e) {
- }
- }
- }
- }
-
- protected Button deleteButton;
- protected Button editButton;
- protected EditNamespaceControl editNamespaceControl;
- protected int heightHint = 250;
- protected List namespaceInfoList = new ArrayList();
- protected Button newButton;
- protected PageBook pageBook;
- protected Button radio1;
- protected Button radio2;
- protected IPath resourceLocation;
- protected Composite tableSection;
- protected CommonNamespaceInfoTable tableViewer;
- protected int widthHint = 500;
-
-
- public CommonAddNamespacesControl(Composite parent, int style, IPath resourceLocation) {
- super(parent, style);
- this.resourceLocation = resourceLocation;
- GridData gd = new GridData(GridData.FILL_BOTH);
- if (widthHint != -1) {
- gd.widthHint = widthHint;
- }
- if (heightHint != -1) {
- gd.heightHint = heightHint;
- }
- setLayoutData(gd);
- setLayout(new GridLayout());
-
- radio1 = new Button(this, SWT.RADIO);
- radio1.setText(XMLUIMessages._UI_SELECT_REGISTERED_NAMESPACES); //$NON-NLS-1$
- radio1.addSelectionListener(this);
-
- radio2 = new Button(this, SWT.RADIO);
- radio2.setText(XMLUIMessages._UI_SPECIFY_NEW_NAMESPACE); //$NON-NLS-1$
- radio2.addSelectionListener(this);
-
- Label separator = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
- separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- //Group namespaceInfoGroup = new Group(this, SWT.NONE);
- //namespaceInfoGroup.setText("Namespace Declarations");
- // //XMLCommonUIPlugin.getInstance().getString("_UI_LABEL_XML_SCHEMA_INFORMATION"));
- //namespaceInfoGroup.setLayout(new GridLayout(2, false));
- //namespaceInfoGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
- pageBook = new PageBook(this, SWT.NONE);
- pageBook.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- tableSection = new Composite(pageBook, SWT.NONE);
- tableSection.setLayout(new GridLayout());
- Label label = new Label(tableSection, SWT.NONE);
- label.setText(XMLUIMessages._UI_SELECT_NAMESPACE_TO_ADD); //$NON-NLS-1$
-
- tableViewer = new CommonNamespaceInfoTable(tableSection, SWT.CHECK, 6);
- editNamespaceControl = new EditNamespaceControl(pageBook);
- pageBook.showPage(tableSection);
-
- tableViewer.setInput(namespaceInfoList);
- }
-
-
-
- public List getNamespaceInfoList() {
- List list = new ArrayList();
- if (radio1.getSelection()) {
- TableItem[] items = tableViewer.getTable().getItems();
- for (int i = 0; i < items.length; i++) {
- TableItem item = items[i];
- if (item.getChecked()) {
- list.add(item.getData());
- }
- }
- } else {
- NamespaceInfo info = new NamespaceInfo();
- info.prefix = editNamespaceControl.prefixField.getText();
- info.uri = editNamespaceControl.uriField.getText();
- info.locationHint = editNamespaceControl.locationHintField.getText();
- list.add(info);
- }
- return list;
- }
-
- public void setNamespaceInfoList(List list) {
- namespaceInfoList = list;
- tableViewer.setInput(namespaceInfoList);
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- if (e.widget == radio1) {
- pageBook.showPage(tableSection);
- } else if (e.widget == radio2) {
- pageBook.showPage(editNamespaceControl);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit/CommonAddNamespacesDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit/CommonAddNamespacesDialog.java
deleted file mode 100644
index 4553512630..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit/CommonAddNamespacesDialog.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.nsedit;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
-import org.eclipse.wst.xml.uriresolver.XMLCatalog;
-import org.eclipse.wst.xml.uriresolver.XMLCatalogEntry;
-import org.eclipse.wst.xml.uriresolver.XMLCatalogPlugin;
-
-
-public class CommonAddNamespacesDialog extends Dialog {
- protected CommonAddNamespacesControl addNamespacesControl;
- protected List existingNamespaces;
- protected List namespaceInfoList;
- protected Button okButton;
- protected HashMap preferredPrefixTable = new HashMap();
- protected IPath resourceLocation;
- protected String title;
-
- public CommonAddNamespacesDialog(Shell parentShell, String title, IPath resourceLocation, List existingNamespaces) {
- super(parentShell);
- this.resourceLocation = resourceLocation;
- setShellStyle(getShellStyle() | SWT.RESIZE);
- this.title = title;
- this.existingNamespaces = existingNamespaces;
- preferredPrefixTable.put("http://schemas.xmlsoap.org/wsdl/", "wsdl"); //$NON-NLS-1$ //$NON-NLS-2$
- preferredPrefixTable.put("http://schemas.xmlsoap.org/wsdl/soap/", "soap"); //$NON-NLS-1$ //$NON-NLS-2$
- preferredPrefixTable.put("http://schemas.xmlsoap.org/wsdl/http/", "http"); //$NON-NLS-1$ //$NON-NLS-2$
- preferredPrefixTable.put("http://schemas.xmlsoap.org/wsdl/mime/", "mime"); //$NON-NLS-1$ //$NON-NLS-2$
- preferredPrefixTable.put("http://schemas.xmlsoap.org/soap/encoding/", "soapenc"); //$NON-NLS-1$ //$NON-NLS-2$
- preferredPrefixTable.put("http://schemas.xmlsoap.org/soap/envelope/", "soapenv"); //$NON-NLS-1$ //$NON-NLS-2$
- preferredPrefixTable.put("http://www.w3.org/2001/XMLSchema-instance", "xsi"); //$NON-NLS-1$ //$NON-NLS-2$
- preferredPrefixTable.put("http://www.w3.org/2001/XMLSchema", "xsd"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- protected void addBuiltInNamespaces(List list) {
- String xsiNamespace = "http://www.w3.org/2001/XMLSchema-instance"; //$NON-NLS-1$
- String xsdNamespace = "http://www.w3.org/2001/XMLSchema"; //$NON-NLS-1$
- if (!isAlreadyDeclared(xsiNamespace)) {
- list.add(new NamespaceInfo("http://www.w3.org/2001/XMLSchema-instance", "xsi", null)); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (!isAlreadyDeclared(xsdNamespace)) {
- list.add(new NamespaceInfo("http://www.w3.org/2001/XMLSchema", "xsd", null)); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- protected void addCatalogMapToList(XMLCatalog catalog, List list) {
- for (Iterator i = catalog.getEntries().iterator(); i.hasNext();) {
- XMLCatalogEntry entry = (XMLCatalogEntry) i.next();
- if (entry.getType() == XMLCatalogEntry.PUBLIC && entry.getURI().endsWith(".xsd")) { //$NON-NLS-1$
- if (!isAlreadyDeclared(entry.getKey())) {
- NamespaceInfo namespaceInfo = new NamespaceInfo(entry.getKey(), "xx", null); //$NON-NLS-1$
- list.add(namespaceInfo);
- }
- }
- }
- }
-
- protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.OK_ID) {
- namespaceInfoList = addNamespacesControl.getNamespaceInfoList();
- }
- super.buttonPressed(buttonId);
- }
-
- public void computeAddablePrefixes(List addableList, List exisitingList) {
- HashMap map = new HashMap();
- for (Iterator i = exisitingList.iterator(); i.hasNext();) {
- NamespaceInfo info = (NamespaceInfo) i.next();
- if (info.prefix != null) {
- map.put(info.prefix, info);
- }
- }
- for (Iterator i = addableList.iterator(); i.hasNext();) {
- NamespaceInfo info = (NamespaceInfo) i.next();
- if (info.uri != null) {
- String prefix = (String) preferredPrefixTable.get(info.uri);
- info.prefix = getUniquePrefix(map, prefix, info.uri);
- map.put(info.prefix, info);
- }
- }
- }
-
- public int createAndOpen() {
- create();
- getShell().setText(title);
- Rectangle r = getShell().getBounds();
- getShell().setBounds(r.x + 80, r.y + 80, r.width, r.height);
- setBlockOnOpen(true);
- return open();
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- protected Control createContents(Composite parent) {
- Control control = super.createContents(parent);
- return control;
- }
-
-
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogArea = (Composite) super.createDialogArea(parent);
- addNamespacesControl = new CommonAddNamespacesControl(dialogArea, SWT.NONE, resourceLocation);
- List list = new ArrayList();
-
- addBuiltInNamespaces(list);
- XMLCatalog catalog = XMLCatalogPlugin.getInstance().getDefaultXMLCatalog();
- addCatalogMapToList(catalog.getChildCatalog(XMLCatalog.USER_CATALOG_ID), list);
- addCatalogMapToList(catalog.getChildCatalog(XMLCatalog.SYSTEM_CATALOG_ID), list);
-
- computeAddablePrefixes(list, existingNamespaces);
-
- addNamespacesControl.setNamespaceInfoList(list);
- return dialogArea;
- }
-
- public List getNamespaceInfoList() {
- return namespaceInfoList;
- }
-
- protected String getPreferredPrefix(String namespaceURI) {
- return (String) preferredPrefixTable.get(namespaceURI);
- }
-
- private String getUniquePrefix(HashMap prefixMap, String prefix, String uri) {
- if (prefix == null) {
- int lastIndex = uri.lastIndexOf('/');
- if (lastIndex == uri.length() - 1) {
- uri = uri.substring(0, lastIndex);
- lastIndex = uri.lastIndexOf('/');
- }
- prefix = uri.substring(lastIndex + 1);
- if (prefix.length() > 20 || prefix.indexOf(':') != -1) {
- prefix = null;
- }
- }
- if (prefix == null) {
- prefix = "p"; //$NON-NLS-1$
- }
- if (prefixMap.get(prefix) != null) {
- String base = prefix;
- for (int count = 0; prefixMap.get(prefix) != null; count++) {
- prefix = base + count;
- }
- }
- return prefix;
- }
-
- protected boolean isAlreadyDeclared(String namespaceURI) {
- boolean result = false;
- for (Iterator i = existingNamespaces.iterator(); i.hasNext();) {
- NamespaceInfo namespaceInfo = (NamespaceInfo) i.next();
- if (namespaceURI.equals(namespaceInfo.uri)) {
- result = true;
- break;
- }
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit/CommonEditNamespacesDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit/CommonEditNamespacesDialog.java
deleted file mode 100644
index 7489cba0b4..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit/CommonEditNamespacesDialog.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.nsedit;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-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.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-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.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
-import org.eclipse.wst.xml.ui.dialogs.EditNamespaceInfoDialog;
-import org.eclipse.wst.xml.ui.dialogs.NamespaceInfoErrorHelper;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-public class CommonEditNamespacesDialog {
- protected Composite commonComposite;
- protected Button deleteButton;
- protected Button editButton;
-
- protected Label errorMessageLabel;
- protected int heightHint = 250;
- protected List namespaceInfoList = new ArrayList();
-
- protected Button newButton;
- protected IPath resourceLocation;
-
- private boolean showLocationText = false;
- protected String tableLabel = ""; //$NON-NLS-1$
- protected CommonNamespaceInfoTable tableViewer;
-
- protected Composite topComposite;
- protected boolean useGroup;
- protected int widthHint = 500;
-
- public CommonEditNamespacesDialog(Composite parent, IPath resourceLocation, String stringTableLabel) {
- this(parent, resourceLocation, stringTableLabel, false, false);
- }
-
- public CommonEditNamespacesDialog(Composite parent, IPath resourceLocation, String stringTableLabel, boolean useGroup, boolean showLocText) {
- this.resourceLocation = resourceLocation;
- tableLabel = stringTableLabel;
- this.useGroup = useGroup;
- showLocationText = showLocText;
-
- GridData gd = new GridData(GridData.FILL_BOTH);
- if (widthHint != -1) {
- gd.widthHint = widthHint;
- }
- if (heightHint != -1) {
- gd.heightHint = heightHint;
- }
-
- // Set GridData and GridLayout for the parent Composite
- parent.setLayoutData(gd);
- parent.setLayout(new GridLayout());
-
- // Create the top Composite
- topComposite = new Composite(parent, SWT.NONE);
- GridData topData = new GridData(GridData.FILL_HORIZONTAL);
- topData.heightHint = 0;
- topComposite.setLayoutData(topData);
- topComposite.setLayout(new GridLayout());
-
- // Create the 'common'/middle Composite
- if (useGroup) {
- commonComposite = new Group(parent, SWT.NONE);
- } else {
- commonComposite = new Composite(parent, SWT.NONE);
- }
- commonComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
- commonComposite.setLayout(new GridLayout(3, false));
-
- // Add the error Message Label
- errorMessageLabel = new Label(parent, SWT.NONE);
- errorMessageLabel.setLayoutData(createHorizontalFill());
- Color color = new Color(errorMessageLabel.getDisplay(), 200, 0, 0);
- errorMessageLabel.setForeground(color);
-
- createControlArea();
- }
-
-
- protected void createButtons(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 1;
- gridLayout.marginHeight = 0;
- gridLayout.marginWidth = 0;
- composite.setLayout(gridLayout);
-
- SelectionListener selectionListener = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (e.widget == newButton) {
- performNew();
- } else if (e.widget == editButton) {
- performEdit();
- } else if (e.widget == deleteButton) {
- performDelete();
- }
- }
- };
-
- // create a composite to hold the three buttons
- Composite buttonComposite = new Composite(composite, SWT.NONE);
- buttonComposite.setLayoutData(createHorizontalFill());
- GridLayout buttonGridLayout = new GridLayout();
- //buttonGridLayout.numColumns = 3;
- //buttonGridLayout.makeColumnsEqualWidth = true;
- buttonComposite.setLayout(buttonGridLayout);
-
- // add the New button
- //
- newButton = new Button(buttonComposite, SWT.NONE);
- //newButton.setText(" " +
- // XMLCommonUIPlugin.getInstance().getString("_UI_BUTTON_NEW") + " ");
- newButton.setText(" " + XMLUIMessages.CommonEditNamespacesDialog_0 + " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- newButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); //ViewUtility.createHorizontalFill());
- newButton.addSelectionListener(selectionListener);
-
- // add the Edit button
- //
- //gd = new GridData();
- //gd.horizontalAlignment = gd.FILL;
- //gd.grabExcessHorizontalSpace = true;
-
- editButton = new Button(buttonComposite, SWT.NONE);
- editButton.setText(XMLUIMessages._UI_BUTTON_EDIT); //$NON-NLS-1$
- editButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); //ViewUtility.createHorizontalFill());
- editButton.addSelectionListener(selectionListener);
-
- // add the Delete button
- //
- //gd = new GridData();
- //gd.horizontalAlignment = gd.FILL;
- //gd.grabExcessHorizontalSpace = true;
-
- deleteButton = new Button(buttonComposite, SWT.NONE);
- deleteButton.setText(XMLUIMessages._UI_BUTTON_DELETE); //$NON-NLS-1$
- deleteButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); //ViewUtility.createHorizontalFill());
- deleteButton.addSelectionListener(selectionListener);
- }
-
- private void createControlArea() {
- if (useGroup) {
- ((Group) commonComposite).setText(tableLabel);
- } else {
- Label label = new Label(commonComposite, SWT.NONE);
- label.setText(tableLabel);
- label.setLayoutData(createGridData(false, 3));
- }
-
- tableViewer = new CommonNamespaceInfoTable(commonComposite, 6, showLocationText);
- tableViewer.getControl().setLayoutData(createGridData(true, 2));
- createButtons(commonComposite);
-
- tableViewer.setInput(namespaceInfoList);
- updateButtonEnabledState();
- ISelectionChangedListener selectionChangedListener = new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- updateButtonEnabledState();
- }
- };
- tableViewer.addSelectionChangedListener(selectionChangedListener);
- }
-
- protected GridData createGridData(boolean both, int span) {
- GridData gd = new GridData(both ? GridData.FILL_BOTH : GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- return gd;
- }
-
- private GridData createHorizontalFill() {
- GridData gd = new GridData();
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = true;
- return gd;
- }
-
-
-
- public NamespaceInfo getNamespaceInfo(String namespace) {
- NamespaceInfo result = null;
- for (Iterator i = namespaceInfoList.iterator(); i.hasNext();) {
- NamespaceInfo info = (NamespaceInfo) i.next();
- if (info.uri != null && info.uri.equals(namespace)) {
- result = info;
- break;
- }
- }
- return result;
- }
-
- protected Object getSelection(ISelection selection) {
- if (selection == null) {
- return null;
- } // end of if ()
-
- Object result = null;
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection es = (IStructuredSelection) selection;
- Iterator i = es.iterator();
- if (i.hasNext()) {
- result = i.next();
- }
- }
- return result;
- }
-
- /*
- * Use the returned Composite to add content above the 'common contents'.
- * Note: The GridData for the returned Composite has a heightHint = 0.
- * This means when using the returned Composite, the GridData must be
- * reset, else the Composite and it's contents will not appear.
- */
- protected Composite getTopComposite() {
- return topComposite;
- }
-
- protected EditNamespaceInfoDialog invokeDialog(String title, NamespaceInfo info) {
- Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
- EditNamespaceInfoDialog dialog = new EditNamespaceInfoDialog(shell, info);
- dialog.create();
- dialog.getShell().setText(title);
- dialog.setBlockOnOpen(true);
- dialog.setResourceLocation(resourceLocation);
- dialog.open();
- return dialog;
- }
-
- protected void performDelayedUpdate() {
- tableViewer.refresh();
- /*
- * Runnable delayedUpdate = new Runnable() { public void run() {
- * tableViewer.refresh(); } };
- * Display.getCurrent().asyncExec(delayedUpdate);
- */
- //if (updateListener != null)
- //{
- // updateListener.updateOccured(this, namespaceInfoList);
- //}
- }
-
- public void performDelete() {
- ISelection selection = tableViewer.getSelection();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- namespaceInfoList.removeAll(structuredSelection.toList());
- updateErrorMessage(namespaceInfoList);
- performDelayedUpdate();
- }
- }
-
- public void performEdit() {
- Object selection = getSelection(tableViewer.getSelection());
- if (selection != null) {
- EditNamespaceInfoDialog dialog = invokeDialog(XMLUIMessages._UI_LABEL_NEW_NAMESPACE_INFORMATION, (NamespaceInfo) selection); //$NON-NLS-1$
- updateErrorMessage(namespaceInfoList);
- performDelayedUpdate();
- }
- }
-
- public void performNew() {
- Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
- CommonAddNamespacesDialog dialog = new CommonAddNamespacesDialog(shell, XMLUIMessages._UI_ADD_NAMESPACE_DECLARATIONS, resourceLocation, namespaceInfoList); //$NON-NLS-1$
- dialog.createAndOpen();
- if (dialog.getReturnCode() == Window.OK) {
- namespaceInfoList.addAll(dialog.getNamespaceInfoList());
- updateErrorMessage(namespaceInfoList);
- performDelayedUpdate();
- }
- }
-
- public void setNamespaceInfoList(List list) {
- namespaceInfoList = list;
- tableViewer.setInput(namespaceInfoList);
- }
-
- public void updateButtonEnabledState() {
- Object selection = getSelection(tableViewer.getSelection());
- NamespaceInfo info = (NamespaceInfo) selection;
- editButton.setEnabled(info != null);
- deleteButton.setEnabled(info != null && info.getProperty("unremovable") == null); //$NON-NLS-1$
- }
-
- public void updateErrorMessage(List namespaceInfoList) {
- NamespaceInfoErrorHelper helper = new NamespaceInfoErrorHelper();
- String errorMessage = helper.computeErrorMessage(namespaceInfoList, null);
- errorMessageLabel.setText(errorMessage != null ? errorMessage : ""); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit/CommonEditNamespacesTargetFieldDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit/CommonEditNamespacesTargetFieldDialog.java
deleted file mode 100644
index bec63f1668..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit/CommonEditNamespacesTargetFieldDialog.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.nsedit;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
-import org.eclipse.wst.xml.ui.dialogs.EditNamespaceInfoDialog;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-/*
- * This class is an extension of CommonEditNamespacesDialog. This class adds
- * the target namespaces dialog field.
- */
-public class CommonEditNamespacesTargetFieldDialog extends CommonEditNamespacesDialog {
-
- class TargetNamespaceModifyListener implements ModifyListener {
- public void modifyText(ModifyEvent e) {
- String oldTargetNamespace = targetNamespace;
- targetNamespace = targetNamespaceField.getText();
- updateTargetNamespaceAndNamespaceInfo(oldTargetNamespace, targetNamespace);
- }
- }
-
- protected String targetNamespace;
- protected Text targetNamespaceField;
-
- public CommonEditNamespacesTargetFieldDialog(Composite parent, IPath resourceLocation) {
- super(parent, resourceLocation, XMLUIMessages._UI_NAMESPACE_DECLARATIONS); //$NON-NLS-1$
-
- Composite targetComp = getTopComposite();
- targetComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- GridData gd = new GridData(GridData.FILL_BOTH);
- Label targetNamespaceLabel = new Label(targetComp, SWT.NONE);
- targetNamespaceLabel.setLayoutData(gd);
- targetNamespaceLabel.setText(XMLUIMessages._UI_TARGET_NAMESPACE); //$NON-NLS-1$
-
- targetNamespaceField = new Text(targetComp, SWT.BORDER);
- targetNamespaceField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- targetNamespaceField.addModifyListener(new TargetNamespaceModifyListener());
-
- // createControlArea();
- }
-
- public String getTargetNamespace() {
- return targetNamespace;
- }
-
- public void performEdit() {
- Object selection = getSelection(tableViewer.getSelection());
- if (selection != null) {
- boolean editTargetNamespace = false;
- NamespaceInfo nsInfo = (NamespaceInfo) selection;
- if (getTargetNamespace().equals(nsInfo.uri)) {
- editTargetNamespace = true;
- }
-
- EditNamespaceInfoDialog dialog = invokeDialog(XMLUIMessages._UI_LABEL_NEW_NAMESPACE_INFORMATION, nsInfo); //$NON-NLS-1$
- updateErrorMessage(namespaceInfoList);
- performDelayedUpdate();
-
- if (editTargetNamespace) {
- targetNamespaceField.setText(nsInfo.uri);
- }
- }
- }
-
- public void setTargetNamespace(String theTargetNamespace) {
- targetNamespace = theTargetNamespace != null ? theTargetNamespace : ""; //$NON-NLS-1$
- targetNamespaceField.setText(targetNamespace);
- //updateTargetNamespaceAndNamespaceInfo(targetNamespace);
- }
-
- private void updateTargetNamespaceAndNamespaceInfo(String oldTargetNamespace, String newTargetNamespace) {
- NamespaceInfo info = getNamespaceInfo(newTargetNamespace);
- if (info == null) {
- info = getNamespaceInfo(oldTargetNamespace);
- if (info == null) {
- info = new NamespaceInfo(newTargetNamespace, "tns", null); //$NON-NLS-1$
- namespaceInfoList.add(info);
- } else {
- info.uri = targetNamespace;
- }
- }
- tableViewer.refresh();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit/CommonNamespaceInfoTable.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit/CommonNamespaceInfoTable.java
deleted file mode 100644
index 594eb75935..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/nsedit/CommonNamespaceInfoTable.java
+++ /dev/null
@@ -1,340 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.nsedit;
-
-import java.util.ArrayList;
-import java.util.List;
-
-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.swt.SWT;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-public class CommonNamespaceInfoTable extends TableViewer {
-
- /**
- * NamespaceInfoTableLabelProvider
- */
- protected class Provider extends LabelProvider implements ITableLabelProvider, IStructuredContentProvider {
- Viewer viewer;
-
- public Image getColumnImage(Object object, int columnIndex) {
- Image result = null;
- int columnCode = getColumnCode(columnIndex);
- if (columnCode == COLUMN_LOCATION_HINT) {
- NamespaceInfo info = (NamespaceInfo) object;
- if (info.locationHint == null || info.locationHint.trim().equals("")) { //$NON-NLS-1$
- // Comment this out until we solve the alignment/(space
- // for image being allocated
- // to prefix column) ......
- // result =
- // XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_WARNING_OBJ);
- }
- }
-
- return result;
- }
-
- public String getColumnText(Object object, int column) {
- NamespaceInfo info = (NamespaceInfo) object;
- String result = null;
- int columnCode = getColumnCode(column);
- switch (columnCode) {
- case COLUMN_PREFIX : {
- result = info.prefix;
- break;
- }
- case COLUMN_NAMESPACE_URI : {
- result = info.uri;
- break;
- }
- case COLUMN_CHECKBOX : {
- result = ""; //info.locationHint; //$NON-NLS-1$
- break;
- }
- case COLUMN_LOCATION_HINT : {
- result = info.locationHint;
- break;
- }
- }
- result = result != null ? result : ""; //$NON-NLS-1$
- if (result.equals("")) { //$NON-NLS-1$
- switch (columnCode) {
- case COLUMN_PREFIX : {
- result = XMLUIMessages._UI_NO_PREFIX; //$NON-NLS-1$
- break;
- }
- case COLUMN_NAMESPACE_URI : {
- result = XMLUIMessages._UI_NO_NAMESPACE_NAME; //$NON-NLS-1$
- break;
- }
- }
- }
- return result;
- }
-
- public Object[] getElements(Object inputElement) {
- List list = (List) viewer.getInput();
- return list != null ? list.toArray() : null;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- this.viewer = viewer;
- }
- }
-
- class TableItemChecker extends MouseAdapter {
- public void mouseDown(MouseEvent e) {
- TableItem item = getTable().getItem(new Point(e.x, e.y));
- if (item != null) {
- Object obj = item.getData();
- if (obj != null) {
- NamespaceInfo info = (NamespaceInfo) obj;
- TableColumn col = getTable().getColumn(0);
- if (e.x < col.getWidth()) // if the point falls within the
- // Select column then perform
- // check/uncheck
- {
- String currentState = (String) info.getProperty("checked"); //$NON-NLS-1$
- System.out.println("currentState" + currentState); //$NON-NLS-1$
- if (currentState == null || currentState.equals("false")) //$NON-NLS-1$
- {
- info.setProperty("checked", "true"); //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- info.setProperty("checked", "false"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- refresh();
- }
- }
- }
- }
- }
-
- protected static final int COLUMN_CHECKBOX = 1;
- protected static final int COLUMN_LOCATION_HINT = 4;
- protected static final int COLUMN_NAMESPACE_URI = 2;
- protected static final int COLUMN_PREFIX = 3;
-
- protected static final String LABEL_CHECKBOX = ""; //$NON-NLS-1$
- protected static final String LABEL_LOCATION_HINT = XMLUIMessages._UI_LABEL_LOCATION_HINT; //$NON-NLS-1$
- protected static final String LABEL_NAMESPACE_URI = XMLUIMessages._UI_LABEL_NAMESPACE_NAME; //$NON-NLS-1$
- protected static final String LABEL_PREFIX = XMLUIMessages._UI_LABEL_PREFIX; //$NON-NLS-1$
- protected List checkedList = new ArrayList();
-
- //protected List namespaceInfoList = new ArrayList();
- protected int[] columnIndexMap;
- protected boolean showCheckBoxes = true;
- private boolean showLocationText = false;
-
- private Table table;
- protected int visibleRows = -1;
-
- public CommonNamespaceInfoTable(Composite parent, int visibleRows) {
- this(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER, visibleRows, false);
- }
-
- //protected CellEditor getCellEditor(int column)
- // {
- // return (column == COLUMN_CHECKBOX) ? checkBoxCellEditor :
- // textCellEditor;
- // }
-
- public CommonNamespaceInfoTable(Composite parent, int visibleRows, boolean showLocationText) {
- this(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER, visibleRows, showLocationText);
- }
-
- public CommonNamespaceInfoTable(Composite parent, int style, int visibleRows) {
- this(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER | style, visibleRows, false);
- }
-
- public CommonNamespaceInfoTable(Composite parent, int style, int visibleRows, boolean showLocationText) {
- super(new Table(parent, style));
- getTable().setLinesVisible(true);
- this.showCheckBoxes = (style & SWT.CHECK) != 0;
- columnIndexMap = createColumnIndexMap();
- this.showLocationText = showLocationText;
-
- Provider provider = new Provider();
- setContentProvider(provider);
- setLabelProvider(provider);
-
- String[] columnPropertiesArray = createColumnPropertiesArray();
- setColumnProperties(columnPropertiesArray);
-
- table = getTable();
- table.setHeaderVisible(true);
- table.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- TableLayout layout = new TableLayout();
-
- for (int i = 0; i < columnPropertiesArray.length; i++) {
- TableColumn column = new TableColumn(table, i);
- if ((columnPropertiesArray[i]).equals(LABEL_LOCATION_HINT)) {
- if (showLocationText) {
- column.setText(columnPropertiesArray[i]);
- } else {
- // Comment this out until we solve the alignment/(space
- // for image being allocated
- // to prefix column) ......
- // column.setImage(XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TXTEXT));
- }
- } else {
- column.setText(columnPropertiesArray[i]);
- }
- column.setAlignment(SWT.LEFT);
- layout.addColumnData(new ColumnWeightData(getColumnWidth(i), true));
- }
- table.setLayout(layout);
-
- this.visibleRows = visibleRows;
- //for (int i = 0; i < visibleRows; i++)
- // {
- // TableItem item = new TableItem(table, SWT.NONE);
- // item.setText("#######");
- //}
- //checkBoxCellEditor = new NamespaceInfoCheckboxCellEditor(table);
- //textCellEditor = new TextCellEditor(table);
-
- /*
- * CellEditor[] cellEditors = new
- * CellEditor[columnPropertiesArray.length]; for (int i = 0; i <
- * columnPropertiesArray.length; i++) { cellEditors[i] =
- * getCellEditor(i); } setCellEditors(cellEditors);
- */
- //if (showCheckBoxes)
- //{
- // getTable().addMouseListener(new TableItemChecker());
- //}
- }
-
- //protected CellEditor checkBoxCellEditor;
- //protected CellEditor textCellEditor;
-
- protected int[] createColumnIndexMap() {
- int[] result = new int[showCheckBoxes ? 4 : 3];
- int i = 0;
- if (showCheckBoxes) {
- result[i++] = COLUMN_CHECKBOX;
- }
- result[i++] = COLUMN_PREFIX;
- result[i++] = COLUMN_NAMESPACE_URI;
- if (!showCheckBoxes) {
- result[i++] = COLUMN_LOCATION_HINT;
- }
- return result;
- }
-
- protected String[] createColumnPropertiesArray() {
- String[] result = new String[3];
- int i = 0;
- if (showCheckBoxes) {
- result[i++] = LABEL_CHECKBOX;
- }
- result[i++] = LABEL_PREFIX;
- result[i++] = LABEL_NAMESPACE_URI;
- if (!showCheckBoxes) {
- result[i++] = LABEL_LOCATION_HINT;
- }
- return result;
- }
-
- protected int getColumnCode(int column) {
- int result = 0;
- if (column < columnIndexMap.length) {
- result = columnIndexMap[column];
- }
- return result;
- }
-
- protected int getColumnWidth(int column) {
- int result = 0;
- switch (getColumnCode(column)) {
- case COLUMN_PREFIX : {
- result = 5;
- break;
- }
- case COLUMN_NAMESPACE_URI : {
- // Size columns differently when location hint text label is
- // displayed
- if (showLocationText) {
- result = 10;
- } else {
- result = 20;
- }
- break;
- }
- case COLUMN_CHECKBOX : {
- result = 1; //info.locationHint;
- break;
- }
- case COLUMN_LOCATION_HINT : {
- // Size columns differently when location hint text label is
- // displayed
- if (showLocationText) {
- result = 10;
- } else {
- result = 2;
- }
- break;
- }
- }
- return result;
- }
- /*
- * protected class NamespaceInfoCellModifier implements ICellModifier {
- * public NamespaceInfoCellModifier() { }
- *
- * public boolean canModify(Object element, String property) { if
- * (property.equals(LABEL_CHECKBOX)) { return true; } else if
- * (property.equals(LABEL_PREFIX)) { return true; } return false; }
- *
- * public Object getValue(Object element, String property) { int column =
- * 0; if (property.equals(LABEL_CHECKBOX)) { column = 0; } else if
- * (property.equals(LABEL_PREFIX)) { column = 1; } else if
- * (property.equals(LABEL_NAMESPACE_URI)) { column = 2; }
- *
- * //if (element instanceof TableElement) //{ // return
- * provider.getColumnText(element, column); //} //else //{ // return null; // }
- * return "hello"; }
- *
- * public void modify(Object element, String property, Object value) { } }
- *
- * protected class NamespaceInfoCheckboxCellEditor extends
- * CheckboxCellEditor implements MouseListener { public
- * NamespaceInfoCheckboxCellEditor(Composite parent) { super(parent); }
- *
- * protected void doSetValue(Object value) { }
- *
- * public void activate() { super.activate(); deactivate();
- * Display.getCurrent().getFocusControl().redraw(); }
- *
- * public void mouseDown(MouseEvent e) { if (getTable().getItem(new
- * Point(e.x, e.y)) != null) { } } public void mouseDoubleClick(MouseEvent
- * e) { } public void mouseUp(MouseEvent e) { } }
- */
-}

Back to the top