Example usage for java.beans PropertyChangeListener PropertyChangeListener

List of usage examples for java.beans PropertyChangeListener PropertyChangeListener

Introduction

In this page you can find the example usage for java.beans PropertyChangeListener PropertyChangeListener.

Prototype

PropertyChangeListener

Source Link

Usage

From source file:ec.util.chart.swing.JTimeSeriesChart.java

private void enableProperties() {
    addPropertyChangeListener(new PropertyChangeListener() {
        @Override/*from   ww w  .  j  a  v a 2s. c  om*/
        public void propertyChange(PropertyChangeEvent evt) {
            notification.suspend();
            switch (evt.getPropertyName()) {
            case COLOR_SCHEME_SUPPORT_PROPERTY:
                onColorSchemeSupportChange();
                break;
            case LINE_THICKNESS_PROPERTY:
                onLineThicknessChange();
                break;
            case PERIOD_FORMAT_PROPERTY:
                onPeriodFormatChange();
                break;
            case VALUE_FORMAT_PROPERTY:
                onValueFormatChange();
                break;
            case SERIES_RENDERER_PROPERTY:
                onSeriesRendererChange();
                break;
            case SERIES_FORMATTER_PROPERTY:
                onSeriesFormatterChange();
                break;
            case SERIES_COLORIST_PROPERTY:
                onSeriesColoristChange();
                break;
            case OBS_FORMATTER_PROPERTY:
                onObsFormatterChange();
                break;
            case OBS_COLORIST_PROPERTY:
                onObsColoristChange();
                break;
            case DASH_PREDICATE_PROPERTY:
                onDashPredicateChange();
                break;
            case LEGEND_VISIBILITY_PREDICATE_PROPERTY:
                onLegendVisibilityPredicateChange();
                break;
            case PLOT_DISPATCHER_PROPERTY:
                onPlotDispatcherChange();
                break;
            case DATASET_PROPERTY:
                onDatasetChange();
                break;
            case TITLE_PROPERTY:
                onTitleChange();
                break;
            case NO_DATA_MESSAGE_PROPERTY:
                onNoDataMessageChange();
                break;
            case PLOT_WEIGHTS_PROPERTY:
                onPlotWeightsChange();
                break;
            case ELEMENT_VISIBLE_PROPERTY:
                onElementVisibleChange();
                break;
            case CROSSHAIR_ORIENTATION_PROPERTY:
                onCrosshairOrientationChange();
                break;
            case HOVERED_OBS_PROPERTY:
                onHoveredObsChange();
                break;
            case SELECTED_OBS_PROPERTY:
                onSelectedObsChange();
                break;
            case OBS_HIGHLIGHTER_PROPERTY:
                onObsHighlighterChange();
                break;
            case TOOLTIP_TRIGGER_PROPERTY:
                onTooltipTriggerChange();
                break;
            case CROSSHAIR_TRIGGER_PROPERTY:
                onCrosshairTriggerChange();
                break;
            case REVEAL_OBS_PROPERTY:
                onRevealObsChange();
                break;
            case "enabled":
                boolean enabled = isEnabled();
                chartPanel.setDomainZoomable(enabled);
                chartPanel.setRangeZoomable(enabled);
                break;
            case "componentPopupMenu":
                onComponentPopupMenuChange();
                break;
            }
            notification.resume();
        }
    });
}

From source file:org.apache.log4j.chainsaw.LogUI.java

/**
 * Initialises the Help system and the WelcomePanel
 *
 *//*from w w w  . j  a v a  2s  . co m*/
private void setupHelpSystem() {
    welcomePanel = new WelcomePanel();

    JToolBar tb = welcomePanel.getToolbar();

    tb.add(new SmallButton(new AbstractAction("Tutorial", new ImageIcon(ChainsawIcons.HELP)) {
        public void actionPerformed(ActionEvent e) {
            setupTutorial();
        }
    }));
    tb.addSeparator();

    final Action exampleConfigAction = new AbstractAction("View example Receiver configuration") {
        public void actionPerformed(ActionEvent e) {
            HelpManager.getInstance().setHelpURL(ChainsawConstants.EXAMPLE_CONFIG_URL);
        }
    };

    exampleConfigAction.putValue(Action.SHORT_DESCRIPTION,
            "Displays an example Log4j configuration file with several Receivers defined.");

    JButton exampleButton = new SmallButton(exampleConfigAction);
    tb.add(exampleButton);

    tb.add(Box.createHorizontalGlue());

    /**
     * Setup a listener on the HelpURL property and automatically change the WelcomePages URL
     * to it.
     */
    HelpManager.getInstance().addPropertyChangeListener("helpURL", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            URL newURL = (URL) evt.getNewValue();

            if (newURL != null) {
                welcomePanel.setURL(newURL);
                ensureWelcomePanelVisible();
            }
        }
    });
}

From source file:edu.ku.brc.specify.tasks.subpane.images.ImagesPane.java

/**
 * //from  ww  w.  j av a2 s  .co m
 */
private void searchForRecordSetAttachments() {
    final String MEGS = "MEGS";
    final String STATUSBAR_NAME = "ImageSearchStatusBar";

    rowsVector.clear();
    items = recordSet.getOrderedItems();

    final int numItems = items.size();

    SwingWorker<Integer, Integer> backupWorker = new SwingWorker<Integer, Integer>() {
        @Override
        protected Integer doInBackground() throws Exception {
            final DBTableInfo ti = DBTableIdMgr.getInstance().getInfoById(recordSet.getDbTableId());

            boolean isAttachmentTableItself = ti.getTableId() == Attachment.getClassTableId();

            String sql;
            if (!isAttachmentTableItself) {
                sql = "SELECT a.AttachmentID, a.TableID, a.Title, a.AttachmentLocation, a.MimeType FROM attachment a "
                        + "INNER JOIN %sattachment coa ON a.AttachmentID = coa.AttachmentID "
                        + "WHERE coa.%s IN (%s) %s ORDER BY FIELD(%s, %s)";
            } else {
                sql = "SELECT a.AttachmentID, a.TableID, a.Title, a.AttachmentLocation, a.MimeType FROM attachment a "
                        + "WHERE AttachmentID IN (%s) ORDER BY FIELD(a.AttachmentID, %s)";
            }

            int batchSize = 500;
            int attchIndex = 0;
            int batches = (numItems / batchSize) + (numItems % batchSize == 0 ? 0 : 1);
            if (numItems < batchSize) {
                batchSize = numItems;
            }

            Statement stmt = null;
            try {
                stmt = DBConnection.getInstance().getConnection().createStatement();

                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < batches; i++) {
                    firePropertyChange(MEGS, 0, i + 1);
                    sb.setLength(0);
                    for (int j = 0; j < batchSize && attchIndex < numItems; j++) {
                        RecordSetItemIFace rsi = items.get(attchIndex++);
                        if (j > 0)
                            sb.append(',');
                        sb.append(rsi.getRecordId().toString());
                    }

                    String filter = getFilterString();
                    if (StringUtils.isNotEmpty(filter)) {
                        filter = " AND " + filter;
                    }

                    String fullSQL;
                    if (!isAttachmentTableItself) {
                        fullSQL = String.format(sql, ti.getName(), ti.getIdColumnName(), sb.toString(), filter,
                                ti.getIdColumnName(), sb.toString());
                    } else {
                        fullSQL = String.format(sql, sb.toString(), filter, sb.toString());
                    }
                    log.debug(fullSQL);
                    ResultSet rs = stmt.executeQuery(fullSQL);
                    while (rs.next()) {
                        ImageDataItem imgDataItem = new ImageDataItem(rs.getInt(1), rs.getInt(2),
                                rs.getString(3), rs.getString(4), rs.getString(5));
                        rowsVector.add(imgDataItem);
                    }
                    rs.close();
                }

            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                try {
                    if (stmt != null)
                        stmt.close();
                } catch (Exception e) {
                }
            }
            return null;
        }

        @Override
        protected void done() {
            super.done();

            getStatusBar().setProgressDone(STATUSBAR_NAME);
            clearSimpleGlassPaneMsg();

            if (rowsVector != null && rowsVector.size() > 0) {
                gridPanel.setItemList(rowsVector);
                JScrollPane sb = new JScrollPane(gridPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                        JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
                add(sb, BorderLayout.CENTER);

                ((AttachmentsTask) task).attachmentSearchDone(ImagesPane.this);

            } else {
                ((AttachmentsTask) task).attachmentSearchDone(null);
                writeTimedSimpleGlassPaneMsg(getNotFoundMessage());
            }
        }
    };

    final JStatusBar statusBar = getStatusBar();
    statusBar.setIndeterminate(STATUSBAR_NAME, true);

    writeSimpleGlassPaneMsg(getResourceString("ATTCH_SEARCH_IMGS"), 24);

    backupWorker.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent evt) {
            if (MEGS.equals(evt.getPropertyName())) {
                Integer value = (Integer) evt.getNewValue();
                int val = (int) (((double) value / (double) numItems) * 100.0);
                statusBar.setText(Integer.toString(val));//getLocalizedMessage("MySQLBackupService.BACKUP_MEGS", val));
            }
        }
    });
    backupWorker.execute();
}

