Search in sources :

Example 11 with ControlEvent

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

the class VersionManagementPage method createItemTableColumns.

@Override
protected void createItemTableColumns() {
    TableColumn itemColumn = new TableColumn(itemTable, SWT.CENTER);
    //$NON-NLS-1$
    itemColumn.setText(Messages.getString("VersionManagementDialog.Items"));
    itemColumn.setWidth(110);
    TableColumn oldVersionColumn = new TableColumn(itemTable, SWT.CENTER);
    //$NON-NLS-1$
    oldVersionColumn.setText(Messages.getString("VersionManagementDialog.Version"));
    oldVersionColumn.setWidth(60);
    TableColumn versionColumn = new TableColumn(itemTable, SWT.CENTER);
    //$NON-NLS-1$
    versionColumn.setText(Messages.getString("VersionManagementDialog.NewVersion"));
    versionColumn.setWidth(82);
    final TableColumn delColumn = new TableColumn(itemTable, SWT.CENTER);
    //$NON-NLS-1$
    delColumn.setText("");
    delColumn.setWidth(26);
    delColumn.setResizable(false);
    versionColumn.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            if (!isFixedVersion()) {
                refreshTableItems();
            }
        }
    });
    itemTable.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            checkButtonsState();
        }
    });
}
Also used : ControlAdapter(org.eclipse.swt.events.ControlAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlEvent(org.eclipse.swt.events.ControlEvent) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 12 with ControlEvent

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

the class DataMapTableView method createExpressionCellEditor.

protected TextCellEditor createExpressionCellEditor(final TableViewerCreator tableViewerCreator, TableViewerCreatorColumn column, final Zone[] zones, boolean isConstraintExpressionCellEditor) {
    final TextCellEditorWithProposal cellEditor = new TextCellEditorWithProposal(tableViewerCreator.getTable(), SWT.MULTI | SWT.BORDER, column);
    final Text expressionTextEditor = (Text) cellEditor.getControl();
    if (isConstraintExpressionCellEditor) {
    // moved to it's caller to execute
    // constraintExpressionTextEditor = expressionTextEditor;
    } else {
        columnExpressionTextEditor = expressionTextEditor;
    }
    cellEditor.addListener(new ICellEditorListener() {

        Text text = (Text) cellEditor.getControl();

        @Override
        public void applyEditorValue() {
            ModifiedObjectInfo modifiedObjectInfo = tableViewerCreator.getModifiedObjectInfo();
            mapperManager.getUiManager().parseNewExpression(text.getText(), (ITableEntry) modifiedObjectInfo.getCurrentModifiedBean(), true);
        }

        @Override
        public void cancelEditor() {
            ModifiedObjectInfo modifiedObjectInfo = tableViewerCreator.getModifiedObjectInfo();
            text.setText((String) modifiedObjectInfo.getOriginalPropertyBeanValue());
            ITableEntry tableEntry = (ITableEntry) (modifiedObjectInfo.getCurrentModifiedBean() != null ? modifiedObjectInfo.getCurrentModifiedBean() : modifiedObjectInfo.getPreviousModifiedBean());
            String originalExpression = (String) modifiedObjectInfo.getOriginalPropertyBeanValue();
            mapperManager.getUiManager().parseNewExpression(originalExpression, tableEntry, true);
        }

        @Override
        public void editorValueChanged(boolean oldValidState, boolean newValidState) {
            if (expressionTextEditor.isFocusControl() || lastExpressionEditorTextWhichLostFocus == expressionTextEditor) {
                ModifiedObjectInfo modifiedObjectInfo = tableViewerCreator.getModifiedObjectInfo();
                ITableEntry tableEntry = (ITableEntry) (modifiedObjectInfo.getCurrentModifiedBean() != null ? modifiedObjectInfo.getCurrentModifiedBean() : modifiedObjectInfo.getPreviousModifiedBean());
                mapperManager.getUiManager().parseNewExpression(text.getText(), tableEntry, false);
                resizeTextEditor(text, tableViewerCreator);
            }
        }
    });
    expressionTextEditor.addControlListener(new ControlListener() {

        ExecutionLimiter executionLimiter = null;

        @Override
        public void controlMoved(ControlEvent e) {
        }

        @Override
        public void controlResized(ControlEvent e) {
            if (executionLimiter == null) {
                executionLimiter = new ExecutionLimiter(50, true) {

                    @Override
                    public void execute(boolean isFinalExecution, Object data) {
                        if (isFinalExecution && !expressionTextEditor.isDisposed()) {
                            expressionTextEditor.getDisplay().syncExec(new Runnable() {

                                @Override
                                public void run() {
                                    if (expressionTextEditor.isDisposed()) {
                                        return;
                                    }
                                    resizeTextEditor(expressionTextEditor, tableViewerCreator);
                                }
                            });
                        }
                    }
                };
            }
            executionLimiter.startIfExecutable();
        }
    });
    expressionTextEditor.addFocusListener(new FocusListener() {

        @Override
        public void focusGained(FocusEvent e) {
            ITableEntry currentModifiedEntry = (ITableEntry) tableViewerCreator.getModifiedObjectInfo().getCurrentModifiedBean();
            initExpressionProposals(cellEditor, zones, tableViewerCreator, currentModifiedEntry);
            resizeTextEditor(expressionTextEditor, tableViewerCreator);
            StyledTextHandler styledTextHandler = mapperManager.getUiManager().getTabFolderEditors().getStyledTextHandler();
            styledTextHandler.setCurrentEntry(currentModifiedEntry);
            //$NON-NLS-1$
            styledTextHandler.setTextWithoutNotifyListeners(currentModifiedEntry.getExpression() == null ? "" : currentModifiedEntry.getExpression());
        }

        @Override
        public void focusLost(FocusEvent e) {
            expressionEditorTextSelectionBeforeFocusLost = expressionTextEditor.getSelection();
            lastExpressionEditorTextWhichLostFocus = expressionTextEditor;
        }
    });
    column.setCellEditor(cellEditor, new CellEditorValueAdapter() {

        @Override
        public Object getCellEditorTypedValue(CellEditor cellEditor, Object originalTypedValue) {
            return super.getCellEditorTypedValue(cellEditor, originalTypedValue);
        }

        @Override
        public String getColumnText(CellEditor cellEditor, Object bean, Object cellEditorTypedValue) {
            //$NON-NLS-1$ //$NON-NLS-2$
            return super.getColumnText(cellEditor, bean, cellEditorTypedValue).replaceAll("[\r\n\t]+", " ... ");
        }

        @Override
        public Object getOriginalTypedValue(CellEditor cellEditor, Object cellEditorTypedValue) {
            return super.getOriginalTypedValue(cellEditor, cellEditorTypedValue);
        }
    });
    return cellEditor;
}
Also used : TextCellEditorWithProposal(org.talend.commons.ui.swt.proposal.TextCellEditorWithProposal) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) StyledTextHandler(org.talend.designer.dbmap.ui.tabs.StyledTextHandler) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) CellEditorValueAdapter(org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) UnnotifiableColorStyledText(org.talend.commons.ui.swt.colorstyledtext.UnnotifiableColorStyledText) FocusEvent(org.eclipse.swt.events.FocusEvent) ICellEditorListener(org.eclipse.jface.viewers.ICellEditorListener) ControlListener(org.eclipse.swt.events.ControlListener) ModifiedObjectInfo(org.talend.commons.ui.runtime.swt.tableviewer.data.ModifiedObjectInfo) ExecutionLimiter(org.talend.commons.utils.threading.ExecutionLimiter) ControlEvent(org.eclipse.swt.events.ControlEvent) FocusListener(org.eclipse.swt.events.FocusListener)

