Example usage for javax.swing.event ListSelectionListener ListSelectionListener

List of usage examples for javax.swing.event ListSelectionListener ListSelectionListener

Introduction

In this page you can find the example usage for javax.swing.event ListSelectionListener ListSelectionListener.

Prototype

ListSelectionListener

Source Link

Usage

From source file:AppSpringLayout.java

/**
 * Initialize the contents of the frame.
 *//*from w w  w .  jav  a  2s  .c  o m*/
private void initialize() {

    frame = new JFrame();
    frame.setBounds(0, 0, 850, 750);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    springLayout = new SpringLayout();
    frame.getContentPane().setLayout(springLayout);
    frame.setLocationRelativeTo(null);

    FileNameExtensionFilter filter = new FileNameExtensionFilter("Image files", "jpg", "jpeg", "png");
    fc = new JFileChooser();
    fc.setFileFilter(filter);
    // frame.getContentPane().add(fc);

    btnTurnCameraOn = new JButton("Turn camera on");
    springLayout.putConstraint(SpringLayout.WEST, btnTurnCameraOn, 51, SpringLayout.WEST,
            frame.getContentPane());
    springLayout.putConstraint(SpringLayout.EAST, btnTurnCameraOn, -581, SpringLayout.EAST,
            frame.getContentPane());
    frame.getContentPane().add(btnTurnCameraOn);

    urlTextField = new JTextField();
    springLayout.putConstraint(SpringLayout.SOUTH, btnTurnCameraOn, -6, SpringLayout.NORTH, urlTextField);
    springLayout.putConstraint(SpringLayout.WEST, urlTextField, 0, SpringLayout.WEST, btnTurnCameraOn);
    springLayout.putConstraint(SpringLayout.EAST, urlTextField, 274, SpringLayout.WEST, frame.getContentPane());
    frame.getContentPane().add(urlTextField);
    urlTextField.setColumns(10);

    originalImageLabel = new JLabel("");
    springLayout.putConstraint(SpringLayout.NORTH, originalImageLabel, 102, SpringLayout.NORTH,
            frame.getContentPane());
    springLayout.putConstraint(SpringLayout.WEST, originalImageLabel, 34, SpringLayout.WEST,
            frame.getContentPane());
    springLayout.putConstraint(SpringLayout.SOUTH, originalImageLabel, -326, SpringLayout.SOUTH,
            frame.getContentPane());
    springLayout.putConstraint(SpringLayout.EAST, originalImageLabel, -566, SpringLayout.EAST,
            frame.getContentPane());
    springLayout.putConstraint(SpringLayout.SOUTH, urlTextField, -6, SpringLayout.NORTH, originalImageLabel);
    frame.getContentPane().add(originalImageLabel);

    btnAnalyseImage = new JButton("Analyse image");
    springLayout.putConstraint(SpringLayout.NORTH, btnAnalyseImage, 6, SpringLayout.SOUTH, originalImageLabel);
    springLayout.putConstraint(SpringLayout.WEST, btnAnalyseImage, 58, SpringLayout.WEST,
            frame.getContentPane());
    springLayout.putConstraint(SpringLayout.EAST, btnAnalyseImage, 252, SpringLayout.WEST,
            frame.getContentPane());
    frame.getContentPane().add(btnAnalyseImage);

    lblTags = new JLabel("Tags:");
    frame.getContentPane().add(lblTags);

    lblDescription = new JLabel("Description:");
    springLayout.putConstraint(SpringLayout.WEST, lblDescription, 84, SpringLayout.EAST, lblTags);
    springLayout.putConstraint(SpringLayout.NORTH, lblTags, 0, SpringLayout.NORTH, lblDescription);
    springLayout.putConstraint(SpringLayout.NORTH, lblDescription, 6, SpringLayout.SOUTH, btnAnalyseImage);
    springLayout.putConstraint(SpringLayout.SOUTH, lblDescription, -269, SpringLayout.SOUTH,
            frame.getContentPane());
    frame.getContentPane().add(lblDescription);

    tagsTextArea = new JTextArea();
    springLayout.putConstraint(SpringLayout.NORTH, tagsTextArea, 459, SpringLayout.NORTH,
            frame.getContentPane());
    springLayout.putConstraint(SpringLayout.WEST, tagsTextArea, 10, SpringLayout.WEST, frame.getContentPane());
    springLayout.putConstraint(SpringLayout.EAST, tagsTextArea, -727, SpringLayout.EAST,
            frame.getContentPane());
    frame.getContentPane().add(tagsTextArea);

    descriptionTextArea = new JTextArea();
    springLayout.putConstraint(SpringLayout.NORTH, descriptionTextArea, 0, SpringLayout.SOUTH, lblDescription);
    springLayout.putConstraint(SpringLayout.WEST, descriptionTextArea, 18, SpringLayout.EAST, tagsTextArea);
    descriptionTextArea.setLineWrap(true);
    descriptionTextArea.setWrapStyleWord(true);
    frame.getContentPane().add(descriptionTextArea);

    lblImageType = new JLabel("Image type");
    springLayout.putConstraint(SpringLayout.WEST, lblTags, 0, SpringLayout.WEST, lblImageType);
    springLayout.putConstraint(SpringLayout.NORTH, lblImageType, 10, SpringLayout.SOUTH, tagsTextArea);
    springLayout.putConstraint(SpringLayout.WEST, lblImageType, 20, SpringLayout.WEST, frame.getContentPane());
    frame.getContentPane().add(lblImageType);

    lblSize = new JLabel("Size");
    springLayout.putConstraint(SpringLayout.NORTH, lblSize, 21, SpringLayout.SOUTH, lblImageType);
    springLayout.putConstraint(SpringLayout.WEST, lblSize, 20, SpringLayout.WEST, frame.getContentPane());
    frame.getContentPane().add(lblSize);

    lblLicense = new JLabel("License");
    springLayout.putConstraint(SpringLayout.WEST, lblLicense, 20, SpringLayout.WEST, frame.getContentPane());
    frame.getContentPane().add(lblLicense);

    lblSafeSearch = new JLabel("Safe search");
    springLayout.putConstraint(SpringLayout.WEST, lblSafeSearch, 10, SpringLayout.WEST, frame.getContentPane());
    springLayout.putConstraint(SpringLayout.SOUTH, lblSafeSearch, 139, SpringLayout.SOUTH,
            frame.getContentPane());
    frame.getContentPane().add(lblSafeSearch);

    String[] licenseTypes = { "unspecified", "Public", "Share", "ShareCommercially", "Modify" };
    licenseBox = new JComboBox(licenseTypes);
    springLayout.putConstraint(SpringLayout.WEST, licenseBox, 28, SpringLayout.EAST, lblLicense);
    frame.getContentPane().add(licenseBox);

    String[] sizeTypes = { "unspecified", "Small", "Medium", "Large", "Wallpaper" };
    sizeBox = new JComboBox(sizeTypes);
    springLayout.putConstraint(SpringLayout.WEST, sizeBox, 50, SpringLayout.EAST, lblSize);
    springLayout.putConstraint(SpringLayout.EAST, sizeBox, -556, SpringLayout.EAST, frame.getContentPane());
    springLayout.putConstraint(SpringLayout.EAST, licenseBox, 0, SpringLayout.EAST, sizeBox);
    frame.getContentPane().add(sizeBox);

    String[] imageTypes = { "unspecified", "AnimategGif", "Clipart", "Line", "Photo" };
    imageTypeBox = new JComboBox(imageTypes);
    springLayout.putConstraint(SpringLayout.SOUTH, descriptionTextArea, -6, SpringLayout.NORTH, imageTypeBox);
    springLayout.putConstraint(SpringLayout.NORTH, imageTypeBox, 547, SpringLayout.NORTH,
            frame.getContentPane());
    springLayout.putConstraint(SpringLayout.SOUTH, tagsTextArea, -6, SpringLayout.NORTH, imageTypeBox);
    springLayout.putConstraint(SpringLayout.WEST, imageTypeBox, 6, SpringLayout.EAST, lblImageType);
    springLayout.putConstraint(SpringLayout.EAST, imageTypeBox, -556, SpringLayout.EAST,
            frame.getContentPane());
    springLayout.putConstraint(SpringLayout.NORTH, sizeBox, 10, SpringLayout.SOUTH, imageTypeBox);
    frame.getContentPane().add(imageTypeBox);

    btnBrowse = new JButton("Browse");
    springLayout.putConstraint(SpringLayout.WEST, btnBrowse, 0, SpringLayout.WEST, btnTurnCameraOn);
    springLayout.putConstraint(SpringLayout.EAST, btnBrowse, -583, SpringLayout.EAST, frame.getContentPane());
    frame.getContentPane().add(btnBrowse);

    lblSafeSearch_1 = new JLabel("Safe search");
    springLayout.putConstraint(SpringLayout.WEST, lblSafeSearch_1, 20, SpringLayout.WEST,
            frame.getContentPane());
    springLayout.putConstraint(SpringLayout.SOUTH, lblLicense, -17, SpringLayout.NORTH, lblSafeSearch_1);
    frame.getContentPane().add(lblSafeSearch_1);

    String[] safeSearchTypes = { "Strict", "Moderate", "Off" };
    safeSearchBox = new JComboBox(safeSearchTypes);
    springLayout.putConstraint(SpringLayout.SOUTH, licenseBox, -6, SpringLayout.NORTH, safeSearchBox);
    springLayout.putConstraint(SpringLayout.WEST, safeSearchBox, 4, SpringLayout.EAST, lblSafeSearch_1);
    springLayout.putConstraint(SpringLayout.EAST, safeSearchBox, 0, SpringLayout.EAST, licenseBox);
    frame.getContentPane().add(safeSearchBox);

    btnSearchForSimilar = new JButton("Search for similar images");
    springLayout.putConstraint(SpringLayout.SOUTH, lblSafeSearch_1, -13, SpringLayout.NORTH,
            btnSearchForSimilar);
    springLayout.putConstraint(SpringLayout.SOUTH, safeSearchBox, -6, SpringLayout.NORTH, btnSearchForSimilar);
    springLayout.putConstraint(SpringLayout.NORTH, btnSearchForSimilar, 689, SpringLayout.NORTH,
            frame.getContentPane());
    springLayout.putConstraint(SpringLayout.WEST, btnSearchForSimilar, 36, SpringLayout.WEST,
            frame.getContentPane());
    frame.getContentPane().add(btnSearchForSimilar);

    btnCancel = new JButton("Cancel");
    springLayout.putConstraint(SpringLayout.NORTH, btnCancel, 0, SpringLayout.NORTH, btnBrowse);
    btnCancel.setVisible(false);
    frame.getContentPane().add(btnCancel);

    btnSave = new JButton("Save");
    springLayout.putConstraint(SpringLayout.WEST, btnCancel, 6, SpringLayout.EAST, btnSave);
    springLayout.putConstraint(SpringLayout.NORTH, btnSave, 0, SpringLayout.NORTH, btnBrowse);
    btnSave.setVisible(false);
    frame.getContentPane().add(btnSave);

    btnTakeAPicture = new JButton("Take a picture");
    springLayout.putConstraint(SpringLayout.WEST, btnTakeAPicture, 114, SpringLayout.EAST, btnBrowse);
    springLayout.putConstraint(SpringLayout.WEST, btnSave, 6, SpringLayout.EAST, btnTakeAPicture);
    springLayout.putConstraint(SpringLayout.NORTH, btnTakeAPicture, 0, SpringLayout.NORTH, btnBrowse);
    btnTakeAPicture.setVisible(false);
    frame.getContentPane().add(btnTakeAPicture);

    //// JScrollPane scroll = new JScrollPane(list);
    // Constraints c = springLayout.getConstraints(list);
    // frame.getContentPane().add(scroll, c);

    list = new JList();
    JScrollPane scroll = new JScrollPane(list);
    springLayout.putConstraint(SpringLayout.EAST, descriptionTextArea, -89, SpringLayout.WEST, list);
    springLayout.putConstraint(SpringLayout.EAST, list, -128, SpringLayout.EAST, frame.getContentPane());
    springLayout.putConstraint(SpringLayout.WEST, list, 64, SpringLayout.EAST, licenseBox);
    springLayout.putConstraint(SpringLayout.NORTH, list, 0, SpringLayout.NORTH, btnTurnCameraOn);
    springLayout.putConstraint(SpringLayout.SOUTH, list, -35, SpringLayout.SOUTH, lblSafeSearch_1);

    Constraints c = springLayout.getConstraints(list);
    frame.getContentPane().add(scroll, c);

    // frame.getContentPane().add(list);

    progressBar = new JProgressBar();
    springLayout.putConstraint(SpringLayout.NORTH, progressBar, 15, SpringLayout.SOUTH, list);
    springLayout.putConstraint(SpringLayout.WEST, progressBar, 24, SpringLayout.EAST, safeSearchBox);
    springLayout.putConstraint(SpringLayout.EAST, progressBar, 389, SpringLayout.WEST, btnTakeAPicture);
    progressBar.setIndeterminate(true);
    progressBar.setStringPainted(true);
    progressBar.setVisible(false);
    Border border = BorderFactory
            .createTitledBorder("We are checking every image, pixel by pixel, it may take a while...");
    progressBar.setBorder(border);
    frame.getContentPane().add(progressBar);

    labelTryLinks = new JLabel();
    labelTryLinks.setVisible(false);
    springLayout.putConstraint(SpringLayout.NORTH, labelTryLinks, -16, SpringLayout.SOUTH, btnSearchForSimilar);
    springLayout.putConstraint(SpringLayout.WEST, labelTryLinks, -61, SpringLayout.EAST, licenseBox);
    springLayout.putConstraint(SpringLayout.SOUTH, labelTryLinks, 0, SpringLayout.SOUTH, btnSearchForSimilar);
    springLayout.putConstraint(SpringLayout.EAST, labelTryLinks, 0, SpringLayout.EAST, licenseBox);
    frame.getContentPane().add(labelTryLinks);

    lblFoundLinks = new JLabel("");
    springLayout.putConstraint(SpringLayout.NORTH, lblFoundLinks, -29, SpringLayout.NORTH, progressBar);
    springLayout.putConstraint(SpringLayout.WEST, lblFoundLinks, 6, SpringLayout.EAST, scroll);
    springLayout.putConstraint(SpringLayout.SOUTH, lblFoundLinks, -13, SpringLayout.NORTH, progressBar);
    springLayout.putConstraint(SpringLayout.EAST, lblFoundLinks, -10, SpringLayout.EAST,
            frame.getContentPane());
    frame.getContentPane().add(lblFoundLinks);

    numberOfImagesToSearchFor = new JTextField();
    springLayout.putConstraint(SpringLayout.NORTH, numberOfImagesToSearchFor, 0, SpringLayout.NORTH,
            tagsTextArea);
    springLayout.putConstraint(SpringLayout.WEST, numberOfImagesToSearchFor, 6, SpringLayout.EAST,
            descriptionTextArea);
    springLayout.putConstraint(SpringLayout.EAST, numberOfImagesToSearchFor, -36, SpringLayout.WEST, scroll);
    frame.getContentPane().add(numberOfImagesToSearchFor);
    numberOfImagesToSearchFor.setColumns(10);

    JLabel lblNumberOfImages = new JLabel("Number");
    springLayout.putConstraint(SpringLayout.NORTH, lblNumberOfImages, 0, SpringLayout.NORTH, lblTags);
    springLayout.putConstraint(SpringLayout.WEST, lblNumberOfImages, 31, SpringLayout.EAST, btnAnalyseImage);
    springLayout.putConstraint(SpringLayout.EAST, lblNumberOfImages, -6, SpringLayout.WEST, scroll);
    frame.getContentPane().add(lblNumberOfImages);

    // label to get coordinates for web camera panel
    // lblNewLabel_1 = new JLabel("New label");
    // springLayout.putConstraint(SpringLayout.NORTH, lblNewLabel_1, 0,
    // SpringLayout.NORTH, btnTurnCameraOn);
    // springLayout.putConstraint(SpringLayout.WEST, lblNewLabel_1, 98,
    // SpringLayout.EAST, originalImagesLabel);
    // springLayout.putConstraint(SpringLayout.SOUTH, lblNewLabel_1, -430,
    // SpringLayout.SOUTH, lblSafeSearch_1);
    // springLayout.putConstraint(SpringLayout.EAST, lblNewLabel_1, 0,
    // SpringLayout.EAST, btnCancel);
    // frame.getContentPane().add(lblNewLabel_1);

    btnBrowse.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (fc.showOpenDialog(frame) == JFileChooser.APPROVE_OPTION) {
                openFilechooser();
            }
        }
    });

    btnTurnCameraOn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("turn camera on");
            turnCameraOn();
            btnCancel.setVisible(true);
            btnTakeAPicture.setVisible(true);
        }
    });

    btnTakeAPicture.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            btnSave.setVisible(true);
            imageWebcam = webcam.getImage();
            originalImage = imageWebcam;

            // to mirror the image we create a temporary file, flip it
            // horizontally and then delete

            // get user's name to store file in the user directory
            String user = System.getProperty("user.home");
            String fileName = user + "/webCamPhoto.jpg";
            File newFile = new File(fileName);

            try {
                ImageIO.write(originalImage, "jpg", newFile);
            } catch (IOException e1) {
                e1.printStackTrace();
            }
            try {
                originalImage = (BufferedImage) ImageIO.read(newFile);
            } catch (IOException e1) {
                e1.printStackTrace();
            }
            newFile.delete();
            originalImage = mirrorImage(originalImage);
            icon = scaleBufferedImage(originalImage, originalImageLabel);
            originalImageLabel.setIcon(icon);
        }
    });

    btnSave.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (fc.showSaveDialog(frame) == JFileChooser.APPROVE_OPTION) {
                try {

                    file = fc.getSelectedFile();
                    File output = new File(file.toString());
                    // check if image already exists
                    if (output.exists()) {
                        int response = JOptionPane.showConfirmDialog(null, //
                                "Do you want to replace the existing file?", //
                                "Confirm", JOptionPane.YES_NO_OPTION, //
                                JOptionPane.QUESTION_MESSAGE);
                        if (response != JOptionPane.YES_OPTION) {
                            return;
                        }
                    }
                    ImageIO.write(toBufferedImage(originalImage), "jpg", output);
                    System.out.println("Your image has been saved in the folder " + file.getPath());
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
        }
    });

    btnCancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            btnTakeAPicture.setVisible(false);
            btnCancel.setVisible(false);
            btnSave.setVisible(false);
            webcam.close();
            panel.setVisible(false);
        }
    });

    urlTextField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            if (urlTextField.getText().length() > 0) {
                String linkNew = urlTextField.getText();
                displayImage(linkNew, originalImageLabel);
                originalImage = imageResponses;
            }
        }
    });

    btnAnalyseImage.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Token computerVisionToken = new Token();
            String computerVisionTokenFileName = "APIToken.txt";

            try {
                computerVisionImageToken = computerVisionToken.getApiToken(computerVisionTokenFileName);
                try {
                    analyse();
                } catch (NullPointerException e1) {
                    // if user clicks on "analyze" button without uploading
                    // image or posts a broken link
                    JOptionPane.showMessageDialog(null, "Please choose an image");
                    e1.printStackTrace();
                }
            } catch (NullPointerException e1) {
                e1.printStackTrace();
            }
        }
    });

    btnSearchForSimilar.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            listModel.clear();

            Token bingImageToken = new Token();
            String bingImageTokenFileName = "SearchApiToken.txt";
            bingToken = bingImageToken.getApiToken(bingImageTokenFileName);

            // in case user edited description or tags, update it and
            // replace new line character, spaces and breaks with %20
            text = descriptionTextArea.getText().replace(" ", "%20").replace("\r", "%20").replace("\n", "%20");
            String tagsString = tagsTextArea.getText().replace(" ", "%20").replace("\r", "%20").replace("\n",
                    "%20");

            String numberOfImages = numberOfImagesToSearchFor.getText();

            try {
                int numberOfImagesTry = Integer.parseInt(numberOfImages);
                System.out.println(numberOfImagesTry);

                imageTypeString = imageTypeBox.getSelectedItem().toString();
                sizeTypeString = sizeBox.getSelectedItem().toString();
                licenseTypeString = licenseBox.getSelectedItem().toString();
                safeSearchTypeString = safeSearchBox.getSelectedItem().toString();

                searchParameters = tagsString + text;
                System.out.println("search parameters: " + searchParameters);

                if (searchParameters.length() != 0) {

                    // add new thread for searching, so that progress bar
                    // and searching could run simultaneously
                    Thread t1 = new Thread(new Runnable() {
                        @Override
                        public void run() {
                            progressBar.setVisible(true);
                            workingUrls = searchToDisplayOnJList(searchParameters, imageTypeString,
                                    sizeTypeString, licenseTypeString, safeSearchTypeString, numberOfImages);
                        }
                    });
                    // start searching in a separate thread
                    t1.start();
                } else {
                    JOptionPane.showMessageDialog(null,
                            "Please choose first an image to analyse or insert search parameters");
                }
            } catch (NumberFormatException e1) {
                JOptionPane.showMessageDialog(null, "Please insert a valid number of images to search for");
                e1.printStackTrace();

            }
        }
    });

    list.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            int i = list.getSelectedIndex();

            if (fc.showSaveDialog(frame) == JFileChooser.APPROVE_OPTION) {
                try {
                    file = fc.getSelectedFile();
                    File output = new File(file.toString());
                    // check if file already exists, ask user if they
                    // wish to overwrite it
                    if (output.exists()) {
                        int response = JOptionPane.showConfirmDialog(null, //
                                "Do you want to replace the existing file?", //
                                "Confirm", JOptionPane.YES_NO_OPTION, //
                                JOptionPane.QUESTION_MESSAGE);
                        if (response != JOptionPane.YES_OPTION) {
                            return;
                        }
                    }
                    try {

                        URL fileNameAsUrl = new URL(linksResponse[i]);
                        originalImage = ImageIO.read(fileNameAsUrl);
                        ImageIO.write(toBufferedImage(originalImage), "jpeg", output);
                        System.out.println("image saved, in the folder: " + output.getAbsolutePath());

                    } catch (MalformedURLException e1) {
                        e1.printStackTrace();
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    }
                } catch (NullPointerException e2) {
                    e2.getMessage();
                }
            }
        }
    });
}