From source file:de.bfs.radon.omsimulation.gui.OMPanelResults.java

/**
 * Initialises the interface of the results panel.
 *//*from w  w  w. j  a va 2  s .  c  om*/
protected void initialize() {
    setLayout(null);

    lblExportChartTo = new JLabel("Export chart to ...");
    lblExportChartTo.setBounds(436, 479, 144, 14);
    lblExportChartTo.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    lblExportChartTo.setVisible(false);
    add(lblExportChartTo);

    btnMaximize = new JButton("Fullscreen");
    btnMaximize.setBounds(10, 475, 124, 23);
    btnMaximize.setFont(new Font("SansSerif", Font.PLAIN, 11));
    btnMaximize.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (comboBoxSimulations.isEnabled()) {
                if (comboBoxSimulations.getSelectedItem() != null) {
                    JFrame chartFrame = new JFrame();
                    OMSimulation simulation = (OMSimulation) comboBoxSimulations.getSelectedItem();
                    String title = simulation.toString();
                    DescriptiveStatistics statistics = null;
                    OMStatistics statisticsType = (OMStatistics) comboBoxStatistics.getSelectedItem();
                    OMRoomType roomType = null;
                    switch (statisticsType) {
                    case RoomArithmeticMeans:
                        title = "R_AM, " + title;
                        statistics = simulation.getRoomAmDescriptiveStats();
                        roomType = OMRoomType.Room;
                        break;
                    case RoomGeometricMeans:
                        title = "R_GM, " + title;
                        statistics = simulation.getRoomGmDescriptiveStats();
                        roomType = OMRoomType.Room;
                        break;
                    case RoomMedianQ50:
                        title = "R_MED, " + title;
                        statistics = simulation.getRoomMedDescriptiveStats();
                        roomType = OMRoomType.Room;
                        break;
                    case RoomMaxima:
                        title = "R_MAX, " + title;
                        statistics = simulation.getRoomMaxDescriptiveStats();
                        roomType = OMRoomType.Room;
                        break;
                    case CellarArithmeticMeans:
                        title = "C_AM, " + title;
                        statistics = simulation.getCellarAmDescriptiveStats();
                        roomType = OMRoomType.Cellar;
                        break;
                    case CellarGeometricMeans:
                        title = "C_GM, " + title;
                        statistics = simulation.getCellarGmDescriptiveStats();
                        roomType = OMRoomType.Cellar;
                        break;
                    case CellarMedianQ50:
                        title = "C_MED, " + title;
                        statistics = simulation.getCellarMedDescriptiveStats();
                        roomType = OMRoomType.Cellar;
                        break;
                    case CellarMaxima:
                        title = "C_MAX, " + title;
                        statistics = simulation.getCellarMaxDescriptiveStats();
                        roomType = OMRoomType.Cellar;
                        break;
                    default:
                        title = "R_AM, " + title;
                        statistics = simulation.getRoomAmDescriptiveStats();
                        roomType = OMRoomType.Misc;
                        break;
                    }
                    JPanel chartPanel = createDistributionPanel(title, statistics, roomType, false, true, true);
                    chartFrame.getContentPane().add(chartPanel);
                    chartFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
                    chartFrame.setBounds(0, 0, (int) dim.getWidth(), (int) dim.getHeight());
                    chartFrame.setTitle("OM Simulation Tool: " + title);
                    chartFrame.setResizable(true);
                    chartFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
                    chartFrame.setVisible(true);
                }
            }
        }
    });
    add(btnMaximize);

    btnCsv = new JButton("CSV");
    btnCsv.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileDialog = new JFileChooser();
            fileDialog.setFileFilter(new FileNameExtensionFilter("*.csv", "csv"));
            fileDialog.showSaveDialog(getParent());
            final File file = fileDialog.getSelectedFile();
            if (file != null) {
                String csv;
                String[] tmpFileName = file.getAbsolutePath().split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("csv")) {
                    csv = "";
                } else {
                    csv = ".csv";
                }
                String csvPath = file.getAbsolutePath() + csv;
                OMSimulation simulation = (OMSimulation) comboBoxSimulations.getSelectedItem();
                OMCampaign[] campaigns = simulation.getCampaigns();
                File csvFile = new File(csvPath);
                try {
                    FileWriter logWriter = new FileWriter(csvFile);
                    BufferedWriter csvOutput = new BufferedWriter(logWriter);
                    OMStatistics statisticsType = (OMStatistics) comboBoxStatistics.getSelectedItem();
                    String head = "";
                    switch (statisticsType) {
                    case RoomArithmeticMeans:
                        head = "R_AM";
                        break;
                    case RoomGeometricMeans:
                        head = "R_GM";
                        break;
                    case RoomMedianQ50:
                        head = "R_MED";
                        break;
                    case RoomMaxima:
                        head = "R_MAX";
                        break;
                    case CellarArithmeticMeans:
                        head = "C_AM";
                        break;
                    case CellarGeometricMeans:
                        head = "C_GM";
                        break;
                    case CellarMedianQ50:
                        head = "C_MED";
                        break;
                    case CellarMaxima:
                        head = "C_MAX";
                        break;
                    default:
                        head = "R_AM";
                        break;
                    }
                    csvOutput.write("\"ID\";\"CAMPAIGN\";\"START\";\"" + head + "\"");
                    csvOutput.newLine();
                    int value = 0;
                    for (int i = 0; i < campaigns.length; i++) {
                        switch (statisticsType) {
                        case RoomArithmeticMeans:
                            value = (int) campaigns[i].getRoomAverage();
                            break;
                        case RoomGeometricMeans:
                            value = (int) campaigns[i].getRoomLogAverage();
                            break;
                        case RoomMedianQ50:
                            value = (int) campaigns[i].getRoomMedian();
                            break;
                        case RoomMaxima:
                            value = (int) campaigns[i].getRoomMaximum();
                            break;
                        case CellarArithmeticMeans:
                            value = (int) campaigns[i].getCellarAverage();
                            break;
                        case CellarGeometricMeans:
                            value = (int) campaigns[i].getCellarLogAverage();
                            break;
                        case CellarMedianQ50:
                            value = (int) campaigns[i].getCellarMedian();
                            break;
                        case CellarMaxima:
                            value = (int) campaigns[i].getCellarMaximum();
                            break;
                        default:
                            value = (int) campaigns[i].getRoomAverage();
                            break;
                        }
                        csvOutput.write("\"" + i + "\";\"" + campaigns[i].getVariation() + "\";\""
                                + campaigns[i].getStart() + "\";\"" + value + "\"");
                        csvOutput.newLine();
                    }
                    JOptionPane.showMessageDialog(null, "CSV saved successfully!\n" + csvPath, "Success",
                            JOptionPane.INFORMATION_MESSAGE);
                    csvOutput.close();
                } catch (IOException ioe) {
                    JOptionPane.showMessageDialog(null,
                            "Failed to write CSV. Please check permissions!\n" + ioe.getMessage(), "Failed",
                            JOptionPane.ERROR_MESSAGE);
                    ioe.printStackTrace();
                }
            } else {
                JOptionPane.showMessageDialog(null, "Failed to write CSV. Please check the file path!",
                        "Failed", JOptionPane.ERROR_MESSAGE);
            }
        }
    });
    btnCsv.setBounds(590, 475, 70, 23);
    btnCsv.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    btnCsv.setVisible(false);
    add(btnCsv);

    btnPdf = new JButton("PDF");
    btnPdf.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileDialog = new JFileChooser();
            fileDialog.setFileFilter(new FileNameExtensionFilter("*.pdf", "pdf"));
            fileDialog.showSaveDialog(getParent());
            final File file = fileDialog.getSelectedFile();
            if (file != null) {
                String pdf;
                String[] tmpFileName = file.getAbsolutePath().split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("pdf")) {
                    pdf = "";
                } else {
                    pdf = ".pdf";
                }
                String pdfPath = file.getAbsolutePath() + pdf;
                OMSimulation simulation = (OMSimulation) comboBoxSimulations.getSelectedItem();
                String title = simulation.toString();
                DescriptiveStatistics statistics = null;
                OMStatistics statisticsType = (OMStatistics) comboBoxStatistics.getSelectedItem();
                OMRoomType roomType = null;
                switch (statisticsType) {
                case RoomArithmeticMeans:
                    title = "R_AM, " + title;
                    statistics = simulation.getRoomAmDescriptiveStats();
                    roomType = OMRoomType.Room;
                    break;
                case RoomGeometricMeans:
                    title = "R_GM, " + title;
                    statistics = simulation.getRoomGmDescriptiveStats();
                    roomType = OMRoomType.Room;
                    break;
                case RoomMedianQ50:
                    title = "R_MED, " + title;
                    statistics = simulation.getRoomMedDescriptiveStats();
                    roomType = OMRoomType.Room;
                    break;
                case RoomMaxima:
                    title = "R_MAX, " + title;
                    statistics = simulation.getRoomMaxDescriptiveStats();
                    roomType = OMRoomType.Room;
                    break;
                case CellarArithmeticMeans:
                    title = "C_AM, " + title;
                    statistics = simulation.getCellarAmDescriptiveStats();
                    roomType = OMRoomType.Cellar;
                    break;
                case CellarGeometricMeans:
                    title = "C_GM, " + title;
                    statistics = simulation.getCellarGmDescriptiveStats();
                    roomType = OMRoomType.Cellar;
                    break;
                case CellarMedianQ50:
                    title = "C_MED, " + title;
                    statistics = simulation.getCellarMedDescriptiveStats();
                    roomType = OMRoomType.Cellar;
                    break;
                case CellarMaxima:
                    title = "C_MAX, " + title;
                    statistics = simulation.getCellarMaxDescriptiveStats();
                    roomType = OMRoomType.Cellar;
                    break;
                default:
                    title = "R_AM, " + title;
                    statistics = simulation.getRoomAmDescriptiveStats();
                    roomType = OMRoomType.Misc;
                    break;
                }
                JFreeChart chart = OMCharts.createDistributionChart(title, statistics, roomType, false);
                int height = (int) PageSize.A4.getWidth();
                int width = (int) PageSize.A4.getHeight();
                try {
                    OMExports.exportPdf(pdfPath, chart, width, height, new DefaultFontMapper(), title);
                    JOptionPane.showMessageDialog(null, "PDF saved successfully!\n" + pdfPath, "Success",
                            JOptionPane.INFORMATION_MESSAGE);
                } catch (IOException ioe) {
                    JOptionPane.showMessageDialog(null,
                            "Failed to write PDF. Please check permissions!\n" + ioe.getMessage(), "Failed",
                            JOptionPane.ERROR_MESSAGE);
                    ioe.printStackTrace();
                }
            } else {
                JOptionPane.showMessageDialog(null, "Failed to write PDF. Please check the file path!",
                        "Failed", JOptionPane.ERROR_MESSAGE);
            }
        }
    });
    btnPdf.setBounds(670, 475, 70, 23);
    btnPdf.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    btnPdf.setVisible(false);
    add(btnPdf);

    lblSelectSimulation = new JLabel("Select Simulation");
    lblSelectSimulation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    lblSelectSimulation.setBounds(10, 65, 132, 14);
    add(lblSelectSimulation);

    lblSelectStatistics = new JLabel("Select Statistics");
    lblSelectStatistics.setFont(new Font("SansSerif", Font.PLAIN, 11));
    lblSelectStatistics.setBounds(10, 94, 132, 14);
    add(lblSelectStatistics);

    comboBoxSimulations = new JComboBox<OMSimulation>();
    comboBoxSimulations.setFont(new Font("SansSerif", Font.PLAIN, 11));
    comboBoxSimulations.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent arg0) {
            boolean b = false;
            if (comboBoxSimulations.isEnabled()) {
                if (comboBoxSimulations.getSelectedItem() != null) {
                    b = true;
                    comboBoxStatistics.removeAllItems();
                    comboBoxStatistics.setModel(new DefaultComboBoxModel<OMStatistics>(OMStatistics.values()));
                } else {
                    b = false;
                    comboBoxStatistics.removeAllItems();
                }
            } else {
                b = false;
                comboBoxStatistics.removeAllItems();
            }
            progressBar.setEnabled(b);
            btnPdf.setVisible(b);
            btnCsv.setVisible(b);
            btnMaximize.setVisible(b);
            lblExportChartTo.setVisible(b);
            comboBoxStatistics.setEnabled(b);
            lblSelectStatistics.setEnabled(b);
        }
    });
    comboBoxSimulations.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            boolean b = false;
            if (comboBoxSimulations.isEnabled()) {
                if (comboBoxSimulations.getSelectedItem() != null) {
                    b = true;
                    comboBoxStatistics.removeAllItems();
                    comboBoxStatistics.setModel(new DefaultComboBoxModel<OMStatistics>(OMStatistics.values()));
                    comboBoxStatistics.setSelectedIndex(0);
                } else {
                    b = false;
                    comboBoxStatistics.removeAllItems();
                }
            } else {
                b = false;
                comboBoxStatistics.removeAllItems();
            }
            progressBar.setEnabled(b);
            btnPdf.setVisible(b);
            btnCsv.setVisible(b);
            btnMaximize.setVisible(b);
            lblExportChartTo.setVisible(b);
            comboBoxStatistics.setEnabled(b);
            lblSelectStatistics.setEnabled(b);
        }
    });
    comboBoxSimulations.setBounds(152, 61, 454, 22);
    add(comboBoxSimulations);

    btnRefresh = new JButton("Load");
    btnRefresh.setFont(new Font("SansSerif", Font.PLAIN, 11));
    btnRefresh.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (txtOmsFile.getText() != null && !txtOmsFile.getText().equals("")
                    && !txtOmsFile.getText().equals(" ")) {
                txtOmsFile.setBackground(Color.WHITE);
                String omsPath = txtOmsFile.getText();
                String oms;
                String[] tmpFileName = omsPath.split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("oms")) {
                    oms = "";
                } else {
                    oms = ".oms";
                }
                txtOmsFile.setText(omsPath + oms);
                setOmsFile(omsPath + oms);
                File omsFile = new File(omsPath + oms);
                if (omsFile.exists()) {
                    txtOmsFile.setBackground(Color.WHITE);
                    btnRefresh.setEnabled(false);
                    comboBoxSimulations.setEnabled(false);
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    progressBar.setStringPainted(true);
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                    btnPdf.setVisible(false);
                    btnCsv.setVisible(false);
                    btnMaximize.setVisible(false);
                    lblExportChartTo.setVisible(false);
                    refreshSimulationsTask = new RefreshSimulations();
                    refreshSimulationsTask.execute();
                } else {
                    txtOmsFile.setBackground(new Color(255, 222, 222, 128));
                    JOptionPane.showMessageDialog(null, "OMS-file not found, please check the file path!",
                            "Error", JOptionPane.ERROR_MESSAGE);
                }
            } else {
                txtOmsFile.setBackground(new Color(255, 222, 222, 128));
                JOptionPane.showMessageDialog(null, "Please select an OMS-file!", "Warning",
                        JOptionPane.WARNING_MESSAGE);
            }
        }
    });

    comboBoxStatistics = new JComboBox<OMStatistics>();
    comboBoxStatistics.setFont(new Font("SansSerif", Font.PLAIN, 11));
    comboBoxStatistics.setBounds(152, 90, 454, 22);
    comboBoxStatistics.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            updateDistribution();
        }
    });
    add(comboBoxStatistics);

    btnRefresh.setBounds(616, 61, 124, 23);
    add(btnRefresh);

    panelDistribution = new JPanel();
    panelDistribution.setBounds(10, 118, 730, 347);
    add(panelDistribution);

    progressBar = new JProgressBar();
    progressBar.setFont(new Font("SansSerif", Font.PLAIN, 11));
    progressBar.setBounds(10, 475, 730, 23);
    add(progressBar);

    progressBar.setEnabled(false);
    comboBoxStatistics.setEnabled(false);
    lblSelectStatistics.setEnabled(false);
    btnPdf.setVisible(false);
    btnCsv.setVisible(false);
    btnMaximize.setVisible(false);
    lblExportChartTo.setVisible(false);

    lblHelp = new JLabel("Select an OMS-Simulation file to analyse the simulation results and "
            + "display the distribution chart.");
    lblHelp.setForeground(Color.GRAY);
    lblHelp.setFont(new Font("SansSerif", Font.PLAIN, 11));
    lblHelp.setBounds(10, 10, 730, 14);
    add(lblHelp);

    lblSelectOms = new JLabel("Open OMS-File");
    lblSelectOms.setFont(new Font("SansSerif", Font.PLAIN, 11));
    lblSelectOms.setBounds(10, 36, 132, 14);
    add(lblSelectOms);

    txtOmsFile = new JTextField();
    txtOmsFile.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            setOmsFile(txtOmsFile.getText());
        }
    });
    txtOmsFile.setFont(new Font("SansSerif", Font.PLAIN, 11));
    txtOmsFile.setColumns(10);
    txtOmsFile.setBounds(152, 33, 454, 20);
    add(txtOmsFile);

    buttonBrowse = new JButton("Browse");
    buttonBrowse.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            JFileChooser fileDialog = new JFileChooser();
            fileDialog.setFileFilter(new FileNameExtensionFilter("*.oms", "oms"));
            fileDialog.showOpenDialog(getParent());
            final File file = fileDialog.getSelectedFile();
            if (file != null) {
                String oms;
                String[] tmpFileName = file.getAbsolutePath().split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("oms")) {
                    oms = "";
                } else {
                    oms = ".oms";
                }
                txtOmsFile.setText(file.getAbsolutePath() + oms);
                setOmsFile(file.getAbsolutePath() + oms);
            }
        }
    });
    buttonBrowse.setFont(new Font("SansSerif", Font.PLAIN, 11));
    buttonBrowse.setBounds(616, 32, 124, 23);
    add(buttonBrowse);
    progressBar.setVisible(false);
}

