Example usage for javax.swing JScrollPane setPreferredSize

List of usage examples for javax.swing JScrollPane setPreferredSize

Introduction

In this page you can find the example usage for javax.swing JScrollPane setPreferredSize.

Prototype

@BeanProperty(preferred = true, description = "The preferred size of the component.")
public void setPreferredSize(Dimension preferredSize) 

Source Link

Document

Sets the preferred size of this component.

Usage

From source file:org.geworkbench.components.lincs.LincsInterface.java

private JScrollPane buildJListPanel(List<String> dataList, JList aJlist) {

    aJlist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    aJlist.setSelectionModel(new LincsListSelectionModel());
    aJlist.setModel(new LincsListModel(dataList));
    JScrollPane jScrollPane1 = new javax.swing.JScrollPane(aJlist,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    jScrollPane1.setPreferredSize(new java.awt.Dimension(200, 70));

    return jScrollPane1;

}

From source file:org.geworkbench.components.lincs.LincsInterface.java

private JScrollPane buildFilterJListPanel(List<String> dataList, FilteredJList filteredJList) {

    filteredJList.setSelectionModel(new LincsListSelectionModel());
    filteredJList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    for (int i = 0; i < dataList.size(); i++)
        filteredJList.addItem(dataList.get(i));
    JScrollPane jScrollPane1 = new javax.swing.JScrollPane(filteredJList,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    jScrollPane1.setPreferredSize(new java.awt.Dimension(200, 70));

    return jScrollPane1;

}

From source file:org.interreg.docexplore.GeneralConfigPanel.java

public GeneralConfigPanel(final File config) throws Exception {
    this.configFile = config;

    final String xml = config.exists() ? StringUtils.readFile(config) : "<config></config>";
    setLayout(new LooseGridLayout(0, 1, 5, 5, true, true, SwingConstants.LEFT, SwingConstants.TOP));

    //      JPanel ac = new JPanel(new LooseGridLayout(0, 1, 5, 5, false, true, SwingConstants.LEFT, SwingConstants.TOP));
    //      ac.setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgACLabel")));
    //      ac.add(useAutoConnect = new JCheckBox(XMLResourceBundle.getBundledString("cfgUseACLabel")));
    //      JPanel typePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    //      typePanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgTypeLabel")));
    //      typePanel.add(autoConnectType = new JComboBox(new Object [] {XMLResourceBundle.getBundledString("cfgFileLabel"), XMLResourceBundle.getBundledString("cfgMysqlLabel")}));
    //      ac.add(typePanel);
    //      ac.add(autoConnectSubPanel = new JPanel(new BorderLayout()));
    //      //from w w w. java 2s . c o  m
    //      fsSubPanel = new JPanel(new LooseGridLayout(0, 2, 5, 5, false, true, SwingConstants.LEFT, SwingConstants.TOP));
    //      fsSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgPathLabel"))); fsSubPanel.add(acFSPath = new JTextField(40));
    //      
    //      dbSubPanel = new JPanel(new LooseGridLayout(0, 2, 5, 5, false, true, SwingConstants.LEFT, SwingConstants.TOP));
    //      dbSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgPathLabel"))); dbSubPanel.add(acDBPath = new JTextField(40));
    //      dbSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgHostLabel"))); dbSubPanel.add(acDBHost = new JTextField(40));
    //      dbSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgDBLabel"))); dbSubPanel.add(acDBDatabase = new JTextField(40));
    //      dbSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgUserLabel"))); dbSubPanel.add(acDBUser = new JTextField(40));
    //      dbSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgPasswordLabel"))); dbSubPanel.add(acDBPassword = new JTextField(40));
    //      
    //      Set<ConnectionHandler.PastConnection> cons = new ConnectionHandler().connections;
    //      if (cons != null)
    //      {
    //         Vector<Object> recentCons = new Vector<Object>();
    //         for (ConnectionHandler.PastConnection con : cons)
    //            if (con.source instanceof DataLinkMySQLSource || con.source instanceof DataLinkFS2Source)
    //               recentCons.add(con);
    //         
    //         if (!recentCons.isEmpty())
    //         {
    //            recentCons.insertElementAt(XMLResourceBundle.getBundledString("cfgCurrentLabel"), 0);
    //            JPanel recentPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    //            recentPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgRecentLabel")));
    //            JComboBox recentBox = new JComboBox(recentCons);
    //            recentPanel.add(recentBox);
    //            ac.add(recentPanel);
    //            
    //            recentBox.addItemListener(new ItemListener() {public void itemStateChanged(ItemEvent e)
    //            {
    //               if (e.getStateChange() != ItemEvent.SELECTED)
    //                  return;
    //               if (e.getItem().equals(XMLResourceBundle.getBundledString("cfgCurrentLabel")))
    //                  fillAutoConnect(xml);
    //               else fillAutoConnect((ConnectionHandler.PastConnection)e.getItem());
    //            }});
    //         }
    //      }

    JPanel display = new JPanel(
            new LooseGridLayout(0, 1, 5, 5, false, true, SwingConstants.LEFT, SwingConstants.TOP));
    display.setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgDisplayLabel")));
    JPanel displayDims = new JPanel(
            new LooseGridLayout(0, 2, 5, 5, false, true, SwingConstants.LEFT, SwingConstants.TOP));
    displayDims.add(new JLabel(XMLResourceBundle.getBundledString("cfgWidthLabel")));
    displayDims.add(displayWidth = new JTextField(5));
    displayDims.add(new JLabel(XMLResourceBundle.getBundledString("cfgHeightLabel")));
    displayDims.add(displayHeight = new JTextField(5));
    displayDims.add(new JLabel(XMLResourceBundle.getBundledString("cfgLanguageLabel")));
    displayDims.add(
            displayLang = new JComboBox(new Object[] { XMLResourceBundle.getBundledString("cfgEnglishLabel"),
                    XMLResourceBundle.getBundledString("cfgFrenchLabel") }));
    display.add(displayHelp = new JCheckBox(XMLResourceBundle.getBundledString("cfgHelpLabel")));
    display.add(displayFullscreen = new JCheckBox(XMLResourceBundle.getBundledString("cfgFullscreenLabel")));
    display.add(displayNativeCursor = new JCheckBox(XMLResourceBundle.getBundledString("cfgUseCursorLabel")));
    display.add(displayDims);

    JPanel topPluginsPanel = new JPanel(
            new LooseGridLayout(0, 1, 5, 5, true, true, SwingConstants.LEFT, SwingConstants.TOP));
    topPluginsPanel
            .setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgPluginsLabel")));
    pluginsPanel = new JPanel(
            new LooseGridLayout(0, 1, 5, 5, true, false, SwingConstants.LEFT, SwingConstants.TOP, true, false));
    JScrollPane scrollPane = new JScrollPane(pluginsPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setPreferredSize(new Dimension(500, 300));
    scrollPane.getVerticalScrollBar().setUnitIncrement(10);
    topPluginsPanel.add(scrollPane);

    JPanel addPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    addPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgAddPluginLabel")) {
        public void actionPerformed(ActionEvent e) {
            try {
                JOptionPane.showMessageDialog(GeneralConfigPanel.this,
                        XMLResourceBundle.getBundledString("cfgAddPluginMessage").replace("%pdir",
                                DocExploreTool.getPluginDir().getAbsolutePath()));
                if (System.getProperty("os.name").toLowerCase().contains("win"))
                    Runtime.getRuntime()
                            .exec(new String[] { "explorer", DocExploreTool.getPluginDir().getAbsolutePath() });
                else if (System.getProperty("os.name").toLowerCase().contains("mac"))
                    Runtime.getRuntime()
                            .exec(new String[] { "open", DocExploreTool.getPluginDir().getAbsolutePath() });
            } catch (Exception ex) {
                ErrorHandler.defaultHandler.submit(ex);
            }
            //         File jarFile = browsePlugins();
            //         if (jarFile == null)
            //            return;
            //         PluginPanel pluginPanel = new PluginPanel(GeneralConfigPanel.this, "yes", jarFile.getName(), "");
            //         pluginPanels.add(pluginPanel);
            //         pluginsPanel.add(pluginPanel);
            //         ((Window)getTopLevelAncestor()).pack();
        }
    }));
    addPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgRefreshPluginsLabel")) {
        public void actionPerformed(ActionEvent e) {
            refreshPlugins(xml);
            ((Window) getTopLevelAncestor()).pack();
        }
    }));
    topPluginsPanel.add(addPanel);

    //      setAutoConnectSubPanel(fsSubPanel);

    //      add(ac);
    add(display);
    add(topPluginsPanel);

    add(safeMode = new JCheckBox(XMLResourceBundle.getBundledString("cfgSafeModeLabel")));

    //      autoConnectType.addItemListener(new ItemListener() {public void itemStateChanged(ItemEvent e)
    //      {
    //         if (e.getStateChange() != ItemEvent.SELECTED)
    //            return;
    //         if (e.getItem().equals(XMLResourceBundle.getBundledString("cfgFileLabel")))
    //            setAutoConnectSubPanel(fsSubPanel);
    //         else setAutoConnectSubPanel(dbSubPanel);
    //         Window top = (Window)getTopLevelAncestor();
    //         if (top != null)
    //            top.pack();
    //      }});

    if (xml != null)
        fill(xml);
}

