use of org.eclipse.jface.viewers.TreeViewer in project dbeaver by serge-rider.
the class NavigatorHandlerLocalFolderCreate method createFolder.
public static boolean createFolder(IWorkbenchWindow workbenchWindow, IWorkbenchPart activePart, DBNProjectDatabases databases, final DBNLocalFolder parentFolder, final Collection<DBNDataSource> nodes, String newName) {
if (newName == null) {
newName = EnterNameDialog.chooseName(workbenchWindow.getShell(), "Folder name");
}
if (CommonUtils.isEmpty(newName)) {
return false;
}
// Create folder and refresh databases root
// DS container will reload folders on refresh
final DBPDataSourceRegistry dsRegistry = databases.getDataSourceRegistry();
DBPDataSourceFolder folder = dsRegistry.addFolder(parentFolder == null ? null : parentFolder.getFolder(), newName);
for (DBNDataSource node : nodes) {
node.setFolder(folder);
}
if (parentFolder != null && activePart instanceof NavigatorViewBase) {
final TreeViewer viewer = ((NavigatorViewBase) activePart).getNavigatorViewer();
if (viewer != null) {
DBeaverUI.asyncExec(new Runnable() {
@Override
public void run() {
viewer.expandToLevel(parentFolder, 1);
}
});
}
}
DBNModel.updateConfigAndRefreshDatabases(databases);
return true;
}
use of org.eclipse.jface.viewers.TreeViewer in project dbeaver by serge-rider.
the class AbstractSearchResultsPage method populateObjects.
public void populateObjects(DBRProgressMonitor monitor, Collection<OBJECT_TYPE> objects) {
if (itemList != null && !itemList.isDisposed()) {
List<DBNNode> nodes = new ArrayList<>(objects.size());
for (OBJECT_TYPE object : objects) {
nodes.add(getNodeFromObject(object));
}
TreeViewer itemsViewer = (TreeViewer) itemList.getItemsViewer();
Collection<DBNNode> oldNodes = itemList.getListData();
List<DBNNode> newNodes = new ArrayList<>();
if (!CommonUtils.isEmpty(oldNodes)) {
newNodes.addAll(oldNodes);
}
newNodes.addAll(nodes);
((ResultsContentProvider) itemsViewer.getContentProvider()).rebuildObjectTree(newNodes);
itemList.appendListData(nodes);
itemsViewer.expandAll();
}
}
use of org.eclipse.jface.viewers.TreeViewer in project meclipse by flaper87.
the class MeclipseView method createPartControl.
/**
* This is a callback that will allow us to create the viewer and initialize
* it.
*/
public void createPartControl(Composite parent) {
viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
// drillDownAdapter = new DrillDownAdapter(viewer);
viewer.setContentProvider(content);
viewer.setLabelProvider(new ViewLabelProvider());
viewer.setSorter(new NameSorter());
viewer.setInput(new Root(this));
// Hook viewer up to the Eclipse selection provider:
getSite().setSelectionProvider(viewer);
// Create the help context id for the viewer's control
PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "org.mongodb.meclipse.views");
makeActions();
hookContextMenu();
hookDoubleClickAction();
contributeToActionBars();
MeclipsePlugin.getDefault().setMongoDbView(this);
}
use of org.eclipse.jface.viewers.TreeViewer in project translationstudio8 by heartsome.
the class TermDbManagerDialog method createTreeViewer.
/**
* Create a new <code>TreeViewer</code>.
* @param parent
* the parent <code>Composite</code>.
* @return the <code>TreeViewer</code>.
*/
protected TreeViewer createTreeViewer(Composite parent) {
final TreeViewer viewer = new TreeViewer(parent, SWT.NONE);
addListeners(viewer);
viewer.setLabelProvider(new TreeLableProvider());
viewer.setContentProvider(new TreeContentProvider());
return viewer;
}
use of org.eclipse.jface.viewers.TreeViewer in project translationstudio8 by heartsome.
the class HsPreferenceDialog method createTreeAreaContents.
@Override
protected Control createTreeAreaContents(Composite parent) {
// 创建左侧树
Control result = super.createTreeAreaContents(parent);
TreeViewer treeViewer = getTreeViewer();
// 设置排序器
IContributionService cs = (IContributionService) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(IContributionService.class);
treeViewer.setComparator(cs.getComparatorFor(IContributionService.TYPE_PREFERENCE));
// 展开所有
treeViewer.expandAll();
return result;
}
Aggregations