Author: EvaV Date: 2010-02-19 00:44:53 +0100 (Fri, 19 Feb 2010) New Revision: 1790 Modified: trunk/layouteditor/LayoutDesigner/src/applet/DocumentTypes.java trunk/layouteditor/LayoutDesigner/src/applet/LayoutDesigner.java trunk/layouteditor/LayoutDesigner/src/applet/MovingObject.java trunk/layouteditor/LayoutDesigner/src/applet/ServerSideContext.java Log: lokalizace Modified: trunk/layouteditor/LayoutDesigner/src/applet/DocumentTypes.java =================================================================== --- trunk/layouteditor/LayoutDesigner/src/applet/DocumentTypes.java 2010-02-18 22:32:39 UTC (rev 1789) +++ trunk/layouteditor/LayoutDesigner/src/applet/DocumentTypes.java 2010-02-18 23:44:53 UTC (rev 1790) @@ -57,7 +57,7 @@ // initializes and add type permitted buttons typePermittedButtons = new Vector<JCheckBox>(); for (int i = 0; i < typesOfDocuments.size(); ++i) { - JCheckBox typePermittedButton = new JCheckBox(typesOfDocuments.get(i)); + JCheckBox typePermittedButton = new JCheckBox(properties.getProperty(typesOfDocuments.get(i))); typePermittedButton.setFocusable(false); typePermittedButton.setEnabled(false); typePermittedButton.addActionListener(new ActionListener() { Modified: trunk/layouteditor/LayoutDesigner/src/applet/LayoutDesigner.java =================================================================== --- trunk/layouteditor/LayoutDesigner/src/applet/LayoutDesigner.java 2010-02-18 22:32:39 UTC (rev 1789) +++ trunk/layouteditor/LayoutDesigner/src/applet/LayoutDesigner.java 2010-02-18 23:44:53 UTC (rev 1790) @@ -51,7 +51,7 @@ /** rootPane of this applet */ // constants - private final static String PROPERTIES_FILE_NAME = "LayoutDesigner.properties"; + private final static String PROPERTIES_FILE_NAME = "LayoutDesigner"; /** name of file with properties */ private final static String PROPERTIES_FILE_PATH = "/webServer2/applets/"; /** file path to properties file */ @@ -64,6 +64,11 @@ private final static int PROPERTIES_MANAGER_WIDTH = 200; /** width of properties manager */ private final static String NOT_LOADED_PROPERTIES = "Server communication error: It isn't possible to read properties file"; + /** user error message - error loading properties file */ + private final static String NOT_SUPPORTED = "This localization isn't supported"; + /** user error message - localization is not supported */ + private final static String WARNING = "Warning"; + /** warning dialog title in case properties file isn't loaded */ public static LayoutDesigner getInstance() { return new LayoutDesigner(); @@ -93,11 +98,24 @@ throw new RuntimeException(e); } + try { + ServerSideContext.getInstance().getProperties(instance, + tabbedPane); + } catch (Exception e) { + e.printStackTrace(); + } + + String localization = ServerSideContext.getInstance().getLocalization(); + if(!ServerSideContext.getInstance().getLOCALIZATION().contains(localization)) { + new WarningDialog(new JFrame(), NOT_SUPPORTED, WARNING); + closeLayoutDesignerBrowserWindow(); + } + URL url = null; try { String urlString = ServerSideContext.getInstance() .getHost() - + PROPERTIES_FILE_PATH + PROPERTIES_FILE_NAME; + + PROPERTIES_FILE_PATH + PROPERTIES_FILE_NAME + "_" + localization + ".properties"; url = new URL(urlString); } catch (MalformedURLException e1) { } @@ -107,20 +125,15 @@ try { properties.load(url.openStream()); } catch (IOException e) { - new WarningDialog(new JFrame(), NOT_LOADED_PROPERTIES, - properties.getProperty("warning.warning")); + new WarningDialog(new JFrame(), NOT_LOADED_PROPERTIES, WARNING); e.printStackTrace(); } tabbedPane.setProperties(properties); tabbedPane.setComponentSizes(componentSizes); - try { - ServerSideContext.getInstance().getProperties(instance, - tabbedPane); - } catch (Exception e) { - e.printStackTrace(); - } + + SupportedResolutions supportedAspectRatios; // gets permitted types of document from server @@ -330,7 +343,7 @@ } /** - * When applet is started, it locks edited layout, nobodyelse is able to + * When applet is started, it locks edited layout, nobody else is able to * edit this layout */ public void start() { Modified: trunk/layouteditor/LayoutDesigner/src/applet/MovingObject.java =================================================================== --- trunk/layouteditor/LayoutDesigner/src/applet/MovingObject.java 2010-02-18 22:32:39 UTC (rev 1789) +++ trunk/layouteditor/LayoutDesigner/src/applet/MovingObject.java 2010-02-18 23:44:53 UTC (rev 1790) @@ -167,8 +167,8 @@ .get(i)); } else { labelName += this - .getThreeBeginningLetters(permittedTypesOfDocuments - .get(i)); + .getThreeBeginningLetters(designArea.getProperties().getProperty(permittedTypesOfDocuments + .get(i))); } } Modified: trunk/layouteditor/LayoutDesigner/src/applet/ServerSideContext.java =================================================================== --- trunk/layouteditor/LayoutDesigner/src/applet/ServerSideContext.java 2010-02-18 22:32:39 UTC (rev 1789) +++ trunk/layouteditor/LayoutDesigner/src/applet/ServerSideContext.java 2010-02-18 23:44:53 UTC (rev 1790) @@ -9,6 +9,9 @@ import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import java.util.Vector; public class ServerSideContext { @@ -24,6 +27,7 @@ private boolean isLocked; /** flag whatever this layout is locked during opening */ private boolean isLockedByMe; /** flag whatever this layout is locked during saving */ private String lockedUser; /** name of user who has locked this layout */ + private String localization; /** suffix of properties file with localization */ // singleton variable private static ServerSideContext instance; /** instance of this class */ @@ -33,18 +37,21 @@ private static final String PROPREF_COMPANY_ID = "companyID"; /** name of parameter companyID */ private static final String PROPREF_LAYOUT_ID = "layoutID"; /** name of parameter layoutID */ private static final String PROPREF_USER_ID = "userID"; /** name of parameter userID */ + private static final String PROPREF_LOCALIZATION = "localization"; /** name of parameter localization */ private static final String PROP_SAVE_URL = "/dispatcher/storeLayout"; /** name of servlet for storing layout in dispatcher */ private static final String PROP_TYPES_URL = "/dispatcher/permTypes"; /** name of servlet for getting permitted types in dispatcher */ private static final String PROP_RESOLUTIONS_URL = "/dispatcher/resolutions"; /** name of servlet for getting supported resolution in dispatcher */ private static final String PROP_LOAD_LAYOUT_URL = "/dispatcher/loadLayoutByID"; /** name of servlet for loading layout in dispatcher */ private static final String PROP_LOCK_LAYOUT_URL = "/dispatcher/LayoutLocking"; /** name of servlet for layout locking in dispatcher */ private static final String ASPECT_RATIO_DELIMITER = " "; /** delimiter of aspect ratios */ - private static final String IS_LOCKED = "locked"; /** response from dispatcher that layout is locked */ - private static final String LOCK_ACTION = "lock"; - private static final String UNLOCK_ACTION = "unlock"; - private static final String LOCKED_BY_ME_ACTION ="lockedByMe"; - private static final String IS_LAYOUT_LOCKED="isLocked"; + private static final String IS_LOCKED = "locked"; /** dispatcher answer that layout is locked */ + private static final String LOCK_ACTION = "lock"; /** dispatcher request input - asks to lock layout */ + private static final String UNLOCK_ACTION = "unlock"; /** dispatcher request input - asks to unlock layout */ + private static final String LOCKED_BY_ME_ACTION ="lockedByMe"; /** dispatcher request input - asks whatever layout is locked by me */ + private static final String IS_LAYOUT_LOCKED="isLocked"; /** dispatcher request input - asks whatever layout is locked */ + private static final List<String> LOCALIZATION = Arrays.asList("cs"); /** list of all supported localization */ + // private constructor- due to singleton /** * Empty constructor of the class ServerSideContext @@ -91,7 +98,7 @@ instance.host = "http://"; + hostAddr + ":" + port; // for debugging: - //instance.host = "http://localhost:8080/";; + // instance.host = "http://localhost:8080/";; } @@ -115,6 +122,7 @@ String userID = applet.getParameter(PROPREF_USER_ID); instance.userID = Integer.parseInt(userID); + instance.setLocalization(applet.getParameter(PROPREF_LOCALIZATION)); // set permitted document types @@ -268,7 +276,6 @@ SupportedResolutions ratios = new SupportedResolutions(); if (result == null || result.equals("")) { - System.out.println("nedodany aspect-ratia"); return ratios; } else { StringReader strr = new StringReader(result); @@ -281,7 +288,6 @@ ratios.add(supportedResolution); } } - System.out.println("nacteny aspect-ratia"); return ratios; } } @@ -624,6 +630,7 @@ } /** + * Sets name of user who has this layout locked * @param lockedUser the lockedUser to set */ public void setLockedUser(String lockedUser) { @@ -631,10 +638,35 @@ } /** + * Gets name of user who has this layout locked * @return the lockedUser */ public String getLockedUser() { return lockedUser; } + /** + * Sets suffix of properties file with localization + * @param localization the localization to set + */ + public void setLocalization(String localization) { + this.localization = localization; + } + + /** + * Gets suffix of properties file with localization + * @return the localization + */ + public String getLocalization() { + return localization; + } + + /** + * Gets list of all supported localization + * @return the LOCALIZATION + */ + public List<String> getLOCALIZATION() { + return LOCALIZATION; + } + }