SlideShare una empresa de Scribd logo
1 de 16
Interfacing to Eclipse Standard Views




Eclipse contains a large number of standard views that can be extended
to support new languages or data models. This model focus on the
interface to the most common Eclipse views: Problems View, Outline
View, and the Properties View.




Redistribution and other use of this material requires written permission from The RCP Company.

L0001 - 2010-11-27
Problems View


The problems view is used to show resource markers, which can represent
anything(!), but normally are error conditions

Markers are installed on resources (IResource)
     The file of an editor is found via the editor input (IEditorInput) via
      adaption
       IFile res = (IFile)editor.getEditorInput().getAdapter(IFile.class);



     This only works for files in the workspace – not files opened via
      “File”→”Open File…” – for the later the above construct returns null




2
                                                                              L0001 - 2010-11-27
Markers (IMarker)


Markers are associated as detail data on resources (IResource)
Markers have a type, an unique ID (per resource) and a set of text attributes
New marker types are defined with the org.eclipse.core.resources.markers extension point
     Each marker type has a name, a set of super-marker-types, a persistence and a set
      of attributes
     The resulting new marker type will inherit all attributes from super-markertypes

Only persistent markers are saved between invocations
     A new marker type is non-persistent unless explicitly set

Basic marker types related to problems
     org.eclipse.core.resources.problemmarker – with attributes severity, message, and
      location
     org.eclipse.core.resources.textmarker – with attributes charStart, charEnd,
      lineNumber
All relevant marker related constants are defined in IMarker
Makers can be grouped in the Problems View via support in the
org.eclipse.ui.ide.markerSupport extension point


3
                                                                                          L0001 - 2010-11-27
Creating a new Marker Type


The extension for a new marker type is special
     The id of the new marker type is specified directly in the extension and
      not in a sub-element (like for views and perspectives)
     If no id is specified, the target Eclipse cannot start!!!



        <extension id="problem" name=“My Personal Problem"
            point="org.eclipse.core.resources.markers">
          <super type="org.eclipse.core.resources.problemmarker" />
        </extension>




4
                                                                           L0001 - 2010-11-27
Markers Manipulation


Markers are accessed using methods of IResource
     createMarker(type) – creates and returns a new marker of the specified
      type
     findMarker(id) – find a specific marker
     deleteMarkers(type, includeSubtypes, depth) – deletes all markers of the
      specified type
     …and many more…

Markers also has a large set of methods
     delete() – deletes the marker
     getType() – returns the type
     getAttribute(name) – returns the value of the attribute
     setAttribute(name, value) – sets the value of the attribute
     setAttributes(String[] attributeNames, Object[] values) – sets the values
      of many attributes


5
                                                                              L0001 - 2010-11-27
Working with Markers


To create a “problem” marker for a complete file, just use the following



         try {
            IFile file = myEditor.getFile();
            IMarker marker = file.createMarker(IMarker.PROBLEM);
            marker.setAttribute(IMarker.MESSAGE, "hello");
         } catch (CoreException e) {
            e.printStackTrace();
         }




6
                                                                          L0001 - 2010-11-27
Lab Exercise


Add a new marker type for your problems
     Use problemmarker and textmarker as super-types

Create markers for all errors at the end of each parse
     Remember to delete old markers

Do they show up in the problems view?

Do you see annotations and squibbles in the editor?




7
                                                         L0001 - 2010-11-27
Outline View


The Outline view shows an outline of domain model of the current editor
     Requires a domain model has been built
     Has dependency on org.eclipse.ui.views

The content of the outline view is supplied by the active editor via adaption
to IContentOutlinePage
     Result should inherit from ContentOutlinePage
     Cache returned object as this method is called often

        private IContentOutlinePage myContentOutlinePage = null;
        @Override
        public Object getAdapter(Class adapter) {
           if (adapter == IContentOutlinePage.class) {
               if (myContentOutlinePage == null) {
                   myContentOutlinePage = new NINEditorOutlinePage(this);
               }
               return myContentOutlinePage;
           }
           return super.getAdapter(adapter);
        }




8
                                                                            L0001 - 2010-11-27
Outline of Outline Page




