本文整理汇总了Java中org.eclipse.jface.viewers.SelectionChangedEvent.getSelection方法的典型用法代码示例。如果您正苦于以下问题:Java SelectionChangedEvent.getSelection方法的具体用法?Java SelectionChangedEvent.getSelection怎么用?Java SelectionChangedEvent.getSelection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.viewers.SelectionChangedEvent
的用法示例。
在下文中一共展示了SelectionChangedEvent.getSelection方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: modifyEvent
import org.eclipse.jface.viewers.SelectionChangedEvent; //导入方法依赖的package包/类
/**
* Ensures that IProject is present as first element
* and DBPair is present as second element of the selection.
*/
private SelectionChangedEvent modifyEvent(SelectionChangedEvent event, DBPair dbPair) {
ISelection selection = event.getSelection();
if (selection.isEmpty()) {
return defaultSelectionEvent;
}
if (!(selection instanceof IStructuredSelection)) {
Log.log(Log.LOG_WARNING, "Cannot handle this selection type: " + selection.toString()); //$NON-NLS-1$
// no way to deal with empty/other types of selections
return defaultSelectionEvent;
}
IStructuredSelection sel = (IStructuredSelection) selection;
List<?> elements = sel.toList();
List<Object> newElements = new ArrayList<>(elements.size() + 2);
newElements.add(proj);
newElements.add(dbPair);
newElements.addAll(elements);
return new SelectionChangedEvent((ISelectionProvider) event.getSource(),
new StructuredSelection(newElements));
}
示例2: createISelectionChangedListener
import org.eclipse.jface.viewers.SelectionChangedEvent; //导入方法依赖的package包/类
public ISelectionChangedListener createISelectionChangedListener() {
return new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
StructuredSelection sSelection = (StructuredSelection) event
.getSelection();
AbstractGraphicalEditPart selectedEditPart = (AbstractGraphicalEditPart) sSelection
.getFirstElement();
defaultComponentLocation.setLocation(selectedEditPart
.getFigure().getBounds().x, selectedEditPart
.getFigure().getBounds().y);
}
};
}
示例3: dbBlocksJournalViewSelectionChanged
import org.eclipse.jface.viewers.SelectionChangedEvent; //导入方法依赖的package包/类
private void dbBlocksJournalViewSelectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (selection.isEmpty()) {
dbBlocksJournalProcessInfoView.hide();
} else {
DBProcess process;
IStructuredSelection structuredSelection = (IStructuredSelection)selection;
Object element = structuredSelection.getFirstElement();
if (element instanceof DBBlocksJournalProcess) {
DBBlocksJournalProcess blocksJournalProcess = (DBBlocksJournalProcess)element;
process = blocksJournalProcess.getProcess();
} else {
process = (DBProcess)element;
}
dbBlocksJournalProcessInfoView.show(process);
}
}
示例4: selectionChanged
import org.eclipse.jface.viewers.SelectionChangedEvent; //导入方法依赖的package包/类
public void selectionChanged(SelectionChangedEvent event) {
if (event.getSelection() instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
Object selectedObject = selection.getFirstElement();
parentDialog.enableOK((selectedObject instanceof TVScreenClass));
}
}
示例5: selectionChanged
import org.eclipse.jface.viewers.SelectionChangedEvent; //导入方法依赖的package包/类
/**
* This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener},
* handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings
* that can be added to the selected object and updating the menus accordingly.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void selectionChanged(SelectionChangedEvent event) {
// Remove any menu items for old selection.
//
if (createChildMenuManager != null) {
depopulateManager(createChildMenuManager, createChildActions);
}
if (createSiblingMenuManager != null) {
depopulateManager(createSiblingMenuManager, createSiblingActions);
}
// Query the new selection for appropriate new child/sibling descriptors
//
Collection<?> newChildDescriptors = null;
Collection<?> newSiblingDescriptors = null;
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) {
Object object = ((IStructuredSelection)selection).getFirstElement();
EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain();
newChildDescriptors = domain.getNewChildDescriptors(object, null);
newSiblingDescriptors = domain.getNewChildDescriptors(null, object);
}
// Generate actions for selection; populate and redraw the menus.
//
createChildActions = generateCreateChildActions(newChildDescriptors, selection);
createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection);
if (createChildMenuManager != null) {
populateManager(createChildMenuManager, createChildActions, null);
createChildMenuManager.update(true);
}
if (createSiblingMenuManager != null) {
populateManager(createSiblingMenuManager, createSiblingActions, null);
createSiblingMenuManager.update(true);
}
}
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:48,代码来源:TracingannotationsActionBarContributor.java
示例6: selectionChanged
import org.eclipse.jface.viewers.SelectionChangedEvent; //导入方法依赖的package包/类
@Override
public void selectionChanged(SelectionChangedEvent event) {
try {
if (event.getSelection() instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
parentDialog.enableOK(selection.isEmpty() || ((TVObject) selection.getFirstElement()).isSelectable);
}
}
catch (Exception e) {
parentDialog.enableOK(false);
}
}
示例7: selectionChanged
import org.eclipse.jface.viewers.SelectionChangedEvent; //导入方法依赖的package包/类
/**
* Handles tree view selection
*/
public void selectionChanged(SelectionChangedEvent event) {
if (event.getSource() instanceof ISelectionProvider) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
TreeObject treeObject = (TreeObject) selection.getFirstElement();
if (treeObject != null) {
if (ILearnable.class.isAssignableFrom(this.getClass()) && (!HttpConnectorComposite.class.equals(this.getClass()))) {
ConnectorTreeObject connectorTreeObject = treeObject.getConnectorTreeObject();
if (connectorTreeObject != null) {
Connector connector = (Connector)connectorTreeObject.getObject();
if (connector.equals(this.connector)) {
if (treeObject instanceof TransactionTreeObject) {
if (!this.connector.isLearning())
toolBarSetEnable("Learn", true);
}
else {
if (!this.connector.isLearning())
toolBarSetEnable("Learn", false);
}
}
else {
if (!this.connector.isLearning())
toolBarSetEnable("Learn", false);
}
}
}
}
}
}
示例8: dbProcessesViewSelectionChanged
import org.eclipse.jface.viewers.SelectionChangedEvent; //导入方法依赖的package包/类
private void dbProcessesViewSelectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (selection.isEmpty()) {
selectedProcess = null;
dbProcessInfoView.hide();
} else {
IStructuredSelection structuredSelection = (IStructuredSelection)selection;
DBProcess process = (DBProcess)structuredSelection.getFirstElement();
selectedProcess = process;
dbProcessInfoView.show(process);
}
}
示例9: selectionChanged
import org.eclipse.jface.viewers.SelectionChangedEvent; //导入方法依赖的package包/类
@Override
public void selectionChanged(SelectionChangedEvent event) {
super.selectionChanged(event);
TreeSelection selection = (TreeSelection) event.getSelection();
PropertyElement propertyElement = (PropertyElement) selection.getFirstElement();
editor.setHighlightRange(propertyElement.getLineOffset(), 0, true);
TableViewer tableViewer = propEditor.getTableViewer();
StructuredSelection ss = new StructuredSelection(tableViewer.getElementAt(propertyElement
.getIndex()));
tableViewer.setSelection(ss, true);
}
示例10: selectionChanged
import org.eclipse.jface.viewers.SelectionChangedEvent; //导入方法依赖的package包/类
/**
* This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener},
* handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings
* that can be added to the selected object and updating the menus accordingly.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void selectionChanged ( SelectionChangedEvent event )
{
// Remove any menu items for old selection.
//
if ( createChildMenuManager != null )
{
depopulateManager ( createChildMenuManager, createChildActions );
}
if ( createSiblingMenuManager != null )
{
depopulateManager ( createSiblingMenuManager, createSiblingActions );
}
// Query the new selection for appropriate new child/sibling descriptors
//
Collection<?> newChildDescriptors = null;
Collection<?> newSiblingDescriptors = null;
ISelection selection = event.getSelection ();
if ( selection instanceof IStructuredSelection && ( (IStructuredSelection)selection ).size () == 1 )
{
Object object = ( (IStructuredSelection)selection ).getFirstElement ();
EditingDomain domain = ( (IEditingDomainProvider)activeEditorPart ).getEditingDomain ();
newChildDescriptors = domain.getNewChildDescriptors ( object, null );
newSiblingDescriptors = domain.getNewChildDescriptors ( null, object );
}
// Generate actions for selection; populate and redraw the menus.
//
createChildActions = generateCreateChildActions ( newChildDescriptors, selection );
createSiblingActions = generateCreateSiblingActions ( newSiblingDescriptors, selection );
if ( createChildMenuManager != null )
{
populateManager ( createChildMenuManager, createChildActions, null );
createChildMenuManager.update ( true );
}
if ( createSiblingMenuManager != null )
{
populateManager ( createSiblingMenuManager, createSiblingActions, null );
createSiblingMenuManager.update ( true );
}
}
示例11: selectionChanged
import org.eclipse.jface.viewers.SelectionChangedEvent; //导入方法依赖的package包/类
/**
* This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener},
* handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings
* that can be added to the selected object and updating the menus accordingly.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void selectionChanged(SelectionChangedEvent event) {
// Remove any menu items for old selection.
//
if (createChildMenuManager != null) {
depopulateManager(createChildMenuManager, createChildActions);
}
if (createSiblingMenuManager != null) {
depopulateManager(createSiblingMenuManager, createSiblingActions);
}
// Query the new selection for appropriate new child/sibling descriptors
//
Collection<?> newChildDescriptors = null;
Collection<?> newSiblingDescriptors = null;
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection
&& ((IStructuredSelection) selection).size() == 1) {
Object object = ((IStructuredSelection) selection)
.getFirstElement();
EditingDomain domain = ((IEditingDomainProvider) activeEditorPart)
.getEditingDomain();
newChildDescriptors = domain.getNewChildDescriptors(object, null);
newSiblingDescriptors = domain.getNewChildDescriptors(null, object);
}
// Generate actions for selection; populate and redraw the menus.
//
createChildActions = generateCreateChildActions(newChildDescriptors,
selection);
createSiblingActions = generateCreateSiblingActions(
newSiblingDescriptors, selection);
if (createChildMenuManager != null) {
populateManager(createChildMenuManager, createChildActions, null);
createChildMenuManager.update(true);
}
if (createSiblingMenuManager != null) {
populateManager(createSiblingMenuManager, createSiblingActions,
null);
createSiblingMenuManager.update(true);
}
}
示例12: selectionChanged
import org.eclipse.jface.viewers.SelectionChangedEvent; //导入方法依赖的package包/类
/**
* This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener},
* handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings
* that can be added to the selected object and updating the menus accordingly.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void selectionChanged ( SelectionChangedEvent event )
{
// Remove any menu items for old selection.
//
if ( createChildMenuManager != null )
{
depopulateManager ( createChildMenuManager, createChildSubmenuActions );
depopulateManager ( createChildMenuManager, createChildActions );
}
if ( createSiblingMenuManager != null )
{
depopulateManager ( createSiblingMenuManager, createSiblingSubmenuActions );
depopulateManager ( createSiblingMenuManager, createSiblingActions );
}
// Query the new selection for appropriate new child/sibling descriptors
//
Collection<?> newChildDescriptors = null;
Collection<?> newSiblingDescriptors = null;
ISelection selection = event.getSelection ();
if ( selection instanceof IStructuredSelection && ( (IStructuredSelection)selection ).size () == 1 )
{
Object object = ( (IStructuredSelection)selection ).getFirstElement ();
EditingDomain domain = ( (IEditingDomainProvider)activeEditorPart ).getEditingDomain ();
newChildDescriptors = domain.getNewChildDescriptors ( object, null );
newSiblingDescriptors = domain.getNewChildDescriptors ( null, object );
}
// Generate actions for selection; populate and redraw the menus.
//
createChildActions = generateCreateChildActions ( newChildDescriptors, selection );
createChildSubmenuActions = extractSubmenuActions ( createChildActions );
createSiblingActions = generateCreateSiblingActions ( newSiblingDescriptors, selection );
createSiblingSubmenuActions = extractSubmenuActions ( createSiblingActions );
if ( createChildMenuManager != null )
{
populateManager ( createChildMenuManager, createChildSubmenuActions, null );
populateManager ( createChildMenuManager, createChildActions, null );
createChildMenuManager.update ( true );
}
if ( createSiblingMenuManager != null )
{
populateManager ( createSiblingMenuManager, createSiblingSubmenuActions, null );
populateManager ( createSiblingMenuManager, createSiblingActions, null );
createSiblingMenuManager.update ( true );
}
}
示例13: selectionChanged
import org.eclipse.jface.viewers.SelectionChangedEvent; //导入方法依赖的package包/类
@Override
public void selectionChanged(final SelectionChangedEvent event) {
if (SelectionChangeListener.preMarker != null && SelectionChangeListener.preMarker.exists()) {
try {
if (event.getSelection().isEmpty()) {
// Deleting marker for element removed.
SelectionChangeListener.preMarker.delete();
} else {
if (SelectionChangeListener.preMarker.getAttribute("oldUri") == null) {
// Saving Uri of marker which before change
SelectionChangeListener.preMarker.setAttribute("oldUri",
SelectionChangeListener.preMarker.getAttribute("uri"));
}
// Updating Uri of Marker
MarkUtilities.setUri(SelectionChangeListener.preMarker, EcoreUtil
.getURI((EObject) SelectionChangeListener.preSelection.getFirstElement()).toString());
String text = null;
// According to selected element, setting the text.
// if (SelectionChangeListener.preSelection.getFirstElement() instanceof Identifiable) {
// text = MarkerFactory.reqIfToString(
// (Identifiable) SelectionChangeListener.preSelection.getFirstElement());
// }else
if (SelectionChangeListener.preSelection.getFirstElement() instanceof ENamedElement) {
text =
((ENamedElement) SelectionChangeListener.preSelection.getFirstElement()).getName();
} else if (!(SelectionChangeListener.preSelection
.getFirstElement() instanceof EModelElement)) {
text = MarkerFactory
.instanceToString((EObject) SelectionChangeListener.preSelection.getFirstElement());
}
// Saving text of marker which before change
if (SelectionChangeListener.preMarker.getAttribute("oldText") == null) {
SelectionChangeListener.preMarker.setAttribute("oldText",
MarkUtilities.getText(SelectionChangeListener.preMarker));
}
// Updating marker text.
MarkUtilities.setText(SelectionChangeListener.preMarker, text);
SelectionChangeListener.preMarker = null;
SelectionChangeListener.preSelection = null;
}
} catch (final CoreException e) {
e.printStackTrace();
}
}
if (SelectionChangeListener.preSelection == null
|| SelectionChangeListener.preSelection.getFirstElement() instanceof ENamedElement
// || SelectionChangeListener.preSelection.getFirstElement() instanceof Identifiable
|| !(SelectionChangeListener.preSelection.getFirstElement() instanceof EModelElement)) {
SelectionChangeListener.preSelection = (ITreeSelection) event.getSelection();
SelectionChangeListener.preMarker = MarkerFactory
.findMarkerByTreeSelection((ITreeSelection) event.getSelection(), this.eFile);
} else {
SelectionChangeListener.preSelection = (ITreeSelection) event.getSelection();
}
}