/** * Copyright 1999-2009 The Pegadi Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * A dialog for edition article information. * * @author Jørgen Binningsbø <jb@underdusken.no> */ package org.pegadi.lister; import no.dusken.common.model.Person; import org.pegadi.model.*; import org.pegadi.permissions.GlobalPermissions; import org.pegadi.server.NoAccessException; import org.pegadi.swing.FloatField; import org.pegadi.swing.IntField; import org.pegadi.swing.PersonChooser; import org.pegadi.util.GridBagConstraints2; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.WindowEvent; import java.text.MessageFormat; import java.util.*; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class ArticleDialog extends JDialog { private JLabel headerLabel = new JLabel(); private JPanel mainPanel = new JPanel(); private JPanel permissionPanel = new JPanel(); private GridBagLayout gridBagLayout1 = new GridBagLayout(); private JLabel nameLabel = new JLabel(); private JTextField nameField = new JTextField(); private JLabel publicationLabel = new JLabel(); private JComboBox publicationCombo = new JComboBox(); private JLabel journalistLabel = new JLabel(); private JLabel photographerLabel = new JLabel(); private PersonChooser journalistCombo = null; private PersonChooser photographerCombo = null; private PersonChooser coJournalistCombo = null; private JPanel bottomPanel = new JPanel(); private JButton okButton = new JButton(); private JButton cancelButton = new JButton(); private JLabel charactersLabel = new JLabel(); private IntField charactersField = new IntField(); private JLabel pagesLabel = new JLabel(); private JTextField pagesField = new FloatField(); private JLabel commentLabel = new JLabel(); private JLabel articleTypeLabel = new JLabel(); private JComboBox articleTypeCombo = new JComboBox(); private JLabel articleIdLabel = new JLabel(); private JTabbedPane tabbedpane = new JTabbedPane(); private JButton addJournalistButton; private JButton addAllJournalistsButton; private JButton rem; private JButton removeAllButton; private JList coJournalistList; private JCheckBox mailNotification; private CoJournalistListModel coJournalistListModel; Article article; boolean okArticle = false; ArticleStatus privateStatus; JLabel jLabel1 = new JLabel(); JLabel statusLabel = new JLabel(); JComboBox departmentCombo = new JComboBox(); JComboBox statusCombo = new JComboBox(); ResourceBundle messages; Locale currentLocale; JScrollPane commentScrollPane = new JScrollPane(); JTextArea commentArea = new JTextArea(); BorderLayout borderLayout1 = new BorderLayout(); private final Logger log = LoggerFactory.getLogger(getClass()); public ArticleDialog(JFrame frame, Article article) { super(frame, true); this.addWindowListener(new java.awt.event.WindowAdapter() { public void windowOpened(WindowEvent e) { this_windowOpened(e); } }); if (article.getId() <= 0) { try { article.setJournalist(LoginContext.server.getSessionUser(LoginContext.sessionKey)); //article.setID(server.getNewUniqueID(sessionKey, server.ARTICLE_ID)); } catch (Exception e) { log.error("Error getting session user", e); } } journalistCombo = new PersonChooser(PersonChooser.JOURNALISTS, article.getJournalist()); journalistCombo.setMaximumRowCount(23); journalistCombo.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(ItemEvent e) { journalistCombo_itemStateChanged(e); } }); coJournalistCombo = new PersonChooser(PersonChooser.JOURNALISTS); coJournalistCombo.setMaximumRowCount(25); photographerCombo = new PersonChooser(PersonChooser.PHOTOGRAPHERS, article.getPhotographer()); this.article = article; init(article.getName(), article.getWantedNumberOfCharacters(), article.getWantedNumberOfPages(), article.getDescription()); photographerCombo.setMaximumRowCount(21); } protected void init(String name, Integer chars, Float pages, String desc) { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); currentLocale = Locale.getDefault(); try { messages = ResourceBundle.getBundle("org.pegadi.lister.ArticleDialogStrings", currentLocale); } catch (Exception e) { log.error("Exception opening resource bundle", e); } if (this.article == null || this.article.getId() <= 0) { this.setTitle(messages.getString("new")); } else { this.setTitle(messages.getString("old")); } populateCoJournalistList(); try { jbInit(); } catch (Exception e) { log.error("Error initialising GUI", e); } populatePublicationCombo(); populateDepartmentCombo(); populateStatusCombo(); populateArticleTypeCombo(); nameField.setText(name); nameField.setRequestFocusEnabled(true); charactersField.setText(chars.toString()); pagesField.setText(pages.toString()); commentArea.setText(desc); } public void this_windowOpened(WindowEvent e) { nameField.requestFocus(); } /** * The method populates the combobox with the active publications */ public void populatePublicationCombo() { try { boolean inList = false; // This is not neceserry since we should have a publication representing this (ID=9999) // publicationCombo.addItem(messages.getString("no_publication")); java.util.List<Publication> publist = LoginContext.server.getActivePublications(LoginContext.sessionKey); Publication curPub = this.article.getPublication(); for (Publication aPublist : publist) { publicationCombo.addItem(aPublist); if (aPublist.equals(curPub)) { inList = true; publicationCombo.setSelectedItem(aPublist); } } if (!inList) { if (curPub != null && curPub.getId() != 0) { publicationCombo.addItem(curPub); publicationCombo.setSelectedItem(curPub); } else { publicationCombo.setSelectedIndex(0); } } } catch (Exception e) { log.error("error populating combobox", e); } } /** * The method populates the combobox with the active departments */ public void populateDepartmentCombo() { try { boolean inList = false; java.util.List<Section> depts = LoginContext.server.getDepartments(LoginContext.sessionKey); for (Section dept : depts) { departmentCombo.addItem(dept); if (this.article.getSection() != null) if (this.article.getSection().equals(dept)) inList = true; } if (this.article.getSection() != null) { if (!inList) departmentCombo.addItem(this.article.getSection()); departmentCombo.setSelectedItem(this.article.getSection()); } else departmentCombo.setSelectedIndex(0); } catch (Exception e) { log.error("error populating department combobox", e); } } /** * The method populates the combobox with the article status */ public void populateStatusCombo() { try { boolean inList = false; java.util.List<ArticleStatus> status = LoginContext.server.getArticleStatuses(LoginContext.sessionKey); for (ArticleStatus statu : status) { statusCombo.addItem(statu); if (this.article.getArticleStatus() != null) if (this.article.getArticleStatus().getId().equals(statu.getId())) { inList = true; this.article.setArticleStatus(statu); // sorta dirty quick-fix, but it works and it will never fail, so who really cares to change it? } } if (this.article.getArticleStatus() != null) { if (!inList) statusCombo.addItem(this.article.getArticleStatus()); statusCombo.setSelectedItem(this.article.getArticleStatus()); } else statusCombo.setSelectedIndex(0); } catch (Exception e) { log.error("error populating article status combobox", e); } } /** * The method populates the combobox with the active article types. */ public void populateArticleTypeCombo() { try { boolean inList = false; java.util.List<ArticleType> articleTypes = LoginContext.server.getArticleTypes(LoginContext.sessionKey); for (ArticleType articleType : articleTypes) { articleTypeCombo.addItem(articleType); if (this.article.getArticleType() != null) if (this.article.getArticleType().equals(articleType)) inList = true; } if (this.article.getArticleType() != null) { if (!inList) articleTypeCombo.addItem(this.article.getArticleType()); articleTypeCombo.setSelectedItem(this.article.getArticleType()); } else articleTypeCombo.setSelectedIndex(0); articleTypeCombo.setMaximumRowCount(20); } catch (Exception e) { log.error("Error populating combobox", e); } } private void populateCoJournalistList() { try { List<Person> users = LoginContext.server.getCoJournalistsForArticle(article.getId(), LoginContext.sessionKey); coJournalistListModel = new CoJournalistListModel(users); } catch (java.rmi.RemoteException e) { log.error("Could not initialize list with co-journalists", e); } } /** * Returns the article with the given values. * * @return an <code>Article</code> value */ public Article getArticle() { if (okArticle) return article; else return null; } public List<String> getCoJournalists() { return coJournalistListModel.getAllAsUsernames(); } public void updateValues() { this.article.setName(nameField.getText()); this.article.setArticleType((ArticleType) articleTypeCombo.getSelectedItem()); this.article.setJournalist(journalistCombo.getSelectedUser()); this.article.setPhotographer(photographerCombo.getSelectedUser()); Object pub = publicationCombo.getSelectedItem(); if (pub instanceof Publication) { this.article.setPublication((Publication) pub); } else { this.article.setPublication(null); } this.article.setSection((Section) departmentCombo.getSelectedItem()); this.article.setArticleStatus((ArticleStatus) statusCombo.getSelectedItem()); int intt = charactersField.getValue(); //new Integer(charactersField.getText()); this.article.setWantedNumberOfCharacters(intt);//.intValue()); Float floatt = new Float(pagesField.getText()); this.article.setWantedNumberOfPages(floatt); this.article.setDescription(commentArea.getText()); okArticle = true; } private void jbInit() { headerLabel.setFont(new java.awt.Font("Dialog", 1, 24)); headerLabel.setHorizontalAlignment(SwingConstants.CENTER); headerLabel.setHorizontalTextPosition(SwingConstants.CENTER); if (this.article == null | this.article.getId() <= 0) headerLabel.setText(messages.getString("new")); else headerLabel.setText(messages.getString("old")); mainPanel.setLayout(gridBagLayout1); nameLabel.setText(messages.getString("name")); publicationLabel.setText(messages.getString("publication")); journalistLabel.setText(messages.getString("journalist")); photographerLabel.setText(messages.getString("photographer")); okButton.setText(messages.getString("ok_button")); okButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { okButton_actionPerformed(e); } }); cancelButton.setText(messages.getString("cancel_button")); cancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { cancelButton_actionPerformed(e); } }); charactersLabel.setToolTipText(""); charactersLabel.setText(messages.getString("numChar")); mainPanel.setMinimumSize(new Dimension(600, 139)); pagesLabel.setText(messages.getString("numPages")); commentLabel.setText(messages.getString("comment")); articleTypeLabel.setText(messages.getString("artType")); jLabel1.setText(messages.getString("section")); statusLabel.setText(messages.getString("status")); mailNotification = new JCheckBox(messages.getString(("mail_checkbox"))); articleIdLabel.setText(messages.getString("article_id") + " " + article.getId()); articleIdLabel.setFont(new Font("sansserif", Font.PLAIN, 9)); commentArea.setWrapStyleWord(true); commentArea.setLineWrap(true); commentArea.setRows(8); this.getContentPane().setLayout(borderLayout1); this.getContentPane().add(headerLabel, BorderLayout.NORTH); this.getContentPane().add(bottomPanel, BorderLayout.SOUTH); bottomPanel.setLayout(new BorderLayout()); bottomPanel.add(mailNotification, BorderLayout.NORTH); JPanel bottomButtonPanel = new JPanel(); bottomButtonPanel.add(okButton, null); bottomButtonPanel.add(cancelButton, null); bottomButtonPanel.add(articleIdLabel, null); bottomPanel.add(bottomButtonPanel, BorderLayout.CENTER); tabbedpane.addTab(messages.getString("details_tab"), mainPanel); tabbedpane.addTab(messages.getString("access_tab"), permissionPanel); try { String userid = LoginContext.server.getUserID(LoginContext.sessionKey); if (!(article.getJournalist() == null || article.getJournalist().getUsername().equals(userid) || LoginContext.server.hasGlobalPermission(userid, GlobalPermissions.LEGACY_IS_GOD, LoginContext.sessionKey))) { tabbedpane.setEnabledAt(1, false); journalistCombo.setEnabled(false); } } catch (Exception e) { log.error("Could not determine whether user can change priviligies", e); } this.getContentPane().add(tabbedpane, BorderLayout.CENTER); GridBagConstraints gridBagConstr1 = new GridBagConstraints(); gridBagConstr1.gridy = 1; gridBagConstr1.gridwidth = 1; gridBagConstr1.gridheight = 1; gridBagConstr1.anchor = GridBagConstraints.WEST; gridBagConstr1.fill = GridBagConstraints.NONE; gridBagConstr1.ipadx = 8; gridBagConstr1.insets = new Insets(20, 10, 0, 0); mainPanel.add(nameLabel, gridBagConstr1); GridBagConstraints gridBagConstr2 = new GridBagConstraints(); gridBagConstr2.gridx = 1; gridBagConstr2.gridy = 1; gridBagConstr2.gridwidth = 2; gridBagConstr2.gridheight = 1; gridBagConstr2.anchor = GridBagConstraints.CENTER; gridBagConstr2.fill = GridBagConstraints.BOTH; gridBagConstr2.insets = new Insets(20, 4, 0, 10); mainPanel.add(nameField, gridBagConstr2); GridBagConstraints gridBagConstr3 = new GridBagConstraints(); gridBagConstr3.gridy = 5; gridBagConstr3.gridwidth = 1; gridBagConstr3.gridheight = 1; gridBagConstr3.anchor = GridBagConstraints.WEST; gridBagConstr3.fill = GridBagConstraints.NONE; gridBagConstr3.insets = new Insets(0, 10, 0, 0); mainPanel.add(photographerLabel, gridBagConstr3); GridBagConstraints gridBagConstr4 = new GridBagConstraints(); gridBagConstr4.gridx = 1; gridBagConstr4.gridy = 5; gridBagConstr4.gridwidth = 1; gridBagConstr4.gridheight = 1; gridBagConstr4.anchor = GridBagConstraints.WEST; gridBagConstr4.fill = GridBagConstraints.HORIZONTAL; gridBagConstr4.insets = new Insets(0, 4, 0, 10); mainPanel.add(photographerCombo, gridBagConstr4); mainPanel.add(charactersLabel, new GridBagConstraints2(0, 7, 1, 1, 0.0, 0.0 , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0)); mainPanel.add(charactersField, new GridBagConstraints2(1, 7, 1, 1, 0.0, 0.0 , GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 4, 0, 10), 0, 0)); mainPanel.add(pagesField, new GridBagConstraints2(1, 8, 1, 1, 0.0, 0.0 , GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 4, 0, 10), 0, 0)); mainPanel.add(pagesLabel, new GridBagConstraints2(0, 8, 1, 1, 0.0, 0.0 , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0)); mainPanel.add(publicationLabel, new GridBagConstraints2(0, 6, 1, 1, 0.0, 0.0 , GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(30, 10, 0, 0), 0, 0)); mainPanel.add(publicationCombo, new GridBagConstraints2(1, 6, 1, 1, 0.0, 0.0 , GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 4, 0, 10), 0, 0)); mainPanel.add(journalistLabel, new GridBagConstraints2(0, 4, 1, 1, 0.0, 0.0 , GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, new Insets(29, 10, 0, 0), 0, 0)); mainPanel.add(articleTypeLabel, new GridBagConstraints2(0, 2, 1, 1, 0.0, 0.0 , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(26, 10, 0, 0), 0, 0)); mainPanel.add(articleTypeCombo, new GridBagConstraints2(1, 2, 1, 1, 0.0, 0.0 , GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 4, 0, 10), 0, 0)); mainPanel.add(commentLabel, new GridBagConstraints2(0, 10, 1, 1, 0.0, 0.0 , GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(30, 10, 0, 0), 0, 0)); mainPanel.add(journalistCombo, new GridBagConstraints2(1, 4, 1, 1, 0.0, 0.0 , GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 4, 0, 10), 0, 0)); mainPanel.add(departmentCombo, new GridBagConstraints2(1, 3, 1, 1, 0.0, 0.0 , GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 4, 0, 10), 0, 0)); mainPanel.add(statusCombo, new GridBagConstraints2(1, 9, 1, 1, 0.0, 0.0 , GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 4, 0, 10), 0, 0)); mainPanel.add(jLabel1, new GridBagConstraints2(0, 3, 1, 1, 0.0, 0.0 , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0)); mainPanel.add(statusLabel, new GridBagConstraints2(0, 9, 1, 1, 0.0, 0.0 , GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0)); mainPanel.add(commentScrollPane, new GridBagConstraints2(0, 11, 2, 1, 1.0, 1.0 , GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 10, 0, 10), 0, 0)); commentScrollPane.getViewport().add(commentArea, null); // mainPanel.add(articleIdLabel, new GridBagConstraints2(0, 12, 1, 1, 0.0, 0.0 // ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0)); permissionPanel.setLayout(new BorderLayout()); Box mainBox = Box.createVerticalBox(); permissionPanel.add(mainBox, BorderLayout.NORTH); Box descBox = Box.createHorizontalBox(); JTextArea desc = new JTextArea(messages.getString("access_text")); desc.setLineWrap(true); desc.setEditable(false); desc.setWrapStyleWord(true); desc.setBackground(getBackground()); descBox.add(Box.createHorizontalStrut(5)); descBox.add(desc); descBox.add(Box.createHorizontalStrut(5)); mainBox.add(Box.createVerticalStrut(5)); mainBox.add(descBox); mainBox.add(Box.createVerticalStrut(5)); Box journalistbox = Box.createHorizontalBox(); //journalistbox.add(journalistCombo); journalistbox.add(coJournalistCombo); addJournalistButton = new JButton(messages.getString("add_journalist")); addJournalistButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { addJournalist_actionPerformed(e); } }); journalistbox.add(addJournalistButton); mainBox.add(journalistbox); coJournalistList = new JList(coJournalistListModel); coJournalistList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); mainBox.add(Box.createVerticalStrut(5)); mainBox.add(new JScrollPane(coJournalistList)); rem = new JButton(messages.getString("remove_journalist")); rem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { removeJournalist_actionPerformed(e); } }); addAllJournalistsButton = new JButton(messages.getString("add_all")); addAllJournalistsButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { addAllJournalists_actionPerformed(); } }); removeAllButton = new JButton(messages.getString("remove_all")); removeAllButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { removeAll_actionPerformed(); } }); Box buttonBox = Box.createHorizontalBox(); buttonBox.add(Box.createHorizontalStrut(10)); buttonBox.add(rem); buttonBox.add(addAllJournalistsButton); buttonBox.add(removeAllButton); buttonBox.add(Box.createHorizontalGlue()); mainBox.add(buttonBox); } private void addJournalist_actionPerformed(ActionEvent e) { coJournalistListModel.add(coJournalistCombo.getSelectedUser()); } private void addAllJournalists_actionPerformed() { int size = coJournalistCombo.getItemCount(); for(int i=0; i<size; i++) { coJournalistListModel.add(coJournalistCombo.getUserAt(i)); } } private void removeJournalist_actionPerformed(ActionEvent e) { coJournalistListModel.remove(coJournalistList.getSelectedIndex()); } private void removeAll_actionPerformed() { coJournalistListModel.removeAll(); } void cancelButton_actionPerformed(ActionEvent e) { dispose(); } void okButton_actionPerformed(ActionEvent e) { updateValues(); dispose(); if(mailNotification.isSelected()) { ExecutorService executor = Executors.newSingleThreadExecutor(); executor.execute( new Runnable() { public void run() { notifyUsers(); } }); executor.shutdown(); } } private void notifyUsers() { String from = messages.getString("mail_from"); String subject = article.getName(); String creator = null; try { creator = LoginContext.server.getSessionUser(LoginContext.sessionKey).getName(); } catch(NoAccessException nae) { log.error("No access", nae); creator = "Pegadi"; } Object[] textArgs = {creator, article.getName()}; if(coJournalistListModel.getSize() > 0) { List<String> rcpt = new ArrayList<String>(); for(Person user : coJournalistListModel) { rcpt.add(user.getEmailAddress()); } String text = messages.getString("coJournalist_mail"); text = MessageFormat.format(text, textArgs); try { LoginContext.server.sendmail(from, rcpt, subject, text, LoginContext.sessionKey); } catch(NoAccessException nae) { log.error("No access", nae); } } Person photographer = article.getPhotographer(); if(photographer != null) { String text = messages.getString("photographer_mail"); text = MessageFormat.format(text, textArgs); try { LoginContext.server.sendmail(from, photographer.getEmailAddress(), subject, text, LoginContext.sessionKey); } catch(NoAccessException nae) { log.error("No access", nae); } } } void journalistCombo_itemStateChanged(ItemEvent e) { Person selected = journalistCombo.getSelectedUser(); String current = null; try { current = LoginContext.server.getUserID(LoginContext.sessionKey); } catch (Exception ex) { log.error("Error getting userid", ex); } if (selected == null) setPrivateStatusEnabled(false); else setPrivateStatusEnabled(selected.getUsername().equals(current)); } void setPrivateStatusEnabled(boolean enabled) { for (int i = 0; i < statusCombo.getItemCount(); i++) { ArticleStatus as = (ArticleStatus) statusCombo.getItemAt(i); if (as.getId() == 7) { // This is the private status if (!enabled) { privateStatus = as; statusCombo.removeItemAt(i); if (as == statusCombo.getSelectedItem()) statusCombo.setSelectedIndex(0); return; } } } // There was no private status in the list if (enabled && privateStatus != null) { statusCombo.addItem(privateStatus); privateStatus = null; } } /** * Returns <code>true</code> if the dialog was successful. * * @return The result of the dialog. */ public boolean dialogResult() { return okArticle; } private class CoJournalistListModel extends AbstractListModel implements Iterable<Person> { private List<Person> coJournalists; public CoJournalistListModel(List<Person> coJournalists) { this.coJournalists = coJournalists; } public void add(Person journalist) { if (coJournalists.indexOf(journalist) < 0 && journalist != null) { coJournalists.add(journalist); fireIntervalAdded(this, 0, getSize()); } } public void remove(int index) { if (index >= 0) { coJournalists.remove(index); fireIntervalRemoved(this, 0, getSize()); } } public void removeAll() { coJournalists.clear(); fireIntervalRemoved(this, 0, getSize()); } public List<String> getAllAsUsernames() { List<String> all = new ArrayList<String>(); for (Person coJournalist : coJournalists) { all.add(coJournalist.getUsername()); } return all; } public Person getElementAt(int index) { return coJournalists.get(index); } public int getSize() { return coJournalists.size(); } public Iterator<Person> iterator() { return coJournalists.iterator(); } } public void disableEditing() { nameField.setEditable(false); articleTypeCombo.setEnabled(false); publicationCombo.setEnabled(false); journalistCombo.setEnabled(false); photographerCombo.setEnabled(false); charactersField.setEditable(false); pagesField.setEditable(false); statusCombo.setEnabled(false); addJournalistButton.setEnabled(false); coJournalistCombo.setEnabled(false); departmentCombo.setEnabled(false); rem.setEnabled(false); commentArea.setEditable(false); okButton.setEnabled(false); mailNotification.setEnabled(false); addAllJournalistsButton.setEnabled(false); removeAllButton.setEnabled(false); } }