* @param iColumn Column # that tasks apply to.
*/
private void fillColumnMenu(final TableColumnOrTreeColumn tcColumn,
boolean isBlankArea) {
if (!isBlankArea) {
TableColumnManager tcm = TableColumnManager.getInstance();
TableColumnCore[] allTableColumns = tcm.getAllTableColumnCoreAsArray(
classPluginDataSourceType, sTableID);
Arrays.sort(allTableColumns,
TableColumnManager.getTableColumnOrderComparator());
for (final TableColumnCore tc : allTableColumns) {
boolean visible = tc.isVisible();
if (!visible) {
TableColumnInfo columnInfo = tcm.getColumnInfo(classPluginDataSourceType, sTableID, tc.getName());
if (columnInfo.getProficiency() != TableColumnInfo.PROFICIENCY_BEGINNER) {
continue;
}
}
MenuItem menuItem = new MenuItem(menu, SWT.CHECK);
Messages.setLanguageText(menuItem, tc.getTitleLanguageKey());
if (visible) {
menuItem.setSelection(true);
}
menuItem.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
tc.setVisible(!tc.isVisible());
tableStructureChanged(true, null);
}
});
}
}
if (menu.getItemCount() > 0) {
new MenuItem(menu, SWT.SEPARATOR);
}
final MenuItem itemResetColumns = new MenuItem(menu, SWT.PUSH);
Messages.setLanguageText(itemResetColumns, "table.columns.reset");
itemResetColumns.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
TableColumnManager tcm = TableColumnManager.getInstance();
String[] defaultColumnNames = tcm.getDefaultColumnNames(sTableID);
if (defaultColumnNames != null) {
for (TableColumnCore column : tableColumns) {
column.setVisible(false);
}
int i = 0;
for (String name : defaultColumnNames) {
TableColumnCore column = tcm.getTableColumnCore(sTableID, name);
if (column != null) {
column.reset();
column.setVisible(true);
column.setPositionNoShift(i++);
}
}
tcm.saveTableColumns(classPluginDataSourceType, sTableID);
TableStructureEventDispatcher.getInstance(sTableID).tableStructureChanged(true, classPluginDataSourceType);
}
}
});