Search in sources :

Example 1 with VerifyEvent

use of org.eclipse.swt.events.VerifyEvent in project cogtool by cogtool.

the class ActionSet method createTransitionName.

private Text createTransitionName(Composite parent, String txt) {
    final Text name = new Text(parent, SWT.BORDER);
    final NameInfo info = new NameInfo(txt);
    // Note that we have to use a VerifyListener to prevent editing the
    // contents of the Text, as SWT has made the rather surprising decision
    // that setting its editable field to false also
    // takes away our ability to select and navigate in the field, and copy
    // its contents. Grr.
    name.addVerifyListener(new VerifyListener() {

        public void verifyText(VerifyEvent evt) {
            // the user's trying to modify an already populated Text. Yuk.
            switch(transitionNameState) {
                case NORMAL:
                    info.fullName = evt.text;
                    evt.text = SWTStringUtil.insertEllipsis(info.fullName, name.getSize().x, StringUtil.EQUAL, name.getFont());
                    break;
                case HAS_FOCUS:
                    evt.doit = false;
                    break;
                case GAINING_FOCUS:
                    break;
            }
        }
    });
    name.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent evt) {
            transitionNameState = TransitionNameState.GAINING_FOCUS;
            name.setText(info.fullName);
            transitionNameState = TransitionNameState.HAS_FOCUS;
        }

        @Override
        public void focusLost(FocusEvent evt) {
            transitionNameState = TransitionNameState.NORMAL;
            name.setText(info.fullName);
        }
    });
    name.setText(txt);
    return name;
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) VerifyListener(org.eclipse.swt.events.VerifyListener) ManagedText(edu.cmu.cs.hcii.cogtool.util.ManagedText) Text(org.eclipse.swt.widgets.Text) VerifyEvent(org.eclipse.swt.events.VerifyEvent) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 2 with VerifyEvent

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

the class StyledTextHandler method addListeners.

/**
     * DOC amaumont Comment method "addListeners".
     */
private void addListeners() {
    styledText.addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent e) {
            refreshProposalSize();
        }

        public void focusLost(FocusEvent e) {
        }
    });
    styledText.addControlListener(new ControlListener() {

        public void controlMoved(ControlEvent e) {
        }

        public void controlResized(ControlEvent e) {
            refreshProposalSize();
        }
    });
    styledText.addExtendedModifyListener(new ExtendedModifyListener() {

        public void modifyText(ExtendedModifyEvent event) {
            // System.out.println("ExtendedModifyListener modify text");
            updateCellExpression();
        }
    });
    styledText.getContent().addTextChangeListener(new TextChangeListener() {

        public void textChanged(TextChangedEvent event) {
            highlightLineOfCursorPosition(styledText.getSelection());
        }

        public void textChanging(TextChangingEvent event) {
        // System.out.println("textChanging");
        }

        public void textSet(TextChangedEvent event) {
        // System.out.println("textSet");
        }
    });
    styledText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            highlightLineOfCursorPosition(styledText.getSelection());
        }
    });
    styledText.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            highlightLineOfCursorPosition(styledText.getSelection());
        }

        public void keyReleased(KeyEvent e) {
        // TODO Auto-generated method stub
        }
    });
    styledText.addVerifyKeyListener(new VerifyKeyListener() {

        public void verifyKey(VerifyEvent verifyEvent) {
            if (verifyEvent.character == '\r' && contentProposalAdapter != null && contentProposalAdapter.isProposalOpened()) {
                verifyEvent.doit = false;
            } else {
                verifyEvent.doit = true;
            }
        }
    });
    styledText.addMouseListener(new MouseListener() {

        public void mouseDoubleClick(MouseEvent e) {
            highlightLineOfCursorPosition(styledText.getSelection());
        }

        public void mouseDown(MouseEvent e) {
            highlightLineOfCursorPosition(styledText.getSelection());
        }

        public void mouseUp(MouseEvent e) {
        }
    });
}
Also used : ExtendedModifyEvent(org.eclipse.swt.custom.ExtendedModifyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) ExtendedModifyListener(org.eclipse.swt.custom.ExtendedModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) ExtendedModifyListener(org.eclipse.swt.custom.ExtendedModifyListener) VerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener) TextChangingEvent(org.eclipse.swt.custom.TextChangingEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) TextChangedEvent(org.eclipse.swt.custom.TextChangedEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ExtendedModifyEvent(org.eclipse.swt.custom.ExtendedModifyEvent) MouseListener(org.eclipse.swt.events.MouseListener) ControlListener(org.eclipse.swt.events.ControlListener) VerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener) KeyListener(org.eclipse.swt.events.KeyListener) ControlEvent(org.eclipse.swt.events.ControlEvent) TextChangeListener(org.eclipse.swt.custom.TextChangeListener) FocusListener(org.eclipse.swt.events.FocusListener) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Example 3 with VerifyEvent

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

