Search in sources :

Example 16 with RefactoringWizardOpenOperation

use of org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation in project titan.EclipsePlug-ins by eclipse.

the class OrganizeImportsFromBrowser method performOrganizeImport.

private void performOrganizeImport() {
    // getting the active editor
    final TTCN3Editor targetEditor = Utils.getActiveEditor();
    // find selection
    if (!(selection instanceof IStructuredSelection)) {
        return;
    }
    final IStructuredSelection structSelection = (IStructuredSelection) selection;
    final Set<IProject> projsToUpdate = Utils.findAllProjectsInSelection(structSelection);
    // update AST before refactoring
    Utils.updateASTBeforeRefactoring(projsToUpdate, "OrganizeImports");
    Activator.getDefault().pauseHandlingResourceChanges();
    // create refactoring
    final OrganizeImportsRefactoring refactoring = new OrganizeImportsRefactoring(structSelection);
    // open wizard
    final OrganizeImportsWizard wiz = new OrganizeImportsWizard(refactoring);
    final RefactoringWizardOpenOperation operation = new RefactoringWizardOpenOperation(wiz);
    try {
        operation.run(targetEditor == null ? null : targetEditor.getEditorSite().getShell(), "");
    } catch (InterruptedException irex) {
    // operation was cancelled
    } catch (Exception e) {
        ErrorReporter.logError("OrganizeImportsFromBrowser: Error while performing refactoring change! ");
        ErrorReporter.logExceptionStackTrace(e);
    }
    Activator.getDefault().resumeHandlingResourceChanges();
    // update AST after refactoring
    Utils.updateASTAfterRefactoring(wiz, refactoring.getAffectedObjects(), refactoring.getName());
}
Also used : TTCN3Editor(org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor) RefactoringWizardOpenOperation(org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IProject(org.eclipse.core.resources.IProject) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 17 with RefactoringWizardOpenOperation

use of org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation in project titan.EclipsePlug-ins by eclipse.

the class OrganizeImportsFromEditor method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    // update AST
    Utils.updateASTForProjectActiveInEditor("OrganizeImports");
    Activator.getDefault().pauseHandlingResourceChanges();
    // getting the active editor
    final TTCN3Editor targetEditor = Utils.getActiveEditor();
    if (targetEditor == null) {
        return null;
    }
    // getting selected file
    final IFile selectedFile = Utils.getSelectedFileInEditor("OrganizeImports");
    if (selectedFile == null) {
        return null;
    }
    final IStructuredSelection structSelection = new StructuredSelection(selectedFile);
    final OrganizeImportsRefactoring refactoring = new OrganizeImportsRefactoring(structSelection);
    // open wizard
    final OrganizeImportsWizard wiz = new OrganizeImportsWizard(refactoring);
    final RefactoringWizardOpenOperation operation = new RefactoringWizardOpenOperation(wiz);
    try {
        operation.run(targetEditor.getEditorSite().getShell(), "");
    } catch (InterruptedException irex) {
    // operation was cancelled
    } catch (Exception e) {
        ErrorReporter.logError("OrganizeImportsFromEditor: Error while performing refactoring change! ");
        ErrorReporter.logExceptionStackTrace(e);
    }
    // update AST again
    Activator.getDefault().resumeHandlingResourceChanges();
    final IProject project = selectedFile.getProject();
    GlobalParser.getProjectSourceParser(project).reportOutdating(selectedFile);
    GlobalParser.getProjectSourceParser(project).analyzeAll();
    return null;
}
Also used : TTCN3Editor(org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor) IFile(org.eclipse.core.resources.IFile) RefactoringWizardOpenOperation(org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ExecutionException(org.eclipse.core.commands.ExecutionException) IProject(org.eclipse.core.resources.IProject)

Example 18 with RefactoringWizardOpenOperation

use of org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation in project titan.EclipsePlug-ins by eclipse.

the class LazyficationActionFromBrowser method performLazyfication.

private void performLazyfication() {
    // getting the active editor
    final TTCN3Editor targetEditor = Utils.getActiveEditor();
    // find selection
    if (!(selection instanceof IStructuredSelection)) {
        return;
    }
    final IStructuredSelection structSelection = (IStructuredSelection) selection;
    final Set<IProject> projsToUpdate = Utils.findAllProjectsInSelection(structSelection);
    // update AST before refactoring
    Utils.updateASTBeforeRefactoring(projsToUpdate, "Lazyfication");
    Activator.getDefault().pauseHandlingResourceChanges();
    // create refactoring
    final LazyficationRefactoring refactoring = new LazyficationRefactoring(structSelection);
    // open wizard
    final LazyficationWizard wiz = new LazyficationWizard(refactoring);
    final RefactoringWizardOpenOperation operation = new RefactoringWizardOpenOperation(wiz);
    try {
        operation.run(targetEditor == null ? null : targetEditor.getEditorSite().getShell(), "");
    } catch (InterruptedException irex) {
    // operation was cancelled
    } catch (Exception e) {
        ErrorReporter.logError("LazyficationActionFromBrowser: Error while performing refactoring change! ");
        ErrorReporter.logExceptionStackTrace(e);
    }
    Activator.getDefault().resumeHandlingResourceChanges();
    // update AST after refactoring
    Utils.updateASTAfterRefactoring(wiz, refactoring.getAffectedObjects(), refactoring.getName());
}
Also used : TTCN3Editor(org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor) RefactoringWizardOpenOperation(org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IProject(org.eclipse.core.resources.IProject) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 19 with RefactoringWizardOpenOperation

use of org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation in project titan.EclipsePlug-ins by eclipse.

the class LazyficationActionFromEditor method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    // update AST
    Utils.updateASTForProjectActiveInEditor("Lazyfication");
    Activator.getDefault().pauseHandlingResourceChanges();
    // getting the active editor
    final TTCN3Editor targetEditor = Utils.getActiveEditor();
    if (targetEditor == null) {
        return null;
    }
    // getting selected file
    final IFile selectedFile = Utils.getSelectedFileInEditor("Lazyfication");
    if (selectedFile == null) {
        return null;
    }
    final IStructuredSelection structSelection = new StructuredSelection(selectedFile);
    final LazyficationRefactoring refactoring = new LazyficationRefactoring(structSelection);
    // open wizard
    final LazyficationWizard wiz = new LazyficationWizard(refactoring);
    final RefactoringWizardOpenOperation operation = new RefactoringWizardOpenOperation(wiz);
    try {
        operation.run(targetEditor.getEditorSite().getShell(), "");
    } catch (InterruptedException irex) {
    // operation was cancelled
    } catch (Exception e) {
        ErrorReporter.logError("LazyficationActionFromEditor: Error while performing refactoring change! ");
        ErrorReporter.logExceptionStackTrace(e);
    }
    // update AST again
    Activator.getDefault().resumeHandlingResourceChanges();
    final IProject project = selectedFile.getProject();
    GlobalParser.getProjectSourceParser(project).reportOutdating(selectedFile);
    GlobalParser.getProjectSourceParser(project).analyzeAll();
    return null;
}
Also used : TTCN3Editor(org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor) IFile(org.eclipse.core.resources.IFile) RefactoringWizardOpenOperation(org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ExecutionException(org.eclipse.core.commands.ExecutionException) IProject(org.eclipse.core.resources.IProject)

Example 20 with RefactoringWizardOpenOperation

use of org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation in project titan.EclipsePlug-ins by eclipse.

the class InsertFieldActionFromEditor method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    // update AST
    Utils.updateASTForProjectActiveInEditor("InsertField");
    Activator.getDefault().pauseHandlingResourceChanges();
    // getting the active editor
    final TTCN3Editor targetEditor = Utils.getActiveEditor();
    if (targetEditor == null) {
        return null;
    }
    // getting selected file
    final IFile selectedFile = Utils.getSelectedFileInEditor("InsertField");
    if (selectedFile == null) {
        return null;
    }
    final IStructuredSelection structSelection = new StructuredSelection(selectedFile);
    final InsertFieldRefactoring refactoring = new InsertFieldRefactoring(structSelection, null);
    // open wizard
    final InsertFieldWizard wiz = new InsertFieldWizard(refactoring, refactoring.getSelection());
    final RefactoringWizardOpenOperation operation = new RefactoringWizardOpenOperation(wiz);
    try {
        operation.run(targetEditor.getEditorSite().getShell(), "");
    } catch (InterruptedException irex) {
    // operation was cancelled
    } catch (Exception e) {
        ErrorReporter.logError("InsertFieldActionFromEditor: Error while performing refactoring change! ");
        ErrorReporter.logExceptionStackTrace(e);
    }
    // update AST again
    Activator.getDefault().resumeHandlingResourceChanges();
    final IProject project = selectedFile.getProject();
    GlobalParser.getProjectSourceParser(project).reportOutdating(selectedFile);
    GlobalParser.getProjectSourceParser(project).analyzeAll();
    return null;
}
Also used : TTCN3Editor(org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor) IFile(org.eclipse.core.resources.IFile) RefactoringWizardOpenOperation(org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ExecutionException(org.eclipse.core.commands.ExecutionException) IProject(org.eclipse.core.resources.IProject)

Aggregations

RefactoringWizardOpenOperation (org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation)22 ExecutionException (org.eclipse.core.commands.ExecutionException)14 IProject (org.eclipse.core.resources.IProject)14 TTCN3Editor (org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor)13 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)12 IFile (org.eclipse.core.resources.IFile)9 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)6 RefactoringWizard (org.eclipse.ltk.ui.refactoring.RefactoringWizard)6 RenameRefactoring (org.eclipse.ltk.core.refactoring.participants.RenameRefactoring)5 RenameRefactoringWizard (org.eclipse.wst.xsd.ui.internal.refactor.wizard.RenameRefactoringWizard)5 ArrayList (java.util.ArrayList)2 IResource (org.eclipse.core.resources.IResource)2 TextSelection (org.eclipse.jface.text.TextSelection)2 ISelection (org.eclipse.jface.viewers.ISelection)2 Shell (org.eclipse.swt.widgets.Shell)2 RefactoringComponent (org.eclipse.wst.xsd.ui.internal.refactor.RefactoringComponent)2 XMLRefactoringComponent (org.eclipse.wst.xsd.ui.internal.refactor.XMLRefactoringComponent)2 RenameComponentProcessor (org.eclipse.wst.xsd.ui.internal.refactor.rename.RenameComponentProcessor)2 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)1 HashSet (java.util.HashSet)1