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());
}
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;
}
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());
}
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;
}
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;
}
Aggregations