From source file:org.interreg.docexplore.ServerConfigPanel.java

public ServerConfigPanel(final File config, final File serverDir) throws Exception {
    super(new LooseGridLayout(0, 1, 5, 5, true, false, SwingConstants.LEFT, SwingConstants.TOP, true, false));

    this.serverDir = serverDir;
    this.books = new Vector<Book>();
    this.bookList = new JList(new DefaultListModel());

    JPanel listPanel = new JPanel(new BorderLayout());
    listPanel.setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgBooksLabel")));
    bookList.setOpaque(false);//  w ww  .j  a va 2 s  . co m
    bookList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    bookList.setCellRenderer(new ListCellRenderer() {
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            Book book = (Book) value;
            JLabel label = new JLabel("<html><b>" + book.name + "</b> - " + book.nPages + " pages</html>");
            label.setOpaque(true);
            if (isSelected) {
                label.setBackground(TextToolbar.styleHighLightedBackground);
                label.setForeground(Color.white);
            }
            if (book.deleted)
                label.setForeground(Color.red);
            else if (!book.used)
                label.setForeground(Color.gray);
            return label;
        }
    });
    bookList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting())
                return;
            setFields((Book) bookList.getSelectedValue());
        }
    });
    JScrollPane scrollPane = new JScrollPane(bookList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setPreferredSize(new Dimension(500, 300));
    scrollPane.getVerticalScrollBar().setUnitIncrement(10);
    listPanel.add(scrollPane, BorderLayout.CENTER);

    JPanel importPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    importPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgImportLabel")) {
        public void actionPerformed(ActionEvent e) {
            final File inFile = DocExploreTool.getFileDialogs().openFile(DocExploreTool.getIBookCategory());
            if (inFile == null)
                return;

            try {
                final File tmpDir = new File(serverDir, "tmp");
                tmpDir.mkdir();

                GuiUtils.blockUntilComplete(new ProgressRunnable() {
                    float[] progress = { 0 };

                    public void run() {
                        try {
                            ZipUtils.unzip(inFile, tmpDir, progress);
                        } catch (Exception ex) {
                            ErrorHandler.defaultHandler.submit(ex);
                        }
                    }

                    public float getProgress() {
                        return (float) progress[0];
                    }
                }, ServerConfigPanel.this);

                File tmpFile = new File(tmpDir, "index.tmp");
                ObjectInputStream input = new ObjectInputStream(new FileInputStream(tmpFile));
                String bookFile = input.readUTF();
                String bookName = input.readUTF();
                String bookDesc = input.readUTF();
                input.close();

                new PresentationImporter().doImport(ServerConfigPanel.this, bookName, bookDesc,
                        new File(tmpDir, bookFile));
                FileUtils.cleanDirectory(tmpDir);
                FileUtils.deleteDirectory(tmpDir);
                updateBooks();
            } catch (Exception ex) {
                ErrorHandler.defaultHandler.submit(ex);
            }
        }
    }));
    listPanel.add(importPanel, BorderLayout.SOUTH);
    add(listPanel);

    JPanel setupPanel = new JPanel(
            new LooseGridLayout(0, 1, 5, 5, true, false, SwingConstants.LEFT, SwingConstants.TOP, true, false));
    setupPanel.setBorder(
            BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgBookInfoLabel")));
    usedBox = new JCheckBox(XMLResourceBundle.getBundledString("cfgUseLabel"));
    usedBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Book book = (Book) bookList.getSelectedValue();
            if (book != null) {
                book.used = usedBox.isSelected();
                bookList.repaint();
            }
        }
    });
    setupPanel.add(usedBox);

    JPanel fieldPanel = new JPanel(new LooseGridLayout(0, 2, 5, 5, false, false, SwingConstants.LEFT,
            SwingConstants.TOP, true, false));
    fieldPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgTitleLabel")));
    nameField = new JTextField(50);
    nameField.getDocument().addDocumentListener(new DocumentListener() {
        public void removeUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        public void insertUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        public void changedUpdate(DocumentEvent e) {
            Book book = (Book) bookList.getSelectedValue();
            if (book == null)
                return;
            book.name = nameField.getText();
            bookList.repaint();
        }
    });
    fieldPanel.add(nameField);

    fieldPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgDescriptionLabel")));
    descField = new JTextPane();
    //descField.setWrapStyleWord(true);
    descField.getDocument().addDocumentListener(new DocumentListener() {
        public void removeUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        public void insertUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        public void changedUpdate(DocumentEvent e) {
            Book book = (Book) bookList.getSelectedValue();
            if (book == null)
                return;
            book.desc = descField.getText();
        }
    });
    scrollPane = new JScrollPane(descField, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setPreferredSize(new Dimension(420, 50));
    scrollPane.getVerticalScrollBar().setUnitIncrement(10);
    fieldPanel.add(scrollPane);

    setupPanel.add(fieldPanel);

    exportButton = new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgExportLabel")) {
        public void actionPerformed(ActionEvent e) {
            File file = DocExploreTool.getFileDialogs().saveFile(DocExploreTool.getIBookCategory());
            if (file == null)
                return;
            final Book book = (Book) bookList.getSelectedValue();
            final File indexFile = new File(serverDir, "index.tmp");
            try {
                final File outFile = file;
                ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(indexFile));
                out.writeUTF(book.bookFile.getName());
                out.writeUTF(book.name);
                out.writeUTF(book.desc);
                out.close();

                GuiUtils.blockUntilComplete(new ProgressRunnable() {
                    float[] progress = { 0 };

                    public void run() {
                        try {
                            ZipUtils.zip(serverDir, new File[] { indexFile, book.bookFile, book.bookDir },
                                    outFile, progress, 0, 1, 9);
                        } catch (Exception ex) {
                            ErrorHandler.defaultHandler.submit(ex);
                        }
                    }

                    public float getProgress() {
                        return (float) progress[0];
                    }
                }, ServerConfigPanel.this);
            } catch (Exception ex) {
                ErrorHandler.defaultHandler.submit(ex);
            }
            if (indexFile.exists())
                indexFile.delete();
        }
    });
    deleteButton = new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgDeleteRestoreLabel")) {
        public void actionPerformed(ActionEvent e) {
            Book book = (Book) bookList.getSelectedValue();
            if (book == null)
                return;
            book.deleted = !book.deleted;
            bookList.repaint();
        }
    });

    JPanel actionsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    actionsPanel.add(exportButton);
    actionsPanel.add(deleteButton);
    setupPanel.add(actionsPanel);

    add(setupPanel);

    JPanel optionsPanel = new JPanel(new LooseGridLayout(0, 2, 5, 5, false, false, SwingConstants.LEFT,
            SwingConstants.TOP, true, false));
    optionsPanel
            .setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgOptionsLabel")));
    JPanel timeoutPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    timeoutField = new JTextField(5);
    timeoutPanel.add(timeoutField);
    timeoutPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgTimeoutLabel")));
    optionsPanel.add(timeoutPanel);
    add(optionsPanel);

    updateBooks();
    setFields(null);

    final String xml = config.exists() ? StringUtils.readFile(config) : "<config></config>";
    String idle = StringUtils.getTagContent(xml, "idle");
    if (idle != null)
        try {
            timeoutField.setText("" + Integer.parseInt(idle));
        } catch (Throwable e) {
        }
}

