Example usage for javax.swing JLabel setToolTipText

List of usage examples for javax.swing JLabel setToolTipText

Introduction

In this page you can find the example usage for javax.swing JLabel setToolTipText.

Prototype

@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.")
public void setToolTipText(String text) 

Source Link

Document

Registers the text to display in a tool tip.

Usage

From source file:org.broad.igv.hic.MainWindow.java

private void initComponents() {
    JPanel mainPanel = new JPanel();
    JPanel toolbarPanel = new JPanel();

    //======== this ========

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    mainPanel.setLayout(new BorderLayout());

    toolbarPanel.setBorder(null);/*from   ww  w  .  ja  v a2s  .c o  m*/
    toolbarPanel.setLayout(new GridLayout());

    JPanel chrSelectionPanel = new JPanel();
    chrSelectionPanel.setBorder(LineBorder.createGrayLineBorder());
    chrSelectionPanel.setMinimumSize(new Dimension(130, 57));
    chrSelectionPanel.setPreferredSize(new Dimension(130, 57));
    chrSelectionPanel.setLayout(new BorderLayout());

    JPanel panel10 = new JPanel();
    panel10.setBackground(new Color(204, 204, 204));
    panel10.setLayout(new BorderLayout());

    JLabel label3 = new JLabel();
    label3.setText("Chromosomes");
    label3.setHorizontalAlignment(SwingConstants.CENTER);
    panel10.add(label3, BorderLayout.CENTER);

    chrSelectionPanel.add(panel10, BorderLayout.PAGE_START);

    JPanel panel9 = new JPanel();
    panel9.setBackground(new Color(238, 238, 238));
    panel9.setLayout(new BoxLayout(panel9, BoxLayout.X_AXIS));

    //---- chrBox1 ----
    chrBox1 = new JComboBox();
    chrBox1.setModel(new DefaultComboBoxModel(new String[] { "All" }));
    chrBox1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            chrBox1ActionPerformed(e);
        }
    });
    panel9.add(chrBox1);

    //---- chrBox2 ----
    chrBox2 = new JComboBox();
    chrBox2.setModel(new DefaultComboBoxModel(new String[] { "All" }));
    chrBox2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            chrBox2ActionPerformed(e);
        }
    });
    panel9.add(chrBox2);

    //---- refreshButton ----
    JideButton refreshButton = new JideButton();
    refreshButton
            .setIcon(new ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Refresh24.gif")));
    refreshButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            refreshButtonActionPerformed(e);
        }
    });
    panel9.add(refreshButton);

    chrSelectionPanel.add(panel9, BorderLayout.CENTER);

    toolbarPanel.add(chrSelectionPanel);

    //======== displayOptionPanel ========
    JPanel displayOptionPanel = new JPanel();
    JPanel panel1 = new JPanel();
    displayOptionComboBox = new JComboBox();

    displayOptionPanel.setBackground(new Color(238, 238, 238));
    displayOptionPanel.setBorder(LineBorder.createGrayLineBorder());
    displayOptionPanel.setLayout(new BorderLayout());

    //======== panel14 ========

    JPanel panel14 = new JPanel();
    panel14.setBackground(new Color(204, 204, 204));
    panel14.setLayout(new BorderLayout());

    //---- label4 ----
    JLabel label4 = new JLabel();
    label4.setText("Show");
    label4.setHorizontalAlignment(SwingConstants.CENTER);
    panel14.add(label4, BorderLayout.CENTER);

    displayOptionPanel.add(panel14, BorderLayout.PAGE_START);

    //======== panel1 ========

    panel1.setBorder(new EmptyBorder(0, 10, 0, 10));
    panel1.setLayout(new GridLayout(1, 0, 20, 0));

    //---- comboBox1 ----
    displayOptionComboBox
            .setModel(new DefaultComboBoxModel(new String[] { DisplayOption.OBSERVED.toString() }));
    displayOptionComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            displayOptionComboBoxActionPerformed(e);
        }
    });
    panel1.add(displayOptionComboBox);

    displayOptionPanel.add(panel1, BorderLayout.CENTER);

    toolbarPanel.add(displayOptionPanel);

    //======== colorRangePanel ========

    JPanel colorRangePanel = new JPanel();
    JLabel colorRangeLabel = new JLabel();
    colorRangeSlider = new RangeSlider();
    colorRangePanel.setBorder(LineBorder.createGrayLineBorder());
    colorRangePanel.setMinimumSize(new Dimension(96, 70));
    colorRangePanel.setPreferredSize(new Dimension(202, 70));
    colorRangePanel.setMaximumSize(new Dimension(32769, 70));
    colorRangePanel.setLayout(new BorderLayout());

    //======== panel11 ========

    JPanel colorLabelPanel = new JPanel();
    colorLabelPanel.setBackground(new Color(204, 204, 204));
    colorLabelPanel.setLayout(new BorderLayout());

    //---- colorRangeLabel ----
    colorRangeLabel.setText("Color Range");
    colorRangeLabel.setHorizontalAlignment(SwingConstants.CENTER);
    colorRangeLabel.setToolTipText("Range of color scale in counts per mega-base squared.");
    colorRangeLabel.setHorizontalTextPosition(SwingConstants.CENTER);
    colorRangeLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) {
                ColorRangeDialog rangeDialog = new ColorRangeDialog(MainWindow.this, colorRangeSlider);
                rangeDialog.setVisible(true);
            }
        }

        @Override
        public void mouseClicked(MouseEvent e) {
            ColorRangeDialog rangeDialog = new ColorRangeDialog(MainWindow.this, colorRangeSlider);
            rangeDialog.setVisible(true);
        }
    });
    colorLabelPanel.add(colorRangeLabel, BorderLayout.CENTER);

    colorRangePanel.add(colorLabelPanel, BorderLayout.PAGE_START);

    //---- colorRangeSlider ----
    colorRangeSlider.setPaintTicks(true);
    colorRangeSlider.setPaintLabels(true);
    colorRangeSlider.setLowerValue(0);
    colorRangeSlider.setMajorTickSpacing(500);
    colorRangeSlider.setMaximumSize(new Dimension(32767, 52));
    colorRangeSlider.setPreferredSize(new Dimension(200, 52));
    colorRangeSlider.setMinimumSize(new Dimension(36, 52));
    colorRangeSlider.setMaximum(2000);
    colorRangeSlider.setUpperValue(500);
    colorRangeSlider.setMinorTickSpacing(100);
    colorRangeSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            colorRangeSliderStateChanged(e);
        }
    });
    colorRangePanel.add(colorRangeSlider, BorderLayout.PAGE_END);

    //        JPanel colorRangeTextPanel = new JPanel();
    //        colorRangeTextPanel.setLayout(new FlowLayout());
    //        JTextField minField = new JTextField();
    //        minField.setPreferredSize(new Dimension(50, 15));
    //        colorRangeTextPanel.add(minField);
    //        colorRangeTextPanel.add(new JLabel(" - "));
    //        JTextField maxField = new JTextField();
    //        maxField.setPreferredSize(new Dimension(50, 15));
    //        colorRangeTextPanel.add(maxField);
    //        colorRangeTextPanel.setPreferredSize(new Dimension(200, 52));
    //        colorRangePanel.add(colorRangeTextPanel, BorderLayout.PAGE_END);

    toolbarPanel.add(colorRangePanel);

    //======== resolutionPanel ========

    JLabel resolutionLabel = new JLabel();
    JPanel resolutionPanel = new JPanel();

    resolutionPanel.setBorder(LineBorder.createGrayLineBorder());
    resolutionPanel.setLayout(new BorderLayout());

    //======== panel12 ========

    JPanel panel12 = new JPanel();
    panel12.setBackground(new Color(204, 204, 204));
    panel12.setLayout(new BorderLayout());

    //---- resolutionLabel ----
    resolutionLabel.setText("Resolution");
    resolutionLabel.setHorizontalAlignment(SwingConstants.CENTER);
    resolutionLabel.setBackground(new Color(204, 204, 204));
    panel12.add(resolutionLabel, BorderLayout.CENTER);

    resolutionPanel.add(panel12, BorderLayout.PAGE_START);

    //======== panel2 ========

    JPanel panel2 = new JPanel();
    panel2.setLayout(new BoxLayout(panel2, BoxLayout.X_AXIS));

    //---- resolutionSlider ----
    resolutionSlider = new JSlider();
    resolutionSlider.setMaximum(8);
    resolutionSlider.setMajorTickSpacing(1);
    resolutionSlider.setPaintTicks(true);
    resolutionSlider.setSnapToTicks(true);
    resolutionSlider.setPaintLabels(true);
    resolutionSlider.setMinorTickSpacing(1);

    Dictionary<Integer, JLabel> resolutionLabels = new Hashtable<Integer, JLabel>();
    Font f = FontManager.getFont(8);
    for (int i = 0; i < HiCGlobals.zoomLabels.length; i++) {
        if ((i + 1) % 2 == 0) {
            final JLabel tickLabel = new JLabel(HiCGlobals.zoomLabels[i]);
            tickLabel.setFont(f);
            resolutionLabels.put(i, tickLabel);
        }
    }
    resolutionSlider.setLabelTable(resolutionLabels);
    // Setting the zoom should always be done by calling resolutionSlider.setValue() so work isn't done twice.
    resolutionSlider.addChangeListener(new ChangeListener() {
        // Change zoom level while staying centered on current location.
        // Centering is relative to the bounds of the data, which might not be the bounds of the window

        public void stateChanged(ChangeEvent e) {
            if (!resolutionSlider.getValueIsAdjusting()) {
                int idx = resolutionSlider.getValue();
                idx = Math.max(0, Math.min(idx, MAX_ZOOM));

                if (hic.zd != null && idx == hic.zd.getZoom()) {
                    // Nothing to do
                    return;
                }

                if (hic.xContext != null) {
                    int centerLocationX = (int) hic.xContext
                            .getChromosomePosition(getHeatmapPanel().getWidth() / 2);
                    int centerLocationY = (int) hic.yContext
                            .getChromosomePosition(getHeatmapPanel().getHeight() / 2);
                    hic.setZoom(idx, centerLocationX, centerLocationY, false);
                }
                //zoomInButton.setEnabled(newZoom < MAX_ZOOM);
                //zoomOutButton.setEnabled(newZoom > 0);
            }
        }
    });
    panel2.add(resolutionSlider);

    resolutionPanel.add(panel2, BorderLayout.CENTER);

    toolbarPanel.add(resolutionPanel);

    mainPanel.add(toolbarPanel, BorderLayout.NORTH);

    //======== hiCPanel ========

    final JPanel hiCPanel = new JPanel();
    hiCPanel.setLayout(new HiCLayout());

    //---- rulerPanel2 ----
    rulerPanel2 = new HiCRulerPanel(hic);
    rulerPanel2.setMaximumSize(new Dimension(4000, 50));
    rulerPanel2.setMinimumSize(new Dimension(1, 50));
    rulerPanel2.setPreferredSize(new Dimension(1, 50));
    rulerPanel2.setBorder(null);

    JPanel panel2_5 = new JPanel();
    panel2_5.setLayout(new BorderLayout());
    panel2_5.add(rulerPanel2, BorderLayout.SOUTH);

    trackPanel = new TrackPanel(hic);
    trackPanel.setMaximumSize(new Dimension(4000, 50));
    trackPanel.setPreferredSize(new Dimension(1, 50));
    trackPanel.setMinimumSize(new Dimension(1, 50));
    trackPanel.setBorder(null);

    //        trackPanelScrollpane = new JScrollPane();
    //        trackPanelScrollpane.getViewport().add(trackPanel);
    //        trackPanelScrollpane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    //        trackPanelScrollpane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    //        trackPanelScrollpane.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 102)));
    //        trackPanelScrollpane.setBackground(new java.awt.Color(237, 237, 237));
    //        trackPanelScrollpane.setVisible(false);
    //        panel2_5.add(trackPanelScrollpane, BorderLayout.NORTH);
    //
    trackPanel.setVisible(false);
    panel2_5.add(trackPanel, BorderLayout.NORTH);

    hiCPanel.add(panel2_5, BorderLayout.NORTH);

    //---- rulerPanel1 ----
    rulerPanel1 = new HiCRulerPanel(hic);
    rulerPanel1.setMaximumSize(new Dimension(50, 4000));
    rulerPanel1.setPreferredSize(new Dimension(50, 500));
    rulerPanel1.setBorder(null);
    rulerPanel1.setMinimumSize(new Dimension(50, 1));
    hiCPanel.add(rulerPanel1, BorderLayout.WEST);

    //---- heatmapPanel ----
    heatmapPanel = new HeatmapPanel(this, hic);
    heatmapPanel.setBorder(LineBorder.createBlackLineBorder());
    heatmapPanel.setMaximumSize(new Dimension(500, 500));
    heatmapPanel.setMinimumSize(new Dimension(500, 500));
    heatmapPanel.setPreferredSize(new Dimension(500, 500));
    heatmapPanel.setBackground(new Color(238, 238, 238));
    hiCPanel.add(heatmapPanel, BorderLayout.CENTER);

    //======== panel8 ========

    JPanel rightSidePanel = new JPanel();
    rightSidePanel.setMaximumSize(new Dimension(120, 100));
    rightSidePanel.setBorder(new EmptyBorder(0, 10, 0, 0));
    rightSidePanel.setLayout(null);

    //---- thumbnailPanel ----
    thumbnailPanel = new ThumbnailPanel(this, hic);
    thumbnailPanel.setMaximumSize(new Dimension(100, 100));
    thumbnailPanel.setMinimumSize(new Dimension(100, 100));
    thumbnailPanel.setPreferredSize(new Dimension(100, 100));
    thumbnailPanel.setBorder(LineBorder.createBlackLineBorder());
    thumbnailPanel.setPreferredSize(new Dimension(100, 100));
    thumbnailPanel.setBounds(new Rectangle(new Point(20, 0), thumbnailPanel.getPreferredSize()));
    rightSidePanel.add(thumbnailPanel);

    //======== xPlotPanel ========

    xPlotPanel = new JPanel();
    xPlotPanel.setPreferredSize(new Dimension(250, 100));
    xPlotPanel.setLayout(null);

    rightSidePanel.add(xPlotPanel);
    xPlotPanel.setBounds(10, 100, xPlotPanel.getPreferredSize().width, 228);

    //======== yPlotPanel ========

    yPlotPanel = new JPanel();
    yPlotPanel.setPreferredSize(new Dimension(250, 100));
    yPlotPanel.setLayout(null);

    rightSidePanel.add(yPlotPanel);
    yPlotPanel.setBounds(10, 328, yPlotPanel.getPreferredSize().width, 228);

    // compute preferred size
    Dimension preferredSize = new Dimension();
    for (int i = 0; i < rightSidePanel.getComponentCount(); i++) {
        Rectangle bounds = rightSidePanel.getComponent(i).getBounds();
        preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
        preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
    }
    Insets insets = rightSidePanel.getInsets();
    preferredSize.width += insets.right;
    preferredSize.height += insets.bottom;
    rightSidePanel.setMinimumSize(preferredSize);
    rightSidePanel.setPreferredSize(preferredSize);

    hiCPanel.add(rightSidePanel, BorderLayout.EAST);

    mainPanel.add(hiCPanel, BorderLayout.CENTER);

    contentPane.add(mainPanel, BorderLayout.CENTER);

    JMenuBar menuBar = createMenuBar(hiCPanel);
    contentPane.add(menuBar, BorderLayout.NORTH);

    // setup the glass pane to display a wait cursor when visible, and to grab all mouse events
    rootPane.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    rootPane.getGlassPane().addMouseListener(new MouseAdapter() {
    });

}

