Example usage for javax.swing JList JList

List of usage examples for javax.swing JList JList

Introduction

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

Prototype

public JList(final Vector<? extends E> listData) 

Source Link

Document

Constructs a JList that displays the elements in the specified Vector.

Usage

From source file:gui.QTLResultsPanel.java

private void setsimple(Trait trait) {
    if (AppFrame.tpmmode == AppFrame.TPMMODE_QTL) {
        DefaultListModel<String> simplemodelModel = new DefaultListModel<String>();
        simplemodelModel.addElement("Model       Adj R^2   SIC");
        for (String l : trait.getBestSimpleModels()) {
            simplemodelModel.addElement(l);
        }/*  www. j a v  a  2  s. co  m*/
        modelList = new JList<String>(simplemodelModel);
        modelList.addListSelectionListener(this);
        modelList.setFont(new Font("Monospaced", Font.PLAIN, 11));
        modelList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        simpleDetails = new JScrollPane(modelList);
        // simple_details.setFont(new Font("Monospaced", Font.PLAIN, 11));
        simpleDetails.setPreferredSize(new Dimension(200, 50));
        simplesplit.setLeftComponent(simpleDetails);
    } else {
        setTrait_simple(trait, simpleright);
    }
}

From source file:eu.apenet.dpt.standalone.gui.DataPreparationToolGUI.java

private void setupTool() {
    LoggerJAXB.outputJaxpImplementationInfo();
    Locale currentLocale = Locale.getDefault();

    labels = new ResourceBundlesWrapper(I18N_BASENAMES, currentLocale);

    retrieveFromDb = new RetrieveFromDb();
    apePanel = new APEPanel(labels, getContentPane(), this, retrieveFromDb);

    Utilities.setXsdList(fillXsdList());

    CheckList checkList = new CheckList();
    langList = checkList.getLangList();//  ww  w  .  j av  a  2 s  .c  o  m
    levelList = checkList.getLevelList();

    dateNormalization = new DateNormalization();

    super.setTitle(labels.getString("title"));
    Image topLeftIcon = Utilities.icon.getImage();
    setIconImage(topLeftIcon);

    doChecks();

    if (isFileMissing(Utilities.LOG_DIR)) {
        new File(Utilities.LOG_DIR).mkdir();
    }

    File tempDir = new File(Utilities.TEMP_DIR);
    //In case it didn't deleteOnExit at the previous closing of the program, we clean up.
    if (tempDir.exists()) {
        LOG.warn("Probably a problem when deleting the temp files at closure, so we clean up");
        eraseOldTempFiles(tempDir);
        try {
            FileUtils.deleteDirectory(tempDir);
        } catch (IOException e) {
            LOG.error("Could not delete the temp directory. Attempt to delete the directory once more: "
                    + (tempDir.delete() ? "Successful." : "Unsuccessful."));
        }
    }
    tempDir.mkdir();
    tempDir.deleteOnExit();
    //        ListControlaccessTerms listControlaccessTerms = new ListControlaccessTerms("/Users/yoannmoranville/Documents/Work/APE/data/AD78/");
    //        listControlaccessTerms.countTerms();
    //        listControlaccessTerms.displayLogsResults();
    //        CountCLevels countCLevels = new CountCLevels("/Users/yoannmoranville/Work/APEnet/Projects/data/Ready_APEnet/READY/Finland/HeNAF/FA_EAD/");
    //        CountCLevels countCLevels = new CountCLevels("/Users/yoannmoranville/Work/APEnet/Projects/data/BORA/ALL/");
    //        countCLevels.setCopyInAppropriateDirs(true);
    //        countCLevels.changeMainagencycodeForSweden(false);
    //        countCLevels.countLevels();

    //        SeparateFinnishFiles separateFinnishFiles = new SeparateFinnishFiles(new File("/Users/yoannmoranville/Desktop/files_fi"), TEMP_DIR);
    makeDefaultXsdMenuItems();
    makeDefaultXslMenuItems();

    getContentPane().add(apePanel);

    xmlEadListModel = new ProfileListModel(fileInstances, this);
    xmlEadList = new JList(xmlEadListModel);
    xmlEadList.setCellRenderer(new IconListCellRenderer(fileInstances));
    xmlEadList.setDragEnabled(true);

    xmlEadList.setTransferHandler(new ListTransferHandler());

    xmlEadList.setDropTarget(new DropTarget(xmlEadList, new ListDropTargetListener(xmlEadList, from)));
    xmlEadListModel.setList(xmlEadList);

    JMenuBar menuBar = new JMenuBar();
    menuBar.add(fileMenu);
    menuBar.add(optionMenu);
    menuBar.add(actionMenu);
    menuBar.add(windowMenu);
    menuBar.add(helpMenu);
    fileItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    fileMenu.add(fileItem);

    closeSelectedItem.setEnabled(false);
    //        closeSelectedItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    closeSelectedItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    fileMenu.add(closeSelectedItem);
    saveSelectedItem.setEnabled(false);
    saveSelectedItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    fileMenu.add(saveSelectedItem);
    saveMessageReportItem.setEnabled(false);
    saveMessageReportItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    fileMenu.add(saveMessageReportItem);
    //        sendFilesWebDAV.setEnabled(false);
    //        fileMenu.add(sendFilesWebDAV);
    fileMenu.addSeparator();
    fileMenu.add(quitItem);

    optionMenu.add(countryCodeItem);
    optionMenu.add(repositoryCodeItem);
    optionMenu.add(digitalObjectTypeItem);
    optionMenu.add(edmGeneralOptionsItem);
    optionMenu.add(listDateConversionRulesItem);
    optionMenu.addSeparator();
    optionMenu.add(xsltItem);
    optionMenu.add(xsdItem);
    optionMenu.add(defaultXslSelectionSubmenu);
    optionMenu.add(defaultXsdSelectionSubmenu);
    optionMenu.addSeparator();
    optionMenu.add(checksLoadingFilesItem);
    optionMenu.add(defaultSaveFolderItem);
    optionMenu.add(languageMenu);
    if (Utilities.isDev) {
        optionMenu.addSeparator();
        optionMenu.add(databaseItem);
    }

    validateItem.setEnabled(false);
    validateItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    actionMenu.add(validateItem);
    convertItem.setEnabled(false);
    convertItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_M, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    actionMenu.add(convertItem);

    actionMenu.addSeparator();

    // TODO: Uncomment when edit will be available.
    //        eacCpfItem.add(this.editEacCpfFile);     //add the different EAC-CPF options menu
    eacCpfItem.add(createEacCpf);
    actionMenu.add(eacCpfItem);

    createEag2012Item.add(createEag2012FromExistingEag2012);
    createEag2012Item.add(createEag2012FromScratch);
    actionMenu.add(createEag2012Item);

    summaryWindowItem.setEnabled(true);
    summaryWindowItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_1, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    windowMenu.add(summaryWindowItem);
    validationWindowItem.setEnabled(true);
    validationWindowItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_2, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    windowMenu.add(validationWindowItem);
    conversionWindowItem.setEnabled(true);
    conversionWindowItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_3, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    windowMenu.add(conversionWindowItem);
    edmConversionWindowItem.setEnabled(true);
    edmConversionWindowItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_4, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    windowMenu.add(edmConversionWindowItem);
    editionWindowItem.setEnabled(true);
    editionWindowItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_5, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    windowMenu.add(editionWindowItem);
    helpMenu.add(internetApexItem);
    helpMenu.addSeparator();
    JMenuItem versionItem = new JMenuItem("APE DPT v" + VERSION_NB);
    versionItem.setEnabled(false);
    helpMenu.add(versionItem);
    createLanguageMenu();
    fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    fileChooser.setMultiSelectionEnabled(true);

    getContentPane().add(menuBar, BorderLayout.NORTH);

    apePanel.setFilename("");

    createHgListener = new CreateHGListener(retrieveFromDb, labels, getContentPane(), fileInstances, xmlEadList,
            this);
    createHGBtn.addActionListener(createHgListener);
    createHGBtn.setEnabled(false);

    analyzeControlaccessListener = new AnalyzeControlaccessListener(labels, getContentPane(), fileInstances);
    analyzeControlaccessBtn.addActionListener(analyzeControlaccessListener);
    analyzeControlaccessBtn.setEnabled(false);

    validateItem.addActionListener(new ConvertAndValidateActionListener(this, apePanel.getApeTabbedPane(),
            ConvertAndValidateActionListener.VALIDATE));
    convertItem.addActionListener(new ConvertAndValidateActionListener(this, apePanel.getApeTabbedPane(),
            ConvertAndValidateActionListener.CONVERT));

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    getContentPane().add(createWest(), BorderLayout.WEST);

    //        convertAndValidateBtn.addActionListener(new ConvertAndValidateActionListener(this, getContentPane()));
    //        validateSelectionBtn.addActionListener(new ValidateSelectionActionListener(this, getContentPane()));
    //        convertEdmSelectionBtn.addActionListener(new ConvertEdmActionListener(labels, this, apePanel));

    nameComponents();
    wireUp();
    setSize(Toolkit.getDefaultToolkit().getScreenSize());
    setMinimumSize(Toolkit.getDefaultToolkit().getScreenSize());
    setExtendedState(JFrame.MAXIMIZED_BOTH);
}