From source file:org.isatools.gui.datamanager.exportisa.ExportISAGUI.java

public void createGUI() {
    // header image
    add(UIHelper.wrapComponentInPanel(new JLabel(panelHeader, SwingConstants.RIGHT)), BorderLayout.NORTH);

    // add a checkable jtree with investigations & studies...
    JPanel availableSubmissionsContainer = new JPanel(new BorderLayout());
    availableSubmissionsContainer.setOpaque(false);

    JPanel optionsContainer = new JPanel();
    optionsContainer.setLayout(new BoxLayout(optionsContainer, BoxLayout.LINE_AXIS));
    optionsContainer.setOpaque(false);//from  w ww  . ja v  a  2s. com

    JPanel optionsAndInformationPanel = new JPanel();
    optionsAndInformationPanel.setLayout(new BoxLayout(optionsAndInformationPanel, BoxLayout.PAGE_AXIS));
    optionsAndInformationPanel.setOpaque(false);

    JLabel fileInformation = UIHelper.createLabel("<html><i>where</i> to save the isatab files?</html>",
            UIHelper.VER_12_BOLD, UIHelper.LIGHT_GREY_COLOR);
    fileInformation.setVerticalAlignment(JLabel.TOP);

    JPanel fileLocationOptionContainer = new JPanel();
    fileLocationOptionContainer.setLayout(new BoxLayout(fileLocationOptionContainer, BoxLayout.PAGE_AXIS));
    fileLocationOptionContainer.setOpaque(false);

    // add component for selection of output to repository or output to folder...
    fileLocationOptionGroup = new OptionGroup<String>(OptionGroup.HORIZONTAL_ALIGNMENT, true);
    fileLocationOptionGroup.addOptionItem("BII repository", true);
    fileLocationOptionGroup.addOptionItem("Local file system");

    localDirectoryLocation = new FileSelectionUtil("select output directory", createFileChooser(),
            UIHelper.VER_11_BOLD, UIHelper.GREY_COLOR);
    localDirectoryLocation.setVisible(false);
    localDirectoryLocation.setPreferredSize(new Dimension(150, 20));

    fileLocationOptionGroup.addPropertyChangeListener("optionSelectionChange", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
            localDirectoryLocation
                    .setVisible(fileLocationOptionGroup.getSelectedItem().equals("Local file system"));
            revalidate();
        }
    });

    fileLocationOptionContainer.add(UIHelper.wrapComponentInPanel(fileInformation));
    fileLocationOptionContainer.add(UIHelper.wrapComponentInPanel(fileLocationOptionGroup));
    fileLocationOptionContainer.add(Box.createVerticalStrut(5));
    fileLocationOptionContainer.add(UIHelper.wrapComponentInPanel(localDirectoryLocation));

    optionsContainer.add(fileLocationOptionContainer);

    JPanel dataFileExportOptionContainer = new JPanel();
    dataFileExportOptionContainer.setLayout(new BoxLayout(dataFileExportOptionContainer, BoxLayout.PAGE_AXIS));
    dataFileExportOptionContainer.setOpaque(false);

    JLabel dataFileExportInformation = UIHelper.createLabel("<html>export data files?</html>",
            UIHelper.VER_12_BOLD, UIHelper.LIGHT_GREY_COLOR);
    dataFileExportInformation.setVerticalAlignment(JLabel.TOP);

    dataFileExportOptionGroup = new OptionGroup<String>(OptionGroup.HORIZONTAL_ALIGNMENT, true);
    dataFileExportOptionGroup.addOptionItem("yes", true);
    dataFileExportOptionGroup.addOptionItem("no");

    dataFileExportOptionContainer.add(UIHelper.wrapComponentInPanel(dataFileExportInformation));
    dataFileExportOptionContainer.add(UIHelper.wrapComponentInPanel(dataFileExportOptionGroup));
    dataFileExportOptionContainer.add(Box.createVerticalStrut(25));

    optionsContainer.add(dataFileExportOptionContainer);

    optionsAndInformationPanel.add(Box.createVerticalStrut(5));
    optionsAndInformationPanel.add(optionsContainer);
    optionsAndInformationPanel.add(Box.createVerticalStrut(10));

    JLabel information = UIHelper.createLabel(
            "<html>please <i>select</i> the submissions to be exported...</html>", UIHelper.VER_12_BOLD,
            UIHelper.LIGHT_GREY_COLOR);
    information.setVerticalAlignment(JLabel.TOP);

    optionsAndInformationPanel.add(UIHelper.wrapComponentInPanel(information));
    optionsAndInformationPanel.add(Box.createVerticalStrut(5));

    availableSubmissionsContainer.add(optionsAndInformationPanel, BorderLayout.NORTH);

    retrieveAndProcessStudyInformation();

    JScrollPane treeScroller = new JScrollPane(studyAvailabilityTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    treeScroller.getViewport().setOpaque(false);
    treeScroller.setOpaque(false);
    treeScroller.setBorder(new EmptyBorder(1, 1, 1, 1));

    treeScroller.setPreferredSize(new Dimension(380, 250));

    availableSubmissionsContainer.add(treeScroller, BorderLayout.CENTER);
    add(availableSubmissionsContainer, BorderLayout.CENTER);
    add(createSouthPanel(), BorderLayout.SOUTH);
}