From source file:org.datacleaner.widgets.OpenAnalysisJobFileChooserAccessory.java

private void showFileInformation() {
    JaxbJobReader reader = new JaxbJobReader(_configuration);

    try {/*from  www. ja va2s  .c  o  m*/
        _metadata = reader.readMetadata(_file);
    } catch (Exception e) {
        // metadata could not be produced so we cannot display the file
        // information
        logger.warn("An unexpected error occurred reading metadata from file", e);
        setVisible(false);
        return;
    }

    _centerPanel.removeAll();

    final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

    final int separatorHeight = 6;

    final String jobName = _metadata.getJobName();
    if (jobName != null) {
        _centerPanel.add(new JLabel("<html><b>Job name:</b></html>"));
        _centerPanel.add(new JLabel(jobName));
        _centerPanel.add(Box.createVerticalStrut(separatorHeight));
    }
    final String jobDescription = _metadata.getJobDescription();
    if (jobDescription != null) {
        _centerPanel.add(new JLabel("<html><b>Job description:</b></html>"));
        DCLabel descriptionLabel = DCLabel.darkMultiLine(jobDescription);
        descriptionLabel.setMaximumWidth(WIDTH);
        _centerPanel.add(descriptionLabel);
        _centerPanel.add(Box.createVerticalStrut(separatorHeight));
    }
    final String jobVersion = _metadata.getJobVersion();
    if (jobVersion != null) {
        _centerPanel.add(new JLabel("<html><b>Job version:</b></html>"));
        _centerPanel.add(new JLabel(jobVersion));
        _centerPanel.add(Box.createVerticalStrut(separatorHeight));
    }
    final String author = _metadata.getAuthor();
    if (author != null) {
        _centerPanel.add(new JLabel("<html><b>Author:</b></html>"));
        _centerPanel.add(new JLabel(author));
        _centerPanel.add(Box.createVerticalStrut(separatorHeight));
    }
    final Date createdDate = _metadata.getCreatedDate();
    if (createdDate != null) {
        _centerPanel.add(new JLabel("<html><b>Created:</b></html>"));
        _centerPanel.add(new JLabel(dateFormat.format(createdDate)));
        _centerPanel.add(Box.createVerticalStrut(separatorHeight));
    }
    final Date updatedDate = _metadata.getUpdatedDate();
    if (updatedDate != null) {
        _centerPanel.add(new JLabel("<html><b>Updated:</b></html>"));
        _centerPanel.add(new JLabel(dateFormat.format(updatedDate)));
        _centerPanel.add(Box.createVerticalStrut(separatorHeight));
    }

    final String datastoreName = _metadata.getDatastoreName();

    _centerPanel.add(new JLabel("<html><b>Datastore:</b></html>"));
    final JLabel datastoreLabel = new JLabel(datastoreName);

    Datastore datastore = _configuration.getDatastoreCatalog().getDatastore(datastoreName);
    if (datastore == null) {
        _openJobButton.setEnabled(false);
        datastoreLabel.setIcon(imageManager.getImageIcon(IconUtils.STATUS_WARNING, IconUtils.ICON_SIZE_SMALL));
        datastoreLabel.setToolTipText("No such datastore: " + datastoreName);
    } else {
        _openJobButton.setEnabled(true);
        datastoreLabel.setIcon(IconUtils.getDatastoreIcon(datastore, IconUtils.ICON_SIZE_SMALL));
        datastoreLabel.setToolTipText(null);
    }

    _centerPanel.add(datastoreLabel);
    _centerPanel.add(Box.createVerticalStrut(separatorHeight));
    _centerPanel.add(new JLabel("<html><b>Source columns:</b></html>"));
    List<String> paths = _metadata.getSourceColumnPaths();
    for (String path : paths) {
        JLabel columnLabel = new JLabel(path);
        columnLabel.setIcon(imageManager.getImageIcon("images/model/column.png", IconUtils.ICON_SIZE_SMALL));
        _centerPanel.add(columnLabel);
    }

    _centerPanel.updateUI();
    setVisible(true);
}

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

