Skip to main content
summaryrefslogtreecommitdiffstats
blob: fbcde9386a761d6d7868d05294825966cd67dc0c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*******************************************************************************
 * 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