use of org.eclipse.ui.ISelectionListener in project webtools.sourceediting by eclipse.
the class ShowPropertiesAction method run.
public void run() {
super.run();
if (fSelectionProvider != null) {
IWorkbenchWindow window = SSEUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();
if (page != null) {
IViewPart findView = page.findView(getViewID());
if (findView instanceof ISelectionListener && fPart != null) {
((ISelectionListener) findView).selectionChanged(fPart, fSelectionProvider.getSelection());
} else {
findView.getViewSite().getSelectionProvider().setSelection(fSelectionProvider.getSelection());
}
}
}
}
use of org.eclipse.ui.ISelectionListener in project hale by halestudio.
the class MappingView method createViewControl.
@Override
public void createViewControl(Composite parent) {
super.createViewControl(parent);
updateLayout(false);
getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(selectionListener = new ISelectionListener() {
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if (!(selection instanceof SchemaSelection)) {
// only react on schema selections
return;
}
if (part != MappingView.this) {
update((SchemaSelection) selection);
}
}
});
AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
// update();
as.addListener(alignmentListener = new AlignmentServiceAdapter() {
@Override
public void cellsRemoved(Iterable<Cell> cells) {
updateViewWithCurrentSelection(cells);
}
@Override
public void cellsReplaced(Map<? extends Cell, ? extends Cell> cells) {
List<Cell> changedCells = new ArrayList<Cell>(2);
changedCells.addAll(cells.keySet());
changedCells.addAll(cells.values());
updateViewWithCurrentSelection(changedCells);
}
@Override
public void customFunctionsChanged() {
SchemaSelection current = SchemaSelectionHelper.getSchemaSelection();
if (current != null) {
update(current);
}
}
@Override
public void cellsAdded(Iterable<Cell> cells) {
updateViewWithCurrentSelection(cells);
}
@Override
public void cellsPropertyChanged(Iterable<Cell> cells, String propertyName) {
updateViewWithCurrentSelection(cells);
}
});
TaskService taskService = PlatformUI.getWorkbench().getService(TaskService.class);
taskService.addListener(new TaskServiceListener() {
@Override
public void tasksRemoved(Iterable<Task<?>> tasks) {
updateViewWithCurrentSelection(getAffectedCells(tasks));
}
@Override
public void tasksAdded(Iterable<Task<?>> tasks) {
updateViewWithCurrentSelection(getAffectedCells(tasks));
}
@Override
public void taskUserDataChanged(ResolvedTask<?> task) {
updateViewWithCurrentSelection(getAffectedCells(Collections.singleton(task)));
}
private List<Cell> getAffectedCells(Iterable<Task<?>> tasks) {
List<Cell> affectedCells = new ArrayList<>();
tasks.forEach(t -> {
if (t.getMainContext() instanceof Cell) {
affectedCells.add((Cell) t.getMainContext());
}
});
return affectedCells;
}
});
SchemaSelection current = SchemaSelectionHelper.getSchemaSelection();
if (current != null) {
update(current);
}
// listen on size changes
getViewer().getControl().addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
updateLayout(true);
}
});
}
use of org.eclipse.ui.ISelectionListener in project hale by halestudio.
the class AlignmentView method createViewControl.
/**
* @see eu.esdihumboldt.hale.ui.views.mapping.AbstractMappingView#createViewControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createViewControl(Composite parent) {
Composite page = new Composite(parent, SWT.NONE);
page.setLayout(GridLayoutFactory.fillDefaults().create());
// create type relation selection control
sourceTargetSelector = new SourceTargetTypeSelector(page);
sourceTargetSelector.getControl().setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).create());
sourceTargetSelector.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
getViewer().setInput(sourceTargetSelector.getSelectedCell());
if (deactivatedCellFilterAction != null) {
deactivatedCellFilterAction.setEnabled(sourceTargetSelector.isCellSelected());
if (!sourceTargetSelector.isCellSelected())
deactivatedCellFilterAction.setChecked(true);
}
refreshGraph();
}
});
// typeRelations = new ComboViewer(page, SWT.DROP_DOWN | SWT.READ_ONLY);
// typeRelations.setContentProvider(ArrayContentProvider.getInstance());
// typeRelations.setLabelProvider(new LabelProvider() {
//
// @Override
// public Image getImage(Object element) {
// if (element instanceof Cell) {
// // use function image if possible
// Cell cell = (Cell) element;
// String functionId = cell.getTransformationIdentifier();
// AbstractFunction<?> function = FunctionUtil.getFunction(functionId);
// if (function != null) {
// return functionLabels.getImage(function);
// }
// return null;
// }
//
// return super.getImage(element);
// }
//
// @Override
// public String getText(Object element) {
// if (element instanceof Cell) {
// Cell cell = (Cell) element;
//
// return CellUtil.getCellDescription(cell);
// }
//
// return super.getText(element);
// }
//
// });
// typeRelations.addSelectionChangedListener(new ISelectionChangedListener() {
//
// @Override
// public void selectionChanged(SelectionChangedEvent event) {
// updateGraph();
// }
// });
// typeRelations.getControl().setLayoutData(
// GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false)
// .create());
// create viewer
Composite viewerContainer = new Composite(page, SWT.NONE);
viewerContainer.setLayout(new FillLayout());
viewerContainer.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
super.createViewControl(viewerContainer);
updateLayout(false);
AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
// update();
as.addListener(alignmentListener = new AlignmentServiceAdapter() {
@Override
public void alignmentCleared() {
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
sourceTargetSelector.setSelection(StructuredSelection.EMPTY);
}
});
}
@Override
public void cellsRemoved(Iterable<Cell> cells) {
if (sourceTargetSelector.isCellSelected() && Iterables.contains(cells, sourceTargetSelector.getSelectedCell()))
sourceTargetSelector.setSelection(StructuredSelection.EMPTY);
refreshGraph();
}
@Override
public void cellsReplaced(Map<? extends Cell, ? extends Cell> cells) {
if (sourceTargetSelector.isCellSelected() && cells.keySet().contains(sourceTargetSelector.getSelectedCell()))
sourceTargetSelector.setSelection(StructuredSelection.EMPTY);
refreshGraph();
}
@Override
public void cellsAdded(Iterable<Cell> cells) {
refreshGraph();
}
@Override
public void alignmentChanged() {
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
sourceTargetSelector.setSelection(StructuredSelection.EMPTY);
}
});
}
@Override
public void cellsPropertyChanged(Iterable<Cell> cells, String propertyName) {
refreshGraph();
}
@Override
public void customFunctionsChanged() {
refreshGraph();
}
});
TaskService taskService = PlatformUI.getWorkbench().getService(TaskService.class);
taskService.addListener(tasksListener = new TaskServiceListener() {
@Override
public void tasksRemoved(Iterable<Task<?>> tasks) {
refreshGraph();
}
@Override
public void tasksAdded(Iterable<Task<?>> tasks) {
refreshGraph();
}
@Override
public void taskUserDataChanged(ResolvedTask<?> task) {
refreshGraph();
}
});
// initialize compatibility checkup and display
CompatibilityService cs = PlatformUI.getWorkbench().getService(CompatibilityService.class);
cs.addListener(compListener = new ExclusiveExtensionListener<CompatibilityMode, CompatibilityModeFactory>() {
@Override
public void currentObjectChanged(final CompatibilityMode arg0, final CompatibilityModeFactory arg1) {
refreshGraph();
}
});
// listen on SchemaSelections
getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(selectionListener = new ISelectionListener() {
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if (!(selection instanceof SchemaSelection)) {
// only react on schema selections
return;
}
if (part != AlignmentView.this) {
updateRelation((SchemaSelection) selection);
}
}
});
// select type cell, if it is double clicked
getViewer().addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection.size() == 1) {
Object selected = selection.getFirstElement();
if (selected instanceof Cell && AlignmentUtil.isTypeCell((Cell) selected))
sourceTargetSelector.setSelection(selection);
}
}
});
// listen on size changes
getViewer().getControl().addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
updateLayout(true);
}
});
getViewer().setInput(new DefaultCell());
}
use of org.eclipse.ui.ISelectionListener in project webtools.sourceediting by eclipse.
the class ToggleBreakpointAction method createBreakpoints.
protected boolean createBreakpoints(int lineNumber) {
/*
* Note: we'll always allow processing to continue, even for a "read
* only" IStorageEditorInput, for the ActiveScript debugger. But this
* means sometimes the ActiveScript provider might get an input from
* CVS or something that is not related to debugging.
*/
ITextEditor editor = getTextEditor();
IEditorInput input = editor.getEditorInput();
IDocument document = editor.getDocumentProvider().getDocument(input);
if (document == null)
return false;
String contentType = getContentType(document);
IBreakpointProvider[] providers = BreakpointProviderBuilder.getInstance().getBreakpointProviders(editor, contentType, getFileExtension(input));
int pos = -1;
ISourceEditingTextTools tools = editor.getAdapter(ISourceEditingTextTools.class);
if (tools != null) {
pos = tools.getCaretOffset();
}
final int n = providers.length;
List<IStatus> errors = new ArrayList<>(0);
for (int i = 0; i < n; i++) {
try {
if (Debug.debugBreakpoints)
// $NON-NLS-1$
System.out.println(providers[i].getClass().getName() + " adding breakpoint to line " + lineNumber);
IStatus status = providers[i].addBreakpoint(document, input, lineNumber, pos);
if (status != null && !status.isOK()) {
errors.add(status);
}
} catch (CoreException e) {
errors.add(e.getStatus());
} catch (Exception t) {
// $NON-NLS-1$
Logger.logException("exception while adding breakpoint", t);
}
}
IStatus status = null;
if (errors.size() > 0) {
Shell shell = editor.getSite().getShell();
if (errors.size() > 1) {
// $NON-NLS-1$
status = new MultiStatus(SSEUIPlugin.ID, IStatus.OK, errors.toArray(new IStatus[0]), SSEUIMessages.ManageBreakpoints_error_adding_message1, null);
} else {
status = errors.get(0);
}
if ((status.getSeverity() > IStatus.INFO) || (Platform.inDebugMode() && !status.isOK())) {
Platform.getLog(SSEUIPlugin.getDefault().getBundle()).log(status);
}
/*
* Show for conditions more severe than INFO or when no
* breakpoints were created
*/
if (status.getSeverity() > IStatus.INFO && getBreakpoints(getMarkers()).length < 1) {
// $NON-NLS-1$ //$NON-NLS-2$
ErrorDialog.openError(shell, SSEUIMessages.ManageBreakpoints_error_adding_title1, status.getMessage(), status);
return false;
}
}
/*
* Although no errors were reported, no breakpoints exist on this line
* after having run the existing providers. Run the fallback action.
*/
if ((status == null || status.getSeverity() < IStatus.WARNING) && fFallbackAction != null && !hasMarkers()) {
if (fFallbackAction instanceof ISelectionListener) {
((ISelectionListener) fFallbackAction).selectionChanged(null, null);
}
fFallbackAction.run();
}
return true;
}
use of org.eclipse.ui.ISelectionListener in project netxms by netxms.
the class DashboardDynamicView method createPartControl.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets
* .Composite)
*/
@Override
public void createPartControl(Composite parent) {
selectionProvider = new IntermediateSelectionProvider();
getSite().setSelectionProvider(selectionProvider);
parentComposite = parent;
if (dashboard != null)
dbc = new DashboardControl(parent, SWT.NONE, dashboard, this, selectionProvider, false);
createActions();
contributeToActionBars();
selectionService = getSite().getWorkbenchWindow().getSelectionService();
selectionListener = new ISelectionListener() {
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if ((part instanceof DashboardNavigator) && (selection instanceof IStructuredSelection) && !selection.isEmpty()) {
Object object = ((IStructuredSelection) selection).getFirstElement();
if (object instanceof Dashboard) {
setObject((Dashboard) object);
}
}
}
};
selectionService.addSelectionListener(selectionListener);
}
Aggregations