From source file:com.diversityarrays.kdxplore.trials.TrialViewPanel.java

public TrialViewPanel(WindowOpener<JFrame> windowOpener, OfflineData od,
        Transformer<Trial, Boolean> checkIfEditorActive, Consumer<Trial> onTraitInstancesRemoved,
        MessagePrinter mp) {//w  w w.j a v  a  2s  .  co  m
    super(new BorderLayout());

    this.windowOpener = windowOpener;
    this.checkIfEditorActive = checkIfEditorActive;
    this.onTraitInstancesRemoved = onTraitInstancesRemoved;
    this.messagePrinter = mp;

    this.offlineData = od;
    this.offlineData.addOfflineDataChangeListener(offlineDataChangeListener);
    KdxploreDatabase db = offlineData.getKdxploreDatabase();
    if (db != null) {
        db.addEntityChangeListener(trialChangeListener);
    }

    trialDataTable.setTransferHandler(TableTransferHandler.initialiseForCopySelectAll(trialDataTable, true));
    trialPropertiesTable
            .setTransferHandler(TableTransferHandler.initialiseForCopySelectAll(trialPropertiesTable, true));

    // Note: Can't use renderers because the TM always returns String.class
    // for getColumnClass()
    // trialPropertiesTable.setDefaultRenderer(TrialLayout.class, new
    // TrialLayoutRenderer(trialPropertiesTableModel));
    // trialPropertiesTable.setDefaultRenderer(PlotIdentOption.class, new
    // PlotIdentOptionRenderer(trialPropertiesTableModel));

    trialPropertiesTableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            if (trialPropertiesTableModel.getRowCount() > 0) {
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        GuiUtil.initialiseTableColumnWidths(trialPropertiesTable);
                    }
                });
                trialPropertiesTableModel.removeTableModelListener(this);
            }
        }
    });

    //      int tnsColumnIndex = -1;
    //      for (int col = trialPropertiesTableModel.getColumnCount(); --col >= 0; ) {
    //         if (TraitNameStyle.class == trialPropertiesTableModel.getColumnClass(col)) {
    //            tnsColumnIndex = col;
    //            break;
    //         }
    //      }

    editAction.setEnabled(false);
    trialPropertiesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                int vrow = trialPropertiesTable.getSelectedRow();
                editAction.setEnabled(vrow >= 0 && trialPropertiesTableModel.isCellEditable(vrow, 1));
            }
        }
    });

    errorMessage.setForeground(Color.RED);
    Box top = Box.createHorizontalBox();
    top.add(errorMessage);
    top.add(Box.createHorizontalGlue());
    top.add(new JButton(editAction));

    JPanel main = new JPanel(new BorderLayout());
    main.add(new JScrollPane(trialPropertiesTable), BorderLayout.CENTER);
    main.add(legendPanel, BorderLayout.SOUTH);

    JScrollPane trialDataTableScrollPane = new JScrollPane(trialDataTable);

    // The preferred height of the viewport is determined
    // by whether or not we need to use hh:mm:ss in the name of any of
    // the scoring data sets.
    JViewport viewPort = new JViewport() {
        @Override
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            d.height = 32;
            TableModel model = trialDataTable.getModel();
            if (model instanceof TrialData) {
                if (((TrialData) model).isUsingHMSformat()) {
                    d.height = 48;
                }
            }
            return d;
        }
    };
    trialDataTableScrollPane.setColumnHeader(viewPort);

    JTableHeader th = trialDataTable.getTableHeader();
    th.setDefaultRenderer(trialDataTableHeaderRenderer);
    th.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            int column = th.columnAtPoint(e.getPoint());
            trialDataTableHeaderRenderer.columnSelected = column;
            boolean shifted = 0 != (MouseEvent.SHIFT_MASK & e.getModifiers());
            boolean right = SwingUtilities.isRightMouseButton(e);
            updateDeleteSamplesAction(shifted, right);
            e.consume();
        }
    });

    trialDataTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                removeTraitInstancesAction.setEnabled(trialDataTable.getSelectedRowCount() > 0);
            }
        }
    });
    removeTraitInstancesAction.setEnabled(false);

    KDClientUtils.initAction(ImageId.PLUS_BLUE_24, addSampleGroupAction, Msg.TOOLTIP_ADD_SAMPLES_FOR_SCORING());
    KDClientUtils.initAction(ImageId.TRASH_24, deleteSamplesAction, Msg.TOOLTIP_DELETE_COLLECTED_SAMPLES());
    KDClientUtils.initAction(ImageId.EXPORT_24, exportSamplesAction, Msg.TOOLTIP_EXPORT_SAMPLES_OR_TRAITS());
    KDClientUtils.initAction(ImageId.MINUS_GOLD_24, removeTraitInstancesAction,
            Msg.TOOLTIP_REMOVE_TRAIT_INSTANCES_WITH_NO_DATA());

    JPanel trialDataPanel = new JPanel(new BorderLayout());
    Box buttons = Box.createHorizontalBox();

    buttons.add(new JButton(removeTraitInstancesAction));
    buttons.add(Box.createHorizontalGlue());
    buttons.add(new JButton(exportSamplesAction));
    buttons.add(Box.createHorizontalGlue());
    buttons.add(new JButton(addSampleGroupAction));
    buttons.add(Box.createHorizontalStrut(8));
    buttons.add(new JButton(deleteSamplesAction));
    trialDataPanel.add(GuiUtil.createLabelSeparator("Measurements by Source", buttons), BorderLayout.NORTH);
    trialDataPanel.add(trialDataTableScrollPane, BorderLayout.CENTER);

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, main, trialDataPanel);
    splitPane.setResizeWeight(0.5);

    add(top, BorderLayout.NORTH);
    add(splitPane, BorderLayout.CENTER);

    trialDataTable.setDefaultRenderer(Object.class, new TrialDataCellRenderer());

    trialDataTable.addPropertyChangeListener("model", new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            trialDataTableHeaderRenderer.columnSelected = -1;
            updateDeleteSamplesAction(false, false);
        }
    });
}

