expandFilters.setSpacing(1);
final Composite cFilterArea = new Composite(expandFilters, SWT.NONE);
cFilterArea.setLayout(new FormLayout());
final TableColumnManager tcm = TableColumnManager.getInstance();
Group cResultArea = new Group(shell, SWT.NONE);
Messages.setLanguageText(cResultArea, "ColumnSetup.chosencolumns");
cResultArea.setLayout(new FormLayout());
Composite cResultButtonArea = new Composite(cResultArea, SWT.NONE);
cResultButtonArea.setLayout(new FormLayout());
tvAvail = createTVAvail();
cTableAvail = new Composite(cPickArea, SWT.NO_FOCUS);
GridLayout gridLayout = new GridLayout();
gridLayout.marginWidth = gridLayout.marginHeight = 0;
cTableAvail.setLayout(gridLayout);
tvAvail.initialize(cTableAvail);
TableColumnCore[] datasources = tcm.getAllTableColumnCoreAsArray(
forDataSourceType, forTableID);
listColumnsNoCat = new ArrayList<TableColumnCore>(
Arrays.asList(datasources));
listCats = new ArrayList<String>();
for (int i = 0; i < datasources.length; i++) {
TableColumnCore column = datasources[i];
TableColumnInfo info = tcm.getColumnInfo(forDataSourceType, forTableID,
column.getName());
if (info != null) {
String[] categories = info.getCategories();
if (categories != null && categories.length > 0) {
for (int j = 0; j < categories.length; j++) {
String cat = categories[j];
if (!listCats.contains(cat)) {
listCats.add(cat);
}
}
listColumnsNoCat.remove(column);
}
}
}
Listener radListener = new Listener() {
public void handleEvent(Event event) {
fillAvail();
}
};
Composite cProficiency = new Composite(cFilterArea, SWT.NONE);
cProficiency.setBackgroundMode(SWT.INHERIT_FORCE);
cProficiency.setLayout(new FormLayout());
Label lblProficiency = new Label(cProficiency, SWT.NONE);
Messages.setLanguageText(lblProficiency, "ColumnSetup.proficiency");
radProficiency[0] = new Button(cProficiency, SWT.RADIO);
Messages.setLanguageText(radProficiency[0], "ConfigView.section.mode.beginner");
fd = new FormData();
fd.left = new FormAttachment(lblProficiency, 5);
radProficiency[0].setLayoutData(fd);
radProficiency[0].addListener(SWT.Selection, radListener);
radProficiency[1] = new Button(cProficiency, SWT.RADIO);
Messages.setLanguageText(radProficiency[1], "ConfigView.section.mode.intermediate");
fd = new FormData();
fd.left = new FormAttachment(radProficiency[0], 5);
radProficiency[1].setLayoutData(fd);
radProficiency[1].addListener(SWT.Selection, radListener);
radProficiency[2] = new Button(cProficiency, SWT.RADIO);
Messages.setLanguageText(radProficiency[2], "ConfigView.section.mode.advanced");
fd = new FormData();
fd.left = new FormAttachment(radProficiency[1], 5);
radProficiency[2].setLayoutData(fd);
radProficiency[2].addListener(SWT.Selection, radListener);
int userMode = COConfigurationManager.getIntParameter("User Mode");
if (userMode < 0) {
userMode = 0;
} else if (userMode >= radProficiency.length) {
userMode = radProficiency.length - 1;
}
radProficiency[userMode].setSelection(true);
// >>>>>>>> Buttons
Listener buttonListener = new Listener() {
public void handleEvent(Event event) {
Control[] children = cCategories.getChildren();
for (int i = 0; i < children.length; i++) {
Control child = children[i];
if (child != event.widget && (child instanceof Button)) {
Button btn = (Button) child;
btn.setSelection(false);
}
}
fillAvail();
}
};
Label lblCat = new Label(cFilterArea, SWT.NONE);
Messages.setLanguageText(lblCat, "ColumnSetup.categories");
if (CAT_BUTTONS) {
cCategories = new Composite(cFilterArea, SWT.NONE);
cCategories.setLayout(new RowLayout());
Button button = new Button(cCategories, SWT.TOGGLE);
Messages.setLanguageText(button, "Categories.all");
button.addListener(SWT.Selection, buttonListener);
button.setSelection(true);
for (String cat : listCats) {
button = new Button(cCategories, SWT.TOGGLE);
button.setData("cat", cat);
if (MessageText.keyExists("ColumnCategory." + cat)) {
button.setText(MessageText.getString("ColumnCategory." + cat));
} else {
button.setText(cat);
}
button.addListener(SWT.Selection, buttonListener);
}
if (listColumnsNoCat.size() > 0) {
button = new Button(cCategories, SWT.TOGGLE);
if (MessageText.keyExists("ColumnCategory.uncat")) {
button.setText(MessageText.getString("ColumnCategory.uncat"));
} else {
button.setText("?");
}
button.setText("?");
button.setData("cat", "uncat");
button.addListener(SWT.Selection, buttonListener);
}
} else {
comboFilter = new Combo(cFilterArea, SWT.DROP_DOWN | SWT.READ_ONLY);
comboFilter.addListener(SWT.Selection, radListener);
listCats.add(0, "all");
for (String cat : listCats) {
comboFilter.add(cat);
}
comboFilter.select(0);
}
final ExpandItem expandItemFilters = new ExpandItem(expandFilters, SWT.NONE);
expandItemFilters.setText(MessageText.getString("ColumnSetup.filters"));
expandItemFilters.setControl(cFilterArea);
expandFilters.addListener(SWT.Resize, new Listener() {
public void handleEvent(Event event) {
expandItemFilters.setHeight(cFilterArea.computeSize(
expandFilters.getSize().x, SWT.DEFAULT).y + 3);
}
});
expandFilters.addListener(SWT.Expand, new Listener() {
public void handleEvent(Event event) {
Utils.execSWTThreadLater(Constants.isLinux ? 250 : 0, new AERunnable() {
public void runSupport() {
shell.layout(true, true);
}
});
}
});
expandFilters.addListener(SWT.Collapse, new Listener() {
public void handleEvent(Event event) {
Utils.execSWTThreadLater(Constants.isLinux ? 250 : 0, new AERunnable() {
public void runSupport() {
shell.layout(true, true);
}
});
}
});
// <<<<<<< Buttons
// >>>>>>> Chosen
ImageLoader imageLoader = ImageLoader.getInstance();
Button btnUp = new Button(cResultButtonArea, SWT.PUSH);
imageLoader.setButtonImage(btnUp, "up");
btnUp.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
moveChosenUp();
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
Button btnDown = new Button(cResultButtonArea, SWT.PUSH);
imageLoader.setButtonImage(btnDown, "down");
btnDown.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
moveChosenDown();
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
Button btnDel = new Button(cResultButtonArea, SWT.PUSH);
imageLoader.setButtonImage(btnDel, "delete");
btnDel.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
removeSelectedChosen();
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
tvChosen = createTVChosen();
cTableChosen = new Composite(cResultArea, SWT.NONE);
gridLayout = new GridLayout();
gridLayout.marginWidth = gridLayout.marginHeight = 0;
cTableChosen.setLayout(gridLayout);
tvChosen.initialize(cTableChosen);
columnsChosen = tcm.getAllTableColumnCoreAsArray(forDataSourceType,
forTableID);
Arrays.sort(columnsChosen,
TableColumnManager.getTableColumnOrderComparator());
columnsOriginalOrder = new TableColumnCore[columnsChosen.length];
System.arraycopy(columnsChosen, 0, columnsOriginalOrder, 0,
columnsChosen.length);
int pos = 0;
for (int i = 0; i < columnsChosen.length; i++) {
boolean visible = columnsChosen[i].isVisible();
mapNewVisibility.put(columnsChosen[i], new Boolean(visible));
if (visible) {
columnsChosen[i].setPositionNoShift(pos++);
tvChosen.addDataSource(columnsChosen[i]);
}
}
tvChosen.processDataSourceQueue();
Button btnReset = null;
String[] defaultColumnNames = tcm.getDefaultColumnNames(forTableID);
if (defaultColumnNames != null) {
btnReset = new Button(cResultButtonArea, SWT.PUSH);
Messages.setLanguageText(btnReset, "Button.reset");
btnReset.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String[] defaultColumnNames = tcm.getDefaultColumnNames(forTableID);
if (defaultColumnNames != null) {
List<TableColumnCore> defaultColumns = new ArrayList<TableColumnCore>();
for (String name : defaultColumnNames) {
TableColumnCore column = tcm.getTableColumnCore(forTableID, name);
if (column != null) {
defaultColumns.add(column);
}
}
if (defaultColumns.size() > 0) {