/*
- * jSite - ProjectPage.java - Copyright © 2006–2012 David Roden
+ * jSite - ProjectPage.java - Copyright © 2006–2014 David Roden
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
import java.awt.event.KeyEvent;
import java.io.IOException;
import java.text.MessageFormat;
+import java.util.List;
+import java.util.Map.Entry;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.text.Document;
import javax.swing.text.DocumentFilter;
+import net.pterodactylus.util.swing.SortedListModel;
+import de.todesbaum.jsite.application.FileOption;
import de.todesbaum.jsite.application.Freenet7Interface;
-import de.todesbaum.jsite.application.KeyDialog;
import de.todesbaum.jsite.application.Project;
+import de.todesbaum.jsite.application.WebOfTrustInterface;
import de.todesbaum.jsite.i18n.I18n;
import de.todesbaum.jsite.i18n.I18nContainer;
-import de.todesbaum.util.swing.SortedListModel;
import de.todesbaum.util.swing.TLabel;
import de.todesbaum.util.swing.TWizard;
import de.todesbaum.util.swing.TWizardPage;
/** The freenet interface. */
private Freenet7Interface freenetInterface;
+ /** The web of trust interface. */
+ private WebOfTrustInterface webOfTrustInterface;
+
/** The “browse” action. */
private Action projectLocalPathBrowseAction;
I18nContainer.getInstance().registerRunnable(new Runnable() {
+ @Override
public void run() {
setHeading(I18n.getMessage("jsite.project.heading"));
setDescription(I18n.getMessage("jsite.project.description"));
private void createActions() {
projectLocalPathBrowseAction = new AbstractAction(I18n.getMessage("jsite.project.action.browse")) {
+ @Override
@SuppressWarnings("synthetic-access")
public void actionPerformed(ActionEvent actionEvent) {
actionLocalPathBrowse();
projectAddAction = new AbstractAction(I18n.getMessage("jsite.project.action.add-project")) {
+ @Override
@SuppressWarnings("synthetic-access")
public void actionPerformed(ActionEvent actionEvent) {
actionAdd();
projectDeleteAction = new AbstractAction(I18n.getMessage("jsite.project.action.delete-project")) {
+ @Override
@SuppressWarnings("synthetic-access")
public void actionPerformed(ActionEvent actionEvent) {
actionDelete();
projectCloneAction = new AbstractAction(I18n.getMessage("jsite.project.action.clone-project")) {
+ @Override
@SuppressWarnings("synthetic-access")
public void actionPerformed(ActionEvent actionEvent) {
actionClone();
projectCopyURIAction = new AbstractAction(I18n.getMessage("jsite.project.action.copy-uri")) {
+ @Override
@SuppressWarnings("synthetic-access")
public void actionPerformed(ActionEvent actionEvent) {
actionCopyURI();
projectManageKeysAction = new AbstractAction(I18n.getMessage("jsite.project.action.manage-keys")) {
+ @Override
@SuppressWarnings("synthetic-access")
public void actionPerformed(ActionEvent actionEvent) {
actionManageKeys();
projectResetEditionAction = new AbstractAction(I18n.getMessage("jsite.project.action.reset-edition")) {
+ @Override
@SuppressWarnings("synthetic-access")
public void actionPerformed(ActionEvent actionEvent) {
actionResetEdition();
I18nContainer.getInstance().registerRunnable(new Runnable() {
+ @Override
@SuppressWarnings("synthetic-access")
public void run() {
projectLocalPathBrowseAction.putValue(Action.NAME, I18n.getMessage("jsite.project.action.browse"));
I18nContainer.getInstance().registerRunnable(new Runnable() {
+ @Override
public void run() {
projectInformationLabel.setText("<html><b>" + I18n.getMessage("jsite.project.project.information") + "</b></html>");
projectNameLabel.setText(I18n.getMessage("jsite.project.project.name") + ":");
* @param projects
* The list of projects
*/
- public void setProjects(Project[] projects) {
+ public void setProjects(List<Project> projects) {
projectListModel.clear();
for (Project project : projects) {
projectListModel.add(project);
*
* @return The list of projects
*/
- public Project[] getProjects() {
- return projectListModel.toArray(new Project[projectListModel.size()]);
+ public List<Project> getProjects() {
+ return projectListModel;
}
/**
}
/**
+ * Sets the web of trust interface to use.
+ *
+ * @param webOfTrustInterface
+ * The web of trust interface to use
+ */
+ public void setWebOfTrustInterface(WebOfTrustInterface webOfTrustInterface) {
+ this.webOfTrustInterface = webOfTrustInterface;
+ }
+
+ /**
* Returns the currently selected project.
*
* @return The currently selected project
KeyDialog keyDialog = new KeyDialog(freenetInterface, wizard);
keyDialog.setPrivateKey(selectedProject.getInsertURI());
keyDialog.setPublicKey(selectedProject.getRequestURI());
+ keyDialog.setProjects(getProjects());
+ keyDialog.setOwnIdentities(webOfTrustInterface.getOwnIdentities());
keyDialog.setVisible(true);
if (!keyDialog.wasCancelled()) {
String originalPublicKey = selectedProject.getRequestURI();
selectedProject.setRequestURI(keyDialog.getPublicKey());
if (!originalPublicKey.equals(selectedProject.getRequestURI()) || !originalPrivateKey.equals(selectedProject.getInsertURI())) {
selectedProject.setEdition(-1);
+ for (Entry<String, FileOption> fileOption : selectedProject.getFileOptions().entrySet()) {
+ fileOption.getValue().setLastInsertHash(null);
+ }
}
updateCompleteURI();
}
/**
* {@inheritDoc}
*/
+ @Override
public void valueChanged(ListSelectionEvent listSelectionEvent) {
int selectedRow = projectList.getSelectedIndex();
Project selectedProject = (Project) projectList.getSelectedValue();
/**
* {@inheritDoc}
*/
+ @Override
public void insertUpdate(DocumentEvent documentEvent) {
setTextField(documentEvent);
}
/**
* {@inheritDoc}
*/
+ @Override
public void removeUpdate(DocumentEvent documentEvent) {
setTextField(documentEvent);
}
/**
* {@inheritDoc}
*/
+ @Override
public void changedUpdate(DocumentEvent documentEvent) {
setTextField(documentEvent);
}
/**
* {@inheritDoc}
*/
+ @Override
public void lostOwnership(Clipboard clipboard, Transferable contents) {
/* ignore. */
}