Package org.python.pydev.ui.dialogs

Examples of org.python.pydev.ui.dialogs.MapOfStringsInputDialog


            }

            @Override
            protected void handleAddButtonSelected(int nButton) {
                if (nButton == 0) {
                    addItemWithDialog(new MapOfStringsInputDialog(getShell(), "Variable",
                            "Enter the variable name/value.", vars) {

                        protected boolean isExistingKeyEdit() {
                            return false;
                        }
                    });

                } else {
                    throw new AssertionError("Unexpected (only 0 should be available)");
                }
            }

            @Override
            protected void handleEdit() {
                TreeItem[] selection = this.tree.getSelection();
                if (selection.length != 1) {
                    return;
                }
                TreeItem treeItem = selection[0];
                if (treeItem == null) {
                    return;
                }

                final String fixedKeyText = treeItem.getText(0);

                //Overridden because we want the key to be fixed.
                MapOfStringsInputDialog dialog = new MapOfStringsInputDialog(getShell(), "Variable",
                        "Enter the variable name/value.", vars) {

                    protected org.eclipse.swt.widgets.Control createDialogArea(Composite parent) {
                        Control control = super.createDialogArea(parent);
                        this.keyField.setText(fixedKeyText);
                        this.keyField.setEditable(false);
                        this.valueField.setFocus();
                        String value = vars.get(fixedKeyText);
                        if (value == null) {
                            value = "";
                        }
                        this.valueField.setText(value);
                        return control;
                    }

                    protected boolean isExistingKeyEdit() {
                        return true;
                    };

                    protected String getInitialMessage() {
                        return null; //it starts in a valid state
                    };

                };

                if (dialog.open() == Window.OK) {
                    Tuple<String, String> keyAndValueEntered = dialog.getKeyAndValueEntered();
                    if (keyAndValueEntered != null) {
                        vars.put(keyAndValueEntered.o1, keyAndValueEntered.o2);
                        treeItem.setText(1, keyAndValueEntered.o2);
                    }
                }
View Full Code Here

TOP

Related Classes of org.python.pydev.ui.dialogs.MapOfStringsInputDialog

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.