/** * Constructs a new modal {@code FileCrypter}. * * @param encrypt Whether to encrypt or decrypt the files * @param files The files to encrypt or decrypt * @see #init() */ private FileCrypter(boolean encrypt, @Nullable VFSFile... files) { super( jEdit.getActiveView(), jEdit.getProperty(encrypt ? "cipher.file-encrypter.title" : "cipher.file-decrypter.title"), true); this.encrypt = encrypt; this.files = files; cipherOptionPane = new CipherOptionPane(false, false); newFileHandlingLabel = new JLabel(jEdit.getProperty("cipher.file-crypter.new-file-handling.label")); Dimension dim = new Dimension(20, 0); firstColumnFiller = new Filler(dim, dim, dim); directoryFiller = new Filler(dim, dim, dim); suffixFiller = new Filler(dim, dim, dim); overwriteRadioButton = new JRadioButton(jEdit.getProperty("cipher.file-crypter.overwrite.label"), false); dim = overwriteRadioButton.getMaximumSize(); dim.width = Integer.MAX_VALUE; overwriteRadioButton.setMaximumSize(dim); newFileHandlingLabel.setLabelFor(overwriteRadioButton); otherDirectoryRadioButton = new JRadioButton(jEdit.getProperty("cipher.file-crypter.other-directory.label"), false); dim = otherDirectoryRadioButton.getMaximumSize(); dim.width = Integer.MAX_VALUE; otherDirectoryRadioButton.setMaximumSize(dim); directoryLabel = new JLabel(jEdit.getProperty("cipher.file-crypter.directory.label")); directoryTextField = new JTextField(jEdit.getProperty("options.cipher.file-crypter.directory")); directoryTextField.setEditable(false); directoryTextField.setColumns(25); directoryTextField.setCaretPosition(0); directoryLabel.setLabelFor(directoryTextField); chooseDirectoryButton = new JButton(jEdit.getProperty("cipher.file-crypter.choose-button.label")); dim = chooseDirectoryButton.getMaximumSize(); dim.height = Integer.MAX_VALUE; chooseDirectoryButton.setMaximumSize(dim); suffixRadioButton = new JRadioButton(jEdit.getProperty("cipher.file-crypter.suffix-radio-button.label"), false); dim = suffixRadioButton.getMaximumSize(); dim.width = Integer.MAX_VALUE; suffixRadioButton.setMaximumSize(dim); suffixLabel = new JLabel(jEdit.getProperty("cipher.file-crypter.suffix.label")); suffixTextField = new JTextField(jEdit.getProperty("options.cipher.file-crypter.suffix")); suffixTextField.setColumns(25); suffixTextField.setCaretPosition(0); suffixLabel.setLabelFor(suffixTextField); cryptButton = new JButton( jEdit.getProperty( encrypt ? "cipher.file-crypter.encrypt-button.label" : "cipher.file-crypter.decrypt-button.label")); dim = cryptButton.getMaximumSize(); dim.width = Integer.MAX_VALUE; cryptButton.setMaximumSize(dim); getRootPane().setDefaultButton(cryptButton); NewFileHandling newFileHandling = Enum.valueOf( NewFileHandling.class, jEdit.getProperty("options.cipher.file-crypter.new-file-handling", "OVERWRITE")); switch (newFileHandling) { case OVERWRITE: overwriteRadioButton.setSelected(true); break; case OTHER_DIRECTORY: otherDirectoryRadioButton.setSelected(true); break; case SUFFIX: suffixRadioButton.setSelected(true); break; default: throw new InternalError("missing case branch for NewFileHandling: " + newFileHandling); } ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(overwriteRadioButton); buttonGroup.add(otherDirectoryRadioButton); buttonGroup.add(suffixRadioButton); setLayout(new ExtendedGridLayout(5, 5, new Insets(5, 5, 5, 5))); add(cipherOptionPane, new ExtendedGridLayoutConstraints(0, 5, 1, cipherOptionPane)); add(newFileHandlingLabel, new ExtendedGridLayoutConstraints(1, 5, 1, newFileHandlingLabel)); add(firstColumnFiller, new ExtendedGridLayoutConstraints(2, 1, 5, firstColumnFiller)); add(overwriteRadioButton, new ExtendedGridLayoutConstraints(2, 4, 1, overwriteRadioButton)); add( otherDirectoryRadioButton, new ExtendedGridLayoutConstraints(3, 4, 1, otherDirectoryRadioButton)); add(directoryFiller, new ExtendedGridLayoutConstraints(4, directoryFiller)); add(directoryLabel, new ExtendedGridLayoutConstraints(4, directoryLabel)); add(directoryTextField, new ExtendedGridLayoutConstraints(4, directoryTextField)); add(chooseDirectoryButton, new ExtendedGridLayoutConstraints(4, chooseDirectoryButton)); add(suffixRadioButton, new ExtendedGridLayoutConstraints(5, 4, 1, suffixRadioButton)); add(suffixFiller, new ExtendedGridLayoutConstraints(6, suffixFiller)); add(suffixLabel, new ExtendedGridLayoutConstraints(6, suffixLabel)); add(suffixTextField, new ExtendedGridLayoutConstraints(6, 2, 1, suffixTextField)); add(cryptButton, new ExtendedGridLayoutConstraints(7, 5, 1, cryptButton)); }
void jbInit() throws Exception { this.setResizable(false); // Build headerPanel headerPanel.setBackground(Color.WHITE); headerPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); header.setFont(new java.awt.Font("Dialog", 0, 20)); header.setForeground(new Color(0, 0, 124)); header.setText(Local.getString("Event")); header.setIcon( new ImageIcon( net.sf.memoranda.ui.EventDialog.class.getResource("resources/icons/event48.png"))); headerPanel.add(header); // Build eventPanel lblTime.setText(Local.getString("Time")); lblTime.setMinimumSize(new Dimension(60, 24)); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.insets = new Insets(10, 10, 5, 10); gbc.anchor = GridBagConstraints.WEST; eventPanel.add(lblTime, gbc); timeSpin.setPreferredSize(new Dimension(60, 24)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.insets = new Insets(10, 0, 5, 5); gbc.anchor = GridBagConstraints.WEST; eventPanel.add(timeSpin, gbc); lblText.setText(Local.getString("Text")); lblText.setMinimumSize(new Dimension(120, 24)); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 3; gbc.insets = new Insets(5, 10, 5, 10); gbc.anchor = GridBagConstraints.WEST; eventPanel.add(lblText, gbc); textField.setMinimumSize(new Dimension(375, 24)); textField.setPreferredSize(new Dimension(375, 24)); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.gridwidth = 6; gbc.insets = new Insets(5, 10, 10, 10); gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; eventPanel.add(textField, gbc); // Build RepeatPanel repeatBorder = new TitledBorder(BorderFactory.createLineBorder(Color.gray, 1), Local.getString("Repeat")); // Added by (jcscoobyrs) on 12-Nov-2003 at 15:34:27 PM // --------------------------------------------------- SimpleDateFormat sdf = new SimpleDateFormat(); sdf = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT); // Build ButtonsPanel okB.setMaximumSize(new Dimension(100, 26)); okB.setMinimumSize(new Dimension(100, 26)); okB.setPreferredSize(new Dimension(100, 26)); okB.setText(Local.getString("Ok")); okB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { okB_actionPerformed(e); } }); this.getRootPane().setDefaultButton(okB); cancelB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { cancelB_actionPerformed(e); } }); cancelB.setText(Local.getString("Cancel")); cancelB.setPreferredSize(new Dimension(100, 26)); cancelB.setMinimumSize(new Dimension(100, 26)); cancelB.setMaximumSize(new Dimension(100, 26)); buttonsPanel.add(okB); buttonsPanel.add(cancelB); // Finally build the Dialog topPanel.add(headerPanel, BorderLayout.NORTH); topPanel.add(eventPanel, BorderLayout.SOUTH); GridBagConstraints gbc_repeatPanel = new GridBagConstraints(); gbc_repeatPanel.insets = new Insets(0, 0, 0, 5); gbc_repeatPanel.gridx = 1; gbc_repeatPanel.gridy = 3; eventPanel.add(repeatPanel, gbc_repeatPanel); repeatPanel.setBorder(repeatBorder); noRepeatRB.setMaximumSize(new Dimension(80, 35)); noRepeatRB.setSelected(true); noRepeatRB.setText(Local.getString("No repeat")); noRepeatRB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { noRepeatRB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 4; gbc.insets = new Insets(5, 5, 5, 0); gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; repeatPanel.add(noRepeatRB, gbc); dailyRepeatRB.setActionCommand("daily"); dailyRepeatRB.setText(Local.getString("Every")); dailyRepeatRB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { dailyRepeatRB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.insets = new Insets(5, 5, 5, 0); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(dailyRepeatRB, gbc); daySpin.setPreferredSize(new Dimension(50, 24)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.insets = new Insets(5, 5, 5, 0); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(daySpin, gbc); lblDays.setText(Local.getString("day(s)")); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 1; gbc.gridwidth = 2; gbc.insets = new Insets(5, 5, 5, 40); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(lblDays, gbc); lblSince.setText(Local.getString("Since")); lblSince.setMinimumSize(new Dimension(70, 16)); gbc = new GridBagConstraints(); gbc.gridx = 4; gbc.gridy = 1; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.EAST; repeatPanel.add(lblSince, gbc); startDate.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { if (ignoreStartChanged) return; ignoreStartChanged = true; Date sd = (Date) startDate.getModel().getValue(); Date ed = (Date) endDate.getModel().getValue(); // Commented out, value was resetted to endDate !!! if (sd.after(ed)) { endDate.getModel().setValue(sd); ed = sd; } startCalFrame.cal.set(new CalendarDate(sd)); ignoreStartChanged = false; } }); startDate.setPreferredSize(new Dimension(80, 24)); startDate.setEditor(new JSpinner.DateEditor(startDate, sdf.toPattern())); // --------------------------------------------------- gbc = new GridBagConstraints(); gbc.gridx = 5; gbc.gridy = 1; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(startDate, gbc); setStartDateB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { setStartDateB_actionPerformed(e); } }); setStartDateB.setIcon( new ImageIcon( net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/calendar.png"))); setStartDateB.setText(""); setStartDateB.setPreferredSize(new Dimension(24, 24)); gbc = new GridBagConstraints(); gbc.gridx = 6; gbc.gridy = 1; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(setStartDateB, gbc); weeklyRepeatRB.setActionCommand("weekly"); weeklyRepeatRB.setText(Local.getString("Every")); weeklyRepeatRB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { weeklyRepeatRB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(weeklyRepeatRB, gbc); weekdaysCB.setPreferredSize(new Dimension(100, 25)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 2; gbc.gridwidth = 2; gbc.insets = new Insets(5, 0, 5, 40); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(weekdaysCB, gbc); enableEndDateCB.setHorizontalAlignment(SwingConstants.RIGHT); enableEndDateCB.setText(Local.getString("Till")); enableEndDateCB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { enableEndDateCB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 4; gbc.gridy = 2; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.EAST; repeatPanel.add(enableEndDateCB, gbc); endDate.setPreferredSize(new Dimension(80, 24)); // Added by (jcscoobyrs) on 12-Nov-2003 at 15:34:27 PM // --------------------------------------------------- endDate.setEditor(new JSpinner.DateEditor(endDate, sdf.toPattern())); // --------------------------------------------------- endDate.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { if (ignoreEndChanged) return; ignoreEndChanged = true; Date sd = (Date) startDate.getModel().getValue(); Date ed = (Date) endDate.getModel().getValue(); if (sd.after(ed)) { endDate.getModel().setValue(sd); ed = sd; } endCalFrame.cal.set(new CalendarDate(ed)); ignoreEndChanged = false; } }); // working days workingDaysOnlyCB.setText(Local.getString("Working days only")); workingDaysOnlyCB.setHorizontalAlignment(SwingConstants.RIGHT); gbc = new GridBagConstraints(); gbc.gridx = 4; gbc.gridy = 3; gbc.gridwidth = 2; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.EAST; repeatPanel.add(workingDaysOnlyCB, gbc); // ------------------------------------- gbc = new GridBagConstraints(); gbc.gridx = 5; gbc.gridy = 2; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(endDate, gbc); setEndDateB.setMinimumSize(new Dimension(24, 24)); setEndDateB.setPreferredSize(new Dimension(24, 24)); setEndDateB.setText(""); setEndDateB.setIcon( new ImageIcon( net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/calendar.png"))); setEndDateB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { setEndDateB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 6; gbc.gridy = 2; gbc.insets = new Insets(5, 0, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(setEndDateB, gbc); monthlyRepeatRB.setActionCommand("daily"); monthlyRepeatRB.setText(Local.getString("Every")); monthlyRepeatRB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { monthlyRepeatRB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 3; gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(monthlyRepeatRB, gbc); dayOfMonthSpin.setPreferredSize(new Dimension(50, 24)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 3; gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(dayOfMonthSpin, gbc); lblDoM.setText(Local.getString("day of month")); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 3; gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(lblDoM, gbc); yearlyRepeatRB.setActionCommand("yearly"); yearlyRepeatRB.setText(Local.getString("Yearly")); yearlyRepeatRB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { yearlyRepeatRB_actionPerformed(e); } }); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 4; gbc.gridwidth = 5; gbc.insets = new Insets(5, 5, 5, 10); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(yearlyRepeatRB, gbc); // Exception label lblExceptions.setText("Specific days to not recur on (exceptions)"); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 5; gbc.gridwidth = 2; gbc.insets = new Insets(5, 5, 5, 10); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(lblExceptions, gbc); // Exception text field exceptionDate.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { if (ignoreExceptionChanged) return; ignoreExceptionChanged = true; Date exd = (Date) exceptionDate.getModel().getValue(); exceptionCalFrame.cal.set(new CalendarDate(exd)); ignoreExceptionChanged = false; } }); exceptionDate.setPreferredSize(new Dimension(80, 24)); exceptionDate.setEditor(new JSpinner.DateEditor(exceptionDate, sdf.toPattern())); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 6; gbc.insets = new Insets(5, 5, 5, 4); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(exceptionDate, gbc); // Exception Calendar Button setExceptionDateB.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { setExceptionDateB_actionPerformed(e); } }); setExceptionDateB.setIcon( new ImageIcon( net.sf.memoranda.ui.AppFrame.class.getResource("resources/icons/calendar.png"))); setExceptionDateB.setText(""); setExceptionDateB.setPreferredSize(new Dimension(24, 24)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 6; gbc.insets = new Insets(5, 0, 5, 4); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(setExceptionDateB, gbc); // Exception date add button addExceptionDate.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { addExceptionDate_actionPerformed(e); } }); addExceptionDate.setText("Add"); addExceptionDate.setPreferredSize(new Dimension(80, 24)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 6; gbc.insets = new Insets(2, 36, 5, 2); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(addExceptionDate, gbc); // Exception List exceptionPane.setPreferredSize(new Dimension(136, 96)); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 6; gbc.gridwidth = 4; gbc.gridheight = 4; gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(exceptionPane, gbc); // Exception date remove button removeExceptionDate.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { removeExceptionDate_actionPerformed(e); } }); removeExceptionDate.setText("Remove"); removeExceptionDate.setPreferredSize(new Dimension(80, 24)); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 7; gbc.insets = new Insets(2, 36, 5, 2); gbc.anchor = GridBagConstraints.WEST; repeatPanel.add(removeExceptionDate, gbc); repeatRBGroup.add(noRepeatRB); repeatRBGroup.add(dailyRepeatRB); repeatRBGroup.add(weeklyRepeatRB); repeatRBGroup.add(monthlyRepeatRB); repeatRBGroup.add(yearlyRepeatRB); bottomPanel.add(buttonsPanel, BorderLayout.SOUTH); this.getContentPane().add(topPanel, BorderLayout.NORTH); this.getContentPane().add(bottomPanel, BorderLayout.SOUTH); // Do final things... startCalFrame.cal.addSelectionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (ignoreStartChanged) return; startDate.getModel().setValue(startCalFrame.cal.get().getCalendar().getTime()); } }); endCalFrame.cal.addSelectionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (ignoreEndChanged) return; endDate.getModel().setValue(endCalFrame.cal.get().getCalendar().getTime()); } }); exceptionCalFrame.cal.addSelectionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (ignoreExceptionChanged) return; exceptionDate.getModel().setValue(exceptionCalFrame.cal.get().getCalendar().getTime()); } }); disableElements(); ((JSpinner.DateEditor) timeSpin.getEditor()).getFormat().applyPattern("HH:mm"); enableEndDateCB_actionPerformed(null); }