use of net.sourceforge.pmd.eclipse.ui.BasicTableLabelProvider in project pmd-eclipse-plugin by pmd.
the class BasicTableManager method setupColumns.
/**
* @param columnDescs
* RuleColumnDescriptor[]
* @param groupingField
* RuleFieldAccessor
*/
public void setupColumns(ItemColumnDescriptor[] columnDescs) {
Table table = tableViewer.getTable();
for (int i = 0; i < columnDescs.length; i++) {
columnDescs[i].buildTableColumn(table, this);
}
tableViewer.setLabelProvider(new BasicTableLabelProvider(columnDescs));
TableColumn[] columns = table.getColumns();
for (TableColumn column : columns) {
column.pack();
}
}
use of net.sourceforge.pmd.eclipse.ui.BasicTableLabelProvider in project pmd-eclipse-plugin by pmd.
the class FilterPreferencesPage method buildFilterGroup.
/**
* Build the group of priority preferences
*
* @param parent
* the parent composite
*
* @return the group widget
*/
private Composite buildFilterGroup(Composite parent) {
IStructuredContentProvider contentProvider = new IStructuredContentProvider() {
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
public Object[] getElements(Object inputElement) {
return (FilterHolder[]) inputElement;
}
};
BasicTableLabelProvider labelProvider = new BasicTableLabelProvider(FilterColumnUI.VISIBLE_COLUMNS);
reportTableMgr = new BasicTableManager<FilterHolder>("renderers", null, FilterColumnUI.VISIBLE_COLUMNS);
tableViewer = reportTableMgr.buildTableViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK);
reportTableMgr.setupColumns(FilterColumnUI.VISIBLE_COLUMNS);
Table table = tableViewer.getTable();
table.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 1, 1));
tableViewer.setLabelProvider(labelProvider);
tableViewer.setContentProvider(contentProvider);
table.setHeaderVisible(true);
tableViewer.setInput(currentFilters());
selectCheckedFilters();
TableColumn[] columns = table.getColumns();
for (TableColumn column : columns) {
column.pack();
}
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
patternsSelected();
}
});
tableViewer.getTable().addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if (event.detail == SWT.CHECK) {
checked(event.item);
}
}
});
return parent;
}
use of net.sourceforge.pmd.eclipse.ui.BasicTableLabelProvider in project pmd-eclipse-plugin by pmd.
the class ASTViewPage method createControl.
/**
* TODO use an adjustable Sash to separate the two sections TODO add an
* XPath version combo widget
*/
public void createControl(Composite parent) {
sashForm = new SashForm(parent, SWT.HORIZONTAL);
Composite astPanel = new Composite(sashForm, SWT.NONE);
GridLayout mainLayout = new GridLayout(3, false);
astPanel.setLayout(mainLayout);
Composite titleArea = new Composite(astPanel, SWT.NONE);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
titleArea.setLayoutData(gridData);
titleArea.setLayout(new GridLayout(4, false));
Label showLabel = new Label(titleArea, 0);
showLabel.setText("Show: ");
final Button classBtn = new Button(titleArea, SWT.RADIO);
classBtn.setText("Class");
classBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent se) {
if (classBtn.getSelection()) {
showClass();
}
}
});
final Button methodBtn = new Button(titleArea, SWT.RADIO);
methodBtn.setText("Method");
methodBtn.setSelection(true);
methodBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent se) {
enableMethodSelector(methodBtn.getSelection());
methodPicked();
}
});
buildMethodSelector(titleArea);
astViewer = new TreeViewer(astPanel, SWT.MULTI | SWT.BORDER);
contentProvider = new ASTContentProvider(true, true);
astViewer.setContentProvider(contentProvider);
astViewer.setLabelProvider(new ASTLabelProvider());
setupListeners(astViewer.getTree());
GridData data = new GridData(GridData.FILL_BOTH);
data.horizontalSpan = 2;
astViewer.getTree().setLayoutData(data);
// ==================
Composite xpathTestPanel = new Composite(sashForm, SWT.NONE);
data = new GridData(GridData.FILL_BOTH);
data.horizontalSpan = 1;
xpathTestPanel.setLayoutData(data);
GridLayout playLayout = new GridLayout(2, false);
xpathTestPanel.setLayout(playLayout);
xpathField = new StyledText(xpathTestPanel, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
gridData = new GridData(GridData.FILL_BOTH);
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalSpan = 1;
xpathField.setLayoutData(gridData);
SyntaxManager.adapt(xpathField, "xpath", null);
addXPathValidator();
goButton = new Button(xpathTestPanel, SWT.PUSH);
goButton.setText("GO");
gridData = new GridData(GridData.FILL_BOTH);
gridData.grabExcessHorizontalSpace = false;
gridData.horizontalSpan = 1;
goButton.setLayoutData(gridData);
goButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
evaluateXPath();
}
});
// outputField = new StyledText(xpathTestPanel, SWT.BORDER |
// SWT.H_SCROLL | SWT.V_SCROLL);
gridData = new GridData(GridData.FILL_BOTH);
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalSpan = 2;
// outputField.setLayoutData(gridData);
// SyntaxManager.adapt(outputField, "xpath", null);
BasicTableManager tableMgr = new BasicTableManager("ast", null, NodeColumnUI.VISIBLE_COLUMNS);
resultsViewer = tableMgr.buildTableViewer(xpathTestPanel);
tableMgr.setupColumns(NodeColumnUI.VISIBLE_COLUMNS);
IStructuredContentProvider contentProvider = new IStructuredContentProvider() {
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
public Object[] getElements(Object inputElement) {
return (Node[]) inputElement;
}
};
BasicTableLabelProvider labelProvider = new BasicTableLabelProvider(NodeColumnUI.VISIBLE_COLUMNS);
Table table = resultsViewer.getTable();
table.setLayoutData(gridData);
resultsViewer.setLabelProvider(labelProvider);
resultsViewer.setContentProvider(contentProvider);
registerListeners();
showFirstMethod();
}
use of net.sourceforge.pmd.eclipse.ui.BasicTableLabelProvider in project pmd-eclipse-plugin by pmd.
the class GeneralPreferencesPage method buildPriorityGroup.
/**
* Build the group of priority preferences
*
* @param parent
* the parent composite
* @return the group widget
*/
private Group buildPriorityGroup(final Composite parent) {
Group group = new Group(parent, SWT.SHADOW_IN);
group.setText(getMessage(StringKeys.PREF_GENERAL_GROUP_PRIORITIES));
group.setLayout(new GridLayout(2, false));
Link link = createPreferenceLink(group, "PMD folder annotations can be enabled on the <A>label decorations</A> page", "org.eclipse.ui.preferencePages.Decorators");
link.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 1, 1));
useCustomPriorityNames = buildUseCustomPriorityNamesButton(group);
useCustomPriorityNames.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false, 1, 1));
IStructuredContentProvider contentProvider = new IStructuredContentProvider() {
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
public Object[] getElements(Object inputElement) {
return (RulePriority[]) inputElement;
}
};
BasicTableLabelProvider labelProvider = new BasicTableLabelProvider(PriorityColumnUI.VISIBLE_COLUMNS);
priorityTableMgr = new BasicTableManager("prio", null, PriorityColumnUI.VISIBLE_COLUMNS);
tableViewer = priorityTableMgr.buildTableViewer(group);
priorityTableMgr.setupColumns(PriorityColumnUI.VISIBLE_COLUMNS);
Table table = tableViewer.getTable();
table.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, true, 2, 1));
tableViewer.setLabelProvider(labelProvider);
tableViewer.setContentProvider(contentProvider);
table.setHeaderVisible(true);
// labelProvider.addColumnsTo(table);
tableViewer.setInput(UISettings.currentPriorities(true));
// TableColumn[] columns = table.getColumns();
// for (TableColumn column : columns) column.pack();
Composite editorPanel = new Composite(group, SWT.None);
editorPanel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, true));
editorPanel.setLayout(new GridLayout(6, false));
Label shapeLabel = new Label(editorPanel, SWT.None);
shapeLabel.setLayoutData(new GridData());
shapeLabel.setText("Shape:");
final ShapePicker<Shape> ssc = new ShapePicker<Shape>(editorPanel, SWT.None, 14);
ssc.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
ssc.setSize(280, 30);
ssc.setShapeMap(UISettings.shapeSet(SHAPE_COLOR, 10));
ssc.setItems(UISettings.allShapes());
Label colourLabel = new Label(editorPanel, SWT.None);
colourLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 1, 1));
colourLabel.setText("Color:");
final ColorSelector colorPicker = new ColorSelector(editorPanel);
Label nameLabel = new Label(editorPanel, SWT.None);
nameLabel.setLayoutData(new GridData());
nameLabel.setText("Name:");
final Text priorityName = new Text(editorPanel, SWT.BORDER);
priorityName.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, true));
nameFields = new Control[] { nameLabel, priorityName };
// final Label descLabel = new Label(editorPanel, SWT.None);
// descLabel.setLayoutData( new GridData(GridData.FILL, GridData.CENTER,
// false, true, 1, 1));
// descLabel.setText("Description:");
// final Text priorityDesc = new Text(editorPanel, SWT.BORDER);
// priorityDesc.setLayoutData( new GridData(GridData.FILL,
// GridData.CENTER, true, true, 5, 1) );
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
selectedPriorities(selection.toList(), ssc, colorPicker, priorityName);
}
});
ssc.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
setShape((Shape) selection.getFirstElement());
}
});
colorPicker.addListener(new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
setColor((RGB) event.getNewValue());
}
});
priorityName.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
setName(priorityName.getText());
}
});
// only set this once the name fields are built
useCustomPriorityNames.setSelection(preferences.useCustomPriorityNames());
return group;
}
use of net.sourceforge.pmd.eclipse.ui.BasicTableLabelProvider in project pmd-eclipse-plugin by pmd.
the class ReportPreferencesPage method buildReportGroup.
/**
* Build the group of priority preferences
*
* @param parent
* the parent composite
*
* @return the group widget
*/
private Composite buildReportGroup(Composite parent) {
Composite group = new Composite(parent, SWT.NONE);
// group.setText("Formats");
group.setLayout(new GridLayout(2, false));
IStructuredContentProvider contentProvider = new IStructuredContentProvider() {
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
public Object[] getElements(Object inputElement) {
return (Renderer[]) inputElement;
}
};
BasicTableLabelProvider labelProvider = new BasicTableLabelProvider(ReportColumnUI.VISIBLE_COLUMNS);
reportTableMgr = new BasicTableManager("renderers", null, ReportColumnUI.VISIBLE_COLUMNS);
tableViewer = reportTableMgr.buildTableViewer(group, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK);
reportTableMgr.setupColumns(ReportColumnUI.VISIBLE_COLUMNS);
Table table = tableViewer.getTable();
table.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, true, 2, 1));
tableViewer.setLabelProvider(labelProvider);
tableViewer.setContentProvider(contentProvider);
table.setHeaderVisible(true);
// labelProvider.addColumnsTo(table);
tableViewer.setInput(ReportManager.INSTANCE.allRenderers());
selectCheckedRenderers();
TableColumn[] columns = table.getColumns();
for (TableColumn column : columns) {
column.pack();
}
Composite editorPanel = new Composite(group, SWT.None);
editorPanel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, true));
editorPanel.setLayout(new GridLayout(4, false));
Label nameLabel = new Label(editorPanel, SWT.None);
nameLabel.setLayoutData(new GridData());
nameLabel.setText("Name:");
final Label rendererName = new Label(editorPanel, SWT.BORDER);
rendererName.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, true));
final Button suppressed = new Button(editorPanel, SWT.CHECK);
suppressed.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
suppressed.setText("Show suppressed violations");
Label descLabel = new Label(editorPanel, SWT.None);
descLabel.setLayoutData(new GridData());
descLabel.setText("Description:");
final Label descValue = new Label(editorPanel, SWT.BORDER);
descValue.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, true, 3, 1));
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
List items = selection.toList();
selectedRenderers(items, rendererName, descValue, suppressed);
if (items.size() == 1) {
formArranger.arrangeFor((Renderer) items.get(0));
} else {
formArranger.clearChildren();
}
}
});
tableViewer.getTable().addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if (event.detail == SWT.CHECK) {
checked(event.item);
}
}
});
suppressed.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
}
});
rendererName.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
setName(rendererName.getText());
}
});
return group;
}
Aggregations