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);
+ LOGGER.info("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();
String fileName = parts[0] + ".extFile";
Path from = dbFolder.resolve(readDirName).resolve(fileName);
Path to = baseline.resolve(fileName);
- System.err.println("purge copies " + from + " => " + to);
+ LOGGER.info("purge copies " + from + " => " + to);
Files.copy(from, to, StandardCopyOption.COPY_ATTRIBUTES);
FileInfo info = fileLRU.getWithoutMutex(parts[0]);
info.moveTo(baseline);
String readDirName = parts[1];
if(!readDirName.equals(currentDir)) {
ClusterStreamChunk chunk = streamLRU.purge(parts[0]);
- System.err.println("purge removes " + chunk);
+ LOGGER.info("purge removes " + chunk);
}
}
if(!readDirName.equals(currentDir)) {
Long revisionId = Long.parseLong(parts[0]);
ChangeSetInfo info = csLRU.purge(revisionId);
- System.err.println("purge removes " + info);
+ LOGGER.info("purge removes " + info);
}
// Path readDir = dbFolder.resolve(parts[1]);
// Long revisionId = Long.parseLong(parts[0]);
void tryPurgeDirectory(Path f) {
- System.err.println("purge deletes " + f);
+ LOGGER.info("purge deletes " + f);
String currentDir = f.getFileName().toString();
if(currentDir.endsWith("db"))
int ordinal = Integer.parseInt(currentDir);
if(ordinal < mainState.headDir - 1) {
- System.err.println("purge deletes " + f);
+ LOGGER.info("purge deletes " + f);
FileUtils.deleteDir(f.toFile());
}
throw cause;
// Maximum autosave frequency is per 60s
if(!fullSave && System.nanoTime() - lastSnapshot < 10*1000000000L) {
- // System.err.println("lastSnapshot too early");
+ // LOGGER.info("lastSnapshot too early");
return false;
}
// e.printStackTrace();
// }
- // System.err.println("-- load statistics --");
+ // LOGGER.info("-- load statistics --");
// for(Pair<ClusterUID, Integer> entry :
// CollectionUtils.valueSortedEntries(histogram)) {
- // System.err.println(" " + entry.second + " " + entry.first);
+ // LOGGER.info(" " + entry.second + " " + entry.first);
// }
// }
}
// Files
for (String fileKey : state.files) {
- // System.err.println("loadFile: " + fileKey);
+ // LOGGER.info("loadFile: " + fileKey);
String[] parts = fileKey.split("#");
Path readDir = dbFolder.resolve(parts[1]);
int offset = Integer.parseInt(parts[2]);
}
// Update chunks
for (String fileKey : state.stream) {
- // System.err.println("loadStream: " + fileKey);
+ // LOGGER.info("loadStream: " + fileKey);
String[] parts = fileKey.split("#");
Path readDir = dbFolder.resolve(parts[1]);
int offset = Integer.parseInt(parts[2]);
import java.util.Set;
import org.simantics.databoard.file.RuntimeIOException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class FileIO {
-
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(FileIO.class);
private static final FileAttribute<?>[] NO_ATTRIBUTES = new FileAttribute[0];
private static final Set<OpenOption> CREATE_OPTIONS = new HashSet<>(2);
if(TRACE_PERF) {
long duration = System.nanoTime()-start;
double ds = 1e-9*duration;
- System.err.println("Wrote " + bytes.length + " bytes @ " + 1e-6*bytes.length / ds + "MB/s");
+ LOGGER.info("Wrote " + bytes.length + " bytes @ " + 1e-6*bytes.length / ds + "MB/s");
}
return result;
} catch (Throwable t) {
}
byte[] result = buf.array();
if (result.length != length)
- System.err.println("faa");
+ LOGGER.info("result length does not match expected {} {} {}", this, result.length, length);
if (TRACE_PERF) {
long duration = System.nanoTime() - start;
double ds = 1e-9 * duration;
- System.err.println("Read " + result.length + " bytes @ " + 1e-6 * result.length / ds + "MB/s");
+ LOGGER.info("Read " + result.length + " bytes @ " + 1e-6 * result.length / ds + "MB/s");
}
return result;
}
syncPath(test);
- long duration = System.nanoTime()-s;
- System.err.println("Took " + 1e-6*duration + "ms.");
-
-
+ if (LOGGER.isDebugEnabled()) {
+ long duration = System.nanoTime()-s;
+ LOGGER.info("Took " + 1e-6*duration + "ms.");
+ }
}
}
boolean executorTerminated = executor.awaitTermination(500, TimeUnit.MILLISECONDS);
boolean saverTerminated = saver.awaitTermination(500, TimeUnit.MILLISECONDS);
- System.err.println("executorTerminated=" + executorTerminated + ", saverTerminated=" + saverTerminated);
+ LOGGER.info("executorTerminated=" + executorTerminated + ", saverTerminated=" + saverTerminated);
try {
clusters.mainState.save(dbFolder);
final int changeSetId = clusters.state.headChangeSetId;
if(ClusterUpdateProcessorBase.DEBUG)
- System.err.println(" === BEGIN UNDO ===");
+ LOGGER.info(" === BEGIN UNDO ===");
for(int i=0;i<changeSetIds.length;i++) {
final long id = changeSetIds[changeSetIds.length-1-i];
String ccsid = ccss.get(ccss.size()-j-1);
try {
if(ClusterUpdateProcessorBase.DEBUG)
- System.err.println("performUndo " + ccsid);
+ LOGGER.info("performUndo " + ccsid);
performUndo(ccsid, clusterChanges, support);
} catch (DatabaseException e) {
e.printStackTrace();
}
if(ClusterUpdateProcessorBase.DEBUG)
- System.err.println(" === END UNDO ===");
+ LOGGER.info(" === END UNDO ===");
for(int i=0;i<clusterChanges.size();i++) {
import org.simantics.acorn.exception.IllegalAcornStateException;
import org.simantics.db.service.Bytes;
import org.simantics.utils.datastructures.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import gnu.trove.list.array.TByteArrayList;
public class ChangeSetInfo extends LRUObject<Long, ChangeSetInfo> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ChangeSetInfo.class);
private byte[] metadataBytes;
private ArrayList<String> clusterChangeSetIds;
return false;
}
+ @Override
+ public Logger getLogger() {
+ return LOGGER;
+ }
}
\ No newline at end of file
import org.simantics.db.service.Bytes;
import org.simantics.db.service.ClusterUID;
import org.simantics.utils.datastructures.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ClusterInfo extends LRUObject<ClusterUID, ClusterInfo> implements Persistable {
-
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ClusterInfo.class);
final private ClusterManager manager;
private ClusterImpl cluster;
public int changeSetId;
long start = System.nanoTime();
state.waitForUpdates();
long duration = System.nanoTime() - start;
- System.err.println("Wait updates to cluster " + getKey() + " for " + (1e-6 * duration) + "ms.");
+ if (LOGGER.isDebugEnabled())
+ LOGGER.debug("Wait updates to cluster " + getKey() + " for " + (1e-6 * duration) + "ms.");
}
}
protected boolean overwrite() {
return true;
}
-
+
+ @Override
+ public Logger getLogger() {
+ return LOGGER;
+ }
}
\ No newline at end of file
import org.simantics.db.impl.ClusterBase;
import org.simantics.db.impl.ClusterI;
import org.simantics.db.service.ClusterUID;
+import org.slf4j.LoggerFactory;
import gnu.trove.map.hash.TIntIntHashMap;
public class ClusterLRU extends LRU<ClusterUID, ClusterInfo> {
+ private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ClusterLRU.class);
+
final private BijectionMap<ClusterUID, Integer> clusterMapping = new BijectionMap<ClusterUID, Integer>();
public ClusterLRU(ClusterManager manager, String identifier, Path writeDir) {
synchronized(map) {
value = map.get(key);
if(key != value) {
- System.err.println("Read failed for real " + key + " vs. " + value);
+ LOGGER.warn("Read failed for real " + key + " vs. " + value);
}
//ws.release();
}
write.join();
read.join();
- long duration = System.nanoTime() - start;
- System.err.println("took " + 1e-9*duration + "s.");
-
+ if (LOGGER.isDebugEnabled()) {
+ long duration = System.nanoTime() - start;
+ LOGGER.debug("took " + 1e-9*duration + "s.");
+ }
}
}
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.service.Bytes;
import org.simantics.utils.datastructures.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import gnu.trove.list.array.TByteArrayList;
public class ClusterStreamChunk extends LRUObject<String, ClusterStreamChunk> implements Persistable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ClusterStreamChunk.class);
// 500KB is a fine chunk
private static int MAX_CHUNK_SIZE = 500*1024;
protected boolean overwrite() {
return false;
}
-
+
+ @Override
+ public Logger getLogger() {
+ return LOGGER;
+ }
}
\ No newline at end of file
import org.simantics.acorn.exception.IllegalAcornStateException;
import org.simantics.db.Database.Session.ResourceSegment;
import org.simantics.utils.datastructures.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import gnu.trove.list.array.TByteArrayList;
public class FileInfo extends LRUObject<String, FileInfo> {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FileInfo.class);
private TByteArrayList bytes;
// Stub
return true;
}
+ @Override
+ public Logger getLogger() {
+ return LOGGER;
+ }
}
\ No newline at end of file
public void acquireMutex() throws IllegalAcornStateException {
try {
while(!mutex.tryAcquire(3, TimeUnit.SECONDS)) {
- System.err.println("Mutex is taking a long time to acquire - owner is " + mutexOwner);
+ LOGGER.info("Mutex is taking a long time to acquire - owner is " + mutexOwner);
}
if(VERIFY)
mutexOwner = Thread.currentThread();
public void shutdown() {
if (GraphClientImpl2.DEBUG)
- System.err.println("Shutting down LRU writers " + writers);
+ LOGGER.info("Shutting down LRU writers " + writers);
writers.shutdown();
try {
writers.awaitTermination(60, TimeUnit.SECONDS);
}
});
if (GraphClientImpl2.DEBUG)
- System.err.println("Resuming LRU writers " + writers);
+ LOGGER.info("Resuming LRU writers " + writers);
}
/*
import org.simantics.acorn.exception.AcornAccessVerificationException;
import org.simantics.acorn.exception.IllegalAcornStateException;
import org.simantics.utils.datastructures.Pair;
+import org.slf4j.Logger;
public abstract class LRUObject<MapKey, MapValue extends LRUObject<MapKey, MapValue>> implements Persistable {
-
+
+ public abstract Logger getLogger();
public static boolean VERIFY = true;
// Final stuff
public void acquireMutex() throws IllegalAcornStateException {
try {
while(!mutex.tryAcquire(3, TimeUnit.SECONDS)) {
- System.err.println("Mutex is taking a long time to acquire - owner is " + mutexOwner);
+ getLogger().info("Mutex is taking a long time to acquire - owner is " + mutexOwner);
}
if(VERIFY)
if(var != null) {
map.put(name, var);
} else {
- System.err.println("No adapter for " + child + " in " + context.getURI(graph));
+ LOGGER.warn("No adapter for " + child + " in " + context.getURI(graph));
}
}
return map;
org.eclipse.jface;bundle-version="3.6.0",
org.simantics.ui;bundle-version="1.0.0",
org.simantics.databoard;bundle-version="0.6.2",
- org.simantics.common;bundle-version="1.0.0"
+ org.simantics.common;bundle-version="1.0.0",
+ org.slf4j.api
Export-Package: org.simantics.browsing.ui.common,
org.simantics.browsing.ui.common.comparators,
org.simantics.browsing.ui.common.contributor,
import org.simantics.browsing.ui.common.internal.IGECache.IGECacheEntry;
import org.simantics.browsing.ui.exception.NoDataSourceException;
import org.simantics.browsing.ui.exception.NoQueryProcessorException;
+import org.slf4j.LoggerFactory;
public class GENodeQueryManager implements NodeQueryManager, PrimitiveQueryUpdater {
+ private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(GENodeQueryManager.class);
private static final boolean DEBUG = false;
protected IGraphExplorerContext ge;
void queryDebug(String s) {
for (int i = 0; i < ge.queryIndent(); ++i)
- System.err.append(" ");
- System.err.println(s);
+ LOGGER.info(" ");
+ LOGGER.info(s);
}
String toString(UIElementReference ref) {
org.simantics.db.management;bundle-version="0.8.0",
org.eclipse.ui;bundle-version="3.6.0",
org.simantics.browsing.ui.model;bundle-version="1.0.0",
- org.simantics.ui;bundle-version="1.0.0"
+ org.simantics.ui;bundle-version="1.0.0",
+ org.slf4j.api
Export-Package: org.simantics.browsing.ui.graph.impl,
org.simantics.browsing.ui.graph.impl.contribution,
org.simantics.browsing.ui.graph.impl.contributor.imager,
import org.simantics.layer0.Layer0;
import org.simantics.utils.datastructures.ArrayMap;
import org.simantics.utils.datastructures.slice.ValueRange;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Tuukka Lehtonen
}
return null;
}
+
+ @Override
+ public Logger getLogger() {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
static class ArrayPropertyLabeler extends LazyGraphLabeler {
}
return null;
}
+
+ @Override
+ public Logger getLogger() {
+ return LoggerFactory.getLogger(ArrayPropertyLabeler.class);
+ }
};
}
import org.simantics.db.common.request.ReadRequest;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.exception.ResourceNotFoundException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* An entry point for loading an EvaluatorData in a data-oriented fashion. Also
*/
public class Evaluators {
+ private static final Logger LOGGER = LoggerFactory.getLogger(Evaluators.class);
public static final boolean DEBUG = false;
public static void create(EvaluatorData data, final ResourceManager resourceManager,
for(String browseContext : browseContexts) {
try {
browseContextResources.add(graph.getResource(browseContext));
- } catch(ResourceNotFoundException e) {
- // Expected result, if no modelled contributions exist.
- //System.err.println("Didn't find " + browseContext + " while loading model browser.");
} catch(DatabaseException e) {
- System.err.println("Didn't find " + browseContext + " while loading model browser.");
- e.printStackTrace();
+ LOGGER.error("Didn't find " + browseContext + " while loading model browser.", e);
}
}
import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
import org.simantics.db.exception.DatabaseException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public abstract class GraphLabelerFactory implements LabelerFactory {
public Modifier getModifier(ModificationContext modificationContext, String key) {
return GraphLabelerFactory.this.getModifier(key);
}
+
+ @Override
+ public Logger getLogger() {
+ return LoggerFactory.getLogger(GraphLabelerFactory.class);
+ }
};
}
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.procedure.Listener;
import org.simantics.utils.ui.ErrorLogger;
+import org.slf4j.Logger;
public abstract class LazyGraphLabeler extends LabelerStub {
@Override
public void exception(Throwable t) {
- System.err.println("LazyGraphLabeler2: ");
- t.printStackTrace();
+ getLogger().error("LazyGraphLabeler2: ", t);
}
};
}
+ public abstract Logger getLogger();
}
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.management.ISessionContext;
import org.simantics.utils.datastructures.ArrayMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Requires {@link IProperty} as input.
}
return null;
}
+
+ @Override
+ public Logger getLogger() {
+ return LoggerFactory.getLogger(getClass());
+ }
+
};
}
import org.simantics.db.RelationContext;
import org.simantics.db.exception.DatabaseException;
import org.simantics.utils.datastructures.ArrayMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Tuukka Lehtonen
object = LabelerUtil.safeStringRepresentation(graph, ctx.getStatement().getObject());
return ArrayMap.make(ColumnKeys.KEYS_PROPERTY_VALUE, new String[] { property, object });
}
+
+ @Override
+ public Logger getLogger() {
+ return LoggerFactory.getLogger(RelationContextLabelerFactory.class);
+ }
};
}
import org.simantics.db.WriteGraph;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.management.ISessionContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class StringRepresentationLabelerFactory implements LabelerFactory {
}
return null;
}
+
+ @Override
+ public Logger getLogger() {
+ return LoggerFactory.getLogger(StringRepresentationLabelerFactory.class);
+ }
};
}
gnu.trove3;bundle-version="3.0.3",
org.simantics.graphviz;bundle-version="1.1.0",
org.simantics.graphviz.ui;bundle-version="1.1.0",
- org.simantics.ui;bundle-version="1.0.0"
+ org.simantics.ui;bundle-version="1.0.0",
+ org.slf4j.api
Export-Package: org.simantics.browsing.ui.model,
org.simantics.browsing.ui.model.actions,
org.simantics.browsing.ui.model.browsecontexts,
import org.simantics.graphviz.ui.GraphvizComponent;
import org.simantics.scl.reflection.OntologyVersions;
import org.simantics.viewpoint.ontology.ViewpointResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* BrowseContext holds all contributions related to given set of browse contexts.
* @author Hannu Niemistö
*/
public class BrowseContext {
-
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(BrowseContext.class);
public static final boolean DEBUG = false;
NodeTypeMultiMap<ChildContribution> childContributions = new NodeTypeMultiMap<ChildContribution>();
try {
browseContextResources.add(graph.getResource(browseContext));
} catch (ResourceNotFoundException e) {
- // Expected result, if no modelled contributions exist.
- //System.err.println("Didn't find " + browseContext + " while loading model browser.");
+ LOGGER.error("Didn't find " + browseContext + " while loading model browser.", e);
}
}
Collection<Resource> allBrowseContextResources = BrowseContext.findSubcontexts(graph, browseContextResources);
Collection<NodeContext> children = contribution.getChildren(graph, parent);
result.addAll(children);
if(DEBUG) {
- System.err.println("contribution: " + contribution.getIdentifier());
+ LOGGER.info("contribution: " + contribution.getIdentifier());
for(NodeContext ctx : children)
- System.err.println("-" + ctx);
+ LOGGER.info("-" + ctx);
}
}
import org.simantics.db.Resource;
import org.simantics.db.exception.DatabaseException;
import org.simantics.viewpoint.ontology.ViewpointResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Constant label decoration rule decorates the label in a fixed way.
*/
public class ConstantLabelDecorationRule extends AbstractLabelDecorator implements LabelDecorationRule {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ConstantLabelDecorationRule.class);
/**
* For headless instances where no Display is available
*/
this.style |= SWT.ITALIC;
break;
default:
- System.err.println("Invalid character '" + c + "' in style string. Only B and I recognized.");
+ LOGGER.info("Invalid character '" + c + "' in style string. Only B and I recognized.");
}
}
import org.simantics.db.layer0.variable.Variable;
import org.simantics.ui.selection.WorkbenchSelectionElement;
import org.simantics.viewpoint.ontology.ViewpointResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class SpecialNodeType implements NodeType {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(SpecialNodeType.class);
+
public Resource resource;
Class<?> contentType;
if (bundleId != null) {
bundle = Platform.getBundle(bundleId);
if (bundle == null)
- System.err.println("Referenced bundle '" + bundleId + "' not found in platform.");
+ LOGGER.warn("Referenced bundle '" + bundleId + "' not found in platform.");
}
if (bundle != null)
contentType = bundle.loadClass(contentTypeName);
else
contentType = Class.forName(contentTypeName);
} catch (ClassNotFoundException e) {
- System.err.println("Unknown content type " + contentTypeName);
+ LOGGER.error("Unknown content type {} - {}", contentTypeName, e.getMessage());
+ if (LOGGER.isTraceEnabled())
+ LOGGER.trace("Unknown content type {}", contentTypeName, e);
}
else
- System.err.println("Content type is NULL.");
+ LOGGER.warn("Content type is NULL.");
}
return new SpecialNodeType(r, contentType);
}
import org.simantics.db.Resource;
import org.simantics.db.exception.DatabaseException;
import org.simantics.viewpoint.ontology.ViewpointResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* A visual contribution rule test that checks whether the input content is an
*/
public class InstanceOfTest implements Test {
+ private static final Logger LOGGER = LoggerFactory.getLogger(InstanceOfTest.class);
String bundleName;
String className;
Class<?> clazz;
return clazz;
Bundle b = Platform.getBundle(bundleName);
if (b == null) {
- System.err.println(getClass() + " could not resolve class " + className + ", bundle " + bundleName + " not found in platform");
+ LOGGER.error(getClass() + " could not resolve class " + className + ", bundle " + bundleName + " not found in platform");
failed = true;
return null;
}
this.clazz = b.loadClass(className);
return clazz;
} catch (ClassNotFoundException e) {
- System.err.println(getClass() + " could not resolve class " + className + ", from bundle " + bundleName);
+ LOGGER.error(getClass() + " could not resolve class " + className + ", from bundle " + bundleName, e);
failed = true;
return null;
}
org.simantics.databoard;bundle-version="0.6.5",
org.simantics.datatypes;bundle-version="1.0.0",
org.simantics.db;bundle-version="1.1.0",
- org.simantics.ui;bundle-version="1.0.0"
+ org.simantics.ui;bundle-version="1.0.0",
+ org.slf4j.api
Export-Package: org.simantics.g2d.canvas,
org.simantics.g2d.canvas.impl,
org.simantics.g2d.chassis,
import org.simantics.g2d.routing.IRouter2;
import org.simantics.g2d.routing.TrivialRouter2;
import org.simantics.scenegraph.utils.GeometryUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import gnu.trove.map.hash.THashMap;
*/
public class DiagramUtils {
+ private static final Logger LOGGER = LoggerFactory.getLogger(DiagramUtils.class);
/**
* Get rectangle that contains all elements or null if there are no elements.
* @param d
for (final IElement element : elementsToFix) {
if (!d.containsElement(element)) {
- System.err.println("Fixing element not contained by diagram " + d + ": " + element);
+ LOGGER.warn("Fixing element not contained by diagram " + d + ": " + element);
continue;
}
import org.simantics.utils.datastructures.hints.IHintObservable;
import org.simantics.utils.datastructures.hints.IHintContext.Key;
import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Paints terminals of elements.
*/
public class TerminalPainter extends AbstractDiagramParticipant {
+ private static final Logger LOGGER = LoggerFactory.getLogger(TerminalPainter.class);
public static final int PAINT_PRIORITY = ElementPainter.ELEMENT_PAINT_PRIORITY + 10;
public interface TerminalHoverStrategy {
AffineTransform invTx = util.getInverseTransform();
if (invTx == null) {
- System.err.println("NO CANVAS TRANSFORM INVERSE AVAILABLE, CANVAS TRANSFORM IS: " + util.getTransform());
+ LOGGER.warn("NO CANVAS TRANSFORM INVERSE AVAILABLE, CANVAS TRANSFORM IS: " + util.getTransform());
return;
}
import org.simantics.scenegraph.g2d.snap.ISnapAdvisor;
import org.simantics.utils.datastructures.context.IContext;
import org.simantics.utils.datastructures.context.IContextListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This participant paints an array of icons of a drag operation.
* @author Toni Kalajainen
*/
public class DragPainter extends AbstractCanvasParticipant {
+ private static final Logger LOGGER = LoggerFactory.getLogger(DragPainter.class);
// Priority of drag event, eats ecs key
public final static int DRAG_EVENT_PRIORITY = Integer.MAX_VALUE - 1500;
public final static int DRAG_PAINT_PRIORITY = Integer.MAX_VALUE - 1100;
IG2DNode itemHolder = node.getNode(""+item.hashCode());
if (itemHolder != null && !(itemHolder instanceof SingleElementNode)) {
- System.err.println("BUG: item hash codes collide within the dragged item context - found unrecognized item " + itemHolder + " with node id '" + item.hashCode() + "'");
+ LOGGER.error("BUG: item hash codes collide within the dragged item context - found unrecognized item " + itemHolder + " with node id '" + item.hashCode() + "'");
continue;
}
import org.simantics.utils.threads.ThreadUtils;
import org.simantics.utils.threads.logger.ITask;
import org.simantics.utils.threads.logger.ThreadLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Toni Kalajainen <toni.kalajainen@vtt.fi>
*/
public class GalleryViewer extends ContentViewer {
+ private static final Logger LOGGER = LoggerFactory.getLogger(GalleryViewer.class);
/**
* A hint key for storing a GalleryViewer within the hint stack of
* {@link GalleryViewer}'s {@link ICanvasContext}.
*/
void refreshElementSizes() {
if (awtComponent == null) {
- System.err.println("GalleryViewer.refreshElementSizes: awtComponent is null");
+ LOGGER.error("GalleryViewer.refreshElementSizes: awtComponent is null");
return;
}
double t_y = b1_y - s_x * a1_y - s_y * a1_x;
double mat[] = new double[] {s_x, s_y, -s_y, s_x, t_x, t_y};
- AffineTransform at = new AffineTransform(mat);
+ AffineTransform at = new AffineTransform(mat);
setDirty();
AffineTransform gat = util.getTransform();
import org.simantics.databoard.serialization.RuntimeSerializerConstructionException;
import org.simantics.databoard.serialization.Serializer;
import org.simantics.databoard.type.Datatype;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
final public class TransferableGraphFileReader extends ByteFileReader {
+ private static final Logger LOGGER = LoggerFactory.getLogger(TransferableGraphFileReader.class);
+
InputStream in = new InputStream() {
@Override
int pos = dst.position();
int limit = dst.limit();
int i=stream.read(dst.array(), pos, limit-pos);
- //System.err.println("Read " + i + " (expected " + dst.array().length + ")");
+ //LOGGER.warn("Read " + i + " (expected " + dst.array().length + ")");
return i;
}
int identities = safeInt();
Identity[] ids = new Identity[identities];
-// System.err.println("rc: " + resourceCount);
-// System.err.println("ids: " + identities);
+// LOGGER.warn("rc: " + resourceCount);
+// LOGGER.warn("ids: " + identities);
// long duration = System.nanoTime() - start;
-// System.err.println("start in " + 1e-9*duration + "s.");
+// LOGGER.warn("start in " + 1e-9*duration + "s.");
// start = System.nanoTime();
for(int i=0;i<identities;i++) {
}
-// for(Identity id : ids) System.err.println("id: " + id);
+// for(Identity id : ids) LOGGER.warn("id: " + id);
// duration = System.nanoTime() - start;
-// System.err.println("ids in " + 1e-9*duration + "s.");
+// LOGGER.warn("ids in " + 1e-9*duration + "s.");
// start = System.nanoTime();
int stmLength = safeInt();
-// System.err.println("statements: " + stmLength + " (" + byteIndex + ")");
+// LOGGER.warn("statements: " + stmLength + " (" + byteIndex + ")");
int[] statements = new int[stmLength];
}
// duration = System.nanoTime() - start;
-// System.err.println("stms in " + 1e-9*duration + "s.");
+// LOGGER.warn("stms in " + 1e-9*duration + "s.");
//
// start = System.nanoTime();
int valueLength = safeInt();
-// System.err.println("values: " + valueLength + " (" + byteIndex + ")");
+// LOGGER.warn("values: " + valueLength + " (" + byteIndex + ")");
Value[] values = new Value[valueLength];
.deserialize((DataInput)dis, idcontext);
values[i] = new Value(resource, value);
- //System.err.println("read variant[" + resource + "]: " + value.toString().substring(0, Math.min(100, value.toString().length())));
+ //LOGGER.warn("read variant[" + resource + "]: " + value.toString().substring(0, Math.min(100, value.toString().length())));
}
// duration = System.nanoTime() - start;
-// System.err.println("values in " + 1e-9*duration + "s.");
+// LOGGER.warn("values in " + 1e-9*duration + "s.");
return new TransferableGraph1(resourceCount, ids, statements, values, extensions.map);
long s = System.nanoTime();
reader.readTG();
long d = System.nanoTime() - s;
- System.err.println("Duration=" + 1e-9*d + "s.");
+ LOGGER.warn("Duration=" + 1e-9*d + "s.");
} catch (Throwable t) {
import org.simantics.layer0.Layer0;
import org.simantics.scl.runtime.function.Function2;
import org.simantics.simulation.ontology.SimulationResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class DependencyIssueSource2 implements IssueSource {
+ private static final Logger LOGGER = LoggerFactory.getLogger(DependencyIssueSource2.class);
public static final boolean DEBUG = false;
private Resource source;
HashSet<Resource> depSet = new HashSet<>();
if(DEBUG) {
- System.err.println("resourcesToCheck[" + NameUtils.getSafeName(graph, source) + "] - component changes for type " + NameUtils.getSafeName(graph, searchTypes));
+ LOGGER.info("resourcesToCheck[" + NameUtils.getSafeName(graph, source) + "] - component changes for type " + NameUtils.getSafeName(graph, searchTypes));
}
depSet.addAll(IssueSourceUtils.getChangedDependencies(graph, model, base, searchTypes, event));
List<Resource> deps = new ArrayList<>(depSet);
if(DEBUG) {
- System.err.println("resourcesToCheck[" + NameUtils.getSafeName(graph, source) + "] " + deps);
+ LOGGER.info("resourcesToCheck[" + NameUtils.getSafeName(graph, source) + "] " + deps);
for(Resource r : deps) {
- System.err.println("dep " + NameUtils.getSafeName(graph, r));
+ LOGGER.info("dep " + NameUtils.getSafeName(graph, r));
}
}
if(DEBUG) {
for(Resource r : deps) {
- System.err.println("dep extension " + NameUtils.getSafeName(graph, r));
+ LOGGER.info("dep extension " + NameUtils.getSafeName(graph, r));
}
}
import org.simantics.issues.common.DependencyIssueValidator2.DependencyIssueDescriptions;
import org.simantics.issues.ontology.IssueResource;
import org.simantics.layer0.Layer0;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class DependencyIssueSynchronizer2 extends WriteRequest {
+ private static final Logger LOGGER = LoggerFactory.getLogger(DependencyIssueSynchronizer2.class);
public static final boolean DEBUG = false;
private Resource resource;
@Override
public void perform(WriteGraph graph) throws DatabaseException {
- if(DEBUG) System.err.println("Running DependencySynchronizer for " + resource);
+ if(DEBUG) LOGGER.info("Running DependencySynchronizer for " + resource);
Set<Issue> existing = graph.syncRequest(new DependencyIssueDescriptions(source, resource), TransientCacheListener.<Set<Issue>>instance());
Set<Issue> contexts = Collections.emptySet();
try {
@SuppressWarnings("unchecked")
Set<Issue> contexts = new HashSet<Issue>((List<Issue>)Functions.exec(graph, function, graph, resource2));
- if(DEBUG) System.err.println("Validator found: " + contexts.size() + " issues (" + contexts + ")");
+ if(DEBUG) LOGGER.info("Validator found: " + contexts.size() + " issues (" + contexts + ")");
return contexts;
} catch (DatabaseException e) {
LOGGER.error("Reading a constraint validator failed", e);
@Override
public Boolean perform(ReadGraph graph) throws DatabaseException {
- if(DEBUG) System.err.println("Running DependencyValidator for " + NameUtils.getSafeName(graph, resource) + " " + NameUtils.getSafeName(graph, resource3));
+ if(DEBUG) LOGGER.info("Running DependencyValidator for " + NameUtils.getSafeName(graph, resource) + " " + NameUtils.getSafeName(graph, resource3));
Set<Issue> existing = graph.syncRequest(new DependencyIssueDescriptions(resource3, resource), TransientCacheListener.<Set<Issue>>instance());
- if(DEBUG) System.err.println("Existing: " + existing.size() + " issues (" + existing + ")");
+ if(DEBUG) LOGGER.info("Existing: " + existing.size() + " issues (" + existing + ")");
// Removed resources do not have issues
if(!graph.hasStatement(resource)) {
- if(DEBUG) System.err.println("No statements");
+ if(DEBUG) LOGGER.info("No statements");
return existing.isEmpty();
}
Set<Issue> contexts = graph.syncRequest(new Contexts(resource3, resource), TransientCacheListener.<Set<Issue>>instance());
- if(DEBUG) System.err.println("Current: " + contexts.size() + " issues (" + contexts + ")");
+ if(DEBUG) LOGGER.info("Current: " + contexts.size() + " issues (" + contexts + ")");
return existing.equals(contexts);
import org.simantics.db.service.ManagementSupport;
import org.simantics.db.service.VirtualGraphSupport;
import org.simantics.issues.ontology.IssueResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class IssueSourceUtils {
-
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(IssueSourceUtils.class);
public static final boolean DEBUG = false;
public static final boolean DEBUG_CHANGE_ENTRIES = false;
public static final boolean DEBUG_RESOURCES = false;
IssueResource ISSUE = IssueResource.getInstance(graph);
graph.claimLiteral(source, ISSUE.ContinuousIssueSource_lastUpdateRevision, headRevision, Bindings.LONG);
if(DEBUG)
- System.err.println("-update[" + NameUtils.getSafeName(graph, source) + "][" + headRevision + "]");
+ LOGGER.info("-update[" + NameUtils.getSafeName(graph, source) + "][" + headRevision + "]");
}
});
Collection<Resource> data = graph.syncRequest(new Test3(component, types), TransientCacheAsyncListener.<Collection<Resource>>instance());
if(DEBUG_RESOURCES) {
for(Resource r : data) {
- System.err.println("IssueSourceUtils.test " + " " + NameUtils.getSafeName(graph, component) + " " + NameUtils.getSafeName(graph, types) + " " + NameUtils.getSafeName(graph, r));
+ LOGGER.info("IssueSourceUtils.test " + " " + NameUtils.getSafeName(graph, component) + " " + NameUtils.getSafeName(graph, types) + " " + NameUtils.getSafeName(graph, r));
}
}
result.addAll(data);
public static void processChange(ReadGraph graph, Change c, ResourceSet types, Set<Resource> result) throws DatabaseException {
if(DEBUG_CHANGE_ENTRIES)
- System.err.println("-processChange: " + c.toString(graph));
+ LOGGER.info("-processChange: " + c.toString(graph));
if(c instanceof ComponentAddition) {
ComponentAddition addition = (ComponentAddition)c;
test(graph, addition.component, types, result);
if(revisionId == null) revisionId = 0L;
if(DEBUG)
- System.err.println("getChangedDependencies[" + NameUtils.getSafeName(graph, source) + "][" + revisionId + "]");
+ LOGGER.info("getChangedDependencies[" + NameUtils.getSafeName(graph, source) + "][" + revisionId + "]");
Map<Resource, Collection<Change>> index = MetadataUtils.getDependencyChangesFrom(graph, revisionId+1);
Require-Bundle: gnu.trove3;bundle-version="3.0.3",
org.simantics.layer0;bundle-version="1.0.0",
org.simantics.layer0.utils;bundle-version="0.8.0",
- org.simantics.db.layer0;bundle-version="1.1.0"
+ org.simantics.db.layer0;bundle-version="1.1.0",
+ org.slf4j.api
Export-Package: org.simantics.mapping,
org.simantics.mapping.constraint,
org.simantics.mapping.constraint.instructions,
*******************************************************************************/
package org.simantics.mapping.rule.instructions;
-import gnu.trove.map.hash.TIntIntHashMap;
-import gnu.trove.procedure.TIntProcedure;
-import gnu.trove.set.hash.TIntHashSet;
-
import org.simantics.db.ReadGraph;
import org.simantics.db.WriteGraph;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.request.Read;
import org.simantics.layer0.utils.triggers.IModification;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import gnu.trove.map.hash.TIntIntHashMap;
+import gnu.trove.procedure.TIntProcedure;
+import gnu.trove.set.hash.TIntHashSet;
public class QueryRuleInstruction implements IRuleInstruction {
+ private static final Logger LOGGER = LoggerFactory.getLogger(QueryRuleInstruction.class);
IRuleInstruction rule;
int[] variables;
int workSpace;
if(parameter != null)
result += parameter.hashCode();
else
- System.err.println("Parameter is null!!!");
+ LOGGER.error("Parameter is null!!!");
}
return result;
}
Bundle-Activator: org.simantics.message.internal.Activator
Bundle-Vendor: Semantum Oy
Require-Bundle: org.eclipse.core.runtime,
- org.simantics.db;bundle-version="[1.0.0,2.0.0)"
+ org.simantics.db;bundle-version="[1.0.0,2.0.0)",
+ org.slf4j.api
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: org.simantics.message,
import org.eclipse.core.runtime.dynamichelpers.IFilter;
import org.simantics.message.IMessageDataSchemeExtension;
import org.simantics.message.IMessageSchemeManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Tuukka Lehtonen
*/
public class MessageSchemeManager implements IExtensionChangeHandler, IMessageSchemeManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(MessageSchemeManager.class);
public final static String NAMESPACE = "org.simantics.message";
public final static String ELEMENT_NAME = "scheme";
public final static String EP_NAME = "messageDataScheme";
msg.append("\n 1st: " + ext.getSchemeElement().getContributor().getName());
msg.append("\n 2nd: " + el.getContributor().getName());
msg.append("\nUsing the first one.");
- // TODO: proper logging
- System.err.println(msg.toString());
+ LOGGER.info(msg.toString());
continue;
}
StringBuilder msg = new StringBuilder();
msg.append("No scheme extension for message scheme id '" + id + "'. Ignoring handler '" + el.getAttribute("handler") + "'");
msg.append("\nUsing the first one.");
- // TODO: proper logging
- System.err.println(msg.toString());
+ LOGGER.info(msg.toString());
continue;
}
msg.append("\n 1st: " + prev.getContributor().getName());
msg.append("\n 2nd: " + el.getContributor().getName());
msg.append("\nUsing the first one.");
- // TODO: proper logging
- System.err.println(msg.toString());
+ LOGGER.info(msg.toString());
continue;
}
import org.simantics.diagram.synchronization.runtime.DiagramSelectionUpdater;
import org.simantics.g2d.canvas.ICanvasContext;
import org.simantics.modeling.flags.MergeFlags;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Hannu Niemistö
*/
public class MergeFlagsHandler extends FlagOperationHandler {
+ private static final Logger LOGGER = LoggerFactory.getLogger(MergeFlagsHandler.class);
protected void perform(IProgressMonitor monitor, WriteGraph graph, List<Resource> flags, ICanvasContext canvasContext) throws DatabaseException {
monitor.beginTask("Merge Selected Flags", IProgressMonitor.UNKNOWN);
performMerge(graph, flags, canvasContext);
public static void performMerge(WriteGraph graph, List<Resource> flags, ICanvasContext canvasContext) throws DatabaseException {
final String text = MergeFlags.validateForMerge(graph, flags);
if(text != null) {
- System.err.println(text);
+ LOGGER.error(text);
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
else {
String result = MergeFlags.merge(graph, flags);
if(result != null && !result.isEmpty()) {
- System.err.println(result); // Should not happen because of prevalidation
+ LOGGER.error(result); // Should not happen because of prevalidation
} else {
if (canvasContext != null) {
// Make sure the diagram selection is set to the
import org.simantics.modeling.ui.modelBrowser.model.IUpdateable;
import org.simantics.ui.SimanticsUI;
import org.simantics.utils.datastructures.UnaryFunction;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Hannu Niemistö
public int category(ReadGraph graph) throws DatabaseException {
return ((INode) context.getConstant(BuiltinKeys.INPUT)).getCategory(graph);
}
+
+ @Override
+ public Logger getLogger() {
+ return LoggerFactory.getLogger(NodeLabelerFactory.class);
+ }
};
}
}
import org.simantics.modeling.internal.Activator;
import org.simantics.utils.FileUtils;
import org.simantics.utils.datastructures.Pair;
+import org.slf4j.LoggerFactory;
/**
* @author Antti Villberg
*/
public class CompilePGraphs {
+ private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(CompilePGraphs.class);
+
public static interface UserAgent {
void reportProblems(CompilationResult result);
}
if (name == null) name = id;
if (name.equals(thisOntology.first))
continue;
+ if (name.contains("ModelBroker"))
+ continue;
URL tg = b.getEntry("/graph.tg");
if (tg == null) continue;
File f = url2file(FileLocator.resolve(tg), b.getSymbolicName());
Logger.defaultLogError(e);
}
} else {
- System.err.println("Unsupported URL protocol '" + url + "' for FastLZ native library file '" + fileName);
+ LOGGER.warn("Unsupported URL protocol");
}
return null;
}
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.variable.RVI;
import org.simantics.db.layer0.variable.Variable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class PartialIC {
+ private static final Logger LOGGER = LoggerFactory.getLogger(PartialIC.class);
public static Binding BINDING = Bindings.getBindingUnchecked(PartialIC.class);
public RVI[] rvis = {};
// Variant variant = entry.getValue();
// Variable v = rvi.resolvePossible(graph, base);
// if(v != null) {
-//// System.err.println("apply " + v.getURI(graph) + " => " + variant);
+//// LOGGER.warn("apply " + v.getURI(graph) + " => " + variant);
// v.setValue(graph, variant.getValue(), variant.getBinding());
// } else {
-// System.err.println("failed to resolve " + rvi);
+// LOGGER.warn("failed to resolve " + rvi);
// }
// }
Variant variant = variants[i];
Variable v = rvi.resolvePossible(graph, base);
if (v != null) {
-// System.err.println("apply " + v.getURI(graph) + " => " + variant);
+// LOGGER.warn("apply " + v.getURI(graph) + " => " + variant);
v.setValue(graph, variant.getValue(), variant.getBinding());
} else {
- System.err.println("failed to resolve " + rvi);
+ LOGGER.warn("failed to resolve " + rvi);
}
}
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.compiler.types.kinds.Kinds;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class SCLTypeUtils {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SCLTypeUtils.class);
private static final THashMap<String, Type> TYPE_MAP = new THashMap<String, Type>();
private static void add(TCon type) {
public static Type getType(String typeText) {
Type type = TYPE_MAP.get(typeText);
if(type == null) {
- System.err.println("SCLTypeUtils.getType cannot transform '" + typeText + "' to type. Returns a as default.");
+ LOGGER.warn("SCLTypeUtils.getType cannot transform '" + typeText + "' to type. Returns a as default.");
return Types.var(Kinds.STAR);
}
return type;
else if(dataType instanceof ArrayType)
return Types.list(getType(((ArrayType)dataType).componentType));
else {
- System.err.println("SCLTypeUtils.getType cannot transform data type '" + dataType + "' to type. Returns a as default.");
+ LOGGER.warn("SCLTypeUtils.getType cannot transform data type '" + dataType + "' to type. Returns a as default.");
return Types.var(Kinds.STAR);
}
}
else if(propertyInfo.requiredDatatype != null)
return getType(propertyInfo.requiredDatatype);
else {
- System.err.println(propertyInfo.name + " doesn't have type information. Returns a as default.");
+ LOGGER.warn(propertyInfo.name + " doesn't have type information. Returns a as default.");
return Types.var(Kinds.STAR);
}
}
import org.simantics.utils.datastructures.Pair;
import org.simantics.utils.datastructures.Triple;
import org.simantics.utils.strings.AlphanumComparator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import gnu.trove.set.hash.THashSet;
*/
public class UserComponentMigration {
+ private static final Logger LOGGER = LoggerFactory.getLogger(UserComponentMigration.class);
+
public static void migrateUserComponents(WriteGraph graph, Resource source, Resource target, Collection<Resource> components) throws DatabaseException {
MigrateModel model = getComponentTypeModel(graph, source, target, null);
if (model.instances.isEmpty())
Resource type = graph.getPossibleType(instance, STR.Component);
String uri = graph.getPossibleURI(instance);
if (type == null || uri == null) {
- System.err.println("CANNOT MIGRATE INSTANCE DUE TO TYPING PROBLEM: " + NameUtils.getURIOrSafeNameInternal(graph, instance));
+ LOGGER.warn("CANNOT MIGRATE INSTANCE DUE TO TYPING PROBLEM: " + NameUtils.getURIOrSafeNameInternal(graph, instance));
continue;
}
NamedResource best = matchBest(graph, type, targetOntology);
import org.simantics.document.DocumentResource;
import org.simantics.layer0.Layer0;
import org.simantics.modeling.ModelingUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class DocumentCleanupMigrationStep implements MigrationStep {
+ private static final Logger LOGGER = LoggerFactory.getLogger(DocumentCleanupMigrationStep.class);
+
@Override
public void applyTo(IProgressMonitor monitor, Session session, MigrationState state) throws DatabaseException {
for(Resource model : graph.getObjects(indexRoot, L0.ConsistsOf)) {
for(Resource instance : ModelingUtils.searchByType(graph, model, DOC.ScenegraphDocument)) {
if(!graph.hasStatement(instance, DOC.HasDocumentation_Inverse)) {
- System.err.println("Removing stray document " + graph.getURI(instance));
+ LOGGER.info("Removing stray document " + graph.getURI(instance));
RemoverUtil.remove(graph, instance);
}
}
import org.simantics.structural2.modelingRules.IConnectionPoint;
import org.simantics.structural2.modelingRules.IModelingRules;
import org.simantics.structural2.modelingRules.Policy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class MappedModelingRules extends AbstractModelingRules {
+ private static final Logger LOGGER = LoggerFactory.getLogger(MappedModelingRules.class);
IModelingRules baseRules;
IMapping mapping;
ModelingResources MOD = ModelingResources.getInstance(g);
if(Policy.DEBUG_STANDARD_MODELING_RULES)
- System.out.println("setConnectionType(" + NameUtils.getSafeName(g, connection) + ", " + NameUtils.getSafeName(g, connectionType) + ")");
+ LOGGER.info("setConnectionType(" + NameUtils.getSafeName(g, connection) + ", " + NameUtils.getSafeName(g, connectionType) + ")");
RelatedDiagramConnections rdc = new RelatedDiagramConnections(g);
rdc.addConnection(connection);
if(cp == null)
throw new IllegalArgumentException("Null connection point encountered.");
if(Policy.DEBUG_STANDARD_MODELING_RULES)
- System.out.println("Mapping CP: " + cp.toString(g));
+ LOGGER.info("Mapping CP: " + cp.toString(g));
int mcps = mapping.mapToConnectionPoints(g, cp, mappedConnectionPoints);
if(mcps > 0) {
if(Policy.DEBUG_STANDARD_MODELING_RULES)
for (IConnectionPoint mcpt : mappedConnectionPoints.subList(mappedConnectionPoints.size()-mcps, mappedConnectionPoints.size()))
- System.out.println("Mapped CP: " + mcpt.toString(g));
+ LOGGER.info("Mapped CP: " + mcpt.toString(g));
} else {
if(cp instanceof CPTerminal) {
// TODO move this logic elsewhere
Resource connection) throws DatabaseException {
Resource mappedConnection = mapping.mapConnection(g, connection);
if(mappedConnection == null)
- System.err.println("Connection mapped from " + NameUtils.getSafeName(g, connection, true) + " is null");
+ LOGGER.warn("Connection mapped from " + NameUtils.getSafeName(g, connection, true) + " is null");
return new MappedAttachmentRelationMap(
baseRules.getAttachmentRelations(g, mappedConnection)
);
import org.simantics.db.Resource;
import org.simantics.db.exception.DatabaseException;
import org.simantics.diagram.stubs.DiagramResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class RouteGraphMatching {
+ private static final Logger LOGGER = LoggerFactory.getLogger(RouteGraphMatching.class);
public static boolean TRACE = false;
private static class Link {
}
for(int i=0;i<result.length;++i)
if(result[i] == null) {
- System.err.println("Didn't resolve resource " + i + ".");
+ LOGGER.warn("Didn't resolve resource " + i + ".");
printState();
return false;
}
}
private void printState() {
+ StringBuilder sb = new StringBuilder();
for(int i=0;i<result.length;++i) {
- System.out.print(" {" + i + "} ");
+ sb.append(" {" + i + "} ");
if(result[i] != null)
- System.out.print(" = " + result[i].getResourceId());
+ sb.append(" = " + result[i].getResourceId());
else if(alternatives[i] != null) {
- System.out.print(" in");
+ sb.append(" in");
for(Resource r : alternatives[i])
- System.out.print(" " + r.getResourceId());
+ sb.append(" " + r.getResourceId());
}
else
- System.out.print(" unknown");
+ sb.append(" unknown");
if(!ls[i].isEmpty()) {
- System.out.print(", links to");
+ sb.append(", links to");
for(Link l : ls[i])
- System.out.print(" " + (l.a==i ? l.b : l.a));
+ sb.append(" " + (l.a==i ? l.b : l.a));
}
- System.out.println();
+ sb.append('\n');
}
+ LOGGER.info(sb.toString());
}
private boolean propagate(int pos) throws DatabaseException {
import org.simantics.layer0.Layer0;
import org.simantics.scl.runtime.function.Function;
import org.simantics.scl.runtime.function.Function1;
-import org.simantics.scl.runtime.tuple.Tuple3;
import org.simantics.scl.runtime.tuple.Tuple4;
import org.simantics.structural.stubs.StructuralResource2;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import gnu.trove.set.hash.THashSet;
*/
public class CaseInsensitiveComponentFunctionNamingStrategy extends ComponentNamingStrategyBase {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CaseInsensitiveComponentFunctionNamingStrategy.class);
protected static final boolean DEBUG_INDEX_SEARCH = false | DEBUG_ALL;
@SuppressWarnings("rawtypes")
Set<Resource> rs = new THashSet<Resource>();
for (Resource componentResult : components) {
if (DEBUG_INDEX_SEARCH)
- System.out.println(getClass().getSimpleName() + ": found " + componentResult);
+ LOGGER.info(getClass().getSimpleName() + ": found " + componentResult);
String n = graph.getPossibleRelatedValue(componentResult, L0.HasName, Bindings.STRING);
if (n != null && n.toLowerCase().equals(lowercaseName))
rs.add(componentResult);
Layer0 L0 = Layer0.getInstance(graph);
for (Resource componentResult : components) {
if (DEBUG_INDEX_SEARCH)
- System.out.println(getClass().getSimpleName() + ": found " + componentResult);
+ LOGGER.info(getClass().getSimpleName() + ": found " + componentResult);
String name = graph.getPossibleRelatedValue(componentResult, L0.HasName, Bindings.STRING);
if (name != null)
reserved.add(name);
}
- System.err.println("found " + reserved.size() + " components");
+ LOGGER.warn("found " + reserved.size() + " components");
return reserved;
Resource componentType, String proposition, boolean acceptProposition) throws NamingException, DatabaseException {
Resource indexRoot = graph.syncRequest(new PossibleIndexRoot(configurationRoot));
if (indexRoot == null) {
- System.err.println("Could not find index root from configuration root '" + NameUtils.getSafeName(graph, configurationRoot, true) + "'");
+ LOGGER.warn("Could not find index root from configuration root '" + NameUtils.getSafeName(graph, configurationRoot, true) + "'");
if(fallbackStrategy == null)
fallbackStrategy =
new CaseInsensitiveComponentNamingStrategy2(graph.getService(GraphChangeListenerSupport.class), generatedNameFormat);
cache.addRequested(result);
if (DEBUG_INDEX_SEARCH)
- System.out.println(getClass().getSimpleName() + ": validated instance name " + result);
+ LOGGER.info(getClass().getSimpleName() + ": validated instance name " + result);
return result;
}
List<Resource> components = (List<Resource>) index.apply(graph, indexRoot, search, Integer.MAX_VALUE);
if (DEBUG_INDEX_SEARCH)
- System.out.println(getClass().getSimpleName() + ": found " + components.size()
+ LOGGER.info(getClass().getSimpleName() + ": found " + components.size()
+ " index results for index root " + indexRoot + " & configurationRoot " + configurationRoot
+ " & proposition '" + proposition + "':");
reserved.clear();
for (Resource componentResult : components) {
if (DEBUG_INDEX_SEARCH)
- System.out.println(getClass().getSimpleName() + ": found " + componentResult);
+ LOGGER.info(getClass().getSimpleName() + ": found " + componentResult);
String name = graph.getPossibleRelatedValue(componentResult, L0.HasName, Bindings.STRING);
if (name != null)
reserved.add(name);
result.add(name);
if (DEBUG_INDEX_SEARCH)
- System.out.println(getClass().getSimpleName() + ": validated instance name " + proposition + " -> " + name);
+ LOGGER.info(getClass().getSimpleName() + ": validated instance name " + proposition + " -> " + name);
}
if (DEBUG_INDEX_SEARCH)
- System.out.println(getClass().getSimpleName() + ": validated instance names " + propositions + " -> " + result);
+ LOGGER.info(getClass().getSimpleName() + ": validated instance names " + propositions + " -> " + result);
return result;
}
import org.simantics.structural.stubs.StructuralResource2;
import org.simantics.utils.datastructures.Pair;
import org.simantics.utils.ui.ErrorLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* A first-hand component naming strategy implementation for structural models.
*/
public class CaseInsensitiveComponentNamingStrategy extends ComponentNamingStrategyBase implements ChangeListener {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CaseInsensitiveComponentNamingStrategy.class);
private static final boolean DEBUG_ALL = false;
private static final boolean DEBUG_GRAPH_UPDATES = false | DEBUG_ALL;
private static final boolean DEBUG_CACHE_INITIALIZATION = false | DEBUG_ALL;
// Validate cache.
Set<Resource> existingEntries = getMapSet(s2r, newName);
if (!existingEntries.isEmpty()) {
- System.out.println("WARNING: Somebody is screwing the model up with duplicate name: " + newName);
+ LOGGER.warn("WARNING: Somebody is screwing the model up with duplicate name: " + newName);
// TODO: generate issue or message
}
if (existingEntries.contains(component))
continue;
- System.out.println("WARNING: Somebody is screwing the model up with duplicate name: " + newName);
+ LOGGER.warn("WARNING: Somebody is screwing the model up with duplicate name: " + newName);
// TODO: generate issue or message
}
if (components.size() > 1) {
// Found duplicate names in the model !!
// TODO: generate issue!
- System.err.println("WARNING: found multiple components with same name '" + componentName + "': " + components);
- System.err.println("TODO: generate issue");
+ LOGGER.warn("WARNING: found multiple components with same name '" + componentName + "': " + components);
+ LOGGER.warn("TODO: generate issue");
} else {
String prevName = r2s.putIfAbsent(component, componentName);
if (prevName == null)
}
private static void debug(Object obj, String string) {
- System.out.println("[" + obj.getClass().getSimpleName() + "(" + System.identityHashCode(obj) + ")] " + string);
+ LOGGER.info("[" + obj.getClass().getSimpleName() + "(" + System.identityHashCode(obj) + ")] " + string);
}
private static <K,V> Set<V> addToMapSet(ConcurrentMap<K, Set<V>> map, K key, V value) {
import org.simantics.structural.stubs.StructuralResource2;
import org.simantics.utils.datastructures.Pair;
import org.simantics.utils.ui.ErrorLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* A first-hand component naming strategy implementation for structural models.
*/
public class CaseInsensitiveComponentNamingStrategy2 extends ComponentNamingStrategyBase implements ChangeListener {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CaseInsensitiveComponentNamingStrategy2.class);
private static final boolean DEBUG_ALL = false;
private static final boolean DEBUG_GRAPH_UPDATES = false | DEBUG_ALL;
private static final boolean DEBUG_CACHE_INITIALIZATION = false | DEBUG_ALL;
if (components.size() > 1) {
// Found duplicate names in the model !!
// TODO: generate issue!
- System.err.println("WARNING: found multiple components with same name '" + componentName + "': " + components);
- System.err.println("TODO: generate issue");
+ LOGGER.warn("WARNING: found multiple components with same name '" + componentName + "': " + components);
+ LOGGER.warn("TODO: generate issue");
} else {
String prevName = r2s.putIfAbsent(component, componentName);
if (prevName == null)
import org.simantics.selectionview.SelectionViewResources;
import org.simantics.structural.stubs.StructuralResource2;
import org.simantics.structural2.utils.StructuralUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ComponentTypeCommands {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ComponentTypeCommands.class);
+
public static void applyCode(WriteGraph g, Resource componentType, String code) throws DatabaseException {
StructuralResource2 STR = StructuralResource2.getInstance(g);
g.claimLiteral(componentType, STR.ProceduralComponentType_code, code, Bindings.STRING);
Resource object = getAssertedObject(g, type, relation);
if(object == null) {
- System.err.println("Didn't find assertion for " + NameUtils.getSafeName(g, relation) +
+ LOGGER.warn("Didn't find assertion for " + NameUtils.getSafeName(g, relation) +
" in " + NameUtils.getSafeName(g, type) + ".");
return;
}
Resource object = getAssertedObject(g, type, relation);
if(object == null) {
- System.err.println("Didn't find assertion for " + NameUtils.getSafeName(g, relation) +
+ LOGGER.warn("Didn't find assertion for " + NameUtils.getSafeName(g, relation) +
" in " + NameUtils.getSafeName(g, type) + ".");
return;
}
public static void setUnit(WriteGraph graph, Resource type, Resource relation, String unit) throws DatabaseException {
Resource object = getAssertedObject(graph, type, relation);
if (object == null) {
- System.err.println("Didn't find assertion for " + NameUtils.getSafeName(graph, relation) +
+ LOGGER.warn("Didn't find assertion for " + NameUtils.getSafeName(graph, relation) +
" in " + NameUtils.getSafeName(graph, type) + ".");
return;
}
public static void setRange(WriteGraph graph, Resource type, Resource relation, String newRange) throws DatabaseException {
Resource object = getAssertedObject(graph, type, relation);
if (object == null) {
- System.err.println("Didn't find assertion for " + NameUtils.getSafeName(graph, relation) +
+ LOGGER.warn("Didn't find assertion for " + NameUtils.getSafeName(graph, relation) +
" in " + NameUtils.getSafeName(graph, type) + ".");
return;
}
Datatype newDatatype = TypeConversion.convertSCLTypeToDatatype(newSCLType);
if(newDatatype == null) {
- System.err.println("Couldn't convert default value to <" + newSCLType + ">.");
+ LOGGER.warn("Couldn't convert default value to <" + newSCLType + ">.");
return null;
}
Binding newBinding = Bindings.getBinding(newDatatype);
Resource type, Resource relation, String newSCLType) throws DatabaseException {
Resource object = getAssertedObject(g, type, relation);
if(object == null) {
- System.err.println("Didn't find assertion for " + NameUtils.getSafeName(g, relation) +
+ LOGGER.warn("Didn't find assertion for " + NameUtils.getSafeName(g, relation) +
" in " + NameUtils.getSafeName(g, type) + ".");
return;
}
LOGGER.error("Extraction to " + fileName + " failed from url " + url, e);
}
} else {
- System.err.println("Unsupported URL protocol '" + url + "' for FastLZ native library file '" + fileName);
+ LOGGER.error("Unsupported URL protocol '" + url + "' for FastLZ native library file '" + fileName);
}
return null;
}
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.simantics;bundle-version="1.0.0",
org.simantics.scenegraph;bundle-version="1.1.1";visibility:=reexport,
- org.simantics.scenegraph.ontology;bundle-version="1.0.0"
+ org.simantics.scenegraph.ontology;bundle-version="1.0.0",
+ org.slf4j.api
Export-Package: org.simantics.scenegraph.loader
import org.simantics.utils.datastructures.Pair;
import org.simantics.utils.threads.IThreadWorkQueue;
import org.simantics.utils.threads.ThreadUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ScenegraphLoaderUtils {
-
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ScenegraphLoaderUtils.class);
static Map<Pair<Variable, String>, Collection<Procedure<Object>>> externalMap = new HashMap<Pair<Variable, String>, Collection<Procedure<Object>>>();
static Map<Pair<Variable, String>, Object> externalValueMap = new HashMap<Pair<Variable, String>, Object>();
try {
return node.getClass().getField(propertyName);
} catch (SecurityException e) {
- e.printStackTrace();
+ LOGGER.error("node: " + node, e);
} catch (NoSuchFieldException e) {
- System.err.println("node:" + node);
- e.printStackTrace();
+ LOGGER.error("node: " + node, e);
}
return null;
}
package com.infomatiq.jsi;
import gnu.trove.TIntArrayList;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import gnu.trove.TFloatArrayList;
/**
* @version 1.0b8
*/
public class PriorityQueue {
+ private static final Logger LOGGER = LoggerFactory.getLogger(PriorityQueue.class);
public static final boolean SORT_ORDER_ASCENDING = true;
public static final boolean SORT_ORDER_DESCENDING = false;
if (leftIndex <= lastIndex) {
float leftPriority = priorities.get(leftIndex);
if (sortsEarlierThan(leftPriority, currentPriority)) {
- System.err.println("Internal error in PriorityQueue");
+ LOGGER.error("Internal error in PriorityQueue");
}
}
if (rightIndex <= lastIndex) {
float rightPriority = priorities.get(rightIndex);
if (sortsEarlierThan(rightPriority, currentPriority)) {
- System.err.println("Internal error in PriorityQueue");
+ LOGGER.error("Internal error in PriorityQueue");
}
}
}
import org.simantics.scl.runtime.function.Function1;
import org.simantics.scl.runtime.function.Function2;
import org.simantics.utils.threads.AWTThread;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
private static final long serialVersionUID = 8508750881358776559L;
+ private static final Logger LOGGER = LoggerFactory.getLogger(SVGNode.class);
protected String data = null;
protected String defaultData = null;
protected Point targetSize = null;
e.setAttribute(ass.attributeNameOrId, ass.value);
}
} else {
- System.err.println("Element with id='" + ass.elementId + " was not found.");
+ LOGGER.warn("Element with id='" + ass.elementId + " was not found.");
}
}
if (!data.equals(documentCache) || diagramCache == null) {
dataHash = parseSVG();
if (diagramCache == null) {
- System.err.println("UNABLE TO PARSE SVG:\n" + data);
+ LOGGER.warn("UNABLE TO PARSE SVG:\n" + data);
return;
}
}
import java.util.concurrent.ConcurrentHashMap;
import org.simantics.scenegraph.g2d.G2DNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Antti Villberg
*/
public abstract class GraphPropertyNode extends G2DNode {
+ private static final Logger LOGGER = LoggerFactory.getLogger(GraphPropertyNode.class);
private static final long serialVersionUID = 245761992671850588L;
private static Map<Class<? extends GraphPropertyNode>, Map<String, Field>> fieldCache = new ConcurrentHashMap<Class<? extends GraphPropertyNode>, Map<String, Field>>();
public void setProperty(String field, Object value) {
Field f = fields.get(field);
if (f == null) {
- System.err.println("GraphPropertyNode tried to set undefined property '" + field + "'");
+ LOGGER.warn("GraphPropertyNode tried to set undefined property '" + field + "'");
return;
}
try {
import java.awt.image.VolatileImage;
import java.util.concurrent.atomic.AtomicInteger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import com.kitfox.svg.SVGDiagram;
/**
*/
public class MipMapVRamBufferedImage extends MipMapBufferedImage {
+ private static final Logger LOGGER = LoggerFactory.getLogger(MipMapVRamBufferedImage.class);
/**
* @param original
* @param imageBounds
// Couldn't get image? This is not supposed to happen but happened anyway.
if (image == null) {
- System.err.println("BUG: VolatileImageProvider.get returned null!");
+ LOGGER.error("BUG: VolatileImageProvider.get returned null!");
return null;
}
import org.simantics.scl.runtime.function.FunctionImpl1;
import org.simantics.utils.datastructures.Pair;
import org.simantics.utils.threads.IThreadWorkQueue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Utilities for debugging/printing the contents of a scenegraph.
*/
public final class NodeUtil {
+ private static final Logger LOGGER = LoggerFactory.getLogger(NodeUtil.class);
/**
* @param <T>
*/
} else {
if(pc.length > 0) {
- System.err.println("Method " + setter.getName() + " expects " + pc[0].getCanonicalName() + " (got " + value.getClass().getCanonicalName() + ").");
+ LOGGER.warn("Method " + setter.getName() + " expects " + pc[0].getCanonicalName() + " (got " + value.getClass().getCanonicalName() + ").");
}
}
// Find node transform..
AffineTransform transform = getGlobalToLocalTransform(node, null);
if (transform == null) {
- System.err.println("WARNING: Non-invertible transform for node: " + node);
+ LOGGER.warn("WARNING: Non-invertible transform for node: " + node);
return event;
}
MouseEvent me = (MouseEvent)event;
if(DEBUG_BOUNDS) {
for(int i=0;i<indent;i++) System.err.print(" ");
- System.err.println("+getLocalBoundsImpl " + next + " => " + bl);
+ LOGGER.warn("+getLocalBoundsImpl " + next + " => " + bl);
}
if(bl != null) {
if(DEBUG_BOUNDS) {
for(int i=0;i<indent;i++) System.err.print(" ");
- System.err.println("=getLocalBoundsImpl " + node + " => " + bounds);
+ LOGGER.warn("=getLocalBoundsImpl " + node + " => " + bounds);
}
return bounds;
if(result != null) {
if(DEBUG_BOUNDS) {
for(int i=0;i<indent;i++) System.err.print(" ");
- System.err.println("=getLocalBoundsImpl " + node + " => " + result);
+ LOGGER.warn("=getLocalBoundsImpl " + node + " => " + result);
}
return result;
}
org.simantics.scl.osgi;bundle-version="1.0.4",
org.simantics.scl.compiler;bundle-version="0.4.0",
org.simantics.db.common;bundle-version="1.1.0",
- org.simantics;bundle-version="1.0.0"
+ org.simantics;bundle-version="1.0.0",
+ org.slf4j.api
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.runtime.function.Function;
import org.simantics.scl.runtime.function.Function2;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class CommandSerializerFactory {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CommandSerializerFactory.class);
@SuppressWarnings("unchecked")
public static CommandSerializer create(String name, Type[] parameterTypes) {
Function2<Resource,Object,String>[] stringConverters = new Function[parameterTypes.length];
try {
stringConverters[i] = StringConverterFactory.stringConverterFor(parameterTypes[i]);
} catch(SCLExpressionCompilationException e) {
- System.err.println("Failed to create a string converter for type " + parameterTypes[i] + ".");
- System.err.println(CompilationErrorFormatter.toString(e.getErrors()));
+ LOGGER.error("Failed to create a string converter for type " + parameterTypes[i] + ".");
+ LOGGER.error(CompilationErrorFormatter.toString(e.getErrors()), e);
return new ErrorSerializer(name);
} catch (ImportFailureException e) {
- System.err.println("Failed to create a string converter for type " + parameterTypes[i] + ".");
- System.err.println("Didn't find Simantics/GShow/gshow.");
+ LOGGER.error("Failed to create a string converter for type " + parameterTypes[i] + ".");
+ LOGGER.error("Didn't find Simantics/GShow/gshow.", e);
return new ErrorSerializer(name);
}
}
import org.simantics.db.Resource;
import org.simantics.db.WriteGraph;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ErrorSerializer implements CommandSerializer {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ErrorSerializer.class);
String name;
public ErrorSerializer(String name) {
@Override
public void serialize(WriteGraph graph, Resource context, Object[] parameters) {
- System.err.println("Failed to serialize command " + name + ".");
+ LOGGER.error("Failed to serialize command " + name + ".");
}
}
import org.simantics.scl.compiler.types.TVar;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public final class ValRef implements IVal {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ValRef.class);
public static final ValRef[] EMPTY_ARRAY = new ValRef[0];
Val binding;
try {
binding.occurrence = next;
} catch(NullPointerException e) {
- System.err.println("removeModiId = " + removeModiId);
- System.err.println("current ModiId = " + SSASimplificationContext.modiId);
+ LOGGER.error("removeModiId = " + removeModiId);
+ LOGGER.error("current ModiId = " + SSASimplificationContext.modiId, e);
throw new InternalCompilerError("The ValRef has already been removed.");
}
else
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.compiler.types.util.TypeUnparsingContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import gnu.trove.map.hash.TObjectIntHashMap;
import gnu.trove.procedure.TObjectIntProcedure;
public class SSAValidationContext {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SSAValidationContext.class);
+
public THashSet<BoundVar> validBoundVariables = new THashSet<BoundVar>();
public THashSet<Cont> validContinuations = new THashSet<Cont>();
public THashSet<TVar> validTypeVariables = new THashSet<TVar>();
public void assertEquals(Object loc, Type a, Type b) {
if(!Types.equals(a, b)) {
TypeUnparsingContext tuc = new TypeUnparsingContext();
- System.err.println(a.toString(tuc) + " != " + b.toString(tuc));
+ String message = a.toString(tuc) + " != " + b.toString(tuc);
+ LOGGER.error(message);
setErrorMarker(loc);
- throw new InternalCompilerError();
+ throw new InternalCompilerError(message);
}
}
public void assertEqualsEffect(Object loc, Type a, Type b) {
if(!Types.equalsEffect(a, b)) {
TypeUnparsingContext tuc = new TypeUnparsingContext();
- System.err.println(a.toString(tuc) + " != " + b.toString(tuc));
+ String message = a.toString(tuc) + " != " + b.toString(tuc);
+ LOGGER.error(message);
setErrorMarker(loc);
- throw new InternalCompilerError();
+ throw new InternalCompilerError(message);
}
}
int realCount = val.occurrenceCount();
if(realCount != count) {
- System.out.println(val + ": " + realCount + " != " + count);
- invalidReferenceCounts = true;
+ LOGGER.warn(val + ": " + realCount + " != " + count);
+ invalidReferenceCounts = true;
}
return true;
}
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.compiler.types.kinds.Kind;
import org.simantics.scl.compiler.types.kinds.Kinds;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import gnu.trove.map.hash.TObjectIntHashMap;
import gnu.trove.set.hash.TIntHashSet;
* This class represents an abstract syntax tree node for a type variable.
* The only property of a type variable is its name.
*/
-public class TVarAst extends TypeAst {
+public class TVarAst extends TypeAst {
+ private static final Logger LOGGER = LoggerFactory.getLogger(TVarAst.class);
public final String name;
public TVarAst(String name) {
if(name.charAt(i) != ',') {
con = context.resolveTypeConstructor(name.substring(1, name.length()-1));
if(con == null) {
- System.err.println("Didn't find type constructor " + name + ".");
+ LOGGER.warn("Didn't find type constructor " + name + ".");
return Types.metaVar(Kinds.STAR);
}
break block;
else {
con = context.resolveTypeConstructor(name);
if(con == null) {
- System.err.println("Didn't find type constructor " + name + ".");
+ LOGGER.warn("Didn't find type constructor " + name + ".");
return Types.metaVar(Kinds.STAR);
}
}
else {
Type con = context.resolveTypeConstructor(name);
if(con == null) {
- System.err.println("Didn't find effect constructor " + name + ".");
+ LOGGER.warn("Didn't find effect constructor " + name + ".");
return Types.metaVar(Kinds.EFFECT);
}
return con;
import org.simantics.scl.compiler.types.TVar;
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.compiler.types.util.TypeUnparsingContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import gnu.trove.map.hash.THashMap;
import gnu.trove.procedure.TObjectProcedure;
public class SCLDocumentationExtensionNodeHandler implements ExtensionNodeHandler {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SCLDocumentationExtensionNodeHandler.class);
final ModuleRepository moduleRepository;
final String documentationName;
if(name.isEmpty())
continue;
if(!documentedValues.add(name))
- System.err.println("Value '" + name + "' has already been documented in " + documentationName + ".");
+ LOGGER.warn("Value '" + name + "' has already been documented in " + documentationName + ".");
generateValueDocumentation(container, name);
}
return container;
if(name.isEmpty())
continue;
if(!documentedClasses.add(name))
- System.err.println("Class '" + name + "' has already been documented in " + documentationName + ".");
+ LOGGER.warn("Class '" + name + "' has already been documented in " + documentationName + ".");
generateClassDocumentation(container, name);
}
return container;
if(name.isEmpty())
continue;
if(!documentedTypeConstructors.add(name))
- System.err.println("Type constructor '" + name + "' has already been documented in " + documentationName + ".");
+ LOGGER.warn("Type constructor '" + name + "' has already been documented in " + documentationName + ".");
generateDataDocumentation(container, name);
}
return container;
if(relatedModule == null) {
relatedModule = moduleRepository.getModule(documentationName);
if(!relatedModule.didSucceed())
- System.err.println("Couldn't load the module " + documentationName);
+ LOGGER.warn("Couldn't load the module " + documentationName);
}
if(relatedModule.didSucceed())
return relatedModule.getResult();
fm = moduleRepository.getModule(moduleName);
moduleCache.put(moduleName, fm);
if(!fm.didSucceed())
- System.err.println("Couldn't load the module " + moduleName);
+ LOGGER.warn("Couldn't load the module " + moduleName);
}
if(fm.didSucceed())
return fm.getResult();
if(value == null) {
StringBuilder error = new StringBuilder();
error.append("Didn't find the value '" + name + "'.");
- System.err.println(error);
+ LOGGER.error(error.toString());
container.addChild(new CodeBlockNode(error));
return;
}
if(value.isPrivate())
- System.err.println("Documentation " + documentationName + " refers to a private value " + name + ".");
+ LOGGER.warn("Documentation " + documentationName + " refers to a private value " + name + ".");
StringBuilder signature = new StringBuilder();
signature.append("<div id=\"")
container.addChild(parser.parseDocument(value.documentation));
}
else
- System.out.println(name);
+ LOGGER.info(name);
container.addChild(new HtmlNode("</div></div>"));
}
if(typeClass == null) {
StringBuilder error = new StringBuilder();
error.append("Didn't find the type class '" + name + "'.");
- System.err.println(error);
+ LOGGER.error(error.toString());
container.addChild(new CodeBlockNode(error));
return;
}
container.addChild(parser.parseDocument(typeClass.documentation));
}
else
- System.out.println(name);
+ LOGGER.info(name);
for(String methodName : typeClass.methodNames) {
if(!documentedValues.add(methodName))
- System.err.println("Method '" + methodName + "' has already been documented in " + documentationName + ".");
+ LOGGER.warn("Method '" + methodName + "' has already been documented in " + documentationName + ".");
generateValueDocumentation(container, module, methodName, new TypeUnparsingContext(tuc));
}
container.addChild(new HtmlNode("</div></div>"));
container.addChild(parser.parseDocument(typeDescriptor.getDocumentation()));
}
else
- System.out.println(name);
+ LOGGER.info(name);
if(typeDescriptor instanceof TypeConstructor) {
for(Constructor constructor : ((TypeConstructor)typeDescriptor).constructors) {
if(!documentedValues.add(constructor.name.name))
- System.err.println("Method '" + constructor.name.name + "' has already been documented in " + documentationName + ".");
+ LOGGER.warn("Method '" + constructor.name.name + "' has already been documented in " + documentationName + ".");
generateValueDocumentation(container, module, constructor.name.name, new TypeUnparsingContext(tuc));
}
}
import org.simantics.scl.compiler.parser.generator.grammar.AnaGrammar;
import org.simantics.scl.compiler.parser.generator.grammar.Prod;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import gnu.trove.list.array.TIntArrayList;
import gnu.trove.list.array.TLongArrayList;
import gnu.trove.set.hash.TLongHashSet;
public class ParseTableBuilder {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParseTableBuilder.class);
public final static int MAX_STACK_ID = 10;
private static final int STATE_MASK = 0x0fff;
//System.out.println(newState + " " + grammar.getName(a) + " " + stackOp);
if(stackOverflow) {
- System.err.println("Stack overflow when following " + grammar.getName(a) + " at");
- System.err.println(itemSet.toString(grammar));
+ LOGGER.error("Stack overflow when following " + grammar.getName(a) + " at");
+ LOGGER.error(itemSet.toString(grammar));
}
else {
int state = getState(a, b);
trans.put(symbol, REDUCE_MASK | production | (stackPos << 13));
}
else {
- System.err.println("Shift/reduce conflict when encountering " + grammar.terminalNames[symbol] + " in context");
- System.err.println(itemSets.get(i).toString(grammar));
+ LOGGER.error("Shift/reduce conflict when encountering " + grammar.terminalNames[symbol] + " in context");
+ LOGGER.error(itemSets.get(i).toString(grammar));
}
}
else {
- System.err.println("Reduce/reduce conflict when encountering " + grammar.terminalNames[symbol] + " in context");
- System.err.println(itemSets.get(i).toString(grammar));
+ LOGGER.error("Reduce/reduce conflict when encountering " + grammar.terminalNames[symbol] + " in context");
+ LOGGER.error(itemSets.get(i).toString(grammar));
}
}
else
builder.createReduceActions();
- System.out.println("States: " + builder.itemSets.size());
+ LOGGER.info("States: " + builder.itemSets.size());
//builder.visualize();
}
});
for(int i=0;i<stateSets.length;++i) {
- System.out.println("--- State " + i + " ---");
- System.out.println(stateSets[i].toString(grammar));
+ LOGGER.info("--- State " + i + " ---");
+ LOGGER.info(stateSets[i].toString(grammar));
final TIntIntHashMap stackOp = stackOps.get(i);
transitions.get(i).forEachEntry(new TIntIntProcedure() {
@Override
public boolean execute(int a, int b) {
int sOp = stackOp.get(a);
- System.out.print(grammar.getName(a) + " -> ");
+ LOGGER.info(grammar.getName(a) + " -> ");
if(sOp != 0) {
- System.out.print("[");
+ LOGGER.info("[");
if((sOp & PUSH_MASK) != 0) {
sOp ^= PUSH_MASK;
- System.out.print("PUSH ");
+ LOGGER.info("PUSH ");
}
if((sOp & POP_MASK) != 0) {
sOp ^= POP_MASK;
- System.out.print("POP ");
+ LOGGER.info("POP ");
}
if(sOp != 0)
- System.out.print(sOp);
- System.out.print("] ");
+ LOGGER.info(Integer.toString(sOp));
+ LOGGER.info("] ");
}
if((b & REDUCE_MASK) != 0) {
b ^= REDUCE_MASK;
- System.out.println("reduce " + b); // grammar.prods.get(~b).toString(grammar));
+ LOGGER.info("reduce " + b); // grammar.prods.get(~b).toString(grammar));
}
else {
- System.out.println("shift " + b);
+ LOGGER.info("shift " + b);
}
return true;
}
package org.simantics.scl.compiler.parser.grammar;
import org.simantics.scl.compiler.parser.regexp.Namer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class Grammar implements Namer {
+ private static final Logger LOGGER = LoggerFactory.getLogger(Grammar.class);
public final Production[] productions;
public final String[] terminalNames;
public final String[] nonterminalNames;
++prodCount[~prod.lhs];
for(int i=0;i<nonterminalNames.length;++i)
if(prodCount[i]==0)
- System.err.println("Nonterminal " + nonterminalNames[i] + " does not have productions.");
+ LOGGER.error("Nonterminal " + nonterminalNames[i] + " does not have productions.");
}
}
org.simantics.scl.runtime;bundle-version="0.1.4",
gnu.trove3;bundle-version="3.0.0",
org.eclipse.core.runtime;bundle-version="3.6.0",
- org.junit;bundle-version="4.12.0";resolution:=optional
+ org.junit;bundle-version="4.12.0";resolution:=optional,
+ org.slf4j.api
Export-Package: org.simantics.scl.reflection,
org.simantics.scl.reflection.annotations,
org.simantics.scl.reflection.functions
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class Activator implements BundleActivator {
+ private static final Logger LOGGER = LoggerFactory.getLogger(Activator.class);
private BundleContext context;
private static Activator instance;
}
public static void logError(String description, Exception e) {
- System.err.println(description);
+ LOGGER.error(description);
if(e != null)
e.printStackTrace();
Bundle bundle = getInstance().getContext().getBundle();
import org.simantics.scl.runtime.SCLContext;
import org.simantics.scl.runtime.function.Function;
import org.simantics.scl.runtime.tuple.Tuple0;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Static methods for calling the currently active {@link SCLReportingHandler}.
*/
public class SCLReporting {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SCLReporting.class);
+
public static void print(String text) {
SCLReportingHandler handler = ((SCLReportingHandler)SCLContext.getCurrent().get(SCLReportingHandler.REPORTING_HANDLER));
if(handler != null)
if(handler != null)
handler.printError(text);
else
- System.err.println(text);
+ LOGGER.error(text);
}
public static void didWork(double amount) {
@Override
public void printError(String error) {
- System.err.println(error);
+ LOGGER.error(error);
}
};
@Override
public void printError(String error) {
- System.err.println(error);
+ LOGGER.error(error);
}
@Override
org.junit;bundle-version="4.12.0";resolution:=optional,
com.ibm.icu,
org.slf4j.api,
- org.eclipse.search;bundle-version="3.11.100"
+ org.eclipse.search;bundle-version="3.11.100",
+ org.eclipse.ui.views
Export-Package: org.simantics.scl.ui.console,
org.simantics.scl.ui.editor,
org.simantics.scl.ui.editor2,
searchResultClass="org.simantics.scl.ui.search.SCLSearchResult">
</viewPage>
</extension>
-
</plugin>
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.simantics.scl.runtime.tuple.Tuple2;
+import org.slf4j.Logger;
/**
* A console with input and output area that can be embedded
range.start = 0;
range.length = 1;
input.setStyleRange(range);
- System.err.println("The following error message didn't have a proper location:");
- System.err.println(annotation.description);
+ getLogger().error("The following error message didn't have a proper location: {}", annotation.description, e);
}
}
}
}
}
+ public abstract Logger getLogger();
}
import org.simantics.scl.ui.Activator;
import org.simantics.scl.ui.assist.SCLContentProposalProvider;
import org.simantics.scl.ui.assist.StyledTextContentAdapter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import gnu.trove.set.hash.THashSet;
}
}.open();
}
+
+ @Override
+ public Logger getLogger() {
+ return LoggerFactory.getLogger(getClass());
+ }
+
}
--- /dev/null
+package org.simantics.scl.ui.outline;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.part.Page;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+import org.simantics.scl.ui.editor2.SCLModuleEditor2;
+
+public class SCLModuleOutlinePage extends Page implements IContentOutlinePage {
+
+ private SCLOutlineViewer outlineViewer;
+ private SCLModuleEditor2 moduleEditor;
+
+ public SCLModuleOutlinePage(SCLModuleEditor2 moduleEditor) {
+ this.moduleEditor = moduleEditor;
+ }
+
+ @Override
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ if (outlineViewer != null)
+ outlineViewer.addSelectionChangedListener(listener);
+ }
+
+ @Override
+ public ISelection getSelection() {
+ if (outlineViewer != null)
+ outlineViewer.getSelection();
+ return StructuredSelection.EMPTY;
+ }
+
+ @Override
+ public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ if (outlineViewer != null)
+ outlineViewer.removeSelectionChangedListener(listener);
+ }
+
+ @Override
+ public void setSelection(ISelection selection) {
+ if (outlineViewer != null)
+ outlineViewer.setSelection(selection);
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ Tree tree = new Tree(parent, SWT.MULTI);
+ outlineViewer = new SCLOutlineViewer(tree);
+
+ SCLModuleOutlineProvider provider = new SCLModuleOutlineProvider();
+ outlineViewer.setContentProvider(provider);
+ outlineViewer.setLabelProvider(provider);
+
+ outlineViewer.setInput(moduleEditor.getEditorInput());
+ }
+
+ @Override
+ public Control getControl() {
+ if (outlineViewer != null)
+ outlineViewer.getControl();
+ return null;
+ }
+
+ @Override
+ public void setFocus() {
+ if (outlineViewer != null)
+ outlineViewer.getControl().setFocus();
+ }
+
+ protected class SCLOutlineViewer extends TreeViewer {
+
+ public SCLOutlineViewer(Tree tree) {
+ super(tree);
+ setAutoExpandLevel(ALL_LEVELS);
+ setUseHashlookup(true);
+ }
+
+
+ }
+
+ protected class SCLModuleOutlineProvider implements ITreeContentProvider, ILabelProvider {
+
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return null;
+ }
+
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ return null;
+ }
+
+ @Override
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ @Override
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+
+ @Override
+ public void addListener(ILabelProviderListener listener) {
+
+ }
+
+ @Override
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ @Override
+ public void removeListener(ILabelProviderListener listener) {
+
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ return null;
+ }
+
+ @Override
+ public String getText(Object element) {
+ return null;
+ }
+
+ @Override
+ public void dispose() {
+ ITreeContentProvider.super.dispose();
+ }
+
+ }
+}
import org.simantics.spreadsheet.graph.synchronization.SheetLineComponent;
import org.simantics.structural.synchronization.base.ReferenceResolverBase;
import org.simantics.structural.synchronization.base.Solver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class SpreadsheetReferenceResolver extends ReferenceResolverBase<SheetLineComponent> {
throw new IllegalStateException();
}
+ @Override
+ public Logger getLogger() {
+ return LoggerFactory.getLogger(getClass());
+ }
}
import org.simantics.spreadsheet.graph.SpreadsheetBook;
import org.simantics.spreadsheet.graph.SpreadsheetReferenceResolver;
import org.simantics.structural.synchronization.base.SynchronizationEventHandlerBase;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class SpreadsheetSynchronizationEventHandler extends SynchronizationEventHandlerBase<SheetLineComponent> {
public SpreadsheetSynchronizationEventHandler(ReadGraph graph, SpreadsheetBook book) {
super(book, new SpreadsheetReferenceResolver(book), book, book, book, book.getMapping());
}
-
+
+ @Override
+ public Logger getLogger() {
+ return LoggerFactory.getLogger(getClass());
+ }
+
}
org.simantics;bundle-version="1.0.0",
org.simantics.simulation;bundle-version="1.1.0",
org.simantics.datatypes.ontology;bundle-version="1.1.0",
- org.simantics.structural.synchronization;bundle-version="1.0.0";visibility:=reexport
+ org.simantics.structural.synchronization;bundle-version="1.0.0";visibility:=reexport,
+ org.slf4j.api
Export-Package: org.simantics.structural.synchronization,
org.simantics.structural.synchronization.base
import org.simantics.databoard.util.URIStringUtils;
import org.simantics.structural.synchronization.protocol.SynchronizationEventHandler;
+import org.slf4j.Logger;
abstract public class ReferenceResolverBase<T extends ComponentBase<T>> {
String message = "Couldn't resolve " + connectionPoint +
", because child " + segment + " does not exist.";
if(eventHandler == null)
- System.err.println(message);
+ getLogger().warn(message);
else
eventHandler.reportProblem(message);
return;
}
});
Collections.sort(pending);
- System.out.println("Still pending:");
+ getLogger().info("Still pending:");
for(String p : pending)
- System.out.println(" " + p);
+ getLogger().info(" " + p);
}
}
public void resolvePendingSelfReferences() {
// Can be customized in subclasses
}
-
+
+ public abstract Logger getLogger();
}
import org.simantics.structural.synchronization.protocol.SerializedVariable;
import org.simantics.structural.synchronization.protocol.SynchronizationEventHandler;
import org.simantics.structural.synchronization.protocol.SynchronizationException;
+import org.slf4j.Logger;
import gnu.trove.map.hash.THashMap;
import gnu.trove.set.hash.THashSet;
}
public void reportProblem(String description) {
- System.err.println(description);
+ getLogger().error(description);
}
public void reportProblem(String description, Exception e) {
- System.err.println(description);
- e.printStackTrace();
+ getLogger().error(description, e);
}
public void addPostSynchronizationAction(Runnable action) {
public long getFromRevision() {
return mapping.currentRevision;
}
+
+ public abstract Logger getLogger();
}
org.simantics.structural.synchronization.utils
Require-Bundle: org.simantics.databoard;bundle-version="0.6.5",
org.eclipse.core.runtime;bundle-version="3.7.0",
- gnu.trove3;bundle-version="3.0.3"
+ gnu.trove3;bundle-version="3.0.3",
+ org.slf4j.api
import org.simantics.structural.synchronization.protocol.SerializedVariable;
import org.simantics.structural.synchronization.protocol.SynchronizationEventHandler;
import org.simantics.structural.synchronization.protocol.SynchronizationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class DiagnosticSynchronizationEventHandler implements SynchronizationEventHandler {
+ private static final Logger LOGGER = LoggerFactory.getLogger(DiagnosticSynchronizationEventHandler.class);
int indentation;
@Override
Collection<SerializedVariable> properties,
Collection<Connection> connections, Collection<ChildInfo> children)
throws SynchronizationException {
+ StringBuilder indent = new StringBuilder();
for(int i=0;i<indentation;++i)
- System.out.print(" ");
- System.out.print(name);
+ indent.append(" ");
+ indent.append(name);
if(typeId != null)
- System.out.print(" :: " + typeId);
- System.out.println();
+ indent.append(" :: " + typeId);
+ LOGGER.info(indent.toString());
for(SerializedVariable var : properties) {
+ indent = new StringBuilder();
for(int i=0;i<=indentation;++i)
- System.out.print(" ");
- System.out.println(SerializedVariable.print(var, indentation*2+2));
+ indent.append(" ");
+ indent.append(SerializedVariable.print(var, indentation*2+2));
+ LOGGER.info(indent.toString());
}
for(Connection connection : connections) {
+ indent = new StringBuilder();
for(int i=0;i<=indentation;++i)
- System.out.print(" ");
- System.out.println(connection);
+ indent.append(" ");
+ indent.append(connection);
+ LOGGER.info(indent.toString());
}
if(!children.isEmpty()) {
+ indent = new StringBuilder();
for(int i=0;i<=indentation;++i)
- System.out.print(" ");
- System.out.print("Children ");
+ indent.append(" ");
+ indent.append("Children ");
if(children != null)
- System.out.println(children);
+ indent.append(children);
+ LOGGER.info(indent.toString());
}
++indentation;
}
@Override
public void beginType(String id, Collection<SerializedVariable> properties) {
- System.out.println("--- Type " + id + " --------------------------------");
+ LOGGER.info("--- Type " + id + " --------------------------------");
for(SerializedVariable var : properties)
- System.out.println(SerializedVariable.print(var, 2));
+ LOGGER.info(SerializedVariable.print(var, 2));
}
@Override
public void endType() {
- System.out.println("----------------------------------------------------");
+ LOGGER.info("----------------------------------------------------");
}
@Override
public void reportProblem(String description) {
- System.err.println(description);
+ LOGGER.error(description);
}
@Override
public void reportProblem(String description, Exception e) {
- System.err.println(description);
- e.printStackTrace();
+ LOGGER.error(description, e);
}
}
import org.simantics.structural2.procedural.Property;
import org.simantics.structural2.procedural.Terminal;
import org.simantics.utils.datastructures.Pair;
+import org.slf4j.LoggerFactory;
public class StandardProceduralChildVariable extends AbstractChildVariable {
+ private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(StandardProceduralChildVariable.class);
/*
* Extension points
*
result.add(desc.getVariable(graph));
}
else
- System.err.println("no cp " + cp.first + " for " + component.getURI(graph));
+ LOGGER.warn("no cp " + cp.first + " for " + component.getURI(graph));
}
return result;
result.add(desc.getURI(graph));
}
else
- System.err.println("no cp " + cp.first + " for " + component.getURI(graph));
+ LOGGER.warn("no cp " + cp.first + " for " + component.getURI(graph));
}
return result;
if(cp2 != null)
result.addAll(ConnectionBrowser.flatten(graph, component, cp.second, relationType));
else
- System.err.println("no cp " + cp.first + " for " + component.getURI(graph));
+ LOGGER.warn("no cp " + cp.first + " for " + component.getURI(graph));
}
return result;
org.simantics.databoard;bundle-version="0.6.2",
org.simantics.history;bundle-version="1.0.0",
org.simantics.simulation;bundle-version="1.1.0";resolution:=optional,
- com.lowagie.text;bundle-version="2.1.5";resolution:=optional
+ com.lowagie.text;bundle-version="2.1.5";resolution:=optional,
+ org.slf4j.api
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.simantics.trend,
import org.simantics.trend.configuration.TrendItem.DrawMode;
import org.simantics.trend.configuration.TrendItem.Renderer;
import org.simantics.trend.util.KvikDeviationBuilder;
+import org.slf4j.LoggerFactory;
/**
* Data node for a TrendItem
public class ItemNode extends G2DNode implements TrendLayout {
private static final long serialVersionUID = -4741446944761752871L;
-
+ private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ItemNode.class);
+
public static final AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .61f);
public TrendItem item;
s.accessor.get(i, s.sampleBinding, vb.getSample());
if(!validSample(vb)) {
- System.err.println("-invalid value band: " + i + "/" + count + ":" + vb);
+ LOGGER.warn("-invalid value band: " + i + "/" + count + ":" + vb);
continue;
}
// Non-continuation point
import org.simantics.db.layer0.util.SessionGarbageCollection;
import org.simantics.db.service.LifecycleSupport;
import org.simantics.utils.ui.ErrorLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Tuukka Lehtonen
*/
public class SessionGarbageCollectorJob extends Job {
+ private static final Logger LOGGER = LoggerFactory.getLogger(SessionGarbageCollectorJob.class);
private static SessionGarbageCollectorJob instance;
public synchronized static SessionGarbageCollectorJob getInstance() {
if (TRACE) {
if (!enabled) {
long t = System.currentTimeMillis();
- System.out.println("GC disabled, not running @ " + ((double) (t - start) * 1e-3) + " seconds");
+ LOGGER.info("GC disabled, not running @ " + ((double) (t - start) * 1e-3) + " seconds");
}
}
return enabled;
long begin = System.currentTimeMillis();
if (TRACE) {
- System.out.println("running GC @ " + ((double) (begin - start) * 1e-3) + " seconds");
+ LOGGER.info("running GC @ " + ((double) (begin - start) * 1e-3) + " seconds");
}
boolean busy = SessionGarbageCollection.gc(monitor, session, true, errorCallback);
if (TRACE)
if(busy)
- System.err.println("Session GC ended busy. New quiet time is " + quietTime);
+ LOGGER.info("Session GC ended busy. New quiet time is " + quietTime);
// This quiet time might have been adjusted in GC
interval = quietTime;
if (TRACE) {
//long end = System.currentTimeMillis();
//System.out.println("Session.GC " + (intermediate - begin) + "ms, System.GC " + (end-intermediate) + "ms, total " + (end - begin) + "ms");
- System.out.println("Session.GC " + (intermediate - begin) + "ms");
+ LOGGER.info("Session.GC " + (intermediate - begin) + "ms");
}
// Reschedule after a quiet period.
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Tuukka Lehtonen
*/
public class WorkbenchShutdownServiceImpl implements WorkbenchShutdownService {
+ private static final Logger LOGGER = LoggerFactory.getLogger(WorkbenchShutdownServiceImpl.class);
private static ServiceRegistration service = null;
private final List<Runnable> hooks = new ArrayList<Runnable>();
}
protected void handleException(Object source, Throwable t) {
- System.err.println(getClass().getSimpleName() + ": workbench shutdown hook " + source + " caused unexpected exception:");
- t.printStackTrace();
+ LOGGER.error(getClass().getSimpleName() + ": workbench shutdown hook " + source + " caused unexpected exception:", t);
}
}
org.simantics.utils.threads.logger
Bundle-Vendor: VTT Technical Research Centre of Finland
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Require-Bundle: org.slf4j.api
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* Utility for switching threads
*
*/
public class ThreadUtils {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ThreadUtils.class);
public static final int CORES = Runtime.getRuntime().availableProcessors();
/**
if (!pool.awaitTermination(timeoutMs, TimeUnit.MILLISECONDS)) {
List<Runnable> leftovers = pool.shutdownNow(); // Cancel currently executing tasks
if (!leftovers.isEmpty())
- System.err.println("Thread pool '" + pool.toString() + "' contained " + leftovers.size() + " tasks at forced shutdown: " + leftovers);
+ LOGGER.warn("Thread pool '" + pool.toString() + "' contained " + leftovers.size() + " tasks at forced shutdown: " + leftovers);
// Wait a while for tasks to respond to being cancelled
if (!pool.awaitTermination(timeoutMs, TimeUnit.MILLISECONDS))
- System.err.println("Thread pool '" + pool.toString() + "' did not terminate");
+ LOGGER.warn("Thread pool '" + pool.toString() + "' did not terminate");
}
} catch (InterruptedException ie) {
// (Re-)Cancel if current thread also interrupted
org.simantics.utils,
org.simantics.utils.datastructures,
org.eclipse.ui;bundle-version="3.7.0",
- org.eclipse.core.expressions
+ org.eclipse.core.expressions,
+ org.slf4j.api
Export-Package: org.simantics.utils.ui,
org.simantics.utils.ui.action,
org.simantics.utils.ui.awt,
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Composite;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This is a TrackedTest SWT Text-widget 'decorator'.
* @author Tuukka Lehtonen
*/
public class TrackedStyledText {
+ private static final Logger LOGGER = LoggerFactory.getLogger(TrackedStyledText.class);
private static final int EDITING = 1 << 0;
private static final int MODIFIED_DURING_EDITING = 1 << 1;
}
private void applyEdit() {
- System.err.println("apply edit");
+ LOGGER.info("apply edit");
try {
if (isTextValid() != null) {
text.setText(textBeforeEdit);
}
private void endEdit() {
- System.err.println("endedit");
+ LOGGER.info("endedit");
if (!isEditing()) {
// Print some debug incase we end are in an invalid state
//ExceptionUtils.logError(new Exception("BUG: endEdit called when not in editing state"));
if (!isEditing()) {
// Print some debug incase we end are in an invalid state
//ExceptionUtils.logError(new Exception("BUG: revertEdit called when not in editing state"));
- System.out.println("BUG: revertEdit called when not in editing state");
+ LOGGER.warn("BUG: revertEdit called when not in editing state");
}
text.setText(textBeforeEdit);
text.setSelection(caretPositionBeforeEdit);
import org.simantics.databoard.binding.Binding;
import org.simantics.databoard.binding.error.BindingException;
import org.simantics.databoard.binding.mutable.Variant;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class Development {
+ private static final Logger LOGGER = LoggerFactory.getLogger(Development.class);
public static TreeMap<String,Integer> histogram = new TreeMap<String,Integer>();
public static final boolean DEVELOPMENT = false;
@Override
public void handle(Object event) {
if((Boolean) getProperty(PRINT, Bindings.BOOLEAN))
- System.err.println(event.toString());
+ LOGGER.info(event.toString());
}
});
String key = o.toString();
Integer i = Development.histogram.get(key);
if(i == null) i = 0;
- Development.histogram.put(key, i+1);
+ int newValue = i+1;
+ if (newValue == 1000) {
+ newValue = newValue;
+ }
+ Development.histogram.put(key, newValue);
}
}
ch.qos.logback.classic;bundle-version="1.1.7",
ch.qos.logback.core;bundle-version="1.1.7",
org.apache.commons.collections;bundle-version="3.2.2",
- org.eclipse.equinox.ds;bundle-version="1.4.300"
+ org.eclipse.equinox.ds;bundle-version="1.4.300",
+ org.slf4j.api
import org.simantics.scl.compiler.top.SCLExpressionCompilationException;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class MemoryLeakExperiment {
+ private static final Logger LOGGER = LoggerFactory.getLogger(MemoryLeakExperiment.class);
ModuleRepository moduleRepository;
EnvironmentSpecification environmentSpecification;
getClass().getClassLoader());
} catch(ImportFailureException e) {
for(ImportFailure failure : e.failures)
- System.err.println("Failed to import " + failure.moduleName);
+ LOGGER.warn("Failed to import " + failure.moduleName);
throw e;
}
if(expectedValue != null)
Assert.assertEquals(expectedValue, result);
} catch(SCLExpressionCompilationException e) {
- System.out.println(CompilationErrorFormatter.toString(expressionText, e.getErrors()));
+ LOGGER.error(CompilationErrorFormatter.toString(expressionText, e.getErrors()));
throw e;
}
}
System.gc();
Thread.sleep(100L);
double used = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory());
- System.out.println(i + " " + used*1e-6 + " Mb, " + (used / i) + " b / expression");
+ LOGGER.info(i + " " + used*1e-6 + " Mb, " + (used / i) + " b / expression");
}
}
}
import org.junit.Test;
import org.simantics.scl.compiler.commands.CommandSession;
import org.simantics.scl.compiler.errors.CompilationError;
-import org.simantics.scl.compiler.errors.CompilationErrorFormatter;
import org.simantics.scl.compiler.module.repository.ModuleRepository;
import org.simantics.scl.runtime.reporting.AbstractSCLReportingHandler;
import org.simantics.scl.runtime.reporting.SCLReportingHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class TestCommandSession {
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestCommandSession.class);
ModuleRepository moduleRepository;
@Before
private static final SCLReportingHandler TEST_HANDLER = new AbstractSCLReportingHandler() {
@Override
public void print(String text) {
- System.out.println(text);
+ LOGGER.info(text);
}
public void printError(String error) {
- System.err.println(error);
+ LOGGER.error(error);
throw new SCLErrorMessageException(error);
}
};
import org.simantics.scl.compiler.module.repository.ImportFailureException;
import org.simantics.scl.compiler.module.repository.ModuleRepository;
import org.simantics.scl.compiler.runtime.RuntimeEnvironment;
-import org.simantics.scl.compiler.source.repository.CompositeModuleSourceRepository;
-import org.simantics.scl.compiler.source.repository.SourceRepositories;
import org.simantics.scl.compiler.top.ExpressionEvaluator;
import org.simantics.scl.compiler.top.SCLExpressionCompilationException;
import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.runtime.function.Function;
import org.simantics.scl.runtime.tuple.Tuple0;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class TestExpressionEvaluator {
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestExpressionEvaluator.class);
public static final boolean TIMING = false;
public static final int COUNT = 10000;
getClass().getClassLoader());
} catch(ImportFailureException e) {
for(ImportFailure failure : e.failures)
- System.err.println("Failed to import " + failure.moduleName);
+ LOGGER.warn("Failed to import " + failure.moduleName);
throw e;
}
}
if(expectedValue != null)
Assert.assertEquals(expectedValue, result);
} catch(SCLExpressionCompilationException e) {
- System.out.println(CompilationErrorFormatter.toString(expressionText, e.getErrors()));
+ LOGGER.error(CompilationErrorFormatter.toString(expressionText, e.getErrors()));
throw e;
}
}
Object expectedValue,
Type expectedType) throws Exception {
if(TIMING) {
- System.out.println(expressionText);
+ LOGGER.info(expressionText);
long beginTime = System.nanoTime();
for(int i=0;i<COUNT;++i)
testExpression0(expressionText, expectedValue, expectedType);
long endTime = System.nanoTime();
- System.out.println( " " + (endTime-beginTime)*1e-6/COUNT + " ms");
+ LOGGER.info( " " + (endTime-beginTime)*1e-6/COUNT + " ms");
}
else
testExpression0(expressionText, expectedValue, expectedType);
Double.valueOf(15.0),
((Function)result).apply(7.0, 8.0));
} catch(SCLExpressionCompilationException e) {
- System.out.println(CompilationErrorFormatter.toString(expressionText, e.getErrors()));
+ LOGGER.error(CompilationErrorFormatter.toString(expressionText, e.getErrors()));
throw e;
}
}