From source file:org.isatools.gui.datamanager.studyaccess.StudyAccessionGUI.java

private JPanel createStudySelectionPanel() {

    JPanel container = new JPanel();
    container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));
    container.setOpaque(false);/*from www . j  a  v a 2s.  com*/

    JPanel studyAccessionSelector = new JPanel();
    studyAccessionSelector.setLayout(new BorderLayout());
    studyAccessionSelector.setOpaque(false);

    JLabel information = new JLabel(unloadStudyHeader);
    information.setHorizontalAlignment(SwingConstants.RIGHT);
    information.setVerticalAlignment(SwingConstants.TOP);

    studyAccessionSelector.add(information, BorderLayout.NORTH);

    retrieveAndProcessStudyInformation();

    JScrollPane treeScroller = new JScrollPane(studyAvailabilityTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    treeScroller.getViewport().setOpaque(false);
    treeScroller.setOpaque(false);
    treeScroller.setBorder(new EmptyBorder(1, 1, 1, 1));

    treeScroller.setPreferredSize(new Dimension(380, 210));

    studyAccessionSelector.add(treeScroller);

    container.add(studyAccessionSelector);

    // and need a convert button!
    JPanel buttonCont = new JPanel(new BorderLayout());
    buttonCont.setOpaque(false);

    final JLabel unload = new JLabel(this.unloadButton, JLabel.RIGHT);

    unload.addMouseListener(new MouseAdapter() {

        public void mouseEntered(MouseEvent mouseEvent) {
            unload.setIcon(unloadButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            unload.setIcon(StudyAccessionGUI.this.unloadButton);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            Set<String> studiesToUnload = studyAvailabilityTree
                    .getCheckedStudies(studyAvailabilityTree.getRoot());
            log.info("going to unload: ");
            for (String acc : studiesToUnload) {
                log.info("study with acc " + acc);
            }
            doUnloading(studiesToUnload);
        }

    });
    buttonCont.add(unload, BorderLayout.EAST);

    buttonCont.add(createBackToMainMenuButton(), BorderLayout.WEST);

    container.add(buttonCont);

    return container;
}

From source file:org.isatools.isacreator.filechooser.FileChooserUI.java

/**
 * Creates the FileSelection panel containing the list of selected files, and the toolbar to modify the list
 *
 * @return JPanel containing a selection pane
 *///from   ww w  . j  ava  2 s  . c om
private JPanel createFilesSelectedPanel() {
    JPanel selectionContainer = new JPanel(new BorderLayout());
    selectionContainer.setBackground(UIHelper.BG_COLOR);
    selectionContainer.setBorder(
            new TitledBorder(UIHelper.GREEN_ROUNDED_BORDER, "selection(s)", TitledBorder.DEFAULT_JUSTIFICATION,
                    TitledBorder.DEFAULT_POSITION, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR));

    selectedFiles = new DirectoryFileList();
    listModel = (DefaultListModel) selectedFiles.getModel();

    selectedFiles.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    selectedFiles.setDragEnabled(false);

    JScrollPane selectedFileScroller = new JScrollPane(selectedFiles, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    selectedFileScroller.setPreferredSize(new Dimension(200, 175));
    selectedFileScroller.setBorder(new EmptyBorder(0, 0, 0, 0));

    IAppWidgetFactory.makeIAppScrollPane(selectedFileScroller);

    selectionContainer.add(selectedFileScroller, BorderLayout.CENTER);

    // add list modification toolbar to sort, move, and delete files from the list.
    JPanel optionsPanel = new JPanel();
    optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.LINE_AXIS));
    optionsPanel.setBackground(UIHelper.BG_COLOR);

    final JLabel moveDown = new JLabel(downIcon);
    moveDown.setOpaque(false);
    moveDown.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            moveDown.setIcon(downIcon);

            if (!selectedFiles.isSelectionEmpty()) {
                int toMoveDown = selectedFiles.getSelectedIndex();

                if (toMoveDown != (listModel.getSize() - 1)) {
                    swapElements(toMoveDown, toMoveDown + 1);
                }
            }
        }

        public void mouseEntered(MouseEvent event) {
            moveDown.setIcon(downIconOver);
        }

        public void mouseExited(MouseEvent event) {
            moveDown.setIcon(downIcon);
        }
    });

    optionsPanel.add(moveDown);
    optionsPanel.add(Box.createHorizontalStrut(5));

    final JLabel moveUp = new JLabel(upIcon);
    moveUp.setOpaque(false);
    moveUp.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            moveUp.setIcon(upIcon);

            if (!selectedFiles.isSelectionEmpty()) {
                int toMoveUp = selectedFiles.getSelectedIndex();

                if (toMoveUp != 0) {
                    swapElements(toMoveUp, toMoveUp - 1);
                }
            }
        }

        public void mouseEntered(MouseEvent event) {
            moveUp.setIcon(upIconOver);
        }

        public void mouseExited(MouseEvent event) {
            moveUp.setIcon(upIcon);
        }
    });

    optionsPanel.add(moveUp);
    optionsPanel.add(Box.createHorizontalStrut(5));

    final JLabel deleteItem = new JLabel(deleteIcon);
    deleteItem.setOpaque(false);
    deleteItem.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            deleteItem.setIcon(deleteIcon);

            if (selectedFiles.getSelectedValues() != null) {
                for (Object o : selectedFiles.getSelectedValues()) {
                    listModel.removeElement(o);
                }
            }
        }

        public void mouseEntered(MouseEvent event) {
            deleteItem.setIcon(deleteIconOver);
        }

        public void mouseExited(MouseEvent event) {
            deleteItem.setIcon(deleteIcon);
        }
    });

    optionsPanel.add(deleteItem);
    optionsPanel.add(Box.createHorizontalStrut(5));

    final JLabel sortAsc = new JLabel(sortAscIcon);
    sortAsc.setOpaque(false);
    sortAsc.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            sortAsc.setIcon(sortAscIcon);
            if (listModel.getSize() > 0) {
                sort(true);
            }
        }

        public void mouseEntered(MouseEvent event) {
            sortAsc.setIcon(sortAscIconOver);
        }

        public void mouseExited(MouseEvent event) {
            sortAsc.setIcon(sortAscIcon);
        }
    });

    optionsPanel.add(sortAsc);
    optionsPanel.add(Box.createHorizontalStrut(5));

    final JLabel sortDesc = new JLabel(sortDescIcon);
    sortDesc.setOpaque(false);
    sortDesc.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            sortDesc.setIcon(sortDescIcon);
            if (listModel.getSize() > 0) {
                sort(false);
            }
        }

        public void mouseEntered(MouseEvent event) {
            sortDesc.setIcon(sortDescIconOver);
        }

        public void mouseExited(MouseEvent event) {
            sortDesc.setIcon(sortDescIcon);
        }
    });

    optionsPanel.add(sortDesc);
    optionsPanel.add(Box.createHorizontalStrut(5));

    selectionContainer.add(optionsPanel, BorderLayout.SOUTH);

    return selectionContainer;
}