Example 13 with ControlEvent

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

the class RowGeneratorUI method addParentListeners.

/**
     * qzhang Comment method "addParentListeners".
     * 
     * @param uiManager
     * @param uiProperties
     */
private void addParentListeners(final UIManager uiManager, final ExternalRowGeneratorUiProperties uiProperties) {
    rowGenUIParent.addListener(SWT.Close, new Listener() {

        @Override
        public void handleEvent(Event event) {
            if (uiManager.getRowGenResponse() == SWT.NONE) {
                uiManager.closeRowGenerator(SWT.CANCEL, false);
            }
        }
    });
    rowGenUIParent.addFocusListener(new FocusListener() {

        @Override
        public void focusGained(FocusEvent e) {
            updateBackground(false, true);
        }

        @Override
        public void focusLost(FocusEvent e) {
        }
    });
    // store size if not maximized
    if (rowGenUIParent instanceof Shell) {
        ((Shell) rowGenUIParent).addControlListener(new ControlListener() {

            @Override
            public void controlMoved(ControlEvent e) {
            }

            @Override
            public void controlResized(ControlEvent e) {
                if (!((Shell) e.getSource()).getMaximized()) {
                    ExternalRowGeneratorUiProperties.setBoundsRowGen(((Shell) e.getSource()).getBounds());
                }
            }
        });
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) DisposeListener(org.eclipse.swt.events.DisposeListener) ControlListener(org.eclipse.swt.events.ControlListener) FocusListener(org.eclipse.swt.events.FocusListener) Listener(org.eclipse.swt.widgets.Listener) IModifiedBeanListener(org.talend.commons.ui.swt.tableviewer.IModifiedBeanListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) Event(org.eclipse.swt.widgets.Event) ControlEvent(org.eclipse.swt.events.ControlEvent) ModifiedBeanEvent(org.talend.commons.ui.swt.tableviewer.ModifiedBeanEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlListener(org.eclipse.swt.events.ControlListener) ControlEvent(org.eclipse.swt.events.ControlEvent) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 14 with ControlEvent

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

the class BrokerDashboardViewPart method createPartControl.

/**
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 * 
	 * @param parent the parent composite
	 */
public void createPartControl(Composite parent) {
    final ScrolledComposite scrolledComp = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
    composite = new Composite(scrolledComp, SWT.NONE);
    composite.setLayout(new GridLayout());
    BrokerTblColumnSetHelp bcsh = BrokerTblColumnSetHelp.getInstance();
    bcsh.loadSetting(BrokerTblColumnSetHelp.StatusColumn.BrokerStatusBasicColumn, BrokerStatusBasicColumn.values());
    bcsh.loadSetting(BrokerTblColumnSetHelp.StatusColumn.BrokerStatusAsColumn, BrokerStatusAsColumn.values());
    bcsh.loadSetting(BrokerTblColumnSetHelp.StatusColumn.BrokerStatusJqColumn, BrokerStatusJqColumn.values());
    brokerTablePart.setServerInfo(serverInfo);
    brokerTablePart.setAppendDiag(true);
    basicTableViewer = brokerTablePart.createBasicTable(composite);
    asTableViewer = brokerTablePart.createAsTable(composite);
    jqTableViewer = brokerTablePart.createJobTable(composite);
    makeActions();
    composite.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent event) {
            updateTableLayout();
        }
    });
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            IStructuredSelection selection = (IStructuredSelection) asTableViewer.getSelection();
            ApplyServerInfo as = (ApplyServerInfo) (selection.toArray()[0]);
            RestartAction restartAcion = new RestartAction(as.getAs_id());
            manager.add(restartAcion);
        }
    });
    Menu contextMenu = menuManager.createContextMenu(asTableViewer.getControl());
    asTableViewer.getControl().setMenu(contextMenu);
    scrolledComp.setContent(composite);
    scrolledComp.setExpandHorizontal(true);
    scrolledComp.setExpandVertical(true);
    scrolledComp.setMinHeight(300);
    scrolledComp.setMinWidth(800);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) IMenuListener(org.eclipse.jface.action.IMenuListener) GridLayout(org.eclipse.swt.layout.GridLayout) BrokerTblColumnSetHelp(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerTblColumnSetHelp) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 15 with ControlEvent