From source file:com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI.java

@Override
public PropertyChangeListener createPropertyChangeListener(VFSJFileChooser fc) {
    return new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            String s = e.getPropertyName();

            if (s.equals(VFSJFileChooserConstants.SELECTED_FILE_CHANGED_PROPERTY)) {
                doSelectedFileChanged(e);
            } else if (s.equals(VFSJFileChooserConstants.SELECTED_FILES_CHANGED_PROPERTY)) {
                doSelectedFilesChanged(e);
            } else if (s.equals(VFSJFileChooserConstants.DIRECTORY_CHANGED_PROPERTY)) {
                doDirectoryChanged(e);//from   w ww.  j  a v a  2s  .  c  o m
            } else if (s.equals(VFSJFileChooserConstants.FILE_FILTER_CHANGED_PROPERTY)) {
                doFilterChanged(e);
            } else if (s.equals(VFSJFileChooserConstants.FILE_SELECTION_MODE_CHANGED_PROPERTY)) {
                doFileSelectionModeChanged(e);
            } else if (s.equals(VFSJFileChooserConstants.ACCESSORY_CHANGED_PROPERTY)) {
                doAccessoryChanged(e);
            } else if (s.equals(VFSJFileChooserConstants.APPROVE_BUTTON_TEXT_CHANGED_PROPERTY)
                    || s.equals(VFSJFileChooserConstants.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY)) {
                doApproveButtonTextChanged(e);
            } else if (s.equals(VFSJFileChooserConstants.DIALOG_TYPE_CHANGED_PROPERTY)) {
                doDialogTypeChanged(e);
            } else if (s.equals(VFSJFileChooserConstants.APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY)) {
                doApproveButtonMnemonicChanged(e);
            } else if (s.equals(VFSJFileChooserConstants.CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY)) {
                doControlButtonsChanged(e);
            } else if (s.equals("componentOrientation")) {
                ComponentOrientation o = (ComponentOrientation) e.getNewValue();
                VFSJFileChooser cc = (VFSJFileChooser) e.getSource();

                if (o != (ComponentOrientation) e.getOldValue()) {
                    cc.applyComponentOrientation(o);
                }
            } else if (s.equals("FileChooser.useShellFolder")) {
                updateUseShellFolder();
                doDirectoryChanged(e);
            } else if (s.equals("ancestor")) {
                if ((e.getOldValue() == null) && (e.getNewValue() != null)) {
                    // Ancestor was added, set initial focus
                    fileNameTextField.selectAll();
                    fileNameTextField.requestFocus();
                }
            }
        }
    };
}

From source file:ome.formats.importer.gui.GuiImporter.java

