Example usage for javax.swing JButton setToolTipText

List of usage examples for javax.swing JButton setToolTipText

Introduction

In this page you can find the example usage for javax.swing JButton 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.ayound.js.debug.ui.DebugMainFrame.java

private void initToolBar() {
    toolBar = new JToolBar();

    Container debugInfoContainer = new Box(BoxLayout.LINE_AXIS);
    toolBar.add(debugInfoContainer);/*from   w ww . j  a v  a 2s. co m*/

    JLabel urlLabel = new JLabel(Messages.getString("DebugMainFrame.UrlLabel")); //$NON-NLS-1$
    debugInfoContainer.add(urlLabel);

    urlText = new JTextField(20);
    String historyUrl = ConfigUtil.getPropertie("url");
    if (historyUrl == null) {
        File testFile = new File(new File(getBaseDir()), "test/test.htm"); //$NON-NLS-1$
        urlText.setText(testFile.getAbsolutePath().replace('\\', '/'));
    } else {
        urlText.setText(historyUrl);
    }
    debugInfoContainer.add(urlText);

    urlButton = new JButton(Messages.getString("DebugMainFrame.Select")); //$NON-NLS-1$
    urlButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            JFileChooser fileDialog = new JFileChooser(); // 
            fileDialog.setFileFilter(new FileFilter() {

                @Override
                public boolean accept(File f) {
                    String fileName = f.getName().toLowerCase();
                    if (fileName.endsWith(".htm") //$NON-NLS-1$
                            || fileName.endsWith(".html") //$NON-NLS-1$
                            || f.isDirectory()) {
                        return true;
                    } else {
                        return false;
                    }

                }

                @Override
                public String getDescription() {
                    return ".htm,.html"; //$NON-NLS-1$
                }
            });
            int result = fileDialog.showOpenDialog(DebugMainFrame.this);
            if (result == JFileChooser.APPROVE_OPTION) {
                urlText.setText(fileDialog.getSelectedFile().getAbsolutePath());
            }
        }
    });
    debugInfoContainer.add(urlButton);

    JLabel portLabel = new JLabel(Messages.getString("DebugMainFrame.PortLabel")); //$NON-NLS-1$
    debugInfoContainer.add(portLabel);

    portText = new JTextField(2);
    portText.setText("8088"); //$NON-NLS-1$
    debugInfoContainer.add(portText);

    JLabel browserLabel = new JLabel(Messages.getString("DebugMainFrame.BrowserLabel")); //$NON-NLS-1$
    debugInfoContainer.add(browserLabel);

    browserText = new JTextField(20);
    debugInfoContainer.add(browserText);
    String historyBrowser = ConfigUtil.getPropertie("browser");
    if (historyBrowser != null) {
        browserText.setText(historyBrowser);
        // .setText("C:\\Program Files\\Internet Explorer\\iexplore.exe");
        // //$NON-NLS-1$
    }

    browserButton = new JButton(Messages.getString("DebugMainFrame.Select")); //$NON-NLS-1$
    browserButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            JFileChooser fileDialog = new JFileChooser(); // 
            fileDialog.setFileFilter(new FileFilter() {

                @Override
                public boolean accept(File f) {
                    String fileName = f.getName().toLowerCase();
                    if (fileName.endsWith(".exe") || f.isDirectory()) { //$NON-NLS-1$
                        return true;
                    } else {
                        return false;
                    }

                }

                @Override
                public String getDescription() {
                    return ".exe(windows)"; //$NON-NLS-1$
                }
            });
            int result = fileDialog.showOpenDialog(DebugMainFrame.this);
            if (result == JFileChooser.APPROVE_OPTION) {
                browserText.setText(fileDialog.getSelectedFile().getAbsolutePath());
            }
        }
    });
    debugInfoContainer.add(browserButton);

    toolBar.addSeparator();

    JButton startBtn = toolBar.add(actionDebugStart);
    startBtn.setToolTipText(Messages.getString("DebugMainFrame.StartDebug")); //$NON-NLS-1$

    JButton endBtn = toolBar.add(actionDebugEnd);
    endBtn.setToolTipText(Messages.getString("DebugMainFrame.EndDebug")); //$NON-NLS-1$

    getContentPane().add(toolBar, BorderLayout.BEFORE_FIRST_LINE);
}

From source file:org.datacleaner.panels.DatabaseDriversPanel.java

