Search in sources :

Example 1 with InputDialogWithCheckbox

use of org.erlide.wrangler.refactoring.codeinspection.ui.InputDialogWithCheckbox in project erlide_eclipse by erlang.

the class SimpleCodeInspectionHandler method handleLongFunctions.

private void handleLongFunctions(final IErlSelection wranglerSelection, final Shell shell) {
    try {
        CodeInspectionViewsManager.hideView(SimpleCodeInspectionHandler.LONG_FUNCTIONS);
        // call inputdialog
        final InputDialogWithCheckbox dialog = new InputDialogWithCheckbox(shell, "Search for long functions", "Number of lines:", "Search in the project", "", new IntegerInputValidator());
        if (Window.OK == dialog.open()) {
            final int linesVal = Integer.parseInt(dialog.getValue());
            final boolean inProject = dialog.isCheckBoxChecked();
            RpcResult res = null;
            if (inProject) {
                res = WranglerBackendManager.getRefactoringBackend().callInspection("long_functions_in_dirs_eclipse", "ixi", linesVal, wranglerSelection.getSearchPath(), GlobalParameters.getTabWidth());
            } else {
                res = WranglerBackendManager.getRefactoringBackend().callInspection("long_functions_in_file_eclipse", "sixi", wranglerSelection.getFilePath(), linesVal, wranglerSelection.getSearchPath(), GlobalParameters.getTabWidth());
            }
            // handle rpc
            final ArrayList<IErlElement> elements = processFunctionResult(shell, res);
            if (elements == null) {
                return;
            }
            // show result
            if (!elements.isEmpty()) {
                CodeInspectionViewsManager.showErlElements("Long functions", elements, SimpleCodeInspectionHandler.LONG_FUNCTIONS);
            } else {
                MessageDialog.openInformation(shell, "No result", "Could not found any function which is longer, than " + linesVal + " lines.");
            }
        }
    } catch (final Exception e) {
        ErlLogger.error(e);
    }
}
Also used : InputDialogWithCheckbox(org.erlide.wrangler.refactoring.codeinspection.ui.InputDialogWithCheckbox) IErlElement(org.erlide.engine.model.IErlElement) RpcResult(org.erlide.runtime.rpc.RpcResult) ErlModelException(org.erlide.engine.model.ErlModelException) ExecutionException(org.eclipse.core.commands.ExecutionException) WranglerException(org.erlide.wrangler.refactoring.exception.WranglerException) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException)

Example 2 with InputDialogWithCheckbox

use of org.erlide.wrangler.refactoring.codeinspection.ui.InputDialogWithCheckbox in project erlide_eclipse by erlang.

the class SimpleCodeInspectionHandler method handleNested.

private void handleNested(final IErlSelection wranglerSelection, final Shell shell, final String type) {
    try {
        CodeInspectionViewsManager.hideView(SimpleCodeInspectionHandler.NESTED_EXPRESSIONS + type);
        // call inputdialog
        final InputDialogWithCheckbox dialog = new InputDialogWithCheckbox(shell, "Search for nested expression", "Nest level:", "Search in the project", "", new IntegerInputValidator());
        if (Window.OK == dialog.open()) {
            final int nestedVal = Integer.parseInt(dialog.getValue());
            final boolean inProject = dialog.isCheckBoxChecked();
            RpcResult res = null;
            if (inProject) {
                res = WranglerBackendManager.getRefactoringBackend().callInspection("nested_exprs_in_dirs_eclipse", "iaxi", nestedVal, type, wranglerSelection.getSearchPath(), GlobalParameters.getTabWidth());
            } else {
                res = WranglerBackendManager.getRefactoringBackend().callInspection("nested_exprs_in_file_eclipse", "siaxi", wranglerSelection.getFilePath(), nestedVal, type, wranglerSelection.getSearchPath(), GlobalParameters.getTabWidth());
            }
            // handle rpc
            final ArrayList<IErlElement> elements = processFunctionResult(shell, res);
            if (elements == null) {
                return;
            }
            // show result
            if (!elements.isEmpty()) {
                CodeInspectionViewsManager.showErlElements("Nested " + type + " expressions", elements, SimpleCodeInspectionHandler.NESTED_EXPRESSIONS + type);
            } else {
                MessageDialog.openInformation(shell, "No result", "Could not found any " + nestedVal + " levels nested " + type + " expression!");
            }
        }
    } catch (final Exception e) {
        ErlLogger.error(e);
    }
}
Also used : InputDialogWithCheckbox(org.erlide.wrangler.refactoring.codeinspection.ui.InputDialogWithCheckbox) IErlElement(org.erlide.engine.model.IErlElement) RpcResult(org.erlide.runtime.rpc.RpcResult) ErlModelException(org.erlide.engine.model.ErlModelException) ExecutionException(org.eclipse.core.commands.ExecutionException) WranglerException(org.erlide.wrangler.refactoring.exception.WranglerException) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException)

Aggregations

OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)2 ExecutionException (org.eclipse.core.commands.ExecutionException)2 ErlModelException (org.erlide.engine.model.ErlModelException)2 IErlElement (org.erlide.engine.model.IErlElement)2 RpcResult (org.erlide.runtime.rpc.RpcResult)2 InputDialogWithCheckbox (org.erlide.wrangler.refactoring.codeinspection.ui.InputDialogWithCheckbox)2 WranglerException (org.erlide.wrangler.refactoring.exception.WranglerException)2