mirror of
https://github.com/processing/processing4.git
synced 2026-02-11 09:39:19 +01:00
get rid of tabs, remove dead code
This commit is contained in:
@@ -50,42 +50,36 @@ public class ErrorTable extends JTable {
|
||||
public boolean isWarning();
|
||||
}
|
||||
|
||||
static final String[] columnNames = {
|
||||
"", // the blank column used for spacing
|
||||
Language.text("editor.footer.errors.problem"),
|
||||
Language.text("editor.footer.errors.tab"),
|
||||
Language.text("editor.footer.errors.line")
|
||||
};
|
||||
static final String[] columnNames = {
|
||||
"", // the blank column used for spacing
|
||||
Language.text("editor.footer.errors.problem"),
|
||||
Language.text("editor.footer.errors.tab"),
|
||||
Language.text("editor.footer.errors.line")
|
||||
};
|
||||
|
||||
//int[] columnWidths = { Editor.LEFT_GUTTER, 400, 100, 50 };
|
||||
//static final int[] DEFAULT_WIDTHS = { Editor.LEFT_GUTTER, 400, 100, 50 };
|
||||
static final int DATA_COLUMN = 0;
|
||||
static final int PROBLEM_COLUMN = 1;
|
||||
static final int TAB_COLUMN = 2;
|
||||
static final int LINE_COLUMN = 3;
|
||||
|
||||
static final int DATA_COLUMN = 0;
|
||||
static final int PROBLEM_COLUMN = 1;
|
||||
static final int TAB_COLUMN = 2;
|
||||
static final int LINE_COLUMN = 3;
|
||||
Font headerFont;
|
||||
Color headerColor;
|
||||
Color headerBgColor;
|
||||
|
||||
// /** Is the column being resized? */
|
||||
// private boolean columnResizing = false;
|
||||
|
||||
Font headerFont;
|
||||
Color headerColor;
|
||||
Color headerBgColor;
|
||||
|
||||
Font rowFont;
|
||||
Color rowColor;
|
||||
Color rowBgColor;
|
||||
Font rowFont;
|
||||
Color rowColor;
|
||||
Color rowBgColor;
|
||||
|
||||
|
||||
public ErrorTable(final Editor editor) {
|
||||
super(new DefaultTableModel(columnNames, 0));
|
||||
public ErrorTable(final Editor editor) {
|
||||
super(new DefaultTableModel(columnNames, 0));
|
||||
|
||||
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
|
||||
this.editor = editor;
|
||||
JTableHeader header = getTableHeader();
|
||||
this.editor = editor;
|
||||
JTableHeader header = getTableHeader();
|
||||
|
||||
Mode mode = editor.getMode();
|
||||
Mode mode = editor.getMode();
|
||||
header.setDefaultRenderer(new GradyHeaderRenderer(mode));
|
||||
setDefaultRenderer(Object.class, new GradyRowRenderer(mode));
|
||||
//setShowGrid(false);
|
||||
@@ -104,7 +98,7 @@ public class ErrorTable extends JTable {
|
||||
// columnModel.getColumn(i).setPreferredWidth(columnWidths[i]);
|
||||
// }
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
synchronized public void mouseClicked(MouseEvent e) {
|
||||
try {
|
||||
@@ -117,8 +111,8 @@ public class ErrorTable extends JTable {
|
||||
} else if (clickCount > 1) {
|
||||
editor.errorTableDoubleClick(data);
|
||||
}
|
||||
editor.getTextArea().requestFocusInWindow();
|
||||
// editor.getErrorChecker().scrollToErrorLine(row);
|
||||
editor.getTextArea().requestFocusInWindow();
|
||||
// editor.getErrorChecker().scrollToErrorLine(row);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@@ -126,71 +120,12 @@ public class ErrorTable extends JTable {
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
addMouseMotionListener(new MouseMotionAdapter() {
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent evt) {
|
||||
int rowIndex = rowAtPoint(evt.getPoint());
|
||||
|
||||
List<Problem> problemsList = editor.getErrorChecker().problemsList;
|
||||
synchronized (problemsList) {
|
||||
if (rowIndex < problemsList.size()) {
|
||||
|
||||
Problem p = problemsList.get(rowIndex);
|
||||
if (p.getImportSuggestions() != null
|
||||
&& p.getImportSuggestions().length > 0) {
|
||||
String t = p.getMessage() + "(Import Suggestions available)";
|
||||
FontMetrics fm = getFontMetrics(getFont());
|
||||
int x1 = fm.stringWidth(p.getMessage());
|
||||
int x2 = fm.stringWidth(t);
|
||||
if (evt.getX() > x1 && evt.getX() < x2) {
|
||||
String[] list = p.getImportSuggestions();
|
||||
String className = list[0].substring(list[0].lastIndexOf('.') + 1);
|
||||
String[] temp = new String[list.length];
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
temp[i] = "<html>Import '" + className + "' <font color=#777777>(" + list[i] + ")</font></html>";
|
||||
}
|
||||
showImportSuggestion(temp, evt.getXOnScreen(), evt.getYOnScreen() - 3 * getFont().getSize());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
header.setReorderingAllowed(false);
|
||||
// header.setResizingAllowed(false);
|
||||
|
||||
/*
|
||||
// Handles the resizing of columns. When mouse press is detected on
|
||||
// table header, Stop updating the table, store new values of column
|
||||
// widths, and resume updating. Updating is disabled as long as
|
||||
// columnResizing is true
|
||||
header.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
columnResizing = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
columnResizing = false;
|
||||
TableColumnModel columnModel =
|
||||
((JTableHeader) e.getSource()).getColumnModel();
|
||||
for (int i = 0; i < columnModel.getColumnCount(); i++) {
|
||||
columnWidths[i] = columnModel.getColumn(i).getWidth();
|
||||
}
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
ToolTipManager.sharedInstance().registerComponent(this);
|
||||
}
|
||||
header.setReorderingAllowed(false);
|
||||
ToolTipManager.sharedInstance().registerComponent(this);
|
||||
}
|
||||
|
||||
|
||||
public void clearRows() {
|
||||
public void clearRows() {
|
||||
DefaultTableModel dtm = (DefaultTableModel) getModel();
|
||||
dtm.setRowCount(0);
|
||||
}
|
||||
@@ -202,202 +137,107 @@ public class ErrorTable extends JTable {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public void updateColumns() {
|
||||
// figure out the column widths
|
||||
TableColumnModel columnModel = getColumnModel();
|
||||
int tabWidth = getMaxColumnWidth(this, TAB_COLUMN);
|
||||
int lineWidth = getMaxColumnWidth(this, LINE_COLUMN);
|
||||
int problemWidth = getWidth() - Editor.LEFT_GUTTER - tabWidth - lineWidth;
|
||||
|
||||
columnModel.getColumn(DATA_COLUMN).setMaxWidth(Editor.LEFT_GUTTER);
|
||||
columnModel.getColumn(TAB_COLUMN).setMaxWidth(tabWidth);
|
||||
columnModel.getColumn(LINE_COLUMN).setMaxWidth(lineWidth);
|
||||
columnModel.getColumn(PROBLEM_COLUMN).setMaxWidth(problemWidth);
|
||||
|
||||
// System.out.println(tabWidth + " " + lineWidth + " " + problemWidth);
|
||||
|
||||
// for (int i = 0; i < columnModel.getColumnCount(); i++) {
|
||||
// columnModel.getColumn(i).setPreferredWidth(columnWidths[i]);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
static private int getMaxColumnWidth(JTable table, int col) {
|
||||
TableCellRenderer renderer =
|
||||
table.getTableHeader().getDefaultRenderer();
|
||||
Component comp =
|
||||
renderer.getTableCellRendererComponent(table, columnNames[col],
|
||||
false, false, 0, col);
|
||||
int maxWidth = comp.getPreferredSize().width;
|
||||
|
||||
// TableColumn column = table.getColumnModel().getColumn(col);
|
||||
// renderer = column.getCellRenderer();
|
||||
renderer = table.getDefaultRenderer(Object.class);
|
||||
// System.out.println("renderer is " + renderer);
|
||||
|
||||
for (int row = 0; row < table.getModel().getRowCount(); row++) {
|
||||
Object value = table.getModel().getValueAt(row, col);
|
||||
comp = renderer.getTableCellRendererComponent(table, value,
|
||||
false, false, row, col);
|
||||
double valueWidth = comp.getPreferredSize().getWidth();
|
||||
maxWidth = (int) Math.max(maxWidth, valueWidth);
|
||||
}
|
||||
return maxWidth;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int colIndex) {
|
||||
return false; // Disallow the editing of any cell
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
synchronized public boolean updateTable(final TableModel tableModel) {
|
||||
if (!isVisible()) return false;
|
||||
|
||||
SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {
|
||||
|
||||
protected Object doInBackground() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void done() {
|
||||
try {
|
||||
setModel(tableModel);
|
||||
|
||||
// Set column widths to user defined widths
|
||||
for (int i = 0; i < getColumnModel().getColumnCount(); i++) {
|
||||
getColumnModel().getColumn(i).setPreferredWidth(columnWidths[i]);
|
||||
}
|
||||
getTableHeader().setReorderingAllowed(false);
|
||||
validate();
|
||||
repaint();
|
||||
} catch (Exception e) {
|
||||
System.out.println("Exception at XQErrorTable.updateTable " + e);
|
||||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
if (!columnResizing) {
|
||||
worker.execute();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("ErrorTable updateTable Worker's slacking."
|
||||
+ e.getMessage());
|
||||
// e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
static class GradyHeaderRenderer extends JLabel implements TableCellRenderer {
|
||||
|
||||
public GradyHeaderRenderer(Mode mode) {
|
||||
setFont(mode.getFont("errors.header.font"));
|
||||
setAlignmentX(LEFT_ALIGNMENT);
|
||||
|
||||
setForeground(mode.getColor("errors.header.fgcolor"));
|
||||
setBackground(mode.getColor("errors.header.bgcolor"));
|
||||
setOpaque(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value,
|
||||
boolean selected,
|
||||
boolean focused,
|
||||
int row, int column) {
|
||||
setText(value == null ? "" : value.toString());
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static class GradyHeaderRenderer extends JLabel implements TableCellRenderer {
|
||||
|
||||
public GradyHeaderRenderer(Mode mode) {
|
||||
setFont(mode.getFont("errors.header.font"));
|
||||
setAlignmentX(LEFT_ALIGNMENT);
|
||||
|
||||
setForeground(mode.getColor("errors.header.fgcolor"));
|
||||
setBackground(mode.getColor("errors.header.bgcolor"));
|
||||
setOpaque(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value,
|
||||
boolean selected,
|
||||
boolean focused,
|
||||
int row, int column) {
|
||||
setText(value == null ? "" : value.toString());
|
||||
return this;
|
||||
}
|
||||
}
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
static class GradyRowRenderer extends JLabel implements TableCellRenderer {
|
||||
Color textColor;
|
||||
Color bgColor;
|
||||
Color textColorSelected;
|
||||
Color bgColorSelected;
|
||||
Color bgColorError;
|
||||
Color bgColorWarning;
|
||||
|
||||
// int indicatorSize;
|
||||
Color errorIndicatorColor;
|
||||
Color warningIndicatorColor;
|
||||
|
||||
static class GradyRowRenderer extends JLabel implements TableCellRenderer {
|
||||
Color textColor;
|
||||
Color bgColor;
|
||||
Color textColorSelected;
|
||||
Color bgColorSelected;
|
||||
Color bgColorError;
|
||||
Color bgColorWarning;
|
||||
public GradyRowRenderer(Mode mode) {
|
||||
setFont(mode.getFont("errors.row.font"));
|
||||
setAlignmentX(LEFT_ALIGNMENT);
|
||||
|
||||
// int indicatorSize;
|
||||
Color errorIndicatorColor;
|
||||
Color warningIndicatorColor;
|
||||
textColor = mode.getColor("errors.row.fgcolor");
|
||||
bgColor = mode.getColor("errors.row.bgcolor");
|
||||
textColorSelected = mode.getColor("errors.selection.fgcolor");
|
||||
bgColorSelected = mode.getColor("errors.selection.bgcolor");
|
||||
bgColorError = mode.getColor("errors.selection.error.bgcolor");
|
||||
bgColorWarning = mode.getColor("errors.selection.warning.bgcolor");
|
||||
|
||||
public GradyRowRenderer(Mode mode) {
|
||||
setFont(mode.getFont("errors.row.font"));
|
||||
setAlignmentX(LEFT_ALIGNMENT);
|
||||
// indicatorSize = mode.getInteger("errors.indicator.size");
|
||||
errorIndicatorColor = mode.getColor("errors.indicator.error.color");
|
||||
warningIndicatorColor = mode.getColor("errors.indicator.warning.color");
|
||||
|
||||
textColor = mode.getColor("errors.row.fgcolor");
|
||||
bgColor = mode.getColor("errors.row.bgcolor");
|
||||
textColorSelected = mode.getColor("errors.selection.fgcolor");
|
||||
bgColorSelected = mode.getColor("errors.selection.bgcolor");
|
||||
bgColorError = mode.getColor("errors.selection.error.bgcolor");
|
||||
bgColorWarning = mode.getColor("errors.selection.warning.bgcolor");
|
||||
setOpaque(true);
|
||||
}
|
||||
|
||||
// indicatorSize = mode.getInteger("errors.indicator.size");
|
||||
errorIndicatorColor = mode.getColor("errors.indicator.error.color");
|
||||
warningIndicatorColor = mode.getColor("errors.indicator.warning.color");
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value,
|
||||
boolean selected,
|
||||
boolean focused,
|
||||
int row, int column) {
|
||||
Entry entry = (Entry) table.getValueAt(row, DATA_COLUMN);
|
||||
|
||||
setOpaque(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value,
|
||||
boolean selected,
|
||||
boolean focused,
|
||||
int row, int column) {
|
||||
Entry entry = (Entry) table.getValueAt(row, DATA_COLUMN);
|
||||
|
||||
if (selected) {
|
||||
setForeground(textColorSelected);
|
||||
if (entry.isError()) {
|
||||
setBackground(bgColorError);
|
||||
} else if (entry.isWarning()) {
|
||||
setBackground(bgColorWarning);
|
||||
} else {
|
||||
setBackground(bgColorSelected);
|
||||
}
|
||||
} else {
|
||||
setForeground(textColor);
|
||||
setBackground(bgColor);
|
||||
}
|
||||
if (column == DATA_COLUMN) {
|
||||
setText("\u2022");
|
||||
setHorizontalAlignment(SwingConstants.CENTER);
|
||||
if (entry.isError()) {
|
||||
setForeground(errorIndicatorColor);
|
||||
} else if (entry.isWarning()) {
|
||||
setForeground(warningIndicatorColor);
|
||||
} else {
|
||||
setText(""); // no dot
|
||||
}
|
||||
} else if (value == null) {
|
||||
setText("");
|
||||
} else {
|
||||
if (selected) {
|
||||
setForeground(textColorSelected);
|
||||
if (entry.isError()) {
|
||||
setBackground(bgColorError);
|
||||
} else if (entry.isWarning()) {
|
||||
setBackground(bgColorWarning);
|
||||
} else {
|
||||
setBackground(bgColorSelected);
|
||||
}
|
||||
} else {
|
||||
setForeground(textColor);
|
||||
setBackground(bgColor);
|
||||
}
|
||||
if (column == DATA_COLUMN) {
|
||||
setText("\u2022");
|
||||
setHorizontalAlignment(SwingConstants.CENTER);
|
||||
if (entry.isError()) {
|
||||
setForeground(errorIndicatorColor);
|
||||
} else if (entry.isWarning()) {
|
||||
setForeground(warningIndicatorColor);
|
||||
} else {
|
||||
setText(""); // no dot
|
||||
}
|
||||
} else if (value == null) {
|
||||
setText("");
|
||||
} else {
|
||||
setHorizontalAlignment(SwingConstants.LEFT);
|
||||
setText(value.toString());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// Component dot = new JComponent() {
|
||||
// @Override
|
||||
// public void paintComponent(Graphics g) {
|
||||
//
|
||||
// }
|
||||
// };
|
||||
}
|
||||
setText(value.toString());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user