Search in sources :

Example 66 with TreeColumn

use of org.eclipse.swt.widgets.TreeColumn in project egit by eclipse.

the class GitTraceConfigurationDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite main = new Composite(parent, SWT.NONE);
    main.setLayout(new GridLayout(3, false));
    platformSwitch = new Button(main, SWT.CHECK);
    platformSwitch.setText(UIText.GitTraceConfigurationDialog_PlatformSwitchCheckbox);
    GridDataFactory.fillDefaults().span(3, 1).applyTo(platformSwitch);
    platformSwitch.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateEnablement();
        }
    });
    tv = new CheckboxTreeViewer(main, SWT.BORDER);
    tv.setContentProvider(new TraceTableContentProvider(optionsMap));
    Tree tree = tv.getTree();
    GridDataFactory.fillDefaults().span(3, 1).grab(true, true).applyTo(tree);
    // enable testing with SWTBot
    // $NON-NLS-1$ //$NON-NLS-2$
    tree.setData("org.eclipse.swtbot.widget.key", "LocationTree");
    TreeColumn c1 = new TreeColumn(tree, SWT.NONE);
    c1.setWidth(400);
    c1.setText(UIText.GitTraceConfigurationDialog_LocationHeader);
    tree.setHeaderVisible(true);
    Label fileLabel = new Label(main, SWT.NONE);
    fileLabel.setText(UIText.GitTraceConfigurationDialog_TraceFileLocationLabel);
    traceFileLocation = new Text(main, SWT.BORDER);
    traceFileLocation.setEditable(false);
    GridDataFactory.defaultsFor(traceFileLocation).grab(true, false).applyTo(traceFileLocation);
    Button openButton = new Button(main, SWT.PUSH);
    openButton.setText(UIText.GitTraceConfigurationDialog_OpenInEditorButton);
    openButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IFileStore store = EFS.getLocalFileSystem().getStore(new Path(traceFileLocation.getText()));
            try {
                IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), new FileStoreEditorInput(store), EditorsUI.DEFAULT_TEXT_EDITOR_ID);
            } catch (PartInitException ex) {
                Activator.handleError(ex.getMessage(), ex, true);
            }
        }
    });
    initValues();
    platformSwitch.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            setDirty(true);
        }
    });
    tv.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            setDirty(true);
        }
    });
    Dialog.applyDialogFont(main);
    return main;
}
Also used : Path(org.eclipse.core.runtime.Path) Composite(org.eclipse.swt.widgets.Composite) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) UIText(org.eclipse.egit.ui.internal.UIText) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) TreeColumn(org.eclipse.swt.widgets.TreeColumn) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) IFileStore(org.eclipse.core.filesystem.IFileStore) PartInitException(org.eclipse.ui.PartInitException) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) FileStoreEditorInput(org.eclipse.ui.ide.FileStoreEditorInput)

Example 67 with TreeColumn

use of org.eclipse.swt.widgets.TreeColumn in project egit by eclipse.

the class CommitViewerComparator method createFileSection.