From source file:edu.ku.brc.ui.ChooseFromListDlg.java

/**
 * Create the UI for the dialog.// w  w w  .  j a v a2s. c  om
 * 
 * @param altName title for dialog
 * @param desc the list to be selected from
 * @param includeCancelBtn  indicates whether to create and display a cancel btn
 * @param includeHelpBtn indicates whether to create and display a help btn
 * @param helpContext help context identifier
 * @param titleArg title for dialog
 * @param desc the list to be selected from
 * @param includeCancelBtn indicates whether to create and display a cancel btn
 */
public void createUI() {
    setTitle(title);

    boolean hasDesc = StringUtils.isNotEmpty(desc);
    PanelBuilder builder = new PanelBuilder(
            new FormLayout("f:max(300px;p):g", "p," + (hasDesc ? "2px,p," : "") + "5px,p"));
    CellConstraints cc = new CellConstraints();
    //builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 10));
    builder.setDefaultDialogBorder();

    int y = 1;
    if (hasDesc) {
        JLabel lbl = createLabel(desc, SwingConstants.CENTER);
        builder.add(lbl, cc.xy(1, y));
        y += 2;
    }

    try {
        ListModel listModel = new AbstractListModel() {
            public int getSize() {
                return items.size();
            }

            public Object getElementAt(int index) {
                return items.get(index).toString();
            }
        };

        list = new JList(listModel);
        if (icon != null) {
            list.setCellRenderer(getListCellRenderer()); // icon comes from the base
            // class (it's probably size
            // 16)
        }
        list.setSelectionMode(isMultiSelect ? ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
                : ListSelectionModel.SINGLE_SELECTION);
        list.setVisibleRowCount(10);

        if (selectedIndices != null) {
            list.setSelectedIndices(selectedIndices);
        }

        list.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    okBtn.doClick(); // emulate button click
                }
            }
        });
        list.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                    updateUIState();
                }
            }
        });
        JScrollPane listScroller = new JScrollPane(list);
        builder.add(listScroller, cc.xy(1, y));
        y += 2;

        // Bottom Button UI
        okBtn = createButton(StringUtils.isNotEmpty(okLabel) ? okLabel : getResourceString("OK"));
        okBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                isCancelled = false;
                btnPressed = OK_BTN;
                setVisible(false);
            }
        });
        getRootPane().setDefaultButton(okBtn);

        if ((whichBtns & CANCEL_BTN) == CANCEL_BTN) {
            cancelBtn = createButton(
                    StringUtils.isNotEmpty(cancelLabel) ? cancelLabel : getResourceString("CANCEL"));
            cancelBtn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    isCancelled = true;
                    btnPressed = CANCEL_BTN;
                    setVisible(false);
                }
            });
        }

        if ((whichBtns & HELP_BTN) == HELP_BTN) {
            helpBtn = createButton(
                    StringUtils.isNotEmpty(cancelLabel) ? cancelLabel : getResourceString("HELP"));
            if (StringUtils.isNotEmpty(helpContext)) {
                HelpMgr.registerComponent(helpBtn, helpContext);
            } else {
                helpBtn.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        btnPressed = HELP_BTN;
                    }
                });
            }
        }

        if ((whichBtns & APPLY_BTN) == APPLY_BTN) {
            applyBtn = createButton(
                    StringUtils.isNotEmpty(applyLabel) ? applyLabel : getResourceString("Apply"));
            applyBtn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    btnPressed = APPLY_BTN;
                    if (isCloseOnApply) {
                        isCancelled = false;
                        setVisible(false);
                    }
                }
            });
        }

        JPanel bb;
        if (whichBtns == OK_BTN) {
            bb = ButtonBarFactory.buildOKBar(okBtn);

        } else if (whichBtns == OKCANCEL) {
            bb = ButtonBarFactory.buildOKCancelBar(okBtn, cancelBtn);

        } else if (whichBtns == OKCANCELAPPLY) {
            bb = ButtonBarFactory.buildOKCancelApplyBar(okBtn, cancelBtn, applyBtn);

        } else if (whichBtns == OKHELP) {
            bb = ButtonBarFactory.buildOKHelpBar(okBtn, helpBtn);

        } else if (whichBtns == OKCANCELHELP) {
            bb = ButtonBarFactory.buildOKCancelHelpBar(okBtn, cancelBtn, helpBtn);

        } else if (whichBtns == OKCANCELAPPLYHELP) {
            bb = ButtonBarFactory.buildOKCancelApplyHelpBar(okBtn, cancelBtn, applyBtn, helpBtn);

        } else {
            bb = ButtonBarFactory.buildOKBar(okBtn);
        }

        builder.add(bb, cc.xy(1, y));
        y += 2;

        updateUIState();

    } catch (Exception ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ChooseFromListDlg.class, ex);
        log.error(ex);
    }

    setContentPane(builder.getPanel());
    pack();
    // setLocationRelativeTo(locationComp);
}

