Java Code Examples for org.jdesktop.swingx.JXTreeTable

The following examples show how to use org.jdesktop.swingx.JXTreeTable. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: aion-germany   Source File: ProtocolTab.java    License: GNU General Public License v3.0 6 votes vote down vote up
private JXTreeTable createTreeTable(PacketFormat format) {
	JXTreeTable partsTreeTable = new JXTreeTable(new PacketPartsTreeTableModel(format));
	partsTreeTable.setDefaultEditor(TreeTableModel.class, new TreeTableComboBoxCellEditor(partsTreeTable));
	partsTreeTable.setDefaultEditor(String.class, new TreeTableTextCellEditor(partsTreeTable));
	partsTreeTable.setDefaultEditor(Integer.class, new TreeTableTextCellEditor(partsTreeTable));
	partsTreeTable.setTreeCellRenderer(new PacketPartsTreeRenderer(partsTreeTable, format));
	partsTreeTable.setRootVisible(false);
	partsTreeTable.addTreeExpansionListener(new PacketPartsTreeExpensionListener(partsTreeTable));
	// partsTreeTable.getColumnModel().getColumn(2).setMaxWidth(25);
	// partsTreeTable.getColumnModel().getColumn(3).setMaxWidth(115);
	// partsTreeTable.getColumnModel().getColumn(3).setPreferredWidth(105);
	resizeTreeColumn(partsTreeTable);
	TreeTableComboBoxCellEditor editor = (TreeTableComboBoxCellEditor) partsTreeTable
		.getDefaultEditor(TreeTableModel.class);
	JComboBox<?> combo = editor.getComboBox();
	combo.setRenderer(new IconComboBoxRenderer());
	_partsTreeTable = partsTreeTable;
	return partsTreeTable;
}
 
Example 2
Source Project: SIMVA-SoS   Source File: NewJFrame.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @param evt Activates start button for single simulation
 */
private void Start_Button1ActionPerformed(java.awt.event.ActionEvent evt) {
    // start button for single simulation
    
    fileBufferSingle.clear();
    
    System.setOut(this.printStreamSingle);
    System.setErr(this.printStreamSingle);
    
    //This is for tree table on single simulation
    MyTreeTableModel treeTableModel = new MyTreeTableModel();
    JXTreeTable jXTreeTable = new JXTreeTable(treeTableModel);
    jScrollPane3.getViewport().add(jXTreeTable);
    
    //drawign line graph
    try {
        createDataset();
        
    } catch (Exception wow) {
    
    }
}
 
Example 3
Source Project: cuba   Source File: TreeTableModelAdapter.java    License: Apache License 2.0 6 votes vote down vote up
public TreeTableModelAdapter(JXTreeTable treeTable, HierarchicalDatasource datasource, List<Table.Column> columns,
                             boolean autoRefresh) {

    this.treeTable = treeTable;
    this.treeDelegate = createTreeModelAdapter(datasource, autoRefresh);
    this.tableDelegate = new TableModelAdapter(datasource, columns, autoRefresh);

    collectionChangeListener = e -> {
        Object root1 = getRoot();
        // Fixes #1160
        JXTreeTableExt impl = (JXTreeTableExt) TreeTableModelAdapter.this.treeTable;
        impl.setAutoCreateColumnsFromModel(false);
        impl.backupExpandedNodes();

        for (DataChangeListener changeListener : changeListeners) {
            changeListener.beforeChange(true);
        }

        modelSupport.fireTreeStructureChanged(root1 == null ? null : new TreePath(root1));
    };
    //noinspection unchecked
    datasource.addCollectionChangeListener(new WeakCollectionChangeListener(datasource, collectionChangeListener));
}
 
