Example usage for com.jgoodies.common.collect ArrayListModel ArrayListModel

List of usage examples for com.jgoodies.common.collect ArrayListModel ArrayListModel

Introduction

In this page you can find the example usage for com.jgoodies.common.collect ArrayListModel ArrayListModel.

Prototype

public ArrayListModel(Collection<? extends E> c) 

Source Link

Document

Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator.

Usage

From source file:cz.vity.freerapid.gui.dialogs.DownloadHistoryDialog.java

private void initTable() {
    table.setName("historyTable");
    table.setModel(new CustomTableModel(new ArrayListModel<FileHistoryItem>(manager.getItems()),
            getList("columns", 7)));
    table.setAutoCreateColumnsFromModel(false);
    table.setEditable(false);/*from   ww w.ja  va 2s  .  c  o m*/
    table.setColumnControlVisible(true);
    table.setSortable(true);
    table.setColumnMargin(10);
    table.setRolloverEnabled(true);

    if (!AppPrefs.getProperty(UserProp.SLIM_LINES_IN_HISTORY, UserProp.SLIM_LINES_IN_HISTORY_DEFAULT)) {
        table.setRowHeight(36);
    }
    table.setShowGrid(true, false);

    table.setColumnSelectionAllowed(false);

    table.getSelectionModel().addListSelectionListener(this);

    table.createDefaultColumnsFromModel();
    Swinger.updateColumn(table, "Date", COLUMN_DATE, -1, 40, new DateCellRenderer(getResourceMap()));
    Swinger.updateColumn(table, "Name", COLUMN_NAME, -1, 150,
            new FileNameCellRenderer(director.getFileTypeIconProvider()));
    Swinger.updateColumn(table, "Description", COLUMN_DESCRIPTION, -1, 170, new DescriptionCellRenderer());
    Swinger.updateColumn(table, "Size", COLUMN_SIZE, -1, 40, new SizeCellRenderer());
    Swinger.updateColumn(table, "URL", COLUMN_URL, -1, -1, SwingXUtils.getHyperLinkTableCellRenderer());
    final TableColumnExt connection = (TableColumnExt) Swinger.updateColumn(table, "Connection",
            COLUMN_CONNECTION, -1, -1, new ConnectionCellRenderer());
    final TableColumnExt avgSpeed = (TableColumnExt) Swinger.updateColumn(table, "AvgSpeed", COLUMN_AVG_SPEED,
            -1, -1, new AvgSpeedCellRenderer());
    avgSpeed.setVisible(false);
    connection.setVisible(false);

    table.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (!table.hasFocus())
                Swinger.inputFocus(table);
            if (SwingUtilities.isRightMouseButton(e))
                showPopMenu(e);
            else if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() >= 2) {
                openFileAction();
            }
        }
    });

    final InputMap tableInputMap = table.getInputMap();
    final ActionMap tableActionMap = table.getActionMap();
    final ActionMap actionMap = getActionMap();

    tableInputMap.put(SwingUtils.getCtrlKeyStroke(KeyEvent.VK_C), "copy");
    tableActionMap.put("copy", actionMap.get("copyContent"));

    tableInputMap.put(SwingUtils.getShiftKeyStroke(KeyEvent.VK_DELETE), "deleteFileAction");
    tableActionMap.put("deleteFileAction", actionMap.get("deleteFileAction"));

    tableInputMap.put(SwingUtils.getCtrlKeyStroke(KeyEvent.VK_ENTER), "openDirectoryAction");
    tableActionMap.put("openDirectoryAction", actionMap.get("openDirectoryAction"));

    final KeyStroke ctrlF = SwingUtils.getCtrlKeyStroke(KeyEvent.VK_F);
    tableInputMap.put(ctrlF, "getFocusFind");
    final AbstractAction focusFilterAction = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            Swinger.inputFocus(fieldFilter);
        }
    };
    tableActionMap.put("getFocusFind", focusFilterAction);

    table.getParent().setPreferredSize(new Dimension(600, 400));

    tableInputMap.put(SwingUtils.getShiftKeyStroke(KeyEvent.VK_HOME), "selectFirstRowExtendSelection");
    tableInputMap.put(SwingUtils.getShiftKeyStroke(KeyEvent.VK_END), "selectLastRowExtendSelection");

    registerKeyboardAction(focusFilterAction, ctrlF);
    //        this.getRootPane().getInputMap().put(ctrlF, "getFocusFind");
    //        this.getRootPane().getActionMap().put("getFocusFind", focusFilterAction);
}

