Package org.eclipse.jface.dialogs

Examples of org.eclipse.jface.dialogs.InputDialog


    };

    rename = new Action(getCaption("collection.renameColl")) {
      @Override
      public void run() {
        InputDialog dialog = new InputDialog(view.getSite().getShell(),
            getCaption("collection.renameColl"),
            getCaption("collection.msg.newCollName"),
            col.getName(), new RequiredInputValidator(
                getCaption("collection.msg.inputCollName")));
        if (dialog.open() == InputDialog.OK) {
          try {
            col.rename(dialog.getValue());
          } catch (MongoException ex) {
            UIUtils.openErrorDialog(view.getSite().getShell(),
                ex.toString());
          }
          view.getViewer().refresh(getParent());
View Full Code Here


    public CreateCollectionAction() {
      super("Create Collection");
    }

    public void run() {
      InputDialog dialog = new InputDialog(view.getSite().getShell(),
          getCaption("database.newCollection.title"),
          getCaption("database.newCollection.msg"), "",
          new RequiredInputValidator(
              getCaption("database.newCollection.errorMsg")));
      if (dialog.open() == InputDialog.OK) {
        try {
          db.createCollection(dialog.getValue(), new BasicDBObject());
        } catch (MongoException ex) {
          UIUtils.openErrorDialog(view.getSite().getShell(),
              ex.toString());
        }
        view.getViewer().refresh(Database.this);
View Full Code Here

        final List<String> sel = field.getSelectedElements();
        field.removeElements(sel);
    }

    private void addPath(final ListDialogField<String> field) {
        final InputDialog dlg = new InputDialog(new Shell(), "Add path",
                "Enter a path to be added to ", "", null);
        dlg.setBlockOnOpen(true);
        dlg.open();
        final String value = dlg.getValue();

        if (value != null && value.length() > 0) {
            final File f = new File(value);
            if (f.exists()) {
                field.addElement(value);
View Full Code Here

            return;
        }

        // open input dialog

        final InputDialog nameDialog = new InputDialog(shell, "Saving coverage results",
                "Enter the name for saving coverage results", statName.toString(),
                new IInputValidator() {

                    @Override
                    public String isValid(final String newText) {

                        final String[] names = dir.list();

                        if (newText == null || newText.length() < 1) {
                            return "Name too short";
                        }

                        for (final String name : names) {
                            if (name.equals(newText)) {
                                return "Results file with the same name already exists";
                            }
                        }

                        return null;
                    }

                });

        nameDialog.open();

        String name = "";
        if (nameDialog.getReturnCode() == Window.OK) {
            name = nameDialog.getValue();
        } else {
            return;
        }

        //
View Full Code Here

            @Override
            public void widgetSelected(final SelectionEvent e) {
                final String[] configurations = ConfigurationManager.getTPConfigs();
                final Set<String> existingNames = new HashSet<String>(Arrays
                        .asList(configurations));
                final InputDialog dialog = new ConfigurationSaveAsDialog(parent
                        .getShell(), "Save trace pattern configuration",
                        "Enter name for configuration:", patternsConfigName,
                        existingNames);

                if (dialog.open() == Window.OK) {
                    if (ConfigurationManager.saveTPConfig(dialog.getValue())) {
                        patternsConfigName = dialog.getValue();
                        configNameLabel.setText(patternsConfigName);
                    } else {
                        final MessageBox messageBox = new MessageBox(parent.getShell(),
                                SWT.ICON_ERROR | SWT.OK);
                        messageBox.setMessage("Unable to save configuration: "
                                + dialog.getValue());
                        messageBox.setText("Error");
                        messageBox.open();
                    }
                }
            }
View Full Code Here

            @Override
            public void widgetSelected(final SelectionEvent e) {
                final String[] configurations = ConfigurationManager.getNodesConfig();
                final Set<String> existingNames = new HashSet<String>(Arrays
                        .asList(configurations));
                final InputDialog dialog = new ConfigurationSaveAsDialog(parent
                        .getShell(), "Save nodes configuration",
                        "Enter name for configuration:", nodesConfigName, existingNames);

                if (dialog.open() == Window.OK) {
                    if (ConfigurationManager.saveNodesConfig(dialog.getValue())) {
                        nodesConfigName = dialog.getValue();
                        configNameLabel.setText(nodesConfigName);
                    } else {
                        final MessageBox messageBox = new MessageBox(parent.getShell(),
                                SWT.ICON_ERROR | SWT.OK);
                        messageBox.setMessage("Unable to save configuration: "
                                + dialog.getValue());
                        messageBox.setText("Error");
                        messageBox.open();
                    }
                }
            }
View Full Code Here

    private void handleLargeModulesCall(final IErlSelection wranglerSelection,
            final Shell shell) {
        CodeInspectionViewsManager.hideView(
                CodeInspectionViewsManager.CODE_INSPECTION_VIEW, LARGE_MODULES_VIEW_ID);

        final InputDialog dialog = new InputDialog(shell, "Lines of a large module",
                "Lines of a large module:", "", new IntegerInputValidator());
        final int ret = dialog.open();
        if (ret == Window.CANCEL) {
            return;
        }
        final int lines = Integer.parseInt(dialog.getValue());
        final RpcResult res = WranglerBackendManager
                .getRefactoringBackend()
                .callInspection("large_modules_eclipse", "ixi", lines,
                        wranglerSelection.getSearchPath(), GlobalParameters.getTabWidth());
View Full Code Here

        final ArrayList<WranglerPage> pages = new ArrayList<WranglerPage>();

        // apply ad hoc refactoring
        if (actionId.equals("org.erlide.wrangler.refactoring.adhoc")) {
            final InputDialog dialog = getModuleInput("Apply ad hoc refactoring",
                    "Please type the gen_refac module name!");

            dialog.open();

            if (dialog.getReturnCode() == Window.CANCEL) {
                return null;
            }

            final String callbackModule = dialog.getValue();

            pages.add(new UserRefacInputPage("Apply ad hoc refactoring",
                    "Please type input arguments for this refactoring",
                    "Arguments should not be empty!", new NonEmptyStringValidator()));
            refactoring = new ApplyAdhocElemRefactoring();

            ((ApplyAdhocElemRefactoring) refactoring)
                    .setCallbackModuleName(callbackModule);

            if (!((ApplyAdhocElemRefactoring) refactoring).fetchParPrompts()) {
                MessageDialog.openError(PlatformUI.getWorkbench()
                        .getActiveWorkbenchWindow().getShell(),
                        "Elementary refactoring error", "Can not load callback module");
                return null;
            }

            // apply user-defined refactoring
        } else if (actionId.equals("org.erlide.wrangler.refactoring.gen_refac")) {
            final String callbackModule = event
                    .getParameter("org.erlide.wrangler.refactoring.gen_refac.callback");
            final String name = event
                    .getParameter("org.erlide.wrangler.refactoring.gen_refac.name");

            pages.add(new UserRefacInputPage(name,
                    "Please type input arguments for this refactoring",
                    "Arguments should not be empty!", new NonEmptyStringValidator()));
            refactoring = new ApplyUserElementaryRefactoring(name, callbackModule);

            if (!((ApplyUserElementaryRefactoring) refactoring).fetchParPrompts()) {
                MessageDialog.openError(PlatformUI.getWorkbench()
                        .getActiveWorkbenchWindow().getShell(), "Refactoring error",
                        "Can not find callback module");
                return null;
            }

            // run rename variable refactoring
        } else if (actionId.equals("org.erlide.wrangler.refactoring.renamevariable")) {
            refactoring = new RenameVariableRefactoring();
            final SimpleInputPage page = new SimpleInputPage("Rename variable",
                    "Please type the new variable name!", "New variable name:",
                    "New name must be a valid Erlang variable name!",
                    new VariableNameValidator());
            page.setInput(refactoring.getDefaultValue());
            pages.add(page);

            // introduce new variable refactoring
        } else if (actionId
                .equals("org.erlide.wrangler.refactoring.introducenewvariable")) {
            pages.add(new SimpleInputPage("Introduce new variable",
                    "Please type the new variable name!", "New variable name:",
                    "New name must be a valid Erlang variable name!",
                    new VariableNameValidator()));
            refactoring = new IntroduceNewVariableRefactoring();

            // run rename function refactoring
        } else if (actionId.equals("org.erlide.wrangler.refactoring.renamefunction")) {
            refactoring = new RenameFunctionRefactoring();
            final CostumworkFlowInputPage page = new CostumworkFlowInputPage(
                    "Rename function", "Please type the new function name!",
                    "New function name:", "New name must be a valid Erlang atom!",
                    new AtomValidator());
            page.setInput(refactoring.getDefaultValue());
            pages.add(page);

            // run extract function refactoring
        } else if (actionId.equals("org.erlide.wrangler.refactoring.extractfunction")) {
            pages.add(new CostumworkFlowInputPage("Extract function",
                    "Please type a function name!", "Function name:",
                    "Function name must be a valid Erlang atom!", new AtomValidator()));
            refactoring = new ExtractFunctionRefactoring();

            // run rename module refactoring
        } else if (actionId.equals("org.erlide.wrangler.refactoring.renamemodule")) {
            final boolean answer = MessageDialog
                    .openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                            .getShell(), "Warning!",
                            "The requested operation cannot be undone. Would you like to continue?");

            if (!answer) {
                return null;
            }

            refactoring = new RenameModuleRefactoring();
            final CostumworkFlowInputPage page = new CostumworkFlowInputPage(
                    "Rename module", "Please type the new module name!",
                    "New module name:", "New module name must be a valid Erlang atom!",
                    new AtomValidator());
            page.setInput(refactoring.getDefaultValue());
            pages.add(page);

            // run move function refactoring
        } else if (actionId.equals("org.erlide.wrangler.refactoring.movefunction")) {

            final IProject project = ErlangEngine.getInstance().getModelUtilService()
                    .getProject(GlobalParameters.getWranglerSelection().getErlElement())
                    .getWorkspaceProject();
            final ArrayList<String> moduleList = WranglerUtils.getModuleNames(project);
            final String moduleName = GlobalParameters.getWranglerSelection()
                    .getErlElement().getResource().getName();
            moduleList.remove(WranglerUtils.removeExtension(moduleName));

            pages.add(new ComboInputPage("Move function",
                    "Please select the destination module", "Destination module:",
                    moduleList));
            refactoring = new MoveFunctionRefactoring();

            // run fold expression against a local function
        } else if (actionId.equals("org.erlide.wrangler.refactoring.foldlocalexpression")) {

            refactoring = new FoldLocalExpressionRefactoring();

            pages.add(new SelectionInputPage("Fold expression",
                    "Please select expression which should be fold!",
                    "Select expressions which should be folded!",
                    (CostumWorkflowRefactoringWithPositionsSelection) refactoring));

            // run fold expression against a remote function
        } else {
            final Shell activeShell = PlatformUI.getWorkbench().getDisplay()
                    .getActiveShell();
            if (actionId.equals("org.erlide.wrangler.refactoring.foldremoteexpression")) {

                // must store the selection, because, the user through the
                // dialog
                // may change it
                final IErlMemberSelection sel = (IErlMemberSelection) GlobalParameters
                        .getWranglerSelection();

                final RemoteFunctionClauseDialog dialog = new RemoteFunctionClauseDialog(
                        activeShell, "Fold expression");

                dialog.open();
                dialog.resetSelection();

                if (dialog.isFinished()) {
                    final IErlFunctionClause functionClause = dialog.getFunctionClause();
                    refactoring = new FoldRemoteExpressionRefactoring(functionClause, sel);
                    pages.add(new SelectionInputPage("Fold expression",
                            "Please select expression which should be fold!",
                            "Select expressions which should be folded!",
                            (CostumWorkflowRefactoringWithPositionsSelection) refactoring));
View Full Code Here

        return null;

    }

    private InputDialog getModuleInput(final String name, final String mesg) {
        return new InputDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                .getShell(), name, mesg, "", new IInputValidator() {

            public IValidator internalV = new ModuleNameValidator();

            @Override
View Full Code Here

public class AddRefacHandler extends AbstractHandler {

    @Override
    public Object execute(final ExecutionEvent event) throws ExecutionException {

        final InputDialog dialog = new InputDialog(PlatformUI.getWorkbench()
                .getActiveWorkbenchWindow().getShell(), "Add user-defined refactoring",
                "Please type callback module name!", "", new IInputValidator() {

                    public IValidator internalV = new ModuleNameValidator();

                    @Override
                    public String isValid(final String newText) {
                        if (internalV.isValid(newText)) {
                            return null;
                        }
                        return "Please type a correct module name!";
                    }
                });

        dialog.open();

        if (dialog.getReturnCode() == Window.CANCEL) {
            return null;
        }

        final String callbackModule = dialog.getValue();

        final RefacType type = checkType(callbackModule);
        if (type == null) {
            showErrorMesg("Callback module must implement either "
                    + "gen_refac or gen_composite_refac behaviour");
View Full Code Here

TOP

Related Classes of org.eclipse.jface.dialogs.InputDialog

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.