Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug422465 - Sample project (horizontal extension e4 tooling)
- Loading branch information
Showing
11 changed files
with
237 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>at.descher.editor.extension.bug422465.feature</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.pde.FeatureBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.pde.FeatureNature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bin.includes = feature.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<feature | ||
id="at.descher.editor.extension.feature" | ||
label="Feature" | ||
version="1.0.0.qualifier" | ||
provider-name="descher.at"> | ||
|
||
<description url="http://www.example.com/description"> | ||
[Enter Feature Description here.] | ||
</description> | ||
|
||
<copyright url="http://www.example.com/copyright"> | ||
[Enter Copyright Description here.] | ||
</copyright> | ||
|
||
<license url="http://www.example.com/license"> | ||
[Enter License Description here.] | ||
</license> | ||
|
||
<plugin | ||
id="at.descher.editor.extension" | ||
download-size="0" | ||
install-size="0" | ||
version="0.0.0" | ||
unpack="false"/> | ||
|
||
</feature> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>at.descher.editor.extension.bug422465</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.ManifestBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.SchemaBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.pde.PluginNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
7 changes: 7 additions & 0 deletions
7
at.descher.editor.extension.bug422465/.settings/org.eclipse.jdt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 | ||
org.eclipse.jdt.core.compiler.compliance=1.7 | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.7 |
18 changes: 18 additions & 0 deletions
18
at.descher.editor.extension.bug422465/META-INF/MANIFEST.MF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: Sample Editor Extension | ||
Bundle-SymbolicName: at.descher.editor.extension.bug422465;singleton:=true | ||
Bundle-Version: 1.0.0.qualifier | ||
Bundle-Vendor: descher.at | ||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7 | ||
Require-Bundle: org.eclipse.e4.tools.emf.ui;bundle-version="0.12.0", | ||
org.eclipse.e4.ui.model.workbench, | ||
org.eclipse.core.databinding.observable, | ||
org.eclipse.swt, | ||
org.eclipse.jface.databinding, | ||
org.eclipse.emf.databinding.edit, | ||
org.eclipse.jface, | ||
org.eclipse.core.databinding.property;bundle-version="1.4.200" | ||
Import-Package: org.eclipse.core.runtime;version="3.4.0", | ||
org.eclipse.emf.databinding, | ||
org.eclipse.swt.widgets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
source.. = src/ | ||
output.. = bin/ | ||
bin.includes = META-INF/,\ | ||
.,\ | ||
plugin.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?eclipse version="3.4"?> | ||
<plugin> | ||
<extension | ||
point="org.eclipse.e4.tools.emf.ui.elementEditorTab"> | ||
<elementEditorTab | ||
contribution="at.descher.editor.extension.SampleElementtEditorContribution"> | ||
</elementEditorTab> | ||
</extension> | ||
|
||
</plugin> |
115 changes: 115 additions & 0 deletions
115
...extension.bug422465/src/at/descher/editor/extension/SampleElementtEditorContribution.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package at.descher.editor.extension; | ||
|
||
import org.eclipse.core.databinding.UpdateValueStrategy; | ||
import org.eclipse.core.databinding.observable.value.IObservableValue; | ||
import org.eclipse.core.databinding.observable.value.WritableValue; | ||
import org.eclipse.core.databinding.validation.IValidator; | ||
import org.eclipse.core.databinding.validation.ValidationStatus; | ||
import org.eclipse.core.runtime.IStatus; | ||
import org.eclipse.core.runtime.Status; | ||
import org.eclipse.e4.tools.emf.ui.internal.editor.extension.ElementEditorContribution; | ||
import org.eclipse.e4.ui.model.application.MApplicationElement; | ||
import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl; | ||
import org.eclipse.e4.ui.model.application.ui.basic.MPart; | ||
import org.eclipse.e4.ui.model.application.ui.impl.UiPackageImpl; | ||
import org.eclipse.emf.databinding.EMFDataBindingContext; | ||
import org.eclipse.emf.databinding.IEMFValueProperty; | ||
import org.eclipse.emf.databinding.edit.EMFEditProperties; | ||
import org.eclipse.emf.databinding.edit.IEMFEditValueProperty; | ||
import org.eclipse.emf.ecore.EPackage; | ||
import org.eclipse.emf.ecore.EcorePackage; | ||
import org.eclipse.emf.ecore.impl.EcorePackageImpl; | ||
import org.eclipse.emf.edit.domain.EditingDomain; | ||
import org.eclipse.jface.databinding.swt.IWidgetValueProperty; | ||
import org.eclipse.jface.databinding.swt.WidgetProperties; | ||
import org.eclipse.jface.fieldassist.ControlDecoration; | ||
import org.eclipse.jface.fieldassist.FieldDecoration; | ||
import org.eclipse.jface.fieldassist.FieldDecorationRegistry; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.custom.CTabFolder; | ||
import org.eclipse.swt.custom.CTabItem; | ||
import org.eclipse.swt.layout.GridData; | ||
import org.eclipse.swt.widgets.Composite; | ||
import org.eclipse.swt.widgets.Label; | ||
import org.eclipse.swt.widgets.Text; | ||
|
||
public class SampleElementtEditorContribution extends ElementEditorContribution { | ||
|
||
@Override | ||
public Class<? extends MApplicationElement> getContributedTo() { | ||
return MPart.class; | ||
} | ||
|
||
@Override | ||
public void createContributedForm(CTabFolder folder, | ||
EMFDataBindingContext context, WritableValue master, EditingDomain editingDomain) { | ||
|
||
CTabItem item = new CTabItem(folder, SWT.BORDER); | ||
item.setText("SampleAddition"); | ||
|
||
Composite parent = createScrollableContainer(folder); | ||
item.setControl(parent.getParent()); | ||
|
||
IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); | ||
|
||
IEMFEditValueProperty modelProp = EMFEditProperties.value( | ||
editingDomain, | ||
ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__ELEMENT_ID); | ||
|
||
createTextField(parent, "SampleLabel", "SampleTooltip", master, | ||
context, textProp, modelProp, "sampleWarning"); | ||
} | ||
|
||
private void createTextField(Composite parent, String label, | ||
String tooltip, IObservableValue master, | ||
EMFDataBindingContext context, IWidgetValueProperty textProp, | ||
IEMFEditValueProperty modelProp, final String warningText) { | ||
Label l = new Label(parent, SWT.NONE); | ||
l.setText(label); | ||
if (tooltip != null) { | ||
l.setToolTipText(tooltip); | ||
} | ||
l.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); | ||
|
||
final Text t = new Text(parent, SWT.BORDER); | ||
GridData gd = new GridData(GridData.FILL_HORIZONTAL); | ||
gd.horizontalSpan = 2; | ||
t.setLayoutData(gd); | ||
|
||
if (warningText != null) { | ||
final ControlDecoration controlDecoration = new ControlDecoration( | ||
t, SWT.LEFT | SWT.TOP); | ||
controlDecoration.setDescriptionText(warningText); | ||
FieldDecoration fieldDecoration = FieldDecorationRegistry | ||
.getDefault().getFieldDecoration( | ||
FieldDecorationRegistry.DEC_WARNING); | ||
controlDecoration.setImage(fieldDecoration.getImage()); | ||
IValidator iv = new IValidator() { | ||
|
||
@Override | ||
public IStatus validate(Object value) { | ||
if (value == null) { | ||
controlDecoration.show(); | ||
return ValidationStatus.warning(warningText); | ||
} | ||
if (value instanceof String) { | ||
String text = (String) value; | ||
if (text.trim().length() == 0) { | ||
controlDecoration.show(); | ||
return ValidationStatus.warning(warningText); | ||
} | ||
} | ||
controlDecoration.hide(); | ||
return Status.OK_STATUS; | ||
} | ||
}; | ||
UpdateValueStrategy acv = new UpdateValueStrategy() | ||
.setAfterConvertValidator(iv); | ||
context.bindValue(textProp.observeDelayed(200, t), | ||
modelProp.observeDetail(master), acv, acv); | ||
} else | ||
context.bindValue(textProp.observeDelayed(200, t), | ||
modelProp.observeDetail(master)); | ||
} | ||
|
||
} |