public void update(IObservable importLibrary, ImportEvent event) {

    // Keep alive has failed, call logout
    if (event instanceof ImportEvent.LOGGED_OUT) {
        logout();/*from  w  w  w . j  a v  a  2s . com*/
        showLogoutMessage();
    }

    if (event instanceof ImportEvent.LOADING_IMAGE) {
        ImportEvent.LOADING_IMAGE ev = (ImportEvent.LOADING_IMAGE) event;

        getStatusBar().setProgress(true, -1, "Loading file " + ev.numDone + " of " + ev.total);
        appendToOutput("> [" + ev.index + "] Loading image \"" + ev.shortName + "\"...\n");
        getStatusBar().setStatusIcon("gfx/import_icon_16.png", "Prepping file \"" + ev.shortName);
    }

    else if (event instanceof ImportEvent.LOADED_IMAGE) {
        ImportEvent.LOADED_IMAGE ev = (ImportEvent.LOADED_IMAGE) event;

        getStatusBar().setProgress(true, -1, "Analyzing file " + ev.numDone + " of " + ev.total);
        appendToOutput(" Succesfully loaded.\n");
        appendToOutput("> [" + ev.index + "] Importing metadata for " + "image \"" + ev.shortName + "\"... ");
        getStatusBar().setStatusIcon("gfx/import_icon_16.png",
                "Analyzing the metadata for file \"" + ev.shortName);
    }

    else if (event instanceof ImportEvent.BEGIN_SAVE_TO_DB) {
        ImportEvent.BEGIN_SAVE_TO_DB ev = (ImportEvent.BEGIN_SAVE_TO_DB) event;
        appendToOutput("> [" + ev.index + "] Saving metadata for " + "image \"" + ev.filename + "\"... ");
        getStatusBar().setStatusIcon("gfx/import_icon_16.png", "Saving metadata for file \"" + ev.filename);
    }

    else if (event instanceof ImportEvent.DATASET_STORED) {
        ImportEvent.DATASET_STORED ev = (ImportEvent.DATASET_STORED) event;

        int num = ev.numDone;
        int tot = ev.total;
        int pro = num - 1;
        appendToOutputLn("Successfully stored to " + ev.target.getClass().getSimpleName() + " \"" + ev.filename
                + "\" with id \"" + ev.target.getId().getValue() + "\".");
        appendToOutputLn(
                "> [" + ev.series + "] Importing pixel data for " + "image \"" + ev.filename + "\"... ");
        getStatusBar().setProgress(true, 0, "Importing file " + num + " of " + tot);
        getStatusBar().setProgressValue(pro);
        getStatusBar().setStatusIcon("gfx/import_icon_16.png",
                "Importing the pixel data for file \"" + ev.filename);
        appendToOutput("> Importing plane: ");
    }

    else if (event instanceof ImportEvent.DATA_STORED) {
        ImportEvent.DATA_STORED ev = (ImportEvent.DATA_STORED) event;

        appendToOutputLn("> Successfully stored with pixels id \"" + ev.pixId + "\".");
        appendToOutputLn("> [" + ev.filename + "] Image imported successfully!");
    }

    else if (event instanceof FILE_EXCEPTION) {
        FILE_EXCEPTION ev = (FILE_EXCEPTION) event;
        if (IOException.class.isAssignableFrom(ev.exception.getClass())) {

            final JOptionPane optionPane = new JOptionPane(
                    "The importer cannot retrieve one of your images in a timely manner.\n"
                            + "The file in question is:\n'" + ev.filename + "'\n\n"
                            + "There are a number of reasons you may see this error:\n"
                            + " - The file has been deleted.\n"
                            + " - There was a networking error retrieving a remotely saved file.\n"
                            + " - An archived file has not been fully retrieved from backup.\n\n"
                            + "The importer should now continue with the remainer of your imports.\n",
                    JOptionPane.ERROR_MESSAGE);

            final JDialog dialog = new JDialog(this, "IO Error");
            dialog.setAlwaysOnTop(true);
            dialog.setContentPane(optionPane);
            dialog.pack();
            dialog.setVisible(true);
            optionPane.addPropertyChangeListener(new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent e) {
                    String prop = e.getPropertyName();

                    if (dialog.isVisible() && (e.getSource() == optionPane)
                            && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
                        dialog.dispose();
                    }
                }
            });
        }
    }

    else if (event instanceof EXCEPTION_EVENT) {
        EXCEPTION_EVENT ev = (EXCEPTION_EVENT) event;
        log.error("EXCEPTION_EVENT", ev.exception);
    }

    else if (event instanceof INTERNAL_EXCEPTION) {
        INTERNAL_EXCEPTION e = (INTERNAL_EXCEPTION) event;
        log.error("INTERNAL_EXCEPTION", e.exception);

        // What else should we do here? Why are EXCEPTION_EVENTs being
        // handled here?
    }

    else if (event instanceof ImportEvent.ERRORS_PENDING) {
        tPane.setIconAt(4, GuiCommonElements.getImageIcon(ERROR_ICON_ANIM));
        errors_pending = true;
        error_notification = true;
    }

    else if (event instanceof ImportEvent.ERRORS_COMPLETE) {
        tPane.setIconAt(4, GuiCommonElements.getImageIcon(ERROR_ICON));
        error_notification = false;
    }

    else if (event instanceof ImportEvent.ERRORS_COMPLETE) {
        tPane.setIconAt(4, GuiCommonElements.getImageIcon(ERROR_ICON));
        error_notification = false;
    }

    else if (event instanceof ImportEvent.ERRORS_FAILED) {
        sendingErrorsFailed(this);
    }

    else if (event instanceof ImportEvent.IMPORT_QUEUE_DONE && errors_pending == true) {
        errors_pending = false;
        importErrorsCollected(this);
    }

}

From source file:ca.phon.ipamap.IpaMap.java

private IpaMapSearchField createSearchField() {
    final IpaMapSearchField searchField = new IpaMapSearchField();
    searchField.setPrompt("Search Glyphs");
    searchField.setFont(getFont().deriveFont(12.0f));
    searchField.getDocument().addDocumentListener(new DocumentListener() {

        @Override/*from   www  .  j a v a 2  s.co m*/
        public void removeUpdate(DocumentEvent arg0) {
            if (searchField.getState() == FieldState.INPUT)
                updateSearchPanel(searchField.getSearchType(), searchField.getText());
            else
                updateSearchPanel(searchField.getSearchType(), "");
        }

        @Override
        public void insertUpdate(DocumentEvent arg0) {
            if (searchField.getState() == FieldState.INPUT)
                updateSearchPanel(searchField.getSearchType(), searchField.getText());
            else
                updateSearchPanel(searchField.getSearchType(), "");
        }

        @Override
        public void changedUpdate(DocumentEvent arg0) {

        }
    });

    searchField.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent arg0) {
            if (arg0.getPropertyName().equals(IpaMapSearchField.SEARCH_TYPE_PROP)) {
                if (searchField.getText().length() > 0) {
                    updateSearchPanel(searchField.getSearchType(), searchField.getText());
                }
            }
        }
    });
    return searchField;
}

From source file:org.isatools.isacreator.spreadsheet.Spreadsheet.java

/**
 * Create the FlatButton panel - a panel which contains graphical representations of the options available
 * to the user when interacting with the software.
 *//*from w ww  .  j  a v  a  2 s  . co m*/