private DCTable getDatabaseDriverTable() {
    final List<DatabaseDriverDescriptor> databaseDrivers = _databaseDriverCatalog.getDatabaseDrivers();
    final List<UserDatabaseDriver> userPreferencesDatabaseDrivers = _userPreferences.getDatabaseDrivers();
    final List<UserDatabaseDriver> unknownManuallyInstalledDrivers = getUnknownManuallyInstalledDrivers(
            userPreferencesDatabaseDrivers, databaseDrivers);
    final TableModel tableModel = new DefaultTableModel(
            new String[] { "", "Database", "Driver class", "Installed?", "Used?" },
            databaseDrivers.size() + unknownManuallyInstalledDrivers.size());

    final DCTable table = new DCTable(tableModel);

    final Icon validIcon = imageManager.getImageIcon(IconUtils.STATUS_VALID, IconUtils.ICON_SIZE_SMALL);
    final Icon invalidIcon = imageManager.getImageIcon(IconUtils.STATUS_ERROR, IconUtils.ICON_SIZE_SMALL);

    final int installedCol = 3;
    final int usedCol = 4;
    int row = 0;/*from w ww.  jav a  2s.  c om*/
    for (final DatabaseDriverDescriptor dd : databaseDrivers) {
        final String driverClassName = dd.getDriverClassName();
        final String displayName = dd.getDisplayName();

        final Icon driverIcon = imageManager.getImageIcon(DatabaseDriverCatalog.getIconImagePath(dd),
                IconUtils.ICON_SIZE_SMALL);

        tableModel.setValueAt(driverIcon, row, 0);
        tableModel.setValueAt(displayName, row, 1);
        tableModel.setValueAt(driverClassName, row, 2);
        tableModel.setValueAt("", row, 3);
        tableModel.setValueAt("", row, 4);

        final DatabaseDriverState state = _databaseDriverCatalog.getState(dd);
        if (state == DatabaseDriverState.INSTALLED_WORKING) {
            tableModel.setValueAt(validIcon, row, installedCol);
        } else if (state == DatabaseDriverState.INSTALLED_NOT_WORKING) {
            tableModel.setValueAt(invalidIcon, row, installedCol);
        } else if (state == DatabaseDriverState.NOT_INSTALLED) {
            final String[] downloadUrls = dd.getDownloadUrls();
            if (downloadUrls != null) {
                final DCPanel buttonPanel = new DCPanel();
                buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 4, 0));

                final JButton downloadButton = WidgetFactory.createSmallButton(IconUtils.ACTION_DOWNLOAD);
                downloadButton.setToolTipText("Download and install the driver for " + dd.getDisplayName());

                downloadButton.addActionListener(createDownloadActionListener(dd));
                buttonPanel.add(downloadButton);

                tableModel.setValueAt(buttonPanel, row, installedCol);
            }
        }

        if (isUsed(driverClassName)) {
            tableModel.setValueAt(validIcon, row, usedCol);
        }

        row++;
    }

    for (UserDatabaseDriver driver : unknownManuallyInstalledDrivers) {
        final String driverClassName = driver.getDriverClassName();
        final Icon driverIcon = imageManager.getImageIcon(IconUtils.GENERIC_DATASTORE_IMAGEPATH,
                IconUtils.ICON_SIZE_SMALL);
        tableModel.setValueAt(driverIcon, row, 0);
        tableModel.setValueAt("", row, 1);
        tableModel.setValueAt(driverClassName, row, 2);
        final DatabaseDriverState state = driver.getState();
        if (state == DatabaseDriverState.INSTALLED_WORKING) {
            tableModel.setValueAt(validIcon, row, installedCol);
        } else if (state == DatabaseDriverState.INSTALLED_NOT_WORKING) {
            tableModel.setValueAt(invalidIcon, row, installedCol);
        } else if (state == DatabaseDriverState.NOT_INSTALLED) {
            final Icon icon = imageManager.getImageIcon(IconUtils.STATUS_WARNING, IconUtils.ICON_SIZE_SMALL);
            tableModel.setValueAt(icon, row, installedCol);

        }
        if (isUsed(driverClassName)) {
            tableModel.setValueAt(validIcon, row, usedCol);
        }
        row++;
    }

    table.setAlignment(installedCol, Alignment.CENTER);
    table.setAlignment(usedCol, Alignment.CENTER);

    table.setRowHeight(IconUtils.ICON_SIZE_SMALL + 4);
    table.getColumn(0).setMaxWidth(IconUtils.ICON_SIZE_SMALL + 4);
    table.getColumn(installedCol).setMaxWidth(84);
    table.getColumn(usedCol).setMaxWidth(70);
    table.setColumnControlVisible(false);
    return table;
}

From source file:org.datacleaner.panels.WelcomePanel.java

