public LoginUI(IAuthentication authentication) { Container container = getContentPane(); mainPanel = new GridBagLayoutPanel(); usernameField = new JTextField(25); passwordField = new JPasswordField(25); serverURLField = new JTextField(25); String server_text = (String) authentication.get("server_url"); if (server_text != null) { serverURLField.setText(server_text); } buttonPanel = new JPanel(); okButton = new JButton(PluginServices.getText(this, "login_ok")); okButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { OK(); } }); exitButton = new JButton(PluginServices.getText(this, "login_exit")); exitButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { Cancel(); } }); buttonPanel.add(okButton); buttonPanel.add(exitButton); JPanel logoPanel = new JPanel(); logoPanel.add(new JLabel(gvsigIcon)); logoPanel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 10)); container.add(logoPanel, BorderLayout.WEST); container.add(mainPanel, BorderLayout.CENTER); mainPanel.addComponent(PluginServices.getText(this, "login_name"), usernameField); mainPanel.addComponent(PluginServices.getText(this, "login_password"), passwordField); mainPanel.addComponent(PluginServices.getText(this, "login_name"), serverURLField); invalidLoginLabel = new JLabel(PluginServices.getText(this, "login_invalid_user")); invalidLoginLabel.setForeground(Color.RED); invalidLoginLabel.setVisible(false); mainPanel.addComponent(invalidLoginLabel, buttonPanel); mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); this.authentication = authentication; this.setBounds(400, 400, this.getWidth(), this.getHeight()); this.setTitle("Login"); this.setModal(true); this.setSize(400, 200); this.setResizable(false); pack(); setVisible(true); }
public FolderingPage() { super(); setParentID(GeneralPage.id); icon = PluginServices.getIconTheme().get("folder-icon"); btnFileChooserAction = new ActionListener() { public void actionPerformed(ActionEvent e) { String path; if (e.getSource().equals(btnSelectProjectsFolder)) { path = txtProjectsFolder.getText(); } else if (e.getSource().equals(btnSelectDataFolder)) { path = txtDataFolder.getText(); } else if (e.getSource().equals(btnSelectSymbolLibraryFolder)) { path = txtSymbolLibraryFolder.getText(); } else { path = txtTemplatesFolder.getText(); } // The file filter for the JFileChooser FileFilter def = new FileFilter() { public boolean accept(File f) { return (f.isDirectory()); } public String getDescription() { return null; } }; File file = new File(path); JFileChooser fc; if (file.exists()) { fc = new JFileChooser(file); } else { fc = new JFileChooser(); } fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.setMultiSelectionEnabled(false); fc.setAcceptAllFileFilterUsed(false); fc.addChoosableFileFilter(def); int result = fc.showOpenDialog(FolderingPage.this); if (result == JFileChooser.APPROVE_OPTION && (file = fc.getSelectedFile()) != null) { if (e.getSource().equals(btnSelectProjectsFolder)) { txtProjectsFolder.setText(file.getAbsolutePath()); } else if (e.getSource().equals(btnSelectDataFolder)) { txtDataFolder.setText(file.getAbsolutePath()); } else if (e.getSource().equals(btnSelectSymbolLibraryFolder)) { txtSymbolLibraryFolder.setText(file.getAbsolutePath()); } else { txtTemplatesFolder.setText(file.getAbsolutePath()); } } } }; btnSelectProjectsFolder = new JButton(PluginServices.getText(this, "browse")); btnSelectProjectsFolder.addActionListener(btnFileChooserAction); btnSelectDataFolder = new JButton(PluginServices.getText(this, "browse")); btnSelectDataFolder.addActionListener(btnFileChooserAction); btnSelectTemplatesFolder = new JButton(PluginServices.getText(this, "browse")); btnSelectTemplatesFolder.addActionListener(btnFileChooserAction); btnSelectSymbolLibraryFolder = new JButton(PluginServices.getText(this, "browse")); btnSelectSymbolLibraryFolder.addActionListener(btnFileChooserAction); JLabel lblProjectsFolder = new JLabel( "<html><b>" + PluginServices.getText(this, "options.foldering.projects_folder") + "</b></html>"); addComponent(lblProjectsFolder); addComponent(txtProjectsFolder = new JTextField(30), btnSelectProjectsFolder); addComponent(new JLabel(" ")); JLabel lblDataFolder = new JLabel( "<html><b>" + PluginServices.getText(this, "options.foldering.data_folder") + "</b></html>"); addComponent(lblDataFolder); addComponent(txtDataFolder = new JTextField(30), btnSelectDataFolder); addComponent(new JLabel(" ")); JLabel lblTemplatesFolder = new JLabel( "<html><b>" + PluginServices.getText(this, "options.foldering.template_folder") + "</b></html>"); addComponent(lblTemplatesFolder); addComponent(txtTemplatesFolder = new JTextField(30), btnSelectTemplatesFolder); addComponent(new JLabel(" ")); JLabel lblSymbolLibraryFolder = new JLabel( "<html><b>" + PluginServices.getText(this, "options.foldering.symbol_library_folder") + "</b></html>"); addComponent(lblSymbolLibraryFolder); addComponent(txtSymbolLibraryFolder = new JTextField(30), btnSelectSymbolLibraryFolder); addComponent(new JLabel(" ")); PluginServices ps = PluginServices.getPluginServices(this); XMLEntity xml = ps.getPersistentXML(); if (xml.contains(PROJECTS_FOLDER_PROPERTY_NAME)) { prefs.put( PROJECTS_FOLDER_PROPERTY_NAME, xml.getStringProperty(PROJECTS_FOLDER_PROPERTY_NAME)); } if (xml.contains(DATA_FOLDER_PROPERTY_NAME)) { prefs.put(DATA_FOLDER_PROPERTY_NAME, xml.getStringProperty(DATA_FOLDER_PROPERTY_NAME)); } if (xml.contains(TEMPLATES_FOLDER_PROPERTY_NAME)) { prefs.put( TEMPLATES_FOLDER_PROPERTY_NAME, xml.getStringProperty(TEMPLATES_FOLDER_PROPERTY_NAME)); } if (xml.contains(SYMBOL_LIBRARY_FOLDER_PROPERTY_NAME)) { prefs.put( SYMBOL_LIBRARY_FOLDER_PROPERTY_NAME, xml.getStringProperty(SYMBOL_LIBRARY_FOLDER_PROPERTY_NAME)); } }