Search in sources :

Example 1 with TreeExpansionEvent

use of org.eclipse.jface.viewers.TreeExpansionEvent in project tdi-studio-se by Talend.

the class StatLogsAndImplicitcontextTreeViewPage method createStatTree.

private void createStatTree(Composite composite) {
    //$NON-NLS-1$
    Group g = widgetFactory.createGroup(composite, Messages.getString("StatsAndLogsComposite.StatsLogsSettings"));
    GridData gd = new GridData(GridData.FILL_BOTH);
    g.setLayoutData(gd);
    g.setLayout(new FillLayout());
    statViewer = new CheckboxRepositoryTreeViewer(g, SWT.MULTI | SWT.V_SCROLL);
    statContentProvider = new AllJobContentProvider(repositoryView);
    statViewer.setContentProvider(statContentProvider);
    statViewer.setLabelProvider(new RepositoryLabelProvider(repositoryView));
    statViewer.setSorter(repositoryView.getViewer().getSorter());
    IViewSite viewSite = repositoryView.getViewSite();
    statViewer.setInput(viewSite);
    // This only tree listener aim is to change open/close icons on folders :
    statViewer.addTreeListener(new ITreeViewerListener() {

        @Override
        public void treeCollapsed(TreeExpansionEvent event) {
            RepositoryNode node = (RepositoryNode) event.getElement();
            if (node.getType().equals(ENodeType.SIMPLE_FOLDER)) {
                TreeItem item = getObject(statViewer.getTree(), event.getElement());
                if (item != null) {
                    item.setImage(ImageProvider.getImage(ECoreImage.FOLDER_CLOSE_ICON));
                }
            }
        }

        @Override
        public void treeExpanded(TreeExpansionEvent event) {
            RepositoryNode node = (RepositoryNode) event.getElement();
            if (node.getType().equals(ENodeType.SIMPLE_FOLDER)) {
                TreeItem item = getObject(statViewer.getTree(), event.getElement());
                if (item != null) {
                    item.setImage(ImageProvider.getImage(ECoreImage.FOLDER_OPEN_ICON));
                }
            }
        }
    });
    statViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            RepositoryNode node = (RepositoryNode) event.getElement();
            List<RepositoryNode> objects = new ArrayList<RepositoryNode>();
            processItems(objects, node);
            if (event.getChecked()) {
                statAddedObjects.addAll(objects);
                statRemovedObjects.removeAll(objects);
                statCheckedObjects.addAll(objects);
            } else {
                statAddedObjects.removeAll(objects);
                statRemovedObjects.addAll(objects);
                statCheckedObjects.removeAll(objects);
            }
            // set checked
            statViewer.setCheckedElements(statCheckedObjects.toArray());
        // viewer.refresh();
        }
    });
    RepositoryNode[] nodes = statContentProvider.getContents();
    List<RepositoryNode> objects = new ArrayList<RepositoryNode>();
    if (nodes != null) {
        for (RepositoryNode n : nodes) {
            processItems(objects, n);
            for (RepositoryNode node : objects) {
                if (isStatUseProjectSetting(node)) {
                    if (!statCheckedObjects.contains(node)) {
                        statCheckedObjects.add(node);
                    }
                }
            }
        }
    }
    statViewer.setCheckedElements(statCheckedObjects.toArray());
    if (nodes != null) {
        statViewer.setExpandedElements(nodes);
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) TreeItem(org.eclipse.swt.widgets.TreeItem) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) ArrayList(java.util.ArrayList) FillLayout(org.eclipse.swt.layout.FillLayout) RepositoryLabelProvider(org.talend.core.repository.ui.view.RepositoryLabelProvider) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IViewSite(org.eclipse.ui.IViewSite) CheckboxRepositoryTreeViewer(org.talend.repository.viewer.ui.viewer.CheckboxRepositoryTreeViewer) GridData(org.eclipse.swt.layout.GridData) List(java.util.List) ArrayList(java.util.ArrayList) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent)

Example 2 with TreeExpansionEvent

