use of org.eclipse.jface.viewers.LabelProvider in project tdi-studio-se by Talend.
the class SaveChartSetAsDialog method createChartSetViewer.
/**
* Creates the chart set viewer.
*
* @param parent The parent composite
* @return The chart set viewer
*/
private TableViewer createChartSetViewer(Composite parent) {
TableViewer viewer = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION);
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.heightHint = 300;
viewer.getTable().setLayoutData(gridData);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new LabelProvider());
viewer.setInput(chartSets.toArray(new String[chartSets.size()]));
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
if (ignoreSelection) {
return;
}
ISelection selection = event.getSelection();
if (selection instanceof StructuredSelection) {
Object element = ((StructuredSelection) selection).getFirstElement();
if (element != null) {
chartSetText.setText(element.toString());
deleteButton.setEnabled(true);
}
}
}
});
return viewer;
}
use of org.eclipse.jface.viewers.LabelProvider in project tdi-studio-se by Talend.
the class SelectDeleteProjectDialog method createTreeViewer.
private void createTreeViewer(Composite parent) {
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 0;
layout.makeColumnsEqualWidth = false;
parent.setLayout(layout);
parent.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
GridData listData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
treeViewer = new ContainerCheckedTreeViewer(parent);
treeViewer.getControl().setLayoutData(listData);
// treeViewer.setContentProvider(getResourceProvider(IResource.FOLDER | IResource.PROJECT));
treeViewer.setContentProvider(getResourceProvider(IResource.PROJECT));
// treeViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
treeViewer.setLabelProvider(new LabelProvider() {
@Override
public final String getText(Object element) {
// query the element for its label
//$NON-NLS-1$
String label = "";
if (element instanceof IProject) {
IProject project = (IProject) element;
label = getLabel(project.getName());
} else if (element instanceof IFolder) {
IFolder folder = (IFolder) element;
label = getLabel(folder.getName());
}
return label;
}
private String getLabel(String name) {
List<Project> proItem = getProjectItem();
for (int i = 0; i < proItem.size(); i++) {
Project p = proItem.get(i);
String proName = p.getTechnicalLabel();
if (proName.equals(name)) {
return ProjectManager.getProjectDisplayLabel(p.getEmfProject());
}
}
return name;
}
@Override
public final Image getImage(Object element) {
if (element instanceof IProject) {
return ImageProvider.getImage(ERepositoryImages.PROJECT_ICON);
} else if (element instanceof IFolder) {
return ImageProvider.getImage(ERepositoryImages.FOLDER_ICON);
}
return null;
}
});
treeViewer.setInput(projectItemList);
treeViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
addTreeListener();
createButtons(parent);
}
use of org.eclipse.jface.viewers.LabelProvider in project tdi-studio-se by Talend.
the class ImportItemWizardPage method createTreeViewer.
private TreeViewer createTreeViewer(Composite listComposite) {
filteredCheckboxTree = new FilteredCheckboxTree(listComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
CheckboxTreeViewer viewer = filteredCheckboxTree.getViewer();
viewer.setContentProvider(new ITreeContentProvider() {
@Override
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof IContainerNode) {
return ((IContainerNode) parentElement).getChildren().toArray();
}
return null;
}
@Override
public Object[] getElements(Object inputElement) {
// return getValidItems();
return repositoryUtil.getTreeViewInput().toArray();
}
@Override
public boolean hasChildren(Object element) {
if (element instanceof IContainerNode) {
return ((IContainerNode) element).hasChildren();
}
return false;
}
@Override
public Object getParent(Object element) {
return null;
}
@Override
public void dispose() {
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
viewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof IContainerNode) {
if (element instanceof ProjectNode) {
Project project = ((ProjectNode) element).getProject();
return ProjectManager.getProjectDisplayLabel(project);
}
return ((IContainerNode) element).getLabel();
} else if (element instanceof ItemRecord) {
return ((ItemRecord) element).getLabel();
}
return super.getText(element);
}
@Override
public Image getImage(Object element) {
if (element instanceof IContainerNode) {
return ((IContainerNode) element).getImage();
} else if (element instanceof ItemRecord) {
return ((ItemRecord) element).getImage();
}
return super.getImage(element);
}
});
viewer.setSorter(TreeBuilder.createSorter());
viewer.setInput(this);
viewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
filteredCheckboxTree.calculateCheckedLeafNodes();
updateFinishStatus();
}
});
filteredCheckboxTree.getViewer().addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return selectRepositoryNode(viewer, element);
}
});
return viewer;
}
use of org.eclipse.jface.viewers.LabelProvider in project bndtools by bndtools.
the class RunFrameworkPart method createSection.
final void createSection(Section section, FormToolkit tk) {
section.setText("Core Runtime");
Composite composite = tk.createComposite(section);
section.setClient(composite);
Label lblFramework = new Label(composite, SWT.NONE);
tk.adapt(lblFramework, true, true);
lblFramework.setText("OSGi Framework:");
cmbFramework = new Combo(composite, SWT.DROP_DOWN);
tk.adapt(cmbFramework);
tk.paintBordersFor(cmbFramework);
cmbFramework.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
frameworkViewer = new ComboViewer(cmbFramework);
frameworkViewer.setUseHashlookup(true);
frameworkViewer.setContentProvider(fwkContentProvider);
Label lblExecEnv = tk.createLabel(composite, "Execution Env.:");
cmbExecEnv = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
ControlDecoration eeDecor = new ControlDecoration(cmbExecEnv, SWT.LEFT | SWT.TOP, composite);
eeDecor.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
eeDecor.setDescriptionText("The runtime Java Virtual Machine will be required/assumed " + "\nto support this Execution Environment");
eeViewer = new ComboViewer(cmbExecEnv);
eeViewer.setContentProvider(ArrayContentProvider.getInstance());
eeViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((EE) element).getEEName();
}
});
eeViewer.setInput(EE.values());
// Listeners
cmbFramework.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
lock.ifNotModifying(new Runnable() {
@Override
public void run() {
markDirty();
selectedFramework = cmbFramework.getText();
}
});
}
});
frameworkViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
lock.ifNotModifying(new Runnable() {
@Override
public void run() {
Object element = ((IStructuredSelection) frameworkViewer.getSelection()).getFirstElement();
if (element instanceof LoadingContentElement) {
return;
}
markDirty();
if (element == null)
selectedFramework = null;
else
selectedFramework = element.toString();
}
});
}
});
eeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
lock.ifNotModifying(new Runnable() {
@Override
public void run() {
markDirty();
selectedEE = (EE) ((IStructuredSelection) event.getSelection()).getFirstElement();
}
});
}
});
GridLayout layout = new GridLayout(2, false);
layout.horizontalSpacing = 10;
composite.setLayout(layout);
lblFramework.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
GridData gd;
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
gd.widthHint = 20;
gd.heightHint = 20;
cmbFramework.setLayoutData(gd);
lblExecEnv.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
gd.widthHint = 20;
gd.heightHint = 20;
cmbExecEnv.setLayoutData(gd);
}
use of org.eclipse.jface.viewers.LabelProvider in project bndtools by bndtools.
the class NewDSComponentWizardPage method createLifecycleMethodStubControls.
protected void createLifecycleMethodStubControls(Composite composite, int nColumns) {
fLifecycleMethodDialogField.doFillIntoGrid(composite, nColumns - 1);
DialogField.createEmptySpace(composite);
Combo cmbActivateStub = fLifecycleMethodDialogField.getComboControl(composite);
vwrActivateStub = new ComboViewer(cmbActivateStub);
vwrActivateStub.setContentProvider(ArrayContentProvider.getInstance());
vwrActivateStub.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((ActivateSignature) element).label;
}
});
vwrActivateStub.setInput(EnumSet.allOf(ActivateSignature.class));
vwrActivateStub.setSelection(new StructuredSelection(activateSignature), true);
vwrActivateStub.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
ISelection sel = event.getSelection();
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
activateSignature = (ActivateSignature) ((IStructuredSelection) sel).getFirstElement();
} else {
activateSignature = ActivateSignature.NoActivate;
}
activateSignatureStatus = activateSignatureChanged();
handleFieldChanged("activateSignature");
}
});
}
Aggregations