List of usage examples for javax.swing SortOrder ASCENDING
SortOrder ASCENDING
To view the source code for javax.swing SortOrder ASCENDING.
Click Source Link
From source file:com.hp.alm.ali.idea.content.taskboard.TaskBoardPanel.java
private void loadTasks(final Entity sprint, final Entity team, final List<Entity> previousBacklogItems, final List<Entity> previousTasks) { EntityQuery query = new EntityQuery("release-backlog-item"); query.setStartIndex(previousBacklogItems.size() + 1); query.setPageSize(BACKLOG_ITEM_PAGE_SIZE); query.setValue("is-leaf", "Y"); query.setValue("team-id", team.getPropertyValue("id")); query.setValue("sprint-id", String.valueOf(sprint.getId())); query.setPropertyResolved("is-leaf", true); query.setPropertyResolved("team-id", true); query.addOrder("rank", SortOrder.ASCENDING); query.addOrder("id", SortOrder.ASCENDING); queue.query(query, new QueryTarget() { @Override/*from w ww .jav a 2s . c o m*/ public void handleResult(EntityList list) { updateBacklogItems(sprint, team, list, previousBacklogItems, previousTasks); } }); }
From source file:com.hp.alm.ali.idea.services.EntityService.java
private String orderToString(EntityQuery query) { StringBuffer buf = new StringBuffer(); LinkedHashMap<String, SortOrder> order = query.getOrder(); for (String name : order.keySet()) { if (buf.length() > 0) { buf.append("; "); }//from w ww . j a v a 2 s.co m buf.append(name); buf.append("["); buf.append(order.get(name) == SortOrder.ASCENDING ? "ASC" : "DESC"); buf.append("]"); } return buf.toString(); }
From source file:com.hp.alm.ali.idea.model.HorizonStrategy.java
private DetailContent acceptanceTests(Entity entity) { ActionToolbar actionToolbar = ActionUtil.createActionToolbar("hpali.acceptance-test", "detail", true); EntityQuery query = new EntityQuery("acceptance-test"); query.setValue("entity-id", String.valueOf(entity.getId())); query.setPropertyResolved("entity-id", true); query.addOrder("logical-order", SortOrder.ASCENDING); return aliStrategyUtil.detailTable(entity, query, "Acceptance Tests", IconLoader.getIcon("/fileTypes/text.png"), actionToolbar); }
From source file:com.hp.alm.ali.idea.content.taskboard.TaskBoardPanel.java
private void loadTasksChunk(final Entity sprint, final Entity team, final EntityList backlogItems, final List<Entity> previousBacklogItems, final int previousTasksTotalCount, final List<Entity> previousTasks, final int startIndex, final Runnable redo) { EntityQuery query = new EntityQuery("project-task"); query.addOrder("id", SortOrder.ASCENDING); query.setOrValues("release-backlog-item-id", backlogItems.getIdStrings()); query.setStartIndex(startIndex);// w w w . j a v a2 s . c om query.setPageSize(TASK_PAGE_SIZE); final EntityList tasks = entityService.query(query); UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { final EntityList merged = EntityList.empty(); merged.addAll(previousTasks); merged.addAll(tasks); content.retainTasks(merged); for (Entity task : tasks) { updateTask(task, false); } Runnable more = null; if (tasks.getTotal() > tasks.size() + startIndex - 1) { more = new Runnable() { @Override public void run() { loadTasksChunk(sprint, team, backlogItems, previousBacklogItems, previousTasksTotalCount, merged, startIndex + tasks.size(), redo); } }; } else if (backlogItems.getTotal() > previousBacklogItems.size() + backlogItems.size()) { more = new Runnable() { @Override public void run() { ArrayList<Entity> mergedItems = new ArrayList<Entity>(); mergedItems.addAll(previousBacklogItems); mergedItems.addAll(backlogItems); loadTasks(sprint, team, mergedItems, merged); } }; } String backlogItemsCount = EntityStatusPanel.getItemCountString(backlogItems.getTotal(), previousBacklogItems.size() + backlogItems.size(), "backlog items"); String tasksCount = EntityStatusPanel.getItemCountString(previousTasksTotalCount + tasks.getTotal(), merged.size(), "tasks"); status.info("Loaded " + backlogItemsCount + " and " + tasksCount, null, redo, more); } }); }
From source file:edu.ku.brc.ui.tmanfe.SpreadSheet.java
/** * //w w w. j a va2s .c o m */ protected void buildSpreadsheet() { this.setShowGrid(true); int numRows = model.getRowCount(); scrollPane = new JScrollPane(this, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); setAutoResizeMode(JTable.AUTO_RESIZE_OFF); final SpreadSheet ss = this; JButton cornerBtn = UIHelper.createIconBtn("Blank", IconManager.IconSize.Std16, "SelectAll", new ActionListener() { public void actionPerformed(ActionEvent ae) { ss.selectAll(); } }); cornerBtn.setEnabled(true); scrollPane.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, cornerBtn); // Allows row and collumn selections to exit at the same time setCellSelectionEnabled(true); setRowSelectionAllowed(true); setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); addMouseListener(new MouseAdapter() { /* (non-Javadoc) * @see java.awt.event.MouseAdapter#mousePressed(java.awt.event.MouseEvent) */ @SuppressWarnings("synthetic-access") @Override public void mouseReleased(MouseEvent e) { // XXX For Java 5 Bug prevRowSelInx = getSelectedRow(); prevColSelInx = getSelectedColumn(); if (e.getClickCount() == 2) { int rowIndexStart = getSelectedRow(); int colIndexStart = getSelectedColumn(); ss.editCellAt(rowIndexStart, colIndexStart); if (ss.getEditorComponent() != null && ss.getEditorComponent() instanceof JTextComponent) { ss.getEditorComponent().requestFocus(); final JTextComponent txtComp = (JTextComponent) ss.getEditorComponent(); String txt = txtComp.getText(); FontMetrics fm = txtComp.getFontMetrics(txtComp.getFont()); int x = e.getPoint().x - ss.getEditorComponent().getBounds().x - 1; int prevWidth = 0; for (int i = 0; i < txt.length(); i++) { int width = fm.stringWidth(txt.substring(0, i)); int basePlusHalf = prevWidth + (int) (((width - prevWidth) / 2) + 0.5); //System.out.println(prevWidth + " X[" + x + "] " + width+" ["+txt.substring(0, i)+"] " + i + " " + basePlusHalf); //System.out.println(" X[" + x + "] " + prevWidth + " - "+ basePlusHalf+" - " + width+" ["+txt.substring(0, i)+"] " + i); if (x < width) { // Clearing the selection is needed for Window for some reason final int inx = i + (x <= basePlusHalf ? -1 : 0); SwingUtilities.invokeLater(new Runnable() { @SuppressWarnings("synthetic-access") public void run() { txtComp.setSelectionStart(0); txtComp.setSelectionEnd(0); txtComp.setCaretPosition(inx > 0 ? inx : 0); } }); break; } prevWidth = width; } } } } }); // Create a row-header to display row numbers. // This row-header is made of labels whose Borders, // Foregrounds, Backgrounds, and Fonts must be // the one used for the table column headers. // Also ensure that the row-header labels and the table // rows have the same height. //i have no idea WHY this has to be called. i rearranged //the table and find replace panel, // i started getting an array index out of //bounds on the column header ON MAC ONLY. //tried firing this off, first and it fixed the problem.//meg this.getModel().fireTableStructureChanged(); /* * Create the Row Header Panel */ rowHeaderPanel = new JPanel((LayoutManager) null); if (getColumnModel().getColumnCount() > 0) { TableColumn column = getColumnModel().getColumn(0); TableCellRenderer renderer = getTableHeader().getDefaultRenderer(); if (renderer == null) { renderer = column.getHeaderRenderer(); } Component cellRenderComp = renderer.getTableCellRendererComponent(this, column.getHeaderValue(), false, false, -1, 0); cellFont = cellRenderComp.getFont(); } else { cellFont = (new JLabel()).getFont(); } // Calculate Row Height cellBorder = (Border) UIManager.getDefaults().get("TableHeader.cellBorder"); Insets insets = cellBorder.getBorderInsets(tableHeader); FontMetrics metrics = getFontMetrics(cellFont); rowHeight = insets.bottom + metrics.getHeight() + insets.top; rowLabelWidth = metrics.stringWidth("9999") + insets.right + insets.left; Dimension dim = new Dimension(rowLabelWidth, rowHeight * numRows); rowHeaderPanel.setPreferredSize(dim); // need to call this when no layout manager is used. rhCellMouseAdapter = new RHCellMouseAdapter(this); // Adding the row header labels for (int ii = 0; ii < numRows; ii++) { addRow(ii, ii + 1, false); } JViewport viewPort = new JViewport(); dim.height = rowHeight * numRows; viewPort.setViewSize(dim); viewPort.setView(rowHeaderPanel); scrollPane.setRowHeader(viewPort); // Experimental from the web, but I think it does the trick. addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (!ss.isEditing() && !e.isActionKey() && !e.isControlDown() && !e.isMetaDown() && !e.isAltDown() && e.getKeyCode() != KeyEvent.VK_SHIFT && e.getKeyCode() != KeyEvent.VK_TAB && e.getKeyCode() != KeyEvent.VK_ENTER) { log.error("Grabbed the event as input"); int rowIndexStart = getSelectedRow(); int colIndexStart = getSelectedColumn(); if (rowIndexStart == -1 || colIndexStart == -1) return; ss.editCellAt(rowIndexStart, colIndexStart); Component c = ss.getEditorComponent(); if (c instanceof JTextComponent) ((JTextComponent) c).setText(""); } } }); resizeAndRepaint(); // Taken from a JavaWorld Example (But it works) KeyStroke cut = KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false); KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false); KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false); Action ssAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { SpreadSheet.this.actionPerformed(e); } }; getInputMap().put(cut, "Cut"); getActionMap().put("Cut", ssAction); getInputMap().put(copy, "Copy"); getActionMap().put("Copy", ssAction); getInputMap().put(paste, "Paste"); getActionMap().put("Paste", ssAction); ((JMenuItem) UIRegistry.get(UIRegistry.COPY)).addActionListener(this); ((JMenuItem) UIRegistry.get(UIRegistry.CUT)).addActionListener(this); ((JMenuItem) UIRegistry.get(UIRegistry.PASTE)).addActionListener(this); setSortOrderCycle(SortOrder.ASCENDING, SortOrder.DESCENDING, SortOrder.UNSORTED); }
From source file:AltiConsole.AltiConsoleMainScreen.java
public boolean RetrievingFlight() { this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); listData = null;/*from www. java2 s .c om*/ listData = new DefaultListModel(); if (Serial.getConnected() == false) { boolean ret = false; ret = ConnectToAlti(); if (!ret) { System.out.println("Data retrieval timed out1\n"); JOptionPane.showMessageDialog(null, trans.get("AltiConsoleMainScreen.dataTimeOut"), trans.get("AltiConsoleMainScreen.ConnectionError"), JOptionPane.ERROR_MESSAGE); this.setCursor(Cursor.getDefaultCursor()); return false; } } // check the connection //Serial.DataReady = false; Serial.setDataReady(false); Serial.writeData("h;\n"); long startTime; // = System.currentTimeMillis(); Serial.lastReceived = System.currentTimeMillis(); while (!Serial.getDataReady()) { long currentTime = System.currentTimeMillis(); startTime = Serial.lastReceived; if ((currentTime - startTime) > 130000) { // This is some sort of data retrieval timeout System.out.println("Data retrieval timed out2 flight\n"); JOptionPane.showMessageDialog(null, trans.get("AltiConsoleMainScreen.dataTimeOut"), trans.get("AltiConsoleMainScreen.ConnectionError"), JOptionPane.ERROR_MESSAGE); this.setCursor(Cursor.getDefaultCursor()); return false; } } Serial.initFlightData(UserPref.getAppUnits()); // get the flight data //Serial.DataReady = false; Serial.setDataReady(false); Serial.writeData("a;\n"); Serial.lastReceived = System.currentTimeMillis(); while (!Serial.getDataReady()) { long currentTime = System.currentTimeMillis(); startTime = Serial.lastReceived; if ((currentTime - startTime) > 130000) { // This is some sort of data retrieval timeout System.out.println("Data retrieval timed out3\n"); JOptionPane.showMessageDialog(null, trans.get("AltiConsoleMainScreen.dataTimeOut"), trans.get("AltiConsoleMainScreen.ConnectionError"), JOptionPane.ERROR_MESSAGE); this.setCursor(Cursor.getDefaultCursor()); return false; } } System.out.println("done retrieving flight\n"); List<String> AllFlightNames2; AllFlightNames2 = Serial.MyFlight.getAllFlightNames2(); for (String z : AllFlightNames2) { listData.addElement(z); } flightList.setModel(listData); flightList.setAutoCreateRowSorter(true); flightList.toggleSortOrder(); flightList.setSortOrder(SortOrder.ASCENDING); flightList.clearSelection(); flightList.setSelectedIndex(0); if (Serial.MyFlight.FlightExist("Flight 1")) { plot.setDataset(0, Serial.MyFlight.GetFlightData("Flight 1")); } this.setCursor(Cursor.getDefaultCursor()); return true; }
From source file:de.codesourcery.eve.skills.ui.components.impl.AssetListComponent.java
protected void updateAssetListModel(AssetList assets) { final int selectedRow = table.getSelectedRow(); final Asset oldRowSelection = (selectedRow != -1) ? model.getRow(model.getRowSorter().convertRowIndexToModel(selectedRow)) : null;/* ww w . j a v a2s. c om*/ if (log.isTraceEnabled()) { log.trace("updateAssetListModel(): selected = " + oldRowSelection); } model.setAssetList(assets, !this.mergeAssetsByType.isSelected()); updateComboBoxModels(assets); /* * Try to restore old selection. */ model.getRowSorter().setSortKeys(Arrays.asList(new SortKey(0, SortOrder.ASCENDING))); if (oldRowSelection != null) { // try to find same item int matchByItemId = -1; int matchByType = -1; for (int i = 0; i < model.getRowCount(); i++) { final Asset row = model.getRow(i); if (row.getItemId() == oldRowSelection.getItemId()) { matchByItemId = i; break; } else if (matchByType == -1l && row.getType().equals(oldRowSelection.getType())) { matchByType = i; break; } } int modelRow = matchByItemId; if (modelRow == -1) { modelRow = matchByType; } if (modelRow != -1) { int viewRow = model.convertModelRowToView(modelRow); if (log.isTraceEnabled()) { log.debug("updateAssetList(): Scrolling to view row " + viewRow); } Misc.scrollTableToRow(table, viewRow); table.setRowSelectionInterval(viewRow, viewRow); } else { log.debug("updateAssetList(): Failed to restore selection"); } } }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopAbstractTable.java
@Override public void sortBy(Object propertyId, boolean ascending) { if (isSortable()) { for (int i = 0; i < columnsOrder.size(); i++) { Column column = columnsOrder.get(i); if (column.getId().equals(propertyId)) { SortOrder sortOrder = ascending ? SortOrder.ASCENDING : SortOrder.DESCENDING; tableModel.sort(singletonList(new RowSorter.SortKey(i, sortOrder))); onDataChange();/*from w ww .j av a 2 s . c o m*/ packRows(); break; } } } }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopAbstractTable.java
@Override public void sort(String columnId, SortDirection direction) { Column column = getColumn(columnId); if (column == null) { throw new IllegalArgumentException("Unable to find column " + columnId); }// www. j a v a2s . c om if (isSortable()) { SortOrder sortOrder = direction == SortDirection.ASCENDING ? SortOrder.ASCENDING : SortOrder.DESCENDING; int columnIndex = columnsOrder.indexOf(column); tableModel.sort(singletonList(new RowSorter.SortKey(columnIndex, sortOrder))); onDataChange(); packRows(); } }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopAbstractTable.java
@Nullable @Override/*from w w w . j a v a2 s. c o m*/ public SortInfo getSortInfo() { // SortInfo is returned only for sorting triggered from UI List<? extends RowSorter.SortKey> sortKeys = impl.getRowSorter().getSortKeys(); if (CollectionUtils.isNotEmpty(sortKeys)) { RowSorter.SortKey sortKey = sortKeys.get(0); return new SortInfo(columnsOrder.get(sortKey.getColumn()).getId(), SortOrder.ASCENDING.equals(sortKey.getSortOrder())); } return null; }