use of org.eclipse.jface.viewers.IStructuredContentProvider in project azure-tools-for-java by Microsoft.
the class ApplicationInsightsPreferencePage method createApplicationInsightsResourceTable.
/**
* createApplicationInsightsResourceTable.
*/
public void createApplicationInsightsResourceTable(Composite parent) {
table = new Table(parent, SWT.BORDER | SWT.FULL_SELECTION);
table.setHeaderVisible(true);
table.setLinesVisible(true);
GridData gridData = new GridData();
gridData.heightHint = 360;
gridData.verticalIndent = 15;
gridData.horizontalAlignment = SWT.FILL;
gridData.grabExcessHorizontalSpace = false;
table.setLayoutData(gridData);
TableColumn strNameCol = new TableColumn(table, SWT.FILL);
strNameCol.setText(Messages.resrcName);
strNameCol.setWidth(150);
TableColumn strUrlDisCol = new TableColumn(table, SWT.FILL);
strUrlDisCol.setText(Messages.instrKey);
strUrlDisCol.setWidth(190);
tableViewer = new TableViewer(table);
tableViewer.setContentProvider(new IStructuredContentProvider() {
@Override
public void inputChanged(Viewer viewer, Object obj, Object obj1) {
}
@Override
public void dispose() {
}
@Override
public Object[] getElements(Object obj) {
return getTableContent();
}
});
tableViewer.setLabelProvider(new ITableLabelProvider() {
@Override
public void removeListener(ILabelProviderListener ilabelproviderlistener) {
}
@Override
public boolean isLabelProperty(Object element, String s) {
return false;
}
@Override
public void dispose() {
}
@Override
public void addListener(ILabelProviderListener ilabelproviderlistener) {
}
@Override
public String getColumnText(Object element, int i) {
ApplicationInsightsPageTableElement rowElement = (ApplicationInsightsPageTableElement) element;
String result = "";
switch(i) {
case 0:
result = rowElement.getResourceName();
break;
case 1:
result = rowElement.getInstrumentationKey();
break;
default:
break;
}
return result;
}
@Override
public Image getColumnImage(Object element, int i) {
return null;
}
});
tableViewer.setInput(getTableContent());
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 1;
gridData = new GridData();
gridData.horizontalAlignment = SWT.END;
gridData.verticalAlignment = GridData.BEGINNING;
gridData.verticalIndent = 15;
Composite containerButtons = new Composite(parent, SWT.NONE);
containerButtons.setLayout(gridLayout);
containerButtons.setLayoutData(gridData);
btnNew = new Button(containerButtons, SWT.PUSH);
btnNew.setText(Messages.btnNewLbl);
gridData = new GridData();
gridData.widthHint = 70;
btnNew.setLayoutData(gridData);
btnNew.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent arg0) {
newButtonListener();
}
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
btnAdd = new Button(containerButtons, SWT.PUSH);
btnAdd.setText(Messages.btnAddLbl);
gridData = new GridData();
gridData.widthHint = 70;
btnAdd.setLayoutData(gridData);
btnAdd.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent arg0) {
addButtonListener();
}
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
btnDetails = new Button(containerButtons, SWT.PUSH);
btnDetails.setEnabled(false);
btnDetails.setText(Messages.btnDtlsLbl);
gridData = new GridData();
gridData.widthHint = 70;
btnDetails.setLayoutData(gridData);
btnDetails.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent arg0) {
detailsButtonListener();
}
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
btnRemove = new Button(containerButtons, SWT.PUSH);
btnRemove.setEnabled(false);
btnRemove.setText(Messages.btnRmvLbl);
gridData = new GridData();
gridData.widthHint = 70;
btnRemove.setLayoutData(gridData);
btnRemove.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent arg0) {
removeButtonListener();
}
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
table.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent event) {
selIndex = tableViewer.getTable().getSelectionIndex();
btnDetails.setEnabled(true);
btnRemove.setEnabled(true);
}
@Override
public void widgetDefaultSelected(SelectionEvent event) {
}
});
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent selectionchangedevent) {
if (selectionchangedevent.getSelection().isEmpty()) {
btnDetails.setEnabled(false);
btnRemove.setEnabled(false);
}
}
});
}
use of org.eclipse.jface.viewers.IStructuredContentProvider 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 org.eclipse.jface.viewers.IStructuredContentProvider 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;
}
use of org.eclipse.jface.viewers.IStructuredContentProvider in project erlide_eclipse by erlang.
the class FoldingConfigurationBlock method createProviderViewer.
private ComboViewer createProviderViewer() {
/* list viewer */
final ComboViewer viewer = new ComboViewer(fProviderCombo);
viewer.setContentProvider(new IStructuredContentProvider() {
/*
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
@Override
public void dispose() {
}
/*
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse
* .jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public void inputChanged(final Viewer v, final Object oldInput, final Object newInput) {
}
/*
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements
* (java.lang.Object)
*/
@Override
public Object[] getElements(final Object inputElement) {
return fProviderDescriptors.values().toArray();
}
});
viewer.setLabelProvider(new LabelProvider() {
/*
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object )
*/
@Override
public Image getImage(final Object element) {
return null;
}
/*
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
*/
@Override
public String getText(final Object element) {
return ((ErlangFoldingStructureProviderDescriptor) element).getName();
}
});
viewer.addSelectionChangedListener(event -> {
final IStructuredSelection sel = (IStructuredSelection) event.getSelection();
if (!sel.isEmpty()) {
fStore.setValue(PreferenceConstants.EDITOR_FOLDING_PROVIDER, ((ErlangFoldingStructureProviderDescriptor) sel.getFirstElement()).getId());
updateListDependencies();
}
});
viewer.setInput(fProviderDescriptors);
viewer.refresh();
return viewer;
}
Aggregations