From source file:client.ui.FilePane.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*from w  w w.  j a va  2s . co m*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    fileButtonPane = new JPanel();
    uploadFileButton = new JButton();
    downloadFileButton = new JButton();
    deleteFileButton = new JButton();
    renameFileButton = new JButton();
    authorizationButton = new JButton();
    jSeparator1 = new JSeparator();
    addNoteButton = new JButton();
    deleteNoteButton = new JButton();
    jSeparator2 = new JSeparator();
    targetIDField = new JTextField();
    searchUserButton = new JButton();
    returnButton = new JButton();
    jSeparator3 = new JSeparator();
    refreshButton = new JButton();
    jSeparator4 = new JSeparator();
    changePasswdButton = new JButton();
    fileSplitPane = new JSplitPane();
    jSplitPane2 = new JSplitPane();
    fileInfoScroll = new JScrollPane();
    fileInfoTable = new JTable();
    noteDisplayScroll = new JScrollPane();
    noteTable = new JTable();
    jSplitPane1 = new JSplitPane();
    fileDisplayScroll = new JScrollPane();
    fileContentArea = new JTextArea();
    noteInputScroll = new JScrollPane();
    noteInputArea = new JTextArea();

    FormListener formListener = new FormListener();

    setForeground(new Color(240, 240, 240));
    setFont(new Font("", 0, 12)); // NOI18N
    setMaximumSize(new Dimension(1366, 768));
    setPreferredSize(new Dimension(1366, 700));

    fileButtonPane.setMaximumSize(new Dimension(32767, 50));
    fileButtonPane.setMinimumSize(new Dimension(404, 50));

    uploadFileButton.setFont(new Font("", 0, 12)); // NOI18N
    uploadFileButton.setText("");
    uploadFileButton.setActionCommand("JButton1");
    uploadFileButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    uploadFileButton.setBorderPainted(false);
    uploadFileButton.setContentAreaFilled(false);
    uploadFileButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    uploadFileButton.setFocusPainted(false);
    uploadFileButton.setMaximumSize(new Dimension(30, 20));
    uploadFileButton.setMinimumSize(new Dimension(30, 20));
    uploadFileButton.addMouseListener(formListener);
    uploadFileButton.addActionListener(formListener);

    downloadFileButton.setFont(new Font("", 0, 12)); // NOI18N
    downloadFileButton.setText("");
    downloadFileButton.setActionCommand("JButton1");
    downloadFileButton.setBorder(null);
    downloadFileButton.setBorderPainted(false);
    downloadFileButton.setContentAreaFilled(false);
    downloadFileButton.setEnabled(false);
    downloadFileButton.setFocusPainted(false);
    downloadFileButton.setMaximumSize(new Dimension(30, 20));
    downloadFileButton.setMinimumSize(new Dimension(30, 20));
    downloadFileButton.setPreferredSize(new Dimension(30, 20));
    downloadFileButton.addMouseListener(formListener);
    downloadFileButton.addActionListener(formListener);

    deleteFileButton.setFont(new Font("", 0, 12)); // NOI18N
    deleteFileButton.setText("");
    deleteFileButton.setBorder(null);
    deleteFileButton.setBorderPainted(false);
    deleteFileButton.setContentAreaFilled(false);
    deleteFileButton.setEnabled(false);
    deleteFileButton.setFocusPainted(false);
    deleteFileButton.addMouseListener(formListener);
    deleteFileButton.addActionListener(formListener);

    renameFileButton.setFont(new Font("", 0, 12)); // NOI18N
    renameFileButton.setText("???");
    renameFileButton.setBorder(null);
    renameFileButton.setBorderPainted(false);
    renameFileButton.setContentAreaFilled(false);
    renameFileButton.setEnabled(false);
    renameFileButton.setFocusPainted(false);
    renameFileButton.addMouseListener(formListener);
    renameFileButton.addActionListener(formListener);

    authorizationButton.setFont(new Font("", 0, 12)); // NOI18N
    authorizationButton.setText("??");
    authorizationButton.setBorder(null);
    authorizationButton.setBorderPainted(false);
    authorizationButton.setContentAreaFilled(false);
    authorizationButton.setEnabled(false);
    authorizationButton.setFocusPainted(false);
    authorizationButton.addMouseListener(formListener);
    authorizationButton.addActionListener(formListener);

    jSeparator1.setOrientation(SwingConstants.VERTICAL);

    addNoteButton.setFont(new Font("", 0, 12)); // NOI18N
    addNoteButton.setText("");
    addNoteButton.setActionCommand("JButton1");
    addNoteButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    addNoteButton.setBorderPainted(false);
    addNoteButton.setContentAreaFilled(false);
    addNoteButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    addNoteButton.setEnabled(false);
    addNoteButton.setFocusPainted(false);
    addNoteButton.setMaximumSize(new Dimension(30, 20));
    addNoteButton.setMinimumSize(new Dimension(30, 20));
    addNoteButton.addMouseListener(formListener);
    addNoteButton.addActionListener(formListener);

    deleteNoteButton.setFont(new Font("", 0, 12)); // NOI18N
    deleteNoteButton.setText("");
    deleteNoteButton.setActionCommand("JButton1");
    deleteNoteButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    deleteNoteButton.setBorderPainted(false);
    deleteNoteButton.setContentAreaFilled(false);
    deleteNoteButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    deleteNoteButton.setEnabled(false);
    deleteNoteButton.setFocusPainted(false);
    deleteNoteButton.setMaximumSize(new Dimension(30, 20));
    deleteNoteButton.setMinimumSize(new Dimension(30, 20));
    deleteNoteButton.addMouseListener(formListener);
    deleteNoteButton.addActionListener(formListener);

    jSeparator2.setOrientation(SwingConstants.VERTICAL);

    targetIDField.setFont(new Font("", 0, 12)); // NOI18N

    searchUserButton.setFont(new Font("", 0, 12)); // NOI18N
    searchUserButton.setText("");
    searchUserButton.setActionCommand("JButton1");
    searchUserButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    searchUserButton.setBorderPainted(false);
    searchUserButton.setContentAreaFilled(false);
    searchUserButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    searchUserButton.setFocusPainted(false);
    searchUserButton.setMaximumSize(new Dimension(30, 20));
    searchUserButton.setMinimumSize(new Dimension(30, 20));
    searchUserButton.addMouseListener(formListener);
    searchUserButton.addActionListener(formListener);

    returnButton.setFont(new Font("", 0, 12)); // NOI18N
    returnButton.setText("");
    returnButton.setActionCommand("JButton1");
    returnButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    returnButton.setBorderPainted(false);
    returnButton.setContentAreaFilled(false);
    returnButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    returnButton.setFocusPainted(false);
    returnButton.setMaximumSize(new Dimension(30, 20));
    returnButton.setMinimumSize(new Dimension(30, 20));
    returnButton.addMouseListener(formListener);
    returnButton.addActionListener(formListener);

    jSeparator3.setOrientation(SwingConstants.VERTICAL);

    refreshButton.setFont(new Font("", 0, 12)); // NOI18N
    refreshButton.setText("");
    refreshButton.setActionCommand("JButton1");
    refreshButton.setBorder(null);
    refreshButton.setBorderPainted(false);
    refreshButton.setContentAreaFilled(false);
    refreshButton.setFocusPainted(false);
    refreshButton.setMaximumSize(new Dimension(30, 20));
    refreshButton.setMinimumSize(new Dimension(30, 20));
    refreshButton.setPreferredSize(new Dimension(30, 20));
    refreshButton.addMouseListener(formListener);
    refreshButton.addActionListener(formListener);

    jSeparator4.setOrientation(SwingConstants.VERTICAL);

    changePasswdButton.setFont(new Font("", 0, 12)); // NOI18N
    changePasswdButton.setText("?");
    changePasswdButton.setActionCommand("JButton1");
    changePasswdButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    changePasswdButton.setBorderPainted(false);
    changePasswdButton.setContentAreaFilled(false);
    changePasswdButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    changePasswdButton.setFocusPainted(false);
    changePasswdButton.setMaximumSize(new Dimension(30, 20));
    changePasswdButton.setMinimumSize(new Dimension(30, 20));
    changePasswdButton.addMouseListener(formListener);
    changePasswdButton.addActionListener(formListener);

    GroupLayout fileButtonPaneLayout = new GroupLayout(fileButtonPane);
    fileButtonPane.setLayout(fileButtonPaneLayout);
    fileButtonPaneLayout.setHorizontalGroup(fileButtonPaneLayout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(fileButtonPaneLayout.createSequentialGroup()
                    .addComponent(uploadFileButton, GroupLayout.PREFERRED_SIZE, 46, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(downloadFileButton, GroupLayout.PREFERRED_SIZE, 46,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(deleteFileButton, GroupLayout.PREFERRED_SIZE, 46, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(renameFileButton, GroupLayout.PREFERRED_SIZE, 57, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(authorizationButton, GroupLayout.PREFERRED_SIZE, 63,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jSeparator1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(addNoteButton, GroupLayout.PREFERRED_SIZE, 63, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(deleteNoteButton, GroupLayout.PREFERRED_SIZE, 63, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jSeparator2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(targetIDField, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(searchUserButton, GroupLayout.PREFERRED_SIZE, 63, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(returnButton, GroupLayout.PREFERRED_SIZE, 63, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jSeparator3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(refreshButton, GroupLayout.PREFERRED_SIZE, 46, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jSeparator4, GroupLayout.PREFERRED_SIZE, 2, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(changePasswdButton,
                            GroupLayout.PREFERRED_SIZE, 63, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(18, Short.MAX_VALUE)));
    fileButtonPaneLayout.setVerticalGroup(fileButtonPaneLayout
            .createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING,
                    fileButtonPaneLayout.createSequentialGroup().addContainerGap().addGroup(fileButtonPaneLayout
                            .createParallelGroup(GroupLayout.Alignment.TRAILING).addComponent(jSeparator4)
                            .addGroup(fileButtonPaneLayout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE)
                                    .addGroup(fileButtonPaneLayout
                                            .createParallelGroup(GroupLayout.Alignment.TRAILING)
                                            .addComponent(changePasswdButton, GroupLayout.PREFERRED_SIZE, 25,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addGroup(fileButtonPaneLayout
                                                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                                                    .addComponent(refreshButton, GroupLayout.PREFERRED_SIZE, 25,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addGroup(fileButtonPaneLayout
                                                            .createParallelGroup(
                                                                    GroupLayout.Alignment.TRAILING, false)
                                                            .addComponent(jSeparator2)
                                                            .addGroup(fileButtonPaneLayout
                                                                    .createParallelGroup(
                                                                            GroupLayout.Alignment.BASELINE)
                                                                    .addComponent(addNoteButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE)
                                                                    .addComponent(deleteNoteButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE))
                                                            .addComponent(jSeparator1)
                                                            .addGroup(fileButtonPaneLayout
                                                                    .createParallelGroup(
                                                                            GroupLayout.Alignment.BASELINE)
                                                                    .addComponent(downloadFileButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE)
                                                                    .addComponent(deleteFileButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE)
                                                                    .addComponent(renameFileButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE)
                                                                    .addComponent(authorizationButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE)
                                                                    .addComponent(uploadFileButton,
                                                                            GroupLayout.PREFERRED_SIZE, 25,
                                                                            GroupLayout.PREFERRED_SIZE))
                                                            .addComponent(jSeparator3)
                                                            .addGroup(GroupLayout.Alignment.LEADING,
                                                                    fileButtonPaneLayout.createParallelGroup(
                                                                            GroupLayout.Alignment.BASELINE)
                                                                            .addComponent(targetIDField)
                                                                            .addComponent(searchUserButton,
                                                                                    GroupLayout.PREFERRED_SIZE,
                                                                                    25,
                                                                                    GroupLayout.PREFERRED_SIZE)
                                                                            .addComponent(returnButton,
                                                                                    GroupLayout.PREFERRED_SIZE,
                                                                                    25,
                                                                                    GroupLayout.PREFERRED_SIZE)))))))
                            .addGap(15, 15, 15)));

    fileSplitPane.setBackground(new Color(255, 255, 255));
    fileSplitPane.setDividerLocation(750);
    fileSplitPane.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    fileSplitPane.setMaximumSize(new Dimension(1366, 768));
    fileSplitPane.setPreferredSize(new Dimension(701, 646));

    jSplitPane2.setDividerLocation(400);
    jSplitPane2.setOrientation(JSplitPane.VERTICAL_SPLIT);
    jSplitPane2.setContinuousLayout(true);
    jSplitPane2.setMaximumSize(new Dimension(1366, 768));

    fileInfoScroll.setBackground(new Color(255, 255, 255));
    fileInfoScroll.setFont(new Font("", 0, 12)); // NOI18N
    fileInfoScroll.getViewport().setBackground(Color.WHITE);
    fileInfoScroll.addMouseListener(formListener);

    fileInfoTable.setAutoCreateRowSorter(true);
    fileInfoTable.setFont(new Font("", 0, 12)); // NOI18N
    fileInfoTable.setModel(fileTableModel);
    fileInfoTable.getTableHeader().setFont(new Font("", 0, 12));
    fileInfoTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    fileInfoTable.setRowHeight(20);
    fileInfoTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    fileInfoTable.setShowHorizontalLines(false);
    fileInfoTable.setShowVerticalLines(false);
    fileInfoTable.addMouseListener(formListener);
    fileInfoTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent evt) {
            fileSelectedChanged(evt);
        }
    });
    fileInfoScroll.setViewportView(fileInfoTable);

    jSplitPane2.setTopComponent(fileInfoScroll);

    noteDisplayScroll.setBackground(new Color(255, 255, 255));
    noteDisplayScroll.setFont(new Font("", 0, 12)); // NOI18N
    noteDisplayScroll.getViewport().setBackground(Color.WHITE);
    noteDisplayScroll.addMouseListener(formListener);

    noteTable.setAutoCreateRowSorter(true);
    noteTable.setFont(new Font("", 0, 12)); // NOI18N
    noteTable.setModel(noteTableModel);
    noteTable.getTableHeader().setFont(new Font("", 0, 12));
    noteTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    noteTable.setRowHeight(20);
    noteTable.setShowHorizontalLines(false);
    noteTable.setShowVerticalLines(false);
    noteTable.addMouseListener(formListener);
    noteTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
            noteSelectedChanged(evt);
        }
    });
    noteDisplayScroll.setViewportView(noteTable);

    jSplitPane2.setBottomComponent(noteDisplayScroll);

    fileSplitPane.setLeftComponent(jSplitPane2);

    jSplitPane1.setDividerLocation(500);
    jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);

    fileDisplayScroll.setFont(new Font("", 0, 12)); // NOI18N
    fileDisplayScroll.setMinimumSize(new Dimension(30, 30));

    fileContentArea.setEditable(false);
    fileContentArea.setColumns(20);
    fileContentArea.setFont(new Font("", 0, 12)); // NOI18N
    fileContentArea.setRows(5);
    fileContentArea.setToolTipText("");
    fileContentArea
            .setBorder(BorderFactory.createTitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION,
                    TitledBorder.DEFAULT_POSITION, new Font("", 0, 12))); // NOI18N
    fileDisplayScroll.setViewportView(fileContentArea);

    jSplitPane1.setTopComponent(fileDisplayScroll);

    noteInputScroll.setFont(new Font("", 0, 12)); // NOI18N
    noteInputScroll.setMaximumSize(new Dimension(1366, 768));
    noteInputScroll.setMinimumSize(new Dimension(30, 30));

    noteInputArea.setColumns(20);
    noteInputArea.setFont(new Font("", 0, 12)); // NOI18N
    noteInputArea.setRows(5);
    noteInputArea.setToolTipText("");
    noteInputArea
            .setBorder(BorderFactory.createTitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION,
                    TitledBorder.DEFAULT_POSITION, new Font("", 0, 12))); // NOI18N
    noteInputScroll.setViewportView(noteInputArea);

    jSplitPane1.setBottomComponent(noteInputScroll);

    fileSplitPane.setRightComponent(jSplitPane1);

    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
            .createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(fileSplitPane, GroupLayout.DEFAULT_SIZE, 1346, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                            .addComponent(fileButtonPane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, Short.MAX_VALUE)))
            .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                    .addComponent(fileButtonPane, GroupLayout.PREFERRED_SIZE, 38, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(fileSplitPane,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));
}

From source file:com.mirth.connect.client.ui.editors.filter.FilterPane.java

public void makeFilterTable() {
    filterTable = new MirthTable();

    filterTable.setModel(new DefaultTableModel(new String[] { "#", "Operator", "Name", "Type", "Data" }, 0) {

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            boolean[] canEdit;
            FilterRulePlugin plugin;/*from   w w  w  . j  av a2  s.  c om*/
            try {
                plugin = getPlugin((String) filterTableModel.getValueAt(rowIndex, RULE_TYPE_COL));
                canEdit = new boolean[] { false, true, plugin.isNameEditable(), true, true };
            } catch (Exception e) {
                canEdit = new boolean[] { false, true, true, true, true };
            }
            return canEdit[columnIndex];
        }
    });

    filterTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

    filterTableModel = (DefaultTableModel) filterTable.getModel();

    filterTable.getColumnModel().getColumn(RULE_NAME_COL).setCellEditor(new EditorTableCellEditor(this));
    filterTable.setCustomEditorControls(true);

    // Set the combobox editor on the operator column, and add action
    // listener
    MirthComboBoxTableCellEditor comboBoxOp = new MirthComboBoxTableCellEditor(filterTable, comboBoxValues, 2,
            true, new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    modified = true;
                    updateOperations();
                }
            });

    // Set the combobox editor on the type column, and add action listener
    String[] defaultComboBoxValues = new String[LoadedExtensions.getInstance().getFilterRulePlugins().size()];
    FilterRulePlugin[] pluginArray = LoadedExtensions.getInstance().getFilterRulePlugins().values()
            .toArray(new FilterRulePlugin[0]);
    for (int i = 0; i < pluginArray.length; i++) {
        defaultComboBoxValues[i] = pluginArray[i].getPluginPointName();
    }

    MirthComboBoxTableCellEditor comboBoxType = new MirthComboBoxTableCellEditor(filterTable,
            defaultComboBoxValues, 2, true, new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent evt) {
                    if (filterTable.getEditingRow() != -1) {
                        int row = getSelectedRow();
                        String selectedType = ((JComboBox) evt.getSource()).getSelectedItem().toString();
                        String previousType = (String) filterTable.getValueAt(row, RULE_TYPE_COL);

                        if (selectedType.equalsIgnoreCase(previousType)) {
                            return;
                        }

                        modified = true;
                        FilterRulePlugin plugin;
                        try {
                            if (rulePanel.isModified() && !PlatformUI.MIRTH_FRAME.alertOption(
                                    PlatformUI.MIRTH_FRAME,
                                    "Are you sure you would like to change this filter rule and lose all of the current filter data?")) {
                                ((JComboBox) evt.getSource()).getModel().setSelectedItem(previousType);
                                return;
                            }

                            plugin = getPlugin(selectedType);
                            plugin.initData();
                            filterTableModel.setValueAt(plugin.getNewName(), row, RULE_NAME_COL);
                            rulePanel.showCard(selectedType);
                            updateTaskPane(selectedType);
                            updateCodePanel(selectedType);
                        } catch (Exception e) {
                            parent.alertThrowable(parent, e);
                        }

                    }
                }
            });

    filterTable.setSelectionMode(0); // only select one row at a time

    filterTable.getColumnExt(RULE_NUMBER_COL).setMaxWidth(UIConstants.MAX_WIDTH);
    filterTable.getColumnExt(RULE_OP_COL).setMaxWidth(UIConstants.MAX_WIDTH);

    filterTable.getColumnExt(RULE_NUMBER_COL).setPreferredWidth(30);
    filterTable.getColumnExt(RULE_OP_COL).setPreferredWidth(60);

    filterTable.getColumnExt(RULE_NUMBER_COL).setCellRenderer(new CenterCellRenderer());
    filterTable.getColumnExt(RULE_OP_COL).setCellEditor(comboBoxOp);
    filterTable.getColumnExt(RULE_OP_COL).setCellRenderer(new MirthComboBoxTableCellRenderer(comboBoxValues) {
        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            if (value instanceof String && value.equals("")) {
                value = null;
            } else if (value != null) {
                value = value.toString();
            }

            return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        }
    });

    filterTable.getColumnExt(RULE_TYPE_COL).setMaxWidth(UIConstants.MAX_WIDTH);
    filterTable.getColumnExt(RULE_TYPE_COL).setMinWidth(120);
    filterTable.getColumnExt(RULE_TYPE_COL).setPreferredWidth(120);
    filterTable.getColumnExt(RULE_TYPE_COL).setCellEditor(comboBoxType);
    filterTable.getColumnExt(RULE_TYPE_COL)
            .setCellRenderer(new MirthComboBoxTableCellRenderer(defaultComboBoxValues));

    filterTable.getColumnExt(RULE_DATA_COL).setVisible(false);

    filterTable.setRowHeight(UIConstants.ROW_HEIGHT);
    filterTable.packTable(UIConstants.COL_MARGIN);
    filterTable.setSortable(false);
    filterTable.setOpaque(true);
    filterTable.setRowSelectionAllowed(true);
    filterTable.setDragEnabled(false);
    filterTable.getTableHeader().setReorderingAllowed(false);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR);
        filterTable.setHighlighters(highlighter);
    }

    filterTable.setDropTarget(dropTarget);
    filterTablePane.setDropTarget(dropTarget);

    filterTable.setBorder(BorderFactory.createEmptyBorder());
    filterTablePane.setBorder(BorderFactory.createEmptyBorder());

    filterTablePane.setViewportView(filterTable);

    filterTable.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent evt) {
            checkSelectionAndPopupMenu(evt);
        }

        public void mouseReleased(MouseEvent evt) {
            checkSelectionAndPopupMenu(evt);
        }
    });

    filterTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent evt) {
            if (!updating && !evt.getValueIsAdjusting()) {
                FilterListSelected(evt);
                updateCodePanel(null);
            }
        }
    });
    filterTable.addKeyListener(new KeyListener() {
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                deleteRule();
            }
        }

        public void keyReleased(KeyEvent e) {
        }

        public void keyTyped(KeyEvent e) {
        }
    });
}

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

