本文整理汇总了Java中org.eclipse.ui.model.BaseWorkbenchContentProvider类的典型用法代码示例。如果您正苦于以下问题:Java BaseWorkbenchContentProvider类的具体用法?Java BaseWorkbenchContentProvider怎么用?Java BaseWorkbenchContentProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BaseWorkbenchContentProvider类属于org.eclipse.ui.model包,在下文中一共展示了BaseWorkbenchContentProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTreeViewer
import org.eclipse.ui.model.BaseWorkbenchContentProvider; //导入依赖的package包/类
@Override
protected CheckboxTreeViewer createTreeViewer(Composite parent) {
int style = SWT.VIRTUAL | SWT.FULL_SELECTION | SWT.BORDER
| SWT.H_SCROLL | SWT.V_SCROLL;
CheckboxTreeViewer result = new CheckboxTreeViewer(parent, style);
result.setLabelProvider(new WorkbenchLabelProvider());
result.setContentProvider(new BaseWorkbenchContentProvider());
result.setComparator(new NodeWrapperTreeSorter());
result.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
if (recursiveTreeSelect) {
tree.setSubtreeChecked(event.getElement(), event.getChecked());
}
}
});
tree = result;
return result;
}
示例2: getContentProvider
import org.eclipse.ui.model.BaseWorkbenchContentProvider; //导入依赖的package包/类
/**
* getContentProvider
*
* @return
*/
private IStructuredContentProvider getContentProvider()
{
return new BaseWorkbenchContentProvider()
{
/*
* (non-Javadoc)
* @see org.eclipse.ui.model.BaseWorkbenchContentProvider#getChildren(java.lang.Object)
*/
@Override
public Object[] getChildren(Object element)
{
if (element instanceof Set<?>)
{
return ((Set<?>) element).toArray();
}
return super.getChildren(element);
}
};
}
示例3: selectInProject
import org.eclipse.ui.model.BaseWorkbenchContentProvider; //导入依赖的package包/类
private void selectInProject() {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());
dialog.setTitle("Select a file in the project:");
dialog.setMessage("Select a file in the project:");
// Filter to the project
dialog.addFilter(new ViewerFilter() {
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IProject) {
return ((IProject) element).getName().equals(project.getName());
}
// we want a folder
return defaultExtension != null || element instanceof IContainer;
}
});
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
// TODO try to preselect the current file
dialog.open();
Object[] results = dialog.getResult();
if ((results != null) && (results.length > 0) && (results[0] instanceof IResource)) {
IPath path = ((IResource) results[0]).getFullPath();
setProjectLoc(path.removeFirstSegments(1).makeRelative().toString());
}
}
示例4: showSaveDirtyFileDialog
import org.eclipse.ui.model.BaseWorkbenchContentProvider; //导入依赖的package包/类
private static boolean showSaveDirtyFileDialog(
List<IEditorPart> dirtyEditors )
{
AdaptableList input = new AdaptableList( dirtyEditors );
ListDialog dlg = new ListDialog( PlatformUI.getWorkbench( )
.getActiveWorkbenchWindow( )
.getShell( ) );
dlg.setContentProvider( new BaseWorkbenchContentProvider( ) );
dlg.setLabelProvider( new WorkbenchPartLabelProvider( ) );
dlg.setInput( input );
dlg.setMessage( Messages.getString( "renameChecker.saveResourcesMessage" ) ); //$NON-NLS-1$
dlg.setTitle( Messages.getString( "renameChecker.saveResourcesTitle" ) ); //$NON-NLS-1$
// Just return false to prevent the operation continuing
return dlg.open( ) == IDialogConstants.OK_ID;
}
示例5: selectFolderInProject
import org.eclipse.ui.model.BaseWorkbenchContentProvider; //导入依赖的package包/类
private IFolder selectFolderInProject() {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getControl().getShell(),
new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());
dialog.setTitle("Select View Root");
dialog.setMessage("select the view root:");
dialog.setInput(getProject());
dialog.addFilter(new ViewerFilter() {
public boolean select(Viewer viewer, Object parentElement, Object element) {
return element instanceof IFolder && ((IFolder) element).isAccessible();
}
});
if (Window.OK == dialog.open()) {
Object[] result = dialog.getResult();
if (result.length > 0) {
return (IFolder) result[0];
}
}
return null;
}
示例6: addAddBtn
import org.eclipse.ui.model.BaseWorkbenchContentProvider; //导入依赖的package包/类
protected void addAddBtn(final Composite btnComposite) {
Button add = new Button(btnComposite, SWT.FLAT);
GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).applyTo(add);
add.setText("Add...");
add.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(btnComposite.getShell(),
new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());
dialog.setValidator(new CheaderBlacklistSelectionStatusValidator());
dialog.setTitle("Add blacklist item");
dialog.setMessage("Select a blacklist item:");
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
dialog.addFilter(new CHeaderViewerFilter(getActualProject()));
if (!values.isEmpty())
dialog.setInitialSelection(values.get(values.size() - 1));
dialog.setDialogBoundsSettings(BuilderActivator.getDefault().getDialogSettings(),
Dialog.DIALOG_PERSISTLOCATION);
dialog.open();
Object[] result = dialog.getResult();
if (result != null) {
for (Object selection : result) {
if (selection instanceof IResource) {
values.add((IResource) selection);
}
}
blackListViewer.refresh();
}
}
});
}
示例7: modelPropertyChange
import org.eclipse.ui.model.BaseWorkbenchContentProvider; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void modelPropertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(
ControllerProperties.PROJECTLIST_PROPERTY.getProperty())) {
root = new ProjectRoot((ArrayList<IProject>) evt.getNewValue());
deltaController.getChanges(selectedfilePatch);
} else if (evt.getPropertyName().equals(
ControllerProperties.UNIFIEDDIFF_PROPERTY.getProperty())) {
ProjectSelectionDialog dlg = new ProjectSelectionDialog(viewer
.getControl().getShell(), root,
new BaseWorkbenchContentProvider(),
new WorkbenchLabelProvider(),
"Select the project to be synchronized:",
(String) evt.getNewValue());
dlg.setTitle("Project Selection");
dlg.open();
Object[] result = dlg.getResult();
if (result != null && result.length > 0) {
synchronizationController
.synchronize(result, selectedfilePatch);
}
} else if (evt.getPropertyName().equals(
ControllerProperties.REFRESHTREE_PROPERTY.getProperty())) {
refreshTree();
}
}
示例8: createTreeViewer
import org.eclipse.ui.model.BaseWorkbenchContentProvider; //导入依赖的package包/类
/**
* Can be overridden to provide a customized tree viewer.
* For example, the derived type {@link CheckNodeTreeView}
* uses a {@code CheckboxTreeViewer}.
*/
protected TreeViewer createTreeViewer(Composite parent) {
int style = SWT.VIRTUAL | SWT.FULL_SELECTION | SWT.BORDER
| SWT.H_SCROLL | SWT.V_SCROLL;
TreeViewer result = new TreeViewer(parent, style);
result.setLabelProvider(new WorkbenchLabelProvider());
result.setContentProvider(new BaseWorkbenchContentProvider());
result.setComparator(SORTER);
setupHierarchyMenu(result);
return result;
}
示例9: getContentProvider
import org.eclipse.ui.model.BaseWorkbenchContentProvider; //导入依赖的package包/类
/**
* Returns a content provider for the list dialog. The content provider will include all available natures as
* strings.
*
* @return the content provider that shows the natures (as string children)
*/
private IStructuredContentProvider getContentProvider()
{
return new BaseWorkbenchContentProvider()
{
@Override
public Object[] getChildren(Object o)
{
if (!(o instanceof IWorkspace))
{
return new Object[0];
}
Set<String> elements = new HashSet<String>();
// collect all available natures in the workspace
IProjectNatureDescriptor[] natureDescriptors = ((IWorkspace) o).getNatureDescriptors();
String natureId;
for (IProjectNatureDescriptor descriptor : natureDescriptors)
{
natureId = descriptor.getNatureId();
if (natureId != null)
{
if (ResourceUtil.isAptanaNature(natureId))
{
elements.add(natureId);
fNatureDescriptions.put(natureId, descriptor.getLabel());
}
}
}
return elements.toArray();
}
};
}
示例10: createFileDialog
import org.eclipse.ui.model.BaseWorkbenchContentProvider; //导入依赖的package包/类
private ResourceFileSelectionDialog createFileDialog(String title, Object selection) {
ResourceFileSelectionDialog diag = new ResourceFileSelectionDialog(getShell(),
new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());
configureDialog(diag, title, "Select Folder", selection);
return diag;
}
示例11: createFolderDialog
import org.eclipse.ui.model.BaseWorkbenchContentProvider; //导入依赖的package包/类
private ElementTreeSelectionDialog createFolderDialog(String title, Object selection) {
ElementTreeSelectionDialog diag = new ElementTreeSelectionDialog(getShell(),
new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());
diag.addFilter(new TypedViewerFilter(new Class[]{IFolder.class}));
configureDialog(diag, title, "Select Folder", selection);
return diag;
}
示例12: selectInWorkspace
import org.eclipse.ui.model.BaseWorkbenchContentProvider; //导入依赖的package包/类
private void selectInWorkspace() {
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());
dialog.setTitle("Select a file in the workspace:");
dialog.setMessage("Select a file in the workspace:");
// Filter closed projects
dialog.addFilter(new ViewerFilter() {
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IProject) {
return ((IProject) element).isAccessible();
}
// we want a folder
return defaultExtension != null || element instanceof IContainer;
}
});
dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
// TODO try to preselect the current file
dialog.open();
Object[] results = dialog.getResult();
if (results != null && results.length > 0 && results[0] instanceof IResource) {
IPath path = ((IResource) results[0]).getFullPath();
if (project != null && path.segment(0).equals(project.getProject().getName())) {
setProjectLoc(path.removeFirstSegments(1).makeRelative().toString());
} else {
String containerName = path.makeRelative().toString();
setWorkspaceLoc("${workspace_loc:" + containerName + "}");
}
}
}
示例13: getOperatorTypeCreationDialog
import org.eclipse.ui.model.BaseWorkbenchContentProvider; //导入依赖的package包/类
public static MIDTreeSelectionDialog getOperatorTypeCreationDialog(MID typeMID) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
MIDTreeSelectionDialog dialog = new MIDTreeSelectionDialog(
shell,
new WorkbenchLabelProvider(),
new BaseWorkbenchContentProvider(),
ResourcesPlugin.getWorkspace().getRoot()
);
dialog.addFilter(new NewOperatorTypeDialogFilter());
dialog.setValidator(new NewOperatorTypeDialogSelectionValidator());
return dialog;
}
示例14: getModelImportDialog
import org.eclipse.ui.model.BaseWorkbenchContentProvider; //导入依赖的package包/类
/**
* Gets a tree dialog that shows all model files in the workspace, in order
* to import an existing model.
*
* @return The tree dialog to import an existing model.
*/
public static MIDTreeSelectionDialog getModelImportDialog() {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
MIDTreeSelectionDialog dialog = new MIDTreeSelectionDialog(
shell,
new WorkbenchLabelProvider(),
new BaseWorkbenchContentProvider(),
ResourcesPlugin.getWorkspace().getRoot()
);
dialog.addFilter(new ImportModelDialogFilter());
dialog.setValidator(new ImportModelDialogSelectionValidator());
return dialog;
}
示例15: openFolderDialog
import org.eclipse.ui.model.BaseWorkbenchContentProvider; //导入依赖的package包/类
private PathListElement[] openFolderDialog(PathListElement existing) {
Class[] acceptedClasses = new Class[] { IProject.class, IFolder.class };
List existingContainers = getExistingContainers(null);
IProject[] allProjects = workspaceRoot.getProjects();
ArrayList rejectedElements = new ArrayList(allProjects.length);
IProject currProject = project;
for (int i = 0; i < allProjects.length; i++) {
if (!allProjects[i].equals(currProject)) {
rejectedElements.add(allProjects[i]);
}
}
ViewerFilter filter = new TypedViewerFilter(acceptedClasses, rejectedElements
.toArray());
ILabelProvider lp = new WorkbenchLabelProvider();
ITreeContentProvider cp = new BaseWorkbenchContentProvider();
String title = "Folder Selection";
String message = "&Choose folders to be added to the synchronization mapping:";
MultipleFolderSelectionDialog dialog = new MultipleFolderSelectionDialog(
getShell(), lp, cp);
dialog.setExisting(existingContainers.toArray());
dialog.setTitle(title);
dialog.setMessage(message);
dialog.addFilter(filter);
dialog.setInput(project.getParent());
if (existing == null) {
dialog.setInitialFocus(project);
} else {
dialog.setInitialFocus(existing.getResource());
}
if (dialog.open() == Window.OK) {
Object[] elements = dialog.getResult();
PathListElement[] res = new PathListElement[elements.length];
for (int i = 0; i < res.length; i++) {
IResource elem = (IResource) elements[i];
res[i] = newFolderElement(elem);
}
return res;
}
return null;
}