use of org.eclipse.jface.viewers.ITableLabelProvider in project tdi-studio-se by Talend.
the class StatusConfirmSettingDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
TableViewer viewer = new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
GridData data = new GridData(GridData.FILL_BOTH);
data.minimumHeight = 200;
data.heightHint = 200;
data.minimumWidth = 350;
data.widthHint = 350;
viewer.getControl().setLayoutData(data);
final Table table = viewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn column = new TableColumn(table, SWT.NONE);
//$NON-NLS-1$
column.setText(Messages.getString("VersionManagementDialog.Items"));
column.setWidth(140);
column = new TableColumn(table, SWT.NONE);
//$NON-NLS-1$
column.setText(Messages.getString("StatusManagementDialog.Status"));
column.setWidth(120);
column = new TableColumn(table, SWT.NONE);
//$NON-NLS-1$
column.setText(Messages.getString("StatusManagementDialog.NewStatus"));
column.setWidth(90);
viewer.setContentProvider(ArrayContentProvider.getInstance());
viewer.setLabelProvider(new ITableLabelProvider() {
public Image getColumnImage(Object element, int columnIndex) {
RepositoryObject object = (RepositoryObject) element;
if (columnIndex == 0) {
ERepositoryObjectType itemType = object.getRepositoryObjectType();
return getItemsImage(CoreImageProvider.getIcon(itemType));
}
return null;
}
public String getColumnText(Object element, int columnIndex) {
RepositoryObject object = (RepositoryObject) element;
switch(columnIndex) {
case 0:
return object.getLabel();
case 1:
return statusHelper.getStatusLabel(object.getProperty().getOldStatusCode());
case 2:
if (object.getStatusCode().equals(object.getProperty().getOldStatusCode())) {
//$NON-NLS-1$
return "-";
}
return statusHelper.getStatusLabel(object.getStatusCode());
default:
}
return null;
}
public void addListener(ILabelProviderListener listener) {
}
public void dispose() {
}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void removeListener(ILabelProviderListener listener) {
}
});
viewer.setInput(modifiedVersionItems);
for (TableItem item : table.getItems()) {
RepositoryObject object = (RepositoryObject) item.getData();
// if (!object.getOldVersion().equals(object.getNewVersion())) {
item.setForeground(2, Display.getDefault().getSystemColor(SWT.COLOR_RED));
// }
}
return composite;
}
use of org.eclipse.jface.viewers.ITableLabelProvider in project tdi-studio-se by Talend.
the class ProcessVersionComposite method addSortListener.
/**
* DOC Administrator Comment method "addSortListener".
*
* @param table
* @param column1
* @param column2
* @param column3
*/
private void addSortListener(final Table table, final TableColumn column1, final TableColumn column2, final TableColumn column3, final TableColumn column4) {
Listener sortListener = new Listener() {
private int direction = 1;
@Override
public void handleEvent(Event e) {
final TableColumn column = (TableColumn) e.widget;
if (column == table.getSortColumn()) {
direction = -direction;
}
if (direction == 1) {
table.setSortDirection(SWT.DOWN);
} else {
table.setSortDirection(SWT.UP);
}
table.setSortColumn(column);
tableViewer.setSorter(new ViewerSorter() {
int index = 0;
@Override
public void sort(Viewer viewer, Object[] elements) {
while (index < table.getColumns().length && table.getColumn(index) != column) {
index++;
}
super.sort(viewer, elements);
}
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
ITableLabelProvider labelProvider = (ITableLabelProvider) tableViewer.getLabelProvider();
String columnText = labelProvider.getColumnText(e1, index) != null ? labelProvider.getColumnText(e1, index) : //$NON-NLS-1$
"";
String columnText2 = labelProvider.getColumnText(e2, index) != null ? labelProvider.getColumnText(e2, index) : //$NON-NLS-1$
"";
return getComparator().compare(columnText, columnText2) * direction;
}
});
}
};
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
/*
* (non-Javadoc)
*
* @seeorg.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.
* SelectionChangedEvent)
*/
@Override
public void selectionChanged(SelectionChangedEvent event) {
ProcessVersionComposite.this.selection = event.getSelection();
if (getParentWizard() != null) {
((WizardPage) getParentWizard()).setPageComplete(true);
}
}
});
column1.addListener(SWT.Selection, sortListener);
column2.addListener(SWT.Selection, sortListener);
column3.addListener(SWT.Selection, sortListener);
column4.addListener(SWT.Selection, sortListener);
table.setSortColumn(column1);
table.setSortDirection(SWT.DOWN);
tableViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
if (getParentWizard() == null) {
ITreeContextualAction editPropertiesAction = getEditPropertiesAction(EditPropertiesAction.class);
if (editPropertiesAction != null) {
editPropertiesAction.run();
}
}
}
});
}
use of org.eclipse.jface.viewers.ITableLabelProvider in project tdi-studio-se by Talend.
the class ImportDemoProjectItemsPage method initializeViewer.
/**
* initializeViewer.
*/
private void initializeViewer() {
wizardSelectionViewer.setContentProvider(new IStructuredContentProvider() {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// TODO Auto-generated method stub
}
@Override
public void dispose() {
// TODO Auto-generated method stub
}
@Override
public Object[] getElements(Object inputElement) {
if (inputElement instanceof List) {
return ((List) inputElement).toArray();
}
return null;
}
});
wizardSelectionViewer.setLabelProvider(new ITableLabelProvider() {
@Override
public void removeListener(ILabelProviderListener listener) {
}
@Override
public boolean isLabelProperty(Object element, String property) {
return false;
}
@Override
public void dispose() {
}
@Override
public void addListener(ILabelProviderListener listener) {
}
@Override
public String getColumnText(Object element, int columnIndex) {
if (element instanceof DemoProjectBean) {
DemoProjectBean field = (DemoProjectBean) element;
return field.getDemoDesc();
}
return "";
}
@Override
public Image getColumnImage(Object element, int columnIndex) {
if (element instanceof DemoProjectBean) {
return getFullImagePath((DemoProjectBean) element);
}
return null;
}
});
wizardSelectionViewer.setInput(this.demoProjectList);
}
use of org.eclipse.jface.viewers.ITableLabelProvider in project tdi-studio-se by Talend.
the class VersionSection method createControls.
@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
composite = getWidgetFactory().createFlatFormComposite(parent);
tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
final Table table = tableViewer.getTable();
TableLayout tableLayout = new TableLayout();
table.setLayout(tableLayout);
table.setHeaderVisible(true);
table.setLinesVisible(true);
final String[] columnProperties = new String[] { //$NON-NLS-1$
Messages.getString("VersionSection.Version"), //$NON-NLS-1$
Messages.getString("VersionSection.CreationDate"), Messages.getString("VersionSection.ModificationDate"), //$NON-NLS-1$ //$NON-NLS-2$
Messages.getString("VersionSection.Status") };
final TableColumn column1 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column1.setText(columnProperties[0]);
final TableColumn column2 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column2.setText(columnProperties[1]);
final TableColumn column3 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column3.setText(columnProperties[2]);
final TableColumn column4 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnWeightData(1, 150, true));
column4.setText(columnProperties[3]);
tableViewer.setColumnProperties(columnProperties);
Object layoutData = parent.getLayoutData();
if (layoutData instanceof GridData) {
GridData gridData = (GridData) layoutData;
gridData.grabExcessVerticalSpace = true;
gridData.verticalAlignment = SWT.FILL;
}
FormData formData = new FormData();
formData.left = new FormAttachment(0);
formData.top = new FormAttachment(0);
formData.right = new FormAttachment(100);
formData.bottom = new FormAttachment(100);
table.setLayoutData(formData);
tableViewer.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
IRepositoryViewObject repositoryObject = ((IRepositoryViewObject) inputElement);
if (repositoryObject.getProperty() == null) {
return null;
}
RepositoryNode parentRepositoryNode = RepositoryNodeUtilities.getParentRepositoryNodeFromSelection(repositoryObject);
try {
List<IRepositoryViewObject> allVersion = ProxyRepositoryFactory.getInstance().getAllVersion(repositoryObject.getId());
Collections.sort(allVersion, new IRepositoryObjectComparator());
Object[] objects = new Object[allVersion.size()];
for (int i = 0; i < objects.length; i++) {
IRepositoryViewObject repositoryObjectVersion = allVersion.get(i);
RepositoryNode repositoryNode = createRepositoryNode(parentRepositoryNode, repositoryObjectVersion);
objects[i] = repositoryNode;
}
return objects;
} catch (PersistenceException e) {
return null;
}
}
private RepositoryNode createRepositoryNode(RepositoryNode parentRepositoryNode, IRepositoryViewObject repositoryObjectVersion) {
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(repositoryObjectVersion.getProperty().getItem());
RepositoryNode repositoryNode = new RepositoryNode(repositoryObjectVersion, parentRepositoryNode, ENodeType.REPOSITORY_ELEMENT);
repositoryNode.setProperties(EProperties.CONTENT_TYPE, itemType);
repositoryNode.setProperties(EProperties.LABEL, repositoryObjectVersion.getLabel());
return repositoryNode;
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
tableViewer.setLabelProvider(new ITableLabelProvider() {
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
public String getColumnText(Object element, int columnIndex) {
RepositoryNode repositoryNode = (RepositoryNode) element;
switch(columnIndex) {
case 0:
return repositoryNode.getObject().getVersion();
case 1:
if (repositoryNode.getObject().getCreationDate() != null) {
return FORMATTER.format(repositoryNode.getObject().getCreationDate());
} else {
return null;
}
case 2:
if (repositoryNode.getObject().getModificationDate() != null) {
return FORMATTER.format(repositoryNode.getObject().getModificationDate());
} else {
return null;
}
case 3:
if (repositoryNode.getObject().getStatusCode() != null) {
return repositoryNode.getObject().getStatusCode();
} else {
return null;
}
default:
return null;
}
}
public void addListener(ILabelProviderListener listener) {
}
public void dispose() {
}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void removeListener(ILabelProviderListener listener) {
}
});
//$NON-NLS-1$
MenuManager menuMgr = new MenuManager("#PopUp");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager mgr) {
ISelection selection = tableViewer.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
for (ITreeContextualAction action : contextualsActions) {
if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
action.init(null, structuredSelection);
if (action.isVisible()) {
mgr.add(action);
}
}
}
}
}
});
Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
tableViewer.getControl().setMenu(menu);
Listener sortListener = new Listener() {
private int direction = 1;
public void handleEvent(Event e) {
final TableColumn column = (TableColumn) e.widget;
if (column == table.getSortColumn()) {
direction = -direction;
}
if (direction == 1) {
table.setSortDirection(SWT.DOWN);
} else {
table.setSortDirection(SWT.UP);
}
table.setSortColumn(column);
tableViewer.setSorter(new ViewerSorter() {
int index = 0;
@Override
public void sort(Viewer viewer, Object[] elements) {
while (index < table.getColumns().length && table.getColumn(index) != column) {
index++;
}
super.sort(viewer, elements);
}
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
ITableLabelProvider labelProvider = (ITableLabelProvider) tableViewer.getLabelProvider();
String columnText = labelProvider.getColumnText(e1, index) != null ? labelProvider.getColumnText(e1, index) : //$NON-NLS-1$
"";
String columnText2 = labelProvider.getColumnText(e2, index) != null ? labelProvider.getColumnText(e2, index) : //$NON-NLS-1$
"";
return getComparator().compare(columnText, columnText2) * direction;
}
});
}
};
column1.addListener(SWT.Selection, sortListener);
column2.addListener(SWT.Selection, sortListener);
column3.addListener(SWT.Selection, sortListener);
column4.addListener(SWT.Selection, sortListener);
table.setSortColumn(column1);
table.setSortDirection(SWT.DOWN);
aTabbedPropertySheetPage.getSite().setSelectionProvider(this);
}
use of org.eclipse.jface.viewers.ITableLabelProvider in project bndtools by bndtools.
the class BndContainerPage method createControl.
/*
* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets .Composite)
*/
@Override
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NULL);
composite.setLayout(new FormLayout());
composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
composite.setFont(parent.getFont());
setControl(composite);
final Button wCreate = new Button(composite, SWT.NONE);
wCreate.setEnabled(model == null);
final FormData fd_wCreate = new FormData();
fd_wCreate.bottom = new FormAttachment(100, -5);
fd_wCreate.right = new FormAttachment(100, -4);
wCreate.setLayoutData(fd_wCreate);
wCreate.setText("Create bnd.bnd");
final TableViewer tableViewer = new TableViewer(composite, SWT.BORDER);
table = tableViewer.getTable();
final FormData fd_table = new FormData();
fd_table.top = new FormAttachment(0, 3);
fd_table.left = new FormAttachment(0, 3);
fd_table.right = new FormAttachment(100, -4);
fd_table.bottom = new FormAttachment(100, -37);
table.setLayoutData(fd_table);
table.setLinesVisible(true);
table.setHeaderVisible(true);
final TableColumn wBsn = new TableColumn(table, SWT.NONE);
wBsn.setWidth(200);
wBsn.setText("Bundle Symbolic Name");
final TableColumn wVersion = new TableColumn(table, SWT.NONE);
wVersion.setWidth(100);
wVersion.setText("Version");
final TableColumn wOptions = new TableColumn(table, SWT.NONE);
wOptions.setWidth(200);
wOptions.setText("Options");
final TableColumn wFile = new TableColumn(table, SWT.NONE);
wFile.setWidth(100);
wFile.setText("File");
tableViewer.setContentProvider(new IStructuredContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
if (model != null)
try {
return model.getBuildpath().toArray();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return new Object[0];
}
@Override
public void dispose() {
// TODO Auto-generated method stub
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
tableViewer.setLabelProvider(new ITableLabelProvider() {
@Override
public Image getColumnImage(Object element, int columnIndex) {
// TODO Auto-generated method stub
return null;
}
@Override
public String getColumnText(Object element, int columnIndex) {
Container c = (Container) element;
switch(columnIndex) {
case 0:
return c.getBundleSymbolicName();
case 1:
return c.getVersion();
case 2:
return c.getError();
case 3:
return c.getFile() + " (" + (c.getFile() != null && c.getFile().exists() ? "exists" : "?") + ")";
default:
break;
}
return null;
}
@Override
public void addListener(ILabelProviderListener listener) {
// TODO Auto-generated method stub
}
@Override
public void dispose() {
// TODO Auto-generated method stub
}
@Override
public boolean isLabelProperty(Object element, String property) {
// TODO Auto-generated method stub
return false;
}
@Override
public void removeListener(ILabelProviderListener listener) {
// TODO Auto-generated method stub
}
});
tableViewer.setInput(model);
wCreate.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
System.out.println("defw selected");
}
@Override
public void widgetSelected(SelectionEvent e) {
wCreate.setEnabled(!createBnd());
tableViewer.setInput(model);
}
});
}
Aggregations