private void enableSelection() {
    chartPanel.addMouseListener(new SelectionMouseListener(seriesSelectionModel, true) {
        @Override//from w w  w  .j  a  v  a  2s. c  om
        public void mousePressed(MouseEvent e) {
            if (isInteractive()) {
                super.mousePressed(e);
            }
        }

        @Override
        protected int getSelectionIndex(LegendItemEntity entity) {
            return entity != null ? dataset.indexOf(entity.getSeriesKey()) : -1;
        }
    });
    seriesSelectionModel.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                notification.forceRefresh();
            }
        }
    });
}

From source file:com.mirth.connect.client.ui.browsers.event.EventBrowser.java

/**
 * Creates the table with all of the information given after being filtered by the specified
 * 'filter'//from  w w w.  jav a 2s.c o  m
 */
private void makeEventTable() {
    updateEventTable(null);

    eventTable.setSelectionMode(0);
    eventTable.setMirthColumnControlEnabled(true);
    eventTable.restoreColumnPreferences();

    eventTable.getColumnExt(EVENT_LEVEL_COLUMN_NAME)
            .setCellRenderer(new ImageCellRenderer(SwingConstants.CENTER));
    eventTable.getColumnExt(EVENT_OUTCOME_COLUMN_NAME)
            .setCellRenderer(new ImageCellRenderer(SwingConstants.CENTER));

    eventTable.getColumnExt(EVENT_ID_COLUMN_NAME).setVisible(false);

    DateCellRenderer dateCellRenderer = new DateCellRenderer();
    dateCellRenderer.setDateFormat(new SimpleDateFormat(DATE_FORMAT));

    eventTable.getColumnExt(EVENT_DATE_COLUMN_NAME).setCellRenderer(dateCellRenderer);
    eventTable.getColumnExt(EVENT_DATE_COLUMN_NAME).setMinWidth(140);
    eventTable.getColumnExt(EVENT_DATE_COLUMN_NAME).setMaxWidth(140);
    eventTable.getColumnExt(EVENT_LEVEL_COLUMN_NAME).setMinWidth(50);
    eventTable.getColumnExt(EVENT_LEVEL_COLUMN_NAME).setMaxWidth(50);
    eventTable.getColumnExt(EVENT_SERVER_ID_COLUMN_NAME).setMinWidth(220);
    eventTable.getColumnExt(EVENT_SERVER_ID_COLUMN_NAME).setMaxWidth(220);
    eventTable.getColumnExt(EVENT_OUTCOME_COLUMN_NAME).setMinWidth(65);
    eventTable.getColumnExt(EVENT_OUTCOME_COLUMN_NAME).setMaxWidth(65);

    eventTable.setRowHeight(UIConstants.ROW_HEIGHT);
    eventTable.setOpaque(true);
    eventTable.setRowSelectionAllowed(true);
    deselectRows();

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR);
        eventTable.setHighlighters(highlighter);
    }

    eventPane.setViewportView(eventTable);
    eventSplitPane.setLeftComponent(eventPane);

    eventTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent evt) {
            EventListSelected(evt);
        }
    });

    eventTable.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mousePressed(java.awt.event.MouseEvent evt) {
            checkSelectionAndPopupMenu(evt);
        }

        public void mouseReleased(java.awt.event.MouseEvent evt) {
            checkSelectionAndPopupMenu(evt);
        }
    });

    // Set highlighter.
    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR);
        eventTable.setHighlighters(highlighter);
    }
}