use of org.eclipse.jface.viewers.TreeExpansionEvent in project cubrid-manager by CUBRID.

the class CubridHostNavigatorView method createNavigator.

/**
	 * Create the navigator
	 */
protected void createNavigator() {
    tv.setSorter(new CMNavigatorViewSorter());
    tv.setContentProvider(new DeferredContentProvider());
    tv.setLabelProvider(new DecoratingLabelProvider(new NavigatorTreeLabelProvider()));
    tv.addDoubleClickListener(LayoutManager.getInstance());
    tv.addTreeListener(new ITreeViewerListener() {

        public void treeCollapsed(TreeExpansionEvent event) {
            CommonUITool.clearExpandedElements(tv);
        }

        public void treeExpanded(TreeExpansionEvent event) {
            CommonUITool.clearExpandedElements(tv);
        }
    });
    CubridActionBuilder.init();
    hookRetragetActions();
    addHostListener();
}
Also used : DeferredContentProvider(com.cubrid.common.ui.common.navigator.DeferredContentProvider) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) DecoratingLabelProvider(com.cubrid.common.ui.common.navigator.DecoratingLabelProvider) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent)

Example 3 with TreeExpansionEvent

use of org.eclipse.jface.viewers.TreeExpansionEvent in project cubrid-manager by CUBRID.

the class CubridMonitorNavigatorView method createNavigator.

/**
	 * Create the navigator
	 *
	 */
protected void createNavigator() {
    tv.setContentProvider(new DeferredContentProvider());
    tv.setLabelProvider(new NavigatorTreeLabelProvider());
    tv.addDoubleClickListener(LayoutManager.getInstance());
    tv.addTreeListener(new ITreeViewerListener() {

        public void treeCollapsed(TreeExpansionEvent event) {
            CommonUITool.clearExpandedElements(tv);
        }

        public void treeExpanded(TreeExpansionEvent event) {
            CommonUITool.clearExpandedElements(tv);
        }
    });
    tv.setInput(getTreeViewerInput());
}
Also used : DeferredContentProvider(com.cubrid.common.ui.common.navigator.DeferredContentProvider) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent)

Example 4 with TreeExpansionEvent

use of org.eclipse.jface.viewers.TreeExpansionEvent in project cubrid-manager by CUBRID.

the class CubridQueryNavigatorView method createNavigator.

/**
	 * Create the navigator
	 */
protected void createNavigator() {
    tv.setSorter(new CQBNavigatorViewSorter());
    tv.setContentProvider(new DeferredContentProvider());
    tv.setLabelProvider(new DecoratingLabelProvider(new NavigatorTreeLabelProvider()));
    tv.addDoubleClickListener(LayoutManager.getInstance());
    tv.addTreeListener(new ITreeViewerListener() {

        public void treeCollapsed(TreeExpansionEvent event) {
            CommonUITool.clearExpandedElements(tv);
        }

        public void treeExpanded(TreeExpansionEvent event) {
            CommonUITool.clearExpandedElements(tv);
        }
    });
    CubridActionBuilder.init();
    hookRetragetActions();
    addConnectionListener();
}
Also used : DeferredContentProvider(com.cubrid.common.ui.common.navigator.DeferredContentProvider) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) DecoratingLabelProvider(com.cubrid.common.ui.common.navigator.DecoratingLabelProvider) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent)

Example 5 with TreeExpansionEvent

use of org.eclipse.jface.viewers.TreeExpansionEvent in project tdi-studio-se by Talend.

the class MultiSchemasUI method addFieldListeners.

