import de.todesbaum.util.swing.TWizardPage;
/**
+ * 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();
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();
}
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"));
});
}
+ /**
+ * 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());
I18nContainer.getInstance().registerRunnable(new Runnable() {
+ @SuppressWarnings("synthetic-access")
public void run() {
projectInformationLabel.setText("<html><b>" + I18n.getMessage("jsite.insert.project-information") + "</b></html>");
requestURILabel.setText(I18n.getMessage("jsite.insert.request-uri") + ":");
this.wizard.setQuitName(I18n.getMessage("jsite.wizard.quit"));
}
+ /**
+ * Starts the insert.
+ */
public void startInsert() {
wizard.setNextEnabled(false);
copyURIAction.setEnabled(false);
}
/**
+ * Sets whether to activate the debug mode.
+ *
* @param debug
- * The debug to set.
+ * <code>true</code> to activate the debug mode,
+ * <code>false</code> 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);
}
startTime = System.currentTimeMillis();
SwingUtilities.invokeLater(new Runnable() {
+ @SuppressWarnings("synthetic-access")
public void run() {
startTimeLabel.setText(DateFormat.getDateTimeInstance().format(new Date(startTime)));
}
*/
public void projectURIGenerated(Project project, final String uri) {
SwingUtilities.invokeLater(new Runnable() {
+
+ @SuppressWarnings("synthetic-access")
public void run() {
copyURIAction.setEnabled(true);
requestURITextField.setText(uri);
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);
}
SwingUtilities.invokeLater(new Runnable() {
+ @SuppressWarnings("synthetic-access")
public void run() {
progressBar.setValue(progressBar.getMaximum());
progressBar.setString(I18n.getMessage("jsite.insert.done"));
// 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);
}
* {@inheritDoc}
*/
public void lostOwnership(Clipboard clipboard, Transferable contents) {
+ /* ignore. */
}
}