- Timestamp:
- 01/07/14 10:59:52 (10 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 7 added
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Misc.java
r645 r655 1160 1160 if(!FreeItems.textOnlyAttachedToCursor()) { 1161 1161 text = DisplayIO.getCurrentFrame().addText(FrameMouseActions.getX(), FrameMouseActions.getY(), 1162 NetworkSettings. homePage, null);1162 NetworkSettings.HomePage.get(), null); 1163 1163 text.setParent(DisplayIO.getCurrentFrame()); // set parent of text source for InteractiveWidget.createWidget() 1164 1164 FrameMouseActions.pickup(text); // Attach new text link to cursor … … 1372 1372 */ 1373 1373 public static void resetHomeFrame() { 1374 Frame homeFrame = FrameIO.LoadFrame(UserSettings.HomeFrame );1374 Frame homeFrame = FrameIO.LoadFrame(UserSettings.HomeFrame.get()); 1375 1375 homeFrame.removeAllItems(homeFrame.getItems()); 1376 1376 homeFrame.addText(0, 0, "title", null); 1377 FrameUtils.CreateDefaultProfile(UserSettings.UserName , homeFrame);1377 FrameUtils.CreateDefaultProfile(UserSettings.UserName.get(), homeFrame); 1378 1378 } 1379 1379 … … 1398 1398 // If no text with url is passed to action create a new text item 1399 1399 if(!FreeItems.textOnlyAttachedToCursor()) { 1400 url = NetworkSettings. homePage; // use home page specified by settings1400 url = NetworkSettings.HomePage.get(); // use home page specified by settings 1401 1401 text = DisplayIO.getCurrentFrame().addText(FrameMouseActions.getX(), FrameMouseActions.getY(), 1402 1402 "Web Browser Session", null); -
trunk/src/org/expeditee/actions/Navigation.java
r570 r655 42 42 */ 43 43 public static void GotoHome() { 44 FrameUtils.DisplayFrame(UserSettings.HomeFrame );44 FrameUtils.DisplayFrame(UserSettings.HomeFrame.get()); 45 45 } 46 46 … … 54 54 */ 55 55 public static void GotoProfile() { 56 FrameUtils.DisplayFrame(UserSettings.ProfileName + '1');56 FrameUtils.DisplayFrame(UserSettings.ProfileName.get() + '1'); 57 57 } 58 58 -
trunk/src/org/expeditee/actions/Spelling.java
r570 r655 28 28 } 29 29 if (path == null) { 30 for (String possiblePath : UserSettings.FrameDirs ) {30 for (String possiblePath : UserSettings.FrameDirs.get()) { 31 31 fullPath = FrameIO 32 32 .getFrameFullPathName(possiblePath, frameName); -
trunk/src/org/expeditee/agents/SearchTree.java
r570 r655 70 70 71 71 String fullPath = null; 72 for (String possiblePath : UserSettings.FrameDirs ) {72 for (String possiblePath : UserSettings.FrameDirs.get()) { 73 73 fullPath = FrameIO.getFrameFullPathName(possiblePath, frameName); 74 74 if (fullPath != null) -
trunk/src/org/expeditee/agents/SearchTreeNoResults.java
r570 r655 53 53 54 54 String fullPath = null; 55 for (String possiblePath : UserSettings.FrameDirs ) {55 for (String possiblePath : UserSettings.FrameDirs.get()) { 56 56 fullPath = FrameIO.getFrameFullPathName(possiblePath, frameName); 57 57 if (fullPath != null) -
trunk/src/org/expeditee/gui/Browser.java
r618 r655 151 151 private Browser() { 152 152 // Use the default values initially so we can load the profile frame 153 setSizes(new Dimension(UserSettings.InitialWidth ,154 UserSettings.InitialHeight ));153 setSizes(new Dimension(UserSettings.InitialWidth.get(), 154 UserSettings.InitialHeight.get())); 155 155 // center the frame on the screen 156 156 Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); 157 157 double xpos = screen.getWidth() / 2; 158 158 double ypos = screen.getHeight() / 2; 159 setLocation((int) (xpos - (UserSettings.InitialWidth / 2)),160 (int) (ypos - (UserSettings.InitialHeight / 2)));159 setLocation((int) (xpos - (UserSettings.InitialWidth.get() / 2)), 160 (int) (ypos - (UserSettings.InitialHeight.get() / 2))); 161 161 162 162 addWindowListener(this); … … 182 182 } 183 183 184 UserSettings.ProfileName = FrameIO.ConvertToValidFramesetName(System 185 .getProperty("user.name")); 186 String userName = UserSettings.ProfileName; 187 UserSettings.UserName = UserSettings.ProfileName; 184 // UserSettings.ProfileName.set(FrameIO.ConvertToValidFramesetName(System.getProperty("user.name"))); 185 String userName = UserSettings.ProfileName.get(); 186 //UserSettings.UserName.set(UserSettings.ProfileName.get()); 188 187 189 188 Frame profile = loadProfile(userName); … … 226 225 // Reset windows to user specified size 227 226 // Must be done after initialising the content pane above! 228 setSizes(new Dimension(UserSettings.InitialWidth ,229 UserSettings.InitialHeight ));227 setSizes(new Dimension(UserSettings.InitialWidth.get(), 228 UserSettings.InitialHeight.get())); 230 229 231 230 /* -
trunk/src/org/expeditee/gui/DisplayIO.java
r570 r655 791 791 if (_VisitedFrames[opposite].size() == 0) { 792 792 FrameIO.SuspendCache(); 793 setCurrentFrame(FrameIO.LoadFrame(UserSettings.HomeFrame ), true);793 setCurrentFrame(FrameIO.LoadFrame(UserSettings.HomeFrame.get()), true); 794 794 FrameIO.ResumeCache(); 795 795 } else { -
trunk/src/org/expeditee/gui/Frame.java
r602 r655 135 135 private Collection<Item> _vectorItems = new LinkedHashSet<Item>(); 136 136 137 private Text _dotTemplate = UserSettings.DotTemplate. copy();137 private Text _dotTemplate = UserSettings.DotTemplate.get().copy(); 138 138 139 139 /** … … 421 421 422 422 if (frameTitle == null) { 423 if (UserSettings.TitleTemplate == null) {423 if (UserSettings.TitleTemplate.get() == null) { 424 424 frameTitle = new Text(getNextItemID(), title); 425 425 /* … … 430 430 frameTitle.resetTitlePosition(); 431 431 } else { 432 frameTitle = UserSettings.TitleTemplate. copy();432 frameTitle = UserSettings.TitleTemplate.get().copy(); 433 433 frameTitle.setID(this.getNextItemID()); 434 434 frameTitle.setText(title); 435 frameTitle.resetTitlePosition(); 435 436 } 436 437 addItem(frameTitle); … … 464 465 List<Item> items = getVisibleItems(); 465 466 for (Item i : items) { 466 if (i instanceof Text && i.getX() < UserSettings.TitlePosition 467 && i.getY() < UserSettings.TitlePosition )467 if (i instanceof Text && i.getX() < UserSettings.TitlePosition.get() 468 && i.getY() < UserSettings.TitlePosition.get()) 468 469 return (Text) i; 469 470 } … … 485 486 486 487 public Text getItemTemplate() { 487 return getTemplate(UserSettings.ItemTemplate ,488 return getTemplate(UserSettings.ItemTemplate.get(), 488 489 ItemUtils.TAG_ITEM_TEMPLATE); 489 490 } 490 491 491 492 public Text getAnnotationTemplate() { 492 Text t = getTemplate(UserSettings.AnnotationTemplate ,493 Text t = getTemplate(UserSettings.AnnotationTemplate.get(), 493 494 ItemUtils.TAG_ANNOTATION_TEMPLATE); 494 495 … … 502 503 public Text getStatTemplate() { 503 504 SessionStats.CreatedText(); 504 Text t = getTemplate(UserSettings.StatTemplate ,505 Text t = getTemplate(UserSettings.StatTemplate.get(), 505 506 ItemUtils.TAG_STAT_TEMPLATE); 506 507 … … 533 534 534 535 public Text getCodeCommentTemplate() { 535 Text t = getTemplate(UserSettings.CodeCommentTemplate ,536 Text t = getTemplate(UserSettings.CodeCommentTemplate.get(), 536 537 ItemUtils.TAG_CODE_COMMENT_TEMPLATE); 537 538 -
trunk/src/org/expeditee/gui/FrameCreator.java
r427 r655 7 7 import org.expeditee.items.Text; 8 8 9 /** 10 * TODO: merge with @see org.expeditee.settings.Settings.generateSettingsTree 11 */ 9 12 public class FrameCreator { 10 13 public static final int INDENT_FROM_TITLE = 20; -
trunk/src/org/expeditee/gui/FrameGraphics.java
r616 r655 339 339 // Nicer looking lines, but may be too jerky while 340 340 // rubber-banding on older machines 341 if (UserSettings.AntiAlias )341 if (UserSettings.AntiAlias.get()) 342 342 bg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 343 343 RenderingHints.VALUE_ANTIALIAS_ON); -
trunk/src/org/expeditee/gui/FrameIO.java
r614 r655 215 215 } else { 216 216 217 for (String path : UserSettings.FrameDirs ) {217 for (String path : UserSettings.FrameDirs.get()) { 218 218 loaded = LoadKnowPath(path, framename); 219 219 if (loaded != null) { … … 243 243 StringBuffer list = new StringBuffer(); 244 244 245 for (String path : UserSettings.FrameDirs ) {245 for (String path : UserSettings.FrameDirs.get()) { 246 246 File files = new File(path); 247 247 if (!files.exists()) … … 305 305 } 306 306 307 for (String path : UserSettings.FrameDirs ) {307 for (String path : UserSettings.FrameDirs.get()) { 308 308 if (getFrameFullPathName(path, frameName) != null) 309 309 return true; … … 316 316 String fullPath = null; 317 317 if (path == null) { 318 for (String possiblePath : UserSettings.FrameDirs ) {318 for (String possiblePath : UserSettings.FrameDirs.get()) { 319 319 fullPath = getFrameFullPathName(possiblePath, frameName); 320 320 if (fullPath != null) … … 666 666 + template.getName() + " from TDFC"); 667 667 668 template.setOwner(UserSettings.UserName );668 template.setOwner(UserSettings.UserName.get()); 669 669 template.reset(); 670 670 template.resetDateCreated(); … … 1242 1242 public static Boolean canAccessFrameset(String framesetName) { 1243 1243 framesetName = framesetName.toLowerCase(); 1244 for (String path : UserSettings.FrameDirs ) {1244 for (String path : UserSettings.FrameDirs.get()) { 1245 1245 if ((new File(path + framesetName)).exists()) 1246 1246 return true; … … 1300 1300 Frame base = null; 1301 1301 try { 1302 base = LoadFrame(UserSettings.DefaultFrame );1302 base = LoadFrame(UserSettings.DefaultFrame.get()); 1303 1303 } catch (Exception e) { 1304 1304 } … … 1318 1318 base.setPath(path); 1319 1319 base.change(); 1320 base.setOwner(UserSettings.UserName );1320 base.setOwner(UserSettings.UserName.get()); 1321 1321 SaveFrame(base, false); 1322 1322 … … 1326 1326 base.setTitle(frameset); 1327 1327 base.change(); 1328 base.setOwner(UserSettings.UserName );1328 base.setOwner(UserSettings.UserName.get()); 1329 1329 SaveFrame(base, true); 1330 1330 … … 1379 1379 1380 1380 // Search all the available directories for the directory 1381 for (String path : UserSettings.FrameDirs ) {1381 for (String path : UserSettings.FrameDirs.get()) { 1382 1382 String source = path + framesetName.toLowerCase() + File.separator; 1383 1383 File framesetDirectory = new File(source); … … 1419 1419 // search through all the directories to find the frameset we are 1420 1420 // copying 1421 for (String path : UserSettings.FrameDirs ) {1421 for (String path : UserSettings.FrameDirs.get()) { 1422 1422 String source = path + framesetToCopy.toLowerCase() 1423 1423 + File.separator; … … 1576 1576 public static void setSavedProperties(Frame toSave) { 1577 1577 toSave.setLastModifyDate(Formatter.getDateTime()); 1578 toSave.setLastModifyUser(UserSettings.UserName );1578 toSave.setLastModifyUser(UserSettings.UserName.get()); 1579 1579 toSave.setVersion(toSave.getVersion() + 1); 1580 1580 Time darkTime = new Time(SessionStats.getFrameDarkTime().getTime() -
trunk/src/org/expeditee/gui/FrameKeyboardActions.java
r626 r655 1042 1042 case SizeDown: 1043 1043 if (isControlDown) { 1044 UserSettings.ScaleFactor -= 0.05;1044 UserSettings.ScaleFactor.set(UserSettings.ScaleFactor.get() - 0.05f); 1045 1045 Misc.repaint(); 1046 1046 return; … … 1048 1048 case SizeUp: 1049 1049 if (isControlDown) { 1050 UserSettings.ScaleFactor += 0.05;1050 UserSettings.ScaleFactor.set(UserSettings.ScaleFactor.get() + 0.05f); 1051 1051 Misc.repaint(); 1052 1052 return; -
trunk/src/org/expeditee/gui/FrameMouseActions.java
r637 r655 250 250 } 251 251 252 if(ExperimentalFeatures.MousePan ) {252 if(ExperimentalFeatures.MousePan.get()) { 253 253 // don't pan if we're not over the frame 254 254 _overFrame = FrameUtils.getCurrentItem() == null; … … 522 522 if(!_isPanOp) { 523 523 MessageBay.displayMessage("Action cancelled, mouse moved more than " 524 + UserSettings.NoOpThreshold + " pixels.");524 + UserSettings.NoOpThreshold.get() + " pixels."); 525 525 } 526 526 FrameGraphics.Repaint(); … … 1690 1690 1691 1691 // panning the frame when dragging the mouse while shift-leftclicking 1692 if(ExperimentalFeatures.MousePan && _overFrame && e.isShiftDown() &&1692 if(ExperimentalFeatures.MousePan.get() && _overFrame && e.isShiftDown() && 1693 1693 (e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0 && 1694 1694 (_isPanOp || (Math.max(Math.abs(panStartX - e.getX()), Math.abs(panStartY - e.getY())) > 5))) { … … 1713 1713 - _lastRanged.getBoundsHeight(); 1714 1714 1715 if (distance > UserSettings.NoOpThreshold ) {1715 if (distance > UserSettings.NoOpThreshold.get()) { 1716 1716 _lastRanged.clearSelectionEnd(); 1717 1717 _isNoOp = true; … … 1783 1783 // Use the below calculation for better speed. If it causes problems 1784 1784 // switch back to the Euclidean distance calculation 1785 if (Math.abs(MouseX - e.getX()) > UserSettings.NoOpThreshold 1786 || Math.abs(MouseY - e.getY()) > UserSettings.NoOpThreshold )1785 if (Math.abs(MouseX - e.getX()) > UserSettings.NoOpThreshold.get() 1786 || Math.abs(MouseY - e.getY()) > UserSettings.NoOpThreshold.get()) 1787 1787 _isNoOp = true; 1788 1788 -
trunk/src/org/expeditee/gui/FrameUtils.java
r618 r655 67 67 public static int MINIMUM_INTERITEM_SPACING = -6; 68 68 69 public static Double MAXIMUM_SPACING_RATIO = null;70 71 public static Double MINIMUM_SPACING_RATIO = null;72 73 69 public static float getResponseTimeTotal() { 74 70 return _ResponseTimeSum; … … 241 237 space = MINIMUM_INTERITEM_SPACING; 242 238 243 if ( MAXIMUM_SPACING_RATIO!= null) {244 double maxSpace = MAXIMUM_SPACING_RATIO* above.getSize();239 if (UserSettings.FormatSpacingMax.get() != null) { 240 double maxSpace = UserSettings.FormatSpacingMax.get() * above.getSize(); 245 241 if (maxSpace < space) { 246 242 space = (int) Math.round(maxSpace); … … 248 244 } 249 245 250 if ( MINIMUM_SPACING_RATIO!= null) {251 double minSpace = MINIMUM_SPACING_RATIO* above.getSize();246 if (UserSettings.FormatSpacingMin.get() != null) { 247 double minSpace = UserSettings.FormatSpacingMin.get() * above.getSize(); 252 248 if (minSpace > space) { 253 249 space = (int) Math.round(minSpace); … … 594 590 DisplayIO.setCursor(Item.DEFAULT_CURSOR); 595 591 596 UserSettings.TitleTemplate = profile.getTitleItem();592 UserSettings.TitleTemplate.set(profile.getTitleItem()); 597 593 598 594 // check for settings tags … … 632 628 */ 633 629 public static void loadFirstFrame(Frame profile) { 634 if (UserSettings.HomeFrame == null)635 UserSettings.HomeFrame = profile.getName();636 637 Frame firstFrame = FrameIO.LoadFrame(UserSettings.HomeFrame );630 if (UserSettings.HomeFrame.get() == null) 631 UserSettings.HomeFrame.set(profile.getName()); 632 633 Frame firstFrame = FrameIO.LoadFrame(UserSettings.HomeFrame.get()); 638 634 if (firstFrame == null) { 639 635 MessageBay.warningMessage("Home frame not found: " 640 636 + UserSettings.HomeFrame); 641 UserSettings.HomeFrame = profile.getName();637 UserSettings.HomeFrame.set(profile.getName()); 642 638 DisplayIO.setCurrentFrame(profile, true); 643 639 } else { … … 647 643 } 648 644 649 public static Color[] getColorWheel(Item item) { 650 Frame child = item.getChild(); 651 if (child != null) { 652 List<Text> textItems = child.getBodyTextItems(false); 645 public static Color[] getColorWheel(Frame frame) { 646 if (frame != null) { 647 List<Text> textItems = frame.getBodyTextItems(false); 653 648 Color[] colorList = new Color[textItems.size() + 1]; 654 649 for (int i = 0; i < textItems.size(); i++) { … … 670 665 assert (avp != null); 671 666 672 if (avp.hasPair() ) {667 if (avp.hasPair() && avp.getValue().trim().length() != 0) { 673 668 item.setLink(avp.getValue()); 674 669 return avp.getValue(); -
trunk/src/org/expeditee/io/AbstractHTMLWriter.java
r570 r655 48 48 49 49 // Go through all the styles 50 List<Text> style = UserSettings.Style ;50 List<Text> style = UserSettings.Style.get(); 51 51 52 52 writeStyleInfo(_writer, "P", style.get(0)); -
trunk/src/org/expeditee/io/PDF2Writer.java
r570 r655 49 49 _pdfDocument.open(); 50 50 _pdfDocument.addCreationDate(); 51 _pdfDocument.addAuthor(UserSettings.UserName );51 _pdfDocument.addAuthor(UserSettings.UserName.get()); 52 52 _pdfDocument.addCreator("Expeditee"); 53 53 } catch (DocumentException e) { -
trunk/src/org/expeditee/io/PDFWriter.java
r570 r655 33 33 34 34 public PDFWriter() { 35 assert(UserSettings.Style != null);36 if (UserSettings.Style. size() > 0) {37 Text text = UserSettings.Style.get( 0);35 assert(UserSettings.Style.get() != null); 36 if (UserSettings.Style.get().size() > 0) { 37 Text text = UserSettings.Style.get().get(0); 38 38 _bodyFont = FontFactory.getFont(Conversion.getPdfFont(text 39 39 .getFamily()), text.getSize(), text.getPaintFont() … … 52 52 _pdfDocument.open(); 53 53 _pdfDocument.addCreationDate(); 54 _pdfDocument.addAuthor(UserSettings.UserName );54 _pdfDocument.addAuthor(UserSettings.UserName.get()); 55 55 _pdfDocument.addCreator("Expeditee"); 56 56 _pdfDocument.addTitle(start.getTitle()); … … 68 68 return; 69 69 70 if (indent < UserSettings.Style. size()) {70 if (indent < UserSettings.Style.get().size()) { 71 71 String text = toWrite.getText(); 72 toWrite = UserSettings.Style.get( indent).getTemplateForm();72 toWrite = UserSettings.Style.get().get(indent).getTemplateForm(); 73 73 toWrite.setText(text); 74 74 } -
trunk/src/org/expeditee/io/PdfFramesetWriter.java
r570 r655 72 72 _pdfDocument.open(); 73 73 _pdfDocument.addCreationDate(); 74 _pdfDocument.addAuthor(UserSettings.UserName );74 _pdfDocument.addAuthor(UserSettings.UserName.get()); 75 75 _pdfDocument.addCreator("Expeditee"); 76 76 } catch (DocumentException e) { -
trunk/src/org/expeditee/items/Item.java
r632 r655 229 229 230 230 if (parent != null && !UserSettings.UserName.equals(parent.getOwner())) { 231 dest.setOwner(UserSettings.UserName );231 dest.setOwner(UserSettings.UserName.get()); 232 232 } 233 233 } … … 254 254 return 2; 255 255 } 256 return org.expeditee.settings.UserSettings.Gravity;256 return UserSettings.Gravity.get(); 257 257 } 258 258 259 259 public static boolean showLineHighlight() { 260 return org.expeditee.settings.UserSettings.LineHighlight;260 return UserSettings.LineHighlight.get(); 261 261 } 262 262 … … 1696 1696 if (_parent != null && UserSettings.UserName != null 1697 1697 && !UserSettings.UserName.equals(_parent.getOwner())) { 1698 setOwner(UserSettings.UserName );1698 setOwner(UserSettings.UserName.get()); 1699 1699 } 1700 1700 } -
trunk/src/org/expeditee/items/ItemUtils.java
r601 r655 371 371 File file = null; 372 372 373 for (String dir : org.expeditee.settings.UserSettings.ImageDirs ) {373 for (String dir : org.expeditee.settings.UserSettings.ImageDirs.get()) { 374 374 file = new File(dir + path); 375 375 if (file.exists() && !file.isDirectory()) -
trunk/src/org/expeditee/items/Text.java
r635 r655 1434 1434 List<Point[]> lines = null; 1435 1435 1436 if(_autoWrap || ExperimentalFeatures.AutoWrap ) {1436 if(_autoWrap || ExperimentalFeatures.AutoWrap.get()) { 1437 1437 lines = new LinkedList<Point[]>(); 1438 1438 if(DisplayIO.getCurrentFrame() == null) { … … 1472 1472 while (_lineBreaker.getPosition() < _text.length()) { 1473 1473 1474 if(_autoWrap || ExperimentalFeatures.AutoWrap ) {1474 if(_autoWrap || ExperimentalFeatures.AutoWrap.get()) { 1475 1475 requireNextWord = width < FrameGraphics.getMaxFrameSize().width - getX(); 1476 1476 } … … 1505 1505 _textLayouts.add(layout); 1506 1506 1507 if(_autoWrap || ExperimentalFeatures.AutoWrap ) {1507 if(_autoWrap || ExperimentalFeatures.AutoWrap.get()) { 1508 1508 1509 1509 if(lineHeight != Float.NaN) { … … 1650 1650 return; 1651 1651 1652 if(_autoWrap || ExperimentalFeatures.AutoWrap ) {1652 if(_autoWrap || ExperimentalFeatures.AutoWrap.get()) { 1653 1653 invalidateAll(); 1654 1654 … … 2119 2119 2120 2120 // if autowrap is on, wrapping is done every time we draw 2121 if(ExperimentalFeatures.AutoWrap ) {2121 if(ExperimentalFeatures.AutoWrap.get()) { 2122 2122 return; 2123 2123 } -
trunk/src/org/expeditee/items/widgets/JfxBrowser.java
r645 r655 407 407 public JfxBrowser(Text source, String[] args) { 408 408 // Initial page is either the page stored in the arguments (if there is one stored) or the homepage 409 super(source, new WebBrowserPanel((args != null && args.length > 0) ? args[0] : NetworkSettings. homePage), -1, 500, -1, -1, 300, -1);409 super(source, new WebBrowserPanel((args != null && args.length > 0) ? args[0] : NetworkSettings.HomePage.get()), -1, 500, -1, -1, 300, -1); 410 410 _browser = (WebBrowserPanel) _swingComponent; 411 411 _browser.owner = this; … … 434 434 (firstSpace != -1 && firstSpace < firstSQ)) { // no '/' or '?' -> search 435 435 // make it a search 436 actualURL = NetworkSettings. searchEngine+ url;436 actualURL = NetworkSettings.SearchEngine.get() + url; 437 437 } else { 438 438 // add the missing protocol -
trunk/src/org/expeditee/settings/Settings.java
r641 r655 3 3 import java.lang.reflect.Field; 4 4 import java.lang.reflect.Method; 5 import java.lang.reflect.Modifier;6 5 import java.util.HashMap; 7 6 import java.util.LinkedList; … … 13 12 import org.expeditee.gui.FrameIO; 14 13 import org.expeditee.gui.FrameUtils; 14 import org.expeditee.items.Item; 15 15 import org.expeditee.items.Text; 16 16 import org.expeditee.items.widgets.Password; 17 17 import org.expeditee.reflection.PackageLoader; 18 import org.expeditee.setting.GenericSetting; 19 import org.expeditee.setting.Setting; 20 import org.expeditee.setting.VariableSetting; 18 21 19 22 public abstract class Settings { … … 24 27 private static final class PageDescriptor { 25 28 26 private static final class FieldSet { 27 28 private final Field field; 29 private final Method method; 30 31 private FieldSet(Field field, Method method) { 32 this.field = field; 33 this.method = method; 34 } 35 } 36 37 private final HashMap<String, FieldSet> settings = new HashMap<String, FieldSet>(); 38 private final List<Field> hasDefault = new LinkedList<Field>(); 29 private final HashMap<String, Setting> settings = new HashMap<String, Setting>(); 39 30 private final List<String> orderedEntries = new LinkedList<String>(); 31 private final List<VariableSetting> hasDefault = new LinkedList<VariableSetting>(); 40 32 private final Method onParsed; 41 33 42 34 private PageDescriptor(Class<?> clazz) { 43 35 44 // populate map of settings with methods 45 for(Method m : clazz.getMethods()) { 46 // method name must start with "set", and method must take 1 Text item as parameter 47 if(m.getName().toLowerCase().startsWith("set") && m.getParameterTypes().length == 1 && m.getParameterTypes()[0] == Text.class) { 48 // System.out.println(m.getName().toLowerCase()); 49 settings.put(m.getName().substring(3).toLowerCase(), new FieldSet(null, m)); 50 if(!orderedEntries.contains(m.getName().substring(3))) { 51 orderedEntries.add(m.getName().substring(3)); 52 } 53 } 54 } 55 // populate map of settings with fields 36 // populate map of settings 56 37 for(Field f : clazz.getFields()) { 57 Class<?> type = f.getType();58 38 // only allow valid types 59 if(type != String.class && 60 type != Boolean.class && type != boolean.class && 61 type != Integer.class && type != int.class && 62 type != Double.class && type != double.class && 63 type != Float.class && type != float.class) { 64 continue; 65 } 66 FieldSet fs = settings.get(f.getName().toLowerCase()); 67 if(fs == null) { 68 settings.put(f.getName().toLowerCase(), new FieldSet(f, null)); 69 } else { 70 settings.put(f.getName().toLowerCase(), new FieldSet(f, fs.method)); 71 } 72 if(!orderedEntries.contains(f.getName())) { 73 orderedEntries.add(f.getName()); 74 } 75 } 76 // check which fields have default values 77 for(Field f : clazz.getFields()) { 78 if(!Modifier.isFinal(f.getModifiers())) { 79 if(this.settings.get("default" + f.getName().toLowerCase()) != null) { 80 this.hasDefault.add(f); 81 } 82 } 39 if(! Setting.class.isAssignableFrom(f.getType())) { 40 continue; 41 } 42 try { 43 Setting s = (Setting) f.get(null); 44 settings.put(f.getName().toLowerCase(), s); 45 if(s instanceof VariableSetting && ((VariableSetting) s).hasDefault()) { 46 hasDefault.add((VariableSetting) s); 47 } 48 orderedEntries.add(f.getName()); 49 } catch (Exception e) { 50 e.printStackTrace(); 51 } 83 52 } 84 53 Method m = null; … … 108 77 e.printStackTrace(); 109 78 } 110 FrameUtils.ParseProfile(FrameIO.LoadProfile(UserSettings.ProfileName ));79 FrameUtils.ParseProfile(FrameIO.LoadProfile(UserSettings.ProfileName.get())); 111 80 } 112 81 … … 136 105 return; 137 106 } 138 List< Field> toDefault = new LinkedList<Field>(pd.hasDefault);107 List<VariableSetting> toDefault = new LinkedList<VariableSetting>(pd.hasDefault); 139 108 // set the fields 140 109 for (Text t : text.getChild().getBodyTextItems(true)) { … … 142 111 try { 143 112 // System.out.println(avp.getAttributeOrValue().trim().toLowerCase().replaceAll("^@", "")); 144 PageDescriptor.FieldSet fs = pd.settings.get(avp.getAttributeOrValue().trim().toLowerCase().replaceAll("^@", ""));145 if( fs == null) {113 Setting s = pd.settings.get(avp.getAttributeOrValue().trim().toLowerCase().replaceAll("^@", "")); 114 if(s == null) { 146 115 continue; 147 116 } 148 Field f = fs.field; 149 Method m = fs.method; 150 if(m != null) { 151 m.invoke(null, t); 152 // System.out.println("Set " + avp.getAttributeOrValue() + " by method"); 153 // we're setting this field, so remove it from the list of fields to default 154 toDefault.remove(f); 155 } else { 156 if (f != null) { 157 // if the value is empty, set it to the default 158 if(avp.getValue() == null || avp.getValue().trim().length() == 0) { 159 continue; 160 } 161 Class<?> type = f.getType(); 162 if(type == String.class) { 163 f.set(null, avp.getValue()); 164 } else if(type == Boolean.class || type == boolean.class) { 165 f.set(null, avp.getBooleanValue()); 166 } else if(type == Integer.class || type == int.class) { 167 f.set(null, avp.getIntegerValue()); 168 } else if(type == Double.class || type == double.class) { 169 f.set(null, avp.getDoubleValue()); 170 } else if(type == Float.class || type == float.class) { 171 f.set(null, avp.getDoubleValue().floatValue()); 172 } else { 173 System.err.println("Failed to set " + f.getName() + " of " + type); 174 continue; 175 } 176 // we're setting this field, so remove it from the list of fields to default 177 toDefault.remove(f); 178 // System.out.println("Set " + f.getName() + " to " + f.get(null)); 179 } 117 if(s.setSetting(t)) { 118 toDefault.remove(s); 180 119 } 181 120 } catch (Exception e) { … … 184 123 } 185 124 // set any unset fields to their default 186 for( Field f: toDefault) {125 for(VariableSetting s : toDefault) { 187 126 try { 188 f.set(null, pd.settings.get("default" + f.getName().toLowerCase()).field.get(null)); 127 // System.out.println("Resetting " + s.getTooltip()); 128 s.reset(); 189 129 // System.out.println("Set " + f.getName() + " to default value " + f.get(null)); 190 130 } catch (Exception e) { … … 210 150 } 211 151 152 /** 153 * 154 * Generates settings tree 155 * TODO: merge with @see FrameCreator 156 * 157 */ 212 158 private static Text generateSettingsTree(String page, Text text) { 213 159 Frame frame = FrameIO.CreateNewFrame(text); … … 215 161 216 162 int x = 50, y = 100; 217 int dY = UserSettings.ItemTemplate.get Polygon().getBounds().height + 1;218 int maxY = UserSettings.InitialHeight - 150;163 int dY = UserSettings.ItemTemplate.get().getPolygon().getBounds().height + 1; 164 int maxY = UserSettings.InitialHeight.get() - 150; 219 165 220 166 // add subpages of the current page … … 243 189 for(String str : pd.orderedEntries) { 244 190 String key = str.toLowerCase(); 245 if(key.startsWith("default")) { 246 continue; 247 } 248 PageDescriptor.FieldSet fs = pd.settings.get(key); 249 String name = null; 250 Object value = ""; 251 name = str.substring(0, 1).toUpperCase() + str.substring(1); 252 if(fs.method == null && fs.field != null) { 253 try { 254 if(pd.hasDefault.contains(fs.field)) { 255 value = ": " + pd.settings.get("default" + key).field.get(null); 256 } else { 257 value = ": " + fs.field.get(null); 258 } 259 } catch (Exception e) { 260 e.printStackTrace(); 261 } 262 } else if(fs.method == null) { 263 continue; 191 Setting s = pd.settings.get(key); 192 if(s == null) { 193 continue; 194 } 195 String name = str.substring(0, 1).toUpperCase() + str.substring(1); 196 String value = ""; 197 if(s instanceof GenericSetting && ((GenericSetting) s).isPrimitive()) { 198 System.out.println("VALUE: " + ((GenericSetting) s).get()); 199 if(((GenericSetting) s).get() != null) { 200 value = ": " + ((GenericSetting) s).get(); 201 } else { 202 value = ": "; 203 } 264 204 } 265 205 if(key.equals("pass")) { 266 Password pw = new Password(frame.createNewText("@iw: org.expeditee.items.widgets.Password"), null); 206 Text t = frame.addText(x, y, "iw: org.expeditee.items.widgets.Password", null); 207 Password pw = new Password(t, null); 267 208 pw.setPassword((String) value); 268 pw.setPosition(x, y);209 frame.removeItem(t); 269 210 frame.addAllItems(pw.getItems()); 270 211 y += pw.getHeight(); 212 } else if(s instanceof GenericSetting && ((GenericSetting) s).getType().equals(Text.class)) { 213 Text t = ((GenericSetting<Text>) s).get(); 214 if(t == null) continue; 215 t = t.copy(); 216 int h = t.getPolygon().getBounds().height + 1; 217 t.setID(frame.getNextItemID()); 218 t.setX(x); 219 t.setY(y + h / 2); 220 t.setText(name); 221 frame.addItem(t); 222 y += h; 271 223 } else { 272 frame.addText(x, y , name + value, null);273 }274 y += dY;224 frame.addText(x, y + dY / 2, name + value, null); 225 y += dY; 226 } 275 227 if(y >= maxY) { 276 228 x += 300; -
trunk/src/org/expeditee/settings/UserSettings.java
r642 r655 1 1 package org.expeditee.settings; 2 2 3 import java.awt.Color; 3 4 import java.io.File; 4 5 import java.io.FileNotFoundException; … … 18 19 import org.expeditee.gui.FreeItems; 19 20 import org.expeditee.gui.MessageBay; 20 import org.expeditee.gui.Reminders;21 21 import org.expeditee.items.Item; 22 22 import org.expeditee.items.ItemUtils; 23 23 import org.expeditee.items.Text; 24 import org.expeditee.setting.FrameSetting; 25 import org.expeditee.setting.FunctionSetting; 26 import org.expeditee.setting.GenericSetting; 27 import org.expeditee.setting.ListSetting; 28 import org.expeditee.setting.Setting; 24 29 25 30 /** … … 35 40 * General settings (no setter functions) 36 41 */ 37 public static final int defaultGravity = 3; 38 public static int Gravity = defaultGravity; 39 40 public static final float defaultScaleFactor = 1F; 41 public static float ScaleFactor = defaultScaleFactor; 42 43 public static final int defaultLineStraightenThreshold = 15; 44 public static int LineStraightenThreshold = defaultLineStraightenThreshold; 45 46 public static final int defaultNoOpThreshold = 60; 47 public static int NoOpThreshold = defaultNoOpThreshold; 48 49 public static final int defaultTitlePosition = 150; 50 public static int TitlePosition = defaultTitlePosition; 51 52 public static final int defaultInitialWidth = 1024; 53 public static int InitialWidth = defaultInitialWidth; 54 55 public static final int defaultInitialHeight = 768; 56 public static int InitialHeight = defaultInitialHeight; 57 58 public static String ProfileName; 59 60 public static String UserName; 61 62 public static final boolean defaultAntiAlias = false; 63 public static boolean AntiAlias = defaultAntiAlias; 64 65 public static final boolean defaultLineHighlight = false; 66 public static boolean LineHighlight = defaultLineHighlight; 67 68 public static final boolean defaultLogging = false; 69 public static boolean Logging = defaultLogging; 70 71 public static final boolean defaultLogStats = true; 72 public static boolean LogStats = defaultLogStats; 73 74 public static final boolean defaultThreading = true; 75 public static boolean Threading = defaultThreading; 42 43 public static final GenericSetting<Float> ScaleFactor = new GenericSetting<Float>(Float.class, "Scale Factor for drawing (TODO: does this even do anything?)", 1F); 44 45 public static final GenericSetting<Float> FormatSpacingMin = new GenericSetting<Float>(Float.class, "Minimum spacing ratio", null); 46 47 public static final GenericSetting<Float> FormatSpacingMax = new GenericSetting<Float>(Float.class, "Maximum spacing ratio", null); 48 49 public static final GenericSetting<Integer> Gravity = new GenericSetting<Integer>(Integer.class, "Distance the cursor has to be from a text item to select the text item", 3); 50 51 public static final GenericSetting<Integer> LineStraightenThreshold = new GenericSetting<Integer>(Integer.class, "Threshold for straightening a line (TODO: does this even do anything?)", 15); 52 53 public static final GenericSetting<Integer> NoOpThreshold = new GenericSetting<Integer>(Integer.class, "Distance the cursor may be dragged while clicking before the operation is cancelled", 60); 54 55 public static final GenericSetting<Integer> TitlePosition = new GenericSetting<Integer>(Integer.class, "Position of title item in frame (TODO: find whether this is x-offset or y-offset)", 150); 56 57 public static final GenericSetting<Integer> InitialWidth = new GenericSetting<Integer>(Integer.class, "Initial width of Expeditee window", 1024); 58 59 public static final GenericSetting<Integer> InitialHeight = new GenericSetting<Integer>(Integer.class, "Initial height of Expeditee window", 768); 60 61 public static final GenericSetting<String> ProfileName = new GenericSetting<String>(String.class, "Profile name", FrameIO.ConvertToValidFramesetName(System.getProperty("user.name"))); 62 63 public static final GenericSetting<String> UserName = new GenericSetting<String>(String.class, "User name", ProfileName.get()); 64 65 public static final GenericSetting<Boolean> AntiAlias = new GenericSetting<Boolean>(Boolean.class, "Whether anti-aliasing should be enabled", false); 66 67 public static final GenericSetting<Boolean> LineHighlight = new GenericSetting<Boolean>(Boolean.class, "Whether lines should be highlighted", false); 68 69 public static final GenericSetting<Boolean> Logging = new GenericSetting<Boolean>(Boolean.class, "Whether logging should be enabled", false); 70 71 public static final GenericSetting<Boolean> LogStats = new GenericSetting<Boolean>(Boolean.class, "Whether stats should be logged", true); 72 73 public static final GenericSetting<Boolean> Threading = new GenericSetting<Boolean>(Boolean.class, "Whether threading should be enabled", true); 76 74 77 75 … … 79 77 * Frames 80 78 */ 81 public static String DefaultFrame = null; 82 public static void setDefaultFrame(Text t) { 83 UserSettings.DefaultFrame = FrameUtils.getLink(t, UserSettings.DefaultFrame); 84 } 85 86 public static String StatisticsFrameset = null; 87 88 public static String MenuFrame = null; 89 90 public static String HomeFrame = null; 91 public static void setHomeFrame(Text t) { 92 if(t.getText().indexOf(':') == -1 || !t.hasLink()) { 93 t.setLink(FrameIO.LoadProfile(UserSettings.ProfileName).getName()); 94 } 95 String first = FrameUtils.getLink(t, UserSettings.HomeFrame); 96 // do not use non-existant frames as the first frame 97 if (FrameIO.isValidFrameName(first)) { 98 UserSettings.HomeFrame = first; 99 } 100 // warn the user 101 else { 102 // MessageBay.warningMessage("Home frame: " + first 103 // + " is not a valid frame."); 104 UserSettings.HomeFrame = FrameIO.LoadProfile(UserSettings.ProfileName).getName(); 105 } 106 } 79 public static final GenericSetting<String> DefaultFrame = new GenericSetting<String>(String.class, "The default frame", null) { 80 @Override 81 public boolean setSetting(Text text) { 82 _value = FrameUtils.getLink(text, _value); 83 return true; 84 } 85 }; 86 87 public static final GenericSetting<String> StatisticsFrameset = new GenericSetting<String>(String.class, "The statistics frameset", null); 88 89 public static final GenericSetting<String> MenuFrame = new GenericSetting<String>(String.class, "The menu frame", null); 90 91 public static final GenericSetting<String> HomeFrame = new GenericSetting<String>(String.class, "The home frame", null) { 92 @Override 93 public boolean setSetting(Text text) { 94 if(text.getText().indexOf(':') == -1 || !text.hasLink()) { 95 text.setLink(FrameIO.LoadProfile(UserSettings.ProfileName.get()).getName()); 96 } 97 String first = FrameUtils.getLink(text, UserSettings.HomeFrame.get()); 98 // do not use non-existant frames as the first frame 99 if (FrameIO.isValidFrameName(first)) { 100 _value = first; 101 } 102 // warn the user 103 else { 104 // MessageBay.warningMessage("Home frame: " + first 105 // + " is not a valid frame."); 106 _value = FrameIO.LoadProfile(UserSettings.ProfileName.get()).getName(); 107 } 108 return true; 109 } 110 }; 107 111 108 112 /* 109 113 * Directories 110 114 */ 111 public static List<String> FrameDirs = new LinkedList<String>(); 112 public static void setFrameDirs(Text t) { 113 UserSettings.FrameDirs.addAll(FrameUtils.getDirs(t)); 114 } 115 public static void setFramesetDir(Text t) { 116 if(t.getText().indexOf(':') == -1) { 117 return; 118 } 119 String dir = null; 120 AttributeValuePair avp = new AttributeValuePair(t.getText()); 121 if(avp.getValue().trim().length() != 0) { 122 dir = FrameUtils.getDir(avp.getValue()); 123 } 124 if (dir != null) { 125 UserSettings.FrameDirs.add(dir); 126 } 127 } 128 129 public static List<String> ImageDirs = new LinkedList<String>(); 130 public static void setImageDirs(Text t) { 131 UserSettings.ImageDirs.addAll(FrameUtils.getDirs(t)); 132 } 133 public static void setImageDir(Text t) { 134 if(t.getText().indexOf(':') == -1) { 135 return; 136 } 137 String dir = null; 138 AttributeValuePair avp = new AttributeValuePair(t.getText()); 139 if(avp.getValue().trim().length() != 0) { 140 dir = FrameUtils.getDir(avp.getValue()); 141 } 142 if (dir != null) { 143 UserSettings.ImageDirs.add(0, dir); 144 } 145 } 146 147 public static void setLogDir(Text t) { 148 if(t.getText().indexOf(':') == -1) { 149 return; 150 } 151 AttributeValuePair avp = new AttributeValuePair(t.getText()); 152 if(avp.getValue().trim().length() != 0) { 153 FrameIO.LOGS_DIR = FrameUtils.getDir(avp.getValue()); 154 } 155 } 115 public static final ListSetting<String> FrameDirs = new ListSetting<String>("Directories to look in for frames") { 116 @Override 117 public boolean setSetting(Text text) { 118 _value.addAll(FrameUtils.getDirs(text)); 119 return true; 120 } 121 }; 122 public static final Setting FramesetDir = new Setting("Adds a directory to look in for frames") { 123 @Override 124 public boolean setSetting(Text text) { 125 if(text.getText().indexOf(':') == -1) { 126 return false; 127 } 128 AttributeValuePair avp = new AttributeValuePair(text.getText()); 129 if(avp.getValue().trim().length() != 0) { 130 String dir = FrameUtils.getDir(avp.getValue()); 131 if (dir != null) { 132 UserSettings.FrameDirs.get().add(dir); 133 return true; 134 } 135 } 136 return false; 137 } 138 }; 139 140 public static ListSetting<String> ImageDirs = new ListSetting<String>("Directories to look in for images") { 141 @Override 142 public boolean setSetting(Text text) { 143 _value.addAll(FrameUtils.getDirs(text)); 144 return true; 145 } 146 }; 147 public static final Setting ImageDir = new Setting("Adds a directory to look in for images") { 148 @Override 149 public boolean setSetting(Text text) { 150 if(text.getText().indexOf(':') == -1) { 151 return false; 152 } 153 AttributeValuePair avp = new AttributeValuePair(text.getText()); 154 if(avp.getValue().trim().length() != 0) { 155 String dir = FrameUtils.getDir(avp.getValue()); 156 if(dir != null) { 157 UserSettings.ImageDirs.get().add(0, dir); 158 return true; 159 } 160 } 161 return false; 162 } 163 }; 164 165 public static final Setting LogDir = new Setting("Set the directory to save logs") { 166 @Override 167 public boolean setSetting(Text text) { 168 if(text.getText().indexOf(':') == -1) { 169 return false; 170 } 171 AttributeValuePair avp = new AttributeValuePair(text.getText()); 172 if(avp.getValue().trim().length() != 0) { 173 FrameIO.LOGS_DIR = FrameUtils.getDir(avp.getValue()); 174 } 175 return true; 176 } 177 }; 156 178 157 179 /* 158 180 * Templates 159 181 */ 160 public static Text TitleTemplate = null; 161 162 public static Text ItemTemplate = new Text("@ItemTemplate"); 163 public static void setItemTemplate(Text t) { 164 UserSettings.ItemTemplate = t.getTemplateForm(); 165 } 166 167 public static Text DotTemplate = new Text("@DotTemplate"); 168 public static void setDotTemplate(Text t) { 169 UserSettings.DotTemplate = t.getTemplateForm(); 170 } 171 172 public static Text AnnotationTemplate = null; 173 public static void setAnnotationTemplate(Text t) { 174 UserSettings.AnnotationTemplate = t.getTemplateForm(); 175 } 176 177 public static Text CodeCommentTemplate = null; 178 public static void setCommentTemplate(Text t) { 179 UserSettings.CodeCommentTemplate = t.getTemplateForm(); 180 } 181 182 public static Text StatTemplate = null; 183 public static void setStatsTemplate(Text t) { 184 UserSettings.StatTemplate = t.getTemplateForm(); 185 } 182 public static final GenericSetting<Text> TitleTemplate = new GenericSetting<Text>(Text.class, "Template for Title text item"); 183 184 public static final GenericSetting<Text> ItemTemplate = new GenericSetting<Text>(Text.class, "Template for normal text items", new Text("@ItemTemplate")) { 185 @Override 186 public boolean setSetting(Text text) { 187 _value = text.getTemplateForm(); 188 return true; 189 } 190 }; 191 192 public static final GenericSetting<Text> DotTemplate = new GenericSetting<Text>(Text.class, "Template for dot items", new Text("@DotTemplate")) { 193 @Override 194 public boolean setSetting(Text text) { 195 _value = text.getTemplateForm(); 196 return true; 197 } 198 }; 199 200 private static final Text annotationTemplate() { 201 Text t = new Text("@AnnotationTemplate"); 202 t.setColor(Color.gray); 203 return t; 204 } 205 public static final GenericSetting<Text> AnnotationTemplate = new GenericSetting<Text>(Text.class, "Template for annotation text items", annotationTemplate()) { 206 @Override 207 public boolean setSetting(Text text) { 208 _value = text.getTemplateForm(); 209 return true; 210 } 211 }; 212 213 private static final Text codeCommentTemplate() { 214 Text t = new Text("@CommentTemplate"); 215 t.setColor(Color.green.darker()); 216 return t; 217 } 218 public static final GenericSetting<Text> CodeCommentTemplate = new GenericSetting<Text>(Text.class, "Template for code comment text items", codeCommentTemplate()) { 219 @Override 220 public boolean setSetting(Text text) { 221 _value = text.getTemplateForm(); 222 return true; 223 } 224 }; 225 226 private static final Text statTemplate() { 227 Text t = new Text("@StatsTemplate"); 228 t.setColor(Color.BLACK); 229 t.setBackgroundColor(new Color(0.9F, 0.9F, 0.9F)); 230 t.setFamily(Text.MONOSPACED_FONT); 231 t.setSize(14); 232 return t; 233 } 234 public static final GenericSetting<Text> StatTemplate = new GenericSetting<Text>(Text.class, "Template for statistics (e.g. extracted attributes) text items", statTemplate()) { 235 @Override 236 public boolean setSetting(Text text) { 237 _value = text.getTemplateForm(); 238 return true; 239 } 240 }; 186 241 187 242 /* 188 243 * Colorwheels 189 244 */ 190 public static void setColorWheel(Text t) { 191 if(t.getChild() != null) Item.COLOR_WHEEL = FrameUtils.getColorWheel(t); 192 } 193 194 public static void setFillColorWheel(Text t) { 195 if(t.getChild() != null) Item.FILL_COLOR_WHEEL = FrameUtils.getColorWheel(t); 196 } 197 198 public static void setBackgroundColorWheel(Text t) { 199 if(t.getChild() != null) Frame.COLOR_WHEEL = FrameUtils.getColorWheel(t); 200 } 245 public static final FrameSetting ColorWheel = new FrameSetting("The colours of items in the child frame are used to populate the colour wheel") { 246 @Override 247 protected void run(Frame frame) { 248 Item.COLOR_WHEEL = FrameUtils.getColorWheel(frame); 249 } 250 }; 251 252 public static final FrameSetting FillColorWheel = new FrameSetting("The colours of items in the child frame are used to populate the colour wheel") { 253 @Override 254 protected void run(Frame frame) { 255 Item.FILL_COLOR_WHEEL = FrameUtils.getColorWheel(frame); 256 } 257 }; 258 259 public static final FrameSetting BackgroundColorWheel = new FrameSetting("The colours of items in the child frame are used to populate the colour wheel") { 260 @Override 261 protected void run(Frame frame) { 262 Frame.COLOR_WHEEL = FrameUtils.getColorWheel(frame); 263 } 264 }; 201 265 202 266 /* 203 267 * Other 204 268 */ 205 public static List<Text> Style = new LinkedList<Text>(); 206 public static void setStyle(Text t) { 207 Frame child = t.getChild(); 208 if (child == null) { 209 UserSettings.Style = new LinkedList<Text>(); 210 return; 211 } 212 213 214 List<Text> style = new ArrayList<Text>(8); 215 for (int i = 0; i < 10; i++) { 216 style.add(null); 217 } 218 219 for (Text text : child.getBodyTextItems(false)) { 220 String type = text.getText(); 221 char lastChar = type.charAt(type.length() - 1); 222 if (Character.isDigit(lastChar)) { 223 style.set(lastChar - '0', text); 224 } else { 225 style.set(0, text); 226 } 227 } 228 UserSettings.Style = style; 229 } 230 231 public static void setSpellChecker(Text t) { 232 AttributeValuePair avp = new AttributeValuePair(t.getText()); 233 if(avp.getBooleanValue()) { 234 try { 269 public static final ListSetting<Text> Style = new ListSetting<Text>("Set the style (TODO: what does this do?)") { 270 @Override 271 public boolean setSetting(Text text) { 272 Frame child = text.getChild(); 273 if (child == null) { 274 _value = new LinkedList<Text>(); 275 return true; 276 } 277 278 279 List<Text> style = new ArrayList<Text>(8); 280 for (int i = 0; i < 10; i++) { 281 style.add(null); 282 } 283 284 for (Text t : child.getBodyTextItems(false)) { 285 String type = t.getText(); 286 char lastChar = type.charAt(type.length() - 1); 287 if (Character.isDigit(lastChar)) { 288 style.set(lastChar - '0', t); 289 } else { 290 style.set(0, t); 291 } 292 } 293 _value = style; 294 return true; 295 } 296 }; 297 298 public static final FunctionSetting SpellChecker = new FunctionSetting("Enables the dictionary with the default dictionary") { 299 @Override 300 public void run() { 301 try { 235 302 JSpellChecker.create(); 236 303 } catch (FileNotFoundException e) { 237 MessageBay.errorMessage("Could not find dictionary: " 238 + e.getMessage()); 304 MessageBay.errorMessage("Could not find dictionary: " + e.getMessage()); 239 305 } catch (IOException e) { 240 306 e.printStackTrace(); 241 307 } 242 308 } 243 } 244 public static void setSpelling(Text t) { 245 if(t.getChild() != null) { 246 try { 247 JSpellChecker.create(t.getChild()); 248 } catch (Exception e) { 249 e.printStackTrace(); 250 } 251 } 252 } 253 254 public static void setGreenstoneSettings(Text t) { 255 if(t.getChild() != null) SearchGreenstone.init(t.getChild()); 256 } 257 258 public static void setReminders(Text t) { 259 if(t.getChild() != null) Reminders.init(t.getChild()); 260 } 261 262 public static void setFormatSpacingMin(Text t) { 263 double value = new AttributeValuePair(t.getText()).getDoubleValue(); 264 if(value != Double.NaN) { 265 FrameUtils.MINIMUM_SPACING_RATIO = value; 266 } 267 } 268 269 public static void setFormatSpacingMax(Text t) { 270 double value = new AttributeValuePair(t.getText()).getDoubleValue(); 271 if(value != Double.NaN) { 272 FrameUtils.MAXIMUM_SPACING_RATIO = value; 273 } 274 } 275 276 public static void setMailSettings(Text t) { 277 if(t.getChild() != null) MailSession.init(t.getChild()); 278 } 279 280 public static void setCursorFrame(Text t) { 281 if (t.getChild() != null) { 282 FreeItems.getCursor().addAll(ItemUtils.CopyItems(t.getChild().getAllItems())); 309 }; 310 public static final FrameSetting Spelling = new FrameSetting("Enables the dictionary and adds the items in the child frame to the dictionary") { 311 @Override 312 public void run(Frame frame) { 313 try { 314 JSpellChecker.create(frame); 315 } catch (Exception e) { 316 e.printStackTrace(); 317 } 318 } 319 }; 320 321 public static final FrameSetting GreenstoneSettings = new FrameSetting("Greenstone settings (TODO: What are these for?)") { 322 @Override 323 public void run(Frame frame) { 324 SearchGreenstone.init(frame); 325 } 326 }; 327 328 public static final FrameSetting Reminders = new FrameSetting("Reminders (TODO: What are these for?)") { 329 @Override 330 public void run(Frame frame) { 331 org.expeditee.gui.Reminders.init(frame); 332 } 333 }; 334 335 public static final FrameSetting MailSettings = new FrameSetting("Mail Settings (TODO: How does this work?)") { 336 @Override 337 public void run(Frame frame) { 338 MailSession.init(frame); 339 } 340 }; 341 342 public static final FrameSetting CursorFrame = new FrameSetting("Items on this frame will be used as the cursor (clearing the frame or removing the link will default back to a normal cursor)") { 343 @Override 344 public void run(Frame frame) { 345 FreeItems.getCursor().addAll(ItemUtils.CopyItems(frame.getAllItems())); 283 346 for (Item i : FreeItems.getCursor()) { 284 347 i.setParent(null); … … 287 350 DisplayIO.setCursor(Item.DEFAULT_CURSOR); 288 351 } 289 } 352 }; 290 353 291 354 … … 299 362 } 300 363 301 UserSettings.FrameDirs. add(FrameIO.FRAME_PATH);302 UserSettings.FrameDirs. add(FrameIO.PUBLIC_PATH);303 UserSettings.FrameDirs. add(FrameIO.PROFILE_PATH);304 UserSettings.FrameDirs. add(FrameIO.HELP_PATH);305 UserSettings.ImageDirs. add(FrameIO.IMAGES_PATH);306 UserSettings.FrameDirs. add(FrameIO.MESSAGES_PATH);364 UserSettings.FrameDirs.get().add(FrameIO.FRAME_PATH); 365 UserSettings.FrameDirs.get().add(FrameIO.PUBLIC_PATH); 366 UserSettings.FrameDirs.get().add(FrameIO.PROFILE_PATH); 367 UserSettings.FrameDirs.get().add(FrameIO.HELP_PATH); 368 UserSettings.ImageDirs.get().add(FrameIO.IMAGES_PATH); 369 UserSettings.FrameDirs.get().add(FrameIO.MESSAGES_PATH); 307 370 } 308 371 -
trunk/src/org/expeditee/settings/experimental/ExperimentalFeatures.java
r632 r655 1 1 package org.expeditee.settings.experimental; 2 3 import org.expeditee.setting.GenericSetting; 2 4 3 5 public class ExperimentalFeatures { 4 6 5 public static final boolean defaultAutoWrap = false; 6 public static boolean AutoWrap = defaultAutoWrap; 7 public static final GenericSetting<Boolean> AutoWrap = new GenericSetting<Boolean>(Boolean.class, "Enable auto wrapping of text", false); 7 8 8 public static final boolean defaultMousePan = false; 9 public static boolean MousePan = defaultMousePan; 9 public static final GenericSetting<Boolean> MousePan = new GenericSetting<Boolean>(Boolean.class, "Enable panning of the frame by shift-click and dragging the mouse", false); 10 10 11 11 } -
trunk/src/org/expeditee/settings/network/NetworkSettings.java
r629 r655 1 1 package org.expeditee.settings.network; 2 2 3 4 import org.expeditee.gui.Frame; 3 5 import org.expeditee.items.Text; 4 6 import org.expeditee.network.FrameShare; 7 import org.expeditee.setting.FrameSetting; 8 import org.expeditee.setting.GenericSetting; 5 9 6 10 public abstract class NetworkSettings { 7 11 8 12 // The URL to prepend to web searches 9 public static final String defaultSearchEngine = "https://duckduckgo.com/?q="; 10 public static String searchEngine = defaultSearchEngine; 13 public static final GenericSetting<String> SearchEngine = new GenericSetting<String>(String.class, "The search engine for the JfxBrowser", "https://duckduckgo.com/?q="); 11 14 12 public static final String defaultHomePage = "https://duckduckgo.com"; 13 public static String homePage = defaultHomePage; 15 public static final GenericSetting<String> HomePage = new GenericSetting<String>(String.class, "The home page for the JfxBrowser", "https://duckduckgo.com"); 14 16 15 16 public static void setFrameShare(Text t) { 17 FrameShare.init(t.getChild()); 18 } 17 public static final FrameSetting FrameShare = new FrameSetting("Enable accessing remote frames") { 18 @Override 19 public void run(Frame frame) { 20 org.expeditee.network.FrameShare.init(frame); 21 } 22 }; 19 23 20 24 public static void onParsed(Text text) { -
trunk/src/org/expeditee/settings/network/proxy/ProxySettings.java
r652 r655 1 1 package org.expeditee.settings.network.proxy; 2 3 import java.awt.Color;4 2 5 3 import org.expeditee.gui.Browser; … … 11 9 import org.expeditee.items.widgets.WidgetCorner; 12 10 import org.expeditee.items.widgets.WidgetEdge; 11 import org.expeditee.setting.GenericSetting; 13 12 14 13 public abstract class ProxySettings { 15 14 16 public static String host = null;17 public static String port = null;18 public static String user = null;19 public static String pass = null;15 public static final GenericSetting<String> Host = new GenericSetting<String>(String.class, "The host for the proxy", null); 16 public static final GenericSetting<String> Port = new GenericSetting<String>(String.class, "The port for the proxy (e.g. port 80)", "80"); 17 public static final GenericSetting<String> User = new GenericSetting<String>(String.class, "Your username for the proxy", null); 18 public static final GenericSetting<String> Pass = new GenericSetting<String>(String.class, "Your password for the proxy", null); 20 19 21 20 public static void onParsed(Text text) { … … 35 34 try { 36 35 passwordWidget = (Password) InteractiveWidget.createWidget((Text) i); 37 if ( pass!= null) {36 if (Pass.get() != null) { 38 37 // MessageBay.displayMessage("pass was defined multiple times!", Color.ORANGE); 39 38 } 40 pass = passwordWidget.getPassword();39 Pass.set(passwordWidget.getPassword()); 41 40 } catch (Exception e) { 42 41 e.printStackTrace(); … … 56 55 passwordWidget = (Password) iw; 57 56 } 58 if( pass!= null) {57 if(Pass.get() != null) { 59 58 // MessageBay.displayMessage("pass was defined multiple times!", Color.ORANGE); 60 59 } 61 pass = passwordWidget.getPassword();60 Pass.set(passwordWidget.getPassword()); 62 61 } 63 62 } 64 63 } 65 64 66 if( host== null) {65 if(Host.get() == null) { 67 66 MessageBay.warningMessage("proxy host was not defined"); 68 67 return; 69 68 } 70 if( port== null) {69 if(Port.get() == null) { 71 70 MessageBay.warningMessage("proxy port was not defined (defaulted to 80)"); 72 port = "80";71 Port.set("80"); 73 72 } 74 if( user== null) {73 if(User.get() == null) { 75 74 MessageBay.warningMessage("proxy user was not defined"); 76 75 return; 77 76 } 78 if( pass== null) {77 if(Pass.get() == null) { 79 78 MessageBay.warningMessage("proxy pass was not defined"); 80 79 return; 81 80 } 82 81 // TODO: Is it possible to have different host/port for http/https protocols for a proxy server? 83 System.setProperty("http.proxyHost", host);84 System.setProperty("http.proxyPort", port);85 System.setProperty("https.proxyHost", host);86 System.setProperty("https.proxyPort", port);87 Browser.proxyAuth.setup( user, pass);82 System.setProperty("http.proxyHost", Host.get()); 83 System.setProperty("http.proxyPort", Port.get()); 84 System.setProperty("https.proxyHost", Host.get()); 85 System.setProperty("https.proxyPort", Port.get()); 86 Browser.proxyAuth.setup(User.get(), Pass.get()); 88 87 89 88 // System.out.println("proxy parsed"); -
trunk/src/org/expeditee/stats/DocumentStatsFast.java
r570 r655 57 57 58 58 String fullPath = null; 59 for (String possiblePath : UserSettings.FrameDirs ) {59 for (String possiblePath : UserSettings.FrameDirs.get()) { 60 60 fullPath = FrameIO.getFrameFullPathName(possiblePath, _name); 61 61 if (fullPath != null) -
trunk/src/org/expeditee/stats/Logger.java
r570 r655 78 78 */ 79 79 public static void Init() { 80 if (!org.expeditee.settings.UserSettings.Logging )80 if (!org.expeditee.settings.UserSettings.Logging.get()) 81 81 return; 82 82 … … 148 148 149 149 private static void WriteToFile(String toWrite) { 150 if (!org.expeditee.settings.UserSettings.Logging )150 if (!org.expeditee.settings.UserSettings.Logging.get()) 151 151 return; 152 152 -
trunk/src/org/expeditee/stats/StatsLogger.java
r570 r655 35 35 */ 36 36 private static void Init() { 37 if (!org.expeditee.settings.UserSettings.LogStats )37 if (!org.expeditee.settings.UserSettings.LogStats.get()) 38 38 return; 39 39 … … 50 50 */ 51 51 public static void WriteStatsFile() { 52 if (!org.expeditee.settings.UserSettings.LogStats )52 if (!org.expeditee.settings.UserSettings.LogStats.get()) 53 53 return; 54 54 55 55 Init(); 56 56 57 String statsFrameset = UserSettings.StatisticsFrameset ;57 String statsFrameset = UserSettings.StatisticsFrameset.get(); 58 58 if (statsFrameset != null) { 59 59 try {
Note:
See TracChangeset
for help on using the changeset viewer.