Example 4
Source Project: cuba   Source File: DesktopTreeTable.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void applyFont(JTable table, Font font) {
    JXTreeTable treeTable = (JXTreeTable) table;
    if (treeTable.getModel() != null && impl != null) {
        int hierarchicalColumn = treeTable.getHierarchicalColumn();
        TableCellRenderer cellRenderer = treeTable.getCellRenderer(0, hierarchicalColumn);
        if (cellRenderer instanceof DesktopAbstractTable.StylingCellRenderer) {
            cellRenderer = ((DesktopAbstractTable.StylingCellRenderer) cellRenderer).getDelegate();
        }
        if (cellRenderer instanceof JXTree) {
            // default JXTreeTable renderer for hierarchical column is JXTree
            ((JXTree) cellRenderer).setFont(font);
        }
    }
    super.applyFont(table, font);
}
 
Example 5
public List<Task> getVisibleNodes(JXTreeTable jtree, int minHeight, int maxHeight, int nodeHeight) {
  List<MutableTreeTableNode> preorderedNodes = TreeUtil.collectSubtree((MutableTreeTableNode) jtree.getTreeTableModel().getRoot());
  List<Task> result = new ArrayList<Task>();
  int currentHeight = 0;
  for (int i = 1; i < preorderedNodes.size(); i++) {
    MutableTreeTableNode nextNode = preorderedNodes.get(i);
    if (false == nextNode.getUserObject() instanceof Task) {
      continue;
    }
    if ((currentHeight + nodeHeight) > minHeight && jtree.isVisible(TreeUtil.createPath(nextNode))) {
      result.add((Task) nextNode.getUserObject());
    }
    if (jtree.isVisible(TreeUtil.createPath(nextNode))) {
      currentHeight += nodeHeight;
    }
    if (currentHeight > minHeight + maxHeight) {
      break;
    }
  }
  return result;
}
 
Example 6
@Override
public boolean canImport(TransferHandler.TransferSupport support) {
  if (!support.isDrop()) {
    return false;
  }
  support.setShowDropLocation(true);
  if (!support.isDataFlavorSupported(GPTransferable.INTERNAL_DATA_FLAVOR)) {
    return false;
  }
  // Do not allow a drop on the drag source selections.
  JXTreeTable.DropLocation dl = (JXTreeTable.DropLocation) support.getDropLocation();
  int dropRow = myTreeTable.rowAtPoint(dl.getDropPoint());
  int[] selRows = myTreeTable.getSelectedRows();
  for (int i = 0; i < selRows.length; i++) {
    if (selRows[i] == dropRow) {
      return false;
    }
  }
  return true;
}
 
Example 7
Source Project: aion-germany   Source File: ProtocolTab.java    License: GNU General Public License v3.0 5 votes vote down vote up
private static void resizeTreeColumn(JXTreeTable treeTable) {
	/*
	 * TableCellRenderer headerRenderer = treeTable.getTableHeader().getDefaultRenderer(); TableColumn column =
	 * treeTable.getColumnModel().getColumn(0); Component comp = headerRenderer.getTableCellRendererComponent( null,
	 * column.getHeaderValue(), false, false, 0, 0); int headerWidth = comp.getPreferredSize().width; int cellWidth =
	 * treeTable.getMaximumSize().width; cellWidth += 40; //offset for the comboBox int newWith = Math.max(headerWidth,
	 * cellWidth); column.setPreferredWidth(newWith); column.setMinWidth(newWith); column.setMaxWidth(newWith);
	 */
	treeTable.sizeColumnsToFit(0);
}
 
Example 8
Source Project: ramus   Source File: TableRowHeader.java    License: GNU General Public License v3.0 5 votes vote down vote up
public TableRowHeader(final JXTreeTable table, final QualifierModel model) {
    super(new TableRowHeaderModel(table));
    this.table = table;
    this.model = model;
    // ((RowTreeTable) table).setHeader(this);
    m = preferredHeaderWidth();
    setFixedCellHeight(table.getRowHeight());
    setFixedCellWidth(m);
    setCellRenderer(renderer);

    setSelectionModel(table.getSelectionModel());
    table.getModel().addTableModelListener(listener);
    addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(final MouseEvent e) {
            final int index = locationToIndex(e.getPoint());
            if (index >= 0) {
                final Row row = (Row) getModel().getElementAt(index);
                if (row != null) {
                    TableRowHeader.this.model.setSelectedRow(row,
                            !TableRowHeader.this.model.isChecked(row));
                    TableRowHeader.this.repaint();
                }
            }
        }
    });
}
 