private JPanel createTopPanel() {

    final JTextField uri = new RoundedJTextField(20);
    final JTextField username = new RoundedJTextField(20);
    final JPasswordField password = new RoundedJPasswordField(20);

    final JPanel topContainer = new JPanel();
    topContainer.setLayout(new BoxLayout(topContainer, BoxLayout.PAGE_AXIS));
    topContainer.setBackground(UIHelper.BG_COLOR);

    HUDTitleBar titlePanel = new HUDTitleBar(null, null, true);
    add(titlePanel, BorderLayout.NORTH);
    titlePanel.installListeners();// w  w  w . ja v  a2  s  .c o m

    topContainer.add(titlePanel);

    JPanel buttonPanel = new JPanel(new GridLayout(1, 1));
    buttonPanel.setOpaque(false);

    JPanel fileSystemPanel = new JPanel();
    fileSystemPanel.setLayout(new BoxLayout(fileSystemPanel, BoxLayout.LINE_AXIS));
    fileSystemPanel.setBackground(UIHelper.BG_COLOR);

    localFsChoice = new JLabel(localFileSystemIcon, JLabel.LEFT);
    localFsChoice.setBackground(UIHelper.BG_COLOR);
    localFsChoice.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    localFsChoice.setIcon(localFileSystemIconOver);
                    remoteFsChoice.setIcon(remoteFileSystemIcon);
                    ftpConnectionContainer.setVisible(false);
                    topContainer.revalidate();
                    status.setText("");
                    fileBrowser = new LocalBrowser();
                    try {
                        updateTree(fileBrowser.getHomeDirectory());
                    } catch (IOException e) {
                        FileBrowserTreeNode defaultFTPNode = new FileBrowserTreeNode("problem occurred!", false,
                                FileBrowserTreeNode.DIRECTORY);
                        updateTree(defaultFTPNode);
                    }

                }
            });

        }
    });

    fileSystemPanel.add(localFsChoice);
    fileSystemPanel.add(Box.createHorizontalStrut(5));

    remoteFsChoice = new JLabel(remoteFileSystemIcon, JLabel.LEFT);
    remoteFsChoice.setBackground(UIHelper.BG_COLOR);
    remoteFsChoice.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    localFsChoice.setIcon(localFileSystemIcon);
                    remoteFsChoice.setIcon(remoteFileSystemIconOver);
                    ftpConnectionContainer.setVisible(true);
                    topContainer.revalidate();
                }
            });
            // immediately try to call FTP manager to get last sessions details
            final FTPAuthentication lastSession;
            if ((lastSession = ftpManager.getLastSession()) != null) {
                Thread remoteConnector = new Thread(new Runnable() {
                    public void run() {
                        connectToFTP(lastSession.getUri(), lastSession.getUsername(),
                                lastSession.getPassword());
                    }
                });
                remoteConnector.start();
            } else {
                errorAction("no ftp location");
            }

        }
    });

    fileSystemPanel.add(remoteFsChoice);
    fileSystemPanel.add(Box.createHorizontalStrut(5));

    status = UIHelper.createLabel("", UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR);
    status.setHorizontalAlignment(JLabel.RIGHT);

    fileSystemPanel.add(status);

    buttonPanel.add(fileSystemPanel);

    topContainer.add(buttonPanel);

    // now create panel to configure the FTP site
    ftpConnectionContainer = new JPanel(new GridLayout(1, 1));
    ftpConnectionContainer.setBackground(UIHelper.BG_COLOR);

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

    // add field to add URI
    JPanel uriPanel = new JPanel(new GridLayout(1, 2));
    uriPanel.setBackground(UIHelper.BG_COLOR);

    JLabel uriLab = UIHelper.createLabel("FTP URI: ", UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR);
    UIHelper.renderComponent(uri, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    uriPanel.add(uriLab);
    uriPanel.add(uri);

    userAuthFTP.add(uriPanel);

    // add field to add username
    JPanel usernamePanel = new JPanel(new GridLayout(1, 2));
    usernamePanel.setBackground(UIHelper.BG_COLOR);

    JLabel usernameLab = UIHelper.createLabel("Username: ", UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR);

    UIHelper.renderComponent(username, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    uriPanel.add(usernameLab);
    uriPanel.add(username);

    userAuthFTP.add(usernamePanel);

    // add field to add password
    JPanel passwordPanel = new JPanel(new GridLayout(1, 2));
    passwordPanel.setBackground(UIHelper.BG_COLOR);

    JLabel passwordLab = UIHelper.createLabel("Password: ", UIHelper.VER_10_BOLD, UIHelper.DARK_GREEN_COLOR);

    UIHelper.renderComponent(password, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    passwordPanel.add(passwordLab);
    passwordPanel.add(password);

    userAuthFTP.add(passwordPanel);

    JLabel connectLab = new JLabel(connectIcon);
    connectLab.setOpaque(false);
    connectLab.setToolTipText("<html><b>Connect</b><p>Connect to the FTP source defined!</p></html>");

    connectLab.addMouseListener(new CommonMouseAdapter() {
        public void mousePressed(MouseEvent event) {
            super.mousePressed(event);
            if (uri.getText() != null && !uri.getText().trim().equals("")) {
                String user = (username.getText() != null) ? username.getText() : "";
                String pass = (password.getPassword() != null) ? new String(password.getPassword()) : "";

                final FTPAuthentication newFTPLocation = new FTPAuthentication(uri.getText(), user, pass);

                Thread remoteConnector = new Thread(new Runnable() {
                    public void run() {
                        connectToFTP(newFTPLocation.getUri(), newFTPLocation.getUsername(),
                                newFTPLocation.getPassword());
                    }
                });
                remoteConnector.start();
            }
        }

    });

    userAuthFTP.add(connectLab);

    JLabel historyLab = new JLabel(viewHistoryIcon);
    historyLab.setOpaque(false);
    historyLab.setToolTipText(
            "<html><b>Search previously connected to FTP locations</b><p>Connect to a previously defined FTP location</p></html>");
    historyLab.addMouseListener(new CommonMouseAdapter() {

        public void mousePressed(MouseEvent event) {
            super.mousePressed(event);
            SelectFromFTPHistory selectFTP = new SelectFromFTPHistory();
            selectFTP.addPropertyChangeListener("locationSelected", new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent event) {

                    if (event.getNewValue() != null) {
                        final FTPAuthentication ftpRecord = ftpManager
                                .retrieveFTPAuthenticationObject(event.getNewValue().toString());
                        Thread remoteConnector = new Thread(new Runnable() {
                            public void run() {
                                connectToFTP(ftpRecord.getUri(), ftpRecord.getUsername(),
                                        ftpRecord.getPassword());
                            }
                        });
                        remoteConnector.start();
                    }

                }
            });
            selectFTP.createGUI();
            showJDialogAsSheet(selectFTP);
        }

    });

    userAuthFTP.add(historyLab);

    ftpConnectionContainer.add(userAuthFTP);

    ftpConnectionContainer.setVisible(false);

    topContainer.add(ftpConnectionContainer);

    return topContainer;
}

