Package org.erlide.wrangler.refactoring.ui.validator

Examples of org.erlide.wrangler.refactoring.ui.validator.NonEmptyStringValidator


            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));

                } else {
                    return null;
                }

                // run introduce macro refactoring
            } else if (actionId.equals("org.erlide.wrangler.refactoring.introducemacro")) {
                refactoring = new IntroduceMacroRefactoring();
                pages.add(new SimpleInputPage("Introduce macro definition",
                        "Please type the new macro name!", "New macro name:",
                        "Macro name cannot be empty!", new NonEmptyStringValidator()));
                // run rename process refactoring
            } else if (actionId.equals("org.erlide.wrangler.refactoring.renameprocess")) {
                refactoring = new RenameProcessRefactoring();
                pages.add(new SimpleInputPage("Rename process",
                        "Please type the new process name!", "New process name:",
View Full Code Here

TOP

Related Classes of org.erlide.wrangler.refactoring.ui.validator.NonEmptyStringValidator

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.