use of org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField in project linuxtools by eclipse.
the class ChartDialog method produceChart.
/**
* Build the chart from configuration
*
* @return a new chart
*/
private Chart produceChart() {
IStructuredSelection selection = (IStructuredSelection) stViewer.getViewer().getSelection();
if (selection == StructuredSelection.EMPTY)
return null;
Object[] objects = selection.toArray();
ISTDataViewersField labelField = getLabelField(stViewer);
List<IChartField> selectedFields = new ArrayList<>();
for (Button button : columnButtons) {
if (button.getSelection()) {
selectedFields.add((IChartField) button.getData());
}
}
boolean barChartType = barGraphButton.getSelection();
boolean horizontalBars = !verticalBarsButton.getSelection();
if (barChartType) {
return ChartFactory.produceBarChart(objects, labelField, selectedFields, Messages.ChartConstants_BAR_GRAPH, horizontalBars);
} else {
return ChartFactory.producePieChart(objects, labelField, selectedFields, Messages.ChartConstants_PIE_CHART);
}
}
use of org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField in project linuxtools by eclipse.
the class STCopyAction method run.
@Override
public void run() {
Clipboard cb = new Clipboard(Display.getDefault());
IStructuredSelection selections = (IStructuredSelection) stViewer.getViewer().getSelection();
Iterator<?> iterator = selections.iterator();
StringBuilder sb = new StringBuilder();
while (iterator.hasNext()) {
Object obj = iterator.next();
boolean needTab = false;
for (ISTDataViewersField field : stViewer.getAllFields()) {
if (needTab) {
sb.append("\t");
}
needTab = true;
if (field.getValue(obj) != null) {
sb.append(field.getValue(obj));
}
}
sb.append("\n");
}
cb.setContents(new Object[] { sb.toString() }, new Transfer[] { TextTransfer.getInstance() });
}
use of org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField in project linuxtools by eclipse.
the class STDataViewersSortDialog method updateUI.
private void updateUI(int[] priorities, int[] directions) {
Item[] columns = sorter.getColumns();
List<String> allItems = new ArrayList<>();
List<Integer> allDirections = new ArrayList<>();
for (int i = 0; i < columns.length; i++) {
if (priorities == null || directions == null) {
allItems.add(columns[i].getText());
ISTDataViewersField field = (ISTDataViewersField) columns[i].getData();
allDirections.add(field.getDefaultDirection());
} else {
allItems.add(columns[priorities[i]].getText());
allDirections.add(directions[priorities[i]]);
}
}
for (int i = 0; i < priorityCombos.length; i++) {
priorityCombos[i].removeAll();
priorityCombos[i].setItems(allItems.toArray(new String[allItems.size()]));
priorityCombos[i].select(0);
allItems.remove(0);
ascendingButtons[i].setSelection(allDirections.get(0) == STDataViewersComparator.ASCENDING);
descendingButtons[i].setSelection(allDirections.get(0) == STDataViewersComparator.DESCENDING);
allDirections.remove(0);
}
}
use of org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField in project linuxtools by eclipse.
the class STHeaderListener method widgetSelected.
@Override
public void widgetSelected(SelectionEvent e) {
final Item column = (Item) e.widget;
final ISTDataViewersField field = (ISTDataViewersField) column.getData();
resortTable(column, field);
}
use of org.eclipse.linuxtools.dataviewers.abstractviewers.ISTDataViewersField in project linuxtools by eclipse.
the class ChartDialog method addColumnButtons.
/**
* Adds one check button for each column implementing the IChartField interface.
*
* @see IChartField
* @param comp
* @param listener
*/
private void addColumnButtons(Composite comp, SelectionListener listener) {
columnButtons = new LinkedList<>();
for (ISTDataViewersField field : stViewer.getAllFields()) {
if (field instanceof IChartField) {
IChartField cField = (IChartField) field;
Button b = new Button(comp, SWT.CHECK);
b.setText(cField.getColumnHeaderText());
b.setData(cField);
b.addSelectionListener(listener);
GridData dt = new GridData();
b.setLayoutData(dt);
columnButtons.add(b);
}
}
Label sep = new Label(comp, SWT.SEPARATOR | SWT.HORIZONTAL);
GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
sep.setLayoutData(data);
Composite buttonComposite = new Composite(comp, SWT.NONE);
data = new GridData();
buttonComposite.setLayoutData(data);
FillLayout l = new FillLayout();
l.spacing = 5;
buttonComposite.setLayout(l);
final Button b1 = new Button(buttonComposite, SWT.PUSH);
b1.setText(Messages.ChartConstants_SELECT_ALL);
final Button b2 = new Button(buttonComposite, SWT.PUSH);
b2.setText(Messages.ChartConstants_DESELECT_ALL);
SelectionListener sl = new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
boolean b = (e.getSource() == b1);
for (Button button : columnButtons) {
button.setSelection(b);
}
validateInput();
}
};
b1.addSelectionListener(sl);
b2.addSelectionListener(sl);
}
Aggregations