douzhuan1467 2015-05-07 08:12
浏览 72
已采纳

如何将PHP性质赋予eclipse插件

I have created a plugin for a Custom framework , i need to give it a php nature so that while developing using this plugin the developer can use the features of php. Currently i am using custom nature. But i do not know how to switch to a php nature. My plugin.xml looks like this.

<?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>

Also i have used this tutorial to go through the development process.

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

Any help will be appreciated.

  • 写回答

1条回答 默认 最新

  • down2323 2015-05-07 08:32
    关注

    Use the following code to add a nature to a project:

    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);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