private JComponent createContentPanel() {
    JComponent result = null;/*from w ww.j av a 2s.  c  om*/

    final String welcomePanelClassName = SystemProperties.getString(SystemProperties.UI_DESKTOP_WELCOME_PANEL,
            null);
    if (!Strings.isNullOrEmpty(welcomePanelClassName)) {
        final Injector injector = _dcModule.createInjectorBuilder().with(WelcomePanel.class, this)
                .createInjector();
        try {
            @SuppressWarnings("unchecked")
            final Class<? extends JComponent> componentClass = (Class<? extends JComponent>) Class
                    .forName(welcomePanelClassName);

            result = injector.getInstance(componentClass);
        } catch (Exception e) {
            logger.error("Failed to instantiate welcome panel class: {}", welcomePanelClassName, e);
        }
    }

    if (result == null) {
        result = new DCPanel();
        if (Version.isCommunityEdition()) {
            final JXEditorPane editorPane = new JXEditorPane("text/html",
                    "You're now using the <b>Community Edition</b> of DataCleaner.<br/><br/>"
                            + "We hope that you enjoy this free product. We encourage you to also check out the "
                            + "commercial DataCleaner editions which feature added functionality, "
                            + "helpful getting started wizards and commercial support. "
                            + "You can find more information about them online.");
            editorPane.setEditable(false);
            editorPane.setOpaque(false);
            editorPane.setFont(WidgetUtils.FONT_HEADER2);
            editorPane.setPreferredSize(new Dimension(DCSplashPanel.WIDTH_CONTENT, 120));

            final JButton tryProfessionalButton = WidgetFactory.createDefaultButton("Try professional edition",
                    IconUtils.APPLICATION_ICON);
            tryProfessionalButton
                    .addActionListener(new OpenBrowserAction("http://datacleaner.org/get_datacleaner"));

            final JButton readMoreButton = WidgetFactory.createDefaultButton("Compare the editions",
                    IconUtils.WEBSITE);
            readMoreButton.addActionListener(new OpenBrowserAction("http://datacleaner.org/editions"));

            final JButton discussionForumButton = WidgetFactory
                    .createDefaultButton("Visit the discussion forum", "images/menu/forum.png");
            discussionForumButton.setToolTipText(
                    "Visit the online discussion forum for questions and answers in the community");
            final OpenBrowserAction forumActionListener = new OpenBrowserAction("http://datacleaner.org/forum");
            discussionForumButton.addActionListener(forumActionListener);

            final JButton twitterButton = WidgetFactory.createDefaultButton(null, "images/menu/twitter.png");
            twitterButton.setToolTipText("Spread the message about #DataCleaner on Twitter");
            twitterButton.addActionListener(new OpenBrowserAction("https://twitter.com/intent/tweet?text="
                    + UrlEscapers.urlFormParameterEscaper().escape("I'm using @DataCleaner (v. "
                            + Version.getVersion() + ") for some really fancy #dataquality stuff!")));

            final JButton linkedInButton = WidgetFactory.createDefaultButton(null, "images/menu/linkedin.png");
            linkedInButton.setToolTipText("Join our LinkedIn group of users and professionals");
            linkedInButton
                    .addActionListener(new OpenBrowserAction("http://www.linkedin.com/groups?gid=3352784"));

            final JLabel loveFeedbackAnimation = new JLabel(
                    ImageManager.get().getImageIcon("images/window/we_love_community_and_feedback.gif"),
                    JLabel.LEFT);
            loveFeedbackAnimation.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            loveFeedbackAnimation.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    forumActionListener.actionPerformed(null);
                }
            });

            final DCPanel innerPanel = new DCPanel();
            innerPanel.setLayout(new VerticalLayout());
            innerPanel.setBorder(
                    new CompoundBorder(WidgetUtils.BORDER_LIST_ITEM_LEFT_ONLY, new EmptyBorder(0, 20, 0, 0)));
            innerPanel.add(editorPane);
            innerPanel.add(DCPanel.flow(tryProfessionalButton, readMoreButton));
            innerPanel.add(Box.createVerticalStrut(80));
            innerPanel.add(loveFeedbackAnimation);
            innerPanel.add(Box.createVerticalStrut(20));
            innerPanel.add(DCPanel.flow(discussionForumButton, twitterButton, linkedInButton));
            innerPanel.add(Box.createVerticalStrut(5));

            result.setLayout(new VerticalLayout());
            result.add(Box.createVerticalStrut(100));
            result.add(innerPanel);
        }
    }

    return wrapContent(result);
}

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

private JButton getOpenAsTemplateButton() {
    final JButton openAsTemplateButton = new JButton("Open as template");
    openAsTemplateButton.setToolTipText(
            "Allows you to open the job with a different datastore and different source columns.");
    openAsTemplateButton.addActionListener(new ActionListener() {
        @Override/*from  ww  w.  j ava2s .  c o  m*/
        public void actionPerformed(ActionEvent e) {
            OpenAnalysisJobAsTemplateDialog dialog = new OpenAnalysisJobAsTemplateDialog(_windowContext,
                    _configuration, _file, _metadata, _openAnalysisJobActionListenerProvider);
            _fileChooser.cancelSelection();
            dialog.setVisible(true);
        }
    });
    return openAsTemplateButton;
}

From source file:org.datacleaner.widgets.properties.MultipleInputColumnsPropertyWidget.java

