Search in sources :

Example 6 with TraverseEvent

use of org.eclipse.swt.events.TraverseEvent 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)

Example 7 with TraverseEvent

use of org.eclipse.swt.events.TraverseEvent in project tdi-studio-se by Talend.

the class ExpressionCellEditor method createText.

public Text createText(Composite parent) {
    text = new Text(parent, SWT.NONE);
    text.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            handleDefaultSelection(e);
        }
    });
    text.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent e) {
            if (e.detail == SWT.TRAVERSE_ESCAPE || e.detail == SWT.TRAVERSE_RETURN) {
                e.doit = false;
            }
        }
    });
    // We really want a selection listener but it is not supported so we
    // use a key listener and a mouse listener to know when selection
    // changes
    // may have occured
    text.addMouseListener(new MouseAdapter() {

        public void mouseDown(MouseEvent e) {
            highlightLineAndSetSelectionOfStyledTextFromTextControl(text);
        }

        @Override
        public void mouseUp(MouseEvent e) {
            checkSelection();
            checkDeleteable();
            checkSelectable();
        }
    });
    text.setFont(parent.getFont());
    text.setBackground(parent.getBackground());
    //$NON-NLS-1$
    text.setText("");
    text.addModifyListener(getModifyListener());
    return text;
}
Also used : TraverseEvent(org.eclipse.swt.events.TraverseEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) TraverseListener(org.eclipse.swt.events.TraverseListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MouseAdapter(org.eclipse.swt.events.MouseAdapter) StyledText(org.eclipse.swt.custom.StyledText) UnnotifiableColorStyledText(org.talend.commons.ui.swt.colorstyledtext.UnnotifiableColorStyledText) Text(org.eclipse.swt.widgets.Text)

Example 8 with TraverseEvent

use of org.eclipse.swt.events.TraverseEvent in project tdi-studio-se by Talend.

the class MultiPageSqlBuilderEditor method createContainer.

private CTabFolder createContainer(Composite parent) {
    // use SWT.FLAT style so that an extra 1 pixel border is not reserved
    // inside the folder
    parent.setLayout(new FillLayout());
    final CTabFolder newContainer = new CTabFolder(parent, SWT.BOTTOM | SWT.FLAT);
    newContainer.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            int newPageIndex = newContainer.indexOf((CTabItem) e.item);
            pageChange(newPageIndex);
        }
    });
    newContainer.addTraverseListener(new TraverseListener() {

        // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=199499 : Switching tabs by Ctrl+PageUp/PageDown must not be caught on the inner tab set
        @Override
        public void keyTraversed(TraverseEvent e) {
            switch(e.detail) {
                case SWT.TRAVERSE_PAGE_NEXT:
                case SWT.TRAVERSE_PAGE_PREVIOUS:
                    int detail = e.detail;
                    e.doit = true;
                    e.detail = SWT.TRAVERSE_NONE;
                    Control control = newContainer.getParent();
                    do {
                        if (control.traverse(detail))
                            return;
                        if (control.getListeners(SWT.Traverse).length != 0)
                            return;
                        if (control instanceof Shell)
                            return;
                        control = control.getParent();
                    } while (control != null);
            }
        }
    });
    return newContainer;
}
Also used : Control(org.eclipse.swt.widgets.Control) Shell(org.eclipse.swt.widgets.Shell) CTabFolder(org.eclipse.swt.custom.CTabFolder) TraverseEvent(org.eclipse.swt.events.TraverseEvent) TraverseListener(org.eclipse.swt.events.TraverseListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FillLayout(org.eclipse.swt.layout.FillLayout) CTabItem(org.eclipse.swt.custom.CTabItem)

Example 9 with TraverseEvent

use of org.eclipse.swt.events.TraverseEvent in project cubrid-manager by CUBRID.

the class JdbcOptionComposite method focusCell.

public void focusCell(final TableItem item, final int row, final int col) {
    final StyledText text = new StyledText(jdbcInfoTv.getTable(), SWT.SINGLE);
    Listener textListener = new TableItemEditor(text, item, row, col);
    text.addListener(SWT.FocusOut, textListener);
    text.addListener(SWT.Traverse, textListener);
    text.addListener(SWT.FocusIn, textListener);
    text.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent e) {
            if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
                e.doit = false;
                int newColumn = col == 0 ? 1 : 0;
                focusCell(item, row, newColumn);
            } else if (e.detail == SWT.TRAVERSE_RETURN) {
                e.doit = false;
                addButton.setFocus();
            }
        }
    });
    text.setEditable(true);
    editor.setEditor(text, item, col);
    text.setText(item.getText(col));
    text.selectAll();
    try {
        text.setFocus();
    } catch (Exception e) {
    }
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) Listener(org.eclipse.swt.widgets.Listener) TraverseListener(org.eclipse.swt.events.TraverseListener) MouseListener(org.eclipse.swt.events.MouseListener) TraverseEvent(org.eclipse.swt.events.TraverseEvent) TraverseListener(org.eclipse.swt.events.TraverseListener)

