Search in sources :

Example 1 with CheckboxTreeViewer

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

the class UseDynamicJobSelectionDialog method createSelectionButton.

/**
     * DOC hcw Comment method "createSelectionButton".
     * 
     * @param itemComposite
     */
private void createSelectionButton(Composite itemComposite) {
    Composite buttonComposite = new Composite(itemComposite, SWT.NONE);
    GridLayoutFactory.swtDefaults().margins(0, 25).applyTo(buttonComposite);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING).applyTo(buttonComposite);
    Button selectAll = new Button(buttonComposite, SWT.PUSH);
    // selectAll.setText(DataTransferMessages.DataTransfer_selectAll);
    //$NON-NLS-1$
    selectAll.setText(Messages.getString("DataTransferMessages.DataTransfer_selectAll"));
    selectAll.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CheckboxTreeViewer exportItemsTreeViewer = getItemsTreeViewer();
            exportItemsTreeViewer.setAllChecked(true);
        }
    });
    setButtonLayoutData(selectAll);
    Button deselectAll = new Button(buttonComposite, SWT.PUSH);
    // deselectAll.setText(DataTransferMessages.DataTransfer_deselectAll);
    //$NON-NLS-1$
    deselectAll.setText(Messages.getString("DataTransferMessages.DataTransfer_deselectAll"));
    deselectAll.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CheckboxTreeViewer exportItemsTreeViewer = getItemsTreeViewer();
            exportItemsTreeViewer.setAllChecked(false);
        }
    });
    setButtonLayoutData(deselectAll);
    Button expandBtn = new Button(buttonComposite, SWT.PUSH);
    //$NON-NLS-1$
    expandBtn.setText(Messages.getString("UseDynamicJobSelectionDialog.expandBtnText"));
    expandBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CheckboxTreeViewer exportItemsTreeViewer = getItemsTreeViewer();
            exportItemsTreeViewer.expandAll();
        }
    });
    setButtonLayoutData(expandBtn);
    Button collapseBtn = new Button(buttonComposite, SWT.PUSH);
    //$NON-NLS-1$
    collapseBtn.setText(Messages.getString("UseDynamicJobSelectionDialog.collapseBtnText"));
    collapseBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CheckboxTreeViewer exportItemsTreeViewer = getItemsTreeViewer();
            exportItemsTreeViewer.collapseAll();
        }
    });
    setButtonLayoutData(collapseBtn);
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 2 with CheckboxTreeViewer

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

the class UseDynamicJobSelectionDialog method dispose.

/**
     * DOC nrousseau Comment method "dispose".
     */
public void dispose() {
    CheckboxTreeViewer exportItemsTreeViewer = getItemsTreeViewer();
    exportItemsTreeViewer.setCheckedElements(ArrayUtils.EMPTY_OBJECT_ARRAY);
    exportItemsTreeViewer = null;
    repositoryNodes.clear();
    repositoryNodes = null;
    needCheckedjobs = null;
    curProcessId = null;
    filteredCheckboxTree = null;
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer)

Example 3 with CheckboxTreeViewer

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

the class UseDynamicJobSelectionDialog method addCheckStateListener.

public void addCheckStateListener(ICheckStateListener listener) {
    CheckboxTreeViewer exportItemsTreeViewer = getItemsTreeViewer();
    exportItemsTreeViewer.addCheckStateListener(listener);
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer)

Example 4 with CheckboxTreeViewer

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

the class ExportItemWizardPage method createItemList.

/**
     * DOC hcw Comment method "createItemList".
     * 
     * @param workArea
     */
private void createItemList(Composite workArea) {
    Composite itemComposite = new Composite(workArea, SWT.NONE);
    GridLayoutFactory.swtDefaults().numColumns(2).applyTo(itemComposite);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(500, 300).applyTo(itemComposite);
    Label label = new Label(itemComposite, SWT.NONE);
    //$NON-NLS-1$
    label.setText(Messages.getString("ExportItemWizardPage.labelText"));
    GridDataFactory.swtDefaults().span(2, 1).applyTo(label);
    createTreeViewer(itemComposite);
    //$NON-NLS-1$
    TimeMeasure.step(this.getClass().getSimpleName(), "finished to createTreeViewer");
    createSelectionButton(itemComposite);
    CheckboxTreeViewer exportItemsTreeViewer = getItemsTreeViewer();
    addTreeCheckedSelection();
    // if user has select some items in repository view, mark them as checked
    checkSelectedElements(exportItemsTreeViewer);
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label)