@Inject
public MultipleInputColumnsPropertyWidget(ComponentBuilder componentBuilder,
        ConfiguredPropertyDescriptor propertyDescriptor) {
    super(componentBuilder, propertyDescriptor);
    // setBorder(WidgetUtils.BORDER_LIST_ITEM);
    _checkBoxes = new LinkedHashMap<>();
    _checkBoxDecorations = new IdentityHashMap<>();
    _firstUpdate = true;/*from  w  w w .  j a va  2  s.c  om*/
    _dataType = propertyDescriptor.getTypeArgument(0);
    getAnalysisJobBuilder().addSourceColumnChangeListener(this);
    getAnalysisJobBuilder().addTransformerChangeListener(this);

    setLayout(new VerticalLayout(2));

    _searchDatastoreTextField = WidgetFactory.createTextField("Search/filter columns");
    _searchDatastoreTextField.setBorder(
            new CompoundBorder(WidgetUtils.BORDER_CHECKBOX_LIST_INDENTATION, WidgetUtils.BORDER_THIN));
    _searchDatastoreTextField.getDocument().addDocumentListener(new DCDocumentListener() {
        @Override
        protected void onChange(DocumentEvent event) {
            String text = _searchDatastoreTextField.getText();
            if (StringUtils.isNullOrEmpty(text)) {
                // when there is no search query, set all datastores
                // visible
                for (JCheckBox cb : _checkBoxes.values()) {
                    cb.setVisible(true);
                }
            } else {
                // do a case insensitive search
                text = text.trim().toLowerCase();
                for (JCheckBox cb : _checkBoxes.values()) {
                    String name = cb.getText().toLowerCase();
                    cb.setVisible(name.contains(text));
                }
            }
        }
    });

    if (_dataType == null || _dataType == Object.class) {
        _notAvailableCheckBox = new DCCheckBox<>(
                "<html><font color=\"gray\">- no columns available -</font></html>", false);
    } else {
        _notAvailableCheckBox = new DCCheckBox<>("<html><font color=\"gray\">- no <i>"
                + LabelUtils.getDataTypeLabel(_dataType) + "</i> columns available -</font></html>", false);
    }
    _notAvailableCheckBox.setEnabled(false);

    _buttonPanel = new DCPanel();
    _buttonPanel.setLayout(new HorizontalLayout(2));
    _buttonPanel.setBorder(WidgetUtils.BORDER_CHECKBOX_LIST_INDENTATION);

    JButton selectAllButton = WidgetFactory.createDefaultButton("Select all");
    selectAllButton.setFont(WidgetUtils.FONT_SMALL);
    selectAllButton.addActionListener(selectAllActionListener);
    _buttonPanel.add(selectAllButton);

    JButton selectNoneButton = WidgetFactory.createDefaultButton("Select none");
    selectNoneButton.setFont(WidgetUtils.FONT_SMALL);
    selectNoneButton.addActionListener(selectNoneActionListener);
    _buttonPanel.add(selectNoneButton);

    if (propertyDescriptor.isArray()) {
        if (_dataType == String.class || _dataType == Object.class) {
            final JButton expressionColumnButton = WidgetFactory
                    .createSmallButton(IconUtils.MODEL_COLUMN_EXPRESSION);
            expressionColumnButton.setToolTipText("Create expression/value based column");
            expressionColumnButton
                    .addActionListener(AddExpressionBasedColumnActionListener.forMultipleColumns(this));
            _buttonPanel.add(expressionColumnButton);
        }

        final JButton reorderColumnsButton = WidgetFactory.createSmallButton(IconUtils.ACTION_REORDER_COLUMNS);
        reorderColumnsButton.setToolTipText("Reorder columns");
        reorderColumnsButton.addActionListener(new ReorderColumnsActionListener(this));
        _buttonPanel.add(reorderColumnsButton);
    }

    add(_buttonPanel);
    add(_searchDatastoreTextField);
}

From source file:org.datacleaner.windows.AnalysisJobBuilderWindowImpl.java

private JComponent getWindowPanelContent() {
    if (_datastore != null) {
        setDatastore(_datastore);//from w  ww  .ja  va2  s .  c om
    }

    final SaveAnalysisJobActionListener saveAnalysisJobActionListener = _saveAnalysisJobActionListenerProvider
            .get();
    _saveButton.addActionListener(saveAnalysisJobActionListener);
    _saveAsButton.addActionListener(saveAnalysisJobActionListener);
    _saveAsButton.setActionCommand(SaveAnalysisJobActionListener.ACTION_COMMAND_SAVE_AS);

    // Run analysis
    _executeButton.addActionListener(execute(_analysisJobBuilder));

    _executionAlternativesButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            final JMenuItem executeNormallyMenutItem = WidgetFactory.createMenuItem("Run normally",
                    IconUtils.ACTION_EXECUTE);
            executeNormallyMenutItem.addActionListener(execute(_analysisJobBuilder));

            final JMenuItem executePreviewMenuItem = WidgetFactory.createMenuItem("Run first N records",
                    IconUtils.ACTION_PREVIEW);
            executePreviewMenuItem.addActionListener(executePreview());

            final JMenuItem executeSingleThreadedMenuItem = WidgetFactory.createMenuItem("Run single-threaded",
                    IconUtils.MODEL_ROW);
            executeSingleThreadedMenuItem.addActionListener(executeSingleThreaded());

            final JPopupMenu menu = new JPopupMenu();
            menu.add(executeNormallyMenutItem);
            menu.addSeparator();
            menu.add(executePreviewMenuItem);
            menu.add(executeSingleThreadedMenuItem);

            final int horizontalPosition = -1 * menu.getPreferredSize().width
                    + _executionAlternativesButton.getWidth();
            menu.show(_executionAlternativesButton, horizontalPosition,
                    _executionAlternativesButton.getHeight());
        }
    });

    final JButton newJobButton = createToolbarButton("New", IconUtils.MENU_NEW);
    newJobButton.addActionListener(_newAnalysisJobActionListenerProvider.get());

    final JButton openJobButton = createToolbarButton("Open", IconUtils.MENU_OPEN);
    openJobButton.addActionListener(_openAnalysisJobActionListenerProvider.get());

    final JToggleButton moreButton = createMoreMenuButton();

    final JButton logoButton = new JButton(imageManager.getImageIcon("images/menu/dc-logo-30.png"));
    logoButton.setToolTipText("About DataCleaner");
    logoButton.setBorder(new EmptyBorder(0, 4, 0, 10));
    logoButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            new AboutDialog(getWindowContext()).open();
        }
    });

    final JToolBar toolBar = WidgetFactory.createToolBar();
    toolBar.add(logoButton);
    toolBar.add(newJobButton);
    toolBar.add(openJobButton);
    toolBar.add(_saveButton);
    toolBar.add(_saveAsButton);
    toolBar.add(DCLabel.bright(" | "));
    toolBar.add(moreButton);

    toolBar.add(WidgetFactory.createToolBarSeparator());
    toolBar.add(_executeButton);
    toolBar.add(DCLabel.bright("|"));
    toolBar.add(_executionAlternativesButton);

    final JXStatusBar statusBar = WidgetFactory.createStatusBar(_statusLabel);
    statusBar.add(_classicViewButton);
    statusBar.add(_graphViewButton);
    statusBar.add(Box.createHorizontalStrut(10));

    final LicenceAndEditionStatusLabel statusLabel = new LicenceAndEditionStatusLabel(_glassPane);
    statusBar.add(statusLabel);

    final DCPanel toolBarPanel = new DCPanel(WidgetUtils.BG_COLOR_DARK);
    toolBarPanel.setLayout(new BorderLayout());
    toolBarPanel.add(toolBar, BorderLayout.CENTER);

    final DCPanel panel = new DCPersistentSizedPanel(_windowSizePreference);
    panel.setLayout(new BorderLayout());
    panel.add(toolBarPanel, BorderLayout.NORTH);
    panel.add(_leftPanel, BorderLayout.WEST);

    // newPanel.add(_tabbedPane, BorderLayout.NORTH);
    panel.add(_contentContainerPanel, BorderLayout.CENTER);

    panel.add(statusBar, BorderLayout.SOUTH);

    // invoke to trigger enablement/disablement of buttons.
    onSourceColumnsChanged();
    updateStatusLabel();

    WidgetUtils.centerOnScreen(this);
    return panel;
}