private void addFieldListeners() {
    fileField.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            getConnection().setFilePath(fileField.getText());
            previewBtn.setEnabled(checkFieldsValue());
            clearPreview();
            refreshPreview();
        }
    });
    rowSeparatorText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            getConnection().setRowSeparatorValue(rowSeparatorText.getText());
            previewBtn.setEnabled(checkFieldsValue());
            clearPreview();
        }
    });
    fieldSeparatorText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            getConnection().setFieldSeparatorValue(fieldSeparatorText.getText());
            previewBtn.setEnabled(checkFieldsValue());
            clearPreview();
        }
    });
    useMultiSaparators.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean selected = useMultiSaparators.getSelection();
            fieldSeparatorCombo.setEnabled(!selected);
            fieldSeparatorText.setEditable(!selected);
            multiSeparatorsText.setEditable(selected);
            keyValuesText.setEditable(selected);
            keyIndexText.setEditable(selected);
            escapeCharCombo.setEnabled(selected);
            textEnclosureCombo.setEnabled(selected);
            csvRadio.setSelection(selected);
            delimitedRadio.setSelection(!selected);
            delimitedRadio.setEnabled(!selected);
            if (selected) {
                getConnection().setFieldSeparatorValue(multiSeparatorsText.getText());
                multiSchemaManager.setSelectedColumnIndex(Integer.parseInt(keyIndexText.getText()));
            } else {
                getConnection().setFieldSeparatorValue(fieldSeparatorText.getText());
            }
            clearPreview();
            previewBtn.setEnabled(checkFieldsValue());
            if (previewBtn.isEnabled()) {
                refreshPreview();
            }
        }
    });
    schemaTreeViewer.getTree().addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            getUIManager().refreshSchemasDetailView(schemaTreeViewer, schemaDetailsViewer, getSchemaDetailModel());
        }
    });
    schemaTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            removeRow.setEnabled(true);
            editSchema.setEnabled(true);
            if (isReadOnly()) {
                leftBtn.setEnabled(false);
                rightBtn.setEnabled(false);
            } else {
                leftBtn.setEnabled(getUIManager().enableMovedRecord(schemaTreeViewer, true));
                rightBtn.setEnabled(getUIManager().enableMovedRecord(schemaTreeViewer, false));
            }
            IStructuredSelection selection = (IStructuredSelection) schemaTreeViewer.getSelection();
            Object element = selection.getFirstElement();
            if (element != null && (element instanceof SchemasKeyData) && ((SchemasKeyData) element).getTagLevel() > 0) {
                cardText.setText(((SchemasKeyData) element).getCard());
                cardText.setEnabled(true);
            } else {
                //$NON-NLS-1$
                cardText.setText("");
                cardText.setEnabled(false);
            }
        }
    });
    schemaTreeViewer.getTree().addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
        //
        }

        @Override
        public void keyReleased(KeyEvent e) {
        //
        }
    });
    schemaTreeViewer.addTreeListener(new ITreeViewerListener() {

        public void treeCollapsed(TreeExpansionEvent event) {
        // getUIManager().packSchemaTreeFirstColumn(schemaTreeViewer);
        }

        public void treeExpanded(TreeExpansionEvent event) {
        // getUIManager().packSchemaTreeFirstColumn(schemaTreeViewer);
        }
    });
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SchemasKeyData(org.talend.designer.filemultischemas.data.SchemasKeyData) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent)

Aggregations

ITreeViewerListener (org.eclipse.jface.viewers.ITreeViewerListener)9 TreeExpansionEvent (org.eclipse.jface.viewers.TreeExpansionEvent)9 GridData (org.eclipse.swt.layout.GridData)5 IRepositoryNode (org.talend.repository.model.IRepositoryNode)5 RepositoryNode (org.talend.repository.model.RepositoryNode)5 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)4 CheckboxRepositoryTreeViewer (org.talend.repository.viewer.ui.viewer.CheckboxRepositoryTreeViewer)4 DeferredContentProvider (com.cubrid.common.ui.common.navigator.DeferredContentProvider)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)3 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)3 DecoratingLabelProvider (com.cubrid.common.ui.common.navigator.DecoratingLabelProvider)2 Viewer (org.eclipse.jface.viewers.Viewer)2 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)2 FillLayout (org.eclipse.swt.layout.FillLayout)2 Group (org.eclipse.swt.widgets.Group)2 TreeItem (org.eclipse.swt.widgets.TreeItem)2 IViewSite (org.eclipse.ui.IViewSite)2 RepositoryLabelProvider (org.talend.core.repository.ui.view.RepositoryLabelProvider)2