dbeaver 创建资源管理

 

 

类似这样,创建一个自定义的资源文件管理,需要按以下步骤创建:

1. 在plugin.xml中创建文档类型

 

 其中base-type属性可不填,示例代码如下:  https://alvinalexander.com/java/jwarehouse/eclipse/org.eclipse.core.tests.runtime/plugin.xml.shtml

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin>

     <extension
         id="test-preferences"
         name="test-preferences"
         point="org.eclipse.core.runtime.preferences">
      <scope
            name="test"
            class="org.eclipse.core.tests.internal.preferences.TestScope"/>
   </extension>
   <extension
         point="org.eclipse.core.runtime.contentTypes">      
      <content-type      
            name="My Content Type"
            id="myContent"
            file-names=" myContent.mc1 , myContent.mc2 "
            file-extensions=" myContent1, myContent2 "
            describer="org.eclipse.core.tests.runtime.content.MyContentDescriber"/>
      <!-- content types for content/name matching tests -->
      <content-type
            name="BinaryBase"
            id="binary_base"
            file-extensions="mybinary">
         <describer
            class="org.eclipse.core.runtime.content.BinarySignatureDescriber">
            <parameter name="signature" value="0A, 0B"/>
            <parameter name="required" value="false"/>            
         </describer>
      </content-type>
      <content-type                  
            name="BinaryDerived1"
            id="binary_derived1"
            file-names="foo.mybinary"
            file-extensions="mybinary"
            base-type="binary_base">            
         <describer
            class="org.eclipse.core.runtime.content.BinarySignatureDescriber">
            <parameter name="signature" value="0A, 0B, 0C"/>
            <parameter name="required" value="false"/>
         </describer>
      </content-type>
      <content-type                  
            name="BinaryDerived2"
            id="binary_derived2"
            base-type="binary_base">
         <describer
            class="org.eclipse.core.runtime.content.BinarySignatureDescriber">
            <parameter name="signature" value="0A, 0B, 0D"/>
            <parameter name="required" value="false"/>
         </describer>
      </content-type>            
      <!-- A base type and a sub-type are in conflict. Sub type should be picked. --> 
      <content-type      
            file-extensions="conflict1"
            name="Conflict 1"
            id="base_conflict1"/>         
      <content-type      
            base-type="base_conflict1"     
            name="Specialized Conflict 1"
            id="sub_conflict1"/>
      <!-- 
          A base type and a sub-type (that restates file-spec) are in conflict. 
          Base type still should be picked. 
      -->
      <content-type      
            file-extensions="conflict2"
            name="Conflict 2"
            id="base_conflict2"/>         
      <content-type      
            base-type="base_conflict2"         
            file-extensions="conflict2"
            name="Specialized Conflict 2"
            id="sub_conflict2"/>
      <!-- 
          Two unrelated types (sub_conflict3 and unrelated conflict3) are in conflict. 
          Order will be arbitrary.
          -->
      <content-type                    
            id="base_conflict3"                  
            file-extensions="base_conflict3"
            name="Conflict 3"/>
      <content-type
            id="sub_conflict3"      
            base-type="base_conflict3"         
            file-extensions="conflict3"
            name="Deeper Conflict 3"/>
      <content-type
            id="unrelated_conflict3"      
            file-extensions="conflict3"
            name="Unrelated Conflict 3"/>                                              
      <!-- end of conflict-related content types -->
      <content-type
            file-extensions="tzt"
            name="My Text"
            id="mytext">
            <property name="property1" default="value1"/>
            <!-- declares property for documentation purposes only -->
            <property name="property2"/>            
            <property name="property3" default="value3"/>
            <!-- overrides (non-local) parent property definition -->
            <property name="org.eclipse.core.runtime.charset" default="BAR"/>
      </content-type>
      <content-type
              base-type="mytext"
            file-extensions="tzt1"
            name="My Text1"
            id="mytext1">
            <!-- overrides parent property definition by assigning a default value -->
            <property name="property2" default="value2"/>
            <!-- overrides parent property definition by clearing the default value -->
            <property name="property3"/>
            <property name="property4" default="value4"/>
      </content-type>
      <!-- overrides parent charset definition by clearing the default value -->                              
      <!-- Here we really want to use the deprecated way for defining charsets. -->      
      <content-type
              base-type="mytext"      
            file-extensions="tzt2"
            default-charset=""
            name="My Text2"
            id="mytext2">
            <property name="property1"/>
            <property name="property2"/>
            <property name="property3"/>
            <property name="property4"/>
            <!-- Use a local property name clashing with an inherited one -->
            <property name="charset" default="mytext2"/>
      </content-type>
      <content-type
            file-names="foo.bar"
            file-extensions="bar"
            name="Foo Bar"
            id="fooBar"/>
      <content-type
            base-type="fooBar"
            name="Sub Foo Bar"
            id="subFooBar"/>
      <content-type
            file-extensions="xml2"
            base-type="org.eclipse.core.runtime.xml"
            name="XML Based with Different Extension"
            id="xml-based-different-extension">
      </content-type>
      <content-type
            file-names="xml-based.xml"
            base-type="org.eclipse.core.runtime.xml"
            name="XML Based with Specific Name"
            id="xml-based-specific-name"/>
      <content-type
            file-extensions="samplebin1"
            name="Sample Binary 1"
            id="sample-binary1">
         <describer
            class="org.eclipse.core.runtime.content.BinarySignatureDescriber">
            <parameter name="signature" value="10, AB, CD, FF"/>
            <parameter name="offset" value="5"/>                           
         </describer>
      </content-type>
      <content-type
            file-extensions="samplebin2"
            name="Sample Binary 2"
            id="sample-binary2">
         <describer
            class="org.eclipse.core.runtime.content.BinarySignatureDescriber">
            <parameter name="signature" value="10, AB, CD, EF"/>   
         </describer>
      </content-type>            
      <content-type
            file-extensions="class"
            name="Java Class file"
            id="javaClass">
         <describer
            class="org.eclipse.core.runtime.content.BinarySignatureDescriber">
            <parameter name="signature" value="CA, FE, BA, BE"/>   
         </describer>
      </content-type>            
      
      <!-- content types for association tests -->
      <content-type
            id="assoc1" 
            name="Association Test 1"
            base-type="org.eclipse.core.runtime.text"
            describer="org.eclipse.core.tests.runtime.content.NaySayerContentDescriber"/>
      <content-type
            id="assoc2" 
            name="Association Test 2"
            base-type="org.eclipse.core.runtime.text"
            file-extensions="txt_assoc2builtin"            
            describer="org.eclipse.core.tests.runtime.content.NaySayerContentDescriber"/>
      <file-association
            file-extensions="txt_assoc1pluginadded"
            content-type="org.eclipse.core.tests.runtime.assoc1"/>
      <file-association
            file-extensions="txt_assoc2pluginadded"
            content-type="org.eclipse.core.tests.runtime.assoc2"/>
      <file-association
            file-extensions="txt_pluginadded"
            content-type="org.eclipse.core.runtime.text"/>            
            
      <!-- content types for orphan tests -->            
      <content-type
            file-names="foo.orphan"
            file-extensions="orphan"
            base-type="org.eclipse.bundle01.missing"
            name="Orphan Type"
            id="orphan"/>
      <file-association
            file-extensions="orphan2"
            content-type="org.eclipse.bundle01.missing"/>
      <!-- content types for alias tests -->                        
      <content-type 
              id="alias"
            name="Alias Type"
              file-extensions="missing-target"
              alias-for="org.eclipse.bundle02.missing-target"/>
      <content-type 
              id="derived-from-alias"              
            name="Derived from Alias Type"              
              base-type="alias"/>
      <!-- content types for content describer tests -->
      <content-type
            base-type="org.eclipse.core.runtime.xml"
            name="Root Element"
            id="root-element"
            describer="org.eclipse.core.runtime.content.XMLRootElementContentDescriber:org.eclipse.core.runtime.tests.root-element"/>
      <content-type
            base-type="org.eclipse.core.runtime.xml"
            name="Root Element in namespace"
            id="ns-root-element">
         <describer
               class="org.eclipse.core.runtime.content.XMLRootElementContentDescriber2">
            <parameter name="element" value="{urn:eclipse.core.runtime.ns1}rootElement1"/>
            <parameter name="element" value="{urn:eclipse.core.runtime.ns2}rootElement2"/>
         </describer>
      </content-type>      
      <content-type
            base-type="org.eclipse.core.runtime.xml"
            name="Wildcard element in namespace"
            id="ns-wildcard">
         <describer
               class="org.eclipse.core.runtime.content.XMLRootElementContentDescriber2">
            <parameter name="element" value="*/org.eclipse.core.runtime.tests.some.dtd3"/>
            <parameter name="element" value="{urn:eclipse.core.runtime.nsWild}*"/>
         </describer>
      </content-type>
      <content-type
            base-type="org.eclipse.core.runtime.xml"
            id="empty-ns-root-element"
            name="Root Element in empty namespace">
         <describer
               class="org.eclipse.core.runtime.content.XMLRootElementContentDescriber2">
            <parameter
                  name="element"
                  value="{}rootElement">
            </parameter>
         </describer>
      </content-type>
      <content-type
            base-type="org.eclipse.core.runtime.xml"
            name="DTD"
            id="dtd">
         <describer
               class="org.eclipse.core.runtime.content.XMLRootElementContentDescriber">
            <parameter name="dtd" value="org.eclipse.core.runtime.tests.some.dtd"/>
         </describer>
      </content-type>      
      <!-- this content type is used by the content description tests -->
      <content-type
            name="Void content type"
            id="void"/>      
      <content-type
            base-type="org.eclipse.core.runtime.xml"
            file-extensions="xml2"
            id="xml-based-different-extension-low-priority"
            name="XML Based with Different Extension and Low Priority"
            priority="low">
      </content-type>
   </extension>
   <extension
         point="org.eclipse.core.runtime.adapters">
      <factory
            class="org.eclipse.core.tests.runtime.TestAdapterFactory"
            adaptableType="org.eclipse.core.tests.runtime.TestAdaptable">
         <adapter
               type="org.eclipse.core.tests.runtime.TestAdapter">
         </adapter>
      </factory>
   </extension>
   <extension-point id="factoryLoaderTest" name="factoryLoaderTest" schema="schema/factoryLoaderTest.exsd"/>
   <extension point="org.eclipse.core.runtime.adapters">
      <factory class="org.eclipse.core.tests.runtime.TestAdapterFactoryLoader" 
         adaptableType="org.eclipse.core.tests.runtime.TestAdaptable">
         <adapter type="testAdapter.testUnknown"/>
      </factory>
   </extension>
</plugin>

2. 定义资源处理类 org.jkiss.dbeaver.ui.controls.querylog.SQLiteHandlerImpl  这个类自己创建

 

 其中id属性不可缺省,否则程序运行会NPE

 

 

 需要注意的是: 操作文件时进入不同的handler 是会根据文件的后缀名判断。

 

posted @ 2020-05-14 14:35  margo  阅读(256)  评论(0编辑  收藏  举报