From source file:org.eobjects.datacleaner.panels.DatabaseDriversPanel.java

private DCTable getDatabaseDriverTable() {
    final List<DatabaseDriverDescriptor> databaseDrivers = _databaseDriverCatalog.getDatabaseDrivers();
    final TableModel tableModel = new DefaultTableModel(
            new String[] { "", "Database", "Driver class", "Installed?", "Used?" }, databaseDrivers.size());

    final DCTable table = new DCTable(tableModel);

    final Icon validIcon = imageManager.getImageIcon(IconUtils.STATUS_VALID, IconUtils.ICON_SIZE_SMALL);
    final Icon invalidIcon = imageManager.getImageIcon(IconUtils.STATUS_ERROR, IconUtils.ICON_SIZE_SMALL);

    final int installedCol = 3;
    final int usedCol = 4;
    int row = 0;/*from w  ww  .j  a v a 2  s.c  o m*/
    for (final DatabaseDriverDescriptor dd : databaseDrivers) {
        final String driverClassName = dd.getDriverClassName();
        final String displayName = dd.getDisplayName();

        final Icon driverIcon = imageManager.getImageIcon(DatabaseDriverCatalog.getIconImagePath(dd),
                IconUtils.ICON_SIZE_SMALL);

        tableModel.setValueAt(driverIcon, row, 0);
        tableModel.setValueAt(displayName, row, 1);
        tableModel.setValueAt(driverClassName, row, 2);
        tableModel.setValueAt("", row, 3);
        tableModel.setValueAt("", row, 4);

        final DatabaseDriverState state = _databaseDriverCatalog.getState(dd);
        if (state == DatabaseDriverState.INSTALLED_WORKING) {
            tableModel.setValueAt(validIcon, row, installedCol);
        } else if (state == DatabaseDriverState.INSTALLED_NOT_WORKING) {
            tableModel.setValueAt(invalidIcon, row, installedCol);
        } else if (state == DatabaseDriverState.NOT_INSTALLED) {
            final String[] downloadUrls = dd.getDownloadUrls();
            if (downloadUrls != null) {
                final DCPanel buttonPanel = new DCPanel();
                buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 4, 0));

                final JButton downloadButton = WidgetFactory.createSmallButton("images/actions/download.png");
                downloadButton.setToolTipText("Download and install the driver for " + dd.getDisplayName());

                downloadButton.addActionListener(createDownloadActionListener(dd));
                buttonPanel.add(downloadButton);

                tableModel.setValueAt(buttonPanel, row, installedCol);
            }
        }

        if (isUsed(driverClassName)) {
            tableModel.setValueAt(validIcon, row, usedCol);
        }

        row++;
    }

    table.setAlignment(installedCol, Alignment.CENTER);
    table.setAlignment(usedCol, Alignment.CENTER);

    table.setRowHeight(IconUtils.ICON_SIZE_SMALL + 4);
    table.getColumn(0).setMaxWidth(IconUtils.ICON_SIZE_SMALL + 4);
    table.getColumn(installedCol).setMaxWidth(84);
    table.getColumn(usedCol).setMaxWidth(70);
    table.setColumnControlVisible(false);
    return table;
}

