import org.splat.util.BeanHelper;
import org.splat.wapp.ToolBar;
-public class OpenStudy extends OpenObject implements OpenStudyServices {
+public class OpenStudy extends AbstractOpenObject implements OpenStudyServices {
/**
* Serial version ID.
protected final static Logger LOGGER = org.splat.simer.Action.LOG;
private transient Study _mystudy;
- private transient StudyRights _urightstudy; // User rights on the open study
- private transient StepRights _urightstep; // User rights on the selected step
+ /**
+ * User rights on the open study.
+ */
+ private transient StudyRights _urightstudy;
+ /**
+ * User rights on the selected step.
+ */
+ private transient StepRights _urightstep;
private transient String _version;
private transient String _credate;
private transient String _lasdate;
Revision.Format verstring = new Revision.Format(getProjectSettings()
.getRevisionPattern());
- cuser = user; // May be null if nobody connected
+ _cuser = user; // May be null if nobody connected
_mystudy = study;
- selection = "0.1"; // Default selection
+ _selection = "0.1"; // Default selection
_selecdoc = null;
// Preparation of the display
_version = verstring.format(_mystudy.getVersion());
_credate = datstring.format(_mystudy.getDate());
_lasdate = ""; // Not yet supported
- description = _mystudy.getDescription();
- involving = new ArrayList<Step>(1);
- context = new ArrayList<SimulationContextFacade>();
- ustep = getProjectElementService().getFirstStep(_mystudy);
- ustep.setActor(cuser);
- involving.add(ustep);
- for (Iterator<SimulationContext> i = ustep.getAllSimulationContexts()
+ _description = _mystudy.getDescription();
+ _involving = new ArrayList<Step>(1);
+ _context = new ArrayList<SimulationContextFacade>();
+ _ustep = getProjectElementService().getFirstStep(_mystudy);
+ _ustep.setActor(_cuser);
+ _involving.add(_ustep);
+ for (Iterator<SimulationContext> i = _ustep.getAllSimulationContexts()
.iterator(); i.hasNext();) {
- context.add(new SimulationContextFacade(i.next(),
+ _context.add(new SimulationContextFacade(i.next(),
getProjectSettings().getAllSteps()));
}
- if (getStudyService().isStaffedBy(_mystudy, cuser)
- || getStudyService().hasActor(_mystudy, cuser)) {
+ if (getStudyService().isStaffedBy(_mystudy, _cuser)
+ || getStudyService().hasActor(_mystudy, _cuser)) {
// ProgressState state = mystudy.getProgressState();
// if (state == ProgressState.inCHECK) popup = getApplicationSettings().getPopupMenu("stapprovable");
// else if (state == ProgressState.APPROVED) popup = getApplicationSettings().getPopupMenu("stapproved");
- /* else */popup = getApplicationSettings().getPopupMenu(
+ /* else */_popup = getApplicationSettings().getPopupMenu(
"steditable");
- popup.setContext("study", new StudyRights(cuser, _mystudy));
+ _popup.setContext("study", new StudyRights(_cuser, _mystudy));
}
- _urightstudy = new StudyRights(cuser, _mystudy);
- _urightstep = new StepRights(cuser, ustep);
+ _urightstudy = new StudyRights(_cuser, _mystudy);
+ _urightstep = new StepRights(_cuser, _ustep);
// RKV menu = new StudyMenu(mystudy);
- menu = (getMenu()).init(_mystudy); // RKV
- menu.selects(selection); // Initializes menu items to be displayed
+ _menu = (getMenu()).init(_mystudy); // RKV
+ _menu.selects(_selection); // Initializes menu items to be displayed
setupContents(); // Initializes documents and knowledge at ustep
return this;
}
@Override
public StudyMenu getMenu() {
- return (StudyMenu) menu;
+ return (StudyMenu) _menu;
}
public void setMenu(final StudyMenu aMenu) {
- menu = aMenu;
+ _menu = aMenu;
}
public ProgressState getProgressState() {
String path = docurl.substring(prefix.length());
Document value = getDocumentService().getDocumentByPath(path);
- _selecdoc = ustep.getDocument(value.getIndex());
+ _selecdoc = _ustep.getDocument(value.getIndex());
} catch (Exception error) {
LOGGER.error("Reason:", error);
}
}
public void setSelection(final String step) {
- if (!step.equals(selection)) {
- selection = step;
+ if (!step.equals(_selection)) {
+ _selection = step;
_selecdoc = null;
setupPreviousToSelectedSteps();
updateSimulationContexts(); // Initializes contexts according to the selected steps
}
- ustep = involving.get(involving.size() - 1);
- _urightstep = new StepRights(cuser, ustep);
- ustep.setActor(cuser);
- menu.selects(selection); // Updates menu items to be displayed
+ _ustep = _involving.get(_involving.size() - 1);
+ _urightstep = new StepRights(_cuser, _ustep);
+ _ustep.setActor(_cuser);
+ _menu.selects(_selection); // Updates menu items to be displayed
setupContents(); // The contents may have changed even if the selection is the same
}
protected void add(final Publication doc) {
DocumentFacade facade = new DocumentFacade(this, doc,
getProjectSettings(), getPublicationService());
- boolean first = (contents.size() == 0);
+ boolean first = (_contents.size() == 0);
docpres.put(doc.getIndex(), facade);
- contents.add(0, facade); // Prepend the new publication
+ _contents.add(0, facade); // Prepend the new publication
if (first) {
this.getMenu().refreshSelectedItem();
}
SimulationContextFacade facade = new SimulationContextFacade(contex,
getProjectSettings().getAllSteps());
- context.add(facade);
+ _context.add(facade);
}
protected void add(final KnowledgeElement kelm) {
// Knowledges are ordered by type index, from 0 to n-1, the first one being reserved (reason for -2)
// RKV:Begin: Find a knowledge iterator for appropriate knowledge type
KnowledgeIterator known = null;
- for (KnowledgeIterator aKnowledgeSection : knowledge) {
+ for (KnowledgeIterator aKnowledgeSection : _knowledge) {
if (aKnowledgeSection.getIndex().equals(
String.valueOf(kelm.getType().getIndex()))) {
known = aKnowledgeSection;
}
if (known != null) { // RKV:End
knowpres.put(kelm.getIndex(), facade);
- known.list.add(facade); // Insert the new knowledge at the end of the corresponding knowledge type
+ known._list.add(facade); // Insert the new knowledge at the end of the corresponding knowledge type
}
}
protected void remove(final Publication doctag) {
- for (Iterator<DocumentFacade> i = contents.iterator(); i.hasNext();) {
+ for (Iterator<DocumentFacade> i = _contents.iterator(); i.hasNext();) {
DocumentFacade facade = i.next();
if (!facade.isFacadeOf(doctag)) {
continue;
i.remove();
break;
}
- if (contents.size() == 0) {
+ if (_contents.size() == 0) {
this.getMenu().refreshSelectedItem();
}
}
protected void changeUser(final User user) {
- cuser = user;
- popup = null;
- if (getStudyService().isStaffedBy(_mystudy, cuser)) {
- popup = getApplicationSettings().getPopupMenu("steditable");
- popup.setContext("study", new StudyRights(cuser, _mystudy));
+ _cuser = user;
+ _popup = null;
+ if (getStudyService().isStaffedBy(_mystudy, _cuser)) {
+ _popup = getApplicationSettings().getPopupMenu("steditable");
+ _popup.setContext("study", new StudyRights(_cuser, _mystudy));
}
// ustep = getProjectElementService().getFirstStep(mystudy);
- if (ustep != null) {
- ustep.setActor(cuser);
+ if (_ustep != null) {
+ _ustep.setActor(_cuser);
}
- _urightstudy = new StudyRights(cuser, _mystudy);
- _urightstep = new StepRights(cuser, ustep);
+ _urightstudy = new StudyRights(_cuser, _mystudy);
+ _urightstep = new StepRights(_cuser, _ustep);
}
protected void remove(final SimulationContext contex) {
- for (Iterator<SimulationContextFacade> i = context.iterator(); i
+ for (Iterator<SimulationContextFacade> i = _context.iterator(); i
.hasNext();) {
SimulationContextFacade facade = i.next();
if (!facade.isFacadeOf(contex)) {
}
protected void remove(final KnowledgeElement kelm) {
- KnowledgeIterator known = knowledge.get((int) (kelm.getType()
+ KnowledgeIterator known = _knowledge.get((int) (kelm.getType()
.getIndex() - 2));
// Knowledges are ordered by type index, from 0 to n-1, the first one being reserved (reason for -2)
knowpres.remove(kelm.getIndex());
- for (Iterator<KnowledgeElementFacade> i = known.list.iterator(); i
+ for (Iterator<KnowledgeElementFacade> i = known._list.iterator(); i
.hasNext();) {
KnowledgeElementFacade facade = i.next();
if (!facade.isFacadeOf(BeanHelper.copyBean(kelm,
}
protected void updateSimulationContexts() {
- context.clear();
- for (Iterator<Step> i = involving.iterator(); i.hasNext();) {
+ _context.clear();
+ for (Iterator<Step> i = _involving.iterator(); i.hasNext();) {
for (Iterator<SimulationContext> j = i.next()
.getAllSimulationContexts().iterator(); j.hasNext();) {
- context.add(new SimulationContextFacade(j.next(),
+ _context.add(new SimulationContextFacade(j.next(),
getProjectSettings().getAllSteps()));
}
}
// ==============================================================================================================================
private void setupPreviousToSelectedSteps() {
- String[] item = selection.split("\\x2E");
+ String[] item = _selection.split("\\x2E");
int major = Integer.valueOf(item[0]);
int minor = Integer.valueOf(item[1]);
int base = minor;
Step[] step;
- involving.clear();
+ _involving.clear();
if (major > 0) {
Scenario[] branch = _mystudy.getScenarii();
Scenario scenar = branch[0];
step = getProjectElementService().getSteps(scenar);
base = step[0].getNumber() - 1;
for (int i = 0; i + base < minor; i++) {
- involving.add(step[i]);
+ _involving.add(step[i]);
}
}
step = getProjectElementService().getSteps(_mystudy);
if (firstep.getNumber() > base) {
continue;
}
- involving.add(0, firstep);
+ _involving.add(0, firstep);
}
}