SPARK-1258

default.properties
Plugins downloading setting
plugins deleting setting
look and feel change setting
look and feel default setting
---------------------------------
polish update in spellchecker

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12158 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Wolf Posdorfer
2011-03-22 10:28:31 +00:00
committed by wolf.posdorfer
parent a1ade79122
commit 8eed6dc308
12 changed files with 135 additions and 53 deletions

View File

@ -329,7 +329,7 @@ public final class LoginDialog {
autoLoginBox.addActionListener(this);
if (!"true".equals(Default.getString(Default.ACCOUNT_DISABLED))) {
if (!Default.getBoolean(Default.ACCOUNT_DISABLED)) {
buttonPanel.add(createAccountButton,
new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0));
@ -899,7 +899,7 @@ public final class LoginDialog {
if (!ModelUtil.hasLength(resource)) {
resource = "spark";
}
connection.login(getUsername(), getPassword(), resource);
connection.login(getUsername(), getPassword(), modifyWildcards(resource));
sessionManager.setServerAddress(connection.getServiceName());
sessionManager.initializeSession(connection, getUsername(), getPassword());
@ -1007,7 +1007,27 @@ public final class LoginDialog {
return !hasErrors;
}
public void handle(Callback[] callbacks) throws IOException {
/**
* Modifies Wildcards such as <code>$r</code>,<code>$s</code>,<code>$v</code>
* into what they represent r = randomnumber , s=os.name, v=os.version
* @param resource
* @return
*/
private String modifyWildcards(String resource) {
resource = resource.replace("$r",
"" + Math.round((Math.random() * 1000)));
resource = resource.replace("$s", System.getProperty("os.name")
.replace(" ", ""));
resource = resource.replace("$v", System.getProperty("os.version")
.replace(" ", ""));
return resource;
}
public void handle(Callback[] callbacks) throws IOException {
for (Callback callback : callbacks) {
if (callback instanceof NameCallback) {
NameCallback ncb = (NameCallback) callback;

View File

@ -169,38 +169,10 @@ public final class Spark {
// Set default language set by the user.
loadLanguage();
final LocalPreferences preferences = SettingsManager.getLocalPreferences();
final String laf = preferences.getLookAndFeel();
try {
String classname = UIManager.getSystemLookAndFeelClassName();
if (laf.toLowerCase().contains("substance")) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
if (Spark.isWindows()) {
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
}
UIManager.setLookAndFeel(laf);
} catch (Exception e) {
// dont care
e.printStackTrace();
}
}
});
} else {
try {
UIManager.setLookAndFeel(classname);
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (Exception e) {
Log.error(e);
}
installBaseUIProperties();
/**
* Loads the LookandFeel
*/
loadLookAndFeel();
buf.append(classPath);
@ -233,6 +205,52 @@ public final class Spark {
}
}
/**
* Handles the Loading of the Look And Feel
*/
private void loadLookAndFeel() {
final LocalPreferences preferences = SettingsManager.getLocalPreferences();
final String laf;
if(Default.getString(Default.DEFAULT_LOOK_AND_FEEL).length()>0)
{
laf = Default.getString(Default.DEFAULT_LOOK_AND_FEEL);
}
else
{
laf = preferences.getLookAndFeel();
}
try {
String classname = UIManager.getSystemLookAndFeelClassName();
if (laf.toLowerCase().contains("substance")) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
if (Spark.isWindows()) {
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
}
UIManager.setLookAndFeel(laf);
} catch (Exception e) {
// dont care
e.printStackTrace();
}
}
});
} else {
try {
UIManager.setLookAndFeel(classname);
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (Exception e) {
Log.error(e);
}
installBaseUIProperties();
}
// Setup the look and feel of this application.
static {
@ -388,7 +406,7 @@ public final class Spark {
}
public static boolean isCustomBuild() {
return "true".equals(Default.getString("CUSTOM"));
return Default.getBoolean("CUSTOM");
}
public static void setApplicationFont(Font f) {
@ -400,6 +418,9 @@ public final class Spark {
}
}
/**
* Sets Spark specific colors
*/
public static void installBaseUIProperties() {
setApplicationFont(new Font("Dialog", Font.PLAIN, 11));
UIManager.put("TextField.lightforeground", Color.gray);

View File

@ -59,6 +59,11 @@ public class Default {
public static final String CHANGE_PASSWORD_DISABLED = "CHANGE_PASSWORD_DISABLED";
public static final String TRAY_IMAGE = "TRAY_IMAGE";
public static final String FRAME_IMAGE = "FRAME_IMAGE";
public static final String LOOK_AND_FEEL_DISABLED = "LOOK_AND_FEEL_DISABLED";
public static final String DEFAULT_LOOK_AND_FEEL = "DEFAULT_LOOK_AND_FEEL";
public static final String INSTALL_PLUGINS_DISABLED = "INSTALL_PLUGINS_DISABLED";
public static final String DEINSTALL_PLUGINS_DISABLED = "DEINSTALL_PLUGINS_DISABLED";
static ClassLoader cl = SparkRes.class.getClassLoader();
@ -82,6 +87,10 @@ public class Default {
return prb.getString(propertyName);
}
public static boolean getBoolean(String propertyName) {
return prb.getString(propertyName).equals("true");
}
public static ImageIcon getImageIcon(String imageName) {
// Check custom map
Object o = customMap.get(imageName);

View File

@ -1,3 +1,5 @@
# The Login image
# suggested image dimensions 244 x 188 pixels
MAIN_IMAGE = images/spark.png
APPLICATION_NAME = Spark
SHORT_NAME = Spark
@ -7,9 +9,14 @@ SECONDARY_BACKGROUND_IMAGE = images/steel.png
# Branding only
# Branded images appear in the Top-Right corner, and must be included in the classpath
# place them in src/resource/images and path will be "images/file.jpg"
BRANDED_IMAGE =
# Specify a fixed Hostname
# Changing the Hostname will also be prohibited if set
HOST_NAME =
SHOW_POWERED_BY =
# if Custom build = true, there will be no references anywhere to igniterealtime.org
CUSTOM =
@ -27,11 +34,24 @@ TAB_END_COLOR =
PROXY_HOST =
PROXY_PORT =
# Account Disabled
# Remove account creation Button from Loginwindow
ACCOUNT_DISABLED =
# add Contact Disabled
# Disables adding of contacts
ADD_CONTACT_DISABLED =
# Change Password Disabled
CHANGE_PASSWORD_DISABLED =
# Disable Look&Feel change || "true" = disabled , anything else = enabled
LOOK_AND_FEEL_DISABLED =
# you can use org.jvnet.substance.skin.SubstanceBusinessBlueSteelLookAndFeel for example
# If Setting this you should also consider disabling the above
DEFAULT_LOOK_AND_FEEL =
# Disable Installing of Plugins
# set true if you want to disable installing of Plugins
INSTALL_PLUGINS_DISABLED =
# Disable deleting of Plugins
# set true if you want to disable deinstalling of Plugins
DEINSTALL_PLUGINS_DISABLED =

View File

@ -281,7 +281,7 @@ public final class ContactList extends JPanel implements ActionListener,
final RolloverButton addContactButton = new RolloverButton(SparkRes.getImageIcon(SparkRes.USER1_ADD_16x16));
if (!"true".equals(Default.getString(Default.ADD_CONTACT_DISABLED))) {
if (!Default.getBoolean(Default.ADD_CONTACT_DISABLED)) {
commandPanel.add(addContactButton);
}
addContactButton.setToolTipText(Res.getString("message.add.a.contact"));
@ -1419,7 +1419,7 @@ public final class ContactList extends JPanel implements ActionListener,
final JPopupMenu popup = new JPopupMenu();
if (!"true".equals(Default.getString(Default.ADD_CONTACT_DISABLED))) {
if (!Default.getBoolean(Default.ADD_CONTACT_DISABLED)) {
popup.add(addContactMenu);
}
@ -1926,7 +1926,7 @@ public final class ContactList extends JPanel implements ActionListener,
ResourceUtils.resButton(addContactsMenu, Res.getString("menuitem.add.contact"));
ResourceUtils.resButton(addContactGroupMenu, Res.getString("menuitem.add.contact.group"));
if (!"true".equals(Default.getString(Default.ADD_CONTACT_DISABLED))) {
if (!Default.getBoolean(Default.ADD_CONTACT_DISABLED)) {
contactsMenu.add(addContactsMenu);
}
contactsMenu.add(addContactGroupMenu);

View File

@ -163,7 +163,7 @@ public class ChatRoomImpl extends ChatRoom {
addToRosterButton = new ChatRoomButton("", SparkRes.getImageIcon(SparkRes.ADD_IMAGE_24x24));
if (entry == null && !StringUtils.parseResource(participantJID).equals(participantNickname)) {
addToRosterButton.setToolTipText(Res.getString("message.add.this.user.to.your.roster"));
if (!"true".equals(Default.getString(Default.ADD_CONTACT_DISABLED))) {
if(!Default.getBoolean(Default.ADD_CONTACT_DISABLED)) {
getToolBar().addChatRoomButton(addToRosterButton);
}
addToRosterButton.addActionListener(this);

View File

@ -20,6 +20,7 @@
package org.jivesoftware.spark.ui.themes;
import org.jivesoftware.Spark;
import org.jivesoftware.resource.Default;
import org.jivesoftware.resource.Res;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.ui.TranscriptWindow;
@ -147,6 +148,10 @@ public class ThemePanel extends JPanel {
_lookandfeel = new JComboBox(lafname);
if (Default.getBoolean(Default.LOOK_AND_FEEL_DISABLED)){
_lookandfeel.disable();
}
_lookandfeelLabel = new JLabel(Res.getString("lookandfeel.select"));
_lookandfeelpreview = new JButton(Res.getString("lookandfeel.change.now"));

View File

@ -27,6 +27,7 @@ import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;
import org.jivesoftware.resource.Default;
import org.jivesoftware.resource.Res;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.spark.PluginManager;
@ -115,8 +116,9 @@ public class PluginViewer extends JPanel implements Plugin {
// Add Tabs
tabbedPane.addTab(Res.getString("tab.installed.plugins"), new JScrollPane(installedPanel));
if(!Default.getBoolean(Default.INSTALL_PLUGINS_DISABLED)){
tabbedPane.addTab(Res.getString("tab.available.plugins"), new JScrollPane(availablePanel));
}
loadInstalledPlugins();

View File

@ -40,6 +40,7 @@ import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.jivesoftware.resource.Default;
import org.jivesoftware.resource.Res;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.spark.PluginManager;
@ -167,6 +168,9 @@ public class SparkPlugUI extends JPanel {
setBackground(new Color(234, 230, 212));
showOperationButton();
setBorder(BorderFactory.createEtchedBorder());
if (Default.getBoolean(Default.DEINSTALL_PLUGINS_DISABLED)) {
installButton.setVisible(false);
}
}
else {
setBackground(Color.white);

View File

@ -103,7 +103,7 @@ public class ChatPreferencePanel extends JPanel implements ActionListener {
generalPanel.setBorder(BorderFactory.createTitledBorder(Res.getString("group.general.information")));
chatWindowPanel.setBorder(BorderFactory.createTitledBorder(Res.getString("group.chat.window.information")));
if (!"true".equals(Default.getString(Default.CHANGE_PASSWORD_DISABLED))) {
if (!Default.getBoolean(Default.CHANGE_PASSWORD_DISABLED)) {
add(generalPanel);
}
add(chatWindowPanel);

View File

@ -188,7 +188,7 @@ public class UserSearchResults extends JPanel {
}
};
if (!"true".equals(Default.getString(Default.ADD_CONTACT_DISABLED))) {
if (!Default.getBoolean(Default.ADD_CONTACT_DISABLED)) {
final JMenuItem addAsContact = new JMenuItem(addContactAction);
addContactAction.putValue(Action.SMALL_ICON, SparkRes.getImageIcon(SparkRes.SMALL_ADD_IMAGE));
addContactAction.putValue(Action.NAME, Res.getString("menuitem.add.as.contact"));

View File

@ -3,3 +3,4 @@ title.spellchecker = Sprawdzanie pisowni
preference.spellcheckingEnabled = W\u0142\u0105cz sprawdzanie pisowni
preference.autoSpellcheckingEnabled = W\u0142\u0105cz automatyczne sprawdzanie pisowni
preference.language = J\u0119zyk - s\u0142ownik
button.check.spelling = Sprawd\u017a pisowni\u0119