/******************************* Copyright notice ******************************* Copyright (C)2002 by Andrei Loskutov <loskutov@gmx.de>. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ********************************************************************************/ /** * Created on 29.11.2002 * * To change this generated comment edit the template variable "filecomment": * Window>Preferences>Java>Templates. * To enable and disable the creation of file comments go to * Window>Preferences>Java>Code Generation. */ package adiag.connection; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Properties; import adiag.model.BVException; import adiag.model.Const; /** * Administrator class for settings and config - file * @author Andy the Great */ public class PropertySetter { /** is props file read yet? */ protected boolean init; /** current application properties */ protected Properties props; /** * Constructor for PropertySetter. */ public PropertySetter() throws BVException { super(); readProps(); } /** * See return description * @return Properties curent config object */ public Properties getProps() { return props; } /** * See return description * @return ArrayList with all props keys */ public ArrayList getKeyList() { return new ArrayList(getProps().keySet()); } /** * Write props file to HD * @throws ExplainedException, if something goes wrong */ public void storeProperties() throws BVException { // remove "open file" property Properties properties = getProps(); String open_file = properties.getProperty(Const.PROPERTY_OPEN_FILE); properties.remove(Const.PROPERTY_OPEN_FILE); OutputStream out; File f = new File(Configuration.getIniUrl()); try { out = new BufferedOutputStream(new FileOutputStream(f)); properties.store(out, "BranchView tool configuration file, please don't edit if you don't understand!"); out.close(); } catch (IOException e) { throw new BVException("Cannot store properties: " + e.getMessage(), e); } if(open_file != null){ properties.put(Const.PROPERTY_OPEN_FILE, open_file); } } /** * See return description * @return boolean true, if props file are read */ public boolean isInitDone(){ return init; } /** * Read props from HD * @throws IOException if something goes wrong */ public void readProps() throws BVException { if (props == null) { props = new Properties(); } File f = new File(Configuration.getIniUrl()); InputStream is; try { is = new BufferedInputStream(new FileInputStream(f)); props.load(is); is.close(); } catch (FileNotFoundException e) { try { f.createNewFile(); } catch (Exception ex) { String message = "The ini - file " + f.getPath() + " cannot be created.\n"; throw new BVException(message + e.getMessage(), e); } } catch(IOException ioe){ throw new BVException("Cannot read properties: " + ioe.getMessage(), ioe); } // set to default for (int i = 0; i < Const.PROPERTIES.length; i++) { if (!props.containsKey(Const.PROPERTIES[i])) { props.put(Const.PROPERTIES[i], Configuration.getDefaultProperty(Const.PROPERTIES[i])); } } init = true; } /** * Set current value for given props key, and update all known windows * instances * @param key option name, one of Const.PROPERTY_ - constants * @param value current value for given props key */ public void setProperty(String key, String value) { key = key == null ? "" : key.trim(); if(Const.PROPERTY_P4_PASSWD.equals(key)){ if(value!=null && value.length()!=0 ){ // encode passwort try { value = Configuration.toStringBlock(value.getBytes()); } catch (Exception e) { e.printStackTrace(); } } } getProps().setProperty(key, value); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 2735 | andrei_loskutov | sources are now included to binary distribution at http://andrei.gmxhome.de/perforce/index.html | ||
#3 | 2554 | andrei_loskutov |
#25.12.2002 23:29 Revision 1.3.0.4 beta 1) Some small refactoring 2) First integration with P4eclipse: properties etc, thanks Boris Pr�ssmann 5) Better integration to Eclipse: use Eclipse internal compare tool for diff. 6) Fix some minor bugs. #14.12.2002 23:15 Revision 1.3.0.3 beta 1) Fix endless loop bug if p4 path was not set. 2) Fix never getting focus bug after error message shown 3) Fix painting bug on JDK 1.4.1 (must be verified!!!) 4) Some small refactoring 5) Fix error handling. 6) Fix some minor bugs. |
||
#2 | 2552 | andrei_loskutov | 1.3.0.4 changes | ||
#1 | 2460 | andrei_loskutov |
1) Change configuration: always reed properties 2) Change password store to hex format/password field 3) Create standalone/not standalone state for new branchview eclipse wrapper 4) Refactor all main classes to remove cyclic package dependency 5) Add workaround to fix new JDK 1.4.1 Swing bugs on JScrollPane/JViewPort 6) Add dispose methods to panel/connector 7) Minor internal GUI fixes/refactorings |