58,454
社区成员
发帖
与我相关
我的任务
分享
<plugin>
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
adaptable="true"
id="resources"
objectClass="org.eclipse.core.resources.IProject">
<action
class="solonote.example.popupmenu.ActionLoader"
id="solonote.example.popupMenu.loadaction"
menubarPath="additions"
enablesFor="1"
label="导入资源">
</action>
<visibility>
<objectState
name="projectNature"
value="org.eclipse.jdt.core.javanature">
</objectState>
</visibility>
</objectContribution>
</extension>
</plugin>
public class ActionLoader implements IObjectActionDelegate {
private IProject selectProject = null;
public ActionLoader(){
super();
}
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
// TODO Auto-generated method stub
}
public void run(IAction action) {
// TODO Auto-generated method stub
File f = new File("导入资源");
try {
selectProject.refreshLocal(IProject.DEPTH_INFINITE,null);
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void selectionChanged(IAction action, ISelection selection) {
// TODO Auto-generated method stub
if (selection instanceof StructuredSelection) {
StructuredSelection structSelection = (StructuredSelection) selection;
Object object = structSelection.getFirstElement();
if(object instanceof IProject){
selectProject = (IProject)object;
}
}
}
}