*/
private Component createLoginComponents() {
JPanel panel = new JPanel(new GridBagLayout());
panel.setBorder(BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(), GT._("Login")));
Configuration configuration = Configuration.getConfiguration();
// Initialize constraints
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.gridheight = 1;
constraints.gridwidth = 1;
constraints.gridx = 0;
constraints.gridy = 0;
constraints.insets = new Insets(1, 1, 1, 1);
constraints.ipadx = 0;
constraints.ipady = 0;
constraints.weightx = 0;
constraints.weighty = 0;
// Wikipedia
EnumWikipedia defaultWikipedia = configuration.getWikipedia();
comboWikipedia = new JComboBox(EnumWikipedia.getList().toArray());
comboWikipedia.setEditable(false);
comboWikipedia.setSelectedItem(defaultWikipedia);
comboWikipedia.addItemListener(EventHandler.create(
ItemListener.class, this, "actionChangeWiki"));
JLabel labelWikipedia = Utilities.createJLabel(GT._("Wiki"));
labelWikipedia.setLabelFor(comboWikipedia);
labelWikipedia.setHorizontalAlignment(SwingConstants.TRAILING);
JToolBar toolbarWikipedia = new JToolBar(SwingConstants.HORIZONTAL);
toolbarWikipedia.setFloatable(false);
toolbarWikipedia.setBorderPainted(false);
JButton buttonWikipediaInfo = Utilities.createJButton(
"tango-help-browser.png", EnumImageSize.SMALL,
GT._("Other Wikipedia"), false, null);
buttonWikipediaInfo.addActionListener(EventHandler.create(
ActionListener.class, this, "actionOtherWikipedia"));
toolbarWikipedia.add(buttonWikipediaInfo);
constraints.gridx = 0;
constraints.weightx = 0;
panel.add(labelWikipedia, constraints);
constraints.gridx = 1;
constraints.weightx = 1;
panel.add(comboWikipedia, constraints);
constraints.gridx = 2;
constraints.weightx = 0;
panel.add(toolbarWikipedia, constraints);
constraints.gridy++;
// Language
comboLanguage = new JComboBox(EnumLanguage.getList().toArray());
comboLanguage.setEditable(false);
comboLanguage.setSelectedItem(configuration.getLanguage());
comboLanguage.addItemListener(EventHandler.create(
ItemListener.class, this, "actionChangeLanguage"));
JLabel labelLanguage = Utilities.createJLabel(GT._("Language"));
labelLanguage.setLabelFor(comboLanguage);
labelLanguage.setHorizontalAlignment(SwingConstants.TRAILING);
JToolBar toolbarLanguage = new JToolBar(SwingConstants.HORIZONTAL);
toolbarLanguage.setFloatable(false);
toolbarLanguage.setBorderPainted(false);
JButton buttonLanguageInfo = Utilities.createJButton(
"tango-help-browser.png", EnumImageSize.SMALL,
GT._("Other Language"), false, null);
buttonLanguageInfo.addActionListener(EventHandler.create(
ActionListener.class, this, "actionOtherLanguage"));
toolbarLanguage.add(buttonLanguageInfo);
constraints.gridx = 0;
constraints.weightx = 0;
panel.add(labelLanguage, constraints);
constraints.gridx = 1;
constraints.weightx = 1;
panel.add(comboLanguage, constraints);
constraints.gridx = 2;
constraints.weightx = 0;
panel.add(toolbarLanguage, constraints);
constraints.gridy++;
// User name
comboUser = new JComboBox();
comboUser.setEditable(true);
comboUser.addItemListener(EventHandler.create(
ItemListener.class, this, "actionChangeUser"));
JLabel labelUsername = Utilities.createJLabel(GT._("Username:"));
labelUsername.setLabelFor(comboUser);
labelUsername.setHorizontalAlignment(SwingConstants.TRAILING);
constraints.gridx = 0;
constraints.weightx = 0;
panel.add(labelUsername, constraints);
constraints.gridx = 1;
constraints.weightx = 1;
panel.add(comboUser, constraints);
constraints.gridy++;
// Password
textPassword = new JPasswordField();
textPassword.setText("");
echoPassword = textPassword.getEchoChar();
JLabel labelPassword = Utilities.createJLabel(GT._("Password :"));
labelPassword.setLabelFor(textPassword);
labelPassword.setHorizontalAlignment(SwingConstants.TRAILING);
constraints.gridx = 0;
constraints.weightx = 0;
panel.add(labelPassword, constraints);
constraints.gridx = 1;
constraints.weightx = 1;
panel.add(textPassword, constraints);
constraints.gridy++;
// Login/Demo/Logout buttons
JToolBar buttonToolbar = new JToolBar(SwingConstants.HORIZONTAL);
buttonToolbar.setFloatable(false);
buttonToolbar.setBorderPainted(false);
buttonLogin = Utilities.createJButton(
GT._("Login"),
ConfigurationValueShortcut.LOGIN);
buttonLogin.addActionListener(EventHandler.create(
ActionListener.class, this, "actionLogin"));
buttonToolbar.add(buttonLogin);
buttonToolbar.addSeparator();
buttonDemo = Utilities.createJButton(GT._("Demo"), null);
buttonDemo.addActionListener(EventHandler.create(
ActionListener.class, this, "actionDemo"));
buttonToolbar.add(buttonDemo);
buttonToolbar.addSeparator();
buttonLogout = Utilities.createJButton(
GT._("Wiki logout"),
ConfigurationValueShortcut.LOGOUT);
buttonLogout.addActionListener(EventHandler.create(
ActionListener.class, this, "actionLogout"));
buttonToolbar.add(buttonLogout);
buttonToolbar.addSeparator();
buttonDisconnect = Utilities.createJButton(
GT._("WPC logout"), null);
buttonDisconnect.addActionListener(EventHandler.create(
ActionListener.class, this, "actionDisconnect"));
buttonToolbar.add(buttonDisconnect);
constraints.fill = GridBagConstraints.NONE;
constraints.gridwidth = 2;
constraints.gridx = 0;
constraints.weightx = 1;
panel.add(buttonToolbar, constraints);
constraints.gridy++;
// Buttons
buttonToolbar = new JToolBar(SwingConstants.HORIZONTAL);
buttonToolbar.setFloatable(false);
buttonToolbar.setBorderPainted(false);
buttonHelp = Utilities.createJButton(
"tango-help-browser.png", EnumImageSize.NORMAL,
GT._("Help"), false,
ConfigurationValueShortcut.HELP);
buttonHelp.addActionListener(EventHandler.create(
ActionListener.class, this, "actionHelp"));
buttonToolbar.add(buttonHelp);
buttonOptions = Utilities.createJButton(
"gnome-preferences-other.png", EnumImageSize.NORMAL,
GT._("Options"), false,
ConfigurationValueShortcut.OPTIONS);
buttonOptions.addActionListener(EventHandler.create(
ActionListener.class, this, "actionOptions"));
buttonToolbar.add(buttonOptions);
buttonOptionsSystem = Utilities.createJButton(
"gnome-preferences-system.png", EnumImageSize.NORMAL,
GT._("System options"), false,
ConfigurationValueShortcut.SYSTEM_OPTIONS);
buttonOptionsSystem.addActionListener(EventHandler.create(
ActionListener.class, this, "actionOptionsSystem"));
buttonToolbar.add(buttonOptionsSystem);
buttonReloadOptions = Utilities.createJButton(
"gnome-view-refresh.png", EnumImageSize.NORMAL,
GT._("Reload system options"), false, null);
buttonReloadOptions.addActionListener(EventHandler.create(
ActionListener.class, this, "actionReloadOptions"));
buttonToolbar.add(buttonReloadOptions);
buttonCheckSpelling = Utilities.createJButton(
"gnome-tools-check-spelling.png", EnumImageSize.NORMAL,
GT._("Check spelling options"), false, null);
buttonCheckSpelling.addActionListener(EventHandler.create(
ActionListener.class, this, "actionCheckSpelling"));
buttonToolbar.add(buttonCheckSpelling);
buttonToolbar.addSeparator();
buttonIdea = Utilities.createJButton(
GT._("Idea? Bug?"),
ConfigurationValueShortcut.BUG_REPORT);
buttonIdea.addActionListener(EventHandler.create(
ActionListener.class, this, "actionIdea"));
buttonToolbar.add(buttonIdea);
buttonToolbar.addSeparator();
buttonAbout = Utilities.createJButton(GT._("About"), null);
buttonAbout.addActionListener(EventHandler.create(
ActionListener.class, this, "actionAbout"));
buttonToolbar.add(buttonAbout);
constraints.fill = GridBagConstraints.NONE;
constraints.weighty = 0;
panel.add(buttonToolbar, constraints);
constraints.gridy++;
// Save password
int saveUser = configuration.getInt(
null, ConfigurationValueInteger.SAVE_USER);
groupSaveUsernamePassword = new ButtonGroup();
radSavePassword = Utilities.createJRadioButton(
GT._("Save username and password"),
(saveUser == ConfigurationConstants.VALUE_SAVE_USER_BOTH));