private void createButtonPanel() {

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

    addRow = new JLabel(addRowButton);
    addRow.setToolTipText("<html><b>add row</b>" + "<p>add a new row to the table</p></html>");
    addRow.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent mouseEvent) {
            addRow.setIcon(addRowButton);
            showMultipleRowsGUI();
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            addRow.setIcon(addRowButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            addRow.setIcon(addRowButton);
        }
    });

    deleteRow = new JLabel(deleteRowButton);
    deleteRow.setToolTipText("<html><b>remove row</b>" + "<p>remove selected row from table</p></html>");
    deleteRow.setEnabled(false);
    deleteRow.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent mouseEvent) {
            deleteRow.setIcon(deleteRowButton);
            if (table.getSelectedRow() != -1) {
                if (!(table.getSelectedRowCount() > 1)) {
                    spreadsheetFunctions.deleteRow(table.getSelectedRow());
                } else {
                    spreadsheetFunctions.deleteRow(table.getSelectedRows());
                }

            }
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            deleteRow.setIcon(deleteRowButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            deleteRow.setIcon(deleteRowButton);
        }
    });

    deleteColumn = new JLabel(deleteColumnButton);
    deleteColumn
            .setToolTipText("<html><b>remove column</b>" + "<p>remove selected column from table</p></html>");
    deleteColumn.setEnabled(false);
    deleteColumn.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent mouseEvent) {
            deleteColumn.setIcon(deleteColumnButton);
            if (!(table.getSelectedColumns().length > 1)) {
                spreadsheetFunctions.deleteColumn(table.getSelectedColumn());
            } else {
                showColumnErrorMessage();
            }
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            deleteColumn.setIcon(deleteColumnButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            deleteColumn.setIcon(deleteColumnButton);
        }
    });

    multipleSort = new JLabel(multipleSortButton);
    multipleSort.setToolTipText(
            "<html><b>multiple sort</b>" + "<p>perform a multiple sort on the table</p></html>");
    multipleSort.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent mouseEvent) {
            multipleSort.setIcon(multipleSortButton);
            showMultipleColumnSortGUI();
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            multipleSort.setIcon(multipleSortButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            multipleSort.setIcon(multipleSortButton);
        }
    });

    copyColDown = new JLabel(copyColDownButton);
    copyColDown.setToolTipText("<html><b>copy column downwards</b>"
            + "<p>duplicate selected column and copy it from the current</p>"
            + "<p>position down to the final row in the table</p></html>");
    copyColDown.setEnabled(false);
    copyColDown.addMouseListener(new MouseAdapter() {

        public void mouseExited(MouseEvent mouseEvent) {
            copyColDown.setIcon(copyColDownButton);
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            copyColDown.setIcon(copyColDownButtonOver);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            copyColDown.setIcon(copyColDownButton);

            final int row = table.getSelectedRow();
            final int col = table.getSelectedColumn();

            if (row != -1 && col != -1) {
                JOptionPane copyColDownConfirmationPane = new JOptionPane(
                        "<html><b>Confirm Copy of Column...</b><p>Are you sure you wish to copy "
                                + "this column downwards?</p><p>This Action can not be undone!</p></html>",
                        JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);

                copyColDownConfirmationPane.setIcon(copyColumnDownWarningIcon);
                UIHelper.applyOptionPaneBackground(copyColDownConfirmationPane, UIHelper.BG_COLOR);

                copyColDownConfirmationPane.addPropertyChangeListener(new PropertyChangeListener() {
                    public void propertyChange(PropertyChangeEvent event) {
                        if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) {
                            int lastOptionAnswer = Integer.valueOf(event.getNewValue().toString());
                            parentFrame.hideSheet();
                            if (lastOptionAnswer == JOptionPane.YES_OPTION) {
                                spreadsheetFunctions.copyColumnDownwards(row, col);
                            }
                        }
                    }
                });
                parentFrame.showJDialogAsSheet(
                        copyColDownConfirmationPane.createDialog(Spreadsheet.this, "Copy Column?"));
            }
        }
    });

    copyRowDown = new JLabel(copyRowDownButton);
    copyRowDown.setToolTipText(
            "<html><b>copy row downwards</b>" + "<p>duplicate selected row and copy it from the current</p>"
                    + "<p>position down to the final row</p></html>");
    copyRowDown.setEnabled(false);
    copyRowDown.addMouseListener(new MouseAdapter() {

        public void mouseExited(MouseEvent mouseEvent) {
            copyRowDown.setIcon(copyRowDownButton);
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            copyRowDown.setIcon(copyRowDownButtonOver);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            copyRowDown.setIcon(copyRowDownButton);

            final int row = table.getSelectedRow();

            JOptionPane copyRowDownConfirmationPane = new JOptionPane(
                    "<html><b>Confirm Copy of Row...</b><p>Are you sure you wish to copy "
                            + "this row downwards?</p><p>This Action can not be undone!</p>",
                    JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);

            copyRowDownConfirmationPane.setIcon(copyRowDownWarningIcon);

            UIHelper.applyOptionPaneBackground(copyRowDownConfirmationPane, UIHelper.BG_COLOR);

            copyRowDownConfirmationPane.addPropertyChangeListener(new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent event) {
                    if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) {
                        int lastOptionAnswer = Integer.valueOf(event.getNewValue().toString());
                        parentFrame.hideSheet();
                        if (lastOptionAnswer == JOptionPane.YES_OPTION) {
                            spreadsheetFunctions.copyRowDownwards(row);
                        }
                    }
                }
            });
            parentFrame.showJDialogAsSheet(
                    copyRowDownConfirmationPane.createDialog(Spreadsheet.this, "Copy Row Down?"));
        }
    });

    addProtocol = new JLabel(addProtocolButton);
    addProtocol.setToolTipText(
            "<html><b>add a protocol column</b>" + "<p>Add a protocol column to the table</p></html>");
    addProtocol.addMouseListener(new MouseAdapter() {

        public void mouseEntered(MouseEvent mouseEvent) {
            addProtocol.setIcon(addProtocolButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            addProtocol.setIcon(addProtocolButton);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            addProtocol.setIcon(addProtocolButton);
            if (addProtocol.isEnabled()) {
                FieldObject fo = new FieldObject(table.getColumnCount(), "Protocol REF",
                        "Protocol used for experiment", DataTypes.LIST, "", false, false, false);

                fo.setFieldList(studyDataEntryEnvironment.getProtocolNames());

                spreadsheetFunctions.addFieldToReferenceObject(fo);

                spreadsheetFunctions.addColumnAfterPosition("Protocol REF", null, fo.isRequired(), -1);
            }
        }
    });

    addFactor = new JLabel(addFactorButton);
    addFactor.setToolTipText(
            "<html><b>add a factor column</b>" + "<p>Add a factor column to the table</p></html>");
    addFactor.addMouseListener(new MouseAdapter() {
        public void mouseEntered(MouseEvent mouseEvent) {
            addFactor.setIcon(addFactorButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            addFactor.setIcon(addFactorButton);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            addFactor.setIcon(addFactorButton);
            if (addFactor.isEnabled()) {
                showAddColumnsGUI(AddColumnGUI.ADD_FACTOR_COLUMN);
            }
        }
    });

    addCharacteristic = new JLabel(addCharacteristicButton);
    addCharacteristic.setToolTipText("<html><b>add a characteristic column</b>"
            + "<p>Add a characteristic column to the table</p></html>");
    addCharacteristic.addMouseListener(new MouseAdapter() {
        public void mouseEntered(MouseEvent mouseEvent) {
            addCharacteristic.setIcon(addCharacteristicButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            addCharacteristic.setIcon(addCharacteristicButton);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            addCharacteristic.setIcon(addCharacteristicButton);
            if (addCharacteristic.isEnabled()) {
                showAddColumnsGUI(AddColumnGUI.ADD_CHARACTERISTIC_COLUMN);
            }
        }
    });

    addParameter = new JLabel(addParameterButton);
    addParameter.setToolTipText(
            "<html><b>add a parameter column</b>" + "<p>Add a parameter column to the table</p></html>");
    addParameter.addMouseListener(new MouseAdapter() {
        public void mouseEntered(MouseEvent mouseEvent) {
            addParameter.setIcon(addParameterButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            addParameter.setIcon(addParameterButton);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            addParameter.setIcon(addParameterButton);
            if (addParameter.isEnabled()) {
                showAddColumnsGUI(AddColumnGUI.ADD_PARAMETER_COLUMN);
            }
        }
    });

    undo = new JLabel(undoButton);
    undo.setToolTipText("<html><b>undo previous action<b></html>");
    undo.setEnabled(undoManager.canUndo());
    undo.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent mouseEvent) {
            undo.setIcon(undoButton);
            undoManager.undo();

            if (highlightActive) {
                setRowsToDefaultColor();
            }
            table.addNotify();
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            undo.setIcon(undoButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            undo.setIcon(undoButton);
        }
    });

    redo = new JLabel(redoButton);
    redo.setToolTipText("<html><b>redo action<b></html>");
    redo.setEnabled(undoManager.canRedo());
    redo.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent mouseEvent) {
            redo.setIcon(redoButton);
            undoManager.redo();

            if (highlightActive) {
                setRowsToDefaultColor();
            }
            table.addNotify();

        }

        public void mouseEntered(MouseEvent mouseEvent) {
            redo.setIcon(redoButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            redo.setIcon(redoButton);
        }
    });

    transpose = new JLabel(transposeIcon);
    transpose.setToolTipText("<html>View a transposed version of this spreadsheet</html>");
    transpose.addMouseListener(new MouseAdapter() {

        public void mouseExited(MouseEvent mouseEvent) {
            transpose.setIcon(transposeIcon);
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            transpose.setIcon(transposeIconOver);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            showTransposeSpreadsheetGUI();
        }
    });

    addButtons();

    if (studyDataEntryEnvironment != null) {
        JPanel labelContainer = new JPanel(new GridLayout(1, 1));
        labelContainer.setBackground(UIHelper.BG_COLOR);

        JLabel lab = UIHelper.createLabel(spreadsheetTitle, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR,
                JLabel.RIGHT);
        lab.setBackground(UIHelper.BG_COLOR);
        lab.setVerticalAlignment(JLabel.CENTER);
        lab.setPreferredSize(new Dimension(200, 30));

        labelContainer.add(lab);

        spreadsheetFunctionPanel.add(labelContainer);
        spreadsheetFunctionPanel.add(Box.createHorizontalStrut(10));
    }

    add(spreadsheetFunctionPanel, BorderLayout.NORTH);
}

From source file:org.talend.designer.runprocess.ui.ProcessComposite.java

/**
 * DOC amaumont Comment method "initGraphicComponents".
 * //from  w w  w.j  a  va  2 s. c om
 * @param parent
 */