From source file:com.mirth.connect.client.ui.editors.transformer.TransformerPane.java

public void makeTransformerTable() {
    transformerTable = new MirthTable();
    transformerTable.setBorder(BorderFactory.createEmptyBorder());

    // Data Column is hidden
    transformerTable.setModel(new DefaultTableModel(new String[] { "#", "Name", "Type", "Data" }, 0) {

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            boolean[] canEdit;
            TransformerStepPlugin plugin;
            try {
                plugin = getPlugin((String) transformerTableModel.getValueAt(rowIndex, STEP_TYPE_COL));
                canEdit = new boolean[] { false, plugin.isNameEditable(), true, true };
            } catch (Exception e) {
                canEdit = new boolean[] { false, false, true, true };
            }/*from  www .  j a  va  2  s  .c  o m*/
            return canEdit[columnIndex];
        }
    });

    transformerTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

    transformerTableModel = (DefaultTableModel) transformerTable.getModel();

    transformerTable.getColumnModel().getColumn(STEP_NAME_COL).setCellEditor(new EditorTableCellEditor(this));
    transformerTable.setCustomEditorControls(true);

    // Set the combobox editor on the type column, and add action listener
    String[] defaultComboBoxValues = new String[LoadedExtensions.getInstance().getTransformerStepPlugins()
            .size()];
    TransformerStepPlugin[] pluginArray = LoadedExtensions.getInstance().getTransformerStepPlugins().values()
            .toArray(new TransformerStepPlugin[0]);
    for (int i = 0; i < pluginArray.length; i++) {
        defaultComboBoxValues[i] = pluginArray[i].getPluginPointName();
    }

    MirthComboBoxTableCellEditor comboBox = new MirthComboBoxTableCellEditor(transformerTable,
            defaultComboBoxValues, 2, true, new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent evt) {
                    if (transformerTable.getEditingRow() != -1) {
                        int row = getSelectedRow();
                        String selectedType = ((JComboBox) evt.getSource()).getSelectedItem().toString();
                        String previousType = (String) transformerTable.getValueAt(row, STEP_TYPE_COL);

                        if (selectedType.equalsIgnoreCase(previousType)) {
                            return;
                        }

                        modified = true;
                        invalidVar = false;
                        TransformerStepPlugin plugin = null;
                        try {

                            if (stepPanel.isModified() && !PlatformUI.MIRTH_FRAME.alertOption(
                                    PlatformUI.MIRTH_FRAME,
                                    "Are you sure you would like to change this transformer step and lose all of the current transformer data?")) {
                                ((JComboBox) evt.getSource()).getModel().setSelectedItem(previousType);
                                return;
                            }

                            plugin = getPlugin(selectedType);
                            plugin.initData();
                            transformerTableModel.setValueAt(plugin.getNewName(), row, STEP_NAME_COL);
                            stepPanel.showCard(selectedType);
                            updateTaskPane(selectedType);
                            updateCodePanel(selectedType);
                        } catch (Exception e) {
                            parent.alertThrowable(PlatformUI.MIRTH_FRAME, e);
                        }
                    }
                }
            });

    transformerTable.setSelectionMode(0); // only select one row at a time

    transformerTable.getColumnExt(STEP_NUMBER_COL).setMaxWidth(UIConstants.MAX_WIDTH);
    transformerTable.getColumnExt(STEP_TYPE_COL).setMaxWidth(UIConstants.MAX_WIDTH);
    transformerTable.getColumnExt(STEP_TYPE_COL).setMinWidth(120);

    transformerTable.getColumnExt(STEP_NUMBER_COL).setPreferredWidth(30);
    transformerTable.getColumnExt(STEP_TYPE_COL).setPreferredWidth(120);

    transformerTable.getColumnExt(STEP_NUMBER_COL).setCellRenderer(new CenterCellRenderer());
    transformerTable.getColumnExt(STEP_TYPE_COL).setCellEditor(comboBox);
    transformerTable.getColumnExt(STEP_TYPE_COL)
            .setCellRenderer(new MirthComboBoxTableCellRenderer(defaultComboBoxValues));

    transformerTable.getColumnExt(STEP_DATA_COL).setVisible(false);

    transformerTable.setRowHeight(UIConstants.ROW_HEIGHT);
    transformerTable.packTable(UIConstants.COL_MARGIN);
    transformerTable.setSortable(false);
    transformerTable.setOpaque(true);
    transformerTable.setRowSelectionAllowed(true);
    transformerTable.setDragEnabled(false);
    transformerTable.getTableHeader().setReorderingAllowed(false);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR);
        transformerTable.setHighlighters(highlighter);
    }

    transformerTable.setDropTarget(dropTarget);
    transformerTablePane.setDropTarget(dropTarget);

    transformerTable.setBorder(BorderFactory.createEmptyBorder());
    transformerTablePane.setBorder(BorderFactory.createEmptyBorder());
    transformerTablePane.setViewportView(transformerTable);

    // listen for mouse clicks on the actual table
    transformerTable.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent evt) {
            checkSelectionAndPopupMenu(evt);
        }

        public void mouseReleased(MouseEvent evt) {
            checkSelectionAndPopupMenu(evt);
        }
    });

    transformerTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent evt) {
            if (!updating && !evt.getValueIsAdjusting()) {
                TransformerListSelected(evt);
                updateCodePanel(null);
            }
        }
    });
    transformerTable.addKeyListener(new KeyListener() {
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                deleteStep();
            }
        }

        public void keyReleased(KeyEvent e) {
        }

        public void keyTyped(KeyEvent e) {
        }
    });
}

