private void refreshPWLabel() { if (passwordMatch == null || passwordMatch.isDisposed()) return; byte[] password = COConfigurationManager.getByteParameter("Password", "".getBytes()); COConfigurationManager.setParameter("Password enabled", false); if (password.length == 0) { passwordMatch.setText(MessageText.getString(LBLKEY_PREFIX + "passwordmatchnone")); } else { byte[] confirm = COConfigurationManager.getByteParameter("Password Confirm", "".getBytes()); if (confirm.length == 0) { passwordMatch.setText(MessageText.getString(LBLKEY_PREFIX + "passwordmatchno")); } else { boolean same = true; for (int i = 0; i < password.length; i++) { if (password[i] != confirm[i]) same = false; } if (same) { passwordMatch.setText(MessageText.getString(LBLKEY_PREFIX + "passwordmatchyes")); COConfigurationManager.setParameter("Password enabled", true); } else { passwordMatch.setText(MessageText.getString(LBLKEY_PREFIX + "passwordmatchno")); } } } }
public void _setWhatsNew() { if (sWhatsNew.indexOf("<html") >= 0 || sWhatsNew.indexOf("<HTML") >= 0) { BrowserWrapper browser = Utils.createSafeBrowser(cWhatsNew, SWT.NONE); if (browser != null) { browser.setText(sWhatsNew); } else { try { File tempFile = File.createTempFile("AZU", ".html"); tempFile.deleteOnExit(); FileUtil.writeBytesAsFile(tempFile.getAbsolutePath(), sWhatsNew.getBytes("utf8")); Utils.launch(tempFile.getAbsolutePath()); shell.dispose(); return; } catch (IOException e) { } } } else { StyledText helpPanel = new StyledText(cWhatsNew, SWT.VERTICAL | SWT.HORIZONTAL); helpPanel.setEditable(false); try { helpPanel.setRedraw(false); helpPanel.setWordWrap(false); helpPanel.setFont(monospace); black = ColorCache.getColor(display, 0, 0, 0); white = ColorCache.getColor(display, 255, 255, 255); light = ColorCache.getColor(display, 200, 200, 200); grey = ColorCache.getColor(display, 50, 50, 50); green = ColorCache.getColor(display, 30, 80, 30); blue = ColorCache.getColor(display, 20, 20, 80); int style; boolean setStyle; helpPanel.setForeground(grey); String[] lines = sWhatsNew.split("\\r?\\n"); for (int i = 0; i < lines.length; i++) { String line = lines[i]; setStyle = false; fg = grey; bg = white; style = SWT.NORMAL; char styleChar; String text; if (line.length() < 2) { styleChar = ' '; text = " " + lineSeparator; } else { styleChar = line.charAt(0); text = line.substring(1) + lineSeparator; } switch (styleChar) { case '*': text = " * " + text; fg = green; setStyle = true; break; case '+': text = " " + text; fg = black; bg = light; style = SWT.BOLD; setStyle = true; break; case '!': style = SWT.BOLD; setStyle = true; break; case '@': fg = blue; setStyle = true; break; case '$': bg = blue; fg = white; style = SWT.BOLD; setStyle = true; break; case ' ': text = " " + text; break; default: text = styleChar + text; } helpPanel.append(text); if (setStyle) { int lineCount = helpPanel.getLineCount() - 1; int charCount = helpPanel.getCharCount(); // System.out.println("Got Linecount " + lineCount + ", Charcount " + // charCount); int lineOfs = helpPanel.getOffsetAtLine(lineCount - 1); int lineLen = charCount - lineOfs; // System.out.println("Setting Style : " + lineOfs + ", " + lineLen); helpPanel.setStyleRange(new StyleRange(lineOfs, lineLen, fg, bg, style)); helpPanel.setLineBackground(lineCount - 1, 1, bg); } } helpPanel.setRedraw(true); } catch (Exception e) { System.out.println("Unable to load help contents because:" + e); // e.printStackTrace(); } } if (labelLoading != null && !labelLoading.isDisposed()) { labelLoading.dispose(); } shell.layout(true, true); }