facebook

create project, folder and file

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #224840 Reply

    husniteja
    Member

    dear all

    I am working with eclipse 3.00 and with the simple “helloworld” plugin, i want to create project, folder and file using workspace API. So i add some code in the helloworld class :

    
    package hus.lit.khan.helloworld.actions;
    
    import org.eclipse.jface.action.IAction;
    import org.eclipse.jface.viewers.ISelection;
    import org.eclipse.ui.IStartup;
    ....
    
    
    public class SampleAction implements IWorkbenchWindowActionDelegate, IStartup{
        private IWorkbenchWindow window;
        /**
         * The constructor.
         */
        public SampleAction() {
        }
    
    
        public void run(IAction action) {
    
    
            createProject();
            
                
        }
    
    
        public void selectionChanged(IAction action, ISelection selection) {
        }
    
        public void dispose() {
        }
    
    
        public void init(IWorkbenchWindow window) {
            this.window = window;
        }
    ....    
            
    private void createProject(){
            IWorkspace workspace = ResourcesPlugin.getWorkspace();
            IWorkspaceRoot root = workspace.getRoot();
            IProject newProjectHandle = root.getProject("test");
            IPath targetPath = new Path("C:/eclipse-SDK-3.0-win32/eclipse/workspace/"+newProjectHandle.getName());
            final IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
            description.setLocation(targetPath);
            try{
                newProjectHandle.create(description, null);
                newProjectHandle.open(null);
            }catch (CoreException e){
                
            }
        }
    
        public void earlyStartup() {
            // TODO Auto-generated method stub
            
        }
    }
    
    
    

    I just add the createProject() in the run method. But i cannot see this code can create the new project. Some error in console told me :

    Unhandled Exception
    Reason:
    Unable to execute early startup code for an extension
    Bad extension specification
    Reason:
    startup class must implement org.eclipse.ui.IStartup

    and after click the action, in console told me :

    Unhandled event loop exception
    Reason:
    org/eclipse/core/resources/ResourcesPlugin

    any body can figure out how to make project, folder and file using workspace API

    #224854 Reply

    Riyad Kalla
    Member

    Moving to OT > Soft dev, this has nothing to do with ME.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: create project, folder and file

You must be logged in to post in the forum log in