private void setTextPresenterProperties() { configuration.setVariable(MuSnapshot.TEXT_FILE_PRESENTER_FULL_SCREEN, TextViewer.isFullScreen()); configuration.setVariable(MuSnapshot.TEXT_FILE_PRESENTER_LINE_WRAP, TextViewer.isLineWrap()); configuration.setVariable(MuSnapshot.TEXT_FILE_PRESENTER_LINE_NUMBERS, TextViewer.isLineNumbers()); }
/** * Check whether the preferences file exists * @return true if the preferences file exits, false otherwise. * @throws IOException if an error occurred. */ boolean isFileExists() throws IOException { return configuration.getSource().isExists(); }
/** * Loads the muCommander CONFIGURATION. * @throws IOException if an I/O error occurs. * @throws ConfigurationException if a CONFIGURATION related error occurs. */ void read() throws IOException, ConfigurationException { VersionedXmlConfigurationReader reader = new VersionedXmlConfigurationReader(); configuration.read(reader); // Ensure backward compatibility configurationVersion = reader.getVersion(); if(configurationVersion == null || !configurationVersion.equals(RuntimeConstants.VERSION)) { // Rename preferences that have changed (from v0.8.5) configuration.renameVariable("show_hidden_files", SHOW_HIDDEN_FILES); configuration.renameVariable("auto_size_columns", AUTO_SIZE_COLUMNS); configuration.renameVariable("show_toolbar", TOOLBAR_VISIBLE); configuration.renameVariable("show_status_bar", STATUS_BAR_VISIBLE); configuration.renameVariable("show_command_bar", COMMAND_BAR_VISIBLE); } // Initializes MAC OS X specific values if(OsFamily.MAC_OS_X.isCurrent()) { if(configuration.getVariable(SHELL_ENCODING) == null) { configuration.setVariable(SHELL_ENCODING, "UTF-8"); configuration.setVariable(AUTODETECT_SHELL_ENCODING, false); } } }
/** * Creates a new instance of <code>Configuration</code> using the specified source and format. * @param source where the resulting instance will look for its configuration data. * @param reader factory for configuration readers. * @param writer factory for configuration writers. */ public Configuration(ConfigurationSource source, ConfigurationReaderFactory reader, ConfigurationWriterFactory writer) { setSource(source); setReaderFactory(reader); setWriterFactory(writer); }
/** * Moves the value of <code>fromVar</code> to <code>toVar</code>. * <p> * At the end of this call, <code>fromVar</code> will have been deleted. Note that if <code>fromVar</code> doesn't * exist, but <code>toVar</code> does, <code>toVar</code> will be deleted. * </p> * <p> * This method might trigger as many as two {@link ConfigurationEvent events}: * <ul> * <li>One when <code>fromVar</code> is removed.</li> * <li>One when <code>toVar</code> is set.</li> * </ul> * The removal event will always be triggered first. * </p> * @param fromVar fully qualified name of the variable to rename. * @param toVar fully qualified name of the variable that will receive <code>fromVar</code>'s value. */ public void renameVariable(String fromVar, String toVar) { setVariable(toVar, removeVariable(fromVar)); }
/** * Writes the configuration to the specified {@link Writer}. * <p> * This method will use {@link #getWriterFactory()} to create instances of configuration writer. * </p> * @param out where to write the configuration to. * @throws ConfigurationException if any error occurs. * @throws ConfigurationFormatException if a syntax error occurs in the configuration data. * @throws ConfigurationStructureException if the configuration data doesn't describe a valid configuration tree. * @throws WriterConfigurationException if the {@link ConfigurationWriterFactory} isn't properly configured. * @see #read(InputStream) * @see #write() */ public void write(Writer out) throws ConfigurationException { write(getWriterFactory().getWriterInstance(out)); }
/** * Saves the muCommander CONFIGURATION. * @throws IOException if an I/O error occurs. * @throws ConfigurationException if a CONFIGURATION related error occurs. */ void write() throws IOException, ConfigurationException { if(configurationVersion != null && !configurationVersion.equals(RuntimeConstants.VERSION)) { // Clear the configuration before saving to drop preferences which are unused anymore Configuration conf = new Configuration(MuPreferencesFile.getPreferencesFile(), new VersionedXmlConfigurationReaderFactory(), new VersionedXmlConfigurationWriterFactory(ROOT_ELEMENT)); for (MuPreference preference : MuPreference.values()) conf.setVariable(preference.toString(), configuration.getVariable(preference.toString())); // Remove preferences which are not relevant if we're not using MAC if (!OsFamily.MAC_OS_X.isCurrent()) { conf.removeVariable(USE_BRUSHED_METAL); conf.removeVariable(USE_SCREEN_MENU_BAR); } configuration = conf; } configuration.write(); }
/** * Checks whether the specified variable has been set. * @param name fully qualified name of the variable to check for. * @return <code>true</code> if the variable is set, <code>false</code> otherwise. */ public boolean isVariableSet(String name) { return getVariable(name) != null; }
configuration.clear(); configuration.setVariable(WINDOWS_COUNT, nbMainFrames); configuration.setVariable(WINDOWS_SELECTION, indexOfSelectedWindow); configuration.setVariable(MuSnapshot.SCREEN_WIDTH, screenSize.width); configuration.setVariable(MuSnapshot.SCREEN_HEIGHT, screenSize.height); configuration.write();
/** * Fills the configuration instance with test values. */ @BeforeMethod public void setUp() { StringBuilder buffer; buffer = new StringBuilder(); conf = new Configuration(); for(int i = 0; i < DEPTH; i++) { conf.setVariable(buffer.toString() + VARIABLE_NAME + i, VARIABLE_VALUE + i); buffer.append(SECTION_NAME); buffer.append(i); buffer.append('.'); } }
public String removeVariable(String name) { return configuration.removeVariable(name); } }
/** * Private Constructor */ private GlobalLocationHistory() { Configuration snapshot = MuConfigurations.getSnapshot(); // Restore the global history from last run int nbLocations = snapshot.getIntegerVariable(MuSnapshot.getRecentLocationsCountVariable()); for (int i=0; i<nbLocations; ++i) { String filePath = snapshot.getVariable(MuSnapshot.getRecentLocationVariable(i)); try { history.add(FileURL.getFileURL(filePath)); } catch (MalformedURLException e) { LOGGER.debug("Got invalid URL from the snapshot file: " + filePath, e); } } }
/** * Loads configuration from the specified reader. * <p> * This method will use the configuration reader set by {@link #setReaderFactory(ConfigurationReaderFactory)} if any, * or an {@link XmlConfigurationReader} instance if not. * </p> * @param in where to read the configuration from. * @throws ConfigurationException if a configuration error occurs. * @throws ConfigurationFormatException if a syntax error occurs in the configuration data. * @throws ConfigurationStructureException if the configuration data doesn't describe a valid configuration tree. * @throws ReaderConfigurationException if the {@link ConfigurationReaderFactory} isn't properly configured. * @throws IOException if an I/O error occurs. * @see #read() * @see #read(ConfigurationReader) * @see #read(Reader,ConfigurationReader) */ public void read(Reader in) throws ConfigurationException, IOException { read(in, getReaderFactory().getReaderInstance()); }
private MainFrame createMainFrame(int index) { int nbTabsInLeftPanel = snapshot.getIntegerVariable(MuSnapshot.getTabsCountVariable(index, true)); ConfFileTableTab[] leftTabs = new ConfFileTableTab[nbTabsInLeftPanel]; for (int i=0; i<nbTabsInLeftPanel; ++i) leftTabs[i] = new ConfFileTableTab( snapshot.getBooleanVariable(MuSnapshot.getTabLockedVariable(index, true, i)), restoreFileURL(snapshot.getVariable(MuSnapshot.getTabLocationVariable(index, true, i))), snapshot.getVariable(MuSnapshot.getTabTitleVariable(index, true, i))); int nbTabsInRightPanel = snapshot.getIntegerVariable(MuSnapshot.getTabsCountVariable(index, false)); ConfFileTableTab[] rightTabs = new ConfFileTableTab[nbTabsInRightPanel]; for (int i=0; i<nbTabsInRightPanel; ++i) rightTabs[i] = new ConfFileTableTab( snapshot.getBooleanVariable(MuSnapshot.getTabLockedVariable(index, false, i)), restoreFileURL(snapshot.getVariable(MuSnapshot.getTabLocationVariable(index, false, i))), snapshot.getVariable(MuSnapshot.getTabTitleVariable(index, false, i))); int x = MuConfigurations.getSnapshot().getIntegerVariable(MuSnapshot.getX(index)); int y = MuConfigurations.getSnapshot().getIntegerVariable(MuSnapshot.getY(index)); int width = MuConfigurations.getSnapshot().getIntegerVariable(MuSnapshot.getWidth(index)); int height = MuConfigurations.getSnapshot().getIntegerVariable(MuSnapshot.getHeight(index)); int lastScreenWidth = MuConfigurations.getSnapshot().getIntegerVariable(MuSnapshot.SCREEN_WIDTH); int lastScreenHeight = MuConfigurations.getSnapshot().getIntegerVariable(MuSnapshot.SCREEN_HEIGHT); if (MuConfigurations.getSnapshot().getBooleanVariable(MuSnapshot.getSinglePanelViewToggleState(index))) { ActionManager.performAction(ToggleUseSinglePanelAction.Descriptor.ACTION_ID, mainFrame);
/** * Initialises the test case. */ @BeforeMethod public void setUp() { conf = new Configuration(); }
/** * Creates a new instance of <code>Configuration</code> using the specified source. * <p> * The resulting instance will use the default {@link XmlConfigurationReader readers} and * {@link XmlConfigurationWriter writers}. * </p> * @param source where the resulting instance will look for its configuration data. */ public Configuration(ConfigurationSource source) { setSource(source); }
/** * Loads the muCommander CONFIGURATION. * Here, we don't try to convert preferences that were changed between muCommander versions, * as those are 'dynamic' preferences and as such can be ignored when the user installs new version. * * @throws IOException if an I/O error occurs. * @throws ConfigurationException if a CONFIGURATION related error occurs. */ void read() throws IOException, ConfigurationException { VersionedXmlConfigurationReader reader = new VersionedXmlConfigurationReader(); configuration.read(reader); }
/** * Adds the specified object to the list of registered CONFIGURATION listeners. * @param listener object to register as a CONFIGURATION listener. * @see #removeConfigurationListener(ConfigurationListener) */ void addConfigurationListener(ConfigurationListener listener) {configuration.addConfigurationListener(listener);}