From source file:org.isatools.isacreator.gui.formelements.SubForm.java

private JPanel setupOptionsPanel() {
    options = new JPanel();
    options.setLayout(new BoxLayout(options, BoxLayout.LINE_AXIS));
    options.setOpaque(false);//ww w.j a v a  2s  .  co  m

    String addRecordString = fieldType == FieldTypes.ASSAY && dataEntryForm != null ? "create assay"
            : "add a new " + fieldType + " column";

    final JLabel addRecord = new JLabel(addRecordString, addRecordIcon, JLabel.LEFT);

    String toolTipText;

    if (fieldType == FieldTypes.ASSAY) {
        toolTipText = "<html><b>Create a new Assay</b>"
                + "          <p>Complete the details for the assay in the fields provided</p>"
                + "          <p>and click this button to add the assay to this study...</p>" + "</html>";
    } else {
        toolTipText = "<html><b>Add a new " + fieldType + "</b>"
                + "          <p>Click here to add a new column to enter an additional " + fieldType + "</p>"
                + "</html>";
    }

    addRecord.setToolTipText(toolTipText);
    Font fontToUse = fieldType == FieldTypes.ASSAY && dataEntryForm != null ? UIHelper.VER_12_BOLD
            : UIHelper.VER_12_PLAIN;
    UIHelper.renderComponent(addRecord, fontToUse, UIHelper.DARK_GREEN_COLOR, false);

    addRecord.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent event) {
            addRecord.setIcon(addRecordIcon);
            if (addColumn()) {
                updateTables();
            }
        }

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            addRecord.setIcon(addRecordIconOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            addRecord.setIcon(addRecordIcon);
        }
    });

    options.add(addRecord);
    options.add(Box.createHorizontalStrut(10));

    removeRecord = new JLabel("Remove " + fieldType + "...", removeIcon, JLabel.LEFT);
    removeRecord.setVisible(false);
    UIHelper.renderComponent(removeRecord, UIHelper.VER_12_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    removeRecord.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent event) {
            if (removeRecord.getIcon() != null) {
                removeRecord.setIcon(removeIcon);
            }
            removalConfirmation(fieldType);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            if (removeRecord.getIcon() != null) {
                removeRecord.setIcon(removeIcon);
            }
        }

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            if (removeRecord.getIcon() != null) {
                removeRecord.setIcon(removeIconOver);
            }
        }
    });

    if (!showRemoveOption) {
        removeRecord.setIcon(null);
        removeRecord.setText("");
    }

    options.add(removeRecord);
    options.add(Box.createHorizontalStrut(10));
    createCustomOptions();

    options.add(Box.createGlue());

    return options;
}