Example 10 with TraverseEvent

use of org.eclipse.swt.events.TraverseEvent in project cubrid-manager by CUBRID.

the class PstmtOneDataDialog method handleValueInPlace.

/**
	 * 
	 * Edit value in place
	 * 
	 * @param item TableItem
	 */
private void handleValueInPlace(final TableItem item) {
    final Text newEditor = new Text(parameterTable, SWT.MULTI | SWT.WRAP);
    final int editColumn = 2;
    newEditor.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            if (!validate(newEditor.getText(), item)) {
                getButton(IDialogConstants.OK_ID).setEnabled(false);
            }
        }
    });
    newEditor.addFocusListener(new FocusAdapter() {

        public void focusLost(FocusEvent event) {
            if (isChanging) {
                return;
            }
            isChanging = true;
            if (validate(newEditor.getText(), item)) {
                item.setText(editColumn, newEditor.getText());
            }
            newEditor.dispose();
            isChanging = false;
            packTable();
            validate();
        }
    });
    // add listener for key pressed
    newEditor.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent event) {
            if (event.detail == SWT.TRAVERSE_RETURN) {
                if (isChanging) {
                    return;
                }
                isChanging = true;
                if (validate(newEditor.getText(), item)) {
                    item.setText(editColumn, newEditor.getText());
                }
                newEditor.dispose();
                isChanging = false;
                packTable();
                validate();
                event.doit = true;
                int selItem = 0;
                for (int i = 0; i < parameterTable.getItemCount(); i++) {
                    if (item == parameterTable.getItem(i)) {
                        selItem = i;
                        break;
                    }
                }
                selItem = selItem + 1;
                if (selItem >= parameterTable.getItemCount()) {
                    getButton(IDialogConstants.OK_ID).setFocus();
                } else {
                    handleType(parameterTable.getItem(selItem));
                }
            } else if (event.detail == SWT.TRAVERSE_ESCAPE) {
                if (isChanging) {
                    return;
                }
                isChanging = true;
                newEditor.dispose();
                event.doit = false;
                isChanging = false;
            }
        }
    });
    tableEditor.setEditor(newEditor, item, editColumn);
    newEditor.setText(item.getText(editColumn));
    newEditor.selectAll();
    newEditor.setFocus();
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) ModifyEvent(org.eclipse.swt.events.ModifyEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) TraverseListener(org.eclipse.swt.events.TraverseListener) Text(org.eclipse.swt.widgets.Text) FocusEvent(org.eclipse.swt.events.FocusEvent)

Aggregations

TraverseEvent (org.eclipse.swt.events.TraverseEvent)26 TraverseListener (org.eclipse.swt.events.TraverseListener)26 FocusAdapter (org.eclipse.swt.events.FocusAdapter)9 FocusEvent (org.eclipse.swt.events.FocusEvent)8 SelectionEvent (org.eclipse.swt.events.SelectionEvent)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)7 Text (org.eclipse.swt.widgets.Text)7 StyledText (org.eclipse.swt.custom.StyledText)6 ModifyEvent (org.eclipse.swt.events.ModifyEvent)6 ModifyListener (org.eclipse.swt.events.ModifyListener)6 MouseEvent (org.eclipse.swt.events.MouseEvent)6 Point (org.eclipse.swt.graphics.Point)6 Button (org.eclipse.swt.widgets.Button)6 KeyEvent (org.eclipse.swt.events.KeyEvent)5 MouseAdapter (org.eclipse.swt.events.MouseAdapter)5 Composite (org.eclipse.swt.widgets.Composite)5 GridData (org.eclipse.swt.layout.GridData)4 Label (org.eclipse.swt.widgets.Label)4 ComboWithEnableFix (edu.cmu.cs.hcii.cogtool.util.ComboWithEnableFix)3 TextWithEnableFix (edu.cmu.cs.hcii.cogtool.util.TextWithEnableFix)3