javax.swing.SortOrder Java Examples
The following examples show how to use
javax.swing.SortOrder.
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: BrowserViewSupport.java From visualvm with GNU General Public License v2.0 | 6 votes |
private void initComponents() { tableModel = new EventsTableModel(); table = new ProfilerTable(tableModel, true, true, null); table.setFitWidthColumn(-1); table.setSorting(0, SortOrder.UNSORTED); table.setDefaultSortOrder(SortOrder.ASCENDING); table.setDefaultRenderer(Comparable.class, new LabelRenderer()); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { int selected = table.getSelectedRow(); if (selected == 0 && values[0] == null) selected = -1; // "loading events..." idSelected(selected == -1 ? -1 : ids[table.convertRowIndexToModel(selected)]); } } }); setLayout(new BorderLayout()); add(new ProfilerTableContainer(table, false, null), BorderLayout.CENTER); }
Example #2
Source File: TreeTableView.java From visualvm with GNU General Public License v2.0 | 6 votes |
public void setSortColumn(DataType dataType, SortOrder sortOrder) { if (treeTable == null) { initialSortColumn = dataType; initialSortOrder = sortOrder; } else { int column = getColumn(dataType); if (column == -1) return; if (sortOrder == null) sortOrder = SortOrder.UNSORTED; List<? extends RowSorter.SortKey> sortKeys = treeTable.getRowSorter().getSortKeys(); if (sortKeys != null && sortKeys.size() == 1) { RowSorter.SortKey sortKey = sortKeys.get(0); if (sortKey.getColumn() == column && sortOrder.equals(sortKey.getSortOrder())) return; } treeTable.setSorting(column, sortOrder); } }
Example #3
Source File: LuckTableCellHeaderRenderer.java From littleluck with Apache License 2.0 | 6 votes |
public static SortOrder getColumnSortOrder(JTable table, int column) { SortOrder rv = null; if (table == null || table.getRowSorter() == null) { return rv; } java.util.List<? extends RowSorter.SortKey> sortKeys = table .getRowSorter().getSortKeys(); if (sortKeys.size() > 0 && sortKeys.get(0).getColumn() == table .convertColumnIndexToModel(column)) { rv = sortKeys.get(0).getSortOrder(); } return rv; }
Example #4
Source File: ProfilerRowSorter.java From visualvm with GNU General Public License v2.0 | 6 votes |
void loadFromStorage(Properties properties, ProfilerTable table) { String columnS = properties.getProperty(SORT_COLUMN_KEY); String orderS = properties.getProperty(SORT_ORDER_KEY); if (columnS != null) { try { int column = Integer.parseInt(columnS); SortOrder order = getSortOrder(orderS); // if (SortOrder.UNSORTED.equals(order)) order = getDefaultSortOrder(column); setSortColumn(column, order); } catch (NumberFormatException e) { // Reset sorting? Set default column? } } else { // Reset sorting? Set default column? } }
Example #5
Source File: JavaSysPropsPage.java From scelight with Apache License 2.0 | 6 votes |
@Override public JComponent createPageComp() { final BorderPanel p = new BorderPanel(); final XTable table = new XTable(); final Vector< Vector< Object > > data = new Vector<>(); final Properties props = System.getProperties(); // Use name enumeration which properly returns names from the default properties of a property // (while HashTable.entrySet() does not!). final Enumeration< ? > nameEnum = props.propertyNames(); while ( nameEnum.hasMoreElements() ) { final Object name = nameEnum.nextElement(); data.add( Utils.vector( name, props.getProperty( name.toString() ) ) ); } table.getXTableModel().setDataVector( data, Utils.vector( "Property name", "Property value" ) ); table.getRowSorter().setSortKeys( Arrays.asList( new SortKey( 0, SortOrder.ASCENDING ) ) ); table.packColumnsExceptLast(); p.addCenter( table.createWrapperBox( true, table.createToolBarParams( p ) ) ); return p; }
Example #6
Source File: NetworkMonitorTopComponent.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void toggleSortOrder(int column) { List<? extends SortKey> sortKeys = getSortKeys(); if (!sortKeys.isEmpty()) { SortKey sortKey = sortKeys.get(0); if (sortKey.getColumn() == column && sortKey.getSortOrder() == SortOrder.DESCENDING) { setSortKeys(null); return; } } super.toggleSortOrder(column); }
Example #7
Source File: MoreObjectsNode.java From visualvm with GNU General Public License v2.0 | 5 votes |
private HeapViewerNode[] computeChildren(int containerIndex, Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) throws InterruptedException { // long start = System.currentTimeMillis(); // try { // No sorting - plain fetch SortOrder sortOrder = sortOrders == null || sortOrders.isEmpty() ? null : sortOrders.get(0); if (sortOrder == null || sortOrder.equals(SortOrder.UNSORTED)) return MoreObjectsNode.this.loadChildren(containerIndex, progress); // Sorting by count or own size - plain fetch DataType dataType = dataTypes == null || dataTypes.isEmpty() ? null : dataTypes.get(0); if (dataType == null || !sorts(dataType)) return MoreObjectsNode.this.loadChildren(containerIndex, progress); // Sorting - must resolve instanceIDs T[] objects = MoreObjectsNode.this.getObjects(containerIndex, heap, null, dataType, sortOrder, progress); // System.err.println(">>> Children: " + Arrays.toString(objects)); Thread worker = Thread.currentThread(); HeapViewerNode[] nodes = new HeapViewerNode[objects.length]; for (int i = 0; i < nodes.length; i++) { // System.err.println(">>> Creating node at idx " + i + " from object " + objects[i]); nodes[i] = createNode(objects[i]); if (worker.isInterrupted()) throw new InterruptedException(); } return nodes; // } finally { // System.err.println(">>> Container " + containerIndex + " computed in " + (System.currentTimeMillis() - start)); // } }
Example #8
Source File: PanamaHitek_DataBuffer.java From PanamaHitek_Arduino with GNU Lesser General Public License v3.0 | 5 votes |
/** * Permite ordenar los datos en una columna de la tabla que genera la clase * * @param column La columna que se desea ordenar * @param ascending si se desea un orden ascendente o descendente * * @since 3.0.3 */ public void sortColumn(int column, boolean ascending) { TableRowSorter<TableModel> sorter = new TableRowSorter<>(table.getModel()); table.setRowSorter(sorter); List<RowSorter.SortKey> sortKeys = new ArrayList<>(); if (ascending) { sortKeys.add(new RowSorter.SortKey(column, SortOrder.ASCENDING)); } else { sortKeys.add(new RowSorter.SortKey(column, SortOrder.DESCENDING)); } sorter.setSortKeys(sortKeys); sorter.sort(); }
Example #9
Source File: TreeTableView.java From visualvm with GNU General Public License v2.0 | 5 votes |
protected void initializeColumns(DataType initialSortColumn, SortOrder initialSortOrder, ColumnConfiguration initialColumnConfiguration) { if (initialSortColumn != null) { SortOrder sortOder = initialSortOrder == null ? SortOrder.UNSORTED : initialSortOrder; setSortColumn(initialSortColumn, sortOder); } if (initialColumnConfiguration != null) configureColumns(initialColumnConfiguration); }
Example #10
Source File: DefaultRowSorter.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Reverses the sort order from ascending to descending (or * descending to ascending) if the specified column is already the * primary sorted column; otherwise, makes the specified column * the primary sorted column, with an ascending sort order. If * the specified column is not sortable, this method has no * effect. * * @param column index of the column to make the primary sorted column, * in terms of the underlying model * @throws IndexOutOfBoundsException {@inheritDoc} * @see #setSortable(int,boolean) * @see #setMaxSortKeys(int) */ public void toggleSortOrder(int column) { checkColumn(column); if (isSortable(column)) { List<SortKey> keys = new ArrayList<SortKey>(getSortKeys()); SortKey sortKey; int sortIndex; for (sortIndex = keys.size() - 1; sortIndex >= 0; sortIndex--) { if (keys.get(sortIndex).getColumn() == column) { break; } } if (sortIndex == -1) { // Key doesn't exist sortKey = new SortKey(column, SortOrder.ASCENDING); keys.add(0, sortKey); } else if (sortIndex == 0) { // It's the primary sorting key, toggle it keys.set(0, toggle(keys.get(0))); } else { // It's not the first, but was sorted on, remove old // entry, insert as first with ascending. keys.remove(sortIndex); keys.add(0, new SortKey(column, SortOrder.ASCENDING)); } if (keys.size() > getMaxSortKeys()) { keys = keys.subList(0, getMaxSortKeys()); } setSortKeys(keys); } }
Example #11
Source File: DefaultRowSorter.java From Java8CN with Apache License 2.0 | 5 votes |
/** * Reverses the sort order from ascending to descending (or * descending to ascending) if the specified column is already the * primary sorted column; otherwise, makes the specified column * the primary sorted column, with an ascending sort order. If * the specified column is not sortable, this method has no * effect. * * @param column index of the column to make the primary sorted column, * in terms of the underlying model * @throws IndexOutOfBoundsException {@inheritDoc} * @see #setSortable(int,boolean) * @see #setMaxSortKeys(int) */ public void toggleSortOrder(int column) { checkColumn(column); if (isSortable(column)) { List<SortKey> keys = new ArrayList<SortKey>(getSortKeys()); SortKey sortKey; int sortIndex; for (sortIndex = keys.size() - 1; sortIndex >= 0; sortIndex--) { if (keys.get(sortIndex).getColumn() == column) { break; } } if (sortIndex == -1) { // Key doesn't exist sortKey = new SortKey(column, SortOrder.ASCENDING); keys.add(0, sortKey); } else if (sortIndex == 0) { // It's the primary sorting key, toggle it keys.set(0, toggle(keys.get(0))); } else { // It's not the first, but was sorted on, remove old // entry, insert as first with ascending. keys.remove(sortIndex); keys.add(0, new SortKey(column, SortOrder.ASCENDING)); } if (keys.size() > getMaxSortKeys()) { keys = keys.subList(0, getMaxSortKeys()); } setSortKeys(keys); } }
Example #12
Source File: DefaultRowSorter.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Reverses the sort order from ascending to descending (or * descending to ascending) if the specified column is already the * primary sorted column; otherwise, makes the specified column * the primary sorted column, with an ascending sort order. If * the specified column is not sortable, this method has no * effect. * * @param column index of the column to make the primary sorted column, * in terms of the underlying model * @throws IndexOutOfBoundsException {@inheritDoc} * @see #setSortable(int,boolean) * @see #setMaxSortKeys(int) */ public void toggleSortOrder(int column) { checkColumn(column); if (isSortable(column)) { List<SortKey> keys = new ArrayList<SortKey>(getSortKeys()); SortKey sortKey; int sortIndex; for (sortIndex = keys.size() - 1; sortIndex >= 0; sortIndex--) { if (keys.get(sortIndex).getColumn() == column) { break; } } if (sortIndex == -1) { // Key doesn't exist sortKey = new SortKey(column, SortOrder.ASCENDING); keys.add(0, sortKey); } else if (sortIndex == 0) { // It's the primary sorting key, toggle it keys.set(0, toggle(keys.get(0))); } else { // It's not the first, but was sorted on, remove old // entry, insert as first with ascending. keys.remove(sortIndex); keys.add(0, new SortKey(column, SortOrder.ASCENDING)); } if (keys.size() > getMaxSortKeys()) { keys = keys.subList(0, getMaxSortKeys()); } setSortKeys(keys); } }
Example #13
Source File: ProfilerTable.java From visualvm with GNU General Public License v2.0 | 5 votes |
protected TableRowSorter createRowSorter() { ProfilerRowSorter s = new ProfilerRowSorter(getModel()); s.setStringConverter(new TableStringConverter() { public String toString(TableModel model, int row, int column) { return getModelStringValue(row, column); } }); s.setDefaultSortOrder(SortOrder.DESCENDING); s.setSortColumn(0); return s; }
Example #14
Source File: JavaClassesProvider.java From visualvm with GNU General Public License v2.0 | 5 votes |
public static HeapViewerNode[] getHeapPackages(HeapViewerNode parent, Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) throws InterruptedException { List<HeapViewerNode> nodes = new ArrayList(); Map<String, ClassesContainer.Objects> packages = new HashMap(); Thread worker = Thread.currentThread(); List<JavaClass> classes = heap.getAllClasses(); for (JavaClass cls : classes) { String className = cls.getName(); int nameIdx = className.lastIndexOf('.'); if (nameIdx == -1) { ClassNode clsn = new ClassNode(cls); if (viewFilter == null || viewFilter.passes(clsn, heap)) nodes.add(clsn); } else { if (viewFilter != null && !viewFilter.passes(new ClassNode(cls), heap)) continue; String pkgName = className.substring(0, nameIdx); ClassesContainer.Objects node = packages.get(pkgName); if (node == null) { node = new ClassesContainer.Objects(pkgName); nodes.add(node); packages.put(pkgName, node); } node.add(cls, heap); } if (worker.isInterrupted()) throw new InterruptedException(); } return nodes.isEmpty() ? new HeapViewerNode[] { new TextNode(Classes_Messages.getNoPackagesString(viewFilter)) } : nodes.toArray(HeapViewerNode.NO_NODES); }
Example #15
Source File: TruffleThreadsView.java From visualvm with GNU General Public License v2.0 | 5 votes |
public TruffleThreadsView(TruffleLanguage language, HeapContext context, HeapViewerActions actions) { super(idFromLanguage(language), Bundle.TruffleThreadsView_Name(), Bundle.TruffleThreadsView_Description(), iconFromLanguage(language), 300); Heap heap = context.getFragment().getHeap(); final TruffleThreadsProvider threadsProvider = new TruffleThreadsProvider(language); objectsView = new PluggableTreeTableView(getID() + OBJECTS_ID, context, actions, TreeTableViewColumn.instances(heap, false)) { @Override protected HeapViewerNode[] computeData(RootNode root, Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) throws InterruptedException { return threadsProvider.getThreadsObjects(root, heap, viewID, viewFilter, dataTypes, sortOrders, progress); } protected void childrenChanged() { CCTNode[] children = getRoot().getChildren(); for (CCTNode child : children) expandNode((HeapViewerNode)child); } }; objectsView.setViewName(getName()); htmlView = new HTMLView(getID() + HTML_ID, context, actions, "<br> " + Bundle.TruffleThreadsView_ComputingThreads()) { // NOI18N protected String computeData(HeapContext context, String viewID) { return threadsProvider.getThreadsHTML(context); } protected HeapViewerNode nodeForURL(URL url, HeapContext context) { return threadsProvider.getNodeForURL(url, context); } }; }
Example #16
Source File: ProfilerRowSorter.java From netbeans with Apache License 2.0 | 5 votes |
public void toggleSortOrder(int column) { // UNSORTED not allowed for sorting columns (default) if (!allowsThreeStateColumns()) { super.toggleSortOrder(column); return; } // Switching from one column to another if (getSortColumn() != column) { super.toggleSortOrder(column); return; } // Toggling from default sort order SortOrder so = getSortOrder(); if (Objects.equals(getDefaultSortOrder(column), so)) { super.toggleSortOrder(column); return; } // Resetting UNSORTED, use default sort order if (Objects.equals(SortOrder.UNSORTED, so)) { setSortColumn(column); return; } // Toggling from second sort order, switch to UNSORTED setSortColumn(column, SortOrder.UNSORTED); }
Example #17
Source File: DefaultRowSorter.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Reverses the sort order from ascending to descending (or * descending to ascending) if the specified column is already the * primary sorted column; otherwise, makes the specified column * the primary sorted column, with an ascending sort order. If * the specified column is not sortable, this method has no * effect. * * @param column index of the column to make the primary sorted column, * in terms of the underlying model * @throws IndexOutOfBoundsException {@inheritDoc} * @see #setSortable(int,boolean) * @see #setMaxSortKeys(int) */ public void toggleSortOrder(int column) { checkColumn(column); if (isSortable(column)) { List<SortKey> keys = new ArrayList<SortKey>(getSortKeys()); SortKey sortKey; int sortIndex; for (sortIndex = keys.size() - 1; sortIndex >= 0; sortIndex--) { if (keys.get(sortIndex).getColumn() == column) { break; } } if (sortIndex == -1) { // Key doesn't exist sortKey = new SortKey(column, SortOrder.ASCENDING); keys.add(0, sortKey); } else if (sortIndex == 0) { // It's the primary sorting key, toggle it keys.set(0, toggle(keys.get(0))); } else { // It's not the first, but was sorted on, remove old // entry, insert as first with ascending. keys.remove(sortIndex); keys.add(0, new SortKey(column, SortOrder.ASCENDING)); } if (keys.size() > getMaxSortKeys()) { keys = keys.subList(0, getMaxSortKeys()); } setSortKeys(keys); } }
Example #18
Source File: MemorySamplerViewSupport.java From visualvm with GNU General Public License v2.0 | 5 votes |
private void initComponents() { setLayout(new BorderLayout()); setOpaque(false); if (!hasData) { setLayout(new BorderLayout()); add(MessageComponent.noData("Per thread allocations", JFRSnapshotSamplerViewProvider.ThreadAllocationsChecker.checkedTypes()), BorderLayout.CENTER); } else { tableModel = new TreadsAllocTableModel(); table = new ProfilerTable(tableModel, true, true, null); table.setMainColumn(0); table.setFitWidthColumn(0); table.setSortColumn(1); table.setDefaultSortOrder(SortOrder.DESCENDING); table.setDefaultSortOrder(0, SortOrder.ASCENDING); renderers = new HideableBarRenderer[1]; renderers[0] = new HideableBarRenderer(new NumberPercentRenderer(Formatters.bytesFormat())); LabelRenderer threadRenderer = new LabelRenderer(); threadRenderer.setIcon(Icons.getIcon(ProfilerIcons.THREAD)); threadRenderer.setFont(threadRenderer.getFont().deriveFont(Font.BOLD)); table.setColumnRenderer(0, threadRenderer); table.setColumnRenderer(1, renderers[0]); add(new ProfilerTableContainer(table, false, null), BorderLayout.CENTER); } }
Example #19
Source File: ProfilerRowSorter.java From visualvm with GNU General Public License v2.0 | 5 votes |
public void toggleSortOrder(int column) { // UNSORTED not allowed for sorting columns (default) if (!allowsThreeStateColumns()) { super.toggleSortOrder(column); return; } // Switching from one column to another if (getSortColumn() != column) { super.toggleSortOrder(column); return; } // Toggling from default sort order SortOrder so = getSortOrder(); if (Objects.equals(getDefaultSortOrder(column), so)) { super.toggleSortOrder(column); return; } // Resetting UNSORTED, use default sort order if (Objects.equals(SortOrder.UNSORTED, so)) { setSortColumn(column); return; } // Toggling from second sort order, switch to UNSORTED setSortColumn(column, SortOrder.UNSORTED); }
Example #20
Source File: DefaultRowSorter.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Reverses the sort order from ascending to descending (or * descending to ascending) if the specified column is already the * primary sorted column; otherwise, makes the specified column * the primary sorted column, with an ascending sort order. If * the specified column is not sortable, this method has no * effect. * * @param column index of the column to make the primary sorted column, * in terms of the underlying model * @throws IndexOutOfBoundsException {@inheritDoc} * @see #setSortable(int,boolean) * @see #setMaxSortKeys(int) */ public void toggleSortOrder(int column) { checkColumn(column); if (isSortable(column)) { List<SortKey> keys = new ArrayList<SortKey>(getSortKeys()); SortKey sortKey; int sortIndex; for (sortIndex = keys.size() - 1; sortIndex >= 0; sortIndex--) { if (keys.get(sortIndex).getColumn() == column) { break; } } if (sortIndex == -1) { // Key doesn't exist sortKey = new SortKey(column, SortOrder.ASCENDING); keys.add(0, sortKey); } else if (sortIndex == 0) { // It's the primary sorting key, toggle it keys.set(0, toggle(keys.get(0))); } else { // It's not the first, but was sorted on, remove old // entry, insert as first with ascending. keys.remove(sortIndex); keys.add(0, new SortKey(column, SortOrder.ASCENDING)); } if (keys.size() > getMaxSortKeys()) { keys = keys.subList(0, getMaxSortKeys()); } setSortKeys(keys); } }
Example #21
Source File: JavaReferencesPlugin.java From visualvm with GNU General Public License v2.0 | 4 votes |
public JavaReferencesPlugin(HeapContext context, HeapViewerActions actions, final JavaReferencesProvider provider) { super(Bundle.JavaReferencesPlugin_Name(), Bundle.JavaReferencesPlugin_Description(), Icons.getIcon(ProfilerIcons.NODE_REVERSE)); heap = context.getFragment().getHeap(); TreeTableViewColumn[] columns = new TreeTableViewColumn[] { new TreeTableViewColumn.Name(heap), new TreeTableViewColumn.LogicalValue(heap), new TreeTableViewColumn.Count(heap, true, true), new TreeTableViewColumn.OwnSize(heap, false, false), new TreeTableViewColumn.RetainedSize(heap, false, false), new TreeTableViewColumn.ObjectID(heap) }; objectsView = new TreeTableView("java_objects_references", context, actions, columns) { // NOI18N protected HeapViewerNode[] computeData(RootNode root, Heap heap, String viewID, HeapViewerNodeFilter viewFilter, List<DataType> dataTypes, List<SortOrder> sortOrders, Progress progress) throws InterruptedException { if (mergedRequest) return HeapViewerNode.NO_NODES; HeapViewerNode _selected; synchronized (objectsView) { _selected = selected; } if (_selected == null) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (!CCONF_INSTANCE.equals(objectsView.getCurrentColumnConfiguration())) objectsView.configureColumns(CCONF_INSTANCE); } }); return new HeapViewerNode[] { new TextNode(Bundle.JavaReferencesPlugin_NoSelection()) }; } InstancesWrapper wrapper = HeapViewerNode.getValue(_selected, DataType.INSTANCES_WRAPPER, heap); if (wrapper != null) { SwingUtilities.invokeLater(new Runnable() { public void run() { // if (!mergedReferences && !CCONF_INSTANCE.equals(objectsView.getCurrentColumnConfiguration())) // objectsView.configureColumns(CCONF_INSTANCE); // else if (mergedReferences && !CCONF_CLASS.equals(objectsView.getCurrentColumnConfiguration())) // objectsView.configureColumns(CCONF_CLASS); if (!CCONF_CLASS.equals(objectsView.getCurrentColumnConfiguration())) objectsView.configureColumns(CCONF_CLASS); } }); // if (!mergedReferences) return new HeapViewerNode[] { new TextNode(Bundle.JavaReferencesPlugin_NoReferencesFiltered()) }; return computeInstancesReferences(wrapper, root, heap, viewID, null, dataTypes, sortOrders, progress); } else { SwingUtilities.invokeLater(new Runnable() { public void run() { if (!CCONF_INSTANCE.equals(objectsView.getCurrentColumnConfiguration())) objectsView.configureColumns(CCONF_INSTANCE); } }); Instance instance = HeapViewerNode.getValue(_selected, DataType.INSTANCE, heap); if (instance != null) { HeapViewerNode[] nodes = provider.getNodes(instance, root, heap, viewID, null, dataTypes, sortOrders, progress); return nodes == null || nodes.length == 0 ? new HeapViewerNode[] { new TextNode(Bundle.JavaReferencesPlugin_NoReferences()) } : nodes; } return new HeapViewerNode[] { new TextNode(Bundle.JavaReferencesPlugin_NoSelection()) }; } } @Override protected void populatePopup(HeapViewerNode node, JPopupMenu popup) { if (popup.getComponentCount() > 0) popup.addSeparator(); popup.add(new JCheckBoxMenuItem(Bundle.JavaReferencesPlugin_AutoComputeMergedReferencesLbl(), isAutoMerge()) { @Override protected void fireActionPerformed(ActionEvent event) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { setAutoMerge(isSelected()); } }); } }); if (!CCONF_INSTANCE.equals(objectsView.getCurrentColumnConfiguration())) popup.add(new JCheckBoxMenuItem(Bundle.JavaReferencesPlugin_MenuShowLogicalReferences(), isLogicalReferences()) { @Override protected void fireActionPerformed(ActionEvent event) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { setLogicalReferences(isSelected()); if (CCONF_CLASS.equals(objectsView.getCurrentColumnConfiguration())) { // only update view for class selection reloadView(); } } }); } }); } }; }
Example #22
Source File: CPUTableView.java From netbeans with Apache License 2.0 | 4 votes |
private void initUI() { tableModel = new CPUTableModel(); table = new ProfilerTable(tableModel, true, true, null) { public ClientUtils.SourceCodeSelection getUserValueForRow(int row) { return CPUTableView.this.getUserValueForRow(row); } protected void populatePopup(JPopupMenu popup, Object value, Object userValue) { CPUTableView.this.populatePopup(popup, value, (ClientUtils.SourceCodeSelection)userValue); } protected void popupShowing() { CPUTableView.this.popupShowing(); } protected void popupHidden() { CPUTableView.this.popupHidden(); } }; setToolTips(); table.providePopupMenu(true); installDefaultAction(); int offset = selection == null ? -1 : 0; table.setMainColumn(1 + offset); table.setFitWidthColumn(1 + offset); table.setSortColumn(3 + offset); table.setDefaultSortOrder(1 + offset, SortOrder.ASCENDING); if (selection != null) table.setColumnVisibility(0, false); table.setColumnVisibility(2 + offset, false); table.setColumnVisibility(4 + offset, false); table.setColumnVisibility(6 + offset, false); renderers = new HideableBarRenderer[5]; renderers[0] = new HideableBarRenderer(new NumberPercentRenderer(new McsTimeRenderer())); renderers[1] = new HideableBarRenderer(new NumberPercentRenderer(new McsTimeRenderer())); renderers[2] = new HideableBarRenderer(new NumberPercentRenderer(new McsTimeRenderer())); renderers[3] = new HideableBarRenderer(new NumberPercentRenderer(new McsTimeRenderer())); renderers[4] = new HideableBarRenderer(new NumberRenderer()); long refTime = 123456; renderers[0].setMaxValue(refTime); renderers[1].setMaxValue(refTime); renderers[2].setMaxValue(refTime); renderers[3].setMaxValue(refTime); renderers[4].setMaxValue(refTime); if (selection != null) table.setColumnRenderer(0, new CheckBoxRenderer() { private boolean visible; public void setValue(Object value, int row) { visible = isSelectable(idMap.get(data.getMethodIdAtRow(row))); if (visible) super.setValue(value, row); } public void paint(Graphics g) { if (visible) { super.paint(g); } else { g.setColor(getBackground()); g.fillRect(0, 0, size.width, size.height); } } }); table.setColumnRenderer(1 + offset, new JavaNameRenderer(Icons.getIcon(ProfilerIcons.NODE_LEAF))); table.setColumnRenderer(2 + offset, renderers[0]); table.setColumnRenderer(3 + offset, renderers[1]); table.setColumnRenderer(4 + offset, renderers[2]); table.setColumnRenderer(5 + offset, renderers[3]); table.setColumnRenderer(6 + offset, renderers[4]); int w; if (selection != null) { w = new JLabel(table.getColumnName(0)).getPreferredSize().width; table.setDefaultColumnWidth(0, w + 15); } table.setDefaultColumnWidth(2 + offset, renderers[0].getMaxNoBarWidth()); table.setDefaultColumnWidth(3 + offset, renderers[1].getOptimalWidth()); table.setDefaultColumnWidth(4 + offset, renderers[2].getMaxNoBarWidth()); table.setDefaultColumnWidth(5 + offset, renderers[3].getMaxNoBarWidth()); sampled = !sampled; w = new JLabel(table.getColumnName(6 + offset)).getPreferredSize().width; sampled = !sampled; w = Math.max(w, new JLabel(table.getColumnName(6 + offset)).getPreferredSize().width); table.setDefaultColumnWidth(6 + offset, Math.max(renderers[4].getNoBarWidth(), w + 15)); ProfilerTableContainer tableContainer = new ProfilerTableContainer(table, false, null); setLayout(new BorderLayout()); add(tableContainer, BorderLayout.CENTER); }
Example #23
Source File: EnvVarsPage.java From scelight with Apache License 2.0 | 4 votes |
@Override public JComponent createPageComp() { final BorderPanel p = new BorderPanel(); final XTable table = new XTable(); final Vector< Vector< Object > > data = new Vector<>(); for ( final Entry< String, String > entry : System.getenv().entrySet() ) data.add( Utils.vector( entry.getKey(), entry.getValue() ) ); table.getXTableModel().setDataVector( data, Utils.vector( "Property name", "Property value" ) ); table.getRowSorter().setSortKeys( Arrays.asList( new SortKey( 0, SortOrder.ASCENDING ) ) ); table.packColumnsExceptLast(); p.addCenter( table.createWrapperBox( true, table.createToolBarParams( p ) ) ); return p; }
Example #24
Source File: ProfilerRowSorter.java From visualvm with GNU General Public License v2.0 | 4 votes |
SortOrder getSortOrder() { RowSorter.SortKey key = getSortKey(); return key == null ? SortOrder.UNSORTED : key.getSortOrder(); }
Example #25
Source File: ProfilerRowSorter.java From netbeans with Apache License 2.0 | 4 votes |
SortOrder getDefaultSortOrder(int column) { SortOrder order = defaultSortOrders == null ? null : defaultSortOrders.get(column); return order == null ? defaultSortOrder : order; }
Example #26
Source File: ProfilerRowSorter.java From netbeans with Apache License 2.0 | 4 votes |
void setSortColumn(int column, SortOrder order) { setSortKey(new RowSorter.SortKey(column, order)); }
Example #27
Source File: LuckTableCellHeaderRenderer.java From littleluck with Apache License 2.0 | 4 votes |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (table == null) { return this; } if(column == table.getColumnCount() - 1) { setBorder(endColumnBorder); } else { setBorder(noramlBorder); } boolean isPaintingForPrint = false; if(table.getTableHeader() != null) { isPaintingForPrint = table.getTableHeader().isPaintingForPrint(); } Icon sortIcon = null; if (!isPaintingForPrint && table.getRowSorter() != null) { SortOrder sortOrder = getColumnSortOrder(table, column); if (sortOrder != null) { switch (sortOrder) { case ASCENDING: sortIcon = UIManager.getIcon("Table.ascendingSortIcon"); break; case DESCENDING: sortIcon = UIManager.getIcon("Table.descendingSortIcon"); break; case UNSORTED: break; } } } setIcon(sortIcon); setFont(table.getFont()); setValue(value); return this; }
Example #28
Source File: DefaultRowSorter.java From Java8CN with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private int compare(int model1, int model2) { int column; SortOrder sortOrder; Object v1, v2; int result; for (int counter = 0; counter < cachedSortKeys.length; counter++) { column = cachedSortKeys[counter].getColumn(); sortOrder = cachedSortKeys[counter].getSortOrder(); if (sortOrder == SortOrder.UNSORTED) { result = model1 - model2; } else { // v1 != null && v2 != null if (useToString[column]) { v1 = getModelWrapper().getStringValueAt(model1, column); v2 = getModelWrapper().getStringValueAt(model2, column); } else { v1 = getModelWrapper().getValueAt(model1, column); v2 = getModelWrapper().getValueAt(model2, column); } // Treat nulls as < then non-null if (v1 == null) { if (v2 == null) { result = 0; } else { result = -1; } } else if (v2 == null) { result = 1; } else { result = sortComparators[counter].compare(v1, v2); } if (sortOrder == SortOrder.DESCENDING) { result *= -1; } } if (result != 0) { return result; } } // If we get here, they're equal. Fallback to model order. return model1 - model2; }
Example #29
Source File: BrowserViewSupport.java From visualvm with GNU General Public License v2.0 | 4 votes |
private void initComponents(long eventsCount) { tableModel = new DataModel(); table = new ProfilerTreeTable(tableModel, true, true, new int[] { 0 }); table.setRootVisible(false); table.setShowsRootHandles(true); table.setMainColumn(0); table.setFitWidthColumn(0); table.setDefaultSortOrder(SortOrder.ASCENDING); table.setDefaultSortOrder(2, SortOrder.DESCENDING); table.setSortColumn(0); final BrowserRenderers.NameRenderer nameRenderer = new BrowserRenderers.NameRenderer(); nameRenderer.setShowsCount(!BrowserRenderers.EventsCountRenderer.isInitiallyVisible()); table.setTreeCellRenderer(nameRenderer); BrowserRenderers.TypeIDRenderer typeIDRenderer = new BrowserRenderers.TypeIDRenderer(); table.setColumnRenderer(1, typeIDRenderer); table.setDefaultColumnWidth(1, typeIDRenderer.getPreferredWidth()); table.setColumnVisibility(1, BrowserRenderers.TypeIDRenderer.isInitiallyVisible()); BrowserRenderers.EventsCountRenderer eventsCountRenderer = new BrowserRenderers.EventsCountRenderer(); HideableBarRenderer eventsCountRendererH = new HideableBarRenderer(eventsCountRenderer, eventsCountRenderer.getPreferredWidth()); eventsCountRendererH.setMaxValue(eventsCount); table.setColumnRenderer(2, eventsCountRendererH); table.setDefaultColumnWidth(2, eventsCountRendererH.getOptimalWidth()); table.setColumnVisibility(2, BrowserRenderers.EventsCountRenderer.isInitiallyVisible()); table.getColumnModel().getColumn(2).addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if ("maxWidth".equals(evt.getPropertyName())) { // NOI18N nameRenderer.setShowsCount(Integer.valueOf(0).equals(evt.getNewValue())); table.repaint(); } } }); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) refreshSelection(); } }); setLayout(new BorderLayout()); add(new ProfilerTableContainer(table, false, null), BorderLayout.CENTER); }
Example #30
Source File: ProfilerRowSorter.java From netbeans with Apache License 2.0 | 4 votes |
SortOrder getSortOrder() { RowSorter.SortKey key = getSortKey(); return key == null ? SortOrder.UNSORTED : key.getSortOrder(); }