org.jdesktop.swingx.JXTreeTable Java Examples

The following examples show how to use org.jdesktop.swingx.JXTreeTable. 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 File: GPTreeTransferHandler.java    From ganttproject with GNU General Public License v3.0 6 votes vote down vote up
@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 #2
Source File: VisibleNodesFilter.java    From ganttproject with GNU General Public License v3.0 6 votes vote down vote up
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 #3
Source File: DesktopTreeTable.java    From cuba with 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 #4
Source File: ProtocolTab.java    From aion-germany with 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 #5
Source File: TreeTableModelAdapter.java    From cuba with 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 #6
Source File: NewJFrame.java    From SIMVA-SoS with 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 #7
Source File: CheckTreeTableManager.java    From GsonFormat with 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 #8
Source File: GPTreeTransferHandler.java    From ganttproject with GNU General Public License v3.0 5 votes vote down vote up
@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 #9
Source File: CollectionAnalyzerWorker.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
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
Source File: TableRowHeader.java    From ramus with 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 #11
Source File: ProtocolTab.java    From aion-germany with 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 #12
Source File: GanttTree2.java    From ganttproject with GNU General Public License v3.0 4 votes vote down vote up
/** @return the JTree. */
JXTreeTable getJTree() {
  return getTreeTable();
}
 
Example #13
Source File: FileSystemPanel.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
protected void setFileTree(JXTreeTable fileTree)
{
    _fileTree = fileTree;
}
 
Example #14
Source File: TreeTableContainer.java    From ganttproject with GNU General Public License v3.0 4 votes vote down vote up
protected JXTreeTable getTree() {
  return getTreeTable().getTree();
}
 
Example #15
Source File: GPTreeTableBase.java    From ganttproject with GNU General Public License v3.0 4 votes vote down vote up
public JXTreeTable getTreeTable() {
  return this;
}
 
Example #16
Source File: GPTreeTableBase.java    From ganttproject with GNU General Public License v3.0 4 votes vote down vote up
public JXTreeTable getTree() {
  return this;
}
 
Example #17
Source File: GPTreeTableBase.java    From ganttproject with 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 #18
Source File: FileSystemPanel.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
public JXTreeTable getFileTree()
{
    return _fileTree;
}
 
Example #19
Source File: LogFilesTab.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
public LogSelectionListener(JXTreeTable table)
{
    _table = table;
}
 
Example #20
Source File: ViewPane.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
PartSelectionListener(JXTreeTable table) {
	_table = table;
}
 
Example #21
Source File: ProtocolTab.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
public PacketPartMouseMotionListener(JXTreeTable partsTreeTable, PacketFormat format) {
	_treeTable = partsTreeTable;
	_format = format;
}
 
Example #22
Source File: ConfigurationPanelGUI.java    From MtgDesktopCompanion with GNU General Public License v3.0 4 votes vote down vote up
@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 File: TreeTableComboBoxCellEditor.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
public TreeTableComboBoxCellEditor(JXTreeTable table)
{
	super(new PartTypeComboBox());
	this.table = table;
}
 
Example #24
Source File: TreeTableTextCellEditor.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
public TreeTableTextCellEditor(JXTreeTable table) {
	super(new TreeTableTextField());
	this.table = table;
}
 
Example #25
Source File: ProtocolTab.java    From aion-germany with 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 #26
Source File: TableRowHeaderModel.java    From ramus with GNU General Public License v3.0 4 votes vote down vote up
public TableRowHeaderModel(JXTreeTable table) {
    this.table = table;
}
 
Example #27
Source File: ProtocolTab.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
public PacketPartsTreeExpensionListener(JXTreeTable partsTreeTable) {
	_treeTable = partsTreeTable;
}