the class ReconcilerViewer method initializeViewer.

protected void initializeViewer(IDocument document) {
    fAnnotationPreferences = EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
    setDocument(document);
    installViewerConfiguration();
    setEditable(true);
    Font font = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT);
    getTextWidget().setFont(font);
    Control control = getControl();
    GridData data = new GridData(GridData.FILL_BOTH);
    control.setLayoutData(data);
    prependVerifyKeyListener(new VerifyKeyListener() {

        @Override
        public void verifyKey(VerifyEvent event) {
            handleVerifyKeyPressed(event);
        }
    });
    addDocumentListener(document);
    addMenu();
}
Also used : IInformationControl(org.eclipse.jface.text.IInformationControl) SourceViewerInformationControl(org.eclipse.jdt.internal.ui.text.java.hover.SourceViewerInformationControl) Control(org.eclipse.swt.widgets.Control) VerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener) GridData(org.eclipse.swt.layout.GridData) VerifyEvent(org.eclipse.swt.events.VerifyEvent) Font(org.eclipse.swt.graphics.Font)

Example 4 with VerifyEvent

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

the class BrokersParameterPropertyPage method initial.

/**
	 * Initializes the parameters of this dialog
	 */
private void initial() {
    oldConfParaMap = node.getServer().getServerInfo().getBrokerConfParaMap();
    Map<String, String> map = null;
    if (oldConfParaMap != null) {
        map = oldConfParaMap.get(ConfConstants.BROKER_SECTION_NAME);
    }
    if (map != null) {
        Iterator<Map.Entry<String, String>> it = map.entrySet().iterator();
        Map<String, String> defaultMap = new HashMap<String, String>();
        defaultValueMap.put(ConfConstants.BROKER_SECTION_NAME, defaultMap);
        while (it.hasNext()) {
            Map.Entry<String, String> entry = it.next();
            defaultMap.put(entry.getKey(), entry.getValue());
        }
        if (null == defaultMap.get(ConfConstants.MASTER_SHM_ID)) {
            masterShmIdTxt.setText("");
        } else {
            masterShmIdTxt.setText(defaultMap.get(ConfConstants.MASTER_SHM_ID));
        }
        if (null == defaultMap.get(ConfConstants.ADMIN_LOG_FILE)) {
            adminlogTxt.setText("");
        } else {
            adminlogTxt.setText(defaultMap.get(ConfConstants.ADMIN_LOG_FILE));
        }
        if (isSupportEnableAccessControl) {
            if (null == defaultMap.get(ConfConstants.ENABLE_ACCESS_CONTROL)) {
                enableAccessControlCombo.select(1);
            } else {
                enableAccessControlCombo.setText(defaultMap.get(ConfConstants.ENABLE_ACCESS_CONTROL));
            }
            if (null == defaultMap.get(ConfConstants.ACCESS_CONTROL_FILE)) {
                accessControlFileTxt.setText("");
            } else {
                accessControlFileTxt.setText(defaultMap.get(ConfConstants.ACCESS_CONTROL_FILE));
            }
        }
    }
    brokerList = new ArrayList<Map<String, String>>();
    if (oldConfParaMap == null) {
        return;
    }
    // set the broker list
    String[][] supportedBrokerParams = ConfConstants.getBrokerParameters(serverInfo);
    for (Map.Entry<String, Map<String, String>> brokerPara : oldConfParaMap.entrySet()) {
        if (brokerPara.getKey().equals(ConfConstants.BROKER_SECTION_NAME)) {
            continue;
        }
        String name = brokerPara.getKey();
        Map<String, String> pair = brokerPara.getValue();
        String port = pair.get(ConfConstants.BROKER_PORT);
        Map<String, String> dataMap = new HashMap<String, String>();
        dataMap.put("0", name);
        dataMap.put("1", port);
        for (int i = 0; i < supportedBrokerParams.length; i++) {
            String paramKey = supportedBrokerParams[i][0];
            String value = pair.get(paramKey);
            dataMap.put(paramKey, value);
        }
        brokerList.add(dataMap);
    }
    brokersTableViewer.setInput(brokerList);
    // initialize refresh
    BrokerIntervalSettingManager manager = BrokerIntervalSettingManager.getInstance();
    serverName = node.getServer().getLabel();
    brokerEnvName = node.getLabel();
    BrokerIntervalSetting setting = manager.getBrokerIntervalSetting(serverName, brokerEnvName);
    oldIntervalSettingMap = new HashMap<String, BrokerIntervalSetting>();
    newIntervalSettingMap = new HashMap<String, BrokerIntervalSetting>();
    if (null != setting) {
        boolean isOn = setting.isOn();
        refreshBtn.setSelection(isOn);
        intervalTxt.setText(setting.getInterval());
        intervalTxt.setEnabled(isOn);
        oldIntervalSettingMap.put(serverName + "_" + brokerEnvName, setting);
    }
    for (Map<String, String> dataMap : brokerList) {
        String brokername = dataMap.get("0");
        setting = manager.getBrokerIntervalSetting(serverName, brokername);
        if (null != setting) {
            oldIntervalSettingMap.put(serverName + "_" + brokername, setting);
        }
    }
    for (Map.Entry<String, BrokerIntervalSetting> entry : oldIntervalSettingMap.entrySet()) {
        String aSettingName = entry.getKey();
        BrokerIntervalSetting aSetting = new BrokerIntervalSetting();
        String aBrokerName = entry.getValue().getBrokerName();
        String aServerName = entry.getValue().getServerName();
        String aInterval = entry.getValue().getInterval();
        boolean aOn = entry.getValue().isOn();
        aSetting.setBrokerName(aBrokerName);
        aSetting.setServerName(aServerName);
        aSetting.setInterval(aInterval);
        aSetting.setOn(aOn);
        newIntervalSettingMap.put(aSettingName, aSetting);
    }
    // add Listener
    refreshBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            BrokerIntervalSetting brokerEnvSetting = newIntervalSettingMap.get(serverName + "_" + brokerEnvName);
            if (refreshBtn.getSelection()) {
                intervalTxt.setEnabled(true);
                brokerEnvSetting.setOn(true);
            } else {
                intervalTxt.setEnabled(false);
                brokerEnvSetting.setOn(false);
            }
        }
    });
    intervalTxt.addVerifyListener(new VerifyListener() {

        public void verifyText(VerifyEvent event) {
            if (!"".equals(event.text) && !ValidateUtil.isNumber(event.text)) {
                event.doit = false;
                return;
            }
        }
    });
    intervalTxt.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            String newInterval = intervalTxt.getText().trim();
            BrokerIntervalSetting brokerEnvSetting = newIntervalSettingMap.get(serverName + "_" + brokerEnvName);
            brokerEnvSetting.setInterval(newInterval);
        }
    });
}
Also used : BrokerIntervalSettingManager(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSettingManager) VerifyListener(org.eclipse.swt.events.VerifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) HashMap(java.util.HashMap) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Point(org.eclipse.swt.graphics.Point) BrokerIntervalSetting(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSetting) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Map(java.util.Map) HashMap(java.util.HashMap) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Example 5 with VerifyEvent

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