public class NINEditorOutlinePage extends ContentOutlinePage {
  @Override
  public void createControl(Composite parent) {
     super.createControl(parent);
     final TreeViewer tree = getTreeViewer();
     tree.setLabelProvider(new MyLabelProvider());
     tree.setContentProvider(new MyContentProvider());
     tree.setInput(new Object());
     // Add listener on model, so tree can be refreshed when model is updated
  }
  private class MyLabelProvider extends LabelProvider { … }
  private class MyContentProvider implements ITreeContentProvider { … }
}




9
                                                                                L0001 - 2010-11-27
Outline View Extras


 To get popup menu
      Just install it in the tree – remember to register it

 To synchronize view with editor navigation
      Add navigation tracker in the editor and let the view listen

 To synchronize editor with selection in view
      Add selection listener in editor
      If current selection is a domain object of the editor, move to that
       position
        
            Use ITextViewer.revealRange(int offset, int length)

 To add filtering and sorting to view
      Extend ContentOutlinePage.setActionBars(IActionBars)




10
                                                                             L0001 - 2010-11-27
Lab Exercise


 Extend editor with support for outline view

 Synchronize the editor with the current selection in the view




11
                                                                 L0001 - 2010-11-27
Properties View


 The Properties view shows properties of the current selection
      Requires a domain model as been built in editor
      Has dependency on org.eclipse.ui.views

 A property source (IPropertySource) describes how the property view should
 show the properties of an object

 The content of the property view is supplied by the current selection via
 inheritance from or adaption to IPropertySource
      Inherits from IPropertySource
      Implements IAdaptable.getAdapter(IPropertySource.class)
        
            Can be accomplished via adapter factory




12
                                                                             L0001 - 2010-11-27
Implementation of Property Sources (IPropertySource)


 A property source describes the supported properties using descriptors
 (IPropertyDescriptor)
      A descriptor includes information about
        
            name, description, help
        
            optionally a label provider, how to create a property editor
        
            If it can create a property editor, it is settable
      The platform includes a number of standard descriptors
        
            PropertyDescriptor – read-only property
        
            TextPropertyDescriptor – text based property
        
            ColorPropertyDescriptor – color property
        
            ComboBoxPropertyDescriptor – list based property

 A property source can get and possibly set and reset property values




13
                                                                           L0001 - 2010-11-27
Interesting Parts of Property Source

public class ExPropertySource implements IPropertySource {
  … myObject;
  public IPropertyDescriptor[] getPropertyDescriptors() {
     return IPropertyDescriptor[] = { new TextPropertyDescriptor("name", "name") };
  }
  public Object getPropertyValue(Object id) {
     if ("name".equals(id)) {
         return myObject.getName();
     } else {
         return null;
     }
  }
  public void setPropertyValue(Object id, Object value) {
     if ("name".equals(id)) {
         myObject.setName((String) value);
     }
  }
}




14
                                                                                      L0001 - 2010-11-27
Lab Exercise


 Extend editor with support for properties view

 Add support for setting the name in the domain model
      Use IDocument.replace(offset, length, text)




15
                                                        L0001 - 2010-11-27
More Information


 “Mark My Words: Using markers to tell users about problems and tasks”
      http://www.eclipse.org/resources/resource.php?id=237
      
          Somewhat basic article on markers

 “Take control of your properties”
      http://www.eclipse.org/resources/resource.php?id=214
      
          Good introduction with plenty of code examples

 “The Eclipse Tabbed Properties View”
      http://www.eclipse.org/resources/resource.php?id=138
      
          Introduction to the new tabbed properties view




16
                                                                         L0001 - 2010-11-27

Más contenido relacionado

La actualidad más candente

Z blue introduction to gui (39023299)
Z blue   introduction to gui (39023299)Z blue   introduction to gui (39023299)
Z blue introduction to gui (39023299)Narayana Swamy
 
Java Swing
Java SwingJava Swing
Java SwingShraddha
 
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...Dave Steinberg
 
Eclipse Training - Standard Extension Points and APIs
Eclipse Training - Standard Extension Points and APIsEclipse Training - Standard Extension Points and APIs
Eclipse Training - Standard Extension Points and APIsLuca D'Onofrio
 
