本文整理匯總了Java中org.eclipse.jface.viewers.SelectionChangedEvent類的典型用法代碼示例。如果您正苦於以下問題:Java SelectionChangedEvent類的具體用法?Java SelectionChangedEvent怎麽用?Java SelectionChangedEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SelectionChangedEvent類屬於org.eclipse.jface.viewers包,在下文中一共展示了SelectionChangedEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setActiveEditor
import org.eclipse.jface.viewers.SelectionChangedEvent; //導入依賴的package包/類
/**
* When the active editor changes, this remembers the change and registers with it as a selection provider.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setActiveEditor(IEditorPart part) {
super.setActiveEditor(part);
activeEditorPart = part;
// Switch to the new selection provider.
//
if (selectionProvider != null) {
selectionProvider.removeSelectionChangedListener(this);
}
if (part == null) {
selectionProvider = null;
}
else {
selectionProvider = part.getSite().getSelectionProvider();
selectionProvider.addSelectionChangedListener(this);
// Fake a selection changed event to update the menus.
//
if (selectionProvider.getSelection() != null) {
selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()));
}
}
}
示例2: setActiveEditor
import org.eclipse.jface.viewers.SelectionChangedEvent; //導入依賴的package包/類
/**
* When the active editor changes, this remembers the change and registers with it as a selection provider.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setActiveEditor(IEditorPart part) {
super.setActiveEditor(part);
activeEditorPart = part;
// Switch to the new selection provider.
//
if (selectionProvider != null) {
selectionProvider.removeSelectionChangedListener(this);
}
if (part == null) {
selectionProvider = null;
}
else {
selectionProvider = part.getSite().getSelectionProvider();
selectionProvider.addSelectionChangedListener(this);
// Fake a selection changed event to update the menus.
//
if (selectionProvider.getSelection() != null) {
selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()));
}
}
}
示例3: handleSelectionChanged
import org.eclipse.jface.viewers.SelectionChangedEvent; //導入依賴的package包/類
protected void handleSelectionChanged ( final SelectionChangedEvent event )
{
if ( this.handlingEvent )
{
return;
}
final TreeNode node = (TreeNode) ( (IStructuredSelection)event.getSelection () ).getFirstElement ();
final TreeNode nodeShown = this.manager.showPage ( node );
try
{
this.handlingEvent = true;
// select the node, could also be the old one
this.viewer.setSelection ( new StructuredSelection ( nodeShown ), true );
}
finally
{
this.handlingEvent = false;
}
}
示例4: selectionChanged
import org.eclipse.jface.viewers.SelectionChangedEvent; //導入依賴的package包/類
@Override
public void selectionChanged(SelectionChangedEvent event) {
super.selectionChanged(event);
ISelection selection = event.getSelection();
if (selection.isEmpty()) {
sqlEditor.resetHighlightRange();
} else {
Segments segment = (Segments) ((IStructuredSelection) selection)
.getFirstElement();
int start = segment.getOffset();
int length = segment.getLength();
try {
sqlEditor.setHighlightRange(start, length, true);
sqlEditor.selectAndReveal(start, length);
} catch (IllegalArgumentException x) {
sqlEditor.resetHighlightRange();
}
}
}
示例5: selectionChanged
import org.eclipse.jface.viewers.SelectionChangedEvent; //導入依賴的package包/類
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
Object selected = selection.getFirstElement();
if (selected instanceof TemplateProvider) {
provider = (TemplateProvider) selected;
}
if (selected instanceof Folder) {
targetFolder = (Folder)selected;
}
if (selected instanceof InitialBuildPolicies) {
policies = ((InitialBuildPolicies) selected);
}
if (selected instanceof String) {
filename = ((String) selected);
}
fExtraPage.validatePage();
}
示例6: selectionChanged
import org.eclipse.jface.viewers.SelectionChangedEvent; //導入依賴的package包/類
public void selectionChanged(SelectionChangedEvent event) {
if (event.getSource() instanceof ISelectionProvider) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
TreeObject treeObject = (TreeObject) selection.getFirstElement();
if (treeObject != null) {
ConnectorTreeObject connectorTreeObject = treeObject.getConnectorTreeObject();
if (connectorTreeObject != null) {
Connector connector = (Connector)connectorTreeObject.getObject();
if (connector.equals(htmlConnector)) {
if (treeObject instanceof TransactionTreeObject) {
if (!htmlConnector.isLearning())
toolLearn.setEnabled(true);
}
else {
if (!htmlConnector.isLearning())
toolLearn.setEnabled(false);
}
}
else {
if (!htmlConnector.isLearning())
toolLearn.setEnabled(false);
}
}
}
}
}
示例7: selectionChanged
import org.eclipse.jface.viewers.SelectionChangedEvent; //導入依賴的package包/類
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
Object selected = selection.getFirstElement();
if (selected instanceof TemplateProvider) {
provider = (TemplateProvider) selected;
}
if (selected instanceof IFolder) {
targetFolder = ((IFolder) selected);
project = targetFolder.getProject();
}
if (selected instanceof InitialBuildPolicies) {
policies = ((InitialBuildPolicies) selected);
}
if (selected instanceof String) {
filename = ((String) selected);
}
fExtraPage.validatePage();
}
示例8: 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));
}
示例9: fireSelection
import org.eclipse.jface.viewers.SelectionChangedEvent; //導入依賴的package包/類
/**
* Call to programmatically fire a selection. This should be called directly from outside
* this class to set the workbench selection when the elements in the selection are not
* in the wrapped selection provider (e.g. a {@link TableViewer}).
* @param selection selection to fire
*/
public void fireSelection(ISelection selection) {
if (listeners.isEmpty()) return;
SelectionChangedEvent e = new SelectionChangedEvent(this, selection);
ISelectionChangedListener[] sl = listeners.toArray(new ISelectionChangedListener[listeners.size()]);
for (ISelectionChangedListener s : sl) s.selectionChanged(e);
}
示例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: onSelectionChanged
import org.eclipse.jface.viewers.SelectionChangedEvent; //導入依賴的package包/類
protected void onSelectionChanged(@SuppressWarnings("unused") SelectionChangedEvent event) {
final ListEntry selEntry = getSingleSelectedEntry();
if (selEntry != null) {
canvas.setGraph(selEntry.graph);
} else {
canvas.clear();
}
}
示例12: setSelection
import org.eclipse.jface.viewers.SelectionChangedEvent; //導入依賴的package包/類
@Override
public void setSelection(ISelection selection) {
currentEditorSelection = selection;
for (ISelectionChangedListener listener : selectionChangedListeners) {
listener.selectionChanged(new SelectionChangedEvent(this, selection));
}
}
示例13: initialize
import org.eclipse.jface.viewers.SelectionChangedEvent; //導入依賴的package包/類
public void initialize(String widgetid, boolean active) {
setEnabled(active);
setContentProvider(new IStructuredContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
List<IFile> files = (List<IFile>) inputElement;
Object[] ret = new Object[files.size()];
int index = 0;
for (IFile file : files) {
ret[index++] = JavaCore.create(file);
}
return ret;
}
});
setLabelProvider(new JavaElementLabelProvider(
JavaElementLabelProvider.SHOW_QUALIFIED | JavaElementLabelProvider.SHOW_ROOT));
addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection.size() > 0) {
ICompilationUnit element = (ICompilationUnit) selection.getFirstElement();
GeneratorChoiceComposite.this.pkgf = (IPackageFragment) element.getParent();
listener.handleEvent(null);
}
}
});
setData(GW4E_CONVERSION_WIDGET_ID, widgetid);
setInput(ancestors);
if (active && hasItems()) {
setSelection(new StructuredSelection(JavaCore.create(ancestors.get(0))));
}
}
示例14: 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);
}
}
示例15: setSelection
import org.eclipse.jface.viewers.SelectionChangedEvent; //導入依賴的package包/類
/**
* This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection.
* Calling this result will notify the listeners.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setSelection(ISelection selection) {
editorSelection = selection;
for (ISelectionChangedListener listener : selectionChangedListeners) {
listener.selectionChanged(new SelectionChangedEvent(this, selection));
}
setStatusLineManager(selection);
}