From source file:it.ventuland.ytd.ui.GUIClient.java

private void addComponentsToPane(final Container pane) {
    this.panel = new JPanel();
    this.panel.setLayout(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(5, 5, 5, 5);
    gbc.anchor = GridBagConstraints.WEST;

    ActionManager lActionManager = new ActionManager();

    dlm = new DefaultListModel<String>();
    this.urllist = new JList<String>(dlm);
    // TODO maybe we add a button to remove added URLs from list?
    //this.userlist.setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );
    this.urllist.setFocusable(false);
    textarea = new JTextArea(2, 2);
    textarea.setEditable(true);//from   w w  w.ja v a  2  s .  c  o  m
    textarea.setFocusable(false);

    JScrollPane leftscrollpane = new JScrollPane(this.urllist);
    JScrollPane rightscrollpane = new JScrollPane(textarea);
    this.middlepane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftscrollpane, rightscrollpane);
    this.middlepane.setOneTouchExpandable(true);
    this.middlepane.setDividerLocation(150);

    Dimension minimumSize = new Dimension(25, 25);
    leftscrollpane.setMinimumSize(minimumSize);
    rightscrollpane.setMinimumSize(minimumSize);

    this.directorybutton = new JButton("", createImageIcon("images/open.png", ""));
    gbc.gridx = 0;
    gbc.gridy = 0;
    this.directorybutton.addActionListener(lActionManager);
    this.panel.add(this.directorybutton, gbc);

    this.saveconfigcheckbox = new JCheckBox("Save config");
    this.saveconfigcheckbox.setSelected(false);

    this.panel.add(this.saveconfigcheckbox);

    this.saveconfigcheckbox.setEnabled(false);

    // TODO check if initial download directory exists
    // assume that at least the users homedir exists
    String shomedir = System.getProperty("user.home").concat(File.separator);

    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.gridwidth = 2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.directorytextfield = new JTextField(shomedir, 20 + (mIsDebug ? 48 : 0));
    this.directorytextfield.setEnabled(false);
    this.directorytextfield.setFocusable(true);
    this.directorytextfield.addActionListener(lActionManager);
    this.panel.add(this.directorytextfield, gbc);

    JLabel dirhint = new JLabel("Download to folder:");

    gbc.gridx = 0;
    gbc.gridy = 1;
    this.panel.add(dirhint, gbc);

    this.middlepane.setPreferredSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize().width / 3,
            Toolkit.getDefaultToolkit().getScreenSize().height / 4 + (mIsDebug ? 200 : 0)));

    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weighty = 2;
    gbc.weightx = 2;
    gbc.gridwidth = 2;
    this.panel.add(this.middlepane, gbc);

    // radio buttons for resolution to download
    mVideoResolutionBtnGrp = new ButtonGroup();
    JPanel lRadioPanel = new JPanel(new GridLayout(1, 0));
    List<Object> lVidQ = mAppContext.getList("youtube-downloader.video-quality");
    JRadioButton lRadioButton = null;
    for (Object obj : lVidQ) {
        String lQuality = (String) obj;
        String lToolTip = mAppContext.getString("youtube-downloader.video-quality." + lQuality + ".tooltip");
        boolean lSelected = mAppContext
                .getBoolean("youtube-downloader.video-quality." + lQuality + ".selected");
        boolean lEnabled = mAppContext.getBoolean("youtube-downloader.video-quality." + lQuality + ".enabled");
        lRadioButton = new JRadioButton(lQuality);
        lRadioButton.setName(lQuality);
        lRadioButton.setActionCommand(lQuality.toLowerCase());
        lRadioButton.addActionListener(lActionManager);
        lRadioButton.setToolTipText(lToolTip);
        lRadioButton.setSelected(lSelected);
        lRadioButton.setEnabled(lEnabled);
        mVideoResolutionBtnGrp.add(lRadioButton);
        lRadioPanel.add(lRadioButton);
    }

    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.gridheight = 0;
    gbc.gridwidth = 0;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.NORTHEAST;
    this.panel.add(lRadioPanel, gbc);

    // radio buttons for video format to download
    mVideoQualityBtnGrp = new ButtonGroup();
    lRadioPanel = new JPanel(new GridLayout(1, 0));
    save3dcheckbox = new JCheckBox("3D");
    save3dcheckbox.setToolTipText("stereoscopic video");
    save3dcheckbox.setSelected(false);
    save3dcheckbox.setEnabled(true);
    lRadioPanel.add(save3dcheckbox);
    List<Object> lVidR = mAppContext.getList("youtube-downloader.video-resolution");
    lRadioButton = null;
    for (Object obj : lVidR) {
        String lResolution = (String) obj;
        String lToolTip = mAppContext
                .getString("youtube-downloader.video-resolution." + lResolution + ".tooltip");
        boolean lSelected = mAppContext
                .getBoolean("youtube-downloader.video-resolution." + lResolution + ".selected");
        boolean lEnabled = mAppContext
                .getBoolean("youtube-downloader.video-resolution." + lResolution + ".enabled");
        lRadioButton = new JRadioButton(lResolution);
        lRadioButton.setName(lResolution);
        lRadioButton.setActionCommand(lResolution.toLowerCase());
        lRadioButton.addActionListener(lActionManager);
        lRadioButton.setToolTipText(lToolTip);
        lRadioButton.setSelected(lSelected);
        lRadioButton.setEnabled(lEnabled);
        mVideoQualityBtnGrp.add(lRadioButton);
        lRadioPanel.add(lRadioButton);
    }

    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.gridheight = 0;
    gbc.gridwidth = 0;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.NORTHEAST;
    this.panel.add(lRadioPanel, gbc);

    JLabel hint = new JLabel("Type, paste or drag'n drop a YouTube video address:");

    gbc.fill = 0;
    gbc.gridwidth = 0;
    gbc.gridheight = 1;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.anchor = GridBagConstraints.WEST;
    this.panel.add(hint, gbc);

    textinputfield = new JTextField(20);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.gridwidth = 2;
    textinputfield.setEnabled(true);
    textinputfield.setFocusable(true);
    textinputfield.addActionListener(lActionManager);
    textinputfield.getDocument().addDocumentListener(new UrlInsertListener());
    this.panel.add(textinputfield, gbc);

    this.quitbutton = new JButton("", createImageIcon("images/exit.png", ""));
    gbc.gridx = 2;
    gbc.gridy = 5;
    gbc.gridwidth = 0;
    this.quitbutton.addActionListener(lActionManager);
    this.quitbutton.setActionCommand("quit");
    this.quitbutton.setToolTipText("Exit.");

    this.panel.add(this.quitbutton, gbc);

    pane.add(this.panel);
    addWindowListener(new GUIWindowAdapter());

    this.setDropTarget(new DropTarget(this, new DragDropListener()));
    textarea.setTransferHandler(null); // otherwise the dropped text would be inserted

}