Basic using of Swing in Java
Basic using of Swing in JavaBasic using of Swing in Java
Basic using of Swing in Javasuraj pandey
 
Swing and Graphical User Interface in Java
Swing and Graphical User Interface in JavaSwing and Graphical User Interface in Java
Swing and Graphical User Interface in Javababak danyal
 
Complete java swing
Complete java swingComplete java swing
Complete java swingjehan1987
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1PRN USM
 

La actualidad más candente (20)

Introdu.awt
Introdu.awtIntrodu.awt
Introdu.awt
 
Chapter 1 swings
Chapter 1 swingsChapter 1 swings
Chapter 1 swings
 
Z blue introduction to gui (39023299)
Z blue   introduction to gui (39023299)Z blue   introduction to gui (39023299)
Z blue introduction to gui (39023299)
 
Swing
SwingSwing
Swing
 
Java Swing
Java SwingJava Swing
Java Swing
 
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...
 
Eclipse Training - Standard Extension Points and APIs
Eclipse Training - Standard Extension Points and APIsEclipse Training - Standard Extension Points and APIs
Eclipse Training - Standard Extension Points and APIs
 
java swing
java swingjava swing
java swing
 
Lab3-Android
Lab3-AndroidLab3-Android
Lab3-Android
 
Basic using of Swing in Java
Basic using of Swing in JavaBasic using of Swing in Java
Basic using of Swing in Java
 
Java swing
Java swingJava swing
Java swing
 
Swing and Graphical User Interface in Java
Swing and Graphical User Interface in JavaSwing and Graphical User Interface in Java
Swing and Graphical User Interface in Java
 
introduction of Java beans
introduction of Java beansintroduction of Java beans
introduction of Java beans
 
Bean Intro
Bean IntroBean Intro
Bean Intro
 
Complete java swing
Complete java swingComplete java swing
Complete java swing
 
Swings in java
Swings in javaSwings in java
Swings in java
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
 
Unit iv
Unit ivUnit iv
Unit iv
 
Java Beans
Java BeansJava Beans
Java Beans
 
javabeans
javabeansjavabeans
javabeans
 

Similar a L0043 - Interfacing to Eclipse Standard Views

react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryjanet736113
 
Swift Tableview iOS App Development
Swift Tableview iOS App DevelopmentSwift Tableview iOS App Development
Swift Tableview iOS App DevelopmentKetan Raval
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programmingNeelesh Shukla
 
Jetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedJetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedToru Wonyoung Choi
 
Ad103 - Have it Your Way: Extending IBM Lotus Domino Designer
Ad103 - Have it Your Way: Extending IBM Lotus Domino DesignerAd103 - Have it Your Way: Extending IBM Lotus Domino Designer
Ad103 - Have it Your Way: Extending IBM Lotus Domino Designerddrschiw
 
Joel Landis Net Portfolio
Joel Landis Net PortfolioJoel Landis Net Portfolio
Joel Landis Net Portfoliojlshare
 
Code camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una DalyCode camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una DalyUna Daly
 
A brief overview of java frameworks
A brief overview of java frameworksA brief overview of java frameworks
A brief overview of java frameworksMD Sayem Ahmed
 
OOPS IN PHP.pptx
OOPS IN PHP.pptxOOPS IN PHP.pptx
OOPS IN PHP.pptxrani marri
 
-Kotlin_Camp_Unit2.pptx
-Kotlin_Camp_Unit2.pptx-Kotlin_Camp_Unit2.pptx
-Kotlin_Camp_Unit2.pptxRishiGandhi19
 
Intro to iOS Development • Made by Many
Intro to iOS Development • Made by ManyIntro to iOS Development • Made by Many
Intro to iOS Development • Made by Manykenatmxm
 
Context and Dependency Injection 2.0
Context and Dependency Injection 2.0Context and Dependency Injection 2.0
Context and Dependency Injection 2.0Brian S. Paskin
 
Intro to Core Data
Intro to Core DataIntro to Core Data
Intro to Core DataMake School
 
Introduction to java beans
Introduction to java beansIntroduction to java beans
Introduction to java beansHitesh Parmar
 

