X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.ui%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fui%2Fconsole%2FPreferences.java;h=6b733146b8105254571afebaa7d232d6da0c316d;hp=e1529af28e040a9c736fd7ad0eeed4512fc8c755;hb=501ad95ad5ca980ef4c6e65af1451a0d7b63cddc;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/Preferences.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/Preferences.java index e1529af28..6b733146b 100644 --- a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/Preferences.java +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/Preferences.java @@ -1,51 +1,84 @@ -package org.simantics.scl.ui.console; - -import java.util.Collection; -import java.util.Deque; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Set; -import java.util.TreeSet; - -/** - * @author Antti Villberg - */ -public final class Preferences { - - public static final String COMMAND_HISTORY = "COMMAND_HISTORY"; - - private static final String DELIMITER = "¤¤¤¤"; - - public static String join(Collection s, String delimiter) { - if (s == null || s.isEmpty()) return ""; - Iterator iter = s.iterator(); - StringBuilder builder = new StringBuilder(iter.next()); - while( iter.hasNext() ) - { - builder.append(delimiter).append(iter.next()); - } - return builder.toString(); - } - - public static Deque decodePaths(String recentPathsPref) { - Deque result = new LinkedList(); - for(String s : recentPathsPref.split(DELIMITER)) result.add(s); - return result; - } - - public static String encodePaths(Collection recentPaths) { - return join(recentPaths, DELIMITER); - } - - public static void removeDuplicates(Iterable iter) { - // Remove duplicates - Set dups = new TreeSet(String.CASE_INSENSITIVE_ORDER); - for (Iterator it = iter.iterator(); it.hasNext();) { - String path = it.next(); - if (!dups.add(path)) { - it.remove(); - } - } - } - -} +package org.simantics.scl.ui.console; + +import java.util.Collection; +import java.util.Deque; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Set; +import java.util.TreeSet; + +/** + * @author Antti Villberg + */ +public final class Preferences { + + /** + * Console buffer high and low water marks + */ + public static final String CONSOLE_LIMIT_CONSOLE_OUTPUT = "SCLConsole.limitConsoleOutput"; //$NON-NLS-1$ + + public static final String CONSOLE_LOW_WATER_MARK = "SCLConsole.lowWaterMark"; //$NON-NLS-1$ + + public static final String CONSOLE_HIGH_WATER_MARK = "SCLConsole.highWaterMark"; //$NON-NLS-1$ + + /** + * By default console output buffer size is limited. + */ + public static final boolean CONSOLE_LIMIT_CONSOLE_OUTPUT_DEFAULT = true; + + /** + * The console low water mark default value {@value #CONSOLE_LOW_WATER_MARK_DEFAULT_VALUE}. + */ + public static final int CONSOLE_LOW_WATER_MARK_DEFAULT_VALUE = 5000000; + + /** + * The console low water mark default value {@value #CONSOLE_HIGH_WATER_MARK_DEFAULT_VALUE}. + */ + public static final int CONSOLE_HIGH_WATER_MARK_DEFAULT_VALUE = highWatermarkForLow(CONSOLE_LOW_WATER_MARK_DEFAULT_VALUE); + + /** + * The console low water mark maximum value {@value #CONSOLE_LOW_WATER_MARK_MAX_VALUE}. + */ + public static final int CONSOLE_LOW_WATER_MARK_MAX_VALUE = 10000000; + + public static int highWatermarkForLow(int low) { + return low + 80*100; + } + + public static final String COMMAND_HISTORY = "COMMAND_HISTORY"; //$NON-NLS-1$ + + private static final String DELIMITER = "¤¤¤¤"; //$NON-NLS-1$ + + public static String join(Collection s, String delimiter) { + if (s == null || s.isEmpty()) return ""; //$NON-NLS-1$ + Iterator iter = s.iterator(); + StringBuilder builder = new StringBuilder(iter.next()); + while( iter.hasNext() ) + { + builder.append(delimiter).append(iter.next()); + } + return builder.toString(); + } + + public static Deque decodePaths(String recentPathsPref) { + Deque result = new LinkedList(); + for(String s : recentPathsPref.split(DELIMITER)) result.add(s); + return result; + } + + public static String encodePaths(Collection recentPaths) { + return join(recentPaths, DELIMITER); + } + + public static void removeDuplicates(Iterable iter) { + // Remove duplicates + Set dups = new TreeSet(String.CASE_INSENSITIVE_ORDER); + for (Iterator it = iter.iterator(); it.hasNext();) { + String path = it.next(); + if (!dups.add(path)) { + it.remove(); + } + } + } + +}