private Section createFileSection(Composite container) {
    Section filesSection = toolkit.createSection(container, ExpandableComposite.TITLE_BAR | ExpandableComposite.CLIENT_INDENT);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(filesSection);
    Composite filesArea = toolkit.createComposite(filesSection);
    filesSection.setClient(filesArea);
    toolkit.paintBordersFor(filesArea);
    GridLayoutFactory.fillDefaults().extendedMargins(2, 2, 2, 2).applyTo(filesArea);
    ToolBar filesToolbar = new ToolBar(filesSection, SWT.FLAT);
    filesSection.setTextClient(filesToolbar);
    PatternFilter patternFilter = new PatternFilter() {

        @Override
        protected boolean isLeafMatch(Viewer viewer, Object element) {
            if (element instanceof CommitItem) {
                CommitItem commitItem = (CommitItem) element;
                return wordMatches(commitItem.path);
            }
            return super.isLeafMatch(viewer, element);
        }
    };
    patternFilter.setIncludeLeadingWildcard(true);
    FilteredCheckboxTree resourcesTreeComposite = new FilteredCheckboxTree(filesArea, toolkit, SWT.FULL_SELECTION, patternFilter) {

        @Override
        protected WorkbenchJob doCreateRefreshJob() {
            // workaround for file filter not having an explicit change
            // listener
            WorkbenchJob filterJob = super.doCreateRefreshJob();
            filterJob.addJobChangeListener(new JobChangeAdapter() {

                @Override
                public void done(IJobChangeEvent event) {
                    if (event.getResult().isOK()) {
                        getDisplay().asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                updateFileSectionText();
                            }
                        });
                    }
                }
            });
            return filterJob;
        }
    };
    Tree resourcesTree = resourcesTreeComposite.getViewer().getTree();
    resourcesTree.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
    resourcesTreeComposite.setLayoutData(GridDataFactory.fillDefaults().hint(600, 200).grab(true, true).create());
    resourcesTree.addSelectionListener(new CommitItemSelectionListener());
    resourcesTree.setHeaderVisible(true);
    if (getPreferenceStore().getBoolean(UIPreferences.WARN_BEFORE_COMMITTING) && getPreferenceStore().getBoolean(UIPreferences.BLOCK_COMMIT)) {
        ignoreErrors = new Button(resourcesTreeComposite, SWT.CHECK);
        ignoreErrors.setText(UIText.CommitDialog_IgnoreErrors);
        ignoreErrors.setSelection(false);
        ignoreErrors.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                Button button = (Button) e.getSource();
                boolean enable = button.getSelection();
                updateMessage();
                updateCommitButtons(enable);
            }
        });
    }
    TreeColumn statCol = new TreeColumn(resourcesTree, SWT.LEFT);
    statCol.setText(UIText.CommitDialog_Status);
    statCol.setWidth(150);
    statCol.addSelectionListener(new HeaderSelectionListener(CommitItem.Order.ByStatus));
    TreeColumn resourceCol = new TreeColumn(resourcesTree, SWT.LEFT);
    resourceCol.setText(UIText.CommitDialog_Path);
    resourceCol.setWidth(415);
    resourceCol.addSelectionListener(new HeaderSelectionListener(CommitItem.Order.ByFile));
    filesViewer = resourcesTreeComposite.getCheckboxTreeViewer();
    new TreeViewerColumn(filesViewer, statCol).setLabelProvider(createStatusLabelProvider());
    new TreeViewerColumn(filesViewer, resourceCol).setLabelProvider(new CommitPathLabelProvider());
    ColumnViewerToolTipSupport.enableFor(filesViewer);
    filesViewer.setContentProvider(new CommitFileContentProvider());
    filesViewer.setUseHashlookup(true);
    IDialogSettings settings = org.eclipse.egit.ui.Activator.getDefault().getDialogSettings();
    if (settings.get(SHOW_UNTRACKED_PREF) != null) {
        // note, no matter how the dialog settings are, if
        // the preferences force us to include untracked files
        // we must show them
        showUntracked = Boolean.valueOf(settings.get(SHOW_UNTRACKED_PREF)).booleanValue() || getPreferenceStore().getBoolean(UIPreferences.COMMIT_DIALOG_INCLUDE_UNTRACKED);
    }
    filesViewer.addFilter(new CommitItemFilter());
    filesViewer.setInput(items.toArray());
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(createContextMenuListener());
    filesViewer.getTree().setMenu(menuManager.createContextMenu(filesViewer.getTree()));
    filesViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            updateFileSectionText();
        }
    });
    showUntrackedItem = new ToolItem(filesToolbar, SWT.CHECK);
    Image showUntrackedImage = UIIcons.UNTRACKED_FILE.createImage();
    UIUtils.hookDisposal(showUntrackedItem, showUntrackedImage);
    showUntrackedItem.setImage(showUntrackedImage);
    showUntrackedItem.setToolTipText(UIText.CommitDialog_ShowUntrackedFiles);
    showUntrackedItem.setSelection(showUntracked);
    showUntrackedItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            showUntracked = showUntrackedItem.getSelection();
            filesViewer.refresh(true);
            updateFileSectionText();
            updateMessage();
        }
    });
    ToolItem checkAllItem = new ToolItem(filesToolbar, SWT.PUSH);
    Image checkImage = UIIcons.CHECK_ALL.createImage();
    UIUtils.hookDisposal(checkAllItem, checkImage);
    checkAllItem.setImage(checkImage);
    checkAllItem.setToolTipText(UIText.CommitDialog_SelectAll);
    checkAllItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            filesViewer.setAllChecked(true);
            updateFileSectionText();
            updateMessage();
        }
    });
    ToolItem uncheckAllItem = new ToolItem(filesToolbar, SWT.PUSH);
    Image uncheckImage = UIIcons.UNCHECK_ALL.createImage();
    UIUtils.hookDisposal(uncheckAllItem, uncheckImage);
    uncheckAllItem.setImage(uncheckImage);
    uncheckAllItem.setToolTipText(UIText.CommitDialog_DeselectAll);
    uncheckAllItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            filesViewer.setAllChecked(false);
            updateFileSectionText();
            updateMessage();
        }
    });
    if (!allowToChangeSelection) {
        amendingItem.setSelection(false);
        amendingItem.setEnabled(false);
        showUntrackedItem.setSelection(false);
        showUntrackedItem.setEnabled(false);
        checkAllItem.setEnabled(false);
        uncheckAllItem.setEnabled(false);
        filesViewer.addCheckStateListener(new ICheckStateListener() {

            @Override
            public void checkStateChanged(CheckStateChangedEvent event) {
                if (!event.getChecked())
                    filesViewer.setAllChecked(true);
                updateFileSectionText();
            }
        });
        filesViewer.setAllChecked(true);
    } else {
        final boolean includeUntracked = getPreferenceStore().getBoolean(UIPreferences.COMMIT_DIALOG_INCLUDE_UNTRACKED);
        for (CommitItem item : items) {
            if (!preselectAll && !preselectedFiles.contains(item.path))
                continue;
            if (item.status == Status.ASSUME_UNCHANGED)
                continue;
            if (!includeUntracked && item.status == Status.UNTRACKED)
                continue;
            filesViewer.setChecked(item, true);
        }
    }
    statCol.pack();
    resourceCol.pack();
    return filesSection;
}
Also used : PatternFilter(org.eclipse.ui.dialogs.PatternFilter) FilteredCheckboxTree(org.eclipse.egit.ui.internal.components.FilteredCheckboxTree) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) CachedCheckboxTreeViewer(org.eclipse.egit.ui.internal.components.CachedCheckboxTreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) Image(org.eclipse.swt.graphics.Image) Button(org.eclipse.swt.widgets.Button) TreeColumn(org.eclipse.swt.widgets.TreeColumn) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FilteredCheckboxTree(org.eclipse.egit.ui.internal.components.FilteredCheckboxTree) Tree(org.eclipse.swt.widgets.Tree) ToolItem(org.eclipse.swt.widgets.ToolItem) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) WorkbenchJob(org.eclipse.ui.progress.WorkbenchJob) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) Section(org.eclipse.ui.forms.widgets.Section) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) ToolBar(org.eclipse.swt.widgets.ToolBar) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 68 with TreeColumn

