Skip to main content
summaryrefslogblamecommitdiffstats
blob: fbcde9386a761d6d7868d05294825966cd67dc0c (plain) (tree)
1
2
3
4
5
6
7

                                                                                




                                                               








































                                                                                                 
                                                                                                            


                                    
                                              

                   
                                                  





                            
                                           





                                                             




                                                             
       

     
                                         


   
/*******************************************************************************
 * Copyright (c) 2016-2017, Thales Global Services S.A.S.
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *   Abel Hegedus, Tamas Borbas, Peter Lunk (IncQuery Labs Ltd.) - initial API and implementation
 *******************************************************************************/
package org.eclipse.emf.diffmerge.patch.ui.wizards

import org.eclipse.emf.diffmerge.patch.api.ModelPatchException
import org.eclipse.emf.diffmerge.patch.ui.utils.ModelpatchApplicationDTO
import org.eclipse.emf.diffmerge.patch.ui.wizards.pages.ModelpatchEDMWizardPage
import org.eclipse.emf.diffmerge.patch.ui.wizards.pages.ModelpatchFilteringWizardPage
import org.eclipse.emf.diffmerge.patch.ui.wizards.pages.ModelpatchLoadingPatchWizardPage
import org.eclipse.emf.diffmerge.patch.ui.wizards.pages.ModelpatchResultWizardPage
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.jface.wizard.IWizardPage
import org.eclipse.jface.wizard.Wizard

class ModelpatchApplicationWizard extends Wizard {
  ModelpatchApplicationDTO dto

  ModelpatchLoadingPatchWizardPage patchLoadingPage
  ModelpatchFilteringWizardPage patchModificationPage
  ModelpatchResultWizardPage resultPage
  ModelpatchEDMWizardPage edmPage

  new(Resource originalModel) {
    setWindowTitle("Modelpatch Application")
    dto = new ModelpatchApplicationDTO(originalModel)
    patchLoadingPage = new ModelpatchLoadingPatchWizardPage(dto)
    patchModificationPage = new ModelpatchFilteringWizardPage(dto)
    resultPage = new ModelpatchResultWizardPage(dto)
    edmPage = new ModelpatchEDMWizardPage(dto)
  }

  override void addPages() {
    addPage(patchLoadingPage)
    addPage(patchModificationPage)
    addPage(resultPage)
    addPage(edmPage)
  }

  override canFinish() {
    return container.currentPage == resultPage || (container.currentPage == edmPage && edmPage.pageComplete)
  }

  override boolean performFinish() {
    if (container.currentPage == resultPage) {
      dto.saveModel
      return true
    } else if (container.currentPage == edmPage) {
      return true
    }
    return false
  }

  override performCancel() {
    if (container.currentPage == edmPage) {
      dto.undoEDMModifications
    }
    super.performCancel()
  }

  override IWizardPage getNextPage(IWizardPage currentPage) {
    if (currentPage == patchLoadingPage) {
      try {
        dto.loadPatch(patchLoadingPage.getSelectedFilePath())
      } catch (ModelPatchException e) {
        e.printStackTrace()
      }
    }

    return super.getNextPage(currentPage)
  }

}

Back to the top