Package de.innovationgate.eclipse.editors.design.wizards

Source Code of de.innovationgate.eclipse.editors.design.wizards.ExportWGAPluginLocal

/*******************************************************************************
* 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.editors.design.wizards;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.wizard.IWizardPage;

import de.innovationgate.eclipse.editors.Plugin;
import de.innovationgate.eclipse.utils.WorkbenchUtils;
import de.innovationgate.eclipse.utils.ui.CancelWizardPage;


public class ExportWGAPluginLocal extends ExportWGADesignWizardBase {

  protected ExportWGAPluginLocalPage _exportAsPluginAsFilePage;

  public ExportWGAPluginLocal() {
    super();
    setWindowTitle("Export WGA Plugin");
    setNeedsProgressMonitor(true);
  }

  protected boolean innerPerformFinish() { 
    if (_exportAsPluginAsFilePage.isPageComplete()) {
      File exportFile = _model.getPluginExportFile(new File(_exportAsPluginAsFilePage.getExportLocation()), _exportAsPluginAsFilePage.isShortFileName());
      if (exportFile.exists()) {
        boolean confirm = MessageDialog.openConfirm(getShell(), "Overwrite?", "The plugin file '" + exportFile + "' already exists. Overwrite?");
        if (!confirm) {
          return false;
        }
      }
      try {
        _model.exportPlugin(exportFile, _exportAsPluginAsFilePage.getBuild(), false, false);
        _designContainer.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());       
        MessageDialog.openInformation(getShell(), "Export finished.", "Plugin has been exported to '" + exportFile.getAbsolutePath() + "'.");
        return true;
      } catch (Exception e) {
        WorkbenchUtils.showErrorDialog(Plugin.getDefault(), getShell(), "Export plugin failed", "Unable to export plugin to file '" + exportFile.getAbsolutePath() + "'", e);
      }
    }
    return false;
  }


  @Override
  protected List<IWizardPage> createPages() {
    List<IWizardPage> pages = new ArrayList<IWizardPage>();
   
     if (_model.hasPluginConfig()) {
       _exportAsPluginAsFilePage = new ExportWGAPluginLocalPage(_designContainer);
      _exportAsPluginAsFilePage.setModel(_model);
      pages.add(_exportAsPluginAsFilePage);
    } else {
      pages.add(new CancelWizardPage("No plugin configuration found.", "This design has no plugin configuration yet. You can create a plugin config within the design editor."));
      setOpenDesignEditor(true);
    }
   
   
   
    return pages;
  }
}
TOP

Related Classes of de.innovationgate.eclipse.editors.design.wizards.ExportWGAPluginLocal

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.