From source file:edu.ku.brc.specify.tasks.subpane.wb.TemplateEditor.java

@Override
public void createUI() {
    super.createUI();

    databaseSchema = WorkbenchTask.getDatabaseSchema();

    int disciplineeId = AppContextMgr.getInstance().getClassObject(Discipline.class).getDisciplineId();
    SchemaI18NService.getInstance().loadWithLocale(SpLocaleContainer.WORKBENCH_SCHEMA, disciplineeId,
            databaseSchema, SchemaI18NService.getCurrentLocale());

    // Create the Table List
    Vector<TableInfo> tableInfoList = new Vector<TableInfo>();
    for (DBTableInfo ti : databaseSchema.getTables()) {
        if (StringUtils.isNotEmpty(ti.toString())) {
            TableInfo tableInfo = new TableInfo(ti, IconManager.STD_ICON_SIZE);
            tableInfoList.add(tableInfo);

            Vector<FieldInfo> fldList = new Vector<FieldInfo>();
            for (DBFieldInfo fi : ti.getFields()) {
                String fldTitle = fi.getTitle().replace(" ", "");
                if (fldTitle.equalsIgnoreCase(fi.getName())) {
                    //get title from mapped field
                    UploadInfo upInfo = getUploadInfo(fi);
                    DBFieldInfo mInfo = getMappedFieldInfo(fi);
                    if (mInfo != null) {
                        String title = mInfo.getTitle();
                        if (upInfo != null && upInfo.getSequence() != -1) {
                            title += " " + (upInfo.getSequence() + 1);
                        }//w  w  w.  ja va2 s  .  c o  m
                        //if mapped-to table is different than the container table used
                        // in the wb, add the mapped-to table's title
                        if (mInfo.getTableInfo().getTableId() != ti.getTableId()) {
                            title = mInfo.getTableInfo().getTitle() + " " + title;
                        }
                        fi.setTitle(title);
                    }
                }
                fldList.add(new FieldInfo(ti, fi));
            }
            //Collections.sort(fldList);
            tableInfo.setFieldItems(fldList);
        }
    }
    Collections.sort(tableInfoList);

    fieldModel = new DefaultModifiableListModel<FieldInfo>();
    tableModel = new DefaultModifiableListModel<TableInfo>();
    for (TableInfo ti : tableInfoList) {
        tableModel.add(ti);

        // only added for layout
        for (FieldInfo fi : ti.getFieldItems()) {
            fieldModel.add(fi);
        }
    }

    tableList = new JList(tableModel);
    tableList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tableList.setCellRenderer(tableInfoListRenderer = new TableInfoListRenderer(IconManager.STD_ICON_SIZE));
    JScrollPane tableScrollPane = new JScrollPane(tableList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    tableList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                Object selObj = tableList.getSelectedValue();
                if (selObj != null) {
                    fillFieldList((TableInfo) selObj);
                }
                updateEnabledState();
            }
        }
    });

    fieldList = new JList(fieldModel);
    fieldList.setCellRenderer(tableInfoListRenderer = new TableInfoListRenderer(IconManager.STD_ICON_SIZE));
    fieldList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    JScrollPane fieldScrollPane = new JScrollPane(fieldList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    fieldList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                updateEnabledState();
                updateFieldDescription();
            }
        }
    });

    mapModel = new DefaultModifiableListModel<FieldMappingPanel>();
    mapList = new JList(mapModel);
    mapList.setCellRenderer(new MapCellRenderer());
    mapList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    mapScrollPane = new JScrollPane(mapList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    mapList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                FieldMappingPanel fmp = (FieldMappingPanel) mapList.getSelectedValue();
                if (fmp != null) {
                    ignoreMapListUpdate = true;

                    FieldInfo fldInfo = fmp.getFieldInfo();
                    if (fldInfo != null) {
                        for (int i = 0; i < tableModel.size(); i++) {
                            TableInfo tblInfo = (TableInfo) tableModel.get(i);
                            if (fldInfo.getTableinfo() == tblInfo.getTableInfo()) {
                                tableList.setSelectedValue(tblInfo, true);
                                fillFieldList(tblInfo);
                                //System.out.println(fldInfo.hashCode()+" "+fldInfo.getFieldInfo().hashCode());
                                fieldList.setSelectedValue(fldInfo, true);
                                updateFieldDescription();
                                break;
                            }
                        }
                    }
                    ignoreMapListUpdate = false;
                    updateEnabledState();
                }
            }
        }
    });

    upBtn = createIconBtn("ReorderUp", "WB_MOVE_UP", new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            int inx = mapList.getSelectedIndex();
            FieldMappingPanel fmp = mapModel.getElementAt(inx);

            mapModel.remove(fmp);
            mapModel.insertElementAt(fmp, inx - 1);
            mapList.setSelectedIndex(inx - 1);
            updateEnabledState();
            setChanged(true);
        }
    });
    downBtn = createIconBtn("ReorderDown", "WB_MOVE_DOWN", new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            int inx = mapList.getSelectedIndex();
            FieldMappingPanel fmp = mapModel.getElementAt(inx);

            mapModel.remove(fmp);
            mapModel.insertElementAt(fmp, inx + 1);
            mapList.setSelectedIndex(inx + 1);
            updateEnabledState();
            setChanged(true);
        }
    });

    JButton dumpMappingBtn = createIconBtn("BlankIcon", IconManager.IconSize.Std16, "WB_MAPPING_DUMP",
            new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    dumpMapping();
                }
            });
    dumpMappingBtn.setEnabled(true);
    dumpMappingBtn.setFocusable(false);
    dumpMappingBtn.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent e) {
            ((JButton) e.getSource()).setIcon(IconManager.getIcon("Save", IconManager.IconSize.Std16));
            super.mouseEntered(e);
        }

        @Override
        public void mouseExited(MouseEvent e) {
            ((JButton) e.getSource()).setIcon(IconManager.getIcon("BlankIcon", IconManager.IconSize.Std16));
            super.mouseExited(e);
        }

    });

    mapToBtn = createIconBtn("Map", "WB_ADD_MAPPING_ITEM", new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            map();
        }
    });
    unmapBtn = createIconBtn("Unmap", "WB_REMOVE_MAPPING_ITEM", new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            unmap();
        }
    });

    // Adjust all Labels depending on whether we are creating a new template or not
    // and whether it is from a file or not
    String mapListLeftLabel;
    String mapListRightLabel;

    // Note: if workbenchTemplate is null then it is 
    String dataTypeLabel = getResourceString("WB_DATA_TYPE");
    String fieldsLabel = getResourceString("WB_FIELDS");

    mapListLeftLabel = fieldsLabel;
    mapListRightLabel = getResourceString("WB_COLUMNS");

    CellConstraints cc = new CellConstraints();

    JPanel mainLayoutPanel = new JPanel();

    PanelBuilder labelsBldr = new PanelBuilder(new FormLayout("p, f:p:g, p", "p"));
    labelsBldr.add(createLabel(mapListLeftLabel, SwingConstants.LEFT), cc.xy(1, 1));
    labelsBldr.add(createLabel(mapListRightLabel, SwingConstants.RIGHT), cc.xy(3, 1));

    PanelBuilder upDownPanel = new PanelBuilder(new FormLayout("p", "p,f:p:g, p, 2px, p, f:p:g"));
    upDownPanel.add(dumpMappingBtn, cc.xy(1, 1));
    upDownPanel.add(upBtn, cc.xy(1, 3));
    upDownPanel.add(downBtn, cc.xy(1, 5));

    PanelBuilder middlePanel = new PanelBuilder(new FormLayout("c:p:g", "p, 2px, p"));
    middlePanel.add(mapToBtn, cc.xy(1, 1));
    middlePanel.add(unmapBtn, cc.xy(1, 3));

    btnPanel = middlePanel.getPanel();
    btnPanel.setOpaque(false);

    PanelBuilder outerMiddlePanel = new PanelBuilder(new FormLayout("c:p:g", "f:p:g, p, f:p:g"));
    outerMiddlePanel.add(btnPanel, cc.xy(1, 2));
    outerMiddlePanel.getPanel().setOpaque(false);

    // Main Pane Layout
    PanelBuilder builder = new PanelBuilder(
            new FormLayout("f:max(200px;p):g, 5px, max(200px;p), 5px, p:g, 5px, f:max(250px;p):g, 2px, p",
                    "p, 2px, f:max(350px;p):g"),
            mainLayoutPanel);

    builder.add(createLabel(dataTypeLabel, SwingConstants.CENTER), cc.xy(1, 1));
    builder.add(createLabel(fieldsLabel, SwingConstants.CENTER), cc.xy(3, 1));
    builder.add(labelsBldr.getPanel(), cc.xy(7, 1));

    builder.add(tableScrollPane, cc.xy(1, 3));
    builder.add(fieldScrollPane, cc.xy(3, 3));

    builder.add(outerMiddlePanel.getPanel(), cc.xy(5, 3));

    builder.add(mapScrollPane, cc.xy(7, 3));
    builder.add(upDownPanel.getPanel(), cc.xy(9, 3));

    mainLayoutPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    JPanel megaPanel = new JPanel(new BorderLayout());
    megaPanel.add(mainLayoutPanel, BorderLayout.CENTER);
    descriptionLbl = createLabel("  ", SwingConstants.LEFT);
    //PanelBuilder descBuilder = new PanelBuilder(new FormLayout("f:p:g, 3dlu","p"));
    //descBuilder.add(descriptionLbl, cc.xy(1, 1));
    //megaPanel.add(descBuilder.getPanel(), BorderLayout.SOUTH);
    megaPanel.add(descriptionLbl, BorderLayout.SOUTH);
    //contentPanel = mainLayoutPanel;
    contentPanel = megaPanel;

    Color bgColor = btnPanel.getBackground();
    int inc = 16;
    btnPanelColor = new Color(Math.min(255, bgColor.getRed() + inc), Math.min(255, bgColor.getGreen() + inc),
            Math.min(255, bgColor.getBlue() + inc));
    btnPanel.setBackground(btnPanelColor);
    btnPanel.setBorder(BorderFactory.createEmptyBorder(4, 6, 4, 6));

    okBtn.setEnabled(false);

    HelpMgr.registerComponent(helpBtn, helpContext);

    if (dataFileInfo != null) {
        autoMapFromDataFile(dataFileInfo.getColInfo());
    }
    if (workbenchTemplate != null) {
        fillFromTemplate();
        setChanged(false);
    }

    mainPanel.add(contentPanel, BorderLayout.CENTER);

    if (dataFileInfo == null) //can't add new mappings when importing.
    {
        FieldMappingPanel fmp = addMappingItem(null,
                IconManager.getIcon("BlankIcon", IconManager.STD_ICON_SIZE), null);
        fmp.setAdded(true);
        fmp.setNew(true);
    }

    pack();

    SwingUtilities.invokeLater(new Runnable() {
        @SuppressWarnings("synthetic-access")
        public void run() {
            cancelBtn.requestFocus();
            fieldModel.clear();
            fieldList.clearSelection();
            updateFieldDescription();
            updateEnabledState();

            if (mapModel.size() > 1) {
                mapList.clearSelection();
            }
        }
    });
}

