2 * jSite - a tool for uploading websites into Freenet
3 * Copyright (C) 2006 David Roden
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 package de.todesbaum.jsite.gui;
22 import java.awt.BorderLayout;
23 import java.awt.Dimension;
24 import java.awt.FlowLayout;
25 import java.awt.GridBagConstraints;
26 import java.awt.GridBagLayout;
27 import java.awt.Insets;
28 import java.awt.Toolkit;
29 import java.awt.datatransfer.Clipboard;
30 import java.awt.datatransfer.ClipboardOwner;
31 import java.awt.datatransfer.StringSelection;
32 import java.awt.datatransfer.Transferable;
33 import java.awt.event.ActionEvent;
34 import java.awt.event.KeyEvent;
35 import java.io.IOException;
36 import java.text.MessageFormat;
38 import javax.swing.AbstractAction;
39 import javax.swing.Action;
40 import javax.swing.JButton;
41 import javax.swing.JComponent;
42 import javax.swing.JFileChooser;
43 import javax.swing.JLabel;
44 import javax.swing.JList;
45 import javax.swing.JOptionPane;
46 import javax.swing.JPanel;
47 import javax.swing.JScrollPane;
48 import javax.swing.JTextField;
49 import javax.swing.ListSelectionModel;
50 import javax.swing.border.EmptyBorder;
51 import javax.swing.event.DocumentEvent;
52 import javax.swing.event.DocumentListener;
53 import javax.swing.event.ListSelectionEvent;
54 import javax.swing.event.ListSelectionListener;
55 import javax.swing.text.AbstractDocument;
56 import javax.swing.text.AttributeSet;
57 import javax.swing.text.BadLocationException;
58 import javax.swing.text.Document;
59 import javax.swing.text.DocumentFilter;
61 import de.todesbaum.jsite.application.Freenet7Interface;
62 import de.todesbaum.jsite.application.Project;
63 import de.todesbaum.jsite.i18n.I18n;
64 import de.todesbaum.jsite.i18n.I18nContainer;
65 import de.todesbaum.util.swing.SortedListModel;
66 import de.todesbaum.util.swing.TLabel;
67 import de.todesbaum.util.swing.TWizard;
68 import de.todesbaum.util.swing.TWizardPage;
71 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
73 public class ProjectPage extends TWizardPage implements ListSelectionListener, DocumentListener, ClipboardOwner {
75 private Freenet7Interface freenetInterface;
77 private Action projectLocalPathBrowseAction;
78 private Action projectAddAction;
79 private Action projectDeleteAction;
80 private Action projectCloneAction;
81 private Action projectCopyURIAction;
82 private Action projectGenerateKeyAction;
84 private JFileChooser pathChooser;
85 private SortedListModel projectListModel;
86 private JScrollPane projectScrollPane;
87 private JList projectList;
88 private JTextField projectNameTextField;
89 private JTextField projectDescriptionTextField;
90 private JTextField projectLocalPathTextField;
91 private JTextField projectPublicKeyTextField;
92 private JTextField projectPrivateKeyTextField;
93 private JTextField projectPathTextField;
95 public ProjectPage(final TWizard wizard) {
97 setLayout(new BorderLayout(12, 12));
99 setHeading(I18n.getMessage("jsite.project.heading"));
100 setDescription(I18n.getMessage("jsite.project.description"));
102 I18nContainer.getInstance().registerRunnable(new Runnable() {
105 setHeading(I18n.getMessage("jsite.project.heading"));
106 setDescription(I18n.getMessage("jsite.project.description"));
111 protected void dialogInit() {
114 pathChooser = new JFileChooser();
115 projectListModel = new SortedListModel();
116 projectList = new JList(projectListModel);
117 projectList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
118 projectList.addListSelectionListener(this);
119 projectList.setPreferredSize(new Dimension(150, projectList.getPreferredSize().height));
121 add(projectScrollPane = new JScrollPane(projectList), BorderLayout.LINE_START);
122 add(createInformationPanel(), BorderLayout.CENTER);
129 public void pageAdded(TWizard wizard) {
130 super.pageAdded(wizard);
131 projectList.clearSelection();
132 this.wizard.setPreviousName(I18n.getMessage("jsite.menu.nodes.manage-nodes"));
133 this.wizard.setNextName(I18n.getMessage("jsite.wizard.next"));
134 this.wizard.setQuitName(I18n.getMessage("jsite.wizard.quit"));
135 this.wizard.setNextEnabled(false);
140 public void addListSelectionListener(ListSelectionListener listener) {
141 projectList.addListSelectionListener(listener);
146 public void removeListSelectionListener(ListSelectionListener listener) {
147 projectList.removeListSelectionListener(listener);
150 private void createActions() {
151 projectLocalPathBrowseAction = new AbstractAction(I18n.getMessage("jsite.project.action.browse")) {
153 @SuppressWarnings("synthetic-access")
154 public void actionPerformed(ActionEvent actionEvent) {
155 actionLocalPathBrowse();
158 projectLocalPathBrowseAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.browse.tooltip"));
159 projectLocalPathBrowseAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_B);
160 projectLocalPathBrowseAction.setEnabled(false);
162 projectAddAction = new AbstractAction(I18n.getMessage("jsite.project.action.add-project")) {
164 @SuppressWarnings("synthetic-access")
165 public void actionPerformed(ActionEvent actionEvent) {
169 projectAddAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.add-project.tooltip"));
170 projectAddAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_A);
172 projectDeleteAction = new AbstractAction(I18n.getMessage("jsite.project.action.delete-project")) {
174 @SuppressWarnings("synthetic-access")
175 public void actionPerformed(ActionEvent actionEvent) {
179 projectDeleteAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.delete-project.tooltip"));
180 projectDeleteAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_D);
181 projectDeleteAction.setEnabled(false);
183 projectCloneAction = new AbstractAction(I18n.getMessage("jsite.project.action.clone-project")) {
185 @SuppressWarnings("synthetic-access")
186 public void actionPerformed(ActionEvent actionEvent) {
190 projectCloneAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.clone-project.tooltip"));
191 projectCloneAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_L);
192 projectCloneAction.setEnabled(false);
194 projectCopyURIAction = new AbstractAction(I18n.getMessage("jsite.project.action.copy-uri")) {
196 @SuppressWarnings("synthetic-access")
197 public void actionPerformed(ActionEvent actionEvent) {
201 projectCopyURIAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.copy-uri.tooltip"));
202 projectCopyURIAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_U);
203 projectCopyURIAction.setEnabled(false);
205 projectGenerateKeyAction = new AbstractAction(I18n.getMessage("jsite.project.action.generate-new-key")) {
207 @SuppressWarnings("synthetic-access")
208 public void actionPerformed(ActionEvent actionEvent) {
209 actionGenerateNewKey();
212 projectGenerateKeyAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.generate-new-key.tooltip"));
213 projectGenerateKeyAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_G);
214 projectGenerateKeyAction.setEnabled(false);
216 I18nContainer.getInstance().registerRunnable(new Runnable() {
218 @SuppressWarnings("synthetic-access")
220 projectLocalPathBrowseAction.putValue(Action.NAME, I18n.getMessage("jsite.project.action.browse"));
221 projectLocalPathBrowseAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.browse.tooltip"));
222 projectAddAction.putValue(Action.NAME, I18n.getMessage("jsite.project.action.add-project"));
223 projectAddAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.add-project.tooltip"));
224 projectDeleteAction.putValue(Action.NAME, I18n.getMessage("jsite.project.action.delete-project"));
225 projectDeleteAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.delete-project.tooltip"));
226 projectCloneAction.putValue(Action.NAME, I18n.getMessage("jsite.project.action.clone-project"));
227 projectCloneAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.clone-project.tooltip"));
228 projectCopyURIAction.putValue(Action.NAME, I18n.getMessage("jsite.project.action.copy-uri"));
229 projectCopyURIAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.copy-uri.tooltip"));
230 projectGenerateKeyAction.putValue(Action.NAME, I18n.getMessage("jsite.project.action.generate-new-key"));
231 projectGenerateKeyAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.generate-new-key.tooltip"));
232 pathChooser.setApproveButtonText(I18n.getMessage("jsite.project.action.browse.choose"));
237 private JComponent createInformationPanel() {
238 JPanel informationPanel = new JPanel(new BorderLayout(12, 12));
240 JPanel informationTable = new JPanel(new GridBagLayout());
242 JPanel functionButtons = new JPanel(new FlowLayout(FlowLayout.LEADING, 12, 12));
243 functionButtons.setBorder(new EmptyBorder(-12, -12, -12, -12));
244 functionButtons.add(new JButton(projectAddAction));
245 functionButtons.add(new JButton(projectDeleteAction));
246 functionButtons.add(new JButton(projectCloneAction));
247 functionButtons.add(new JButton(projectCopyURIAction));
249 informationPanel.add(functionButtons, BorderLayout.PAGE_START);
250 informationPanel.add(informationTable, BorderLayout.CENTER);
252 final JLabel projectInformationLabel = new JLabel("<html><b>" + I18n.getMessage("jsite.project.project.information") + "</b></html>");
253 informationTable.add(projectInformationLabel, new GridBagConstraints(0, 0, 3, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
255 projectNameTextField = new JTextField();
256 projectNameTextField.getDocument().putProperty("name", "project.name");
257 projectNameTextField.getDocument().addDocumentListener(this);
258 projectNameTextField.setEnabled(false);
260 final TLabel projectNameLabel = new TLabel(I18n.getMessage("jsite.project.project.name") + ":", KeyEvent.VK_N, projectNameTextField);
261 informationTable.add(projectNameLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
262 informationTable.add(projectNameTextField, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
264 projectDescriptionTextField = new JTextField();
265 projectDescriptionTextField.getDocument().putProperty("name", "project.description");
266 projectDescriptionTextField.getDocument().addDocumentListener(this);
267 projectDescriptionTextField.setEnabled(false);
269 final TLabel projectDescriptionLabel = new TLabel(I18n.getMessage("jsite.project.project.description") + ":", KeyEvent.VK_D, projectDescriptionTextField);
270 informationTable.add(projectDescriptionLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
271 informationTable.add(projectDescriptionTextField, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
273 projectLocalPathTextField = new JTextField();
274 projectLocalPathTextField.getDocument().putProperty("name", "project.localpath");
275 projectLocalPathTextField.getDocument().addDocumentListener(this);
276 projectLocalPathTextField.setEnabled(false);
278 final TLabel projectLocalPathLabel = new TLabel(I18n.getMessage("jsite.project.project.local-path") + ":", KeyEvent.VK_L, projectLocalPathTextField);
279 informationTable.add(projectLocalPathLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
280 informationTable.add(projectLocalPathTextField, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
281 informationTable.add(new JButton(projectLocalPathBrowseAction), new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
283 final JLabel projectAddressLabel = new JLabel("<html><b>" + I18n.getMessage("jsite.project.project.address") + "</b></html>");
284 informationTable.add(projectAddressLabel, new GridBagConstraints(0, 4, 3, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(12, 0, 0, 0), 0, 0));
286 projectPublicKeyTextField = new JTextField(27);
287 projectPublicKeyTextField.getDocument().putProperty("name", "project.publickey");
288 projectPublicKeyTextField.getDocument().addDocumentListener(this);
289 projectPublicKeyTextField.setEnabled(false);
291 final TLabel projectPublicKeyLabel = new TLabel(I18n.getMessage("jsite.project.project.public-key") + ":", KeyEvent.VK_U, projectPublicKeyTextField);
292 informationTable.add(projectPublicKeyLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
293 informationTable.add(projectPublicKeyTextField, new GridBagConstraints(1, 5, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
294 informationTable.add(new JButton(projectGenerateKeyAction), new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
296 projectPrivateKeyTextField = new JTextField(27);
297 projectPrivateKeyTextField.getDocument().putProperty("name", "project.privatekey");
298 projectPrivateKeyTextField.getDocument().addDocumentListener(this);
299 projectPrivateKeyTextField.setEnabled(false);
301 final TLabel projectPrivateKeyLabel = new TLabel(I18n.getMessage("jsite.project.project.private-key") + ":", KeyEvent.VK_R, projectPrivateKeyTextField);
302 informationTable.add(projectPrivateKeyLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
303 informationTable.add(projectPrivateKeyTextField, new GridBagConstraints(1, 6, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
305 projectPathTextField = new JTextField();
306 projectPathTextField.getDocument().putProperty("name", "project.path");
307 projectPathTextField.getDocument().addDocumentListener(this);
308 ((AbstractDocument) projectPathTextField.getDocument()).setDocumentFilter(new DocumentFilter() {
314 public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException {
315 super.insertString(fb, offset, string.replaceAll("/", ""), attr);
322 public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
323 super.replace(fb, offset, length, text.replaceAll("/", ""), attrs);
326 projectPathTextField.setEnabled(false);
328 final TLabel projectPathLabel = new TLabel(I18n.getMessage("jsite.project.project.path") + ":", KeyEvent.VK_P, projectPathTextField);
329 I18nContainer.getInstance().registerRunnable(new Runnable() {
332 projectInformationLabel.setText("<html><b>" + I18n.getMessage("jsite.project.project.information") + "</b></html>");
333 projectNameLabel.setText(I18n.getMessage("jsite.project.project.name") + ":");
334 projectDescriptionLabel.setText(I18n.getMessage("jsite.project.project.description") + ":");
335 projectLocalPathLabel.setText(I18n.getMessage("jsite.project.project.local-path") + ":");
336 projectAddressLabel.setText("<html><b>" + I18n.getMessage("jsite.project.project.address") + "</b></html>");
337 projectPublicKeyLabel.setText(I18n.getMessage("jsite.project.project.public-key") + ":");
338 projectPrivateKeyLabel.setText(I18n.getMessage("jsite.project.project.private-key") + ":");
339 projectPathLabel.setText(I18n.getMessage("jsite.project.project.path") + ":");
342 informationTable.add(projectPathLabel, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(6, 18, 0, 0), 0, 0));
343 informationTable.add(projectPathTextField, new GridBagConstraints(1, 7, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 0, 0), 0, 0));
345 return informationPanel;
348 public void setProjects(Project[] projects) {
349 projectListModel.clear();
350 for (Project project: projects) {
351 projectListModel.add(project);
355 public Project[] getProjects() {
356 return (Project[]) projectListModel.toArray(new Project[projectListModel.size()]);
360 * @param freenetInterface
361 * The freenetInterface to set.
363 public void setFreenetInterface(Freenet7Interface freenetInterface) {
364 this.freenetInterface = freenetInterface;
367 public Project getSelectedProject() {
368 return (Project) projectList.getSelectedValue();
371 private void setTextField(DocumentEvent documentEvent) {
372 Document document = documentEvent.getDocument();
373 String propertyName = (String) document.getProperty("name");
374 Project project = (Project) projectList.getSelectedValue();
375 if (project == null) {
379 String text = document.getText(0, document.getLength()).trim();
380 if ("project.name".equals(propertyName)) {
381 project.setName(text);
382 projectList.repaint();
383 } else if ("project.description".equals(propertyName)) {
384 project.setDescription(text);
385 } else if ("project.localpath".equals(propertyName)) {
386 project.setLocalPath(text);
387 } else if ("project.privatekey".equals(propertyName)) {
388 project.setInsertURI(text);
389 } else if ("project.publickey".equals(propertyName)) {
390 project.setRequestURI(text);
391 } else if ("project.path".equals(propertyName)) {
392 project.setPath(text);
394 } catch (BadLocationException e) {
402 private void actionLocalPathBrowse() {
403 Project project = (Project) projectList.getSelectedValue();
404 if (project == null) {
407 pathChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
408 if (pathChooser.showDialog(this, I18n.getMessage("jsite.project.action.browse.choose")) == JFileChooser.APPROVE_OPTION) {
409 projectLocalPathTextField.setText(pathChooser.getSelectedFile().getPath());
413 private void actionAdd() {
414 String[] keyPair = null;
415 if (!freenetInterface.hasNode()) {
416 JOptionPane.showMessageDialog(this, I18n.getMessage("jsite.project-files.no-node-selected"), null, JOptionPane.ERROR_MESSAGE);
420 keyPair = freenetInterface.generateKeyPair();
421 } catch (IOException ioe1) {
422 JOptionPane.showMessageDialog(this, MessageFormat.format(I18n.getMessage("jsite.project.keygen.io-error"), ioe1.getMessage()), null, JOptionPane.ERROR_MESSAGE);
425 Project newProject = new Project();
426 newProject.setName(I18n.getMessage("jsite.project.new-project.name"));
427 newProject.setInsertURI(keyPair[0]);
428 newProject.setRequestURI(keyPair[1]);
429 newProject.setEdition(0);
430 projectListModel.add(newProject);
431 projectScrollPane.revalidate();
432 projectScrollPane.repaint();
433 projectList.setSelectedIndex(projectListModel.size() - 1);
436 private void actionDelete() {
437 int selectedIndex = projectList.getSelectedIndex();
438 if (selectedIndex > -1) {
439 if (JOptionPane.showConfirmDialog(this, MessageFormat.format(I18n.getMessage("jsite.project.action.delete-project.confirm"), ((Project) projectList.getSelectedValue()).getName()), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
440 projectListModel.remove(selectedIndex);
441 projectList.clearSelection();
442 if (projectListModel.getSize() != 0) {
443 projectList.setSelectedIndex(Math.min(selectedIndex, projectListModel.getSize() - 1));
449 private void actionClone() {
450 int selectedIndex = projectList.getSelectedIndex();
451 if (selectedIndex > -1) {
452 Project newProject = new Project((Project) projectList.getSelectedValue());
453 newProject.setName(MessageFormat.format(I18n.getMessage("jsite.project.action.clone-project.copy"), newProject.getName()));
454 projectListModel.add(newProject);
455 projectList.setSelectedIndex(projectListModel.indexOf(newProject));
459 private void actionCopyURI() {
460 int selectedIndex = projectList.getSelectedIndex();
461 if (selectedIndex > -1) {
462 Project selectedProject = (Project) projectList.getSelectedValue();
463 Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
464 clipboard.setContents(new StringSelection(selectedProject.getFinalRequestURI(0)), this);
468 private void actionGenerateNewKey() {
469 if (JOptionPane.showConfirmDialog(this, I18n.getMessage("jsite.project.warning.generate-new-key"), null, JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION) {
472 int selectedIndex = projectList.getSelectedIndex();
473 if (selectedIndex > -1) {
474 Project selectedProject = (Project) projectList.getSelectedValue();
475 String[] keyPair = null;
477 keyPair = freenetInterface.generateKeyPair();
478 } catch (IOException ioe1) {
479 JOptionPane.showMessageDialog(this, MessageFormat.format(I18n.getMessage("jsite.project.keygen.io-error"), ioe1.getMessage()), null, JOptionPane.ERROR_MESSAGE);
482 selectedProject.setInsertURI(keyPair[0]);
483 selectedProject.setRequestURI(keyPair[1]);
484 projectPublicKeyTextField.setText(selectedProject.getRequestURI());
485 projectPrivateKeyTextField.setText(selectedProject.getInsertURI());
490 // INTERFACE ListSelectionListener
496 public void valueChanged(ListSelectionEvent listSelectionEvent) {
497 int selectedRow = projectList.getSelectedIndex();
498 Project selectedProject = (Project) projectList.getSelectedValue();
499 projectNameTextField.setEnabled(selectedRow > -1);
500 projectDescriptionTextField.setEnabled(selectedRow > -1);
501 projectLocalPathTextField.setEnabled(selectedRow > -1);
502 projectPublicKeyTextField.setEnabled(selectedRow > -1);
503 projectPrivateKeyTextField.setEnabled(selectedRow > -1);
504 projectPathTextField.setEnabled(selectedRow > -1);
505 projectLocalPathBrowseAction.setEnabled(selectedRow > -1);
506 projectDeleteAction.setEnabled(selectedRow > -1);
507 projectCloneAction.setEnabled(selectedRow > -1);
508 projectCopyURIAction.setEnabled(selectedRow > -1);
509 projectGenerateKeyAction.setEnabled(selectedRow > -1);
510 if (selectedRow > -1) {
511 projectNameTextField.setText(selectedProject.getName());
512 projectDescriptionTextField.setText(selectedProject.getDescription());
513 projectLocalPathTextField.setText(selectedProject.getLocalPath());
514 projectPublicKeyTextField.setText(selectedProject.getRequestURI());
515 projectPrivateKeyTextField.setText(selectedProject.getInsertURI());
516 projectPathTextField.setText(selectedProject.getPath());
518 projectNameTextField.setText("");
519 projectDescriptionTextField.setText("");
520 projectLocalPathTextField.setText("");
521 projectPublicKeyTextField.setText("");
522 projectPrivateKeyTextField.setText("");
523 projectPathTextField.setText("");
528 // INTERFACE ChangeListener
532 // INTERFACE DocumentListener
538 public void insertUpdate(DocumentEvent documentEvent) {
539 setTextField(documentEvent);
545 public void removeUpdate(DocumentEvent documentEvent) {
546 setTextField(documentEvent);
552 public void changedUpdate(DocumentEvent documentEvent) {
553 setTextField(documentEvent);
557 // INTERFACE ClipboardOwner
563 public void lostOwnership(Clipboard clipboard, Transferable contents) {