use of org.eclipse.jface.viewers.ViewerComparator in project tdq-studio-se by Talend.
the class AbstractMatchAnalysisTableViewer method initTable.
/**
* DOC zshen Comment method "initTable".
*
* @param headers the name of column
* @param columnMap all of columns which can be used by current Table
* @param pixelDataOfHeaders the width of the column
*/
public void initTable(List<String> headers, List<MetadataColumn> columnMap, boolean withSorter) {
TableLayout tLayout = new TableLayout();
innerTable.setLayout(tLayout);
innerTable.setHeaderVisible(true);
innerTable.setLinesVisible(true);
GridData gd = new GridData(GridData.FILL_BOTH);
innerTable.setLayoutData(gd);
for (int index = 0; index < headers.size(); index++) {
final int sortIndex = index;
String columnTechnologyLabel = headers.get(index);
String columnLabel = getInternationalizedLabel(columnTechnologyLabel);
if (columnLabel != null) {
if (columnLabel.length() == 1) {
columnLabel = columnLabel + PluginConstant.SPACE_STRING + PluginConstant.SPACE_STRING;
}
tLayout.addColumnData(new ColumnPixelData(columnLabel.length() * getHeaderDisplayWeight(index)));
final TableViewerColumn tableColumn = new TableViewerColumn(this, SWT.LEFT);
tableColumn.getColumn().setText(columnLabel);
addEditingSupportForColumn(tableColumn, columnTechnologyLabel);
if (withSorter) {
final ViewerComparator comparator = getComparator();
tableColumn.getColumn().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
((GroupStatisticsRowCompartor) comparator).setColumn(sortIndex);
int dir = getTable().getSortDirection();
if (getTable().getSortColumn() == tableColumn.getColumn()) {
dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
} else {
dir = SWT.DOWN;
}
getTable().setSortDirection(dir);
getTable().setSortColumn(tableColumn.getColumn());
refresh();
}
});
}
}
}
CellEditor[] editors = getCellEditor(headers, columnMap);
// add menu
addContextMenu();
AbstractMatchCellModifier<T> cellModifier = getTableCellModifier();
if (cellModifier != null) {
cellModifier.setColumnMap(columnMap);
this.setCellModifier(cellModifier);
}
this.setCellEditors(editors);
this.setColumnProperties(headers.toArray(new String[headers.size()]));
this.setContentProvider(getTableContentProvider());
this.setLabelProvider(getTableLabelProvider());
GridData tableGD = new GridData(GridData.FILL_BOTH);
tableGD.heightHint = getTableHeightHint();
innerTable.setLayoutData(tableGD);
}
use of org.eclipse.jface.viewers.ViewerComparator in project whole by wholeplatform.
the class EditorPreferencePage method createContents.
protected Control createContents(Composite parent) {
Label label;
GridData gd;
Composite topComposite = new Composite(parent, SWT.NONE);
topComposite.setLayout(new GridLayout(1, false));
topComposite.setFont(parent.getFont());
gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 1;
topComposite.setLayoutData(gd);
Label fontsLabel = new Label(topComposite, SWT.LEFT);
fontsLabel.setText("Font category:");
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
fontsLabel.setLayoutData(gd);
Composite fontComposite = new Composite(topComposite, SWT.BORDER);
GridLayout fontLayout = new GridLayout(3, false);
fontComposite.setLayout(fontLayout);
fontComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
monospaceFont = new FontFieldEditor(PreferenceConstants.MONOSPACE_FONT, "Monospace", fontComposite);
sanserifFont = new FontFieldEditor(PreferenceConstants.SANSERIF_FONT, "Sans Serif", fontComposite);
serifFont = new FontFieldEditor(PreferenceConstants.SERIF_FONT, "Serif", fontComposite);
GridLayout bgLayout = new GridLayout(2, false);
bgLayout.marginHeight = 5;
bgLayout.marginWidth = 10;
topComposite.setLayout(bgLayout);
Label bgLabel = new Label(topComposite, SWT.LEFT);
bgLabel.setText("Hilight category:");
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
bgLabel.setLayoutData(gd);
bgCategoryTable = new TableViewer(topComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
bgCategoryTable.setContentProvider(new ArrayContentProvider());
bgCategoryTable.setLabelProvider(new PresentationLabelProvider(bgCategoryTable));
bgCategoryTable.setComparator(new ViewerComparator());
gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_BOTH);
gd.widthHint = convertWidthInCharsToPixels(25);
// convertHeightInCharsToPixels(5);
gd.heightHint = 90;
bgCategoryTable.getControl().setLayoutData(gd);
bgColumn = new TableColumn(bgCategoryTable.getTable(), SWT.LEFT);
Composite bgStylesComposite = new Composite(topComposite, SWT.NONE);
GridLayout bgStylesLayout = new GridLayout(2, false);
bgStylesLayout.marginHeight = 0;
bgStylesLayout.marginWidth = 0;
bgStylesComposite.setLayout(bgStylesLayout);
bgStylesComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
label = new Label(bgStylesComposite, SWT.LEFT);
label.setText("Color:");
label.setLayoutData(new GridData());
bgColorSelector = new ColorSelector(bgStylesComposite);
Label fgLabel = new Label(topComposite, SWT.NONE);
fgLabel.setText("Syntax category:");
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
fgLabel.setLayoutData(gd);
fgCategoryTable = new TableViewer(topComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
fgCategoryTable.setContentProvider(new ArrayContentProvider());
fgCategoryTable.setLabelProvider(new PresentationLabelProvider(fgCategoryTable));
fgCategoryTable.setComparator(new ViewerComparator());
gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_BOTH);
gd.widthHint = convertWidthInCharsToPixels(25);
// convertHeightInCharsToPixels(4);
gd.heightHint = 52;
fgCategoryTable.getControl().setLayoutData(gd);
fgColumn = new TableColumn(fgCategoryTable.getTable(), SWT.LEFT);
Composite fgStylesComposite = new Composite(topComposite, SWT.NONE);
GridLayout fgStylesLayout = new GridLayout(2, false);
fgStylesLayout.marginHeight = 0;
fgStylesLayout.marginWidth = 0;
fgStylesComposite.setLayout(fgStylesLayout);
fgStylesComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
label = new Label(fgStylesComposite, SWT.LEFT);
label.setText("Color:");
label.setLayoutData(new GridData());
fgColorSelector = new ColorSelector(fgStylesComposite);
label = new Label(fgStylesComposite, SWT.LEFT);
label.setText("Font:");
label.setLayoutData(new GridData());
classCombo = new Combo(fgStylesComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
classCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
label = new Label(fgStylesComposite, SWT.LEFT);
label.setText("Style:");
label.setLayoutData(new GridData());
styleCombo = new Combo(fgStylesComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
styleCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
label = new Label(fgStylesComposite, SWT.LEFT);
label.setText("Size:");
label.setLayoutData(new GridData());
sizeCombo = new Combo(fgStylesComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
sizeCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
bgCategoryTable.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
if (!event.getSelection().isEmpty()) {
handleBgCategoryListSelection();
}
}
});
bgCategoryTable.getControl().addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
bgColumn.setWidth(bgCategoryTable.getControl().getSize().x - 4);
}
});
bgColorSelector.addListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
RGB newRGB = (RGB) event.getNewValue();
String key = getSelectedKey(bgCategoryTable);
if (key != null && newRGB != null && !newRGB.equals(event.getOldValue())) {
store.putValue(key, StringConverter.asString(newRGB));
}
}
});
fgCategoryTable.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
if (!event.getSelection().isEmpty()) {
handleFgCategoryListSelection();
}
}
});
fgCategoryTable.getControl().addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
fgColumn.setWidth(fgCategoryTable.getControl().getSize().x - 24);
}
});
fgColorSelector.addListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
RGB newRGB = (RGB) event.getNewValue();
String key = getSelectedKey(fgCategoryTable);
if (key != null && newRGB != null && !newRGB.equals(event.getOldValue())) {
store.putValue(key, StringConverter.asString(newRGB));
}
}
});
classCombo.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
String key = getSelectedKey(fgCategoryTable);
store.putValue(key + PreferenceConstants.CLASS, FontClass.nameOf(classCombo.getSelectionIndex()));
}
});
styleCombo.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
String key = getSelectedKey(fgCategoryTable);
store.putValue(key + PreferenceConstants.STYLE, FontStyle.nameOf(styleCombo.getSelectionIndex()));
}
});
sizeCombo.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
String key = getSelectedKey(fgCategoryTable);
store.putValue(key + PreferenceConstants.SIZE, FontSize.nameOf(sizeCombo.getSelectionIndex()));
}
});
initialize();
return topComposite;
}
use of org.eclipse.jface.viewers.ViewerComparator in project portfolio by buchen.
the class ListSelectionDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
Composite container = new Composite(composite, SWT.None);
GridDataFactory.fillDefaults().grab(true, true).hint(400, 300).applyTo(container);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(container);
Label label = new Label(container, SWT.None);
label.setText(this.message);
GridDataFactory.fillDefaults().grab(true, false).applyTo(label);
searchText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, false).applyTo(searchText);
searchText.setFocus();
Composite tableArea = new Composite(container, SWT.NONE);
GridDataFactory.fillDefaults().grab(false, true).applyTo(tableArea);
tableArea.setLayout(new FillLayout());
TableColumnLayout layout = new TableColumnLayout();
tableArea.setLayout(layout);
elementFilter = new ElementFilter();
int style = SWT.BORDER | SWT.FULL_SELECTION;
if (isMultiSelection)
style |= SWT.MULTI;
tableViewer = new TableViewer(tableArea, style);
final Table table = tableViewer.getTable();
table.setHeaderVisible(false);
table.setLinesVisible(false);
TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.None);
layout.setColumnData(column.getColumn(), new ColumnWeightData(100));
tableViewer.setLabelProvider(labelProvider);
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
tableViewer.addFilter(elementFilter);
tableViewer.setInput(elements);
tableViewer.setComparator(new ViewerComparator());
hookListener();
return composite;
}
use of org.eclipse.jface.viewers.ViewerComparator in project portfolio by buchen.
the class OpenPreferenceDialogHandler method execute.
@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell) {
PreferenceManager pm = new PreferenceManager();
// $NON-NLS-1$
pm.addToRoot(new PreferenceNode(PortfolioPlugin.PLUGIN_ID + ".updates", new UpdatePreferencePage()));
// $NON-NLS-1$
pm.addToRoot(new PreferenceNode(PortfolioPlugin.PLUGIN_ID + ".language", new LanguagePreferencePage()));
// $NON-NLS-1$
pm.addToRoot(new PreferenceNode(PortfolioPlugin.PLUGIN_ID + ".proxy", new ProxyPreferencePage()));
// $NON-NLS-1$
pm.addToRoot(new PreferenceNode(PortfolioPlugin.PLUGIN_ID + ".presentation", new PresentationPreferencePage()));
// $NON-NLS-1$
pm.addToRoot(new PreferenceNode(PortfolioPlugin.PLUGIN_ID + ".general", new GeneralPreferencePage()));
// $NON-NLS-1$
pm.addToRoot(new PreferenceNode(PortfolioPlugin.PLUGIN_ID + ".apikeys", new APIKeysPreferencePage()));
PreferenceDialog dialog = new PreferenceDialog(shell, pm);
dialog.setPreferenceStore(PortfolioPlugin.getDefault().getPreferenceStore());
dialog.create();
dialog.getTreeViewer().setComparator(new ViewerComparator());
dialog.getTreeViewer().expandAll();
dialog.open();
}
use of org.eclipse.jface.viewers.ViewerComparator in project titan.EclipsePlug-ins by eclipse.
the class OutlinePage method createControl.
@Override
public void createControl(final Composite parent) {
super.createControl(parent);
final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
viewer = getTreeViewer();
viewer.setContentProvider(new OutlineContentProvider());
viewer.setLabelProvider(new OutlineLabelProvider());
OutlineViewSorter comperator = new OutlineViewSorter();
comperator.setSortByName(store.getBoolean(PreferenceConstants.OUTLINE_SORTED));
viewer.setComparator(comperator);
viewer.setAutoExpandLevel(2);
viewer.setInput(getModule());
viewer.addSelectionChangedListener(this);
IActionBars bars = getSite().getActionBars();
Action sortToggler = new Action("Sort") {
@Override
public void run() {
ViewerComparator comperator = viewer.getComparator();
if (comperator == null) {
comperator = new OutlineViewSorter();
viewer.setComparator(comperator);
}
if (comperator instanceof OutlineViewSorter) {
store.setValue(PreferenceConstants.OUTLINE_SORTED, isChecked());
((OutlineViewSorter) comperator).setSortByName(isChecked());
}
viewer.refresh();
}
};
sortToggler.setImageDescriptor(ImageCache.getImageDescriptor("sort_alphabetically.gif"));
sortToggler.setChecked(store.getBoolean(PreferenceConstants.OUTLINE_SORTED));
bars.getToolBarManager().add(sortToggler);
}
Aggregations