the class ConnectionComposite method createBrokerInfoGroup.

private void createBrokerInfoGroup(Composite composite) {
    Group brokerInfoGroup = new Group(composite, SWT.NONE);
    brokerInfoGroup.setText(Messages.grpBrokerInfo);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    brokerInfoGroup.setLayoutData(gridData);
    brokerInfoGroup.setLayout(createGridLayout(3));
    Label brokerIpLabel = new Label(brokerInfoGroup, SWT.LEFT);
    brokerIpLabel.setText(Messages.lblLoginServerName);
    brokerIpLabel.setLayoutData(createGridData(1, 1, -1, -1));
    brokerIpText = new Text(brokerInfoGroup, SWT.LEFT | SWT.BORDER);
    brokerIpText.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 2, 1, 100, -1));
    brokerIpText.addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent event) {
            brokerIpText.selectAll();
        }
    });
    Label brokerPortLabel = new Label(brokerInfoGroup, SWT.LEFT);
    brokerPortLabel.setText(Messages.lblLoginBrokerPort);
    brokerPortLabel.setLayoutData(createGridData(1, 1, -1, -1));
    VerifyListener verifyListener = new VerifyListener() {

        public void verifyText(VerifyEvent event) {
            Pattern pattern = Pattern.compile("[0-9]*");
            Matcher matcher = pattern.matcher(event.text);
            if (matcher.matches()) {
                event.doit = true;
            } else if (event.text.length() > 0) {
                event.doit = false;
            } else {
                event.doit = true;
            }
        }
    };
    Composite portAndShardComp = new Composite(brokerInfoGroup, SWT.NONE);
    portAndShardComp.setLayout(createGridLayout(3, 0, 0));
    portAndShardComp.setLayoutData(createGridData(FILL_HORIZONTAL, 2, 1, -1, -1));
    if (isMultiBroker) {
        brokerPortCombo = new Combo(portAndShardComp, SWT.LEFT | SWT.BORDER);
        brokerPortCombo.setLayoutData(createGridData(GridData.BEGINNING, 1, 1, 100, -1));
        brokerPortCombo.addVerifyListener(verifyListener);
    } else {
        brokerPortText = new Text(portAndShardComp, SWT.LEFT | SWT.BORDER);
        brokerPortText.setLayoutData(createGridData(BEGINNING, 1, 1, 100, -1));
        brokerPortText.addVerifyListener(verifyListener);
    }
    btnShard = new Button(portAndShardComp, SWT.CHECK);
    btnShard.setLayoutData(createGridData(BEGINNING, 1, 1, -1, -1));
    btnShard.setText(com.cubrid.common.ui.query.Messages.shardBrokerLabel);
    btnShard.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (btnShard.getSelection()) {
                openWarningBox(shardBrokerAlert);
            }
            btnShardId.setEnabled(btnShard.getSelection());
        }
    });
    btnShardId = new Button(portAndShardComp, SWT.PUSH);
    btnShardId.setLayoutData(createGridData(HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
    btnShardId.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            ShardIdSelectionDialog dialog = new ShardIdSelectionDialog(getShell());
            dialog.setDatabaseInfo(dbInfo);
            dialog.setShardId(curShardId);
            dialog.setShardVal(curShardVal);
            dialog.setShardQueryType(shardQueryType);
            if (dialog.open() == OK_ID) {
                curShardId = dialog.getShardId();
                curShardVal = dialog.getShardVal();
                shardQueryType = dialog.getShardQueryType();
                if (dbInfo != null) {
                    dbInfo.setCurrentShardId(curShardId);
                    dbInfo.setCurrentShardVal(curShardVal);
                    dbInfo.setShardQueryType(shardQueryType);
                }
                updateShardIdButtonText();
            }
        }
    });
    updateShardIdButtonText();
    Label charsetLabel = new Label(brokerInfoGroup, SWT.LEFT);
    charsetLabel.setText(com.cubrid.common.ui.query.Messages.lblCharSet);
    charsetLabel.setLayoutData(createGridData(1, 1, -1, -1));
    charsetCombo = new Combo(brokerInfoGroup, SWT.LEFT | SWT.BORDER);
    charsetCombo.setLayoutData(createGridData(FILL_HORIZONTAL, 2, 1, 100, -1));
    Label jdbcLabel = new Label(brokerInfoGroup, SWT.LEFT);
    jdbcLabel.setText(Messages.lblDbJdbcVersion);
    jdbcLabel.setLayoutData(createGridData(1, 1, -1, -1));
    jdbcCombo = new Combo(brokerInfoGroup, SWT.LEFT | SWT.READ_ONLY | SWT.BORDER);
    jdbcCombo.setLayoutData(createGridData(FILL_HORIZONTAL, 1, 1, 100, -1));
    Button btnOpen = new Button(brokerInfoGroup, SWT.NONE);
    btnOpen.setText(Messages.btnBrowse);
    btnOpen.setLayoutData(createGridData(1, 1, 80, -1));
    btnOpen.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            JdbcManageDialog dialog = new JdbcManageDialog(getShell());
            if (dialog.open() == OK_ID) {
                String jdbcVersion = dialog.getSelectedJdbcVersion();
                if (isBlank(jdbcVersion)) {
                    jdbcVersion = jdbcCombo.getText();
                }
                resetJdbcCombo(jdbcVersion);
            }
        }
    });
    // JDBC attributes
    Label attrLabel = new Label(brokerInfoGroup, SWT.LEFT);
    attrLabel.setText(Messages.lblJdbcAttr);
    attrLabel.setLayoutData(createGridData(1, 1, -1, -1));
    attrText = new Text(brokerInfoGroup, SWT.LEFT | SWT.BORDER);
    attrText.setEditable(false);
    attrText.setLayoutData(createGridData(FILL_HORIZONTAL, 1, 1, 100, -1));
    Button btnAttr = new Button(brokerInfoGroup, SWT.NONE);
    btnAttr.setText(Messages.btnJdbcAttr);
    btnAttr.setLayoutData(createGridData(1, 1, 80, -1));
    btnAttr.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            JdbcOptionDialog dialog = new JdbcOptionDialog(getShell(), attrText.getText());
            if (dialog.open() == OK_ID) {
                attrText.setText(dialog.getJdbcOptions());
            }
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) FocusAdapter(org.eclipse.swt.events.FocusAdapter) Pattern(java.util.regex.Pattern) JdbcOptionDialog(com.cubrid.common.ui.common.dialog.JdbcOptionDialog) VerifyListener(org.eclipse.swt.events.VerifyListener) Composite(org.eclipse.swt.widgets.Composite) Matcher(java.util.regex.Matcher) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Messages.shardValLabel(com.cubrid.common.ui.query.Messages.shardValLabel) Messages.autoCommitLabel(com.cubrid.common.ui.query.Messages.autoCommitLabel) Label(org.eclipse.swt.widgets.Label) Messages.shardIdLabel(com.cubrid.common.ui.query.Messages.shardIdLabel) ShardIdSelectionDialog(com.cubrid.common.ui.common.dialog.ShardIdSelectionDialog) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) FocusEvent(org.eclipse.swt.events.FocusEvent) Button(org.eclipse.swt.widgets.Button) CommonUITool.createGridData(com.cubrid.common.ui.spi.util.CommonUITool.createGridData) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) JdbcManageDialog(com.cubrid.common.ui.common.dialog.JdbcManageDialog) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Aggregations

VerifyEvent (org.eclipse.swt.events.VerifyEvent)54 VerifyListener (org.eclipse.swt.events.VerifyListener)39 Text (org.eclipse.swt.widgets.Text)31 GridData (org.eclipse.swt.layout.GridData)20 ModifyEvent (org.eclipse.swt.events.ModifyEvent)19 ModifyListener (org.eclipse.swt.events.ModifyListener)18 SelectionEvent (org.eclipse.swt.events.SelectionEvent)18 Label (org.eclipse.swt.widgets.Label)18 Composite (org.eclipse.swt.widgets.Composite)17 GridLayout (org.eclipse.swt.layout.GridLayout)16 VerifyKeyListener (org.eclipse.swt.custom.VerifyKeyListener)14 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)14 Point (org.eclipse.swt.graphics.Point)14 KeyEvent (org.eclipse.swt.events.KeyEvent)12 Button (org.eclipse.swt.widgets.Button)11 FocusEvent (org.eclipse.swt.events.FocusEvent)10 StyledText (org.eclipse.swt.custom.StyledText)7 MouseEvent (org.eclipse.swt.events.MouseEvent)7 Font (org.eclipse.swt.graphics.Font)7 Pattern (java.util.regex.Pattern)6