├── .gitignore ├── LICENSE ├── README.md ├── e3-based-application ├── org.fipro.eclipse.migration.feature │ ├── .project │ ├── build.properties │ └── feature.xml ├── org.fipro.eclipse.migration.model │ ├── .classpath │ ├── .project │ ├── .settings │ │ └── org.eclipse.jdt.core.prefs │ ├── META-INF │ │ └── MANIFEST.MF │ ├── build.properties │ └── src │ │ └── org │ │ └── fipro │ │ └── eclipse │ │ └── migration │ │ └── model │ │ ├── ModelObject.java │ │ └── Person.java ├── org.fipro.eclipse.migration.product │ ├── .project │ └── org.fipro.eclipse.migration.product ├── org.fipro.eclipse.migration.service │ ├── .classpath │ ├── .project │ ├── .settings │ │ └── org.eclipse.jdt.core.prefs │ ├── META-INF │ │ └── MANIFEST.MF │ ├── build.properties │ └── src │ │ └── org │ │ └── fipro │ │ └── eclipse │ │ └── migration │ │ └── service │ │ └── PersonServiceImpl.java ├── org.fipro.eclipse.migration.target │ ├── .project │ └── org.fipro.eclipse.migration.target.target └── org.fipro.eclipse.migration.ui │ ├── .classpath │ ├── .project │ ├── .settings │ └── org.eclipse.jdt.core.prefs │ ├── META-INF │ └── MANIFEST.MF │ ├── build.properties │ ├── icons │ ├── checked.gif │ ├── eclipse16.gif │ ├── eclipse16.png │ ├── eclipse256.gif │ ├── eclipse256.png │ ├── eclipse32.gif │ ├── eclipse32.png │ ├── eclipse48.png │ ├── eclipse_lg.png │ ├── editor.gif │ ├── environment_obj.gif │ ├── prop_ps.gif │ └── unchecked.gif │ ├── plugin.xml │ └── src │ └── org │ └── fipro │ └── eclipse │ └── migration │ └── ui │ ├── Activator.java │ ├── Application.java │ ├── ApplicationActionBarAdvisor.java │ ├── ApplicationWorkbenchAdvisor.java │ ├── ApplicationWorkbenchWindowAdvisor.java │ ├── Perspective.java │ ├── action │ └── OpenDialogAction.java │ ├── editor │ ├── PersonEditor.java │ └── PersonEditorInput.java │ ├── handler │ └── OpenDialogHandler.java │ ├── preferences │ └── DescriptionPreferencePage.java │ └── view │ ├── DescriptionView.java │ ├── DetailView.java │ └── overview │ ├── FirstNameEditingSupport.java │ ├── FirstNameLabelProvider.java │ ├── GenderEditingSupport.java │ ├── GenderLabelProvider.java │ ├── LastNameEditingSupport.java │ ├── LastNameLabelProvider.java │ ├── MarriedEditingSupport.java │ ├── MarriedLabelProvider.java │ └── OverviewView.java └── e4-based-application ├── org.fipro.eclipse.migration.e4.feature ├── .project ├── build.properties └── feature.xml ├── org.fipro.eclipse.migration.e4.model ├── .classpath ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs ├── META-INF │ └── MANIFEST.MF ├── build.properties └── src │ └── org │ └── fipro │ └── eclipse │ └── migration │ └── e4 │ └── model │ ├── ModelObject.java │ └── Person.java ├── org.fipro.eclipse.migration.e4.product ├── .project └── org.fipro.eclipse.migration.e4.product ├── org.fipro.eclipse.migration.e4.service.preferences ├── .classpath ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs ├── META-INF │ └── MANIFEST.MF ├── OSGI-INF │ └── org.fipro.eclipse.migration.e4.service.preferences.impl.PreferenceManagerSupplier.xml ├── build.properties └── src │ └── org │ └── fipro │ └── eclipse │ └── migration │ └── e4 │ └── service │ └── preferences │ ├── ContributedPreferenceNode.java │ ├── PrefMgr.java │ ├── PreferenceNodeContribution.java │ └── impl │ ├── PreferenceManagerSupplier.java │ └── ScopedPreferenceStore.java ├── org.fipro.eclipse.migration.e4.service ├── .classpath ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs ├── META-INF │ └── MANIFEST.MF ├── OSGI-INF │ └── org.fipro.eclipse.migration.e4.service.internal.PersonServiceImpl.xml ├── build.properties └── src │ └── org │ └── fipro │ └── eclipse │ └── migration │ └── e4 │ └── service │ ├── PersonService.java │ └── internal │ └── PersonServiceImpl.java ├── org.fipro.eclipse.migration.e4.target ├── .project └── org.fipro.eclipse.migration.e4.target.target └── org.fipro.eclipse.migration.e4.ui ├── .classpath ├── .project ├── .settings └── org.eclipse.jdt.core.prefs ├── Application.e4xmi ├── META-INF └── MANIFEST.MF ├── OSGI-INF └── org.fipro.eclipse.migration.e4.ui.preferences.DescriptionPreferenceContribution.xml ├── build.properties ├── fragment.e4xmi ├── icons ├── checked.gif ├── eclipse16.gif ├── eclipse16.png ├── eclipse256.gif ├── eclipse256.png ├── eclipse32.gif ├── eclipse32.png ├── eclipse48.png ├── eclipse_lg.png ├── editor.gif ├── environment_obj.gif ├── prop_ps.gif └── unchecked.gif ├── plugin.xml └── src └── org └── fipro └── eclipse └── migration └── e4 └── ui ├── PerspectiveSwitcher.java ├── PerspectiveSwitcherAddon.java ├── action └── OpenDialogAction.java ├── editor └── PersonEditor.java ├── handler ├── OpenDialogHandler.java ├── PreferencesHandler.java └── SaveHandler.java ├── preferences ├── DescriptionPreferenceContribution.java └── DescriptionPreferencePage.java └── view ├── DescriptionView.java ├── DetailView.java └── overview ├── FirstNameEditingSupport.java ├── FirstNameLabelProvider.java ├── GenderEditingSupport.java ├── GenderLabelProvider.java ├── LastNameEditingSupport.java ├── LastNameLabelProvider.java ├── MarriedEditingSupport.java ├── MarriedLabelProvider.java └── OverviewView.java /.gitignore: -------------------------------------------------------------------------------- 1 | #Ignore all bin folders 2 | bin/ 3 | target/ 4 | #Ignore all .settings folders 5 | */.settings/ 6 | #Ignore vi temporary files 7 | *~ 8 | *.orig 9 | *.patch 10 | class/ 11 | *.class -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Eclipse Public License - v 1.0 2 | 3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 4 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 5 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 6 | 7 | 1. DEFINITIONS 8 | 9 | "Contribution" means: 10 | 11 | a) in the case of the initial Contributor, the initial code and documentation 12 | distributed under this Agreement, and 13 | b) in the case of each subsequent Contributor: 14 | i) changes to the Program, and 15 | ii) additions to the Program; 16 | 17 | where such changes and/or additions to the Program originate from and are 18 | distributed by that particular Contributor. A Contribution 'originates' 19 | from a Contributor if it was added to the Program by such Contributor 20 | itself or anyone acting on such Contributor's behalf. Contributions do not 21 | include additions to the Program which: (i) are separate modules of 22 | software distributed in conjunction with the Program under their own 23 | license agreement, and (ii) are not derivative works of the Program. 24 | 25 | "Contributor" means any person or entity that distributes the Program. 26 | 27 | "Licensed Patents" mean patent claims licensable by a Contributor which are 28 | necessarily infringed by the use or sale of its Contribution alone or when 29 | combined with the Program. 30 | 31 | "Program" means the Contributions distributed in accordance with this 32 | Agreement. 33 | 34 | "Recipient" means anyone who receives the Program under this Agreement, 35 | including all Contributors. 36 | 37 | 2. GRANT OF RIGHTS 38 | a) Subject to the terms of this Agreement, each Contributor hereby grants 39 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 40 | reproduce, prepare derivative works of, publicly display, publicly 41 | perform, distribute and sublicense the Contribution of such Contributor, 42 | if any, and such derivative works, in source code and object code form. 43 | b) Subject to the terms of this Agreement, each Contributor hereby grants 44 | Recipient a non-exclusive, worldwide, royalty-free patent license under 45 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 46 | transfer the Contribution of such Contributor, if any, in source code and 47 | object code form. This patent license shall apply to the combination of 48 | the Contribution and the Program if, at the time the Contribution is 49 | added by the Contributor, such addition of the Contribution causes such 50 | combination to be covered by the Licensed Patents. The patent license 51 | shall not apply to any other combinations which include the Contribution. 52 | No hardware per se is licensed hereunder. 53 | c) Recipient understands that although each Contributor grants the licenses 54 | to its Contributions set forth herein, no assurances are provided by any 55 | Contributor that the Program does not infringe the patent or other 56 | intellectual property rights of any other entity. Each Contributor 57 | disclaims any liability to Recipient for claims brought by any other 58 | entity based on infringement of intellectual property rights or 59 | otherwise. As a condition to exercising the rights and licenses granted 60 | hereunder, each Recipient hereby assumes sole responsibility to secure 61 | any other intellectual property rights needed, if any. For example, if a 62 | third party patent license is required to allow Recipient to distribute 63 | the Program, it is Recipient's responsibility to acquire that license 64 | before distributing the Program. 65 | d) Each Contributor represents that to its knowledge it has sufficient 66 | copyright rights in its Contribution, if any, to grant the copyright 67 | license set forth in this Agreement. 68 | 69 | 3. REQUIREMENTS 70 | 71 | A Contributor may choose to distribute the Program in object code form under 72 | its own license agreement, provided that: 73 | 74 | a) it complies with the terms and conditions of this Agreement; and 75 | b) its license agreement: 76 | i) effectively disclaims on behalf of all Contributors all warranties 77 | and conditions, express and implied, including warranties or 78 | conditions of title and non-infringement, and implied warranties or 79 | conditions of merchantability and fitness for a particular purpose; 80 | ii) effectively excludes on behalf of all Contributors all liability for 81 | damages, including direct, indirect, special, incidental and 82 | consequential damages, such as lost profits; 83 | iii) states that any provisions which differ from this Agreement are 84 | offered by that Contributor alone and not by any other party; and 85 | iv) states that source code for the Program is available from such 86 | Contributor, and informs licensees how to obtain it in a reasonable 87 | manner on or through a medium customarily used for software exchange. 88 | 89 | When the Program is made available in source code form: 90 | 91 | a) it must be made available under this Agreement; and 92 | b) a copy of this Agreement must be included with each copy of the Program. 93 | Contributors may not remove or alter any copyright notices contained 94 | within the Program. 95 | 96 | Each Contributor must identify itself as the originator of its Contribution, 97 | if 98 | any, in a manner that reasonably allows subsequent Recipients to identify the 99 | originator of the Contribution. 100 | 101 | 4. COMMERCIAL DISTRIBUTION 102 | 103 | Commercial distributors of software may accept certain responsibilities with 104 | respect to end users, business partners and the like. While this license is 105 | intended to facilitate the commercial use of the Program, the Contributor who 106 | includes the Program in a commercial product offering should do so in a manner 107 | which does not create potential liability for other Contributors. Therefore, 108 | if a Contributor includes the Program in a commercial product offering, such 109 | Contributor ("Commercial Contributor") hereby agrees to defend and indemnify 110 | every other Contributor ("Indemnified Contributor") against any losses, 111 | damages and costs (collectively "Losses") arising from claims, lawsuits and 112 | other legal actions brought by a third party against the Indemnified 113 | Contributor to the extent caused by the acts or omissions of such Commercial 114 | Contributor in connection with its distribution of the Program in a commercial 115 | product offering. The obligations in this section do not apply to any claims 116 | or Losses relating to any actual or alleged intellectual property 117 | infringement. In order to qualify, an Indemnified Contributor must: 118 | a) promptly notify the Commercial Contributor in writing of such claim, and 119 | b) allow the Commercial Contributor to control, and cooperate with the 120 | Commercial Contributor in, the defense and any related settlement 121 | negotiations. The Indemnified Contributor may participate in any such claim at 122 | its own expense. 123 | 124 | For example, a Contributor might include the Program in a commercial product 125 | offering, Product X. That Contributor is then a Commercial Contributor. If 126 | that Commercial Contributor then makes performance claims, or offers 127 | warranties related to Product X, those performance claims and warranties are 128 | such Commercial Contributor's responsibility alone. Under this section, the 129 | Commercial Contributor would have to defend claims against the other 130 | Contributors related to those performance claims and warranties, and if a 131 | court requires any other Contributor to pay any damages as a result, the 132 | Commercial Contributor must pay those damages. 133 | 134 | 5. NO WARRANTY 135 | 136 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN 137 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR 138 | IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, 139 | NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each 140 | Recipient is solely responsible for determining the appropriateness of using 141 | and distributing the Program and assumes all risks associated with its 142 | exercise of rights under this Agreement , including but not limited to the 143 | risks and costs of program errors, compliance with applicable laws, damage to 144 | or loss of data, programs or equipment, and unavailability or interruption of 145 | operations. 146 | 147 | 6. DISCLAIMER OF LIABILITY 148 | 149 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 150 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 151 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 152 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 153 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 154 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 155 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 156 | OF SUCH DAMAGES. 157 | 158 | 7. GENERAL 159 | 160 | If any provision of this Agreement is invalid or unenforceable under 161 | applicable law, it shall not affect the validity or enforceability of the 162 | remainder of the terms of this Agreement, and without further action by the 163 | parties hereto, such provision shall be reformed to the minimum extent 164 | necessary to make such provision valid and enforceable. 165 | 166 | If Recipient institutes patent litigation against any entity (including a 167 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 168 | (excluding combinations of the Program with other software or hardware) 169 | infringes such Recipient's patent(s), then such Recipient's rights granted 170 | under Section 2(b) shall terminate as of the date such litigation is filed. 171 | 172 | All Recipient's rights under this Agreement shall terminate if it fails to 173 | comply with any of the material terms or conditions of this Agreement and does 174 | not cure such failure in a reasonable period of time after becoming aware of 175 | such noncompliance. If all Recipient's rights under this Agreement terminate, 176 | Recipient agrees to cease use and distribution of the Program as soon as 177 | reasonably practicable. However, Recipient's obligations under this Agreement 178 | and any licenses granted by Recipient relating to the Program shall continue 179 | and survive. 180 | 181 | Everyone is permitted to copy and distribute copies of this Agreement, but in 182 | order to avoid inconsistency the Agreement is copyrighted and may only be 183 | modified in the following manner. The Agreement Steward reserves the right to 184 | publish new versions (including revisions) of this Agreement from time to 185 | time. No one other than the Agreement Steward has the right to modify this 186 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 187 | Eclipse Foundation may assign the responsibility to serve as the Agreement 188 | Steward to a suitable separate entity. Each new version of the Agreement will 189 | be given a distinguishing version number. The Program (including 190 | Contributions) may always be distributed subject to the version of the 191 | Agreement under which it was received. In addition, after a new version of the 192 | Agreement is published, Contributor may elect to distribute the Program 193 | (including its Contributions) under the new version. Except as expressly 194 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 195 | licenses to the intellectual property of any Contributor under this Agreement, 196 | whether expressly, by implication, estoppel or otherwise. All rights in the 197 | Program not expressly granted under this Agreement are reserved. 198 | 199 | This Agreement is governed by the laws of the State of New York and the 200 | intellectual property laws of the United States of America. No party to this 201 | Agreement will bring a legal action under this Agreement more than one year 202 | after the cause of action arose. Each party waives its rights to a jury trial in 203 | any resulting litigation. 204 | 205 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # e4-cookbook-migration-guide 2 |

3 | This project is used to show the basics steps in migrating an Eclipse 3.x based application to an Eclipse 4.x based application.
4 | The e3-based-application folder contains the Eclipse 3.x based application that will be migrated to Eclipse 4.
5 | The e4-based-application folder contains the Eclipse application after the migration. 6 |

