1 2 3 4 5 6 7 | <extension point="org.eclipse.ui.propertyPages"> <page id="XMProjectProperties" name="XM Properties" objectClass="org.eclipse.core.resources.IProject" class="org.ananas.xm.eclipse.XMProjectPropertiesPage"> </page> </extension> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | public Control createContents(Composite parent) { Control control = buildUI(parent); try { IAdaptable adaptable = getElement(); if(adaptable instanceof IProject) { properties = new ProjectProperties((IProject)adaptable); readProperties(); } } catch(CoreException x) { ErrorDialog.openError( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Resources.getString("eclipse.dialogtitle"), Resources.getString("eclipse.propertyerror"), PluginTools.makeStatus(x)); } return control; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | package org.ananas.xm.eclipse; import org.eclipse.core.runtime.*; import org.eclipse.core.resources.*; public class XMProjectNature implements IProjectNature, PluginConstants { private IProject project; public void configure() throws CoreException { IProjectDescription description = project.getDescription(); if(!hasBuildSpec(description.getBuildSpec())) { ICommand[] old = description.getBuildSpec(), specs = new ICommand[old.length + 1]; System.arraycopy(old,0,specs,0,old.length); ICommand command = description.newCommand(); command.setBuilderName(BUILDER_ID); specs[old.length] = command; description.setBuildSpec(specs); project.setDescription(description,new NullProgressMonitor()); } } public void deconfigure() throws CoreException { IProjectDescription description = project.getDescription(); int count = getBuildSpecCount(description.getBuildSpec()); if(count != 0) { ICommand[] old = description.getBuildSpec(), specs = new ICommand[old.length - count]; int i = 0, j = 0; while(i < old.length) { if(!old.getBuilderName().equals(BUILDER_ID)) specs = old[j++]; i++; } description.setBuildSpec(specs); project.setDescription(description,new NullProgressMonitor()); } } public IProject getProject() { return project; } public void setProject(IProject project) { this.project = project; } private boolean hasBuildSpec(ICommand[] commands) { return getBuildSpecCount(commands) != 0; } private int getBuildSpecCount(ICommand[] commands) { int count = 0; for(int i = 0;i < commands.length;i++) if(commands.getBuilderName().equals(BUILDER_ID)) count++; return count; } } |
1 2 3 4 5 6 7 | <extension point="org.eclipse.core.resources.natures" id="xmnature" name="XM Nature"> <runtime> <run class="org.ananas.xm.eclipse.XMProjectNature"/> </runtime> </extension> |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |