Bundle bundle = context.getBundle();
- DOCUMENT_DECORATION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/document_decoration.png"));
- cross = ImageDescriptor.createFromURL(bundle.getResource("icons/silk_small/cross.png"));
- clock_red = ImageDescriptor.createFromURL(bundle.getResource("icons/silk_small/clock_red.png"));
+ DOCUMENT_DECORATION_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/document_decoration.png")); //$NON-NLS-1$
+ cross = ImageDescriptor.createFromURL(bundle.getResource("icons/silk_small/cross.png")); //$NON-NLS-1$
+ clock_red = ImageDescriptor.createFromURL(bundle.getResource("icons/silk_small/clock_red.png")); //$NON-NLS-1$
IPath ipath = Platform.getStateLocation(bundle);
location = Paths.get(ipath.toOSString());
public class CSSCompletionAssistProcessor implements IContentAssistProcessor {
- private String lastError = "";
+ private String lastError = ""; //$NON-NLS-1$
private CSSTextEditorEnvironment environment;
public CSSCompletionAssistProcessor(CSSTextEditorEnvironment environment) {
tmpOffset = selection.getOffset() + selection.getLength();
final int offset = tmpOffset;
IDocument document = viewer.getDocument();
- String tmpPrefix = "";
+ String tmpPrefix = ""; //$NON-NLS-1$
try {
tmpPrefix = getPrefix(document, offset);
} catch (BadLocationException e) {
private static String getPrefix(IDocument doc, int offset) throws BadLocationException {
if (doc == null || offset >= doc.getLength())
- return "";
+ return ""; //$NON-NLS-1$
int length= 0;
while (--offset >= 0 && Character.isJavaIdentifierPart(doc.getChar(offset)) || doc.getChar(offset) == '.')
public class CSSCompletionProposal implements ICompletionProposal, ICompletionProposalExtension, ICompletionProposalExtension2, ICompletionProposalExtension3, ICompletionProposalExtension4, ICompletionProposalExtension5 {
- private static final Image PRIVATE = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/private_co.gif").createImage();
- private static final Image PUBLIC = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/public_co.gif").createImage();
- private static final Image CONST = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/container_obj.gif").createImage();
- private static final Image TYPE = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/typedef_obj.gif").createImage();
+ private static final Image PRIVATE = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/private_co.gif").createImage(); //$NON-NLS-1$ //$NON-NLS-2$
+ private static final Image PUBLIC = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/public_co.gif").createImage(); //$NON-NLS-1$ //$NON-NLS-2$
+ private static final Image CONST = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/container_obj.gif").createImage(); //$NON-NLS-1$ //$NON-NLS-2$
+ private static final Image TYPE = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/typedef_obj.gif").createImage(); //$NON-NLS-1$ //$NON-NLS-2$
private final String content;
private final String name;
this.name = value.getName().name;
this.module = value.getName().module;
this.documentation = value.getDocumentation();
- this.content = name + " :: " + value.getType() + " (" + module + ")";
+ this.content = name + " :: " + value.getType() + " (" + module + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
this.replacementOffset = replacementOffset;
this.prefix = prefix;
// System.out.println(prefix);
public CSSCompletionProposal(String name, String module, CSSCompletionType completionType, int replacementOffset, String prefix) {
this.name = name;
this.module = module;
- this.content = name + " (" + module + ")";
+ this.content = name + " (" + module + ")"; //$NON-NLS-1$ //$NON-NLS-2$
this.documentation = null;
this.replacementOffset = replacementOffset;
this.prefix = prefix;
// String sadd = doc.get(start, end);
// System.out.println("toReplace : " + sadd);
if (p.y > 0) {
- doc.replace(p.x, p.y, "");
+ doc.replace(p.x, p.y, ""); //$NON-NLS-1$
doc.replace(offset, 0, getName());
} else {
String currentText = doc.get(offset - prefix.length(), prefix.length());
if (currentText.equals(getName()))
return;
- doc.replace(offset - prefix.length(), prefix.length(), "");
+ doc.replace(offset - prefix.length(), prefix.length(), ""); //$NON-NLS-1$
doc.replace(offset - prefix.length(), 0, getName());
}
} catch (BadLocationException x) {
*/
public class CSSEditor extends TextEditor {
- public static final String EDITOR_ID = "org.simantics.document.ui.csseditor";
+ public static final String EDITOR_ID = "org.simantics.document.ui.csseditor"; //$NON-NLS-1$
private boolean disposed = false;
try {
getResourceInput().init(null);
} catch (DatabaseException e) {
- throw new PartInitException("Failed to initialize " + input, e);
+ throw new PartInitException("Failed to initialize " + input, e); //$NON-NLS-1$
}
}
DocumentResource DOC = DocumentResource.getInstance(graph);
currentText = graph.getPossibleRelatedValue(resource, DOC.cssDocument, Bindings.STRING);
errorHappened = false;
- return new Document(currentText != null ? currentText : "");
+ return new Document(currentText != null ? currentText : ""); //$NON-NLS-1$
}
});
} catch (DatabaseException e) {
synchronized(annotationModel.getLockObject()) {
annotationModel.removeAllAnnotations();
for(CompilationError error : errors) {
- Annotation annotation = new Annotation("org.eclipse.ui.workbench.texteditor.error", true,
+ Annotation annotation = new Annotation("org.eclipse.ui.workbench.texteditor.error", true, //$NON-NLS-1$
error.description);
int begin = Locations.beginOf(error.location);
int end = Locations.endOf(error.location);
@Override
protected void doSaveDocument(IProgressMonitor monitor, Object element,
IDocument document, boolean overwrite) throws CoreException {
- TimeLogger.resetTimeAndLog("SCLModuleEditorDocumentProvider.doSaveDocument");
+ TimeLogger.resetTimeAndLog("SCLModuleEditorDocumentProvider.doSaveDocument"); //$NON-NLS-1$
currentText = document.get();
Simantics.getSession().asyncRequest(new WriteRequest() {
@Override
ITokenScanner getSclTokenScanner() {
RuleBasedScanner scanner = new RuleBasedScanner();
- Font font = new Font(device, "Courier New", 10, SWT.NORMAL);
- Font boldFont = new Font(device, "Courier New", 10, SWT.BOLD);
+ Font font = new Font(device, "Courier New", 10, SWT.NORMAL); //$NON-NLS-1$
+ Font boldFont = new Font(device, "Courier New", 10, SWT.BOLD); //$NON-NLS-1$
Token defaultToken = new Token(
new TextAttribute(
}
});
- reservedWord.addWord("if", reserved);
- reservedWord.addWord("then", reserved);
- reservedWord.addWord("else", reserved);
- reservedWord.addWord("match", reserved);
- reservedWord.addWord("with", reserved);
- reservedWord.addWord("data", reserved);
- reservedWord.addWord("type", reserved);
- reservedWord.addWord("class", reserved);
+ reservedWord.addWord("if", reserved); //$NON-NLS-1$
+ reservedWord.addWord("then", reserved); //$NON-NLS-1$
+ reservedWord.addWord("else", reserved); //$NON-NLS-1$
+ reservedWord.addWord("match", reserved); //$NON-NLS-1$
+ reservedWord.addWord("with", reserved); //$NON-NLS-1$
+ reservedWord.addWord("data", reserved); //$NON-NLS-1$
+ reservedWord.addWord("type", reserved); //$NON-NLS-1$
+ reservedWord.addWord("class", reserved); //$NON-NLS-1$
IRule[] rules = new IRule[] {
//new MultiLineRule("\"\"\"", "\"\"\"", string),
- new PatternRule("\"", "\"", string, '\\', true),
- new MultiLineRule("/*", "*/", comment),
- new EndOfLineRule("//", comment),
+ new PatternRule("\"", "\"", string, '\\', true), //$NON-NLS-1$ //$NON-NLS-2$
+ new MultiLineRule("/*", "*/", comment), //$NON-NLS-1$ //$NON-NLS-2$
+ new EndOfLineRule("//", comment), //$NON-NLS-1$
reservedWord
};
scanner.setRules(rules);
private class PinSelection extends Action {
public PinSelection() {
- super("Pin Selection", IAction.AS_CHECK_BOX);
+ super(Messages.DocumentView_PinSelection, IAction.AS_CHECK_BOX);
setImageDescriptor(
BundleUtils.getImageDescriptorFromPlugin(
- "org.eclipse.ui",
- "icons/full/etool16/pin_editor.png"));
+ "org.eclipse.ui", //$NON-NLS-1$
+ "icons/full/etool16/pin_editor.png")); //$NON-NLS-1$
}
@Override
--- /dev/null
+package org.simantics.document.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.document.ui.messages"; //$NON-NLS-1$
+ public static String DocumentView_PinSelection;
+ public static String OpenEntityDocumentAdapter_DocumentEditor;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
public class OpenEntityDocumentAdapter extends AbstractResourceEditorAdapter {
- private static final String EDITOR_ID = "org.simantics.document.ui.editor";
+ private static final String EDITOR_ID = "org.simantics.document.ui.editor"; //$NON-NLS-1$
public OpenEntityDocumentAdapter() throws MalformedURLException {
- super("Document Editor", ImageDescriptor.createFromURL(new URL(
- "platform:/plugin/com.famfamfam.silk/icons/table.png")));
+ super(Messages.OpenEntityDocumentAdapter_DocumentEditor, ImageDescriptor.createFromURL(new URL(
+ "platform:/plugin/com.famfamfam.silk/icons/table.png"))); //$NON-NLS-1$
}
protected String getEditorId() {
@Override
public void run() {
- InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), "Add URL", "Input URL", "", new URLValidator());
+ InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), Messages.AddUrlDocument_AddURL, Messages.AddUrlDocument_InputURL, "", new URLValidator()); //$NON-NLS-3$
if (dialog.open() != InputDialog.OK)
return;
final String uriString = dialog.getValue();
}
}, e -> {
if (e != null)
- ExceptionUtils.logAndShowError("Cannot add URL link.", e);
+ ExceptionUtils.logAndShowError(Messages.AddUrlDocument_CannotAddURLLink, e);
});
}
};
}, e -> {
dialog.getAnnotationConfigurator().dispose();
if (e != null)
- ExceptionUtils.logAndShowError("Cannot add URL link.", e);
+ ExceptionUtils.logAndShowError("Cannot add URL link.", e); //$NON-NLS-1$
});
}
};
}
public static Resource addUrlDocumentWithDetailSCL(WriteGraph graph, Resource target, String name, String uriString) throws DatabaseException {
- AddUrlDocumentWithDetail urlDocument = new AddUrlDocumentWithDetail(graph, "http://www.simantics.org/Layer0-1.1/ConsistsOf");
+ AddUrlDocumentWithDetail urlDocument = new AddUrlDocumentWithDetail(graph, "http://www.simantics.org/Layer0-1.1/ConsistsOf"); //$NON-NLS-1$
Resource urlResource = urlDocument.doAddUrl(graph, name, uriString);
urlDocument.linkDocument(graph, target, urlResource);
return urlResource;
return;
exportDocument(resource, filename);
} catch (DatabaseException e) {
- ExceptionUtils.logAndShowError("Cannot export document.", e);
+ ExceptionUtils.logAndShowError(Messages.ExportDocumentFile_CannotExportDocument, e);
}
}
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
public ExportDocumentFolder(ReadGraph graph, String relationUri, String useResourceNames) throws DatabaseException {
relation = graph.getResource(relationUri);
- this.useResourceNames = useResourceNames.equals("true");
+ this.useResourceNames = useResourceNames.equals("true"); //$NON-NLS-1$
}
@Override
File folder = new File(folderName);
int choice = -1;
if (folder.list().length > 0) {
- MessageDialog messageDialog = new MessageDialog(shell, "Folder export", null, "Selected folder \"" + folderName + "\" is not empty.", MessageDialog.QUESTION, new String[]{"Delete and export","Overwrite","Cancel"}, 2);
+ MessageDialog messageDialog = new MessageDialog(shell, Messages.ExportDocumentFolder_FolderExport, null, NLS.bind(Messages.ExportDocumentFolder_SelectedFolder, folderName), MessageDialog.QUESTION, new String[]{Messages.ExportDocumentFolder_DeleteAndExport,Messages.ExportDocumentFolder_Overwrite, IDialogConstants.CANCEL_LABEL }, 2); //$NON-NLS-3$
choice = messageDialog.open();
if (choice == 2)
return;
File folder;
boolean clear = false;
public ExportJob(Resource resource,File folder, boolean clear) {
- super("Export folder");
+ super(Messages.ExportDocumentFolder_ExportFolder);
this.resource = resource;
this.folder = folder;
this.clear = clear;
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
- monitor.beginTask("Export folder", IProgressMonitor.UNKNOWN);
+ monitor.beginTask(Messages.ExportDocumentFolder_ExportFolder, IProgressMonitor.UNKNOWN);
if (clear) {
GraphFileUtil.clearDirectoryStructure(folder);
monitor.worked(1);
}
FileDocumentUtil.exportDocumentFolder(resource, folder, relation, useResourceNames, monitor);
monitor.done();
- return new Status(IStatus.OK, Activator.PLUGIN_ID, "Folder exported.");
+ return new Status(IStatus.OK, Activator.PLUGIN_ID, Messages.ExportDocumentFolder_ActivatorFolderExported);
} catch (Exception e) {
monitor.done();
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Cannot export document folder.", e);
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ExportDocumentFolder_AcivatorCannotExport, e);
}
}
}
// if is, use those extensions to filter this list.
// note: in windows using "reg query ..." to read bindings form registry would work.
// Note : If the above mentioned filtering is implemented it should be made optional / configurable.
- dialog.setFilterExtensions(new String[]{"*.*"});
+ dialog.setFilterExtensions(new String[]{"*.*"}); //$NON-NLS-1$
if (dialog.open() == null) return;
String filterPath = dialog.getFilterPath();
String[] filenames = dialog.getFileNames();
- ImportJob job = new ImportJob(filenames.length > 1 ? "Import files" : "Import file", resource, filterPath, filenames);
+ ImportJob job = new ImportJob(filenames.length > 1 ? Messages.ImportDocument_JobImportFiles : Messages.ImportDocument_ImportFile, resource, filterPath, filenames);
job.setUser(true);
job.schedule();
}
@Override
protected IStatus run(final IProgressMonitor monitor) {
- monitor.beginTask("Importing...", filenames.length);
+ monitor.beginTask(Messages.ImportDocument_ImportingDots, filenames.length);
try {
Simantics.getSession().syncRequest(new WriteRequest() {
@Override
}
}
});
- return new Status(IStatus.OK, Activator.PLUGIN_ID, "Import succesful.");
+ return new Status(IStatus.OK, Activator.PLUGIN_ID, Messages.ImportDocument_ActivatorImportSucessful);
} catch (DatabaseException e) {
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import failed.", e);
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ImportDocument_ImportFailed, e);
} finally {
monitor.done();
}
return;
}
- ImportJob job = new ImportJob("Import folder", resource, filename);
+ ImportJob job = new ImportJob(Messages.ImportDocumentFolder_ImportFolder, resource, filename);
job.setUser(true);
job.schedule();
}
}
}
});
- return new Status(IStatus.OK, Activator.PLUGIN_ID, "Folder imported.");
+ return new Status(IStatus.OK, Activator.PLUGIN_ID, Messages.ImportDocumentFolder_ActivatorFolderImported);
} catch (DatabaseException e) {
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Cannot import document folder.", e);
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ImportDocumentFolder_ActivatorCannotImportDocumentFolder, e);
}
}
}
}, e -> {
dialog.getAnnotationConfigurator().dispose();
if (e != null)
- ExceptionUtils.logAndShowError("Cannot import document.", e);
+ ExceptionUtils.logAndShowError(Messages.ImportDocumentWithDetail_CannotImportDocument, e);
});
}
};
public static Resource importDocumentWithDetailSCL(WriteGraph graph, Resource target, String filename) throws FileNotFoundException, DatabaseException {
File file = new File(filename);
if (!file.exists())
- throw new FileNotFoundException("File not found - " + file.getAbsolutePath());
- ImportDocumentWithDetail document = new ImportDocumentWithDetail(graph, "http://www.simantics.org/Layer0-1.1/ConsistsOf");
+ throw new FileNotFoundException("File not found - " + file.getAbsolutePath()); //$NON-NLS-1$
+ ImportDocumentWithDetail document = new ImportDocumentWithDetail(graph, "http://www.simantics.org/Layer0-1.1/ConsistsOf"); //$NON-NLS-1$
return document.doDocumentImport(graph, target, filename, file.getName());
}
--- /dev/null
+package org.simantics.document.ui.actions;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.document.ui.actions.messages"; //$NON-NLS-1$
+ public static String AddUrlDocument_AddURL;
+ public static String AddUrlDocument_CannotAddURLLink;
+ public static String AddUrlDocument_InputURL;
+ public static String ExportDocumentFile_CannotExportDocument;
+ public static String ExportDocumentFolder_AcivatorCannotExport;
+ public static String ExportDocumentFolder_ActivatorFolderExported;
+ public static String ExportDocumentFolder_DeleteAndExport;
+ public static String ExportDocumentFolder_ExportFolder;
+ public static String ExportDocumentFolder_FolderExport;
+ public static String ExportDocumentFolder_Overwrite;
+ public static String ExportDocumentFolder_SelectedFolder;
+ public static String ImportDocument_ActivatorImportSucessful;
+ public static String ImportDocument_ImportFailed;
+ public static String ImportDocument_ImportFile;
+ public static String ImportDocument_ImportingDots;
+ public static String ImportDocument_JobImportFiles;
+ public static String ImportDocumentFolder_ActivatorCannotImportDocumentFolder;
+ public static String ImportDocumentFolder_ActivatorFolderImported;
+ public static String ImportDocumentFolder_ImportFolder;
+ public static String ImportDocumentWithDetail_CannotImportDocument;
+ public static String NewDocumentFolder_Folder;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
Layer0 l0 = Layer0.getInstance(graph);
- String name = NameUtils.findFreshName(graph, "Folder", resource, relation);
+ String name = NameUtils.findFreshName(graph, Messages.NewDocumentFolder_Folder, resource, relation);
Resource folder = graph.newResource();
graph.claim(folder, l0.InstanceOf, folderType);
graph.claimLiteral(folder, l0.HasName, name);
--- /dev/null
+AddUrlDocument_AddURL=Add URL\r
+AddUrlDocument_CannotAddURLLink=Cannot add URL link.\r
+AddUrlDocument_InputURL=Input URL\r
+ExportDocumentFile_CannotExportDocument=Cannot export document.\r
+ExportDocumentFolder_AcivatorCannotExport=Cannot export document folder.\r
+ExportDocumentFolder_ActivatorFolderExported=Folder exported.\r
+ExportDocumentFolder_DeleteAndExport=Delete and export\r
+ExportDocumentFolder_ExportFolder=Export folder\r
+ExportDocumentFolder_FolderExport=Folder export\r
+ExportDocumentFolder_Overwrite=Overwrite\r
+ExportDocumentFolder_SelectedFolder=Selected folder "{0}" is not empty.\r
+ImportDocument_ActivatorImportSucessful=Import successful.\r
+ImportDocument_ImportFailed=Import failed.\r
+ImportDocument_ImportFile=Import file\r
+ImportDocument_ImportingDots=Importing...\r
+ImportDocument_JobImportFiles=Import files\r
+ImportDocumentFolder_ActivatorCannotImportDocumentFolder=Cannot import document folder.\r
+ImportDocumentFolder_ActivatorFolderImported=Folder imported.\r
+ImportDocumentFolder_ImportFolder=Import folder\r
+ImportDocumentWithDetail_CannotImportDocument=Cannot import document.\r
+NewDocumentFolder_Folder=Folder\r
DocumentResource doc = DocumentResource.getInstance(graph);
if (!graph.isInstanceOf(resource, doc.Document))
return;
- result.add(new ComparableTabContributor(new DocumentPropertyTabContributor(), 1, resource, "Document"));
+ result.add(new ComparableTabContributor(new DocumentPropertyTabContributor(), 1, resource, Messages.DocumentTabContribution_Document));
}
private class DocumentPropertyTabContributor extends PropertyTabContributorImpl {
GridLayoutFactory.fillDefaults().margins(3,3).spacing(1, 1).numColumns(4).applyTo(composite);
Label label = new Label(composite, SWT.NONE);
- label.setText("Name");
+ label.setText(Messages.DocumentTabContribution_Name);
TrackedText name = new TrackedText(composite, support, SWT.BORDER);
name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasName));
support.register(validator);
Button showButton = new Button(composite, SWT.PUSH);
- showButton.setText("Show");
+ showButton.setText(Messages.DocumentTabContribution_Show);
showButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DocumentResource doc;
try {
doc = DocumentResource.getInstance(context.getSession());
- new DocumentRevisionWidget(composite, support, doc.HasOlderVersion, "Old");
- new DocumentRevisionWidget(composite, support, doc.HasNewerVersion, "New");
+ new DocumentRevisionWidget(composite, support, doc.HasOlderVersion, Messages.DocumentTabContribution_Old);
+ new DocumentRevisionWidget(composite, support, doc.HasNewerVersion, Messages.DocumentTabContribution_New);
} catch (DatabaseException e1) {
- ExceptionUtils.logAndShowError("Cannot create documen version UI", e1);
+ ExceptionUtils.logAndShowError(Messages.DocumentTabContribution_CannotCreateDocumentVersionUI, e1);
}
public String perform(ReadGraph graph) throws DatabaseException {
Resource res = AdaptionUtils.adaptToSingle(forSelection, Resource.class);
if (res == null)
- return "N/A";
+ return Messages.DocumentTabContribution_6;
Layer0 l0 = Layer0.getInstance(graph);
return graph.getPossibleRelatedValue(res, l0.HasName);
}
try {
adapter.openEditor(resource);
} catch (Exception e) {
- ExceptionUtils.logAndShowError("Cannot open editor", e);
+ ExceptionUtils.logAndShowError(Messages.DocumentTabContribution_7, e);
}
}
});
label.setText(name);
text = new Text(parent, SWT.SINGLE|SWT.BORDER|SWT.READ_ONLY);
showButton = new Button(parent, SWT.PUSH);
- showButton.setText("Show");
+ showButton.setText(Messages.DocumentTabContribution_8);
showButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
}
});
removeButton = new Button(parent, SWT.PUSH);
- removeButton.setText("Unset");
+ removeButton.setText(Messages.DocumentTabContribution_9);
removeButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
});
revisionDoc = null;
} catch (DatabaseException e1) {
- ExceptionUtils.logAndShowError("Cannot remove document revision", e1);
+ ExceptionUtils.logAndShowError(Messages.DocumentTabContribution_10, e1);
}
updateUI();
}
@Override
public void exception(AsyncReadGraph graph, Throwable t) {
- ExceptionUtils.logAndShowError("Cannot show document revision", t);
+ ExceptionUtils.logAndShowError(Messages.DocumentTabContribution_11, t);
}
@Override
if (revisionDoc != null)
text.setText(revisionDoc.getName());
else
- text.setText("");
+ text.setText(""); //$NON-NLS-1$
}
private void setRevisionDoc(final Resource toSet) {
--- /dev/null
+package org.simantics.document.ui.contribution;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.document.ui.contribution.messages"; //$NON-NLS-1$
+ public static String DocumentTabContribution_10;
+ public static String DocumentTabContribution_11;
+ public static String DocumentTabContribution_6;
+ public static String DocumentTabContribution_7;
+ public static String DocumentTabContribution_8;
+ public static String DocumentTabContribution_9;
+ public static String DocumentTabContribution_CannotCreateDocumentVersionUI;
+ public static String DocumentTabContribution_Document;
+ public static String DocumentTabContribution_Name;
+ public static String DocumentTabContribution_New;
+ public static String DocumentTabContribution_Old;
+ public static String DocumentTabContribution_Show;
+ public static String NameInputValidator_CannotHaveDuplicateName;
+ public static String NameInputValidator_EmptyNameNotAllowed;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
import java.util.Collection;
import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.osgi.util.NLS;
import org.simantics.Simantics;
import org.simantics.browsing.ui.swt.widgets.impl.Widget;
import org.simantics.db.ReadGraph;
@Override
public String isValid(final String newText) {
if (newText == null || newText.length() == 0)
- return "Empty name is not allowed";
+ return Messages.NameInputValidator_EmptyNameNotAllowed;
if (selection != null) {
try {
return Simantics.getSession().syncRequest(new Read<String>() {
continue;
String n = graph.getPossibleRelatedValue(resource, l0.HasName);
if (newText.equals(n))
- return "Cannot have duplicate name " + newText;
+ return NLS.bind(Messages.NameInputValidator_CannotHaveDuplicateName, newText);
}
return null;
}
--- /dev/null
+DocumentTabContribution_10=Cannot remove document revision
+DocumentTabContribution_11=Cannot show document revision
+DocumentTabContribution_6=N/A
+DocumentTabContribution_7=Cannot open editor
+DocumentTabContribution_8=Show
+DocumentTabContribution_9=Unset
+DocumentTabContribution_CannotCreateDocumentVersionUI=Cannot create document version UI
+DocumentTabContribution_Document=Document
+DocumentTabContribution_Name=Name
+DocumentTabContribution_New=New
+DocumentTabContribution_Old=Old
+DocumentTabContribution_Show=Show
+NameInputValidator_CannotHaveDuplicateName=Cannot have duplicate name {0}
+NameInputValidator_EmptyNameNotAllowed=Empty name is not allowed
VirtualGraph vg = null;
if (useVG) {
VirtualGraphSupport support = Simantics.getSession().getService(VirtualGraphSupport.class);
- vg = support.getMemoryPersistent("document_annotation");
+ vg = support.getMemoryPersistent("document_annotation"); //$NON-NLS-1$
}
Variable annotationHolder = null;
try {
Layer0 l0 = Layer0.getInstance(graph);
Resource annotationHolderDoc = graph.newResource();
graph.claim(annotationHolderDoc, l0.InstanceOf, type);
- graph.claimLiteral(annotationHolderDoc, l0.HasName, "Template");
+ graph.claimLiteral(annotationHolderDoc, l0.HasName, "Template"); //$NON-NLS-1$
graph.claim(lib, l0.ConsistsOf, annotationHolderDoc);
if (graph.isInstanceOf(lib, type)) {
copyAnnotations(graph, lib, annotationHolderDoc);
if (useVG) {
VirtualGraphSupport support = Simantics.getSession().getService(VirtualGraphSupport.class);
- VirtualGraph vg = support.getMemoryPersistent("document_annotation");
+ VirtualGraph vg = support.getMemoryPersistent("document_annotation"); //$NON-NLS-1$
support.discard(vg);
} else {
GridDataFactory.fillDefaults().hint(500, 500).applyTo(composite);
Label label = new Label(composite, SWT.NONE);
- label.setText("File:");
+ label.setText(Messages.FileDetailDialog_File);
fileText = new Text(composite, SWT.SINGLE|SWT.BORDER);
Button browseButton = new Button(composite, SWT.PUSH);
- browseButton.setText("Browse");
+ browseButton.setText(Messages.FileDetailDialog_Browse);
label = new Label(composite, SWT.NONE);
- label.setText("Name:");
+ label.setText(Messages.FileDetailDialog_Name);
nameText = new Text(composite, SWT.SINGLE|SWT.BORDER);
label = new Label(composite, SWT.NONE);
label = new Label(composite, SWT.NONE);
- label.setText("Annotations:");
+ label.setText(Messages.FileDetailDialog_Annotations);
annotationComposite = new Composite(composite, SWT.NONE);
annotationComposite.setLayout(new FillLayout());
@Override
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(e.display.getActiveShell(),SWT.OPEN);
- dialog.setFilterExtensions(new String[]{"*.*"});
+ dialog.setFilterExtensions(new String[]{"*.*"}); //$NON-NLS-1$
String s = dialog.open();
if (s != null) {
name = null;
--- /dev/null
+package org.simantics.document.ui.dialogs;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.document.ui.dialogs.messages"; //$NON-NLS-1$
+ public static String FileDetailDialog_Annotations;
+ public static String FileDetailDialog_Browse;
+ public static String FileDetailDialog_File;
+ public static String FileDetailDialog_Name;
+ public static String UrlDetailDialog_Annotations;
+ public static String UrlDetailDialog_Name;
+ public static String UrlDetailDialog_URL;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
GridDataFactory.fillDefaults().hint(500, 500).applyTo(composite);
Label label = new Label(composite, SWT.NONE);
- label.setText("URL:");
+ label.setText(Messages.UrlDetailDialog_URL);
urlText = new Text(composite, SWT.SINGLE|SWT.BORDER);
label = new Label(composite, SWT.NONE);
- label.setText("Name:");
+ label.setText(Messages.UrlDetailDialog_Name);
nameText = new Text(composite, SWT.SINGLE|SWT.BORDER);
label = new Label(composite, SWT.NONE);
- label.setText("Annotations:");
+ label.setText(Messages.UrlDetailDialog_Annotations);
annotationComposite = new Composite(composite, SWT.BORDER);
annotationComposite.setLayout(new FillLayout());
//
--- /dev/null
+FileDetailDialog_Annotations=Annotations:\r
+FileDetailDialog_Browse=Browse\r
+FileDetailDialog_File=File:\r
+FileDetailDialog_Name=Name:\r
+UrlDetailDialog_Annotations=Annotations:\r
+UrlDetailDialog_Name=Name:\r
+UrlDetailDialog_URL=URL:\r
Resource documentType = graph.getSingleObject(binding, DOC.DocumentTypeBinding_HasDocumentType);
Resource document = graph.newResource();
graph.claim(document, L0.InstanceOf, null, DOC.ScenegraphDocument);
- graph.claimLiteral(document, L0.HasName, "Documentation");
+ graph.claimLiteral(document, L0.HasName, "Documentation"); //$NON-NLS-1$
graph.claim(resource, DOC.HasDocumentation, document);
graph.claim(document, L0.PartOf, resource);
Resource scenegraph = graph.newResource();
graph.claim(scenegraph, L0.InstanceOf, null, documentType);
- graph.claimLiteral(scenegraph, L0.HasName, "Scenegraph");
+ graph.claimLiteral(scenegraph, L0.HasName, "Scenegraph"); //$NON-NLS-1$
graph.claim(scenegraph, L0.PartOf, document);
graph.claim(document, DOC.ScenegraphDocument_scenegraph, scenegraph);
Variable result = ScenegraphLoaderProcess.getVariable(graph, null, scenegraph, ScenegraphLoaderUtils.getRuntime(graph, context), root);
if(result != null) {
- Variable userDoc = result.getPossibleProperty(graph, "UserDocumentation");
+ Variable userDoc = result.getPossibleProperty(graph, "UserDocumentation"); //$NON-NLS-1$
if(userDoc != null) return userDoc;
}
@SCLValue(type = "ReadGraph -> Resource -> Variable -> a")
public static Object wikitextModifier(ReadGraph graph, final Resource resource, final Variable context) throws DatabaseException {
- final ScenegraphPropertyReference<String> textReference = ScenegraphLoaderUtils.getRelativePropertyReference(SWTThread.getThreadAccess(), graph, context, ".../TextContainer/Text#text");
+ final ScenegraphPropertyReference<String> textReference = ScenegraphLoaderUtils.getRelativePropertyReference(SWTThread.getThreadAccess(), graph, context, ".../TextContainer/Text#text"); //$NON-NLS-1$
return new FunctionImpl1<Object, Object>() {
@Override
public void perform(WriteGraph graph) throws DatabaseException {
- Variable selection = resolveEditSelection(graph, context, "..../Scroll/Browser#edited");
+ Variable selection = resolveEditSelection(graph, context, "..../Scroll/Browser#edited"); //$NON-NLS-1$
if (selection != null) {
selection.setValue(graph, (String)value, Bindings.STRING);
graph.markUndoPoint();
} else {
- LOGGER.error("No selection for resource : " + resource + ", Variable context : " + context + ", value : " + value);
+ LOGGER.error("No selection for resource : " + resource + ", Variable context : " + context + ", value : " + value); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
@SCLValue(type = "ReadGraph -> Resource -> Variable -> String")
public static String selectedDocumentPart(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {
- Variable selection = resolveEditSelection(graph, context, ".../Scroll/Browser#edited");
+ Variable selection = resolveEditSelection(graph, context, ".../Scroll/Browser#edited"); //$NON-NLS-1$
if(selection == null) return null;
return selection.getValue(graph);
final ScenegraphPropertyReference<Point> selectionReference;
public WikiButtonModifier(ReadGraph graph, Variable context) throws DatabaseException {
- textReference = ScenegraphLoaderUtils.getRelativePropertyReference(SWTThread.getThreadAccess(), graph, context, ".../TextContainer/Text#text");
- selectionReference = ScenegraphLoaderUtils.getRelativePropertyReference(SWTThread.getThreadAccess(), graph, context, ".../TextContainer/Text#selection");
+ textReference = ScenegraphLoaderUtils.getRelativePropertyReference(SWTThread.getThreadAccess(), graph, context, ".../TextContainer/Text#text"); //$NON-NLS-1$
+ selectionReference = ScenegraphLoaderUtils.getRelativePropertyReference(SWTThread.getThreadAccess(), graph, context, ".../TextContainer/Text#selection"); //$NON-NLS-1$
}
abstract void perform(String before, String selected, String after, Point selection);
void perform(String before, String selected, String after, Point selection) {
if(selected.isEmpty()) {
- textReference.setValue(before + "'''bold text'''" + after);
+ textReference.setValue(before + "'''bold text'''" + after); //$NON-NLS-1$
} else {
- textReference.setValue(before + "'''" + selected + "'''" + after);
+ textReference.setValue(before + "'''" + selected + "'''" + after); //$NON-NLS-1$ //$NON-NLS-2$
}
}
void perform(String before, String selected, String after, Point selection) {
if(selected.isEmpty()) {
- textReference.setValue(before + "''italic text''" + after);
+ textReference.setValue(before + "''italic text''" + after); //$NON-NLS-1$
} else {
- textReference.setValue(before + "''" + selected + "''" + after);
+ textReference.setValue(before + "''" + selected + "''" + after); //$NON-NLS-1$ //$NON-NLS-2$
}
}
void perform(String before, String selected, String after, Point selection) {
if(selected.isEmpty()) {
- textReference.setValue(before + "<span style=\"text-decoration:line-through;\">strikethrough text</span>" + after);
+ textReference.setValue(before + "<span style=\"text-decoration:line-through;\">strikethrough text</span>" + after); //$NON-NLS-1$
} else {
- textReference.setValue(before + "<span style=\"text-decoration:line-through;\">" + selected + "</span>" + after);
+ textReference.setValue(before + "<span style=\"text-decoration:line-through;\">" + selected + "</span>" + after); //$NON-NLS-1$ //$NON-NLS-2$
}
}
void perform(String before, String selected, String after, Point selection) {
if(selected.isEmpty()) {
- textReference.setValue(before + "<span style=\"text-decoration:underline;\">strikethrough text</span>" + after);
+ textReference.setValue(before + "<span style=\"text-decoration:underline;\">strikethrough text</span>" + after); //$NON-NLS-1$
} else {
- textReference.setValue(before + "<span style=\"text-decoration:underline;\">" + selected + "</span>" + after);
+ textReference.setValue(before + "<span style=\"text-decoration:underline;\">" + selected + "</span>" + after); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@Override
void perform(String before, String selected, String after, Point selection) {
- textReference.setValue(before + "\r\n<hr/>\r\n" + selected + after);
+ textReference.setValue(before + "\r\n<hr/>\r\n" + selected + after); //$NON-NLS-1$
}
@Override
void perform(String before, String selected, String after, Point selection) {
- textReference.setValue(before + ":" + selected + after);
+ textReference.setValue(before + ":" + selected + after); //$NON-NLS-1$
}
private String hex2(int value) {
String result = Integer.toHexString(value);
- if(result.length() == 1) result = "0" + result;
+ if(result.length() == 1) result = "0" + result; //$NON-NLS-1$
return result;
}
String hex = hex2(rgb.red) + hex2(rgb.green) + hex2(rgb.blue);
if(selected.isEmpty()) {
- textReference.setValue(before + "<font style=\"font-size:" + size + ";color: #" + hex + ";font-family:" + family + ";\" >formatted text</font>" + selected + after);
+ textReference.setValue(before + "<font style=\"font-size:" + size + ";color: #" + hex + ";font-family:" + family + ";\" >formatted text</font>" + selected + after); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
} else {
- textReference.setValue(before + "<font style=\"font-size:" + size + ";color: #" + hex + ";font-family:" + family + ";\" >" + selected + "</font>" + after);
+ textReference.setValue(before + "<font style=\"font-size:" + size + ";color: #" + hex + ";font-family:" + family + ";\" >" + selected + "</font>" + after); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
}
@Override
void perform(String before, String selected, String after, Point selection) {
- textReference.setValue(before + "[[Image:root://Library/image.png|100px]]" + "\r\n" + selected + after);
+ textReference.setValue(before + "[[Image:root://Library/image.png|100px]]" + "\r\n" + selected + after); //$NON-NLS-1$ //$NON-NLS-2$
}
@Override
void perform(String before, String selected, String after, Point selection) {
- textReference.setValue(before + "\r\n= Header 1 =\r\n" + selected + after);
+ textReference.setValue(before + "\r\n= Header 1 =\r\n" + selected + after); //$NON-NLS-1$
}
@Override
void perform(String before, String selected, String after, Point selection) {
- textReference.setValue(before + "\r\n== Header 2 ==\r\n" + selected + after);
+ textReference.setValue(before + "\r\n== Header 2 ==\r\n" + selected + after); //$NON-NLS-1$
}
@Override
void perform(String before, String selected, String after, Point selection) {
- textReference.setValue(before + "\r\n=== Header 3 ===\r\n" + selected + after);
+ textReference.setValue(before + "\r\n=== Header 3 ===\r\n" + selected + after); //$NON-NLS-1$
}
@Override
void perform(String before, String selected, String after, Point selection) {
- textReference.setValue(before + "\r\n==== Header 4 ====\r\n" + selected + after);
+ textReference.setValue(before + "\r\n==== Header 4 ====\r\n" + selected + after); //$NON-NLS-1$
}
@Override
void perform(String before, String selected, String after, Point selection) {
- textReference.setValue(before + "\r\n" +
- "# Item1\r\n" +
- "# Item2\r\n" +
- "## Item2.1\r\n" +
- "# Item3\r\n" + selected + after);
+ textReference.setValue(before + "\r\n" + //$NON-NLS-1$
+ "# Item1\r\n" + //$NON-NLS-1$
+ "# Item2\r\n" + //$NON-NLS-1$
+ "## Item2.1\r\n" + //$NON-NLS-1$
+ "# Item3\r\n" + selected + after); //$NON-NLS-1$
}
@Override
void perform(String before, String selected, String after, Point selection) {
- textReference.setValue(before + "\r\n" +
- "* Item1\r\n" +
- "* Item2\r\n" +
- "** Item2.1\r\n" +
- "* Item3\r\n" + selected + after);
+ textReference.setValue(before + "\r\n" + //$NON-NLS-1$
+ "* Item1\r\n" + //$NON-NLS-1$
+ "* Item2\r\n" + //$NON-NLS-1$
+ "** Item2.1\r\n" + //$NON-NLS-1$
+ "* Item3\r\n" + selected + after); //$NON-NLS-1$
}
@Override
void perform(String before, String selected, String after, Point selection) {
- textReference.setValue(before + "\r\n" +
- "{| border=\"1\"\r\n" +
- "! header\r\n" +
- "! header2 \r\n" +
- "|-\r\n" +
- "| cell || cell2\r\n" +
- "|-\r\n" +
- "| cell3\r\n" +
- "| cell4\r\n" +
- "|}\r\n" + selected + after);
+ textReference.setValue(before + "\r\n" + //$NON-NLS-1$
+ "{| border=\"1\"\r\n" + //$NON-NLS-1$
+ "! header\r\n" + //$NON-NLS-1$
+ "! header2 \r\n" + //$NON-NLS-1$
+ "|-\r\n" + //$NON-NLS-1$
+ "| cell || cell2\r\n" + //$NON-NLS-1$
+ "|-\r\n" + //$NON-NLS-1$
+ "| cell3\r\n" + //$NON-NLS-1$
+ "| cell4\r\n" + //$NON-NLS-1$
+ "|}\r\n" + selected + after); //$NON-NLS-1$
}
@Override
void perform(String before, String selected, String after, Point selection) {
textReference.setValue(before +
- "[[Media:root://Documents/Document.pdf|Link to a file within the model]]\r\n" + selected + after);
+ "[[Media:root://Documents/Document.pdf|Link to a file within the model]]\r\n" + selected + after); //$NON-NLS-1$
}
};
void perform(String before, String selected, String after, Point selection) {
textReference.setValue(before +
- "[http://www.simantics.org External Website Link]\r\n" + selected + after);
+ "[http://www.simantics.org External Website Link]\r\n" + selected + after); //$NON-NLS-1$
}
try {
WorkbenchUtils.openEditor(editorId, new ResourceEditorInput2(editorId, root, root, rvi));
} catch (PartInitException e) {
- LOGGER.error("Failed to open CSS editor for root " + root, e);
+ LOGGER.error("Failed to open CSS editor for root " + root, e); //$NON-NLS-1$
}
});
public static String noDocumentText(ReadGraph graph, final Resource resource, final Variable context) throws DatabaseException {
Variable selection = ScenegraphLoaderUtils.getPossibleVariableSelection(graph, context);
- if(selection == null) return "<no input>";
+ if(selection == null) return "<no input>"; //$NON-NLS-1$
Resource input = selection.getRepresents(graph);
- if(input == null) return "<no input>";
+ if(input == null) return "<no input>"; //$NON-NLS-1$
String path = DocumentUtils.indexRootPath(graph, selection);
if(!path.isEmpty()) {
- return "for " + path + selection.getName(graph);
+ return "for " + path + selection.getName(graph); //$NON-NLS-1$
}
- return "for " + NameUtils.getSafeLabel(graph, input);
+ return "for " + NameUtils.getSafeLabel(graph, input); //$NON-NLS-1$
}
DefaultActions.asyncPerformDefaultAction(s, input, false, false, false);
}
} catch (DatabaseException | InterruptedException e) {
- Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to resolve URI to a database resource or variable: " + uri, e));
+ Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to resolve URI to a database resource or variable: " + uri, e)); //$NON-NLS-1$
}
}
return true;
public SearchResult apply(IProgressMonitor monitor, ReadGraph graph, Resource model, SearchQuery query, Integer maxResults) {
try {
Collection<Map<String, Object>> results = Searching.performSearch(graph, Layer0X.getInstance(graph).Dependencies, model,
- query.escaped(false).getQuery("Name","Types"), maxResults);
+ query.escaped(false).getQuery("Name","Types"), maxResults); //$NON-NLS-1$ //$NON-NLS-2$
return generateSearchResults(graph, results);
} catch (DatabaseException e) {
Logger.defaultLogError(e);
public static void createNewVersion(WriteGraph graph, Resource oldDocument, Resource newDocument, Resource relation) throws DatabaseException{
DocumentResource doc = DocumentResource.getInstance(graph);
if (graph.hasStatement(oldDocument, doc.HasNewerVersion))
- throw new DatabaseException("Document " + NameUtils.getSafeName(graph, oldDocument) +" has already new version");
+ throw new DatabaseException("Document " + NameUtils.getSafeName(graph, oldDocument) +" has already new version"); //$NON-NLS-1$ //$NON-NLS-2$
Resource inverse = graph.getInverse(relation);
Resource lib = graph.getSingleObject(oldDocument, inverse);
if (!graph.getSingleType(document2, doc.Document).equals(graph.getSingleType(document1, doc.Document)))
return;
if (!versionRel.equals(doc.HasNewerVersion) && !(versionRel.equals(doc.HasOlderVersion)))
- throw new IllegalArgumentException("Unknow version relation + " + graph.getPossibleURI(versionRel));
+ throw new IllegalArgumentException("Unknow version relation + " + graph.getPossibleURI(versionRel)); //$NON-NLS-1$
Resource versionRelInv = graph.getInverse(versionRel);
// toSet must not be part of the document's version history
if (lib != null) {
Resource relation = graph.getPossibleObject(lib, doc.HasLibraryRelation);
String type= graph.getPossibleRelatedValue(lib, doc.HasVersionType);
- if ("TREE".equals(type) && relation != null) {
+ if ("TREE".equals(type) && relation != null) { //$NON-NLS-1$
if (versionRel.equals(doc.HasOlderVersion)) {
graph.deny(document2, graph.getInverse(relation));
graph.claim(document1,relation,document2);
public static void unsetVersion(WriteGraph graph, Resource document1, Resource document2, Resource versionRel) throws DatabaseException {
DocumentResource doc = DocumentResource.getInstance(graph);
if (!versionRel.equals(doc.HasNewerVersion) && !(versionRel.equals(doc.HasOlderVersion)))
- throw new IllegalArgumentException("Unknow version relation + " + graph.getPossibleURI(versionRel));
+ throw new IllegalArgumentException("Unknow version relation + " + graph.getPossibleURI(versionRel)); //$NON-NLS-1$
graph.deny(document1, versionRel,document2);
Resource lib = getLib(graph, document1);
if (lib != null) {
Resource relation = graph.getPossibleObject(lib, doc.HasLibraryRelation);
String type= graph.getPossibleRelatedValue(lib, doc.HasVersionType);
- if ("TREE".equals(type) && relation != null) {
+ if ("TREE".equals(type) && relation != null) { //$NON-NLS-1$
if (versionRel.equals(doc.HasOlderVersion)) {
graph.deny(document1, relation);
graph.claim(lib,relation,document2);
private static ExternalFileWatcher fileWatcher;
public ExternalEditorAdapter() {
- super("External Editor", Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/page.png"));
+ super(Messages.ExternalEditorAdapter_ExternalEditor, Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/page.png")); //$NON-NLS-2$ //$NON-NLS-3$
}
@Override
StringBuilder sb = new StringBuilder();
String uri = graph.getPossibleURI(input);
if (uri != null) {
- sb.append(generateSHA1(uri)).append("_");
+ sb.append(generateSHA1(uri)).append("_"); //$NON-NLS-1$
}
sb.append(graph.getRelatedValue(input, Layer0.getInstance(graph).HasName).toString());
Path filePath = Activator.getInstanceLocation().resolve(sb.toString());
try {
GraphFileUtil.writeDataToFile(graph, input, filePath.toFile());
} catch (IOException | DatabaseException e) {
- LOGGER.error("Could not write data to file ", e);
+ LOGGER.error("Could not write data to file ", e); //$NON-NLS-1$
}
return input;
});
- LOGGER.info("Adding tempFile {} with resource {}", filePath, input);
+ LOGGER.info("Adding tempFile {} with resource {}", filePath, input); //$NON-NLS-1$
return filePath;
}
});
}
public static String generateSHA1(String message) {
- return hashString(message, "SHA-1");
+ return hashString(message, "SHA-1"); //$NON-NLS-1$
}
private static String hashString(String message, String algorithm) {
try {
MessageDigest digest = MessageDigest.getInstance(algorithm);
- byte[] hashedBytes = digest.digest(message.getBytes("UTF-8"));
+ byte[] hashedBytes = digest.digest(message.getBytes("UTF-8")); //$NON-NLS-1$
return convertByteArrayToHexString(hashedBytes);
} catch (NoSuchAlgorithmException | UnsupportedEncodingException ex) {
// Should not happen
- LOGGER.error("Could not generate hash", ex);
+ LOGGER.error("Could not generate hash", ex); //$NON-NLS-1$
}
- return "";
+ return ""; //$NON-NLS-1$
}
private static String convertByteArrayToHexString(byte[] arrayBytes) {
Path parent = keys.get(key);
Path newPath = parent.resolve(pathEvent.context());
if (ENTRY_MODIFY == kind) {
- LOGGER.info("New path modified: " + newPath);
+ LOGGER.info("New path modified: " + newPath); //$NON-NLS-1$
Resource resource = tempFiles.get(newPath);
if (resource != null) {
GraphFileUtil.writeDataToGraph(newPath.toFile(), resource);
} else {
- LOGGER.warn("No resource found for {}", newPath.toAbsolutePath());
+ LOGGER.warn("No resource found for {}", newPath.toAbsolutePath()); //$NON-NLS-1$
}
} else if (ENTRY_DELETE == kind) {
- System.out.println("New path deleted: " + newPath);
+ System.out.println("New path deleted: " + newPath); //$NON-NLS-1$
}
}
if (!key.reset()) {
}
} catch (InterruptedException e) {
if (!stopped.get())
- LOGGER.error("Could not stop", e);
+ LOGGER.error("Could not stop", e); //$NON-NLS-1$
} catch (Throwable t) {
- LOGGER.error("An error occured", t);
+ LOGGER.error("An error occured", t); //$NON-NLS-1$
}
}
});
private void register(Path path) throws IOException {
if (Files.isDirectory(path)) {
- LOGGER.info("Registering path {}", path);
+ LOGGER.info("Registering path {}", path); //$NON-NLS-1$
WatchKey key = path.toAbsolutePath().register(ws, ENTRY_DELETE, ENTRY_MODIFY);
keys.put(key, path);
}
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osgi.util.NLS;
import org.simantics.Simantics;
import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
}
}, e -> {
if (e != null)
- ExceptionUtils.logAndShowError("Cannot import file " + fileName, e);
+ ExceptionUtils.logAndShowError(NLS.bind(Messages.FileDocumentUtil_CannotImportFile, fileName), e);
});
public static void importFolder(WriteGraph graph, File folder, Resource folderResource, Resource relation, IProgressMonitor monitor) throws Exception{
if (monitor != null) {
int count = _countFiles(folder);
- monitor.beginTask("Import files", count);
+ monitor.beginTask(Messages.FileDocumentUtil_MonitorImportFiles, count);
}
_importFolder(graph, folder, folderResource, relation, monitor);
if (monitor != null)
return;
int i = 1;
while (true) {
- String proposal = name +" (" + i +")";
+ String proposal = name +" (" + i +")"; //$NON-NLS-1$ //$NON-NLS-2$
if (!names.contains(proposal)) {
graph.claimLiteral(res, l0.HasName, proposal);
return;
name = graph.getRelatedValue(r, useResourceNames ? gf.HasResourceName : l0.HasName);
canExport = true;
} else if (graph.isInstanceOf(r, doc.UrlDocument)) {
- name = graph.getRelatedValue(r, l0.HasName) +".url";
+ name = graph.getRelatedValue(r, l0.HasName) +".url"; //$NON-NLS-1$
canExport = true;
}
if (canExport) {
name = resolveName(folder, name, names, true);
- File file = new File(folder.getAbsolutePath()+"/"+name);
+ File file = new File(folder.getAbsolutePath()+"/"+name); //$NON-NLS-1$
if (graph.isInstanceOf(r, doc.FileDocument)) {
GraphFileUtil.writeDataToFile(graph,r, file);
} else if (graph.isInstanceOf(r, doc.UrlDocument)) {
if (type.size() == folderType.size() && folderType.containsAll(type)) {
String name = graph.getRelatedValue(r, l0.HasName);
name = resolveName(folder, name, names, false);
- File subFolder = new File(folder.getAbsolutePath()+"/"+name);
+ File subFolder = new File(folder.getAbsolutePath()+"/"+name); //$NON-NLS-1$
if (!subFolder.exists()) {
if (!subFolder.mkdir()) {
// TODO : error.
* @throws DatabaseException
*/
private static void exportUrl(File toFile, String name, String url) throws Exception{
- PrintStream os = new PrintStream(toFile,"UTF-8");
- os.println("[InternetShortcut]");
- os.println("URL="+url);
- os.println("name="+name);
+ PrintStream os = new PrintStream(toFile,"UTF-8"); //$NON-NLS-1$
+ os.println("[InternetShortcut]"); //$NON-NLS-1$
+ os.println("URL="+url); //$NON-NLS-1$
+ os.println("name="+name); //$NON-NLS-1$
os.flush();
os.close();
}
String name = null;
BufferedReader is = null;
try {
- is = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
+ is = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); //$NON-NLS-1$
while ((s = is.readLine()) != null) {
- if (s.startsWith("URL=")) {
+ if (s.startsWith("URL=")) { //$NON-NLS-1$
url = s.substring(4);
- } else if (s.startsWith("name=")) {
+ } else if (s.startsWith("name=")) { //$NON-NLS-1$
name = s.substring(5);
}
}
}
private static boolean isUrl(File file) throws Exception{
- return (file.getAbsolutePath().endsWith(".url"));
+ return (file.getAbsolutePath().endsWith(".url")); //$NON-NLS-1$
}
private static final char ESCAPE = '%';
for (int i = 0; i < len; i++) {
char ch = s.charAt(i);
if (ch == ESCAPE) {
- String num = "0x";
+ String num = "0x"; //$NON-NLS-1$
num += s.charAt(++i);
num += s.charAt(++i);
ch = (char)Integer.decode(num).intValue();
if (used.contains(current)) {
current = createFileName(proposal, i);
} else {
- File subFile = new File(parentFolder.getAbsolutePath()+"/"+current);
+ File subFile = new File(parentFolder.getAbsolutePath()+"/"+current); //$NON-NLS-1$
if (!subFile.exists())
break;
if (subFile.exists() && subFile.isFile() && subFile.canWrite()) {
if (used.contains(current)) {
current = proposal+i;
} else {
- File subFolder = new File(parentFolder.getAbsolutePath()+"/"+current);
+ File subFolder = new File(parentFolder.getAbsolutePath()+"/"+current); //$NON-NLS-1$
if (!subFolder.exists())
break;
if (subFolder.exists() && subFolder.isDirectory()) {
}
private static String createFileName(String original, int i) {
- int extIndex = original.lastIndexOf(".");
+ int extIndex = original.lastIndexOf("."); //$NON-NLS-1$
if (extIndex == -1)
return original+i;
return original.substring(0,extIndex) + i + original.substring(extIndex);
--- /dev/null
+package org.simantics.document.ui.graphfile;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.document.ui.graphfile.messages"; //$NON-NLS-1$
+ public static String ExternalEditorAdapter_ExternalEditor;
+ public static String FileDocumentUtil_CannotImportFile;
+ public static String FileDocumentUtil_MonitorImportFiles;
+ public static String UrlEditorAdapter_Browser;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
public class UrlEditorAdapter extends AbstractResourceEditorAdapter implements EditorAdapter {
public UrlEditorAdapter() {
- super("Browser",Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/world.png"));
+ super(Messages.UrlEditorAdapter_Browser,Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/world.png")); //$NON-NLS-2$ //$NON-NLS-3$
}
--- /dev/null
+ExternalEditorAdapter_ExternalEditor=External Editor
+FileDocumentUtil_CannotImportFile=Cannot import file {0}
+FileDocumentUtil_MonitorImportFiles=Import files
+UrlEditorAdapter_Browser=Browser
--- /dev/null
+DocumentView_PinSelection=Pin Selection
+OpenEntityDocumentAdapter_DocumentEditor=Document Editor
FileSelectionPage fileSelectionPage;
public FileDocumentImportWizard(Resource lib) {
- setWindowTitle("Document File import");
+ setWindowTitle(Messages.FileDocumentImportWizard_DocumentFileImport);
setNeedsProgressMonitor(false);
}
String fileName;
public FileSelectionPage() {
- super("FileSelction","Select a file",null);
+ super(Messages.FileSelectionPage_FileSelection,Messages.FileSelectionPage_SelectAFile,null);
}
@Override
parent.setLayout(new GridLayout(3,false));
fileText = new Text(parent,SWT.BORDER|SWT.SINGLE);
browseButton = new Button(parent, SWT.PUSH);
- browseButton.setText("Browse");
+ browseButton.setText(Messages.FileSelectionPage_Browse);
GridData data;
data = new GridData();
// TODO : is there any way to read file/executable bindings from OS?
// if is, use those extensions to filter this list.
// note: in windows using "reg query ..." to read bindings form registry would work.
- dialog.setFilterExtensions(new String[]{"*.*"});
+ dialog.setFilterExtensions(new String[]{"*.*"}); //$NON-NLS-1$
String name = dialog.open();
if (name != null) {
fileText.setText(name);
--- /dev/null
+package org.simantics.document.ui.wizard;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.simantics.document.ui.wizard.messages"; //$NON-NLS-1$
+ public static String FileDocumentImportWizard_DocumentFileImport;
+ public static String FileSelectionPage_Browse;
+ public static String FileSelectionPage_FileSelection;
+ public static String FileSelectionPage_SelectAFile;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
--- /dev/null
+FileDocumentImportWizard_DocumentFileImport=Document File import\r
+FileSelectionPage_Browse=Browse\r
+FileSelectionPage_FileSelection=FileSelction\r
+FileSelectionPage_SelectAFile=Select a file\r
* [x] org.simantics.debug.ui
* [x] org.simantics.desktop.ui
* [x] org.simantics.document.linking.ui
+* [x] org.simantics.document.ui
* ...
## TODO ##