Eclipseplugins
ProgressUtils.java
1 package com.proalpha.pds.projconf.utils;
2 
3 import org.eclipse.core.runtime.Platform;
4 import org.osgi.framework.Bundle;
5 import org.osgi.framework.Version;
6 
7 import com.openedge.pdt.platform.PlatformSupport;
8 import com.openedge.pdt.platform.Proversion;
9 
10 public class ProgressUtils {
11 
12  private static final String COM_OPENEDGE_PDT_CORE_BUNDLE = "com.openedge.pdt.core";
13  private PlatformSupport platformSupport;
14 
15  public ProgressUtils(PlatformSupport platformSupport)
16  {
17  this.platformSupport = platformSupport;
18  }
19 
26  public Proversion getProgressVersion() {
27 
28  String openEdgeEditorVersion = getOpenEdgeEditorVersion();
29 
30  Proversion proversion = platformSupport.getProversion(openEdgeEditorVersion);
31 
32  // Try for BETA or ALPHA
33  if (proversion == null) {
34  proversion = platformSupport.getProversion(openEdgeEditorVersion + "BETA");
35  }
36 
37  if (proversion == null) {
38  proversion = platformSupport.getProversion(openEdgeEditorVersion + "ALPHA");
39  }
40 
41  if (proversion == null) {
42  StringBuilder supportedVersions = new StringBuilder();
43 
44  for (Proversion proVersion : platformSupport.getProversions()) {
45  supportedVersions.append(" ");
46  supportedVersions.append(proVersion.getVersion());
47  }
48 
49  throw new RuntimeException(
50  "OpenEdge Version not found.\n" + "Supported OpenEdge version are: " + supportedVersions.toString());
51  }
52  return proversion;
53  }
54 
61  public String getOpenEdgeEditorVersion() {
62  return getOpenEdgeVersionWithMinor();
63  }
64 
65  public String getOpenEdgeVersionWithMinor() {
66  String openEdgeVersion = "";
67  Bundle openEdgeBundle = Platform.getBundle(COM_OPENEDGE_PDT_CORE_BUNDLE);
68 
69  if (openEdgeBundle != null) {
70  Version version = openEdgeBundle.getVersion();
71  openEdgeVersion = String.format("%s.%s", version.getMajor(), version.getMinor());
72  }
73 
74  return openEdgeVersion;
75  }
76 
77  public String getOpenEdgeVersionWithMicro() {
78  String openEdgeVersion = "";
79  Bundle openEdgeBundle = Platform.getBundle(COM_OPENEDGE_PDT_CORE_BUNDLE);
80 
81  if (openEdgeBundle != null) {
82  Version version = openEdgeBundle.getVersion();
83  openEdgeVersion = String.format("%s.%s.%s", version.getMajor(),version.getMinor(),version.getMicro());
84  }
85 
86  return openEdgeVersion;
87  }
88 
89 }