Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 4874 Details for
Bug 36888
Close the gap between original and working copies
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
code example
example.txt (text/plain), 3.70 KB, created by
Martin Aeschlimann
on 2003-05-14 12:16:33 EDT
(
hide
)
Description:
code example
Filename:
MIME Type:
Creator:
Martin Aeschlimann
Created:
2003-05-14 12:16:33 EDT
Size:
3.70 KB
patch
obsolete
>// action example > >public class ExampleAddConstructorsAction extends Action implements ISelectionChangedListener { > > private IType fSelectedType; > > public ExampleAddConstructorsAction() { > // set the label, tooltip ect > } > > public void selectionChanged(final SelectionChangedEvent event) { > Runnable runnable= new Runnable() { > public void run() { > internalSelectionChanged(event); > } > }; > JDTCompilationUnitOwner.getDefault().run(runnable); > } > > > private void internalSelectionChanged(SelectionChangedEvent event) { > fSelectedType= null; > boolean isEnabled= false; > > ISelection selection= event.getSelection(); > if (selection instanceof IStructuredSelection) { > Object first= ((IStructuredSelection) selection).getFirstElement(); > try { > if (first instanceof ICompilationUnit) { > ICompilationUnit cu= (ICompilationUnit) first; > IType[] types= cu.getTypes(); > isEnabled= types.length > 0 && !types[0].isInterface(); > fSelectedType= types[0]; > } else if (first instanceof IType) { > isEnabled= ((IType) first).isInterface(); > fSelectedType= ((IType) first); > } > } catch (JavaModelException e) { > // ignore > } > } > setEnabled(isEnabled); > } > > protected void run(final IStructuredSelection selection) { > if (fSelectedType != null) { > Runnable runnable= new Runnable() { > public void run() { > internalRun(selection); > } > }; > JDTCompilationUnitOwner.getDefault().run(runnable); > } > } > > private void internalRun(IStructuredSelection selection) { > // perform the action > } >} > >// content provider example > >public class ExampleContentProvider implements ITreeContentProvider { > > public Object[] getChildren(Object parentElement) { > if (parentElement instanceof IParent) { > final IParent elem= (IParent) parentElement; > final Object[][] res= new Object[][] {null }; > > Runnable runnable= new Runnable() { > public void run() { > try { > res[0]= elem.getChildren(); > } catch (JavaModelException e) { > JavaPlugin.log(e); > } > } > }; > > JDTCompilationUnitOwner.getDefault().run(runnable); > return res[0]; > } > return new Object[0]; > } > > public Object getParent(Object element) { > if (element instanceof IJavaElement) { > final IJavaElement elem= (IJavaElement) element; > final Object[] res= new Object[] {null }; > > Runnable runnable= new Runnable() { > public void run() { > res[0]= elem.getParent(); > } > }; > > JDTCompilationUnitOwner.getDefault().run(runnable); > return res[0]; > } > return null; > } > > public boolean hasChildren(Object element) { > if (element instanceof IParent) { > final IParent elem= (IParent) element; > final boolean[] res= new boolean[] {false }; > > Runnable runnable= new Runnable() { > public void run() { > try { > res[0]= elem.hasChildren(); > } catch (JavaModelException e) { > JavaPlugin.log(e); > } > } > }; > > JDTCompilationUnitOwner.getDefault().run(runnable); > return res[0]; > } > return false; > } > > public Object[] getElements(Object parentElement) { > return getChildren(parentElement); > } > > public void dispose() { > } > > public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { > } >} > >//the JDT CompilationUnitOwner: The world as seen by JDT and the Java editor >public class JDTCompilationUnitOwner /*extends CompilationUnitOwner*/ { > > private static JDTCompilationUnitOwner fgDefault= new JDTCompilationUnitOwner(); > > public static JDTCompilationUnitOwner getDefault() { > return fgDefault; // the JDT CompilationUnitOwner > } > > // defined by CompilationUnitOwner > public void run(Runnable runnable) { > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 36888
: 4874