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:
authornsandonato2010-10-29 18:38:45 +0000
committernsandonato2010-10-29 18:38:45 +0000
commite3f46e30d5f8592d5f2ab349a4336fcc39a811bc (patch)
tree83b66d500b460ff78c971a4b8605597aaf52fe81 /bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui
parent99e6688f60783e473c3ed90958105dea1f5e312b (diff)
downloadwebtools.sourceediting-e3f46e30d5f8592d5f2ab349a4336fcc39a811bc.tar.gz
webtools.sourceediting-e3f46e30d5f8592d5f2ab349a4336fcc39a811bc.tar.xz
webtools.sourceediting-e3f46e30d5f8592d5f2ab349a4336fcc39a811bc.zip
[303379] Allow other multi page editors to reuse the XML grammar & dependencies tool bar contributions.
Diffstat (limited to 'bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui')
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorTester.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorTester.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorTester.java
new file mode 100644
index 0000000000..269dc42ab3
--- /dev/null
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorTester.java
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.wst.xml.ui.internal.editor;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+/**
+ * A property tester that determines if the editor part is or contains (in the case of a {@link org.eclipse.ui.part.MultiPageEditorPart}) the XML editor.
+ *
+ */
+public class XMLEditorTester extends PropertyTester {
+
+ private static final String PROPERTY = "editor"; //$NON-NLS-1$
+
+ /** The XML editor's part ID */
+ private static final String EDITOR_ID = "org.eclipse.core.runtime.xml.source"; //$NON-NLS-1$
+
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if (receiver instanceof IEditorPart && PROPERTY.equals(property)) {
+ ITextEditor editor = null;
+ if (receiver instanceof ITextEditor)
+ editor = (ITextEditor) receiver;
+ else
+ editor = (ITextEditor) ((IEditorPart) receiver).getAdapter(ITextEditor.class);
+ if (editor != null) {
+ IEditorSite site = editor.getEditorSite();
+ if (site != null) {
+ return EDITOR_ID.equals(site.getId());
+ }
+ }
+ }
+ return false;
+ }
+
+}

Back to the top