From source file:io.github.jeremgamer.editor.panels.Others.java

protected void updateList() {
    data.clear();//from ww w.j  a v  a2s .c  o m
    File dir = new File("projects/" + Editor.getProjectName() + "/others");
    if (!dir.exists()) {
        dir.mkdirs();
    }
    for (File file : FileUtils.listFiles(dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) {
        data.addElement(file.getName().replace(".rbd", ""));
    }
    otherList = new JList<String>(data);
}

From source file:inet.CalculationNetworkEditor.visual.view.EditorPane.java

private void addContentToStackingEdgePanel(JPanel rightPanel, E e, Collection<E> allPhysicalCol) {
    //caption/*from w  w w.j  av a 2s.  c  om*/
    JLabel caption = new JLabel("Map: " + e);
    caption.setSize(new Dimension(180, 20));
    caption.setPreferredSize(new Dimension(180, 20));
    rightPanel.add(caption, BorderLayout.NORTH);

    //to
    JPanel toPanel = new JPanel();
    toPanel.setLayout(new BorderLayout());
    rightPanel.add(toPanel, BorderLayout.CENTER);
    JLabel to = new JLabel("To:");
    to.setSize(new Dimension(180, 20));
    to.setPreferredSize(new Dimension(180, 20));
    toPanel.add(to, BorderLayout.NORTH);

    // buttons edge button panel
    JPanel buttonsEdgePanel = new JPanel();
    buttonsEdgePanel.setLayout(new BorderLayout());
    toPanel.add(buttonsEdgePanel, BorderLayout.CENTER);

    // path listPanel
    //JPanel pathListPanel = new JPanel();
    //pathListPanel.setLayout(new BorderLayout);

    defaultListModel = new DefaultListModel<E>();
    pathList = new JList<E>(defaultListModel);
    pathList.setSize(180, 100);
    pathList.setPreferredSize(new Dimension(180, 100));
    buttonsEdgePanel.add(pathList, BorderLayout.CENTER);

    // add remove edge button panel
    JPanel addRemoveEdgePanel = new JPanel();
    addRemoveEdgePanel.setLayout(new BorderLayout());
    buttonsEdgePanel.add(addRemoveEdgePanel, BorderLayout.SOUTH);

    // add Button
    JButton addButton = new JButton("add");
    addRemoveEdgePanel.add(addButton, BorderLayout.LINE_START);
    addButton.addActionListener(editingPanelsListener);
    addButton.setSize(new Dimension(70, 20));
    addButton.setPreferredSize(new Dimension(70, 20));

    // remove Button
    JButton removeButton = new JButton("remove");
    addRemoveEdgePanel.add(removeButton, BorderLayout.LINE_END);
    removeButton.addActionListener(editingPanelsListener);
    removeButton.setSize(new Dimension(90, 20));
    removeButton.setPreferredSize(new Dimension(90, 20));

    // add drop done box with all physical edges
    allPhysicalEdgeJCB = new JComboBox<E>();
    for (E edge : allPhysicalCol) {
        if (!defaultListModel.contains(edge)) {
            allPhysicalEdgeJCB.addItem(edge);
        }
    }
    toPanel.add(allPhysicalEdgeJCB, BorderLayout.SOUTH);
    allPhysicalEdgeJCB.setSize(new Dimension(180, 30));
    allPhysicalEdgeJCB.setPreferredSize(new Dimension(180, 30));
    allPhysicalEdgeJCB.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));

    // JButton stack
    JButton stack = new JButton("map");
    stack.addActionListener(editingPanelsListener);
    rightPanel.add(stack, BorderLayout.SOUTH);
}

