X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Fjsite%2Fgui%2FProjectPage.java;h=f68ec573df118c14ea445d02a48b0e93ea1c845c;hb=705ab7eee0d2b8194f6e8420ce3f588899f6da9a;hp=9f5c9699fb1db9262fcd17bf7ae061f77e1f9748;hpb=7a7dfd4c7096794e36c4e6d70792328e713bdd95;p=jSite.git diff --git a/src/de/todesbaum/jsite/gui/ProjectPage.java b/src/de/todesbaum/jsite/gui/ProjectPage.java index 9f5c969..f68ec57 100644 --- a/src/de/todesbaum/jsite/gui/ProjectPage.java +++ b/src/de/todesbaum/jsite/gui/ProjectPage.java @@ -52,8 +52,11 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import javax.swing.text.AbstractDocument; +import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.Document; +import javax.swing.text.DocumentFilter; import de.todesbaum.jsite.application.Freenet7Interface; import de.todesbaum.jsite.application.Project; @@ -81,6 +84,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D private JFileChooser pathChooser; private SortedListModel projectListModel; + private JScrollPane projectScrollPane; private JList projectList; private JTextField projectNameTextField; private JTextField projectDescriptionTextField; @@ -95,7 +99,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D dialogInit(); setHeading(I18n.getMessage("jsite.project.heading")); setDescription(I18n.getMessage("jsite.project.description")); - + I18nContainer.getInstance().registerRunnable(new Runnable() { public void run() { @@ -115,7 +119,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D projectList.addListSelectionListener(this); projectList.setPreferredSize(new Dimension(150, projectList.getPreferredSize().height)); - add(new JScrollPane(projectList), BorderLayout.LINE_START); + add(projectScrollPane = new JScrollPane(projectList), BorderLayout.LINE_START); add(createInformationPanel(), BorderLayout.CENTER); } @@ -203,9 +207,10 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D projectGenerateKeyAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.generate-new-key.tooltip")); projectGenerateKeyAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_G); projectGenerateKeyAction.setEnabled(false); - + I18nContainer.getInstance().registerRunnable(new Runnable() { + @SuppressWarnings("synthetic-access") public void run() { projectLocalPathBrowseAction.putValue(Action.NAME, I18n.getMessage("jsite.project.action.browse")); projectLocalPathBrowseAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.browse.tooltip")); @@ -219,6 +224,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D projectCopyURIAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.copy-uri.tooltip")); projectGenerateKeyAction.putValue(Action.NAME, I18n.getMessage("jsite.project.action.generate-new-key")); projectGenerateKeyAction.putValue(Action.SHORT_DESCRIPTION, I18n.getMessage("jsite.project.action.generate-new-key.tooltip")); + pathChooser.setApproveButtonText(I18n.getMessage("jsite.project.action.browse.choose")); } }); } @@ -294,6 +300,24 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D projectPathTextField = new JTextField(); projectPathTextField.getDocument().putProperty("name", "project.path"); projectPathTextField.getDocument().addDocumentListener(this); + ((AbstractDocument) projectPathTextField.getDocument()).setDocumentFilter(new DocumentFilter() { + + /** + * {@inheritDoc} + */ + @Override + public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException { + super.insertString(fb, offset, string.replaceAll("/", ""), attr); + } + + /** + * {@inheritDoc} + */ + @Override + public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException { + super.replace(fb, offset, length, text.replaceAll("/", ""), attrs); + } + }); projectPathTextField.setEnabled(false); final TLabel projectPathLabel = new TLabel(I18n.getMessage("jsite.project.project.path") + ":", KeyEvent.VK_P, projectPathTextField); @@ -397,8 +421,10 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D newProject.setName(I18n.getMessage("jsite.project.new-project.name")); newProject.setInsertURI(keyPair[0]); newProject.setRequestURI(keyPair[1]); - newProject.setEdition(1); + newProject.setEdition(0); projectListModel.add(newProject); + projectScrollPane.revalidate(); + projectScrollPane.repaint(); projectList.setSelectedIndex(projectListModel.size() - 1); } @@ -424,7 +450,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D projectList.setSelectedIndex(projectListModel.indexOf(newProject)); } } - + protected void actionCopyURI() { int selectedIndex = projectList.getSelectedIndex(); if (selectedIndex > -1) { @@ -433,7 +459,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D clipboard.setContents(new StringSelection(selectedProject.getFinalRequestURI(0)), this); } } - + protected void actionGenerateNewKey() { if (JOptionPane.showConfirmDialog(this, I18n.getMessage("jsite.project.warning.generate-new-key"), null, JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION) { return; @@ -521,7 +547,7 @@ public class ProjectPage extends TWizardPage implements ListSelectionListener, D public void changedUpdate(DocumentEvent documentEvent) { setTextField(documentEvent); } - + // // INTERFACE ClipboardOwner //