Similar a L0043 - Interfacing to Eclipse Standard Views (20)

react-slides.pptx
react-slides.pptxreact-slides.pptx
react-slides.pptx
 
react-slides.pdf
react-slides.pdfreact-slides.pdf
react-slides.pdf
 
react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react library
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Swift Tableview iOS App Development
Swift Tableview iOS App DevelopmentSwift Tableview iOS App Development
Swift Tableview iOS App Development
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programming
 
Jetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedJetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO Extended
 
Ad103 - Have it Your Way: Extending IBM Lotus Domino Designer
Ad103 - Have it Your Way: Extending IBM Lotus Domino DesignerAd103 - Have it Your Way: Extending IBM Lotus Domino Designer
Ad103 - Have it Your Way: Extending IBM Lotus Domino Designer
 
Joel Landis Net Portfolio
Joel Landis Net PortfolioJoel Landis Net Portfolio
Joel Landis Net Portfolio
 
Advance RCP
Advance RCPAdvance RCP
Advance RCP
 
Code camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una DalyCode camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una Daly
 
A brief overview of java frameworks
A brief overview of java frameworksA brief overview of java frameworks
A brief overview of java frameworks
 
OOPS IN PHP.pptx
OOPS IN PHP.pptxOOPS IN PHP.pptx
OOPS IN PHP.pptx
 
EMF Tips n Tricks
EMF Tips n TricksEMF Tips n Tricks
EMF Tips n Tricks
 
-Kotlin_Camp_Unit2.pptx
-Kotlin_Camp_Unit2.pptx-Kotlin_Camp_Unit2.pptx
-Kotlin_Camp_Unit2.pptx
 
-Kotlin Camp Unit2.pptx
-Kotlin Camp Unit2.pptx-Kotlin Camp Unit2.pptx
-Kotlin Camp Unit2.pptx
 
Intro to iOS Development • Made by Many
Intro to iOS Development • Made by ManyIntro to iOS Development • Made by Many
Intro to iOS Development • Made by Many
 
Context and Dependency Injection 2.0
Context and Dependency Injection 2.0Context and Dependency Injection 2.0
Context and Dependency Injection 2.0
 
Intro to Core Data
Intro to Core DataIntro to Core Data
Intro to Core Data
 
Introduction to java beans
Introduction to java beansIntroduction to java beans
Introduction to java beans
 

Más de Tonny Madsen

L0037 - Basic Eclipse Configuration
L0037 - Basic Eclipse ConfigurationL0037 - Basic Eclipse Configuration
L0037 - Basic Eclipse ConfigurationTonny Madsen
 
L0016 - The Structure of an Eclipse Plug-in
L0016 - The Structure of an Eclipse Plug-inL0016 - The Structure of an Eclipse Plug-in
L0016 - The Structure of an Eclipse Plug-inTonny Madsen
 
L0001 - The Terminology of the Eclipse Platform
L0001 - The Terminology of the Eclipse PlatformL0001 - The Terminology of the Eclipse Platform
L0001 - The Terminology of the Eclipse PlatformTonny Madsen
 
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...Tonny Madsen
 
PROSA - Eclipse Is Just What?
PROSA - Eclipse Is Just What?PROSA - Eclipse Is Just What?
PROSA - Eclipse Is Just What?Tonny Madsen
 
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the FutureEclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the FutureTonny Madsen
 
Eclipse Demo Camp 2010 - UI Bindings - An Introduction
Eclipse Demo Camp 2010 - UI Bindings - An IntroductionEclipse Demo Camp 2010 - UI Bindings - An Introduction
Eclipse Demo Camp 2010 - UI Bindings - An IntroductionTonny Madsen
 
ITU - MDD – Model-to-Model Transformations
ITU - MDD – Model-to-Model TransformationsITU - MDD – Model-to-Model Transformations
ITU - MDD – Model-to-Model TransformationsTonny Madsen
 
IDA - Eclipse Workshop II (In Danish)
IDA - Eclipse Workshop II (In Danish)IDA - Eclipse Workshop II (In Danish)
IDA - Eclipse Workshop II (In Danish)Tonny Madsen
 