From source file:com.diversityarrays.kdxplore.trialmgr.trait.TraitExplorerPanel.java

public TraitExplorerPanel(MessagePrinter mp, OfflineData od, DALClientProvider clientProvider,
        // KdxUploadHandler uploadHandler,
        BackgroundRunner backgroundRunner, ImageIcon addBarcodeIcon,
        Transformer<Trial, Boolean> checkIfEditorActive) {
    super(new BorderLayout());

    this.backgroundRunner = backgroundRunner;
    this.clientProvider = clientProvider;
    // this.uploadHandler = uploadHandler;
    this.messagePrinter = mp;
    this.offlineData = od;
    this.checkIfEditorActive = checkIfEditorActive;

    offlineData.addOfflineDataChangeListener(offlineDataListener);

    editingLocked.setIcon(KDClientUtils.getIcon(ImageId.LOCKED));
    editingLocked.addActionListener(new ActionListener() {
        @Override/*from w ww . jav a 2  s .  c o  m*/
        public void actionPerformed(ActionEvent e) {
            changeEditable(editingLocked.isSelected(), DONT_OVERRIDE);
        }
    });

    changeManager.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            updateUndoRedoActions();
        }
    });

    KDClientUtils.initAction(ImageId.TRASH_24, deleteTraitsAction, "Remove Trait");
    deleteTraitsAction.setEnabled(false);

    KDClientUtils.initAction(ImageId.REFRESH_24, refreshAction, "Refresh Data");

    KDClientUtils.initAction(ImageId.PLUS_BLUE_24, addNewTraitAction, "Add Trait");

    KDClientUtils.initAction(ImageId.UPLOAD_24, uploadTraitsAction, "Upload Traits");

    KDClientUtils.initAction(ImageId.ADD_TRIALS_24, importTraitsAction, "Import Traits");

    KDClientUtils.initAction(ImageId.EXPORT_24, exportTraitsAction, "Export Traits");

    try {
        Class.forName("com.diversityarrays.kdxplore.upload.TraitUploadTask");
    } catch (ClassNotFoundException e1) {
        uploadTraitsAction.setEnabled(false);
        if (RunMode.getRunMode().isDeveloper()) {
            new Toast((JComponent) null,
                    "<HTML>Developer Warning<BR>" + "Trait Upload currently unavailable<BR>", 4000)
                            .showAsError();
        }
    }

    traitPropertiesTable
            .setTransferHandler(TableTransferHandler.initialiseForCopySelectAll(traitPropertiesTable, true));
    traitPropertiesTableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            if (traitPropertiesTableModel.getRowCount() > 0) {
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        GuiUtil.initialiseTableColumnWidths(traitPropertiesTable);
                    }
                });
                traitPropertiesTableModel.removeTableModelListener(this);
            }
        }
    });

    traitTableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            showCorrectCard();
        }
    });

    TrialManagerPreferences preferences = TrialManagerPreferences.getInstance();
    preferences.addChangeListener(TrialManagerPreferences.BAD_FOR_CALC, badForCalcColorChangeListener);
    badForCalc.setForeground(preferences.getBadForCalcColor());
    badForCalc.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isLeftMouseButton(e)) {
                KdxPreference<Color> pref = TrialManagerPreferences.BAD_FOR_CALC;
                String title = pref.getName();
                KdxplorePreferenceEditor.startEditorDialog(TraitExplorerPanel.this, title, pref);
            }
        }
    });

    traitsTable.setAutoCreateRowSorter(true);
    int index = traitTableModel.getTraitNameColumnIndex();
    if (index >= 0) {
        traitsTable.getColumnModel().getColumn(index).setCellRenderer(traitNameCellRenderer);
    }

    traitsTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isLeftMouseButton(e) && 2 == e.getClickCount()) {
                e.consume();

                int vrow = traitsTable.rowAtPoint(e.getPoint());
                if (vrow >= 0) {
                    int mrow = traitsTable.convertRowIndexToModel(vrow);
                    if (mrow >= 0) {
                        Trait trait = traitTableModel.getTraitAtRow(mrow);
                        Integer selectViewRow = null;
                        if (!traitTrialsTableModel.isSelectedTrait(trait)) {
                            selectViewRow = vrow;
                        }
                        if (traitsEditable) {
                            startEditingTraitInternal(trait, selectViewRow, null);
                        } else {
                            warnEditingLocked();
                        }
                    }
                }
            }
        }
    });

    traitsTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    traitsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {

                List<Trait> selectedTraits = getSelectedTraits();
                traitTrialsTableModel.setSelectedTraits(selectedTraits);

                if (selectedTraits.size() == 1) {
                    Trait trait = null;
                    int vrow = traitsTable.getSelectedRow();
                    if (vrow >= 0) {
                        int mrow = traitsTable.convertRowIndexToModel(vrow);
                        if (mrow >= 0) {
                            trait = traitTableModel.getEntityAt(mrow);
                        }
                    }
                    showTraitDetails(trait);
                }

                deleteTraitsAction.setEnabled(selectedTraits.size() > 0);

                showCorrectCard();
            }
        }
    });

    TraitTableModel.initValidationExpressionRenderer(traitsTable);
    if (RunMode.getRunMode().isDeveloper()) {
        TraitTableModel.initTableForRawExpression(traitsTable);
    }
    cardPanel.add(noTraitsComponent, CARD_NO_TRAITS);
    cardPanel.add(selectTraitComponent, CARD_SELECT_TO_EDIT);
    cardPanel.add(new JScrollPane(traitPropertiesTable), CARD_TRAIT_EDITOR);

    JButton undoButton = initAction(undoAction, ImageId.UNDO_24, "Undo",
            KeyStroke.getKeyStroke('Z', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    JButton redoButton = initAction(redoAction, ImageId.REDO_24, "Redo",
            KeyStroke.getKeyStroke('Y', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    Box undoRedoButtons = Box.createHorizontalBox();
    undoRedoButtons.add(undoButton);
    undoRedoButtons.add(redoButton);

    JPanel detailsPanel = new JPanel(new BorderLayout());
    detailsPanel.add(GuiUtil.createLabelSeparator("Details", undoRedoButtons), BorderLayout.NORTH);
    detailsPanel.add(cardPanel, BorderLayout.CENTER);
    detailsPanel.add(legendPanel, BorderLayout.SOUTH);

    PromptScrollPane scrollPane = new PromptScrollPane(traitsTable,
            "Drag/Drop Traits CSV file or use 'Import Traits'");

    TableTransferHandler tth = TableTransferHandler.initialiseForCopySelectAll(traitsTable, true);
    traitsTable.setTransferHandler(new ChainingTransferHandler(flth, tth));

    scrollPane.setTransferHandler(flth);

    if (addBarcodeIcon == null) {
        barcodesMenuAction.putValue(Action.NAME, "Barcodes...");
    } else {
        barcodesMenuAction.putValue(Action.SMALL_ICON, addBarcodeIcon);
    }

    italicsForProtectedCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            traitNameCellRenderer.setUseItalicsForProtected(italicsForProtectedCheckbox.isSelected());
            traitsTable.repaint();
        }
    });

    Box leftTopControls = Box.createHorizontalBox();
    leftTopControls.add(importTraitsButton);
    leftTopControls.add(barcodesMenuButton);
    leftTopControls.add(new JButton(addNewTraitAction));
    leftTopControls.add(new JButton(uploadTraitsAction));
    leftTopControls.add(new JButton(exportTraitsAction));

    leftTopControls.add(Box.createHorizontalGlue());

    leftTopControls.add(editingLocked);
    leftTopControls.add(fixTraitLevelsButton);
    leftTopControls.add(refreshButton);
    leftTopControls.add(Box.createHorizontalStrut(8));
    leftTopControls.add(new JButton(deleteTraitsAction));
    // leftTopControls.add(Box.createHorizontalStrut(4));

    Box explanations = Box.createHorizontalBox();
    explanations.add(italicsForProtectedCheckbox);
    explanations.add(badForCalc);
    explanations.add(Box.createHorizontalGlue());

    fixTraitLevelsButton.setToolTipText("Fix Traits with " + TraitLevel.UNDECIDABLE.visible + " 'Level'");
    fixTraitLevelsButton.setVisible(false);

    JPanel leftTop = new JPanel(new BorderLayout());
    leftTop.add(leftTopControls, BorderLayout.NORTH);
    leftTop.add(scrollPane, BorderLayout.CENTER);
    leftTop.add(explanations, BorderLayout.SOUTH);

    JPanel leftBot = new JPanel(new BorderLayout());
    leftBot.add(GuiUtil.createLabelSeparator("Used by Trials"), BorderLayout.NORTH);
    leftBot.add(new PromptScrollPane(traitTrialsTable, "Any Trials using selected Traits appear here"));

    JSplitPane leftSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, leftTop, leftBot);
    leftSplit.setResizeWeight(0.5);

    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftSplit, detailsPanel);
    splitPane.setOneTouchExpandable(true);
    splitPane.setResizeWeight(0.5);

    add(splitPane, BorderLayout.CENTER);
}