From source file:xmet.ui.templates.TemplatesManagementPane.java

License:Open Source License

/**
 * Instantiates a new templates management pane.
 * @param aEditorSheet the editor sheet//from   w  w  w. j  ava2s .co  m
 * @param aContext the context
 */
public TemplatesManagementPane(final ProfileEditorSheet aEditorSheet, final ClientContext aContext) {
    this.setContext(aContext);
    this.setEditorSheet(aEditorSheet);
    setLayout(new BorderLayout());
    setTemplatesList(new JList(new ArrayListModel<EditorSheetTemplate>(aEditorSheet.getTemplates())));
    getTemplatesList().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    getTemplatesList().getSelectionModel().addListSelectionListener(this);
    final JToolBar editingToolbar = new JToolBar("Templates Management", SwingConstants.VERTICAL);
    final Object[] params = {};
    editingToolbar.add(SwingUtils.BUTTON.getNewV("Rename",
            aContext.getResources().getImageIconResource("images/toolbar.common.renameTemplate.png"),
            new ClassMethodCallback(this, "renameTemplate", params)));
    final Object[] params1 = {};
    editingToolbar.add(SwingUtils.BUTTON.getNewV("Delete",
            aContext.getResources().getImageIconResource("images/toolbar.common.deleteTemplate.png"),
            new ClassMethodCallback(this, "deleteTemplate", params1)));
    editingToolbar.setFloatable(false);
    add(new JScrollPane(getTemplatesList()));
    add(editingToolbar, BorderLayout.EAST);
}

From source file:xmet.ui.templates.TemplatesManagementPane.java

License:Open Source License

/**
 * Rename template.//from  w w w  .j av a  2  s  .  co  m
 */
public void renameTemplate() {
    try {
        final int rowIndex = getTemplatesList().getSelectedIndex();
        if ((rowIndex >= 0) && (rowIndex < getEditorSheet().getTemplates().size())) {
            final EditorSheetTemplate template = getEditorSheet().getTemplates().get(rowIndex);
            String newName = JOptionPaneUtils.getUserInputString("Please enter a new name", template.getName());
            if (newName != null && newName.trim().length() > 0 && !template.getName().equals(newName.trim())) {
                newName = newName.trim().replaceAll("[^\\p{Alnum}\\p{Blank}]", "_").trim();
                getEditorSheet().renameTemplate(template, newName, getContext().getResources());
                getTemplatesList()
                        .setModel(new ArrayListModel<EditorSheetTemplate>(getEditorSheet().getTemplates()));
            }
        }
    } catch (final Exception e) {
        e.printStackTrace();
    }
}

From source file:xmet.ui.templates.TemplatesManagementPane.java

License:Open Source License

/**
 * Delete template.// w w w . j  a v  a 2 s.c o m
 */
public void deleteTemplate() {
    try {
        final int rowIndex = getTemplatesList().getSelectedIndex();
        if ((rowIndex >= 0) && (rowIndex < getEditorSheet().getTemplates().size())) {
            final EditorSheetTemplate template = getEditorSheet().getTemplates().get(rowIndex);
            if (JOptionPaneUtils.getYesNoConfirmation("Delete Template?")) {
                template.deleteTemplate(getContext().getResources());
                getTemplatesList()
                        .setModel(new ArrayListModel<EditorSheetTemplate>(getEditorSheet().getTemplates()));
            }
        }
    } catch (final Exception e) {
        e.printStackTrace();
    }
}