IDA - Eclipse Workshop I (In Danish)
IDA - Eclipse Workshop I (In Danish)IDA - Eclipse Workshop I (In Danish)
IDA - Eclipse Workshop I (In Danish)Tonny Madsen
 
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...Tonny Madsen
 
ITU - MDD - Eclipse Plug-ins
ITU - MDD - Eclipse Plug-insITU - MDD - Eclipse Plug-ins
ITU - MDD - Eclipse Plug-insTonny Madsen
 
eclipse.dk - Eclipse RCP Under the Hood
eclipse.dk - Eclipse RCP Under the Hoodeclipse.dk - Eclipse RCP Under the Hood
eclipse.dk - Eclipse RCP Under the HoodTonny Madsen
 
EclipseCon '08 - BoF - Building a local Eclipse user group
EclipseCon '08 - BoF - Building a local Eclipse user groupEclipseCon '08 - BoF - Building a local Eclipse user group
EclipseCon '08 - BoF - Building a local Eclipse user groupTonny Madsen
 
Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...
Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...
Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...Tonny Madsen
 
EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...
EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...
EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...Tonny Madsen
 
javagruppen.dk - e4, the next generation Eclipse platform
javagruppen.dk - e4, the next generation Eclipse platformjavagruppen.dk - e4, the next generation Eclipse platform
javagruppen.dk - e4, the next generation Eclipse platformTonny Madsen
 
ITU - MDD – Modeling Techniques
ITU - MDD – Modeling TechniquesITU - MDD – Modeling Techniques
ITU - MDD – Modeling TechniquesTonny Madsen
 

Más de Tonny Madsen (20)

L0037 - Basic Eclipse Configuration
L0037 - Basic Eclipse ConfigurationL0037 - Basic Eclipse Configuration
L0037 - Basic Eclipse Configuration
 
L0016 - The Structure of an Eclipse Plug-in
L0016 - The Structure of an Eclipse Plug-inL0016 - The Structure of an Eclipse Plug-in
L0016 - The Structure of an Eclipse Plug-in
 
L0001 - The Terminology of the Eclipse Platform
L0001 - The Terminology of the Eclipse PlatformL0001 - The Terminology of the Eclipse Platform
L0001 - The Terminology of the Eclipse Platform
 
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...
 
PROSA - Eclipse Is Just What?
PROSA - Eclipse Is Just What?PROSA - Eclipse Is Just What?
PROSA - Eclipse Is Just What?
 
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the FutureEclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
 
Eclipse Demo Camp 2010 - UI Bindings - An Introduction
Eclipse Demo Camp 2010 - UI Bindings - An IntroductionEclipse Demo Camp 2010 - UI Bindings - An Introduction
Eclipse Demo Camp 2010 - UI Bindings - An Introduction
 
ITU - MDD – Model-to-Model Transformations
ITU - MDD – Model-to-Model TransformationsITU - MDD – Model-to-Model Transformations
ITU - MDD – Model-to-Model Transformations
 
IDA - Eclipse Workshop II (In Danish)
IDA - Eclipse Workshop II (In Danish)IDA - Eclipse Workshop II (In Danish)
IDA - Eclipse Workshop II (In Danish)
 
IDA - Eclipse Workshop I (In Danish)
IDA - Eclipse Workshop I (In Danish)IDA - Eclipse Workshop I (In Danish)
IDA - Eclipse Workshop I (In Danish)
 
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...
 
ITU - MDD - EMF
ITU - MDD - EMFITU - MDD - EMF
ITU - MDD - EMF
 
ITU - MDD - Eclipse Plug-ins
ITU - MDD - Eclipse Plug-insITU - MDD - Eclipse Plug-ins
ITU - MDD - Eclipse Plug-ins
 
ITU - MDD - XText
ITU - MDD - XTextITU - MDD - XText
ITU - MDD - XText
 
eclipse.dk - Eclipse RCP Under the Hood
eclipse.dk - Eclipse RCP Under the Hoodeclipse.dk - Eclipse RCP Under the Hood
eclipse.dk - Eclipse RCP Under the Hood
 