From source file:org.isatools.isacreator.wizard.GeneralCreationAlgorithm.java

public JPanel instantiatePanel() {
    final JPanel generalQuestionCont = new JPanel();
    generalQuestionCont.setLayout(new BoxLayout(generalQuestionCont, BoxLayout.PAGE_AXIS));
    generalQuestionCont.setBackground(UIHelper.BG_COLOR);

    JLabel info = new JLabel("<html><b>" + assay.getMeasurementEndpoint() + "</b> using <b>"
            + assay.getTechnologyType() + "</b></html>", JLabel.LEFT);
    UIHelper.renderComponent(info, UIHelper.VER_12_PLAIN, UIHelper.GREY_COLOR, false);

    if (assay.getTechnologyType().equals("")) {
        info.setText("<html><b>" + assay.getMeasurementEndpoint() + "</html>");
    }/*from w  w w  . java 2s.  c om*/

    info.setPreferredSize(new Dimension(300, 40));

    JPanel infoPanel = new JPanel(new GridLayout(1, 1));
    infoPanel.setBackground(UIHelper.BG_COLOR);

    infoPanel.add(info);

    generalQuestionCont.add(infoPanel);

    JPanel labelPanel = new JPanel(new GridLayout(1, 2));
    labelPanel.setBackground(UIHelper.BG_COLOR);

    labelCapture = new LabelCapture("Label");
    labelCapture.setVisible(false);

    labelUsed = new JCheckBox("Label used?", false);
    UIHelper.renderComponent(labelUsed, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, UIHelper.BG_COLOR);

    labelUsed.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            labelCapture.setVisible(labelUsed.isSelected());

        }
    });

    labelPanel.add(labelUsed);
    labelPanel.add(labelCapture);

    generalQuestionCont.add(labelPanel);

    final JPanel extractPanel = new JPanel(new GridLayout(2, 2));
    extractPanel.setBackground(UIHelper.BG_COLOR);

    extractDetails.clear();

    JLabel extractsUsedLab = UIHelper.createLabel("Sample(s) used *");
    extractsUsedLab.setHorizontalAlignment(JLabel.LEFT);
    extractsUsedLab.setVerticalAlignment(JLabel.TOP);

    final JPanel extractNameContainer = new JPanel();
    extractNameContainer.setLayout(new BoxLayout(extractNameContainer, BoxLayout.PAGE_AXIS));
    extractNameContainer.setBackground(UIHelper.BG_COLOR);

    extract = new ExtractDetailsCapture("Sample " + (extractDetails.size() + 1),
            ApplicationManager.getUserInterfaceForISASection(study).getDataEntryEnvironment());

    extractDetails.add(extract);
    extractNameContainer.add(extract);

    JLabel addButton = new JLabel("add sample", addRecordIcon, JLabel.RIGHT);
    UIHelper.renderComponent(addButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false);

    addButton.setVerticalAlignment(JLabel.TOP);
    addButton.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            extract = new ExtractDetailsCapture("Sample " + (extractDetails.size() + 1),
                    ApplicationManager.getUserInterfaceForISASection(study).getDataEntryEnvironment());
            extractDetails.add(extract);
            extractNameContainer.add(extract);

            extractNameContainer.revalidate();
            generalQuestionCont.revalidate();
        }

    });

    addButton.setToolTipText(
            "<html><b>add new sample</b><p>add another sample (e.g. Liver, Heart, Urine, Blood)</p></html>");

    JLabel removeButton = new JLabel("remove sample", removeIcon, JLabel.RIGHT);
    removeButton.setVerticalAlignment(JLabel.TOP);
    UIHelper.renderComponent(removeButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    removeButton.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            if (extractDetails.size() > 1) {
                extract = extractDetails.get(extractDetails.size() - 1);
                extractDetails.remove(extract);
                extractNameContainer.remove(extract);
                generalQuestionCont.revalidate();
            }
        }

    });
    removeButton.setToolTipText(
            "<html><b>remove previously added sample</b><p>remove the sample field last added</p></html>");

    extractPanel.add(extractsUsedLab);
    extractPanel.add(extractNameContainer);

    JPanel buttonContainer = new JPanel(new GridLayout(1, 2));
    buttonContainer.setBackground(UIHelper.BG_COLOR);

    buttonContainer.add(addButton);
    buttonContainer.add(removeButton);

    extractPanel.add(new JLabel());
    extractPanel.add(buttonContainer);

    generalQuestionCont.add(extractPanel);

    generalQuestionCont.add(Box.createVerticalStrut(5));
    generalQuestionCont.add(Box.createHorizontalGlue());

    generalQuestionCont.setBorder(new TitledBorder(new RoundedBorder(UIHelper.DARK_GREEN_COLOR, 9),
            assay.getAssayReference(), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
            UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR));

    return generalQuestionCont;
}

From source file:org.isatools.isacreator.wizard.MicroarrayCreationAlgorithm.java

