consoleText.setTabs(areaWidth / 6 / charWidth);
}
});
ScrollBar sb = consoleText.getVerticalBar();
sb.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
bAutoScroll = false;
if (buttonAutoScroll != null && !buttonAutoScroll.isDisposed())
buttonAutoScroll.setSelection(false);
}
});
Composite cLeft = new Composite(panel, SWT.NULL);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 1;
cLeft.setLayout(layout);
gd = new GridData(SWT.TOP, SWT.LEAD, false, false);
cLeft.setLayoutData(gd);
Button buttonPause = new Button(cLeft, SWT.CHECK);
Messages.setLanguageText(buttonPause, "LoggerView.pause");
gd = new GridData();
buttonPause.setLayoutData(gd);
buttonPause.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.widget == null || !(e.widget instanceof Button))
return;
Button btn = (Button) e.widget;
bPaused = btn.getSelection();
if (!bPaused && buffer != null) {
refresh();
}
}
});
Button buttonRealtime = new Button(cLeft, SWT.CHECK);
Messages.setLanguageText(buttonRealtime, "LoggerView.realtime");
gd = new GridData();
buttonRealtime.setLayoutData(gd);
buttonRealtime.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.widget == null || !(e.widget instanceof Button))
return;
Button btn = (Button) e.widget;
bRealtime = btn.getSelection();
}
});
buttonAutoScroll = new Button(cLeft, SWT.CHECK);
Messages.setLanguageText(buttonAutoScroll, "LoggerView.autoscroll");
gd = new GridData();
buttonAutoScroll.setLayoutData(gd);
buttonAutoScroll.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.widget == null || !(e.widget instanceof Button))
return;
Button btn = (Button) e.widget;
bAutoScroll = btn.getSelection();
}
});
buttonAutoScroll.setSelection(true);
Button buttonClear = new Button(cLeft, SWT.PUSH);
Messages.setLanguageText(buttonClear, "LoggerView.clear");
gd = new GridData();
buttonClear.setLayoutData(gd);
buttonClear.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
consoleText.setText("");
}
});
/** FileLogging filter, consisting of a List of types (info, warning, error)
* and a checkbox Table of component IDs.
*/
final String sFilterPrefix = "ConfigView.section.logging.filter";
Group gLogIDs = new Group(panel, SWT.NULL);
Messages.setLanguageText(gLogIDs, "LoggerView.filter");
layout = new GridLayout();
layout.marginHeight = 0;
layout.numColumns = 2;
gLogIDs.setLayout(layout);
gd = new GridData();
gLogIDs.setLayoutData(gd);
Label label = new Label(gLogIDs, SWT.NONE);
Messages.setLanguageText(label, "ConfigView.section.logging.level");
label.setLayoutData(new GridData());
final Label labelCatFilter = new Label(gLogIDs, SWT.NONE);
labelCatFilter.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
final List listLogTypes = new List(gLogIDs, SWT.BORDER | SWT.SINGLE
| SWT.V_SCROLL);
gd = new GridData(SWT.NULL, SWT.BEGINNING, false, false);
listLogTypes.setLayoutData(gd);
final int[] logTypes = { LogEvent.LT_INFORMATION, LogEvent.LT_WARNING,
LogEvent.LT_ERROR };
for (int i = 0; i < logTypes.length; i++)
listLogTypes.add(MessageText.getString("ConfigView.section.logging.log"
+ i + "type"));
listLogTypes.select(0);
final LogIDs[] logIDs = FileLogging.configurableLOGIDs;
//Arrays.sort(logIDs);
Composite cChecksAndButtons = new Composite(gLogIDs, SWT.NULL);
layout = new GridLayout(2, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
cChecksAndButtons.setLayout(layout);
cChecksAndButtons.setLayoutData(new GridData());
final Composite cChecks = new Composite(cChecksAndButtons, SWT.NULL);
RowLayout rowLayout = new RowLayout(SWT.VERTICAL);
rowLayout.wrap = true;
rowLayout.marginLeft = 0;
rowLayout.marginRight = 0;
rowLayout.marginTop = 0;
rowLayout.marginBottom = 0;
cChecks.setLayout(rowLayout);
SelectionAdapter buttonClickListener = new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
int index = listLogTypes.getSelectionIndex();
if (index < 0 || index >= logTypes.length)
return;
Button item = (Button) e.widget;
if (item.getSelection())
ignoredComponents[index].remove(item.getData("LOGID"));
else
ignoredComponents[index].add(item.getData("LOGID"));
}
};
for (int i = 0; i < logIDs.length; i++) {
Button btn = new Button(cChecks, SWT.CHECK);
btn.setText(MessageText.getString(sFilterPrefix + "." + logIDs[i],
logIDs[i].toString()));
btn.setData("LOGID", logIDs[i]);
btn.addSelectionListener(buttonClickListener);
if (i == 0) {
gd = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 2);
gd.heightHint = (btn.computeSize(SWT.DEFAULT, SWT.DEFAULT).y + 2) * 3;
cChecks.setLayoutData(gd);
}
}
// Update table when list selection changes
listLogTypes.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
int index = listLogTypes.getSelectionIndex();
if (index < 0 || index >= logTypes.length)
return;
labelCatFilter.setText(MessageText.getString(
"ConfigView.section.logging.showLogsFor", listLogTypes
.getSelection()));
Control[] items = cChecks.getChildren();
for (int i = 0; i < items.length; i++) {
if (items[i] instanceof Button) {
LogIDs ID = (LogIDs) items[i].getData("LOGID");
if (ID != null) {
boolean checked = !ignoredComponents[index].contains(ID);
((Button) items[i]).setSelection(checked);
}
}
}
}
});
listLogTypes.notifyListeners(SWT.Selection, null);
Button btn;
btn = new Button(cChecksAndButtons, SWT.PUSH);
gd = new GridData();
btn.setLayoutData(gd);
Messages.setLanguageText(btn, "LoggerView.filter.checkAll");
btn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
int index = listLogTypes.getSelectionIndex();
Control[] items = cChecks.getChildren();
for (int i = 0; i < items.length; i++) {
if (items[i] instanceof Button) {
LogIDs ID = (LogIDs) items[i].getData("LOGID");
if (ID != null && ignoredComponents[index].contains(ID)) {
((Button) items[i]).setSelection(true);
ignoredComponents[index].remove(ID);
}
}
}
}
});
btn = new Button(cChecksAndButtons, SWT.PUSH);
gd = new GridData();
btn.setLayoutData(gd);
Messages.setLanguageText(btn, "LoggerView.filter.uncheckAll");
btn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
int index = listLogTypes.getSelectionIndex();
Control[] items = cChecks.getChildren();
for (int i = 0; i < items.length; i++) {