Example usage for javax.swing JTable getClientProperty

List of usage examples for javax.swing JTable getClientProperty

Introduction

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

Prototype

public final Object getClientProperty(Object key) 

Source Link

Document

Returns the value of the property with the specified key.

Usage

From source file:com.aw.swing.mvp.view.IPView.java

public java.util.List getGridCmps(int index) {
    java.util.List components = new ArrayList();
    JPanel jPanel = getPnlTitGrid(index);
    JPanel pnlToolBarGrid = getPnlToolBarGrid(index);
    components.add(jPanel);//from  w ww .  j a  v a2  s  . c om
    components.addAll(Arrays.asList(jPanel.getComponents()));
    if (pnlToolBarGrid != null) {
        components.addAll(Arrays.asList(pnlToolBarGrid.getComponents()));
    }
    JTable jTable = getTblGrid(index);
    components.add(jTable);
    JTable fixedTable = (JTable) jTable.getClientProperty(BndSJTable.CP_FIXED_TABLE);
    if (fixedTable != null) {
        components.add(fixedTable);
    }
    return components;
}

From source file:storybook.ui.table.renderer.AttributesTableCellRenderer.java

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    MainFrame mainFrame = (MainFrame) table.getClientProperty(ClientPropertyName.MAIN_FRAME.toString());
    JLabel lbText = (JLabel) super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row,
            column);/*from  w ww .  j a  v  a 2s .c o  m*/
    if (value == null || value instanceof String) {
        return lbText;
    }
    try {
        @SuppressWarnings("unchecked")
        List<Attribute> list = (List<Attribute>) value;
        if (list == null || list.isEmpty()) {
            return lbText;
        }
        try {
            lbText.setText(StringUtils.join(list, ", "));
        } catch (NullPointerException e) {
            // ignore
        }
    } catch (LazyInitializationException lie) {
        BookModel model = mainFrame.getBookModel();
        Session session = model.beginTransaction();
        @SuppressWarnings("unchecked")
        List<Attribute> list = (List<Attribute>) value;
        try {
            for (Attribute property : list) {
                session.refresh(property);
            }
            lbText.setText(StringUtils.join(list, ", "));
            model.commit();
        } catch (Exception e) {
            // ignore
            // e.printStackTrace();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return lbText;
}

From source file:storybook.ui.table.renderer.ItemsTableCellRenderer.java

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    JLabel lbText = (JLabel) super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row,
            column);//from   www .  j a v a 2s.co  m
    if (value instanceof String) {
        return lbText;
    }
    @SuppressWarnings("unchecked")
    List<Item> list = (List<Item>) value;
    try {
        lbText.setText(StringUtils.join(list, ", "));
    } catch (LazyInitializationException lie) {
        MainFrame mainFrame = (MainFrame) table.getClientProperty(ClientPropertyName.MAIN_FRAME.toString());
        BookModel model = mainFrame.getBookModel();
        Session session = model.beginTransaction();
        for (Item item : list) {
            session.refresh(item);
        }
        lbText.setText(StringUtils.join(list, ", "));
        model.commit();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return lbText;
}

From source file:storybook.ui.table.renderer.LocationsTableCellRenderer.java

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    JLabel lbText = (JLabel) super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row,
            column);/*from  w ww . ja va 2 s .c  o m*/
    if (value instanceof String) {
        return lbText;
    } else {
        @SuppressWarnings("unchecked")
        List<Location> list = (List<Location>) value;
        try {
            lbText.setText(StringUtils.join(list, ", "));
        } catch (LazyInitializationException lie) {
            MainFrame mainFrame = (MainFrame) table.getClientProperty(ClientPropertyName.MAIN_FRAME.toString());
            BookModel model = mainFrame.getBookModel();
            Session session = model.beginTransaction();
            for (Location location : list) {
                session.refresh(location);
            }
            lbText.setText(StringUtils.join(list, ", "));
            model.commit();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return lbText;
}

From source file:storybook.ui.table.renderer.PersonsTableCellRenderer.java

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    JLabel lbText = (JLabel) super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row,
            column);//w  w w  .  j av a2  s  .  c  o m
    if (value instanceof String) {
        return lbText;
    }
    @SuppressWarnings("unchecked")
    List<Person> list = (List<Person>) value;
    List<String> abbrList = new ArrayList<String>();
    try {
        for (Person person : list) {
            abbrList.add(person.getAbbr());
            // CleverLabel lb = new CleverLabel(person.getAbbr());
            // lb.setBackground(person.getJColor());
            // panel.add(lb);
        }
    } catch (LazyInitializationException lie) {
        MainFrame mainFrame = (MainFrame) table.getClientProperty(ClientPropertyName.MAIN_FRAME.toString());
        BookModel model = mainFrame.getBookModel();
        Session session = model.beginTransaction();
        for (Person person : list) {
            session.refresh(person);
            abbrList.add(person.getAbbr());
        }
        model.commit();
    } catch (Exception e) {
        e.printStackTrace();
        return lbText;
    }
    lbText.setText(" " + StringUtils.join(abbrList, ", "));
    return lbText;
}

From source file:storybook.ui.table.renderer.StrandsTableCellRenderer.java

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    MainFrame mainFrame = (MainFrame) table.getClientProperty(ClientPropertyName.MAIN_FRAME.toString());
    JLabel lbText = (JLabel) super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row,
            column);// w ww  .j  a v  a  2  s  .c  o m
    if (value instanceof String) {
        return lbText;
    }
    List<String> abbrList = new ArrayList<String>();
    try {
        @SuppressWarnings("unchecked")
        List<Strand> list = (List<Strand>) value;
        for (Strand strand : list) {
            abbrList.add(strand.getAbbr());
        }
    } catch (LazyInitializationException lie) {
        BookModel model = mainFrame.getBookModel();
        Session session = model.beginTransaction();
        @SuppressWarnings("unchecked")
        List<Strand> list = (List<Strand>) value;
        for (Strand strand : list) {
            session.refresh(strand);
            abbrList.add(strand.getAbbr());
        }
        model.commit();
    } catch (Exception e) {
        e.printStackTrace();
        return lbText;
    }
    lbText.setText(" " + StringUtils.join(abbrList, ", "));
    return lbText;
}