private JPanel instantiatePanel() {
    final JPanel microArrayQuestionCont = new JPanel();
    microArrayQuestionCont.setLayout(new BoxLayout(microArrayQuestionCont, BoxLayout.PAGE_AXIS));
    microArrayQuestionCont.setOpaque(false);

    StringBuilder text = new StringBuilder("<html><b>" + assay.getMeasurementEndpoint() + "</b> using <b>"
            + assay.getTechnologyType() + "</b>");

    if (!StringUtils.isEmpty(assay.getAssayPlatform())) {
        text.append(" on <b>").append(assay.getAssayPlatform()).append("</b>");
    }// w w w. ja v a  2  s .  c  o  m

    JLabel info = new JLabel(text.append("</html>").toString(), JLabel.LEFT);

    UIHelper.renderComponent(info, UIHelper.VER_12_PLAIN, UIHelper.GREY_COLOR, false);
    info.setPreferredSize(new Dimension(300, 40));

    JPanel infoPanel = new JPanel(new GridLayout(1, 1));
    infoPanel.setOpaque(false);

    infoPanel.add(info);

    microArrayQuestionCont.add(infoPanel);

    // create reference sample used checkbox

    JPanel labelPanel = new JPanel(new GridLayout(2, 2));
    labelPanel.setBackground(UIHelper.BG_COLOR);

    final DataEntryForm studyUISection = ApplicationManager.getUserInterfaceForISASection(study);
    System.out.println("Study user interface is null? " + (studyUISection == null));
    System.out
            .println("Study user interface dep is null? " + (studyUISection.getDataEntryEnvironment() == null));

    label1Capture = new LabelCapture("Label (e.g. Cy3)");
    label2Capture = new LabelCapture("Label (e.g. Cy5)");
    label2Capture.setVisible(false);

    // create dye swap check box
    dyeSwapUsed = new JCheckBox("dye-swap performed?", false);
    UIHelper.renderComponent(dyeSwapUsed, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false);

    dyeSwapUsed.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            label2Capture.setVisible(dyeSwapUsed.isSelected());

        }
    });

    labelPanel.add(UIHelper.createLabel("Label(s) used"));
    labelPanel.add(label1Capture);
    labelPanel.add(dyeSwapUsed);
    labelPanel.add(label2Capture);

    microArrayQuestionCont.add(labelPanel);

    final JPanel extractPanel = new JPanel(new GridLayout(2, 2));
    extractPanel.setOpaque(false);

    extractDetails.clear();

    JLabel extractsUsedLab = UIHelper.createLabel("sample(s) used *");
    extractsUsedLab.setHorizontalAlignment(JLabel.LEFT);
    extractsUsedLab.setVerticalAlignment(JLabel.TOP);

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

    extract = new ExtractDetailsCapture("Sample " + (extractDetails.size() + 1),
            studyUISection.getDataEntryEnvironment());

    extractDetails.add(extract);
    extractNameContainer.add(extract);

    JLabel addExtractButton = new JLabel("add sample", addRecordIcon, JLabel.RIGHT);
    UIHelper.renderComponent(addExtractButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false);

    addExtractButton.setVerticalAlignment(JLabel.TOP);
    addExtractButton.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            extract = new ExtractDetailsCapture("Sample " + (extractDetails.size() + 1),
                    studyUISection.getDataEntryEnvironment());
            extractDetails.add(extract);
            extractNameContainer.add(extract);

            extractNameContainer.revalidate();
            microArrayQuestionCont.revalidate();
        }
    });

    addExtractButton.setToolTipText(
            "<html><b>add new sample</b><p>add another sample (e.g. Liver, Heart, Urine, Blood)</p></html>");

    JLabel removeExtractButton = new JLabel("remove sample", removeIcon, JLabel.RIGHT);
    removeExtractButton.setVerticalAlignment(JLabel.TOP);
    UIHelper.renderComponent(removeExtractButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    removeExtractButton.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            if (extractDetails.size() > 1) {
                extract = extractDetails.get(extractDetails.size() - 1);
                extractDetails.remove(extract);
                extractNameContainer.remove(extract);
                microArrayQuestionCont.revalidate();
            }
        }
    });
    removeExtractButton.setToolTipText(
            "<html><b>remove previously added sample</b><p>remove the array design field last added</p></html>");

    extractPanel.add(extractsUsedLab);
    extractPanel.add(extractNameContainer);

    JPanel extractButtonContainer = new JPanel(new GridLayout(1, 2));
    extractButtonContainer.setOpaque(false);

    extractButtonContainer.add(addExtractButton);
    extractButtonContainer.add(removeExtractButton);

    extractPanel.add(new JLabel());
    extractPanel.add(extractButtonContainer);

    microArrayQuestionCont.add(extractPanel);

    // ask for array designs used...
    // create array designs panel
    final JPanel arrayDesignPanel = new JPanel(new GridLayout(2, 2));
    arrayDesignPanel.setOpaque(false);

    arrayDesignsUsed.clear();

    JLabel arrayDesignLab = UIHelper.createLabel("array design(s) used *");
    arrayDesignLab.setVerticalAlignment(JLabel.TOP);
    // the array designs container must adjust to an unknown number of fields. therefore, a JPanel with a BoxLayout
    // will be used since it is flexible!
    final JPanel arrayDesignsContainer = new JPanel();
    arrayDesignsContainer.setLayout(new BoxLayout(arrayDesignsContainer, BoxLayout.PAGE_AXIS));
    arrayDesignsContainer.setOpaque(false);

    newArrayDesign = new AutoFilterCombo(arrayDesigns, true);

    UIHelper.renderComponent(newArrayDesign, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);
    newArrayDesign.setPreferredSize(new Dimension(70, 30));

    arrayDesignsContainer.add(newArrayDesign);
    arrayDesignsUsed.add(newArrayDesign);

    JLabel addButton = new JLabel("add design", addRecordIcon, JLabel.RIGHT);

    UIHelper.renderComponent(addButton, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, false);
    addButton.setVerticalAlignment(JLabel.TOP);
    addButton.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            newArrayDesign = new AutoFilterCombo(arrayDesigns, true);
            UIHelper.renderComponent(newArrayDesign, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);
            newArrayDesign.setPreferredSize(new Dimension(70, 30));
            arrayDesignsUsed.add(newArrayDesign);
            arrayDesignsContainer.add(newArrayDesign);
            arrayDesignsContainer.revalidate();
            microArrayQuestionCont.revalidate();
        }

    });
    addButton.setToolTipText("<html><b>add new array design</b><p>add another array design</p></html>");

    JLabel removeButton = new JLabel("remove design", removeIcon, JLabel.RIGHT);
    removeButton.setVerticalAlignment(JLabel.TOP);
    UIHelper.renderComponent(removeButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    removeButton.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            if (arrayDesignsUsed.size() > 1) {
                newArrayDesign = arrayDesignsUsed.get(arrayDesignsUsed.size() - 1);
                arrayDesignsUsed.remove(newArrayDesign);
                arrayDesignsContainer.remove(newArrayDesign);
                arrayDesignPanel.revalidate();
                microArrayQuestionCont.validate();
            }
        }

    });
    removeButton.setToolTipText(
            "<html><b>remove previously added array design</b><p>remove the array design field last added</p></html>");

    arrayDesignPanel.add(arrayDesignLab);
    arrayDesignPanel.add(arrayDesignsContainer);

    JPanel buttonContainer = new JPanel(new GridLayout(1, 2));
    buttonContainer.setOpaque(false);

    buttonContainer.add(addButton);
    buttonContainer.add(removeButton);

    arrayDesignPanel.add(new JLabel());
    arrayDesignPanel.add(buttonContainer);

    microArrayQuestionCont.add(arrayDesignPanel);

    microArrayQuestionCont.add(Box.createVerticalStrut(5));
    microArrayQuestionCont.add(Box.createHorizontalGlue());

    microArrayQuestionCont.setBorder(new TitledBorder(new RoundedBorder(UIHelper.DARK_GREEN_COLOR, 9),
            assay.getAssayReference(), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
            UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR));

    return microArrayQuestionCont;
}

From source file:org.isatools.isacreatorconfigurator.configui.DataEntryPanel.java

