use of org.eclipse.jface.viewers.StructuredViewer in project tdi-studio-se by Talend.
the class ResourceExtensionContentProvider method processDelta.
/**
* Process a resource delta. Add any runnables
*/
private void processDelta(IResourceDelta delta, Collection runnables) {
// he widget may have been destroyed
// by the time this is run. Check for this and do nothing if so.
Control ctrl = viewer.getControl();
if (ctrl == null || ctrl.isDisposed()) {
return;
}
// Get the affected resource
final IResource resource = delta.getResource();
// If any children have changed type, just do a full refresh of this
// parent,
// since a simple update on such children won't work,
// and trying to map the change to a remove and add is too dicey.
// The case is: folder A renamed to existing file B, answering yes to
// overwrite B.
IResourceDelta[] affectedChildren = delta.getAffectedChildren(IResourceDelta.CHANGED);
for (int i = 0; i < affectedChildren.length; i++) {
if ((affectedChildren[i].getFlags() & IResourceDelta.TYPE) != 0) {
runnables.add(getRefreshRunnable(resource));
return;
}
}
// Check the flags for changes the Navigator cares about.
// See ResourceLabelProvider for the aspects it cares about.
// Notice we don't care about F_CONTENT or F_MARKERS currently.
int changeFlags = delta.getFlags();
if ((changeFlags & (IResourceDelta.OPEN | IResourceDelta.SYNC | IResourceDelta.TYPE | IResourceDelta.DESCRIPTION)) != 0) {
// Runnable updateRunnable = new Runnable(){
// public void run() {
// ((StructuredViewer) viewer).update(resource, null);
// }
// };
// runnables.add(updateRunnable);
/*
* support the Closed Projects filter; when a project is closed, it may need to be removed from the view.
*/
runnables.add(getRefreshRunnable(resource.getParent()));
}
// Replacing a resource may affect its label and its children
if ((changeFlags & IResourceDelta.REPLACED) != 0) {
runnables.add(getRefreshRunnable(resource));
return;
}
// Handle changed children .
for (int i = 0; i < affectedChildren.length; i++) {
processDelta(affectedChildren[i], runnables);
}
// @issue several problems here:
// - should process removals before additions, to avoid multiple equal
// elements in viewer
// - Kim: processing removals before additions was the indirect cause of
// 44081 and its varients
// - Nick: no delta should have an add and a remove on the same element,
// so processing adds first is probably OK
// - using setRedraw will cause extra flashiness
// - setRedraw is used even for simple changes
// - to avoid seeing a rename in two stages, should turn redraw on/off
// around combined removal and addition
// - Kim: done, and only in the case of a rename (both remove and add
// changes in one delta).
IResourceDelta[] addedChildren = delta.getAffectedChildren(IResourceDelta.ADDED);
IResourceDelta[] removedChildren = delta.getAffectedChildren(IResourceDelta.REMOVED);
if (addedChildren.length == 0 && removedChildren.length == 0) {
return;
}
final Object[] addedObjects;
final Object[] removedObjects;
// Process additions before removals as to not cause selection
// preservation prior to new objects being added
// Handle added children. Issue one update for all insertions.
int numMovedFrom = 0;
int numMovedTo = 0;
if (addedChildren.length > 0) {
addedObjects = new Object[addedChildren.length];
for (int i = 0; i < addedChildren.length; i++) {
addedObjects[i] = addedChildren[i].getResource();
if ((addedChildren[i].getFlags() & IResourceDelta.MOVED_FROM) != 0) {
++numMovedFrom;
}
}
} else {
addedObjects = new Object[0];
}
// Handle removed children. Issue one update for all removals.
if (removedChildren.length > 0) {
removedObjects = new Object[removedChildren.length];
for (int i = 0; i < removedChildren.length; i++) {
removedObjects[i] = removedChildren[i].getResource();
if ((removedChildren[i].getFlags() & IResourceDelta.MOVED_TO) != 0) {
++numMovedTo;
}
}
} else {
removedObjects = new Object[0];
}
// heuristic test for items moving within same folder (i.e. renames)
final boolean hasRename = numMovedFrom > 0 && numMovedTo > 0;
Runnable addAndRemove = new Runnable() {
public void run() {
if (viewer instanceof AbstractTreeViewer) {
AbstractTreeViewer treeViewer = (AbstractTreeViewer) viewer;
// rename case)
if (hasRename) {
treeViewer.getControl().setRedraw(false);
}
try {
if (addedObjects.length > 0) {
treeViewer.add(resource, addedObjects);
}
if (removedObjects.length > 0) {
treeViewer.remove(removedObjects);
}
} finally {
if (hasRename) {
treeViewer.getControl().setRedraw(true);
}
}
} else {
((StructuredViewer) viewer).refresh(resource);
}
}
};
runnables.add(addAndRemove);
}
use of org.eclipse.jface.viewers.StructuredViewer in project tdi-studio-se by Talend.
the class JobHierarchyViewPart method createPartControl.
@Override
public void createPartControl(Composite container) {
fParent = container;
addResizeListener(fParent);
fPagebook = new PageBook(container, SWT.NONE);
// page 1 of page book (no hierarchy label)
fNoHierarchyShownLabel = new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP);
fNoHierarchyShownLabel.setText(showEmptyLabel);
// page 2 of page book (viewers)
fTypeMethodsSplitter = new SashForm(fPagebook, SWT.VERTICAL);
fTypeMethodsSplitter.setVisible(false);
fTypeViewerViewForm = new ViewForm(fTypeMethodsSplitter, SWT.NONE);
Control typeViewerControl = createTypeViewerControl(fTypeViewerViewForm);
fTypeViewerViewForm.setContent(typeViewerControl);
dependencyViewerViewForm = new ViewForm(fTypeMethodsSplitter, SWT.NONE);
fTypeMethodsSplitter.setWeights(new int[] { 65, 35 });
Control dependencyViewerPart = createMethodViewerControl(dependencyViewerViewForm);
dependencyViewerViewForm.setContent(dependencyViewerPart);
dependencyViewerPaneLabel = new CLabel(dependencyViewerViewForm, SWT.NONE);
dependencyViewerViewForm.setTopLeft(dependencyViewerPaneLabel);
ToolBar methodViewerToolBar = new ToolBar(dependencyViewerViewForm, SWT.FLAT | SWT.WRAP);
dependencyViewerViewForm.setTopCenter(methodViewerToolBar);
initDragAndDrop();
MenuManager menu = new MenuManager();
menu.add(focusOnTypeAction);
fNoHierarchyShownLabel.setMenu(menu.createContextMenu(fNoHierarchyShownLabel));
fPagebook.showPage(fNoHierarchyShownLabel);
int layout;
try {
layout = fDialogSettings.getInt(DIALOGSTORE_VIEWLAYOUT);
if (layout < 0 || layout > 3) {
layout = VIEW_LAYOUT_AUTOMATIC;
}
} catch (NumberFormatException e) {
layout = VIEW_LAYOUT_AUTOMATIC;
}
// force the update
fCurrentLayout = -1;
// will fill the main tool bar
setViewLayout(layout);
// set the filter menu items
IActionBars actionBars = getViewSite().getActionBars();
IMenuManager viewMenu = actionBars.getMenuManager();
// for (int i = 0; i < fViewActions.length; i++) {
// ToggleViewAction action = fViewActions[i];
// viewMenu.add(action);
// action.setEnabled(false);
// }
// viewMenu.add(new Separator());
// IMenuManager layoutSubMenu = new MenuManager(TypeHierarchyMessages.TypeHierarchyViewPart_layout_submenu);
//$NON-NLS-1$
IMenuManager layoutSubMenu = new MenuManager(Messages.getString("FocusOnJobAction.TypeHierarchyViewPart_layout_submenu"));
viewMenu.add(layoutSubMenu);
for (int i = 0; i < fToggleOrientationActions.length; i++) {
layoutSubMenu.add(fToggleOrientationActions[i]);
}
viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
// selection provider
int nHierarchyViewers = fAllViewers.length;
StructuredViewer[] trackedViewers = new StructuredViewer[nHierarchyViewers + 1];
for (int i = 0; i < nHierarchyViewers; i++) {
trackedViewers[i] = fAllViewers[i];
}
trackedViewers[nHierarchyViewers] = dependencyViewer;
fSelectionProviderMediator = new SelectionProviderMediator(trackedViewers, getCurrentViewer());
getSite().setSelectionProvider(fSelectionProviderMediator);
ActionGroup[] actionGroups = new ActionGroup[] { new JobActionGroup() };
fActionGroups = new CompositeActionGroup(actionGroups);
fActionGroups.fillActionBars(actionBars);
}
use of org.eclipse.jface.viewers.StructuredViewer in project tdi-studio-se by Talend.
the class CreateProcess method selectRootObject.
protected final void selectRootObject(Properties params) {
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (null == workbenchWindow) {
return;
}
IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
if (null == workbenchPage) {
return;
}
IPerspectiveDescriptor currentPerspective = workbenchPage.getPerspective();
if (!getPerspectiveId().equals(currentPerspective.getId())) {
// show di perspective
try {
workbenchWindow.getWorkbench().showPerspective(getPerspectiveId(), workbenchWindow);
workbenchPage = workbenchWindow.getActivePage();
} catch (WorkbenchException e) {
ExceptionHandler.process(e);
return;
}
}
IRepositoryView view = RepositoryManagerHelper.getRepositoryView();
if (view != null) {
Object type = params.get("type");
if (getProcessType().name().equals(type)) {
IRepositoryNode processNode = ((ProjectRepositoryNode) view.getRoot()).getRootRepositoryNode(getProcessType());
if (processNode != null) {
setWorkbenchPart(view);
final StructuredViewer viewer = view.getViewer();
if (viewer instanceof TreeViewer) {
((TreeViewer) viewer).expandToLevel(processNode, 1);
}
viewer.setSelection(new StructuredSelection(processNode));
}
}
}
}
use of org.eclipse.jface.viewers.StructuredViewer in project tesb-studio-se by Talend.
the class CreateCamelBean method selectRootObject.
private void selectRootObject(Properties params) {
IRepositoryView view = RepositoryManagerHelper.getRepositoryView();
if (view != null) {
Object type = params.get("type");
if (CamelRepositoryNodeType.repositoryBeansType.name().equals(type)) {
IRepositoryNode processNode = ((ProjectRepositoryNode) view.getRoot()).getRootRepositoryNode(ERepositoryObjectType.PROCESS);
if (processNode != null) {
setWorkbenchPart(view);
final StructuredViewer viewer = view.getViewer();
if (viewer instanceof TreeViewer) {
((TreeViewer) viewer).expandToLevel(processNode, 1);
}
viewer.setSelection(new StructuredSelection(processNode));
}
}
}
}
use of org.eclipse.jface.viewers.StructuredViewer in project tesb-studio-se by Talend.
the class CreateESBAction method selectRootObject.
private void selectRootObject(Properties params) {
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (null == workbenchWindow) {
return;
}
IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
if (null == workbenchPage) {
return;
}
IPerspectiveDescriptor currentPerspective = workbenchPage.getPerspective();
if (!IBrandingConfiguration.PERSPECTIVE_DI_ID.equals(currentPerspective.getId())) {
// show Integration perspective
try {
workbenchWindow.getWorkbench().showPerspective(IBrandingConfiguration.PERSPECTIVE_DI_ID, workbenchWindow);
workbenchPage = workbenchWindow.getActivePage();
} catch (WorkbenchException e) {
ExceptionHandler.process(e);
return;
}
}
IRepositoryView view = RepositoryManagerHelper.getRepositoryView();
if (view != null) {
Object type = params.get("type");
if (ESBRepositoryNodeType.SERVICES.name().equals(type)) {
RepositoryNode servicesNode = ((ProjectRepositoryNode) view.getRoot()).getRootRepositoryNode(ESBRepositoryNodeType.SERVICES);
if (servicesNode != null) {
setWorkbenchPart(view);
final StructuredViewer viewer = view.getViewer();
if (viewer instanceof TreeViewer) {
((TreeViewer) viewer).expandToLevel(servicesNode, 1);
}
viewer.setSelection(new StructuredSelection(servicesNode));
}
}
}
}
Aggregations