Package tool.importWizards

Source Code of tool.importWizards.ToolImportWizard

package tool.importWizards;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.URI;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IImportWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;

import tool.ToolPlugin;
import tool.ToolProjectSupport;
import tool.properties.ProjectPropertyPage;
import tool.repository.RepositoryExport;
import tool.repository.ToolRepositoryException;

public abstract class ToolImportWizard extends Wizard implements IImportWizard {

  protected ProjectPropertyPage projectPropertyPage;
  protected WizardNewProjectCreationPage projectCreationPage;
  protected IConfigurationElement _configurationElement;






//  @Override
//  public IWizardPage getNextPage(IWizardPage arg0) {
//    // TODO Auto-generated method stub
//    return null;
//  }
//
//
//  @Override
//  public boolean needsPreviousAndNextButtons() {
//    // TODO Auto-generated method stub
//    return false;
//  }



  @Override
  public boolean performFinish() {
    try {
      IWizardContainer container = getContainer();
      String name = projectCreationPage.getProjectName();
      URI location = null;
      if (!projectCreationPage.useDefaults()) {
        location = projectCreationPage.getLocationURI();
      } // else location == null

      String forteLogger = null;
      String repository = null;
      String workspace = null;
      String workspacePassword = null;
      if (projectPropertyPage != null){
        forteLogger = projectPropertyPage.getForteLogger();
        repository = projectPropertyPage.getForteRepository();
        workspace = projectPropertyPage.getForteWorkspace();
        workspacePassword = projectPropertyPage.getForteWorkspacePassword();
      }
      IProject project = ToolProjectSupport.createProject(name, location, forteLogger, repository, workspace, workspacePassword);
     
      project.refreshLocal(IResource.DEPTH_ZERO, null);
      createRepos(project);
      RepositoryExport exporter = new RepositoryExport(project);
      container.run(true, true, exporter);

      return true
    } catch (InvocationTargetException e) {
      ToolPlugin.showError("Error importing from Tool repository",e);
    } catch (InterruptedException e) {
      ToolPlugin.showError("Error importing from Tool repository",e);
    } catch (CoreException e) {
      ToolPlugin.showError("Error importing from Tool repository",e);
    } catch (ToolRepositoryException e) {
      ToolPlugin.showError("Error importing from Tool repository",e);
    } catch (IOException e) {
      ToolPlugin.showError("Error importing from Tool repository",e);
    }
    return false
 


  @Override
  public void init(IWorkbench workbench, IStructuredSelection selection) {
    setWindowTitle("Tool Import from " + fromWhere()); //NON-NLS-1
    setNeedsProgressMonitor(true);
    projectCreationPage = new WizardNewProjectCreationPage("New Tool Project");
      projectPropertyPage = new ProjectPropertyPage("Import Repository", selection);
  }
  public void addPages() {
        addPage(projectCreationPage);
        addPage(projectPropertyPage);       
    }
 
  public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
      _configurationElement = config;
  }
 
  public String fromWhere(){
    return  "no where";
  }

  public abstract void createRepos(IProject project);
 
}
TOP

Related Classes of tool.importWizards.ToolImportWizard

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.