private JPanel createTableListPanel() {

    JPanel container = new JPanel();
    container.setBackground(UIHelper.BG_COLOR);
    container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));

    JLabel lab = new JLabel(tableListTitle);

    container.add(UIHelper.wrapComponentInPanel(lab));
    container.add(Box.createVerticalStrut(5));

    tableModel = new DefaultListModel();
    tableList = new JList(tableModel);
    tableList.setCellRenderer(new TableListRenderer());
    tableList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    tableList.setBackground(UIHelper.BG_COLOR);
    tableList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent event) {
            try {
                saveCurrentField(false, false);
            } catch (DataNotCompleteException dce) {
                showMessagePane(dce.getMessage(), JOptionPane.ERROR_MESSAGE);
            }/*from ww w. j  a v a 2s . c  om*/

            MappingObject currentlyEditedTable = getCurrentlySelectedTable();
            ApplicationManager.setCurrentMappingObject(currentlyEditedTable);

            // update the view error button visibility depending on selected tables error state.
            viewErrorsButton.setVisible(areThereErrorsInThisCurrentObject());

            updateTableInfoDisplay(currentlyEditedTable);
            reformFieldList(currentlyEditedTable);
        }
    });

    JScrollPane listScroller = new JScrollPane(tableList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    listScroller.getViewport().setBackground(UIHelper.BG_COLOR);
    listScroller.setBorder(null);
    listScroller.setPreferredSize(new Dimension(((int) (WIDTH * 0.25)), ((int) (HEIGHT * 0.75))));

    IAppWidgetFactory.makeIAppScrollPane(listScroller);

    container.add(listScroller);
    container.add(Box.createVerticalStrut(5));

    tableCountInfo = UIHelper.createLabel("", UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR);
    container.add(UIHelper.wrapComponentInPanel(tableCountInfo));
    container.add(Box.createVerticalStrut(5));

    // create button panel to add and remove tables
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
    buttonPanel.setBackground(UIHelper.BG_COLOR);

    final JLabel addTableButton = new JLabel(addTable, JLabel.LEFT);
    UIHelper.renderComponent(addTableButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    addTableButton.setOpaque(false);

    addTableButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            addTableButton.setIcon(addTableOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            addTableButton.setIcon(addTable);
        }

        public void mousePressed(MouseEvent event) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    addTableButton.setIcon(addTable);
                    applicationContainer.showJDialogAsSheet(addTableUI);
                }
            });

        }

    });

    addTableButton.setToolTipText("<html><b>Add table</b><p>Add a new table definition.</p></html>");

    final JLabel removeTableButton = new JLabel(removeTable, JLabel.LEFT);
    UIHelper.renderComponent(removeTableButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    removeTableButton.setOpaque(false);

    removeTableButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            removeTableButton.setIcon(removeTableOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            removeTableButton.setIcon(removeTable);
        }

        public void mousePressed(MouseEvent event) {
            removeTableButton.setIcon(removeTable);
            if (tableList.getSelectedValue() != null) {
                String selectedTable = tableList.getSelectedValue().toString();
                MappingObject toRemove = null;
                for (MappingObject mo : tableFields.keySet()) {
                    if (mo.getAssayName().equals(selectedTable)) {
                        toRemove = mo;
                        break;
                    }
                }

                if (toRemove != null) {
                    tableFields.remove(toRemove);
                    reformTableList();
                }
            }
        }

    });

    removeTableButton.setToolTipText("<html><b>Remove table</b><p>Remove table from definitions?</p></html>");

    viewErrorsButton = new JLabel(viewErrorsIcon);
    viewErrorsButton.setVisible(false);
    viewErrorsButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent mouseEvent) {
            viewErrorsButton.setIcon(viewErrorsIcon);
            // show error pane for current table only.

            Validator validator = new Validator();
            validateFormOrTable(validator, ApplicationManager.getCurrentMappingObject());

            ValidationReport report = validator.getReport();

            ConfigurationValidationUI validationUI = new ConfigurationValidationUI(tableFields.keySet(),
                    report);
            validationUI.createGUI();
            validationUI.setLocationRelativeTo(getApplicationContainer());
            validationUI.setAlwaysOnTop(true);
            validationUI.setVisible(true);
        }

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            viewErrorsButton.setIcon(viewErrorsIconOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            viewErrorsButton.setIcon(viewErrorsIcon);
        }
    });

    buttonPanel.add(addTableButton);
    buttonPanel.add(removeTableButton);
    buttonPanel.add(viewErrorsButton);
    buttonPanel.add(Box.createHorizontalGlue());

    container.add(buttonPanel);

    container.add(Box.createVerticalGlue());

    return container;
}

From source file:org.isatools.isacreatorconfigurator.configui.DataEntryPanel.java

