use of org.eclipse.jface.viewers.ViewerComparator in project yamcs-studio by yamcs.
the class AddToStackWizardPage1 method createControl.
@Override
public void createControl(Composite parent) {
var composite = new Composite(parent, SWT.NONE);
setControl(composite);
var gl = new GridLayout();
gl.marginHeight = 0;
gl.marginWidth = 0;
composite.setLayout(gl);
// grid for expand+filter box
var gl2 = new GridLayout(3, false);
gl2.marginHeight = 0;
gl2.marginWidth = 0;
var row = new Composite(composite, SWT.NONE);
row.setLayout(gl2);
row.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// add expand all / collapse all button
var expandAll = new Button(row, SWT.ARROW | SWT.DOWN);
var expandAllData = new GridData(SWT.NONE);
expandAll.setLayoutData(expandAllData);
expandAll.setText("Expand All");
expandAll.setToolTipText("Expand All");
expandAll.setVisible(false);
expandAllData.exclude = true;
var collapseAll = new Button(row, SWT.ARROW | SWT.RIGHT);
var collapseAllData = new GridData(SWT.NONE);
collapseAll.setLayoutData(collapseAllData);
collapseAll.setText("Collapse All");
collapseAll.setToolTipText("Collapse All");
collapseAll.setVisible(true);
// add filter box
var searchbox = new Text(row, SWT.SEARCH | SWT.BORDER | SWT.ICON_CANCEL);
searchbox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
expandAll.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
commandsTreeTable.expandAll();
expandAll.setVisible(false);
collapseAll.setVisible(true);
expandAllData.exclude = true;
collapseAllData.exclude = false;
expandAll.pack();
collapseAll.pack();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
commandsTreeTable.expandAll();
expandAll.setVisible(false);
collapseAll.setVisible(true);
expandAllData.exclude = true;
collapseAllData.exclude = false;
expandAll.pack();
collapseAll.pack();
}
});
collapseAll.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
commandsTreeTable.collapseAll();
expandAll.setVisible(true);
collapseAll.setVisible(false);
expandAllData.exclude = false;
collapseAllData.exclude = true;
expandAll.pack();
collapseAll.pack();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
commandsTreeTable.collapseAll();
expandAll.setVisible(true);
collapseAll.setVisible(false);
expandAllData.exclude = false;
collapseAllData.exclude = true;
expandAll.pack();
collapseAll.pack();
}
});
// build tree table
ResourceManager resourceManager = new LocalResourceManager(JFaceResources.getResources(), composite);
level0Image = resourceManager.createImage(RCPUtils.getImageDescriptor(AddToStackWizardPage1.class, "icons/level0s.png"));
level1Image = resourceManager.createImage(RCPUtils.getImageDescriptor(AddToStackWizardPage1.class, "icons/level1s.png"));
level2Image = resourceManager.createImage(RCPUtils.getImageDescriptor(AddToStackWizardPage1.class, "icons/level2s.png"));
level3Image = resourceManager.createImage(RCPUtils.getImageDescriptor(AddToStackWizardPage1.class, "icons/level3s.png"));
level4Image = resourceManager.createImage(RCPUtils.getImageDescriptor(AddToStackWizardPage1.class, "icons/level4s.png"));
level5Image = resourceManager.createImage(RCPUtils.getImageDescriptor(AddToStackWizardPage1.class, "icons/level5s.png"));
var treeWrapper = new Composite(composite, SWT.NONE);
tcl = new TreeColumnLayout();
var gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 800;
gd.heightHint = 500;
treeWrapper.setLayoutData(gd);
treeWrapper.setLayout(tcl);
commandsTreeTable = new TreeViewer(treeWrapper, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
commandsTreeTable.getTree().setHeaderVisible(true);
commandsTreeTable.getTree().setLinesVisible(true);
// column xtce path
var pathColumn = new TreeViewerColumn(commandsTreeTable, SWT.NONE);
pathColumn.getColumn().setText(COL_PATH);
pathColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof XtceSubSystemNode) {
var node = (XtceSubSystemNode) element;
return node.getName();
} else {
var node = (XtceCommandNode) element;
return node.getCommandInfo().getName();
}
}
});
tcl.setColumnData(pathColumn.getColumn(), new ColumnPixelData(300));
// column significance
var significanceColumn = new TreeViewerColumn(commandsTreeTable, SWT.NONE);
significanceColumn.getColumn().setText(COL_SIGN);
significanceColumn.getColumn().setToolTipText("Significance Level");
significanceColumn.getColumn().setAlignment(SWT.CENTER);
significanceColumn.setLabelProvider(new CenteredImageLabelProvider() {
@Override
public Image getImage(Object element) {
if (element instanceof XtceCommandNode) {
var node = (XtceCommandNode) element;
var cmd = node.getCommandInfo();
if (cmd.getSignificance() == null) {
return level0Image;
}
switch(cmd.getSignificance().getConsequenceLevel()) {
case NONE:
return level0Image;
case WATCH:
return level1Image;
case WARNING:
return level2Image;
case DISTRESS:
return level3Image;
case CRITICAL:
return level4Image;
case SEVERE:
return level5Image;
default:
return null;
}
}
return null;
}
});
tcl.setColumnData(significanceColumn.getColumn(), new ColumnPixelData(50));
// on item selection update significance message and page completion status
commandsTreeTable.addSelectionChangedListener(evt -> {
var sel = (IStructuredSelection) evt.getSelection();
if (sel.isEmpty()) {
setMessage(null);
return;
}
var selectedElement = sel.getFirstElement();
if (selectedElement instanceof XtceCommandNode) {
var cmd = ((XtceCommandNode) sel.getFirstElement()).getCommandInfo();
// setMessage(getMessage(cmd));
command.setMetaCommand(cmd);
setPageComplete(true);
} else {
setPageComplete(false);
}
});
var commandTreeContentProvider = new CommandTreeContentProvider();
commandsTreeTable.setContentProvider(commandTreeContentProvider);
commandsTreeTable.setInput(commandTreeContentProvider);
YamcsPlugin.getMissionDatabase().getCommands().forEach(cmd -> {
if (!cmd.hasAbstract() || !cmd.getAbstract()) {
// add aliases columns
for (var alias : cmd.getAliasList()) {
var namespace = alias.getNamespace();
if (!namespaces.contains(namespace) && !namespace.startsWith("/")) {
namespaces.add(namespace);
addAliasColumn(namespace);
}
}
commandTreeContentProvider.addElement(cmd.getQualifiedName(), cmd);
}
});
commandsTreeTable.expandAll();
var filter = new CommandTreeViewerFilter(commandTreeContentProvider);
commandsTreeTable.addFilter(filter);
searchbox.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent ke) {
if (ke.keyCode == SWT.ARROW_DOWN) {
var items = commandsTreeTable.getTree().getItems();
if (items.length > 0) {
IStructuredSelection sel = new StructuredSelection(items[0].getData());
commandsTreeTable.setSelection(sel);
commandsTreeTable.getTree().setFocus();
}
} else {
filter.setSearchTerm(searchbox.getText());
commandsTreeTable.refresh();
commandsTreeTable.expandAll();
}
}
});
commandsTreeTable.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object o1, Object o2) {
String n1;
String n2;
if (o1 instanceof XtceSubSystemNode) {
n1 = ((XtceSubSystemNode) o1).getName();
} else {
n1 = ((XtceCommandNode) o1).getCommandInfo().getQualifiedName();
}
if (o2 instanceof XtceSubSystemNode) {
n2 = ((XtceSubSystemNode) o2).getName();
} else {
n2 = ((XtceCommandNode) o2).getCommandInfo().getQualifiedName();
}
return n1.compareTo(n2);
}
});
}
use of org.eclipse.jface.viewers.ViewerComparator in project yamcs-studio by yamcs.
the class ConnectionsDialog method createServerPanel.
private Composite createServerPanel(Composite parent, ResourceManager resourceManager) {
var serverPanel = new Composite(parent, SWT.NONE);
var gd = new GridData(GridData.FILL_BOTH);
serverPanel.setLayoutData(gd);
var tcl = new TableColumnLayout();
serverPanel.setLayout(tcl);
var serverImage = resourceManager.createImage(getImageDescriptor(ConnectionsDialog.class, "icons/obj16/server.gif"));
connViewer = new TableViewer(serverPanel, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
connViewer.getTable().setHeaderVisible(true);
connViewer.getTable().setLinesVisible(true);
var urlColumn = new TableViewerColumn(connViewer, SWT.NONE);
urlColumn.getColumn().setText("Server URL");
urlColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public Image getImage(Object element) {
return serverImage;
}
@Override
public String getText(Object element) {
var conf = (YamcsConfiguration) element;
return conf.getURL();
}
});
tcl.setColumnData(urlColumn.getColumn(), new ColumnPixelData(200));
var instanceColumn = new TableViewerColumn(connViewer, SWT.NONE);
instanceColumn.getColumn().setText("Instance");
instanceColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
var conf = (YamcsConfiguration) element;
return conf.getInstance();
}
});
tcl.setColumnData(instanceColumn.getColumn(), new ColumnPixelData(90));
var userColumn = new TableViewerColumn(connViewer, SWT.NONE);
userColumn.getColumn().setText("User");
userColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
var conf = (YamcsConfiguration) element;
if (conf.getAuthType() != AuthType.KERBEROS) {
return conf.getUser();
} else {
return null;
}
}
});
tcl.setColumnData(userColumn.getColumn(), new ColumnPixelData(90));
var nameColumn = new TableViewerColumn(connViewer, SWT.NONE);
nameColumn.getColumn().setText("Comment");
nameColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
var conf = (YamcsConfiguration) element;
return conf.getComment();
}
});
tcl.setColumnData(nameColumn.getColumn(), new ColumnPixelData(200));
IContentProvider contentProvider = (IStructuredContentProvider) inputElement -> connections.toArray();
connViewer.setContentProvider(contentProvider);
connViewer.setInput(contentProvider);
connViewer.addSelectionChangedListener(evt -> {
var sel = (IStructuredSelection) evt.getSelection();
if (sel.getFirstElement() != null) {
var conf = (YamcsConfiguration) sel.getFirstElement();
yamcsInstanceText.setText(forceString(conf.getInstance()));
yamcsURLText.setText(forceString(conf.getURL()));
// / caCertFileText.setText(forceString(conf.getCaCertFile()));
commentText.setText(forceString(conf.getComment()));
var authType = (conf.getAuthType() == null) ? AuthType.STANDARD : conf.getAuthType();
if (authType == AuthType.STANDARD) {
authTypeCombo.select(0);
yamcsUserText.setText(forceString(conf.getUser()));
} else if (authType == AuthType.KERBEROS) {
authTypeCombo.select(1);
yamcsUserText.setText("");
} else {
throw new IllegalArgumentException("Unexpected auth type " + authType);
}
updateState();
}
});
connViewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object o1, Object o2) {
var c1 = (YamcsConfiguration) o1;
var c2 = (YamcsConfiguration) o2;
if (c1.getURL() != null && c2.getURL() != null) {
return c1.getURL().compareTo(c2.getURL());
} else {
return 0;
}
}
});
return serverPanel;
}
use of org.eclipse.jface.viewers.ViewerComparator in project hale by halestudio.
the class InstanceValidationReportDetailsPage method createControls.
/**
* @see CustomReportDetailsPage#createControls(Composite)
*/
@Override
public Control createControls(Composite parent) {
// filtered tree sets itself GridData, so set layout to gridlayout
parent.setLayout(GridLayoutFactory.fillDefaults().create());
// create pattern filter for FilteredTree
PatternFilter filter = new TreePathPatternFilter();
filter.setIncludeLeadingWildcard(true);
// create FilteredTree
FilteredTree filteredTree = new TreePathFilteredTree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, filter, true);
treeViewer = filteredTree.getViewer();
// set content provider
contentProvider = new InstanceValidationReportDetailsContentProvider();
treeViewer.setContentProvider(contentProvider);
// set label provider
treeViewer.setLabelProvider(new InstanceValidationReportDetailsLabelProvider(contentProvider));
// set comparator
treeViewer.setComparator(new ViewerComparator() {
/**
* @see org.eclipse.jface.viewers.ViewerComparator#category(java.lang.Object)
*/
@Override
public int category(Object element) {
if (element instanceof QName || element instanceof Definition<?>)
// Path
return 0;
else if (element instanceof String)
// Category
return 1;
else
// InstanceValidationMessage
return 2;
}
});
// add menu on right-click
MenuManager menuMgr = new MenuManager();
Menu menu = menuMgr.createContextMenu(treeViewer.getTree());
menuMgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
if (getValidSelection() == null)
return;
// selection is valid, offer link to transformed data view
manager.add(new ShowExampleAction());
}
});
// remove previous menus
menuMgr.setRemoveAllWhenShown(true);
// add menu to tree
treeViewer.getTree().setMenu(menu);
treeViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
showSelectionInDataView();
}
});
Image noReportBaseImage = InstanceValidationUIPlugin.getDefault().getImageRegistry().get(InstanceValidationUIPlugin.IMG_INSTANCE_VALIDATION);
reportImage = new DecorationOverlayIcon(noReportBaseImage, PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_DEC_FIELD_WARNING), IDecoration.BOTTOM_LEFT).createImage();
return filteredTree;
}
use of org.eclipse.jface.viewers.ViewerComparator in project hale by halestudio.
the class ReportList method createViewControl.
/**
* Create contents of the view part.
*
* @param parent parent element
*/
@Override
public void createViewControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
TreeColumnLayout layout = new TreeColumnLayout();
composite.setLayout(layout);
{
_treeViewer = new TreeViewer(composite, SWT.BORDER);
final Tree tree = _treeViewer.getTree();
tree.setHeaderVisible(false);
tree.setLinesVisible(false);
// create column for reports
TreeViewerColumn col1 = new TreeViewerColumn(_treeViewer, SWT.NONE);
// add the label provider
col1.setLabelProvider(new TreeColumnViewerLabelProvider(new ReportListLabelProvider()));
// and layout
layout.setColumnData(col1.getColumn(), new ColumnWeightData(3));
// create column for reports
TreeViewerColumn col2 = new TreeViewerColumn(_treeViewer, SWT.NONE);
// add the label provider
col2.setLabelProvider(new TreeColumnViewerLabelProvider(new ReportListLabelDateProvider()));
// create column for reports
layout.setColumnData(col2.getColumn(), new ColumnWeightData(1));
new ReportListMenu(getSite(), _treeViewer);
}
createActions();
initializeToolBar();
initializeMenu();
// set label provider
// _treeViewer.setLabelProvider(new ReportListLabelProvider());
// set content provider
_treeViewer.setContentProvider(new ReportListContentProvider());
// disable this if it uses too much memory
// but should maintain the list much faster
_treeViewer.setUseHashlookup(true);
// order the sessions from latest to oldest
_treeViewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
if (e1 instanceof ReportSession && e2 instanceof ReportSession) {
long first = ((ReportSession) e1).getId();
long second = ((ReportSession) e2).getId();
if (first > second) {
return -1;
} else if (first < second) {
return 1;
} else {
return 0;
}
} else if (e1 instanceof Report<?> && e2 instanceof Report<?>) {
Report<?> first = (Report<?>) e1;
Report<?> second = (Report<?>) e2;
if (first.getStartTime() == null && second.getStartTime() == null) {
return 0;
} else if (first.getStartTime() == null) {
return 1;
} else if (second.getStartTime() == null) {
return -1;
} else if (first.getStartTime().getTime() > second.getStartTime().getTime()) {
return -1;
} else if (first.getStartTime().getTime() < second.getStartTime().getTime()) {
return 1;
} else {
return 0;
}
}
return 0;
}
});
// set selection provider
getSite().setSelectionProvider(_treeViewer);
_treeViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
OpenPropertiesHandler.unpinAndOpenPropertiesView(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
}
});
// load all added reports
this.loadReports();
}
use of org.eclipse.jface.viewers.ViewerComparator in project erlide_eclipse by erlang.
the class ColoringPreferencePage method createSyntaxPage.
private Control createSyntaxPage(final Composite parent) {
final Composite colorComposite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
colorComposite.setLayout(layout);
final Link link = new Link(colorComposite, SWT.NONE);
link.setText(PreferencesMessages.ErlEditorColoringConfigurationBlock_link);
link.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, null);
}
});
final GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
gridData.widthHint = 150;
gridData.horizontalSpan = 2;
link.setLayoutData(gridData);
addFiller(colorComposite, 1);
Label label;
label = new Label(colorComposite, SWT.LEFT);
label.setText(PreferencesMessages.ErlEditorPreferencePage_coloring_element);
label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
final Composite editorComposite = new Composite(colorComposite, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
editorComposite.setLayout(layout);
GridData gd = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
editorComposite.setLayoutData(gd);
fListViewer = new TreeViewer(editorComposite, SWT.SINGLE | SWT.BORDER);
final Tree tree = fListViewer.getTree();
final GridData gdTree = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1);
gdTree.widthHint = 100;
tree.setLayoutData(gdTree);
fListViewer.setLabelProvider(new ColorListLabelProvider());
fListViewer.setContentProvider(new ColorListContentProvider());
fListViewer.setInput(fColors);
fListViewer.setSelection(new StructuredSelection(fErlangCategory));
fListViewer.setComparator(new ViewerComparator() {
@Override
public int category(final Object element) {
// don't sort the top level categories
if (fErlangCategory.equals(element)) {
}
// return 1;
return 0;
}
});
gd = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, true);
gd.heightHint = convertHeightInCharsToPixels(9);
int maxWidth = 0;
for (final TokenHighlight item : fColors.keySet()) {
maxWidth = Math.max(maxWidth, convertWidthInCharsToPixels(item.getName().length()));
}
final ScrollBar vBar = ((Scrollable) fListViewer.getControl()).getVerticalBar();
if (vBar != null) {
// scrollbars and tree
maxWidth += vBar.getSize().x * 3;
}
// indentation guess
gd.widthHint = maxWidth;
fListViewer.getControl().setLayoutData(gd);
fListViewer.expandAll();
final Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 2;
stylesComposite.setLayout(layout);
stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
fEnableCheckbox = new Button(stylesComposite, SWT.CHECK);
fEnableCheckbox.setText(PreferencesMessages.ErlEditorPreferencePage_enable);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.BEGINNING;
gd.horizontalSpan = 2;
fEnableCheckbox.setLayoutData(gd);
// TODO hide this until reworking the dialog
fEnableCheckbox.setVisible(false);
fColorEditorLabel = new Label(stylesComposite, SWT.LEFT);
fColorEditorLabel.setText(PreferencesMessages.ErlEditorPreferencePage_color);
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalIndent = 20;
fColorEditorLabel.setLayoutData(gd);
fSyntaxForegroundColorEditor = new ColorSelector(stylesComposite);
final Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton();
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
foregroundColorButton.setLayoutData(gd);
new Label(stylesComposite, SWT.NONE);
fBoldCheckBox = new Button(stylesComposite, SWT.CHECK);
fBoldCheckBox.setText(PreferencesMessages.ErlEditorPreferencePage_bold);
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalIndent = 20;
gd.horizontalSpan = 2;
fBoldCheckBox.setLayoutData(gd);
fItalicCheckBox = new Button(stylesComposite, SWT.CHECK);
fItalicCheckBox.setText(PreferencesMessages.ErlEditorPreferencePage_italic);
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalIndent = 20;
gd.horizontalSpan = 2;
fItalicCheckBox.setLayoutData(gd);
fStrikethroughCheckBox = new Button(stylesComposite, SWT.CHECK);
fStrikethroughCheckBox.setText(PreferencesMessages.ErlEditorPreferencePage_strikeout);
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalIndent = 20;
gd.horizontalSpan = 2;
fStrikethroughCheckBox.setLayoutData(gd);
fUnderlineCheckBox = new Button(stylesComposite, SWT.CHECK);
fUnderlineCheckBox.setText(PreferencesMessages.ErlEditorPreferencePage_underline);
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalIndent = 20;
gd.horizontalSpan = 2;
fUnderlineCheckBox.setLayoutData(gd);
final String content = ColoringPreferencePage.loadPreviewContentFromFile(getClass(), // $NON-NLS-1$
"ColorSettingPreviewCode.txt");
fPreviewViewer = ErlangSourceViewer.createErlangPreviewer(colorComposite, fColorManager, fOverlayStore, fColors, content);
final Control previewer = fPreviewViewer.getControl();
gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = convertWidthInCharsToPixels(20);
gd.heightHint = convertHeightInCharsToPixels(5);
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
previewer.setLayoutData(gd);
fListViewer.addSelectionChangedListener(event -> handleSyntaxColorListSelection());
foregroundColorButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
// do nothing
}
@Override
public void widgetSelected(final SelectionEvent e) {
final TokenHighlight item = getHighlight();
final HighlightStyle data = item.getStyle(fOverlayStore);
if (data == null) {
return;
}
data.setColor(fSyntaxForegroundColorEditor.getColorValue());
storeHighlight(fOverlayStore, item, data);
fPreviewViewer.invalidateTextPresentation();
}
});
fBoldCheckBox.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
// do nothing
}
@Override
public void widgetSelected(final SelectionEvent e) {
final TokenHighlight item = getHighlight();
final HighlightStyle data = item.getStyle(fOverlayStore);
if (data == null) {
return;
}
data.setStyle(SWT.BOLD, fBoldCheckBox.getSelection());
storeHighlight(fOverlayStore, item, data);
fPreviewViewer.invalidateTextPresentation();
}
});
fItalicCheckBox.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
// do nothing
}
@Override
public void widgetSelected(final SelectionEvent e) {
final TokenHighlight item = getHighlight();
final HighlightStyle data = item.getStyle(fOverlayStore);
if (data == null) {
return;
}
data.setStyle(SWT.ITALIC, fItalicCheckBox.getSelection());
storeHighlight(fOverlayStore, item, data);
fPreviewViewer.invalidateTextPresentation();
}
});
fStrikethroughCheckBox.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
// do nothing
}
@Override
public void widgetSelected(final SelectionEvent e) {
final TokenHighlight item = getHighlight();
final HighlightStyle data = item.getStyle(fOverlayStore);
if (data == null) {
return;
}
data.setStyle(TextAttribute.STRIKETHROUGH, fStrikethroughCheckBox.getSelection());
storeHighlight(fOverlayStore, item, data);
fPreviewViewer.invalidateTextPresentation();
}
});
fUnderlineCheckBox.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
// do nothing
}
@Override
public void widgetSelected(final SelectionEvent e) {
final TokenHighlight item = getHighlight();
final HighlightStyle data = item.getStyle(fOverlayStore);
if (data == null) {
return;
}
data.setStyle(TextAttribute.UNDERLINE, fUnderlineCheckBox.getSelection());
storeHighlight(fOverlayStore, item, data);
fPreviewViewer.invalidateTextPresentation();
}
});
fEnableCheckbox.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
// do nothing
}
@Override
public void widgetSelected(final SelectionEvent e) {
fEnableCheckbox.setSelection(true);
// final TokenHighlight item = getHighlight();
// if (item instanceof SemanticHighlightingColorListItem) {
// final boolean enable = fEnableCheckbox.getSelection();
// getPreferenceStore().setValue(
// ((SemanticHighlightingColorListItem) item)
// .getEnableKey(), enable);
// fEnableCheckbox.setSelection(enable);
// fSyntaxForegroundColorEditor.getButton().setEnabled(enable);
// fColorEditorLabel.setEnabled(enable);
// fBoldCheckBox.setEnabled(enable);
// fItalicCheckBox.setEnabled(enable);
// fStrikethroughCheckBox.setEnabled(enable);
// fUnderlineCheckBox.setEnabled(enable);
// }
}
});
colorComposite.layout(false);
handleSyntaxColorListSelection();
fPreviewViewer.invalidateTextPresentation();
return colorComposite;
}
Aggregations