【问题标题】:How to give PHP nature to a eclipse plugin如何赋予 Eclipse 插件 PHP 特性
【发布时间】:2015-05-07 08:12:21
【问题描述】:

我已经为自定义框架创建了一个插件,我需要给它一个 php 特性,以便开发人员在使用这个插件进行开发时可以使用 php 的功能。目前我正在使用自定义性质。但我不知道如何切换到php性质。我的 plugin.xml 看起来像这样。

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension
         point="org.eclipse.ui.newWizards">
      <category
            id="rudraxplugin.category.wizards"
            name="%category.name">
      </category>
      <wizard
            category="rudraxplugin.category.wizards"
            class="rudraxplugin.wizards.CustomProjectNewWizard"
            finalPerspective="rudraxplugin.perspective"
            id="rudraxplugin.wizard.new.custom"
            name="%wizard.name">
      </wizard>
   </extension>
   <extension
         point="org.eclipse.ui.views">
      <view
            class="org.eclipse.ui.navigator.CommonNavigator"
            icon="icons/sample.gif"
            id="rudraxplugin.navigator"
            name="%view.name">
      </view>
   </extension>
   <extension
         point="org.eclipse.ui.navigator.viewer">
      <viewerActionBinding
            viewerId="rudraxplugin.navigator">
         <includes>
            <actionExtension
                  pattern="org.eclipse.ui.navigator.resources.*">
            </actionExtension>
         </includes>
      </viewerActionBinding>
      <viewerContentBinding
            viewerId="rudraxplugin.navigator">
         <includes>
            <contentExtension
                  pattern="org.eclipse.ui.navigator.resourceContent">
            </contentExtension>
            <contentExtension
                  pattern="org.eclipse.ui.navigator.resources.filters.*">
            </contentExtension>
            <contentExtension
                  pattern="org.eclipse.ui.navigator.resources.linkHelper">
            </contentExtension>
            <contentExtension
                  pattern="org.eclipse.ui.navigator.resources.workingSets">
            </contentExtension>
         </includes>
      </viewerContentBinding>
   </extension>
   <extension
         point="org.eclipse.ui.perspectives">
      <perspective
            class="rudraxplugin.perspectives.Perspective"
            id="rudraxplugin.perspective"
            name="%perspective.name">
      </perspective>
   </extension>
   <extension
         point="org.eclipse.ui.perspectiveExtensions">
      <perspectiveExtension
            targetID="rudraxplugin.perspective">
         <view
               id="rudraxplugin.navigator"
               minimized="false"
               ratio="0.25"
               relationship="left"
               relative="org.eclipse.ui.editorss">
         </view>
      </perspectiveExtension>
   </extension>
   <extension
         id="rudraxplugin.projectNature"
         point="org.eclipse.core.resources.natures">
      <runtime>
         <run
               class="rudraxplugin.natures.ProjectNature">
         </run>
      </runtime>
   </extension>

</plugin>

我也使用本教程完成了开发过程。

https://cvalcarcel.wordpress.com/2009/07/08/

任何帮助将不胜感激。

【问题讨论】:

    标签: php eclipse-plugin eclipse-pde


    【解决方案1】:

    使用以下代码为项目添加性质:

    IProject project = .... get the project you want to modify
    
    IProjectDescription description = project.getDescription();
    
    String [] natures = description.getNatureIds();
    
    String [] newNatures = new String[natures.length + 1];
    
    System.arraycopy(natures, 0, newNatures, 0, natures.length);
    
    newNatures[natures.length] = "org.eclipse.php.core.PHPNature";
    
    description.setNatureIds(newNatures);
    
    project.setDescription(description, null);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-15
      • 1970-01-01
      • 2012-08-03
      • 1970-01-01
      • 2023-03-23
      • 1970-01-01
      • 1970-01-01
      • 2012-12-03
      相关资源
      最近更新 更多