From source file:org.isatools.isacreator.filechooser.FileChooserUI.java

/**
 * Create the Navigation Tree panel//from  w  w w .  ja v  a2s . c om
 *
 * @return @see JPanel containing the navigation tree to browse a file system.
 */
private JPanel createNavTree() {
    JPanel treeContainer = new JPanel(new BorderLayout());
    treeContainer.setBackground(UIHelper.BG_COLOR);
    treeContainer
            .setBorder(new TitledBorder(UIHelper.GREEN_ROUNDED_BORDER, "", TitledBorder.DEFAULT_JUSTIFICATION,
                    TitledBorder.DEFAULT_POSITION, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR));

    JPanel navigationControls = new JPanel();
    navigationControls.setLayout(new BoxLayout(navigationControls, BoxLayout.LINE_AXIS));
    navigationControls.setOpaque(false);

    final JLabel navToParentDir = new JLabel(upIcon);
    navToParentDir.setOpaque(false);
    navToParentDir.addMouseListener(new CommonMouseAdapter() {

        public void mousePressed(MouseEvent event) {
            super.mousePressed(event);
            navToParentDir.setIcon(upIcon);
            try {
                updateTree(fileBrowser.getParentDirectory());
            } catch (IOException e) {
                errorAction("problem occurred!");
            }
        }

        public void mouseEntered(MouseEvent event) {
            super.mouseEntered(event);
            navToParentDir.setIcon(upIconOver);
        }

        public void mouseExited(MouseEvent event) {
            super.mouseExited(event);
            navToParentDir.setIcon(upIcon);
        }
    });

    navigationControls.add(navToParentDir);
    navigationControls.add(Box.createHorizontalStrut(5));

    final JLabel navToHomeDir = new JLabel(homeIcon);
    navToHomeDir.setOpaque(false);
    navToHomeDir.addMouseListener(new CommonMouseAdapter() {

        public void mousePressed(MouseEvent event) {
            super.mousePressed(event);
            navToHomeDir.setIcon(homeIcon);
            try {
                updateTree(fileBrowser.getHomeDirectory());

            } catch (IOException e) {
                if (e instanceof ConnectionException) {
                    status.setText("<html>status: not connected!</html>");
                }
                FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false,
                        FileBrowserTreeNode.DIRECTORY);
                updateTree(defaultFTPNode);
            }
        }

        public void mouseEntered(MouseEvent event) {
            super.mouseEntered(event);
            navToHomeDir.setIcon(homeIconOver);
        }

        public void mouseExited(MouseEvent event) {
            super.mouseExited(event);
            navToHomeDir.setIcon(homeIcon);
        }
    });

    navigationControls.add(navToHomeDir);
    navigationControls.add(Box.createGlue());

    treeContainer.add(navigationControls, BorderLayout.NORTH);

    try {
        treeModel = new DefaultTreeModel(fileBrowser.getHomeDirectory());
        directoryTree = new JTree(treeModel);
        directoryTree.setFont(UIHelper.VER_11_PLAIN);
        directoryTree.setCellRenderer(new FileSystemTreeCellRenderer());
    } catch (IOException e) {
        FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false,
                FileBrowserTreeNode.DIRECTORY);
        updateTree(defaultFTPNode);
    }

    directoryTree.addMouseListener(new CommonMouseAdapter() {

        public void mousePressed(MouseEvent event) {
            super.mousePressed(event);
            int selRow = directoryTree.getRowForLocation(event.getX(), event.getY());

            TreePath selPath = directoryTree.getPathForLocation(event.getX(), event.getY());

            if (selRow != -1) {
                final FileBrowserTreeNode node = (FileBrowserTreeNode) selPath.getLastPathComponent();

                if (SwingUtilities.isLeftMouseButton(event)) {

                    if (event.getClickCount() == 2) {
                        if ((node.getType() == FileBrowserTreeNode.DIRECTORY) && (node.getLevel() != 0)) {

                            String newPath;
                            if (fileBrowser instanceof LocalBrowser) {
                                newPath = ((File) fileBrowser.getDirFiles().get(node.toString())).getPath();
                            } else {
                                newPath = node.toString();
                            }
                            updateTree(fileBrowser.changeDirectory(newPath));
                        }

                        // else, if a leaf node, then add file to to list
                        if (node.isLeaf() && (node.getType() != FileBrowserTreeNode.DIRECTORY)) {
                            String extension = node.toString().substring(node.toString().lastIndexOf(".") + 1)
                                    .trim().toUpperCase();

                            FileChooserFile toAdd = null;

                            for (Object o : fileBrowser.getFileMap().get(extension)) {
                                String fileName;
                                String filePath;
                                if (fileBrowser instanceof LocalBrowser) {
                                    File file = (File) o;
                                    fileName = file.getName();
                                    filePath = file.getPath();

                                    if (fileName.equals(node.toString())) {
                                        toAdd = new CustomFile(filePath);
                                        break;
                                    }
                                } else {
                                    FTPFile ftpFile = (FTPFile) o;
                                    fileName = ftpFile.getName();
                                    filePath = fileBrowser.getAbsoluteWorkingDirectory() + File.separator
                                            + ftpFile.getName();

                                    if (fileName.equals(node.toString())) {
                                        toAdd = new CustomFTPFile(ftpFile, filePath);
                                        break;
                                    }
                                }

                            }

                            if (toAdd != null && !checkIfInList(toAdd)) {
                                selectedFiles.addFileItem(toAdd);
                            }
                        }
                    }
                } else {
                    if ((node.getType() == FileBrowserTreeNode.DIRECTORY) && (node.getLevel() != 0)) {

                        // show popup to add the directory to the selected files
                        JPopupMenu popup = new JPopupMenu();

                        JMenuItem addDirectory = new JMenuItem("add directory");
                        addDirectory.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent ae) {

                                Object fileToAdd = fileBrowser.getDirFiles().get(node.toString());
                                FileChooserFile toAdd;

                                if (fileToAdd instanceof File) {
                                    toAdd = new CustomFile(((File) fileToAdd).getPath());
                                } else {
                                    FTPFile ftpFile = (FTPFile) fileToAdd;
                                    String filePath = fileBrowser.getAbsoluteWorkingDirectory() + File.separator
                                            + ftpFile.getName();

                                    toAdd = new CustomFTPFile(ftpFile, filePath);
                                }

                                if (!checkIfInList(toAdd)) {
                                    selectedFiles.addDirectoryItem(toAdd);
                                }
                            }
                        });

                        popup.add(addDirectory);
                        popup.show(directoryTree, event.getX(), event.getY());
                    }
                }
            }
        }

    });

    BasicTreeUI ui = new BasicTreeUI() {
        public Icon getCollapsedIcon() {
            return null;
        }

        public Icon getExpandedIcon() {
            return null;
        }
    };

    directoryTree.setUI(ui);
    directoryTree.setFont(UIHelper.VER_12_PLAIN);

    JScrollPane treeScroll = new JScrollPane(directoryTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    treeScroll.setPreferredSize(new Dimension(300, 200));
    treeScroll.setBorder(new EmptyBorder(0, 0, 0, 0));
    treeContainer.add(treeScroll, BorderLayout.CENTER);

    IAppWidgetFactory.makeIAppScrollPane(treeScroll);

    return treeContainer;
}

