import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.ResourceBundle;
_display = State.deepopen;
} else { // Opening the document
if (_uses == null) {
- List<Publication> relist = _me.getRelations(UsesRelation.class);
+ List<Relation> relist = _me.value().getRelations(UsesRelation.class);
_uses = new ArrayList<DocumentFacade>(relist.size());
- for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
- Publication used = i.next();
- long index = used.getIndex();
- DocumentFacade facade = _owner._docpres.get(index);
+ for (Relation relation : relist) {
+ Document used = ((UsesRelation)relation).getTo();
+
+ DocumentFacade facade = null;
+
+ Publication publication = _me.getOwner().getPublication(used);
+ if(publication == null) {
+ publication = _me.getOwnerStudy().getPublication(used);
+ }
+ if(publication != null) {
+ facade = _owner._docpres.get(publication.getIndex());
+ }
+
if (facade == null) {
facade = new DocumentFacade(_owner, used,
getProjectSettings(), getPublicationService(),
getApplicationSettings());
- _owner._docpres.put(index, facade);
}
_uses.add(facade);
}
}
if (_exports == null) {
- List<Relation> relation = _mydoc
- .getRelations(ConvertsRelation.class);
-
- _exports = new ArrayList<FileFacade>(relation.size());
- for (Iterator<Relation> i = relation.iterator(); i.hasNext();) {
- ConvertsRelation export = (ConvertsRelation) i.next();
- _exports.add(new FileFacade(export,
- getApplicationSettings()));
- }
+ updateExports();
}
if (_history == null) {
if (_mydoc.getPreviousVersion() != null
_display = State.open;
}
}
+
+ /**
+ * Update the list of export files.
+ */
+ private void updateExports() {
+ List<Relation> relations = _mydoc
+ .getRelations(ConvertsRelation.class);
+
+ _exports = new ArrayList<FileFacade>(relations.size());
+ for (Relation rel : relations) {
+ _exports.add(new FileFacade((ConvertsRelation)rel,
+ getApplicationSettings()));
+ }
+ }
/**
* Close the presentation tree partially.
_version = verstring.format(_version);
_size = sizstring.format(_mydoc.getSourceFile().asFile().length() / 1000);
_date = datstring.format(_mydoc.getLastModificationDate());
-
+ updateExports();
// Refresh of the history in case of promotion
if (_display == State.deepopen) {
_history.clear();
_sharing = "image.share.png";
_updated = "icon.hold.png";
}
- if (_me.isOutdated()) {
- _state = ProgressState.inWORK; // Overrides the document state
- }
+ //if (_me.isOutdated()) {
+ // _state = ProgressState.inWORK; // Overrides the document state
+ //}
}
}