eclipse.preferences.version=1
+encoding//src/org/simantics/document/linking/actions/messages.properties=ISO-8859-1
+encoding//src/org/simantics/document/linking/ge/messages.properties=ISO-8859-1
encoding//src/org/simantics/document/linking/report/ExportToPDF.java=UTF-8
+encoding//src/org/simantics/document/linking/report/messages.properties=ISO-8859-1
encoding//src/org/simantics/document/linking/report/templates/ModelDocumentWriter.java=UTF-8
encoding//src/org/simantics/document/linking/report/templates/ReferredDocumentWriter.java=UTF-8
+encoding//src/org/simantics/document/linking/report/templates/messages.properties=ISO-8859-1
+encoding//src/org/simantics/document/linking/utils/messages.properties=ISO-8859-1
+encoding//src/org/simantics/document/linking/views/messages.properties=ISO-8859-1
+encoding//src/org/simantics/document/linking/wizard/messages.properties=ISO-8859-1
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
- cross = imageDescriptorFromPlugin(PLUGIN_ID, "icons/silk_small/cross.png");
- clock_red = imageDescriptorFromPlugin(PLUGIN_ID, "icons/silk_small/clock_red.png");
+ cross = imageDescriptorFromPlugin(PLUGIN_ID, "icons/silk_small/cross.png"); //$NON-NLS-1$
+ clock_red = imageDescriptorFromPlugin(PLUGIN_ID, "icons/silk_small/clock_red.png"); //$NON-NLS-1$
}
/*
--- /dev/null
+package org.simantics.document.linking.actions;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.document.linking.actions.messages"; //$NON-NLS-1$
+ public static String SearchLinksAction_CannotPerformSearch;
+ public static String UpdateReferencesAction_CannotUpdateReferences;
+ public static String UpdateReferencesAction_FixOldReferences;
+ public static String UpdateReferencesAction_FixReferences;
+ public static String UpdateReferencesAction_NothingToFix;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
Layer0 l0 = Layer0.getInstance(graph);
String s = graph.getPossibleRelatedValue(resource, l0.HasLabel, Bindings.STRING);
if (s == null)
- s = graph.getRelatedValue(resource, l0.HasName, Bindings.STRING);
+ s = graph.getRelatedValue(resource, l0.HasName, Bindings.STRING);
return s;
}
});
- ISearchService searchService = (ISearchService)PlatformUI.getWorkbench().getService(ISearchService.class);
+ ISearchService searchService = (ISearchService) PlatformUI.getWorkbench().getService(ISearchService.class);
SearchQuery query = new SearchQuery(name);
- query.setSearchFlag("Name", "on");
- query.setSearchFlag(DocumentLink.URIs.SearchFunction, "on");
+ query.setSearchFlag("Name", "on"); //$NON-NLS-1$ //$NON-NLS-2$
+ query.setSearchFlag(DocumentLink.URIs.SearchFunction, "on"); //$NON-NLS-1$
searchService.performQuery(query, ISearchService.ResultBrowser.VIEW, true);
} catch (DatabaseException e) {
- ExceptionUtils.logAndShowError("Cannot perform search",e);
+ ExceptionUtils.logAndShowError(Messages.SearchLinksAction_CannotPerformSearch, e);
}
-
-
+
}
};
}
import java.util.Collection;
import java.util.Collections;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.simantics.Simantics;
import org.simantics.db.ReadGraph;
@Override
public Collection<Resource> perform(ReadGraph graph)
throws DatabaseException {
- return findDocumentReferences(graph, document);
+ return findDocumentReferences(graph, document);
}
});
-
+
if (coll == null)
return;
-
- String dialogTitle = "Fix References";
- String dialogMessage = "Fix " + coll.size() + " old references?";
- String dialogButtonLabels[] = new String[]{"Ok","Cancel"};
+
+ String dialogTitle = Messages.UpdateReferencesAction_FixReferences;
+ String dialogMessage = NLS.bind(Messages.UpdateReferencesAction_FixOldReferences, coll.size());
+ String dialogButtonLabels[] = new String[] { IDialogConstants.OK_LABEL,
+ IDialogConstants.CANCEL_LABEL };
int defaultIndex = 0;
if (coll.size() == 0) {
- dialogMessage = "Nothing to fix.";
- dialogButtonLabels = new String[]{"OK"};
- MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), dialogTitle, null, dialogMessage, MessageDialog.CONFIRM, dialogButtonLabels, defaultIndex);
+ dialogMessage = Messages.UpdateReferencesAction_NothingToFix;
+ dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL };
+ MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), dialogTitle,
+ null, dialogMessage, MessageDialog.CONFIRM, dialogButtonLabels, defaultIndex);
dialog.open();
return;
}
- MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), dialogTitle, null, dialogMessage, MessageDialog.CONFIRM, dialogButtonLabels, defaultIndex);
+ MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), dialogTitle, null,
+ dialogMessage, MessageDialog.CONFIRM, dialogButtonLabels, defaultIndex);
if (dialog.open() != 0)
return;
Simantics.getSession().markUndoPoint();
fixDocumentReferences(coll);
} catch (DatabaseException e) {
- ExceptionUtils.logAndShowError("Cannot update references",e);
+ ExceptionUtils.logAndShowError(Messages.UpdateReferencesAction_CannotUpdateReferences, e);
}
-
-
+
}
};
}
--- /dev/null
+SearchLinksAction_CannotPerformSearch=Cannot perform search\r
+UpdateReferencesAction_CannotUpdateReferences=Cannot update references\r
+UpdateReferencesAction_FixOldReferences=Fix {0} old references?\r
+UpdateReferencesAction_FixReferences=Fix References\r
+UpdateReferencesAction_NothingToFix=Nothing to fix.\r
static {
columns = new ArrayList<SearchResultColumn>();
- columns.add(new SearchResultColumn("Name"));
- columns.add(new SearchResultColumn("Comment"));
- columns.add(new SearchResultColumn("Part Of"));
+ columns.add(new SearchResultColumn("Name")); //$NON-NLS-1$
+ columns.add(new SearchResultColumn("Comment")); //$NON-NLS-1$
+ columns.add(new SearchResultColumn("Part Of")); //$NON-NLS-1$
}
@Override
int type = 0;
public NameComparator(String query) {
- String parts[] = query.split(" OR ");
+ String parts[] = query.split(" OR "); //$NON-NLS-1$
for (String s : parts) {
- if (s.startsWith("Name:")) {
+ if (s.startsWith("Name:")) { //$NON-NLS-1$
name = s.substring(5);
}
}
name = name.trim();
boolean freeStart = false;
boolean freeEnd = false;
- if (name.endsWith("*")) {
+ if (name.endsWith("*")) { //$NON-NLS-1$
name = name.substring(0,name.length()-1);
freeEnd = true;
}
- if (name.startsWith("*")) {
+ if (name.startsWith("*")) { //$NON-NLS-1$
name = name.substring(1,name.length());
freeStart = true;
}
SearchResult result = new SearchResult(columns);
Set<Resource> processed = new HashSet<Resource>();
- NameComparator c = new NameComparator(query.getQuery("Name"));
+ NameComparator c = new NameComparator(query.getQuery("Name")); //$NON-NLS-1$
for (Resource source : results) {
// Prevent index corruption from producing duplicate results.
String relationName = NameUtils.getSafeLabel(graph, relation);
if (relationName.length() == 0)
relationName = NameUtils.getSafeName(graph, relation);
- parentName = parentName +"#"+relationName;
+ parentName = parentName +"#"+relationName; //$NON-NLS-1$
}
DocumentLinkRow rst = new DocumentLinkRow();
public String getContent(int column) {
switch (column) {
case 0:
- return "<a class=\"small\" href=\"resource:"+ resource.getResource() +"\"" + (resource.getUri() == null ? "" : " title=\""+resource.getUri()+"\">")+StringUtil.escape(resource.getName())+"</a>";
+ return "<a class=\"small\" href=\"resource:"+ resource.getResource() +"\"" + (resource.getUri() == null ? "" : " title=\""+resource.getUri()+"\">")+StringUtil.escape(resource.getName())+"</a>"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
case 1:
if (comment != null)
return comment;
- return "";
+ return ""; //$NON-NLS-1$
case 2:
if (parent != null)
- return "<a class=\"small\" href=\"resource:"+ parent.getResource() +"\"" + (parent.getUri() == null ? "" : " title=\""+parent.getUri()+"\">")+StringUtil.escape(parent.getName())+"</a>";
- return "";
+ return "<a class=\"small\" href=\"resource:"+ parent.getResource() +"\"" + (parent.getUri() == null ? "" : " title=\""+parent.getUri()+"\">")+StringUtil.escape(parent.getName())+"</a>"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ return ""; //$NON-NLS-1$
default:
- return "";
+ return ""; //$NON-NLS-1$
}
}
}
public class Constants {
- public static String NAME = "Name";
- public static String VALUE = "Value";
- public static String REFERENCE = "Reference";
- public static String COMMENT = "Comment";
+ public static String NAME = "Name"; //$NON-NLS-1$
+ public static String VALUE = "Value"; //$NON-NLS-1$
+ public static String REFERENCE = "Reference"; //$NON-NLS-1$
+ public static String COMMENT = "Comment"; //$NON-NLS-1$
public static String[] SOURCE_COLUMN_KEYS = {NAME,VALUE,REFERENCE,COMMENT};
public static Column[] SOURCE_COLUMNS = new Column[] {
- new Column(NAME,Align.LEFT,200,"Name",false),
- new Column(VALUE,Align.LEFT,100,"Value",false),
- new Column(REFERENCE,Align.LEFT,150,"Reference Document",false),
- new Column(COMMENT,Align.LEFT,200,"Comment",true)
+ new Column(NAME,Align.LEFT,200,Messages.Constants_Name,false),
+ new Column(VALUE,Align.LEFT,100,Messages.Constants_Value,false),
+ new Column(REFERENCE,Align.LEFT,150,Messages.Constants_ReferenceDocument,false),
+ new Column(COMMENT,Align.LEFT,200,Messages.Constants_Comment,true)
};
public static String[] SOURCE_OBJECT_COLUMN_KEYS = {NAME,REFERENCE,COMMENT};
public static Column[] SOURCE_OBJECT_COLUMNS = new Column[] {
- new Column(NAME,Align.LEFT,200,"Name",false),
- new Column(REFERENCE,Align.LEFT,150,"Reference Document",false),
- new Column(COMMENT,Align.LEFT,200,"Comment",true)
+ new Column(NAME,Align.LEFT,200,Messages.Constants_Name,false),
+ new Column(REFERENCE,Align.LEFT,150,Messages.Constants_RefernceDocument,false),
+ new Column(COMMENT,Align.LEFT,200,Messages.Constants_Comment,true)
};
}
import java.util.List;
import java.util.Stack;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.simantics.Simantics;
import org.simantics.db.ReadGraph;
public void run() {
System.out.println(target);
try {
- Pair<Collection<Resource>, Collection<Resource>> refs = Simantics.getSession().syncRequest(new FindFixable(target));
- String dialogTitle = "Fix References";
- String dialogMessage = "Fix " + refs.first.size() + " old references and " + refs.second.size() + " removed references?";
- String dialogButtonLabels[] = new String[]{"Ok","Cancel"};
+ Pair<Collection<Resource>, Collection<Resource>> refs = Simantics.getSession()
+ .syncRequest(new FindFixable(target));
+ String dialogTitle = Messages.FixAllReferencesAction_FixReferences;
+ String dialogMessage = NLS.bind(Messages.FixAllReferencesAction_FixOldReferences,
+ new Object[] { refs.first.size(), refs.second.size() });
+ String dialogButtonLabels[] = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
int defaultIndex = 0;
if (refs.first.size() == 0 && refs.second.size() == 0) {
- dialogMessage = "Nothing to fix.";
- dialogButtonLabels = new String[]{"OK"};
- MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), dialogTitle, null, dialogMessage, MessageDialog.CONFIRM, dialogButtonLabels, defaultIndex);
+ dialogMessage = Messages.FixAllReferencesAction_NothingToFix;
+ dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL };
+ MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), dialogTitle,
+ null, dialogMessage, MessageDialog.CONFIRM, dialogButtonLabels, defaultIndex);
dialog.open();
return;
}
- MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), dialogTitle, null, dialogMessage, MessageDialog.CONFIRM, dialogButtonLabels, defaultIndex);
+ MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), dialogTitle, null,
+ dialogMessage, MessageDialog.CONFIRM, dialogButtonLabels, defaultIndex);
if (dialog.open() != 0)
return;
Simantics.getSession().markUndoPoint();
Simantics.getSession().syncRequest(new FixAll(refs));
} catch (DatabaseException e) {
- ExceptionUtils.logAndShowError("Cannot fix references", e);
+ ExceptionUtils.logAndShowError(Messages.FixAllReferencesAction_CannotFixReferences, e);
}
}
};
--- /dev/null
+package org.simantics.document.linking.ge;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.document.linking.ge.messages"; //$NON-NLS-1$
+ public static String Constants_Comment;
+ public static String Constants_Name;
+ public static String Constants_ReferenceDocument;
+ public static String Constants_RefernceDocument;
+ public static String Constants_Value;
+ public static String FixAllReferencesAction_CannotFixReferences;
+ public static String FixAllReferencesAction_FixOldReferences;
+ public static String FixAllReferencesAction_FixReferences;
+ public static String FixAllReferencesAction_NothingToFix;
+ public static String ShowDocumentAction_CannotOpenEditor;
+ public static String ShowDocumentWithAction_CannotOpenEditor;
+ public static String ShowDocumentWithAction_OpenWith;
+ public static String SourceObjectDropAction_CannotCreateDocumentLink;
+ public static String SourceObjectDropAction_DocumentLink;
+ public static String VariableLabelRule_DeletedReference;
+ public static String VariableLabelRule_LabelDefault;
+ public static String VariableLabelRule_NoValue;
+ public static String VariableLabelRule_ReferencesDoesNotExists;
+ public static String VariableLabelRule_ReferencesHasNotBeenSet;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
try {
adapter.openEditor(reference);
} catch (Exception e) {
- ExceptionUtils.logAndShowError("Cannot open editor", e);
+ ExceptionUtils.logAndShowError(Messages.ShowDocumentAction_CannotOpenEditor, e);
}
}
});
dialog.setContentProvider(new ArrayContentProvider());
dialog.setLabelProvider(new EditorAdapterLabelProvider());
dialog.setInput(adapters);
- dialog.setTitle("Open with");
+ dialog.setTitle(Messages.ShowDocumentWithAction_OpenWith);
if (dialog.open() != ListDialog.OK)
return;
EditorAdapter adapter = (EditorAdapter)dialog.getResult()[0];
adapter.openEditor(reference);
} catch (Exception e) {
- ExceptionUtils.logAndShowError("Cannot open editor", e);
+ ExceptionUtils.logAndShowError(Messages.ShowDocumentWithAction_CannotOpenEditor, e);
}
}
});
package org.simantics.document.linking.ge;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.simantics.Simantics;
import org.simantics.db.ReadGraph;
@Override
public void run() {
- String dialogMessage = "Cannot create document link to \"" + label +"\":" + e.getMessage();
- MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), "Document Link", null, dialogMessage, MessageDialog.INFORMATION, new String[]{"OK"}, 0);
+ String dialogMessage = NLS.bind(Messages.SourceObjectDropAction_CannotCreateDocumentLink , new Object[] { label , e.getMessage() });
+ MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), Messages.SourceObjectDropAction_DocumentLink, null, dialogMessage, MessageDialog.INFORMATION, new String[]{ IDialogConstants.OK_LABEL }, 0);
dialog.open();
}
});
import java.util.Map;
+import org.eclipse.osgi.util.NLS;
import org.simantics.browsing.ui.model.labels.LabelRule;
import org.simantics.databoard.Bindings;
import org.simantics.db.ReadGraph;
if (graph.isInstanceOf(node, sl.Source)) {
Resource reference = SourceLinkUtil.getReferredDocument(graph, node);
String comment = graph.getPossibleRelatedValue(node, sl.hasSourceComment);
- labels[0] = "";
- labels[1] = "";
- labels[3] = comment != null ? comment : "";
+ labels[0] = ""; //$NON-NLS-1$
+ labels[1] = ""; //$NON-NLS-1$
+ labels[3] = comment != null ? comment : ""; //$NON-NLS-1$
if (reference != null) {
if (SourceLinkUtil.isValidReference(graph, reference)) {
labels[2] = NameUtils.getSafeLabel(graph, reference);
} else {
- labels[2] = "Deleted reference";
+ labels[2] = Messages.VariableLabelRule_DeletedReference;
}
} else {
if (graph.getPossibleRelatedValue(node, sl.hasSourceReferenceURI, Bindings.STRING) != null) {
- labels[2] = "Reference does not exist";
+ labels[2] = Messages.VariableLabelRule_ReferencesDoesNotExists;
} else {
- labels[2] = "Reference has not been set";
+ labels[2] = Messages.VariableLabelRule_ReferencesHasNotBeenSet;
}
}
} else {
- labels[0] = "";
+ labels[0] = ""; //$NON-NLS-1$
}
if (graph.hasValue(node)) {
Object value = graph.getValue(node);
labels[1] = SourceLinkUtil.getValueString(value);
} else if (!graph.isInstanceOf(node, l0.SCLValue)){
- labels[1] = "No Value";
+ labels[1] = Messages.VariableLabelRule_NoValue;
} else {
- labels[1] = "";
+ labels[1] = ""; //$NON-NLS-1$
}
if (defaultValue) {
- labels[1] +=" (default)";
+ NLS.bind(Messages.VariableLabelRule_LabelDefault,labels[1] );
}
- labels[2] = "";
- labels[3] = "";
+ labels[2] = ""; //$NON-NLS-1$
+ labels[3] = ""; //$NON-NLS-1$
} else {
labels[0] = NameUtils.getSafeLabel(graph, node);//graph.getRelatedValue(node, l0.HasName);
if (labels[0].length() == 0)
labels[0] = NameUtils.getSafeName(graph, node);//graph.getRelatedValue(node, l0.HasName);
- labels[1] = "";
- labels[2] = "";
- labels[3] = "";
+ labels[1] = ""; //$NON-NLS-1$
+ labels[2] = ""; //$NON-NLS-1$
+ labels[3] = ""; //$NON-NLS-1$
}
--- /dev/null
+Constants_Comment=Comment\r
+Constants_Name=Name\r
+Constants_ReferenceDocument=Reference Document\r
+Constants_RefernceDocument=Reference Document\r
+Constants_Value=Value\r
+FixAllReferencesAction_CannotFixReferences=Cannot fix references\r
+FixAllReferencesAction_FixOldReferences=Fix {0} old references and \r
+FixAllReferencesAction_FixReferences=Fix References\r
+FixAllReferencesAction_NothingToFix=Nothing to fix.\r
+ShowDocumentAction_CannotOpenEditor=Cannot open editor\r
+ShowDocumentWithAction_CannotOpenEditor=Cannot open editor\r
+ShowDocumentWithAction_OpenWith=Open with\r
+SourceObjectDropAction_CannotCreateDocumentLink=Cannot create document link to "{0}":{1}\r
+SourceObjectDropAction_DocumentLink=Document Link\r
+VariableLabelRule_DeletedReference=Deleted reference\r
+VariableLabelRule_LabelDefault={0} (default)\r
+VariableLabelRule_NoValue=No Value\r
+VariableLabelRule_ReferencesDoesNotExists=Reference does not exist\r
+VariableLabelRule_ReferencesHasNotBeenSet=Reference has not been set\r
*/
public interface Document {
- public static String TOC = "toc";
+ public static String TOC = "toc"; //$NON-NLS-1$
public enum TextSize {TINY,SMALL,MEDIUM,LARGE,HUGE};
ReportWriter<?> reportWriter = (ReportWriter<?>)context.get(ReportWriter.class);
CustomizableContent content = null;
if (reportWriter instanceof CustomizableContentProvider) {
- content = ((CustomizableContentProvider)reportWriter).getContent("Title");
+ content = ((CustomizableContentProvider)reportWriter).getContent("Title"); //$NON-NLS-1$
}
if (content == null)
- writeTitle(getDefaultLines(graph, (Resource)context.get("model"), (String)context.get("DocumentName")));
+ writeTitle(getDefaultLines(graph, (Resource)context.get("model"), (String)context.get("DocumentName"))); //$NON-NLS-1$ //$NON-NLS-2$
else {
- List<DocumentLine> lines = content.getLines(graph, (Resource)context.get("model"), context);
+ List<DocumentLine> lines = content.getLines(graph, (Resource)context.get("model"), context); //$NON-NLS-1$
writeTitle(lines);
}
}
Document lineWriter = null;
try {
- if (filename.toLowerCase().endsWith(".pdf"))
- lineWriter = new PDFDocument(filename, new Font("Arial", Font.PLAIN, 10),new Font("Arial", Font.BOLD, 10));
- else if (filename.toLowerCase().endsWith(".html") ||
- filename.toLowerCase().endsWith(".htm"))
+ if (filename.toLowerCase().endsWith(".pdf")) //$NON-NLS-1$
+ lineWriter = new PDFDocument(filename, new Font("Arial", Font.PLAIN, 10),new Font("Arial", Font.BOLD, 10)); //$NON-NLS-1$ //$NON-NLS-2$
+ else if (filename.toLowerCase().endsWith(".html") || //$NON-NLS-1$
+ filename.toLowerCase().endsWith(".htm")) //$NON-NLS-1$
lineWriter = new HTMLDocument(new File(filename));
else {
- throw new Exception("File has unknow extension " + filename);
+ throw new Exception("File has unknow extension " + filename); //$NON-NLS-1$
}
export(lineWriter, reportWriter, monitor);
} catch (Exception e) {
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not generate report", e);
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ExportToPDF_ActivatorCouldNotGenerateReport, e);
} finally {
if (lineWriter != null) {
try {
}
}
- String status = "Report generated.";
+ String status = Messages.ExportToPDF_ReportGenerated;
// if (lineWriter instanceof PDFTableWriter) {
// status += " Report size " + ((PDFTableWriter)lineWriter).getCurrentPageIndex() + " pages.";
// }
try {
Map<Object, Object> context = new HashMap<Object, Object>();
- context.put("model", model);
+ context.put("model", model); //$NON-NLS-1$
context.put(Document.class, document);
context.put(ReportWriter.class, reportWriter);
- context.put("DocumentName", reportWriter.getName());
+ context.put("DocumentName", reportWriter.getName()); //$NON-NLS-1$
reportWriter.start(graph, model, document, context);
List<T> list = reportWriter.getReportItems(graph);
- monitor.beginTask("Write Report", list.size());
+ monitor.beginTask(Messages.ExportToPDF_MonitorWriteReport, list.size());
T previous = null;
T current = null;
--- /dev/null
+package org.simantics.document.linking.report;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.document.linking.report.messages"; //$NON-NLS-1$
+ public static String ExportToPDF_ActivatorCouldNotGenerateReport;
+ public static String ExportToPDF_MonitorWriteReport;
+ public static String ExportToPDF_ReportGenerated;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
@Override
public ImageDescriptor getImage() {
if (alignment == Alignment.LEFT) {
- return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_align_left.png");
+ return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_align_left.png"); //$NON-NLS-1$ //$NON-NLS-2$
} else if (alignment == Alignment.CENTER) {
- return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_align_center.png");
+ return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_align_center.png"); //$NON-NLS-1$ //$NON-NLS-2$
} else {
- return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_align_right.png");
+ return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_align_right.png"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
public And() {
- separator = " ";
+ separator = " "; //$NON-NLS-1$
}
public And(String separator) {
@Override
public String getValue(ReadGraph graph, Variable variable, Map<Object, Object> context) throws DatabaseException {
- String s = "";
+ String s = ""; //$NON-NLS-1$
for (int i = 0 ; i < children.size(); i++) {
String s2 = children.get(i).getValue(graph, variable, context);
if (s2 != null) {
@Override
public String toString() {
- return "and " + "(" + separator +")" ;
+ return "and " + "(" + separator +")" ; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@RelatedGetValue(DocumentLink.URIs.EvaluatorTree_HasValue)
@Override
public ImageDescriptor getImage() {
- return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_columns.png");
+ return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_columns.png"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
public Constant() {
- string = "text";
+ string = "text"; //$NON-NLS-1$
}
public Constant(String text) {
if (text == null)
- throw new NullPointerException("Text is null");
+ throw new NullPointerException("Text is null"); //$NON-NLS-1$
string = text;
}
@Override
public String toString() {
- return "\"" + string + "\"";
+ return "\"" + string + "\""; //$NON-NLS-1$ //$NON-NLS-2$
}
@RelatedGetValue(DocumentLink.URIs.EvaluatorTree_HasValue)
@Override
public ImageDescriptor getImage() {
- return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/textfield.png");
+ return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/textfield.png"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
public static List<NamedResource> getTemplates(final Resource library) throws DatabaseException{
if (library == null)
- throw new IllegalArgumentException("Library cannot be null");
+ throw new IllegalArgumentException("Library cannot be null"); //$NON-NLS-1$
List<NamedResource> templates = Simantics.getSession().syncRequest(new Read<List<NamedResource>>() {
@Override
public List<NamedResource> perform(ReadGraph graph) throws DatabaseException{
@Override
public ImageDescriptor getImage() {
- return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/date.png");
+ return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/date.png"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@Override
public String toString() {
- return "root";
+ return "root"; //$NON-NLS-1$
}
@Override
@Override
public String getValue(ReadGraph graph, Variable variable, Map<Object, Object> context) throws DatabaseException {
if (children.size() > 3)
- throw new DatabaseException("If node has more than 3 children.");
+ throw new DatabaseException("If node has more than 3 children."); //$NON-NLS-1$
String ifVal = children.get(0).getValue(graph, variable, context);
if (ifVal != null && ifVal.length() > 0 && !Boolean.FALSE.toString().equals(ifVal)) {
@Override
public List<DocumentLine> getLines(ReadGraph graph, Variable variable, Map<Object, Object> context) throws DatabaseException {
if (children.size() > 3)
- throw new DatabaseException("If node has more than 3 children.");
+ throw new DatabaseException("If node has more than 3 children."); //$NON-NLS-1$
String ifVal = children.get(0).getValue(graph, variable, context);
if (ifVal != null && ifVal.length() > 0 && !Boolean.FALSE.toString().equals(ifVal)) {
return children.get(1).getLines(graph, variable, context);
@Override
public String toString() {
- return "if";
+ return "if"; //$NON-NLS-1$
}
@Override
@Override
public ImageDescriptor getImage() {
- return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/help.png");
+ return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/help.png"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Override
@Override
public String getValue(ReadGraph graph, Variable variable, Map<Object, Object> context) throws DatabaseException {
- String s = "";
+ String s = ""; //$NON-NLS-1$
for (int i = 0 ; i < children.size(); i++) {
String s2 = children.get(i).getValue(graph, variable, context);
if (s2 != null) {
s+= s2;
if (i < children.size()-1)
- s+=System.getProperty("line.separator");
+ s+=System.getProperty("line.separator"); //$NON-NLS-1$
}
}
if (s.length() == 0)
@Override
public String toString() {
- return "Lines" ;
+ return "Lines" ; //$NON-NLS-1$
}
@Override
public ImageDescriptor getImage() {
- return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_linespacing.png");
+ return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_linespacing.png"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@Override
public String toString() {
- return "or";
+ return "or"; //$NON-NLS-1$
}
@Override
@Override
public ImageDescriptor getImage() {
- return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_list_numbers.png");
+ return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_list_numbers.png"); //$NON-NLS-1$ //$NON-NLS-2$
}
String separator;
public Path() {
- separator = "/";
+ separator = "/"; //$NON-NLS-1$
}
public Path(String separator) {
@Override
public String toString() {
- return "path " + "(" + separator +")" ;
+ return "path " + "(" + separator +")" ; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@Override
@Override
public String getValue(ReadGraph graph, Variable variable,
Map<Object, Object> context) throws DatabaseException {
- Resource model = (Resource)context.get("model");
- String text = "";
+ Resource model = (Resource)context.get("model"); //$NON-NLS-1$
+ String text = ""; //$NON-NLS-1$
Variable parent = variable.getParent(graph);
while (parent != null) {
text = children.get(0).getValue(graph, parent, context) + separator + text;
public List<DocumentLine> getLines(ReadGraph graph, Variable variable,
Map<Object, Object> context) throws DatabaseException {
List<DocumentLine> result = new ArrayList<DocumentLine>();
- Resource model = (Resource)context.get("model");
+ Resource model = (Resource)context.get("model"); //$NON-NLS-1$
for (int i = 0 ; i < children.size(); i++) {
Variable parent = variable.getParent(graph);
while (parent != null) {
@Override
public ImageDescriptor getImage() {
- return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/folder.png");
+ return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/folder.png"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Override
*
*/
public class PredefinedVariables {
- public static final String root = "root";
- public static final String project = "project";
- public static final String model = "model";
- public static final String template = "template";
- public static final String current = ".";
+ public static final String root = "root"; //$NON-NLS-1$
+ public static final String project = "project"; //$NON-NLS-1$
+ public static final String model = "model"; //$NON-NLS-1$
+ public static final String template = "template"; //$NON-NLS-1$
+ public static final String current = "."; //$NON-NLS-1$
private static PredefinedVariables factory = new PredefinedVariables();
if (colonInx != -1 && firstFlashInx != -1 && colonInx+1 == firstFlashInx && path.length() > firstFlashInx+1){
String scheme = path.substring(0, colonInx);
String absPath = path.substring(firstFlashInx+1);
- if (scheme.equals("pre")){
+ if (scheme.equals("pre")){ //$NON-NLS-1$
int endOfPredefined1 = absPath.indexOf('/');
int endOfPredefined2 = absPath.indexOf('#');
if (endOfPredefined1 == -1 && endOfPredefined2 == -1)
Variable property = null;
if (relativePath != null){
- if (relativePath.startsWith("/."))
+ if (relativePath.startsWith("/.")) //$NON-NLS-1$
relativePath = relativePath.substring(1);
property = v.browsePossible(graph, relativePath);
}
@Override
public ImageDescriptor getImage() {
if (textSize == TextSize.TINY) {
- return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_heading_5.png");
+ return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_heading_5.png"); //$NON-NLS-1$ //$NON-NLS-2$
} else if (textSize == TextSize.SMALL) {
- return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_heading_4.png");
+ return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_heading_4.png"); //$NON-NLS-1$ //$NON-NLS-2$
} else if (textSize == TextSize.MEDIUM) {
- return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_heading_3.png");
+ return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_heading_3.png"); //$NON-NLS-1$ //$NON-NLS-2$
} else if (textSize == TextSize.LARGE) {
- return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_heading_2.png");
+ return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_heading_2.png"); //$NON-NLS-1$ //$NON-NLS-2$
} else if (textSize == TextSize.HUGE) {
- return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_heading_1.png");
+ return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/text_heading_1.png"); //$NON-NLS-1$ //$NON-NLS-2$
} else {
return null;
}
@GraphType(DocumentLink.URIs.EvaluatorTree_Variable)
public class Variable extends EvaluatorLeaf implements StringEditableNode{
- String variableRef = "#HasName";
+ String variableRef = "#HasName"; //$NON-NLS-1$
public Variable() {
@Override
public String setValue(String value) {
if (value.length() == 0)
- return "Variable reference cannot be empty";
+ return "Variable reference cannot be empty"; //$NON-NLS-1$
variableRef = value;
return null;
}
@Override
public ImageDescriptor getImage() {
- return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/database_go.png");
+ return Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/database_go.png"); //$NON-NLS-1$ //$NON-NLS-2$
}
index = index + 1;
uniqueIndex.put(cls,index);
- return cls.getSimpleName() +"_"+index;
+ return cls.getSimpleName() +"_"+index; //$NON-NLS-1$
}
String getUniqueId(HTMLElement element) {
Class<? extends HTMLElement> cls = element.getClass();
private static String getDataUrl() throws IOException {
Bundle b = Platform.getBundle(Activator.PLUGIN_ID);
- URL dataUrl = FileLocator.find(b, new Path("report"), null);
+ URL dataUrl = FileLocator.find(b, new Path("report"), null); //$NON-NLS-1$
URL fileUrl = FileLocator.toFileURL(dataUrl);
- return URLDecoder.decode(fileUrl.getPath(), "UTF-8");
+ return URLDecoder.decode(fileUrl.getPath(), "UTF-8"); //$NON-NLS-1$
}
private void copyBaseCSS(String cssUrl) throws Exception {
- File f = new File(URLDecoder.decode(cssUrl, "UTF-8")).getAbsoluteFile();
+ File f = new File(URLDecoder.decode(cssUrl, "UTF-8")).getAbsoluteFile(); //$NON-NLS-1$
copyData(f, os);
}
private void header() throws Exception {
PrintStream resultOs = os;
- String cssUrl = getDataUrl() +"/report.css";
- resultOs.println("<!DOCTYPE html>");
- resultOs.println("<html lang=\"en\">");
- resultOs.println("<head>");
- resultOs.println(" <meta charset=\"utf-8\">");
- resultOs.println(" <title>Report</title>");
+ String cssUrl = getDataUrl() +"/report.css"; //$NON-NLS-1$
+ resultOs.println("<!DOCTYPE html>"); //$NON-NLS-1$
+ resultOs.println("<html lang=\"en\">"); //$NON-NLS-1$
+ resultOs.println("<head>"); //$NON-NLS-1$
+ resultOs.println(" <meta charset=\"utf-8\">"); //$NON-NLS-1$
+ resultOs.println(" <title>Report</title>"); //$NON-NLS-1$
if (referCSS)
- resultOs.println(" <link rel=\"stylesheet\" href=\"" + cssUrl + "\" type=\"text/css\">");
- resultOs.println(" <style>");
+ resultOs.println(" <link rel=\"stylesheet\" href=\"" + cssUrl + "\" type=\"text/css\">"); //$NON-NLS-1$ //$NON-NLS-2$
+ resultOs.println(" <style>"); //$NON-NLS-1$
if (!referCSS) {
copyBaseCSS(cssUrl);
}
- resultOs.println(" </style>");
- resultOs.println("</head>");
- resultOs.println("<body>");
+ resultOs.println(" </style>"); //$NON-NLS-1$
+ resultOs.println("</head>"); //$NON-NLS-1$
+ resultOs.println("<body>"); //$NON-NLS-1$
}
private void footer() throws Exception{
toc.close();
content.close();
PrintStream resultOs = os;
- resultOs.println("</body>");
- resultOs.println("</html>");
+ resultOs.println("</body>"); //$NON-NLS-1$
+ resultOs.println("</html>"); //$NON-NLS-1$
}
@Override
return (T)getOrCreateToc();
} else if (cls == DocumentTitlePage.class) {
if (titlePage != null)
- throw new Exception("Document many have only one title page");
+ throw new Exception("Document many have only one title page"); //$NON-NLS-1$
titlePage = new HTMLTitlePage(this);
return (T)titlePage;
}
public HTMLStreamElement(File file) throws Exception{
parent = null;
this.file = file;
- os = new PrintStream(file,"UTF-8");
+ os = new PrintStream(file,"UTF-8"); //$NON-NLS-1$
}
public HTMLStreamElement(HTMLStreamElement parent) throws Exception{
}
private void openStream() throws IOException {
- file = File.createTempFile("report_content", ".html");
- os = new PrintStream(file,"UTF-8");
+ file = File.createTempFile("report_content", ".html"); //$NON-NLS-1$ //$NON-NLS-2$
+ os = new PrintStream(file,"UTF-8"); //$NON-NLS-1$
}
public TableRow writeRowRaw(List<String> line) throws Exception {
if (currentLine == 0)
startTable();
- String clz = "\"";
- clz += currentLine % 2 == 0 ? "even" : "odd";
- clz += " "+currentTextSize;
- clz += "\"";
- os.println(" <tr class=" + clz+ ">");
+ String clz = "\""; //$NON-NLS-1$
+ clz += currentLine % 2 == 0 ? "even" : "odd"; //$NON-NLS-1$ //$NON-NLS-2$
+ clz += " "+currentTextSize; //$NON-NLS-1$
+ clz += "\""; //$NON-NLS-1$
+ os.println(" <tr class=" + clz+ ">"); //$NON-NLS-1$ //$NON-NLS-2$
if (line.size() > 1) {
for (int i = 0; i < line.size(); i++) {
String s = line.get(i);
Alignment a = columns.get(i).getAlignment();
- String tdClass = "class=\"" +a.toString()+"\"";
+ String tdClass = "class=\"" +a.toString()+"\""; //$NON-NLS-1$ //$NON-NLS-2$
if (s != null)
- os.println(" <td "+tdClass+">" + s + "</td>");
+ os.println(" <td "+tdClass+">" + s + "</td>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
else
- os.println(" <td> </td>");
+ os.println(" <td> </td>"); //$NON-NLS-1$
}
} else if (line.size() == 1){
String s = line.get(0);
Alignment a = columns.get(0).getAlignment();
- String tdClass = "class=\"" +a.toString()+"\"";
+ String tdClass = "class=\"" +a.toString()+"\""; //$NON-NLS-1$ //$NON-NLS-2$
if (s != null)
- os.println(" <td "+tdClass + " colspan=\"" + columns.size()+"\">" + s + "</td>");
+ os.println(" <td "+tdClass + " colspan=\"" + columns.size()+"\">" + s + "</td>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
else
- os.println(" <td colspan=\"" + columns.size()+"\"> </td>");
+ os.println(" <td colspan=\"" + columns.size()+"\"> </td>"); //$NON-NLS-1$ //$NON-NLS-2$
} else {
- os.println(" <td colspan=\"" + columns.size()+"\"> </td>");
+ os.println(" <td colspan=\"" + columns.size()+"\"> </td>"); //$NON-NLS-1$ //$NON-NLS-2$
}
- os.println(" </tr>");
+ os.println(" </tr>"); //$NON-NLS-1$
currentLine++;
writer.currentLine++;
return new HTMLTableRow(null);
public TableRow writeRowRaw2(List<TextItem> line) throws Exception {
if (currentLine == 0)
startTable();
- String clz = "\"";
- clz += currentLine % 2 == 0 ? "even" : "odd";
- clz += " "+currentTextSize;
- clz += "\"";
- os.println(" <tr class=" + clz+ ">");
+ String clz = "\""; //$NON-NLS-1$
+ clz += currentLine % 2 == 0 ? "even" : "odd"; //$NON-NLS-1$ //$NON-NLS-2$
+ clz += " "+currentTextSize; //$NON-NLS-1$
+ clz += "\""; //$NON-NLS-1$
+ os.println(" <tr class=" + clz+ ">"); //$NON-NLS-1$ //$NON-NLS-2$
if (line.size() > 1) {
for (int i = 0; i < line.size(); i++) {
TextItem item = line.get(i);
Alignment a = columns.get(i).getAlignment();
- String tdClass = "class=\"" +a.toString()+"\"";
+ String tdClass = "class=\"" +a.toString()+"\""; //$NON-NLS-1$ //$NON-NLS-2$
if (item != null && item.getText() != null)
- os.println(" <td "+tdClass+">" + item.toString() + "</td>");
+ os.println(" <td "+tdClass+">" + item.toString() + "</td>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
else
- os.println(" <td> </td>");
+ os.println(" <td> </td>"); //$NON-NLS-1$
}
} else if (line.size() == 1){
String s = line.get(0).toString();
Alignment a = columns.get(0).getAlignment();
- String tdClass = "class=\"" +a.toString()+"\"";
+ String tdClass = "class=\"" +a.toString()+"\""; //$NON-NLS-1$ //$NON-NLS-2$
if (s != null)
- os.println(" <td "+tdClass + " colspan=\"" + columns.size()+"\">" + s + "</td>");
+ os.println(" <td "+tdClass + " colspan=\"" + columns.size()+"\">" + s + "</td>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
else
- os.println(" <td colspan=\"" + columns.size()+"\"> </td>");
+ os.println(" <td colspan=\"" + columns.size()+"\"> </td>"); //$NON-NLS-1$ //$NON-NLS-2$
} else {
- os.println(" <td colspan=\"" + columns.size()+"\"> </td>");
+ os.println(" <td colspan=\"" + columns.size()+"\"> </td>"); //$NON-NLS-1$ //$NON-NLS-2$
}
- os.println(" </tr>");
+ os.println(" </tr>"); //$NON-NLS-1$
currentLine++;
writer.currentLine++;
return new HTMLTableRow(null);
void style() {
for (int i = 0; i < columns.size(); i++) {
- os.println("table."+classID+" th.column"+i+" {");
- os.println(" width: " + ((int)(columns.get(i).getWidth()*100.0)) + "%;");
- os.println("}");
+ os.println("table."+classID+" th.column"+i+" {"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ os.println(" width: " + ((int)(columns.get(i).getWidth()*100.0)) + "%;"); //$NON-NLS-1$ //$NON-NLS-2$
+ os.println("}"); //$NON-NLS-1$
}
}
void startTable() {
if (id != null) {
- os.println("<a id=\"" + id + "\"></a>");
+ os.println("<a id=\"" + id + "\"></a>"); //$NON-NLS-1$ //$NON-NLS-2$
}
- String clz = classID + " " + (linesVisible ? "lines" : "nolines");
- os.println("<table class=\"" + clz +"\" >");
+ String clz = classID + " " + (linesVisible ? "lines" : "nolines"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ os.println("<table class=\"" + clz +"\" >"); //$NON-NLS-1$ //$NON-NLS-2$
if (headerVisible) {
if (title != null)
- os.println(" <caption>"+title+"</caption>");
- os.println(" <thead>");
- os.println(" <tr class=MEDIUM>");
+ os.println(" <caption>"+title+"</caption>"); //$NON-NLS-1$ //$NON-NLS-2$
+ os.println(" <thead>"); //$NON-NLS-1$
+ os.println(" <tr class=MEDIUM>"); //$NON-NLS-1$
int ci = 0;
for (TableColumn c : columns) {
- os.println(" <th class=\"column" + ci +"\">" + escape(c.getName()) + "</th>");
+ os.println(" <th class=\"column" + ci +"\">" + escape(c.getName()) + "</th>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ci++;
}
- os.println(" </tr>");
- os.println(" </thead>");
+ os.println(" </tr>"); //$NON-NLS-1$
+ os.println(" </thead>"); //$NON-NLS-1$
}
- os.println(" <tbody>");
+ os.println(" <tbody>"); //$NON-NLS-1$
}
void endTable() throws Exception{
if (currentLine > 0) {
- os.println(" </tbody>");
- os.println("</table>");
- os.println("<br>");
+ os.println(" </tbody>"); //$NON-NLS-1$
+ os.println("</table>"); //$NON-NLS-1$
+ os.println("<br>"); //$NON-NLS-1$
if (!copyStyle) {
- os.println("<style>");
+ os.println("<style>"); //$NON-NLS-1$
style();
- os.println("</style>");
+ os.println("</style>"); //$NON-NLS-1$
}
}
}
public void writeTitle(List<DocumentLine> lines) throws Exception {
writer.nextPage();
for (DocumentLine line : lines) {
- String hTag = "h4";
+ String hTag = "h4"; //$NON-NLS-1$
if (line.getHints().containsKey(TextSize.class)) {
TextSize size = (TextSize)line.getHints().get(TextSize.class);
switch (size) {
case HUGE:
- hTag = "h1";
+ hTag = "h1"; //$NON-NLS-1$
break;
case LARGE:
- hTag = "h2";
+ hTag = "h2"; //$NON-NLS-1$
break;
case MEDIUM:
- hTag = "h3";
+ hTag = "h3"; //$NON-NLS-1$
break;
case SMALL:
- hTag = "h4";
+ hTag = "h4"; //$NON-NLS-1$
break;
case TINY:
- hTag = "h5";
+ hTag = "h5"; //$NON-NLS-1$
break;
default:
break;
}
}
- writer.os.println("<"+hTag +">" + line.getLine() + "</"+hTag+">");
+ writer.os.println("<"+hTag +">" + line.getLine() + "</"+hTag+">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
writer.nextPage();
public HTMLTocElement(HTMLDocument writer) throws Exception{
super(writer);
- this.os.println("<h2>Table of Contents</h2>");
+ this.os.println(Messages.HTMLTocElement_TocHeading);
tocTable = new HTMLTable(writer, os, false);
tocTable.setHeaderVisible(false);
tocTable.setLinesVisible(false);
- tocTable.addColumn("Name", 1.0);
+ tocTable.addColumn("Name", 1.0); //$NON-NLS-1$
}
@Override
public void addTocElement(String label, DocumentElement element) throws Exception{
HTMLElement e = (HTMLElement)element;
if (e.getId() == null)
- throw new IllegalArgumentException("Element has no id " + element);
+ throw new IllegalArgumentException("Element has no id " + element); //$NON-NLS-1$
//os.println("<a href=\"#" + e.getId() + "\">" + label + "</a><br>");
- tocTable.writeRow("<a href=\"#" + e.getId() + "\">" + label + "</a><br>");
+ tocTable.writeRow("<a href=\"#" + e.getId() + "\">" + label + "</a><br>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
public void close() throws Exception{
tocTable.endTable();
- os.print("<br>");
+ os.print("<br>"); //$NON-NLS-1$
super.close();
}
@Override
public String getId() {
- return "toc";
+ return "toc"; //$NON-NLS-1$
}
}
@Override
public String toString() {
if (getURL() != null)
- return "<a href=\"" + getURL().toString() + "\">" + getText() + "</a>";
+ return "<a href=\"" + getURL().toString() + "\">" + getText() + "</a>"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return super.toString();
}
--- /dev/null
+package org.simantics.document.linking.report.html;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.document.linking.report.html.messages"; //$NON-NLS-1$
+ public static String HTMLTocElement_TocHeading;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
--- /dev/null
+HTMLTocElement_TocHeading=<h2>Table of Contents</h2>
--- /dev/null
+ExportToPDF_ActivatorCouldNotGenerateReport=Could not generate report\r
+ExportToPDF_MonitorWriteReport=Write Report\r
+ExportToPDF_ReportGenerated=Report generated.\r
--- /dev/null
+package org.simantics.document.linking.report.pdf;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.document.linking.report.pdf.messages"; //$NON-NLS-1$
+ public static String PDFTocElement_TocHeading;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
}
private void defaultFonts() {
- fonts.put(TextSize.TINY, new Font("Arial", Font.PLAIN, 6));
- fonts.put(TextSize.SMALL, new Font("Arial", Font.PLAIN, 8));
- fonts.put(TextSize.MEDIUM, new Font("Arial", Font.PLAIN, 10));
- fonts.put(TextSize.LARGE, new Font("Arial", Font.PLAIN, 16));
- fonts.put(TextSize.HUGE, new Font("Arial", Font.BOLD, 24));
+ fonts.put(TextSize.TINY, new Font("Arial", Font.PLAIN, 6)); //$NON-NLS-1$
+ fonts.put(TextSize.SMALL, new Font("Arial", Font.PLAIN, 8)); //$NON-NLS-1$
+ fonts.put(TextSize.MEDIUM, new Font("Arial", Font.PLAIN, 10)); //$NON-NLS-1$
+ fonts.put(TextSize.LARGE, new Font("Arial", Font.PLAIN, 16)); //$NON-NLS-1$
+ fonts.put(TextSize.HUGE, new Font("Arial", Font.BOLD, 24)); //$NON-NLS-1$
contentStream.setDefaultFont(fonts.get(TextSize.SMALL));
}
return (T)getOrCreateToc();
} else if (cls == DocumentTitlePage.class) {
if (titlePage != null)
- throw new Exception("Report may contain only one title page");
+ throw new Exception("Report may contain only one title page"); //$NON-NLS-1$
titlePage = new PDFTitlePage(this);
return (T)titlePage;
}
if (currentTable != null && currentTable.currentLine > 0) {
currentTable.setLinesVisible(false);
currentTable.setHeaderVisible(false);
- currentTable.writeLine("");
+ currentTable.writeLine(""); //$NON-NLS-1$
}
}
this.stream = stream;
Rectangle pageSize = stream.getPageSize();
document = new Document(pageSize);
- tempFile = File.createTempFile("ReportGenerator", ".pdf");
+ tempFile = File.createTempFile("ReportGenerator", ".pdf"); //$NON-NLS-1$ //$NON-NLS-2$
writer = PdfWriter.getInstance(document, new FileOutputStream(tempFile));
document.open();
this.cb = writer.getDirectContent();
// Find possible line break and set it as a limit to the next layout
next = lineMeasurer.nextOffset(cellWidth);
limit = next;
- charat = text.indexOf(System.getProperty("line.separator"),position+1);
+ charat = text.indexOf(System.getProperty("line.separator"),position+1); //$NON-NLS-1$
if(charat < next && charat != -1){
limit = charat;
}
document.nextPage();
this.page = document.contentStream.getCurrentPage();
Table table = document.newElement(Table.class);
- table.addColumn("Names", 1.0).setAlignment(alignment);
+ table.addColumn("Names", 1.0).setAlignment(alignment); //$NON-NLS-1$
table.setLinesVisible(false);
table.setHeaderVisible(false);
table.setTextSize(textSize);
int lines = (document.contentStream.getAvailableLines()-3)/2;
for (int i = 0; i < lines; i++)
- table.writeRow("");
+ table.writeRow(""); //$NON-NLS-1$
for (DocumentLine line : titleLines) {
TextSize s = (TextSize)line.getHints().get(TextSize.class);
if (s != null)
//linesPerPage = stream.getAvailableLines();
PDFPage page = stream.getCurrentPage();
page.setFont(titleFont);
- page.writeLine("Table of Contents");
+ page.writeLine(Messages.PDFTocElement_TocHeading);
page.setFont(itemFont);
- page.writeLine("");
+ page.writeLine(""); //$NON-NLS-1$
linesOnFirstPage = tocTable.getAvailableLines();
//linesOnFirstPage = page.availableLines;
}
List<PDFPage> pages = destStream.getPages();
int tocIndex = pages.indexOf(after)+1;
- tocTable.addColumn("Document", 0.9);
- tocTable.addColumn("Page", 0.1).setAlignment(Alignment.RIGHT);
+ tocTable.addColumn("Document", 0.9); //$NON-NLS-1$
+ tocTable.addColumn("Page", 0.1).setAlignment(Alignment.RIGHT); //$NON-NLS-1$
tocTable.setHeaderVisible(false);
tocTable.setLinesVisible(false);
for (Pair<String, PDFElement> item : toc) {
--- /dev/null
+PDFTocElement_TocHeading=Table of Contents
@Override
public String getName() {
- return "Complete Structure";
+ return "Complete Structure"; //$NON-NLS-1$
}
@Override
writer.newElement(TableOfContents.class);
Table table = writer.newElement(Table.class,Document.TOC);
- table.addColumn("Name", 0.2);
- table.addColumn("Attribute", 0.2);
- table.addColumn("Value", 0.15);
- table.addColumn("Document", 0.2);
- table.addColumn("Comment", 0.25);
+ table.addColumn("Name", 0.2); //$NON-NLS-1$
+ table.addColumn("Attribute", 0.2); //$NON-NLS-1$
+ table.addColumn("Value", 0.15); //$NON-NLS-1$
+ table.addColumn("Document", 0.2); //$NON-NLS-1$
+ table.addColumn("Comment", 0.25); //$NON-NLS-1$
//lineWriter.nextPage();
}
if (obj != null) {
- String text = "";
+ String text = ""; //$NON-NLS-1$
List<Resource> path = SourceLinkUtil.getDiagramPath(graph, model, obj);
if (path == null) {
Resource r = path.get(i);
text += parentComparator.getText(r);
if (i < path.size()-2)
- text += "/";
+ text += "/"; //$NON-NLS-1$
}
} else {
for (int i = 0 ; i < path.size(); i++) {
Resource r = path.get(i);
text += parentComparator.getText(r);
if (i < path.size()-1)
- text += "/";
+ text += "/"; //$NON-NLS-1$
}
}
//row[0] = text;
toc.addTocElement(text, table);
} else {
//row[0] = "Hierarchy missing";
- table.setTitle("Hierarchy missing");
+ table.setTitle("Hierarchy missing"); //$NON-NLS-1$
}
}
}
text[2].setText(SourceLinkUtil.getValueString(value));
}
} else {
- text[1].setText("Error in property reference");
+ text[1].setText(Messages.CompleteStructureWriter_ErrorInPropertyRefrence);
}
}
Resource document = SourceLinkUtil.getReferredDocument(graph, source);
@Override
public String getName() {
- return "Diagram structure with dependencies";
+ return "Diagram structure with dependencies"; //$NON-NLS-1$
}
@Override
@Override
public String getName() {
- return "Diagram structure";
+ return "Diagram structure"; //$NON-NLS-1$
}
@Override
titlePage.writeTitle(graph, context);
Table table = lineWriter.newElement(Table.class);
- table.addColumn("Name", 0.4);
- table.addColumn("Document", 0.6);
+ table.addColumn("Name", 0.4); //$NON-NLS-1$
+ table.addColumn("Document", 0.6); //$NON-NLS-1$
//lineWriter.nextPage();
List<Resource> path = SourceLinkUtil.getDiagramPath(graph, model, obj);
if (writer.getAvailableLines() < 2)
writer.nextPage();
- String text = "";
+ String text = ""; //$NON-NLS-1$
for (int i = 0 ; i < path.size(); i++) {
Resource r = path.get(i);
text += diagramComparator.getText(r);
if (i < path.size()-1)
- text += "/";
+ text += "/"; //$NON-NLS-1$
}
row[0].setText(text);
} else {
- row[0].setText("Hierarchy missing");
+ row[0].setText(Messages.DiagramStructureWriter_Hierarchymissing);
}
}
@Override
public String getName() {
- return "Document Structure";
+ return "Document Structure"; //$NON-NLS-1$
}
@Override
titlePage.writeTitle(graph, context);
writer.newElement(TableOfContents.class);
Table table = writer.newElement(Table.class,Document.TOC);
- table.addColumn("Name", 0.2);
- table.addColumn("Attribute", 0.35);
- table.addColumn("Value", 0.15);
- table.addColumn("Comment", 0.3);
+ table.addColumn("Name", 0.2); //$NON-NLS-1$
+ table.addColumn("Attribute", 0.35); //$NON-NLS-1$
+ table.addColumn("Value", 0.15); //$NON-NLS-1$
+ table.addColumn("Comment", 0.3); //$NON-NLS-1$
//lineWriter.nextPage();
this.graph = graph;
if (path != null) {
TextSize size = table.getTextSize();
table.setTextSize(TextSize.MEDIUM);
- table.writeRow(" " + diagramComparator.getText(path.get(path.size()-1)));
+ table.writeRow(" " + diagramComparator.getText(path.get(path.size()-1))); //$NON-NLS-1$
table.setTextSize(size);
}
}
text[2].setText(SourceLinkUtil.getValueString(value));
}
} else {
- text[1].setText("Error in property reference ");
+ text[1].setText(Messages.DocumentStructureWriter_ErrorInPropertyReference);
}
}
@Override
public void setDefaultContent(String id) {
- if ("Document".equals(id) || id == null) {
- EvaluatorCustomizableContent c = new EvaluatorCustomizableContent("Document format");
+ if ("Document".equals(id) || id == null) { //$NON-NLS-1$
+ EvaluatorCustomizableContent c = new EvaluatorCustomizableContent("Document format"); //$NON-NLS-1$
Or item = new Or();
- item.addChild(new Variable("#HasLabel"));
- item.addChild(new Variable("#HasName"));
+ item.addChild(new Variable("#HasLabel")); //$NON-NLS-1$
+ item.addChild(new Variable("#HasName")); //$NON-NLS-1$
c.setItem(item);
c.setSupportStyles(false);
c.setSupportMultiline(true);
- content.put("Document", c);
+ content.put("Document", c); //$NON-NLS-1$
}
- if ("Title".equals(id) || id == null) {
- EvaluatorCustomizableContent e = new EvaluatorCustomizableContent("Document Title");
+ if ("Title".equals(id) || id == null) { //$NON-NLS-1$
+ EvaluatorCustomizableContent e = new EvaluatorCustomizableContent("Document Title"); //$NON-NLS-1$
EvaluatorNode lines = new Lines();
Or nameOr = new Or();
- nameOr.createChild(Variable.class).setVariableRef("#HasLabel");
- nameOr.createChild(Variable.class).setVariableRef("#HasName");
+ nameOr.createChild(Variable.class).setVariableRef("#HasLabel"); //$NON-NLS-1$
+ nameOr.createChild(Variable.class).setVariableRef("#HasName"); //$NON-NLS-1$
lines.createChild(TextSizeHint.class).setTextSize(TextSize.HUGE).createChild(AlignmentHint.class).setAlignment(Alignment.CENTER).addChild(nameOr.copy());
- lines.createChild(TextSizeHint.class).setTextSize(TextSize.HUGE).createChild(AlignmentHint.class).setAlignment(Alignment.CENTER).createChild(Variable.class).setVariableRef("DocumentName");
+ lines.createChild(TextSizeHint.class).setTextSize(TextSize.HUGE).createChild(AlignmentHint.class).setAlignment(Alignment.CENTER).createChild(Variable.class).setVariableRef("DocumentName"); //$NON-NLS-1$
lines.createChild(TextSizeHint.class).setTextSize(TextSize.LARGE).createChild(AlignmentHint.class).setAlignment(Alignment.CENTER).createChild(Date.class);
e.setItem(lines);
e.setSupportStyles(true);
e.setSupportMultiline(true);
- content.put("Title", e);
+ content.put("Title", e); //$NON-NLS-1$
}
}
} else {
item = this.document.newItem(TextItem.class);
}
- item.setText(getContent("Document").getContent(graph, document,context));
+ item.setText(getContent("Document").getContent(graph, document,context)); //$NON-NLS-1$
return item;
}
protected TextItem getNonExistingDocumentItem() throws Exception{
TextItem item = this.document.newItem(TextItem.class);
- item.setText("[DOCUMENT DOES NOT EXIST]");
+ item.setText(Messages.DocumentWriter_DocumentDoesNotExist);
return item;
}
--- /dev/null
+package org.simantics.document.linking.report.templates;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.document.linking.report.templates.messages"; //$NON-NLS-1$
+ public static String CompleteStructureWriter_ErrorInPropertyRefrence;
+ public static String DiagramStructureWriter_Hierarchymissing;
+ public static String DocumentStructureWriter_ErrorInPropertyReference;
+ public static String DocumentWriter_DocumentDoesNotExist;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
@Override
public String getName() {
- return "Model Internal Documents";
+ return "Model Internal Documents"; //$NON-NLS-1$
}
@Override
DocumentTitlePage titlePage = lineWriter.newElement(DocumentTitlePage.class);
titlePage.writeTitle(graph, context);
Table table = lineWriter.newElement(Table.class);
- table.addColumn("Folder", 0.4);
- table.addColumn("Document", 0.6);
+ table.addColumn("Folder", 0.4); //$NON-NLS-1$
+ table.addColumn("Document", 0.6); //$NON-NLS-1$
//lineWriter.nextPage();
this.graph = graph;
private String getText(List<Resource> current, boolean indent) throws DatabaseException {
- String text = "";
+ String text = ""; //$NON-NLS-1$
if (indent)
for (int i = 0; i < current.size()-1; i++) {
- text += " ";
+ text += " "; //$NON-NLS-1$
}
text += NameUtils.getSafeLabel(graph, current.get(current.size()-1));
private class DocumentContentProvider implements RowContentProvider<List<Resource>> {
public void setText(Document writer, java.util.List<Resource> previous, java.util.List<Resource> current, java.util.List<Resource> next, TextItem[] row) throws Exception {
- String s = "";
+ String s = ""; //$NON-NLS-1$
Resource document = current.get(current.size()-1);
int rev = revisionIndex(document);
for (int i = 0; i < rev; i++)
- s += " ";
+ s += " "; //$NON-NLS-1$
row[1] = getDocumentItem(document);
row[1].setText(s + row[1].getText());
};
@Override
public String getName() {
- return "Referred Documents";
+ return "Referred Documents"; //$NON-NLS-1$
}
public String getContent(ReadGraph graph, Resource resource, Map<Object, Object> context)
throws DatabaseException {
if (!SourceLinkUtil.isValidReference(graph, resource))
- return "Deleted reference";
+ return "Deleted reference"; //$NON-NLS-1$
Variable variable = graph.adapt(resource, Variable.class);
return item.getValue(graph, variable,context);
}
public List<DocumentLine> getLines(ReadGraph graph, Resource resource, Map<Object, Object> context)
throws DatabaseException {
if (!SourceLinkUtil.isValidReference(graph, resource))
- return Collections.singletonList(new DocumentLine("Deleted reference"));
+ return Collections.singletonList(new DocumentLine("Deleted reference")); //$NON-NLS-1$
Variable variable = graph.adapt(resource, Variable.class);
return item.getLines(graph, variable,context);
}
public SCLCustomizableContent(String label) {
session = new CommandSession(SCLOsgi.MODULE_REPOSITORY, null);
- sclCode = new String[]{"import \"Simantics/Ontologies\"",
- "nameOfResource r = match possibleRelatedValue r L0.HasName with\n"+
- " Just name -> name\n"+
- " Nothing -> \"no name\"",
- "nameOfResource res"};
+ sclCode = new String[]{"import \"Simantics/Ontologies\"", //$NON-NLS-1$
+ "nameOfResource r = match possibleRelatedValue r L0.HasName with\n"+ //$NON-NLS-1$
+ " Just name -> name\n"+ //$NON-NLS-1$
+ " Nothing -> \"no name\"", //$NON-NLS-1$
+ "nameOfResource res"}; //$NON-NLS-1$
}
@Override
public String getContent(ReadGraph graph, Resource resource, Map<Object, Object> context)
throws DatabaseException {
- session.setVariable("res", Types.con("Simantics/DB", "Resource"), resource);
+ session.setVariable("res", Types.con("Simantics/DB", "Resource"), resource); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
final StringBuilder responseBuilder = new StringBuilder();
final StringBuilder errorBuilder = new StringBuilder();
for (String code : sclCode) {
}
});
if(errorBuilder.length() > 0)
- throw new DatabaseException("Error executing SCL \"" + code + "\" " + errorBuilder.toString().trim());
+ throw new DatabaseException("Error executing SCL \"" + code + "\" " + errorBuilder.toString().trim()); //$NON-NLS-1$ //$NON-NLS-2$
}
return responseBuilder.toString().trim();
}
--- /dev/null
+CompleteStructureWriter_ErrorInPropertyRefrence=Error in property reference\r
+DiagramStructureWriter_Hierarchymissing=Hierarchy missing\r
+DocumentStructureWriter_ErrorInPropertyReference=Error in property reference \r
+DocumentWriter_DocumentDoesNotExist=[DOCUMENT DOES NOT EXIST]\r
--- /dev/null
+package org.simantics.document.linking.utils;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.document.linking.utils.messages"; //$NON-NLS-1$
+ public static String SourceLinkUtil_DatabaseExceptionDocumentInDifferentModel;
+ public static String SourceLinkUtil_DatabaseExceptionLocNotModelPart;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
Resource link = null;
DependencyCheckResult result = checkDependecies(graph, document, instance);
if (result == DependencyCheckResult.NoLocationModel)
- throw new DatabaseException("Location of document link is not part of a model.");
+ throw new DatabaseException(Messages.SourceLinkUtil_DatabaseExceptionLocNotModelPart);
if (result == DependencyCheckResult.DifferentModel) {
- throw new DatabaseException("Location of document link and document are in different models, document link cannot be created.");
+ throw new DatabaseException(Messages.SourceLinkUtil_DatabaseExceptionDocumentInDifferentModel);
}
if (result == DependencyCheckResult.NoReferenceModel) {
//referred document and location are not in the same model, create an URI reference.
}
public static Resource createInstanceSource(WriteGraph graph, Resource reference, Resource location) throws DatabaseException {
- return createInstanceSource(graph, reference, location, "");
+ return createInstanceSource(graph, reference, location, ""); //$NON-NLS-1$
}
public static Resource createInstanceSource(WriteGraph graph, Resource reference, Resource location, String comment) throws DatabaseException {
}
public static Resource createInstanceSource(WriteGraph graph, String reference, Resource location) throws DatabaseException {
- return createInstanceSource(graph, reference, location, "");
+ return createInstanceSource(graph, reference, location, ""); //$NON-NLS-1$
}
public static Resource createInstanceSource(WriteGraph graph, String reference, Resource location, String comment) throws DatabaseException {
}
public static Resource createFunctionalSource(WriteGraph graph, Resource reference, Resource location, Resource relation) throws DatabaseException {
- return createFunctionalSource(graph, reference, location, relation, "");
+ return createFunctionalSource(graph, reference, location, relation, ""); //$NON-NLS-1$
}
}
public static Resource createFunctionalSource(WriteGraph graph, String reference, Resource location, Resource relation) throws DatabaseException {
- return createFunctionalSource(graph, reference, location, relation, "");
+ return createFunctionalSource(graph, reference, location, relation, ""); //$NON-NLS-1$
}
} else if (value instanceof Object[]) {
return Arrays.toString((Object[])value);
} else {
- return "TODO: Array " + value.getClass().getSimpleName();
+ return "TODO: Array " + value.getClass().getSimpleName(); //$NON-NLS-1$
}
} else {
return value.toString();
}
public static String getCustomizedString(ReadGraph graph, Resource document, List<String> annotationContent) throws DatabaseException{
- String label = "";
+ String label = ""; //$NON-NLS-1$
Variable doc = graph.adapt(document, Variable.class);
for (String path : annotationContent) {
- if (path.startsWith("\"") && path.endsWith("\"")) {
- label += path.substring(1,path.length()-1)+ " ";
+ if (path.startsWith("\"") && path.endsWith("\"")) { //$NON-NLS-1$ //$NON-NLS-2$
+ label += path.substring(1,path.length()-1)+ " "; //$NON-NLS-1$
} else {
Variable v = PredefinedVariables.getInstance().getVariable(graph, path, null, doc);
if (v != null) {
- label += v.getValue(graph) + " ";
+ label += v.getValue(graph) + " "; //$NON-NLS-1$
}
}
}
--- /dev/null
+SourceLinkUtil_DatabaseExceptionDocumentInDifferentModel=Location of document link and document are in different models, document link cannot be created.\r
+SourceLinkUtil_DatabaseExceptionLocNotModelPart=Location of document link is not part of a model.\r
--- /dev/null
+package org.simantics.document.linking.views;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.document.linking.views.messages"; //$NON-NLS-1$
+ public static String SourceView_All;
+ public static String SourceView_Browsing;
+ public static String SourceView_LinkAll;
+ public static String SourceView_LinkDocuments;
+ public static String SourceView_Linking;
+ public static String SourceView_OldRemoved;
+ public static String SourceView_PinSelection;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
/**
* The ID of the view as specified by the extension.
*/
- public static final String ID = "org.simantics.document.linking.views.SourceView";
+ public static final String ID = "org.simantics.document.linking.views.SourceView"; //$NON-NLS-1$
private Composite composite;
composite.setLayout(new FillLayout());
tabFolder = new TabFolder(composite, SWT.NONE);
TabItem link = new TabItem(tabFolder, SWT.NONE);
- link.setText("Linking");
+ link.setText(Messages.SourceView_Linking);
TabItem browse = new TabItem(tabFolder, SWT.NONE);
- browse.setText("Browsing");
+ browse.setText(Messages.SourceView_Browsing);
linkComposite = new Composite(tabFolder, SWT.NONE);
link.setControl(linkComposite);
}
});
Button checkingButton = new Button(browseComposite, SWT.TOGGLE);
- checkingButton.setText("All");
+ checkingButton.setText(Messages.SourceView_All);
checkingButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean checked = button.getSelection();
browseExplorer.dispose();
createModelExplorer(checked,support,browseComposite);
- button.setText(checked ? "Old/Removed" : "All");
+ button.setText(checked ? Messages.SourceView_OldRemoved : Messages.SourceView_All);
if (currentModel != null)
setModel(currentModel, true);
browseComposite.getParent().layout(true, true);
}
private void createModelExplorer(boolean onlyCheckable,WidgetSupport support,Composite browseComposite) {
- browseExplorer = new SourceLinkExplorerComposite(ArrayMap.keys("displaySelectors", "displayFilter","treeView").values(false, false, true), selectionProvider,getSite(), browseComposite, support,false, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
+ browseExplorer = new SourceLinkExplorerComposite(ArrayMap.keys("displaySelectors", "displayFilter","treeView").values(false, false, true), selectionProvider,getSite(), browseComposite, support,false, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
if(!onlyCheckable)
browseExplorer.setBrowseContexts(DocumentLink.URIs.ModelViewpointBrowseContext, DocumentLink.URIs.ModelViewpointActionContext);
else
browseExplorer.setInputSource(new SingleSelectionInputSource(Resource.class));
browseExplorer.getExplorer().setAutoExpandLevel(2); // Expand everything in the beginning
browseExplorer.setColumnsVisible(true);
- browseExplorer.setContextMenuId("#SourceModelViewPopup");
+ browseExplorer.setContextMenuId("#SourceModelViewPopup"); //$NON-NLS-1$
browseExplorer.finish();
((Tree)browseExplorer.getExplorer().getControl()).setLinesVisible(true);
}
private void createLinkTab(final Composite linkComposite) {
- objectExplorer = new SourceLinkExplorerComposite(ArrayMap.keys("displaySelectors", "displayFilter","treeView").values(false, false,true), selectionProvider,getSite(), linkComposite, support, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
+ objectExplorer = new SourceLinkExplorerComposite(ArrayMap.keys("displaySelectors", "displayFilter","treeView").values(false, false,true), selectionProvider,getSite(), linkComposite, support, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
objectExplorer.setBrowseContexts(DocumentLink.URIs.SourceObjectViewpointBrowseContext, DocumentLink.URIs.SourceObjectViewpointActionContext);
objectExplorer.setColumns(Constants.SOURCE_OBJECT_COLUMNS);
objectExplorer.setInputSource(new SingleSelectionInputSource(Resource.class));
objectExplorer.getExplorer().setAutoExpandLevel(2); // Expand everything in the beginning
objectExplorer.setColumnsVisible(true);
- objectExplorer.setContextMenuId("#SourceObjectViewPopup");
+ objectExplorer.setContextMenuId("#SourceObjectViewPopup"); //$NON-NLS-1$
objectExplorer.finish();
((Tree)objectExplorer.getExplorer().getControl()).setLinesVisible(true);
final Sash sash = new Sash (linkComposite, SWT.HORIZONTAL);
- propertyExplorer = new SourceLinkExplorerComposite(ArrayMap.keys("displaySelectors", "displayFilter","treeView").values(false, false,true), selectionProvider,getSite(), linkComposite, support, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
+ propertyExplorer = new SourceLinkExplorerComposite(ArrayMap.keys("displaySelectors", "displayFilter","treeView").values(false, false,true), selectionProvider,getSite(), linkComposite, support, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
propertyExplorer.setBrowseContexts(DocumentLink.URIs.SourcePropertyViewpointBrowseContext, DocumentLink.URIs.SourcePropertyViewpointActionContext);
propertyExplorer.setColumns(Constants.SOURCE_COLUMNS);
propertyExplorer.setInputSource(new SingleSelectionInputSource(Resource.class));
propertyExplorer.getExplorer().setAutoExpandLevel(2); // Expand everything in the beginning
propertyExplorer.setColumnsVisible(true);
- propertyExplorer.setContextMenuId("#SourcePropertyViewPopup");
+ propertyExplorer.setContextMenuId("#SourcePropertyViewPopup"); //$NON-NLS-1$
propertyExplorer.finish();
((Tree)propertyExplorer.getExplorer().getControl()).setLinesVisible(true);
}
private void makeActions() {
- pinSelectionAction = new Action("Pin selection", Action.AS_CHECK_BOX) {
+ pinSelectionAction = new Action(Messages.SourceView_PinSelection, Action.AS_CHECK_BOX) {
public void run() {
pinSelection = isChecked();
}
};
// action1.setToolTipText("Action 1 tooltip");
- pinSelectionAction.setImageDescriptor(Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/lock.png"));
+ pinSelectionAction.setImageDescriptor(Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/lock.png")); //$NON-NLS-1$ //$NON-NLS-2$
- linkAllAction = new Action("Link All", Action.AS_RADIO_BUTTON) {
+ linkAllAction = new Action(Messages.SourceView_LinkAll, Action.AS_RADIO_BUTTON) {
@Override
public void run() {
setAcceptedObject(AcceptedObject.ALL);
}
};
- linkDocumentsAction = new Action("Link Documents", Action.AS_RADIO_BUTTON) {
+ linkDocumentsAction = new Action(Messages.SourceView_LinkDocuments, Action.AS_RADIO_BUTTON) {
@Override
public void run() {
setAcceptedObject(AcceptedObject.DOCUMENT);
--- /dev/null
+SourceView_All=All\r
+SourceView_Browsing=Browsing\r
+SourceView_LinkAll=Link All\r
+SourceView_LinkDocuments=Link Documents\r
+SourceView_Linking=Linking\r
+SourceView_OldRemoved=Old/Removed\r
+SourceView_PinSelection=Pin selection\r
viewer.setLabelProvider(new EvaluatorLabelProvider());
viewer.setCellEditors(new CellEditor[]{new EvaluatorNodeCellEditor(viewer.getTree())});
viewer.setCellModifier(new EvaluatorNodeCellModifier());
- viewer.setColumnProperties(new String[]{"value"});
+ viewer.setColumnProperties(new String[]{"value"}); //$NON-NLS-1$
viewer.setInput(root);
viewer.getTree().addMenuDetectListener(new MenuDetectListener() {
final EvaluatorItem item = i;
Menu menu = new Menu(viewer.getControl());
MenuItem add = new MenuItem(menu, SWT.CASCADE);
- add.setText("Add");
+ add.setText(Messages.EvaluatorConfigurationWidget_Add);
Menu addMenu = new Menu(menu);
add.setMenu(addMenu);
- add.setImage(manager.createImage(AbstractUIPlugin.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/arrow_right.png")));
+ add.setImage(manager.createImage(AbstractUIPlugin.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/arrow_right.png"))); //$NON-NLS-1$ //$NON-NLS-2$
MenuItem insert = new MenuItem(menu, SWT.CASCADE);
- insert.setText("Insert");
+ insert.setText("Insert"); //$NON-NLS-1$
Menu insertMenu = new Menu(menu);
insert.setMenu(insertMenu);
- insert.setImage(manager.createImage(AbstractUIPlugin.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/arrow_left.png")));
+ insert.setImage(manager.createImage(AbstractUIPlugin.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/arrow_left.png"))); //$NON-NLS-1$ //$NON-NLS-2$
// add menu
if (item instanceof EvaluatorNode) {
insert.setEnabled(false);
MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
- menuItem.setText("Remove");
+ menuItem.setText(Messages.EvaluatorConfigurationWidget_Remove);
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
EvaluatorNode parent = item.getParent();
};
});
menuItem.setEnabled(item != root);
- menuItem.setImage(manager.createImage(AbstractUIPlugin.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/delete.png")));
+ menuItem.setImage(manager.createImage(AbstractUIPlugin.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/delete.png"))); //$NON-NLS-1$ //$NON-NLS-2$
menu.setLocation(event.x,event.y);
menu.setVisible(true);
}
return 0;
}
- return "";
+ return ""; //$NON-NLS-1$
}
@Override
public void modify(Object element, String property, Object value) {
--- /dev/null
+package org.simantics.document.linking.wizard;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.document.linking.wizard.messages"; //$NON-NLS-1$
+ public static String EvaluatorConfigurationWidget_Add;
+ public static String EvaluatorConfigurationWidget_Remove;
+ public static String ReportCustomizationPage_Defaults;
+ public static String ReportCustomizationPage_GiveTemplateName;
+ public static String ReportCustomizationPage_Library;
+ public static String ReportCustomizationPage_Load;
+ public static String ReportCustomizationPage_Name;
+ public static String ReportCustomizationPage_NameCannotBeEmpty;
+ public static String ReportCustomizationPage_Save;
+ public static String ReportCustomizationPage_SaveReportCustomizations;
+ public static String ReportGeneratePage_File;
+ public static String ReportGeneratePage_FileNotSelected;
+ public static String ReportGeneratePage_GenerateReport;
+ public static String ReportGeneratePage_GeneratingReport;
+ public static String ReportGeneratePage_Report;
+ public static String ReportGeneratePage_ReportFail;
+ public static String ReportGeneratePage_ReportFailed;
+ public static String ReportGeneratePage_ReportNotGenerated;
+ public static String ReportGeneratePage_ReportWriterNotSelected;
+ public static String ReportGeneratePage_ShowReport;
+ public static String ReportGeneratePage_Status;
+ public static String ReportSelectionPage_Browse;
+ public static String ReportSelectionPage_File;
+ public static String ReportSelectionPage_FilterHTMLDocument;
+ public static String ReportSelectionPage_FilterPDFDocument;
+ public static String ReportSelectionPage_Model;
+ public static String ReportSelectionPage_ReportTemplates;
+ public static String ReportWizard_CustomizeReport;
+ public static String ReportWizard_RunReport;
+ public static String ReportWizard_SelectReportParameters;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(loadButton);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(saveButton);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(resetButton);
- loadButton.setText("Load");
- saveButton.setText("Save");
- resetButton.setText("Defaults");
+ loadButton.setText(Messages.ReportCustomizationPage_Load);
+ saveButton.setText(Messages.ReportCustomizationPage_Save);
+ resetButton.setText(Messages.ReportCustomizationPage_Defaults);
loadButton.addSelectionListener(new SelectionAdapter() {
@Override
@Override
public Resource perform(ReadGraph graph) throws DatabaseException {
Layer0 l0 = Layer0.getInstance(graph);
- Resource lib = graph.syncRequest(new PossibleObjectWithName(model, l0.ConsistsOf,"Library"));
+ Resource lib = graph.syncRequest(new PossibleObjectWithName(model, l0.ConsistsOf,Messages.ReportCustomizationPage_Library));
if (lib != null)
return lib;
private void save() {
try {
- InputDialog dialog = new InputDialog(getShell(), "Save report customization", "Give template name", "Name", new NotNullValidator("Name cannot be empty"));
+ InputDialog dialog = new InputDialog(getShell(), Messages.ReportCustomizationPage_SaveReportCustomizations, Messages.ReportCustomizationPage_GiveTemplateName, Messages.ReportCustomizationPage_Name, new NotNullValidator(Messages.ReportCustomizationPage_NameCannotBeEmpty));
if (dialog.open() != InputDialog.OK)
return;
final String name = dialog.getValue();
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(2,false));
Label label = new Label(composite, SWT.NONE);
- label.setText("File:");
+ label.setText(Messages.ReportGeneratePage_File);
fileLabel = new Label(composite, SWT.NONE);
label = new Label(composite, SWT.NONE);
- label.setText("Report:");
+ label.setText(Messages.ReportGeneratePage_Report);
reportLabel = new Label(composite, SWT.NONE);
label = new Label(composite, SWT.NONE);
- label.setText("Status:");
+ label.setText(Messages.ReportGeneratePage_Status);
this.statusLabel = new Label(composite, SWT.NONE);
- this.statusLabel.setText("Report has not been generated");
+ this.statusLabel.setText(Messages.ReportGeneratePage_ReportNotGenerated);
generateButton = new Button(composite, SWT.PUSH);
- generateButton.setText("Generate report");
+ generateButton.setText(Messages.ReportGeneratePage_GenerateReport);
generateButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
}
});
showButton = new Button(composite, SWT.PUSH);
- showButton.setText("Show Report");
+ showButton.setText(Messages.ReportGeneratePage_ShowReport);
showButton.addSelectionListener(new SelectionAdapter() {
@Override
}
private void updateContent() {
- fileLabel.setText(filename == null ? "File has not been selected" : filename);
- reportLabel.setText(reportWriter == null ? "Report Writer has not been selected" : reportWriter.getName());
+ fileLabel.setText(filename == null ? Messages.ReportGeneratePage_FileNotSelected : filename);
+ reportLabel.setText(reportWriter == null ? Messages.ReportGeneratePage_ReportWriterNotSelected : reportWriter.getName());
generateButton.setEnabled(filename != null && reportWriter != null && model != null);
showButton.setEnabled(generated);
generateButton.setEnabled(!generated);
if (!generated)
- statusLabel.setText("Report has not been generated");
+ statusLabel.setText(Messages.ReportGeneratePage_ReportNotGenerated);
}
public void setGenerated(boolean b) {
private void generate() {
generateButton.setEnabled(false);
- statusLabel.setText("Generating report");
+ statusLabel.setText(Messages.ReportGeneratePage_GeneratingReport);
try {
getWizard().getContainer().run(true, false, new IRunnableWithProgress() {
}
});
} catch (InterruptedException err) {
- setErrorMessage("Report failed: " + err.getMessage());
- ErrorLogger.defaultLogError("Report failed.",err);
- statusLabel.setText("Report failed.");
+ setErrorMessage(NLS.bind(Messages.ReportGeneratePage_ReportFailed , err.getMessage()));
+ ErrorLogger.defaultLogError(Messages.ReportGeneratePage_ReportFail,err);
+ statusLabel.setText(Messages.ReportGeneratePage_ReportFail);
} catch (InvocationTargetException e) {
Throwable err = e.getCause();
- setErrorMessage("Report failed: " + err.getMessage());
- ErrorLogger.defaultLogError("Report failed.",err);
- statusLabel.setText("Report failed.");
+ setErrorMessage(NLS.bind(Messages.ReportGeneratePage_ReportFailed , err.getMessage()));
+ ErrorLogger.defaultLogError(Messages.ReportGeneratePage_ReportFail,err);
+ statusLabel.setText(Messages.ReportGeneratePage_ReportFail);
}
setGenerated(true);
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(3,false));
Label label = new Label(composite, SWT.NONE);
- label.setText("Model:");
+ label.setText(Messages.ReportSelectionPage_Model);
modelCombo = new CCombo(composite, SWT.BORDER|SWT.READ_ONLY);
label = new Label(composite, SWT.NONE);
- label.setText("File:");
+ label.setText(Messages.ReportSelectionPage_File);
filenameText = new Text(composite, SWT.BORDER|SWT.SINGLE);
browseButton = new Button(composite, SWT.PUSH);
- browseButton.setText("Browse");
+ browseButton.setText(Messages.ReportSelectionPage_Browse);
reportWriters.add(new ModelDocumentWriter());
reportWriters.add(new ReferredDocumentWriter());
reportWriters.add(new CompleteStructureWriter());
Group group = new Group(composite, SWT.NONE);
- group.setText("Report templates");
+ group.setText(Messages.ReportSelectionPage_ReportTemplates);
group.setLayout(new FillLayout(SWT.VERTICAL));
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(filenameText);
@Override
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(),SWT.SAVE);
- dialog.setFilterExtensions(new String[]{"*.pdf","*.html"});
- dialog.setFilterNames(new String[]{"PDF Document","HTML Document"});
+ dialog.setFilterExtensions(new String[]{"*.pdf","*.html"}); //$NON-NLS-1$ //$NON-NLS-2$
+ dialog.setFilterNames(new String[]{Messages.ReportSelectionPage_FilterPDFDocument,Messages.ReportSelectionPage_FilterHTMLDocument});
String filename = dialog.open();
if (filename == null)
- filenameText.setText("");
+ filenameText.setText(""); //$NON-NLS-1$
else
filenameText.setText(filename);
validate();
@Override
public void addPages() {
- reportSelectionPage = new ReportSelectionPage("Select report parameters");
- reportCustomizationPage = new ReportCustomizationPage("Customize report");
- reportGeneratePage = new ReportGeneratePage("Run Report");
+ reportSelectionPage = new ReportSelectionPage(Messages.ReportWizard_SelectReportParameters);
+ reportCustomizationPage = new ReportCustomizationPage(Messages.ReportWizard_CustomizeReport);
+ reportGeneratePage = new ReportGeneratePage(Messages.ReportWizard_RunReport);
addPage(reportSelectionPage);
addPage(reportCustomizationPage);
addPage(reportGeneratePage);
--- /dev/null
+EvaluatorConfigurationWidget_Add=Add\r
+EvaluatorConfigurationWidget_Remove=Remove\r
+ReportCustomizationPage_Defaults=Defaults\r
+ReportCustomizationPage_GiveTemplateName=Give template name\r
+ReportCustomizationPage_Library=Library\r
+ReportCustomizationPage_Load=Load\r
+ReportCustomizationPage_Name=Name\r
+ReportCustomizationPage_NameCannotBeEmpty=Name cannot be empty\r
+ReportCustomizationPage_Save=Save\r
+ReportCustomizationPage_SaveReportCustomizations=Save report customization\r
+ReportGeneratePage_File=File:\r
+ReportGeneratePage_FileNotSelected=File has not been selected\r
+ReportGeneratePage_GenerateReport=Generate report\r
+ReportGeneratePage_GeneratingReport=Generating report\r
+ReportGeneratePage_Report=Report:\r
+ReportGeneratePage_ReportFail=Report failed.\r
+ReportGeneratePage_ReportFailed=Report failed: {0}\r
+ReportGeneratePage_ReportNotGenerated=Report has not been generated\r
+ReportGeneratePage_ReportWriterNotSelected=Report Writer has not been selected\r
+ReportGeneratePage_ShowReport=Show Report\r
+ReportGeneratePage_Status=Status:\r
+ReportSelectionPage_Browse=Browse\r
+ReportSelectionPage_File=File:\r
+ReportSelectionPage_FilterHTMLDocument=HTML Document\r
+ReportSelectionPage_FilterPDFDocument=PDF Document\r
+ReportSelectionPage_Model=Model:\r
+ReportSelectionPage_ReportTemplates=Report templates\r
+ReportWizard_CustomizeReport=Customize report\r
+ReportWizard_RunReport=Run Report\r
+ReportWizard_SelectReportParameters=Select report parameters\r
* [x] org.simantics.db.procore.ui
* [x] org.simantics.debug.ui
* [x] org.simantics.desktop.ui
+* [x] org.simantics.document.linking.ui
* ...
-
## TODO ##
* /org.simantics.browsing.ui
* /org.simantics.browsing.ui.common (All can be ignored)
* /org.simantics.browsing.ui.platform (Nothing to Exeternalize or all can be ignored)
* /org.simantics.browsing.ui.swt (Nothing to Exeternalize or all can be ignored)
* /org.simantics.debug.browser.ui (Nothing to Exeternalize or all can be ignored)
-* /org.simantics.desktop.ui.ontology
+* /org.simantics.desktop.ui.ontology (No strings to externalize)
* /org.simantics.document.ui
* /org.simantics.document.ui.ontology
* /org.simantics.export.ui