use of org.eclipse.jface.viewers.IContentProvider in project webtools.sourceediting by eclipse.
the class InternalXSDMultiPageEditor method editorModeChanged.
public void editorModeChanged(EditorMode newEditorMode) {
// if (isInitializing)
// return;
EditPartFactory editPartFactory = newEditorMode.getEditPartFactory();
if (editPartFactory != null) {
graphicalViewer.setEditPartFactory(editPartFactory);
if (graphicalViewer instanceof DesignViewGraphicalViewer) {
DesignViewGraphicalViewer viewer = (DesignViewGraphicalViewer) graphicalViewer;
IADTObject input = viewer.getInput();
viewer.setInput(null);
// viewer.getRootEditPart().refresh();
// viewer.getRootEditPart().getContents().refresh();
viewer.setInput(input);
floatingToolbar.setEditPartFactory(editPartFactory);
floatingToolbar.setModel(getModel());
floatingToolbar.refresh(!(input instanceof IModel));
Control control = graphicalViewer.getControl();
if (control instanceof Composite) {
Composite parent = ((Composite) control).getParent();
parent.layout();
}
}
}
IContentProvider provider = newEditorMode.getOutlineProvider();
if (provider != null) {
ADTContentOutlinePage outline = (ADTContentOutlinePage) getContentOutlinePage();
if (outline != null) {
TreeViewer treeViewer = outline.getTreeViewer();
if (treeViewer != null) {
outline.getTreeViewer().setContentProvider(provider);
outline.getTreeViewer().refresh();
}
}
}
}
use of org.eclipse.jface.viewers.IContentProvider in project tdi-studio-se by Talend.
the class ExportItemWizardPage method collectNodes.
private void collectNodes(Map<String, Item> items, Object[] objects) {
for (Object object : objects) {
if (object instanceof RepositoryNode) {
RepositoryNode repositoryNode = (RepositoryNode) object;
IRepositoryViewObject repositoryObject = repositoryNode.getObject();
if (repositoryObject != null) {
if (repositoryObject.getRepositoryObjectType().isResourceItem()) {
Item item = repositoryObject.getProperty().getItem();
items.put(item.getProperty().getId(), item);
}
} else {
if (repositoryNode.getParent() != null && repositoryNode.getParent().getObject() != null) {
Item item = repositoryNode.getParent().getObject().getProperty().getItem();
items.put(item.getProperty().getId(), item);
}
}
if (filteredCheckboxTree != null && !isHadoopClusterNode(repositoryNode)) {
IContentProvider contentProvider = filteredCheckboxTree.getViewer().getContentProvider();
if (contentProvider instanceof ITreeContentProvider) {
// only check childrens of allowed items in this viewer
if (selectRepositoryNode(getItemsTreeViewer(), repositoryNode)) {
Object[] children = ((ITreeContentProvider) contentProvider).getChildren(repositoryNode);
List<Object> childrenNodes = getUnTestCaseChildren(children);
collectNodes(items, childrenNodes.toArray());
}
}
}
} else {
for (IExtendedRepositoryNodeHandler nodeHandler : RepositoryContentManager.getExtendedNodeHandler()) {
Property property = nodeHandler.getProperty(object);
if (property != null) {
items.put(property.getId(), property.getItem());
}
}
}
}
}
use of org.eclipse.jface.viewers.IContentProvider in project tdi-studio-se by Talend.
the class StatusManagerSettingPage method processItems.
private void processItems(List<RepositoryObject> objects, IRepositoryNode node) {
if (node == null) {
return;
}
// if the root node of type is not init, force init.
IProjectRepositoryNode root = node.getRoot();
if (root instanceof ProjectRepositoryNode) {
((ProjectRepositoryNode) root).initNode(node);
}
if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
if (node.getObject() != null) {
Property property = node.getObject().getProperty();
Item item = property.getItem();
if (item != null && filterRepositoryNode((RepositoryNode) node)) {
// must be item
RepositoryObject object = new RepositoryObject(node.getObject().getProperty());
object.setRepositoryNode(node);
// ItemVersionObject object = new ItemVersionObject(node, property.getVersion());
objects.add(object);
}
}
} else {
IContentProvider contentProvider = treeViewer.getContentProvider();
if (contentProvider instanceof NavigatorContentServiceContentProvider) {
NavigatorContentServiceContentProvider navigatorProvider = (NavigatorContentServiceContentProvider) contentProvider;
Object[] children = navigatorProvider.getChildren(node);
for (Object child : children) {
if (child instanceof RepositoryNode) {
processItems(objects, (RepositoryNode) child);
}
}
} else {
for (IRepositoryNode child : node.getChildren()) {
processItems(objects, child);
}
}
}
}
use of org.eclipse.jface.viewers.IContentProvider in project hale by halestudio.
the class PageFunctions method createContents.
/**
* @see org.eclipse.jface.dialogs.DialogTray#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(comp);
Label label = new Label(comp, SWT.NONE);
label.setText("Functions Overview");
label.setFont(JFaceResources.getHeaderFont());
// tree viwever
PatternFilter patternFilter = new TreePathPatternFilter();
patternFilter.setIncludeLeadingWildcard(true);
final FilteredTree filteredTree = new TreePathFilteredTree(comp, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, patternFilter, true);
TreeViewer tree = filteredTree.getViewer();
tree.setUseHashlookup(true);
HelperFunctionLabelProvider labelProvider = new HelperFunctionLabelProvider();
tree.setLabelProvider(labelProvider);
IContentProvider contentProvider;
HelperFunctionsService functions = HaleUI.getServiceProvider().getService(HelperFunctionsService.class);
contentProvider = new TreePathProviderAdapter(new HelperFunctionContentProvider(functions));
tree.setContentProvider(contentProvider);
GridDataFactory.fillDefaults().grab(true, true).hint(280, 400).applyTo(filteredTree);
tree.setComparator(new HelperFunctionComparator());
tree.setInput(Category.ROOT);
// Examples
Label example = new Label(comp, SWT.NONE);
example.setText("Function documentation");
try {
browser = new Browser(comp, SWT.WRAP | SWT.BORDER);
browser.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(300, 250).create());
} catch (Throwable e) {
if (BROWSER_ERROR_REPORTED.compareAndSet(false, true)) {
log.error("Could not create embedded browser, using text field as fall-back", e);
}
textField = new Text(comp, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
textField.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(300, 250).create());
}
tree.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
String eg = null;
HelperFunctionSpecification hfs = null;
if (!event.getSelection().isEmpty()) {
TreeSelection treesel = (TreeSelection) event.getSelection();
TreePath[] paths = treesel.getPaths();
if (paths != null) {
TreePath path = paths[0];
for (int i = 0; i < path.getSegmentCount(); i++) {
if (path.getSegment(i) instanceof Category) {
eg = "Select a function to see its documentation.";
if (browser != null) {
browser.setText(eg);
} else if (textField != null) {
textField.setText(eg);
}
} else if (path.getSegment(i) instanceof HelperFunctionOrCategory) {
HelperFunctionOrCategory hfoc = ((HelperFunctionOrCategory) path.getSegment(i));
try {
hfs = (HelperFunctionSpecification) hfoc.asFunction().getSpec(hfoc.getName());
} catch (Exception e) {
log.error("There is a problem in retrieving the specification for a helper function.", e);
}
// displaying the specification
if (browser != null) {
eg = getFunctionSpecHTML(hfs);
browser.setText(eg);
} else if (textField != null) {
eg = getFunctionSpecText(hfs);
textField.setText(eg);
}
}
}
}
}
}
});
return comp;
}
use of org.eclipse.jface.viewers.IContentProvider in project linuxtools by eclipse.
the class AbstractSTViewer method init.
/*
* Initializes this view with the given view site. A memento is passed to the view which contains a snapshot of the
* views state from a previous session. Where possible, the view should try to recreate that state within the part
* controls. <p> This implementation will ignore the memento and initialize the view in a fresh state. Subclasses
* may override the implementation to perform any state restoration as needed.
*/
/**
* Initializes the viewers. It sets: the columns of the viewers, a viewer setting (similar to memento) a column
* manager a viewer comparator ColumnViewerToolTipSupport an OpenListener a KeyListener a PaintListener a
* DisposeListener the input the content provider
* @param parent The parent composite.
* @param style SWT style to be used.
*/
private void init(Composite parent, int style) {
viewer = createViewer(parent, style);
viewerSettings = createSTAbstractDataViewersSettings();
fields = getAllFields();
createColumns();
restoreColumnOrder();
// building columns manager
// (needs the columns to be created first)
STDataViewersHideShowManager manager = new STDataViewersHideShowManager(this);
manager.restoreState(viewerSettings);
setHideShowManager(manager);
// building the column comparator
// (needs the columns to be created first)
STDataViewersComparator comparator = new STDataViewersComparator(getColumns());
comparator.restoreState(viewerSettings);
setComparator(comparator);
setSortIndicators();
IContentProvider cp = createContentProvider();
viewer.setContentProvider(cp);
viewer.setUseHashlookup(true);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
viewer.getControl().setLayoutData(data);
viewer.setInput(null);
ColumnViewerToolTipSupport.enableFor(viewer);
Scrollable scrollable = (Scrollable) viewer.getControl();
ScrollBar bar = scrollable.getVerticalBar();
if (bar != null) {
bar.setSelection(restoreVerticalScrollBarPosition());
}
bar = scrollable.getHorizontalBar();
if (bar != null) {
bar.setSelection(restoreHorizontalScrollBarPosition());
}
viewer.addOpenListener(event -> handleOpenEvent(event));
viewer.getControl().addDisposeListener(new STDisposeListener(this));
}
Aggregations