use of org.eclipse.swt.widgets.TreeColumn in project tdq-studio-se by Talend.

the class ColumnAnalysisDetailsPage method packOtherColumns.

/**
 * DOC mzhao Comment method "packOtherColumns".
 */
private void packOtherColumns() {
    TreeColumn[] columns = treeViewer.getTree().getColumns();
    for (TreeColumn column : columns) {
        column.pack();
    }
    treeViewer.getTree().pack();
    treeViewer.getTree().getParent().layout();
}
Also used : TreeColumn(org.eclipse.swt.widgets.TreeColumn)

Example 69 with TreeColumn

use of org.eclipse.swt.widgets.TreeColumn in project tdq-studio-se by Talend.

the class AnalyzedElementSynDialog method createTableHeader.

private void createTableHeader() {
    sTreeViewer.getTree().setHeaderVisible(true);
    sTreeViewer.getTree().setLinesVisible(true);
    TreeColumn column1 = new TreeColumn(sTreeViewer.getTree(), SWT.CENTER);
    column1.setWidth(200);
    // $NON-NLS-1$
    column1.setText(DefaultMessagesImpl.getString("AnalyzedElementSynDialog.Name"));
    TreeColumn column2 = new TreeColumn(sTreeViewer.getTree(), SWT.CENTER);
    column2.setWidth(500);
    // $NON-NLS-1$
    column2.setText(DefaultMessagesImpl.getString("AnalyzedElementSynDialog.Status"));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(sTreeViewer.getTree());
}
Also used : TreeColumn(org.eclipse.swt.widgets.TreeColumn)

Example 70 with TreeColumn

use of org.eclipse.swt.widgets.TreeColumn in project tdq-studio-se by Talend.

