use of net.sourceforge.pmd.eclipse.ui.ShapePicker in project pmd-eclipse-plugin by pmd.
the class RulePanelManager method buildPriorityControls.
private void buildPriorityControls(Composite parent) {
Label priorityLabel = buildLabel(parent, StringKeys.PREF_RULEEDIT_LABEL_PRIORITY);
GridData data = new GridData();
data.horizontalSpan = 1;
priorityLabel.setLayoutData(data);
priorityCombo = buildPriorityCombo(parent);
priorityDisplay = new ShapePicker(parent, SWT.NONE, 14);
priorityDisplay.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 4, 1));
priorityDisplay.setShapeMap(UISettings.shapesByPriority());
priorityDisplay.tooltipProvider(new LabelProvider() {
public String labelFor(Object item) {
return UISettings.labelFor((RulePriority) item);
}
});
priorityDisplay.setSize(120, 25);
}
use of net.sourceforge.pmd.eclipse.ui.ShapePicker 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;
}
Aggregations