private JPanel createFieldListPanel() {

    JPanel container = new JPanel();
    container.setBackground(UIHelper.BG_COLOR);
    container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));

    JPanel headerLab = new JPanel(new GridLayout(1, 1));
    headerLab.setOpaque(false);/*  w  w  w  . ja va 2s  .  c o  m*/

    JLabel lab = new JLabel(fieldListTitle);
    headerLab.add(lab);

    container.add(headerLab);
    container.add(Box.createVerticalStrut(5));

    elementModel = new DefaultListModel();
    elementList = new ReOrderableJList(elementModel);
    elementList.setCellRenderer(new CustomReOrderableListCellRenderer(elementList));
    elementList.setDragEnabled(true);
    elementList.setBackground(UIHelper.BG_COLOR);

    elementList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent event) {
            Display selectedNode = (Display) elementList.getSelectedValue();
            if (selectedNode != null) {
                try {
                    saveCurrentField(false, false);
                } catch (DataNotCompleteException dce) {
                    showMessagePane(dce.getMessage(), JOptionPane.ERROR_MESSAGE);
                }
                if (selectedNode instanceof FieldElement) {
                    fieldInterface.setCurrentField((FieldElement) selectedNode);
                    if (currentPage != fieldInterface) {
                        setCurrentPage(fieldInterface);
                    }
                    removeElementButton.setEnabled(!standardISAFields.isFieldRequired(selectedNode.toString()));
                } else {
                    setCurrentPage(structureElement);
                }
            }
        }
    });

    elementList.addPropertyChangeListener("orderChanged", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
            updateFieldOrder();

            if (tableList.getSelectedValue() instanceof MappingObject) {
                validateFormOrTable(ApplicationManager.getCurrentMappingObject());
            }
        }
    });

    JScrollPane listScroller = new JScrollPane(elementList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    listScroller.getViewport().setBackground(UIHelper.BG_COLOR);
    listScroller.setBorder(new EmptyBorder(2, 2, 2, 10));
    listScroller.setPreferredSize(new Dimension(((int) (WIDTH * 0.25)), ((int) (HEIGHT * 0.75))));
    IAppWidgetFactory.makeIAppScrollPane(listScroller);

    container.add(listScroller);
    container.add(Box.createVerticalStrut(5));

    elementCountInfo = UIHelper.createLabel("", UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR);

    container.add(UIHelper.wrapComponentInPanel(elementCountInfo));
    container.add(Box.createVerticalStrut(5));

    // create button panel to add and remove tables
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
    buttonPanel.setBackground(UIHelper.BG_COLOR);

    final JLabel addFieldButton = new JLabel(addElement, JLabel.LEFT);
    addFieldButton.setOpaque(false);

    addFieldButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            addFieldButton.setIcon(addElementOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            addFieldButton.setIcon(addElement);
        }

        public void mousePressed(MouseEvent event) {
            addFieldButton.setIcon(addElement);
            showAddFieldUI();
        }

    });

    addFieldButton.setToolTipText(
            "<html><b>Add Field to table</b><p>Add a new field to currently selected table</b></p></html>");

    removeElementButton = new JLabel(removeElement, JLabel.LEFT);
    removeElementButton.setOpaque(false);

    removeElementButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            removeElementButton.setIcon(removeElementOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            removeElementButton.setIcon(removeElement);
        }

        public void mousePressed(MouseEvent event) {
            removeElementButton.setIcon(removeElement);
            if (removeElementButton.isEnabled()) {
                removeSelectedElement();
            }
        }

    });

    removeElementButton.setToolTipText(
            "<html><b>Remove Field from table</b><p>Remove this field from this list and the currently selected table.</b></p></html>");

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

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            moveDownButton.setIcon(moveDownOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            moveDownButton.setIcon(moveDown);
        }

        public void mousePressed(MouseEvent event) {
            moveDownButton.setIcon(moveDown);
            if (elementList.getSelectedIndex() != -1) {
                int toMoveDown = elementList.getSelectedIndex();

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

                updateFieldOrder();
                validateFormOrTable(ApplicationManager.getCurrentMappingObject());
            }
        }
    });

    moveDownButton.setToolTipText(
            "<html><b>Move Field Down</b><p>Move the selected field down <b>one</b> position in the list.</p></html>");

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

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            moveUpButton.setIcon(moveUpOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            moveUpButton.setIcon(moveUp);
        }

        public void mousePressed(MouseEvent event) {
            moveUpButton.setIcon(moveUp);
            if (elementList.getSelectedIndex() != -1) {
                int toMoveUp = elementList.getSelectedIndex();

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

                updateFieldOrder();
                validateFormOrTable(ApplicationManager.getCurrentMappingObject());

            }
        }

    });

    moveUpButton.setToolTipText(
            "<html><b>Move Field Up</b><p>Move the selected field up <b>one</b> position in the list.</p></html>");

    buttonPanel.add(addFieldButton);
    buttonPanel.add(removeElementButton);
    buttonPanel.add(moveDownButton);
    buttonPanel.add(moveUpButton);

    container.add(buttonPanel);

    container.add(Box.createVerticalGlue());

    return container;
}

From source file:org.jajuk.ui.thumbnails.LastFmAlbumThumbnail.java

/**
 * Thumb populating done in EDT.// www  .ja  v  a2 s.  co  m
 */
@Override
public void populate() {
    preLoad();
    if (ii == null) {
        return;
    }
    jlIcon = new JLabel();
    postPopulate();
    jlIcon.setIcon(ii);
    setLayout(new MigLayout("ins 0,gapy 2"));
    add(jlIcon, "center,wrap");
    JLabel jlTitle;
    String fullTitle = album.getTitle();
    // Add year if available
    String releaseDate = album.getReleaseDateString();
    if (StringUtils.isNotBlank(releaseDate)) {
        fullTitle += " (" + releaseDate + ")";
    }
    int textLength = 15;
    if (isArtistView()) {
        textLength = 50;
    }
    if (bKnown) {
        // Album known in collection, display its name in bold
        jlTitle = new JLabel(UtilString.getLimitedString(fullTitle, textLength),
                IconLoader.getIcon(JajukIcons.ALBUM), SwingConstants.CENTER);
        jlTitle.setFont(FontManager.getInstance().getFont(JajukFont.BOLD));
    } else {
        jlTitle = new JLabel(UtilString.getLimitedString(fullTitle, textLength));
        jlTitle.setFont(FontManager.getInstance().getFont(JajukFont.PLAIN));
    }
    jlTitle.setToolTipText(album.getTitle());
    jlIcon.setToolTipText(album.getTitle());
    add(jlTitle, "center");
    jlIcon.setBorder(new DropShadowBorder(Color.BLACK, 5, 0.5f, 5, false, true, false, true));
    // disable inadequate menu items
    jmiCDDBWizard.setEnabled(false);
    jmiGetCovers.setEnabled(false);
    if (getItem() == null) {
        jmiDelete.setEnabled(false);
        jmiPlay.setEnabled(false);
        jmiPlayRepeat.setEnabled(false);
        jmiPlayShuffle.setEnabled(false);
        jmiFrontPush.setEnabled(false);
        jmiPush.setEnabled(false);
        jmiProperties.setEnabled(false);
    }
    // Set URL to open
    if (UtilSystem.isBrowserSupported()) {
        jmiOpenLastFMSite.putClientProperty(Const.DETAIL_CONTENT, album.getUrl());
    }
}

From source file:org.jajuk.ui.thumbnails.LastFmArtistThumbnail.java

/**
 * Thumb populating done in EDT./* w  w  w. j  av  a2s  .  c o  m*/
 */
@Override
public void populate() {
    preLoad();
    if (ii == null) {
        return;
    }
    jlIcon = new JLabel();
    postPopulate();
    jlIcon.setIcon(ii);
    setLayout(new MigLayout("ins 0,gapy 2"));
    // Use a panel to allow text to be bigger than image under it
    add(jlIcon, "center,wrap");
    int textLength = 15;
    // In artist view, we have plenty of free space
    if (isArtistView()) {
        textLength = 50;
    }
    JLabel jlTitle = new JLabel(UtilString.getLimitedString(artist.getName(), textLength));
    jlTitle.setToolTipText(artist.getName());
    jlIcon.setToolTipText(artist.getName());
    if (bKnown && !isArtistView()) {
        // Artist known in collection, display its name in bold
        jlTitle.setIcon(IconLoader.getIcon(JajukIcons.ARTIST));
        jlTitle.setFont(FontManager.getInstance().getFont(JajukFont.BOLD));
    } else {
        jlTitle.setFont(FontManager.getInstance().getFont(JajukFont.PLAIN));
    }
    if (isArtistView()) {
        add(jlTitle, "center");
    } else {
        add(jlTitle, "left");
    }
    jlIcon.setBorder(new DropShadowBorder(Color.BLACK, 5, 0.5f, 5, false, true, false, true));
    // disable inadequate menu items
    jmiCDDBWizard.setEnabled(false);
    jmiGetCovers.setEnabled(false);
    if (getItem() == null) {
        jmiDelete.setEnabled(false);
        jmiPlay.setEnabled(false);
        jmiPlayRepeat.setEnabled(false);
        jmiPlayShuffle.setEnabled(false);
        jmiFrontPush.setEnabled(false);
        jmiPush.setEnabled(false);
        jmiProperties.setEnabled(false);
    }
    // Set URL to open
    if (UtilSystem.isBrowserSupported()) {
        jmiOpenLastFMSite.putClientProperty(Const.DETAIL_CONTENT, artist.getUrl());
    }
}