X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Fjsite%2Fgui%2FProjectInsertPage.java;h=563ef3cf1d267f3ae948c8810820c27a9234beca;hb=bf46824a2aee4b6b7e4753a74f7cc6d7c9d6c20b;hp=98d29c846dc2a12f29eea1ba6251e038462035a6;hpb=7a7dfd4c7096794e36c4e6d70792328e713bdd95;p=jSite.git
diff --git a/src/de/todesbaum/jsite/gui/ProjectInsertPage.java b/src/de/todesbaum/jsite/gui/ProjectInsertPage.java
index 98d29c8..563ef3c 100644
--- a/src/de/todesbaum/jsite/gui/ProjectInsertPage.java
+++ b/src/de/todesbaum/jsite/gui/ProjectInsertPage.java
@@ -56,19 +56,36 @@ import de.todesbaum.util.swing.TWizard;
import de.todesbaum.util.swing.TWizardPage;
/**
- * @author David Roden <droden@gmail.com>
- * @version $Id$
+ * Wizard page that shows the progress of an insert.
+ *
+ * @author David âBombeâ Roden <bombe@freenetproject.org>
*/
public class ProjectInsertPage extends TWizardPage implements InsertListener, ClipboardOwner {
- protected ProjectInserter projectInserter;
+ /** The project inserter. */
+ private ProjectInserter projectInserter;
- protected Action copyURIAction;
- protected JTextField requestURITextField;
- protected JLabel startTimeLabel;
- protected JProgressBar progressBar;
- protected long startTime = 0;
+ /** The âcopy URIâ action. */
+ private Action copyURIAction;
+ /** The ârequest URIâ textfield. */
+ private JTextField requestURITextField;
+
+ /** The âstart timeâ label. */
+ private JLabel startTimeLabel;
+
+ /** The progress bar. */
+ private JProgressBar progressBar;
+
+ /** The start time of the insert. */
+ private long startTime = 0;
+
+ /**
+ * Creates a new progress insert wizard page.
+ *
+ * @param wizard
+ * The wizard this page belongs to
+ */
public ProjectInsertPage(final TWizard wizard) {
super(wizard);
createActions();
@@ -85,9 +102,14 @@ public class ProjectInsertPage extends TWizardPage implements InsertListener, Cl
projectInserter = new ProjectInserter();
projectInserter.addInsertListener(this);
}
-
+
+ /**
+ * Creates all used actions.
+ */
private void createActions() {
copyURIAction = new AbstractAction(I18n.getMessage("jsite.project.action.copy-uri")) {
+
+ @SuppressWarnings("synthetic-access")
public void actionPerformed(ActionEvent actionEvent) {
actionCopyURI();
}
@@ -98,6 +120,7 @@ public class ProjectInsertPage extends TWizardPage implements InsertListener, Cl
I18nContainer.getInstance().registerRunnable(new Runnable() {
+ @SuppressWarnings("synthetic-access")
public void run() {
copyURIAction.putValue(Action.NAME, I18n.getMessage("jsite.project.action.copy-uri"));
copyURIAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.copy-uri.tooltip"));
@@ -105,11 +128,19 @@ public class ProjectInsertPage extends TWizardPage implements InsertListener, Cl
});
}
+ /**
+ * Initializes the page.
+ */
private void pageInit() {
setLayout(new BorderLayout(12, 12));
add(createProjectInsertPanel(), BorderLayout.CENTER);
}
+ /**
+ * Creates the main panel.
+ *
+ * @return The main panel
+ */
private JComponent createProjectInsertPanel() {
JComponent projectInsertPanel = new JPanel(new GridBagLayout());
@@ -137,6 +168,7 @@ public class ProjectInsertPage extends TWizardPage implements InsertListener, Cl
I18nContainer.getInstance().registerRunnable(new Runnable() {
+ @SuppressWarnings("synthetic-access")
public void run() {
projectInformationLabel.setText("" + I18n.getMessage("jsite.insert.project-information") + "");
requestURILabel.setText(I18n.getMessage("jsite.insert.request-uri") + ":");
@@ -164,36 +196,52 @@ public class ProjectInsertPage extends TWizardPage implements InsertListener, Cl
this.wizard.setQuitName(I18n.getMessage("jsite.wizard.quit"));
}
+ /**
+ * Starts the insert.
+ */
public void startInsert() {
wizard.setNextEnabled(false);
copyURIAction.setEnabled(false);
progressBar.setValue(0);
+ progressBar.setString(I18n.getMessage("jsite.insert.starting"));
progressBar.setFont(progressBar.getFont().deriveFont(Font.PLAIN));
projectInserter.start();
}
/**
+ * Sets whether to activate the debug mode.
+ *
* @param debug
- * The debug to set.
+ * true
to activate the debug mode,
+ * false
to deactivate.
*/
public void setDebug(boolean debug) {
projectInserter.setDebug(debug);
}
/**
+ * Sets the project to insert.
+ *
* @param project
- * The project to set.
+ * The project to insert
*/
public void setProject(final Project project) {
projectInserter.setProject(project);
SwingUtilities.invokeLater(new Runnable() {
+ @SuppressWarnings("synthetic-access")
public void run() {
requestURITextField.setText(project.getFinalRequestURI(1));
}
});
}
-
+
+ /**
+ * Sets the freenet interface to use.
+ *
+ * @param freenetInterface
+ * The freenet interface to use
+ */
public void setFreenetInterface(Freenet7Interface freenetInterface) {
projectInserter.setFreenetInterface(freenetInterface);
}
@@ -209,17 +257,20 @@ public class ProjectInsertPage extends TWizardPage implements InsertListener, Cl
startTime = System.currentTimeMillis();
SwingUtilities.invokeLater(new Runnable() {
+ @SuppressWarnings("synthetic-access")
public void run() {
startTimeLabel.setText(DateFormat.getDateTimeInstance().format(new Date(startTime)));
}
});
}
-
+
/**
* {@inheritDoc}
*/
public void projectURIGenerated(Project project, final String uri) {
SwingUtilities.invokeLater(new Runnable() {
+
+ @SuppressWarnings("synthetic-access")
public void run() {
copyURIAction.setEnabled(true);
requestURITextField.setText(uri);
@@ -233,6 +284,7 @@ public class ProjectInsertPage extends TWizardPage implements InsertListener, Cl
public void projectInsertProgress(Project project, final int succeeded, final int failed, final int fatal, final int total, final boolean finalized) {
SwingUtilities.invokeLater(new Runnable() {
+ @SuppressWarnings("synthetic-access")
public void run() {
progressBar.setMaximum(total);
progressBar.setValue(succeeded + failed + fatal);
@@ -264,20 +316,24 @@ public class ProjectInsertPage extends TWizardPage implements InsertListener, Cl
}
SwingUtilities.invokeLater(new Runnable() {
+ @SuppressWarnings("synthetic-access")
public void run() {
progressBar.setValue(progressBar.getMaximum());
- progressBar.setString("Done");
+ progressBar.setString(I18n.getMessage("jsite.insert.done"));
wizard.setNextEnabled(true);
wizard.setQuitEnabled(true);
}
});
}
-
+
//
// ACTIONS
//
-
- protected void actionCopyURI() {
+
+ /**
+ * Copies the request URI of the project to the clipboard.
+ */
+ private void actionCopyURI() {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(new StringSelection(requestURITextField.getText()), this);
}
@@ -285,11 +341,12 @@ public class ProjectInsertPage extends TWizardPage implements InsertListener, Cl
//
// INTERFACE ClipboardOwner
//
-
+
/**
* {@inheritDoc}
*/
public void lostOwnership(Clipboard clipboard, Transferable contents) {
+ /* ignore. */
}
}