private void initGraphicComponents(Composite parent) {
    setExpandHorizontal(true);
    setExpandVertical(true);
    this.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));

    FormData layouData = new FormData();
    layouData.left = new FormAttachment(0, 0);
    layouData.right = new FormAttachment(100, 0);
    layouData.top = new FormAttachment(0, 0);
    layouData.bottom = new FormAttachment(100, 0);
    setLayoutData(layouData);

    this.setLayout(new FormLayout());
    final Composite panel = new Composite(this, SWT.NONE);
    setContent(panel);
    // panel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_RED));

    FormLayout layout2 = new FormLayout();
    layout2.marginWidth = 5 + 2;
    layout2.marginHeight = 4;
    layout2.spacing = 6 + 1;
    panel.setLayout(layout2);

    GridData data;
    GridLayout layout = new GridLayout();
    // panel.setLayout(layout);

    // Splitter
    // sash = new SashForm(this, SWT.HORIZONTAL | SWT.SMOOTH);
    // sash.setLayoutData(new GridData(GridData.FILL_BOTH));
    //
    // layout = new GridLayout();
    // sash.setLayout(layout);
    //
    // // group Button
    // // qli,see the feature 6366.
    //
    // Composite buttonComposite = new Composite(sash, SWT.ERROR);
    // buttonComposite.setLayout(new GridLayout());
    //
    // moveButton = new Button(buttonComposite, SWT.PUSH);
    //        moveButton.setText("<<"); //$NON-NLS-1$
    //        moveButton.setToolTipText(Messages.getString("ProcessComposite.hideContext")); //$NON-NLS-1$
    //
    // final GridData layoutData = new GridData();
    // layoutData.verticalAlignment = GridData.CENTER;
    // layoutData.horizontalAlignment = GridData.CENTER;
    // layoutData.grabExcessHorizontalSpace = true;
    // layoutData.grabExcessVerticalSpace = true;
    // moveButton.setLayoutData(layoutData);

    // Group execution
    Group execGroup = new Group(panel, SWT.NONE);
    execGroup.setText(Messages.getString("ProcessComposite.execGroup")); //$NON-NLS-1$
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    execGroup.setLayout(layout);

    FormData layouDatag = new FormData();
    layouDatag.left = new FormAttachment(0, 0);
    layouDatag.right = new FormAttachment(100, 0);
    layouDatag.top = new FormAttachment(0, 0);
    layouDatag.bottom = new FormAttachment(100, 0);
    execGroup.setLayoutData(layouDatag);

    // leftTabFolder = new CTabFolder(this, SWT.BORDER);
    // leftTabFolder.setSimple(false);
    // //
    // leftTabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
    // //
    // // // Group context
    // //
    // CTabItem contextTabItem = new CTabItem(leftTabFolder, SWT.BORDER);
    //        contextTabItem.setText(Messages.getString("ProcessComposite.contextTab")); //$NON-NLS-1$
    // // contextComposite = new ProcessContextComposite(this, SWT.NONE);
    // // contextComposite.setBackground(leftTabFolder.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    // // contextTabItem.setControl(contextComposite);
    // //
    // Composite targetExecutionComposite = createTargetExecutionComposite(leftTabFolder);
    // targetExecutionComposite.setBackground(leftTabFolder.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    // //
    // targetExecutionTabItem = new CTabItem(leftTabFolder, SWT.BORDER);
    //        targetExecutionTabItem.setText(Messages.getString("ProcessComposite.targetExecutionTab")); //$NON-NLS-1$
    // targetExecutionTabItem.setToolTipText(Messages.getString("ProcessComposite.targetExecutionTabTooltipAvailable"));
    // targetExecutionTabItem.setControl(targetExecutionComposite);
    // //
    // // // Job Run VM Arguments Tab if language is java.
    // if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
    // jobVMTabItem = new CTabItem(leftTabFolder, SWT.BORDER);
    //            jobVMTabItem.setText(Messages.getString("ProcessComposite.JVMTab")); //$NON-NLS-1$
    // argumentsComposite = new Composite(leftTabFolder, SWT.NONE);
    // argumentsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    // GridLayout gridLayoutArguments = new GridLayout(1, false);
    // argumentsComposite.setLayout(gridLayoutArguments);
    // argumentsViewer = new JobVMArgumentsComposite("vmarguments", Messages
    //                    .getString("RunProcessPreferencePage.vmArgument"), //$NON-NLS-1$
    // argumentsComposite);
    // // argumentsViewer.setEnabled(false, argumentsComposite);
    // jobVMTabItem.setControl(argumentsComposite);
    // }

    ScrolledComposite execScroll = new ScrolledComposite(execGroup, SWT.V_SCROLL | SWT.H_SCROLL);
    execScroll.setExpandHorizontal(true);
    execScroll.setExpandVertical(true);
    execScroll.setLayoutData(new GridData(GridData.FILL_BOTH));

    Composite execContent = new Composite(execScroll, SWT.NONE);
    layout = new GridLayout();
    execContent.setLayout(new FormLayout());
    execScroll.setContent(execContent);

    Composite execHeader = new Composite(execContent, SWT.NONE);
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = 7;
    formLayout.marginHeight = 4;
    formLayout.spacing = 7;
    execHeader.setLayout(formLayout);
    FormData layoutData = new FormData();
    layoutData.left = new FormAttachment(0, 0);
    layoutData.right = new FormAttachment(100, 0);
    layoutData.top = new FormAttachment(0, 0);
    layoutData.bottom = new FormAttachment(0, 50);
    execHeader.setLayoutData(layoutData);// new GridData(GridData.FILL_HORIZONTAL)
    // qli
    // see the feature 6366
    run = new Button(execHeader, SWT.PUSH);

    // itemDropDown = new ToolItem(toolBar, SWT.ARROW);
    run.setText(" " + Messages.getString("ProcessComposite.exec"));//$NON-NLS-1$//$NON-NLS-2$
    run.setData(ProcessView.EXEC_ID);
    run.setToolTipText(Messages.getString("ProcessComposite.execHint"));//$NON-NLS-1$
    run.setImage(ImageProvider.getImage(ERunprocessImages.RUN_PROCESS_ACTION));

    // final Menu menu = new Menu(execHeader);
    run.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            execRun();
        }
    });

    // Run
    // final MenuItem menuItem1 = new MenuItem(menu, SWT.PUSH);
    //        menuItem1.setText(" " + Messages.getString("ProcessComposite.exec"));//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
    // menuItem1.setImage(ImageProvider.getImage(ERunprocessImages.RUN_PROCESS_ACTION));
    // menuItem1.setData(ProcessView.EXEC_ID);
    // menuItem1.addSelectionListener(new SelectionAdapter() {
    //
    // public void widgetSelected(SelectionEvent event) {
    // if (!itemDropDown.getData().equals(ProcessView.PAUSE_ID) &&
    // !itemDropDown.getData().equals(ProcessView.RESUME_ID)) {
    // itemDropDown.setText(menuItem1.getText());
    // itemDropDown.setData(ProcessView.EXEC_ID);
    // itemDropDown.setImage(ImageProvider.getImage(ERunprocessImages.RUN_PROCESS_ACTION));
    //                    itemDropDown.setToolTipText(Messages.getString("ProcessComposite.execHint"));//$NON-NLS-1$
    // toolBar.getParent().layout();
    // }
    // }
    // });
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault()
            .getService(IBrandingService.class);
    // if (brandingService.getBrandingConfiguration().isAllowDebugMode()) {
    // // Debug
    // debugMenuItem = new MenuItem(menu, SWT.PUSH);
    //            debugMenuItem.setText(" " + Messages.getString("ProcessDebugDialog.debugBtn")); //$NON-NLS-1$//$NON-NLS-2$
    // debugMenuItem.setData(ProcessView.DEBUG_ID);
    // debugMenuItem.setImage(ImageProvider.getImage(ERunprocessImages.DEBUG_PROCESS_ACTION));
    // debugMenuItem.addSelectionListener(new SelectionAdapter() {
    //
    // public void widgetSelected(SelectionEvent event) {
    // if (!itemDropDown.getData().equals(ProcessView.PAUSE_ID)
    // && !itemDropDown.getData().equals(ProcessView.RESUME_ID)) {
    // itemDropDown.setText(debugMenuItem.getText());
    // itemDropDown.setData(ProcessView.DEBUG_ID);
    // itemDropDown.setImage(ImageProvider.getImage(ERunprocessImages.DEBUG_PROCESS_ACTION));
    //                        itemDropDown.setToolTipText(Messages.getString("ProcessComposite.debugHint"));//$NON-NLS-1$
    // toolBar.getParent().layout();
    // }
    //
    // }
    // });
    // }
    if (processContext == null) {
        run.setEnabled(false);
    }
    // toolBar.setEnabled(false);
    FormData formData = new FormData();
    // see the feature 6366,qli comment.
    // make a judge when the text change in diffrent languages.

    Point debugSize = null;
    Point execSize = null;
    formData.left = new FormAttachment(0);
    // if (brandingService.getBrandingConfiguration().isAllowDebugMode()) {
    // // set debug text to judge size
    // itemDropDown.setText(debugMenuItem.getText());
    // debugSize = computeSize(itemDropDown.getText());
    //
    // // set exec text to judge size
    // itemDropDown.setText(menuItem1.getText());
    // execSize = computeSize(itemDropDown.getText());
    // if (debugSize.x > execSize.x) {
    // formData.right = new FormAttachment(0, debugSize.x + 70);
    // } else {
    // formData.right = new FormAttachment(0, execSize.x + 70);
    // }
    // } else {
    // set exec text to judge size

    execSize = computeSize(run.getText());
    formData.right = new FormAttachment(0, execSize.x + 70);
    formData.height = 30;
    // }
    run.setLayoutData(formData);

    killBtn = new Button(execHeader, SWT.PUSH);
    killBtn.setText(Messages.getString("ProcessComposite.kill")); //$NON-NLS-1$
    killBtn.setToolTipText(Messages.getString("ProcessComposite.killHint")); //$NON-NLS-1$
    killBtn.setImage(ImageProvider.getImage(ERunprocessImages.KILL_PROCESS_ACTION));
    setButtonLayoutData(killBtn);
    killBtn.setEnabled(false);
    formData = new FormData();
    formData.top = new FormAttachment(run, 0, SWT.TOP);
    formData.left = new FormAttachment(run, 0, SWT.RIGHT);
    // qli modified to fix the bug "7302".
    Point killSize = computeSize(killBtn.getText());
    // if (brandingService.getBrandingConfiguration().isAllowDebugMode()) {
    // if ((killSize.x > debugSize.x) && (killSize.x > execSize.x)) {
    // formData.right = new FormAttachment(toolBar, killSize.x + 70, SWT.RIGHT);
    // } else if (debugSize.x > execSize.x) {
    // formData.right = new FormAttachment(toolBar, debugSize.x + 70, SWT.RIGHT);
    // } else {
    // formData.right = new FormAttachment(toolBar, execSize.x + 70, SWT.RIGHT);
    // }
    // } else {
    // if (killSize.x > execSize.x) {
    // formData.right = new FormAttachment(toolBar, killSize.x + 70, SWT.RIGHT);
    // } else {
    // formData.right = new FormAttachment(toolBar, execSize.x + 70, SWT.RIGHT);
    // }
    // }
    formData.right = new FormAttachment(run, 30 + 70, SWT.RIGHT);
    formData.height = 30;
    killBtn.setLayoutData(formData);

    // saveJobBeforeRunButton = new Button(execHeader, SWT.CHECK);
    //        saveJobBeforeRunButton.setText(Messages.getString("ProcessComposite.saveBeforeRun")); //$NON-NLS-1$
    //        saveJobBeforeRunButton.setToolTipText(Messages.getString("ProcessComposite.saveBeforeRunHint")); //$NON-NLS-1$
    // // saveJobBeforeRunButton.setEnabled(false);
    // saveJobBeforeRunButton.setSelection(RunProcessPlugin.getDefault().getPreferenceStore().getBoolean(
    // RunProcessPrefsConstants.ISSAVEBEFORERUN));
    // data = new GridData();
    // data.horizontalSpan = 2;
    // data.horizontalAlignment = SWT.END;
    // saveJobBeforeRunButton.setLayoutData(data);
    // formData = new FormData();
    // formData.top = new FormAttachment(toolBar, 0, SWT.BOTTOM);
    // formData.left = new FormAttachment(toolBar, 0, SWT.LEFT);
    // saveJobBeforeRunButton.setLayoutData(formData);

    // clearBeforeExec = new Button(execHeader, SWT.CHECK);
    //        clearBeforeExec.setText(Messages.getString("ProcessComposite.clearBefore")); //$NON-NLS-1$
    //        clearBeforeExec.setToolTipText(Messages.getString("ProcessComposite.clearBeforeHint")); //$NON-NLS-1$
    // // clearBeforeExec.setEnabled(false);
    // clearBeforeExec.setSelection(RunProcessPlugin.getDefault().getPreferenceStore().getBoolean(
    // RunProcessPrefsConstants.ISCLEARBEFORERUN));
    // data = new GridData();
    // data.horizontalSpan = 2;
    // data.horizontalAlignment = SWT.END;
    // clearBeforeExec.setLayoutData(data);
    // formData = new FormData();
    // formData.top = new FormAttachment(toolBar, 0, SWT.BOTTOM);
    // formData.left = new FormAttachment(saveJobBeforeRunButton, 0, SWT.RIGHT);
    // clearBeforeExec.setLayoutData(formData);
    //
    // watchBtn = new Button(execHeader, SWT.CHECK);
    //        watchBtn.setText(Messages.getString("ProcessComposite.execTime")); //$NON-NLS-1$
    //        watchBtn.setToolTipText(Messages.getString("ProcessComposite.execTimeHint")); //$NON-NLS-1$
    // watchBtn.setEnabled(false);
    // watchBtn.setSelection(RunProcessPlugin.getDefault().getPreferenceStore().getBoolean(
    // RunProcessPrefsConstants.ISEXECTIMERUN));
    // data = new GridData();
    // data.horizontalSpan = 2;
    // data.horizontalAlignment = SWT.END;
    // watchBtn.setLayoutData(data);
    // formData = new FormData();
    // formData.top = new FormAttachment(killBtn, 0, SWT.BOTTOM);
    // formData.left = new FormAttachment(clearBeforeExec, 0, SWT.RIGHT);
    // watchBtn.setLayoutData(formData);
    //
    // Group statisticsComposite = new Group(execHeader, SWT.NONE);
    //        statisticsComposite.setText(Messages.getString("ProcessComposite2.statsComposite")); //$NON-NLS-1$
    // layout = new GridLayout(3, false);
    // layout.marginWidth = 0;
    // statisticsComposite.setLayout(layout);
    // formData = new FormData();
    // // formData.right = new FormAttachment(100, 0);
    // / formData.left = new FormAttachment(watchBtn, 0, SWT.RIGHT);
    // statisticsComposite.setLayoutData(formData);
    //
    // Composite statisticsButtonComposite = new Composite(statisticsComposite, SWT.NONE);
    // layout = new GridLayout(1, false);
    // layout.marginWidth = 0;
    // statisticsButtonComposite.setLayout(layout);
    // statisticsButtonComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));

    // perfBtn = new Button(statisticsButtonComposite, SWT.CHECK);
    //        perfBtn.setText(Messages.getString("ProcessComposite.stat")); //$NON-NLS-1$
    //        perfBtn.setToolTipText(Messages.getString("ProcessComposite.statHint")); //$NON-NLS-1$
    // perfBtn.setEnabled(false);
    // perfBtn.setSelection(RunProcessPlugin.getDefault().getPreferenceStore().getBoolean(
    // RunProcessPrefsConstants.ISSTATISTICSRUN));
    // traceBtn = new Button(statisticsButtonComposite, SWT.CHECK);
    //        traceBtn.setText(Messages.getString("ProcessComposite.trace")); //$NON-NLS-1$
    //        traceBtn.setToolTipText(Messages.getString("ProcessComposite.traceHint")); //$NON-NLS-1$
    // traceBtn.setEnabled(false);
    // traceBtn
    // .setSelection(RunProcessPlugin.getDefault().getPreferenceStore().getBoolean(RunProcessPrefsConstants.ISTRACESRUN));

    clearTracePerfBtn = new Button(execHeader, SWT.PUSH);
    clearTracePerfBtn.setText(Messages.getString("ProcessComposite.clear")); //$NON-NLS-1$
    clearTracePerfBtn.setToolTipText(Messages.getString("ProcessComposite.clearHint")); //$NON-NLS-1$
    clearTracePerfBtn.setImage(ImageProvider.getImage(RunProcessPlugin
            .imageDescriptorFromPlugin(RunProcessPlugin.PLUGIN_ID, "icons/process_stat_clear.gif"))); //$NON-NLS-1$
    clearTracePerfBtn.setEnabled(false);
    formData = new FormData();
    formData.top = new FormAttachment(killBtn, 0, SWT.TOP);
    formData.left = new FormAttachment(killBtn, 0, SWT.RIGHT);
    formData.right = new FormAttachment(killBtn, 10 + 70, SWT.RIGHT);
    formData.height = 30;
    clearTracePerfBtn.setLayoutData(formData);

    consoleText = new StyledText(execContent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
    consoleText.setWordWrap(true);
    data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    data.minimumHeight = MINIMUM_HEIGHT;
    data.minimumWidth = MINIMUM_WIDTH;
    layouData = new FormData();
    layouData.left = new FormAttachment(0, 10);
    layouData.right = new FormAttachment(100, 0);
    layouData.top = new FormAttachment(0, 50);
    layouData.bottom = new FormAttachment(100, -30);

    consoleText.setLayoutData(layouData);
    // feature 6875, add searching capability, nma
    consoleText.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent evt) {
            // select all
            if ((evt.stateMask == SWT.CTRL) && (evt.keyCode == 'a')) {
                if (consoleText.getText().length() > 0) {
                    consoleText.setSelection(0, (consoleText.getText().length() - 1));
                }
            }
            // search special string value
            else if ((evt.stateMask == SWT.CTRL) && (evt.keyCode == 'f')) {
                FindDialog td = new FindDialog(Display.getCurrent().getActiveShell());
                td.setConsoleText(consoleText);
                td.setBlockOnOpen(true);
                td.open();

            }
        }

        @Override
        public void keyReleased(KeyEvent arg0) {

        }
    });

    // see feature 0004895: Font size of the output console are very small
    setConsoleFont();
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    preferenceStore.addPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
            if (TalendDesignerPrefConstants.CONSOLT_TEXT_FONT.endsWith(event.getProperty())) {
                setConsoleFont();
            }

        }
    });

    // execScroll.setMinSize(execContent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    // sash.setSashWidth(1);
    // sash.setWeights(new int[] { 7, 1, H_WEIGHT });

    pcl = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            runProcessContextChanged(evt);
        }
    };

    streamListener = new IStreamListener() {

        @Override
        public void streamAppended(String text, IStreamMonitor monitor) {
            IProcessMessage message = new ProcessMessage(ProcessMessage.MsgType.STD_OUT, text);
            processContext.addDebugResultToConsole(message);
        }
    };
    addListeners();
    createLineLimitedControl(execContent);
}