use of org.eclipse.jface.viewers.ITreeContentProvider in project liferay-ide by liferay.
the class SDKProjectConvertWizardPage method createProjectsList.
protected void createProjectsList(Composite workArea) {
Label title = new Label(workArea, SWT.NONE);
title.setText(Msgs.importProjectLabel);
title.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
// Composite listComposite = new Composite(workArea, SWT.NONE);
// GridLayout layout = new GridLayout();
// layout.numColumns = 2;
// layout.marginWidth = 0;
// layout.makeColumnsEqualWidth = false;
// listComposite.setLayout(layout);
// GridData gd = new GridData(GridData.GRAB_HORIZONTAL
// | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
// gd.grabExcessHorizontalSpace = true;
// gd.horizontalSpan = 3;
// listComposite.setLayoutData(gd);
projectsList = new CheckboxTreeViewer(workArea, SWT.BORDER);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);
gridData.widthHint = new PixelConverter(projectsList.getControl()).convertWidthInCharsToPixels(25);
gridData.heightHint = new PixelConverter(projectsList.getControl()).convertHeightInCharsToPixels(10);
projectsList.getControl().setLayoutData(gridData);
projectsList.setContentProvider(new ITreeContentProvider() {
public void dispose() {
}
public Object[] getChildren(Object parentElement) {
return null;
}
public Object[] getElements(Object inputElement) {
return (Object[]) getDataModel().getProperty(SELECTED_PROJECTS);
}
public Object getParent(Object element) {
return null;
}
public boolean hasChildren(Object element) {
return false;
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
projectsList.setLabelProvider(new ProjectLabelProvider());
projectsList.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
ProjectRecord element = (ProjectRecord) event.getElement();
if (element.hasConflicts()) {
projectsList.setChecked(element, false);
}
getDataModel().setProperty(SELECTED_PROJECTS, projectsList.getCheckedElements());
setPageComplete(ListUtil.isNotEmpty(projectsList.getCheckedElements()));
}
});
projectsList.setInput(this);
projectsList.setComparator(new ViewerComparator());
}
use of org.eclipse.jface.viewers.ITreeContentProvider in project liferay-ide by liferay.
the class SDKProjectsImportWizardPage method createProjectsList.
protected void createProjectsList(Composite workArea) {
labelProjectsList = new Label(workArea, SWT.NONE);
labelProjectsList.setText(Msgs.importProjectsLabel);
labelProjectsList.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
projectsList = new CheckboxTreeViewer(workArea, SWT.BORDER);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
gridData.widthHint = new PixelConverter(projectsList.getControl()).convertWidthInCharsToPixels(25);
gridData.heightHint = new PixelConverter(projectsList.getControl()).convertHeightInCharsToPixels(10);
projectsList.getControl().setLayoutData(gridData);
projectsList.setContentProvider(new ITreeContentProvider() {
public void dispose() {
}
public Object[] getChildren(Object parentElement) {
return null;
}
public Object[] getElements(Object inputElement) {
return getProjectRecords();
}
public Object getParent(Object element) {
return null;
}
public boolean hasChildren(Object element) {
return false;
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
projectsList.setLabelProvider(createProjectsListLabelProvider());
projectsList.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
handleCheckStateChangedEvent(event);
}
});
projectsList.setInput(this);
projectsList.setComparator(new ViewerComparator());
createSelectionButtons(workArea);
}
use of org.eclipse.jface.viewers.ITreeContentProvider in project liferay-ide by liferay.
the class LiferayDataModelWizardPage method handleFileBrowseButton.
protected void handleFileBrowseButton(final Text text, String title, String message) {
ISelectionStatusValidator validator = getContainerDialogSelectionValidator();
ViewerFilter filter = getContainerDialogViewerFilter();
ITreeContentProvider contentProvider = new WorkbenchContentProvider();
IDecoratorManager decoratorManager = PlatformUI.getWorkbench().getDecoratorManager();
ILabelProvider labelProvider = new DecoratingLabelProvider(new WorkbenchLabelProvider(), decoratorManager.getLabelDecorator());
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), labelProvider, contentProvider);
dialog.setValidator(validator);
dialog.setTitle(title);
dialog.setMessage(message);
dialog.addFilter(filter);
final IWebProject lrproject = LiferayCore.create(IWebProject.class, CoreUtil.getProject(getDataModel().getStringProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME)));
if (lrproject != null) {
final IFolder defaultDocroot = lrproject.getDefaultDocrootFolder();
if (defaultDocroot != null) {
dialog.setInput(defaultDocroot);
if (dialog.open() == Window.OK) {
Object element = dialog.getFirstResult();
try {
if (element instanceof IFile) {
IFile file = (IFile) element;
final IPath relativePath = file.getFullPath().makeRelativeTo(defaultDocroot.getFullPath());
text.setText("/" + relativePath.toPortableString());
// dealWithSelectedContainerResource(container);
}
} catch (Exception ex) {
// Do nothing
}
}
}
}
}
use of org.eclipse.jface.viewers.ITreeContentProvider in project arduino-eclipse-plugin by Sloeber.
the class PlatformSelectionPage method createContents.
@Override
protected Control createContents(Composite parent) {
Composite control = new Composite(parent, SWT.NONE);
control.setLayout(new GridLayout());
Button btnCheckButton = new Button(control, SWT.CHECK);
// $NON-NLS-1$
btnCheckButton.setText("Hide 3th party json files");
btnCheckButton.setSelection(this.myHideJson);
btnCheckButton.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
PlatformSelectionPage.this.myHideJson = btnCheckButton.getSelection();
MyPreferences.setHideJson(PlatformSelectionPage.this.myHideJson);
PlatformSelectionPage.this.viewer.setInput(EMPTY_STRING);
}
});
Text desc = new Text(control, SWT.READ_ONLY);
desc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
desc.setBackground(parent.getBackground());
desc.setText(Messages.platformSelectionTip);
PatternFilter filter = new PatternFilter() {
@Override
protected boolean isLeafMatch(final Viewer viewer1, final Object element) {
boolean isMatch = false;
if (element instanceof InstallableVersion) {
InstallableVersion ver = (InstallableVersion) element;
isMatch |= wordMatches(ver.getVersion().toString());
isMatch |= myWordMatches(ver.getPlatform());
}
if (element instanceof IndexFile) {
IndexFile indexFile = (IndexFile) element;
isMatch |= myWordMatches(indexFile);
}
if (element instanceof Package) {
Package pac = (Package) element;
isMatch |= myWordMatches(pac);
}
if (element instanceof Platform) {
Platform platform = (Platform) element;
isMatch |= myWordMatches(platform);
}
return isMatch;
}
private boolean myWordMatches(Platform platform) {
boolean ret = wordMatches(platform.getName());
ret |= wordMatches(platform.getArchitecture());
ret |= wordMatches(platform.getBoards());
ret |= myWordMatches(platform.getPackage());
return ret;
}
private boolean myWordMatches(Package pac) {
boolean ret = wordMatches(pac.getEmail());
ret |= wordMatches(pac.getMaintainer());
ret |= wordMatches(pac.getName());
ret |= wordMatches(pac.getWebsiteURL().toString());
ret |= wordMatches(pac.getIndexFile().toString());
return ret;
}
private boolean myWordMatches(IndexFile indexFile) {
return wordMatches(indexFile.getFullName());
}
};
this.myGuiplatformTree = new FilteredTree(control, SWT.CHECK | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION, filter, true) {
@Override
protected TreeViewer doCreateTreeViewer(Composite composite, int style) {
CheckboxTreeViewer viewer1 = new CheckboxTreeViewer(composite);
viewer1.setCheckStateProvider(new ICheckStateProvider() {
@Override
public boolean isChecked(Object element) {
if (element instanceof InstallableVersion) {
return ((InstallableVersion) element).isInstalled();
}
if (element instanceof IndexFile) {
return ((IndexFile) element).isInstalled();
}
if (element instanceof Package) {
return ((Package) element).isInstalled();
}
if (element instanceof Platform) {
return ((Platform) element).isInstalled();
}
return false;
}
@Override
public boolean isGrayed(Object element) {
if (element instanceof InstallableVersion) {
return false;
}
if (element instanceof IndexFile) {
return ((IndexFile) element).isInstalled();
}
if (element instanceof Package) {
return ((Package) element).isInstalled();
}
if (element instanceof Platform) {
return ((Platform) element).isInstalled();
}
return false;
}
});
viewer1.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
Object element = event.getElement();
if (element instanceof InstallableVersion) {
InstallableVersion cur = (InstallableVersion) element;
cur.setInstalled(event.getChecked());
}
PlatformSelectionPage.this.viewer.refresh();
}
});
viewer1.setContentProvider(new ITreeContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
if (PlatformSelectionPage.this.myHideJson) {
Set<Package> packages = PlatformSelectionPage.this.myPlatformTree.getAllPackages();
return packages.toArray(new Object[packages.size()]);
}
Collection<IndexFile> indexFiles = PlatformSelectionPage.this.myPlatformTree.getAllIndexFiles();
return indexFiles.toArray(new Object[indexFiles.size()]);
}
@Override
public void dispose() {
// nothing to do
}
@Override
public void inputChanged(Viewer viewer11, Object oldInput, Object newInput) {
// nothing to do
}
@Override
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof IndexFile) {
Collection<Package> packages = ((IndexFile) parentElement).getAllPackages();
return packages.toArray(new Object[packages.size()]);
}
if (parentElement instanceof Package) {
Collection<Platform> platforms = ((Package) parentElement).getPlatforms();
return platforms.toArray(new Object[platforms.size()]);
}
if (parentElement instanceof Platform) {
Collection<InstallableVersion> versions = ((Platform) parentElement).getVersions();
return versions.toArray(new Object[versions.size()]);
}
return null;
}
@Override
public Object getParent(Object element) {
return null;
}
@Override
public boolean hasChildren(Object element) {
return !(element instanceof InstallableVersion);
}
});
viewer1.setLabelProvider(new CellLabelProvider() {
@Override
public String getToolTipText(Object element) {
if (element instanceof IndexFile) {
return ((IndexFile) element).getFullName();
}
if (element instanceof Package) {
Package pkg = (Package) element;
return // $NON-NLS-1$
Messages.packageTooltip.replaceAll("\\$\\{MAINTAINER}", pkg.getMaintainer()).replaceAll("\\$\\{EMAIL}", // $NON-NLS-1$
pkg.getEmail()).replaceAll("\\$\\{URL}", // $NON-NLS-1$
pkg.getWebsiteURL().toString());
}
if (element instanceof Platform) {
return ((Platform) element).getBoards();
}
if (element instanceof InstallableVersion) {
return null;
}
return null;
}
@Override
public org.eclipse.swt.graphics.Point getToolTipShift(Object object) {
return new org.eclipse.swt.graphics.Point(5, 5);
}
@Override
public int getToolTipDisplayDelayTime(Object object) {
return 1000;
}
@Override
public int getToolTipTimeDisplayed(Object object) {
return 5000;
}
@Override
public void update(ViewerCell cell) {
if (cell.getElement() instanceof IndexFile) {
cell.setText(((IndexFile) cell.getElement()).getNiceName());
}
if (cell.getElement() instanceof Package) {
cell.setText(((Package) cell.getElement()).getName());
}
if (cell.getElement() instanceof Platform) {
cell.setText(((Platform) cell.getElement()).getName());
}
if (cell.getElement() instanceof InstallableVersion) {
cell.setText(((InstallableVersion) cell.getElement()).getVersion().toString());
}
}
});
return viewer1;
}
};
this.viewer = this.myGuiplatformTree.getViewer();
ColumnViewerToolTipSupport.enableFor(this.viewer);
this.myGuiplatformTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
this.viewer.setInput(EMPTY_STRING);
return control;
}
use of org.eclipse.jface.viewers.ITreeContentProvider in project jbosstools-openshift by jbosstools.
the class ChooseServerDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite container = (Composite) super.createDialogArea(parent);
final TreeViewer tv = new TreeViewer(container);
tv.setContentProvider(new ITreeContentProvider() {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
@Override
public void dispose() {
}
@Override
public boolean hasChildren(Object element) {
return false;
}
@Override
public Object getParent(Object element) {
return null;
}
@Override
public Object[] getElements(Object inputElement) {
return (IServer[]) valid.toArray(new IServer[valid.size()]);
}
@Override
public Object[] getChildren(Object parentElement) {
return null;
}
});
tv.setLabelProvider(new LabelProvider() {
@Override
public Image getImage(Object element) {
if (element instanceof IServer)
return ImageResource.getImage(((IServer) element).getServerType().getId());
return super.getImage(element);
}
@Override
public String getText(Object element) {
if (element instanceof IServer)
return ((IServer) element).getName();
return super.getText(element);
}
});
tv.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
selected = null;
ISelection sel = tv.getSelection();
if (sel instanceof IStructuredSelection) {
Object first = ((IStructuredSelection) sel).getFirstElement();
if (first instanceof IServer) {
selected = (IServer) first;
}
}
getButton(IDialogConstants.OK_ID).setEnabled(selected != null);
}
});
tv.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
tv.setInput(PlatformUI.getWorkbench());
return container;
}
Aggregations