Search in sources :

Example 6 with WranglerException

use of org.erlide.wrangler.refactoring.exception.WranglerException in project erlide_eclipse by erlang.

the class MoveFunctionDropHandler method handleDrop.

@Override
public IStatus handleDrop(final CommonDropAdapter dropAdapter, final DropTargetEvent dropTargetEvent, final Object target) {
    // get the source data
    final TransferData td = dropAdapter.getCurrentTransfer();
    final ISelection sel = (ISelection) LocalSelectionTransfer.getTransfer().nativeToJava(td);
    final TreeSelection s = (TreeSelection) sel;
    try {
        GlobalParameters.setSelection(s);
    } catch (final WranglerException e1) {
        e1.printStackTrace();
    }
    // get the target data
    String moduleName;
    IFile file;
    if (target instanceof IFile) {
        file = (IFile) target;
    } else {
        file = (IFile) ((IErlElement) target).getResource();
    }
    moduleName = file.getName();
    moduleName = moduleName.substring(0, moduleName.lastIndexOf("."));
    final MoveFunctionRefactoring refactoring = new MoveFunctionRefactoring();
    refactoring.setUserInput(moduleName);
    final RefactoringWizard wizard = new DefaultWranglerRefactoringWizard(refactoring, RefactoringWizard.DIALOG_BASED_USER_INTERFACE, new ArrayList<WranglerPage>());
    final Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
    final RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
    try {
        op.run(shell, refactoring.getName());
    } catch (final Exception e) {
        ErlLogger.error(e);
    }
    return Status.OK_STATUS;
}
Also used : IFile(org.eclipse.core.resources.IFile) MoveFunctionRefactoring(org.erlide.wrangler.refactoring.core.internal.MoveFunctionRefactoring) WranglerException(org.erlide.wrangler.refactoring.exception.WranglerException) WranglerException(org.erlide.wrangler.refactoring.exception.WranglerException) IErlElement(org.erlide.engine.model.IErlElement) Shell(org.eclipse.swt.widgets.Shell) RefactoringWizardOpenOperation(org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation) TransferData(org.eclipse.swt.dnd.TransferData) DefaultWranglerRefactoringWizard(org.erlide.wrangler.refactoring.ui.wizard.DefaultWranglerRefactoringWizard) RefactoringWizard(org.eclipse.ltk.ui.refactoring.RefactoringWizard) TreeSelection(org.eclipse.jface.viewers.TreeSelection) ISelection(org.eclipse.jface.viewers.ISelection) DefaultWranglerRefactoringWizard(org.erlide.wrangler.refactoring.ui.wizard.DefaultWranglerRefactoringWizard) WranglerPage(org.erlide.wrangler.refactoring.ui.wizardpages.WranglerPage)

Example 7 with WranglerException

use of org.erlide.wrangler.refactoring.exception.WranglerException in project erlide_eclipse by erlang.

the class StateDataToRecordRpcMessage method parseRefactoringMessage.

@Override
protected void parseRefactoringMessage(final OtpErlangTuple resultTuple) throws WranglerException {
    final OtpErlangObject wranglerResult = resultTuple.elementAt(1);
    if (!"ok".equals(resultTuple.elementAt(0).toString())) {
        final OtpErlangString msg = (OtpErlangString) wranglerResult;
        setUnsuccessful(msg.stringValue());
    } else {
        if ("non_tuple".equals(wranglerResult.toString())) {
            fieldCount = 1;
        } else {
            try {
                fieldCount = ((OtpErlangLong) ((OtpErlangTuple) wranglerResult).elementAt(1)).intValue();
            } catch (final OtpErlangRangeException e) {
                throw new WranglerException(e.getMessage());
            }
        }
        stateFuns = resultTuple.elementAt(2);
        setSuccessful();
    }
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) WranglerException(org.erlide.wrangler.refactoring.exception.WranglerException) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Aggregations

WranglerException (org.erlide.wrangler.refactoring.exception.WranglerException)7 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)3 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)3 Shell (org.eclipse.swt.widgets.Shell)3 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)2 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)2 ExecutionException (org.eclipse.core.commands.ExecutionException)2 IFile (org.eclipse.core.resources.IFile)2 RefactoringWizardOpenOperation (org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation)2 IErlElement (org.erlide.engine.model.IErlElement)2 MoveFunctionRefactoring (org.erlide.wrangler.refactoring.core.internal.MoveFunctionRefactoring)2 IErlSelection (org.erlide.wrangler.refactoring.selection.IErlSelection)2 OtpErlangBoolean (com.ericsson.otp.erlang.OtpErlangBoolean)1 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 InputDialog (org.eclipse.jface.dialogs.InputDialog)1