From source file:org.isatools.isacreator.gui.DataEntryForm.java

/**
 * Adds the fields describing a section to a Container (e.g. JPanel, Box, etc.)
 *
 * @param containerToAddTo @see JPanel, @see Box, @see  Container
 * @param sectionToAddTo   - @see InvestigationFileSection as a reference for where the fields are being added
 * @param fieldValues      - Map of field name to values.
 * @param referenceObject  - A @see DataEntryReferenceObject which gives information about
 *//*from   w w w. j  a v  a  2s  .  co  m*/
public void addFieldsToPanel(Container containerToAddTo, InvestigationFileSection sectionToAddTo,
        OrderedMap<String, String> fieldValues, DataEntryReferenceObject referenceObject) {

    if (fieldDefinitions == null) {
        fieldDefinitions = new ListOrderedMap<String, JComponent>();
    }

    Set<String> ontologyFields = referenceObject.getOntologyTerms(sectionToAddTo);
    Set<String> fieldsToIgnore = referenceObject.getFieldsToIgnore();

    for (String fieldName : fieldValues.keySet()) {

        if (!fieldsToIgnore.contains(fieldName)) {
            FieldObject fieldDescriptor = referenceObject.getFieldDefinition(fieldName);

            if (!fieldDescriptor.isHidden()) {
                String tmpFieldName = fieldName;

                if (realNamesToAliases.containsKey(fieldName)) {
                    tmpFieldName = realNamesToAliases.get(fieldName);
                }

                JPanel fieldPanel = createFieldPanel(1, 2);
                JLabel fieldLabel = createLabel(tmpFieldName);

                JComponent textComponent;

                if (fieldDescriptor.getDatatype() == DataTypes.STRING
                        || fieldDescriptor.getDatatype() == DataTypes.ONTOLOGY_TERM
                        || fieldDescriptor.getDatatype() == DataTypes.DATE) {
                    textComponent = new RoundedJTextField(10);
                } else if (fieldDescriptor.getDatatype() == DataTypes.LONG_STRING) {
                    textComponent = new JTextArea();

                    ((JTextArea) textComponent).setSelectionColor(UIHelper.LIGHT_GREEN_COLOR);
                    ((JTextArea) textComponent).setSelectedTextColor(UIHelper.BG_COLOR);

                    ((JTextArea) textComponent).setWrapStyleWord(true);
                    ((JTextArea) textComponent).setLineWrap(true);
                    textComponent.setBackground(UIHelper.BG_COLOR);
                    textComponent.setBorder(UIHelper.GREEN_ROUNDED_BORDER);
                } else if (fieldDescriptor.getDatatype() == DataTypes.LIST) {
                    textComponent = new JComboBox(fieldDescriptor.getFieldList());
                } else {
                    textComponent = new RoundedJTextField(10);
                }

                if (textComponent instanceof JTextArea || textComponent instanceof JTextComponent) {
                    ((JTextComponent) textComponent)
                            .setText(fieldValues.get(fieldName).equals("") ? fieldDescriptor.getDefaultVal()
                                    : fieldValues.get(fieldName));
                }
                textComponent.setToolTipText(fieldDescriptor.getDescription());

                UIHelper.renderComponent(textComponent, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR,
                        false);

                fieldPanel.add(fieldLabel);

                if (textComponent instanceof JTextArea) {

                    JScrollPane invDescScroll = new JScrollPane(textComponent,
                            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
                    invDescScroll.setPreferredSize(new Dimension(200, 75));

                    invDescScroll.getViewport().setBackground(UIHelper.BG_COLOR);

                    ((JTextArea) textComponent).getDocument().addDocumentListener(new DocumentChangeListener());

                    IAppWidgetFactory.makeIAppScrollPane(invDescScroll);
                    fieldPanel.add(
                            UIHelper.createTextEditEnableJTextArea(invDescScroll, (JTextArea) textComponent));
                } else if (textComponent instanceof JTextComponent) {

                    if (fieldDescriptor.getDatatype() == DataTypes.ONTOLOGY_TERM
                            || ontologyFields.contains(fieldName)) {
                        fieldPanel.add(createOntologyDropDown(fieldName, (JTextComponent) textComponent, true,
                                false, fieldDescriptor.getRecommmendedOntologySource()));
                    } else if (fieldDescriptor.getDatatype() == DataTypes.DATE) {
                        fieldPanel.add(createDateDropDown((JTextComponent) textComponent));
                    } else if (fieldDescriptor.isAcceptsFileLocations()) {
                        fieldPanel.add(createFileField((JTextComponent) textComponent));
                    } else {
                        fieldPanel.add(textComponent);
                    }
                    ((JTextComponent) textComponent).getDocument()
                            .addDocumentListener(new DocumentChangeListener());
                } else {
                    fieldPanel.add(textComponent);
                }

                fieldDefinitions.put(tmpFieldName, textComponent);

                containerToAddTo.add(fieldPanel);
                containerToAddTo.add(Box.createVerticalStrut(5));
            }
        }
    }
}

From source file:org.isatools.isacreator.visualization.InvestigationInfoPanel.java

private JPanel prepareInvestigationInformation() {

    investigationInformation.removeAll();

    JEditorPane currentlyShowingInfo = new JEditorPane();
    currentlyShowingInfo.setContentType("text/html");
    currentlyShowingInfo.setEditable(false);
    currentlyShowingInfo.setBackground(UIHelper.BG_COLOR);

    JScrollPane infoScroller = new JScrollPane(currentlyShowingInfo, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    infoScroller.setBackground(UIHelper.BG_COLOR);
    infoScroller.getViewport().setBackground(UIHelper.BG_COLOR);
    infoScroller.setPreferredSize(new Dimension(width - 10, height - 50));
    infoScroller.setBorder(null);//from  w w w.  jav  a  2 s. c o  m

    IAppWidgetFactory.makeIAppScrollPane(infoScroller);

    Map<String, String> data = getInvestigationDetails();

    String labelContent = "<html>" + "<head>" + "<style type=\"text/css\">" + "<!--" + ".bodyFont {"
            + "   font-family: Verdana;" + "   font-size: 9px;" + "   color: #006838;" + "}" + "-->"
            + "</style>" + "</head>" + "<body class=\"bodyFont\">";

    for (Object key : data.keySet()) {
        labelContent += ("<p><b>" + ((String) key).trim() + ": </b>");
        labelContent += (data.get(key) + "</font></p>");
    }

    labelContent += "</body></html>";

    currentlyShowingInfo.setText(labelContent);

    investigationInformation.add(infoScroller);

    return investigationInformation;
}