From source file:net.minelord.gui.panes.IRCPane.java

public void connected() {
    SwingUtilities.invokeLater(new Runnable() {

        @Override//from w  w  w .  jav a 2 s  .c  om
        public void run() {
            scroller.setBounds(scrollerWithoutTopicWithUserlist);
            scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
            status = "Connected";
            client.connectAlertListener();
            TitledBorder title = BorderFactory
                    .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Connected");
            title.setTitleJustification(TitledBorder.RIGHT);
            userList = new JList(client.getUserList().toArray());
            userScroller = new JScrollPane(userList);
            userScroller.setBounds(userScrollerWithoutTopic);
            userList.setBounds(0, 0, 210, 250);
            userList.setBackground(Color.gray);
            userList.setForeground(Color.gray.darker().darker().darker());
            userScroller.setBorder(title);
            userScroller.getVerticalScrollBar().setUnitIncrement(5);
            scroller.setBorder(BorderFactory
                    .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), ""));
            if (client.getTopic().trim().length() > 0) {
                topic = new JLabel(client.getTopic());
                scroller.setBounds(scrollerWithTopicWithUserlist);
                userScroller.setBounds(userScrollWithTopic);
                userList.setBounds(0, 0, 210, 225);
                title = BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
                        "Topic set by " + client.getTopicSetter());
                title.setTitleJustification(TitledBorder.LEFT);
                topic.setBorder(title);
                topic.setBounds(topicBounds);
                add(topic);
            } else
                topic = new JLabel("");
            input.setEnabled(true);
            input.requestFocus();
            final JPopupMenu userPopup = new JPopupMenu();
            JLabel breakLine = new JLabel("____");
            JLabel help = new JLabel("Politely ask for help");
            JLabel message = new JLabel("Message");
            JLabel sortNormal = new JLabel("Normal");
            JLabel sortAlphabetical = new JLabel("Alphabetical");
            JLabel sortRoles = new JLabel("Roles");

            help.addMouseListener(new MouseAdapter() {
                public void mousePressed(MouseEvent e) {
                    userPopup.setVisible(false);
                    sendMessage("/me kicks " + userList.getModel().getElementAt(userList.getSelectedIndex())
                            + " in the shins");
                    sendMessage("I need help you pleb");
                }

                public void mouseReleased(MouseEvent e) {
                }
            });
            message.addMouseListener(new MouseAdapter() {

                @Override
                public void mouseReleased(MouseEvent paramMouseEvent) {
                    userPopup.setVisible(false);
                    input.setText("/msg " + userList.getModel().getElementAt(userList.getSelectedIndex())
                            + (input.getText().length() > 0 && input.getText().charAt(0) == ' '
                                    ? input.getText()
                                    : " " + input.getText()));
                    input.select(0, ("/msg " + userList.getModel().getElementAt(userList.getSelectedIndex())
                            + (input.getText().length() > 0 && input.getText().charAt(0) == ' ' ? "" : " "))
                                    .length());
                    input.requestFocus();
                }
            });
            sortNormal.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseReleased(MouseEvent paramMouseEvent) {
                    userPopup.setVisible(false);
                    updateUserList(0);
                }
            });
            sortAlphabetical.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseReleased(MouseEvent paramMouseEvent) {
                    userPopup.setVisible(false);
                    updateUserList(1);
                }
            });
            sortRoles.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseReleased(MouseEvent paramMouseEvent) {
                    userPopup.setVisible(false);
                    updateUserList(2);
                }
            });
            userPopup.add(help);
            userPopup.add(message);
            userPopup.add(breakLine);
            userPopup.add(sortNormal);
            userPopup.add(sortAlphabetical);
            userPopup.add(sortRoles);

            userList.addMouseListener(new MouseAdapter() {
                public void mousePressed(MouseEvent e) {
                    check(e);
                }

                public void mouseReleased(MouseEvent e) {
                    check(e);
                }

                public void check(MouseEvent e) {
                    userList.setSelectedIndex(userList.locationToIndex(e.getPoint()));
                    userPopup.show(userList, e.getX(), e.getY());
                }
            });
            add(userScroller);

            final JPopupMenu textPopup = new JPopupMenu();
            JLabel copy = new JLabel("Copy");
            copy.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseReleased(MouseEvent paramMouseEvent) {
                    textPopup.setVisible(false);
                    if (text.getSelectedText() != null && text.getSelectedText().length() != 0) {
                        StringSelection selection = new StringSelection(text.getSelectedText());
                        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
                        clipboard.setContents(selection, selection);
                    }
                }
            });
            textPopup.add(copy);
            text.addMouseListener(new MouseAdapter() {
                public void mousePressed(MouseEvent e) {
                }

                public void mouseReleased(MouseEvent e) {
                    if (SwingUtilities.isRightMouseButton(e))
                        textPopup.show(text, e.getX(), e.getY());
                }
            });
            add(userScroller);
            repaint();
        }
    });
}

