provide basic information about the open document in the properties view
https://bugs.eclipse.org/bugs/show_bug.cgi?id=385150
Signed-off-by: Florian Thienel <florian@thienel.org>
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/VexEditor.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/VexEditor.java
index 287b54f..c3a8e4c 100644
--- a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/VexEditor.java
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/editor/VexEditor.java
@@ -86,6 +86,7 @@
import org.eclipse.vex.ui.internal.handlers.ConvertElementHandler;
import org.eclipse.vex.ui.internal.handlers.RemoveTagHandler;
import org.eclipse.vex.ui.internal.outline.DocumentOutlinePage;
+import org.eclipse.vex.ui.internal.property.DocumentPropertySource;
import org.eclipse.vex.ui.internal.property.ElementPropertySource;
import org.eclipse.vex.ui.internal.swt.VexWidget;
import org.xml.sax.InputSource;
@@ -750,26 +751,25 @@
@Override
public Object getAdapter(@SuppressWarnings("rawtypes") final Class adapter) {
-
if (adapter == IContentOutlinePage.class) {
return new DocumentOutlinePage();
} else if (adapter == IPropertySheetPage.class) {
-
final PropertySheetPage page = new PropertySheetPage();
page.setPropertySourceProvider(new IPropertySourceProvider() {
public IPropertySource getPropertySource(final Object object) {
if (object instanceof Element) {
- final IStructuredSelection sel = (IStructuredSelection) vexWidget.getSelection();
- final boolean multi = sel != null && sel.size() > 1;
+ final IStructuredSelection selection = (IStructuredSelection) vexWidget.getSelection();
+ final boolean multipleElementsSelected = selection != null && selection.size() > 1;
final Validator validator = vexWidget.getDocument().getValidator();
- return new ElementPropertySource((Element) object, validator, multi);
- } else {
- return null;
+ return new ElementPropertySource((Element) object, validator, multipleElementsSelected);
}
+ if (object instanceof Document) {
+ return new DocumentPropertySource((Document) object);
+ }
+ return null;
}
});
return page;
-
} else if (adapter == IFindReplaceTarget.class) {
return new AbstractRegExFindReplaceTarget() {
diff --git a/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/property/DocumentPropertySource.java b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/property/DocumentPropertySource.java
new file mode 100644
index 0000000..e51c875
--- /dev/null
+++ b/org.eclipse.vex.ui/src/org/eclipse/vex/ui/internal/property/DocumentPropertySource.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Florian Thienel 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:
+ * Florian Thienel - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.vex.ui.internal.property;
+
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource2;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+import org.eclipse.vex.core.internal.dom.Document;
+
+/**
+ * @author Florian Thienel
+ */
+public class DocumentPropertySource implements IPropertySource2 {
+
+ private static final String SYSTEM_ID = "systemId";
+ private static final String PUBLIC_ID = "systemId";
+ private static final String DOCUMENT_URI = "documentUri";
+ private static final String ENCODING = "encoding";
+
+ private final Document document;
+
+ public DocumentPropertySource(final Document document) {
+ this.document = document;
+ }
+
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ return new IPropertyDescriptor[] { new PropertyDescriptor(SYSTEM_ID, "System Identifier"), new PropertyDescriptor(PUBLIC_ID, "Public Identifier"),
+ new PropertyDescriptor(DOCUMENT_URI, "Document URI"), new PropertyDescriptor(ENCODING, "Encoding") };
+ }
+
+ public Object getPropertyValue(final Object id) {
+ if (id == SYSTEM_ID) {
+ return document.getSystemID();
+ }
+ if (id == PUBLIC_ID) {
+ return document.getPublicID();
+ }
+ if (id == DOCUMENT_URI) {
+ return document.getDocumentURI();
+ }
+ if (id == ENCODING) {
+ return document.getEncoding();
+ }
+ return null;
+ }
+
+ public boolean isPropertySet(final Object id) {
+ return false;
+ }
+
+ public Object getEditableValue() {
+ // this property source is read-only
+ return null;
+ }
+
+ public void resetPropertyValue(final Object id) {
+ // this property source is read-only
+ }
+
+ public void setPropertyValue(final Object id, final Object value) {
+ // this property source is read-only
+ }
+
+ public boolean isPropertyResettable(final Object id) {
+ return false;
+ }
+
+}