Changeset 1213 for trunk/src/org/expeditee/settings/UserSettings.java
- Timestamp:
- 01/30/19 12:59:15 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/settings/UserSettings.java
r1120 r1213 23 23 import java.io.IOException; 24 24 import java.util.ArrayList; 25 import java.util.Collection; 25 26 import java.util.LinkedList; 26 27 import java.util.List; … … 33 34 import org.expeditee.gui.FrameUtils; 34 35 import org.expeditee.gui.MessageBay; 36 import org.expeditee.items.Item; 35 37 import org.expeditee.items.Text; 36 38 import org.expeditee.setting.BooleanSetting; … … 50 52 public abstract class UserSettings { 51 53 52 public finalstatic String DEFAULT_PROFILE_NAME = "default";54 public static String DEFAULT_PROFILE_NAME = "default"; 53 55 54 56 public static final IntegerSetting Gravity = new IntegerSetting("Distance the cursor has to be from a text item to select the text item", 3); … … 63 65 public boolean setSetting(Text text) { 64 66 if(text.getText().indexOf(':') == -1 || !text.hasLink()) { 65 text.setLink(FrameIO.LoadProfile(UserSettings.ProfileName.get()).getName()); 67 text.setLink(UserSettings.ProfileName.get() + "1"); 68 //text.setLink(FrameIO.LoadProfile(UserSettings.ProfileName.get()).getName()); 66 69 } 67 70 String first = FrameUtils.getLink(text, UserSettings.HomeFrame.get()); … … 99 102 public static final IntegerSetting TitlePosition = new IntegerSetting("Position of title item in frame (TODO: find whether this is x-offset or y-offset)", 150); 100 103 101 public static final StringSetting ProfileName = new StringSetting("Profile name", FrameIO.ConvertToValidFramesetName(System.getProperty("user.name"))); 102 103 public static final StringSetting UserName = new StringSetting("User name", ProfileName.get()); 104 104 public static final StringSetting ProfileName = new StringSetting("Profile name", FrameIO.ConvertToValidFramesetName(System.getProperty("user.name"))) { 105 106 /** Commit the change to the appropriate frame */ 107 public void set(String value) { 108 super.set(value); 109 commitToSettingsFrameItem(value, "ProfileName:"); 110 }; 111 112 /** If authenticated, then resetting ProfileName should not do anything. */ 113 public void reset() { 114 if (!Authenticated.get()) { 115 super.reset(); 116 } 117 }; 118 }; 119 120 public static final StringSetting UserName = new StringSetting("User name", ProfileName.get()) { 121 /** Commit the change to the appropriate frame */ 122 public void set(String value) { 123 super.set(value); 124 commitToSettingsFrameItem(value, "UserName:"); 125 }; 126 127 /** If authenticated, then resetting UserName should not do anything. */ 128 public void reset() { 129 if (!Authenticated.get()) { 130 super.reset(); 131 } 132 }; 133 }; 134 105 135 public static final BooleanSetting AntiAlias = new BooleanSetting("Whether anti-aliasing should be enabled", false); 106 136 … … 112 142 113 143 public static final BooleanSetting Threading = new BooleanSetting("Whether threading should be enabled", true); 114 144 145 public static final BooleanSetting Authenticated = new BooleanSetting("Whether the current user is authenticated", false) { 146 public void set(Boolean value) { 147 super.set(value); 148 commitToSettingsFrameItem(value, "Authenticated:"); 149 } 150 151 // Authenticated must be maintained rather than rely on default value. 152 public void reset() {}; 153 154 public boolean setSetting(Text text) { 155 return super.setSetting(text); 156 }; 157 }; 115 158 116 159 /* 117 160 * Frames 118 161 */ 119 120 162 public static final StringSetting StatisticsFrameset = new StringSetting("The statistics frameset", null); 121 163 … … 247 289 } 248 290 } 291 292 private static void commitToSettingsFrameItem(Object value, String contentMatch) { 293 String profileName = UserSettings.UserName.get(); 294 int lastNumber = FrameIO.getLastNumber(profileName); 295 for (int i = 1; i <= lastNumber; i++) { 296 Frame frame = FrameIO.LoadFrame(profileName + i); 297 if (frame != null) { 298 Collection<Item> items = frame.getAllItems(); 299 boolean found = false; 300 for (Item item: items) { 301 if (item.getText().startsWith(contentMatch)) { 302 item.setText(contentMatch + " " + value); 303 } 304 } 305 if (found) { break; } 306 } 307 } 308 } 249 309 }
Note:
See TracChangeset
for help on using the changeset viewer.