From source file:at.becast.youploader.gui.FrmMain.java

public void initPlaylistSettingsTab() {
    JPanel TabPlaylistSettings = new JPanel();
    TabbedPane.addTab(LANG.getString("frmMain.Tabs.PlaylistSettings"), null, TabPlaylistSettings, null);

    JPanel panel_1 = new JPanel();

    JScrollPane scrollPane = new JScrollPane();
    GroupLayout gl_TabPlaylistSettings = new GroupLayout(TabPlaylistSettings);
    gl_TabPlaylistSettings.setHorizontalGroup(gl_TabPlaylistSettings.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_TabPlaylistSettings.createSequentialGroup()
                    .addComponent(panel_1, GroupLayout.DEFAULT_SIZE, 188, Short.MAX_VALUE).addGap(8)
                    .addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 675, Short.MAX_VALUE)
                    .addContainerGap()));
    gl_TabPlaylistSettings.setVerticalGroup(gl_TabPlaylistSettings.createParallelGroup(Alignment.TRAILING)
            .addGroup(gl_TabPlaylistSettings.createSequentialGroup()
                    .addGroup(gl_TabPlaylistSettings.createParallelGroup(Alignment.LEADING)
                            .addComponent(panel_1, GroupLayout.DEFAULT_SIZE, 459, Short.MAX_VALUE)
                            .addGroup(gl_TabPlaylistSettings.createSequentialGroup().addGap(11)
                                    .addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 448, Short.MAX_VALUE)))
                    .addContainerGap()));

    PlayPanel = new JPanel();
    scrollPane.setViewportView(PlayPanel);
    PlayPanel.setLayout(new GridLayout(0, 2, 0, 0));

    AccList = new JList<AccountType>(AccListModel);
    AccList.setOpaque(false);/*from   w w  w.  java  2s. c  o  m*/
    AccList.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
    AccList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    GroupLayout gl_panel_1 = new GroupLayout(panel_1);
    gl_panel_1.setHorizontalGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panel_1.createSequentialGroup().addContainerGap()
                    .addComponent(AccList, GroupLayout.DEFAULT_SIZE, 177, Short.MAX_VALUE).addContainerGap()));
    gl_panel_1.setVerticalGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panel_1.createSequentialGroup().addContainerGap()
                    .addComponent(AccList, GroupLayout.DEFAULT_SIZE, 437, Short.MAX_VALUE).addContainerGap()));
    panel_1.setLayout(gl_panel_1);
    TabPlaylistSettings.setLayout(gl_TabPlaylistSettings);
    AccList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            selectPlaylistAccount();
        }
    });
}

From source file:gtu._work.ui.SvnLastestCommitInfoUI.java

