Search in sources :

Example 1 with TreeViewer

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;
}
Also used : DBNDataSource(org.jkiss.dbeaver.model.navigator.DBNDataSource) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DBPDataSourceFolder(org.jkiss.dbeaver.model.DBPDataSourceFolder) NavigatorViewBase(org.jkiss.dbeaver.ui.navigator.database.NavigatorViewBase) DBPDataSourceRegistry(org.jkiss.dbeaver.model.app.DBPDataSourceRegistry)

Example 2 with TreeViewer

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();
    }
}
Also used : DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) TreeViewer(org.eclipse.jface.viewers.TreeViewer)

Example 3 with TreeViewer

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);
}
Also used : Root(org.mongodb.meclipse.views.objects.Root) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ViewLabelProvider(org.mongodb.meclipse.views.objects.ViewLabelProvider)

Example 4 with TreeViewer

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;
}
Also used : ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) TreeViewer(org.eclipse.jface.viewers.TreeViewer)

Example 5 with TreeViewer

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;
}
Also used : Control(org.eclipse.swt.widgets.Control) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IContributionService(org.eclipse.ui.model.IContributionService)

Aggregations

TreeViewer (org.eclipse.jface.viewers.TreeViewer)199 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)62 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)45 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)42 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)40 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)39 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)38 GridData (org.eclipse.swt.layout.GridData)37 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)36 Tree (org.eclipse.swt.widgets.Tree)34 Composite (org.eclipse.swt.widgets.Composite)33 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)31 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)29 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)28 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)28 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)27 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)27 ArrayList (java.util.ArrayList)24 GridLayout (org.eclipse.swt.layout.GridLayout)23 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)22