From source file:edu.ku.brc.specify.plugins.ipadexporter.iPadDBExporterPlugin.java

/**
 * //from w w w.j  a v a  2 s  .co  m
 */
private void removeDataset() {
    Institution inst = iPadDBExporter.getCurrentInstitution();
    List<Pair<String, String>> list = iPadCloud.getDatasetList(inst.getGuid());
    if (list != null && list.size() > 0) {
        CellConstraints cc = new CellConstraints();

        final JList<String> dsList = new JList<String>(new DSListModel(list));
        PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "p,4px,f:p:g"));
        pb.add(UIHelper.createI18NLabel("Choose a Dataset to remove"), cc.xy(1, 1));
        pb.add(dsList, cc.xy(1, 3));
        pb.setDefaultDialogBorder();
        final CustomDialog dlg = new CustomDialog((Frame) getMostRecentWindow(), "Remove Collection", true,
                pb.getPanel());
        dsList.addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                    dlg.getOkBtn().setEnabled(!dsList.isSelectionEmpty());
                }
            }
        });
        dlg.setPreferredSize(new Dimension(300, 400));
        dlg.createUI();
        dlg.getOkBtn().setEnabled(false);
        centerAndShow(dlg, 300, 400);
        if (!dlg.isCancelled()) {
            String collectionGUID = list.get(dsList.getSelectedIndex()).first;
            if (StringUtils.isNotEmpty(collectionGUID)) {
                if (iPadCloud.removeDataSet(collectionGUID)) {
                    enableRemoveDatasetBtn();
                    UIRegistry.writeTimedSimpleGlassPaneMsg("The dataset was removed.");
                } else {
                    UIRegistry.writeTimedSimpleGlassPaneMsg("The dataset was not removed.");
                }
            }
        }
        return;
    }
    UIRegistry.showError("You do not have Datasets to remove."); // should not get here
}