private void initGUI() {
    try {/*from  ww  w  .  jav a  2  s .  co  m*/
        BorderLayout thisLayout = new BorderLayout();
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(thisLayout);
        this.setFocusable(false);
        this.setTitle("SVN lastest commit wather");
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("svn dir", null, jPanel1, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    {
                        TableModel svnTableModel = new DefaultTableModel();
                        svnTable = new JTable();
                        jScrollPane1.setViewportView(svnTable);
                        svnTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                try {
                                    if (evt.getButton() == 3) {
                                        final List<File> list = new ArrayList<File>();
                                        SvnFile svnFile = null;
                                        final StringBuilder sb = new StringBuilder();
                                        for (int row : svnTable.getSelectedRows()) {
                                            svnFile = (SvnFile) svnTable.getModel().getValueAt(
                                                    svnTable.getRowSorter().convertRowIndexToModel(row),
                                                    SvnTableColumn.SVN_FILE.pos);
                                            list.add(svnFile.file);
                                            sb.append(svnFile.file.getName() + ",");
                                        }
                                        if (sb.length() > 200) {
                                            sb.delete(200, sb.length() - 1);
                                        }
                                        JMenuItem copySelectedMeun = new JMenuItem();
                                        copySelectedMeun.setText("copy selected file : " + list.size());
                                        copySelectedMeun.addActionListener(new ActionListener() {
                                            public void actionPerformed(ActionEvent e) {
                                                if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION != JOptionPaneUtil
                                                        .newInstance().iconPlainMessage().confirmButtonYesNo()
                                                        .showConfirmDialog(
                                                                "are you sure copy files :\n" + sb + "\n???",
                                                                "COPY SELECTED FILE : " + list.size())) {
                                                    return;
                                                }
                                                final File copyToDir = JFileChooserUtil.newInstance()
                                                        .selectDirectoryOnly().showOpenDialog()
                                                        .getApproveSelectedFile();
                                                if (copyToDir == null) {
                                                    JOptionPaneUtil.newInstance().iconErrorMessage()
                                                            .showMessageDialog("dir folder is not correct!",
                                                                    "ERROR");
                                                    return;
                                                }
                                                new Thread(Thread.currentThread().getThreadGroup(),
                                                        new Runnable() {
                                                            public void run() {
                                                                StringBuilder errMsg = new StringBuilder();
                                                                int errCount = 0;
                                                                for (File f : list) {
                                                                    try {
                                                                        FileUtil.copyFile(f, new File(copyToDir,
                                                                                f.getName()));
                                                                    } catch (IOException e) {
                                                                        e.printStackTrace();
                                                                        errCount++;
                                                                        errMsg.append(f + "\n");
                                                                    }
                                                                }

                                                                JOptionPaneUtil.newInstance().iconPlainMessage()
                                                                        .showMessageDialog(
                                                                                "copy completed!\nerror : "
                                                                                        + errCount
                                                                                        + "\nerror list : \n"
                                                                                        + errMsg,
                                                                                "COMPLETED");
                                                            }
                                                        }, "copySelectedFiles_" + hashCode()).start();
                                            }
                                        });

                                        JMenuItem copySelectedOringTreeMeun = new JMenuItem();
                                        copySelectedOringTreeMeun
                                                .setText("copy selected file (orign tree): " + list.size());
                                        copySelectedOringTreeMeun.addActionListener(new ActionListener() {
                                            public void actionPerformed(ActionEvent e) {
                                                if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION != JOptionPaneUtil
                                                        .newInstance().iconPlainMessage().confirmButtonYesNo()
                                                        .showConfirmDialog(
                                                                "are you sure copy files :\n" + sb + "\n???",
                                                                "COPY SELECTED FILE : " + list.size())) {
                                                    return;
                                                }
                                                final File copyToDir = JFileChooserUtil.newInstance()
                                                        .selectDirectoryOnly().showOpenDialog()
                                                        .getApproveSelectedFile();
                                                if (copyToDir == null) {
                                                    JOptionPaneUtil.newInstance().iconErrorMessage()
                                                            .showMessageDialog("dir folder is not correct!",
                                                                    "ERROR");
                                                    return;
                                                }
                                                new Thread(Thread.currentThread().getThreadGroup(),
                                                        new Runnable() {
                                                            public void run() {
                                                                File srcBaseDir = FileUtil
                                                                        .exportReceiveBaseDir(list);
                                                                int cutLength = 0;
                                                                if (srcBaseDir != null) {
                                                                    cutLength = srcBaseDir.getAbsolutePath()
                                                                            .length();
                                                                }

                                                                StringBuilder errMsg = new StringBuilder();
                                                                int errCount = 0;
                                                                File newFile = null;
                                                                for (File f : list) {
                                                                    try {
                                                                        newFile = new File(copyToDir + "/"
                                                                                + f.getAbsolutePath()
                                                                                        .substring(cutLength),
                                                                                f.getName());
                                                                        newFile.getParentFile().mkdirs();
                                                                        FileUtil.copyFile(f, newFile);
                                                                    } catch (IOException e) {
                                                                        e.printStackTrace();
                                                                        errCount++;
                                                                        errMsg.append(f + "\n");
                                                                    }
                                                                }

                                                                JOptionPaneUtil.newInstance().iconPlainMessage()
                                                                        .showMessageDialog(
                                                                                "copy completed!\nerror : "
                                                                                        + errCount
                                                                                        + "\nerror list : \n"
                                                                                        + errMsg,
                                                                                "COMPLETED");
                                                            }
                                                        }, "copySelectedFiles_orignTree_" + hashCode()).start();
                                            }
                                        });

                                        JPopupMenuUtil.newInstance(svnTable).applyEvent(evt)
                                                .addJMenuItem(copySelectedMeun, copySelectedOringTreeMeun)
                                                .show();
                                    }

                                    if (!JMouseEventUtil.buttonLeftClick(2, evt)) {
                                        return;
                                    }
                                    int row = JTableUtil.newInstance(svnTable).getSelectedRow();
                                    SvnFile svnFile = (SvnFile) svnTable.getModel().getValueAt(row,
                                            SvnTableColumn.SVN_FILE.pos);
                                    String command = String.format("cmd /c call \"%s\"", svnFile.file);
                                    System.out.println(command);
                                    try {
                                        Runtime.getRuntime().exec(command);
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                } catch (Exception ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        });
                        svnTable.setModel(svnTableModel);
                        JTableUtil.defaultSetting(svnTable);
                    }
                }
                {
                    jPanel3 = new JPanel();
                    jPanel1.add(jPanel3, BorderLayout.NORTH);
                    jPanel3.setPreferredSize(new java.awt.Dimension(379, 35));
                    {
                        filterText = new JTextField();
                        jPanel3.add(filterText);
                        filterText.setPreferredSize(new java.awt.Dimension(258, 24));
                        filterText.getDocument()
                                .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() {
                                    public void process(DocumentEvent event) {
                                        try {
                                            String scanText = JCommonUtil.getDocumentText(event);
                                            reloadSvnTable(scanText, _defaultScanProcess);
                                        } catch (Exception ex) {
                                            JCommonUtil.handleException(ex);
                                        }
                                    }
                                }));
                    }
                    {
                        choiceSvnDir = new JButton();
                        jPanel3.add(choiceSvnDir);
                        choiceSvnDir.setText("choice svn dir");
                        choiceSvnDir.setPreferredSize(new java.awt.Dimension(154, 24));
                        choiceSvnDir.addActionListener(new ActionListener() {

                            Pattern svnOutputPattern = Pattern
                                    .compile("\\s*(\\d*)\\s+(\\d+)\\s+(\\w+)\\s+([\\S]+)");

                            public void actionPerformed(ActionEvent evt) {
                                try {
                                    System.out.println("choiceSvnDir.actionPerformed, event=" + evt);
                                    final File svnDir = JFileChooserUtil.newInstance().selectDirectoryOnly()
                                            .showOpenDialog().getApproveSelectedFile();
                                    if (svnDir == null) {
                                        JOptionPaneUtil.newInstance().iconErrorMessage()
                                                .showMessageDialog("dir is not correct!", "ERROR");
                                        return;
                                    }
                                    Thread thread = new Thread(Thread.currentThread().getThreadGroup(),
                                            new Runnable() {
                                                public void run() {
                                                    long startTime = System.currentTimeMillis();
                                                    String command = String
                                                            .format("cmd /c svn status -v \"%s\"", svnDir);
                                                    Matcher matcher = null;
                                                    try {
                                                        long projectLastestVersion = 0;
                                                        SvnFile svnFile = null;
                                                        Process process = Runtime.getRuntime().exec(command);
                                                        BufferedReader reader = new BufferedReader(
                                                                new InputStreamReader(process.getInputStream(),
                                                                        "BIG5"));
                                                        for (String line = null; (line = reader
                                                                .readLine()) != null;) {
                                                            matcher = svnOutputPattern.matcher(line);
                                                            if (matcher.find()) {
                                                                try {
                                                                    if (StringUtils
                                                                            .isNotBlank(matcher.group(1))) {
                                                                        projectLastestVersion = Math.max(
                                                                                projectLastestVersion,
                                                                                Long.parseLong(
                                                                                        matcher.group(1)));
                                                                    }
                                                                    svnFile = new SvnFile();
                                                                    svnFile.lastestVersion = Long
                                                                            .parseLong(matcher.group(2));
                                                                    svnFile.author = matcher.group(3);
                                                                    svnFile.filePath = matcher.group(4);
                                                                    svnFile.file = new File(svnFile.filePath);
                                                                    svnFile.fileName = svnFile.file.getName();
                                                                    svnFileSet.add(svnFile);
                                                                    authorSet.add(svnFile.author);
                                                                    String extension = null;
                                                                    if (svnFile.file.isFile()
                                                                            && (extension = getExtension(
                                                                                    svnFile.fileName)) != null) {
                                                                        fileExtenstionSet.add(extension);
                                                                    }
                                                                } catch (Exception ex) {
                                                                    ex.printStackTrace();
                                                                }
                                                            } else {
                                                                System.out.println("ignore : " + line);
                                                            }
                                                        }
                                                        reader.close();
                                                        lastestVersion = projectLastestVersion;
                                                        projectName = svnDir.getName();
                                                        resetUiAndShowMessage(startTime, projectName,
                                                                projectLastestVersion);
                                                    } catch (IOException e) {
                                                        JCommonUtil.handleException(e);
                                                    }
                                                }
                                            }, "loadSvnLastest_" + this.hashCode());
                                    thread.setDaemon(true);
                                    thread.start();
                                    setTitle("sweeping...");
                                } catch (Exception ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }

                            String getExtension(String name) {
                                int pos = -1;
                                if ((pos = name.lastIndexOf(".")) != -1) {
                                    return name.substring(pos).toLowerCase();
                                }
                                return null;
                            }
                        });
                    }
                    {
                        jLabel1 = new JLabel();
                        jPanel3.add(jLabel1);
                        jLabel1.setText("match :");
                        jLabel1.setPreferredSize(new java.awt.Dimension(56, 22));
                    }
                    {
                        matchCount = new JLabel();
                        jPanel3.add(matchCount);
                        matchCount.setPreferredSize(new java.awt.Dimension(82, 22));
                    }
                }
            }
            {
                jPanel2 = new JPanel();
                FlowLayout jPanel2Layout = new FlowLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("config", null, jPanel2, null);
                {
                    DefaultComboBoxModel authorComboBoxModel = new DefaultComboBoxModel();
                    authorComboBox = new JComboBox();
                    jPanel2.add(authorComboBox);
                    authorComboBox.setModel(authorComboBoxModel);
                    authorComboBox.setPreferredSize(new java.awt.Dimension(260, 24));
                    authorComboBox.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            try {
                                Object author = authorComboBox.getSelectedItem();
                                if (author instanceof Map.Entry) {
                                    Map.Entry<?, ?> entry = (Map.Entry<?, ?>) author;
                                    reloadSvnTable((String) entry.getKey(), _authorScanProcess);
                                } else {
                                    reloadSvnTable((String) author, _authorScanProcess);
                                }
                            } catch (Exception ex) {
                                JCommonUtil.handleException(ex);
                            }
                        }
                    });
                }
                {
                    ComboBoxModel jComboBox1Model = new DefaultComboBoxModel();
                    fileExtensionComboBox = new JComboBox();
                    jPanel2.add(fileExtensionComboBox);
                    fileExtensionComboBox.setModel(jComboBox1Model);
                    fileExtensionComboBox.setPreferredSize(new java.awt.Dimension(186, 24));
                    fileExtensionComboBox.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            try {
                                String extension = (String) fileExtensionComboBox.getSelectedItem();
                                reloadSvnTable(extension, _fileExtensionScanProcess);
                            } catch (Exception ex) {
                                JCommonUtil.handleException(ex);
                            }
                        }
                    });
                }
                {
                    jScrollPane2 = new JScrollPane();
                    jScrollPane2.setPreferredSize(new java.awt.Dimension(130, 200));
                    jPanel2.add(jScrollPane2);
                    {
                        DefaultListModel model = new DefaultListModel();
                        fileExtensionFilter = new JList();
                        jScrollPane2.setViewportView(fileExtensionFilter);
                        fileExtensionFilter.setModel(model);
                        fileExtensionFilter.addListSelectionListener(new ListSelectionListener() {
                            public void valueChanged(ListSelectionEvent evt) {
                                try {
                                    System.out
                                            .println(Arrays.toString(fileExtensionFilter.getSelectedValues()));
                                    String extensionStr = "";
                                    StringBuilder sb = new StringBuilder();
                                    for (Object val : fileExtensionFilter.getSelectedValues()) {
                                        sb.append(val + ",");
                                    }
                                    extensionStr = (sb.length() > 0 ? sb.deleteCharAt(sb.length() - 1) : sb)
                                            .toString();
                                    System.out.format("extensionStr = [%s]\n", extensionStr);
                                    multiExtendsionFilter.setName(extensionStr);
                                } catch (Exception ex) {
                                    JCommonUtil.handleException(ex);
                                }
                            }
                        });
                    }
                }
                {
                    multiExtendsionFilter = new JButton();
                    jPanel2.add(multiExtendsionFilter);
                    multiExtendsionFilter.setText("multi extension filter");
                    multiExtendsionFilter.setPreferredSize(new java.awt.Dimension(166, 34));
                    multiExtendsionFilter.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            try {
                                reloadSvnTable(multiExtendsionFilter.getName(), _fileExtensionMultiScanProcess);
                            } catch (Exception ex) {
                                JCommonUtil.handleException(ex);
                            }
                        }
                    });
                }
                {
                    loadAuthorReference = new JButton();
                    jPanel2.add(loadAuthorReference);
                    loadAuthorReference.setText("load author reference");
                    loadAuthorReference.setPreferredSize(new java.awt.Dimension(188, 35));
                    loadAuthorReference.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            try {
                                File file = JFileChooserUtil.newInstance().selectFileOnly().showOpenDialog()
                                        .getApproveSelectedFile();
                                if (file == null) {
                                    JOptionPaneUtil.newInstance().iconErrorMessage()
                                            .showMessageDialog("file is not correct!", "ERROR");
                                    return;
                                }
                                authorProps.load(new FileInputStream(file));
                                reloadAuthorComboBox();
                            } catch (Exception ex) {
                                JCommonUtil.handleException(ex);
                            }
                        }
                    });
                }
                {
                    saveCurrentData = new JButton();
                    jPanel2.add(saveCurrentData);
                    saveCurrentData.setText("save current data");
                    saveCurrentData.setPreferredSize(new java.awt.Dimension(166, 34));
                    saveCurrentData.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            try {
                                File saveDataConfig = new File(jarExistLocation, getSaveCurrentDataFileName());
                                ObjectOutputStream writer = new ObjectOutputStream(
                                        new FileOutputStream(saveDataConfig));
                                writer.writeObject(projectName);
                                writer.writeObject(authorSet);
                                writer.writeObject(fileExtenstionSet);
                                writer.writeObject(svnFileSet);
                                writer.writeObject(authorProps);
                                writer.writeObject(lastestVersion);
                                writer.flush();
                                writer.close();

                                JOptionPaneUtil.newInstance().iconInformationMessage()
                                        .showMessageDialog("current project : " + projectName
                                                + " save completed! \n" + saveDataConfig, "SUCCESS");
                            } catch (Exception ex) {
                                JCommonUtil.handleException(ex);
                            }
                        }
                    });
                }
                {
                    loadDataFromFile = new JButton();
                    jPanel2.add(loadDataFromFile);
                    loadDataFromFile.setText("load data cfg");
                    loadDataFromFile.setPreferredSize(new java.awt.Dimension(165, 35));
                    loadDataFromFile.addActionListener(new ActionListener() {
                        @SuppressWarnings("unchecked")
                        public void actionPerformed(ActionEvent evt) {
                            try {
                                File file = JFileChooserUtil.newInstance().selectFileOnly()
                                        .addAcceptFile(".cfg", ".cfg").showOpenDialog()
                                        .getApproveSelectedFile();
                                if (file == null) {
                                    JOptionPaneUtil.newInstance().iconErrorMessage()
                                            .showMessageDialog("file is not correct!", "ERROR");
                                    return;
                                }
                                long startTime = System.currentTimeMillis();
                                ObjectInputStream input = new ObjectInputStream(new FileInputStream(file));
                                projectName = (String) input.readObject();
                                authorSet = (Set<String>) input.readObject();
                                fileExtenstionSet = (Set<String>) input.readObject();
                                svnFileSet = (Set<SvnFile>) input.readObject();
                                authorProps = (Properties) input.readObject();
                                lastestVersion = (Long) input.readObject();
                                input.close();

                                resetUiAndShowMessage(startTime, projectName, lastestVersion);
                            } catch (Exception ex) {
                                JCommonUtil.handleException(ex);
                            }
                        }
                    });
                }
            }
        }
        pack();
        this.setSize(726, 459);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java