From source file:org.eobjects.datacleaner.panels.OpenAnalysisJobPanel.java

public OpenAnalysisJobPanel(final FileObject file, final AnalyzerBeansConfiguration configuration,
        final OpenAnalysisJobActionListener openAnalysisJobActionListener) {
    super(WidgetUtils.BG_COLOR_LESS_BRIGHT, WidgetUtils.BG_COLOR_LESS_BRIGHT);
    _file = file;/* ww w  .  java2 s. c  om*/
    _openAnalysisJobActionListener = openAnalysisJobActionListener;

    setLayout(new BorderLayout());
    setBorder(WidgetUtils.BORDER_LIST_ITEM);

    final AnalysisJobMetadata metadata = getMetadata(configuration);
    final String jobName = metadata.getJobName();
    final String jobDescription = metadata.getJobDescription();
    final String datastoreName = metadata.getDatastoreName();

    final boolean isDemoJob = isDemoJob(metadata);

    final DCPanel labelListPanel = new DCPanel();
    labelListPanel.setLayout(new VerticalLayout(4));
    labelListPanel.setBorder(new EmptyBorder(4, 4, 4, 0));

    final String title;
    final String filename = file.getName().getBaseName();
    if (Strings.isNullOrEmpty(jobName)) {
        final String extension = FileFilters.ANALYSIS_XML.getExtension();
        if (filename.toLowerCase().endsWith(extension)) {
            title = filename.substring(0, filename.length() - extension.length());
        } else {
            title = filename;
        }
    } else {
        title = jobName;
    }

    final JButton titleButton = new JButton(title);
    titleButton.setFont(WidgetUtils.FONT_HEADER1);
    titleButton.setForeground(WidgetUtils.BG_COLOR_BLUE_MEDIUM);
    titleButton.setHorizontalAlignment(SwingConstants.LEFT);
    titleButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, WidgetUtils.BG_COLOR_MEDIUM));
    titleButton.setToolTipText("Open job");
    titleButton.setOpaque(false);
    titleButton.setMargin(new Insets(0, 0, 0, 0));
    titleButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    titleButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (isDemoDatastoreConfigured(datastoreName, configuration)) {
                _openAnalysisJobActionListener.openFile(_file);
            }
        }
    });

    final JButton executeButton = new JButton(executeIcon);
    executeButton.setOpaque(false);
    executeButton.setToolTipText("Execute job directly");
    executeButton.setMargin(new Insets(0, 0, 0, 0));
    executeButton.setBorderPainted(false);
    executeButton.setHorizontalAlignment(SwingConstants.RIGHT);
    executeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (isDemoDatastoreConfigured(datastoreName, configuration)) {
                final ImageIcon executeIconLarge = ImageManager.get().getImageIcon(IconUtils.ACTION_EXECUTE);
                final String question = "Are you sure you want to execute the job\n'" + title + "'?";
                final int choice = JOptionPane.showConfirmDialog(null, question, "Execute job?",
                        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, executeIconLarge);
                if (choice == JOptionPane.YES_OPTION) {
                    final Injector injector = _openAnalysisJobActionListener.openAnalysisJob(_file);
                    if (injector != null) {
                        final ResultWindow resultWindow = injector.getInstance(ResultWindow.class);
                        resultWindow.open();
                        resultWindow.startAnalysis();
                    }
                }
            }
        }
    });

    final DCPanel titlePanel = new DCPanel();
    titlePanel.setLayout(new BorderLayout());
    titlePanel.add(DCPanel.around(titleButton), BorderLayout.CENTER);
    titlePanel.add(executeButton, BorderLayout.EAST);

    labelListPanel.add(titlePanel);

    if (!Strings.isNullOrEmpty(jobDescription)) {
        String desc = StringUtils.replaceWhitespaces(jobDescription, " ");
        desc = StringUtils.replaceAll(desc, "  ", " ");
        final JLabel label = new JLabel(desc);
        label.setFont(WidgetUtils.FONT_SMALL);
        labelListPanel.add(label);
    }

    final Icon icon;
    {
        if (!StringUtils.isNullOrEmpty(datastoreName)) {
            final JLabel label = new JLabel(" " + datastoreName);
            label.setFont(WidgetUtils.FONT_SMALL);
            labelListPanel.add(label);

            final Datastore datastore = configuration.getDatastoreCatalog().getDatastore(datastoreName);
            if (isDemoJob) {
                icon = demoBadgeIcon;
            } else {
                icon = IconUtils.getDatastoreSpecificAnalysisJobIcon(datastore);
            }
        } else {
            icon = ImageManager.get().getImageIcon(IconUtils.MODEL_JOB, IconUtils.ICON_SIZE_LARGE);
        }
    }

    final JLabel iconLabel = new JLabel(icon);
    iconLabel.setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));

    add(iconLabel, BorderLayout.WEST);
    add(labelListPanel, BorderLayout.CENTER);
}

From source file:org.eobjects.datacleaner.widgets.properties.MultipleInputColumnsPropertyWidget.java

