Package ccw.ui

Source Code of ccw.ui.NewProjectIntroAction

package ccw.ui;

import java.util.Properties;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWizard;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.intro.IIntroManager;
import org.eclipse.ui.intro.IIntroPart;
import org.eclipse.ui.intro.IIntroSite;
import org.eclipse.ui.intro.config.IIntroAction;
import org.eclipse.ui.wizards.IWizardDescriptor;

public class NewProjectIntroAction implements IIntroAction {

  @Override
  public void run(IIntroSite site, Properties params) {
    IIntroManager introManager = site.getWorkbenchWindow().getWorkbench().getIntroManager();
    IIntroPart introPart = introManager.getIntro();
    if (introPart != null) {
      introManager.closeIntro(introPart);
    }
    openWizard(site.getShell(), site.getWorkbenchWindow().getWorkbench(), null, "ccw.project.new.wizard");
  }

  public void openWizard(Shell shell, IWorkbench workbench, IStructuredSelection selection, String id) {
    // First see if this is a "new wizard".
    IWizardDescriptor descriptor = PlatformUI.getWorkbench()
        .getNewWizardRegistry().findWizard(id);
    // If not check if it is an "import wizard".
    if (descriptor == null) {
      descriptor = PlatformUI.getWorkbench().getImportWizardRegistry()
          .findWizard(id);
    }
    // Or maybe an export wizard
    if (descriptor == null) {
      descriptor = PlatformUI.getWorkbench().getExportWizardRegistry()
          .findWizard(id);
    }
    try {
      // Then if we have a wizard, open it.
      if (descriptor != null) {
        IWizard wizard = descriptor.createWizard();
        ((IWorkbenchWizard) wizard).init(workbench, selection);
        WizardDialog wd = new WizardDialog(shell, wizard);
        wd.setTitle(wizard.getWindowTitle());
        wd.open();
      }
    } catch (CoreException e) {
      e.printStackTrace();
    }
  }
}
TOP

Related Classes of ccw.ui.NewProjectIntroAction

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.