1 package com.proalpha.pds.paconnector;
3 import java.util.ArrayList;
6 import org.eclipse.core.resources.ProjectScope;
7 import org.eclipse.core.runtime.IPath;
8 import org.eclipse.core.runtime.preferences.IScopeContext;
9 import org.osgi.service.prefs.BackingStoreException;
10 import org.osgi.service.prefs.Preferences;
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
14 import com.openedge.core.runtime.IAVMClient;
15 import com.openedge.core.runtime.IAVMRuntimeListener;
16 import com.openedge.core.runtime.IPropath;
17 import com.openedge.pdt.project.OEProject;
18 import com.proalpha.pds.exception.ProALPHANotAvailableException;
22 private static final Logger logger = LoggerFactory.getLogger(
PaProject.class);
23 private static final String PLUGIN_ID =
Activator.
getDefault().getBundle().getSymbolicName();
25 private final OEProject oeProject;
26 private IAVMRuntimeListener avmRuntimeListener;
27 private String customLevel =
"";
28 private String codepage;
29 private String version;
30 private IPropath propath;
31 private IPath bridgePath;
32 private boolean available;
36 this.oeProject = oeProject;
37 this.available =
false;
38 this.avmRuntimeListener =
new AVMRuntimeListener();
39 this.oeProject.getRuntime().addAVMRuntimeListener(avmRuntimeListener);
42 public IPropath getPropath() {
50 public void setPropath(IPropath propath) {
51 this.propath = propath;
54 public IPath getBridgePath() {
58 public void setBridgePath(IPath bridgePath) {
59 this.bridgePath = bridgePath;
62 public String getCodepage() {
66 public void setCodepage(String codepage) {
67 this.codepage = codepage;
70 public String getVersion() {
74 public void setVersion(String version) {
75 this.version = version;
78 public boolean isAvailable() {
82 public void setAvailable(
boolean available) {
85 this.available = available;
88 public OEProject getOeProject() {
92 public String getCustomLevel() {
96 public void setCustomLevel(String customLevel) {
97 this.customLevel = customLevel;
100 public String getName() {
101 return this.getOeProject().getProject().toString();
105 public String toString() {
106 return "proALPHA Project: " + this.getName();
115 IScopeContext ctxt =
new ProjectScope(this.getOeProject().getProject());
116 Preferences prefs = ctxt.getNode(PLUGIN_ID);
117 List<PaPreference> paPrefs =
new ArrayList<>();
120 for (String pakey : prefs.keys()) {
122 paPrefs.add(tmpPref);
125 }
catch (BackingStoreException e) {
126 logger.error(e.getMessage(), e);
129 return new ArrayList<>();
142 IScopeContext ctxt =
new ProjectScope(this.getOeProject().getProject());
143 Preferences prefs = ctxt.getNode(PLUGIN_ID);
145 if (name ==
null || value ==
null || prefs ==
null)
148 prefs.put(name, value);
152 }
catch (BackingStoreException e) {
160 public void dispose() {
161 if (avmRuntimeListener !=
null) {
162 this.oeProject.getRuntime().removeAVMRuntimeListener(avmRuntimeListener);
163 avmRuntimeListener =
null;
167 private class AVMRuntimeListener
implements IAVMRuntimeListener {
168 public void runtimeStarted(
final IAVMClient runtime) {
169 logger.info(
"Runtime of project {} started", PaProject.this.getName());
170 PaProject.this.setAvailable(
false);
173 public void runtimeStopped(
final IAVMClient runtime) {
174 logger.info(
"Runtime of project {} stopped", PaProject.this.getName());
175 PaProject.this.setAvailable(
false);
178 public void runtimeShutdown(IAVMClient rutime) {
179 logger.info(
"Runtime of project {} shut down", PaProject.this.getName());
180 PaProject.this.setAvailable(
false);
183 public void runtimeInitialized(
final IAVMClient runtime) {
184 logger.info(
"Runtime of project {} initialized", PaProject.this.getName());
187 public void runtimeAvailable(IAVMClient runtime) {
188 logger.info(
"Runtime of project {} available", PaProject.this.getName());
190 PaProject.this.bridge =
new RunCommonPaProgram(PaProject.this);
191 }
catch (ProALPHANotAvailableException e) {
static Activator getDefault()
boolean savePaPref(String name, String value)
List< PaPreference > loadPaPrefs()