Skip to main content
summaryrefslogtreecommitdiffstats
blob: f98b78c2f677ed1003948f00aae024f55090cb95 (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
/*******************************************************************************
 * Copyright (c) 2016-2017, Thales Global Services S.A.S.
 * 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:
 *   Abel Hegedus, Tamas Borbas, Balazs Grill, Peter Lunk, Daniel Segesdi (IncQuery Labs Ltd.) - initial API and implementation
 *******************************************************************************/
package org.eclipse.emf.diffmerge.patch.ui.utils

import org.eclipse.jface.viewers.ILabelProvider
import org.eclipse.jface.viewers.ILabelProviderListener
import org.eclipse.emf.diffmerge.patch.api.ModelPatch
import org.eclipse.emf.diffmerge.patch.api.ModelPatchEntry

class ModelPatchLabelProvider implements ILabelProvider {
  IEntryLabelProvider entryLabelProvider

  new() {
    entryLabelProvider = new DefaultEntryLabelProvider
  }

  new(IEntryLabelProvider entryLabelProvider) {
    this.entryLabelProvider = entryLabelProvider
  }

  override getImage(Object element) {
    return null
  }

  override getText(Object element) {
    return element.label
  }

  override addListener(ILabelProviderListener listener) {}

  override dispose() {}

  override isLabelProperty(Object element, String property) {
    return true
  }

  override removeListener(ILabelProviderListener listener) {}

  private dispatch def String getLabel(ModelPatch patch) {
    return '''ModelPatch [«patch.entries.size»]'''
  }

  private dispatch def String getLabel(ModelPatchEntry entry) {
    return entryLabelProvider.getLabel(entry)
  }

  private dispatch def String getLabel(IdentifiableWrapper wrapper) {
    return '''«wrapper.name»: «wrapper.ident»'''
  }

  private dispatch def String getLabel(Object object) {
    return object.toString
  }

  def correctCase(String string) {
    return string.toLowerCase.toFirstUpper
  }
}

Back to the top