Package de.innovationgate.eclipse.wgadesigner.wizards

Source Code of de.innovationgate.eclipse.wgadesigner.wizards.NewExternalWGADesign

/*******************************************************************************
* Copyright (c) 2009, 2010 Innovation Gate GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*     Innovation Gate GmbH - initial API and implementation
******************************************************************************/
package de.innovationgate.eclipse.wgadesigner.wizards;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;

import de.innovationgate.eclipse.utils.WorkbenchUtils;
import de.innovationgate.eclipse.utils.ui.SingleStructuredSelection;
import de.innovationgate.eclipse.utils.wga.WGADesignStructureHelper;
import de.innovationgate.eclipse.wgadesigner.WGADesignFactory;
import de.innovationgate.eclipse.wgadesigner.WGADesignerPlugin;
import de.innovationgate.eclipse.wgadesigner.natures.WGADesign;

public class NewExternalWGADesign extends Wizard implements INewWizard {

  private NewExternalWGADesignPage _page;

  public NewExternalWGADesign() {
    super();
    setWindowTitle("New external WGA Design");
    setNeedsProgressMonitor(true);
  }

  public void addPages() {
    _page = new NewExternalWGADesignPage();
    addPage(_page);
  }


  public boolean performFinish() {
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();   
    IProject project = root.getProject(_page.getDesignName());
   
    if(!project.exists()){
      try {               
        WGADesign design = WGADesignFactory.createDesign(project, _page.getTemplate());
               
        try {
          WGADesignStructureHelper helper = new WGADesignStructureHelper(design.getDesignFolder());
          WorkbenchUtils.setNavigationViewSelection(new SingleStructuredSelection(helper.getSyncInfo()));
          WorkbenchUtils.setNavigationViewSelection(new SingleStructuredSelection(design.getDesignFolder()));
        } catch (Exception e) {       
        }
       
        return true;
      } catch (CoreException e) {
        WorkbenchUtils.showErrorDialog(WGADesignerPlugin.getDefault(), getShell(), "Design creation failed", "Unable to create new project '" + project.getName() + "'.", e);
      }     
    } else {
      WorkbenchUtils.showErrorDialog(getShell(), "Design creation failed", "A project with name '" + project.getName() + "' already exists in the workspace.");
    }
    return false;
   
  }
 
  public void init(IWorkbench workbench, IStructuredSelection selection) { 
  }
}
TOP

Related Classes of de.innovationgate.eclipse.wgadesigner.wizards.NewExternalWGADesign

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.