the class AnalysisColumnTreeViewer method createTree.

/**
 * @param parent
 */
private Tree createTree(Composite parent) {
    final Tree newTree = new TooltipTree(parent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION) {

        @Override
        protected boolean isValidItem(TreeItem item) {
            if (item == null) {
                return false;
            }
            Object itemData = item.getData(INDICATOR_UNIT_KEY);
            Object columnItemData = item.getData(MODELELEMENT_INDICATOR_KEY);
            if (itemData != null) {
                IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
                if (indicatorUnit != null && !(indicatorUnit.getIndicator() instanceof CompositeIndicator)) {
                    return true;
                }
                return false;
            } else {
                if (columnItemData != null) {
                    ModelElementIndicator modelElementIndicator = (ModelElementIndicator) columnItemData;
                    IRepositoryNode modelElementRepositoryNode = modelElementIndicator.getModelElementRepositoryNode();
                    return modelElementRepositoryNode == null ? false : true;
                }
                return false;
            }
        }

        @Override
        protected String getItemTooltipText(TreeItem item) {
            String expCont = isExpressionNull(item);
            if (expCont == null) {
                // $NON-NLS-1$
                return DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.queryNotGen");
            }
            return expCont;
        }
    };
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(newTree);
    newTree.setHeaderVisible(true);
    // $NON-NLS-1$
    createTreeItem(newTree, 300, "AnalysisColumnTreeViewer.analyzedColumns");
    createTreeDataminingItem(newTree);
    // $NON-NLS-1$
    createTreeItem(newTree, 80, "AnalysisColumnTreeViewer.pattern");
    // $NON-NLS-1$
    createTreeItem(newTree, 80, "AnalysisColumnTreeViewer.udi");
    // $NON-NLS-1$
    createTreeItem(newTree, 80, "AnalysisColumnTreeViewer.operation");
    // TDQ-11622 : add a column here, let the width = 1 and text = EMPTY_STRING TODO need to find a better solution!
    TreeColumn blankColumn = new TreeColumn(newTree, SWT.CENTER);
    blankColumn.setWidth(1);
    // ~ TDQ-11622
    parent.layout();
    AbstractAnalysisActionHandler actionHandler = new AbstractAnalysisActionHandler(parent) {

        @Override
        protected void handleRemove() {
            removeSelectedElements(newTree);
        }
    };
    parent.setData(AbstractMetadataFormPage.ACTION_HANDLER, actionHandler);
    ColumnViewerDND.installDND(newTree);
    this.addTreeListener(newTree);
    newTree.setData(this);
    return newTree;
}
Also used : AbstractAnalysisActionHandler(org.talend.dataprofiler.core.ui.editor.AbstractAnalysisActionHandler) IRepositoryNode(org.talend.repository.model.IRepositoryNode) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeColumn(org.eclipse.swt.widgets.TreeColumn) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) TooltipTree(org.talend.dataprofiler.core.ui.dialog.composite.TooltipTree) Tree(org.eclipse.swt.widgets.Tree) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) MetadataXmlElementTypeRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataXmlElementTypeRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TooltipTree(org.talend.dataprofiler.core.ui.dialog.composite.TooltipTree) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Aggregations

TreeColumn (org.eclipse.swt.widgets.TreeColumn)189 Tree (org.eclipse.swt.widgets.Tree)99 TreeViewer (org.eclipse.jface.viewers.TreeViewer)55 Composite (org.eclipse.swt.widgets.Composite)52 TreeItem (org.eclipse.swt.widgets.TreeItem)45 FillLayout (org.eclipse.swt.layout.FillLayout)40 Point (org.eclipse.swt.graphics.Point)39 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)28 Viewer (org.eclipse.jface.viewers.Viewer)28 GridData (org.eclipse.swt.layout.GridData)28 ControlEvent (org.eclipse.swt.events.ControlEvent)27 ControlAdapter (org.eclipse.swt.events.ControlAdapter)25 SelectionEvent (org.eclipse.swt.events.SelectionEvent)25 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)24 TableColumn (org.eclipse.swt.widgets.TableColumn)24 TableLayout (org.eclipse.jface.viewers.TableLayout)23 Table (org.eclipse.swt.widgets.Table)23 GridLayout (org.eclipse.swt.layout.GridLayout)22 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)21 ViewerPane (org.eclipse.emf.common.ui.ViewerPane)19