Author: scabanovich
Date: 2007-08-15 06:04:18 -0400 (Wed, 15 Aug 2007)
New Revision: 3136
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editor/XMLContentDescriber.java
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/plugin.xml
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/composite/TagAttributesComposite.java
Log:
JBIDE-644
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/plugin.xml
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/plugin.xml 2007-08-15 09:27:38
UTC (rev 3135)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/plugin.xml 2007-08-15 10:04:18
UTC (rev 3136)
@@ -22,13 +22,14 @@
class="org.jboss.tools.common.model.ui.editor.EditorPartWrapper"
contributorClass="org.jboss.tools.common.editor.EditorActionBarContributorWrapper"
default="true"
- extensions="xml, meta"
icon="images/xstudio/editors/xml.gif"
id="org.jboss.tools.common.model.ui.editor.EditorPartWrapper"
matchingStrategy =
"org.jboss.tools.common.core.resources.MatchingStrategyImpl"
name="%editors.xml.advanced.name">
- <contentTypeBinding
contentTypeId="org.eclipse.core.runtime.xml"/>
- <contentTypeBinding
contentTypeId="org.eclipse.wst.xml.core.xmlsource"/>
+ <contentTypeBinding
contentTypeId="org.eclipse.jst.j2ee.webDD"/>
+ <contentTypeBinding
contentTypeId="org.jboss.tools.common.model.ui.xml"/>
+ <contentTypeBinding
contentTypeId="org.eclipse.jst.jsf.facesconfig.facesConfigFile"/>
+
</editor>
</extension>
<extension point="org.jboss.tools.common.model.ui.attributeEditor">
@@ -272,6 +273,24 @@
name="%editors.properties.name">
</editor>
</extension>
+
+ <extension point="org.eclipse.core.runtime.contentTypes">
+ <content-type id="xml"
+ name="Red Hat XML"
+ base-type="org.eclipse.core.runtime.xml"
+ describer="org.jboss.tools.common.model.ui.editor.XMLContentDescriber"
+ file-extensions="xml,meta"
+ priority="high"
+ />
+ <content-type id="xml2"
+ name="A Red Hat XML 2"
+ base-type="org.eclipse.jst.j2ee.webDD"
+ describer="org.jboss.tools.common.model.ui.editor.XMLContentDescriber"
+ file-extensions="xml"
+ priority="high"
+ />
+ </extension>
+
<extension id="e" name="XML Editors"
point="org.jboss.tools.common.model.ui.xmlEditor">
<!--
class="org.jboss.tools.common.model.ui.texteditors.xmleditor.XMLTextEditor"
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editor/XMLContentDescriber.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editor/XMLContentDescriber.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editor/XMLContentDescriber.java 2007-08-15
10:04:18 UTC (rev 3136)
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.model.ui.editor;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+
+import org.eclipse.core.runtime.content.IContentDescription;
+import org.eclipse.core.runtime.content.ITextContentDescriber;
+import org.jboss.tools.common.CommonPlugin;
+import org.jboss.tools.common.model.options.PreferenceModelUtilities;
+import org.jboss.tools.common.util.FileUtil;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class XMLContentDescriber extends
org.eclipse.core.internal.content.XMLContentDescriber implements ITextContentDescriber {
+
+ public int describe(InputStream contents, IContentDescription description) throws
IOException {
+ super.describe(contents, description);
+ contents.reset();
+ String text = FileUtil.readStream(contents);
+ return describe(text, description);
+ }
+
+ public int describe(Reader contents, IContentDescription description) throws IOException
{
+ super.describe(contents, description);
+ contents.reset();
+ String text = read(contents);
+ return describe(text, description);
+ }
+
+ private int describe(String text, IContentDescription description) {
+ String entity =
PreferenceModelUtilities.getPreferenceModel().getEntityRecognizer().getEntityName("xml",
text);
+ if(entity == null || entity.length() == 0 || entity.equals("FileXML")) {
+ return INDETERMINATE;
+ }
+ return VALID;
+ }
+
+ static String read(Reader is) {
+ StringBuffer sb = new StringBuffer("");
+ try {
+ char[] b = new char[4096];
+ while(true) {
+ int l = is.read(b, 0, b.length);
+ if(l < 0) break;
+ sb.append(new String(b, 0, l));
+ }
+ is.close();
+ } catch (Exception e) {
+ CommonPlugin.getPluginLog().logError(e);
+ }
+ return sb.toString();
+ }
+
+}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/composite/TagAttributesComposite.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/composite/TagAttributesComposite.java 2007-08-15
09:27:38 UTC (rev 3135)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/composite/TagAttributesComposite.java 2007-08-15
10:04:18 UTC (rev 3136)
@@ -207,7 +207,19 @@
col.setText("Value");
tableViewer.setColumnProperties(new String[] {"Name","Value"});
+ tableViewer.setUseHashlookup(true);
+ tableViewer.setComparer(new IElementComparer() {
+ public boolean equals(Object a, Object b) {
+ return a == b;
+ }
+
+ public int hashCode(Object element) {
+ return element == null ? 0 : element.hashCode();
+ }
+
+ });
+
tableViewer.setCellModifier(
new ICellModifier(){