本文整理匯總了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();
}
}