Example 9
public CollectionAnalyzerWorker(CollectionEvaluator evaluator, JXTreeTable treeTable, MapTableModel<MagicEdition, Date> modelCache, AbstractBuzyIndicatorComponent buzy,JLabel labTotal) {
	this.treeTable=treeTable;
	this.cacheModel=modelCache;
	collectionModel = new CollectionAnalyzerTreeTableModel();
	this.evaluator=evaluator;
	this.buzy=buzy;
	this.lblPrice=labTotal;
	
	o=(Observable obs, Object ed)->publish((MagicEdition)ed);
	eds = evaluator.getEditions();
	buzy.start(eds.size());
	evaluator.addObserver(o);
	cacheModel.removeAll();
}
 
Example 10
@Override
public boolean importData(TransferHandler.TransferSupport support) {
  if (!canImport(support)) {
    return false;
  }
  try {
    Transferable t = support.getTransferable();
    final ClipboardContents clipboard = (ClipboardContents) t.getTransferData(GPTransferable.INTERNAL_DATA_FLAVOR);
    JXTreeTable.DropLocation dl = (JXTreeTable.DropLocation) support.getDropLocation();
    int dropRow = myTreeTable.rowAtPoint(dl.getDropPoint());
    TreePath dropPath = myTreeTable.getPathForRow(dropRow);
    if (dropPath == null) {
      return false;
    }
    DefaultMutableTreeTableNode dropNode = (DefaultMutableTreeTableNode) dropPath.getLastPathComponent();
    final Task dropTask = (Task) dropNode.getUserObject();
    final ClipboardTaskProcessor processor = new ClipboardTaskProcessor(myTaskManager);
    if (processor.canMove(dropTask, clipboard)) {
      myUndoManager.undoableEdit(GanttLanguage.getInstance().getText("dragndrop.undo.label"), new Runnable() {
        @Override
        public void run() {
          clipboard.cut();
          processor.pasteAsChild(dropTask, clipboard);
        }
      });
      return true;
    }
  } catch (UnsupportedFlavorException | IOException | RuntimeException e) {
    GPLogger.logToLogger(e);
  }
  return false;
}
 
Example 11
Source Project: GsonFormat   Source File: CheckTreeTableManager.java    License: Apache License 2.0 5 votes vote down vote up
public CheckTreeTableManager(JXTreeTable treeTable) {
    this.treetable = treeTable;
    this.tree = (JTree) treeTable.getCellRenderer(0, 0);
    selectionModel = new CheckTreeSelectionModel(tree.getModel());
    tree.setCellRenderer(new DefaultTreeRenderer(new CheckTreeCellProvider(selectionModel)));
    treeTable.addMouseListener(this);

    selectionModel.addTreeSelectionListener(this);
}
 
Example 12
Source Project: aion-germany   Source File: FileSystemPanel.java    License: GNU General Public License v3.0 4 votes vote down vote up
protected void setFileTree(JXTreeTable fileTree)
{
    _fileTree = fileTree;
}
 
Example 13
Source Project: aion-germany   Source File: FileSystemPanel.java    License: GNU General Public License v3.0 4 votes vote down vote up
public JXTreeTable getFileTree()
{
    return _fileTree;
}
 
Example 14
Source Project: aion-germany   Source File: LogFilesTab.java    License: GNU General Public License v3.0 4 votes vote down vote up
public LogSelectionListener(JXTreeTable table)
{
    _table = table;
}
 
Example 15
Source Project: aion-germany   Source File: ViewPane.java    License: GNU General Public License v3.0 4 votes vote down vote up
PartSelectionListener(JXTreeTable table) {
	_table = table;
}
 
Example 16
public TreeTableComboBoxCellEditor(JXTreeTable table)
{
	super(new PartTypeComboBox());
	this.table = table;
}
 
Example 17
public TreeTableTextCellEditor(JXTreeTable table) {
	super(new TreeTableTextField());
	this.table = table;
}
 