@SuppressWarnings("serial")
private JPanel createParamsweepGUI() {

    // left//from w w w.j  a v a  2 s  . co  m
    parameterList = new JList();
    parameterList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    new ListAction(parameterList, new AbstractAction() {
        public void actionPerformed(final ActionEvent event) {
            final AvailableParameter selectedParameter = (AvailableParameter) parameterList.getSelectedValue();
            addParameterToTree(new AvailableParameter[] { selectedParameter }, parameterTreeBranches.get(0));
            enableDisableParameterCombinationButtons();
        }
    });
    parameterList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!parameterList.isSelectionEmpty()) {
                boolean success = true;
                if (editedNode != null)
                    success = modify();

                if (success) {
                    cancelAllSelectionBut(parameterList);
                    resetSettings();
                    updateDescriptionField(parameterList.getSelectedValues());
                    enableDisableParameterCombinationButtons();
                } else
                    parameterList.clearSelection();
            }
        }
    });

    final JScrollPane parameterListPane = new JScrollPane(parameterList);
    parameterListPane.setBorder(BorderFactory.createTitledBorder("")); // for rounded border
    parameterListPane.setPreferredSize(new Dimension(300, 300));

    final JPanel parametersPanel = FormsUtils.build("p ' p:g", "[DialogBorder]00||" + "12||" + "34||" +
    //                                          "56||" + 
            "55||" + "66 f:p:g", new FormsUtils.Separator("<html><b>General parameters</b></html>"),
            NUMBER_OF_TURNS_LABEL_TEXT, numberOfTurnsFieldPSW, NUMBER_OF_TIMESTEPS_TO_IGNORE_LABEL_TEXT,
            numberTimestepsIgnoredPSW,
            //                                          UPDATE_CHARTS_LABEL_TEXT,onLineChartsCheckBoxPSW,
            new FormsUtils.Separator("<html><b>Model parameters</b></html>"), parameterListPane).getPanel();

    combinationsPanel = new JPanel(new GridLayout(0, 1, 5, 5));
    combinationsScrPane = new JScrollPane(combinationsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    combinationsScrPane.setBorder(null);
    combinationsScrPane.setPreferredSize(new Dimension(550, 500));

    parameterDescriptionLabel = new JXLabel();
    parameterDescriptionLabel.setLineWrap(true);
    parameterDescriptionLabel.setVerticalAlignment(SwingConstants.TOP);
    final JScrollPane descriptionScrollPane = new JScrollPane(parameterDescriptionLabel);
    descriptionScrollPane.setBorder(BorderFactory.createTitledBorder(null, "Description", TitledBorder.LEADING,
            TitledBorder.BELOW_TOP));
    descriptionScrollPane.setPreferredSize(
            new Dimension(PARAMETER_DESCRIPTION_LABEL_WIDTH, PARAMETER_DESCRIPTION_LABEL_HEIGHT));
    descriptionScrollPane.setViewportBorder(null);

    final JButton addNewBoxButton = new JButton("Add new combination");
    addNewBoxButton.setActionCommand(ACTIONCOMMAND_ADD_BOX);

    final JPanel left = FormsUtils.build("p ~ f:p:g ~ p", "011 f:p:g ||" + "0_2 p", parametersPanel,
            combinationsScrPane, addNewBoxButton).getPanel();
    left.setBorder(BorderFactory.createTitledBorder(null, "Specify parameter combinations",
            TitledBorder.LEADING, TitledBorder.BELOW_TOP));
    Style.registerCssClasses(left, Dashboard.CSS_CLASS_COMMON_PANEL);

    final JPanel leftAndDesc = new JPanel(new BorderLayout());
    leftAndDesc.add(left, BorderLayout.CENTER);
    leftAndDesc.add(descriptionScrollPane, BorderLayout.SOUTH);
    Style.registerCssClasses(leftAndDesc, Dashboard.CSS_CLASS_COMMON_PANEL);

    // right
    editedParameterText = new JLabel(ORIGINAL_TEXT);
    editedParameterText.setPreferredSize(new Dimension(280, 40));
    constDef = new JRadioButton("Constant");
    listDef = new JRadioButton("List");
    incrDef = new JRadioButton("Increment");

    final JPanel rightTop = FormsUtils.build("p:g", "[DialogBorder]0||" + "1||" + "2||" + "3",
            editedParameterText, constDef, listDef, incrDef).getPanel();

    Style.registerCssClasses(rightTop, Dashboard.CSS_CLASS_COMMON_PANEL);

    constDefField = new JTextField();
    final JPanel constDefPanel = FormsUtils
            .build("p ~ p:g", "[DialogBorder]01 p", "Constant value: ", CellConstraints.TOP, constDefField)
            .getPanel();

    listDefArea = new JTextArea();
    final JScrollPane listDefScr = new JScrollPane(listDefArea,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    final JPanel listDefPanel = FormsUtils.build("p ~ p:g", "[DialogBorder]01|" + "_1 f:p:g||" + "_2 p",
            "Value list: ", listDefScr, "(Separate values with spaces!)").getPanel();

    incrStartValueField = new JTextField();
    incrEndValueField = new JTextField();
    incrStepField = new JTextField();

    final JPanel incrDefPanel = FormsUtils.build("p ~ p:g", "[DialogBorder]01||" + "23||" + "45",
            "Start value: ", incrStartValueField, "End value: ", incrEndValueField, "Step: ", incrStepField)
            .getPanel();

    enumDefBox = new JComboBox(new DefaultComboBoxModel());
    final JPanel enumDefPanel = FormsUtils
            .build("p ~ p:g", "[DialogBorder]01 p", "Constant value:", CellConstraints.TOP, enumDefBox)
            .getPanel();

    submodelTypeBox = new JComboBox();
    final JPanel submodelTypePanel = FormsUtils
            .build("p ~ p:g", "[DialogBorder]01", "Constant value:", CellConstraints.TOP, submodelTypeBox)
            .getPanel();

    fileTextField = new JTextField();
    fileTextField.addKeyListener(new KeyAdapter() {
        public void keyTyped(final KeyEvent e) {
            final char character = e.getKeyChar();
            final File file = new File(Character.isISOControl(character) ? fileTextField.getText()
                    : fileTextField.getText() + character);
            fileTextField.setToolTipText(file.getAbsolutePath());
        }
    });
    fileBrowseButton = new JButton(BROWSE_BUTTON_TEXT);
    fileBrowseButton.setActionCommand(ACTIONCOMMAND_BROWSE);
    final JPanel fileDefPanel = FormsUtils
            .build("p ~ p:g ~p", "[DialogBorder]012", "File:", fileTextField, fileBrowseButton).getPanel();

    constDefPanel.setName("CONST");
    listDefPanel.setName("LIST");
    incrDefPanel.setName("INCREMENT");
    enumDefPanel.setName("ENUM");
    submodelTypePanel.setName("SUBMODEL");
    fileDefPanel.setName("FILE");

    Style.registerCssClasses(constDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL);
    Style.registerCssClasses(listDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL);
    Style.registerCssClasses(incrDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL);
    Style.registerCssClasses(enumDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL);
    Style.registerCssClasses(submodelTypePanel, Dashboard.CSS_CLASS_COMMON_PANEL);
    Style.registerCssClasses(fileDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL);

    rightMiddle = new JPanel(new CardLayout());
    Style.registerCssClasses(rightMiddle, Dashboard.CSS_CLASS_COMMON_PANEL);
    rightMiddle.add(constDefPanel, constDefPanel.getName());
    rightMiddle.add(listDefPanel, listDefPanel.getName());
    rightMiddle.add(incrDefPanel, incrDefPanel.getName());
    rightMiddle.add(enumDefPanel, enumDefPanel.getName());
    rightMiddle.add(submodelTypePanel, submodelTypePanel.getName());
    rightMiddle.add(fileDefPanel, fileDefPanel.getName());

    modifyButton = new JButton("Modify");
    cancelButton = new JButton("Cancel");

    final JPanel rightBottom = FormsUtils
            .build("p:g p ~ p ~ p:g", "[DialogBorder]_01_ p", modifyButton, cancelButton).getPanel();

    Style.registerCssClasses(rightBottom, Dashboard.CSS_CLASS_COMMON_PANEL);

    final JPanel right = new JPanel(new BorderLayout());
    right.add(rightTop, BorderLayout.NORTH);
    right.add(rightMiddle, BorderLayout.CENTER);
    right.add(rightBottom, BorderLayout.SOUTH);
    right.setBorder(BorderFactory.createTitledBorder(null, "Parameter settings", TitledBorder.LEADING,
            TitledBorder.BELOW_TOP));

    Style.registerCssClasses(right, Dashboard.CSS_CLASS_COMMON_PANEL);

    // the whole paramsweep panel

    final JPanel content = FormsUtils.build("p:g p", "01 f:p:g", leftAndDesc, right).getPanel();
    Style.registerCssClasses(content, Dashboard.CSS_CLASS_COMMON_PANEL);

    sweepPanel = new JPanel();
    Style.registerCssClasses(sweepPanel, Dashboard.CSS_CLASS_COMMON_PANEL);
    sweepPanel.setLayout(new BorderLayout());
    final JScrollPane sp = new JScrollPane(content);
    sp.setBorder(null);
    sp.setViewportBorder(null);
    sweepPanel.add(sp, BorderLayout.CENTER);

    GUIUtils.createButtonGroup(constDef, listDef, incrDef);
    constDef.setSelected(true);
    constDef.setActionCommand("CONST");
    listDef.setActionCommand("LIST");
    incrDef.setActionCommand("INCREMENT");

    constDefField.setActionCommand("CONST_FIELD");
    incrStartValueField.setActionCommand("START_FIELD");
    incrEndValueField.setActionCommand("END_FIELD");
    incrStepField.setActionCommand("STEP_FIELD");

    modifyButton.setActionCommand("EDIT");
    cancelButton.setActionCommand("CANCEL");

    listDefArea.setLineWrap(true);
    listDefArea.setWrapStyleWord(true);
    listDefScr.setPreferredSize(new Dimension(100, 200));

    GUIUtils.addActionListener(this, modifyButton, cancelButton, constDef, listDef, incrDef, constDefField,
            incrStartValueField, incrEndValueField, incrStepField, addNewBoxButton, submodelTypeBox,
            fileBrowseButton);

    return sweepPanel;
}