@Inject
public MultipleInputColumnsPropertyWidget(AbstractBeanJobBuilder<?, ?, ?> beanJobBuilder,
        ConfiguredPropertyDescriptor propertyDescriptor) {
    super(beanJobBuilder, propertyDescriptor);
    setBorder(new EtchedBorder(EtchedBorder.LOWERED));
    _checkBoxes = new LinkedHashMap<InputColumn<?>, DCCheckBox<InputColumn<?>>>();
    _checkBoxDecorations = new IdentityHashMap<DCCheckBox<InputColumn<?>>, JComponent>();
    _firstUpdate = true;//from  w  w w.ja v  a 2 s.co  m
    _dataType = propertyDescriptor.getTypeArgument(0);
    getAnalysisJobBuilder().getSourceColumnListeners().add(this);
    getAnalysisJobBuilder().getTransformerChangeListeners().add(this);
    setLayout(new VerticalLayout(2));

    _searchDatastoreTextField = WidgetFactory.createTextField("Search/filter columns");
    _searchDatastoreTextField.setBorder(new CompoundBorder(_indentBorder, WidgetUtils.BORDER_THIN));
    _searchDatastoreTextField.getDocument().addDocumentListener(new DCDocumentListener() {
        @Override
        protected void onChange(DocumentEvent event) {
            String text = _searchDatastoreTextField.getText();
            if (StringUtils.isNullOrEmpty(text)) {
                // when there is no search query, set all datastores
                // visible
                for (JCheckBox cb : _checkBoxes.values()) {
                    cb.setVisible(true);
                }
            } else {
                // do a case insensitive search
                text = text.trim().toLowerCase();
                for (JCheckBox cb : _checkBoxes.values()) {
                    String name = cb.getText().toLowerCase();
                    cb.setVisible(name.indexOf(text) != -1);
                }
            }
        }
    });

    _notAvailableCheckBox = new DCCheckBox<InputColumn<?>>("<html><font color=\"gray\">- no <i>"
            + LabelUtils.getDataTypeLabel(_dataType) + "</i> columns available -</font></html>", false);
    _notAvailableCheckBox.setEnabled(false);

    _buttonPanel = new DCPanel();
    _buttonPanel.setLayout(new HorizontalLayout(2));
    _buttonPanel.setBorder(_indentBorder);

    JButton selectAllButton = new JButton("Select all");
    selectAllButton.setFont(WidgetUtils.FONT_SMALL);
    selectAllButton.addActionListener(selectAllActionListener);
    _buttonPanel.add(selectAllButton);

    JButton selectNoneButton = new JButton("Select none");
    selectNoneButton.setFont(WidgetUtils.FONT_SMALL);
    selectNoneButton.addActionListener(selectNoneActionListener);
    _buttonPanel.add(selectNoneButton);

    if (propertyDescriptor.isArray()) {
        if (_dataType == String.class || _dataType == Object.class) {
            final JButton expressionColumnButton = WidgetFactory
                    .createSmallButton(IconUtils.BUTTON_EXPRESSION_COLUMN_IMAGEPATH);
            expressionColumnButton.setToolTipText("Create expression/value based column");
            expressionColumnButton
                    .addActionListener(AddExpressionBasedColumnActionListener.forMultipleColumns(this));
            _buttonPanel.add(expressionColumnButton);
        }

        final JButton reorderColumnsButton = WidgetFactory
                .createSmallButton(IconUtils.BUTTON_REORDER_COLUMN_IMAGEPATH);
        reorderColumnsButton.setToolTipText("Reorder columns");
        reorderColumnsButton.addActionListener(new ReorderColumnsActionListener(this));
        _buttonPanel.add(reorderColumnsButton);
    }

    add(_buttonPanel);
    add(_searchDatastoreTextField);
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.Cockpit.java

/**
 * Initialises the application's GUI elements.
 *///from w  w  w  .j  a  v  a2 s. com
private void initGui() {
    initMenus();

    JPanel appContent = new JPanel(new GridBagLayout());
    this.getContentPane().add(appContent);

    // Buckets panel.
    JPanel bucketsPanel = new JPanel(new GridBagLayout());

    JButton bucketActionButton = new JButton();
    bucketActionButton.setToolTipText("Bucket actions menu");
    guiUtils.applyIcon(bucketActionButton, "/images/nuvola/16x16/actions/misc.png");
    bucketActionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JButton sourceButton = (JButton) e.getSource();
            bucketActionMenu.show(sourceButton, 0, sourceButton.getHeight());
        }
    });
    bucketsPanel.add(new JHtmlLabel("<html><b>Buckets</b></html>", this), new GridBagConstraints(0, 0, 1, 1, 1,
            0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));
    bucketsPanel.add(bucketActionButton, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));

    bucketTableModel = new BucketTableModel(false);
    bucketTableModelSorter = new TableSorter(bucketTableModel);
    bucketsTable = new JTable(bucketTableModelSorter);
    bucketTableModelSorter.setTableHeader(bucketsTable.getTableHeader());
    bucketsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    bucketsTable.getSelectionModel().addListSelectionListener(this);
    bucketsTable.setShowHorizontalLines(true);
    bucketsTable.setShowVerticalLines(false);
    bucketsTable.addMouseListener(new ContextMenuListener());
    bucketsPanel.add(new JScrollPane(bucketsTable), new GridBagConstraints(0, 1, 2, 1, 1, 1,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0));
    bucketsPanel.add(new JLabel(" "), new GridBagConstraints(0, 2, 2, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, insetsDefault, 0, 0));

    // Filter panel.
    filterObjectsPanel = new JPanel(new GridBagLayout());
    filterObjectsPrefix = new JTextField();
    filterObjectsPrefix.setToolTipText("Only show objects with this prefix");
    filterObjectsPrefix.addActionListener(this);
    filterObjectsPrefix.setActionCommand("RefreshObjects");
    filterObjectsDelimiter = new JComboBox(new String[] { "", "/", "?", "\\" });
    filterObjectsDelimiter.setEditable(true);
    filterObjectsDelimiter.setToolTipText("Object name delimiter");
    filterObjectsDelimiter.addActionListener(this);
    filterObjectsDelimiter.setActionCommand("RefreshObjects");
    filterObjectsPanel.add(new JHtmlLabel("Prefix:", this), new GridBagConstraints(0, 0, 1, 1, 0, 0,
            GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0));
    filterObjectsPanel.add(filterObjectsPrefix, new GridBagConstraints(1, 0, 1, 1, 1, 0,
            GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    filterObjectsPanel.add(new JHtmlLabel("Delimiter:", this), new GridBagConstraints(2, 0, 1, 1, 0, 0,
            GridBagConstraints.WEST, GridBagConstraints.NONE, insetsDefault, 0, 0));
    filterObjectsPanel.add(filterObjectsDelimiter, new GridBagConstraints(3, 0, 1, 1, 0, 0,
            GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0));
    filterObjectsPanel.setVisible(false);

    // Objects panel.
    JPanel objectsPanel = new JPanel(new GridBagLayout());
    int row = 0;
    filterObjectsCheckBox = new JCheckBox("Filter objects");
    filterObjectsCheckBox.addActionListener(this);
    filterObjectsCheckBox.setToolTipText("Check this option to filter the objects listed");
    objectsPanel.add(new JHtmlLabel("<html><b>Objects</b></html>", this), new GridBagConstraints(0, row, 1, 1,
            1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));
    objectsPanel.add(filterObjectsCheckBox, new GridBagConstraints(1, row, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));

    JButton objectActionButton = new JButton();
    objectActionButton.setToolTipText("Object actions menu");
    guiUtils.applyIcon(objectActionButton, "/images/nuvola/16x16/actions/misc.png");
    objectActionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JButton sourceButton = (JButton) e.getSource();
            objectActionMenu.show(sourceButton, 0, sourceButton.getHeight());
        }
    });
    objectsPanel.add(objectActionButton, new GridBagConstraints(2, row, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));

    objectsPanel.add(filterObjectsPanel, new GridBagConstraints(0, ++row, 3, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insetsZero, 0, 0));

    objectsTable = new JTable();
    objectTableModel = new ObjectTableModel();
    objectTableModelSorter = new TableSorter(objectTableModel);
    objectTableModelSorter.setTableHeader(objectsTable.getTableHeader());
    objectsTable.setModel(objectTableModelSorter);
    objectsTable.setDefaultRenderer(Long.class, new DefaultTableCellRenderer() {
        private static final long serialVersionUID = 301092191828910402L;

        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            String formattedSize = byteFormatter.formatByteSize(((Long) value).longValue());
            return super.getTableCellRendererComponent(table, formattedSize, isSelected, hasFocus, row, column);
        }
    });
    objectsTable.setDefaultRenderer(Date.class, new DefaultTableCellRenderer() {
        private static final long serialVersionUID = 7285511556343895652L;

        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            Date date = (Date) value;
            return super.getTableCellRendererComponent(table, yearAndTimeSDF.format(date), isSelected, hasFocus,
                    row, column);
        }
    });
    objectsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    objectsTable.getSelectionModel().addListSelectionListener(this);
    objectsTable.setShowHorizontalLines(true);
    objectsTable.setShowVerticalLines(true);
    objectsTable.addMouseListener(new ContextMenuListener());
    objectsTableSP = new JScrollPane(objectsTable);
    objectsPanel.add(objectsTableSP, new GridBagConstraints(0, ++row, 3, 1, 1, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsZero, 0, 0));
    objectsSummaryLabel = new JHtmlLabel("Please select a bucket", this);
    objectsSummaryLabel.setHorizontalAlignment(JLabel.CENTER);
    objectsSummaryLabel.setFocusable(false);
    objectsPanel.add(objectsSummaryLabel, new GridBagConstraints(0, ++row, 3, 1, 1, 0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

    // Combine sections.
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, bucketsPanel, objectsPanel);
    splitPane.setOneTouchExpandable(true);
    splitPane.setContinuousLayout(true);

    appContent.add(splitPane, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsDefault, 0, 0));

    // Set preferred sizes
    int preferredWidth = 800;
    int preferredHeight = 600;
    this.setBounds(new Rectangle(new Dimension(preferredWidth, preferredHeight)));

    splitPane.setResizeWeight(0.30);

    // Initialize drop target.
    initDropTarget(new JComponent[] { objectsTableSP, objectsTable });
    objectsTable.getDropTarget().setActive(false);
    objectsTableSP.getDropTarget().setActive(false);
}