use of org.eclipse.jface.viewers.IStructuredContentProvider in project tdq-studio-se by Talend.
the class ImportWizardPage method createErrorsList.
/**
* DOC bZhou Comment method "createErrorsList".
*
* @param top
*/
private void createErrorsList(Composite top) {
Group errorGroup = new Group(top, SWT.NONE);
errorGroup.setLayout(new GridLayout());
// $NON-NLS-1$
errorGroup.setText(Messages.getString("ImportWizardPage.5"));
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.heightHint = 100;
errorGroup.setLayoutData(gridData);
errorsList = new TableViewer(errorGroup, SWT.BORDER);
errorsList.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
errorsList.setContentProvider(new IStructuredContentProvider() {
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
public Object[] getElements(Object inputElement) {
return errors.toArray();
}
});
errorsList.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return element.toString();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
*/
@Override
public Image getImage(Object element) {
if (overwriteBTN.getSelection()) {
return ImageLib.getImage(ImageLib.WARN_OVR);
}
return ImageLib.getImage(ImageLib.ICON_ERROR_INFO);
}
});
errorsList.setInput(this);
errorsList.setSorter(new ViewerSorter());
}
use of org.eclipse.jface.viewers.IStructuredContentProvider in project tdq-studio-se by Talend.
the class EditSortMatchRuleNamesDialog method createTableViewer.
/**
* create Table Viewer.
*
* @param parent
* @return
*/
private void createTableViewer(Composite parent) {
tableViewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
Table table_1 = tableViewer.getTable();
GridData gd_table_1 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
gd_table_1.heightHint = 217;
table_1.setLayoutData(gd_table_1);
Table table = (Table) tableViewer.getControl();
TableLayout tableLayout = new TableLayout();
tableLayout.addColumnData(new ColumnPixelData(350));
table.setLayout(tableLayout);
tableViewer.setContentProvider(new IStructuredContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
return (OrderMatchRule[]) inputElement;
}
@Override
public void dispose() {
// do nothing here, until now
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// do nothing here, until now
}
});
createMatchRuleNameColumn();
table.setHeaderVisible(true);
table.setLinesVisible(true);
tableViewer.setInput(orderMatchRuleList.toArray(new OrderMatchRule[orderMatchRuleList.size()]));
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
// when the selection changed, update the up/down buttons status
updateButtonsStatus();
}
});
}
use of org.eclipse.jface.viewers.IStructuredContentProvider in project webtools.servertools by eclipse.
the class ServerClasspathContainerPage method createControl.
public void createControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
comp.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
comp.setLayout(layout);
Label label = new Label(comp, SWT.NONE);
label.setText(Messages.classpathContainerRuntimeList);
Table table = new Table(comp, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION);
table.setLayoutData(new GridData(GridData.FILL_BOTH));
table.setHeaderVisible(false);
TableViewer tableViewer = new TableViewer(table);
tableViewer.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
Object[] obj = runtimeMap.keySet().toArray();
return obj;
}
public void dispose() {
// ignore
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// ignore
}
});
tableViewer.setLabelProvider(new RuntimeTableLabelProvider());
tableViewer.setInput("root");
if (selection != null) {
Set<IRuntime> set = runtimeMap.keySet();
IRuntime rt;
for (Iterator<IRuntime> i = set.iterator(); i.hasNext(); ) {
rt = i.next();
if (runtimeMap.get(rt).getPath().equals(selection.getPath())) {
tableViewer.setSelection(new StructuredSelection(new Object[] { rt }));
setPageComplete(true);
break;
}
}
}
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
try {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
selection = runtimeMap.get(sel.getFirstElement());
setPageComplete(true);
} catch (Exception e) {
selection = null;
setPageComplete(false);
}
}
});
if (tableViewer.getTable().getItemCount() != 0)
tableViewer.getTable().setFocus();
setControl(comp);
}
use of org.eclipse.jface.viewers.IStructuredContentProvider in project mdw-designer by CenturyLinkCloud.
the class ListComposer method createControls.
protected void createControls() {
int buttonWidth = 30;
// create the listener for the bunch of buttons
SelectionListener buttonListener = new ButtonListener();
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = isReadOnly() ? 2 : 3;
gridLayout.marginWidth = 0;
gridLayout.marginTop = 0;
this.setLayout(gridLayout);
GridData gd = new GridData();
gd.horizontalSpan = 2;
if (!isReadOnly()) {
Label srcLabelWidget = new Label(this, SWT.LEFT);
srcLabelWidget.setLayoutData(gd);
if (unselectedTitle != null)
srcLabelWidget.setText(unselectedTitle);
else
srcLabelWidget.setText(isReadOnly() ? "" : "Unselected " + title);
gd = new GridData();
Label destLabelWidget = new Label(this, SWT.LEFT);
destLabelWidget.setLayoutData(gd);
if (selectedTitle != null)
destLabelWidget.setText(selectedTitle);
else
destLabelWidget.setText("Selected " + title);
}
gd = new GridData(SWT.LEFT | GridData.FILL_BOTH);
gd.widthHint = getWidth();
srcViewer = new ListViewer(this);
srcViewer.getList().setLayoutData(gd);
srcViewer.setContentProvider(new IStructuredContentProvider() {
@SuppressWarnings("unchecked")
public Object[] getElements(Object inputElement) {
return ((List<String>) inputElement).toArray();
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
srcViewer.addFilter(new Filter());
if (!isReadOnly()) {
Composite buttons = new Composite(this, SWT.NULL);
buttons.setLayout(new RowLayout(SWT.VERTICAL));
addButton = new Button(buttons, SWT.PUSH);
addButton.setText(">");
Point size = addButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
RowData rd = new RowData(buttonWidth, size.y);
addButton.setLayoutData(rd);
addButton.addSelectionListener(buttonListener);
remButton = new Button(buttons, SWT.PUSH);
remButton.setText("<");
size = remButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
rd = new RowData(buttonWidth, size.y);
remButton.setLayoutData(rd);
remButton.addSelectionListener(buttonListener);
gd = new GridData(SWT.LEFT | GridData.FILL_BOTH);
gd.widthHint = getWidth();
destViewer = new ListViewer(this);
destViewer.getList().setLayoutData(gd);
}
}
use of org.eclipse.jface.viewers.IStructuredContentProvider in project eclipse-integration-commons by spring-projects.
the class GenericWizardCommandListPage method createCommandTableArea.
protected synchronized void createCommandTableArea(Composite parent) {
Composite tableArea = new Composite(parent, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(tableArea);
GridDataFactory.fillDefaults().grab(true, true).applyTo(tableArea);
Label tableLabel = new Label(tableArea, SWT.LEFT);
GridDataFactory.fillDefaults().grab(true, false).applyTo(tableLabel);
tableLabel.setText(SELECT_COMMAND_LABEL);
final ViewerSearchPart part = createSearchControl(tableArea);
Table table = new Table(tableArea, getViewerConfiguration());
commandTableViewer = new TableViewer(table);
part.connectViewer(commandTableViewer);
setTableColumnAndLayout(commandTableViewer);
commandTableViewer.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
if (inputElement instanceof Collection<?>) {
Collection<?> topLevel = (Collection<?>) inputElement;
return topLevel.toArray();
}
return null;
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// Nothing
}
public void dispose() {
// Nothing
}
});
commandTableViewer.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
if (element instanceof IFrameworkCommandDescriptor) {
return ((IFrameworkCommandDescriptor) element).getName();
}
return null;
}
});
commandTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) commandTableViewer.getSelection();
if (selection != null) {
Object selObj = selection.getFirstElement();
if (selObj instanceof IFrameworkCommandDescriptor) {
GenericWizardCommandListPage.this.selectionChanged((IFrameworkCommandDescriptor) selObj);
}
}
checkPageComplete();
}
});
commandTableViewer.getTable().addKeyListener(new KeyListener() {
public void keyReleased(KeyEvent e) {
}
public void keyPressed(KeyEvent e) {
// arrow pressed
if (e.keyCode == SWT.ARROW_UP) {
Object topSelection = commandTableViewer.getElementAt(0);
IFrameworkCommandDescriptor currentSelection = getSelectedCommandDescriptor();
if (topSelection == currentSelection) {
part.getTextControl().setFocus();
}
}
}
});
commandTableViewer.setInput(commandDescriptors);
Text searchText = part.getTextControl();
searchText.addKeyListener(new KeyListener() {
public void keyReleased(KeyEvent e) {
}
public void keyPressed(KeyEvent e) {
// down arrow is pressed
if (e.keyCode == SWT.ARROW_DOWN) {
commandTableViewer.getTable().setFocus();
Object selection = commandTableViewer.getElementAt(0);
if (selection instanceof IFrameworkCommandDescriptor) {
selectCommandInViewer((IFrameworkCommandDescriptor) selection);
}
}
}
});
// STS 1251: Add filter listener to automatically select commands based
// on the pattern that is typed
searchText.addKeyListener(new KeyListener() {
public void keyReleased(KeyEvent event) {
// STS 1251: If one element is left in the table after search is
// performed, select it to enable
// the appropriate wizard buttons
int itemCount = commandTableViewer.getTable().getItemCount();
if (itemCount == 1) {
IFrameworkCommandDescriptor remainingDescriptor = (IFrameworkCommandDescriptor) commandTableViewer.getElementAt(0);
if (remainingDescriptor != null) {
GenericWizardCommandListPage.this.selectCommandInViewer(remainingDescriptor);
}
} else {
// else clear the selection nothing is found by search or
// multiple matches are found
GenericWizardCommandListPage.this.selectCommandInViewer(null);
}
}
public void keyPressed(KeyEvent event) {
}
});
searchText.setFocus();
checkPageComplete();
}
Aggregations