Merge branch 'feature/funcwrite'
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 7 Apr 2017 07:38:57 +0000 (10:38 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 7 Apr 2017 07:38:57 +0000 (10:38 +0300)
334 files changed:
bundles/org.simantics.acorn/src/org/simantics/acorn/ClusterManager.java
bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java
bundles/org.simantics.acorn/src/org/simantics/acorn/HeadState.java
bundles/org.simantics.acorn/src/org/simantics/acorn/HeadState1.java [new file with mode: 0644]
bundles/org.simantics.acorn/src/org/simantics/acorn/internal/AcornDatabase.java
bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRU.java
bundles/org.simantics.acorn/src/org/simantics/acorn/lru/LRUObject.java
bundles/org.simantics.annotation.ui/scl/Simantics/Annotation2.scl
bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/labeldecorators/ConstantLabelDecorationRule.java
bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/labels/LabelContribution.java
bundles/org.simantics.browsing.ui.nattable/src/org/simantics/browsing/ui/nattable/NatTableGraphExplorer.java
bundles/org.simantics.browsing.ui.swt/META-INF/MANIFEST.MF
bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/GraphExplorerFactory.java
bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/GraphExplorerImpl.java
bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/GraphExplorerImpl2.java
bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/widgets/GraphExplorerComposite.java
bundles/org.simantics.browsing.ui/src/org/simantics/browsing/ui/GraphExplorer.java
bundles/org.simantics.charts/scl/Simantics/Chart.scl
bundles/org.simantics.charts/src/org/simantics/charts/Charts.java
bundles/org.simantics.charts/src/org/simantics/charts/TrendSupport.java
bundles/org.simantics.db.impl/META-INF/MANIFEST.MF
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CacheEntryBase.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/URIToResource.java
bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/DatabaseIndexing.java
bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsImpl.java
bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/internal/IndexChangedWriter.java [new file with mode: 0644]
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/impl/SharedOntologyImportAdvisor.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/MigratedImportResult.java [new file with mode: 0644]
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/MigrationStateImpl.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/MigrationStateKeys.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/MigrationUtils.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/PossibleVariableRepresents.java [new file with mode: 0644]
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/ConsistsOfProcess.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/DomainProcessor3.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/DomainProcessorState.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/ExtendedUris.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/ExternalDownloadBean.java [new file with mode: 0644]
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Layer0Utils.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/ModelTransferableGraphSource.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Subgraphs.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/TGRepresentationUtils.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/XSupportImpl.java
bundles/org.simantics.db/src/org/simantics/db/service/XSupport.java
bundles/org.simantics.desktop.ui.ontology/graph.tg
bundles/org.simantics.diagram.ontology/graph.tg
bundles/org.simantics.diagram/META-INF/MANIFEST.MF
bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/CompositeImage.java
bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/DefinedElementFactory.java
bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/DefinedElementHandler.java [new file with mode: 0644]
bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/DefinedElementTerminals.java [new file with mode: 0644]
bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/RouteGraphUtils.java
bundles/org.simantics.diagram/src/org/simantics/diagram/elements/MonitorClass.java
bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextNode.java
bundles/org.simantics.diagram/src/org/simantics/diagram/flag/RouteGraphConnectionSplitter.java
bundles/org.simantics.diagram/src/org/simantics/diagram/flag/Splitter.java
bundles/org.simantics.diagram/src/org/simantics/diagram/handler/CopyPasteHandler.java
bundles/org.simantics.diagram/src/org/simantics/diagram/handler/Paster.java
bundles/org.simantics.diagram/src/org/simantics/diagram/symbollibrary/ui/SymbolLibraryComposite.java
bundles/org.simantics.diagram/src/org/simantics/diagram/synchronization/graph/CopyAdvisorUtil.java
bundles/org.simantics.document.base.ontology/graph.tg
bundles/org.simantics.document.ontology/META-INF/MANIFEST.MF
bundles/org.simantics.document.ontology/graph.tg
bundles/org.simantics.document.ontology/graph/Document.pgraph
bundles/org.simantics.document.ontology/src/org/simantics/document/DocumentResource.java
bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/ITreeTableCell.java
bundles/org.simantics.document.server.io/src/org/simantics/document/server/io/JSONObjectUtils.java
bundles/org.simantics.document.server/scl/Document/All.scl
bundles/org.simantics.document.swt.ontology/graph.tg
bundles/org.simantics.document.ui.ontology/META-INF/MANIFEST.MF
bundles/org.simantics.document.ui.ontology/graph.tg
bundles/org.simantics.document.ui.ontology/graph/DocumentUI.pgraph
bundles/org.simantics.document.ui/META-INF/MANIFEST.MF
bundles/org.simantics.document.ui/scl/Simantics/Document.scl
bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddUrlDocument.java
bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/AddUrlDocumentWithDetail.java
bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ExportDocumentFolder.java
bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ImportDocumentFolder.java
bundles/org.simantics.document.ui/src/org/simantics/document/ui/actions/ImportDocumentWithDetail.java
bundles/org.simantics.document.ui/src/org/simantics/document/ui/function/All.java
bundles/org.simantics.document.ui/src/org/simantics/document/ui/wizard/FileDocumentImportWizard.java
bundles/org.simantics.document/META-INF/MANIFEST.MF
bundles/org.simantics.document/src/org/simantics/document/Activator.java
bundles/org.simantics.document/src/org/simantics/document/AddDocumentAction.java [new file with mode: 0644]
bundles/org.simantics.document/src/org/simantics/document/DocumentUtils.java
bundles/org.simantics.document/src/org/simantics/document/DocumentVersionUtils.java [new file with mode: 0644]
bundles/org.simantics.document/src/org/simantics/document/Exportable.java
bundles/org.simantics.document/src/org/simantics/document/FileDocumentUtil.java [new file with mode: 0644]
bundles/org.simantics.document/src/org/simantics/document/ImportDocument.java [new file with mode: 0644]
bundles/org.simantics.export.core/src/org/simantics/export/core/pdf/ExportPdfFormat.java
bundles/org.simantics.export.core/src/org/simantics/export/core/pdf/ExportPdfWriter.java
bundles/org.simantics.export.core/src/org/simantics/export/core/pdf/FontMapping.java [new file with mode: 0644]
bundles/org.simantics.export.core/src/org/simantics/export/core/pdf/PageNumbering.java [new file with mode: 0644]
bundles/org.simantics.fileimport.ui/META-INF/MANIFEST.MF
bundles/org.simantics.fileimport.ui/src/org/simantics/fileimport/ui/ImportFileHandler.java
bundles/org.simantics.fileimport/META-INF/MANIFEST.MF
bundles/org.simantics.fileimport/scl/Dropins/Core.scl
bundles/org.simantics.fileimport/src/org/simantics/fileimport/Activator.java
bundles/org.simantics.fileimport/src/org/simantics/fileimport/FileImportService.java
bundles/org.simantics.fileimport/src/org/simantics/fileimport/FileReferenceFileImport.java
bundles/org.simantics.fileimport/src/org/simantics/fileimport/LibraryFolderFileImport.java
bundles/org.simantics.fileimport/src/org/simantics/fileimport/scl/DropinsSCL.java
bundles/org.simantics.g2d/META-INF/MANIFEST.MF
bundles/org.simantics.g2d/src/org/simantics/g2d/chassis/AWTChassis.java
bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/participant/ElementPainter.java
bundles/org.simantics.g2d/src/org/simantics/g2d/element/ElementUtils.java
bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/Terminals.java
bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/MonitorClass.java [deleted file]
bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/wheel/RotatorHandler.java
bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/wheel/WheelClass.java
bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/resourceFiles/FilterCRWriter.java [new file with mode: 0644]
bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/resourceFiles/ResourceFile.java
bundles/org.simantics.graph.db/src/org/simantics/graph/db/CoreInitialization.java
bundles/org.simantics.graph.db/src/org/simantics/graph/db/ImportResult.java [new file with mode: 0644]
bundles/org.simantics.graph.db/src/org/simantics/graph/db/StreamingTransferableGraphImportProcess.java
bundles/org.simantics.graph.db/src/org/simantics/graph/db/TransferableGraphs.java
bundles/org.simantics.graph.db/src/org/simantics/graph/db/old/OldTransferableGraphs.java
bundles/org.simantics.graph/src/org/simantics/graph/refactoring/GraphRefactoringUtils.java
bundles/org.simantics.graph/src/org/simantics/graph/representation/PrettyPrintTG.java [new file with mode: 0644]
bundles/org.simantics.graph/src/org/simantics/graph/representation/TransferableGraphUtils.java
bundles/org.simantics.help.ontology/graph.tg
bundles/org.simantics.history/src/org/simantics/history/HistorySampler.java
bundles/org.simantics.issues.common/src/org/simantics/issues/common/All.java
bundles/org.simantics.layer0/graph.tg
bundles/org.simantics.layer0/graph/Layer0.pgraph
bundles/org.simantics.layer0/graph/Layer0SCL.pgraph
bundles/org.simantics.layer0/src/org/simantics/layer0/Layer0.java
bundles/org.simantics.modeling.ontology/graph.tg
bundles/org.simantics.modeling.ontology/graph/Modeling.pgraph
bundles/org.simantics.modeling.ontology/graph/ModelingViewpoint.pgraph
bundles/org.simantics.modeling.ontology/src/org/simantics/modeling/ModelingResources.java
bundles/org.simantics.modeling.template2d.ui/scl/Simantics/DrawingTemplate.scl
bundles/org.simantics.modeling.ui/META-INF/MANIFEST.MF
bundles/org.simantics.modeling.ui/scl/Simantics/Library.scl
bundles/org.simantics.modeling.ui/scl/Simantics/Testing/ActionBrowseContext.scl
bundles/org.simantics.modeling.ui/scl/Simantics/Testing/BrowseContext.scl
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/CompilePGraphs.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/ModeledActions.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/SymbolCodeDocumentProvider2.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/SymbolDropHandlerDocumentProvider.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/SliderClass.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/style/ConnectionPointNameStyle.java [new file with mode: 0644]
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/handlers/ContextualHelp.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser2/label/ConnectionRelationLabelDecorationRule.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/pdf/DiagramPrinter.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/pdf/PDFDiagramExportWizard.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/pdf/PDFExportPlan.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/pdf/PDFPainter.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sharedontology/wizard/SharedOntologyImportWizard.java
bundles/org.simantics.modeling/META-INF/MANIFEST.MF
bundles/org.simantics.modeling/scl/Simantics/All.scl
bundles/org.simantics.modeling/scl/Simantics/Diagram.scl
bundles/org.simantics.modeling/scl/Simantics/DiagramMapping.scl
bundles/org.simantics.modeling/scl/Simantics/Flag.scl
bundles/org.simantics.modeling/scl/Simantics/Issue.scl
bundles/org.simantics.modeling/scl/Simantics/Model.scl
bundles/org.simantics.modeling/scl/Simantics/Rename.scl
bundles/org.simantics.modeling/scl/Simantics/Scenegraph.scl
bundles/org.simantics.modeling/scl/Simantics/Simulation.scl
bundles/org.simantics.modeling/scl/Simantics/Subscription.scl
bundles/org.simantics.modeling/scl/Simantics/UserComponent.scl
bundles/org.simantics.modeling/scl/Simantics/Workbench.scl [new file with mode: 0644]
bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java
bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java
bundles/org.simantics.modeling/src/org/simantics/modeling/internal/Activator.java
bundles/org.simantics.modeling/src/org/simantics/modeling/mapping/ElementCopyAdvisor.java
bundles/org.simantics.modeling/src/org/simantics/modeling/scl/CompileSCLMonitorRequest.java
bundles/org.simantics.modeling/src/org/simantics/modeling/scl/GraphModuleSourceRepository.java
bundles/org.simantics.modeling/src/org/simantics/modeling/scl/OntologyModule.java
bundles/org.simantics.platform.ui.ontology/graph.tg
bundles/org.simantics.project/src/org/simantics/project/ProjectFeatures.java
bundles/org.simantics.project/src/org/simantics/project/internal/ProjectFeatureRegistry.java
bundles/org.simantics.scenegraph.profile/META-INF/MANIFEST.MF
bundles/org.simantics.scenegraph.profile/src/org/simantics/scenegraph/profile/request/AvailableProfiles.java [new file with mode: 0644]
bundles/org.simantics.scenegraph.profile/src/org/simantics/scenegraph/profile/request/RuntimeProfileActiveEntryResources.java
bundles/org.simantics.scenegraph.ui/src/org/simantics/scenegraph/ui/AttributeDialog.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/G2DNode.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/G2DParentNode.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/G2DRenderingHints.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/IG2DNode.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/IG2DNodeVisitor.java [new file with mode: 0644]
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/NodeEventHandler.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/ConnectionNode.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/SVGNode.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/SingleElementNode.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/UnboundedNode.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/NodeUtil.java
bundles/org.simantics.scl.compiler/META-INF/MANIFEST.MF
bundles/org.simantics.scl.compiler/OSGI-INF/org.simantics.scl.compiler.elaboration.java.LoggingModule.xml [new file with mode: 0644]
bundles/org.simantics.scl.compiler/build.properties
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/DeclarationClassification.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/Elaboration.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/SCLCompiler.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/annotations/AnnotationUtils.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/java/Builtins.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/java/JavaModule.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/java/LoggingModule.java [new file with mode: 0644]
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/java/MinigraphModule.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/ssa/SSABlock.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/ssa/SSAFunction.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/ssa/exits/Switch.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/types/DummyJavaReferenceValidator.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/types/JavaReferenceValidator.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/types/JavaReferenceValidatorFactory.java [new file with mode: 0644]
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/types/RuntimeJavaReferenceValidator.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/CodeBuilderUtils.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/ModuleBuilder.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/SSAUtils.java [new file with mode: 0644]
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/ValueFromMethod.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/header/ModuleHeader.java [new file with mode: 0644]
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/interpreted/ILambda.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/declarations/DModuleHeader.java [new file with mode: 0644]
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCL.grammar
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCLParser.dat
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCLParser.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCLParserImpl.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCLParserOptions.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCLPostLexer.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCLTerminals.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/ConcreteModule.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/InvalidModulePathException.java [new file with mode: 0644]
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/Module.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/ModuleUtils.java [new file with mode: 0644]
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/repository/ModuleRepository.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/runtime/RuntimeModule.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/source/TextualModuleSource.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/source/repository/BuiltinModuleSourceRepository.java
bundles/org.simantics.scl.db/scl/Simantics/DB.scl
bundles/org.simantics.scl.db/scl/Simantics/Variables.scl
bundles/org.simantics.scl.db/src/org/simantics/scl/db/SCLFunctions.java
bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/internal/BundleModuleSource.java
bundles/org.simantics.scl.osgi/src/org/simantics/scl/osgi/internal/OsgiJavaReferenceValidatorFactory.java [new file with mode: 0644]
bundles/org.simantics.scl.runtime/generation/org/simantics/scl/runtime/generation/GenerateFunctions.java
bundles/org.simantics.scl.runtime/scl/Prelude.scl
bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/Lists.java
bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/function/UnsaturatedFunction1.java
bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/function/UnsaturatedFunction2.java
bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/function/UnsaturatedFunction3.java
bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/function/UnsaturatedFunction4.java
bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/function/UnsaturatedFunction5.java
bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/function/UnsaturatedFunction6.java
bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/function/UnsaturatedFunction7.java
bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/function/UnsaturatedFunction8.java
bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/function/UnsaturatedFunctionN.java
bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/reporting/SCLReportingWriter.java [new file with mode: 0644]
bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor/completion/SCLTextEditorEnvironment.java
bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/OpenDeclaration.java
bundles/org.simantics.selectionview.ontology/graph.tg
bundles/org.simantics.selectionview.ontology/graph/Selectionview.pgraph
bundles/org.simantics.selectionview.ui.ontology/graph.tg
bundles/org.simantics.selectionview.ui.ontology/graph/SelectionViewUi.pgraph
bundles/org.simantics.selectionview.ui.ontology/graph/scl/SCLMain.scl [new file with mode: 0644]
bundles/org.simantics.selectionview.ui.ontology/src/org/simantics/selectionview/ui/ontology/SelectionViewUIResources.java
bundles/org.simantics.simulation/META-INF/MANIFEST.MF
bundles/org.simantics.simulation/src/org/simantics/simulation/experiment/Experiment.java
bundles/org.simantics.simulation/src/org/simantics/simulation/experiment/ExperimentUtil.java
bundles/org.simantics.simulation/src/org/simantics/simulation/project/ExperimentManager.java
bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/common/TreeTableCell.java
bundles/org.simantics.spreadsheet.fileimport/src/org/simantics/spreadsheet/fileimport/ExcelFileImport.java
bundles/org.simantics.spreadsheet.graph/scl/Spreadsheet/All.scl
bundles/org.simantics.spreadsheet.ontology/graph.tg
bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ModuleUpdateContext.java
bundles/org.simantics.ui/src/org/simantics/ui/contribution/OpenWithMenuContribution.java
bundles/org.simantics.ui/src/org/simantics/ui/contribution/OperationsMenuContribution.java
bundles/org.simantics.ui/src/org/simantics/ui/selection/WorkbenchSelectionUtils.java
bundles/org.simantics.ui/src/org/simantics/ui/workbench/editor/EditorRegistry.java
bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/BinaryCallback.java
bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/Callable.java
bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/TimingUtil.java
bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/UnaryFunction.java
bundles/org.simantics.utils.thread.swt/src/org/simantics/utils/threads/SWTThread.java
bundles/org.simantics.utils.thread/META-INF/MANIFEST.MF
bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/Executors2.java [deleted file]
bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/dialogs/InfoDialog.java [new file with mode: 0644]
bundles/org.simantics.utils/src/org/simantics/utils/FileService.java
bundles/org.simantics.utils/src/org/simantics/utils/FileUtils.java
bundles/org.simantics.viewpoint.ontology/graph.tg
bundles/org.simantics.views.swt/src/org/simantics/views/swt/loader/ButtonLoader.java.keep [deleted file]
bundles/org.simantics.views.swt/src/org/simantics/views/swt/loader/CComboLoader.java.keep [deleted file]
bundles/org.simantics.views.swt/src/org/simantics/views/swt/loader/ComboLoader.java.keep [deleted file]
bundles/org.simantics.views.swt/src/org/simantics/views/swt/loader/CompositeLoader.java.keep [deleted file]
bundles/org.simantics.views.swt/src/org/simantics/views/swt/loader/ExplorerLoader.java.keep [deleted file]
bundles/org.simantics.views.swt/src/org/simantics/views/swt/loader/LabelLoader.java.keep [deleted file]
bundles/org.simantics.views.swt/src/org/simantics/views/swt/loader/ScrolledCompositeLoader.java.keep [deleted file]
bundles/org.simantics.views.swt/src/org/simantics/views/swt/loader/TabFolderLoader.java.keep [deleted file]
bundles/org.simantics.views.swt/src/org/simantics/views/swt/loader/TextLoader.java.keep [deleted file]
bundles/org.simantics.views.swt/src/org/simantics/views/swt/loader/TrackedTextLoader.java.keep [deleted file]
bundles/org.simantics.views.text.ontology/.classpath [new file with mode: 0644]
bundles/org.simantics.views.text.ontology/.project [new file with mode: 0644]
bundles/org.simantics.views.text.ontology/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
bundles/org.simantics.views.text.ontology/META-INF/MANIFEST.MF [new file with mode: 0644]
bundles/org.simantics.views.text.ontology/build.properties [new file with mode: 0644]
bundles/org.simantics.views.text.ontology/graph.tg [new file with mode: 0644]
bundles/org.simantics.views.text.ontology/graph/TextViews.pgraph [new file with mode: 0644]
bundles/org.simantics.views.text.ontology/src/.keep [new file with mode: 0644]
bundles/org.simantics.views.text/.classpath [new file with mode: 0644]
bundles/org.simantics.views.text/.project [new file with mode: 0644]
bundles/org.simantics.views.text/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
bundles/org.simantics.views.text/META-INF/MANIFEST.MF [new file with mode: 0644]
bundles/org.simantics.views.text/adapters.xml [new file with mode: 0644]
bundles/org.simantics.views.text/build.properties [new file with mode: 0644]
bundles/org.simantics.views.text/plugin.xml [new file with mode: 0644]
bundles/org.simantics.views.text/src/org/simantics/views/text/internal/Activator.java [new file with mode: 0644]
bundles/org.simantics.views.text/src/org/simantics/views/text/internal/SWTMarkupSourceViewer.java [new file with mode: 0644]
bundles/org.simantics.views.text/src/org/simantics/views/text/internal/TextViewerConstants.java [new file with mode: 0644]
bundles/org.simantics.views.text/src/org/simantics/views/text/internal/TextViewerUndoHandler.java [new file with mode: 0644]
bundles/org.simantics.wiki.ui/src/org/simantics/wiki/ui/editor/IExportable.java
bundles/org.simantics.workbench.ontology/graph.tg
bundles/org.simantics/src/org/simantics/OntologyImportAdvisor.java
bundles/org.simantics/src/org/simantics/SimanticsPlatform.java
bundles/pom.xml
features/org.simantics.desktop.product.feature/feature.xml
features/org.simantics.g2d.feature/feature.xml
features/org.simantics.sdk.feature/feature.xml
features/org.simantics.ui.workbench.feature/feature.xml
features/org.simantics.views.swt.feature/feature.xml
features/pom.xml
releng/doc/dump-mysql-db.sh [changed mode: 0644->0755]
releng/doc/dump-wikis.sh [changed mode: 0644->0755]
releng/doc/release.html
releng/doc/release.md
releng/org.simantics.desktop.rcp.product/.project [new file with mode: 0644]
releng/org.simantics.desktop.rcp.product/pom.xml [new file with mode: 0644]
releng/org.simantics.desktop.rcp.product/simantics-desktop.product [moved from bundles/org.simantics.desktop.product/simantics-desktop.product with 66% similarity]
releng/org.simantics.sdk.build.p2.site/pom.xml
releng/org.simantics.sdk.build.targetdefinition/org.simantics.sdk.build.targetdefinition.target
releng/org.simantics.sdk.build.targetdefinition/simantics.target
releng/org.simantics.sdk.repository/pom.xml
releng/pom.xml
tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/ActiveTests.java
tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/ModuleRegressionTests.java
tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/ClosureRecursion.scl [new file with mode: 0644]
tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/FunctionIdentity.scl [new file with mode: 0644]
tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/Logger.scl [new file with mode: 0644]
tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/SwitchSimplification.scl [new file with mode: 0644]

index 22629d4e64237ab63c6fc89a12f0754087254edb..40c5de37e8c1991e6e5ce846e2b90e7b651b6c5e 100644 (file)
@@ -2,9 +2,11 @@ package org.simantics.acorn;
 
 import java.io.IOException;
 import java.math.BigInteger;
+import java.nio.file.CopyOption;
 import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -22,6 +24,7 @@ import org.simantics.acorn.lru.ClusterLRU;
 import org.simantics.acorn.lru.ClusterStreamChunk;
 import org.simantics.acorn.lru.FileInfo;
 import org.simantics.acorn.lru.LRU;
+import org.simantics.databoard.file.RuntimeIOException;
 import org.simantics.db.ClusterCreator;
 import org.simantics.db.Database.Session.ClusterIds;
 import org.simantics.db.Database.Session.ResourceSegment;
@@ -33,6 +36,7 @@ import org.simantics.db.impl.ClusterSupport;
 import org.simantics.db.procore.cluster.ClusterTraits;
 import org.simantics.db.service.ClusterSetsSupport;
 import org.simantics.db.service.ClusterUID;
+import org.simantics.utils.FileUtils;
 import org.simantics.utils.threads.logger.ITask;
 import org.simantics.utils.threads.logger.ThreadLogger;
 import org.slf4j.Logger;
@@ -134,6 +138,119 @@ public class ClusterManager {
        private AtomicBoolean safeToMakeSnapshot = new AtomicBoolean(true);
        private IllegalAcornStateException cause;
        
+       public synchronized void purge(ServiceLocator locator) throws IllegalAcornStateException {
+               
+           try {
+
+               // Schedule writing of all data to disk
+               refreshHeadState();
+               // Wait for files to be written
+               synchronizeWorkingDirectory();
+               
+               String currentDir = workingDirectory.getFileName().toString();
+               Path baseline = workingDirectory.resolveSibling(currentDir + "_baseline");
+               
+               Files.createDirectories(baseline);
+               
+               for(String clusterKey : state.clusters) {
+                       String[] parts1 = clusterKey.split("#");
+                       String[] parts = parts1[0].split("\\.");
+                       String readDirName = parts1[1];
+                       if(!readDirName.equals(currentDir)) {
+                               String fileName = parts[0] + "." + parts[1] + ".cluster";
+                               Path from = dbFolder.resolve(readDirName).resolve(fileName);
+                               Path to = baseline.resolve(fileName);
+                               System.err.println("purge copies " + from + "  => " + to);
+                               Files.copy(from, to, StandardCopyOption.COPY_ATTRIBUTES);
+                               long first = new BigInteger(parts[0], 16).longValue();
+                               long second = new BigInteger(parts[1], 16).longValue();
+                               ClusterUID uuid = ClusterUID.make(first, second);
+                               ClusterInfo info = clusterLRU.getWithoutMutex(uuid);
+                               info.moveTo(baseline);
+                       }
+               }
+               
+               for (String fileKey : state.files) {
+                       String[] parts = fileKey.split("#");
+                       String readDirName = parts[1];
+                       if(!readDirName.equals(currentDir)) {
+                               String fileName = parts[0] + ".extFile";
+                               Path from = dbFolder.resolve(readDirName).resolve(fileName);
+                               Path to = baseline.resolve(fileName);
+                               System.err.println("purge copies " + from + "  => " + to);
+                               Files.copy(from, to, StandardCopyOption.COPY_ATTRIBUTES);
+                               FileInfo info = fileLRU.getWithoutMutex(parts[0]);
+                               info.moveTo(baseline);
+                       }
+               }
+               
+               for (String fileKey : state.stream) {
+                       String[] parts = fileKey.split("#");
+                       String readDirName = parts[1];
+                       if(!readDirName.equals(currentDir)) {
+                               ClusterStreamChunk chunk = streamLRU.purge(parts[0]);
+                               System.err.println("purge removes " + chunk);
+                       }
+               }
+               
+               // Change sets
+               for (String fileKey : state.cs) {
+                       String[] parts = fileKey.split("#");
+                       String readDirName = parts[1];
+                       if(!readDirName.equals(currentDir)) {
+                               Long revisionId = Long.parseLong(parts[0]);
+                               ChangeSetInfo info = csLRU.purge(revisionId);
+                               System.err.println("purge removes " + info);
+                       }
+//                     Path readDir = dbFolder.resolve(parts[1]);
+//                     Long revisionId = Long.parseLong(parts[0]);
+//                     int offset = Integer.parseInt(parts[2]);
+//                     int length = Integer.parseInt(parts[3]);
+//                     ChangeSetInfo info = new ChangeSetInfo(csLRU, readDir, revisionId, offset, length);
+//                     csLRU.map(info);
+               }               
+               
+               state.tailChangeSetId = state.headChangeSetId;
+               
+               makeSnapshot(locator, true);
+               
+               Files.walk(dbFolder, 1).filter(Files::isDirectory).forEach(f -> tryPurgeDirectory(f));
+
+           } catch (IllegalAcornStateException e) {
+               notSafeToMakeSnapshot(e);
+               throw e;
+           } catch (IOException e) {
+               IllegalAcornStateException e1 = new IllegalAcornStateException(e);
+               notSafeToMakeSnapshot(e1);
+               throw e1;
+           } catch (AcornAccessVerificationException e) {
+               IllegalAcornStateException e1 = new IllegalAcornStateException(e);
+               notSafeToMakeSnapshot(e1);
+               throw e1;
+               }
+        
+       }
+       
+       void tryPurgeDirectory(Path f) {
+               
+               
+               System.err.println("purge deletes " + f);
+
+               String currentDir = f.getFileName().toString();
+               if(currentDir.endsWith("db"))
+                       return;
+
+               if(currentDir.endsWith("_baseline"))
+                       currentDir = currentDir.replace("_baseline", "");
+
+               int ordinal = Integer.parseInt(currentDir);
+               if(ordinal < mainState.headDir - 1) {
+                       System.err.println("purge deletes " + f);
+                       FileUtils.deleteDir(f.toFile());
+               }
+               
+       }
+
        public synchronized boolean makeSnapshot(ServiceLocator locator, boolean fullSave) throws IllegalAcornStateException {
            try {
            if (!safeToMakeSnapshot.get())
@@ -221,9 +338,13 @@ public class ClusterManager {
                csLRU.persist(state.cs);
        }
        
-       private void persistHeadState() throws IOException {
+       private void synchronizeWorkingDirectory() throws IOException {
                // Sync current working directory
                Files.walk(workingDirectory, 1).filter(Files::isRegularFile).forEach(FileIO::uncheckedSyncPath);
+       }
+       
+       private void persistHeadState() throws IOException {
+               synchronizeWorkingDirectory();
                state.save(workingDirectory);
                mainState.headDir++;
        }
@@ -583,4 +704,8 @@ public class ClusterManager {
         this.cause = t;
     }
 
+    public long getTailChangeSetId() {
+       return state.tailChangeSetId;
+    }
+    
 }
index 904427b6d617f6682c78547db1dde17a419dff48..dce477ebeae0fdf35d1db078acfd7e6e885ea825 100644 (file)
@@ -27,14 +27,13 @@ import org.simantics.acorn.exception.IllegalAcornStateException;
 import org.simantics.acorn.internal.ClusterChange;
 import org.simantics.acorn.internal.ClusterUpdateProcessorBase;
 import org.simantics.acorn.internal.UndoClusterUpdateProcessor;
+import org.simantics.acorn.lru.ClusterChangeSet.Entry;
 import org.simantics.acorn.lru.ClusterInfo;
 import org.simantics.acorn.lru.ClusterStreamChunk;
 import org.simantics.acorn.lru.ClusterUpdateOperation;
-import org.simantics.acorn.lru.ClusterChangeSet.Entry;
 import org.simantics.db.ClusterCreator;
 import org.simantics.db.Database;
 import org.simantics.db.ServiceLocator;
-import org.simantics.db.common.utils.Logger;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.exception.SDBException;
 import org.simantics.db.server.ProCoreException;
@@ -43,11 +42,14 @@ import org.simantics.db.service.ClusterUID;
 import org.simantics.db.service.LifecycleSupport;
 import org.simantics.utils.datastructures.Pair;
 import org.simantics.utils.logging.TimeLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.map.hash.TLongObjectHashMap;
 
 public class GraphClientImpl2 implements Database.Session {
-       
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(GraphClientImpl2.class);
        public static final boolean DEBUG = false;
 
        public final ClusterManager clusters;
@@ -124,10 +126,10 @@ public class GraphClientImpl2 implements Database.Session {
                                                mainProgram.mutex.release();
                                        }
                                } catch (IllegalAcornStateException | ProCoreException e) {
-                                       Logger.defaultLogError("Snapshotting failed", e);
+                                       LOGGER.error("Snapshotting failed", e);
                                        unexpectedClose = true;
                                } catch (InterruptedException e) {
-                                       Logger.defaultLogError("Snapshotting interrupted", e);
+                                   LOGGER.error("Snapshotting interrupted", e);
                                } finally {
                                        try {
                                                if(tr != null)
@@ -137,11 +139,11 @@ public class GraphClientImpl2 implements Database.Session {
                            try {
                                support.close();
                            } catch (DatabaseException e1) {
-                               Logger.defaultLogError("Failed to close database as a safety measure due to failed snapshotting", e1);
+                               LOGGER.error("Failed to close database as a safety measure due to failed snapshotting", e1);
                            }
                                                }
                                        } catch (ProCoreException e) {
-                                               Logger.defaultLogError("Failed to end snapshotting write transaction", e);
+                                           LOGGER.error("Failed to end snapshotting write transaction", e);
                                        }
                                }
                        }
@@ -184,7 +186,7 @@ public class GraphClientImpl2 implements Database.Session {
        
        @Override
        public void close() throws ProCoreException {
-           System.err.println("Closing " + this + " and mainProgram " + mainProgram);
+           LOGGER.info("Closing " + this + " and mainProgram " + mainProgram);
                if(!closed && !isClosing) {
                    isClosing = true;
                        try {
@@ -249,7 +251,7 @@ public class GraphClientImpl2 implements Database.Session {
                        clusters.state.headChangeSetId++;
                        return clusters.state.headChangeSetId;
                } catch (SDBException e) {
-                       Logger.defaultLogError("Failed to undo cancelled transaction", e);
+                   LOGGER.error("Failed to undo cancelled transaction", e);
                        throw new ProCoreException(e);
                }
        }
@@ -725,29 +727,67 @@ public class GraphClientImpl2 implements Database.Session {
     public boolean rolledback() {
         return clusters.rolledback();
     }
+    
+    public void purge() throws IllegalAcornStateException {
+        clusters.purge(locator);
+    }
 
-       
-       
-       
-       
-       
-       
-       
-       
-       
-       
-       ////////////////////////
-       
-       
-       
-       
-       
-       
-       
-       
-       
-       
-       
-       
+    public void purgeDatabase() {
+       
+           if (isClosing || unexpectedClose)
+               return;
+           
+               saver.execute(new Runnable() {
+
+                       @Override
+                       public void run() {
+                               Transaction tr = null;
+                               try {
+                                       // First take a write transaction
+                                       tr = askWriteTransaction(-1);
+                                       // Then make sure that MainProgram is idling
+                                       mainProgram.mutex.acquire();
+                                       try {
+                                               synchronized(mainProgram) {
+                                                       if(mainProgram.operations.isEmpty()) {
+                                                               purge();
+                                                       } else {
+                                                               // MainProgram is becoming busy again - delay snapshotting
+                                                               return;
+                                                       }
+                                               }
+                                       } finally {
+                                               mainProgram.mutex.release();
+                                       }
+                               } catch (IllegalAcornStateException | ProCoreException e) {
+                                   LOGGER.error("Purge failed", e);
+                                       unexpectedClose = true;
+                               } catch (InterruptedException e) {
+                                   LOGGER.error("Purge interrupted", e);
+                               } finally {
+                                       try {
+                                               if(tr != null)
+                                                       endTransaction(tr.getTransactionId());
+                                               if (unexpectedClose) {
+                                               LifecycleSupport support = getServiceLocator().getService(LifecycleSupport.class);
+                           try {
+                               support.close();
+                           } catch (DatabaseException e1) {
+                               LOGGER.error("Failed to close database as a safety measure due to failed purge", e1);
+                           }
+                                               }
+                                       } catch (ProCoreException e) {
+                                           LOGGER.error("Failed to end purge write transaction", e);
+                                       }
+                               }
+                       }
+               });
+       
+    }
+    
+    public long getTailChangeSetId() {
+       return clusters.getTailChangeSetId();
+    }
+    
 }
 
index dd8703c1fc689e0ed0bbfc1968e6730913d74750..fd38bc98542052bbdb2e762c65d49a4cad4f3585 100644 (file)
@@ -12,6 +12,7 @@ import java.util.Arrays;
 
 import org.simantics.acorn.exception.InvalidHeadStateException;
 import org.simantics.databoard.Bindings;
+import org.simantics.databoard.adapter.AdapterConstructionException;
 import org.simantics.databoard.binding.mutable.MutableVariant;
 import org.simantics.databoard.serialization.Serializer;
 import org.simantics.databoard.util.binary.BinaryMemory;
@@ -31,6 +32,8 @@ public class HeadState {
     public ArrayList<String> cs = new ArrayList<>();
 //    public ArrayList<String> ccs = new ArrayList<String>();
 
+    public long tailChangeSetId = 1;
+
     public static HeadState load(Path directory) throws InvalidHeadStateException {
         Path f = directory.resolve(HEAD_STATE);
         
@@ -51,6 +54,11 @@ public class HeadState {
                 return object;
             }
         } catch (IOException i) {
+               Throwable cause = i.getCause();
+               if(cause instanceof AdapterConstructionException) {
+                       HeadState1 old = HeadState1.load(directory);
+                       return old.migrate();
+               }
             return new HeadState();
 //            throw new InvalidHeadStateException(i);
         } catch (NoSuchAlgorithmException e) {
diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/HeadState1.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/HeadState1.java
new file mode 100644 (file)
index 0000000..d58a286
--- /dev/null
@@ -0,0 +1,117 @@
+package org.simantics.acorn;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.simantics.acorn.exception.InvalidHeadStateException;
+import org.simantics.databoard.Bindings;
+import org.simantics.databoard.binding.mutable.MutableVariant;
+import org.simantics.databoard.serialization.Serializer;
+import org.simantics.databoard.util.binary.BinaryMemory;
+
+public class HeadState1 {
+
+    public static final String HEAD_STATE = "head.state";
+    public static final String SHA_1 = "SHA-1";
+    
+    public int headChangeSetId = 0;
+    public long transactionId = 1;
+    public long reservedIds = 3;
+
+    public ArrayList<String> clusters = new ArrayList<>();
+    public ArrayList<String> files = new ArrayList<>();
+    public ArrayList<String> stream = new ArrayList<>();
+    public ArrayList<String> cs = new ArrayList<>();
+    
+    public HeadState migrate() {
+       HeadState state = new HeadState();
+       state.headChangeSetId = headChangeSetId;
+       state.transactionId = transactionId;
+       state.reservedIds = reservedIds;
+       state.clusters = clusters;
+       state.files = files;
+       state.stream = stream;
+       state.cs = cs;
+       return state;
+    }
+
+    public static HeadState1 load(Path directory) throws InvalidHeadStateException {
+        Path f = directory.resolve(HEAD_STATE);
+        
+        try {
+            byte[] bytes = Files.readAllBytes(f);
+            MessageDigest sha1 = MessageDigest.getInstance(SHA_1);
+            int digestLength = sha1.getDigestLength();
+            
+            sha1.update(bytes, digestLength, bytes.length - digestLength);
+            byte[] newChecksum = sha1.digest();
+            if (!Arrays.equals(newChecksum, Arrays.copyOfRange(bytes, 0, digestLength))) {
+                throw new InvalidHeadStateException(
+                        "Checksum " + Arrays.toString(newChecksum) + " does not match excpected "
+                                + Arrays.toString(Arrays.copyOfRange(bytes, 0, digestLength)) + " for " + f.toAbsolutePath());
+            }
+            try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes, digestLength, bytes.length - digestLength)) {
+                HeadState1 object = (HeadState1) org.simantics.databoard.Files.readFile(bais, Bindings.getBindingUnchecked(HeadState1.class));
+                return object;
+            }
+        } catch (IOException i) {
+            return new HeadState1();
+        } catch (NoSuchAlgorithmException e) {
+            throw new Error("SHA-1 Algorithm not found", e);
+        } catch (Throwable t) {
+            throw new InvalidHeadStateException(t);
+        }
+    }
+    
+    public void save(Path directory) throws IOException {
+        Path f = directory.resolve(HEAD_STATE);
+        try {
+            BinaryMemory rf = new BinaryMemory(4096);
+            try {
+                MutableVariant v = new MutableVariant(Bindings.getBindingUnchecked(HeadState1.class), this);
+                Serializer s = Bindings.getSerializerUnchecked( Bindings.VARIANT );
+                s.serialize(rf, v);
+            } finally {
+                rf.close();
+            }
+            
+            byte[] bytes = rf.toByteBuffer().array();
+            
+            MessageDigest sha1 = MessageDigest.getInstance(SHA_1);
+            sha1.update(bytes);
+            byte[] checksum = sha1.digest();
+            
+            try (OutputStream out = Files.newOutputStream(f)) {
+                out.write(checksum);
+                out.write(bytes);
+            }
+            FileIO.syncPath(f);
+        } catch (NoSuchAlgorithmException e) {
+            throw new Error("SHA-1 digest not found, should not happen", e);
+        }
+    }
+
+    public static void validateHeadStateIntegrity(Path headState) throws InvalidHeadStateException, IOException {
+        try {
+            byte[] bytes = Files.readAllBytes(headState);
+            MessageDigest sha1 = MessageDigest.getInstance(SHA_1);
+            int digestLength = sha1.getDigestLength();
+            sha1.update(bytes, digestLength, bytes.length - digestLength);
+            byte[] newChecksum = sha1.digest();
+            if (!Arrays.equals(newChecksum, Arrays.copyOfRange(bytes, 0, digestLength))) {
+                throw new InvalidHeadStateException(
+                        "Checksum " + Arrays.toString(newChecksum) + " does not match excpected "
+                                + Arrays.toString(Arrays.copyOfRange(bytes, 0, digestLength)) + " for " + headState.toAbsolutePath());
+            }
+        } catch (NoSuchAlgorithmException e) {
+            throw new Error("SHA-1 digest not found, should not happen", e);
+        }
+    }
+}
index be505c6039712e322ce80ffa653c1b4c6babac13..1025cc6a5dac0a2e6d5b940b1ad0d17ba971fa00 100644 (file)
@@ -19,7 +19,10 @@ import org.simantics.db.Database;
 import org.simantics.db.DatabaseUserAgent;
 import org.simantics.db.ServiceLocator;
 import org.simantics.db.common.utils.Logger;
+import org.simantics.db.exception.SDBException;
+import org.simantics.db.server.DatabaseStartException;
 import org.simantics.db.server.ProCoreException;
+import org.simantics.db.server.internal.InternalException;
 
 /**
  * @author Tuukka Lehtonen
@@ -27,6 +30,8 @@ import org.simantics.db.server.ProCoreException;
 public class AcornDatabase implements Database {
 
     private final Path folder;
+    
+    private GraphClientImpl2 currentClient;
 
     private DatabaseUserAgent userAgent;
 
@@ -190,22 +195,22 @@ public class AcornDatabase implements Database {
 
     @Override
     public void purgeDatabase() throws ProCoreException {
-        // TODO: implement
-        throw new UnsupportedOperationException();
+       if(currentClient == null) throw new IllegalStateException("No current session.");
+       currentClient.purgeDatabase();
     }
 
     @Override
     public long serverGetTailChangeSetId() throws ProCoreException {
-        // "We have it all"
-        // But after purging we don't so beware.
-        // TODO: beware for purge
-        return 1;
+       if(currentClient == null) throw new IllegalStateException("No current session.");
+       return currentClient.getTailChangeSetId();
     }
 
     @Override
     public Session newSession(ServiceLocator locator) throws ProCoreException {
         try {
-            return new GraphClientImpl2(this, folder, locator);
+               if(currentClient != null) throw new DatabaseStartException(folder.toFile(), "A session is already running. Only one session is supported.");
+               currentClient = new GraphClientImpl2(this, folder, locator); 
+            return currentClient;
         } catch (IOException e) {
             throw new ProCoreException(e);
         }
index 323d66d3df12ea34d2d429293801eeacfc95a23b..80fec7032940ac3e7a6a1abbebb02325880a8bfc 100644 (file)
@@ -16,16 +16,19 @@ import org.simantics.acorn.ClusterManager;
 import org.simantics.acorn.GraphClientImpl2;
 import org.simantics.acorn.exception.AcornAccessVerificationException;
 import org.simantics.acorn.exception.IllegalAcornStateException;
-import org.simantics.db.common.utils.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /*
  * The order rule of synchronization for LRU and LRUObject is:
- *   § Always lock LRUObject first!
+ *    Always lock LRUObject first!
  * 
  */
 
 public class LRU<MapKey,MapValue extends LRUObject<MapKey, MapValue>> {
-       
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(LRU.class); 
+    
        public static boolean VERIFY = true;
 
        final private long swapTime = 5L*1000000000L;
@@ -148,6 +151,12 @@ public class LRU<MapKey,MapValue extends LRUObject<MapKey, MapValue>> {
                }
        }
 
+       
+       
+       public MapValue purge(MapKey id) {
+               return map.remove(id);
+       }
+
        public MapValue get(MapKey key) throws AcornAccessVerificationException {
                
                if(VERIFY) verifyAccess();
@@ -513,7 +522,7 @@ public class LRU<MapKey,MapValue extends LRUObject<MapKey, MapValue>> {
                            manager.notSafeToMakeSnapshot(new IllegalAcornStateException(t));
                        }
                        t.printStackTrace();
-                       Logger.defaultLogError(t);
+                       LOGGER.error("Exception happened in WriteRunnable.run", t);
                    }
                }
 
@@ -553,7 +562,7 @@ public class LRU<MapKey,MapValue extends LRUObject<MapKey, MapValue>> {
                         runWithMutex();
                         done = true;
                     } else {
-                        System.err.println("Retry mutex acquire");
+                        LOGGER.warn("Retry mutex acquire");
                         gotMutex = impl.tryAcquireMutex();
                     }
 
index 3194d591e0b37e8712e8cabf3cc1afcb9549a754..508c951067dedc3df895d938b3a0e84f9dda771c 100644 (file)
@@ -243,5 +243,9 @@ public abstract class LRUObject<MapKey, MapValue extends LRUObject<MapKey, MapVa
                if(VERIFY) verifyAccess();
                return readDirectory;
        }
+
+       public void moveTo(Path path) {
+               readDirectory = path;
+       }
        
 }
\ No newline at end of file
index cd3f851cbf8afd65de822d935d20ad179424d47f..b06a8bdd41d8f810fe8448bae5935e79e037063b 100644 (file)
@@ -104,13 +104,13 @@ getPossibleAnnotationType model name = do
     all = searchByType model ANNO.AnnotationType
     named = filter (\x -> (getAnnotationNameFromType x) == name) all 
     if ((length named) == 1)
-     then Just (fromResource $ named!0) 
+     then Just (named!0) 
      else Nothing
     
 setAnnotationPropertyValue :: AnnotationPropertyRelation -> Resource -> String -> String -> <WriteGraph> ()
 setAnnotationPropertyValue annotation resource property newValue = do
     resourceUri = uriOf resource
-    annotationName = DB.nameOf (toResource annotation)
+    annotationName = DB.nameOf annotation
     completeUri = resourceUri + "#" + annotationName + "#" + property + "#HasDisplayValue"
     propertyVariable = variable completeUri
     setValue propertyVariable newValue
index 3bb2db942095c6a34390377a2d69488c57d2c094..494c0a8198b88685025e84c7e2abd4829e91d94f 100644 (file)
@@ -13,7 +13,9 @@ package org.simantics.browsing.ui.model.labeldecorators;
 
 import org.eclipse.jface.resource.ColorDescriptor;
 import org.eclipse.jface.resource.FontDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.graphics.RGB;
 import org.simantics.browsing.ui.content.LabelDecorator;
 import org.simantics.databoard.Bindings;
@@ -133,6 +135,7 @@ public class ConstantLabelDecorationRule extends AbstractLabelDecorator implemen
             return font;
         else {
             FontDescriptor desc = (FontDescriptor)font;
+            if(desc == null) desc = FontDescriptor.createFrom(JFaceResources.getDialogFont().getFontData());
             return (Font)desc.withStyle(style);
         }
     }
index e8a7b62227db8d40ab51bb5ea978af1bb20dc322..25f0d054d5b55670c934940c993048fbcb728c79 100644 (file)
@@ -24,6 +24,7 @@ import org.simantics.browsing.ui.model.tests.Test;
 import org.simantics.browsing.ui.model.visuals.VisualsContribution;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.exception.PendingVariableException;
 
 /**
  * Produces labels for nodes of given node type.
@@ -31,7 +32,7 @@ import org.simantics.db.exception.DatabaseException;
  */
 public class LabelContribution extends VisualsContribution {
     LabelRule labelRule;
-    
+
     public LabelContribution(NodeType nodeType, Test test, LabelRule labelRule, double priority) throws InvalidContribution {
         super(nodeType, test, priority);
         if(!labelRule.isCompatible(
@@ -40,7 +41,7 @@ public class LabelContribution extends VisualsContribution {
             throw new InvalidContribution("Label rule is not compatible with the content type.");
         this.labelRule = labelRule;
     }
-       
+
     /**
      * Returns a label for the node or null, if contribution is
      * not suitable for the input.
@@ -48,15 +49,15 @@ public class LabelContribution extends VisualsContribution {
     public Map<String, String> getLabel(ReadGraph graph, NodeContext context) {
         Object content = context.getConstant(BuiltinKeys.INPUT);
         try {
-            if(test == null || test.test(graph, content))            
+            if(test == null || test.test(graph, content))
                 return labelRule.getLabel(graph, content);
             else
                 return null;
+        } catch(PendingVariableException e) {
+            return Collections.singletonMap(ColumnKeys.SINGLE, "");
         } catch(DatabaseException e) {
             ErrorLogger.defaultLogError(e);
-               //Logger.defaultLogError(e);
-            // TODO reconsider
             return Collections.singletonMap(ColumnKeys.SINGLE, "");
         }
-    }    
+    }
 }
index cc978e7e8b6ce599957ff6fbb859c76ec96a0d96..3bb05553dc7456e073d52b44e526688c2beffdc0 100644 (file)
@@ -19,6 +19,7 @@ import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.BiFunction;
 import java.util.function.Consumer;
 
 import org.eclipse.core.runtime.Assert;
@@ -89,7 +90,6 @@ import org.eclipse.nebula.widgets.nattable.painter.NatTableBorderOverlayPainter;
 import org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer;
 import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
 import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer.MoveDirectionEnum;
-import org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand;
 import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration;
 import org.eclipse.nebula.widgets.nattable.style.CellStyleAttributes;
 import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
@@ -190,7 +190,6 @@ import org.simantics.browsing.ui.swt.ViewerCellReference;
 import org.simantics.browsing.ui.swt.ViewerRowReference;
 import org.simantics.browsing.ui.swt.internal.Threads;
 import org.simantics.db.layer0.SelectionHints;
-import org.simantics.utils.datastructures.BinaryFunction;
 import org.simantics.utils.datastructures.MapList;
 import org.simantics.utils.datastructures.disposable.AbstractDisposable;
 import org.simantics.utils.datastructures.hints.IHintContext;
@@ -297,10 +296,10 @@ public class NatTableGraphExplorer extends GraphExplorerImplBase implements Grap
     private boolean expand;
     private boolean verticalBarVisible = false;
     
-    private BinaryFunction<Object[], GraphExplorer, Object[]>  selectionTransformation = new BinaryFunction<Object[], GraphExplorer, Object[]>() {
+    private BiFunction<GraphExplorer, Object[], Object[]>  selectionTransformation = new BiFunction<GraphExplorer, Object[], Object[]>() {
 
         @Override
-        public Object[] call(GraphExplorer explorer, Object[] objects) {
+        public Object[] apply(GraphExplorer explorer, Object[] objects) {
             Object[] result = new Object[objects.length];
             for (int i = 0; i < objects.length; i++) {
                 IHintContext context = new AdaptableHintContext(SelectionHints.KEY_MAIN);
@@ -846,7 +845,7 @@ public class NatTableGraphExplorer extends GraphExplorerImplBase implements Grap
     }
     
     protected Object[] transformSelection(Object[] objects) {
-        return selectionTransformation.call(this, objects);
+        return selectionTransformation.apply(this, objects);
     }
     
     protected static Object[] filter(SelectionFilter filter, NodeContext[] contexts) {
@@ -859,7 +858,7 @@ public class NatTableGraphExplorer extends GraphExplorerImplBase implements Grap
 
        @Override
        public void setSelectionTransformation(
-                       BinaryFunction<Object[], GraphExplorer, Object[]> f) {
+                       BiFunction<GraphExplorer, Object[], Object[]> f) {
                this.selectionTransformation = f;
        }
        
index 9869cab3d663ac1d4049c13fb2ac6bb6ba337600..37466aedaec815dd3ae618a0c57592d90bfedc92 100644 (file)
@@ -16,7 +16,8 @@ Require-Bundle: org.simantics.utils.thread.swt;bundle-version="1.0.0",
  com.lowagie.text;bundle-version="2.1.5",
  org.simantics.scl.ui.editor;bundle-version="0.1.3";visibility:=reexport,
  org.simantics.scl.compiler.dummy;bundle-version="0.1.3",
- org.eclipse.e4.core.contexts;bundle-version="1.4.0"
+ org.eclipse.e4.core.contexts;bundle-version="1.4.0",
+ org.slf4j.api;bundle-version="1.7.20"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Export-Package: org.simantics.browsing.ui.swt,
  org.simantics.browsing.ui.swt.contentassist,
index de421565951a2a3b025856676954f469c897e534..b99962bf00d579c6ceb3cf8e0d4eea39a85abe73 100644 (file)
@@ -12,6 +12,7 @@
 package org.simantics.browsing.ui.swt;
 
 import java.lang.reflect.Method;
+import java.util.function.BiFunction;
 
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.swt.SWT;
@@ -34,7 +35,6 @@ import org.simantics.db.layer0.SelectionHints;
 import org.simantics.db.layer0.variable.Variable;
 import org.simantics.db.layer0.variable.Variables;
 import org.simantics.simulation.ontology.SimulationResource;
-import org.simantics.utils.datastructures.BinaryFunction;
 import org.simantics.utils.datastructures.hints.IHintContext;
 import org.simantics.utils.ui.ExceptionUtils;
 
@@ -50,7 +50,7 @@ public class GraphExplorerFactory {
 
     private IServiceLocator        serviceLocator;
 
-    private BinaryFunction<Object[], GraphExplorer, Object[]>  selectionTransformation = new BinaryFunction<Object[], GraphExplorer, Object[]>() {
+    private BiFunction<GraphExplorer, Object[], Object[]> selectionTransformation = new BiFunction<GraphExplorer, Object[], Object[]>() {
 
        private Resource getModel(final Object object) {
                if(object instanceof NodeContext) {
@@ -90,9 +90,8 @@ public class GraphExplorerFactory {
                return null;
        }
        
-       
         @Override
-        public Object[] call(GraphExplorer explorer, Object[] objects) {
+        public Object[] apply(GraphExplorer explorer, Object[] objects) {
             Object[] result = new Object[objects.length];
             for (int i = 0; i < objects.length; i++) {
                 IHintContext context = new AdaptableHintContext(SelectionHints.KEY_MAIN);
@@ -120,7 +119,7 @@ public class GraphExplorerFactory {
         return this;
     }
 
-    public GraphExplorerFactory selectionTransformation(BinaryFunction<Object[], GraphExplorer, Object[]> transformation) {
+    public GraphExplorerFactory selectionTransformation(BiFunction<GraphExplorer, Object[], Object[]> transformation) {
         this.selectionTransformation = transformation;
         return this;
     }
@@ -194,7 +193,8 @@ public class GraphExplorerFactory {
         //GraphExplorerImpl2 explorer = new GraphExplorerImpl2(parent, style);
        try {
                Bundle bundle = Platform.getBundle("org.simantics.browsing.ui.nattable");
-               Class<GraphExplorer> clazz = (Class<GraphExplorer>)bundle.loadClass("org.simantics.browsing.ui.nattable.NatTableGraphExplorer");
+               @SuppressWarnings("unchecked")
+                       Class<GraphExplorer> clazz = (Class<GraphExplorer>)bundle.loadClass("org.simantics.browsing.ui.nattable.NatTableGraphExplorer");
                //Class<GraphExplorer> clazz = (Class<GraphExplorer>)bundle.getClass().getClassLoader().loadClass("org.simantics.browsing.ui.nattable.NatTableGraphExplorer");
                GraphExplorer explorer = clazz.getConstructor(Composite.class, int.class).newInstance(parent,style);
                explorer.setSelectionDataResolver(selectionDataResolver);
index 62b284858cd9893383719e5ec7b89632437335f9..0e45f86ca4843fe53233ecec6217a07026ee4954 100644 (file)
@@ -31,6 +31,7 @@ import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.BiFunction;
 import java.util.function.Consumer;
 
 import org.eclipse.core.runtime.Assert;
@@ -161,7 +162,6 @@ import org.simantics.browsing.ui.swt.internal.Threads;
 import org.simantics.db.layer0.SelectionHints;
 import org.simantics.utils.ObjectUtils;
 import org.simantics.utils.datastructures.BijectionMap;
-import org.simantics.utils.datastructures.BinaryFunction;
 import org.simantics.utils.datastructures.disposable.AbstractDisposable;
 import org.simantics.utils.datastructures.hints.IHintContext;
 import org.simantics.utils.threads.IThreadWorkQueue;
@@ -544,10 +544,10 @@ class GraphExplorerImpl extends GraphExplorerImplBase implements Listener, Graph
     protected BasePostSelectionProvider          selectionProvider        = new BasePostSelectionProvider();
     protected SelectionDataResolver              selectionDataResolver;
     protected SelectionFilter                    selectionFilter;
-    protected BinaryFunction<Object[], GraphExplorer, Object[]>  selectionTransformation = new BinaryFunction<Object[], GraphExplorer, Object[]>() {
+    protected BiFunction<GraphExplorer, Object[], Object[]> selectionTransformation = new BiFunction<GraphExplorer, Object[], Object[]>() {
 
         @Override
-        public Object[] call(GraphExplorer explorer, Object[] objects) {
+        public Object[] apply(GraphExplorer explorer, Object[] objects) {
             Object[] result = new Object[objects.length];
             for (int i = 0; i < objects.length; i++) {
                 IHintContext context = new AdaptableHintContext(SelectionHints.KEY_MAIN);
@@ -1812,7 +1812,7 @@ class GraphExplorerImpl extends GraphExplorerImplBase implements Listener, Graph
     }
 
     @Override
-    public void setSelectionTransformation(BinaryFunction<Object[], GraphExplorer, Object[]> f) {
+    public void setSelectionTransformation(BiFunction<GraphExplorer, Object[], Object[]> f) {
         this.selectionTransformation = f;
     }
 
@@ -3168,7 +3168,7 @@ class GraphExplorerImpl extends GraphExplorerImplBase implements Listener, Graph
     }
 
     protected Object[] transformSelection(Object[] objects) {
-        return selectionTransformation.call(this, objects);
+        return selectionTransformation.apply(this, objects);
     }
 
     protected static Object[] filter(SelectionFilter filter, NodeContext[] contexts) {
index 79bd35b872b2991a05537aedede0b62aa50a6561..928bed03facc844eea8ef2603307e0a2c988f965 100644 (file)
@@ -30,6 +30,7 @@ import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.BiFunction;
 import java.util.function.Consumer;
 
 import org.eclipse.core.runtime.Assert;
@@ -164,7 +165,6 @@ import org.simantics.browsing.ui.swt.internal.Threads;
 import org.simantics.db.layer0.SelectionHints;
 import org.simantics.ui.SimanticsUI;
 import org.simantics.utils.datastructures.BijectionMap;
-import org.simantics.utils.datastructures.BinaryFunction;
 import org.simantics.utils.datastructures.MapList;
 import org.simantics.utils.datastructures.disposable.AbstractDisposable;
 import org.simantics.utils.datastructures.hints.IHintContext;
@@ -251,10 +251,10 @@ public class GraphExplorerImpl2 extends GraphExplorerImplBase implements GraphEx
     private boolean expand;
     private boolean verticalBarVisible = false;
     
-    private BinaryFunction<Object[], GraphExplorer, Object[]>  selectionTransformation = new BinaryFunction<Object[], GraphExplorer, Object[]>() {
+    private BiFunction<GraphExplorer, Object[], Object[]> selectionTransformation = new BiFunction<GraphExplorer, Object[], Object[]>() {
 
         @Override
-        public Object[] call(GraphExplorer explorer, Object[] objects) {
+        public Object[] apply(GraphExplorer explorer, Object[] objects) {
             Object[] result = new Object[objects.length];
             for (int i = 0; i < objects.length; i++) {
                 IHintContext context = new AdaptableHintContext(SelectionHints.KEY_MAIN);
@@ -885,7 +885,7 @@ public class GraphExplorerImpl2 extends GraphExplorerImplBase implements GraphEx
     }
     
     protected Object[] transformSelection(Object[] objects) {
-        return selectionTransformation.call(this, objects);
+        return selectionTransformation.apply(this, objects);
     }
     
     protected static Object[] filter(SelectionFilter filter, NodeContext[] contexts) {
@@ -898,7 +898,7 @@ public class GraphExplorerImpl2 extends GraphExplorerImplBase implements GraphEx
 
        @Override
        public void setSelectionTransformation(
-                       BinaryFunction<Object[], GraphExplorer, Object[]> f) {
+                       BiFunction<GraphExplorer, Object[], Object[]> f) {
                this.selectionTransformation = f;
        }
        
index 4b5a48e14acdb79f0cee6f1e42a798b2b142312b..f583d7e7f1df374f0466232cf40d786a4b14cf2b 100644 (file)
@@ -16,6 +16,7 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+import java.util.function.BiFunction;
 import java.util.function.Consumer;
 
 import org.eclipse.core.runtime.IAdaptable;
@@ -102,12 +103,11 @@ import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.Session;
-import org.simantics.db.common.request.ResourceRead;
-import org.simantics.db.common.utils.Logger;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.SelectionHints;
+import org.simantics.db.layer0.request.PossibleVariable;
+import org.simantics.db.layer0.request.PossibleVariableRepresents;
 import org.simantics.db.layer0.variable.Variable;
-import org.simantics.db.layer0.variable.Variables;
 import org.simantics.db.management.ISessionContext;
 import org.simantics.db.management.ISessionContextChangedListener;
 import org.simantics.db.management.ISessionContextProvider;
@@ -126,7 +126,6 @@ import org.simantics.ui.selection.WorkbenchSelectionContentType;
 import org.simantics.ui.selection.WorkbenchSelectionElement;
 import org.simantics.ui.selection.WorkbenchSelectionUtils;
 import org.simantics.utils.ObjectUtils;
-import org.simantics.utils.datastructures.BinaryFunction;
 import org.simantics.utils.datastructures.Function;
 import org.simantics.utils.datastructures.disposable.DisposeState;
 import org.simantics.utils.datastructures.hints.HintListenerAdapter;
@@ -135,10 +134,14 @@ import org.simantics.utils.datastructures.hints.IHintContext.Key;
 import org.simantics.utils.datastructures.hints.IHintListener;
 import org.simantics.utils.datastructures.hints.IHintObservable;
 import org.simantics.utils.datastructures.hints.IHintTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 public class GraphExplorerComposite extends Composite implements Widget, IAdaptable {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(GraphExplorerComposite.class);
+
     protected UserSelectedComparableFactoryQueryProcessor userSelectedComparableFactoryQueryProcessor;
     protected UserSelectedViewpointFactoryQueryProcessor  userSelectedViewpointFactoryQueryProcessor;
     protected FilterSelectionRequestQueryProcessor        filterSelectionRequestQueryProcessor;
@@ -248,39 +251,41 @@ public class GraphExplorerComposite extends Composite implements Widget, IAdapta
         @SuppressWarnings("unchecked")
         @Override
         public <T> T getContent(WorkbenchSelectionContentType<T> contentType) {
-
-            if(wse != null) {
+            if (wse != null) {
                 T result = wse.getContent(contentType);
-                if(result != null) return result;
+                if (result != null)
+                    return result;
             }
-            
-            if(contentType instanceof AnyResource) return (T)resource;
-            else if(contentType instanceof AnyVariable) {
-                AnyVariable type = (AnyVariable)contentType;
+
+            if (contentType instanceof AnyResource) {
+                if (resource != null)
+                    return (T) resource;
+                if (variable == null)
+                    return null;
+                try {
+                    return (T) ((AnyResource) contentType).processor.syncRequest(new PossibleVariableRepresents(variable));
+                } catch (DatabaseException e) {
+                    LOGGER.error("Unexpected error occurred while resolving Resource from Variable " + variable, e);
+                }
+            }
+            else if (contentType instanceof AnyVariable) {
+                if (variable != null)
+                    return (T) variable;
+                if (resource == null)
+                    return null;
                 try {
-                       
-                       if(variable != null) return (T)variable;
-                       
-                       if(resource == null) return null;
-                       
-                    return (T) type.processor.sync(new ResourceRead<Variable>(resource) {
-                        @Override
-                        public Variable perform(ReadGraph graph) throws DatabaseException {
-                            return Variables.getPossibleVariable(graph, resource);
-                        }
-                        
-                    });
+                    return (T) ((AnyVariable) contentType).processor.syncRequest(new PossibleVariable(resource));
                 } catch (DatabaseException e) {
-                    Logger.defaultLogError(e);
+                    LOGGER.error("Unexpected error occurred while resolving Variable from Resource " + resource, e);
                 }
             } else if (contentType instanceof ExplorerInputContentType) {
-               return (T)input;
+                return (T) input;
             } else if (contentType instanceof ExplorerColumnContentType) {
-               return (T)explorerState.getActiveColumn();
+                return (T) explorerState.getActiveColumn();
             }
             return null;
         }
-        
+
         @SuppressWarnings("rawtypes")
         @Override
         public Object getAdapter(Class adapter) {
@@ -297,12 +302,12 @@ public class GraphExplorerComposite extends Composite implements Widget, IAdapta
         }
 
     }
-    private BinaryFunction<Object[], GraphExplorer, Object[]> selectionTransformation = new BinaryFunction<Object[], GraphExplorer, Object[]>() {
+    private BiFunction<GraphExplorer, Object[], Object[]> selectionTransformation = new BiFunction<GraphExplorer, Object[], Object[]>() {
 
        private Key[] KEYS = new Key[] { SelectionHints.KEY_MAIN };
        
         @Override
-        public Object[] call(GraphExplorer explorer, Object[] objects) {
+        public Object[] apply(GraphExplorer explorer, Object[] objects) {
             Object[] result = new Object[objects.length];
             for (int i = 0; i < objects.length; i++) {
                SelectionElement context = new SelectionElement(explorer, KEYS, objects[i]);
@@ -723,7 +728,7 @@ public class GraphExplorerComposite extends Composite implements Widget, IAdapta
                                                        event.data = WorkbenchSelectionUtils.getPossibleJSON(selectionProvider.getSelection());
                                                } catch (DatabaseException e) {
                                                        event.data = "{ type:\"Exception\" }";
-                                                       Logger.defaultLogError(e);
+                                                       LOGGER.error("Failed to get current selection as JSON.", e);
                                                }
                                        } else if (LocalObjectTransfer.getTransfer().isSupportedType(event.dataType)) {
                                                ls.dragSetData(event);
@@ -863,7 +868,7 @@ public class GraphExplorerComposite extends Composite implements Widget, IAdapta
        this.filterAreaSource = provider;
     }
 
-    public void setSelectionTransformation(BinaryFunction<Object[], GraphExplorer, Object[]> transformation) {
+    public void setSelectionTransformation(BiFunction<GraphExplorer, Object[], Object[]> transformation) {
         this.selectionTransformation = transformation;
         if(explorer != null) explorer.setSelectionTransformation(transformation);
     }
index 0bc3e02158018f79da1b9c24e2b4229fe1644a56..0745d1d81cae3e2cd866cab0aa4210c85b9e0fe2 100644 (file)
@@ -14,6 +14,7 @@ package org.simantics.browsing.ui;
 import java.util.Collection;
 import java.util.Map;
 import java.util.Set;
+import java.util.function.BiFunction;
 import java.util.function.Consumer;
 
 import org.eclipse.core.runtime.IAdaptable;
@@ -22,7 +23,6 @@ import org.simantics.browsing.ui.NodeContext.PrimitiveQueryKey;
 import org.simantics.browsing.ui.NodeContext.QueryKey;
 import org.simantics.browsing.ui.content.Labeler;
 import org.simantics.browsing.ui.content.Labeler.Modifier;
-import org.simantics.utils.datastructures.BinaryFunction;
 import org.simantics.utils.threads.IThreadWorkQueue;
 
 /**
@@ -205,7 +205,7 @@ public interface GraphExplorer extends IAdaptable {
      */
     void setSelectionFilter(SelectionFilter f);
 
-    void setSelectionTransformation(BinaryFunction<Object[], GraphExplorer, Object[]> f);
+    void setSelectionTransformation(BiFunction<GraphExplorer, Object[], Object[]> f);
 
     //ISelectionProvider getSelectionProvider();
 
index 3972fd95c9317f58730eac5a193037a6ed840775..71d20dcce2760e2fc7d29f3fd05a5d3034cc53d2 100644 (file)
@@ -45,11 +45,11 @@ importJava "org.simantics.charts.ui.SCLChart" where
 Browses the given Model for its Charts and then returns them in a list.
 """
 chartsOf :: Model -> <ReadGraph> [Chart]
-chartsOf model = recurse (toResource model)
+chartsOf model = recurse model
   where
     recurse r = do
-        cs = resourceChildrenOf r 
-        charts = map fromResource $ filter isChart cs
+        cs = children r 
+        charts = filter isChart cs
         chartGrp = filter isChartGroup cs
         charts + concatMap recurse chartGrp
     isChart r = isInstanceOf r CHART.TimeSeriesChart
index 1358c402333b40a42d425e66acaef6faf339af42..5e4ef406db3b9185f22e553b43e88c90b1383656 100644 (file)
@@ -48,9 +48,9 @@ public final class Charts {
     public static HistorySamplerItem createHistorySamplerItem(ReadGraph graph, Resource subscriptionItem, ChartData data) throws DatabaseException {
 
         try {
-            Resource model = graph.syncRequest(new PossibleIndexRoot(subscriptionItem));
-            if (model == null) {
-                throw new DatabaseException("There is no model for " + subscriptionItem);
+            Resource indexRoot = graph.syncRequest(new PossibleIndexRoot(subscriptionItem));
+            if (indexRoot == null) {
+                throw new DatabaseException("There is no index root for " + subscriptionItem);
             }
 
             ItemManager im = new ItemManager(data.history.getItems());
index a396d10dacef442fbe089af59e6cdb85b975f369..aeae9f5d3595f05bae50abc8cc168b892947c976 100644 (file)
@@ -41,7 +41,7 @@ import org.simantics.utils.FileUtils;
  * 
  * @author Tuukka Lehtonen
  */
-public class TrendSupport {
+public class TrendSupport implements ITrendSupport {
 
     // Input
     private IDynamicExperiment experiment;
@@ -170,4 +170,13 @@ public class TrendSupport {
         return finalPath.toFile();
     }
 
+    @Override
+    public void setChartData(ReadGraph graph) throws DatabaseException {
+    }
+
+    @Override
+    public ChartData getChartData() {
+       return chartData;
+    }
+    
 }
index 561843e20dc76e83c95f8ae16dfa5072c35c6f6b..4b8c3cbad87dd015fe7f358eac8bdc088480d85a 100644 (file)
@@ -6,7 +6,8 @@ Bundle-Version: 1.1.0.qualifier
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Require-Bundle: org.simantics.db.common;bundle-version="0.8.0",
  org.eclipse.core.runtime;bundle-version="3.6.0",
- gnu.trove3;bundle-version="3.0.0"
+ gnu.trove3;bundle-version="3.0.0",
+ org.slf4j.api
 Export-Package: org.simantics.db.impl,
  org.simantics.db.impl.exception,
  org.simantics.db.impl.graph,
index 31b585aaeeccd43cb2089ebe254d680c314a709b..5776857d330ad98374d9b8c07d575ddb0118f7b2 100644 (file)
@@ -14,14 +14,17 @@ package org.simantics.db.impl.query;
 import java.util.ArrayList;
 import java.util.Iterator;
 
-import org.simantics.db.common.utils.Logger;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.impl.DebugPolicy;
 import org.simantics.db.impl.graph.ReadGraphImpl;
 import org.simantics.db.impl.procedure.InternalProcedure;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 abstract public class CacheEntryBase extends CacheEntry {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(CacheEntryBase.class);
+    
        // Default level is something that is not quite a prospect but still allows for ordering within CacheCollectionResult 
        public static final short UNDEFINED_LEVEL = 5;
        
@@ -108,7 +111,7 @@ abstract public class CacheEntryBase extends CacheEntry {
                statusOrException = EXCEPTED;
                result = t;
        } else {
-               Logger.defaultLogError("Cache entry got excepted status after being discarded: " + getClass().getSimpleName(), t);
+               LOGGER.warn("Cache entry got excepted status after being discarded: " + getClass().getSimpleName(), t);
                result = t;
        }
     }
@@ -139,7 +142,7 @@ abstract public class CacheEntryBase extends CacheEntry {
     final public boolean assertPending() {
        boolean result = isPending();
        if(!result) {
-               System.err.println("Assertion failed, expected pending, got " + statusOrException);
+               LOGGER.warn("Assertion failed, expected pending, got " + statusOrException);
        }
        return result;
     }
index e5a14f77cd480102dad8cda01f65b41166c1f109..c466cb261cca975d10c16a70461eab15bb3f77b2 100644 (file)
@@ -141,8 +141,9 @@ public class URIToResource extends StringQuery<InternalProcedure<Integer>> {
                     }
                 }
                 
-                if(entry != null) entry.addOrSet(graph, graph.processor, new Integer(0));
-                procedure.execute(graph, new Integer(0));
+                Integer zero = 0;
+                if(entry != null) entry.addOrSet(graph, graph.processor, zero);
+                procedure.execute(graph, zero);
 
             }
 
index c8efdc2509edd9e5fedd59f32f9e5b8ad68bfdc6..abd6e1ba54ef1203f7508ee285b8e26a4ed442fd 100644 (file)
@@ -14,6 +14,7 @@ package org.simantics.db.indexing;
 import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
+import java.util.ArrayList;
 
 import org.simantics.db.Resource;
 import org.simantics.db.Session;
@@ -22,6 +23,7 @@ import org.simantics.db.common.request.IndexRoot;
 import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.common.utils.Logger;
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.indexing.internal.IndexChangedWriter;
 import org.simantics.db.layer0.adapter.GenericRelationIndex;
 import org.simantics.db.layer0.genericrelation.IndexedRelations;
 import org.simantics.db.layer0.internal.SimanticsInternal;
@@ -75,7 +77,10 @@ public final class DatabaseIndexing {
             return;
         if (DEBUG)
             System.out.println("Marking all indexes dirty");
-        getAllDirtyFile().createNewFile();
+        File allDirtyFile = getAllDirtyFile();
+        if (allDirtyFile.createNewFile()) {
+            FileUtils.syncFile(allDirtyFile);
+        }
     }
 
     public static void clearAllDirty() throws IOException {
@@ -85,39 +90,61 @@ public final class DatabaseIndexing {
         File indexBase = getIndexBaseLocation();
         if (!indexBase.exists() || !indexBase.isDirectory())
             return;
-        delete(getAllDirtyFile());
 
         forEachIndexPath(new Procedure<File, IOException>() {
             @Override
             public void execute(File indexPath) throws IOException {
-                delete(getChangedFile(indexPath));
+                getChangedFile(indexPath).delete();
             }
         });
-    }
 
+        getAllDirtyFile().delete();
+    }
+    
     /**
      * Internal to indexing, invoked by {@link IndexedRelationsImpl} which
      * doesn't want to throw these exceptions forward. Just log it.
      * 
      * @param indexPath
      */
-    static void markIndexChanged(File indexPath) {
-        if (!indexPath.exists())
-            throw new IllegalArgumentException("index path " + indexPath + " does not exist");
-        if (!indexPath.isDirectory())
-            throw new IllegalArgumentException("index path " + indexPath + " is not a directory");
+    static void markIndexChanged(Session session, File indexPath) {
+        if (DEBUG)
+            System.out.println("Marking index dirty: " + indexPath);
         try {
-            if (DEBUG)
-                System.out.println("Marking index dirty: " + indexPath);
-            getChangedFile(indexPath).createNewFile();
+            File changedFile = getChangedFile(indexPath);
+            // Mark change only once per DB session.
+            if (getIndexChangedWriter(session).markDirty(changedFile)) {
+                if (indexPath.mkdirs()) {
+                    if (changedFile.createNewFile()) {
+                        FileUtils.syncFile(changedFile);
+                    }
+                }
+            }
         } catch (IOException e) {
             Logger.defaultLogError(e);
         }
     }
 
+    private static IndexChangedWriter getIndexChangedWriter(Session session) {
+        IndexChangedWriter writer = session.peekService(IndexChangedWriter.class);
+        if (writer == null) {
+            synchronized (IndexChangedWriter.class) {
+                if (writer == null)
+                    session.registerService(IndexChangedWriter.class, writer = new IndexChangedWriter());
+            }
+        }
+        return writer;
+    }
+
     public static void deleteAllIndexes() throws IOException {
         File indexBase = DatabaseIndexing.getIndexBaseLocation();
-        delete(indexBase);
+
+        ArrayList<String> filter = new ArrayList<>(2);
+        filter.add(getAllDirtyFile().getAbsolutePath());
+        filter.add(indexBase.getAbsolutePath());
+
+        FileUtils.deleteAllWithFilter(indexBase, filter);
+        FileUtils.deleteAll(indexBase);
     }
 
     public static void deleteIndex(final Resource relation, final Resource modelPart) throws DatabaseException {
@@ -148,7 +175,13 @@ public final class DatabaseIndexing {
     public static void deleteIndex(File indexPath) throws IOException {
         if (DEBUG)
             System.out.println("Deleting index " + indexPath);
-        delete(indexPath);
+
+        ArrayList<String> filter = new ArrayList<>(2);
+        filter.add(getChangedFile(indexPath).getAbsolutePath());
+        filter.add(indexPath.getAbsolutePath());
+
+        FileUtils.deleteAllWithFilter(indexPath, filter);
+        FileUtils.deleteAll(indexPath);
     }
 
     public static void validateIndexes() throws IOException {
@@ -161,7 +194,7 @@ public final class DatabaseIndexing {
             // Make sure that index-base is a valid directory
             if (DEBUG)
                 System.out.println(indexBase + " is not a directory! Removing it.");
-            delete(indexBase);
+            FileUtils.deleteAll(indexBase);
             indexBase.mkdirs();
             return;
         }
@@ -169,7 +202,6 @@ public final class DatabaseIndexing {
         if (allDirtyFile.isFile()) {
             if (DEBUG)
                 System.out.println("All indexes marked dirty, removing them.");
-            delete(allDirtyFile);
             deleteAllIndexes();
         } else {
             forEachIndexPath(new Procedure<File, IOException>() {
@@ -186,12 +218,6 @@ public final class DatabaseIndexing {
         }
     }
 
-
-    private static void delete(File fileOrDir) throws IOException {
-        if (fileOrDir.exists())
-            FileUtils.deleteAll(fileOrDir);
-    }
-
     interface Procedure<T, E extends Throwable> {
         void execute(T t) throws E;
     }
index aaadc4704d487ddbdce71af7e59a78522648657b..1b4d62a1d6c6cf9c6d199b7454e713232c763526 100644 (file)
@@ -392,13 +392,13 @@ public class IndexedRelationsImpl implements IndexedRelations {
         
         try {
                
+               DatabaseIndexing.markIndexChanged(processor.getSession(), searcher.getIndexPath());
                if(!searcher.startAccess(null, processor.getSession(), true)) {
                 // Could not write index for some reason. Ignore and let the next index query reinitialize the index.
                        return;
                }
                
             searcher.insertIndex(progress.newChild(40), relation, 1, documents);
-            DatabaseIndexing.markIndexChanged(searcher.getIndexPath());
             
         } catch (InvalidResourceReferenceException e) {
             throw new IndexException(e);
@@ -429,13 +429,13 @@ public class IndexedRelationsImpl implements IndexedRelations {
         LockHandle handle = lock(processor, Pair.make(relationResource, input), true);
         try {
                
+            DatabaseIndexing.markIndexChanged(processor.getSession(), searcher.getIndexPath());
                if(!searcher.startAccess(null, processor.getSession(), true)) {
                 // Could not write index for some reason. Ignore and let the next index query reinitialize the index.
                        return;
                }
                
             searcher.removeIndex(progress.newChild(40), relation, processor, key, keyValues);
-            DatabaseIndexing.markIndexChanged(searcher.getIndexPath());
             
         } catch (DatabaseException e) {
             throw new IndexException(e);
@@ -492,13 +492,12 @@ public class IndexedRelationsImpl implements IndexedRelations {
 
         try {
                
+               DatabaseIndexing.markIndexChanged(processor.getSession(), searcher.getIndexPath());
                if(!searcher.startAccess(null, processor.getSession(), true)) {
                 // Could not write index for some reason. Ignore and let the next index query reinitialize the index.
                        return true;
                }
-            didChange = searcher.replaceIndex(progress.newChild(40), key, keyValues, relation, 1, documents);
-            if(didChange)
-               DatabaseIndexing.markIndexChanged(searcher.getIndexPath());
+            searcher.replaceIndex(progress.newChild(40), key, keyValues, relation, 1, documents);
             
         } catch (InvalidResourceReferenceException e) {
             throw new IndexException(e);
diff --git a/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/internal/IndexChangedWriter.java b/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/internal/IndexChangedWriter.java
new file mode 100644 (file)
index 0000000..c0e97a2
--- /dev/null
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Semantum Oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.db.indexing.internal;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * An internal in-memory container for telling whether a certain index has been
+ * changed since the platform was last started up. 
+ * 
+ * @author Jussi Koskela
+ * @since 1.28.0
+ */
+public class IndexChangedWriter {
+       private Set<String> dirtyFiles = new HashSet<>();
+
+       public synchronized boolean markDirty(File dirtyFile) throws IOException {
+               return dirtyFiles.add(dirtyFile.getAbsolutePath());
+       }
+}
index e16d07cf0469ace76097b80204a264476a5755aa..2a575a578769db92b912ca66e1c02ed427aab314 100644 (file)
@@ -33,6 +33,7 @@ import org.simantics.graph.db.MissingDependencyException;
 import org.simantics.graph.db.TransferableGraphImporter;
 import org.simantics.graph.representation.Root;
 import org.simantics.layer0.Layer0;
+import org.simantics.utils.datastructures.Pair;
 import org.simantics.utils.datastructures.Triple;
 
 public class SharedOntologyImportAdvisor extends AbstractImportAdvisor2 {
@@ -87,7 +88,15 @@ public class SharedOntologyImportAdvisor extends AbstractImportAdvisor2 {
                }
                
                Resource existing = graph.getPossibleResource(uri);
-               if(existing != null) throw new DatabaseException("Shared library " + uri + " exists already.");
+               if(existing != null) {
+                       if(graph.isInstanceOf(existing, L0.ExternalEntity)) {
+                               created.put(r, existing);
+                   addRootInfo(r, r.name, existing);
+                               return null;
+                       } else {
+                               throw new DatabaseException("Shared library " + uri + " exists already.");
+                       }
+               }
                
                Resource type = graph.getPossibleResource(r.type);
                if(type == null) { 
@@ -124,43 +133,62 @@ public class SharedOntologyImportAdvisor extends AbstractImportAdvisor2 {
     public void beforeWrite(WriteOnlyGraph graph, TransferableGraphImporter process)
             throws DatabaseException {
        
-        graph.markUndoPoint();
-        if(published) {
-               XSupport xs = graph.getService(XSupport.class);
-               xs.setServiceMode(false, true);
-        }
-        
-        graph.setClusterSet4NewResource(graph.getRootLibrary());
-        graph.flushCluster();
-
-        for(Map.Entry<Root, Triple<Resource, Resource, List<String>>> entry : toCreate.entrySet()) {
-               
-            Triple<Resource, Resource, List<String>> recipe = entry.getValue();
-
-            Resource base = recipe.first;
-            for(int i=0;i<recipe.third.size()-1;i++) {
-                Resource lib = graph.newResource();
-                graph.claim(lib, L0.InstanceOf, null, L0.Library);
-                graph.addLiteral(lib, L0.HasName, L0.NameOf, URIStringUtils.unescape( recipe.third.get(i) ), Bindings.STRING);
-                graph.claim(base, L0.ConsistsOf, L0.PartOf, lib);
-                base = lib;
-            }
+       XSupport xs = graph.getService(XSupport.class);
 
-            Resource lib = graph.newResource();
-            graph.newClusterSet(lib);
-            graph.setClusterSet4NewResource(lib);
-            graph.claim(lib, L0.InstanceOf, null, recipe.second);
-            String name = URIStringUtils.unescape( recipe.third.get(recipe.third.size()-1) );
-            graph.addLiteral(lib, L0.HasName, L0.NameOf, name, Bindings.STRING);
-            graph.claim(base, L0.ConsistsOf, L0.PartOf, lib);
+       Pair<Boolean,Boolean> mode = xs.getServiceMode();
+       
+       try {
+
+               graph.markUndoPoint();
+               
+               if(published) {
+                       xs.setServiceMode(true, true);
+               } else {
+                       xs.setServiceMode(true, mode.second);
+               }
+               
+               graph.setClusterSet4NewResource(graph.getRootLibrary());
+               graph.flushCluster();
+               
+               for(RootInfo info : getRootInfo()) {
+                       // At this stage these are existing L0.ExternalEntity instances that are now being imported.
+                       graph.deny(info.resource, L0.InstanceOf, null, L0.ExternalEntity, null);
+               }
+               
+               for(Map.Entry<Root, Triple<Resource, Resource, List<String>>> entry : toCreate.entrySet()) {
+                       
+                   Triple<Resource, Resource, List<String>> recipe = entry.getValue();
+       
+                   Resource base = recipe.first;
+                   for(int i=0;i<recipe.third.size()-1;i++) {
+                       Resource lib = graph.newResource();
+                       graph.claim(lib, L0.InstanceOf, null, L0.Library);
+                       graph.addLiteral(lib, L0.HasName, L0.NameOf, URIStringUtils.unescape( recipe.third.get(i) ), Bindings.STRING);
+                       graph.claim(base, L0.ConsistsOf, L0.PartOf, lib);
+                       base = lib;
+                   }
+       
+                   Resource lib = graph.newResource();
+                   graph.newClusterSet(lib);
+                   graph.setClusterSet4NewResource(lib);
+                   graph.claim(lib, L0.InstanceOf, null, recipe.second);
+                   String name = URIStringUtils.unescape( recipe.third.get(recipe.third.size()-1) );
+                   graph.addLiteral(lib, L0.HasName, L0.NameOf, name, Bindings.STRING);
+                   graph.claim(base, L0.ConsistsOf, L0.PartOf, lib);
+       
+                   addRootInfo(entry.getKey(), name, lib);
+                   
+                   created.put(entry.getKey(), lib);
+                   
+               }
+       
+               graph.flushCluster();
+               
+       } finally {
 
-            addRootInfo(entry.getKey(), name, lib);
-            
-            created.put(entry.getKey(), lib);
-            
-        }
-        
-        graph.flushCluster();
+               xs.setServiceMode(mode.first, mode.second);
+               
+       }
         
     }
 
diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/MigratedImportResult.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/MigratedImportResult.java
new file mode 100644 (file)
index 0000000..1981ae4
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Association for Decentralized Information Management in
+ * Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Semantum Oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.db.layer0.migration;
+
+import java.util.Collection;
+
+import org.simantics.db.Resource;
+import org.simantics.db.exception.AssumptionException;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.graph.db.ImportResult;
+
+/**
+ * @author Tuukka Lehtonen
+ * @since 1.28.0
+ */
+public class MigratedImportResult {
+
+       /**
+        * The root resources created by the import process.
+        */
+       public final Collection<Resource> roots;
+
+       public final ImportResult tgResult;
+
+       public MigratedImportResult(Collection<Resource> roots, ImportResult tgResult) {
+               this.roots = roots;
+               this.tgResult = tgResult;
+       }
+
+       public Resource singleRoot() throws DatabaseException {
+               int s = roots.size();
+               if (s != 1)
+                       throw new AssumptionException("No single imported root found, roots are: " + roots);
+               return roots.iterator().next();
+       }
+
+       public boolean hasMissingExternals() {
+               return tgResult != null ? tgResult.hasMissingExternals() : false;
+       }
+
+}
index bf860e44dafe32c400737d9804c95e458a7a61c8..2b19da58607dd66fa9368296ccf99a11100f30c2 100644 (file)
@@ -37,12 +37,14 @@ import org.simantics.db.layer0.adapter.impl.DefaultPasteImportAdvisor;
 import org.simantics.db.layer0.internal.SimanticsInternal;
 import org.simantics.db.layer0.util.Layer0Utils;
 import org.simantics.db.layer0.util.ModelTransferableGraphSourceRequest;
+import org.simantics.db.layer0.util.TGTransferableGraphSource;
 import org.simantics.db.layer0.util.TransferableGraphConfiguration2;
 import org.simantics.db.request.Read;
 import org.simantics.db.service.ManagementSupport;
 import org.simantics.db.service.SerialisationSupport;
 import org.simantics.graph.db.IImportAdvisor;
 import org.simantics.graph.db.IImportAdvisor2;
+import org.simantics.graph.db.ImportResult;
 import org.simantics.graph.db.StreamingTransferableGraphFileReader;
 import org.simantics.graph.db.TGStatusMonitor;
 import org.simantics.graph.db.TransferableGraphImporter;
@@ -201,8 +203,8 @@ public class MigrationStateImpl implements MigrationState {
                                };
                                // Make sure that the supplied advisor is redirected to temp
                                advisor.redirect(indexRoot);
-                
-                TransferableGraphs.importGraph1WithMonitor(session, tg, advisor, new TGStatusMonitor() {
+
+                ImportResult ir = TransferableGraphs.importGraph1(session, new TGTransferableGraphSource(tg), advisor, new TGStatusMonitor() {
                     @Override
                     public void status(int percentage) {
                         monitor.subTask("Importing model from file (" + percentage + "%)");
@@ -212,7 +214,8 @@ public class MigrationStateImpl implements MigrationState {
                         return monitor.isCanceled();
                     }
                 });
-                
+
+                setProperty(MigrationStateKeys.IMPORT_RESULT, ir);
                 setProperty(MigrationStateKeys.CURRENT_RESOURCE, indexRoot);
                 setProperty(MigrationStateKeys.CURRENT_ROOT_RESOURCES, new ArrayList<>(advisor.getRoots()));
                 setProperty(MigrationStateKeys.DATABASE_REVISION_AFTER_TG_IMPORT, session.getService(ManagementSupport.class).getHeadRevisionId());
@@ -258,7 +261,7 @@ public class MigrationStateImpl implements MigrationState {
                                // Make sure that the supplied advisor is redirected to temp
                                advisor.redirect(indexRoot);
                                
-                TransferableGraphs.importGraph1(session, tgs, advisor, new TGStatusMonitor() {
+                ImportResult ir = TransferableGraphs.importGraph1(session, tgs, advisor, new TGStatusMonitor() {
                     @Override
                     public void status(int percentage) {
                         monitor.subTask("Importing model from file (" + percentage + "%)");
@@ -269,6 +272,7 @@ public class MigrationStateImpl implements MigrationState {
                     }
                 });
 
+                setProperty(MigrationStateKeys.IMPORT_RESULT, ir);
                 setProperty(MigrationStateKeys.CURRENT_RESOURCE, indexRoot);
                 setProperty(MigrationStateKeys.CURRENT_ROOT_RESOURCES, new ArrayList<>(advisor.getRoots()));
                 setProperty(MigrationStateKeys.DATABASE_REVISION_AFTER_TG_IMPORT, session.getService(ManagementSupport.class).getHeadRevisionId());
index a1a7a82ae04605444d241e19c3c4f95739772ec4..9a5ac6fdae23196e666ef9534cd95b7df0732754 100644 (file)
@@ -15,6 +15,7 @@ import java.io.PrintWriter;
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.simantics.db.Session;
+import org.simantics.graph.db.ImportResult;
 
 public interface MigrationStateKeys {
 
@@ -51,6 +52,12 @@ public interface MigrationStateKeys {
        public final static String TG_EXTENSIONS = "tgExtensions";
        public final static String CURRENT_RESOURCE = "currentResource";
        public final static String IMPORT_ADVISOR = "importAdvisor";
+
+    /**
+     * Used for storing the {@link ImportResult} resulting from the TG import.
+     */
+    public final static String IMPORT_RESULT = "importResult";
+
     /**
      * All root resources of the imported material as
      * Collection&lt;Resource&gt;.
index 052bc6e6fb393beb39f2f0e1e4b93ef7852f9eb8..5f20036a54e1ea75638fba8699a1f7044e8cb26c 100644 (file)
  *******************************************************************************/
 package org.simantics.db.layer0.migration;
 
+import java.io.DataInputStream;
 import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.simantics.databoard.Bindings;
+import org.simantics.databoard.adapter.AdaptException;
 import org.simantics.databoard.binding.mutable.Variant;
 import org.simantics.databoard.container.DataContainer;
+import org.simantics.databoard.container.DataContainers;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.Session;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.WriteOnlyGraph;
 import org.simantics.db.common.CommentMetadata;
+import org.simantics.db.common.primitiverequest.PossibleResource;
 import org.simantics.db.common.request.BinaryRead;
 import org.simantics.db.common.request.FreshEscapedName;
 import org.simantics.db.common.request.UnaryRead;
@@ -42,10 +50,12 @@ import org.simantics.db.layer0.adapter.impl.DefaultPasteHandler;
 import org.simantics.db.layer0.adapter.impl.SharedOntologyImportAdvisor;
 import org.simantics.db.layer0.adapter.impl.TrashBinRemover;
 import org.simantics.db.layer0.internal.SimanticsInternal;
+import org.simantics.db.layer0.util.ExternalDownloadBean;
 import org.simantics.db.layer0.util.Layer0Utils;
 import org.simantics.db.layer0.util.TGTransferableGraphSource;
 import org.simantics.db.service.XSupport;
 import org.simantics.graph.db.IImportAdvisor;
+import org.simantics.graph.db.ImportResult;
 import org.simantics.graph.db.MissingDependencyException;
 import org.simantics.graph.db.TransferableGraphException;
 import org.simantics.graph.representation.Identity;
@@ -155,7 +165,6 @@ public class MigrationUtils {
     }
     
     
-    @SuppressWarnings("deprecation")
        public static Collection<MigrationStep> getMigrationSteps(DataContainer header) throws DatabaseException {
        
        return SimanticsInternal.sync(new BinaryRead<String,Integer,Collection<MigrationStep>>(header.format, header.version) {
@@ -299,48 +308,57 @@ public class MigrationUtils {
         return t != null ? t : defaultValue;
     }
 
-    public static Resource importSharedOntology(Session session, TransferableGraph1 tg, boolean published) throws DatabaseException {
+    public static MigratedImportResult importSharedOntology(Session session, TransferableGraph1 tg, boolean published) throws DatabaseException {
        return importSharedOntology(null, session, tg, published);
     }
 
-    public static Resource importSharedOntology(IProgressMonitor monitor, Session session, TransferableGraph1 tg, boolean published) throws DatabaseException {
+    public static MigratedImportResult importSharedOntology(IProgressMonitor monitor, Session session, TransferableGraph1 tg, boolean published) throws DatabaseException {
        
        if(monitor == null) monitor = new NullProgressMonitor();
        
+       Variant edbVariant = tg.extensions.get(ExternalDownloadBean.EXTENSION_KEY);
+       if(edbVariant != null) {
+               try {
+                               ExternalDownloadBean edb = (ExternalDownloadBean)edbVariant.getValue(ExternalDownloadBean.BINDING);
+                               for(Map.Entry<String, String> entry : edb.downloads.entrySet()) {
+                                       String uri = entry.getKey();
+                                       Resource existing = session.syncRequest(new PossibleResource(uri));
+                                       if(existing == null) {
+                                               String download = entry.getValue();
+                                                URL url = new URL(download);
+                                                DataContainer container = DataContainers.readFile(new DataInputStream(url.openStream()));
+                                                TransferableGraph1 dependencyTg = (TransferableGraph1) container.content.getValue(TransferableGraph1.BINDING);
+                                                importSharedOntology(monitor, session, dependencyTg, true);
+                                       }
+                               }
+                       } catch (AdaptException e) {
+                               throw new DatabaseException(e);
+                       } catch (MalformedURLException e) {
+                               throw new DatabaseException(e);
+                       } catch (IOException e) {
+                               throw new DatabaseException(e);
+                       }
+               
+       }
+       
         Collection<Identity> roots = TransferableGraphUtils.getRoots(tg);
         if(roots.size() == 1) {
-//             Identity id = roots.iterator().next();
-//             final Root root = (Root)id.definition;
-//             Resource rootResource = session.syncRequest(new WriteResultRequest<Resource>() {
-//                             @Override
-//                             public Resource perform(WriteGraph graph) throws DatabaseException {
-//                                     Resource type = graph.getResource(root.type);
-//                                     Resource existing = graph.getPossibleResource(root.name);
-//                                     if(existing != null) throw new DatabaseException("Shared library " + root.name + " exists already.");
-//                                     return Layer0Utils.applySCL("Simantics/SharedOntologies", "createSharedOntology", graph, root.name, type);
-//                             }
-//             });
             try {
-               
                 TGTransferableGraphSource tgSource = new TGTransferableGraphSource(tg);
                 SharedOntologyImportAdvisor advisor = new SharedOntologyImportAdvisor(published);
-//                TransferableGraphs.importGraph1(session, tgSource, advisor);
-                
-//                if (advisor.getRoots().size() == 1) {
-//                     return advisor.getRoots().iterator().next();
-//                }
-                               //TransferableGraphs.importGraph1(session, tg, new SharedOntologyImportAdvisor(), null);
 
                 MigrationState state = newState();
-                //state.setProperty(MigrationStateKeys.BASE_URI, AprosBuiltins.URIs.Migration);
                 state.setProperty(MigrationStateKeys.UPDATE_DEPENDENCIES, false);
                 state.setProperty(MigrationStateKeys.CURRENT_TGS, tgSource);
                 state.setProperty(MigrationStateKeys.SESSION, session);
                 state.setProperty(MigrationStateKeys.PROGRESS_MONITOR, monitor);
                 state.setProperty(MigrationStateKeys.CURRENT_DATA_CONTAINER, new DataContainer("sharedLibrary", 1, new Variant(TransferableGraph1.BINDING, tg)));
 
-                return MigrationUtils.importMigrated(monitor, session, null, state, advisor, null);
-                
+                MigrationUtils.importMigrated(monitor, session, null, state, advisor, null);
+
+                Collection<Resource> resultRoots = state.getProperty(MigrationStateKeys.CURRENT_ROOT_RESOURCES);
+                ImportResult result = state.getProperty(MigrationStateKeys.IMPORT_RESULT);
+                return new MigratedImportResult(resultRoots, result);
                        } catch (TransferableGraphException e) {
                                throw new DatabaseException(e);
                        } catch (MissingDependencyException e) {
diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/PossibleVariableRepresents.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/PossibleVariableRepresents.java
new file mode 100644 (file)
index 0000000..bb6a77d
--- /dev/null
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Semantum Oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.db.layer0.request;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.variable.Variable;
+
+/**
+ * @author Tuukka Lehtonen
+ * @since 1.28.0
+ */
+public class PossibleVariableRepresents extends VariableRead<Resource> {
+
+    public PossibleVariableRepresents(Variable var) {
+        super(var);
+    }
+
+    @Override
+    public Resource perform(ReadGraph graph) throws DatabaseException {
+        return variable.getPossibleRepresents(graph);
+    }
+
+}
index 39c661e4be2d6649b8bb85074b59fcc8e04a9eb0..d910f13ff946a77e40d9b2dce830c2020c678f40 100644 (file)
 package org.simantics.db.layer0.util;
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 import java.util.Set;
 
 import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
+import org.simantics.db.ResourceMap;
 import org.simantics.db.common.request.ReadRequest;
 import org.simantics.db.common.utils.Logger;
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.adapter.SubgraphExtent.ExtentStatus;
 import org.simantics.db.procedure.AsyncContextMultiProcedure;
-import org.simantics.db.service.CollectionSupport;
+import org.simantics.db.procedure.Procedure;
 import org.simantics.db.service.DirectQuerySupport;
 import org.simantics.layer0.Layer0;
 
 class ConsistsOfProcess {
 
-       final Set<Resource> result;
-       final AsyncContextMultiProcedure<Resource, Resource> structure;
+       final List<InternalEntry> result;
+       final AsyncContextMultiProcedure<InternalEntry, Resource> structure;
+       final AsyncContextMultiProcedure<InternalEntry, Resource> names;
 
-    public static Set<Resource> walk(ReadGraph graph, Collection<Resource> resources, Set<Resource> exclusions, boolean ignoreVirtual) throws DatabaseException {
-       ConsistsOfProcess process = new ConsistsOfProcess(graph, resources, exclusions, ignoreVirtual);
+    public static List<InternalEntry> walk(ReadGraph graph, ResourceMap<ExtentStatus> status, Collection<Resource> resources, Set<Resource> exclusions, boolean ignoreVirtual) throws DatabaseException {
+       ConsistsOfProcess process = new ConsistsOfProcess(graph, status, resources, exclusions, ignoreVirtual);
        return process.result;
     }
+    
+    static class InternalEntry {
+       public InternalEntry parent;
+       public Resource resource;
+       public String name;
+       InternalEntry(InternalEntry parent, Resource resource, String name) {
+               this.parent = parent;
+               this.resource = resource;
+               this.name = name;
+       }
+    }
        
-    private ConsistsOfProcess(ReadGraph graph, final Collection<Resource> resources, final Set<Resource> exclusions, final boolean ignoreVirtual) throws DatabaseException {
+    private ConsistsOfProcess(ReadGraph graph, ResourceMap<ExtentStatus> status, final Collection<Resource> resources, final Set<Resource> exclusions, final boolean ignoreVirtual) throws DatabaseException {
 
                final Layer0 L0 = Layer0.getInstance(graph);
                final DirectQuerySupport dqs = graph.getService(DirectQuerySupport.class);
                
-               CollectionSupport cs = graph.getService(CollectionSupport.class);
-               result = cs.createSet();
+               result = new ArrayList<InternalEntry>();
+               
+               names = dqs.compileForEachObject(graph, L0.HasName, new AsyncContextMultiProcedure<InternalEntry, Resource>() {
+
+                       @Override
+                       public void execute(AsyncReadGraph graph, InternalEntry entry, Resource nameResource) {
+               
+                               if(status != null)
+                                       status.put(nameResource, ExtentStatus.EXCLUDED);
+                               
+                               graph.forPossibleValue(nameResource, new Procedure<String>() {
+
+                                       @Override
+                                       public void execute(String result) {
+                                               entry.name = result;
+                                       }
+
+                                       @Override
+                                       public void exception(Throwable t) {
+                                               Logger.defaultLogError(t);
+                                       }
+                                       
+                               });
+                       }
+
+                       @Override
+                       public void exception(AsyncReadGraph graph, Throwable throwable) {
+                               Logger.defaultLogError(throwable);
+                       }
+
+                       @Override
+                       public void finished(AsyncReadGraph graph) {
+                       }
+
+               });
                
-               structure = dqs.compileForEachObject(graph, L0.ConsistsOf, new AsyncContextMultiProcedure<Resource, Resource>() {
+               structure = dqs.compileForEachObject(graph, L0.ConsistsOf, new AsyncContextMultiProcedure<InternalEntry, Resource>() {
 
                        @Override
-                       public void execute(AsyncReadGraph graph, Resource parent, Resource child) {
+                       public void execute(AsyncReadGraph graph, InternalEntry parent, Resource child) {
                                
                                if(exclusions.contains(child)) return;
                                
-                               if(!ignoreVirtual || child.isPersistent())
-                                       if(result.add(child)) {
-                                               dqs.forEachObjectCompiled(graph, child, child, structure);
+                               if(!ignoreVirtual || child.isPersistent()) {
+                                       InternalEntry entry = new InternalEntry(parent, child, null);
+                                       if(result.add(entry)) {
+                                               dqs.forEachObjectCompiled(graph, child, entry, structure);
+                                               dqs.forEachObjectCompiled(graph, child, entry, names);
                                        }
+                               }
                                
                        }
 
@@ -61,8 +113,10 @@ class ConsistsOfProcess {
 
                        @Override
                        public void run(ReadGraph graph) throws DatabaseException {
-                               for(Resource r  : resources)
-                                       dqs.forEachObjectCompiled(graph, r, r, structure);
+                               for(Resource r  : resources) {
+                                       InternalEntry root = new InternalEntry(null, r, null);
+                                       dqs.forEachObjectCompiled(graph, r, root, structure);
+                               }
                        }
                        
                });
index b55f0a3d2d0b9c1ebc4e7b2627b8793f375fafd5..bd67680db6704f73bbe3a73d69aaa7774f8d3b5f 100644 (file)
@@ -5,6 +5,7 @@ import java.io.InputStream;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
@@ -25,6 +26,7 @@ import org.simantics.db.common.utils.NameUtils;
 import org.simantics.db.exception.CancelTransactionException;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.adapter.SubgraphExtent.ExtentStatus;
+import org.simantics.db.layer0.util.ConsistsOfProcess.InternalEntry;
 import org.simantics.db.layer0.util.ModelTransferableGraphSourceRequest.Expansion3;
 import org.simantics.db.service.CollectionSupport;
 import org.simantics.db.service.SerialisationSupport;
@@ -502,7 +504,10 @@ public class DomainProcessor3 {
             this.datatypeBinding = Bindings.getBindingUnchecked(Datatype.class);
             this.datatypeSerializer = graph.getService(Databoard.class).getSerializerUnchecked(this.datatypeBinding);
 
-            for(Resource r : ConsistsOfProcess.walk(graph, fringe, exclusions, ignoreVirtual)) {
+            state.internalEntries = ConsistsOfProcess.walk(graph, status, fringe, exclusions, ignoreVirtual); 
+            
+            for(InternalEntry entry : state.internalEntries) {
+               Resource r = entry.resource;
                 if (status.put(r, ExtentStatus.INTERNAL) == null) {
                     if(ModelTransferableGraphSourceRequest.LOG) {
                         String URI = graph.getPossibleURI(r);
index f1dc02242eafdd984d582c701ba573c935c2f649..3f25410187768519082691dad43bd558f1c3d98b 100644 (file)
@@ -1,6 +1,7 @@
 package org.simantics.db.layer0.util;
 
 import java.io.DataOutputStream;
+import java.util.List;
 import java.util.TreeMap;
 
 import org.eclipse.core.runtime.SubMonitor;
@@ -31,5 +32,6 @@ public class DomainProcessorState {
 
        public SubMonitor monitor;
        public TGValueModifier valueModifier;
+       public List<ConsistsOfProcess.InternalEntry> internalEntries;
 
 }
\ No newline at end of file
index 3ccdd691854cc3bd2b961a1b1009fb4180dfa631..d62cc1876d6be1b4d98ba1391e676333383234f6 100644 (file)
@@ -36,7 +36,7 @@ public class ExtendedUris {
                 String name = URIStringUtils.unescape(escapedName);
                 parent = graph.syncRequest(new UnescapedChildMapOfResource(parent)).get(name);
                 if(parent == null)
-                    throw new DatabaseException("Didn't find a child " + name);
+                    throw new DatabaseException("Didn't find a child " + name + " for " + uri.substring(0, beginPos));
             }
             else if(c == '#') {
                 String escapedName = uri.substring(beginPos+1, endPos);
diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/ExternalDownloadBean.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/ExternalDownloadBean.java
new file mode 100644 (file)
index 0000000..6dd2b84
--- /dev/null
@@ -0,0 +1,20 @@
+package org.simantics.db.layer0.util;
+
+import java.util.TreeMap;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.databoard.binding.Binding;
+
+public class ExternalDownloadBean {
+
+       public static final String EXTENSION_KEY = ExternalDownloadBean.class.getSimpleName();
+       
+       public static final Binding BINDING = Bindings.getBindingUnchecked(ExternalDownloadBean.class);
+       
+       public TreeMap<String,String> downloads = new TreeMap<>();
+       
+       public ExternalDownloadBean(TreeMap<String,String> downloads) {
+               this.downloads = downloads;
+       }
+
+}
index 888e5fe4e312af10d98af326966b6e2ad42e7894..adc51c16d88ef0f74f1f849f421e9156398c69f1 100644 (file)
@@ -23,6 +23,7 @@ import java.util.Set;
 import java.util.TreeSet;
 
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.SubMonitor;
 import org.simantics.databoard.Bindings;
 import org.simantics.databoard.Datatypes;
@@ -1234,6 +1235,10 @@ public class Layer0Utils {
        return Layer0.getInstance(graph).String;
     }
 
+    public static void emptyTrashBin() throws ServiceException {
+        emptyTrashBin(new NullProgressMonitor());
+    }
+
     public static void emptyTrashBin(IProgressMonitor monitor) throws ServiceException {
         emptyTrashBin(monitor, SimanticsInternal.getSession(), SimanticsInternal.getProject());
     }
@@ -1281,15 +1286,31 @@ public class Layer0Utils {
                 return;
             mon.subTask("Purging Database");
             mon.newChild(1000);
-            XSupport xs = session.getService(XSupport.class);
-            xs.purge();
+            purgeDatabase(monitor, session);
         } catch (CancelTransactionException e) {
             // Ignore.
         } catch (DatabaseException e) {
             throw new ServiceException(e);
         }
     }
-    
+
+    public static void purgeDatabase() throws ServiceException {
+       purgeDatabase(new NullProgressMonitor());
+    }
+
+    public static void purgeDatabase(final IProgressMonitor monitor) throws ServiceException {
+       purgeDatabase(monitor, SimanticsInternal.getSession());
+    }
+
+    public static void purgeDatabase(final IProgressMonitor monitor, Session session) throws ServiceException {
+       try {
+               XSupport xs = session.getService(XSupport.class);
+               xs.purge();
+       } catch (DatabaseException e) {
+               throw new ServiceException(e);
+       }
+    }
+
     public static Resource getSingleDomainOf(ReadGraph graph, Resource type, Resource target) throws DatabaseException {
        Resource result = null;
        for(Resource candidate : getDomainOf(graph, type).values()) {
@@ -1328,6 +1349,18 @@ public class Layer0Utils {
        return null;
     }
     
+    public static Resource getPossiblePredicateByLabel(ReadGraph graph, Resource instance, String predicateName) throws DatabaseException {
+       Layer0 L0 = Layer0.getInstance(graph);
+       for(Resource type : graph.getPrincipalTypes(instance)) {
+               Map<String, Resource> domainOf = getDomainOf(graph, type);
+               for(Resource r : domainOf.values()) {
+                       String label = graph.getPossibleRelatedValue(r, L0.HasLabel, Bindings.STRING);
+                       if(predicateName.equals(label))
+                               return r;
+               }
+       }
+       return null;
+    }
     
     public static void claimLiteralDataboard(WriteGraph graph, Resource container, Resource property, String valueText) throws DatabaseException {
 
index 8602da82789d97de8830f1927dcd4b5d53c7295b..e7fa24124a2ca1a72fca4955d320e385b87368de 100644 (file)
@@ -27,16 +27,20 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.exception.RuntimeDatabaseException;
 import org.simantics.db.exception.ValidationException;
 import org.simantics.db.layer0.adapter.SubgraphExtent.ExtentStatus;
+import org.simantics.db.layer0.util.ConsistsOfProcess.InternalEntry;
 import org.simantics.db.layer0.util.TransferableGraphConfiguration2.RootSpec;
 import org.simantics.db.service.SerialisationSupport;
 import org.simantics.graph.db.TransferableGraphSource;
 import org.simantics.graph.representation.External;
 import org.simantics.graph.representation.Identity;
+import org.simantics.graph.representation.Internal;
 import org.simantics.graph.representation.Root;
 import org.simantics.graph.representation.Value;
 import org.simantics.layer0.Layer0;
 
 import gnu.trove.list.array.TIntArrayList;
+import gnu.trove.map.TIntObjectMap;
+import gnu.trove.map.hash.TIntObjectHashMap;
 import gnu.trove.procedure.TIntIntProcedure;
 
 public class ModelTransferableGraphSource implements TransferableGraphSource {
@@ -51,7 +55,8 @@ public class ModelTransferableGraphSource implements TransferableGraphSource {
        private volatile boolean closed = false;
 
        TIntArrayList externalParents = new TIntArrayList();
-       ArrayList<String> externalNames = new ArrayList<String>();
+       ArrayList<String> externalNames = new ArrayList<>();
+       TreeMap<String,String> downloads = new TreeMap<String,String>();
 
        public ModelTransferableGraphSource(final ReadGraph graph, TransferableGraphConfiguration2 configuration, final DomainProcessorState state, File ... fs) throws DatabaseException {
 
@@ -79,7 +84,7 @@ public class ModelTransferableGraphSource implements TransferableGraphSource {
                
                this.externalBase = state.id;
 
-               final Collection<String> errors = new HashSet<String>();
+               final Collection<String> errors = new HashSet<>();
 
                // All resource considered as not internal by domain processor. Can also contain roots.
                int[] externals = state.externals.toArray();
@@ -105,7 +110,7 @@ public class ModelTransferableGraphSource implements TransferableGraphSource {
                });
                
                if(!errors.isEmpty()) {
-                       ArrayList<String> sorted = new ArrayList<String>(errors);
+                       ArrayList<String> sorted = new ArrayList<>(errors);
                        Collections.sort(sorted);
                        StringBuilder message = new StringBuilder();
                        message.append("Errors in exported model:\n");
@@ -118,6 +123,8 @@ public class ModelTransferableGraphSource implements TransferableGraphSource {
                
                this.resourceCount = state.id;
                
+               state.extensions.put(ExternalDownloadBean.EXTENSION_KEY, new Variant(ExternalDownloadBean.BINDING, new ExternalDownloadBean(downloads)));
+               
        }
 
        int indent = 0;
@@ -200,6 +207,11 @@ public class ModelTransferableGraphSource implements TransferableGraphSource {
                        state.ids.put(r, state.id);
                        // Ensure that this resource is included into the set of externals to maintain the total number of externals 
                        state.externals.add(r);
+                       String download = graph.getPossibleRelatedValue(res, L0.Ontology_download, Bindings.STRING);
+                       if(download != null) {
+                               String uri = graph.getURI(res);
+                               downloads.put(uri, download);
+                       }
                        return state.id++;
                }
        }
@@ -380,13 +392,17 @@ public class ModelTransferableGraphSource implements TransferableGraphSource {
                // TODO: this should be Root with name ""
                procedure.execute(getRootIdentity(state, support, graph.getRootLibrary()));
 
+               TIntObjectMap<Identity> internalMap = new TIntObjectHashMap<>(100, 0.5f, Integer.MIN_VALUE);
+
                // Declare internal and external roots
                for(RootSpec r : configuration.roots) {
                        Resource type = graph.getPossibleType(r.resource, L0.Entity);
                        if(type == null) type = L0.Entity;
-                       procedure.execute(new Identity(
-                                       state.ids.get(support.getTransientId(r.resource)),
-                                       new Root(r.name, graph.getURI(type))));
+                       int id = state.ids.get(support.getTransientId(r.resource));
+                       Root root = new Root(r.name, graph.getURI(type));
+                       Identity rootId = new Identity(id,root);
+                       internalMap.put(id, rootId);
+                       procedure.execute(rootId);
                }
 
                for(int i = 0; i < state.externals.size() ; i++) {
@@ -394,8 +410,27 @@ public class ModelTransferableGraphSource implements TransferableGraphSource {
                        String name = externalNames.get(i);
                        procedure.execute(new Identity(externalBase + i, new External(parent,name)));
        }
+               
+               if(state.internalEntries != null) {
+                       for(InternalEntry ie : state.internalEntries) {
+                               if(ie.parent != null && ie.name != null) {
+                                       procedure.execute(resolveInternal(graph, support, ie, internalMap));
+                               }
+                       }
+               }
        
        }
+       
+       private Identity resolveInternal(ReadGraph graph, SerialisationSupport ss, InternalEntry entry, TIntObjectMap<Identity> internalMap) throws DatabaseException {
+               int id = state.ids.get(ss.getTransientId(entry.resource));
+               Identity existing = internalMap.get(id);
+               if(existing != null) return existing;
+               Identity parent = resolveInternal(graph, ss, entry.parent, internalMap);
+               Identity result = new Identity(id,
+                               new Internal(parent.resource, entry.name));
+               internalMap.put(id, result);
+               return result;
+       }
 
        @Override
        public TreeMap<String, Variant> getExtensions() {
index 9b85adf8faadc90cac8a09345f02ce36de40ba69..c7e697e6291773b58e44d8bd3a8c2afbf0952442 100644 (file)
  *******************************************************************************/
 package org.simantics.db.layer0.util;
 
-import gnu.trove.list.array.TIntArrayList;
-import gnu.trove.map.hash.TIntIntHashMap;
-import gnu.trove.map.hash.TLongObjectHashMap;
-import gnu.trove.procedure.TIntProcedure;
-import gnu.trove.procedure.TLongObjectProcedure;
-import gnu.trove.set.TIntSet;
-import gnu.trove.set.hash.THashSet;
-import gnu.trove.set.hash.TIntHashSet;
-
 import java.io.DataOutput;
 import java.io.DataOutputStream;
 import java.io.FileNotFoundException;
@@ -30,6 +21,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeMap;
@@ -54,6 +46,7 @@ import org.simantics.db.common.utils.NameUtils;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.adapter.SubgraphAdvisor;
 import org.simantics.db.layer0.adapter.SubgraphExtent.ExtentStatus;
+import org.simantics.db.layer0.util.ConsistsOfProcess.InternalEntry;
 import org.simantics.db.procedure.AsyncProcedure;
 import org.simantics.db.request.AsyncRead;
 import org.simantics.db.service.ClusteringSupport;
@@ -70,6 +63,15 @@ import org.simantics.utils.datastructures.Pair;
 import org.simantics.utils.threads.logger.ITask;
 import org.simantics.utils.threads.logger.ThreadLogger;
 
+import gnu.trove.list.array.TIntArrayList;
+import gnu.trove.map.hash.TIntIntHashMap;
+import gnu.trove.map.hash.TLongObjectHashMap;
+import gnu.trove.procedure.TIntProcedure;
+import gnu.trove.procedure.TLongObjectProcedure;
+import gnu.trove.set.TIntSet;
+import gnu.trove.set.hash.THashSet;
+import gnu.trove.set.hash.TIntHashSet;
+
 public class Subgraphs {
 
        public static String LOG_FILE = "export.log";
@@ -989,7 +991,9 @@ public class Subgraphs {
              * � All o are internal
              * � All stm are included
                         */
-                       for(Resource r : ConsistsOfProcess.walk(graph, fringe, exclusions, true)) {
+                       List<InternalEntry> entries = ConsistsOfProcess.walk(graph, null, fringe, exclusions, true); 
+                       for(InternalEntry entry : entries) {
+                               Resource r = entry.resource;
                                if (status.put(r, ExtentStatus.INTERNAL) == null) {
                                        String URI = graph.getPossibleURI(r);
                                        if(URI != null) log("URI INTERNAL " + URI);
index 82c20514c1aa858f625f89e7c0d028be3a9829cf..ffa39974315a1a06b50c57aada1816ae2677130e 100644 (file)
@@ -22,6 +22,7 @@ import org.simantics.db.Statement;
 import org.simantics.db.common.request.PossibleIndexRoot;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.adapter.impl.EntityInstances.QueryIndex;
+import org.simantics.db.layer0.util.ConsistsOfProcess.InternalEntry;
 import org.simantics.db.layer0.util.DomainProcessor3.ExclusionDecision;
 import org.simantics.layer0.Layer0;
 import org.simantics.scl.runtime.function.Function1;
@@ -62,8 +63,9 @@ public class TGRepresentationUtils {
                         return new GUIDExclusionFunction(graph);
 
                     // The root is OK - check everything beneath
-                    for(Resource part : ConsistsOfProcess.walk(graph, Collections.singleton(r), Collections.emptySet(), true)) {
-                        if(findByIdentifier(graph, targetRoot, part))
+                    List<InternalEntry> entries = ConsistsOfProcess.walk(graph, null, Collections.singleton(r), Collections.emptySet(), true); 
+                    for(InternalEntry entry : entries) {
+                        if(findByIdentifier(graph, targetRoot, entry.resource))
                             return new GUIDExclusionFunction(graph);
                     }
                 }
index 1e8d2731ff4bb65bc47983d5f162412882e636c7..4ac08fc0b8a25ff02f1596f402e8c669d1634726 100644 (file)
@@ -16,6 +16,7 @@ import org.simantics.db.request.WriteTraits;
 import org.simantics.db.service.ClusterUID;
 import org.simantics.db.service.SerialisationSupport;
 import org.simantics.db.service.XSupport;
+import org.simantics.utils.datastructures.Pair;
 
 public class XSupportImpl implements XSupport {
     final private boolean DEBUG = false;
@@ -112,6 +113,12 @@ public class XSupportImpl implements XSupport {
                session.clusterSetsSupport.clear();
         }
     }
+    
+    @Override
+    public Pair<Boolean, Boolean> getServiceMode() {
+       return Pair.make((session.serviceMode & 1) == 1, (session.serviceMode & 2) == 2);
+    }
+    
     @Override
     public Resource convertDelayedResourceToResource(Resource resource) {
         return DelayedWriteGraph.convertDelayedResource(resource);
index 73594cddb4830fb2364ca83a94961847235fdf8d..8e08147c5b34a2c61af386c2154a0d5238f20707 100644 (file)
@@ -17,6 +17,7 @@ import org.simantics.db.WriteOnlyGraph;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.exception.ServiceException;
 import org.simantics.db.request.WriteTraits;
+import org.simantics.utils.datastructures.Pair;
 
 /**
  * @author TUOKSK
@@ -103,6 +104,7 @@ public interface XSupport {
      * @param createAsImmutable <code>true</code> to make all created clusters immutable
      */
     void setServiceMode(boolean allowImmutableWrites, boolean createAsImmutable);
+    Pair<Boolean,Boolean> getServiceMode();
 
     /**
      * If resource is acquired from DelayedWriteGraph during delayed write request then
index 33a3871fc992a5906d0066b237bca8b2a6dec512..c1c8ff68eac6ffba173e8f629300d798596d5f48 100644 (file)
Binary files a/bundles/org.simantics.desktop.ui.ontology/graph.tg and b/bundles/org.simantics.desktop.ui.ontology/graph.tg differ
index 72053ec5b6317e93ecee85e2c5d2afa528b8f79c..45f65af2648849bca8358e73bfd74d919dc95ece 100644 (file)
Binary files a/bundles/org.simantics.diagram.ontology/graph.tg and b/bundles/org.simantics.diagram.ontology/graph.tg differ
index 1ff8d39e0c760de9d7255648d7da777b20fda391..758aa4869a657e59abf396e14ca79840755f2a30 100644 (file)
@@ -13,7 +13,7 @@ Require-Bundle: org.simantics.utils.thread.swt,
  org.simantics.db.layer0;bundle-version="[1.0.0,2.0.0)",
  org.simantics.structural2;bundle-version="1.0.0",
  org.simantics.basicexpression;bundle-version="1.0.0",
javax.vecmath;bundle-version="1.0.0",
org.apache.commons.math3;bundle-version="3.6.1",
  org.simantics.layer0;bundle-version="1.0.0",
  org.simantics.diagram.ontology;bundle-version="1.0.0";visibility:=reexport,
  org.simantics.structural.ontology;bundle-version="1.0.0",
index 93957f0698fc0643691d0676039ce676e78f4b3c..98f229b91324b75a913be0df238676f52813cbec 100644 (file)
@@ -18,6 +18,7 @@ import java.util.EnumSet;
 import java.util.List;
 
 import org.simantics.g2d.element.ElementClass;
+import org.simantics.g2d.element.ElementHints;
 import org.simantics.g2d.element.ElementUtils;
 import org.simantics.g2d.element.IElement;
 import org.simantics.g2d.element.SceneGraphNodeKey;
@@ -140,6 +141,7 @@ public class CompositeImage implements Image {
             SingleElementNode holder = node.getOrCreateNode(ElementUtils.generateNodeId(e), SingleElementNode.class);
             //SingleElementNode holder = parent.getOrCreateNode(ElementUtils.generateNodeId(e), SingleElementNode.class);
             holder.setZIndex(++zIndex);
+            holder.setKey(e.getHint(ElementHints.KEY_OBJECT));
 
             List<SceneGraph> nodeHandlers = ec.getItemsByClass(SceneGraph.class);
             for(SceneGraph n : nodeHandlers) {
index 03250d726c403ee9a864c3407584c7cb717e979b..e7bb472e4ed610450bdbb19a62df5be9f30d67de 100644 (file)
@@ -230,8 +230,8 @@ public class DefinedElementFactory extends ElementFactoryAdapter {
                                             DefaultTransform.INSTANCE,
                                             StaticSymbolImageInitializer.INSTANCE,
                                             new StaticSymbolImpl(img),
-                                            ImageClass.ImageElementHandler.INSTANCE,
-                                            new Terminals(terminals),
+                                            DefinedElementHandler.INSTANCE,
+                                            new DefinedElementTerminals(terminals),
                                             SimpleElementLayers.INSTANCE,
                                             PlainElementPropertySetter.INSTANCE
                                             ).setId(id));
diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/DefinedElementHandler.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/DefinedElementHandler.java
new file mode 100644 (file)
index 0000000..b5cc293
--- /dev/null
@@ -0,0 +1,123 @@
+package org.simantics.diagram.adapter;
+
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+
+import org.simantics.g2d.connection.handler.ConnectionHandler;
+import org.simantics.g2d.element.ElementClass;
+import org.simantics.g2d.element.ElementHints;
+import org.simantics.g2d.element.ElementUtils;
+import org.simantics.g2d.element.IElement;
+import org.simantics.g2d.element.SceneGraphNodeKey;
+import org.simantics.g2d.element.handler.InternalSize;
+import org.simantics.g2d.element.handler.Outline;
+import org.simantics.g2d.element.handler.Resize;
+import org.simantics.g2d.element.handler.SceneGraph;
+import org.simantics.g2d.image.Image;
+import org.simantics.scenegraph.Node;
+import org.simantics.scenegraph.g2d.G2DParentNode;
+import org.simantics.scenegraph.g2d.IG2DNode;
+import org.simantics.utils.datastructures.hints.IHintContext.Key;
+
+public class DefinedElementHandler implements SceneGraph, InternalSize, Resize, Outline {
+
+       private static final long serialVersionUID = -2074850877791708846L;
+
+       public static final DefinedElementHandler INSTANCE = new DefinedElementHandler();
+
+    public static final Key  KEY_SG_NODE             = new SceneGraphNodeKey(Node.class, "IMAGE_SG_NODE");
+
+    protected Image getImage(IElement e) {
+        Image i = e.getHint(ElementHints.KEY_IMAGE);
+        if (i == null)
+            throw new IllegalStateException("element " + e + " has no ElementHints.KEY_IMAGE hint");
+        return i;
+    }
+
+    protected Key getNodeKey() {
+        return KEY_SG_NODE;
+    }
+
+    @Override
+    public void init(final IElement e, final G2DParentNode parent) {
+        Image i = getImage(e);
+        Node node = i.init(parent);
+        if (node != null)
+            e.setHint(getNodeKey(), node);
+        if(node instanceof IG2DNode) {
+               IG2DNode n = (IG2DNode)node;
+               AffineTransform at = ElementUtils.getTransform(e);
+               if(at != null) {
+                       n.setTransform(at); // FIXME: not tested..
+               }
+        }
+    }
+
+    public void cleanup(final IElement e) {
+        Node node = e.removeHint(getNodeKey());
+        if (node != null)
+            node.remove();
+    }
+    
+    public Rectangle2D imageBounds(IElement e) {
+       Image i = getImage(e);
+               return i.getBounds();
+    }
+
+    @Override
+    public Rectangle2D getBounds(IElement e, Rectangle2D size) {
+
+               if (size == null)
+                       size = new Rectangle2D.Double();
+
+       ElementClass ec = e.getElementClass();
+       if(ec.containsClass(ConnectionHandler.class)) {
+               size.setFrame(imageBounds(e));
+       } else {
+               IG2DNode node = e.getHint(getNodeKey());
+               if(node != null) {
+                       size.setFrame(node.getBoundsInLocal()); 
+               } else {
+                       size.setFrame(imageBounds(e));
+               }
+       }
+       
+               return size;
+               
+    }
+
+    @Override
+    public Double getFixedAspectRatio(IElement e) {
+        Image i = getImage(e);
+        Rectangle2D r = i.getBounds();
+        return r.getWidth() / r.getHeight();
+    }
+
+    @Override
+    public Rectangle2D getMaximumSize(IElement e) {
+        Image i = getImage(e);
+        return i.getBounds();
+    }
+
+    @Override
+    public Rectangle2D getMinimumSize(IElement e) {
+        Image i = getImage(e);
+        return i.getBounds();
+    }
+
+    @Override
+    public void resize(IElement e, Rectangle2D newSize) {
+    }
+
+    @Override
+    public Shape getElementShape(IElement e) {
+       
+        IG2DNode node = e.getHint(getNodeKey());
+        if (node == null)
+               throw new IllegalStateException();
+        return node.getBoundsInLocal();
+       
+    }
+       
+}
\ No newline at end of file
diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/DefinedElementTerminals.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/DefinedElementTerminals.java
new file mode 100644 (file)
index 0000000..6f83954
--- /dev/null
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Semantum Oy - #7119 initial API and implementation
+ *******************************************************************************/
+package org.simantics.diagram.adapter;
+
+import java.awt.geom.AffineTransform;
+import java.util.Collection;
+
+import org.simantics.diagram.content.ResourceTerminal;
+import org.simantics.g2d.diagram.handler.Topology.Terminal;
+import org.simantics.g2d.element.IElement;
+import org.simantics.g2d.element.handler.TerminalLayout;
+import org.simantics.g2d.element.handler.TerminalTopology;
+import org.simantics.g2d.element.handler.impl.ObjectTerminal;
+import org.simantics.g2d.element.handler.impl.Terminals;
+import org.simantics.scenegraph.INode;
+import org.simantics.scenegraph.g2d.IG2DNode;
+import org.simantics.scenegraph.g2d.nodes.SingleElementNode;
+import org.simantics.scenegraph.utils.NodeUtil;
+
+/**
+ * A {@link TerminalTopology} and more specifically a {@link TerminalLayout}
+ * implementation that relies primarily on the scene graph and only secondarily
+ * on its internal datastructures to resolve terminal locations. This implementation
+ * is used to support dynamic terminals.
+ * 
+ * @author Antti Villberg
+ * @since 1.29.0
+ */
+public class DefinedElementTerminals extends Terminals {
+
+    private static final long serialVersionUID = -726490868093887444L;
+
+    public DefinedElementTerminals(Collection<ObjectTerminal> ts) {
+        super(ts);
+    }
+
+    private IG2DNode findResourceTerminalNode(IG2DNode node, ResourceTerminal rt) {
+        return (IG2DNode) NodeUtil.forChildrenDeep(node, SingleElementNode.class, n -> {
+            Object key = n.getKey();
+            if (rt.getResource().equals(key)) {
+                IG2DNode[] children = n.getSortedNodes();
+                if (children.length > 0)
+                    return children[0];
+                return n;
+            }
+            return null;
+        });
+    }
+
+    @Override
+    public AffineTransform getTerminalPosition(IElement e, Terminal t) {
+        if (t instanceof ResourceTerminal) {
+            ResourceTerminal rt = (ResourceTerminal) t;
+            IG2DNode node = e.getHint(DefinedElementHandler.KEY_SG_NODE);
+            if (node != null) {
+                IG2DNode n = findResourceTerminalNode(node, rt);
+                if (n != null) {
+                    return n.getTransform();
+                }
+            }
+        }
+
+        ObjectTerminal ti = terminalMap.get(t);
+        if (ti == null)
+            return null;
+        return new AffineTransform(ti.getTransform());
+    }
+
+}
\ No newline at end of file
index de99bd25fb8c626d7ca080161f77e0581681730b..99d9acb705388a6b85f242ec5485c08d1dcdc208 100644 (file)
@@ -69,12 +69,15 @@ import org.simantics.structural2.modelingRules.CPTerminal;
 import org.simantics.structural2.modelingRules.IAttachmentRelationMap;
 import org.simantics.structural2.modelingRules.IModelingRules;
 import org.simantics.utils.threads.CurrentThread;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.map.hash.THashMap;
 import gnu.trove.set.hash.THashSet;
 
 public class RouteGraphUtils {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(RouteGraph.class);
     public static boolean DEBUG = false;
 
     public static final ILineEndStyle HEAD  = new ArrowLineEndStyle("fill 2 1 0");
@@ -341,7 +344,7 @@ public class RouteGraphUtils {
             RouteNode n1 = nodeByData.get(link.first());
             RouteNode n2 = nodeByData.get(link.second());
             if (n1 == null || n2 == null) {
-                System.err.println("Stray connection link found: " + link.toString(graph));
+                LOGGER.warn("Stray connection link found: " + link.toString(graph));
                 continue;
             }
             rg.link(n1, n2);
index 339f180e815525f2eeaf1fd49da350c3de9f6723..c62422d4a5fe0f52e875825b72ef2c663b96d76e 100644 (file)
@@ -25,8 +25,7 @@ import java.awt.geom.Rectangle2D;
 import java.util.EnumSet;
 import java.util.Map;
 
-import javax.vecmath.Vector2d;
-
+import org.apache.commons.math3.geometry.euclidean.twod.Vector2D;
 import org.simantics.db.layer0.variable.RVI;
 import org.simantics.g2d.diagram.IDiagram;
 import org.simantics.g2d.element.ElementClass;
@@ -680,11 +679,9 @@ public class MonitorClass {
             return Double.NaN;
         double angrad = Math.toRadians(angle);
 
-        Vector2d forcedAxis = new Vector2d(Math.cos(angrad), Math.sin(angrad));
-        Vector2d x = new Vector2d(tr.getScaleX(), tr.getShearX());
-        forcedAxis.normalize();
-        x.normalize();
-        double cosa = forcedAxis.dot(x);
+        Vector2D forcedAxis = new Vector2D(Math.cos(angrad), Math.sin(angrad));
+        Vector2D x = new Vector2D(tr.getScaleX(), tr.getShearX()).normalize();
+        double cosa = forcedAxis.dotProduct(x);
         double delta = Math.acos(cosa);
         return delta;
     }
index 85923bc35763923d5d2015178c867d73b84a98a7..4554decee2c01a41b032be9dab5c77ecec2af2f7 100644 (file)
@@ -34,7 +34,6 @@ import java.awt.font.TextLayout;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
-import java.io.IOException;
 import java.text.AttributedCharacterIterator;
 import java.text.AttributedString;
 import java.util.ArrayList;
@@ -75,13 +74,7 @@ import org.simantics.ui.dnd.PlaintextTransfer;
 import org.simantics.ui.fonts.Fonts;
 import org.simantics.utils.threads.AWTThread;
 
-import com.lowagie.text.DocumentException;
-import com.lowagie.text.Element;
-import com.lowagie.text.Rectangle;
-import com.lowagie.text.pdf.FontMapper;
-import com.lowagie.text.pdf.PdfFormField;
 import com.lowagie.text.pdf.PdfWriter;
-import com.lowagie.text.pdf.TextField;
 
 import gnu.trove.list.array.TIntArrayList;
 
@@ -99,7 +92,6 @@ import gnu.trove.list.array.TIntArrayList;
  * TODO:
  * o proper support for defining clipping bounds for the text (needed for page templates) (currently through fixedWidth)
  * o fix editing xOffset to work with fixed width and multi-line text
- * o 
  * 
  * @see Line
  * @see TextLayout
@@ -108,6 +100,12 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
 
     private static final long                serialVersionUID           = 654692698101485672L;
 
+    public static enum TextFlipping {
+        Disabled,
+        VerticalTextUpwards,
+        VerticalTextDownwards,
+    }
+
     /**
      * TODO: justify existence for this
      */
@@ -191,6 +189,8 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
     protected transient static final int STATE_X_OFFSET_IS_DIRTY = (1 << 7);
     protected static final int STATE_ALWAYS_ADD_LISTENERS = (1 << 8);
     protected static final int STATE_LISTENERS_ADDED = (1 << 9);
+    protected static final int STATE_AUTOMATIC_TEXT_FLIP_ENABLED = (1 << 10);
+    protected static final int STATE_AUTOMATIC_TEXT_FLIP_VERTICAL_DOWN = (1 << 11);
 
     /**
      * A combination of all the STATE_ constants defined in this class,
@@ -413,6 +413,21 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
         resetCaches();
     }
 
+    public void setAutomaticTextFlipping(TextFlipping type) {
+        switch (type) {
+        case Disabled:
+            clearState(STATE_AUTOMATIC_TEXT_FLIP_ENABLED | STATE_AUTOMATIC_TEXT_FLIP_VERTICAL_DOWN);
+            break;
+        case VerticalTextDownwards:
+            setState(STATE_AUTOMATIC_TEXT_FLIP_ENABLED | STATE_AUTOMATIC_TEXT_FLIP_VERTICAL_DOWN);
+            break;
+        case VerticalTextUpwards:
+            setState(STATE_AUTOMATIC_TEXT_FLIP_ENABLED);
+            clearState(STATE_AUTOMATIC_TEXT_FLIP_VERTICAL_DOWN);
+            break;
+        }
+    }
+
     @SyncField({"paddingX", "paddingY"})
     public void setPadding(double x, double y) {
         this.paddingX = x;
@@ -628,7 +643,8 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
         // Safety for not rendering when the scale of this text is too small.
         // When the scale is too small it will cause internal exceptions while
         // stroking fonts.
-        double currentScale = GeometryUtils.getScale(g.getTransform());
+        AffineTransform curTr = g.getTransform();
+        double currentScale = GeometryUtils.getScale(curTr);
         //System.out.println("currentScale: " + currentScale);
         if (currentScale < 1e-6)
             return;
@@ -652,6 +668,27 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
             r.setRect(x, y, w, h);
         }
 
+        if (hasState(STATE_AUTOMATIC_TEXT_FLIP_ENABLED)) {
+            boolean needsXFlip;
+            boolean needsYFlip;
+            if (curTr.getScaleX() != 0) {
+                needsXFlip = curTr.getScaleX() < 0.0;
+                needsYFlip = curTr.getScaleY() < 0.0;
+            } else {
+                boolean flipAll = !hasState(STATE_AUTOMATIC_TEXT_FLIP_VERTICAL_DOWN);
+                needsXFlip = (curTr.getShearY() < 0.0) ^ flipAll;
+                needsYFlip = (curTr.getShearX() > 0.0) ^ flipAll;
+            }
+            if (needsXFlip || needsYFlip) {
+                double centerX = r.getWidth()*0.5 + r.getX();
+                double centerY = r.getHeight()*0.5 + r.getY();
+
+                g.translate(centerX, centerY);
+                g.scale(needsXFlip ? -1.0 : 1.0, needsYFlip ? -1.0 : 1.0);
+                g.translate(-centerX, -centerY);
+            }
+        }
+
         Rectangle2D textClip = r.getBounds2D();
 
         expandBoundsUnscaled(r);
@@ -674,22 +711,12 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
         // PDF 
         PdfWriter writer = (PdfWriter) g.getRenderingHint(G2DPDFRenderingHints.KEY_PDF_WRITER);
         boolean isRenderingPdf = writer != null;
-        boolean isPdfField = false;
-        String fieldName = null;
-        if (writer != null) {
-               // TODO: replace this hack with proper text field name field
-               fieldName = NodeUtil.getNodeName(this);
-               isPdfField = ( fieldName.equals("approved_by") ||
-                                               fieldName.equals("checked_by") ||
-                                               fieldName.equals("designer name") ||
-                                               fieldName.equals("created_by") );
-        }
+        /// PDF
 
         Color backgroundColor = hasState(STATE_VALID) ? this.backgroundColor : Color.red;
 
         // RENDER
-        if ( !isPdfField ) {
-
+        {
             // Fill background if necessary
             if (backgroundColor != null) {
                 g.setColor(backgroundColor);
@@ -727,10 +754,7 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
 
                 g.setClip(clip);
 
-                // Caret
-                
                 renderCaret(g);
-                
 
             } else {
 
@@ -740,95 +764,7 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
                 }
 
             }
-        } else {
-            // PDF 
-            // TODO: multiline support
-//                             try {
-                           AffineTransform at = g.getTransform();
-                           float height = writer.getPageSize().getHeight();
-                           Rectangle2D rr = textClip;
-       //                  Point2D pt1 = new Point2D.Double(rr.getX(), rr.getY()+rr.getHeight());
-       //                  Point2D pt2 = new Point2D.Double(rr.getX()+rr.getWidth(), rr.getY());
-                           Point2D pt1 = new Point2D.Double(0, 0);
-                           Point2D pt2 = new Point2D.Double(47.f/*+rr.getWidth()*/, -rr.getHeight());
-                           pt1 = at.transform(pt1, pt1);
-                           pt2 = at.transform(pt2, pt2);
-                               Rectangle rectangle = new Rectangle(
-                                               (float) pt1.getX(), 
-                                               height-(float) pt1.getY(), 
-                                               (float) pt2.getX(), 
-                                               height-(float) pt2.getY()); 
-
-                           FontMapper mapper = (FontMapper) g.getRenderingHint(G2DPDFRenderingHints.KEY_PDF_FONTMAPPER);
-//                             FontMetrics fm    = g.getFontMetrics(font);
-
-                               // TODO Oikea leveys
-                               // TODO Uniikki nimi
-                               /*
-                               PdfFormField field = PdfFormField.createTextField(writer, false, false, 20);
-                               field.setFieldName(this.getId().toString());
-                               field.setWidget(rectangle, PdfAnnotation.HIGHLIGHT_NONE);
-                               field.setQuadding(PdfFormField.Q_RIGHT);
-                               field.setFieldFlags(PdfFormField.FF_READ_ONLY);
-                               field.setRotate(90);
-                               writer.addAnnotation(field);
-                               */
-
-
-                               // Signature Field
-                               /*
-                               if (text==null) {
-                                       PdfFormField field = PdfFormField.createSignature(writer);
-                                       field.setWidget(rectangle, PdfAnnotation.HIGHLIGHT_NONE);
-                                       field.setFieldName(fieldName);
-                                       field.setQuadding(PdfFormField.Q_LEFT);
-                                       field.setFlags(PdfAnnotation.FLAGS_PRINT);
-                                       //field.setFieldFlags(PdfFormField.FF_READ_ONLY)
-                                       field.setFieldFlags(PdfFormField.FF_EDIT);
-                                       field.setPage();
-                                       field.setMKBackgroundColor( backgroundColor!=null?Color.WHITE:backgroundColor );
-                                       PdfAppearance tp = PdfAppearance.createAppearance(writer, 72, 48);
-                                       tp.rectangle(rectangle);
-                                       tp.stroke();                            
-                                       field.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, tp);
-                                       writer.addAnnotation(field);
-                               } else */ 
-                               {
-                                       // Text Field
-                                               try {
-                                               TextField textField = new TextField(writer, rectangle, fieldName);
-                                               textField.setFieldName(fieldName);
-                                               textField.setFont(mapper.awtToPdf(font));
-                                               textField.setBorderStyle(0);
-                                           //textField.setAlignment(Element.ALIGN_LEFT);
-                                           textField.setAlignment(Element.ALIGN_BOTTOM);
-                                           textField.setRotation(90);
-                                       textField.setOptions(TextField.EDIT|TextField.DO_NOT_SPELL_CHECK);
-                                           if ( text!=null ) {
-                                                       textField.setText(text);
-                                           }
-                                           if ( color!=null ) {
-                                               textField.setTextColor(color);
-                                           }
-                                               textField.setBackgroundColor( backgroundColor!=null?Color.WHITE:backgroundColor );
-                                           PdfFormField field = textField.getTextField();
-                                           writer.addAnnotation(field);
-                                               } catch (IOException e) {
-                                                       e.printStackTrace();
-                                               } catch (DocumentException e) {
-                                                       e.printStackTrace();
-                                               }
-                               }
-
-//                             } catch (IOException e) {
-//                                     // TODO Auto-generated catch block
-//                                     e.printStackTrace();
-//                             } catch (DocumentException e) {
-//                                     // TODO Auto-generated catch block
-//                                     e.printStackTrace();
-//                             }
         }
-        /// PDF
 
         g.setClip(clipSave);
 
index 759efbe5634f872717c2701e5adf7ba3739bc156..3f1076b5df48e70047cd4dae8d9531bd494c9d0d 100644 (file)
@@ -7,9 +7,6 @@ import java.awt.geom.Point2D;
 import java.util.ArrayList;
 import java.util.Collection;
 
-import javax.vecmath.Tuple2d;
-import javax.vecmath.Vector2d;
-
 import org.simantics.databoard.Bindings;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
@@ -247,18 +244,18 @@ public class RouteGraphConnectionSplitter {
         String commonLabel = scheme.generateLabel(graph, diagram);
 
         // Create flags and connect both disconnected ends to them.
-        Vector2d pos1, pos2;
+        Point2D pos1, pos2;
         double theta;
         double flagDist = 3.0;
         if(isHorizontal) {
             theta = 0.0;
-            pos1 = new Vector2d(isectX-flagDist, isectY);
-            pos2 = new Vector2d(isectX+flagDist, isectY);
+            pos1 = new Point2D.Double(isectX-flagDist, isectY);
+            pos2 = new Point2D.Double(isectX+flagDist, isectY);
         }
         else {
             theta = Math.PI*0.5;
-            pos1 = new Vector2d(isectX, isectY-flagDist);
-            pos2 = new Vector2d(isectX, isectY+flagDist);
+            pos1 = new Point2D.Double(isectX, isectY-flagDist);
+            pos2 = new Point2D.Double(isectX, isectY+flagDist);
         }
 
         // Chooses flag directions
@@ -398,8 +395,8 @@ public class RouteGraphConnectionSplitter {
         }
     }
 
-    private AffineTransform getFlagTransform(Tuple2d pos, double theta) {
-        AffineTransform at = AffineTransform.getTranslateInstance(pos.x, pos.y);
+    private AffineTransform getFlagTransform(Point2D pos, double theta) {
+        AffineTransform at = AffineTransform.getTranslateInstance(pos.getX(), pos.getY());
         at.rotate(theta);
         return at;
     }
index 57c1a64e34151a40a728c619cb044551acde3068..a5220f99c8a1ce7678d6b7ead492de954127427d 100644 (file)
@@ -8,9 +8,7 @@ import java.util.Deque;
 import java.util.HashSet;
 import java.util.Set;
 
-import javax.vecmath.Tuple2d;
-import javax.vecmath.Vector2d;
-
+import org.apache.commons.math3.geometry.euclidean.twod.Vector2D;
 import org.simantics.databoard.Bindings;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
@@ -129,26 +127,19 @@ public class Splitter {
         // Calculate split position and edge line nearest intersection point
         // ab = normalize( vec(a -> b) )
         // ap = vec(a -> split pos)
-        Vector2d ab = new Vector2d(nearestEdge.getX2() - nearestEdge.getX1(), nearestEdge.getY2() - nearestEdge.getY1());
-        Vector2d ap = new Vector2d(splitCanvasPos.getX() - nearestEdge.getX1(), splitCanvasPos.getY() - nearestEdge.getY1());
-        double theta = Math.atan2(ab.y, ab.x);
-        ab.normalize();
+        Vector2D a = new Vector2D(nearestEdge.getX1(), nearestEdge.getY1());
+        Vector2D ab = new Vector2D(nearestEdge.getX2() - nearestEdge.getX1(), nearestEdge.getY2() - nearestEdge.getY1());
+        Vector2D ap = new Vector2D(splitCanvasPos.getX() - nearestEdge.getX1(), splitCanvasPos.getY() - nearestEdge.getY1());
+        double theta = Math.atan2(ab.getY(), ab.getX());
+        ab = ab.normalize();
 
         // intersection = a + ab*(ap.ab)
-        Vector2d intersection = new Vector2d(ab);
-        intersection.scale(ap.dot(ab));
-        intersection.add(new Vector2d(nearestEdge.getX1(), nearestEdge.getY1()));
+        Vector2D intersection = a.add( ab.scalarMultiply(ap.dotProduct(ab)) );
 
         // Offset flag positions from the intersection point.
-        Vector2d pos1 = new Vector2d(intersection);
-        Vector2d pos2 = new Vector2d(intersection);
-
         // TODO: improve logic for flag positioning, flags just move on the nearest line without boundaries
-        ab.normalize();
-        ab.scale(5);
-        pos2.add(ab);
-        ab.negate();
-        pos1.add(ab);
+        Vector2D pos1 = intersection.subtract(5, ab);
+        Vector2D pos2 = intersection.add(5, ab);
 
         FlagLabelingScheme scheme = DiagramFlagPreferences.getActiveFlagLabelingScheme(graph);
         String commonLabel = scheme.generateLabel(graph, diagram);
@@ -168,8 +159,8 @@ public class Splitter {
         FlagUtil.join(graph, flag1, flag2);
     }
 
-    private AffineTransform getFlagTransform(Tuple2d pos, double theta) {
-        AffineTransform at = AffineTransform.getTranslateInstance(pos.x, pos.y);
+    private AffineTransform getFlagTransform(Vector2D pos, double theta) {
+        AffineTransform at = AffineTransform.getTranslateInstance(pos.getX(), pos.getY());
         at.rotate(theta);
         return at;
     }
index 5b0dfa066478b5362fca8ec6e02492e6ad674fba..52217c3cfcf2b84a6ddc9795d7d13d3f66af80ba 100644 (file)
@@ -150,19 +150,19 @@ public class CopyPasteHandler extends AbstractDiagramParticipant {
      * A key for storing the current selection within the currently active
      * project for copy/paste implementation.
      */
-    private static final Key               KEY_DIAGRAM_SELECTION              = DiagramSelectionRepresentation.KEY_DIAGRAM_SELECTION;
+    private static final Key              KEY_DIAGRAM_SELECTION              = DiagramSelectionRepresentation.KEY_DIAGRAM_SELECTION;
 
     private static final boolean          DEBUG                              = false;
     private static final boolean          DEBUG_SELECTION_UPDATE             = false;
 
     public static final int               COPY_GHOSTING_PAINT_PRIORITY       = 600;
 
-    private static final int              HIGHLIGHT_PAINT_PRIORITY           = 500;
+    protected static final int            HIGHLIGHT_PAINT_PRIORITY           = 500;
 
     @Dependency
-    private Selection                     sel;
+    protected Selection                   sel;
     @Dependency
-    private MouseUtil                     mouseUtil;
+    protected MouseUtil                   mouseUtil;
 
     protected final IStatusLineManager    statusLine;
     protected final CopyPasteStrategy     strategy;
@@ -205,7 +205,7 @@ public class CopyPasteHandler extends AbstractDiagramParticipant {
      */
     protected boolean                     hasFocus                           = false;
 
-    private AbstractCanvasParticipant     highlightMode                      = null;
+    protected AbstractCanvasParticipant   highlightMode                      = null;
     private IProject                      observedProject                    = null;
 
     /**
@@ -375,7 +375,7 @@ public class CopyPasteHandler extends AbstractDiagramParticipant {
         return DiagramSelection.EMPTY;
     }
 
-    private DiagramSelection getProjectSelection() {
+    protected DiagramSelection getProjectSelection() {
         IProject p = peekProject();
         if (p == null)
             return DiagramSelection.EMPTY;
@@ -383,12 +383,12 @@ public class CopyPasteHandler extends AbstractDiagramParticipant {
         return ds != null ? ds : DiagramSelection.EMPTY;
     }
 
-    void setDiagramSelection(DiagramSelection selection) {
+    protected void setDiagramSelection(DiagramSelection selection) {
         setProjectSelection(selection);
         strategy.copyToClipboard(selection);
     }
 
-    void setProjectSelection(DiagramSelection selection) {
+    protected void setProjectSelection(DiagramSelection selection) {
         assert selection != null;
         IProject p = getProject();
         if (p == null)
@@ -399,7 +399,7 @@ public class CopyPasteHandler extends AbstractDiagramParticipant {
         p.setHint(KEY_DIAGRAM_SELECTION, selection);
     }
 
-    private void removeProjectSelection() {
+    protected void removeProjectSelection() {
         setProjectSelection(DiagramSelection.EMPTY);
         removeHighlight();
         clearSG();
@@ -473,7 +473,7 @@ public class CopyPasteHandler extends AbstractDiagramParticipant {
         return false;
     }
 
-    boolean initiateCopy(boolean cut) {
+    protected boolean initiateCopy(boolean cut) {
         //System.out.println("INITIATING COPY");
         int selectionId = 0;
 
@@ -576,7 +576,7 @@ public class CopyPasteHandler extends AbstractDiagramParticipant {
             message(null);
             return false;
         }
-        
+
         TimeLogger.resetTimeAndLog(getClass(), "paste");
 
         ElementObjectAssortment ea = ds.getAssortment();
@@ -685,7 +685,7 @@ public class CopyPasteHandler extends AbstractDiagramParticipant {
         }
     }
 
-    private String fixAssortment(ElementAssortment ea, boolean cut) {
+    protected String fixAssortment(ElementAssortment ea, boolean cut) {
         Topology diagramTopology = diagram.getDiagramClass().getAtMostOneItemOfClass(Topology.class);
         List<Connection> conns = new ArrayList<Connection>();
 
@@ -823,7 +823,7 @@ public class CopyPasteHandler extends AbstractDiagramParticipant {
      * @param ea
      * @return
      */
-    private void pruneAssortment(ElementAssortment ea, boolean cut) {
+    protected void pruneAssortment(ElementAssortment ea, boolean cut) {
         // Edges and branch points are never copied as such.
         // They are always included as parts of copied connections.
         // Edges can never be transformed or modified in any way as such,
@@ -872,7 +872,7 @@ public class CopyPasteHandler extends AbstractDiagramParticipant {
      * @param e
      * @return
      */
-    private static boolean isConnectionOrEdge(IElement e) {
+    protected static boolean isConnectionOrEdge(IElement e) {
         ElementClass ec = e.getElementClass();
         return ec.containsClass(ConnectionHandler.class)|| ec.containsClass(BendsHandler.class);
     }
@@ -881,7 +881,7 @@ public class CopyPasteHandler extends AbstractDiagramParticipant {
      * @param e
      * @return
      */
-    private static boolean isMoveable(IElement e) {
+    protected static boolean isMoveable(IElement e) {
         ElementClass ec = e.getElementClass();
         return ec.containsClass(Move.class) && ec.containsClass(Transform.class);
     }
@@ -891,7 +891,7 @@ public class CopyPasteHandler extends AbstractDiagramParticipant {
      * @return <code>null</code> if a point of reference cannot be determined
      *         for the specified selection.
      */
-    private Point2D getCopyStartPos(Set<IElement> ss) {
+    protected Point2D getCopyStartPos(Set<IElement> ss) {
 //        MouseInfo mi = mouseUtil.getMouseInfo(0);
 //        if (mi != null) {
 //            return (Point2D) mi.canvasPosition.clone();
@@ -1090,11 +1090,11 @@ public class CopyPasteHandler extends AbstractDiagramParticipant {
         return ghostNode.addNode(id, clazz);
     }
 
-    private boolean hasHighlight() {
+    protected boolean hasHighlight() {
         return highlightMode != null;
     }
 
-    private void removeHighlight() {
+    protected void removeHighlight() {
         if (isRemoved())
             return;
         assert getContext().getThreadAccess().currentThreadAccess();
@@ -1111,7 +1111,7 @@ public class CopyPasteHandler extends AbstractDiagramParticipant {
         return (e.stateMask & MouseEvent.CTRL_MASK) != 0;
     }
 
-    void selectedMessage(DiagramSelection ds) {
+    protected void selectedMessage(DiagramSelection ds) {
         int size = ds.getOriginalElements().size();
         StringBuilder sb = new StringBuilder();
         if (size == 0) {
@@ -1133,7 +1133,7 @@ public class CopyPasteHandler extends AbstractDiagramParticipant {
         message(sb.toString());
     }
 
-    void message(final String message) {
+    protected void message(final String message) {
         if (statusLine == null)
             return;
         swtExec(new Runnable() {
@@ -1145,7 +1145,7 @@ public class CopyPasteHandler extends AbstractDiagramParticipant {
         });
     }
 
-    void error(final String message) {
+    protected void error(final String message) {
         if (statusLine == null)
             return;
         swtExec(new Runnable() {
@@ -1156,7 +1156,7 @@ public class CopyPasteHandler extends AbstractDiagramParticipant {
         });
     }
 
-    void swtExec(Runnable r) {
+    protected void swtExec(Runnable r) {
         ThreadUtils.asyncExec(SWTThread.getThreadAccess(Display.getDefault()), r);
     }
 
@@ -1289,7 +1289,7 @@ public class CopyPasteHandler extends AbstractDiagramParticipant {
                                     graph.claim(resource, L0X.ObtainsProperty1, null, template);
                                 }
                             }
-                            
+
                         }
                     });
                 }
index 0f243db4816d72976fee02048a961531a21c6677..c8995f4c1f4777be79311bc0d502616af534f147 100644 (file)
@@ -1,8 +1,6 @@
 package org.simantics.diagram.handler;
 
 import static org.simantics.diagram.handler.Paster.ComposedCutProcedure.compose;
-import gnu.trove.map.hash.THashMap;
-import gnu.trove.set.hash.THashSet;
 
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Point2D;
@@ -14,6 +12,7 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Queue;
 import java.util.Set;
+import java.util.function.BiFunction;
 
 import org.simantics.databoard.Bindings;
 import org.simantics.db.ReadGraph;
@@ -62,9 +61,11 @@ import org.simantics.structural.stubs.StructuralResource2;
 import org.simantics.structural2.modelingRules.CPTerminal;
 import org.simantics.structural2.modelingRules.ConnectionJudgement;
 import org.simantics.structural2.modelingRules.IConnectionPoint;
-import org.simantics.utils.datastructures.BinaryFunction;
 import org.simantics.utils.datastructures.map.Tuple;
 
+import gnu.trove.map.hash.THashMap;
+import gnu.trove.set.hash.THashSet;
+
 /**
  * @author Tuukka Lehtonen
  */
@@ -273,7 +274,7 @@ public class Paster {
         return noParentElementReturnValue;
     }
 
-    private void cut() throws Exception {
+    protected void cut() throws Exception {
         final GraphLayerManager glm = targetContext.get(GraphSynchronizationHints.GRAPH_LAYER_MANAGER);
 
         final THashSet<Resource> cutElements = new THashSet<Resource>();
@@ -688,10 +689,10 @@ public class Paster {
      * Diagram mapping will have problems and potentially break the
      * configuration if the type is not the same as in the source.
      */
-    BinaryFunction<StatementEvaluation, ReadGraph, Statement> statementAdvisor =
-            new BinaryFunction<StatementEvaluation, ReadGraph, Statement>() {
+    BiFunction<ReadGraph, Statement, StatementEvaluation> statementAdvisor =
+            new BiFunction<ReadGraph, Statement, StatementEvaluation>() {
         @Override
-        public StatementEvaluation call(ReadGraph graph, Statement stm) {
+        public StatementEvaluation apply(ReadGraph graph, Statement stm) {
             if (DIA.HasFlagType.equals(stm.getPredicate()))
                 return StatementEvaluation.INCLUDE;
             return StatementEvaluation.USE_DEFAULT;
@@ -747,7 +748,7 @@ public class Paster {
         }
     };
 
-    private void copy() throws Exception {
+    protected void copy() throws Exception {
         nodeMap = new NodeMap();
         
         CommonDBUtils.selectClusterSet(graph, targetDiagram);
@@ -1359,5 +1360,8 @@ public class Paster {
     public NodeMap getNodeMap() {
         return nodeMap;
     }
-
+    
+    protected PasteOperation getOperation() {
+       return op;
+    }
 }
index 7d172318bf1b8561c009f2ef55086e62ee7037fc..4ec3258a7822554f228ccbf0ddd83af6b8dce909 100644 (file)
@@ -987,18 +987,20 @@ public class SymbolLibraryComposite extends Composite {
         final boolean expanded = grp.getExpanded();
         final boolean visible = grp.getVisible();
         final boolean filterChanged = !objectEquals(filter, lastFilter);
+        final ISymbolGroup symbolGroup = (ISymbolGroup) grp.getData(SymbolLibraryKeys.KEY_GROUP);
+        final boolean filterMatchesGroup = filter != null && filter.select(viewer, null, symbolGroup);
 
         // Find out how much data would be shown with the new filter.
-        viewer.setFilter(filter);
+        viewer.setFilter(filterMatchesGroup ? null : filter);
         Object[] elements = viewer.getFilteredElements();
 
-        ISymbolGroup symbolGroup = (ISymbolGroup) grp.getData(SymbolLibraryKeys.KEY_GROUP);
-        boolean filterMatchesGroup = filter != null && filter.select(viewer, null, symbolGroup);
         boolean shouldBeVisible = !groupFiltered && (elements.length > 0 || filterMatchesGroup);
         boolean shouldBeExpanded = shouldBeVisible && (filter != null || userExpanded);
 
-//        System.out.format("%40s: visible/should be = %5s %5s,  expanded/user expanded/should be = %5s %5s %5s\n",
+//        System.out.format("%40s: filterMatchesGroup(%s) = %s, visible/should be = %5s %5s,  expanded/user expanded/should be = %5s %5s %5s\n",
 //                grp.getText(),
+//                symbolGroup.getName(),
+//                String.valueOf(filterMatchesGroup),
 //                String.valueOf(visible),
 //                String.valueOf(shouldBeVisible),
 //                String.valueOf(expanded),
index 60d4c56aeaa54d9c5d0559dcea7b189d188e6a06..61d09acdd3cb18981d53c67e9300d255a3fc23d6 100644 (file)
@@ -15,6 +15,7 @@ import gnu.trove.map.hash.THashMap;
 
 import java.util.Map;
 import java.util.Set;
+import java.util.function.BiFunction;
 
 import org.simantics.databoard.Bindings;
 import org.simantics.databoard.binding.Binding;
@@ -44,7 +45,6 @@ import org.simantics.diagram.synchronization.SynchronizationHints;
 import org.simantics.graph.db.TransferableGraphs;
 import org.simantics.graph.representation.TransferableGraph1;
 import org.simantics.layer0.Layer0;
-import org.simantics.utils.datastructures.BinaryFunction;
 
 /**
  * This class contains utility methods for the basic cut/copy operations
@@ -223,7 +223,7 @@ public class CopyAdvisorUtil {
      * @return the copied resource
      * @throws DatabaseException
      */
-    public static Resource copy(WriteGraph graph, Resource source, BinaryFunction<Boolean, ReadGraph, Statement> advisor) throws DatabaseException {
+    public static Resource copy(WriteGraph graph, Resource source, BiFunction<ReadGraph, Statement, Boolean> advisor) throws DatabaseException {
         return copy(graph, source, 0, advisor, new THashMap<Object, Object>());
     }
 
@@ -238,11 +238,11 @@ public class CopyAdvisorUtil {
      * @return
      * @throws DatabaseException
      */
-    public static Resource copy(WriteGraph graph, Resource source, BinaryFunction<Boolean, ReadGraph, Statement> advisor, Map<Object, Object> copyMap) throws DatabaseException {
+    public static Resource copy(WriteGraph graph, Resource source, BiFunction<ReadGraph, Statement, Boolean> advisor, Map<Object, Object> copyMap) throws DatabaseException {
         return copy(graph, source, 0, advisor, copyMap);
     }
 
-    private static Resource copy(WriteGraph graph, Resource source, int level, BinaryFunction<Boolean, ReadGraph, Statement> advisor, Map<Object, Object> copyMap) throws DatabaseException {
+    private static Resource copy(WriteGraph graph, Resource source, int level, BiFunction<ReadGraph, Statement, Boolean> advisor, Map<Object, Object> copyMap) throws DatabaseException {
         if (DEBUG_COPY)
             System.out.println("[" + level + "] CopyAdvisorUtil.copy(" + NameUtils.getSafeName(graph, source) + ", advisor=" + advisor + ")");
 
@@ -320,7 +320,7 @@ public class CopyAdvisorUtil {
                 }
             } else {
                 if (advisor != null) {
-                    Boolean result = advisor.call(graph, stm);
+                    Boolean result = advisor.apply(graph, stm);
                     if (Boolean.TRUE.equals(result)) {
                         // Don't clone the object, just add relation to the same object.
                         if (inverse != null)
@@ -363,7 +363,7 @@ public class CopyAdvisorUtil {
      * @throws DatabaseException
      */
     public static Resource copy2(WriteGraph graph, Resource source,
-            BinaryFunction<StatementEvaluation, ReadGraph, Statement> advisor) throws DatabaseException {
+            BiFunction<ReadGraph, Statement, StatementEvaluation> advisor) throws DatabaseException {
         return copy2(graph, source, 0, advisor, new THashMap<Object, Object>());
     }
 
@@ -379,13 +379,13 @@ public class CopyAdvisorUtil {
      * @throws DatabaseException 
      */
     public static Resource copy2(WriteGraph graph, Resource source,
-            BinaryFunction<StatementEvaluation, ReadGraph, Statement> advisor, Map<Object, Object> copyMap)
+            BiFunction<ReadGraph, Statement, StatementEvaluation> advisor, Map<Object, Object> copyMap)
             throws DatabaseException {
         return copy2(graph, source, 0, advisor, copyMap);
     }
 
     private static Resource copy2(final WriteGraph graph, final Resource source, final int level,
-            BinaryFunction<StatementEvaluation, ReadGraph, Statement> advisor, Map<Object, Object> copyMap)
+            BiFunction<ReadGraph, Statement, StatementEvaluation> advisor, Map<Object, Object> copyMap)
     throws DatabaseException {
         if (DEBUG_COPY)
             System.out.println("[" + level + "] CopyAdvisorUtil.copy(" + NameUtils.getSafeName(graph, source) + ", advisor=" + advisor + ")");
@@ -536,7 +536,7 @@ public class CopyAdvisorUtil {
      * @throws DatabaseException
      */
     public static Resource copy3(WriteGraph graph, Resource source, Resource model,
-            BinaryFunction<StatementEvaluation, ReadGraph, Statement> advisor) throws DatabaseException {
+            BiFunction<ReadGraph, Statement, StatementEvaluation> advisor) throws DatabaseException {
         String modelURI = graph.getURI(model);
         return copy3(graph, modelURI, source, 0, advisor, new THashMap<Object, Object>());
     }
@@ -554,13 +554,13 @@ public class CopyAdvisorUtil {
      * @throws DatabaseException
      */
     public static Resource copy3(WriteGraph graph, Resource source, Resource model,
-            BinaryFunction<StatementEvaluation, ReadGraph, Statement> advisor, Map<Object, Object> copyMap) throws DatabaseException {
+            BiFunction<ReadGraph, Statement, StatementEvaluation> advisor, Map<Object, Object> copyMap) throws DatabaseException {
         String modelURI = graph.getURI(model);
         return copy3(graph, modelURI, source, 0, advisor, copyMap);
     }
 
     private static Resource copy3(WriteGraph graph, String modelURI, Resource source, int level,
-            BinaryFunction<StatementEvaluation, ReadGraph, Statement> advisor, Map<Object, Object> copyMap)
+            BiFunction<ReadGraph, Statement, StatementEvaluation> advisor, Map<Object, Object> copyMap)
     throws DatabaseException {
         if (DEBUG_COPY)
             System.out.println("[" + level + "] CopyAdvisorUtil.copy(" + NameUtils.getSafeName(graph, source) + ", advisor=" + advisor + ")");
@@ -698,10 +698,10 @@ public class CopyAdvisorUtil {
         return copy;
     }
 
-    protected static StatementEvaluation evaluate(ReadGraph graph, Statement stm, BinaryFunction<StatementEvaluation, ReadGraph, Statement> tester) {
+    protected static StatementEvaluation evaluate(ReadGraph graph, Statement stm, BiFunction<ReadGraph, Statement, StatementEvaluation> tester) {
         if (tester == null)
             return StatementEvaluation.USE_DEFAULT;
-        return tester.call(graph, stm);
+        return tester.apply(graph, stm);
     }
 
     /**
index c321d212ce1dec3ce2362c7fcce3f2b035766e45..51f83d20b95b56c28aed8e4e5b7dff941ea53dd0 100644 (file)
Binary files a/bundles/org.simantics.document.base.ontology/graph.tg and b/bundles/org.simantics.document.base.ontology/graph.tg differ
index 5397d24db2e0fd080cac9cb5315252a58a9ec03a..517ce7f3b4a44b80eaa8288315e283edfd80c369 100644 (file)
@@ -9,6 +9,7 @@ Require-Bundle: org.simantics.layer0,
  org.simantics.scenegraph.ontology;bundle-version="1.0.0",
  org.simantics.viewpoint.ontology;bundle-version="1.0.0",
  org.simantics.selectionview.ontology;bundle-version="1.1.0",
- org.simantics.graphfile.ontology;bundle-version="0.1.0"
+ org.simantics.graphfile.ontology;bundle-version="0.1.0",
+ org.simantics.action.ontology;bundle-version="1.1.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Export-Package: org.simantics.document
index aadabaa9a92d5782509edce10315771b1e9dbcf2..94f3d05181d30bad5872617c811080b9a5861860 100644 (file)
Binary files a/bundles/org.simantics.document.ontology/graph.tg and b/bundles/org.simantics.document.ontology/graph.tg differ
index e006a5fd8a141157a7f5e7687a1b79a030f617c6..b35002d40c3aa9fbad91e1c94b30dbc97c4a11d8 100644 (file)
@@ -3,6 +3,7 @@ L0X = <http://www.simantics.org/Layer0X-1.1>
 SG = <http://www.simantics.org/Scenegraph-1.1>
 SEL = <http://www.simantics.org/SelectionView-1.2>
 GF = <http://www.simantics.org/GraphFile-0.1>
+ACT = <http://www.simantics.org/Action-1.1>
 
 DOC = <http://www.simantics.org/Document-1.2> : L0.Ontology
     @L0.new
@@ -158,4 +159,8 @@ DOC.PlainTextDocument <T DOC.Document
 
 
 DOC.DocumentLibrary <T L0.Library
+
+DOC.Actions : L0.Library
+
+DOC.Actions.ImportFileDocument : ACT.Action
    
\ No newline at end of file
index 2bca437a26934bbbd1be4c85eb835e34b1dd2cc1..d98c2e5b065eea2a940d8ae7132b190f3c22d76e 100644 (file)
@@ -10,6 +10,8 @@ import org.simantics.db.service.QueryControl;
 
 public class DocumentResource {
     
+    public final Resource Actions;
+    public final Resource Actions_ImportFileDocument;
     public final Resource Document;
     public final Resource DocumentLibrary;
     public final Resource DocumentSettings;
@@ -91,6 +93,8 @@ public class DocumentResource {
     public final Resource documentSettings_Inverse;
         
     public static class URIs {
+        public static final String Actions = "http://www.simantics.org/Document-1.2/Actions";
+        public static final String Actions_ImportFileDocument = "http://www.simantics.org/Document-1.2/Actions/ImportFileDocument";
         public static final String Document = "http://www.simantics.org/Document-1.2/Document";
         public static final String DocumentLibrary = "http://www.simantics.org/Document-1.2/DocumentLibrary";
         public static final String DocumentSettings = "http://www.simantics.org/Document-1.2/DocumentSettings";
@@ -182,6 +186,8 @@ public class DocumentResource {
     }
     
     public DocumentResource(ReadGraph graph) {
+        Actions = getResourceOrNull(graph, URIs.Actions);
+        Actions_ImportFileDocument = getResourceOrNull(graph, URIs.Actions_ImportFileDocument);
         Document = getResourceOrNull(graph, URIs.Document);
         DocumentLibrary = getResourceOrNull(graph, URIs.DocumentLibrary);
         DocumentSettings = getResourceOrNull(graph, URIs.DocumentSettings);
index 7a59a14610284d988378e633c1e5773063ff2f6b..9bf10fb3a67d4ad2c1dc7fb23a4bc56b81be9652 100644 (file)
@@ -3,4 +3,9 @@ package org.simantics.document.server.io;
 public interface ITreeTableCell extends ITableCell {
     
        int getParent();
+       
+        Object getData();
+
+     boolean isEditable();
+     
 }
index 8913645a9946c3f4884fd4e8c5ae9f028afaea1a..558ee320459e519823852eac43d654763e90906f 100644 (file)
@@ -13,6 +13,7 @@
 package org.simantics.document.server.io;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -343,4 +344,72 @@ public class JSONObjectUtils {
         else
             return Collections.<IListItem>emptyList();
     }
+    
+    @SuppressWarnings("unchecked")
+    public static Collection<ITreeTableCell> getTreeTableCell(IJSONObject object) {
+        try {
+            Object treeTableCells = object.getValue("tableCells");
+            if (treeTableCells instanceof String) {
+                String tableCellsS = (String) treeTableCells;
+                if (tableCellsS.length() == 0)
+                    return Collections.emptyList();
+            }
+            if (treeTableCells != null) {
+                return (List<ITreeTableCell>) treeTableCells;
+            } else {
+                return Collections.emptyList();
+            }
+        } catch (ClassCastException e) {
+            e.printStackTrace();
+        }
+        return Collections.emptyList();
+    }
+
+    public static final boolean equalObjects(Object oldValue, Object newValue) {
+       if (newValue != null) {
+               if (newValue.getClass().isArray()) {
+                       return arrayEquals(newValue, oldValue);
+               } else {
+                       return newValue.equals(oldValue);
+               }
+       } else
+               return oldValue == null;
+    }
+
+    
+       /**
+        * @param av1 an array (guaranteed)
+        * @param av2 any object
+        * @return <code>true</code> if the two arrays are equal
+        */
+       private static final boolean arrayEquals(Object av1, Object av2) {
+               if (av2 == null)
+                       return false;
+               Class<?> c1 = av1.getClass().getComponentType();
+               Class<?> c2 = av2.getClass().getComponentType();
+               if (c2 == null || !c1.equals(c2))
+                       return false;
+               boolean p1 = c1.isPrimitive();
+               boolean p2 = c2.isPrimitive();
+               if (p1 != p2)
+                       return false;
+               if (!p1)
+                       return Arrays.equals((Object[]) av1, (Object[]) av2);
+               if (boolean.class.equals(c1))
+                       return Arrays.equals((boolean[]) av1, (boolean[]) av2);
+               else if (byte.class.equals(c1))
+                       return Arrays.equals((byte[]) av1, (byte[]) av2);
+               else if (int.class.equals(c1))
+                       return Arrays.equals((int[]) av1, (int[]) av2);
+               else if (long.class.equals(c1))
+                       return Arrays.equals((long[]) av1, (long[]) av2);
+               else if (float.class.equals(c1))
+                       return Arrays.equals((float[]) av1, (float[]) av2);
+               else if (double.class.equals(c1))
+                       return Arrays.equals((double[]) av1, (double[]) av2);
+               throw new RuntimeException("Unsupported objects for equality testing ." + av1 + " vs. " + av2);
+               
+       }
+    
+    
 }
index 23896814224bdeed738e03fb32723c466fc5d367..fa83a224acfc2d7076af4417e2f2e181680e93e7 100644 (file)
@@ -21,6 +21,13 @@ importJava "org.simantics.document.server.io.ITreeTableCell" where
 
 importJava "org.simantics.document.server.io.IFont" where
     data IFont
+    
+    @JavaName getFamily
+    fontFamily :: IFont -> <Proc> Maybe String
+    @JavaName getStyle
+    fontStyle :: IFont -> <Proc> Maybe String
+    @JavaName getHeight
+    fontHeight :: IFont -> <Proc> Integer
 
 importJava "org.simantics.document.server.io.IColor" where
     data IColor
index fb597cc1cac5634dce3932cbda5b52645e80d882..332f21fb25d0649a359ca3152f1b44fc3807cee3 100644 (file)
Binary files a/bundles/org.simantics.document.swt.ontology/graph.tg and b/bundles/org.simantics.document.swt.ontology/graph.tg differ
index e1ef059472784e15937b2adf7600326cd571f634..dc11fa0e32ce64899ea375bfdb7b3f81bcc10835 100644 (file)
@@ -6,6 +6,7 @@ Bundle-Version: 1.1.0.qualifier
 Bundle-Vendor: Semantum Oy
 Require-Bundle: org.simantics.layer0,
  org.simantics.views.ontology;bundle-version="1.1.0",
+ org.simantics.views.text.ontology;bundle-version="1.0.0",
  org.simantics.modeling.ontology;bundle-version="1.1.0",
  org.simantics.scenegraph.ontology;bundle-version="1.0.0",
  org.simantics.document.ontology;bundle-version="1.1.0",
index 66fea40388122bceab20c2c2a1b2f110e3a5154e..8ef6e047fd28d54ce23586151a80cfc152bfcecc 100644 (file)
Binary files a/bundles/org.simantics.document.ui.ontology/graph.tg and b/bundles/org.simantics.document.ui.ontology/graph.tg differ
index 3ac065d5e5ef78299553b91710f9538720db247c..b06a314a38fa29ac97f93c484fd7d42b434e91d2 100644 (file)
@@ -1,5 +1,6 @@
 L0 = <http://www.simantics.org/Layer0-1.1>
 VIEWS = <http://www.simantics.org/Views-1.2>
+TEXTVIEWS = <http://www.simantics.org/TextViews-1.0>
 SG = <http://www.simantics.org/Scenegraph-1.1>
 DOC = <http://www.simantics.org/Document-1.2>
 ACT = <http://www.simantics.org/Action-1.1>
@@ -40,11 +41,6 @@ UI.WikitextContribution.View : VIEWS.Composite
     @L0.list
       _ : VIEWS.Composite
         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
@@ -159,7 +155,7 @@ UI.WikitextContribution.View : VIEWS.Composite
         VIEWS.Composite.layout _ : VIEWS.GridLayout
         SG.Node.children _ : L0.List
           @L0.list
-            UI.WikitextContribution.View.Text : VIEWS.StyledText
+            UI.WikitextContribution.View.Text : TEXTVIEWS.MarkupSourceViewer
               @VIEWS.Control.style4 VIEWS.Control.Style.Constant.Multi VIEWS.Control.Style.Constant.Border VIEWS.Control.Style.Constant.VScroll VIEWS.Control.Style.Constant.HScroll
               VIEWS.TextContainer.text UI.Functions.selectedDocumentPart : L0.Function
                 L0.HasValueType "String"
@@ -200,13 +196,6 @@ UI.Sash : VIEWS.SashForm
   VIEWS.SashForm.orientation VIEWS.SashForm.Vertical
   SG.Node.children _ : L0.List
     @L0.list
-//      UI.Scroll : VIEWS.ScrolledComposite
- //       VIEWS.Control.layoutData
- //         _ : VIEWS.GridLayout.GridData
- //           VIEWS.GridLayout.GridData.horizontalGrab true
- //           VIEWS.GridLayout.GridData.verticalGrab true
- //       SG.Node.children _ : L0.List
- //         @L0.list
       UI.Browser : VIEWS.Browser
         VIEWS.Control.layoutData
           _ : VIEWS.GridLayout.GridData
index 5d0115b16f2e9036ab848cd989c629be03ddce2d..fa2877b11b34c5c98461e973b380b4932a2f169c 100644 (file)
@@ -7,6 +7,7 @@ Bundle-Activator: org.simantics.document.ui.Activator
 Bundle-Vendor: Semantum Oy
 Require-Bundle: org.eclipse.ui,
  org.eclipse.core.runtime,
+ org.simantics.views;bundle-version="1.1.0",
  org.simantics.views.swt;bundle-version="1.0.0",
  org.simantics.document.ontology;bundle-version="1.0.0",
  org.simantics.document.ui.ontology;bundle-version="1.0.0",
@@ -14,12 +15,9 @@ Require-Bundle: org.eclipse.ui,
  org.simantics.modeling.ontology;bundle-version="1.1.0",
  org.simantics.scenegraph.ontology;bundle-version="1.0.0",
  org.simantics.document;bundle-version="1.0.0",
- org.eclipse.mylyn.wikitext.mediawiki.core;bundle-version="1.5.2",
- org.eclipse.mylyn.wikitext.core;bundle-version="1.5.1",
  org.simantics.wiki.ui;bundle-version="1.1.0",
  org.simantics.browsing.ui;bundle-version="1.1.0",
  org.simantics.selectionview;bundle-version="1.0.0",
- org.simantics.views;bundle-version="1.1.0",
  org.simantics.utils.thread.swt;bundle-version="1.1.0",
  org.simantics.browsing.ui.model;bundle-version="1.0.0";visibility:=reexport,
  org.simantics.graphfile;bundle-version="0.1.0",
@@ -29,7 +27,8 @@ Require-Bundle: org.eclipse.ui,
  org.simantics.annotation.ontology;bundle-version="1.0.0",
  org.simantics.annotation.ui;bundle-version="1.0.0",
  org.eclipse.ui.editors;bundle-version="3.9.0",
- org.eclipse.jface.text
+ org.eclipse.jface.text,
+ org.slf4j.api;bundle-version="1.7.2"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Bundle-ActivationPolicy: lazy
 Export-Package: org.simantics.document.ui,
index 2493b1c2c1d58b501858d653ce256f30860e9e16..6cd9ccebb547e1465897724880824d8aac32d110 100644 (file)
@@ -15,20 +15,20 @@ importJava "org.simantics.document.ui.actions.ExportDocumentFile" where
     exportDocument :: Resource -> String -> <Proc> ()
 
 documentsFolders :: Model -> <ReadGraph> [Resource]
-documentsFolders model = recurse DOCUMENT.DocumentLibrary (toResource model)
+documentsFolders model = recurse DOCUMENT.DocumentLibrary model
   where
     recurse t r = do
-        cs = resourceChildrenOf r 
+        cs = children r 
         libraries = filter isLibrary cs
         libraryGrp = filter (not . isLibrary) cs
         libraries + concatMap (recurse t) libraryGrp
     isLibrary r = isInstanceOf r DOCUMENT.DocumentLibrary
 
 documents :: Model -> <ReadGraph> [Resource]
-documents model = recurse DOCUMENT.Document (toResource model)
+documents model = recurse DOCUMENT.Document model
   where
     recurse t r = do
-        cs = resourceChildrenOf r 
+        cs = children r 
         documents = filter isDocument cs
         documentFolder = filter (not . isDocument) cs
         documents + concatMap (recurse t) documentFolder