Example 18
Source Project: aion-germany   Source File: ProtocolTab.java    License: GNU General Public License v3.0 4 votes vote down vote up
public PacketPartsTreeRenderer(JXTreeTable partsTreeTable, PacketFormat format) {
	addMouseMotionListener(new PacketPartMouseMotionListener(partsTreeTable, format));
	addMouseListener(new PacketPartMouseMotionListener(partsTreeTable, format));
}
 
Example 19
Source Project: aion-germany   Source File: ProtocolTab.java    License: GNU General Public License v3.0 4 votes vote down vote up
public PacketPartsTreeExpensionListener(JXTreeTable partsTreeTable) {
	_treeTable = partsTreeTable;
}
 
Example 20
Source Project: aion-germany   Source File: ProtocolTab.java    License: GNU General Public License v3.0 4 votes vote down vote up
public PacketPartMouseMotionListener(JXTreeTable partsTreeTable, PacketFormat format) {
	_treeTable = partsTreeTable;
	_format = format;
}
 
Example 21
Source Project: ramus   Source File: TableRowHeaderModel.java    License: GNU General Public License v3.0 4 votes vote down vote up
public TableRowHeaderModel(JXTreeTable table) {
    this.table = table;
}
 
Example 22
@SuppressWarnings("unchecked")
private <T extends MTGPlugin> void createTab(String label, Icon ic, PluginEntry<T> pe)
{
	
	if(pe.getPlugins().isEmpty())
		PluginRegistry.inst().listPlugins(pe.getParametrizedClass());
	
	JXTreeTable table = new JXTreeTable(new PluginTreeTableModel<>(pe.isMultiprovider(), pe.getPlugins()));
	table.setShowGrid(true, false);
	table.setTreeCellRenderer(new MTGPluginTreeCellRenderer());
	table.setDefaultRenderer(Boolean.class, (JTable t, Object value, boolean isSelected,boolean hasFocus, int row, int column)->{
			JPanel p = new JPanel();
			JCheckBox cbox = new JCheckBox("",Boolean.parseBoolean(value.toString()));
			cbox.setOpaque(false);
			p.add(cbox);
			
			if(isSelected)
				p.setBackground(table.getSelectionBackground());
			else
				p.setBackground(table.getBackground());
			
			return p;
	});
	
	subTabbedProviders.addTab(label, ic,new JScrollPane(table), null);
	table.addTreeSelectionListener(e -> {
		
		if (e.getNewLeadSelectionPath() != null && e.getNewLeadSelectionPath().getPathCount() > 1)
			((PluginTreeTableModel<?>) table.getTreeTableModel()).setSelectedNode((T) e.getNewLeadSelectionPath().getPathComponent(1));
		
		
		if(e.getNewLeadSelectionPath()!=null)
		{
			lblCopyright.setText(((T) e.getNewLeadSelectionPath().getPathComponent(1)).termsAndCondition());
			
			if(e.getNewLeadSelectionPath().getLastPathComponent() instanceof MTGPlugin)
				helpComponent.init(((T) e.getNewLeadSelectionPath().getPathComponent(1)));
		}
	});
	table.packAll();
}
 
Example 23
Source Project: ganttproject   Source File: GanttTree2.java    License: GNU General Public License v3.0 4 votes vote down vote up
/** @return the JTree. */
JXTreeTable getJTree() {
  return getTreeTable();
}
 
Example 24
Source Project: ganttproject   Source File: GPTreeTableBase.java    License: GNU General Public License v3.0 4 votes vote down vote up
ColumnImpl(JXTreeTable table, TableColumnExt tableColumn, ColumnList.Column stub) {
  myTable = table;
  myTableColumn = tableColumn;
  myStub = stub;
}
 
Example 25
Source Project: ganttproject   Source File: GPTreeTableBase.java    License: GNU General Public License v3.0 4 votes vote down vote up
public JXTreeTable getTree() {
  return this;
}
 
Example 26
Source Project: ganttproject   Source File: GPTreeTableBase.java    License: GNU General Public License v3.0 4 votes vote down vote up
public JXTreeTable getTreeTable() {
  return this;
}
 
Example 27
protected JXTreeTable getTree() {
  return getTreeTable().getTree();
}