void selectExhibit() {
    ExhibitInfo e = getCurrentExhibit();

    contentListModel.notifyChange();
    exhibitPhotosModel.notifyChange();
    contentList.setSelectionInterval(0, 0);
    for (ListSelectionListener l : contentList.getListSelectionListeners()) {
      l.valueChanged(new ListSelectionEvent(contentList, 0, 0, false));
    }
    exhibitXCoordField.getModel().setValue(e.getX());
    exhibitXCoordOrig.setText("X coordinate: (was " + e.origXCoord + ")");
    exhibitYCoordField.getModel().setValue(e.getY());
    exhibitYCoordOrig.setText("Y coordinate: (was " + e.origYCoord + ")");

    exhibitNextDropdown.setSelectedItem(e.getNext());
    if (e.getNext() != null) {
      exhibitNextOrig.setText("Next: (was " + e.origNext + ")");
    } else {
      exhibitPreviousOrig.setText("Next:");
    }
    exhibitPreviousDropdown.setSelectedItem(e.getPrevious());
    if (e.getPrevious() != null) {
      exhibitPreviousOrig.setText("Previous: (was " + e.origPrevious + ")");
    } else {
      exhibitPreviousOrig.setText("Previous:");
    }

    exhibitPhotosList.setSelectionInterval(0, 0);
    exhibitAliasesList.setSelectionInterval(0, 0);

    exhibitAliasesModel.notifyChange();

    selectPhoto();
    selectAlias();
  }
 void removeGroup() {
   peer.makeChange();
   peer.getLoader().removeGroup(groupNameList.getSelectedValue().toString());
   groupNameList.setSelectionInterval(0, 0);
   groupExhibitsList.setSelectionInterval(0, 0);
   groupExhibitsModel.notifyChange();
   groupListModel.notifyChange();
 }
