Issue #2436 - disposed of the sort color

Former-commit-id: f27781b74e [formerly 8c8adf8be6] [formerly 9c97908f36] [formerly f27781b74e [formerly 8c8adf8be6] [formerly 9c97908f36] [formerly c4ddd46b44 [formerly 9c97908f36 [formerly 4545de35a0fdbfc5817a8725bf07ae0c405efb39]]]]
Former-commit-id: c4ddd46b44
Former-commit-id: ccbc44f9d3 [formerly 2ed106cac4] [formerly b50a8d2a19218358b07a31a6ee2f605c0ead6152 [formerly 46db8998a6]]
Former-commit-id: d130264f10b1958114f77cf64c39663d19c8c154 [formerly 1000147d0c]
Former-commit-id: b0af7745a6
This commit is contained in:
Lee Venable 2013-10-07 09:11:25 -05:00
parent 9da45fbeba
commit c328869516

View file

@ -63,7 +63,8 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants;
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 7, 2009 lvenable Initial creation
* Apr 7, 2009 lvenable Initial creation
* Oct 7, 2013 #2436 lvenable Disposed of the sort color.
*
* </pre>
*
@ -117,12 +118,16 @@ public abstract class TableComp extends Composite {
protected int defaultColWidth;
protected boolean columnMinimumSize = false;
private int imageWidth = 0;
private int imageHeight = 0;
private int textWidth = 0;
private int textHeight = 0;
private Color sortColor;
private Color sortColor;
/**
* A map that contains a table column and the sort direction.
@ -153,10 +158,10 @@ public abstract class TableComp extends Composite {
* Initialize method.
*/
protected void init() {
tiFont = new Font(parent.getDisplay(), "Arial", 10, SWT.NORMAL);
tiFont = new Font(parent.getDisplay(), "Arial", 10, SWT.NORMAL);
sortColor = new Color(parent.getDisplay(), 133, 104, 190);
sortColor = new Color(parent.getDisplay(), 133, 104, 190);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
GridLayout gl = new GridLayout(1, false);
gl.verticalSpacing = 2;
@ -166,7 +171,7 @@ public abstract class TableComp extends Composite {
this.setLayoutData(gd);
makeImageCalculations();
initData();
createSortImage();
@ -185,6 +190,7 @@ public abstract class TableComp extends Composite {
tiFont.dispose();
lineColor.dispose();
sortImage.dispose();
sortColor.dispose();
}
});
}
@ -206,10 +212,10 @@ public abstract class TableComp extends Composite {
textHeight = gc.getFontMetrics().getHeight();
String[] columnKeys = getColumnKeys(appName);
for ( String key : columnKeys ) {
String columnName = getColumnAttribteData(key).getColumnName();
for (String key : columnKeys) {
String columnName = getColumnAttribteData(key).getColumnName();
String[] nameArray = columnName.split("\n");
for (String tmpStr : nameArray) {
@ -224,7 +230,7 @@ public abstract class TableComp extends Composite {
image.dispose();
}
/**
/**
* Initialize the data.
*/
private void initData() {
@ -293,14 +299,14 @@ public abstract class TableComp extends Composite {
}
});
table.addMouseMoveListener(new MouseMoveListener () {
@Override
public void mouseMove(MouseEvent event) {
tableMouseHoverAction(event);
}
table.addMouseMoveListener(new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent event) {
tableMouseHoverAction(event);
}
});
}
/**
@ -338,13 +344,15 @@ public abstract class TableComp extends Composite {
for (int j = 0; j < cols.length; j++) {
cols[j].setImage(null);
cols[j].setWidth(defaultColWidth);
cols[j].setText(getColumnAttribteData(colnkeys[j]).getColumnName());
cols[j].setText(getColumnAttribteData(colnkeys[j])
.getColumnName());
}
/*
* Set the sort image, pack the column and sort the data.
*/
tc.setImage(getSortHeaderImage(getColumnAttribteData(sortCol).getColumnName()));
tc.setImage(getSortHeaderImage(getColumnAttribteData(
sortCol).getColumnName()));
tc.setText("");
tc.pack();
@ -356,17 +364,19 @@ public abstract class TableComp extends Composite {
sortTableData(tc);
}
});
/**
* DR#10701: The first column is selected for
* sorting by default when a Zone table or Station
* table is first displayed (not for History table)
* DR#10701: The first column is selected for sorting by default
* when a Zone table or Station table is first displayed (not for
* History table)
*/
if ( i == 0 ) {
if ( getColumnAttribteData(columns[i]).getSortDir() != SortDirection.None.getSortDir() ) {
tc.setText("");
tc.setImage(getSortHeaderImage(getColumnAttribteData(columns[0]).getColumnName()));
}
if (i == 0) {
if (getColumnAttribteData(columns[i]).getSortDir() != SortDirection.None
.getSortDir()) {
tc.setText("");
tc.setImage(getSortHeaderImage(getColumnAttribteData(
columns[0]).getColumnName()));
}
}
if (columnMinimumSize == true) {
@ -414,8 +424,8 @@ public abstract class TableComp extends Composite {
for (int i = 0; i < cellData.length; i++) {
ti.setText(i, cellData[i].displayString());
Color c = new Color(parent.getDisplay(), cellData[i]
.getBackgroungRGB());
Color c = new Color(parent.getDisplay(),
cellData[i].getBackgroungRGB());
ti.setBackground(i, c);
c.dispose();
}
@ -462,12 +472,12 @@ public abstract class TableComp extends Composite {
int columnIndex = getColumnIndex(appName, sortCol);
if ( sortCol == "SSZT_SwellPeriod" || sortCol == "SSZT_Swell2Period" ) {
if ( MonitorConfigConstants.isRankSwellPeriodHigh() ) {
sortDir = SWT.DOWN;
} else {
sortDir = SWT.UP;
}
if (sortCol == "SSZT_SwellPeriod" || sortCol == "SSZT_Swell2Period") {
if (MonitorConfigConstants.isRankSwellPeriodHigh()) {
sortDir = SWT.DOWN;
} else {
sortDir = SWT.UP;
}
}
tableData.setSortColumnAndDirection(columnIndex, sortDir);
@ -492,32 +502,34 @@ public abstract class TableComp extends Composite {
gc.dispose();
}
private Image getSortHeaderImage(String header) {
Image image = new Image(parent.getDisplay(), imageWidth, imageHeight);
GC gc = new GC(image);
gc.setFont(tiFont);
gc.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
gc.setBackground(sortColor);
gc.fillRectangle(0, 0, imageWidth, imageHeight);
int xCoord = 0;
int yCoord = 0;
if ( header.indexOf("\n") > 0 ) {
String [] tmpArray = header.split("\n");
int maxTextLen = tmpArray[0].length();
for ( int j = 1; j < tmpArray.length; j++ ) {
if ( tmpArray[j].length() > maxTextLen ) {
maxTextLen = tmpArray[j].length();
}
}
xCoord = Math.round( (imageWidth / 2) - (maxTextLen*textWidth / 2) ) - 2;
yCoord = 0;
} else {
xCoord = Math.round( (imageWidth / 2) - (header.length()*textWidth / 2) ) - 2;
yCoord = imageHeight / 2 - textHeight /2 - 1;
}
gc.drawText(header, xCoord, yCoord, true);
return image;
Image image = new Image(parent.getDisplay(), imageWidth, imageHeight);
GC gc = new GC(image);
gc.setFont(tiFont);
gc.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
gc.setBackground(sortColor);
gc.fillRectangle(0, 0, imageWidth, imageHeight);
int xCoord = 0;
int yCoord = 0;
if (header.indexOf("\n") > 0) {
String[] tmpArray = header.split("\n");
int maxTextLen = tmpArray[0].length();
for (int j = 1; j < tmpArray.length; j++) {
if (tmpArray[j].length() > maxTextLen) {
maxTextLen = tmpArray[j].length();
}
}
xCoord = Math
.round((imageWidth / 2) - (maxTextLen * textWidth / 2)) - 2;
yCoord = 0;
} else {
xCoord = Math.round((imageWidth / 2)
- (header.length() * textWidth / 2)) - 2;
yCoord = imageHeight / 2 - textHeight / 2 - 1;
}
gc.drawText(header, xCoord, yCoord, true);
return image;
}
/**
@ -591,7 +603,7 @@ public abstract class TableComp extends Composite {
/**
* Pack the table columns.
*/
protected abstract void packColumns();
protected abstract void packColumns();
protected abstract void tableColRightMouseAction(MouseEvent event);