use of org.eclipse.jface.action.IStatusLineManager in project InformationSystem by ObeoNetwork.
the class ScaffoldEditor method getContentOutlinePage.
/**
* This accesses a cached version of the content outliner.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public IContentOutlinePage getContentOutlinePage() {
if (contentOutlinePage == null) {
//
class MyContentOutlinePage extends ContentOutlinePage {
@Override
public void createControl(Composite parent) {
super.createControl(parent);
contentOutlineViewer = getTreeViewer();
contentOutlineViewer.addSelectionChangedListener(this);
// Set up the tree viewer.
//
contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
contentOutlineViewer.setInput(editingDomain.getResourceSet());
// Make sure our popups work.
//
createContextMenuFor(contentOutlineViewer);
if (!editingDomain.getResourceSet().getResources().isEmpty()) {
// Select the root object in the view.
//
contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
}
}
@Override
public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) {
super.makeContributions(menuManager, toolBarManager, statusLineManager);
contentOutlineStatusLineManager = statusLineManager;
}
@Override
public void setActionBars(IActionBars actionBars) {
super.setActionBars(actionBars);
getActionBarContributor().shareGlobalActions(this, actionBars);
}
}
contentOutlinePage = new MyContentOutlinePage();
// Listen to selection so that we can handle it is a special way.
//
contentOutlinePage.addSelectionChangedListener(new ISelectionChangedListener() {
// This ensures that we handle selections correctly.
//
public void selectionChanged(SelectionChangedEvent event) {
handleContentOutlineSelection(event.getSelection());
}
});
}
return contentOutlinePage;
}
use of org.eclipse.jface.action.IStatusLineManager in project titan.EclipsePlug-ins by eclipse.
the class SelectionFinder method findSelection.
private Definition findSelection() {
// getting the active editor
final IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (editor == null || !(editor instanceof TTCN3Editor)) {
return null;
}
final TTCN3Editor targetEditor = (TTCN3Editor) editor;
// iterating through part of the module
final IResource selectedRes = extractResource(targetEditor);
if (!(selectedRes instanceof IFile)) {
ErrorReporter.logError("SelectionFinder.findSelection(): Selected resource `" + selectedRes.getName() + "' is not a file.");
return null;
}
final IFile selectedFile = (IFile) selectedRes;
sourceProj = selectedFile.getProject();
final ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(sourceProj);
final Module selectedModule = projectSourceParser.containedModule(selectedFile);
// getting current selection
final ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
final TextSelection textSelection = extractSelection(selectionService.getSelection());
// getting current selection nodes
final int selectionOffset = textSelection.getOffset() + textSelection.getLength();
final SelectionFinderVisitor selVisitor = new SelectionFinderVisitor(selectionOffset);
selectedModule.accept(selVisitor);
final Definition selectedDef = selVisitor.getSelection();
if (selectedDef == null) {
ErrorReporter.logWarning("SelectionFinder.findSelection(): Visitor did not find a definition in the selection.");
final IStatusLineManager statusLineManager = targetEditor.getEditorSite().getActionBars().getStatusLineManager();
statusLineManager.setErrorMessage(ERR_MSG_NO_SELECTION);
return null;
}
return selectedDef;
}
use of org.eclipse.jface.action.IStatusLineManager in project titan.EclipsePlug-ins by eclipse.
the class RenameRefactoring method runAction.
/**
* Helper function used by RenameRefactoringAction classes for TTCN-3,
* ASN.1 and TTCNPP editors
*/
public static void runAction(final IEditorPart targetEditor, final ISelection selection) {
final IStatusLineManager statusLineManager = targetEditor.getEditorSite().getActionBars().getStatusLineManager();
statusLineManager.setErrorMessage(null);
final IFile file = (IFile) targetEditor.getEditorInput().getAdapter(IFile.class);
if (file == null) {
statusLineManager.setErrorMessage(FILENOTIDENTIFIABLE);
return;
}
if (!TITANNature.hasTITANNature(file.getProject())) {
statusLineManager.setErrorMessage(TITANNature.NO_TITAN_FILE_NATURE_FOUND);
return;
}
final IPreferencesService prefs = Platform.getPreferencesService();
final boolean reportDebugInformation = prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null);
int offset;
if (selection instanceof TextSelection && !selection.isEmpty() && !"".equals(((TextSelection) selection).getText())) {
if (reportDebugInformation) {
TITANDebugConsole.getConsole().newMessageStream().println("text selected: " + ((TextSelection) selection).getText());
}
TextSelection tSelection = (TextSelection) selection;
offset = tSelection.getOffset() + tSelection.getLength();
} else {
offset = ((IEditorWithCarretOffset) targetEditor).getCarretOffset();
}
// run semantic analysis to have up-to-date AST
// FIXME: it does not work for incremental parsing
final ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(file.getProject());
final WorkspaceJob job = projectSourceParser.analyzeAll();
if (job == null) {
if (reportDebugInformation) {
TITANDebugConsole.getConsole().newMessageStream().println("Rename refactoring: WorkspaceJob to analyze project could not be created.");
}
return;
}
try {
job.join();
} catch (InterruptedException e) {
ErrorReporter.logExceptionStackTrace(e);
return;
}
// find the module
if (ResourceExclusionHelper.isExcluded(file)) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(MessageFormat.format(EXCLUDEDFROMBUILD, file.getFullPath()));
return;
}
final Module module = projectSourceParser.containedModule(file);
if (module == null) {
statusLineManager.setErrorMessage(MessageFormat.format(NOTFOUNDMODULE, file.getName()));
return;
}
ReferenceFinder rf = findOccurrencesLocationBased(module, offset);
if (rf == null) {
rf = new ReferenceFinder();
boolean isDetected = rf.detectAssignmentDataByOffset(module, offset, targetEditor, true, reportDebugInformation);
if (!isDetected) {
return;
}
}
RenameRefactoring renameRefactoring = new RenameRefactoring(file, module, rf);
RenameRefactoringWizard renameWizard = new RenameRefactoringWizard(renameRefactoring);
RefactoringWizardOpenOperation operation = new RefactoringWizardOpenOperation(renameWizard);
try {
operation.run(targetEditor.getEditorSite().getShell(), "");
} catch (InterruptedException irex) {
// operation was canceled
if (reportDebugInformation) {
TITANDebugConsole.getConsole().newMessageStream().println("Rename refactoring has been cancelled");
}
} finally {
// ===================================
// === Re-analysis after renaming ====
// ===================================
Map<Module, List<Hit>> changed = rf.findAllReferences(module, file.getProject(), null, reportDebugInformation);
final Set<Module> modules = new HashSet<Module>();
modules.add(module);
modules.addAll(changed.keySet());
reanalyseAstAfterRefactoring(file.getProject(), modules);
}
}
use of org.eclipse.jface.action.IStatusLineManager in project InformationSystem by ObeoNetwork.
the class SoaEditor method getContentOutlinePage.
/**
* This accesses a cached version of the content outliner. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public IContentOutlinePage getContentOutlinePage() {
if (contentOutlinePage == null) {
//
class MyContentOutlinePage extends ContentOutlinePage {
@Override
public void createControl(Composite parent) {
super.createControl(parent);
contentOutlineViewer = getTreeViewer();
contentOutlineViewer.addSelectionChangedListener(this);
// Set up the tree viewer.
//
contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
contentOutlineViewer.setInput(editingDomain.getResourceSet());
// Make sure our popups work.
//
createContextMenuFor(contentOutlineViewer);
if (!editingDomain.getResourceSet().getResources().isEmpty()) {
// Select the root object in the view.
//
contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
}
}
@Override
public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) {
super.makeContributions(menuManager, toolBarManager, statusLineManager);
contentOutlineStatusLineManager = statusLineManager;
}
@Override
public void setActionBars(IActionBars actionBars) {
super.setActionBars(actionBars);
getActionBarContributor().shareGlobalActions(this, actionBars);
}
}
contentOutlinePage = new MyContentOutlinePage();
// Listen to selection so that we can handle it is a special way.
//
contentOutlinePage.addSelectionChangedListener(new ISelectionChangedListener() {
// This ensures that we handle selections correctly.
//
public void selectionChanged(SelectionChangedEvent event) {
handleContentOutlineSelection(event.getSelection());
}
});
}
return contentOutlinePage;
}
use of org.eclipse.jface.action.IStatusLineManager in project InformationSystem by ObeoNetwork.
the class StateMachineEditor method getContentOutlinePage.
/**
* This accesses a cached version of the content outliner.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public IContentOutlinePage getContentOutlinePage() {
if (contentOutlinePage == null) {
//
class MyContentOutlinePage extends ContentOutlinePage {
@Override
public void createControl(Composite parent) {
super.createControl(parent);
contentOutlineViewer = getTreeViewer();
contentOutlineViewer.addSelectionChangedListener(this);
// Set up the tree viewer.
//
contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
contentOutlineViewer.setInput(editingDomain.getResourceSet());
// Make sure our popups work.
//
createContextMenuFor(contentOutlineViewer);
if (!editingDomain.getResourceSet().getResources().isEmpty()) {
// Select the root object in the view.
//
contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
}
}
@Override
public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) {
super.makeContributions(menuManager, toolBarManager, statusLineManager);
contentOutlineStatusLineManager = statusLineManager;
}
@Override
public void setActionBars(IActionBars actionBars) {
super.setActionBars(actionBars);
getActionBarContributor().shareGlobalActions(this, actionBars);
}
}
contentOutlinePage = new MyContentOutlinePage();
// Listen to selection so that we can handle it is a special way.
//
contentOutlinePage.addSelectionChangedListener(new ISelectionChangedListener() {
// This ensures that we handle selections correctly.
//
public void selectionChanged(SelectionChangedEvent event) {
handleContentOutlineSelection(event.getSelection());
}
});
}
return contentOutlinePage;
}
Aggregations