Example #3
0
 void endSelection(Point point) {
   last = mainView.locationToIndex(point);
   if (first != last) {
     mainView.setSelectionInterval(first, last);
     // Debug.println(first + ", " + last);
   }
 }
 void selectGroup() {
   ExhibitGroup group = peer.getLoader().getGroup(groupNameList.getSelectedValue().toString());
   groupExhibitsModel.notifyChange();
   groupExhibitsList.setSelectionInterval(0, 0);
   groupXSpinnerModel.setValue(group.xPos);
   groupYSpinnerModel.setValue(group.yPos);
 }
 void removeExhibit() {
   if (exhibitNameList.getModel().getSize() > 1) {
     peer.getLoader().removeExhibit((String) exhibitNameList.getSelectedValue());
     exhibitNameList.setSelectionInterval(0, 0);
     peer.makeChange();
     exhibitNameModel.notifyChange();
   }
 }
  @Override
  protected JComponent createCenterPanel() {
    final JPanel panel = new JPanel(new BorderLayout());
    JTextArea area =
        new JTextArea(
            "The imported language extends other languages.\n"
                + "It might be useful to import all or some of them.");
    area.setEditable(false);
    area.setBackground(this.getContentPane().getBackground());
    area.setBorder(BorderFactory.createEmptyBorder(5, 5, 3, 5));
    panel.add(area, BorderLayout.NORTH);

    JPanel center = new JPanel(new GridBagLayout());
    JTextArea label = new JTextArea("Select additional languages to import:");
    label.setEditable(false);
    label.setBackground(getContentPane().getBackground());
    label.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    center.add(
        label,
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    myList = new JBList(myCandidates.toArray());

    myList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    myList.setSelectionInterval(0, myList.getModel().getSize() - 1);
    myList.setCellRenderer(new MyDefaultListCellRenderer());
    myList.setBorder(BorderFactory.createEtchedBorder());
    center.add(
        ScrollPaneFactory.createScrollPane(myList),
        new GridBagConstraints(
            0,
            GridBagConstraints.RELATIVE,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));

    panel.add(center, BorderLayout.CENTER);
    panel.setPreferredSize(new Dimension(400, 250));

    return panel;
  }
 public void setSelectionInterval(int anchor, int lead) {
   super.setSelectionInterval(anchor, lead);
   int min = Math.min(anchor, lead);
   int max = Math.max(anchor, lead);
   // Table may be showing 0 bytes, but we're showing 1 row header
   if (max < table.getRowCount()) {
     table.setSelectedRows(min, max);
   }
 }
 void removeTag() {
   if (contentList.getModel().getSize() > 1) {
     for (ExhibitInfo e : peer.getLoader().getExhibits()) {
       if (e.getName().equals((String) exhibitNameList.getSelectedValue())) {
         e.setContent((String) contentList.getSelectedValue(), null);
       }
     }
   }
   contentListModel.notifyChange();
   contentList.setSelectionInterval(0, 0);
 }
Example #9
0
 private void dirlist() {
   listFilesModel.removeAllElements();
   listToConvertModel.removeAllElements();
   MyFile dir = new MyFile(textField.getText());
   MyFile[] chld = dir.listFiles();
   for (int i = 0; i < chld.length; i++) {
     if (chld[i].isFile()) listFilesModel.addElement((MyFile) chld[i]);
   }
   if (chld.length > 0) {
     listFiles.setSelectionInterval(0, 0);
   }
 }
Example #10
0
  public void mouseDragged(MouseEvent e) {
    e.consume();

    // update selection
    int mouseDraggedRow = rowHeader.locationToIndex(e.getPoint());

    // make sure mouse pressed is initialized, this may not be the case
    // after closing the popup menu
    if (mousePressedRow < 0) {
      table.stopEditing();
      mousePressedRow = mouseDraggedRow;
    }
    if (AppD.isControlDown(e)) rowHeader.addSelectionInterval(mousePressedRow, mouseDraggedRow);
    else rowHeader.setSelectionInterval(mousePressedRow, mouseDraggedRow);
  }
Example #11
0
  /** Updates the test chooser with possible tests. */
  protected void setTTester() {

    // default is to display all columns
    m_TTester.setDisplayedResultsets(null);

    String name = (new SimpleDateFormat("HH:mm:ss - ")).format(new Date()) + "Available resultsets";
    StringBuffer outBuff = new StringBuffer();
    outBuff.append("Available resultsets\n" + m_TTester.resultsetKey() + "\n\n");
    m_History.addResult(name, outBuff);
    m_History.setSingle(name);

    m_TestsModel.removeAllElements();
    for (int i = 0; i < m_TTester.getNumResultsets(); i++) {
      String tname = m_TTester.getResultsetName(i);
      /*      if (tname.length() > 20) {
      tname = tname.substring(0, 20);
      } */
      m_TestsModel.addElement(tname);
    }

    m_DisplayedModel.removeAllElements();
    for (int i = 0; i < m_TestsModel.size(); i++)
      m_DisplayedModel.addElement(m_TestsModel.elementAt(i));

    m_TestsModel.addElement("Summary");
    m_TestsModel.addElement("Ranking");

    m_TestsList.setSelectedIndex(0);
    m_DisplayedList.setSelectionInterval(0, m_DisplayedModel.size() - 1);

    m_TestsButton.setEnabled(true);
    m_DisplayedButton.setEnabled(true);
    m_ShowStdDevs.setEnabled(true);
    m_OutputFormatButton.setEnabled(true);
    m_PerformBut.setEnabled(true);
  }
Example #12
0
 public Object[] getList() {
   if (listToConvertModel.getSize() > 0) {
     listToConvert.setSelectionInterval(0, listToConvertModel.getSize() - 1);
     return listToConvert.getSelectedValues();
   } else return null;
 }
Example #13
0
 public void selectAll() {
   list.setSelectionInterval(0, list.getModel().getSize() - 1);
 }
 private void fillSequenceChooser() {
   sequenceToShowChooser.setListData(sequenceValues.toArray(new Value[sequenceValues.size()]));
   sequenceToShowChooser.setSelectionInterval(0, sequenceValues.size() - 1);
 }
  public PluginUpdateFrame(final List<PluginDescriptor> toInstallPlugins) {
    super("Plugin Update", true);

    setPreferredSize(new Dimension(640, 500));

    final JPanel titlePanel =
        GuiUtil.createCenteredBoldLabel("Select the plugin(s) to update in the list");
    titlePanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    final JTextArea changeLogArea = new JTextArea();
    changeLogArea.setEditable(false);
    final JLabel changeLogTitleLabel = GuiUtil.createBoldLabel("Change log :");

    listModel = new DefaultListModel();
    pluginList = new JList(listModel);
    for (PluginDescriptor plugin : toInstallPlugins) listModel.addElement(plugin);

    pluginList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    pluginList
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              @Override
              public void valueChanged(ListSelectionEvent e) {
                if (pluginList.getSelectedValue() != null) {
                  final PluginDescriptor plugin = (PluginDescriptor) pluginList.getSelectedValue();

                  plugin.loadChangeLog();
                  final String changeLog = plugin.getChangeLog();

                  if (StringUtil.isEmpty(changeLog)) changeLogArea.setText("no change log");
                  else changeLogArea.setText(changeLog);
                  changeLogArea.setCaretPosition(0);
                  changeLogTitleLabel.setText(plugin.getName() + " change log");
                }
              }
            });
    pluginList.setSelectionInterval(0, toInstallPlugins.size() - 1);

    getOkBtn().setText("Update");
    getCancelBtn().setText("Close");
    setCloseAfterAction(false);
    setOkAction(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            // launch update
            doUpdate();
          }
        });

    final JScrollPane medScrollPane = new JScrollPane(pluginList);
    final JScrollPane changeLogScrollPane =
        new JScrollPane(GuiUtil.createTabArea(changeLogArea, 4));
    final JPanel bottomPanel =
        GuiUtil.createPageBoxPanel(
            Box.createVerticalStrut(4),
            GuiUtil.createCenteredLabel(changeLogTitleLabel),
            Box.createVerticalStrut(4),
            changeLogScrollPane);

    final JPanel mainPanel = getMainPanel();

    final JSplitPane splitPane =
        new JSplitPane(JSplitPane.VERTICAL_SPLIT, medScrollPane, bottomPanel);

    mainPanel.add(titlePanel, BorderLayout.NORTH);
    mainPanel.add(splitPane, BorderLayout.CENTER);

    pack();
    addToDesktopPane();
    setVisible(true);
    center();
    requestFocus();

    // set splitter to middle
    splitPane.setDividerLocation(0.5d);
  }
  public void init() {
    exhibitNameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    exhibitNameList.setModel(exhibitNameModel);
    exhibitNameList.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent arg0) {
            selectExhibit();
          }
        });

    contentList.setModel(contentListModel);
    contentList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    contentList.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent arg0) {
            selectContent();
          }
        });

    groupExhibitsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    groupExhibitsList.setModel(groupExhibitsModel);

    exhibitAliasesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    exhibitAliasesList.setModel(exhibitAliasesModel);
    exhibitAliasesList.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent arg0) {
            selectAlias();
          }
        });

    groupNameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    groupNameList.setModel(groupListModel);
    groupNameList.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent arg0) {
            selectGroup();
          }
        });

    eventsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    eventsList.setModel(eventsListModel);
    eventsList.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent arg0) {
            Event e = eventsListModel.getEvent(eventsList.getSelectedIndex());
            eventDescription.setText(e.getDescription());
            eventName.setText(e.getTitle());
            eventStart.getModel().setValue(e.getStartDay());
            eventEnd.getModel().setValue(e.getEndDay());
            eventPhotoDropdown.setSelectedItem(e.getImage());
          }
        });

    exhibitNextDropdown.setModel(new ExhibitDropdownModel());
    exhibitPreviousDropdown.setModel(new ExhibitDropdownModel());

    htmlContentViewer.setEditable(false);
    htmlContentViewer.setEditorKit(htmlKit);
    Document doc = htmlKit.createDefaultDocument();
    htmlContentViewer.setDocument(doc);

    eventName
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              private void change() {
                Event e = peer.getLoader().getEvents().get(eventsList.getSelectedIndex());
                e.setTitle(eventName.getText());
                peer.makeChange();
                eventsListModel.notifyChange();
              }

              @Override
              public void changedUpdate(DocumentEvent arg0) {
                change();
              }

              @Override
              public void insertUpdate(DocumentEvent arg0) {
                change();
              }

              @Override
              public void removeUpdate(DocumentEvent arg0) {
                change();
              }
            });

    eventDescription.setLineWrap(true);
    eventDescription.setWrapStyleWord(true);
    eventDescription
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              private void change() {
                Event e = peer.getLoader().getEvents().get(eventsList.getSelectedIndex());
                e.setDescription(eventDescription.getText());
                peer.makeChange();
              }

              @Override
              public void changedUpdate(DocumentEvent arg0) {
                change();
              }

              @Override
              public void insertUpdate(DocumentEvent arg0) {
                change();
              }

              @Override
              public void removeUpdate(DocumentEvent arg0) {
                change();
              }
            });

    photoCaption.setBorder(paddedLine);
    photoCaption.setLineWrap(true);
    photoCaption.setWrapStyleWord(true);
    photoCaption
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              private void change() {
                getCurrentExhibit()
                    .getPhotos()[exhibitPhotosList.getSelectedIndex()]
                    .setCaption(photoCaption.getText());
                peer.makeChange();
              }

              @Override
              public void changedUpdate(DocumentEvent arg0) {
                change();
              }

              @Override
              public void insertUpdate(DocumentEvent arg0) {
                change();
              }

              @Override
              public void removeUpdate(DocumentEvent arg0) {
                change();
              }
            });

    exhibitNextDropdown.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            setNext();
          }
        });

    exhibitPreviousDropdown.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            setPrevious();
          }
        });

    addGroupExhibitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent a) {
            addGroupExhibit();
          }
        });

    removeGroupExhibitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            removeGroupExhibit();
          }
        });

    addGroupButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            addGroup();
          }
        });

    editFileButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent a) {
            editFile();
          }
        });

    viewFileButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent a) {
            viewFile();
          }
        });

    removeGroupButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            removeGroup();
          }
        });

    newFileButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            peer.addFile();
            modifiedFilesListModel.notifyChange();
          }
        });

    newExhibitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            addExhibit();
          }
        });

    removeExhibitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            removeExhibit();
          }
        });

    newTagButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            addContent();
          }
        });

    removeTagButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            removeTag();
          }
        });

    newImageButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            addImage();
          }
        });

    addEventButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            Event e = new Event();
            e.setTitle("New Event");
            e.setStartDay(new Date());
            peer.getLoader().getEvents().add(e);
            peer.getLoader().getEvents();
            eventsListModel.notifyChange();
            peer.makeChange();
            eventsList.setSelectedIndex(0);
          }
        });

    removeEventButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            peer.getLoader().getEvents().remove(eventsList.getSelectedIndex());
            peer.getLoader().getEvents();
            eventsListModel.notifyChange();
            peer.makeChange();
          }
        });

    exhibitXSpinnerModel.addChangeListener(this);
    exhibitYSpinnerModel.addChangeListener(this);

    aliasXSpinnerModel.addChangeListener(this);
    aliasYSpinnerModel.addChangeListener(this);

    groupXSpinnerModel.addChangeListener(this);
    groupYSpinnerModel.addChangeListener(this);

    eventStart.getModel().addChangeListener(this);
    eventEnd.getModel().addChangeListener(this);

    eventPhotoDropdown.setEditable(false);
    eventPhotoDropdown.setModel(new PhotoDropdownModel());
    eventPhotoDropdown.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            Event e = peer.getLoader().getEvents().get(eventsList.getSelectedIndex());
            e.setImage(eventPhotoDropdown.getSelectedItem().toString());
          }
        });

    newContentDropdown.setEditable(false);
    newContentDropdown.setModel(new ContentDropdownModel());
    newContentDropdown.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            ExhibitInfo e = getCurrentExhibit();
            String currentTag = (String) contentList.getSelectedValue();
            String content = (String) newContentDropdown.getSelectedItem();
            e.setContent(currentTag, content);
            loadHTMLContent(content);
            if (false == e.getContent(currentTag).equals(e.getOrigContents(currentTag))) {
              peer.makeChange();
            }
          }
        });

    exhibitPhotosList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    exhibitPhotosList.setModel(exhibitPhotosModel);
    exhibitPhotosList.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent arg0) {
            selectPhoto();
          }
        });

    exhibitContentLabel.setBorder(paddedLine);

    modifiedFilesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    modifiedFilesList.setModel(modifiedFilesListModel);

    originalFilesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    originalFilesList.setModel(originalFilesListModel);

    modifiedFilesList.setSelectionInterval(0, 0);
    exhibitNameList.setSelectionInterval(0, 0);
    contentList.setSelectionInterval(0, 0);
    exhibitPhotosList.setSelectionInterval(0, 0);
    groupNameList.setSelectionInterval(0, 0);
    exhibitAliasesList.setSelectionInterval(0, 0);
    eventsList.setSelectionInterval(0, 0);

    JPanel contentDropdownPanel = new JPanel(new GridLayout(4, 1, 2, 2));
    contentDropdownPanel.add(new JLabel("Original content:"));
    contentDropdownPanel.add(exhibitContentLabel);
    contentDropdownPanel.add(new JLabel("Current content:"));
    contentDropdownPanel.add(newContentDropdown);

    JPanel contentButtonPanel = new JPanel(new GridLayout(3, 1, 2, 2));
    contentButtonPanel.add(newTagButton);
    contentButtonPanel.add(removeTagButton);
    contentButtonPanel.add(renameTagButton);

    for (Component c : contentButtonPanel.getComponents()) {
      JButton b = (JButton) c;
      b.setBorder(BorderFactory.createCompoundBorder(b.getBorder(), mediumPaddedBorder));
    }

    addEventButton.setBorder(largePaddedBorder);
    removeEventButton.setBorder(largePaddedBorder);

    JPanel contentListPanel = new JPanel(new BorderLayout());
    contentListPanel.add(new JScrollPane(contentList), BorderLayout.CENTER);
    contentListPanel.add(contentButtonPanel, BorderLayout.EAST);

    JPanel contentControlPanel = new JPanel(new GridLayout(2, 1, 2, 2));
    contentControlPanel.add(contentListPanel);
    contentControlPanel.add(contentDropdownPanel);

    contentPanel.add(new JScrollPane(htmlContentViewer));
    contentPanel.add(contentControlPanel);
    contentPanel.setBorder(mediumPaddedBorder);

    exhibitDataPanel.add(exhibitXCoordOrig);
    exhibitDataPanel.add(exhibitXCoordField);
    exhibitDataPanel.add(exhibitPreviousOrig);
    exhibitDataPanel.add(exhibitPreviousDropdown);
    exhibitDataPanel.add(exhibitYCoordOrig);
    exhibitDataPanel.add(exhibitYCoordField);
    exhibitDataPanel.add(exhibitNextOrig);
    exhibitDataPanel.add(exhibitNextDropdown);

    JPanel exhibitButtonsPanel = new JPanel(new GridLayout(3, 1, 2, 2));
    exhibitButtonsPanel.add(newExhibitButton);
    exhibitButtonsPanel.add(removeExhibitButton);
    exhibitButtonsPanel.add(renameExhibitButton);

    for (Component c : exhibitButtonsPanel.getComponents()) {
      JButton b = (JButton) c;
      b.setBorder(BorderFactory.createCompoundBorder(b.getBorder(), mediumPaddedBorder));
    }

    JPanel listPanelTop = new JPanel(new BorderLayout());
    listPanelTop.add(new JLabel("Exhibits:"), BorderLayout.NORTH);
    listPanelTop.add(new JScrollPane(exhibitNameList), BorderLayout.CENTER);
    listPanelTop.add(exhibitButtonsPanel, BorderLayout.EAST);

    JPanel photoButtonPanel = new JPanel(new GridLayout(1, 2, 2, 2));
    photoButtonPanel.add(newImageButton);
    photoButtonPanel.add(removeImageButton);

    JPanel photoDataPanel = new JPanel(new GridLayout(2, 1, 2, 2));
    photoDataPanel.add(new JScrollPane(exhibitPhotosList));
    photoDataPanel.add(photoCaption);

    JPanel photoPanelRight = new JPanel(new BorderLayout());
    photoPanelRight.add(new JLabel("Exhibit Photos:"), BorderLayout.NORTH);
    photoPanelRight.add(photoDataPanel, BorderLayout.CENTER);
    photoPanelRight.add(photoButtonPanel, BorderLayout.SOUTH);

    JPanel aliasPanel = new JPanel(new GridLayout(1, 3, 2, 2));
    aliasDataPanel.add(new JLabel("Alias X Coordinate"));
    aliasDataPanel.add(aliasXCoordField);
    aliasDataPanel.add(new JLabel("Alias Y Coordinate"));
    aliasDataPanel.add(aliasYCoordField);

    JPanel aliasDataLabeled = new JPanel(new BorderLayout());
    aliasDataLabeled.add(new JLabel("Exhibit Aliases:"), BorderLayout.NORTH);
    aliasDataLabeled.add(new JScrollPane(exhibitAliasesList), BorderLayout.CENTER);

    JPanel aliasButtonsPanel = new JPanel(new GridLayout(2, 1, 2, 2));
    aliasButtonsPanel.add(addAliasButton);
    aliasButtonsPanel.add(removeAliasButton);

    aliasPanel.add(aliasDataLabeled);
    aliasPanel.add(aliasDataPanel);
    aliasPanel.add(aliasButtonsPanel);
    aliasPanel.setBorder(paddedLine);

    JPanel groupXCoordPanel = new JPanel(new GridLayout(1, 2, 2, 2));
    groupXCoordPanel.add(new JLabel("Group X Coordinate"));
    groupXCoordPanel.add(groupXCoordField);

    JPanel groupYCoordPanel = new JPanel(new GridLayout(1, 2, 2, 2));
    groupYCoordPanel.add(new JLabel("Group Y Coordinate"));
    groupYCoordPanel.add(groupYCoordField);

    JPanel groupDataButtonsPanel = new JPanel(new GridLayout(4, 1, 2, 2));
    groupDataButtonsPanel.add(addGroupButton);
    groupDataButtonsPanel.add(removeGroupButton);
    groupDataButtonsPanel.add(addGroupExhibitButton);
    groupDataButtonsPanel.add(removeGroupExhibitButton);

    JPanel groupLocationPanel = new JPanel(new GridLayout(2, 1, 2, 2));
    groupLocationPanel.add(groupXCoordPanel);
    groupLocationPanel.add(groupYCoordPanel);
    groupLocationPanel.setBorder(paddedLine);

    JPanel groupDataPanel = new JPanel(new GridLayout(1, 2, 2, 2));
    groupDataPanel.add(groupLocationPanel);
    groupDataPanel.add(groupDataButtonsPanel);

    JPanel combinedDataPanel = new JPanel(new GridLayout(2, 1, 2, 2));
    combinedDataPanel.add(exhibitDataPanel);
    combinedDataPanel.add(aliasPanel);
    combinedDataPanel.setBorder(mediumPaddedBorder);

    photosPanel.add(new JScrollPane(exhibitPhotosImage));
    photosPanel.add(photoPanelRight);
    photosPanel.setBorder(mediumPaddedBorder);

    exhibitTabs.add("Exhibit Content", contentPanel);
    exhibitTabs.add("Exhibit Photos", photosPanel);
    exhibitTabs.add("Exhibit Properties", combinedDataPanel);

    mainPanel.add(listPanelTop, BorderLayout.NORTH);
    mainPanel.add(exhibitTabs, BorderLayout.CENTER);

    mainPanel.setBorder(mediumPaddedBorder);

    groupListPanel.add(new JScrollPane(groupNameList));
    groupListPanel.add(new JScrollPane(groupExhibitsList));

    JPanel fileButtonPanel = new JPanel(new GridLayout(2, 1, 2, 2));
    fileButtonPanel.add(newFileButton);
    fileButtonPanel.add(editFileButton);

    for (Component c : fileButtonPanel.getComponents()) {
      JButton b = (JButton) c;
      b.setBorder(BorderFactory.createCompoundBorder(b.getBorder(), largePaddedBorder));
    }

    JPanel originalListPanel = new JPanel(new BorderLayout());
    originalListPanel.add(new JLabel("Original Files:"), BorderLayout.NORTH);
    originalListPanel.add(new JScrollPane(originalFilesList), BorderLayout.CENTER);
    originalListPanel.add(viewFileButton, BorderLayout.EAST);

    JPanel modifiedListPanel = new JPanel(new BorderLayout());
    modifiedListPanel.add(new JLabel("Added Files:"), BorderLayout.NORTH);
    modifiedListPanel.add(new JScrollPane(modifiedFilesList), BorderLayout.CENTER);
    modifiedListPanel.add(fileButtonPanel, BorderLayout.EAST);

    JPanel eventImagePanel = new JPanel(new BorderLayout());
    eventImagePanel.add(new JLabel("Event Image: "), BorderLayout.WEST);
    eventImagePanel.add(eventPhotoDropdown, BorderLayout.CENTER);

    JPanel eventTimePanel = new JPanel(new GridLayout(1, 4, 2, 2));
    eventTimePanel.add(new JLabel("Start Date:"));
    eventTimePanel.add(eventStart);
    eventTimePanel.add(new JLabel("End Date:"));
    eventTimePanel.add(eventEnd);

    JPanel eventsSmallDataPanel = new JPanel(new GridLayout(2, 1, 2, 2));
    eventsSmallDataPanel.add(eventTimePanel);
    eventsSmallDataPanel.add(eventImagePanel);

    JPanel eventsDataPanel = new JPanel(new BorderLayout());
    eventsDataPanel.add(eventName, BorderLayout.NORTH);
    eventsDataPanel.add(new JScrollPane(eventDescription), BorderLayout.CENTER);
    eventsDataPanel.add(eventsSmallDataPanel, BorderLayout.SOUTH);

    JPanel eventButtonsPanel = new JPanel(new GridLayout(1, 2, 2, 2));
    eventButtonsPanel.add(addEventButton);
    eventButtonsPanel.add(removeEventButton);

    JPanel eventsListPanel = new JPanel(new BorderLayout());
    eventsListPanel.add(new JScrollPane(eventsList), BorderLayout.CENTER);
    eventsListPanel.add(eventButtonsPanel, BorderLayout.SOUTH);

    JPanel eventsPanel = new JPanel(new GridLayout(2, 1, 2, 2));
    eventsPanel.add(eventsListPanel);
    eventsPanel.add(eventsDataPanel);

    filePanel.add(originalListPanel);
    filePanel.add(modifiedListPanel);

    groupPanel.add(groupListPanel);
    groupPanel.add(groupDataPanel);
    groupPanel.setBorder(mediumPaddedBorder);

    tabbedPane.setBorder(thinPaddedBorder);

    tabbedPane.addTab("Exhibits", mainPanel);
    tabbedPane.addTab("Groups", groupPanel);
    tabbedPane.addTab("Map", mapPanel);
    tabbedPane.addTab("Files", filePanel);
    tabbedPane.addTab("Events", eventsPanel);
  }
  @Override
  public void run() {
    BasePanel panel = frame.basePanel();
    if (panel == null) {
      return;
    }
    if (panel.getSelectedEntries().length == 0) {
      message = Localization.lang("No entries selected.");
      getCallBack().update();
      return;
    }

    Map<String, IExportFormat> m = ExportFormats.getExportFormats();
    IExportFormat[] formats = new ExportFormat[m.size()];
    String[] array = new String[formats.length];

    int piv = 0;
    for (IExportFormat format : m.values()) {
      formats[piv] = format;
      array[piv] = format.getDisplayName();
      piv++;
    }

    JList list = new JList(array);
    list.setBorder(BorderFactory.createEtchedBorder());
    list.setSelectionInterval(0, 0);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    int answer =
        JOptionPane.showOptionDialog(
            frame,
            list,
            Localization.lang("Select format"),
            JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,
            new String[] {Localization.lang("Ok"), Localization.lang("Cancel")},
            Localization.lang("Ok"));

    if (answer == JOptionPane.NO_OPTION) {
      return;
    }

    IExportFormat format = formats[list.getSelectedIndex()];

    // Set the global variable for this database's file directory before exporting,
    // so formatters can resolve linked files correctly.
    // (This is an ugly hack!)
    Globals.prefs.fileDirForDatabase =
        frame.basePanel().metaData().getFileDirectory(GUIGlobals.FILE_FIELD);
    // Also store the database's file in a global variable:
    Globals.prefs.databaseFile = frame.basePanel().metaData().getFile();

    /*final boolean custom = (list.getSelectedIndex() >= Globals.STANDARD_EXPORT_COUNT);
    String dir = null;
    if (custom) {
        int index = list.getSelectedIndex() - Globals.STANDARD_EXPORT_COUNT;
        dir = (String) (Globals.prefs.customExports.getElementAt(index)[1]);
        File f = new File(dir);
        lfName = f.getName();
        lfName = lfName.substring(0, lfName.indexOf("."));
        // Remove file name - we want the directory only.
        dir = f.getParent() + System.getProperty("file.separator");
    }
    final String format = lfName,
            directory = dir;
    */
    File tmp = null;
    Reader reader = null;
    try {
      // To simplify the exporter API we simply do a normal export to a temporary
      // file, and read the contents afterwards:
      tmp = File.createTempFile("jabrefCb", ".tmp");
      tmp.deleteOnExit();
      BibtexEntry[] bes = panel.getSelectedEntries();
      HashSet<String> entries = new HashSet<String>(bes.length);
      for (BibtexEntry be : bes) {
        entries.add(be.getId());
      }

      // Write to file:
      format.performExport(database, panel.metaData(), tmp.getPath(), panel.getEncoding(), entries);
      // Read the file and put the contents on the clipboard:
      StringBuilder sb = new StringBuilder();
      reader = new InputStreamReader(new FileInputStream(tmp), panel.getEncoding());
      int s;
      while ((s = reader.read()) != -1) {
        sb.append((char) s);
      }
      ClipboardOwner owner =
          new ClipboardOwner() {

            @Override
            public void lostOwnership(Clipboard clipboard, Transferable content) {}
          };
      // StringSelection ss = new StringSelection(sw.toString());
      RtfSelection rs = new RtfSelection(sb.toString());
      Toolkit.getDefaultToolkit().getSystemClipboard().setContents(rs, owner);
      message = Localization.lang("Entries exported to clipboard") + ": " + bes.length;

    } catch (Exception e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
      message = Localization.lang("Error exporting to clipboard");
    } finally {
      // Clean up:
      if (tmp != null) {
        tmp.delete();
      }
      if (reader != null) {
        try {
          reader.close();
        } catch (IOException ex) {
          ex.printStackTrace();
        }
      }
    }
  }
Example #18
0
 void continueSelection(Point point) {
   last = mainView.locationToIndex(point);
   mainView.setSelectionInterval(first, last);
   // Debug.println(first + ", " + last);
 }