use of org.eclipse.swt.events.ControlEvent in project MonjaDB by Kanatoko.

the class MActionView method init2.

//--------------------------------------------------------------------------------
public void init2() {
    parent.setLayout(new FormLayout());
    sashForm = new SashForm(parent, SWT.SMOOTH | SWT.VERTICAL);
    FormData fd_sashForm1 = new FormData();
    fd_sashForm1.top = new FormAttachment(0, 1);
    fd_sashForm1.left = new FormAttachment(0, 1);
    fd_sashForm1.right = new FormAttachment(100, -1);
    fd_sashForm1.bottom = new FormAttachment(100, -1);
    sashForm.setLayoutData(fd_sashForm1);
    table = new Table(sashForm, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    table.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            onTableStateChange();
        }
    });
    table.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            if (e.keyCode == 13) {
                e.doit = false;
                if (//Shift + Enter
                (e.stateMask & SWT.SHIFT) != 0) {
                    repeatActionsOnTable();
                } else {
                    editActions();
                }
            }
        }
    });
    FormData fd_table = new FormData();
    fd_table.top = new FormAttachment(0, 0);
    fd_table.bottom = new FormAttachment(100, 0);
    fd_table.left = new FormAttachment(0, 0);
    fd_table.right = new FormAttachment(100, 0);
    table.setLayoutData(fd_table);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    TableColumn actionColumn = new TableColumn(table, SWT.NONE);
    actionColumn.setWidth(100);
    actionColumn.setText("Action");
    TableColumn dateColumn = new TableColumn(table, SWT.NONE);
    dateColumn.setWidth(100);
    dateColumn.setText("Date");
    editorComposite = new Composite(sashForm, SWT.BORDER);
    editorComposite.setLayout(new FormLayout());
    text = new Text(editorComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
    text.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            onTextStateChange();
        }
    });
    FormData fd_text = new FormData();
    fd_text.bottom = new FormAttachment(100, -40);
    fd_text.right = new FormAttachment(100);
    fd_text.top = new FormAttachment(0);
    fd_text.left = new FormAttachment(0);
    text.setLayoutData(fd_text);
    executeButton = new Button(editorComposite, SWT.NONE);
    executeButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            executeActionsOnText();
        }
    });
    executeButton.setEnabled(false);
    FormData fd_executeButton = new FormData();
    fd_executeButton.top = new FormAttachment(text, 6);
    fd_executeButton.left = new FormAttachment(text, -120, SWT.RIGHT);
    fd_executeButton.right = new FormAttachment(100, -10);
    executeButton.setLayoutData(fd_executeButton);
    executeButton.setText("Execute");
    editorComposite.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent e) {
            onSashResize();
        }
    });
    MSwtUtil.getTableColumnWidthFromProperties("actionListTable", table, prop, new int[] { 200, 100 });
    MSwtUtil.addListenerToTableColumns2(table, this);
    //table.addListener( SWT.KeyDown, this );
    table.addListener(SWT.MouseDoubleClick, this);
    menuManager = new MenuManager();
    Menu contextMenu = menuManager.createContextMenu(table);
    table.setMenu(contextMenu);
    //executeTableAction
    {
        redoAction = new Action() {

            public void run() {
                //------------
                repeatActionsOnTable();
            }
        };
        //------------
        redoAction.setToolTipText("Redo Selected Actions");
        redoAction.setText("Redo\tShift+Enter");
        initAction(redoAction, "table_go.png", menuManager);
        redoAction.setEnabled(false);
    }
    //editAction
    {
        editAction = new Action() {

            public void run() {
                //------------
                editActions();
            }
        };
        //------------
        editAction.setToolTipText("Edit Actions on The Text Editor");
        editAction.setText("Edit\tEnter");
        initAction(editAction, "pencil.png", menuManager);
        editAction.setEnabled(false);
    }
    dropDownMenu.add(new Separator());
    menuManager.add(new Separator());
    //executeAction
    {
        executeAction = new Action() {

            public void run() {
                //------------
                executeActionsOnText();
            }
        };
        //------------
        executeAction.setToolTipText("Execute Actions on the Textarea");
        executeAction.setText("Execute");
        setActionImage(executeAction, "bullet_go.png");
        addActionToToolBar(executeAction);
        executeAction.setEnabled(false);
        dropDownMenu.add(executeAction);
    }
    dropDownMenu.add(new Separator());
    menuManager.add(new Separator());
    //copyAction
    {
        copyAction = new Action() {

            public void run() {
                //------------
                copyActions();
            }
        };
        //------------
        copyAction.setToolTipText("Copy Actions to Clipboard");
        copyAction.setText("Copy");
        setActionImage(copyAction, "page_copy.png");
        addActionToToolBar(copyAction);
        copyAction.setEnabled(false);
        dropDownMenu.add(copyAction);
        menuManager.add(copyAction);
    }
    dropDownMenu.add(new Separator());
    menuManager.add(new Separator());
    //clearAction
    {
        clearAction = new Action() {

            public void run() {
                //------------
                clearActions();
            }
        };
        //------------
        clearAction.setToolTipText("Clear All");
        clearAction.setText("Clear All");
        initAction(clearAction, "table_delete.png", menuManager);
        clearAction.setEnabled(false);
    }
    //saveAction
    {
        saveAction = new Action() {

            public void run() {
                //------------
                saveActions();
            }
        };
        //------------
        saveAction.setToolTipText("Save Action");
        saveAction.setText("Save");
        initAction(saveAction, "cog_add.png", menuManager);
        saveAction.setEnabled(false);
    }
    //load actionLogList
    if (prop.containsKey(ACTION_LOG_LIST)) {
        String savedStr = prop.getProperty(ACTION_LOG_LIST);
        actionLogList = (java.util.List) JSON.parse(savedStr);
        for (int i = 0; i < actionLogList.size(); ++i) {
            Map actionLog = (Map) actionLogList.get(i);
            addActionToTable(actionLog);
        }
    } else {
        actionLogList = new LinkedList();
    }
    if (prop.containsKey(ACTIONLOG_COMPOSITE_WEIGHT)) {
        (new Thread() {

            public void run() {
                MSystemUtil.sleep(0);
                shell.getDisplay().asyncExec(new Runnable() {

                    public void run() {
                        //----
                        sashForm.setWeights(prop.getIntArrayProperty(ACTIONLOG_COMPOSITE_WEIGHT));
                    }
                });
            //----
            }
        }).start();
    } else {
        sashForm.setWeights(new int[] { 70, 30 });
    }
    initializedTime = System.currentTimeMillis();
}
Also used : MEditAction(net.jumperz.app.MMonjaDBCore.action.mj.MEditAction) Action(org.eclipse.jface.action.Action) ModifyListener(org.eclipse.swt.events.ModifyListener) ControlAdapter(org.eclipse.swt.events.ControlAdapter) KeyAdapter(org.eclipse.swt.events.KeyAdapter) KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) TableColumn(org.eclipse.swt.widgets.TableColumn) SashForm(org.eclipse.swt.custom.SashForm) java.util(java.util) MenuManager(org.eclipse.jface.action.MenuManager) ControlEvent(org.eclipse.swt.events.ControlEvent) Separator(org.eclipse.jface.action.Separator)

Aggregations

ControlEvent (org.eclipse.swt.events.ControlEvent)62 ControlListener (org.eclipse.swt.events.ControlListener)34 ControlAdapter (org.eclipse.swt.events.ControlAdapter)28 SelectionEvent (org.eclipse.swt.events.SelectionEvent)20 GridData (org.eclipse.swt.layout.GridData)20 Composite (org.eclipse.swt.widgets.Composite)20 GridLayout (org.eclipse.swt.layout.GridLayout)15 Point (org.eclipse.swt.graphics.Point)14 DisposeEvent (org.eclipse.swt.events.DisposeEvent)11 FocusEvent (org.eclipse.swt.events.FocusEvent)11 Control (org.eclipse.swt.widgets.Control)11 Event (org.eclipse.swt.widgets.Event)11 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)10 DisposeListener (org.eclipse.swt.events.DisposeListener)10 ModifyEvent (org.eclipse.swt.events.ModifyEvent)10 MouseEvent (org.eclipse.swt.events.MouseEvent)10 Listener (org.eclipse.swt.widgets.Listener)10 Shell (org.eclipse.swt.widgets.Shell)10 TableColumn (org.eclipse.swt.widgets.TableColumn)10 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)9