Search in sources :

Example 6 with RefactoringWizardOpenOperation

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

the class MinimizeScopeActionFromBrowser method performMinimizeScope.

private void performMinimizeScope() {
    // 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, "MinimizeScope");
    Activator.getDefault().pauseHandlingResourceChanges();
    // create refactoring
    final MinimizeScopeRefactoring refactoring = new MinimizeScopeRefactoring(structSelection, null);
    // open wizard
    final MinimizeScopeWizard wiz = new MinimizeScopeWizard(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("MinimizeScopeActionFromBrowser: 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 7 with RefactoringWizardOpenOperation

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

the class MinimizeScopeActionFromEditor method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    // update AST
    Utils.updateASTForProjectActiveInEditor("MinimizeScope");
    Activator.getDefault().pauseHandlingResourceChanges();
    // getting the active editor
    final TTCN3Editor targetEditor = Utils.getActiveEditor();
    if (targetEditor == null) {
        return null;
    }
    // get selected definition
    selection = findSelection();
    if (selection == null) {
        return null;
    }
    final IResource selectedRes = selection.getLocation().getFile();
    if (!(selectedRes instanceof IFile)) {
        ErrorReporter.logError("MinimizeScopeActionFromEditor.execute(): Selected resource `" + selectedRes.getName() + "' is not a file.");
        return null;
    }
    final IFile selectedFile = (IFile) selectedRes;
    // 
    final MinimizeScopeRefactoring refactoring = new MinimizeScopeRefactoring(selection, null);
    // open wizard
    final MinimizeScopeWizard wiz = new MinimizeScopeWizard(refactoring);
    final RefactoringWizardOpenOperation operation = new RefactoringWizardOpenOperation(wiz);
    try {
        operation.run(targetEditor.getEditorSite().getShell(), "");
    } catch (InterruptedException irex) {
    // operation was cancelled
    } catch (Exception e) {
        ErrorReporter.logError("MinimizeScopeActionFromEditor: 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) IResource(org.eclipse.core.resources.IResource) ExecutionException(org.eclipse.core.commands.ExecutionException) IProject(org.eclipse.core.resources.IProject)

Example 8 with RefactoringWizardOpenOperation

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

the class UngroupModuleparActionFromBrowser method performUngroupModulepar.

private void performUngroupModulepar() {
    // 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, "UngroupModulepar");
    Activator.getDefault().pauseHandlingResourceChanges();
    // create refactoring
    final UngroupModuleparRefactoring refactoring = new UngroupModuleparRefactoring(structSelection);
    // open wizard
    final UngroupModuleparWizard wiz = new UngroupModuleparWizard(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("UngroupModuleparActionFromBrowser: 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 9 with RefactoringWizardOpenOperation

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

the class MinimizeVisibilityActionFromBrowser method performMinimizeVisibility.

private void performMinimizeVisibility() {
    // 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, "MinimizeVisibility");
    Activator.getDefault().pauseHandlingResourceChanges();
    // create refactoring
    final MinimizeVisibilityRefactoring refactoring = new MinimizeVisibilityRefactoring(structSelection);
    // open wizard
    final MinimizeVisibilityWizard wiz = new MinimizeVisibilityWizard(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("MinimizeVisibilityActionFromBrowser: 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 10 with RefactoringWizardOpenOperation

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

the class MinimizeVisibilityActionFromEditor method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    // update AST
    Utils.updateASTForProjectActiveInEditor("MinimizeVisibility");
    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("MinimizeVisibility");
    if (selectedFile == null) {
        return null;
    }
    final IStructuredSelection structSelection = new StructuredSelection(selectedFile);
    final MinimizeVisibilityRefactoring refactoring = new MinimizeVisibilityRefactoring(structSelection);
    // open wizard
    final MinimizeVisibilityWizard wiz = new MinimizeVisibilityWizard(refactoring);
    final RefactoringWizardOpenOperation operation = new RefactoringWizardOpenOperation(wiz);
    try {
        operation.run(targetEditor.getEditorSite().getShell(), "");
    } catch (InterruptedException irex) {
    // operation was cancelled
    } catch (Exception e) {
        ErrorReporter.logError("MinimizeVisibilityActionFromEditor: 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