EclipseCon '08 - BoF - Building a local Eclipse user group
EclipseCon '08 - BoF - Building a local Eclipse user groupEclipseCon '08 - BoF - Building a local Eclipse user group
EclipseCon '08 - BoF - Building a local Eclipse user group
 
Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...
Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...
Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...
 
EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...
EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...
EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...
 
javagruppen.dk - e4, the next generation Eclipse platform
javagruppen.dk - e4, the next generation Eclipse platformjavagruppen.dk - e4, the next generation Eclipse platform
javagruppen.dk - e4, the next generation Eclipse platform
 
ITU - MDD – Modeling Techniques
ITU - MDD – Modeling TechniquesITU - MDD – Modeling Techniques
ITU - MDD – Modeling Techniques
 

Último

Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 

Último (20)

Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 

L0043 - Interfacing to Eclipse Standard Views

  • 1. Interfacing to Eclipse Standard Views Eclipse contains a large number of standard views that can be extended to support new languages or data models. This model focus on the interface to the most common Eclipse views: Problems View, Outline View, and the Properties View. Redistribution and other use of this material requires written permission from The RCP Company. L0001 - 2010-11-27
  • 2. Problems View The problems view is used to show resource markers, which can represent anything(!), but normally are error conditions Markers are installed on resources (IResource)  The file of an editor is found via the editor input (IEditorInput) via adaption IFile res = (IFile)editor.getEditorInput().getAdapter(IFile.class);  This only works for files in the workspace – not files opened via “File”→”Open File…” – for the later the above construct returns null 2 L0001 - 2010-11-27
  • 3. Markers (IMarker) Markers are associated as detail data on resources (IResource) Markers have a type, an unique ID (per resource) and a set of text attributes New marker types are defined with the org.eclipse.core.resources.markers extension point  Each marker type has a name, a set of super-marker-types, a persistence and a set of attributes  The resulting new marker type will inherit all attributes from super-markertypes Only persistent markers are saved between invocations  A new marker type is non-persistent unless explicitly set Basic marker types related to problems  org.eclipse.core.resources.problemmarker – with attributes severity, message, and location  org.eclipse.core.resources.textmarker – with attributes charStart, charEnd, lineNumber All relevant marker related constants are defined in IMarker Makers can be grouped in the Problems View via support in the org.eclipse.ui.ide.markerSupport extension point 3 L0001 - 2010-11-27
  • 4. Creating a new Marker Type The extension for a new marker type is special  The id of the new marker type is specified directly in the extension and not in a sub-element (like for views and perspectives)  If no id is specified, the target Eclipse cannot start!!! <extension id="problem" name=“My Personal Problem" point="org.eclipse.core.resources.markers"> <super type="org.eclipse.core.resources.problemmarker" /> </extension> 4 L0001 - 2010-11-27
  • 5. Markers Manipulation Markers are accessed using methods of IResource  createMarker(type) – creates and returns a new marker of the specified type  findMarker(id) – find a specific marker  deleteMarkers(type, includeSubtypes, depth) – deletes all markers of the specified type  …and many more… Markers also has a large set of methods  delete() – deletes the marker  getType() – returns the type  getAttribute(name) – returns the value of the attribute  setAttribute(name, value) – sets the value of the attribute  setAttributes(String[] attributeNames, Object[] values) – sets the values of many attributes 5 L0001 - 2010-11-27
  • 6. Working with Markers To create a “problem” marker for a complete file, just use the following try { IFile file = myEditor.getFile(); IMarker marker = file.createMarker(IMarker.PROBLEM); marker.setAttribute(IMarker.MESSAGE, "hello"); } catch (CoreException e) { e.printStackTrace(); } 6 L0001 - 2010-11-27
  • 7. Lab Exercise Add a new marker type for your problems  Use problemmarker and textmarker as super-types Create markers for all errors at the end of each parse  Remember to delete old markers Do they show up in the problems view? Do you see annotations and squibbles in the editor? 7 L0001 - 2010-11-27
  • 8. Outline View The Outline view shows an outline of domain model of the current editor  Requires a domain model has been built  Has dependency on org.eclipse.ui.views The content of the outline view is supplied by the active editor via adaption to IContentOutlinePage  Result should inherit from ContentOutlinePage  Cache returned object as this method is called often private IContentOutlinePage myContentOutlinePage = null; @Override public Object getAdapter(Class adapter) { if (adapter == IContentOutlinePage.class) { if (myContentOutlinePage == null) { myContentOutlinePage = new NINEditorOutlinePage(this); } return myContentOutlinePage; } return super.getAdapter(adapter); } 8 L0001 - 2010-11-27
  • 9. Outline of Outline Page public class NINEditorOutlinePage extends ContentOutlinePage { @Override public void createControl(Composite parent) { super.createControl(parent); final TreeViewer tree = getTreeViewer(); tree.setLabelProvider(new MyLabelProvider()); tree.setContentProvider(new MyContentProvider()); tree.setInput(new Object()); // Add listener on model, so tree can be refreshed when model is updated } private class MyLabelProvider extends LabelProvider { … } private class MyContentProvider implements ITreeContentProvider { … } } 9 L0001 - 2010-11-27
  • 10. Outline View Extras To get popup menu  Just install it in the tree – remember to register it To synchronize view with editor navigation  Add navigation tracker in the editor and let the view listen To synchronize editor with selection in view  Add selection listener in editor  If current selection is a domain object of the editor, move to that position  Use ITextViewer.revealRange(int offset, int length) To add filtering and sorting to view  Extend ContentOutlinePage.setActionBars(IActionBars) 10 L0001 - 2010-11-27
  • 11. Lab Exercise Extend editor with support for outline view Synchronize the editor with the current selection in the view 11 L0001 - 2010-11-27
  • 12. Properties View The Properties view shows properties of the current selection  Requires a domain model as been built in editor  Has dependency on org.eclipse.ui.views A property source (IPropertySource) describes how the property view should show the properties of an object The content of the property view is supplied by the current selection via inheritance from or adaption to IPropertySource  Inherits from IPropertySource  Implements IAdaptable.getAdapter(IPropertySource.class)  Can be accomplished via adapter factory 12 L0001 - 2010-11-27
  • 13. Implementation of Property Sources (IPropertySource) A property source describes the supported properties using descriptors (IPropertyDescriptor)  A descriptor includes information about  name, description, help  optionally a label provider, how to create a property editor  If it can create a property editor, it is settable  The platform includes a number of standard descriptors  PropertyDescriptor – read-only property  TextPropertyDescriptor – text based property  ColorPropertyDescriptor – color property  ComboBoxPropertyDescriptor – list based property A property source can get and possibly set and reset property values 13 L0001 - 2010-11-27
  • 14. Interesting Parts of Property Source public class ExPropertySource implements IPropertySource { … myObject; public IPropertyDescriptor[] getPropertyDescriptors() { return IPropertyDescriptor[] = { new TextPropertyDescriptor("name", "name") }; } public Object getPropertyValue(Object id) { if ("name".equals(id)) { return myObject.getName(); } else { return null; } } public void setPropertyValue(Object id, Object value) { if ("name".equals(id)) { myObject.setName((String) value); } } } 14 L0001 - 2010-11-27
  • 15. Lab Exercise Extend editor with support for properties view Add support for setting the name in the domain model  Use IDocument.replace(offset, length, text) 15 L0001 - 2010-11-27
  • 16. More Information “Mark My Words: Using markers to tell users about problems and tasks”  http://www.eclipse.org/resources/resource.php?id=237  Somewhat basic article on markers “Take control of your properties”  http://www.eclipse.org/resources/resource.php?id=214  Good introduction with plenty of code examples “The Eclipse Tabbed Properties View”  http://www.eclipse.org/resources/resource.php?id=138  Introduction to the new tabbed properties view 16 L0001 - 2010-11-27

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. Now it&amp;#x2019;s time for the lab.\n
  8. \n
  9. \n
  10. \n
  11. Now it&amp;#x2019;s time for the lab.\n
  12. \n
  13. ColumnLabelProviders &amp;#x2013; as described in module L0011 &amp;#x201C;Contributing to the Eclipse User Interface&amp;#x201D; &amp;#x2013; can be used. (3.3 edition)\n
  14. \n
  15. Now it&amp;#x2019;s time for the lab.\n
  16. \n