7 | The German article to this repository can be found here: 8 | Tutorial: So portieren Sie Eclipse-3-Anwendungen auf Eclipse 4 -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.feature/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.fipro.eclipse.migration.feature 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.pde.FeatureBuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.pde.FeatureNature 16 | 17 | 18 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.feature/build.properties: -------------------------------------------------------------------------------- 1 | bin.includes = feature.xml 2 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.feature/feature.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | [Enter Feature Description here.] 9 | 10 | 11 | 12 | [Enter Copyright Description here.] 13 | 14 | 15 | 16 | [Enter License Description here.] 17 | 18 | 19 | 25 | 26 | 32 | 33 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.model/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.model/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.fipro.eclipse.migration.model 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.pde.PluginNature 26 | org.eclipse.jdt.core.javanature 27 | 28 | 29 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.model/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 4 | org.eclipse.jdt.core.compiler.compliance=1.7 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.7 8 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.model/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Migration Application Model 4 | Bundle-SymbolicName: org.fipro.eclipse.migration.model 5 | Bundle-Version: 1.0.0.qualifier 6 | Bundle-RequiredExecutionEnvironment: JavaSE-1.7 7 | Export-Package: org.fipro.eclipse.migration.model 8 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.model/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = bin/ 3 | bin.includes = META-INF/,\ 4 | . 5 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/ModelObject.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.model; 2 | 3 | import java.beans.PropertyChangeListener; 4 | import java.beans.PropertyChangeSupport; 5 | 6 | public class ModelObject { 7 | 8 | private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this); 9 | 10 | public void addPropertyChangeListener(PropertyChangeListener listener) { 11 | changeSupport.addPropertyChangeListener(listener); 12 | } 13 | 14 | public void removePropertyChangeListener(PropertyChangeListener listener) { 15 | changeSupport.removePropertyChangeListener(listener); 16 | } 17 | 18 | public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { 19 | changeSupport.addPropertyChangeListener(propertyName, listener); 20 | } 21 | 22 | public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { 23 | changeSupport.removePropertyChangeListener(propertyName, listener); 24 | } 25 | 26 | protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { 27 | changeSupport.firePropertyChange(propertyName, oldValue, newValue); 28 | } 29 | } -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.model/src/org/fipro/eclipse/migration/model/Person.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.model; 2 | 3 | import java.util.Date; 4 | 5 | public class Person extends ModelObject { 6 | 7 | public enum Gender { 8 | MALE, FEMALE 9 | } 10 | 11 | private final int id; 12 | private String firstName; 13 | private String lastName; 14 | private Gender gender; 15 | private boolean married; 16 | private Date birthday; 17 | 18 | public Person(int id) { 19 | this.id = id; 20 | } 21 | 22 | public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { 23 | this.id = id; 24 | this.firstName = firstName; 25 | this.lastName = lastName; 26 | this.gender = gender; 27 | this.married = married; 28 | this.birthday = birthday; 29 | } 30 | 31 | public Person(Person base) { 32 | this.id = base.id; 33 | this.firstName = base.firstName; 34 | this.lastName = base.lastName; 35 | this.gender = base.gender; 36 | this.married = base.married; 37 | this.birthday = base.birthday; 38 | } 39 | 40 | public int getId() { 41 | return id; 42 | } 43 | 44 | public String getFirstName() { 45 | return firstName; 46 | } 47 | 48 | public void setFirstName(String firstName) { 49 | firePropertyChange("firstName", this.firstName, this.firstName = firstName); 50 | } 51 | 52 | public String getLastName() { 53 | return lastName; 54 | } 55 | 56 | public void setLastName(String lastName) { 57 | firePropertyChange("lastName", this.lastName, this.lastName = lastName); 58 | } 59 | 60 | public Gender getGender() { 61 | return gender; 62 | } 63 | 64 | public void setGender(Gender gender) { 65 | firePropertyChange("gender", this.gender, this.gender = gender); 66 | } 67 | 68 | public boolean isMarried() { 69 | return married; 70 | } 71 | 72 | public void setMarried(boolean married) { 73 | firePropertyChange("married", this.married, this.married = married); 74 | } 75 | 76 | public Date getBirthday() { 77 | return birthday; 78 | } 79 | 80 | public void setBirthday(Date birthday) { 81 | this.birthday = birthday; 82 | } 83 | 84 | @Override 85 | public int hashCode() { 86 | final int prime = 31; 87 | int result = 1; 88 | result = prime * result + id; 89 | return result; 90 | } 91 | 92 | @Override 93 | public boolean equals(Object obj) { 94 | if (this == obj) 95 | return true; 96 | if (obj == null) 97 | return false; 98 | if (getClass() != obj.getClass()) 99 | return false; 100 | Person other = (Person) obj; 101 | if (id != other.id) 102 | return false; 103 | return true; 104 | } 105 | 106 | } -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.product/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.fipro.eclipse.migration.product 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.product/org.fipro.eclipse.migration.product: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.service/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.service/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.fipro.eclipse.migration.service 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.pde.PluginNature 26 | org.eclipse.jdt.core.javanature 27 | 28 | 29 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.service/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 4 | org.eclipse.jdt.core.compiler.compliance=1.7 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.7 8 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.service/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Migration Application Services 4 | Bundle-SymbolicName: org.fipro.eclipse.migration.service 5 | Bundle-Version: 1.0.0.qualifier 6 | Bundle-RequiredExecutionEnvironment: JavaSE-1.7 7 | Require-Bundle: org.fipro.eclipse.migration.model;bundle-version="1.0.0" 8 | Export-Package: org.fipro.eclipse.migration.service 9 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.service/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = bin/ 3 | bin.includes = META-INF/,\ 4 | . 5 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.service/src/org/fipro/eclipse/migration/service/PersonServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.service; 2 | 3 | import java.text.ParseException; 4 | import java.text.SimpleDateFormat; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | import java.util.Random; 8 | 9 | import org.fipro.eclipse.migration.model.Person; 10 | 11 | /** 12 | * Class that acts as service for accessing numerous {@link Person}s. 13 | * The values are randomly put together out of names and places from "The Simpsons" 14 | */ 15 | public class PersonServiceImpl { 16 | 17 | public static String[] maleNames = { 18 | "Bart", 19 | "Homer", 20 | "Lenny", 21 | "Carl", 22 | "Waylon", 23 | "Ned", 24 | "Timothy"}; 25 | public static String[] femaleNames = { 26 | "Marge", 27 | "Lisa", 28 | "Maggie", 29 | "Edna", 30 | "Helen", 31 | "Jessica"}; 32 | public static String[] lastNames = { 33 | "Simpson", 34 | "Leonard", 35 | "Carlson", 36 | "Smithers", 37 | "Flanders", 38 | "Krabappel", 39 | "Lovejoy"}; 40 | 41 | /** 42 | * Creates a list of {@link Person}s. 43 | * @param numberOfPersons The number of {@link Person}s that should be generated. 44 | * @return 45 | */ 46 | public static List getPersons(int numberOfPersons) { 47 | List result = new ArrayList(); 48 | 49 | for (int i = 0; i < numberOfPersons; i++) { 50 | result.add(createPerson(i)); 51 | } 52 | 53 | return result; 54 | } 55 | 56 | /** 57 | * Creates a random person out of names which are taken from "The Simpsons" 58 | * and enrich them with random generated married state and birthday date. 59 | * @return 60 | */ 61 | public static Person createPerson(int id) { 62 | Random randomGenerator = new Random(); 63 | 64 | Person result = new Person(id); 65 | result.setGender(Person.Gender.values()[randomGenerator.nextInt(2)]); 66 | 67 | if (result.getGender().equals(Person.Gender.MALE)) { 68 | result.setFirstName(maleNames[randomGenerator.nextInt(maleNames.length)]); 69 | } 70 | else { 71 | result.setFirstName(femaleNames[randomGenerator.nextInt(femaleNames.length)]); 72 | } 73 | 74 | result.setLastName(lastNames[randomGenerator.nextInt(lastNames.length)]); 75 | result.setMarried(randomGenerator.nextBoolean()); 76 | 77 | int month = randomGenerator.nextInt(12); 78 | int day = 0; 79 | if (month == 2) { 80 | day = randomGenerator.nextInt(28); 81 | } 82 | else { 83 | day = randomGenerator.nextInt(30); 84 | } 85 | int year = 1920 + randomGenerator.nextInt(90); 86 | 87 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 88 | try { 89 | result.setBirthday(sdf.parse(""+year+"-"+month+"-"+day)); 90 | } catch (ParseException e) { 91 | e.printStackTrace(); 92 | } 93 | 94 | return result; 95 | } 96 | 97 | } -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.target/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.fipro.eclipse.migration.target 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.target/org.fipro.eclipse.migration.target.target: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.fipro.eclipse.migration.ui 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.pde.PluginNature 26 | org.eclipse.jdt.core.javanature 27 | 28 | 29 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 4 | org.eclipse.jdt.core.compiler.compliance=1.7 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.7 8 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Migration Application UI 4 | Bundle-SymbolicName: org.fipro.eclipse.migration.ui;singleton:=true 5 | Bundle-Version: 1.0.0.qualifier 6 | Bundle-Activator: org.fipro.eclipse.migration.ui.Activator 7 | Require-Bundle: org.eclipse.ui, 8 | org.eclipse.core.runtime, 9 | org.fipro.eclipse.migration.model;bundle-version="1.0.0", 10 | org.fipro.eclipse.migration.service;bundle-version="1.0.0", 11 | org.eclipse.core.databinding;bundle-version="1.4.0", 12 | org.eclipse.core.databinding.beans;bundle-version="1.2.100", 13 | org.eclipse.core.databinding.property;bundle-version="1.4.0", 14 | org.eclipse.jface.databinding;bundle-version="1.5.0" 15 | Bundle-RequiredExecutionEnvironment: JavaSE-1.7 16 | Bundle-ActivationPolicy: lazy 17 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = bin/ 3 | bin.includes = plugin.xml,\ 4 | META-INF/,\ 5 | . 6 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/icons/checked.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e3-based-application/org.fipro.eclipse.migration.ui/icons/checked.gif -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/icons/eclipse16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e3-based-application/org.fipro.eclipse.migration.ui/icons/eclipse16.gif -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/icons/eclipse16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e3-based-application/org.fipro.eclipse.migration.ui/icons/eclipse16.png -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/icons/eclipse256.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e3-based-application/org.fipro.eclipse.migration.ui/icons/eclipse256.gif -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/icons/eclipse256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e3-based-application/org.fipro.eclipse.migration.ui/icons/eclipse256.png -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/icons/eclipse32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e3-based-application/org.fipro.eclipse.migration.ui/icons/eclipse32.gif -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/icons/eclipse32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e3-based-application/org.fipro.eclipse.migration.ui/icons/eclipse32.png -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/icons/eclipse48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e3-based-application/org.fipro.eclipse.migration.ui/icons/eclipse48.png -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/icons/eclipse_lg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e3-based-application/org.fipro.eclipse.migration.ui/icons/eclipse_lg.png -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/icons/editor.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e3-based-application/org.fipro.eclipse.migration.ui/icons/editor.gif -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/icons/environment_obj.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e3-based-application/org.fipro.eclipse.migration.ui/icons/environment_obj.gif -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/icons/prop_ps.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e3-based-application/org.fipro.eclipse.migration.ui/icons/prop_ps.gif -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/icons/unchecked.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e3-based-application/org.fipro.eclipse.migration.ui/icons/unchecked.gif -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 11 | 12 | 13 | 14 | 16 | 21 | 22 | 23 | 25 | 31 | 32 | 38 | 39 | 45 | 46 | 47 | 49 | 51 | 56 | 57 | 63 | 64 | 66 | 67 | 68 | 69 | 72 | 75 | 78 | 79 | 82 | 83 | 84 | 85 | 87 | 90 | 92 | 96 | 97 | 101 | 102 | 103 | 104 | 105 | 107 | 110 | 114 | 116 | 117 | 118 | 124 | 125 | 126 | 127 | 129 | 132 | 133 | 134 | 136 | 139 | 140 | 141 | 143 | 149 | 150 | 151 | 153 | 157 | 158 | 159 | 160 | 161 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/Activator.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui; 2 | 3 | import org.eclipse.jface.resource.ImageDescriptor; 4 | import org.eclipse.ui.plugin.AbstractUIPlugin; 5 | import org.osgi.framework.BundleContext; 6 | 7 | /** 8 | * The activator class controls the plug-in life cycle 9 | */ 10 | public class Activator extends AbstractUIPlugin { 11 | 12 | // The plug-in ID 13 | public static final String PLUGIN_ID = "org.fipro.eclipse.migration.ui"; //$NON-NLS-1$ 14 | 15 | // The shared instance 16 | private static Activator plugin; 17 | 18 | /** 19 | * The constructor 20 | */ 21 | public Activator() { 22 | } 23 | 24 | /* 25 | * (non-Javadoc) 26 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) 27 | */ 28 | @Override 29 | public void start(BundleContext context) throws Exception { 30 | super.start(context); 31 | plugin = this; 32 | } 33 | 34 | /* 35 | * (non-Javadoc) 36 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) 37 | */ 38 | @Override 39 | public void stop(BundleContext context) throws Exception { 40 | plugin = null; 41 | super.stop(context); 42 | } 43 | 44 | /** 45 | * Returns the shared instance 46 | * 47 | * @return the shared instance 48 | */ 49 | public static Activator getDefault() { 50 | return plugin; 51 | } 52 | 53 | /** 54 | * Returns an image descriptor for the image file at the given 55 | * plug-in relative path 56 | * 57 | * @param path the path 58 | * @return the image descriptor 59 | */ 60 | public static ImageDescriptor getImageDescriptor(String path) { 61 | return imageDescriptorFromPlugin(PLUGIN_ID, path); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/Application.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui; 2 | 3 | import org.eclipse.equinox.app.IApplication; 4 | import org.eclipse.equinox.app.IApplicationContext; 5 | import org.eclipse.swt.widgets.Display; 6 | import org.eclipse.ui.IWorkbench; 7 | import org.eclipse.ui.PlatformUI; 8 | 9 | /** 10 | * This class controls all aspects of the application's execution 11 | */ 12 | public class Application implements IApplication { 13 | 14 | /* (non-Javadoc) 15 | * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) 16 | */ 17 | public Object start(IApplicationContext context) throws Exception { 18 | Display display = PlatformUI.createDisplay(); 19 | try { 20 | int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); 21 | if (returnCode == PlatformUI.RETURN_RESTART) 22 | return IApplication.EXIT_RESTART; 23 | else 24 | return IApplication.EXIT_OK; 25 | } finally { 26 | display.dispose(); 27 | } 28 | 29 | } 30 | 31 | /* (non-Javadoc) 32 | * @see org.eclipse.equinox.app.IApplication#stop() 33 | */ 34 | public void stop() { 35 | if (!PlatformUI.isWorkbenchRunning()) 36 | return; 37 | final IWorkbench workbench = PlatformUI.getWorkbench(); 38 | final Display display = workbench.getDisplay(); 39 | display.syncExec(new Runnable() { 40 | public void run() { 41 | if (!display.isDisposed()) 42 | workbench.close(); 43 | } 44 | }); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/ApplicationActionBarAdvisor.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui; 2 | 3 | import org.eclipse.jface.action.IMenuManager; 4 | import org.eclipse.ui.IWorkbenchWindow; 5 | import org.eclipse.ui.application.ActionBarAdvisor; 6 | import org.eclipse.ui.application.IActionBarConfigurer; 7 | 8 | public class ApplicationActionBarAdvisor extends ActionBarAdvisor { 9 | 10 | public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { 11 | super(configurer); 12 | } 13 | 14 | protected void makeActions(IWorkbenchWindow window) { 15 | } 16 | 17 | protected void fillMenuBar(IMenuManager menuBar) { 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/ApplicationWorkbenchAdvisor.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui; 2 | 3 | import org.eclipse.ui.application.IWorkbenchWindowConfigurer; 4 | import org.eclipse.ui.application.WorkbenchAdvisor; 5 | import org.eclipse.ui.application.WorkbenchWindowAdvisor; 6 | 7 | public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { 8 | 9 | private static final String PERSPECTIVE_ID = "org.fipro.eclipse.migration.ui.perspective"; //$NON-NLS-1$ 10 | 11 | @Override 12 | public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { 13 | return new ApplicationWorkbenchWindowAdvisor(configurer); 14 | } 15 | 16 | @Override 17 | public String getInitialWindowPerspectiveId() { 18 | return PERSPECTIVE_ID; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/ApplicationWorkbenchWindowAdvisor.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui; 2 | 3 | import org.eclipse.swt.graphics.Point; 4 | import org.eclipse.ui.application.ActionBarAdvisor; 5 | import org.eclipse.ui.application.IActionBarConfigurer; 6 | import org.eclipse.ui.application.IWorkbenchWindowConfigurer; 7 | import org.eclipse.ui.application.WorkbenchWindowAdvisor; 8 | 9 | public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { 10 | 11 | public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { 12 | super(configurer); 13 | } 14 | 15 | @Override 16 | public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) { 17 | return new ApplicationActionBarAdvisor(configurer); 18 | } 19 | 20 | @Override 21 | public void preWindowOpen() { 22 | IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); 23 | configurer.setInitialSize(new Point(800, 400)); 24 | configurer.setShowCoolBar(false); 25 | configurer.setShowStatusLine(false); 26 | configurer.setTitle("e3 -> e4 Migration"); //$NON-NLS-1$ 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/Perspective.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui; 2 | 3 | import org.eclipse.ui.IPageLayout; 4 | import org.eclipse.ui.IPerspectiveFactory; 5 | 6 | public class Perspective implements IPerspectiveFactory { 7 | 8 | @Override 9 | public void createInitialLayout(IPageLayout layout) { 10 | // layout.setEditorAreaVisible(false); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/action/OpenDialogAction.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui.action; 2 | 3 | import org.eclipse.jface.action.IAction; 4 | import org.eclipse.jface.dialogs.MessageDialog; 5 | import org.eclipse.jface.viewers.ISelection; 6 | import org.eclipse.ui.IWorkbenchWindow; 7 | import org.eclipse.ui.IWorkbenchWindowActionDelegate; 8 | 9 | public class OpenDialogAction implements IWorkbenchWindowActionDelegate { 10 | 11 | @Override 12 | public void run(IAction action) { 13 | MessageDialog.openInformation(null, "Info", "Opened dialog via action"); 14 | } 15 | 16 | @Override 17 | public void selectionChanged(IAction action, ISelection selection) { 18 | // TODO Auto-generated method stub 19 | 20 | } 21 | 22 | @Override 23 | public void dispose() { 24 | // TODO Auto-generated method stub 25 | 26 | } 27 | 28 | @Override 29 | public void init(IWorkbenchWindow window) { 30 | // TODO Auto-generated method stub 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/editor/PersonEditor.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui.editor; 2 | 3 | import java.beans.PropertyChangeEvent; 4 | import java.beans.PropertyChangeListener; 5 | 6 | import org.eclipse.core.databinding.DataBindingContext; 7 | import org.eclipse.core.databinding.beans.BeanProperties; 8 | import org.eclipse.core.databinding.observable.value.IObservableValue; 9 | import org.eclipse.core.runtime.IProgressMonitor; 10 | import org.eclipse.jface.databinding.swt.WidgetProperties; 11 | import org.eclipse.jface.databinding.viewers.ViewersObservables; 12 | import org.eclipse.jface.layout.GridDataFactory; 13 | import org.eclipse.jface.viewers.ArrayContentProvider; 14 | import org.eclipse.jface.viewers.ComboViewer; 15 | import org.eclipse.jface.viewers.LabelProvider; 16 | import org.eclipse.swt.SWT; 17 | import org.eclipse.swt.layout.GridLayout; 18 | import org.eclipse.swt.widgets.Button; 19 | import org.eclipse.swt.widgets.Composite; 20 | import org.eclipse.swt.widgets.Label; 21 | import org.eclipse.swt.widgets.Text; 22 | import org.eclipse.ui.IEditorInput; 23 | import org.eclipse.ui.IEditorPart; 24 | import org.eclipse.ui.IEditorSite; 25 | import org.eclipse.ui.PartInitException; 26 | import org.eclipse.ui.part.EditorPart; 27 | import org.fipro.eclipse.migration.model.Person; 28 | import org.fipro.eclipse.migration.model.Person.Gender; 29 | 30 | 31 | public class PersonEditor extends EditorPart { 32 | 33 | public static final String ID = "org.fipro.eclipse.migration.ui.editor.personeditor"; 34 | 35 | Person person; 36 | Person activePerson; 37 | 38 | boolean dirty = false; 39 | 40 | @Override 41 | public void init(IEditorSite site, IEditorInput input) throws PartInitException { 42 | if (!(input instanceof PersonEditorInput)) { 43 | throw new RuntimeException("Wrong input"); 44 | } 45 | 46 | this.person = ((PersonEditorInput) input).person; 47 | this.activePerson = new Person(this.person); 48 | setSite(site); 49 | setInput(input); 50 | setPartName(input.getName()); 51 | } 52 | 53 | @Override 54 | public void createPartControl(Composite parent) { 55 | parent.setLayout(new GridLayout(2, false)); 56 | 57 | Label firstNameLabel = new Label(parent, SWT.NONE); 58 | firstNameLabel.setText("Firstname:"); 59 | GridDataFactory.defaultsFor(firstNameLabel).applyTo(firstNameLabel); 60 | 61 | Text firstNameField = new Text(parent, SWT.BORDER); 62 | GridDataFactory.fillDefaults().grab(true, false).applyTo(firstNameField); 63 | 64 | Label lastNameLabel = new Label(parent, SWT.NONE); 65 | lastNameLabel.setText("Lastname:"); 66 | GridDataFactory.defaultsFor(lastNameLabel).applyTo(lastNameLabel); 67 | 68 | Text lastNameField = new Text(parent, SWT.BORDER); 69 | GridDataFactory.fillDefaults().grab(true, false).applyTo(lastNameField); 70 | 71 | Label marriedLabel = new Label(parent, SWT.NONE); 72 | marriedLabel.setText("Married:"); 73 | GridDataFactory.defaultsFor(marriedLabel).applyTo(marriedLabel); 74 | 75 | Button marriedButton = new Button(parent, SWT.CHECK); 76 | 77 | Label genderLabel = new Label(parent, SWT.NONE); 78 | genderLabel.setText("Gender:"); 79 | GridDataFactory.defaultsFor(marriedLabel).applyTo(genderLabel); 80 | 81 | ComboViewer genderCombo = new ComboViewer(parent); 82 | genderCombo.setContentProvider(ArrayContentProvider.getInstance()); 83 | genderCombo.setLabelProvider(new LabelProvider() { 84 | @Override 85 | public String getText(Object element) { 86 | return super.getText(element); 87 | } 88 | }); 89 | genderCombo.setInput(Gender.values()); 90 | GridDataFactory.fillDefaults().grab(true, false).applyTo(genderCombo.getControl()); 91 | 92 | // add bindings 93 | DataBindingContext ctx = new DataBindingContext(); 94 | IObservableValue fnTarget = 95 | WidgetProperties.text(SWT.Modify).observe(firstNameField); 96 | IObservableValue lnTarget = 97 | WidgetProperties.text(SWT.Modify).observe(lastNameField); 98 | IObservableValue mTarget = 99 | WidgetProperties.selection().observe(marriedButton); 100 | IObservableValue gTarget = 101 | ViewersObservables.observeSingleSelection(genderCombo); 102 | 103 | IObservableValue fnModel= BeanProperties. 104 | value(Person.class,"firstName").observe(activePerson); 105 | IObservableValue lnModel= BeanProperties. 106 | value(Person.class,"lastName").observe(activePerson); 107 | IObservableValue mModel= BeanProperties. 108 | value(Person.class,"married").observe(activePerson); 109 | IObservableValue gModel= BeanProperties. 110 | value(Person.class,"gender").observe(activePerson); 111 | 112 | ctx.bindValue(fnTarget, fnModel); 113 | ctx.bindValue(lnTarget, lnModel); 114 | ctx.bindValue(mTarget, mModel); 115 | ctx.bindValue(gTarget, gModel); 116 | 117 | this.activePerson.addPropertyChangeListener(new PropertyChangeListener() { 118 | 119 | @Override 120 | public void propertyChange(PropertyChangeEvent evt) { 121 | dirty = true; 122 | firePropertyChange(IEditorPart.PROP_DIRTY); 123 | } 124 | }); 125 | } 126 | 127 | @Override 128 | public void doSave(IProgressMonitor monitor) { 129 | this.person.setFirstName(this.activePerson.getFirstName()); 130 | this.person.setLastName(this.activePerson.getLastName()); 131 | this.person.setMarried(this.activePerson.isMarried()); 132 | this.person.setGender(this.activePerson.getGender()); 133 | 134 | // TODO update table 135 | 136 | this.dirty = false; 137 | firePropertyChange(IEditorPart.PROP_DIRTY); 138 | } 139 | 140 | @Override 141 | public void doSaveAs() { 142 | } 143 | 144 | @Override 145 | public boolean isDirty() { 146 | return this.dirty; 147 | } 148 | 149 | @Override 150 | public boolean isSaveAsAllowed() { 151 | return false; 152 | } 153 | 154 | @Override 155 | public void setFocus() { 156 | } 157 | 158 | } 159 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/editor/PersonEditorInput.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui.editor; 2 | 3 | import org.eclipse.jface.resource.ImageDescriptor; 4 | import org.eclipse.ui.IEditorInput; 5 | import org.eclipse.ui.IPersistableElement; 6 | import org.fipro.eclipse.migration.model.Person; 7 | 8 | public class PersonEditorInput implements IEditorInput { 9 | 10 | Person person; 11 | 12 | public PersonEditorInput(Person person) { 13 | this.person = person; 14 | } 15 | 16 | 17 | @SuppressWarnings("rawtypes") 18 | @Override 19 | public Object getAdapter(Class adapter) { 20 | return null; 21 | } 22 | 23 | @Override 24 | public boolean exists() { 25 | return true; 26 | } 27 | 28 | @Override 29 | public ImageDescriptor getImageDescriptor() { 30 | return null; 31 | } 32 | 33 | @Override 34 | public String getName() { 35 | return person.getFirstName() + " " + person.getLastName(); 36 | } 37 | 38 | @Override 39 | public IPersistableElement getPersistable() { 40 | return null; 41 | } 42 | 43 | @Override 44 | public String getToolTipText() { 45 | return getName() + " editor"; 46 | } 47 | 48 | @Override 49 | public int hashCode() { 50 | final int prime = 31; 51 | int result = 1; 52 | result = prime * result + ((person == null) ? 0 : person.hashCode()); 53 | return result; 54 | } 55 | 56 | @Override 57 | public boolean equals(Object obj) { 58 | if (this == obj) 59 | return true; 60 | if (obj == null) 61 | return false; 62 | if (getClass() != obj.getClass()) 63 | return false; 64 | PersonEditorInput other = (PersonEditorInput) obj; 65 | if (person == null) { 66 | if (other.person != null) 67 | return false; 68 | } else if (!person.equals(other.person)) 69 | return false; 70 | return true; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/handler/OpenDialogHandler.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui.handler; 2 | 3 | import org.eclipse.core.commands.AbstractHandler; 4 | import org.eclipse.core.commands.ExecutionEvent; 5 | import org.eclipse.core.commands.ExecutionException; 6 | import org.eclipse.core.commands.IHandler; 7 | import org.eclipse.jface.dialogs.MessageDialog; 8 | 9 | public class OpenDialogHandler extends AbstractHandler implements IHandler { 10 | 11 | @Override 12 | public Object execute(ExecutionEvent event) throws ExecutionException { 13 | MessageDialog.openInformation(null, "Info", "Opened dialog via handler"); 14 | return null; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/preferences/DescriptionPreferencePage.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui.preferences; 2 | 3 | import org.eclipse.jface.preference.IPreferenceStore; 4 | import org.eclipse.jface.preference.PreferencePage; 5 | import org.eclipse.swt.SWT; 6 | import org.eclipse.swt.events.SelectionAdapter; 7 | import org.eclipse.swt.events.SelectionEvent; 8 | import org.eclipse.swt.layout.GridLayout; 9 | import org.eclipse.swt.widgets.Button; 10 | import org.eclipse.swt.widgets.Composite; 11 | import org.eclipse.swt.widgets.Control; 12 | import org.eclipse.ui.IWorkbench; 13 | import org.eclipse.ui.IWorkbenchPreferencePage; 14 | import org.fipro.eclipse.migration.ui.Activator; 15 | 16 | public class DescriptionPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { 17 | 18 | // Names for preferences 19 | private static final String DESCRIPTION_COLOR = "description_color"; 20 | 21 | // The checkboxes 22 | private Button checkBoxBlack; 23 | private Button checkBoxBlue; 24 | 25 | /** 26 | * Creates the controls for this page 27 | */ 28 | @Override 29 | protected Control createContents(Composite parent) { 30 | Composite composite = new Composite(parent, SWT.NONE); 31 | composite.setLayout(new GridLayout(2, false)); 32 | 33 | // Get the preference store 34 | IPreferenceStore preferenceStore = getPreferenceStore(); 35 | 36 | String color = preferenceStore.getString(DESCRIPTION_COLOR); 37 | boolean isBlack = (color != null && !color.isEmpty()) ? "black".equals(color) : true; 38 | 39 | // Create the checkboxes 40 | checkBoxBlack = new Button(composite, SWT.RADIO); 41 | checkBoxBlack.setText("Text Color Black"); 42 | checkBoxBlack.setSelection(isBlack); 43 | 44 | checkBoxBlue = new Button(composite, SWT.RADIO); 45 | checkBoxBlue.setText("Text Color Blue"); 46 | checkBoxBlue.setSelection(!isBlack); 47 | 48 | checkBoxBlack.addSelectionListener(new SelectionAdapter() { 49 | @Override 50 | public void widgetSelected(SelectionEvent e) { 51 | checkBoxBlack.setSelection(true); 52 | checkBoxBlue.setSelection(false); 53 | } 54 | }); 55 | 56 | checkBoxBlue.addSelectionListener(new SelectionAdapter() { 57 | @Override 58 | public void widgetSelected(SelectionEvent e) { 59 | checkBoxBlack.setSelection(false); 60 | checkBoxBlue.setSelection(true); 61 | } 62 | }); 63 | 64 | return composite; 65 | } 66 | 67 | /** 68 | * Called when user clicks Restore Defaults 69 | */ 70 | @Override 71 | protected void performDefaults() { 72 | // Get the preference store 73 | IPreferenceStore preferenceStore = getPreferenceStore(); 74 | 75 | String color = preferenceStore.getString(DESCRIPTION_COLOR); 76 | boolean isBlack = (color != null && !color.isEmpty()) ? "black".equals(color) : true; 77 | 78 | // Reset the fields to the defaults 79 | checkBoxBlack.setSelection(isBlack); 80 | checkBoxBlue.setSelection(!isBlack); 81 | } 82 | 83 | /** 84 | * Called when user clicks Apply or OK 85 | * 86 | * @return boolean 87 | */ 88 | @Override 89 | public boolean performOk() { 90 | // Get the preference store 91 | IPreferenceStore preferenceStore = getPreferenceStore(); 92 | 93 | // Set the values from the fields 94 | if (checkBoxBlack != null && checkBoxBlack.getSelection()) { 95 | preferenceStore.setValue(DESCRIPTION_COLOR, "black"); 96 | } 97 | else if (checkBoxBlue != null && checkBoxBlue.getSelection()) { 98 | preferenceStore.setValue(DESCRIPTION_COLOR, "blue"); 99 | } 100 | 101 | // Return true to allow dialog to close 102 | return true; 103 | } 104 | 105 | @Override 106 | public void init(IWorkbench workbench) { 107 | setPreferenceStore(Activator.getDefault().getPreferenceStore()); 108 | 109 | setTitle("Description"); 110 | setDescription("The preferences page for the Description view"); 111 | } 112 | 113 | } 114 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/DescriptionView.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui.view; 2 | 3 | import org.eclipse.core.runtime.Platform; 4 | import org.eclipse.jface.util.IPropertyChangeListener; 5 | import org.eclipse.jface.util.PropertyChangeEvent; 6 | import org.eclipse.jface.viewers.ISelection; 7 | import org.eclipse.jface.viewers.IStructuredSelection; 8 | import org.eclipse.swt.SWT; 9 | import org.eclipse.swt.graphics.Color; 10 | import org.eclipse.swt.layout.FillLayout; 11 | import org.eclipse.swt.widgets.Composite; 12 | import org.eclipse.swt.widgets.Display; 13 | import org.eclipse.swt.widgets.Text; 14 | import org.eclipse.ui.ISelectionListener; 15 | import org.eclipse.ui.ISelectionService; 16 | import org.eclipse.ui.IWorkbenchPart; 17 | import org.eclipse.ui.part.ViewPart; 18 | import org.fipro.eclipse.migration.model.Person; 19 | import org.fipro.eclipse.migration.model.Person.Gender; 20 | import org.fipro.eclipse.migration.ui.Activator; 21 | import org.fipro.eclipse.migration.ui.view.overview.OverviewView; 22 | 23 | public class DescriptionView extends ViewPart { 24 | 25 | Text description; 26 | 27 | ISelectionListener selectionListener = new ISelectionListener() { 28 | 29 | @Override 30 | public void selectionChanged(IWorkbenchPart part, ISelection selection) { 31 | if (part instanceof OverviewView 32 | && selection instanceof IStructuredSelection) { 33 | 34 | if (!selection.isEmpty()) { 35 | Object selected = ((IStructuredSelection) selection).getFirstElement(); 36 | Person p = (Person) selected; 37 | description.setText(p.getFirstName() + " " + p.getLastName() 38 | + " is a " + (p.isMarried() ? "married " : "single ") 39 | + (Gender.MALE.equals(p.getGender()) ? "man" : "woman")); 40 | } 41 | else { 42 | description.setText(""); 43 | } 44 | } 45 | } 46 | }; 47 | 48 | @Override 49 | public void createPartControl(Composite parent) { 50 | parent.setLayout(new FillLayout()); 51 | description = new Text(parent, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY); 52 | 53 | // read preferences to set the initial text color 54 | String color = Platform.getPreferencesService(). 55 | getString("org.fipro.eclipse.migration.ui", "description_color", "black", null); 56 | 57 | Color toUse = "blue".equals(color) ? 58 | Display.getDefault().getSystemColor(SWT.COLOR_BLUE) : Display.getDefault().getSystemColor(SWT.COLOR_BLACK); 59 | 60 | description.setForeground(toUse); 61 | 62 | // register a listener on the PreferencesStore to react on changes 63 | Activator.getDefault().getPreferenceStore().addPropertyChangeListener( 64 | new IPropertyChangeListener() { 65 | @Override 66 | public void propertyChange(PropertyChangeEvent event) { 67 | if (event.getProperty() == "description_color") { 68 | Color toUse = "blue".equals(event.getNewValue()) ? 69 | Display.getDefault().getSystemColor(SWT.COLOR_BLUE) : Display.getDefault().getSystemColor(SWT.COLOR_BLACK); 70 | 71 | if (description != null && !description.isDisposed()) { 72 | description.setForeground(toUse); 73 | } 74 | } 75 | } 76 | }); 77 | 78 | getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(selectionListener); 79 | } 80 | 81 | @Override 82 | public void setFocus() { 83 | } 84 | 85 | @Override 86 | public void dispose() { 87 | // on disposal remove the selection listener 88 | ISelectionService s = getSite().getWorkbenchWindow().getSelectionService(); 89 | s.removeSelectionListener(selectionListener); 90 | 91 | super.dispose(); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/DetailView.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui.view; 2 | 3 | import org.eclipse.core.databinding.DataBindingContext; 4 | import org.eclipse.core.databinding.beans.BeanProperties; 5 | import org.eclipse.core.databinding.observable.value.IObservableValue; 6 | import org.eclipse.jface.databinding.swt.WidgetProperties; 7 | import org.eclipse.jface.databinding.viewers.ViewersObservables; 8 | import org.eclipse.jface.layout.GridDataFactory; 9 | import org.eclipse.jface.viewers.ArrayContentProvider; 10 | import org.eclipse.jface.viewers.ComboViewer; 11 | import org.eclipse.jface.viewers.ISelection; 12 | import org.eclipse.jface.viewers.IStructuredSelection; 13 | import org.eclipse.jface.viewers.LabelProvider; 14 | import org.eclipse.swt.SWT; 15 | import org.eclipse.swt.layout.GridLayout; 16 | import org.eclipse.swt.widgets.Button; 17 | import org.eclipse.swt.widgets.Composite; 18 | import org.eclipse.swt.widgets.Label; 19 | import org.eclipse.swt.widgets.Text; 20 | import org.eclipse.ui.ISelectionListener; 21 | import org.eclipse.ui.ISelectionService; 22 | import org.eclipse.ui.IWorkbenchPart; 23 | import org.eclipse.ui.part.ViewPart; 24 | import org.fipro.eclipse.migration.model.Person; 25 | import org.fipro.eclipse.migration.model.Person.Gender; 26 | import org.fipro.eclipse.migration.ui.view.overview.OverviewView; 27 | 28 | public class DetailView extends ViewPart { 29 | 30 | Person activePerson = new Person(-1); 31 | 32 | ISelectionListener selectionListener = new ISelectionListener() { 33 | 34 | @Override 35 | public void selectionChanged(IWorkbenchPart part, ISelection selection) { 36 | if (part instanceof OverviewView 37 | && selection instanceof IStructuredSelection) { 38 | 39 | if (!selection.isEmpty()) { 40 | Object selected = ((IStructuredSelection) selection).getFirstElement(); 41 | Person p = (Person) selected; 42 | activePerson.setFirstName(p.getFirstName()); 43 | activePerson.setLastName(p.getLastName()); 44 | activePerson.setMarried(p.isMarried()); 45 | activePerson.setGender(p.getGender()); 46 | } 47 | else { 48 | activePerson.setFirstName(null); 49 | activePerson.setLastName(null); 50 | activePerson.setMarried(false); 51 | activePerson.setGender(null); 52 | } 53 | } 54 | } 55 | }; 56 | 57 | @Override 58 | public void createPartControl(Composite parent) { 59 | parent.setLayout(new GridLayout(2, false)); 60 | 61 | Label firstNameLabel = new Label(parent, SWT.NONE); 62 | firstNameLabel.setText("Firstname:"); 63 | GridDataFactory.defaultsFor(firstNameLabel).applyTo(firstNameLabel); 64 | 65 | Text firstNameField = new Text(parent, SWT.BORDER); 66 | GridDataFactory.fillDefaults().grab(true, false).applyTo(firstNameField); 67 | 68 | Label lastNameLabel = new Label(parent, SWT.NONE); 69 | lastNameLabel.setText("Lastname:"); 70 | GridDataFactory.defaultsFor(lastNameLabel).applyTo(lastNameLabel); 71 | 72 | Text lastNameField = new Text(parent, SWT.BORDER); 73 | GridDataFactory.fillDefaults().grab(true, false).applyTo(lastNameField); 74 | 75 | Label marriedLabel = new Label(parent, SWT.NONE); 76 | marriedLabel.setText("Married:"); 77 | GridDataFactory.defaultsFor(marriedLabel).applyTo(marriedLabel); 78 | 79 | Button marriedButton = new Button(parent, SWT.CHECK); 80 | 81 | Label genderLabel = new Label(parent, SWT.NONE); 82 | genderLabel.setText("Gender:"); 83 | GridDataFactory.defaultsFor(marriedLabel).applyTo(genderLabel); 84 | 85 | ComboViewer genderCombo = new ComboViewer(parent); 86 | genderCombo.setContentProvider(ArrayContentProvider.getInstance()); 87 | genderCombo.setLabelProvider(new LabelProvider() { 88 | @Override 89 | public String getText(Object element) { 90 | return super.getText(element); 91 | } 92 | }); 93 | genderCombo.setInput(Gender.values()); 94 | GridDataFactory.fillDefaults().grab(true, false).applyTo(genderCombo.getControl()); 95 | 96 | // add bindings 97 | DataBindingContext ctx = new DataBindingContext(); 98 | IObservableValue fnTarget = 99 | WidgetProperties.text(SWT.Modify).observe(firstNameField); 100 | IObservableValue lnTarget = 101 | WidgetProperties.text(SWT.Modify).observe(lastNameField); 102 | IObservableValue mTarget = 103 | WidgetProperties.selection().observe(marriedButton); 104 | IObservableValue gTarget = 105 | ViewersObservables.observeSingleSelection(genderCombo); 106 | 107 | IObservableValue fnModel= BeanProperties. 108 | value(Person.class,"firstName").observe(activePerson); 109 | IObservableValue lnModel= BeanProperties. 110 | value(Person.class,"lastName").observe(activePerson); 111 | IObservableValue mModel= BeanProperties. 112 | value(Person.class,"married").observe(activePerson); 113 | IObservableValue gModel= BeanProperties. 114 | value(Person.class,"gender").observe(activePerson); 115 | 116 | ctx.bindValue(fnTarget, fnModel); 117 | ctx.bindValue(lnTarget, lnModel); 118 | ctx.bindValue(mTarget, mModel); 119 | ctx.bindValue(gTarget, gModel); 120 | 121 | // add the selection listener 122 | getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(selectionListener); 123 | } 124 | 125 | @Override 126 | public void setFocus() { 127 | } 128 | 129 | @Override 130 | public void dispose() { 131 | // on disposal remove the selection listener 132 | ISelectionService s = getSite().getWorkbenchWindow().getSelectionService(); 133 | s.removeSelectionListener(selectionListener); 134 | 135 | super.dispose(); 136 | } 137 | 138 | } 139 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/FirstNameEditingSupport.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui.view.overview; 2 | 3 | import org.eclipse.jface.viewers.CellEditor; 4 | import org.eclipse.jface.viewers.ColumnViewer; 5 | import org.eclipse.jface.viewers.EditingSupport; 6 | import org.eclipse.jface.viewers.TextCellEditor; 7 | import org.eclipse.swt.widgets.Composite; 8 | import org.fipro.eclipse.migration.model.Person; 9 | 10 | public class FirstNameEditingSupport extends EditingSupport { 11 | 12 | public FirstNameEditingSupport(ColumnViewer viewer) { 13 | super(viewer); 14 | } 15 | 16 | @Override 17 | protected CellEditor getCellEditor(Object element) { 18 | return new TextCellEditor((Composite) getViewer().getControl()); 19 | } 20 | 21 | @Override 22 | protected boolean canEdit(Object element) { 23 | return true; 24 | } 25 | 26 | @Override 27 | protected Object getValue(Object element) { 28 | return ((Person) element).getFirstName(); 29 | } 30 | 31 | @Override 32 | protected void setValue(Object element, Object value) { 33 | ((Person) element).setFirstName(String.valueOf(value)); 34 | getViewer().update(element, null); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/FirstNameLabelProvider.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui.view.overview; 2 | 3 | import org.eclipse.jface.viewers.StyledCellLabelProvider; 4 | import org.eclipse.jface.viewers.ViewerCell; 5 | import org.fipro.eclipse.migration.model.Person; 6 | 7 | public class FirstNameLabelProvider extends StyledCellLabelProvider { 8 | @Override 9 | public void update(ViewerCell cell) { 10 | Person element= (Person) cell.getElement(); 11 | cell.setText(element.getFirstName()); 12 | super.update(cell); 13 | } 14 | } -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/GenderEditingSupport.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui.view.overview; 2 | 3 | import java.util.Arrays; 4 | 5 | import org.eclipse.jface.viewers.ArrayContentProvider; 6 | import org.eclipse.jface.viewers.CellEditor; 7 | import org.eclipse.jface.viewers.ColumnViewer; 8 | import org.eclipse.jface.viewers.ComboBoxViewerCellEditor; 9 | import org.eclipse.jface.viewers.EditingSupport; 10 | import org.eclipse.jface.viewers.LabelProvider; 11 | import org.eclipse.swt.widgets.Composite; 12 | import org.fipro.eclipse.migration.model.Person; 13 | import org.fipro.eclipse.migration.model.Person.Gender; 14 | 15 | public class GenderEditingSupport extends EditingSupport { 16 | 17 | private ComboBoxViewerCellEditor cellEditor; 18 | 19 | public GenderEditingSupport(ColumnViewer viewer) { 20 | super(viewer); 21 | cellEditor = new ComboBoxViewerCellEditor((Composite) getViewer().getControl()); 22 | cellEditor.setLabelProvider(new LabelProvider()); 23 | cellEditor.setContentProvider(new ArrayContentProvider()); 24 | cellEditor.setInput(Arrays.asList(Gender.FEMALE, Gender.MALE)); 25 | } 26 | 27 | @Override 28 | protected CellEditor getCellEditor(Object element) { 29 | return cellEditor; 30 | } 31 | 32 | @Override 33 | protected boolean canEdit(Object element) { 34 | return true; 35 | } 36 | 37 | @Override 38 | protected Object getValue(Object element) { 39 | return ((Person) element).getGender(); 40 | } 41 | 42 | @Override 43 | protected void setValue(Object element, Object value) { 44 | ((Person) element).setGender((Gender)value); 45 | getViewer().update(element, null); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/GenderLabelProvider.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui.view.overview; 2 | 3 | import org.eclipse.jface.viewers.StyledCellLabelProvider; 4 | import org.eclipse.jface.viewers.ViewerCell; 5 | import org.fipro.eclipse.migration.model.Person; 6 | 7 | public class GenderLabelProvider extends StyledCellLabelProvider { 8 | @Override 9 | public void update(ViewerCell cell) { 10 | Person element= (Person) cell.getElement(); 11 | cell.setText(element.getGender().toString()); 12 | super.update(cell); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/LastNameEditingSupport.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui.view.overview; 2 | 3 | import org.eclipse.jface.viewers.CellEditor; 4 | import org.eclipse.jface.viewers.ColumnViewer; 5 | import org.eclipse.jface.viewers.EditingSupport; 6 | import org.eclipse.jface.viewers.TextCellEditor; 7 | import org.eclipse.swt.widgets.Composite; 8 | import org.fipro.eclipse.migration.model.Person; 9 | 10 | public class LastNameEditingSupport extends EditingSupport { 11 | 12 | public LastNameEditingSupport(ColumnViewer viewer) { 13 | super(viewer); 14 | } 15 | 16 | @Override 17 | protected CellEditor getCellEditor(Object element) { 18 | return new TextCellEditor((Composite) getViewer().getControl()); 19 | } 20 | 21 | @Override 22 | protected boolean canEdit(Object element) { 23 | return true; 24 | } 25 | 26 | @Override 27 | protected Object getValue(Object element) { 28 | return ((Person) element).getLastName(); 29 | } 30 | 31 | @Override 32 | protected void setValue(Object element, Object value) { 33 | ((Person) element).setLastName(String.valueOf(value)); 34 | getViewer().update(element, null); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/LastNameLabelProvider.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui.view.overview; 2 | 3 | import org.eclipse.jface.viewers.StyledCellLabelProvider; 4 | import org.eclipse.jface.viewers.ViewerCell; 5 | import org.fipro.eclipse.migration.model.Person; 6 | 7 | public class LastNameLabelProvider extends StyledCellLabelProvider { 8 | @Override 9 | public void update(ViewerCell cell) { 10 | Person element= (Person) cell.getElement(); 11 | cell.setText(element.getLastName()); 12 | super.update(cell); 13 | } 14 | } -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/MarriedEditingSupport.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui.view.overview; 2 | 3 | import org.eclipse.jface.viewers.CellEditor; 4 | import org.eclipse.jface.viewers.CheckboxCellEditor; 5 | import org.eclipse.jface.viewers.ColumnViewer; 6 | import org.eclipse.jface.viewers.EditingSupport; 7 | import org.eclipse.swt.SWT; 8 | import org.eclipse.swt.widgets.Composite; 9 | import org.fipro.eclipse.migration.model.Person; 10 | 11 | public class MarriedEditingSupport extends EditingSupport { 12 | 13 | public MarriedEditingSupport(ColumnViewer viewer) { 14 | super(viewer); 15 | } 16 | 17 | @Override 18 | protected CellEditor getCellEditor(Object element) { 19 | return new CheckboxCellEditor((Composite) getViewer().getControl(), SWT.CHECK); 20 | } 21 | 22 | @Override 23 | protected boolean canEdit(Object element) { 24 | return true; 25 | } 26 | 27 | @Override 28 | protected Object getValue(Object element) { 29 | return ((Person) element).isMarried(); 30 | } 31 | 32 | @Override 33 | protected void setValue(Object element, Object value) { 34 | ((Person) element).setMarried((Boolean)value); 35 | getViewer().update(element, null); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/MarriedLabelProvider.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui.view.overview; 2 | 3 | import java.net.URL; 4 | 5 | import org.eclipse.core.runtime.FileLocator; 6 | import org.eclipse.core.runtime.Path; 7 | import org.eclipse.jface.resource.ImageDescriptor; 8 | import org.eclipse.jface.resource.JFaceResources; 9 | import org.eclipse.jface.resource.LocalResourceManager; 10 | import org.eclipse.jface.viewers.StyledCellLabelProvider; 11 | import org.eclipse.jface.viewers.ViewerCell; 12 | import org.eclipse.swt.graphics.Image; 13 | import org.fipro.eclipse.migration.model.Person; 14 | import org.osgi.framework.Bundle; 15 | import org.osgi.framework.FrameworkUtil; 16 | 17 | public class MarriedLabelProvider extends StyledCellLabelProvider { 18 | 19 | private final Image uncheckedImg; 20 | private final Image checkedImg; 21 | 22 | public MarriedLabelProvider() { 23 | LocalResourceManager resourceMgr = new LocalResourceManager(JFaceResources.getResources()); 24 | Bundle bundle = FrameworkUtil.getBundle(getClass()); 25 | URL checked = FileLocator.find(bundle, new Path("icons/checked.gif"), null); 26 | URL unchecked = FileLocator.find(bundle, new Path("icons/unchecked.gif"), null); 27 | this.checkedImg = resourceMgr.createImage(ImageDescriptor.createFromURL(checked)); 28 | this.uncheckedImg = resourceMgr.createImage(ImageDescriptor.createFromURL(unchecked)); 29 | } 30 | 31 | @Override 32 | public void update(ViewerCell cell) { 33 | if (((Person)cell.getElement()).isMarried()) { 34 | cell.setImage(checkedImg); 35 | } 36 | else { 37 | cell.setImage(uncheckedImg); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /e3-based-application/org.fipro.eclipse.migration.ui/src/org/fipro/eclipse/migration/ui/view/overview/OverviewView.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.ui.view.overview; 2 | 3 | import java.beans.PropertyChangeEvent; 4 | import java.beans.PropertyChangeListener; 5 | 6 | import org.eclipse.core.databinding.observable.IObservable; 7 | import org.eclipse.core.databinding.observable.list.WritableList; 8 | import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; 9 | import org.eclipse.jface.layout.GridDataFactory; 10 | import org.eclipse.jface.viewers.DoubleClickEvent; 11 | import org.eclipse.jface.viewers.IDoubleClickListener; 12 | import org.eclipse.jface.viewers.ISelection; 13 | import org.eclipse.jface.viewers.IStructuredSelection; 14 | import org.eclipse.jface.viewers.TableViewer; 15 | import org.eclipse.jface.viewers.TableViewerColumn; 16 | import org.eclipse.swt.SWT; 17 | import org.eclipse.swt.layout.GridLayout; 18 | import org.eclipse.swt.widgets.Composite; 19 | import org.eclipse.ui.PartInitException; 20 | import org.eclipse.ui.part.ViewPart; 21 | import org.fipro.eclipse.migration.model.Person; 22 | import org.fipro.eclipse.migration.service.PersonServiceImpl; 23 | import org.fipro.eclipse.migration.ui.editor.PersonEditor; 24 | import org.fipro.eclipse.migration.ui.editor.PersonEditorInput; 25 | 26 | public class OverviewView extends ViewPart { 27 | 28 | TableViewer viewer; 29 | 30 | @Override 31 | public void createPartControl(Composite parent) { 32 | parent.setLayout(new GridLayout()); 33 | 34 | IObservable list = new WritableList(PersonServiceImpl.getPersons(10), Person.class); 35 | 36 | viewer = new TableViewer(parent, SWT.MULTI|SWT.BORDER|SWT.H_SCROLL|SWT.V_SCROLL|SWT.FULL_SELECTION); 37 | ObservableListContentProvider cp = new ObservableListContentProvider(); 38 | viewer.setContentProvider(cp); 39 | viewer.getTable().setHeaderVisible(true); 40 | viewer.getTable().setLinesVisible(true); 41 | GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl()); 42 | 43 | TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE); 44 | column.getColumn().setText("Firstname"); 45 | column.getColumn().setWidth(100); 46 | column.setLabelProvider(new FirstNameLabelProvider()); 47 | // column.setEditingSupport(new FirstNameEditingSupport(viewer)); 48 | 49 | column = new TableViewerColumn(viewer, SWT.NONE); 50 | column.getColumn().setText("Lastname"); 51 | column.getColumn().setWidth(100); 52 | column.setLabelProvider(new LastNameLabelProvider()); 53 | // column.setEditingSupport(new LastNameEditingSupport(viewer)); 54 | 55 | column = new TableViewerColumn(viewer, SWT.NONE); 56 | column.getColumn().setText("Married"); 57 | column.getColumn().setWidth(60); 58 | column.setLabelProvider(new MarriedLabelProvider()); 59 | // column.setEditingSupport(new MarriedEditingSupport(viewer)); 60 | 61 | column = new TableViewerColumn(viewer, SWT.NONE); 62 | column.getColumn().setText("Gender"); 63 | column.getColumn().setWidth(80); 64 | column.setLabelProvider(new GenderLabelProvider()); 65 | // column.setEditingSupport(new GenderEditingSupport(viewer)); 66 | 67 | viewer.setInput(list); 68 | 69 | // set the viewer as selection provider 70 | getSite().setSelectionProvider(viewer); 71 | 72 | // hook double click for opening an editor 73 | viewer.addDoubleClickListener(new IDoubleClickListener() { 74 | 75 | @Override 76 | public void doubleClick(DoubleClickEvent event) { 77 | ISelection selection = viewer.getSelection(); 78 | if (selection != null && selection instanceof IStructuredSelection) { 79 | Object obj = ((IStructuredSelection) selection).getFirstElement(); 80 | // if we had a selection lets open the editor 81 | if (obj != null) { 82 | Person person = (Person) obj; 83 | person.addPropertyChangeListener(new PropertyChangeListener() { 84 | 85 | @Override 86 | public void propertyChange(PropertyChangeEvent evt) { 87 | viewer.refresh(); 88 | } 89 | }); 90 | PersonEditorInput input = new PersonEditorInput(person); 91 | try { 92 | getSite().getWorkbenchWindow().getActivePage().openEditor(input, PersonEditor.ID); 93 | 94 | } catch (PartInitException e) { 95 | throw new RuntimeException(e); 96 | } 97 | } 98 | } 99 | } 100 | }); 101 | } 102 | 103 | @Override 104 | public void setFocus() { 105 | this.viewer.getControl().setFocus(); 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.feature/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.fipro.eclipse.migration.e4.feature 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.pde.FeatureBuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.pde.FeatureNature 16 | 17 | 18 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.feature/build.properties: -------------------------------------------------------------------------------- 1 | bin.includes = feature.xml 2 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.feature/feature.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | [Enter Feature Description here.] 9 | 10 | 11 | 12 | [Enter Copyright Description here.] 13 | 14 | 15 | 16 | [Enter License Description here.] 17 | 18 | 19 | 25 | 26 | 32 | 33 | 39 | 40 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.model/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.model/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.fipro.eclipse.migration.e4.model 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.pde.PluginNature 26 | org.eclipse.jdt.core.javanature 27 | 28 | 29 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.model/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.8 8 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.model/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Migration Application Model 4 | Bundle-SymbolicName: org.fipro.eclipse.migration.e4.model 5 | Bundle-Version: 1.0.0.qualifier 6 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 7 | Export-Package: org.fipro.eclipse.migration.e4.model 8 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.model/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = bin/ 3 | bin.includes = META-INF/,\ 4 | . 5 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/ModelObject.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.model; 2 | 3 | import java.beans.PropertyChangeListener; 4 | import java.beans.PropertyChangeSupport; 5 | 6 | public class ModelObject { 7 | 8 | private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this); 9 | 10 | public void addPropertyChangeListener(PropertyChangeListener listener) { 11 | changeSupport.addPropertyChangeListener(listener); 12 | } 13 | 14 | public void removePropertyChangeListener(PropertyChangeListener listener) { 15 | changeSupport.removePropertyChangeListener(listener); 16 | } 17 | 18 | public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { 19 | changeSupport.addPropertyChangeListener(propertyName, listener); 20 | } 21 | 22 | public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { 23 | changeSupport.removePropertyChangeListener(propertyName, listener); 24 | } 25 | 26 | protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { 27 | changeSupport.firePropertyChange(propertyName, oldValue, newValue); 28 | } 29 | } -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.model/src/org/fipro/eclipse/migration/e4/model/Person.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.model; 2 | 3 | import java.util.Date; 4 | 5 | public class Person extends ModelObject { 6 | 7 | public enum Gender { 8 | MALE, FEMALE 9 | } 10 | 11 | private final int id; 12 | private String firstName; 13 | private String lastName; 14 | private Gender gender; 15 | private boolean married; 16 | private Date birthday; 17 | 18 | public Person(int id) { 19 | this.id = id; 20 | } 21 | 22 | public Person(int id, String firstName, String lastName, Gender gender, boolean married, Date birthday) { 23 | this.id = id; 24 | this.firstName = firstName; 25 | this.lastName = lastName; 26 | this.gender = gender; 27 | this.married = married; 28 | this.birthday = birthday; 29 | } 30 | 31 | public Person(Person base) { 32 | this.id = base.id; 33 | this.firstName = base.firstName; 34 | this.lastName = base.lastName; 35 | this.gender = base.gender; 36 | this.married = base.married; 37 | this.birthday = base.birthday; 38 | } 39 | 40 | public int getId() { 41 | return id; 42 | } 43 | 44 | public String getFirstName() { 45 | return firstName; 46 | } 47 | 48 | public void setFirstName(String firstName) { 49 | firePropertyChange("firstName", this.firstName, this.firstName = firstName); 50 | } 51 | 52 | public String getLastName() { 53 | return lastName; 54 | } 55 | 56 | public void setLastName(String lastName) { 57 | firePropertyChange("lastName", this.lastName, this.lastName = lastName); 58 | } 59 | 60 | public Gender getGender() { 61 | return gender; 62 | } 63 | 64 | public void setGender(Gender gender) { 65 | firePropertyChange("gender", this.gender, this.gender = gender); 66 | } 67 | 68 | public boolean isMarried() { 69 | return married; 70 | } 71 | 72 | public void setMarried(boolean married) { 73 | firePropertyChange("married", this.married, this.married = married); 74 | } 75 | 76 | public Date getBirthday() { 77 | return birthday; 78 | } 79 | 80 | public void setBirthday(Date birthday) { 81 | this.birthday = birthday; 82 | } 83 | 84 | @Override 85 | public int hashCode() { 86 | final int prime = 31; 87 | int result = 1; 88 | result = prime * result + id; 89 | return result; 90 | } 91 | 92 | @Override 93 | public boolean equals(Object obj) { 94 | if (this == obj) 95 | return true; 96 | if (obj == null) 97 | return false; 98 | if (getClass() != obj.getClass()) 99 | return false; 100 | Person other = (Person) obj; 101 | if (id != other.id) 102 | return false; 103 | return true; 104 | } 105 | 106 | } -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.product/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.fipro.eclipse.migration.e4.product 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.product/org.fipro.eclipse.migration.e4.product: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -clearPersistedState 11 | 12 | -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.fipro.eclipse.migration.e4.service.preferences 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.pde.ds.core.builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.pde.PluginNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.8 8 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Migration Application Preference Services 4 | Bundle-SymbolicName: org.fipro.eclipse.migration.e4.service.preferences 5 | Bundle-Version: 1.0.0.qualifier 6 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 7 | Require-Bundle: org.eclipse.core.runtime;bundle-version="3.10.0", 8 | org.eclipse.e4.core.di;bundle-version="1.4.0", 9 | org.eclipse.jface;bundle-version="3.10.1" 10 | Service-Component: OSGI-INF/org.fipro.eclipse.migration.e4.service.preferences.impl.PreferenceManagerSupplier.xml 11 | Export-Package: org.fipro.eclipse.migration.e4.service.preferences 12 | Bundle-ActivationPolicy: lazy 13 | Import-Package: org.osgi.service.component.annotations;version="1.2.0";resolution:=optional 14 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/OSGI-INF/org.fipro.eclipse.migration.e4.service.preferences.impl.PreferenceManagerSupplier.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/build.properties: -------------------------------------------------------------------------------- 1 | output.. = bin/ 2 | bin.includes = META-INF/,\ 3 | .,\ 4 | OSGI-INF/ 5 | source.. = src/ 6 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/ContributedPreferenceNode.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.service.preferences; 2 | 3 | import org.eclipse.core.runtime.preferences.InstanceScope; 4 | import org.eclipse.jface.preference.IPreferencePage; 5 | import org.eclipse.jface.preference.PreferenceNode; 6 | import org.eclipse.jface.preference.PreferencePage; 7 | import org.eclipse.jface.resource.ImageDescriptor; 8 | import org.fipro.eclipse.migration.e4.service.preferences.impl.ScopedPreferenceStore; 9 | import org.osgi.framework.FrameworkUtil; 10 | 11 | /** 12 | * Specialization of PreferenceNode that overrides createPage() to support 13 | * IPreferencePage creation for contributed pages from other bundles. 14 | * Otherwise the page instance creation will fail because of ClassNotFoundExceptions. 15 | */ 16 | public class ContributedPreferenceNode extends PreferenceNode { 17 | 18 | private final String path; 19 | private final String nodeQualifier; 20 | private final Class pageClass; 21 | 22 | public ContributedPreferenceNode( 23 | String id, String label, 24 | ImageDescriptor imageDescriptor, Class pageClass, 25 | String path, String nodeQualifier) { 26 | 27 | super(id, label, imageDescriptor, pageClass.getName()); 28 | this.path = path; 29 | this.pageClass = pageClass; 30 | 31 | this.nodeQualifier = nodeQualifier != null ? nodeQualifier : FrameworkUtil.getBundle(pageClass).getSymbolicName(); 32 | } 33 | 34 | @Override 35 | public void createPage() { 36 | try { 37 | setPage(this.pageClass.newInstance()); 38 | } catch (InstantiationException|IllegalAccessException e) { 39 | e.printStackTrace(); 40 | } 41 | 42 | if (getLabelImage() != null) { 43 | getPage().setImageDescriptor(getImageDescriptor()); 44 | } 45 | getPage().setTitle(getLabelText()); 46 | 47 | ((PreferencePage)getPage()).setPreferenceStore( 48 | new ScopedPreferenceStore(InstanceScope.INSTANCE, this.nodeQualifier)); 49 | } 50 | 51 | public String getPath() { 52 | return path; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/PrefMgr.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.service.preferences; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import javax.inject.Qualifier; 10 | 11 | @Qualifier 12 | @Documented 13 | @Target({ElementType.PARAMETER, ElementType.FIELD}) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface PrefMgr { 16 | 17 | } -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/PreferenceNodeContribution.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.service.preferences; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.eclipse.jface.preference.IPreferencePage; 7 | import org.eclipse.jface.resource.ImageDescriptor; 8 | 9 | public class PreferenceNodeContribution { 10 | 11 | private final List nodes = new ArrayList<>(); 12 | 13 | public PreferenceNodeContribution(String id, String label, Class pageClass) { 14 | this(id, label, null, pageClass, null, null); 15 | } 16 | 17 | public PreferenceNodeContribution(String id, String label, Class pageClass, String path) { 18 | this(id, label, null, pageClass, path, null); 19 | } 20 | 21 | public PreferenceNodeContribution(String id, String label, Class pageClass, String path, String nodeQualifier) { 22 | this(id, label, null, pageClass, path, nodeQualifier); 23 | } 24 | 25 | public PreferenceNodeContribution( 26 | String id, 27 | String label, 28 | ImageDescriptor imageDescriptor, 29 | Class pageClass, 30 | String path, 31 | String nodeQualifier) { 32 | 33 | this.nodes.add(new ContributedPreferenceNode(id, label, imageDescriptor, pageClass, path, nodeQualifier)); 34 | } 35 | 36 | public List getPreferenceNodes() { 37 | return this.nodes; 38 | } 39 | 40 | public void addPreferenceNode(String id, String label, Class pageClass) { 41 | addPreferenceNode(id, label, null, pageClass, null, null); 42 | } 43 | 44 | public void addPreferenceNode(String id, String label, Class pageClass, String path) { 45 | addPreferenceNode(id, label, null, pageClass, path, null); 46 | } 47 | 48 | public void addPreferenceNode(String id, String label, Class pageClass, String path, String nodeQualifier) { 49 | addPreferenceNode(id, label, null, pageClass, path, nodeQualifier); 50 | } 51 | 52 | public void addPreferenceNode( 53 | String id, 54 | String label, 55 | ImageDescriptor imageDescriptor, 56 | Class pageClass, 57 | String path, 58 | String nodeQualifier) { 59 | 60 | this.nodes.add(new ContributedPreferenceNode(id, label, imageDescriptor, pageClass, path, nodeQualifier)); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/impl/PreferenceManagerSupplier.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.service.preferences.impl; 2 | 3 | import org.eclipse.e4.core.di.suppliers.ExtendedObjectSupplier; 4 | import org.eclipse.e4.core.di.suppliers.IObjectDescriptor; 5 | import org.eclipse.e4.core.di.suppliers.IRequestor; 6 | import org.eclipse.jface.preference.PreferenceManager; 7 | import org.fipro.eclipse.migration.e4.service.preferences.ContributedPreferenceNode; 8 | import org.fipro.eclipse.migration.e4.service.preferences.PreferenceNodeContribution; 9 | import org.osgi.service.component.annotations.Component; 10 | import org.osgi.service.component.annotations.Reference; 11 | import org.osgi.service.component.annotations.ReferenceCardinality; 12 | import org.osgi.service.component.annotations.ReferencePolicy; 13 | 14 | @SuppressWarnings("restriction") 15 | @Component( 16 | service=ExtendedObjectSupplier.class, 17 | property="dependency.injection.annotation=org.fipro.eclipse.migration.e4.service.preferences.PrefMgr" 18 | ) 19 | public class PreferenceManagerSupplier extends ExtendedObjectSupplier { 20 | 21 | PreferenceManager mgr; 22 | 23 | @Override 24 | public Object get(IObjectDescriptor descriptor, IRequestor requestor, boolean track, boolean group) { 25 | return getManager(); 26 | } 27 | 28 | protected PreferenceManager getManager() { 29 | if (this.mgr == null) { 30 | this.mgr = new PreferenceManager(); 31 | } 32 | return mgr; 33 | } 34 | 35 | @Reference( 36 | cardinality=ReferenceCardinality.MULTIPLE, 37 | policy=ReferencePolicy.DYNAMIC 38 | ) 39 | synchronized void addPreferenceNode(PreferenceNodeContribution node) { 40 | for (ContributedPreferenceNode contribNode : node.getPreferenceNodes()) { 41 | if (contribNode.getPath() == null) { 42 | getManager().addToRoot(contribNode); 43 | } 44 | else { 45 | getManager().addTo(contribNode.getPath(), contribNode); 46 | } 47 | } 48 | } 49 | 50 | synchronized void removePreferenceNode(PreferenceNodeContribution node) { 51 | for (ContributedPreferenceNode contribNode : node.getPreferenceNodes()) { 52 | getManager().remove(contribNode); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/impl/ScopedPreferenceStore.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.service.preferences.impl; 2 | 3 | import java.io.IOException; 4 | 5 | import org.eclipse.core.commands.common.EventManager; 6 | import org.eclipse.core.runtime.Assert; 7 | import org.eclipse.core.runtime.Platform; 8 | import org.eclipse.core.runtime.Plugin; 9 | import org.eclipse.core.runtime.SafeRunner; 10 | import org.eclipse.core.runtime.preferences.DefaultScope; 11 | import org.eclipse.core.runtime.preferences.IEclipsePreferences; 12 | import org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener; 13 | import org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent; 14 | import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; 15 | import org.eclipse.core.runtime.preferences.IScopeContext; 16 | import org.eclipse.jface.preference.IPersistentPreferenceStore; 17 | import org.eclipse.jface.preference.IPreferenceStore; 18 | import org.eclipse.jface.resource.JFaceResources; 19 | import org.eclipse.jface.util.IPropertyChangeListener; 20 | import org.eclipse.jface.util.PropertyChangeEvent; 21 | import org.eclipse.jface.util.SafeRunnable; 22 | import org.osgi.service.prefs.BackingStoreException; 23 | 24 | /** 25 | * The ScopedPreferenceStore is an IPreferenceStore that uses the scopes 26 | * provided in org.eclipse.core.runtime.preferences. 27 | *

28 | * A ScopedPreferenceStore does the lookup of a preference based on it's search 29 | * scopes and sets the value of the preference based on its store scope. 30 | *

31 | *

32 | * The default scope is always included in the search scopes when searching for 33 | * preference values. 34 | *

35 | * 36 | * @see org.eclipse.core.runtime.preferences 37 | * @since 3.1 38 | */ 39 | public class ScopedPreferenceStore extends EventManager implements 40 | IPreferenceStore, IPersistentPreferenceStore { 41 | 42 | /** 43 | * The storeContext is the context where values will stored with the 44 | * setValue methods. If there are no searchContexts this will be the search 45 | * context. (along with the "default" context) 46 | */ 47 | private IScopeContext storeContext; 48 | 49 | /** 50 | * The searchContext is the array of contexts that will be used by the get 51 | * methods for searching for values. 52 | */ 53 | private IScopeContext[] searchContexts; 54 | 55 | /** 56 | * A boolean to indicate the property changes should not be propagated. 57 | */ 58 | protected boolean silentRunning = false; 59 | 60 | /** 61 | * The listener on the IEclipsePreferences. This is used to forward updates 62 | * to the property change listeners on the preference store. 63 | */ 64 | IEclipsePreferences.IPreferenceChangeListener preferencesListener; 65 | 66 | /** 67 | * The default context is the context where getDefault and setDefault 68 | * methods will search. This context is also used in the search. 69 | */ 70 | private IScopeContext defaultContext = DefaultScope.INSTANCE; 71 | 72 | /** 73 | * The nodeQualifer is the string used to look up the node in the contexts. 74 | */ 75 | String nodeQualifier; 76 | 77 | /** 78 | * The defaultQualifier is the string used to look up the default node. 79 | */ 80 | String defaultQualifier; 81 | 82 | /** 83 | * Boolean value indicating whether or not this store has changes to be 84 | * saved. 85 | */ 86 | private boolean dirty; 87 | 88 | /** 89 | * Create a new instance of the receiver. Store the values in context in the 90 | * node looked up by qualifier. NOTE: Any instance of 91 | * ScopedPreferenceStore should call 92 | * 93 | * @param context 94 | * the scope to store to 95 | * @param qualifier 96 | * the qualifier used to look up the preference node 97 | * @param defaultQualifierPath 98 | * the qualifier used when looking up the defaults 99 | */ 100 | public ScopedPreferenceStore(IScopeContext context, String qualifier, 101 | String defaultQualifierPath) { 102 | this(context, qualifier); 103 | this.defaultQualifier = defaultQualifierPath; 104 | } 105 | 106 | /** 107 | * Create a new instance of the receiver. Store the values in context in the 108 | * node looked up by qualifier. 109 | * 110 | * @param context 111 | * the scope to store to 112 | * @param qualifier 113 | * the qualifer used to look up the preference node 114 | */ 115 | public ScopedPreferenceStore(IScopeContext context, String qualifier) { 116 | storeContext = context; 117 | this.nodeQualifier = qualifier; 118 | this.defaultQualifier = qualifier; 119 | 120 | ((IEclipsePreferences) getStorePreferences().parent()) 121 | .addNodeChangeListener(getNodeChangeListener()); 122 | } 123 | 124 | /** 125 | * Return a node change listener that adds a removes the receiver when nodes 126 | * change. 127 | * 128 | * @return INodeChangeListener 129 | */ 130 | private INodeChangeListener getNodeChangeListener() { 131 | return new IEclipsePreferences.INodeChangeListener() { 132 | /* 133 | * (non-Javadoc) 134 | * 135 | * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener#added(org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent) 136 | */ 137 | @Override 138 | public void added(NodeChangeEvent event) { 139 | if (nodeQualifier.equals(event.getChild().name()) 140 | && isListenerAttached()) { 141 | getStorePreferences().addPreferenceChangeListener( 142 | preferencesListener); 143 | } 144 | } 145 | 146 | /* 147 | * (non-Javadoc) 148 | * 149 | * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener#removed(org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent) 150 | */ 151 | @Override 152 | public void removed(NodeChangeEvent event) { 153 | // Do nothing as there are no events from removed node 154 | } 155 | }; 156 | } 157 | 158 | /** 159 | * Initialize the preferences listener. 160 | */ 161 | private void initializePreferencesListener() { 162 | if (preferencesListener == null) { 163 | preferencesListener = new IEclipsePreferences.IPreferenceChangeListener() { 164 | /* 165 | * (non-Javadoc) 166 | * 167 | * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent) 168 | */ 169 | @Override 170 | public void preferenceChange(PreferenceChangeEvent event) { 171 | 172 | if (silentRunning) { 173 | return; 174 | } 175 | 176 | Object oldValue = event.getOldValue(); 177 | Object newValue = event.getNewValue(); 178 | String key = event.getKey(); 179 | if (newValue == null) { 180 | newValue = getDefault(key, oldValue); 181 | } else if (oldValue == null) { 182 | oldValue = getDefault(key, newValue); 183 | } 184 | firePropertyChangeEvent(event.getKey(), oldValue, newValue); 185 | } 186 | }; 187 | getStorePreferences().addPreferenceChangeListener( 188 | preferencesListener); 189 | } 190 | 191 | } 192 | 193 | /** 194 | * Does its best at determining the default value for the given key. Checks 195 | * the given object's type and then looks in the list of defaults to see if 196 | * a value exists. If not or if there is a problem converting the value, the 197 | * default default value for that type is returned. 198 | * 199 | * @param key 200 | * the key to search 201 | * @param obj 202 | * the object who default we are looking for 203 | * @return Object or null 204 | */ 205 | Object getDefault(String key, Object obj) { 206 | IEclipsePreferences defaults = getDefaultPreferences(); 207 | if (obj instanceof String) { 208 | return defaults.get(key, STRING_DEFAULT_DEFAULT); 209 | } else if (obj instanceof Integer) { 210 | return new Integer(defaults.getInt(key, INT_DEFAULT_DEFAULT)); 211 | } else if (obj instanceof Double) { 212 | return new Double(defaults.getDouble(key, DOUBLE_DEFAULT_DEFAULT)); 213 | } else if (obj instanceof Float) { 214 | return new Float(defaults.getFloat(key, FLOAT_DEFAULT_DEFAULT)); 215 | } else if (obj instanceof Long) { 216 | return new Long(defaults.getLong(key, LONG_DEFAULT_DEFAULT)); 217 | } else if (obj instanceof Boolean) { 218 | return defaults.getBoolean(key, BOOLEAN_DEFAULT_DEFAULT) ? Boolean.TRUE 219 | : Boolean.FALSE; 220 | } else { 221 | return null; 222 | } 223 | } 224 | 225 | /** 226 | * Return the IEclipsePreferences node associated with this store. 227 | * 228 | * @return the preference node for this store 229 | */ 230 | IEclipsePreferences getStorePreferences() { 231 | return storeContext.getNode(nodeQualifier); 232 | } 233 | 234 | /** 235 | * Return the default IEclipsePreferences for this store. 236 | * 237 | * @return this store's default preference node 238 | */ 239 | private IEclipsePreferences getDefaultPreferences() { 240 | return defaultContext.getNode(defaultQualifier); 241 | } 242 | 243 | /* 244 | * (non-Javadoc) 245 | * 246 | * @see org.eclipse.jface.preference.IPreferenceStore#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) 247 | */ 248 | @Override 249 | public void addPropertyChangeListener(IPropertyChangeListener listener) { 250 | initializePreferencesListener();// Create the preferences listener if it 251 | // does not exist 252 | addListenerObject(listener); 253 | } 254 | 255 | /** 256 | * Return the preference path to search preferences on. This is the list of 257 | * preference nodes based on the scope contexts for this store. If there are 258 | * no search contexts set, then return this store's context. 259 | *

260 | * Whether or not the default context should be included in the resulting 261 | * list is specified by the includeDefault parameter. 262 | *

263 | * 264 | * @param includeDefault 265 | * true if the default context should be included 266 | * and false otherwise 267 | * @return IEclipsePreferences[] 268 | * @since 3.4 public, was added in 3.1 as private method 269 | */ 270 | public IEclipsePreferences[] getPreferenceNodes(boolean includeDefault) { 271 | // if the user didn't specify a search order, then return the scope that 272 | // this store was created on. (and optionally the default) 273 | if (searchContexts == null) { 274 | if (includeDefault) { 275 | return new IEclipsePreferences[] { getStorePreferences(), 276 | getDefaultPreferences() }; 277 | } 278 | return new IEclipsePreferences[] { getStorePreferences() }; 279 | } 280 | // otherwise the user specified a search order so return the appropriate 281 | // nodes based on it 282 | int length = searchContexts.length; 283 | if (includeDefault) { 284 | length++; 285 | } 286 | IEclipsePreferences[] preferences = new IEclipsePreferences[length]; 287 | for (int i = 0; i < searchContexts.length; i++) { 288 | preferences[i] = searchContexts[i].getNode(nodeQualifier); 289 | } 290 | if (includeDefault) { 291 | preferences[length - 1] = getDefaultPreferences(); 292 | } 293 | return preferences; 294 | } 295 | 296 | /** 297 | * Set the search contexts to scopes. When searching for a value the seach 298 | * will be done in the order of scope contexts and will not search the 299 | * storeContext unless it is in this list. 300 | *

301 | * If the given list is null, then clear this store's search 302 | * contexts. This means that only this store's scope context and default 303 | * scope will be used during preference value searching. 304 | *

305 | *

306 | * The defaultContext will be added to the end of this list automatically 307 | * and MUST NOT be included by the user. 308 | *

309 | * 310 | * @param scopes 311 | * a list of scope contexts to use when searching, or 312 | * null 313 | */ 314 | public void setSearchContexts(IScopeContext[] scopes) { 315 | this.searchContexts = scopes; 316 | if (scopes == null) { 317 | return; 318 | } 319 | 320 | // Assert that the default was not included (we automatically add it to 321 | // the end) 322 | for (int i = 0; i < scopes.length; i++) { 323 | if (scopes[i].equals(defaultContext)) { 324 | // TODO localize 325 | Assert.isTrue(false, "Do not add the default to the search contexts"); 326 | } 327 | } 328 | } 329 | 330 | /* 331 | * (non-Javadoc) 332 | * 333 | * @see org.eclipse.jface.preference.IPreferenceStore#contains(java.lang.String) 334 | */ 335 | @Override 336 | public boolean contains(String name) { 337 | if (name == null) { 338 | return false; 339 | } 340 | return (Platform.getPreferencesService().get(name, null, 341 | getPreferenceNodes(true))) != null; 342 | } 343 | 344 | /* 345 | * (non-Javadoc) 346 | * 347 | * @see org.eclipse.jface.preference.IPreferenceStore#firePropertyChangeEvent(java.lang.String, 348 | * java.lang.Object, java.lang.Object) 349 | */ 350 | @Override 351 | public void firePropertyChangeEvent(String name, Object oldValue, 352 | Object newValue) { 353 | // important: create intermediate array to protect against listeners 354 | // being added/removed during the notification 355 | final Object[] list = getListeners(); 356 | if (list.length == 0) { 357 | return; 358 | } 359 | final PropertyChangeEvent event = new PropertyChangeEvent(this, name, 360 | oldValue, newValue); 361 | for (int i = 0; i < list.length; i++) { 362 | final IPropertyChangeListener listener = (IPropertyChangeListener) list[i]; 363 | SafeRunner.run(new SafeRunnable(JFaceResources 364 | .getString("PreferenceStore.changeError")) { //$NON-NLS-1$ 365 | @Override 366 | public void run() { 367 | listener.propertyChange(event); 368 | } 369 | }); 370 | } 371 | } 372 | 373 | /* 374 | * (non-Javadoc) 375 | * 376 | * @see org.eclipse.jface.preference.IPreferenceStore#getBoolean(java.lang.String) 377 | */ 378 | @Override 379 | public boolean getBoolean(String name) { 380 | String value = internalGet(name); 381 | return value == null ? BOOLEAN_DEFAULT_DEFAULT : Boolean.valueOf(value) 382 | .booleanValue(); 383 | } 384 | 385 | /* 386 | * (non-Javadoc) 387 | * 388 | * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultBoolean(java.lang.String) 389 | */ 390 | @Override 391 | public boolean getDefaultBoolean(String name) { 392 | return getDefaultPreferences() 393 | .getBoolean(name, BOOLEAN_DEFAULT_DEFAULT); 394 | } 395 | 396 | /* 397 | * (non-Javadoc) 398 | * 399 | * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultDouble(java.lang.String) 400 | */ 401 | @Override 402 | public double getDefaultDouble(String name) { 403 | return getDefaultPreferences().getDouble(name, DOUBLE_DEFAULT_DEFAULT); 404 | } 405 | 406 | /* 407 | * (non-Javadoc) 408 | * 409 | * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultFloat(java.lang.String) 410 | */ 411 | @Override 412 | public float getDefaultFloat(String name) { 413 | return getDefaultPreferences().getFloat(name, FLOAT_DEFAULT_DEFAULT); 414 | } 415 | 416 | /* 417 | * (non-Javadoc) 418 | * 419 | * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultInt(java.lang.String) 420 | */ 421 | @Override 422 | public int getDefaultInt(String name) { 423 | return getDefaultPreferences().getInt(name, INT_DEFAULT_DEFAULT); 424 | } 425 | 426 | /* 427 | * (non-Javadoc) 428 | * 429 | * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultLong(java.lang.String) 430 | */ 431 | @Override 432 | public long getDefaultLong(String name) { 433 | return getDefaultPreferences().getLong(name, LONG_DEFAULT_DEFAULT); 434 | } 435 | 436 | /* 437 | * (non-Javadoc) 438 | * 439 | * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultString(java.lang.String) 440 | */ 441 | @Override 442 | public String getDefaultString(String name) { 443 | return getDefaultPreferences().get(name, STRING_DEFAULT_DEFAULT); 444 | } 445 | 446 | /* 447 | * (non-Javadoc) 448 | * 449 | * @see org.eclipse.jface.preference.IPreferenceStore#getDouble(java.lang.String) 450 | */ 451 | @Override 452 | public double getDouble(String name) { 453 | String value = internalGet(name); 454 | if (value == null) { 455 | return DOUBLE_DEFAULT_DEFAULT; 456 | } 457 | try { 458 | return Double.parseDouble(value); 459 | } catch (NumberFormatException e) { 460 | return DOUBLE_DEFAULT_DEFAULT; 461 | } 462 | } 463 | 464 | /** 465 | * Return the string value for the specified key. Look in the nodes which 466 | * are specified by this object's list of search scopes. If the value does 467 | * not exist then return null. 468 | * 469 | * @param key 470 | * the key to search with 471 | * @return String or null if the value does not exist. 472 | */ 473 | private String internalGet(String key) { 474 | return Platform.getPreferencesService().get(key, null, 475 | getPreferenceNodes(true)); 476 | } 477 | 478 | /* 479 | * (non-Javadoc) 480 | * 481 | * @see org.eclipse.jface.preference.IPreferenceStore#getFloat(java.lang.String) 482 | */ 483 | @Override 484 | public float getFloat(String name) { 485 | String value = internalGet(name); 486 | if (value == null) { 487 | return FLOAT_DEFAULT_DEFAULT; 488 | } 489 | try { 490 | return Float.parseFloat(value); 491 | } catch (NumberFormatException e) { 492 | return FLOAT_DEFAULT_DEFAULT; 493 | } 494 | } 495 | 496 | /* 497 | * (non-Javadoc) 498 | * 499 | * @see org.eclipse.jface.preference.IPreferenceStore#getInt(java.lang.String) 500 | */ 501 | @Override 502 | public int getInt(String name) { 503 | String value = internalGet(name); 504 | if (value == null) { 505 | return INT_DEFAULT_DEFAULT; 506 | } 507 | try { 508 | return Integer.parseInt(value); 509 | } catch (NumberFormatException e) { 510 | return INT_DEFAULT_DEFAULT; 511 | } 512 | } 513 | 514 | /* 515 | * (non-Javadoc) 516 | * 517 | * @see org.eclipse.jface.preference.IPreferenceStore#getLong(java.lang.String) 518 | */ 519 | @Override 520 | public long getLong(String name) { 521 | String value = internalGet(name); 522 | if (value == null) { 523 | return LONG_DEFAULT_DEFAULT; 524 | } 525 | try { 526 | return Long.parseLong(value); 527 | } catch (NumberFormatException e) { 528 | return LONG_DEFAULT_DEFAULT; 529 | } 530 | } 531 | 532 | /* 533 | * (non-Javadoc) 534 | * 535 | * @see org.eclipse.jface.preference.IPreferenceStore#getString(java.lang.String) 536 | */ 537 | @Override 538 | public String getString(String name) { 539 | String value = internalGet(name); 540 | return value == null ? STRING_DEFAULT_DEFAULT : value; 541 | } 542 | 543 | /* 544 | * (non-Javadoc) 545 | * 546 | * @see org.eclipse.jface.preference.IPreferenceStore#isDefault(java.lang.String) 547 | */ 548 | @Override 549 | public boolean isDefault(String name) { 550 | if (name == null) { 551 | return false; 552 | } 553 | return (Platform.getPreferencesService().get(name, null, 554 | getPreferenceNodes(false))) == null; 555 | } 556 | 557 | /* 558 | * (non-Javadoc) 559 | * 560 | * @see org.eclipse.jface.preference.IPreferenceStore#needsSaving() 561 | */ 562 | @Override 563 | public boolean needsSaving() { 564 | return dirty; 565 | } 566 | 567 | /* 568 | * (non-Javadoc) 569 | * 570 | * @see org.eclipse.jface.preference.IPreferenceStore#putValue(java.lang.String, 571 | * java.lang.String) 572 | */ 573 | @Override 574 | public void putValue(String name, String value) { 575 | try { 576 | // Do not notify listeners 577 | silentRunning = true; 578 | getStorePreferences().put(name, value); 579 | } finally { 580 | // Be sure that an exception does not stop property updates 581 | silentRunning = false; 582 | dirty = true; 583 | } 584 | } 585 | 586 | /* 587 | * (non-Javadoc) 588 | * 589 | * @see org.eclipse.jface.preference.IPreferenceStore#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) 590 | */ 591 | @Override 592 | public void removePropertyChangeListener(IPropertyChangeListener listener) { 593 | removeListenerObject(listener); 594 | if (!isListenerAttached()) { 595 | disposePreferenceStoreListener(); 596 | } 597 | } 598 | 599 | /* 600 | * (non-Javadoc) 601 | * 602 | * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, 603 | * double) 604 | */ 605 | @Override 606 | public void setDefault(String name, double value) { 607 | getDefaultPreferences().putDouble(name, value); 608 | } 609 | 610 | /* 611 | * (non-Javadoc) 612 | * 613 | * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, 614 | * float) 615 | */ 616 | @Override 617 | public void setDefault(String name, float value) { 618 | getDefaultPreferences().putFloat(name, value); 619 | } 620 | 621 | /* 622 | * (non-Javadoc) 623 | * 624 | * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, 625 | * int) 626 | */ 627 | @Override 628 | public void setDefault(String name, int value) { 629 | getDefaultPreferences().putInt(name, value); 630 | } 631 | 632 | /* 633 | * (non-Javadoc) 634 | * 635 | * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, 636 | * long) 637 | */ 638 | @Override 639 | public void setDefault(String name, long value) { 640 | getDefaultPreferences().putLong(name, value); 641 | } 642 | 643 | /* 644 | * (non-Javadoc) 645 | * 646 | * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, 647 | * java.lang.String) 648 | */ 649 | @Override 650 | public void setDefault(String name, String defaultObject) { 651 | getDefaultPreferences().put(name, defaultObject); 652 | } 653 | 654 | /* 655 | * (non-Javadoc) 656 | * 657 | * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, 658 | * boolean) 659 | */ 660 | @Override 661 | public void setDefault(String name, boolean value) { 662 | getDefaultPreferences().putBoolean(name, value); 663 | } 664 | 665 | /* 666 | * (non-Javadoc) 667 | * 668 | * @see org.eclipse.jface.preference.IPreferenceStore#setToDefault(java.lang.String) 669 | */ 670 | @Override 671 | public void setToDefault(String name) { 672 | 673 | String oldValue = getString(name); 674 | String defaultValue = getDefaultString(name); 675 | try { 676 | silentRunning = true;// Turn off updates from the store 677 | // removing a non-existing preference is a no-op so call the Core 678 | // API directly 679 | getStorePreferences().remove(name); 680 | if (oldValue != defaultValue){ 681 | dirty = true; 682 | firePropertyChangeEvent(name, oldValue, defaultValue); 683 | } 684 | 685 | } finally { 686 | silentRunning = false;// Restart listening to preferences 687 | } 688 | 689 | } 690 | 691 | /* 692 | * (non-Javadoc) 693 | * 694 | * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, 695 | * double) 696 | */ 697 | @Override 698 | public void setValue(String name, double value) { 699 | double oldValue = getDouble(name); 700 | if (oldValue == value) { 701 | return; 702 | } 703 | try { 704 | silentRunning = true;// Turn off updates from the store 705 | if (getDefaultDouble(name) == value) { 706 | getStorePreferences().remove(name); 707 | } else { 708 | getStorePreferences().putDouble(name, value); 709 | } 710 | dirty = true; 711 | firePropertyChangeEvent(name, new Double(oldValue), new Double( 712 | value)); 713 | } finally { 714 | silentRunning = false;// Restart listening to preferences 715 | } 716 | } 717 | 718 | /* 719 | * (non-Javadoc) 720 | * 721 | * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, 722 | * float) 723 | */ 724 | @Override 725 | public void setValue(String name, float value) { 726 | float oldValue = getFloat(name); 727 | if (oldValue == value) { 728 | return; 729 | } 730 | try { 731 | silentRunning = true;// Turn off updates from the store 732 | if (getDefaultFloat(name) == value) { 733 | getStorePreferences().remove(name); 734 | } else { 735 | getStorePreferences().putFloat(name, value); 736 | } 737 | dirty = true; 738 | firePropertyChangeEvent(name, new Float(oldValue), new Float(value)); 739 | } finally { 740 | silentRunning = false;// Restart listening to preferences 741 | } 742 | } 743 | 744 | /* 745 | * (non-Javadoc) 746 | * 747 | * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, 748 | * int) 749 | */ 750 | @Override 751 | public void setValue(String name, int value) { 752 | int oldValue = getInt(name); 753 | if (oldValue == value) { 754 | return; 755 | } 756 | try { 757 | silentRunning = true;// Turn off updates from the store 758 | if (getDefaultInt(name) == value) { 759 | getStorePreferences().remove(name); 760 | } else { 761 | getStorePreferences().putInt(name, value); 762 | } 763 | dirty = true; 764 | firePropertyChangeEvent(name, new Integer(oldValue), new Integer( 765 | value)); 766 | } finally { 767 | silentRunning = false;// Restart listening to preferences 768 | } 769 | } 770 | 771 | /* 772 | * (non-Javadoc) 773 | * 774 | * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, 775 | * long) 776 | */ 777 | @Override 778 | public void setValue(String name, long value) { 779 | long oldValue = getLong(name); 780 | if (oldValue == value) { 781 | return; 782 | } 783 | try { 784 | silentRunning = true;// Turn off updates from the store 785 | if (getDefaultLong(name) == value) { 786 | getStorePreferences().remove(name); 787 | } else { 788 | getStorePreferences().putLong(name, value); 789 | } 790 | dirty = true; 791 | firePropertyChangeEvent(name, new Long(oldValue), new Long(value)); 792 | } finally { 793 | silentRunning = false;// Restart listening to preferences 794 | } 795 | } 796 | 797 | /* 798 | * (non-Javadoc) 799 | * 800 | * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, 801 | * java.lang.String) 802 | */ 803 | @Override 804 | public void setValue(String name, String value) { 805 | // Do not turn on silent running here as Strings are propagated 806 | if (getDefaultString(name).equals(value)) { 807 | getStorePreferences().remove(name); 808 | } else { 809 | getStorePreferences().put(name, value); 810 | } 811 | dirty = true; 812 | } 813 | 814 | /* 815 | * (non-Javadoc) 816 | * 817 | * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, 818 | * boolean) 819 | */ 820 | @Override 821 | public void setValue(String name, boolean value) { 822 | boolean oldValue = getBoolean(name); 823 | if (oldValue == value) { 824 | return; 825 | } 826 | try { 827 | silentRunning = true;// Turn off updates from the store 828 | if (getDefaultBoolean(name) == value) { 829 | getStorePreferences().remove(name); 830 | } else { 831 | getStorePreferences().putBoolean(name, value); 832 | } 833 | dirty = true; 834 | firePropertyChangeEvent(name, oldValue ? Boolean.TRUE 835 | : Boolean.FALSE, value ? Boolean.TRUE : Boolean.FALSE); 836 | } finally { 837 | silentRunning = false;// Restart listening to preferences 838 | } 839 | } 840 | 841 | /* 842 | * (non-Javadoc) 843 | * 844 | * @see org.eclipse.jface.preference.IPersistentPreferenceStore#save() 845 | */ 846 | @Override 847 | public void save() throws IOException { 848 | try { 849 | getStorePreferences().flush(); 850 | dirty = false; 851 | } catch (BackingStoreException e) { 852 | throw new IOException(e.getMessage()); 853 | } 854 | 855 | } 856 | 857 | /** 858 | * Dispose the receiver. 859 | */ 860 | private void disposePreferenceStoreListener() { 861 | 862 | IEclipsePreferences root = (IEclipsePreferences) Platform 863 | .getPreferencesService().getRootNode().node( 864 | Plugin.PLUGIN_PREFERENCE_SCOPE); 865 | try { 866 | if (!(root.nodeExists(nodeQualifier))) { 867 | return; 868 | } 869 | } catch (BackingStoreException e) { 870 | return;// No need to report here as the node won't have the 871 | // listener 872 | } 873 | 874 | IEclipsePreferences preferences = getStorePreferences(); 875 | if (preferences == null) { 876 | return; 877 | } 878 | if (preferencesListener != null) { 879 | preferences.removePreferenceChangeListener(preferencesListener); 880 | preferencesListener = null; 881 | } 882 | } 883 | 884 | } 885 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.service/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.service/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.fipro.eclipse.migration.e4.service 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.pde.ds.core.builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.pde.PluginNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.service/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.8 8 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.service/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Migration Application Services 4 | Bundle-SymbolicName: org.fipro.eclipse.migration.e4.service;singleton:=true 5 | Bundle-Version: 1.0.0.qualifier 6 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 7 | Require-Bundle: org.fipro.eclipse.migration.e4.model;bundle-version="1.0.0" 8 | Export-Package: org.fipro.eclipse.migration.e4.service 9 | Service-Component: OSGI-INF/org.fipro.eclipse.migration.e4.service.internal.PersonServiceImpl.xml 10 | Bundle-ActivationPolicy: lazy 11 | Import-Package: org.osgi.service.component.annotations;version="1.2.0";resolution:=optional 12 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.service/OSGI-INF/org.fipro.eclipse.migration.e4.service.internal.PersonServiceImpl.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.service/build.properties: -------------------------------------------------------------------------------- 1 | output.. = bin/ 2 | bin.includes = META-INF/,\ 3 | .,\ 4 | OSGI-INF/ 5 | source.. = src/ 6 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.service/src/org/fipro/eclipse/migration/e4/service/PersonService.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.service; 2 | 3 | import java.util.List; 4 | 5 | import org.fipro.eclipse.migration.e4.model.Person; 6 | 7 | /** 8 | * Class that acts as service for accessing numerous {@link Person}s. 9 | * The values are randomly put together out of names and places from "The Simpsons" 10 | */ 11 | public interface PersonService { 12 | 13 | /** 14 | * Creates a list of {@link Person}s. 15 | * @param numberOfPersons The number of {@link Person}s that should be generated. 16 | * @return 17 | */ 18 | List getPersons(int numberOfPersons); 19 | 20 | /** 21 | * Creates a random person out of names which are taken from "The Simpsons" 22 | * and enrich them with random generated married state and birthday date. 23 | * @return 24 | */ 25 | Person createPerson(int id); 26 | } 27 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.service/src/org/fipro/eclipse/migration/e4/service/internal/PersonServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.service.internal; 2 | 3 | import java.text.ParseException; 4 | import java.text.SimpleDateFormat; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | import java.util.Random; 8 | 9 | import org.fipro.eclipse.migration.e4.model.Person; 10 | import org.fipro.eclipse.migration.e4.service.PersonService; 11 | import org.osgi.service.component.annotations.Component; 12 | 13 | /** 14 | * Class that acts as service for accessing numerous {@link Person}s. 15 | * The values are randomly put together out of names and places from "The Simpsons" 16 | */ 17 | @Component 18 | public final class PersonServiceImpl implements PersonService { 19 | 20 | public String[] maleNames = { 21 | "Bart", 22 | "Homer", 23 | "Lenny", 24 | "Carl", 25 | "Waylon", 26 | "Ned", 27 | "Timothy"}; 28 | public String[] femaleNames = { 29 | "Marge", 30 | "Lisa", 31 | "Maggie", 32 | "Edna", 33 | "Helen", 34 | "Jessica"}; 35 | public String[] lastNames = { 36 | "Simpson", 37 | "Leonard", 38 | "Carlson", 39 | "Smithers", 40 | "Flanders", 41 | "Krabappel", 42 | "Lovejoy"}; 43 | 44 | @Override 45 | public List getPersons(int numberOfPersons) { 46 | List result = new ArrayList(); 47 | 48 | for (int i = 0; i < numberOfPersons; i++) { 49 | result.add(createPerson(i)); 50 | } 51 | 52 | return result; 53 | } 54 | 55 | @Override 56 | public Person createPerson(int id) { 57 | Random randomGenerator = new Random(); 58 | 59 | Person result = new Person(id); 60 | result.setGender(Person.Gender.values()[randomGenerator.nextInt(2)]); 61 | 62 | if (result.getGender().equals(Person.Gender.MALE)) { 63 | result.setFirstName(maleNames[randomGenerator.nextInt(maleNames.length)]); 64 | } 65 | else { 66 | result.setFirstName(femaleNames[randomGenerator.nextInt(femaleNames.length)]); 67 | } 68 | 69 | result.setLastName(lastNames[randomGenerator.nextInt(lastNames.length)]); 70 | result.setMarried(randomGenerator.nextBoolean()); 71 | 72 | int month = randomGenerator.nextInt(12); 73 | int day = 0; 74 | if (month == 2) { 75 | day = randomGenerator.nextInt(28); 76 | } 77 | else { 78 | day = randomGenerator.nextInt(30); 79 | } 80 | int year = 1920 + randomGenerator.nextInt(90); 81 | 82 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 83 | try { 84 | result.setBirthday(sdf.parse(""+year+"-"+month+"-"+day)); 85 | } catch (ParseException e) { 86 | e.printStackTrace(); 87 | } 88 | 89 | return result; 90 | } 91 | 92 | } -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.target/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.fipro.eclipse.migration.e4.target 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.target/org.fipro.eclipse.migration.e4.target.target: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.fipro.eclipse.migration.e4.ui 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.pde.ds.core.builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.pde.PluginNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.8 8 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/Application.e4xmi: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: Migration Application UI 4 | Bundle-SymbolicName: org.fipro.eclipse.migration.e4.ui;singleton:=true 5 | Bundle-Version: 1.0.0.qualifier 6 | Require-Bundle: org.eclipse.core.runtime, 7 | org.eclipse.core.databinding;bundle-version="1.4.0", 8 | org.eclipse.core.databinding.beans;bundle-version="1.2.100", 9 | org.eclipse.core.databinding.property;bundle-version="1.4.0", 10 | org.eclipse.jface.databinding;bundle-version="1.5.0", 11 | org.eclipse.e4.core.di;bundle-version="1.4.0", 12 | org.eclipse.e4.ui.workbench;bundle-version="1.2.1", 13 | org.eclipse.e4.ui.di;bundle-version="1.0.0", 14 | org.eclipse.e4.ui.model.workbench;bundle-version="1.1.0", 15 | org.eclipse.e4.ui.services;bundle-version="1.1.0", 16 | org.eclipse.e4.core.di.extensions;bundle-version="0.12.0", 17 | javax.inject, 18 | org.fipro.eclipse.migration.e4.model;bundle-version="1.0.0", 19 | org.fipro.eclipse.migration.e4.service;bundle-version="1.0.0", 20 | org.fipro.eclipse.migration.e4.service.preferences;bundle-version="1.0.0", 21 | org.eclipse.swt;bundle-version="3.104.0", 22 | org.eclipse.jface;bundle-version="3.11.0" 23 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 24 | Service-Component: OSGI-INF/org.fipro.eclipse.migration.e4.ui.preferences.DescriptionPreferenceContribution.xml 25 | Import-Package: javax.inject;version="1.0.0", 26 | org.osgi.service.component.annotations;version="1.2.0";resolution:=optional, 27 | org.osgi.service.event;version="1.3.0" 28 | Bundle-ActivationPolicy: lazy 29 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/OSGI-INF/org.fipro.eclipse.migration.e4.ui.preferences.DescriptionPreferenceContribution.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/build.properties: -------------------------------------------------------------------------------- 1 | output.. = bin/ 2 | bin.includes = plugin.xml,\ 3 | META-INF/,\ 4 | .,\ 5 | fragment.e4xmi,\ 6 | OSGI-INF/,\ 7 | Application.e4xmi 8 | source.. = src/ 9 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/fragment.e4xmi: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | NoAutoCollapse 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/checked.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/checked.gif -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/eclipse16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/eclipse16.gif -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/eclipse16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/eclipse16.png -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/eclipse256.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/eclipse256.gif -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/eclipse256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/eclipse256.png -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/eclipse32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/eclipse32.gif -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/eclipse32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/eclipse32.png -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/eclipse48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/eclipse48.png -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/eclipse_lg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/eclipse_lg.png -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/editor.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/editor.gif -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/environment_obj.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/environment_obj.gif -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/prop_ps.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/prop_ps.gif -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/unchecked.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fipro78/e4-cookbook-migration-guide/e83a7e9cfa94a5d42234feadaaf5ca0878c9060e/e4-based-application/org.fipro.eclipse.migration.e4.ui/icons/unchecked.gif -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 10 | 13 | 14 | 17 | 18 | 19 | 20 | 23 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/PerspectiveSwitcher.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.ui; 2 | 3 | import java.util.List; 4 | 5 | import javax.annotation.PostConstruct; 6 | import javax.inject.Inject; 7 | 8 | import org.eclipse.e4.core.di.annotations.Optional; 9 | import org.eclipse.e4.ui.di.UIEventTopic; 10 | import org.eclipse.e4.ui.model.application.MApplication; 11 | import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective; 12 | import org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack; 13 | import org.eclipse.e4.ui.model.application.ui.basic.MWindow; 14 | import org.eclipse.e4.ui.workbench.UIEvents; 15 | import org.eclipse.e4.ui.workbench.UIEvents.ElementContainer; 16 | import org.eclipse.e4.ui.workbench.modeling.EModelService; 17 | import org.eclipse.e4.ui.workbench.modeling.EPartService; 18 | import org.eclipse.swt.SWT; 19 | import org.eclipse.swt.events.SelectionAdapter; 20 | import org.eclipse.swt.events.SelectionEvent; 21 | import org.eclipse.swt.widgets.Button; 22 | import org.eclipse.swt.widgets.Composite; 23 | import org.osgi.service.event.Event; 24 | 25 | public class PerspectiveSwitcher { 26 | 27 | @Inject 28 | EModelService modelService; 29 | 30 | @Inject 31 | EPartService partService; 32 | 33 | // FIXME potential bug, toolcontrol rendering is not executed via contribution 34 | 35 | @PostConstruct 36 | public void createGui(Composite parent, MApplication app, MWindow window) { 37 | 38 | List psList = modelService.findElements(window, null, 39 | MPerspectiveStack.class, null); 40 | if (psList.size() > 0) { 41 | System.out.println(psList.get(0).getChildren().size()); 42 | } 43 | 44 | List perspectives = 45 | modelService.findElements(app, null, MPerspective.class, null); 46 | 47 | for (final MPerspective perspective : perspectives) { 48 | Button button = new Button(parent, SWT.PUSH); 49 | button.setText(perspective.getLabel()); 50 | button.addSelectionListener(new SelectionAdapter() { 51 | 52 | @Override 53 | public void widgetSelected(SelectionEvent e) { 54 | partService.switchPerspective(perspective); 55 | } 56 | }); 57 | } 58 | } 59 | 60 | @Inject 61 | @Optional 62 | private void subscribeTopicChildAdded(@UIEventTopic(ElementContainer.TOPIC_CHILDREN) Event event) { 63 | if (event.getProperty(UIEvents.EventTags.ELEMENT) instanceof MPerspectiveStack) { 64 | System.out.println("perspective added"); 65 | if (UIEvents.isADD(event)) { 66 | } 67 | } 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/PerspectiveSwitcherAddon.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.ui; 2 | 3 | import javax.inject.Inject; 4 | 5 | import org.eclipse.e4.core.di.annotations.Optional; 6 | import org.eclipse.e4.ui.di.UIEventTopic; 7 | import org.eclipse.e4.ui.model.application.MApplication; 8 | import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective; 9 | import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar; 10 | import org.eclipse.e4.ui.model.application.ui.basic.MTrimElement; 11 | import org.eclipse.e4.ui.workbench.UIEvents; 12 | import org.eclipse.e4.ui.workbench.UIEvents.EventTags; 13 | import org.eclipse.e4.ui.workbench.modeling.EModelService; 14 | import org.osgi.service.event.Event; 15 | 16 | public class PerspectiveSwitcherAddon { 17 | 18 | static final String PERSPECTIVE_ONE = "org.fipro.toolbar.perspective.one"; 19 | static final String PERSPECTIVE_TWO = "org.fipro.toolbar.perspective.two"; 20 | 21 | static final String FIRST_TOOLBAR = "org.eclipse.ui.main.toolbar"; 22 | static final String SECOND_TOOLBAR = "org.fipro.e4.toolbar.toolbar.0"; 23 | 24 | @Inject 25 | EModelService modelService; 26 | 27 | @Inject 28 | @Optional 29 | public void subscribeTopicSelectedElement( 30 | @UIEventTopic(UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT) Event event, 31 | MApplication application) { 32 | 33 | Object newValue = event.getProperty(EventTags.NEW_VALUE); 34 | if (newValue instanceof MPerspective) { 35 | boolean isPerspectiveOne = ((MPerspective) newValue).getElementId().equals(PERSPECTIVE_ONE); 36 | 37 | MTrimBar top = (MTrimBar) modelService.find("org.eclipse.ui.trimbar.top", application.getChildren().get(0)); 38 | 39 | for (MTrimElement item : top.getChildren()) { 40 | if ((isPerspectiveOne && item.getElementId().equals(SECOND_TOOLBAR)) 41 | || !isPerspectiveOne && item.getElementId().equals(FIRST_TOOLBAR)) { 42 | item.setVisible(false); 43 | } 44 | else if ((!isPerspectiveOne && item.getElementId().equals(SECOND_TOOLBAR)) 45 | || isPerspectiveOne && item.getElementId().equals(FIRST_TOOLBAR)) { 46 | item.setVisible(true); 47 | } 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/action/OpenDialogAction.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.ui.action; 2 | 3 | import org.eclipse.e4.core.di.annotations.Execute; 4 | import org.eclipse.jface.dialogs.MessageDialog; 5 | 6 | public class OpenDialogAction { 7 | 8 | @Execute 9 | public void execute() { 10 | MessageDialog.openInformation(null, "Info", "Opened dialog via action"); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/editor/PersonEditor.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.ui.editor; 2 | 3 | import java.beans.PropertyChangeEvent; 4 | import java.beans.PropertyChangeListener; 5 | import java.util.Map; 6 | 7 | import javax.annotation.PostConstruct; 8 | import javax.inject.Inject; 9 | 10 | import org.eclipse.core.databinding.DataBindingContext; 11 | import org.eclipse.core.databinding.beans.BeanProperties; 12 | import org.eclipse.core.databinding.observable.value.IObservableValue; 13 | import org.eclipse.e4.ui.di.Persist; 14 | import org.eclipse.e4.ui.model.application.ui.MDirtyable; 15 | import org.eclipse.e4.ui.model.application.ui.basic.MPart; 16 | import org.eclipse.jface.databinding.swt.WidgetProperties; 17 | import org.eclipse.jface.databinding.viewers.ViewersObservables; 18 | import org.eclipse.jface.layout.GridDataFactory; 19 | import org.eclipse.jface.viewers.ArrayContentProvider; 20 | import org.eclipse.jface.viewers.ComboViewer; 21 | import org.eclipse.jface.viewers.LabelProvider; 22 | import org.eclipse.swt.SWT; 23 | import org.eclipse.swt.layout.GridLayout; 24 | import org.eclipse.swt.widgets.Button; 25 | import org.eclipse.swt.widgets.Composite; 26 | import org.eclipse.swt.widgets.Label; 27 | import org.eclipse.swt.widgets.Text; 28 | import org.fipro.eclipse.migration.e4.model.Person; 29 | import org.fipro.eclipse.migration.e4.model.Person.Gender; 30 | 31 | public class PersonEditor { 32 | 33 | public static final String ID = "org.fipro.eclipse.migration.ui.editor.personeditor"; 34 | 35 | public static final String CONTRIBUTION_URI = "bundleclass://org.fipro.eclipse.migration.e4.ui/org.fipro.eclipse.migration.e4.ui.editor.PersonEditor"; 36 | 37 | public static final String PERSON_INPUT_DATA = "personInputData"; 38 | 39 | @Inject 40 | private MDirtyable dirtyable; 41 | 42 | private Person person; 43 | private Person activePerson; 44 | 45 | @Inject 46 | public void init(MPart part) { 47 | Map transientData = part.getTransientData(); 48 | 49 | // note that we are using transient data here, because the editor is not 50 | // persisted anyway. 51 | // In order to persist the editor between sessions using 52 | // part.getPersistedState(); is necessary 53 | if (!(transientData.get(PERSON_INPUT_DATA) instanceof Person)) { 54 | throw new RuntimeException("You forgot to pass the actual person as transient data input"); 55 | } 56 | 57 | this.person = (Person) part.getTransientData().get(PERSON_INPUT_DATA); 58 | this.activePerson = new Person(this.person); 59 | } 60 | 61 | @PostConstruct 62 | public void createPartControl(Composite parent) { 63 | parent.setLayout(new GridLayout(2, false)); 64 | 65 | Label firstNameLabel = new Label(parent, SWT.NONE); 66 | firstNameLabel.setText("Firstname:"); 67 | GridDataFactory.defaultsFor(firstNameLabel).applyTo(firstNameLabel); 68 | 69 | Text firstNameField = new Text(parent, SWT.BORDER); 70 | GridDataFactory.fillDefaults().grab(true, false).applyTo(firstNameField); 71 | 72 | Label lastNameLabel = new Label(parent, SWT.NONE); 73 | lastNameLabel.setText("Lastname:"); 74 | GridDataFactory.defaultsFor(lastNameLabel).applyTo(lastNameLabel); 75 | 76 | Text lastNameField = new Text(parent, SWT.BORDER); 77 | GridDataFactory.fillDefaults().grab(true, false).applyTo(lastNameField); 78 | 79 | Label marriedLabel = new Label(parent, SWT.NONE); 80 | marriedLabel.setText("Married:"); 81 | GridDataFactory.defaultsFor(marriedLabel).applyTo(marriedLabel); 82 | 83 | Button marriedButton = new Button(parent, SWT.CHECK); 84 | 85 | Label genderLabel = new Label(parent, SWT.NONE); 86 | genderLabel.setText("Gender:"); 87 | GridDataFactory.defaultsFor(marriedLabel).applyTo(genderLabel); 88 | 89 | ComboViewer genderCombo = new ComboViewer(parent); 90 | genderCombo.setContentProvider(ArrayContentProvider.getInstance()); 91 | genderCombo.setLabelProvider(new LabelProvider() { 92 | @Override 93 | public String getText(Object element) { 94 | return super.getText(element); 95 | } 96 | }); 97 | genderCombo.setInput(Gender.values()); 98 | GridDataFactory.fillDefaults().grab(true, false).applyTo(genderCombo.getControl()); 99 | 100 | // add bindings 101 | DataBindingContext ctx = new DataBindingContext(); 102 | IObservableValue fnTarget = WidgetProperties.text(SWT.Modify).observe(firstNameField); 103 | IObservableValue lnTarget = WidgetProperties.text(SWT.Modify).observe(lastNameField); 104 | IObservableValue mTarget = WidgetProperties.selection().observe(marriedButton); 105 | IObservableValue gTarget = ViewersObservables.observeSingleSelection(genderCombo); 106 | 107 | IObservableValue fnModel = BeanProperties.value(Person.class, "firstName").observe(activePerson); 108 | IObservableValue lnModel = BeanProperties.value(Person.class, "lastName").observe(activePerson); 109 | IObservableValue mModel = BeanProperties.value(Person.class, "married").observe(activePerson); 110 | IObservableValue gModel = BeanProperties.value(Person.class, "gender").observe(activePerson); 111 | 112 | ctx.bindValue(fnTarget, fnModel); 113 | ctx.bindValue(lnTarget, lnModel); 114 | ctx.bindValue(mTarget, mModel); 115 | ctx.bindValue(gTarget, gModel); 116 | 117 | this.activePerson.addPropertyChangeListener(new PropertyChangeListener() { 118 | 119 | @Override 120 | public void propertyChange(PropertyChangeEvent evt) { 121 | dirtyable.setDirty(true); 122 | } 123 | }); 124 | } 125 | 126 | @Persist 127 | public void save() { 128 | this.person.setFirstName(this.activePerson.getFirstName()); 129 | this.person.setLastName(this.activePerson.getLastName()); 130 | this.person.setMarried(this.activePerson.isMarried()); 131 | this.person.setGender(this.activePerson.getGender()); 132 | 133 | dirtyable.setDirty(false); 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/handler/OpenDialogHandler.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.ui.handler; 2 | 3 | import org.eclipse.e4.core.di.annotations.Execute; 4 | import org.eclipse.jface.dialogs.MessageDialog; 5 | 6 | public class OpenDialogHandler { 7 | 8 | @Execute 9 | public void execute() { 10 | MessageDialog.openInformation(null, "Info", "Opened dialog via handler"); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/handler/PreferencesHandler.java: -------------------------------------------------------------------------------- 1 | 2 | package org.fipro.eclipse.migration.e4.ui.handler; 3 | 4 | import org.eclipse.e4.core.di.annotations.Execute; 5 | import org.eclipse.jface.preference.PreferenceDialog; 6 | import org.eclipse.jface.preference.PreferenceManager; 7 | import org.eclipse.jface.viewers.TreeViewer; 8 | import org.eclipse.jface.viewers.ViewerComparator; 9 | import org.eclipse.swt.widgets.Composite; 10 | import org.eclipse.swt.widgets.Shell; 11 | import org.fipro.eclipse.migration.e4.service.preferences.ContributedPreferenceNode; 12 | import org.fipro.eclipse.migration.e4.service.preferences.PrefMgr; 13 | 14 | public class PreferencesHandler { 15 | 16 | @Execute 17 | public void execute(Shell shell, @PrefMgr PreferenceManager manager) { 18 | PreferenceDialog dialog = new PreferenceDialog(shell, manager) { 19 | @Override 20 | protected TreeViewer createTreeViewer(Composite parent) { 21 | TreeViewer viewer = super.createTreeViewer(parent); 22 | 23 | viewer.setComparator(new ViewerComparator() { 24 | 25 | @Override 26 | public int category(Object element) { 27 | // this ensures that the General preferences page is always on top 28 | // while the other pages are ordered alphabetical 29 | if (element instanceof ContributedPreferenceNode 30 | && ("general".equals(((ContributedPreferenceNode) element).getId()))) { 31 | return -1; 32 | } 33 | return 0; 34 | } 35 | 36 | }); 37 | 38 | return viewer; 39 | } 40 | }; 41 | 42 | dialog.open(); 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/handler/SaveHandler.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.ui.handler; 2 | 3 | import org.eclipse.e4.core.di.annotations.CanExecute; 4 | import org.eclipse.e4.core.di.annotations.Execute; 5 | import org.eclipse.e4.ui.workbench.modeling.EPartService; 6 | 7 | public class SaveHandler { 8 | 9 | @Execute 10 | public void execute(EPartService partService) { 11 | partService.saveAll(false); 12 | } 13 | 14 | @CanExecute 15 | public boolean canExecute(EPartService partService) { 16 | if (partService != null) { 17 | return !partService.getDirtyParts().isEmpty(); 18 | } 19 | return false; 20 | } 21 | } -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/preferences/DescriptionPreferenceContribution.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.ui.preferences; 2 | 3 | import org.fipro.eclipse.migration.e4.service.preferences.PreferenceNodeContribution; 4 | import org.osgi.service.component.annotations.Component; 5 | 6 | @Component(service=PreferenceNodeContribution.class) 7 | public class DescriptionPreferenceContribution extends PreferenceNodeContribution { 8 | 9 | public DescriptionPreferenceContribution() { 10 | super("description", "Description", null, DescriptionPreferencePage.class, null, null); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/preferences/DescriptionPreferencePage.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.ui.preferences; 2 | 3 | import org.eclipse.jface.preference.IPreferenceStore; 4 | import org.eclipse.jface.preference.PreferencePage; 5 | import org.eclipse.swt.SWT; 6 | import org.eclipse.swt.events.SelectionAdapter; 7 | import org.eclipse.swt.events.SelectionEvent; 8 | import org.eclipse.swt.layout.GridLayout; 9 | import org.eclipse.swt.widgets.Button; 10 | import org.eclipse.swt.widgets.Composite; 11 | import org.eclipse.swt.widgets.Control; 12 | 13 | public class DescriptionPreferencePage extends PreferencePage { 14 | 15 | // Names for preferences 16 | private static final String DESCRIPTION_COLOR = "description_color"; 17 | 18 | // The checkboxes 19 | private Button checkBoxBlack; 20 | private Button checkBoxBlue; 21 | 22 | public DescriptionPreferencePage() { 23 | super("Description"); 24 | setDescription("The preferences page for the Description view"); 25 | } 26 | 27 | /** 28 | * Creates the controls for this page 29 | */ 30 | @Override 31 | protected Control createContents(Composite parent) { 32 | Composite composite = new Composite(parent, SWT.NONE); 33 | composite.setLayout(new GridLayout(2, false)); 34 | 35 | // Get the preference store 36 | IPreferenceStore preferenceStore = getPreferenceStore(); 37 | 38 | String color = preferenceStore.getString(DESCRIPTION_COLOR); 39 | boolean isBlack = (color != null && !color.isEmpty()) ? "black".equals(color) : true; 40 | 41 | // Create the checkboxes 42 | checkBoxBlack = new Button(composite, SWT.RADIO); 43 | checkBoxBlack.setText("Text Color Black"); 44 | checkBoxBlack.setSelection(isBlack); 45 | 46 | checkBoxBlue = new Button(composite, SWT.RADIO); 47 | checkBoxBlue.setText("Text Color Blue"); 48 | checkBoxBlue.setSelection(!isBlack); 49 | 50 | checkBoxBlack.addSelectionListener(new SelectionAdapter() { 51 | @Override 52 | public void widgetSelected(SelectionEvent e) { 53 | checkBoxBlack.setSelection(true); 54 | checkBoxBlue.setSelection(false); 55 | } 56 | }); 57 | 58 | checkBoxBlue.addSelectionListener(new SelectionAdapter() { 59 | @Override 60 | public void widgetSelected(SelectionEvent e) { 61 | checkBoxBlack.setSelection(false); 62 | checkBoxBlue.setSelection(true); 63 | } 64 | }); 65 | 66 | return composite; 67 | } 68 | 69 | /** 70 | * Called when user clicks Restore Defaults 71 | */ 72 | @Override 73 | protected void performDefaults() { 74 | // Get the preference store 75 | IPreferenceStore preferenceStore = getPreferenceStore(); 76 | 77 | String color = preferenceStore.getString(DESCRIPTION_COLOR); 78 | boolean isBlack = (color != null && !color.isEmpty()) ? "black".equals(color) : true; 79 | 80 | // Reset the fields to the defaults 81 | checkBoxBlack.setSelection(isBlack); 82 | checkBoxBlue.setSelection(!isBlack); 83 | } 84 | 85 | /** 86 | * Called when user clicks Apply or OK 87 | * 88 | * @return boolean 89 | */ 90 | @Override 91 | public boolean performOk() { 92 | // Get the preference store 93 | IPreferenceStore preferenceStore = getPreferenceStore(); 94 | 95 | // Set the values from the fields 96 | if (checkBoxBlack != null && checkBoxBlack.getSelection()) { 97 | preferenceStore.setValue(DESCRIPTION_COLOR, "black"); 98 | } 99 | else if (checkBoxBlue != null && checkBoxBlue.getSelection()) { 100 | preferenceStore.setValue(DESCRIPTION_COLOR, "blue"); 101 | } 102 | 103 | // Return true to allow dialog to close 104 | return true; 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/DescriptionView.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.ui.view; 2 | 3 | import javax.annotation.PostConstruct; 4 | import javax.inject.Inject; 5 | import javax.inject.Named; 6 | 7 | import org.eclipse.e4.core.di.annotations.Optional; 8 | import org.eclipse.e4.core.di.extensions.Preference; 9 | import org.eclipse.e4.ui.services.IServiceConstants; 10 | import org.eclipse.swt.SWT; 11 | import org.eclipse.swt.graphics.Color; 12 | import org.eclipse.swt.layout.FillLayout; 13 | import org.eclipse.swt.widgets.Composite; 14 | import org.eclipse.swt.widgets.Display; 15 | import org.eclipse.swt.widgets.Text; 16 | import org.fipro.eclipse.migration.e4.model.Person; 17 | import org.fipro.eclipse.migration.e4.model.Person.Gender; 18 | 19 | @SuppressWarnings("restriction") 20 | public class DescriptionView { 21 | 22 | Text description; 23 | 24 | @PostConstruct 25 | public void createPartControl(Composite parent) { 26 | parent.setLayout(new FillLayout()); 27 | description = new Text(parent, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY); 28 | } 29 | 30 | @Inject 31 | void updateDescription(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) Person person) { 32 | if (description != null && !description.isDisposed()) { 33 | if (person != null) { 34 | description.setText(person.getFirstName() + " " + person.getLastName() 35 | + " is a " + (person.isMarried() ? "married " : "single ") 36 | + (Gender.MALE.equals(person.getGender()) ? "man" : "woman")); 37 | } 38 | else { 39 | description.setText(""); 40 | } 41 | } 42 | } 43 | 44 | @Inject 45 | @Optional 46 | void setTextColor( 47 | @Preference(nodePath="org.fipro.eclipse.migration.e4.ui", value="description_color") String color) { 48 | 49 | Color toUse = "blue".equals(color) ? 50 | Display.getDefault().getSystemColor(SWT.COLOR_BLUE) : Display.getDefault().getSystemColor(SWT.COLOR_BLACK); 51 | 52 | if (description != null && !description.isDisposed()) { 53 | description.setForeground(toUse); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/DetailView.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.ui.view; 2 | 3 | import javax.annotation.PostConstruct; 4 | import javax.annotation.PreDestroy; 5 | import javax.inject.Inject; 6 | 7 | import org.eclipse.core.databinding.DataBindingContext; 8 | import org.eclipse.core.databinding.beans.BeanProperties; 9 | import org.eclipse.core.databinding.observable.value.IObservableValue; 10 | import org.eclipse.e4.ui.model.application.ui.basic.MPart; 11 | import org.eclipse.e4.ui.workbench.modeling.ESelectionService; 12 | import org.eclipse.e4.ui.workbench.modeling.ISelectionListener; 13 | import org.eclipse.jface.databinding.swt.WidgetProperties; 14 | import org.eclipse.jface.databinding.viewers.ViewersObservables; 15 | import org.eclipse.jface.layout.GridDataFactory; 16 | import org.eclipse.jface.viewers.ArrayContentProvider; 17 | import org.eclipse.jface.viewers.ComboViewer; 18 | import org.eclipse.jface.viewers.LabelProvider; 19 | import org.eclipse.swt.SWT; 20 | import org.eclipse.swt.layout.GridLayout; 21 | import org.eclipse.swt.widgets.Button; 22 | import org.eclipse.swt.widgets.Composite; 23 | import org.eclipse.swt.widgets.Label; 24 | import org.eclipse.swt.widgets.Text; 25 | import org.fipro.eclipse.migration.e4.model.Person; 26 | import org.fipro.eclipse.migration.e4.model.Person.Gender; 27 | import org.fipro.eclipse.migration.e4.ui.view.overview.OverviewView; 28 | 29 | public class DetailView { 30 | 31 | @Inject 32 | ESelectionService selectionService; 33 | 34 | Person activePerson = new Person(-1); 35 | 36 | ISelectionListener selectionListener = new ISelectionListener() { 37 | 38 | @Override 39 | public void selectionChanged(MPart part, Object selection) { 40 | if (part.getObject() instanceof OverviewView) { 41 | if (selection != null 42 | && selection instanceof Person) { 43 | Person p = (Person) selection; 44 | activePerson.setFirstName(p.getFirstName()); 45 | activePerson.setLastName(p.getLastName()); 46 | activePerson.setMarried(p.isMarried()); 47 | activePerson.setGender(p.getGender()); 48 | } 49 | else { 50 | activePerson.setFirstName(null); 51 | activePerson.setLastName(null); 52 | activePerson.setMarried(false); 53 | activePerson.setGender(null); 54 | } 55 | } 56 | } 57 | }; 58 | 59 | @PostConstruct 60 | public void createPartControl(Composite parent) { 61 | parent.setLayout(new GridLayout(2, false)); 62 | 63 | Label firstNameLabel = new Label(parent, SWT.NONE); 64 | firstNameLabel.setText("Firstname:"); 65 | GridDataFactory.defaultsFor(firstNameLabel).applyTo(firstNameLabel); 66 | 67 | Text firstNameField = new Text(parent, SWT.BORDER); 68 | GridDataFactory.fillDefaults().grab(true, false).applyTo(firstNameField); 69 | 70 | Label lastNameLabel = new Label(parent, SWT.NONE); 71 | lastNameLabel.setText("Lastname:"); 72 | GridDataFactory.defaultsFor(lastNameLabel).applyTo(lastNameLabel); 73 | 74 | Text lastNameField = new Text(parent, SWT.BORDER); 75 | GridDataFactory.fillDefaults().grab(true, false).applyTo(lastNameField); 76 | 77 | Label marriedLabel = new Label(parent, SWT.NONE); 78 | marriedLabel.setText("Married:"); 79 | GridDataFactory.defaultsFor(marriedLabel).applyTo(marriedLabel); 80 | 81 | Button marriedButton = new Button(parent, SWT.CHECK); 82 | 83 | Label genderLabel = new Label(parent, SWT.NONE); 84 | genderLabel.setText("Gender:"); 85 | GridDataFactory.defaultsFor(marriedLabel).applyTo(genderLabel); 86 | 87 | ComboViewer genderCombo = new ComboViewer(parent); 88 | genderCombo.setContentProvider(ArrayContentProvider.getInstance()); 89 | genderCombo.setLabelProvider(new LabelProvider() { 90 | @Override 91 | public String getText(Object element) { 92 | return super.getText(element); 93 | } 94 | }); 95 | genderCombo.setInput(Gender.values()); 96 | GridDataFactory.fillDefaults().grab(true, false).applyTo(genderCombo.getControl()); 97 | 98 | // add bindings 99 | DataBindingContext ctx = new DataBindingContext(); 100 | IObservableValue fnTarget = 101 | WidgetProperties.text(SWT.Modify).observe(firstNameField); 102 | IObservableValue lnTarget = 103 | WidgetProperties.text(SWT.Modify).observe(lastNameField); 104 | IObservableValue mTarget = 105 | WidgetProperties.selection().observe(marriedButton); 106 | IObservableValue gTarget = 107 | ViewersObservables.observeSingleSelection(genderCombo); 108 | 109 | IObservableValue fnModel= BeanProperties. 110 | value(Person.class,"firstName").observe(activePerson); 111 | IObservableValue lnModel= BeanProperties. 112 | value(Person.class,"lastName").observe(activePerson); 113 | IObservableValue mModel= BeanProperties. 114 | value(Person.class,"married").observe(activePerson); 115 | IObservableValue gModel= BeanProperties. 116 | value(Person.class,"gender").observe(activePerson); 117 | 118 | ctx.bindValue(fnTarget, fnModel); 119 | ctx.bindValue(lnTarget, lnModel); 120 | ctx.bindValue(mTarget, mModel); 121 | ctx.bindValue(gTarget, gModel); 122 | 123 | // add the selection listener 124 | selectionService.addSelectionListener(selectionListener); 125 | } 126 | 127 | @PreDestroy 128 | public void dispose() { 129 | selectionService.removeSelectionListener(selectionListener); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/FirstNameEditingSupport.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.ui.view.overview; 2 | 3 | import org.eclipse.jface.viewers.CellEditor; 4 | import org.eclipse.jface.viewers.ColumnViewer; 5 | import org.eclipse.jface.viewers.EditingSupport; 6 | import org.eclipse.jface.viewers.TextCellEditor; 7 | import org.eclipse.swt.widgets.Composite; 8 | import org.fipro.eclipse.migration.e4.model.Person; 9 | 10 | public class FirstNameEditingSupport extends EditingSupport { 11 | 12 | public FirstNameEditingSupport(ColumnViewer viewer) { 13 | super(viewer); 14 | } 15 | 16 | @Override 17 | protected CellEditor getCellEditor(Object element) { 18 | return new TextCellEditor((Composite) getViewer().getControl()); 19 | } 20 | 21 | @Override 22 | protected boolean canEdit(Object element) { 23 | return true; 24 | } 25 | 26 | @Override 27 | protected Object getValue(Object element) { 28 | return ((Person) element).getFirstName(); 29 | } 30 | 31 | @Override 32 | protected void setValue(Object element, Object value) { 33 | ((Person) element).setFirstName(String.valueOf(value)); 34 | getViewer().update(element, null); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/FirstNameLabelProvider.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.ui.view.overview; 2 | 3 | import org.eclipse.jface.viewers.StyledCellLabelProvider; 4 | import org.eclipse.jface.viewers.ViewerCell; 5 | import org.fipro.eclipse.migration.e4.model.Person; 6 | 7 | public class FirstNameLabelProvider extends StyledCellLabelProvider { 8 | @Override 9 | public void update(ViewerCell cell) { 10 | Person element= (Person) cell.getElement(); 11 | cell.setText(element.getFirstName()); 12 | super.update(cell); 13 | } 14 | } -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/GenderEditingSupport.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.ui.view.overview; 2 | 3 | import java.util.Arrays; 4 | 5 | import org.eclipse.jface.viewers.ArrayContentProvider; 6 | import org.eclipse.jface.viewers.CellEditor; 7 | import org.eclipse.jface.viewers.ColumnViewer; 8 | import org.eclipse.jface.viewers.ComboBoxViewerCellEditor; 9 | import org.eclipse.jface.viewers.EditingSupport; 10 | import org.eclipse.jface.viewers.LabelProvider; 11 | import org.eclipse.swt.widgets.Composite; 12 | import org.fipro.eclipse.migration.e4.model.Person; 13 | import org.fipro.eclipse.migration.e4.model.Person.Gender; 14 | 15 | public class GenderEditingSupport extends EditingSupport { 16 | 17 | private ComboBoxViewerCellEditor cellEditor; 18 | 19 | public GenderEditingSupport(ColumnViewer viewer) { 20 | super(viewer); 21 | cellEditor = new ComboBoxViewerCellEditor((Composite) getViewer().getControl()); 22 | cellEditor.setLabelProvider(new LabelProvider()); 23 | cellEditor.setContentProvider(new ArrayContentProvider()); 24 | cellEditor.setInput(Arrays.asList(Gender.FEMALE, Gender.MALE)); 25 | } 26 | 27 | @Override 28 | protected CellEditor getCellEditor(Object element) { 29 | return cellEditor; 30 | } 31 | 32 | @Override 33 | protected boolean canEdit(Object element) { 34 | return true; 35 | } 36 | 37 | @Override 38 | protected Object getValue(Object element) { 39 | return ((Person) element).getGender(); 40 | } 41 | 42 | @Override 43 | protected void setValue(Object element, Object value) { 44 | ((Person) element).setGender((Gender)value); 45 | getViewer().update(element, null); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/GenderLabelProvider.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.ui.view.overview; 2 | 3 | import org.eclipse.jface.viewers.StyledCellLabelProvider; 4 | import org.eclipse.jface.viewers.ViewerCell; 5 | import org.fipro.eclipse.migration.e4.model.Person; 6 | 7 | public class GenderLabelProvider extends StyledCellLabelProvider { 8 | @Override 9 | public void update(ViewerCell cell) { 10 | Person element= (Person) cell.getElement(); 11 | cell.setText(element.getGender().toString()); 12 | super.update(cell); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/LastNameEditingSupport.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.ui.view.overview; 2 | 3 | import org.eclipse.jface.viewers.CellEditor; 4 | import org.eclipse.jface.viewers.ColumnViewer; 5 | import org.eclipse.jface.viewers.EditingSupport; 6 | import org.eclipse.jface.viewers.TextCellEditor; 7 | import org.eclipse.swt.widgets.Composite; 8 | import org.fipro.eclipse.migration.e4.model.Person; 9 | 10 | public class LastNameEditingSupport extends EditingSupport { 11 | 12 | public LastNameEditingSupport(ColumnViewer viewer) { 13 | super(viewer); 14 | } 15 | 16 | @Override 17 | protected CellEditor getCellEditor(Object element) { 18 | return new TextCellEditor((Composite) getViewer().getControl()); 19 | } 20 | 21 | @Override 22 | protected boolean canEdit(Object element) { 23 | return true; 24 | } 25 | 26 | @Override 27 | protected Object getValue(Object element) { 28 | return ((Person) element).getLastName(); 29 | } 30 | 31 | @Override 32 | protected void setValue(Object element, Object value) { 33 | ((Person) element).setLastName(String.valueOf(value)); 34 | getViewer().update(element, null); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/LastNameLabelProvider.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.ui.view.overview; 2 | 3 | import org.eclipse.jface.viewers.StyledCellLabelProvider; 4 | import org.eclipse.jface.viewers.ViewerCell; 5 | import org.fipro.eclipse.migration.e4.model.Person; 6 | 7 | public class LastNameLabelProvider extends StyledCellLabelProvider { 8 | @Override 9 | public void update(ViewerCell cell) { 10 | Person element= (Person) cell.getElement(); 11 | cell.setText(element.getLastName()); 12 | super.update(cell); 13 | } 14 | } -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/MarriedEditingSupport.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.ui.view.overview; 2 | 3 | import org.eclipse.jface.viewers.CellEditor; 4 | import org.eclipse.jface.viewers.CheckboxCellEditor; 5 | import org.eclipse.jface.viewers.ColumnViewer; 6 | import org.eclipse.jface.viewers.EditingSupport; 7 | import org.eclipse.swt.SWT; 8 | import org.eclipse.swt.widgets.Composite; 9 | import org.fipro.eclipse.migration.e4.model.Person; 10 | 11 | public class MarriedEditingSupport extends EditingSupport { 12 | 13 | public MarriedEditingSupport(ColumnViewer viewer) { 14 | super(viewer); 15 | } 16 | 17 | @Override 18 | protected CellEditor getCellEditor(Object element) { 19 | return new CheckboxCellEditor((Composite) getViewer().getControl(), SWT.CHECK); 20 | } 21 | 22 | @Override 23 | protected boolean canEdit(Object element) { 24 | return true; 25 | } 26 | 27 | @Override 28 | protected Object getValue(Object element) { 29 | return ((Person) element).isMarried(); 30 | } 31 | 32 | @Override 33 | protected void setValue(Object element, Object value) { 34 | ((Person) element).setMarried((Boolean)value); 35 | getViewer().update(element, null); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/MarriedLabelProvider.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.ui.view.overview; 2 | 3 | import java.net.URL; 4 | 5 | import org.eclipse.core.runtime.FileLocator; 6 | import org.eclipse.core.runtime.Path; 7 | import org.eclipse.jface.resource.ImageDescriptor; 8 | import org.eclipse.jface.resource.JFaceResources; 9 | import org.eclipse.jface.resource.LocalResourceManager; 10 | import org.eclipse.jface.viewers.StyledCellLabelProvider; 11 | import org.eclipse.jface.viewers.ViewerCell; 12 | import org.eclipse.swt.graphics.Image; 13 | import org.fipro.eclipse.migration.e4.model.Person; 14 | import org.osgi.framework.Bundle; 15 | import org.osgi.framework.FrameworkUtil; 16 | 17 | public class MarriedLabelProvider extends StyledCellLabelProvider { 18 | 19 | private final Image uncheckedImg; 20 | private final Image checkedImg; 21 | 22 | public MarriedLabelProvider() { 23 | LocalResourceManager resourceMgr = new LocalResourceManager(JFaceResources.getResources()); 24 | Bundle bundle = FrameworkUtil.getBundle(getClass()); 25 | URL checked = FileLocator.find(bundle, new Path("icons/checked.gif"), null); 26 | URL unchecked = FileLocator.find(bundle, new Path("icons/unchecked.gif"), null); 27 | this.checkedImg = resourceMgr.createImage(ImageDescriptor.createFromURL(checked)); 28 | this.uncheckedImg = resourceMgr.createImage(ImageDescriptor.createFromURL(unchecked)); 29 | } 30 | 31 | @Override 32 | public void update(ViewerCell cell) { 33 | if (((Person)cell.getElement()).isMarried()) { 34 | cell.setImage(checkedImg); 35 | } 36 | else { 37 | cell.setImage(uncheckedImg); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/view/overview/OverviewView.java: -------------------------------------------------------------------------------- 1 | package org.fipro.eclipse.migration.e4.ui.view.overview; 2 | 3 | import java.beans.PropertyChangeEvent; 4 | import java.beans.PropertyChangeListener; 5 | import java.util.List; 6 | 7 | import javax.annotation.PostConstruct; 8 | import javax.inject.Inject; 9 | 10 | import org.eclipse.core.databinding.observable.IObservable; 11 | import org.eclipse.core.databinding.observable.list.WritableList; 12 | import org.eclipse.e4.ui.di.Focus; 13 | import org.eclipse.e4.ui.model.application.MApplication; 14 | import org.eclipse.e4.ui.model.application.ui.basic.MPart; 15 | import org.eclipse.e4.ui.model.application.ui.basic.MPartStack; 16 | import org.eclipse.e4.ui.workbench.modeling.EModelService; 17 | import org.eclipse.e4.ui.workbench.modeling.EPartService; 18 | import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState; 19 | import org.eclipse.e4.ui.workbench.modeling.ESelectionService; 20 | import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; 21 | import org.eclipse.jface.layout.GridDataFactory; 22 | import org.eclipse.jface.viewers.DoubleClickEvent; 23 | import org.eclipse.jface.viewers.IDoubleClickListener; 24 | import org.eclipse.jface.viewers.ISelectionChangedListener; 25 | import org.eclipse.jface.viewers.IStructuredSelection; 26 | import org.eclipse.jface.viewers.SelectionChangedEvent; 27 | import org.eclipse.jface.viewers.TableViewer; 28 | import org.eclipse.jface.viewers.TableViewerColumn; 29 | import org.eclipse.swt.SWT; 30 | import org.eclipse.swt.layout.GridLayout; 31 | import org.eclipse.swt.widgets.Composite; 32 | import org.fipro.eclipse.migration.e4.model.Person; 33 | import org.fipro.eclipse.migration.e4.service.PersonService; 34 | import org.fipro.eclipse.migration.e4.ui.editor.PersonEditor; 35 | 36 | public class OverviewView { 37 | 38 | TableViewer viewer; 39 | 40 | @Inject 41 | private ESelectionService selectionService; 42 | 43 | @Inject 44 | private PersonService personService; 45 | 46 | @Inject 47 | private EPartService partService; 48 | 49 | @Inject 50 | private EModelService modelService; 51 | 52 | @Inject 53 | private MApplication app; 54 | 55 | @PostConstruct 56 | public void createPartControl(Composite parent) { 57 | parent.setLayout(new GridLayout()); 58 | 59 | IObservable list = new WritableList(personService.getPersons(10), Person.class); 60 | 61 | viewer = new TableViewer(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); 62 | ObservableListContentProvider cp = new ObservableListContentProvider(); 63 | viewer.setContentProvider(cp); 64 | viewer.getTable().setHeaderVisible(true); 65 | viewer.getTable().setLinesVisible(true); 66 | GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl()); 67 | 68 | TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE); 69 | column.getColumn().setText("Firstname"); 70 | column.getColumn().setWidth(100); 71 | column.setLabelProvider(new FirstNameLabelProvider()); 72 | // column.setEditingSupport(new FirstNameEditingSupport(viewer)); 73 | 74 | column = new TableViewerColumn(viewer, SWT.NONE); 75 | column.getColumn().setText("Lastname"); 76 | column.getColumn().setWidth(100); 77 | column.setLabelProvider(new LastNameLabelProvider()); 78 | // column.setEditingSupport(new LastNameEditingSupport(viewer)); 79 | 80 | column = new TableViewerColumn(viewer, SWT.NONE); 81 | column.getColumn().setText("Married"); 82 | column.getColumn().setWidth(60); 83 | column.setLabelProvider(new MarriedLabelProvider()); 84 | // column.setEditingSupport(new MarriedEditingSupport(viewer)); 85 | 86 | column = new TableViewerColumn(viewer, SWT.NONE); 87 | column.getColumn().setText("Gender"); 88 | column.getColumn().setWidth(80); 89 | column.setLabelProvider(new GenderLabelProvider()); 90 | // column.setEditingSupport(new GenderEditingSupport(viewer)); 91 | 92 | viewer.setInput(list); 93 | 94 | // set the viewer as selection provider 95 | // getSite().setSelectionProvider(viewer); 96 | viewer.addSelectionChangedListener(new ISelectionChangedListener() { 97 | 98 | @Override 99 | public void selectionChanged(SelectionChangedEvent event) { 100 | IStructuredSelection selection = (IStructuredSelection) event.getSelection(); 101 | Person myInstance = (Person) selection.getFirstElement(); 102 | selectionService.setSelection(myInstance); 103 | } 104 | }); 105 | 106 | // hook double click for opening an editor 107 | viewer.addDoubleClickListener(new IDoubleClickListener() { 108 | 109 | @Override 110 | public void doubleClick(DoubleClickEvent event) { 111 | IStructuredSelection selection = viewer.getStructuredSelection(); 112 | Object obj = selection.getFirstElement(); 113 | // if we had a selection lets open the editor 114 | if (obj != null) { 115 | Person person = (Person) obj; 116 | person.addPropertyChangeListener(new PropertyChangeListener() { 117 | 118 | @Override 119 | public void propertyChange(PropertyChangeEvent evt) { 120 | viewer.refresh(); 121 | } 122 | }); 123 | 124 | String editorID = PersonEditor.ID + "_" + person.getId(); 125 | 126 | List parts = modelService.findElements(app, editorID, MPart.class, null); 127 | MPart personEditor = null; 128 | if (parts == null || parts.isEmpty()) { 129 | personEditor = modelService.createModelElement(MPart.class); 130 | 131 | personEditor.setContributionURI(PersonEditor.CONTRIBUTION_URI); 132 | personEditor.setIconURI("platform:/plugin/org.fipro.eclipse.migration.e4.ui/icons/editor.gif"); 133 | personEditor.setElementId(editorID); 134 | String label = person.getFirstName() + " " + person.getLastName(); 135 | personEditor.setLabel(label); 136 | personEditor.setTooltip(label + " editor"); 137 | personEditor.setCloseable(true); 138 | personEditor.getTags().add("Editor"); 139 | 140 | // set the person as transient data 141 | personEditor.getTransientData().put(PersonEditor.PERSON_INPUT_DATA, person); 142 | 143 | // find the editor partstack, which is defined in the perspective contribution in the fragment.e4xmi 144 | // in compat mode the id is org.eclipse.ui.editorss, in plain e4 this needs to be changed 145 | MPartStack stack = (MPartStack) modelService.find("org.fipro.eclipse.migration.e4.ui.partstack.editor", app); 146 | stack.getChildren().add(personEditor); 147 | } 148 | else { 149 | personEditor = parts.get(0); 150 | } 151 | 152 | partService.showPart(personEditor, PartState.ACTIVATE); 153 | } 154 | } 155 | }); 156 | } 157 | 158 | @Focus 159 | public void setFocus() { 160 | this.viewer.getControl().setFocus(); 161 | } 162 | 163 | } 164 | --------------------------------------------------------------------------------