" + secondary + "
", + "" + secondary, // + "
", JOptionPane.QUESTION_MESSAGE); - String[] options = new String[] { - "Yes", "No" - }; pane.setOptions(options); // highlight the safest option ala apple hig - pane.setInitialValue(options[0]); + pane.setInitialValue(options[highlight]); JDialog dialog = pane.createDialog(editor, null); dialog.setVisible(true); - Object result = pane.getValue(); - if (result == options[0]) { - return JOptionPane.YES_OPTION; - } else if (result == options[1]) { - return JOptionPane.NO_OPTION; - } else { - return JOptionPane.CLOSED_OPTION; - } + result = pane.getValue(); } + for (int i = 0; i < options.length; i++) { + if (result != null && result.equals(options[i])) return i; + } + return -1; } @@ -327,7 +349,9 @@ static public void logf(String message, Object... args) { static public void loge(String message, Throwable e) { if (Base.DEBUG) { - System.err.println(message); + if (message != null) { + System.err.println(message); + } e.printStackTrace(); } } @@ -335,7 +359,7 @@ static public void loge(String message, Throwable e) { static public void loge(String message) { if (Base.DEBUG) { - System.out.println(message); + System.err.println(message); } } -} \ No newline at end of file +} diff --git a/app/src/processing/app/Mode.java b/app/src/processing/app/Mode.java index 148d571f25..9c87f7232b 100644 --- a/app/src/processing/app/Mode.java +++ b/app/src/processing/app/Mode.java @@ -53,8 +53,7 @@ public abstract class Mode { protected File folder; protected TokenMarker tokenMarker; - protected MapDefaultTableHeaderCellRenderer.
- * - * The horizontal alignment and text position are set as appropriate to a - * table header cell, and the opaque property is set to false. - */ - public MyColumnHeaderRenderer() { -// setHorizontalAlignment(CENTER); - setHorizontalTextPosition(LEFT); -// setVerticalAlignment(BOTTOM); - setOpaque(true); - } - - /** - * Returns the default table header cell renderer. - *
- * If the column is sorted, the appropriate icon is retrieved from the - * current Look and Feel, and a border appropriate to a table header cell - * is applied. - *
- * Subclasses may override this method to provide custom content or
- * formatting.
- *
- * @param table the JTable.
- * @param value the value to assign to the header cell
- * @param isSelected This parameter is ignored.
- * @param hasFocus This parameter is ignored.
- * @param row This parameter is ignored.
- * @param column the column of the header cell to render
- * @return the default table header cell renderer
- */
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value,
- boolean isSelected, boolean hasFocus, int row, int column) {
- super.getTableCellRendererComponent(table, value,
- isSelected, hasFocus, row, column);
- JTableHeader tableHeader = table.getTableHeader();
- if (tableHeader != null) {
- setForeground(tableHeader.getForeground());
- }
- setIcon(getIcon(table, column));
- if (column % 2 == 0) {
- setBackground(new Color(0xdfdfdf));
- } else {
- setBackground(new Color(0xebebeb));
- }
- setBorder(null);
- return this;
- }
-
- /**
- * Overloaded to return an icon suitable to the primary sorted column, or null if
- * the column is not the primary sort key.
- *
- * @param table the JTable.
- * @param column the column index.
- * @return the sort icon, or null if the column is unsorted.
- */
- protected Icon getIcon(JTable table, int column) {
- SortKey sortKey = getSortKey(table, column);
- if (sortKey != null && table.convertColumnIndexToView(sortKey.getColumn()) == column) {
- switch (sortKey.getSortOrder()) {
- case ASCENDING:
- return UIManager.getIcon("Table.ascendingSortIcon");
- case DESCENDING:
- return UIManager.getIcon("Table.descendingSortIcon");
- }
- }
- return null;
- }
-
- /**
- * Returns the current sort key, or null if the column is unsorted.
- *
- * @param table the table
- * @param column the column index
- * @return the SortKey, or null if the column is unsorted
- */
- protected SortKey getSortKey(JTable table, int column) {
- RowSorter rowSorter = table.getRowSorter();
- if (rowSorter == null) {
- return null;
- }
-
- List sortedColumns = rowSorter.getSortKeys();
- if (sortedColumns.size() > 0) {
- return (SortKey) sortedColumns.get(0);
- }
- return null;
- }
-}
-
- class StatusRendere extends DefaultTableCellRenderer {
-
- @Override
- public void setVerticalAlignment(int alignment) {
- super.setVerticalAlignment(SwingConstants.CENTER);
- }
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value,
- boolean isSelected,
- boolean hasFocus, int row,
- int column) {
- Contribution contribution = (Contribution) value;
- JLabel label = new JLabel();
- if (column == 0) {
- Icon icon = null;
- label.setBorder(BorderFactory.createEmptyBorder(2, 17, 0, 0));
- label.setFont(Toolkit.getSansFont(14, Font.PLAIN));
- if (contribution.isInstalled()) {
- icon = Toolkit.getLibIcon("manager/up-to-date.png");
- if (contribListing.hasUpdates(contribution)) {
- icon = Toolkit.getLibIcon("manager/update-available.png");
- }
- if (!contribution.isCompatible(Base.getRevision())) {
- icon = Toolkit.getLibIcon("manager/incompatible.png");
- }
- }
- label.setIcon(icon);
- if (isSelected) {
- label.setBackground(new Color(0xe0fffd));
- }
- label.setOpaque(true);
-// return table.getDefaultRenderer(Icon.class).getTableCellRendererComponent(table, icon, isSelected, false, row, column);
- } else if (column == 1) {
- // Generating ellipses based on fontMetrics
- FontMetrics fontMetrics = table.getFontMetrics(table.getFont());
- int colSize = table.getColumnModel().getColumn(1).getWidth();
- String sentence = contribution.getSentence();
- int currentWidth = table.getFontMetrics(table.getFont().deriveFont(Font.BOLD)).stringWidth(contribution.getName() + " | ");
- int ellipsesWidth = fontMetrics.stringWidth("...");
- String name = "