SG.Node.children _ : L0.List
@L0.list
_ : VIEWS.Composite
- VIEWS.Composite.layout _ : VIEWS.GridLayout
- VIEWS.GridLayout.columnCount 19
+ VIEWS.Composite.layout _ : VIEWS.RowLayout
+ //VIEWS.RowLayout.type VIEWS.Control.Style.Constant.Horizontal
+ //VIEWS.RowLayout.spacing 0
+ //VIEWS.RowLayout.justify true
+ //VIEWS.RowLayout.pack true
+ //VIEWS.RowLayout.wrap true
VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
VIEWS.GridLayout.GridData.horizontalGrab true
SG.Node.children _ : L0.List
VIEWS.Button.tooltip "Makes selection bold or inserts some bold text at cursor"
VIEWS.Button.modifier UI.Functions.boldModifier : L0.Function
VIEWS.Button.image SILK.text_bold
- VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
- VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
- VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+ VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
_ : VIEWS.Button
VIEWS.Button.tooltip "Makes selection italic or inserts some italic text at cursor"
VIEWS.Button.modifier UI.Functions.italicModifier : L0.Function
VIEWS.Button.image SILK.text_italic
- VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
- VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
- VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+ VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
_ : VIEWS.Button
VIEWS.Button.tooltip "Makes selection strikethrough or inserts some strikethrough text at cursor"
VIEWS.Button.modifier UI.Functions.strikethroughModifier : L0.Function
VIEWS.Button.image SILK.text_strikethrough
- VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
- VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
- VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+ VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
_ : VIEWS.Button
VIEWS.Button.tooltip "Makes selection underlined or inserts some underlined text at cursor"
VIEWS.Button.modifier UI.Functions.underlineModifier : L0.Function
VIEWS.Button.image SILK.text_underline
- VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
- VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
- VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+ VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
_ : VIEWS.Button
VIEWS.Button.tooltip "Inserts a horizontal ruler at cursor"
VIEWS.Button.modifier UI.Functions.horizontalRulerModifier : L0.Function
VIEWS.Button.image SILK.text_horizontalrule
- VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
- VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
- VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+ VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
_ : VIEWS.Button
VIEWS.Button.tooltip "Indents text"
VIEWS.Button.modifier UI.Functions.indentModifier : L0.Function
VIEWS.Button.image SILK.text_indent
- VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
- VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
- VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+ VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
_ : VIEWS.Button
VIEWS.Button.tooltip "Modifies selection font or inserts text with font settings"
VIEWS.Button.modifier UI.Functions.fontModifier : L0.Function
VIEWS.Button.image SILK.font
- VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
- VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
- VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+ VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
_ : VIEWS.Button
VIEWS.Button.tooltip "Inserts an image"
VIEWS.Button.modifier UI.Functions.imageModifier : L0.Function
VIEWS.Button.image SILK.image
- VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
- VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
- VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+ VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
+ _ : VIEWS.Button
+ VIEWS.Button.tooltip "Inserts an internal model-specific document link"
+ VIEWS.Button.modifier UI.Functions.internalLinkModifier : L0.Function
+ VIEWS.Button.image SILK.database_link
+ VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
+ _ : VIEWS.Button
+ VIEWS.Button.tooltip "Inserts an external website link"
+ VIEWS.Button.modifier UI.Functions.linkModifier : L0.Function
+ VIEWS.Button.image SILK.world_link
+ VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
_ : VIEWS.Button
VIEWS.Button.tooltip "Inserts a 1st level header"
VIEWS.Button.modifier UI.Functions.header1Modifier : L0.Function
VIEWS.Button.image SILK.text_heading_1
- VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
- VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
- VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+ VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
_ : VIEWS.Button
VIEWS.Button.tooltip "Inserts a 2nd level header"
VIEWS.Button.modifier UI.Functions.header2Modifier : L0.Function
VIEWS.Button.image SILK.text_heading_2
- VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
- VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
- VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+ VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
_ : VIEWS.Button
VIEWS.Button.tooltip "Inserts a 3rd level header"
VIEWS.Button.modifier UI.Functions.header3Modifier : L0.Function
VIEWS.Button.image SILK.text_heading_3
- VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
- VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
- VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+ VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
_ : VIEWS.Button
VIEWS.Button.tooltip "Inserts a 4th level header"
VIEWS.Button.modifier UI.Functions.header4Modifier : L0.Function
VIEWS.Button.image SILK.text_heading_4
- VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
- VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
- VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+ VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
_ : VIEWS.Button
VIEWS.Button.tooltip "Inserts a numbered list"
VIEWS.Button.modifier UI.Functions.numberedListModifier : L0.Function
VIEWS.Button.image SILK.text_list_numbers
- VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
- VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
- VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+ VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
_ : VIEWS.Button
VIEWS.Button.tooltip "Inserts a bullet list"
VIEWS.Button.modifier UI.Functions.bulletListModifier : L0.Function
VIEWS.Button.image SILK.text_list_bullets
- VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
- VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
- VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+ VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
_ : VIEWS.Button
VIEWS.Button.tooltip "Inserts a table"
VIEWS.Button.modifier UI.Functions.tableModifier : L0.Function
VIEWS.Button.image SILK.table
- VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
- VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
- VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
- _ : VIEWS.Button
- VIEWS.Button.tooltip "Inserts an external website link"
- VIEWS.Button.modifier UI.Functions.linkModifier : L0.Function
- VIEWS.Button.image SILK.link
- VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
- VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
- VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+ VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
_ : VIEWS.Button
VIEWS.Button.text "&Styles"
VIEWS.Button.tooltip "Edits document styles"
VIEWS.Button.modifier UI.Functions.styleModifier : L0.Function
- VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
- VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
- VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+ VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
_ : VIEWS.Button
VIEWS.Button.text "&Apply changes"
VIEWS.Button.tooltip "Applies any changes in the wiki markup into the document"
VIEWS.Button.modifier UI.Functions.wikitextModifier : L0.Function
- VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
- VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
- VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+ VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
_ : VIEWS.Button
VIEWS.Button.text "Delete document"
VIEWS.Button.tooltip "Deletes the document"
VIEWS.Button.modifier UI.Functions.onDeleteDocumentButton : L0.Function
- VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
- VIEWS.GridLayout.GridData.horizontalAlignment VIEWS.GridLayout.GridData.BEGINNING
- VIEWS.GridLayout.GridData.verticalAlignment VIEWS.GridLayout.GridData.BEGINNING
+ VIEWS.Control.layoutData _ : VIEWS.RowLayout.RowData
UI.WikitextContribution.View.TextContainer : VIEWS.Composite
VIEWS.Control.layoutData _ : VIEWS.GridLayout.GridData
VIEWS.GridLayout.GridData.verticalGrab true
VIEWS.Browser.variable DOC.Functions.documentationRootVariable
VIEWS.Browser.document DOC.Functions.documentationText
+ VIEWS.Browser.locationChanging UI.Functions.locationChanging : L0.Function
+ L0.HasValueType "a -> Boolean"
UI.WikitextContribution.View
UI.NoDocument : VIEWS.Composite
public final Resource Functions_horizontalRulerModifier;\r
public final Resource Functions_imageModifier;\r
public final Resource Functions_indentModifier;\r
+ public final Resource Functions_internalLinkModifier;\r
public final Resource Functions_isWikitext;\r
public final Resource Functions_italicModifier;\r
public final Resource Functions_linkModifier;\r
+ public final Resource Functions_locationChanging;\r
public final Resource Functions_noDocumentText;\r
public final Resource Functions_numberedListModifier;\r
public final Resource Functions_onCreateDocumentButton;\r
public static final String Functions_horizontalRulerModifier = "http://www.simantics.org/DocumentUI-1.1/Functions/horizontalRulerModifier";\r
public static final String Functions_imageModifier = "http://www.simantics.org/DocumentUI-1.1/Functions/imageModifier";\r
public static final String Functions_indentModifier = "http://www.simantics.org/DocumentUI-1.1/Functions/indentModifier";\r
+ public static final String Functions_internalLinkModifier = "http://www.simantics.org/DocumentUI-1.1/Functions/internalLinkModifier";\r
public static final String Functions_isWikitext = "http://www.simantics.org/DocumentUI-1.1/Functions/isWikitext";\r
public static final String Functions_italicModifier = "http://www.simantics.org/DocumentUI-1.1/Functions/italicModifier";\r
public static final String Functions_linkModifier = "http://www.simantics.org/DocumentUI-1.1/Functions/linkModifier";\r
+ public static final String Functions_locationChanging = "http://www.simantics.org/DocumentUI-1.1/Functions/locationChanging";\r
public static final String Functions_noDocumentText = "http://www.simantics.org/DocumentUI-1.1/Functions/noDocumentText";\r
public static final String Functions_numberedListModifier = "http://www.simantics.org/DocumentUI-1.1/Functions/numberedListModifier";\r
public static final String Functions_onCreateDocumentButton = "http://www.simantics.org/DocumentUI-1.1/Functions/onCreateDocumentButton";\r
Functions_horizontalRulerModifier = getResourceOrNull(graph, URIs.Functions_horizontalRulerModifier);\r
Functions_imageModifier = getResourceOrNull(graph, URIs.Functions_imageModifier);\r
Functions_indentModifier = getResourceOrNull(graph, URIs.Functions_indentModifier);\r
+ Functions_internalLinkModifier = getResourceOrNull(graph, URIs.Functions_internalLinkModifier);\r
Functions_isWikitext = getResourceOrNull(graph, URIs.Functions_isWikitext);\r
Functions_italicModifier = getResourceOrNull(graph, URIs.Functions_italicModifier);\r
Functions_linkModifier = getResourceOrNull(graph, URIs.Functions_linkModifier);\r
+ Functions_locationChanging = getResourceOrNull(graph, URIs.Functions_locationChanging);\r
Functions_noDocumentText = getResourceOrNull(graph, URIs.Functions_noDocumentText);\r
Functions_numberedListModifier = getResourceOrNull(graph, URIs.Functions_numberedListModifier);\r
Functions_onCreateDocumentButton = getResourceOrNull(graph, URIs.Functions_onCreateDocumentButton);\r
*******************************************************************************/\r
package org.simantics.document.ui;\r
\r
+import org.eclipse.jface.action.Action;\r
+import org.eclipse.jface.action.IAction;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IWorkbenchPart;\r
import org.simantics.ui.workbench.IPropertyPage;\r
+import org.simantics.utils.ui.BundleUtils;\r
import org.simantics.views.swt.ModelledView;\r
\r
/**\r
*/\r
public class DocumentView extends ModelledView {\r
\r
+ private boolean pinSelection = false;\r
+\r
@Override\r
protected String configurationURI() {\r
return DocumentUIResource.URIs.View;\r
return null;\r
}\r
\r
+ @Override\r
+ protected void inputChanged(IWorkbenchPart provider, Object input) {\r
+ if (pinSelection)\r
+ return;\r
+ super.inputChanged(provider, input);\r
+ }\r
+\r
+ @Override\r
+ public void createPartControl(Composite parent) {\r
+ super.createPartControl(parent);\r
+ getViewSite().getActionBars().getToolBarManager().add(new PinSelection());\r
+ }\r
+\r
+ private class PinSelection extends Action {\r
+ public PinSelection() {\r
+ super("Pin Selection", IAction.AS_CHECK_BOX);\r
+ setImageDescriptor(\r
+ BundleUtils.getImageDescriptorFromPlugin(\r
+ "org.eclipse.ui",\r
+ "icons/full/etool16/pin_editor.png"));\r
+ }\r
+\r
+ @Override\r
+ public void run() {\r
+ pinSelection = isChecked();\r
+ }\r
+ }\r
+\r
}\r
\r
import java.util.TreeMap;\r
\r
+import org.eclipse.core.runtime.IStatus;\r
+import org.eclipse.core.runtime.Status;\r
import org.eclipse.jface.viewers.ISelectionProvider;\r
import org.eclipse.jface.viewers.StructuredSelection;\r
+import org.eclipse.swt.browser.LocationEvent;\r
import org.eclipse.swt.graphics.FontData;\r
import org.eclipse.swt.graphics.Point;\r
import org.eclipse.swt.graphics.RGB;\r
import org.simantics.databoard.Bindings;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
+import org.simantics.db.Session;\r
import org.simantics.db.WriteGraph;\r
import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.common.request.UnaryRead;\r
import org.simantics.db.common.request.WriteRequest;\r
import org.simantics.db.common.utils.Logger;\r
import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.common.utils.RequestUtil;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.layer0.adapter.Instances;\r
import org.simantics.db.layer0.request.PossibleModel;\r
+import org.simantics.db.layer0.request.PossibleResource;\r
import org.simantics.db.layer0.util.RemoverUtil;\r
import org.simantics.db.layer0.variable.RVI;\r
import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.document.DocumentDialect;\r
import org.simantics.document.DocumentResource;\r
import org.simantics.document.DocumentUtils;\r
+import org.simantics.document.ui.Activator;\r
import org.simantics.document.ui.CSSEditor;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.scenegraph.INode;\r
import org.simantics.scenegraph.loader.ScenegraphLoaderUtils;\r
import org.simantics.scenegraph.loader.ScenegraphLoaderUtils.ScenegraphPropertyReference;\r
import org.simantics.scl.reflection.annotations.SCLValue;\r
+import org.simantics.scl.runtime.function.Function1;\r
import org.simantics.scl.runtime.function.FunctionImpl1;\r
import org.simantics.scl.runtime.function.FunctionImpl3;\r
+import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.workbench.ResourceEditorInput2;\r
+import org.simantics.ui.workbench.action.DefaultActions;\r
import org.simantics.utils.threads.SWTThread;\r
import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
\r
@Override\r
void perform(String before, String selected, String after, Point selection) {\r
\r
- textReference.setValue(before + "[[Image:root://Library/image.png|100px]]" + selected + after);\r
+ textReference.setValue(before + "[[Image:root://Library/image.png|100px]]" + "\r\n" + selected + after);\r
\r
}\r
\r
\r
}\r
\r
+ @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")\r
+ public static Object internalLinkModifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {\r
+ return new WikiButtonModifier(graph, context) {\r
+ @Override\r
+ void perform(String before, String selected, String after, Point selection) {\r
+ textReference.setValue(before +\r
+ "[[Media:root://Documents/Document.pdf|Link to a file within the model]]\r\n" + selected + after);\r
+ \r
+ }\r
+ };\r
+ }\r
+ \r
@SCLValue(type = "ReadGraph -> Resource -> Variable -> b")\r
public static Object linkModifier(ReadGraph graph, Resource resource, final Variable context) throws DatabaseException {\r
\r
@Override\r
void perform(String before, String selected, String after, Point selection) {\r
\r
- textReference.setValue(before + "\r\n" +\r
- "[http://www.simantics.org External Website Link]\r\n" + selected + after);\r
+ textReference.setValue(before +\r
+ "[http://www.simantics.org External Website Link]\r\n" + selected + after);\r
\r
}\r
\r
return true;\r
\r
}\r
- \r
+\r
+ private static class ResolveURI extends UnaryRead<String, Object> {\r
+ public ResolveURI(String uri) {\r
+ super(uri);\r
+ }\r
+ @Override\r
+ public Object perform(ReadGraph graph) throws DatabaseException {\r
+ Object result = graph.syncRequest(new PossibleResource(parameter));\r
+ if (result == null)\r
+ result = Variables.getPossibleVariable(graph, parameter);\r
+ return result;\r
+ }\r
+ }\r
+\r
+ private static final Function1<Object, Boolean> PERFORM_DEFAULT_ACTION_FOR_URI_RESOURCE = new Function1<Object, Boolean>() {\r
+ @Override\r
+ public Boolean apply(Object p0) {\r
+ LocationEvent le = (LocationEvent) p0;\r
+ if (le.location.startsWith(DocumentDialect.SIMANTICS_INTERNAL_URI_PREFIX)) {\r
+ // This is not a valid URL anyway so deny relocation.\r
+ le.doit = false;\r
+\r
+ // Try to execute default action for the resource or variable\r
+ // that the URI represents.\r
+ String uri = le.location.substring(DocumentDialect.SIMANTICS_INTERNAL_URI_PREFIX.length());\r
+ try {\r
+ Session s = Simantics.getSession();\r
+ Object input = RequestUtil.trySyncRequest(s,\r
+ SimanticsUI.UI_THREAD_REQUEST_START_TIMEOUT,\r
+ SimanticsUI.UI_THREAD_REQUEST_EXECUTION_TIMEOUT,\r
+ new ResolveURI(uri));\r
+ if (input != null) {\r
+ DefaultActions.asyncPerformDefaultAction(s, input, false, false, false);\r
+ }\r
+ } catch (DatabaseException | InterruptedException e) {\r
+ Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to resolve URI to a database resource or variable: " + uri, e));\r
+ }\r
+ }\r
+ return true;\r
+ }\r
+ };\r
+\r
+ @SCLValue(type = "ReadGraph -> Resource -> Variable -> b")\r
+ public static Function1<Object, Boolean> locationChanging(ReadGraph graph, Resource variable, Variable context) throws DatabaseException {\r
+ return PERFORM_DEFAULT_ACTION_FOR_URI_RESOURCE;\r
+ }\r
+\r
}\r
*******************************************************************************/\r
package org.simantics.document;\r
\r
-import java.io.File;\r
import java.io.IOException;\r
import java.math.BigInteger;\r
+import java.nio.file.Files;\r
+import java.nio.file.Path;\r
import java.security.MessageDigest;\r
import java.security.NoSuchAlgorithmException;\r
import java.util.regex.Matcher;\r
import org.simantics.db.common.request.PossibleIndexRoot;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.image2.ontology.ImageResource;\r
-import org.simantics.utils.FileUtils;\r
-\r
\r
public class DocumentDialect {\r
- \r
- final Pattern imagePattern = Pattern.compile("\\[\\[Image(?::([^\\]]+))?\\]\\]");\r
\r
final static public DocumentDialect INSTANCE = new DocumentDialect();\r
\r
- public String transform(ReadGraph graph, Resource res, String options) {\r
- \r
+ public static final String SIMANTICS_INTERNAL_URI_PREFIX = "http://simantics-internal/";\r
+\r
+ private static final String HTTP = "http://";\r
+ private static final String ROOT = "root:/";\r
+ private static final String IMAGE = "image";\r
+ private static final String MEDIA = "media";\r
+\r
+ final Pattern imageOrMediaPattern = Pattern.compile("\\[\\[([Ii]mage|[Mm]edia)(?::([^\\]]+))?\\]\\]");\r
+\r
+ private static String digest(byte[] bytes) throws NoSuchAlgorithmException {\r
+ MessageDigest md = MessageDigest.getInstance("MD5");\r
+ md.update(bytes);\r
+ BigInteger number = new BigInteger(1, md.digest());\r
+ return number.toString(16);\r
+ }\r
+\r
+ private static String imageExtension(ReadGraph graph, Resource image) throws DatabaseException {\r
+ ImageResource IMAGE = ImageResource.getInstance(graph);\r
+ if (graph.isInstanceOf(image, IMAGE.PngImage))\r
+ return ".png";\r
+ else if (graph.isInstanceOf(image, IMAGE.JpegImage))\r
+ return ".jpg";\r
+ return null;\r
+ }\r
+\r
+ public String transform(ReadGraph graph, Resource res, String type, String options) {\r
try {\r
- \r
String[] parts = options.split("\\|");\r
- if(parts.length > 0) {\r
- \r
+ if (parts.length > 0) {\r
String uri = parts[0];\r
+\r
Resource indexRoot = graph.syncRequest(new PossibleIndexRoot(res));\r
- if(indexRoot == null) return null;\r
+ if (indexRoot == null) return null;\r
String rootURI = graph.getURI(indexRoot);\r
- uri = uri.replace("root:/", rootURI);\r
- // (Apros #12268) For easier image linking, allow users to\r
- // write white space as ' ' in the wiki-style image links.\r
+\r
+ uri = uri.replace(ROOT, rootURI);\r
+\r
+ // (Apros #12268) For more user-friendly linking, allow users to\r
+ // write white space as ' ' in the wiki-style image links instead\r
+ // of having to write %20.\r
uri = uri.replace(" ", "%20");\r
- Resource image = graph.getPossibleResource(uri);\r
- if(image == null) return null;\r
- byte[] bytes = graph.getValue(image, Bindings.BYTE_ARRAY);\r
- MessageDigest md;\r
- md = MessageDigest.getInstance("MD5");\r
- md.update(bytes);\r
- BigInteger number = new BigInteger(1, md.digest());\r
- String digest = number.toString(16);\r
- File dir = Simantics.getTemporaryDirectory("documentImages");\r
- dir.mkdirs();\r
- \r
- ImageResource IMAGE = ImageResource.getInstance(graph);\r
- \r
- String extension;\r
- if(graph.isInstanceOf(image, IMAGE.PngImage)) extension = ".png";\r
- else if(graph.isInstanceOf(image, IMAGE.JpegImage)) extension = ".jpg";\r
- else return null;\r
- \r
- File f = new File(dir, digest + extension);\r
- if(!f.exists())\r
- FileUtils.writeFile(f, bytes);\r
- StringBuilder sb = new StringBuilder();\r
- sb.append("[[File: " + f.toURI());\r
- for(int i=1;i<parts.length;i++) {\r
- sb.append("|");\r
- sb.append(parts[i]);\r
+\r
+ if (IMAGE.equals(type)) {\r
+ Resource image = graph.getPossibleResource(uri);\r
+ if (image == null)\r
+ return null;\r
+\r
+ String extension = imageExtension(graph, image);\r
+ if (extension == null)\r
+ return null;\r
+\r
+ byte[] bytes = graph.getValue(image, Bindings.BYTE_ARRAY);\r
+ String digest = digest(bytes);\r
+\r
+ Path dir = Simantics.getTemporaryDirectory("documentImages").toPath();\r
+ Files.createDirectories(dir);\r
+\r
+ Path f = dir.resolve(digest + extension);\r
+ if (!Files.exists(f))\r
+ Files.write(f, bytes);\r
+\r
+ StringBuilder sb = new StringBuilder(128);\r
+ sb.append("[[File: ").append(f.toUri());\r
+ for (int i = 1; i < parts.length; i++)\r
+ sb.append("|").append(parts[i]);\r
+ sb.append("]]");\r
+ return sb.toString();\r
+ } else if (MEDIA.equals(type)) {\r
+ Resource image = graph.getPossibleResource(uri);\r
+ if (image == null)\r
+ return null;\r
+\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append("[").append(SIMANTICS_INTERNAL_URI_PREFIX).append(uri);\r
+ for (int i = 1; i < parts.length; i++)\r
+ sb.append(" ").append(parts[i]);\r
+ sb.append("]");\r
+ return sb.toString();\r
}\r
- sb.append("]]");\r
- return sb.toString();\r
+\r
}\r
- \r
} catch (DatabaseException e) {\r
} catch (NoSuchAlgorithmException e) {\r
} catch (IOException e) {\r
}\r
\r
return null;\r
- \r
}\r
\r
public String apply(ReadGraph graph, Resource res, String markup) throws DatabaseException {\r
\r
StringBuffer sb = new StringBuffer();\r
- Matcher matcher = imagePattern.matcher(markup);\r
+ Matcher matcher = imageOrMediaPattern.matcher(markup);\r
while(matcher.find()) {\r
matcher.appendReplacement(sb, "");\r
- String options = matcher.group(1);\r
- String match = transform(graph, res, options);\r
+ String type = matcher.group(1);\r
+ String options = matcher.group(2);\r
+ String match = transform(graph, res, type.toLowerCase(), options);\r
if(match != null) sb.append(match);\r
else sb.append("[[Image:" + options + "]]");\r
}\r
return result.toString();\r
}\r
\r
- \r
}\r
}\r
else {\r
Activator.logError("Method " + method.getName() + " in class " + \r
- clazz.getCanonicalName() + " has incompantible SCL type in the SCLValue annotation."\r
+ clazz.getCanonicalName() + " has incompatible SCL type in the SCLValue annotation."\r
);\r
ReflectionUtils.isCompatible(scheme, type, method);\r
}\r
}\r
else {\r
Activator.logError("Constructor of " + \r
- clazz.getCanonicalName() + " has incompantible SCL type in the SCLValue annotation."\r
+ clazz.getCanonicalName() + " has incompatible SCL type in the SCLValue annotation."\r
);\r
}\r
} catch (TypeNotFoundException e) {\r
}\r
else {\r
Activator.logError("Field " + field.getName() + " in class " + \r
- clazz.getCanonicalName() + " has incompantible SCL type in the SCLValue annotation."\r
+ clazz.getCanonicalName() + " has incompatible SCL type in the SCLValue annotation."\r
);\r
}\r
} catch (TypeNotFoundException e) {\r
Views.Control.Style.Constant.Wrap = 64 : L0.Integer
Views.Control.Style.Constant.HScroll = 256 : L0.Integer
Views.Control.Style.Constant.VScroll = 512 : L0.Integer
+Views.Control.Style.Constant.Horizontal = 256 : L0.Integer
+Views.Control.Style.Constant.Vertical = 512 : L0.Integer
Views.Control.Style.Constant.Border = 2048 : L0.Integer
Views.Control.Style.Constant.FullSelection = 65536 : L0.Integer
Views.Control.Style.Constant.NoFocus = 524288 : L0.Integer
Views.Browser <T Views.Control
>-- Views.Browser.document ==> "String" <R SG.Node.HasProperty : L0.FunctionalRelation
>-- Views.Browser.variable ==> "Variable" <R SG.Node.HasProperty : L0.FunctionalRelation
+ >-- Views.Browser.locationChanging ==> "a -> Boolean" <R SG.Node.HasProperty : L0.FunctionalRelation
Views.WikiBrowser <T Views.Control
>-- Views.WikiBrowser.document ==> "String" <R SG.Node.HasProperty : L0.FunctionalRelation
Views.GridLayout.GridData.END = 3 : L0.Integer
Views.GridLayout.GridData.FILL = 4 : L0.Integer
+Views.RowLayout <T Views.Layout
+ @L0.assert L0.HasValueType "RowLayout"
+ @L0.assert
+ L0.ConvertsToValueWith
+ Views.Functions.rowLayout : L0.ExternalValue
+ >-- Views.RowLayout.type ==> "Integer" <R L0.HasProperty : L0.FunctionalRelation
+ >-- Views.RowLayout.spacing ==> "Integer" <R L0.HasProperty : L0.FunctionalRelation
+ >-- Views.RowLayout.center ==> "Boolean" <R L0.HasProperty : L0.FunctionalRelation
+ >-- Views.RowLayout.fill ==> "Boolean" <R L0.HasProperty : L0.FunctionalRelation
+ >-- Views.RowLayout.justify ==> "Boolean" <R L0.HasProperty : L0.FunctionalRelation
+ >-- Views.RowLayout.pack ==> "Boolean" <R L0.HasProperty : L0.FunctionalRelation
+ >-- Views.RowLayout.wrap ==> "Boolean" <R L0.HasProperty : L0.FunctionalRelation
+ >-- Views.RowLayout.extendedMargins ==> "a" <R L0.HasProperty : L0.FunctionalRelation
+ @L0.assert Views.RowLayout.type Views.Control.Style.Constant.Horizontal
+ @L0.assert Views.RowLayout.spacing 3
+ @L0.assert Views.RowLayout.center false
+ @L0.assert Views.RowLayout.fill false
+ @L0.assert Views.RowLayout.justify false
+ @L0.assert Views.RowLayout.pack true
+ @L0.assert Views.RowLayout.wrap true
+ @L0.assert Views.RowLayout.extendedMargins
+ (3,3,3,3) : Views.RowLayout.ExtendedMargins
+
+Views.RowLayout.ExtendedMargins <T L0.Literal
+ @L0.assert L0.HasDataType $(Integer,Integer,Integer,Integer)
+
+Views.RowLayout.RowData <T L0.Value
+ @L0.assert L0.HasValueType "RowData"
+ @L0.assert
+ L0.ConvertsToValueWith
+ Views.Functions.rowData : L0.ExternalValue
+ >-- Views.RowLayout.RowData.width ==> "Integer" <R L0.HasProperty : L0.FunctionalRelation
+ >-- Views.RowLayout.RowData.height ==> "Integer" <R L0.HasProperty : L0.FunctionalRelation
+ @L0.assert Views.RowLayout.RowData.width -1
+ @L0.assert Views.RowLayout.RowData.height -1
+
Views.SingleColumn
@Views.Explorer.Column.full "single" "Entries" "LEFT" 150 "Entries" true 1
public final Resource Browser;\r
public final Resource Browser_document;\r
public final Resource Browser_document_Inverse;\r
+ public final Resource Browser_locationChanging;\r
+ public final Resource Browser_locationChanging_Inverse;\r
public final Resource Browser_variable;\r
public final Resource Browser_variable_Inverse;\r
public final Resource BundleImage;\r
public final Resource Control_Style_Constant_Check;\r
public final Resource Control_Style_Constant_FullSelection;\r
public final Resource Control_Style_Constant_HScroll;\r
+ public final Resource Control_Style_Constant_Horizontal;\r
public final Resource Control_Style_Constant_Multi;\r
public final Resource Control_Style_Constant_NoFocus;\r
public final Resource Control_Style_Constant_None;\r
public final Resource Control_Style_Constant_Push;\r
public final Resource Control_Style_Constant_ReadOnly;\r
public final Resource Control_Style_Constant_VScroll;\r
+ public final Resource Control_Style_Constant_Vertical;\r
public final Resource Control_Style_Constant_Wrap;\r
public final Resource Control_Style_HasConstant;\r
public final Resource Control_Style_HasConstant_Inverse;\r
public final Resource Functions_gridLayout;\r
public final Resource Functions_parameterValue;\r
public final Resource Functions_resourceURI;\r
+ public final Resource Functions_rowData;\r
+ public final Resource Functions_rowLayout;\r
public final Resource Functions_singleResourceSelection;\r
public final Resource Functions_style;\r
public final Resource Functions_tabChildNames;\r
public final Resource ResourceURI;\r
public final Resource ResourceURI_HasResource;\r
public final Resource ResourceURI_HasResource_Inverse;\r
+ public final Resource RowLayout;\r
+ public final Resource RowLayout_ExtendedMargins;\r
+ public final Resource RowLayout_RowData;\r
+ public final Resource RowLayout_RowData_height;\r
+ public final Resource RowLayout_RowData_height_Inverse;\r
+ public final Resource RowLayout_RowData_width;\r
+ public final Resource RowLayout_RowData_width_Inverse;\r
+ public final Resource RowLayout_center;\r
+ public final Resource RowLayout_center_Inverse;\r
+ public final Resource RowLayout_extendedMargins;\r
+ public final Resource RowLayout_extendedMargins_Inverse;\r
+ public final Resource RowLayout_fill;\r
+ public final Resource RowLayout_fill_Inverse;\r
+ public final Resource RowLayout_justify;\r
+ public final Resource RowLayout_justify_Inverse;\r
+ public final Resource RowLayout_pack;\r
+ public final Resource RowLayout_pack_Inverse;\r
+ public final Resource RowLayout_spacing;\r
+ public final Resource RowLayout_spacing_Inverse;\r
+ public final Resource RowLayout_type;\r
+ public final Resource RowLayout_type_Inverse;\r
+ public final Resource RowLayout_wrap;\r
+ public final Resource RowLayout_wrap_Inverse;\r
public final Resource SashForm;\r
public final Resource SashForm_Horizontal;\r
public final Resource SashForm_Vertical;\r
public static final String Browser = "http://www.simantics.org/Views-1.2/Browser";\r
public static final String Browser_document = "http://www.simantics.org/Views-1.2/Browser/document";\r
public static final String Browser_document_Inverse = "http://www.simantics.org/Views-1.2/Browser/document/Inverse";\r
+ public static final String Browser_locationChanging = "http://www.simantics.org/Views-1.2/Browser/locationChanging";\r
+ public static final String Browser_locationChanging_Inverse = "http://www.simantics.org/Views-1.2/Browser/locationChanging/Inverse";\r
public static final String Browser_variable = "http://www.simantics.org/Views-1.2/Browser/variable";\r
public static final String Browser_variable_Inverse = "http://www.simantics.org/Views-1.2/Browser/variable/Inverse";\r
public static final String BundleImage = "http://www.simantics.org/Views-1.2/BundleImage";\r
public static final String Control_Style_Constant_Check = "http://www.simantics.org/Views-1.2/Control/Style/Constant/Check";\r
public static final String Control_Style_Constant_FullSelection = "http://www.simantics.org/Views-1.2/Control/Style/Constant/FullSelection";\r
public static final String Control_Style_Constant_HScroll = "http://www.simantics.org/Views-1.2/Control/Style/Constant/HScroll";\r
+ public static final String Control_Style_Constant_Horizontal = "http://www.simantics.org/Views-1.2/Control/Style/Constant/Horizontal";\r
public static final String Control_Style_Constant_Multi = "http://www.simantics.org/Views-1.2/Control/Style/Constant/Multi";\r
public static final String Control_Style_Constant_NoFocus = "http://www.simantics.org/Views-1.2/Control/Style/Constant/NoFocus";\r
public static final String Control_Style_Constant_None = "http://www.simantics.org/Views-1.2/Control/Style/Constant/None";\r
public static final String Control_Style_Constant_Push = "http://www.simantics.org/Views-1.2/Control/Style/Constant/Push";\r
public static final String Control_Style_Constant_ReadOnly = "http://www.simantics.org/Views-1.2/Control/Style/Constant/ReadOnly";\r
public static final String Control_Style_Constant_VScroll = "http://www.simantics.org/Views-1.2/Control/Style/Constant/VScroll";\r
+ public static final String Control_Style_Constant_Vertical = "http://www.simantics.org/Views-1.2/Control/Style/Constant/Vertical";\r
public static final String Control_Style_Constant_Wrap = "http://www.simantics.org/Views-1.2/Control/Style/Constant/Wrap";\r
public static final String Control_Style_HasConstant = "http://www.simantics.org/Views-1.2/Control/Style/HasConstant";\r
public static final String Control_Style_HasConstant_Inverse = "http://www.simantics.org/Views-1.2/Control/Style/HasConstant/Inverse";\r
public static final String Functions_gridLayout = "http://www.simantics.org/Views-1.2/Functions/gridLayout";\r
public static final String Functions_parameterValue = "http://www.simantics.org/Views-1.2/Functions/parameterValue";\r
public static final String Functions_resourceURI = "http://www.simantics.org/Views-1.2/Functions/resourceURI";\r
+ public static final String Functions_rowData = "http://www.simantics.org/Views-1.2/Functions/rowData";\r
+ public static final String Functions_rowLayout = "http://www.simantics.org/Views-1.2/Functions/rowLayout";\r
public static final String Functions_singleResourceSelection = "http://www.simantics.org/Views-1.2/Functions/singleResourceSelection";\r
public static final String Functions_style = "http://www.simantics.org/Views-1.2/Functions/style";\r
public static final String Functions_tabChildNames = "http://www.simantics.org/Views-1.2/Functions/tabChildNames";\r
public static final String ResourceURI = "http://www.simantics.org/Views-1.2/ResourceURI";\r
public static final String ResourceURI_HasResource = "http://www.simantics.org/Views-1.2/ResourceURI/HasResource";\r
public static final String ResourceURI_HasResource_Inverse = "http://www.simantics.org/Views-1.2/ResourceURI/HasResource/Inverse";\r
+ public static final String RowLayout = "http://www.simantics.org/Views-1.2/RowLayout";\r
+ public static final String RowLayout_ExtendedMargins = "http://www.simantics.org/Views-1.2/RowLayout/ExtendedMargins";\r
+ public static final String RowLayout_RowData = "http://www.simantics.org/Views-1.2/RowLayout/RowData";\r
+ public static final String RowLayout_RowData_height = "http://www.simantics.org/Views-1.2/RowLayout/RowData/height";\r
+ public static final String RowLayout_RowData_height_Inverse = "http://www.simantics.org/Views-1.2/RowLayout/RowData/height/Inverse";\r
+ public static final String RowLayout_RowData_width = "http://www.simantics.org/Views-1.2/RowLayout/RowData/width";\r
+ public static final String RowLayout_RowData_width_Inverse = "http://www.simantics.org/Views-1.2/RowLayout/RowData/width/Inverse";\r
+ public static final String RowLayout_center = "http://www.simantics.org/Views-1.2/RowLayout/center";\r
+ public static final String RowLayout_center_Inverse = "http://www.simantics.org/Views-1.2/RowLayout/center/Inverse";\r
+ public static final String RowLayout_extendedMargins = "http://www.simantics.org/Views-1.2/RowLayout/extendedMargins";\r
+ public static final String RowLayout_extendedMargins_Inverse = "http://www.simantics.org/Views-1.2/RowLayout/extendedMargins/Inverse";\r
+ public static final String RowLayout_fill = "http://www.simantics.org/Views-1.2/RowLayout/fill";\r
+ public static final String RowLayout_fill_Inverse = "http://www.simantics.org/Views-1.2/RowLayout/fill/Inverse";\r
+ public static final String RowLayout_justify = "http://www.simantics.org/Views-1.2/RowLayout/justify";\r
+ public static final String RowLayout_justify_Inverse = "http://www.simantics.org/Views-1.2/RowLayout/justify/Inverse";\r
+ public static final String RowLayout_pack = "http://www.simantics.org/Views-1.2/RowLayout/pack";\r
+ public static final String RowLayout_pack_Inverse = "http://www.simantics.org/Views-1.2/RowLayout/pack/Inverse";\r
+ public static final String RowLayout_spacing = "http://www.simantics.org/Views-1.2/RowLayout/spacing";\r
+ public static final String RowLayout_spacing_Inverse = "http://www.simantics.org/Views-1.2/RowLayout/spacing/Inverse";\r
+ public static final String RowLayout_type = "http://www.simantics.org/Views-1.2/RowLayout/type";\r
+ public static final String RowLayout_type_Inverse = "http://www.simantics.org/Views-1.2/RowLayout/type/Inverse";\r
+ public static final String RowLayout_wrap = "http://www.simantics.org/Views-1.2/RowLayout/wrap";\r
+ public static final String RowLayout_wrap_Inverse = "http://www.simantics.org/Views-1.2/RowLayout/wrap/Inverse";\r
public static final String SashForm = "http://www.simantics.org/Views-1.2/SashForm";\r
public static final String SashForm_Horizontal = "http://www.simantics.org/Views-1.2/SashForm/Horizontal";\r
public static final String SashForm_Vertical = "http://www.simantics.org/Views-1.2/SashForm/Vertical";\r
Browser = getResourceOrNull(graph, URIs.Browser);\r
Browser_document = getResourceOrNull(graph, URIs.Browser_document);\r
Browser_document_Inverse = getResourceOrNull(graph, URIs.Browser_document_Inverse);\r
+ Browser_locationChanging = getResourceOrNull(graph, URIs.Browser_locationChanging);\r
+ Browser_locationChanging_Inverse = getResourceOrNull(graph, URIs.Browser_locationChanging_Inverse);\r
Browser_variable = getResourceOrNull(graph, URIs.Browser_variable);\r
Browser_variable_Inverse = getResourceOrNull(graph, URIs.Browser_variable_Inverse);\r
BundleImage = getResourceOrNull(graph, URIs.BundleImage);\r
Control_Style_Constant_Check = getResourceOrNull(graph, URIs.Control_Style_Constant_Check);\r
Control_Style_Constant_FullSelection = getResourceOrNull(graph, URIs.Control_Style_Constant_FullSelection);\r
Control_Style_Constant_HScroll = getResourceOrNull(graph, URIs.Control_Style_Constant_HScroll);\r
+ Control_Style_Constant_Horizontal = getResourceOrNull(graph, URIs.Control_Style_Constant_Horizontal);\r
Control_Style_Constant_Multi = getResourceOrNull(graph, URIs.Control_Style_Constant_Multi);\r
Control_Style_Constant_NoFocus = getResourceOrNull(graph, URIs.Control_Style_Constant_NoFocus);\r
Control_Style_Constant_None = getResourceOrNull(graph, URIs.Control_Style_Constant_None);\r
Control_Style_Constant_Push = getResourceOrNull(graph, URIs.Control_Style_Constant_Push);\r
Control_Style_Constant_ReadOnly = getResourceOrNull(graph, URIs.Control_Style_Constant_ReadOnly);\r
Control_Style_Constant_VScroll = getResourceOrNull(graph, URIs.Control_Style_Constant_VScroll);\r
+ Control_Style_Constant_Vertical = getResourceOrNull(graph, URIs.Control_Style_Constant_Vertical);\r
Control_Style_Constant_Wrap = getResourceOrNull(graph, URIs.Control_Style_Constant_Wrap);\r
Control_Style_HasConstant = getResourceOrNull(graph, URIs.Control_Style_HasConstant);\r
Control_Style_HasConstant_Inverse = getResourceOrNull(graph, URIs.Control_Style_HasConstant_Inverse);\r
Functions_gridLayout = getResourceOrNull(graph, URIs.Functions_gridLayout);\r
Functions_parameterValue = getResourceOrNull(graph, URIs.Functions_parameterValue);\r
Functions_resourceURI = getResourceOrNull(graph, URIs.Functions_resourceURI);\r
+ Functions_rowData = getResourceOrNull(graph, URIs.Functions_rowData);\r
+ Functions_rowLayout = getResourceOrNull(graph, URIs.Functions_rowLayout);\r
Functions_singleResourceSelection = getResourceOrNull(graph, URIs.Functions_singleResourceSelection);\r
Functions_style = getResourceOrNull(graph, URIs.Functions_style);\r
Functions_tabChildNames = getResourceOrNull(graph, URIs.Functions_tabChildNames);\r
ResourceURI = getResourceOrNull(graph, URIs.ResourceURI);\r
ResourceURI_HasResource = getResourceOrNull(graph, URIs.ResourceURI_HasResource);\r
ResourceURI_HasResource_Inverse = getResourceOrNull(graph, URIs.ResourceURI_HasResource_Inverse);\r
+ RowLayout = getResourceOrNull(graph, URIs.RowLayout);\r
+ RowLayout_ExtendedMargins = getResourceOrNull(graph, URIs.RowLayout_ExtendedMargins);\r
+ RowLayout_RowData = getResourceOrNull(graph, URIs.RowLayout_RowData);\r
+ RowLayout_RowData_height = getResourceOrNull(graph, URIs.RowLayout_RowData_height);\r
+ RowLayout_RowData_height_Inverse = getResourceOrNull(graph, URIs.RowLayout_RowData_height_Inverse);\r
+ RowLayout_RowData_width = getResourceOrNull(graph, URIs.RowLayout_RowData_width);\r
+ RowLayout_RowData_width_Inverse = getResourceOrNull(graph, URIs.RowLayout_RowData_width_Inverse);\r
+ RowLayout_center = getResourceOrNull(graph, URIs.RowLayout_center);\r
+ RowLayout_center_Inverse = getResourceOrNull(graph, URIs.RowLayout_center_Inverse);\r
+ RowLayout_extendedMargins = getResourceOrNull(graph, URIs.RowLayout_extendedMargins);\r
+ RowLayout_extendedMargins_Inverse = getResourceOrNull(graph, URIs.RowLayout_extendedMargins_Inverse);\r
+ RowLayout_fill = getResourceOrNull(graph, URIs.RowLayout_fill);\r
+ RowLayout_fill_Inverse = getResourceOrNull(graph, URIs.RowLayout_fill_Inverse);\r
+ RowLayout_justify = getResourceOrNull(graph, URIs.RowLayout_justify);\r
+ RowLayout_justify_Inverse = getResourceOrNull(graph, URIs.RowLayout_justify_Inverse);\r
+ RowLayout_pack = getResourceOrNull(graph, URIs.RowLayout_pack);\r
+ RowLayout_pack_Inverse = getResourceOrNull(graph, URIs.RowLayout_pack_Inverse);\r
+ RowLayout_spacing = getResourceOrNull(graph, URIs.RowLayout_spacing);\r
+ RowLayout_spacing_Inverse = getResourceOrNull(graph, URIs.RowLayout_spacing_Inverse);\r
+ RowLayout_type = getResourceOrNull(graph, URIs.RowLayout_type);\r
+ RowLayout_type_Inverse = getResourceOrNull(graph, URIs.RowLayout_type_Inverse);\r
+ RowLayout_wrap = getResourceOrNull(graph, URIs.RowLayout_wrap);\r
+ RowLayout_wrap_Inverse = getResourceOrNull(graph, URIs.RowLayout_wrap_Inverse);\r
SashForm = getResourceOrNull(graph, URIs.SashForm);\r
SashForm_Horizontal = getResourceOrNull(graph, URIs.SashForm_Horizontal);\r
SashForm_Vertical = getResourceOrNull(graph, URIs.SashForm_Vertical);\r
package org.simantics.views.swt.client.base;\r
\r
import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.layout.RowLayoutFactory;\r
import org.eclipse.swt.SWT;\r
import org.eclipse.swt.layout.GridData;\r
import org.eclipse.swt.layout.GridLayout;\r
+import org.eclipse.swt.layout.RowData;\r
+import org.eclipse.swt.layout.RowLayout;\r
import org.eclipse.swt.widgets.Layout;\r
import org.simantics.browsing.ui.Column;\r
import org.simantics.browsing.ui.Column.Align;\r
import org.simantics.views.ViewUtils.ColumnBean;\r
import org.simantics.views.ViewUtils.GridDataBean;\r
import org.simantics.views.ViewUtils.GridLayoutBean;\r
+import org.simantics.views.ViewUtils.LayoutBean;\r
+import org.simantics.views.ViewUtils.LayoutDataBean;\r
+import org.simantics.views.ViewUtils.RowDataBean;\r
+import org.simantics.views.ViewUtils.RowLayoutBean;\r
\r
public class SWTViewUtils {\r
\r
result.marginBottom = bean.marginBottom;\r
return result;\r
}\r
- \r
- \r
+\r
+ public static Layout toLayout(RowLayoutBean bean) {\r
+ RowLayout result = RowLayoutFactory.fillDefaults().create();\r
+ result.type = bean.type;\r
+ result.spacing = bean.spacing;\r
+ result.center = bean.center;\r
+ result.fill = bean.fill;\r
+ result.justify = bean.justify;\r
+ result.pack = bean.pack;\r
+ result.wrap = bean.wrap;\r
+ result.marginLeft = bean.marginLeft;\r
+ result.marginRight = bean.marginRight;\r
+ result.marginTop = bean.marginTop;\r
+ result.marginBottom = bean.marginBottom;\r
+ return result;\r
+ }\r
+\r
public static GridData toGridData(GridDataBean bean) {\r
- GridData result = new GridData(SWT.FILL, SWT.FILL, true, false); \r
+ GridData result = new GridData(SWT.FILL, SWT.FILL, true, false);\r
result.horizontalSpan = bean.horizontalSpan;\r
result.grabExcessHorizontalSpace = bean.grabExcessHorizontalSpace;\r
result.grabExcessVerticalSpace = bean.grabExcessVerticalSpace;\r
\r
}\r
\r
+ public static RowData toRowData(RowDataBean bean) {\r
+ return new RowData(bean.width, bean.height);\r
+ }\r
+\r
+ public static Layout toLayout(LayoutBean layout) {\r
+ if (layout instanceof GridLayoutBean)\r
+ return toLayout((GridLayoutBean) layout);\r
+ if (layout instanceof RowLayoutBean)\r
+ return toLayout((RowLayoutBean) layout);\r
+ throw new IllegalArgumentException("unrecognized layout: " + layout);\r
+ }\r
+\r
+\r
+ public static Object toLayoutData(LayoutDataBean layoutData) {\r
+ if (layoutData instanceof GridDataBean)\r
+ return toGridData((GridDataBean) layoutData);\r
+ if (layoutData instanceof RowDataBean)\r
+ return toRowData((RowDataBean) layoutData);\r
+ throw new IllegalArgumentException("unrecognized layout data: " + layoutData);\r
+ }\r
+\r
private static Align getAlign(String alignment) {\r
if("LEFT".equals(alignment)) return Align.LEFT;\r
else if("CENTER".equals(alignment)) return Align.CENTER;\r
import org.simantics.ui.fonts.Fonts;\r
import org.simantics.utils.threads.IThreadWorkQueue;\r
import org.simantics.utils.threads.SWTThread;\r
-import org.simantics.views.ViewUtils.GridDataBean;\r
+import org.simantics.views.ViewUtils.LayoutDataBean;\r
\r
abstract public class SingleSWTViewNode<T extends Control> extends SWTParentNode implements LoaderNode {\r
\r
private Map<String, Object> genericProperties = new HashMap<String, Object>();\r
\r
public Function2<String, Object, Boolean> propertyCallback;\r
- public GridDataBean layoutData;\r
+ public LayoutDataBean layoutData;\r
public int style;\r
public String text;\r
public RGB.Integer background;\r
final public void synchronizeStyle(int style) {\r
}\r
\r
- final public void synchronizeLayoutData(GridDataBean layoutData) {\r
- if(layoutData != null) control.setLayoutData(SWTViewUtils.toGridData(layoutData));\r
+ final public void synchronizeLayoutData(LayoutDataBean layoutData) {\r
+ if(layoutData != null) control.setLayoutData(SWTViewUtils.toLayoutData(layoutData));\r
}\r
\r
}\r
import org.eclipse.jface.layout.GridDataFactory;\r
import org.eclipse.jface.layout.GridLayoutFactory;\r
import org.eclipse.swt.browser.Browser;\r
+import org.eclipse.swt.browser.LocationEvent;\r
+import org.eclipse.swt.browser.LocationListener;\r
import org.eclipse.swt.widgets.Composite;\r
import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.scl.runtime.function.Function1;\r
import org.simantics.utils.datastructures.map.Tuple;\r
import org.simantics.views.swt.client.base.SingleSWTViewNode;\r
\r
\r
private static final long serialVersionUID = -2704760050046054447L;\r
\r
- public String document;\r
- public Variable variable;\r
+ public String document;\r
+ public Variable variable;\r
+ public Function1<Object, Boolean> locationChanging;\r
\r
- private Tuple lastAppliedParametrization;\r
+ private Tuple lastAppliedParametrization;\r
\r
@Override\r
public void reset() {\r
control = new Browser(parent, style);\r
GridDataFactory.fillDefaults().grab(true, true).applyTo(control);\r
\r
+ control.addLocationListener(new LocationListener() {\r
+ @Override\r
+ public void changing(LocationEvent event) {\r
+ Function1<Object, Boolean> lc = locationChanging;\r
+ if (lc != null)\r
+ lc.apply(event);\r
+ }\r
+ @Override\r
+ public void changed(LocationEvent event) {\r
+ }\r
+ });\r
+\r
setProperties();\r
\r
}\r
package org.simantics.views.swt.client.impl;\r
\r
import org.eclipse.swt.widgets.Composite;\r
-import org.simantics.views.ViewUtils.GridLayoutBean;\r
+import org.simantics.views.ViewUtils.LayoutBean;\r
import org.simantics.views.swt.client.base.SWTViewUtils;\r
import org.simantics.views.swt.client.base.SingleSWTViewNode;\r
\r
\r
private static final long serialVersionUID = 7932335224632082902L;\r
\r
- public GridLayoutBean layout;\r
+ public LayoutBean layout;\r
\r
@Override\r
public void createControls(org.eclipse.swt.widgets.Composite parent) {\r
\r
}\r
\r
- final public void synchronizeLayout(GridLayoutBean layout) {\r
+ final public void synchronizeLayout(LayoutBean layout) {\r
if(layout != null) control.setLayout(SWTViewUtils.toLayout(layout));\r
}\r
\r
import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupportImpl;\r
import org.simantics.scl.runtime.function.Function1;\r
import org.simantics.views.ViewUtils.ColumnBean;\r
-import org.simantics.views.ViewUtils.GridLayoutBean;\r
+import org.simantics.views.ViewUtils.LayoutBean;\r
import org.simantics.views.swt.client.base.SWTViewUtils;\r
import org.simantics.views.swt.client.base.SingleSWTViewNode;\r
\r
\r
private static final long serialVersionUID = 7932335224632082902L;\r
\r
- public GridLayoutBean layout;\r
+ public LayoutBean layout;\r
public String browseContext;\r
public String contextMenuId;\r
public String uiContext;\r
}\r
}\r
\r
- final public void synchronizeLayout(GridLayoutBean layout) {\r
+ final public void synchronizeLayout(LayoutBean layout) {\r
}\r
\r
}\r
import org.eclipse.swt.custom.SashForm;\r
import org.eclipse.swt.widgets.Control;\r
import org.eclipse.swt.widgets.Sash;\r
-import org.simantics.views.ViewUtils.GridLayoutBean;\r
+import org.simantics.views.ViewUtils.LayoutBean;\r
import org.simantics.views.swt.client.base.SWTViewUtils;\r
import org.simantics.views.swt.client.base.SingleSWTViewNode;\r
\r
\r
private static final long serialVersionUID = 7932335224632082902L;\r
\r
- public GridLayoutBean layout;\r
+ public LayoutBean layout;\r
public int[] weights;\r
public Integer orientation;\r
\r
\r
}\r
\r
- final public void synchronizeLayout(GridLayoutBean layout) {\r
+ final public void synchronizeLayout(LayoutBean layout) {\r
if(layout != null) control.setLayout(SWTViewUtils.toLayout(layout));\r
}\r
\r
import org.eclipse.swt.widgets.Display;\r
import org.eclipse.swt.widgets.Event;\r
import org.eclipse.swt.widgets.Listener;\r
-import org.simantics.views.ViewUtils.GridLayoutBean;\r
+import org.simantics.views.ViewUtils.LayoutBean;\r
import org.simantics.views.swt.client.base.SWTViewUtils;\r
import org.simantics.views.swt.client.base.SingleSWTViewNode;\r
\r
\r
private static final long serialVersionUID = 7932335224632082902L;\r
\r
- public GridLayoutBean layout;\r
+ public LayoutBean layout;\r
\r
private int minSize = 100;\r
\r
\r
}\r
\r
- final public void synchronizeLayout(GridLayoutBean layout) {\r
+ final public void synchronizeLayout(LayoutBean layout) {\r
if(layout != null) control.setLayout(SWTViewUtils.toLayout(layout));\r
}\r
\r
import org.eclipse.swt.widgets.Control;\r
import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
import org.simantics.utils.ui.jface.BasePostSelectionProvider;\r
-import org.simantics.views.ViewUtils.GridLayoutBean;\r
+import org.simantics.views.ViewUtils.LayoutBean;\r
import org.simantics.views.swt.client.base.ISWTViewNode;\r
import org.simantics.views.swt.client.base.SingleSWTViewNode;\r
\r
\r
public List<String> childNames;\r
\r
- public GridLayoutBean layout;\r
+ public LayoutBean layout;\r
\r
final BasePostSelectionProvider selectionProvider = new BasePostSelectionProvider();\r
\r
\r
}\r
\r
- final public void synchronizeLayout(GridLayoutBean layout) {\r
+ final public void synchronizeLayout(LayoutBean layout) {\r
}\r
\r
}\r
\r
@SCLValue(type = "ReadGraph -> Resource -> Variable -> a")\r
public static Object gridData(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {\r
- return ViewUtils.getGridData(graph, converter);\r
+ return ViewUtils.getGridData(graph, converter);\r
}\r
\r
@SCLValue(type = "ReadGraph -> Resource -> Variable -> a")\r
public static Object gridLayout(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {\r
- return ViewUtils.getLayout(graph, converter);\r
+ return ViewUtils.getLayout(graph, converter);\r
+ }\r
+\r
+ @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")\r
+ public static Object rowData(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {\r
+ return ViewUtils.getRowData(graph, converter);\r
+ }\r
+\r
+ @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")\r
+ public static Object rowLayout(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {\r
+ return ViewUtils.getRowLayout(graph, converter);\r
}\r
\r
@SCLValue(type = "ReadGraph -> Resource -> Variable -> a")\r
}\r
\r
public static final Binding EXTENDED_MARGINS_BINDING = Bindings.getBindingUnchecked(ExtendedMargins.class);\r
- \r
- public static class GridLayoutBean extends Bean {\r
- \r
- public int numColumns;\r
- public int horizontalSpacing;\r
- public int verticalSpacing;\r
+\r
+ public static class LayoutBean extends Bean {\r
public int marginLeft;\r
public int marginRight;\r
public int marginTop;\r
public int marginBottom;\r
+ }\r
+\r
+ public static class GridLayoutBean extends LayoutBean {\r
+ \r
+ public int numColumns;\r
+ public int horizontalSpacing;\r
+ public int verticalSpacing;\r
\r
}\r
- \r
- public static class GridDataBean extends Bean {\r
+\r
+ public static class RowLayoutBean extends LayoutBean {\r
+ public int type;\r
+ public int spacing;\r
+ public boolean center;\r
+ public boolean fill;\r
+ public boolean justify;\r
+ public boolean pack;\r
+ public boolean wrap;\r
+ }\r
+\r
+ public static class LayoutDataBean extends Bean {}\r
+\r
+ public static class GridDataBean extends LayoutDataBean {\r
\r
public int horizontalSpan;\r
public boolean grabExcessHorizontalSpace;\r
public int heightHint;\r
\r
}\r
- \r
+\r
+ public static class RowDataBean extends LayoutDataBean {\r
+ public int width;\r
+ public int height;\r
+ }\r
+\r
public static class ColumnBean extends Bean {\r
\r
public String key;\r
\r
}\r
\r
+ public static RowLayoutBean getRowLayout(RequestProcessor processor, Resource configuration) throws DatabaseException {\r
+ return processor.sync(new ResourceRead<RowLayoutBean>(configuration) {\r
+ @Override\r
+ public RowLayoutBean perform(ReadGraph graph) throws DatabaseException {\r
+ ViewsResources VIEW = ViewsResources.getInstance(graph);\r
+ Integer type = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_type, Bindings.INTEGER);\r
+ Integer spacing = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_spacing, Bindings.INTEGER);\r
+ Boolean center = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_center, Bindings.BOOLEAN);\r
+ Boolean fill = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_fill, Bindings.BOOLEAN);\r
+ Boolean justify = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_justify, Bindings.BOOLEAN);\r
+ Boolean pack = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_pack, Bindings.BOOLEAN);\r
+ Boolean wrap = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_wrap, Bindings.BOOLEAN);\r
+ ExtendedMargins extendedMargins = graph.getPossibleRelatedValue(resource, VIEW.RowLayout_extendedMargins, EXTENDED_MARGINS_BINDING);\r
+\r
+ RowLayoutBean layout = new RowLayoutBean();\r
+ layout.type = type;\r
+ layout.spacing = spacing;\r
+ layout.center = center;\r
+ layout.fill = fill;\r
+ layout.justify = justify;\r
+ layout.pack = pack;\r
+ layout.wrap = wrap;\r
+ layout.marginLeft = extendedMargins.left;\r
+ layout.marginRight = extendedMargins.right;\r
+ layout.marginTop = extendedMargins.top;\r
+ layout.marginBottom = extendedMargins.bottom;\r
+ return layout;\r
+ }\r
+ });\r
+ }\r
+\r
+ public static RowDataBean getRowData(RequestProcessor processor, Resource configuration) throws DatabaseException {\r
+ return processor.sync(new ResourceRead<RowDataBean>(configuration) {\r
+ @Override\r
+ public RowDataBean perform(ReadGraph graph) throws DatabaseException {\r
+ ViewsResources VIEW = ViewsResources.getInstance(graph);\r
+ RowDataBean data = new RowDataBean();\r
+ data.width = graph.getPossibleRelatedValue(resource, VIEW.GridLayout_GridData_preferredWidth, Bindings.INTEGER);\r
+ data.height = graph.getPossibleRelatedValue(resource, VIEW.GridLayout_GridData_preferredHeight, Bindings.INTEGER);\r
+ return data;\r
+ }\r
+ });\r
+ }\r
+\r
public static int getStyle(RequestProcessor processor, Resource configuration) throws DatabaseException {\r
\r
return processor.sync(new ResourceRead<Integer>(configuration) {\r
\r
Simantics.getSession().async(new TernaryRead<Resource, Variable, String, T> (configuration, context, relationURI) {\r
\r
+ @SuppressWarnings("unchecked")\r
@Override\r
public T perform(ReadGraph graph) throws DatabaseException {\r
Object value = graph.getRelatedValue2(parameter, graph.getResource(parameter3), parameter2);\r