Example 5 with CheckboxTreeViewer

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

the class ExportItemWizardPage method createItemRoot.

@SuppressWarnings("restriction")
private void createItemRoot(Composite workArea) {
    Composite projectGroup = new Composite(workArea, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    layout.makeColumnsEqualWidth = false;
    layout.marginWidth = 0;
    projectGroup.setLayout(layout);
    projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    itemFromDirectoryRadio = new Button(projectGroup, SWT.RADIO);
    // itemFromDirectoryRadio.setText(DataTransferMessages.WizardProjectsImportPage_RootSelectTitle);
    //$NON-NLS-1$
    itemFromDirectoryRadio.setText(Messages.getString("DataTransferMessages.WizardProjectsImportPage_RootSelectTitle"));
    this.directoryPathField = new Text(projectGroup, SWT.BORDER);
    String arcFileName = null;
    if (selection != null && selection.getFirstElement() instanceof RepositoryNode) {
        RepositoryNode node = (RepositoryNode) selection.getFirstElement();
        if (node.getObject() == null) {
            arcFileName = node.getLabel();
        } else {
            arcFileName = node.getObject().getLabel();
        }
    }
    this.directoryPathField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    String exportDirPath = reloadExportPath(DIRECTORY_PATH);
    if (exportDirPath != null) {
        if (arcFileName != null) {
            if (new Path(exportDirPath).lastSegment() != null && !new Path(exportDirPath).lastSegment().equals(arcFileName)) {
                exportDirPath = exportDirPath + File.separator + arcFileName;
            }
        }
        this.directoryPathField.setText(exportDirPath);
        this.lastPath = exportDirPath;
    }
    browseDirectoriesButton = new Button(projectGroup, SWT.PUSH);
    // browseDirectoriesButton.setText(DataTransferMessages.DataTransfer_browse);
    //$NON-NLS-1$
    browseDirectoriesButton.setText(Messages.getString("DataTransferMessages.DataTransfer_browse"));
    setButtonLayoutData(browseDirectoriesButton);
    // new project from archive radio button
    itemFromArchiveRadio = new Button(projectGroup, SWT.RADIO);
    // itemFromArchiveRadio.setText(DataTransferMessages.WizardProjectsImportPage_ArchiveSelectTitle);
    //$NON-NLS-1$
    itemFromArchiveRadio.setText(Messages.getString("DataTransferMessages.WizardProjectsImportPage_ArchiveSelectTitle"));
    // project location entry field
    archivePathField = new Text(projectGroup, SWT.BORDER);
    archivePathField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    if (arcFileName != null) {
        String exportArchivePath = reloadExportPath(ARCHIVE_PATH);
        // when first open the exportItem dialog ,the exportPath maybe empty,need judge
        if (exportArchivePath != null && exportArchivePath.trim().length() > 0) {
            File beforeExportArchiveFolder = new File(exportArchivePath).getParentFile();
            /*
                 * TDI-22791, when the exportArchivePath is only name without path. No need check the existed or not.
                 * Because will be create the parent folders, when export item.
                 */
            if (beforeExportArchiveFolder != null) /* && beforeExportArchiveFolder.exists() */
            {
                String newPath = new File(beforeExportArchiveFolder, arcFileName + FileConstants.ZIP_FILE_SUFFIX).getAbsolutePath();
                this.archivePathField.setText(newPath);
            }
        } else if (exportDirPath != null && exportDirPath.trim().length() > 0) {
            String newPath = exportDirPath + File.separator + arcFileName + FileConstants.ZIP_FILE_SUFFIX;
            this.archivePathField.setText(newPath);
        }
    }
    // browse button
    browseArchivesButton = new Button(projectGroup, SWT.PUSH);
    // browseArchivesButton.setText(DataTransferMessages.DataTransfer_browse);
    //$NON-NLS-1$
    browseArchivesButton.setText(Messages.getString("DataTransferMessages.DataTransfer_browse"));
    setButtonLayoutData(browseArchivesButton);
    itemFromDirectoryRadio.setSelection(true);
    archivePathField.setEnabled(false);
    browseArchivesButton.setEnabled(false);
    browseDirectoriesButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            handleLocationDirectoryButtonPressed();
        }
    });
    browseArchivesButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            handleLocationArchiveButtonPressed();
        }
    });
    directoryPathField.addTraverseListener(new TraverseListener() {

        @Override
        public void keyTraversed(TraverseEvent e) {
            if (e.detail == SWT.TRAVERSE_RETURN) {
                e.doit = false;
                lastPath = directoryPathField.getText().trim();
            }
        }
    });
    directoryPathField.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(org.eclipse.swt.events.FocusEvent e) {
            lastPath = directoryPathField.getText().trim();
        }
    });
    directoryPathField.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            String exportPath = resetExportPath(directoryPathField.getText());
            saveExportPath(DIRECTORY_PATH, exportPath);
        }
    });
    archivePathField.addTraverseListener(new TraverseListener() {

        @Override
        public void keyTraversed(TraverseEvent e) {
            if (e.detail == SWT.TRAVERSE_RETURN) {
                e.doit = false;
                lastPath = archivePathField.getText().trim();
            }
        }
    });
    archivePathField.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(org.eclipse.swt.events.FocusEvent e) {
            lastPath = archivePathField.getText().trim();
        }
    });
    archivePathField.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            saveExportPath(ARCHIVE_PATH, archivePathField.getText());
        }
    });
    itemFromDirectoryRadio.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            directoryRadioSelected();
        }
    });
    itemFromArchiveRadio.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            archiveRadioSelected();
        }
    });
    exportDependencies = new Button(workArea, SWT.CHECK);
    //$NON-NLS-1$
    exportDependencies.setText(Messages.getString("ExportItemWizardPage.exportDependenciesText"));
    exportDependencies.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            checkedDependency.clear();
            implicitDependences.clear();
            CheckboxTreeViewer exportItemsTreeViewer = getItemsTreeViewer();
            Set allNode = new HashSet();
            if (exportDependencies.getSelection()) {
                refreshExportDependNodes();
                exportDependenciesSelected();
                allNode.addAll(checkedDependency);
                allNode.addAll(implicitDependences);
            } else {
                allNode.addAll(initcheckedNodes);
            }
            Set toselect = new HashSet();
            for (Object obj : allNode) {
                ERepositoryObjectType objectType = getObjectType(obj);
                expandRoot(objectType);
                expandParent(exportItemsTreeViewer, obj, objectType);
                checkElement(obj, toselect);
            }
            exportItemsTreeViewer.setCheckedElements(toselect.toArray());
            if (!exportDependencies.getSelection()) {
                for (Object unchecked : uncheckedNodes) {
                    exportItemsTreeViewer.setChecked(unchecked, false);
                }
            }
        }
    });
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) TraverseEvent(org.eclipse.swt.events.TraverseEvent) Set(java.util.Set) HashSet(java.util.HashSet) ModifyListener(org.eclipse.swt.events.ModifyListener) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) HashSet(java.util.HashSet) IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) Composite(org.eclipse.swt.widgets.Composite) TraverseListener(org.eclipse.swt.events.TraverseListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) GridData(org.eclipse.swt.layout.GridData) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) File(java.io.File)

Aggregations

CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)25 Composite (org.eclipse.swt.widgets.Composite)14 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)8 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)8 GridData (org.eclipse.swt.layout.GridData)8 GridLayout (org.eclipse.swt.layout.GridLayout)7 Label (org.eclipse.swt.widgets.Label)7 RepositoryNode (org.talend.repository.model.RepositoryNode)7 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)6 SelectionEvent (org.eclipse.swt.events.SelectionEvent)6 Button (org.eclipse.swt.widgets.Button)6 Viewer (org.eclipse.jface.viewers.Viewer)5 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)4 ArrayList (java.util.ArrayList)4 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)4 ModifyEvent (org.eclipse.swt.events.ModifyEvent)4 ModifyListener (org.eclipse.swt.events.ModifyListener)4 Text (org.eclipse.swt.widgets.Text)4 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)4