From source file:fr.duminy.components.swing.listpanel.ListPanelFixtureTest.java

@SuppressWarnings("unchecked")
public ListData buildAndShowList(boolean withNoise, final StandardListPanelFeature... features)
        throws Exception {
    final DefaultMutableListModel[] listModel = new DefaultMutableListModel[1];
    final JList[] list = new JList[1];
    final MockItemManager[] itemManager = new MockItemManager[1];
    Supplier<ListPanel<String, JList<String>>> supplier = new Supplier<ListPanel<String, JList<String>>>() {
        @Override//from  ww w . j  a va2s  .  co  m
        public ListPanel<String, JList<String>> get() {
            listModel[0] = new DefaultMutableListModel<String>();
            listModel[0].add(LINE1);
            listModel[0].add(LINE2);
            list[0] = new JList<String>(listModel[0]);
            list[0].setSelectedIndex(SELECTED_INDEX);
            itemManager[0] = Mockito.spy(new MockItemManager(false));

            final ListPanel<String, JList<String>> listPanel = new ListPanel<>(list[0], itemManager[0]);
            listPanel.setName(COMPONENT_NAME);
            for (StandardListPanelFeature feature : features) {
                listPanel.addFeature(feature);
            }
            return listPanel;
        }
    };

    if (withNoise) {
        SupplierWithNoise<ListPanel<String, JList<String>>> supplierWithNoise = buildAndShowComponentWithNoise(
                supplier);
        ListPanelFixture<String, JList<String>> fixture = new ListPanelFixture<>(robot(),
                supplierWithNoise.getTargetComponent());

        return new ListData(listModel[0], list[0], fixture, itemManager[0], supplierWithNoise);
    } else {
        ListPanel<String, JList<String>> listPanel = buildAndShowWindow(supplier);
        ListPanelFixture<String, JList<String>> fixture = new ListPanelFixture<>(robot(), listPanel);

        return new ListData(listModel[0], list[0], fixture, itemManager[0], null);
    }
}