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 Roden <droden@gmail.com>
74 public class ProjectPage extends TWizardPage implements ListSelectionListener, DocumentListener, ClipboardOwner {
76 private Freenet7Interface freenetInterface;
78 protected Action projectLocalPathBrowseAction;
79 protected Action projectAddAction;
80 protected Action projectDeleteAction;
81 protected Action projectCloneAction;
82 protected Action projectCopyURIAction;
83 protected Action projectGenerateKeyAction;
85 private JFileChooser pathChooser;
86 private SortedListModel projectListModel;
87 private JScrollPane projectScrollPane;
88 private JList projectList;
89 private JTextField projectNameTextField;
90 private JTextField projectDescriptionTextField;
91 private JTextField projectLocalPathTextField;
92 private JTextField projectPublicKeyTextField;
93 private JTextField projectPrivateKeyTextField;
94 private JTextField projectPathTextField;
96 public ProjectPage(final TWizard wizard) {
98 setLayout(new BorderLayout(12, 12));
100 setHeading(I18n.getMessage("jsite.project.heading"));
101 setDescription(I18n.getMessage("jsite.project.description"));
103 I18nContainer.getInstance().registerRunnable(new Runnable() {
106 setHeading(I18n.getMessage("jsite.project.heading"));
107 setDescription(I18n.getMessage("jsite.project.description"));
112 protected void dialogInit() {
115 pathChooser = new JFileChooser();
116 projectListModel = new SortedListModel();
117 projectList = new JList(projectListModel);
118 projectList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
119 projectList.addListSelectionListener(this);
120 projectList.setPreferredSize(new Dimension(150, projectList.getPreferredSize().height));
122 add(projectScrollPane = new JScrollPane(projectList), BorderLayout.LINE_START);
123 add(createInformationPanel(), BorderLayout.CENTER);
130 public void pageAdded(TWizard wizard) {
131 super.pageAdded(wizard);
132 projectList.clearSelection();
133 this.wizard.setPreviousName(I18n.getMessage("jsite.menu.nodes.manage-nodes"));
134 this.wizard.setNextName(I18n.getMessage("jsite.wizard.next"));
135 this.wizard.setQuitName(I18n.getMessage("jsite.wizard.quit"));
136 this.wizard.setNextEnabled(false);
141 public void addListSelectionListener(ListSelectionListener listener) {
142 projectList.addListSelectionListener(listener);
147 public void removeListSelectionListener(ListSelectionListener listener) {
148 projectList.removeListSelectionListener(listener);
151 private void createActions() {
152 projectLocalPathBrowseAction = new AbstractAction(I18n.getMessage("jsite.project.action.browse")) {
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 public void actionPerformed(ActionEvent actionEvent) {
168 projectAddAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.add-project.tooltip"));
169 projectAddAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_A);
171 projectDeleteAction = new AbstractAction(I18n.getMessage("jsite.project.action.delete-project")) {
173 public void actionPerformed(ActionEvent actionEvent) {
177 projectDeleteAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.delete-project.tooltip"));
178 projectDeleteAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_D);
179 projectDeleteAction.setEnabled(false);
181 projectCloneAction = new AbstractAction(I18n.getMessage("jsite.project.action.clone-project")) {
183 public void actionPerformed(ActionEvent actionEvent) {
187 projectCloneAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.clone-project.tooltip"));
188 projectCloneAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_L);
189 projectCloneAction.setEnabled(false);
191 projectCopyURIAction = new AbstractAction(I18n.getMessage("jsite.project.action.copy-uri")) {
193 public void actionPerformed(ActionEvent actionEvent) {
197 projectCopyURIAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.copy-uri.tooltip"));
198 projectCopyURIAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_U);
199 projectCopyURIAction.setEnabled(false);
201 projectGenerateKeyAction = new AbstractAction(I18n.getMessage("jsite.project.action.generate-new-key")) {
203 public void actionPerformed(ActionEvent actionEvent) {
204 actionGenerateNewKey();
207 projectGenerateKeyAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.generate-new-key.tooltip"));
208 projectGenerateKeyAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_G);
209 projectGenerateKeyAction.setEnabled(false);
211 I18nContainer.getInstance().registerRunnable(new Runnable() {
213 @SuppressWarnings("synthetic-access")
215 projectLocalPathBrowseAction.putValue(Action.NAME, I18n.getMessage("jsite.project.action.browse"));
216 projectLocalPathBrowseAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.browse.tooltip"));
217 projectAddAction.putValue(Action.NAME, I18n.getMessage("jsite.project.action.add-project"));
218 projectAddAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.add-project.tooltip"));
219 projectDeleteAction.putValue(Action.NAME, I18n.getMessage("jsite.project.action.delete-project"));
220 projectDeleteAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.delete-project.tooltip"));
221 projectCloneAction.putValue(Action.NAME, I18n.getMessage("jsite.project.action.clone-project"));
222 projectCloneAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.clone-project.tooltip"));
223 projectCopyURIAction.putValue(Action.NAME, I18n.getMessage("jsite.project.action.copy-uri"));
224 projectCopyURIAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.copy-uri.tooltip"));
225 projectGenerateKeyAction.putValue(Action.NAME, I18n.getMessage("jsite.project.action.generate-new-key"));
226 projectGenerateKeyAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.generate-new-key.tooltip"));
227 pathChooser.setApproveButtonText(I18n.getMessage("jsite.project.action.browse.choose"));
232 private JComponent createInformationPanel() {
233 JPanel informationPanel = new JPanel(new BorderLayout(12, 12));
235 JPanel informationTable = new JPanel(new GridBagLayout());
237 JPanel functionButtons = new JPanel(new FlowLayout(FlowLayout.LEADING, 12, 12));
238 functionButtons.setBorder(new EmptyBorder(-12, -12, -12, -12));
239 functionButtons.add(new JButton(projectAddAction));
240 functionButtons.add(new JButton(projectDeleteAction));
241 functionButtons.add(new JButton(projectCloneAction));
242 functionButtons.add(new JButton(projectCopyURIAction));
244 informationPanel.add(functionButtons, BorderLayout.PAGE_START);
245 informationPanel.add(informationTable, BorderLayout.CENTER);
247 final JLabel projectInformationLabel = new JLabel("<html><b>" + I18n.getMessage("jsite.project.project.information") + "</b></html>");
248 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));
250 projectNameTextField = new JTextField();
251 projectNameTextField.getDocument().putProperty("name", "project.name");
252 projectNameTextField.getDocument().addDocumentListener(this);
253 projectNameTextField.setEnabled(false);
255 final TLabel projectNameLabel = new TLabel(I18n.getMessage("jsite.project.project.name") + ":", KeyEvent.VK_N, projectNameTextField);
256 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));
257 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));
259 projectDescriptionTextField = new JTextField();
260 projectDescriptionTextField.getDocument().putProperty("name", "project.description");
261 projectDescriptionTextField.getDocument().addDocumentListener(this);
262 projectDescriptionTextField.setEnabled(false);
264 final TLabel projectDescriptionLabel = new TLabel(I18n.getMessage("jsite.project.project.description") + ":", KeyEvent.VK_D, projectDescriptionTextField);
265 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));
266 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));
268 projectLocalPathTextField = new JTextField();
269 projectLocalPathTextField.getDocument().putProperty("name", "project.localpath");
270 projectLocalPathTextField.getDocument().addDocumentListener(this);
271 projectLocalPathTextField.setEnabled(false);
273 final TLabel projectLocalPathLabel = new TLabel(I18n.getMessage("jsite.project.project.local-path") + ":", KeyEvent.VK_L, projectLocalPathTextField);
274 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));
275 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));
276 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));
278 final JLabel projectAddressLabel = new JLabel("<html><b>" + I18n.getMessage("jsite.project.project.address") + "</b></html>");
279 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));
281 projectPublicKeyTextField = new JTextField(27);
282 projectPublicKeyTextField.getDocument().putProperty("name", "project.publickey");
283 projectPublicKeyTextField.getDocument().addDocumentListener(this);
284 projectPublicKeyTextField.setEnabled(false);
286 final TLabel projectPublicKeyLabel = new TLabel(I18n.getMessage("jsite.project.project.public-key") + ":", KeyEvent.VK_U, projectPublicKeyTextField);
287 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));
288 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));
289 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));
291 projectPrivateKeyTextField = new JTextField(27);
292 projectPrivateKeyTextField.getDocument().putProperty("name", "project.privatekey");
293 projectPrivateKeyTextField.getDocument().addDocumentListener(this);
294 projectPrivateKeyTextField.setEnabled(false);
296 final TLabel projectPrivateKeyLabel = new TLabel(I18n.getMessage("jsite.project.project.private-key") + ":", KeyEvent.VK_R, projectPrivateKeyTextField);
297 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));
298 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));
300 projectPathTextField = new JTextField();
301 projectPathTextField.getDocument().putProperty("name", "project.path");
302 projectPathTextField.getDocument().addDocumentListener(this);
303 ((AbstractDocument) projectPathTextField.getDocument()).setDocumentFilter(new DocumentFilter() {
309 public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException {
310 super.insertString(fb, offset, string.replaceAll("/", ""), attr);
317 public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
318 super.replace(fb, offset, length, text.replaceAll("/", ""), attrs);
321 projectPathTextField.setEnabled(false);
323 final TLabel projectPathLabel = new TLabel(I18n.getMessage("jsite.project.project.path") + ":", KeyEvent.VK_P, projectPathTextField);
324 I18nContainer.getInstance().registerRunnable(new Runnable() {
327 projectInformationLabel.setText("<html><b>" + I18n.getMessage("jsite.project.project.information") + "</b></html>");
328 projectNameLabel.setText(I18n.getMessage("jsite.project.project.name") + ":");
329 projectDescriptionLabel.setText(I18n.getMessage("jsite.project.project.description") + ":");
330 projectLocalPathLabel.setText(I18n.getMessage("jsite.project.project.local-path") + ":");
331 projectAddressLabel.setText("<html><b>" + I18n.getMessage("jsite.project.project.address") + "</b></html>");
332 projectPublicKeyLabel.setText(I18n.getMessage("jsite.project.project.public-key") + ":");
333 projectPrivateKeyLabel.setText(I18n.getMessage("jsite.project.project.private-key") + ":");
334 projectPathLabel.setText(I18n.getMessage("jsite.project.project.path") + ":");
337 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));
338 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));
340 return informationPanel;
343 public void setProjects(Project[] projects) {
344 projectListModel.clear();
345 for (Project project: projects) {
346 projectListModel.add(project);
350 public Project[] getProjects() {
351 return (Project[]) projectListModel.toArray(new Project[projectListModel.size()]);
355 * @param freenetInterface
356 * The freenetInterface to set.
358 public void setFreenetInterface(Freenet7Interface freenetInterface) {
359 this.freenetInterface = freenetInterface;
362 public Project getSelectedProject() {
363 return (Project) projectList.getSelectedValue();
366 private void setTextField(DocumentEvent documentEvent) {
367 Document document = documentEvent.getDocument();
368 String propertyName = (String) document.getProperty("name");
369 Project project = (Project) projectList.getSelectedValue();
370 if (project == null) {
374 String text = document.getText(0, document.getLength()).trim();
375 if ("project.name".equals(propertyName)) {
376 project.setName(text);
377 projectList.repaint();
378 } else if ("project.description".equals(propertyName)) {
379 project.setDescription(text);
380 } else if ("project.localpath".equals(propertyName)) {
381 project.setLocalPath(text);
382 } else if ("project.privatekey".equals(propertyName)) {
383 project.setInsertURI(text);
384 } else if ("project.publickey".equals(propertyName)) {
385 project.setRequestURI(text);
386 } else if ("project.path".equals(propertyName)) {
387 project.setPath(text);
389 } catch (BadLocationException e) {
397 protected void actionLocalPathBrowse() {
398 Project project = (Project) projectList.getSelectedValue();
399 if (project == null) {
402 pathChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
403 if (pathChooser.showDialog(this, I18n.getMessage("jsite.project.action.browse.choose")) == JFileChooser.APPROVE_OPTION) {
404 projectLocalPathTextField.setText(pathChooser.getSelectedFile().getPath());
408 protected void actionAdd() {
409 String[] keyPair = null;
410 if (!freenetInterface.hasNode()) {
411 JOptionPane.showMessageDialog(this, I18n.getMessage("jsite.project-files.no-node-selected"), null, JOptionPane.ERROR_MESSAGE);
415 keyPair = freenetInterface.generateKeyPair();
416 } catch (IOException ioe1) {
417 JOptionPane.showMessageDialog(this, MessageFormat.format(I18n.getMessage("jsite.project.keygen.io-error"), ioe1.getMessage()), null, JOptionPane.ERROR_MESSAGE);
420 Project newProject = new Project();
421 newProject.setName(I18n.getMessage("jsite.project.new-project.name"));
422 newProject.setInsertURI(keyPair[0]);
423 newProject.setRequestURI(keyPair[1]);
424 newProject.setEdition(0);
425 projectListModel.add(newProject);
426 projectScrollPane.revalidate();
427 projectScrollPane.repaint();
428 projectList.setSelectedIndex(projectListModel.size() - 1);
431 protected void actionDelete() {
432 int selectedIndex = projectList.getSelectedIndex();
433 if (selectedIndex > -1) {
434 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) {
435 projectListModel.remove(selectedIndex);
436 projectList.clearSelection();
437 if (projectListModel.getSize() != 0) {
438 projectList.setSelectedIndex(Math.min(selectedIndex, projectListModel.getSize() - 1));
444 protected void actionClone() {
445 int selectedIndex = projectList.getSelectedIndex();
446 if (selectedIndex > -1) {
447 Project newProject = new Project((Project) projectList.getSelectedValue());
448 newProject.setName(MessageFormat.format(I18n.getMessage("jsite.project.action.clone-project.copy"), newProject.getName()));
449 projectListModel.add(newProject);
450 projectList.setSelectedIndex(projectListModel.indexOf(newProject));
454 protected void actionCopyURI() {
455 int selectedIndex = projectList.getSelectedIndex();
456 if (selectedIndex > -1) {
457 Project selectedProject = (Project) projectList.getSelectedValue();
458 Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
459 clipboard.setContents(new StringSelection(selectedProject.getFinalRequestURI(0)), this);
463 protected void actionGenerateNewKey() {
464 if (JOptionPane.showConfirmDialog(this, I18n.getMessage("jsite.project.warning.generate-new-key"), null, JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION) {
467 int selectedIndex = projectList.getSelectedIndex();
468 if (selectedIndex > -1) {
469 Project selectedProject = (Project) projectList.getSelectedValue();
470 String[] keyPair = null;
472 keyPair = freenetInterface.generateKeyPair();
473 } catch (IOException ioe1) {
474 JOptionPane.showMessageDialog(this, MessageFormat.format(I18n.getMessage("jsite.project.keygen.io-error"), ioe1.getMessage()), null, JOptionPane.ERROR_MESSAGE);
477 selectedProject.setInsertURI(keyPair[0]);
478 selectedProject.setRequestURI(keyPair[1]);
479 projectPublicKeyTextField.setText(selectedProject.getRequestURI());
480 projectPrivateKeyTextField.setText(selectedProject.getInsertURI());
485 // INTERFACE ListSelectionListener
491 public void valueChanged(ListSelectionEvent listSelectionEvent) {
492 int selectedRow = projectList.getSelectedIndex();
493 Project selectedProject = (Project) projectList.getSelectedValue();
494 projectNameTextField.setEnabled(selectedRow > -1);
495 projectDescriptionTextField.setEnabled(selectedRow > -1);
496 projectLocalPathTextField.setEnabled(selectedRow > -1);
497 projectPublicKeyTextField.setEnabled(selectedRow > -1);
498 projectPrivateKeyTextField.setEnabled(selectedRow > -1);
499 projectPathTextField.setEnabled(selectedRow > -1);
500 projectLocalPathBrowseAction.setEnabled(selectedRow > -1);
501 projectDeleteAction.setEnabled(selectedRow > -1);
502 projectCloneAction.setEnabled(selectedRow > -1);
503 projectCopyURIAction.setEnabled(selectedRow > -1);
504 projectGenerateKeyAction.setEnabled(selectedRow > -1);
505 if (selectedRow > -1) {
506 projectNameTextField.setText(selectedProject.getName());
507 projectDescriptionTextField.setText(selectedProject.getDescription());
508 projectLocalPathTextField.setText(selectedProject.getLocalPath());
509 projectPublicKeyTextField.setText(selectedProject.getRequestURI());
510 projectPrivateKeyTextField.setText(selectedProject.getInsertURI());
511 projectPathTextField.setText(selectedProject.getPath());
513 projectNameTextField.setText("");
514 projectDescriptionTextField.setText("");
515 projectLocalPathTextField.setText("");
516 projectPublicKeyTextField.setText("");
517 projectPrivateKeyTextField.setText("");
518 projectPathTextField.setText("");
523 // INTERFACE ChangeListener
527 // INTERFACE DocumentListener
533 public void insertUpdate(DocumentEvent documentEvent) {
534 setTextField(documentEvent);
540 public void removeUpdate(DocumentEvent documentEvent) {
541 setTextField(documentEvent);
547 public void changedUpdate(DocumentEvent documentEvent) {
548 setTextField(documentEvent);
552 // INTERFACE ClipboardOwner
558 public void lostOwnership(Clipboard clipboard, Transferable contents) {