-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2096] Add style for the reference widget
Bug: #2096 Signed-off-by: Florian ROUËNÉ <[email protected]>
- Loading branch information
Showing
36 changed files
with
3,455 additions
and
604 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
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
246 changes: 246 additions & 0 deletions
246
...ts/widgets/reference/provider/ConditionalReferenceWidgetDescriptionStyleItemProvider.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,246 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.widgets.reference.provider; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import org.eclipse.emf.common.notify.AdapterFactory; | ||
import org.eclipse.emf.common.notify.Notification; | ||
import org.eclipse.emf.common.util.ResourceLocator; | ||
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; | ||
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; | ||
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; | ||
import org.eclipse.emf.edit.provider.ViewerNotification; | ||
import org.eclipse.sirius.components.view.ViewPackage; | ||
import org.eclipse.sirius.components.view.provider.ConditionalItemProvider; | ||
import org.eclipse.sirius.components.widgets.reference.ConditionalReferenceWidgetDescriptionStyle; | ||
import org.eclipse.sirius.components.widgets.reference.ReferencePackage; | ||
|
||
/** | ||
* This is the item provider adapter for a | ||
* {@link org.eclipse.sirius.components.widgets.reference.ConditionalReferenceWidgetDescriptionStyle} | ||
* object. <!-- begin-user-doc --> <!-- end-user-doc --> | ||
* | ||
* @generated | ||
*/ | ||
public class ConditionalReferenceWidgetDescriptionStyleItemProvider extends ConditionalItemProvider { | ||
|
||
/** | ||
* This constructs an instance from a factory and a notifier. <!-- | ||
* begin-user-doc --> <!-- end-user-doc --> | ||
* | ||
* @generated | ||
*/ | ||
public ConditionalReferenceWidgetDescriptionStyleItemProvider(AdapterFactory adapterFactory) { | ||
super(adapterFactory); | ||
} | ||
|
||
/** | ||
* This returns the property descriptors for the adapted class. <!-- | ||
* begin-user-doc --> <!-- end-user-doc --> | ||
* | ||
* @generated | ||
*/ | ||
@Override | ||
public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) { | ||
if (this.itemPropertyDescriptors == null) { | ||
super.getPropertyDescriptors(object); | ||
|
||
this.addFontSizePropertyDescriptor(object); | ||
this.addItalicPropertyDescriptor(object); | ||
this.addBoldPropertyDescriptor(object); | ||
this.addUnderlinePropertyDescriptor(object); | ||
this.addStrikeThroughPropertyDescriptor(object); | ||
this.addColorPropertyDescriptor(object); | ||
} | ||
return this.itemPropertyDescriptors; | ||
} | ||
|
||
/** | ||
* This adds a property descriptor for the Font Size feature. <!-- | ||
* begin-user-doc --> <!-- end-user-doc --> | ||
* | ||
* @generated | ||
*/ | ||
protected void addFontSizePropertyDescriptor(Object object) { | ||
this.itemPropertyDescriptors | ||
.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), | ||
this.getResourceLocator(), this.getString("_UI_LabelStyle_fontSize_feature"), | ||
this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_fontSize_feature", | ||
"_UI_LabelStyle_type"), | ||
ViewPackage.Literals.LABEL_STYLE__FONT_SIZE, true, false, false, | ||
ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, null, null)); | ||
} | ||
|
||
/** | ||
* This adds a property descriptor for the Italic feature. <!-- begin-user-doc | ||
* --> <!-- end-user-doc --> | ||
* | ||
* @generated | ||
*/ | ||
protected void addItalicPropertyDescriptor(Object object) { | ||
this.itemPropertyDescriptors | ||
.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), | ||
this.getResourceLocator(), this.getString("_UI_LabelStyle_italic_feature"), | ||
this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_italic_feature", | ||
"_UI_LabelStyle_type"), | ||
ViewPackage.Literals.LABEL_STYLE__ITALIC, true, false, false, | ||
ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); | ||
} | ||
|
||
/** | ||
* This adds a property descriptor for the Bold feature. <!-- begin-user-doc --> | ||
* <!-- end-user-doc --> | ||
* | ||
* @generated | ||
*/ | ||
protected void addBoldPropertyDescriptor(Object object) { | ||
this.itemPropertyDescriptors | ||
.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), | ||
this.getResourceLocator(), this.getString("_UI_LabelStyle_bold_feature"), | ||
this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_bold_feature", | ||
"_UI_LabelStyle_type"), | ||
ViewPackage.Literals.LABEL_STYLE__BOLD, true, false, false, | ||
ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); | ||
} | ||
|
||
/** | ||
* This adds a property descriptor for the Underline feature. <!-- | ||
* begin-user-doc --> <!-- end-user-doc --> | ||
* | ||
* @generated | ||
*/ | ||
protected void addUnderlinePropertyDescriptor(Object object) { | ||
this.itemPropertyDescriptors | ||
.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), | ||
this.getResourceLocator(), this.getString("_UI_LabelStyle_underline_feature"), | ||
this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_underline_feature", | ||
"_UI_LabelStyle_type"), | ||
ViewPackage.Literals.LABEL_STYLE__UNDERLINE, true, false, false, | ||
ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); | ||
} | ||
|
||
/** | ||
* This adds a property descriptor for the Strike Through feature. <!-- | ||
* begin-user-doc --> <!-- end-user-doc --> | ||
* | ||
* @generated | ||
*/ | ||
protected void addStrikeThroughPropertyDescriptor(Object object) { | ||
this.itemPropertyDescriptors | ||
.add(this.createItemPropertyDescriptor(((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), | ||
this.getResourceLocator(), this.getString("_UI_LabelStyle_strikeThrough_feature"), | ||
this.getString("_UI_PropertyDescriptor_description", "_UI_LabelStyle_strikeThrough_feature", | ||
"_UI_LabelStyle_type"), | ||
ViewPackage.Literals.LABEL_STYLE__STRIKE_THROUGH, true, false, false, | ||
ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE, null, null)); | ||
} | ||
|
||
/** | ||
* This adds a property descriptor for the Color feature. <!-- begin-user-doc | ||
* --> <!-- end-user-doc --> | ||
* | ||
* @generated | ||
*/ | ||
protected void addColorPropertyDescriptor(Object object) { | ||
this.itemPropertyDescriptors.add(this.createItemPropertyDescriptor( | ||
((ComposeableAdapterFactory) this.adapterFactory).getRootAdapterFactory(), this.getResourceLocator(), | ||
this.getString("_UI_ReferenceWidgetDescriptionStyle_color_feature"), | ||
this.getString("_UI_PropertyDescriptor_description", "_UI_ReferenceWidgetDescriptionStyle_color_feature", | ||
"_UI_ReferenceWidgetDescriptionStyle_type"), | ||
ReferencePackage.Literals.REFERENCE_WIDGET_DESCRIPTION_STYLE__COLOR, true, false, true, null, null, | ||
null)); | ||
} | ||
|
||
/** | ||
* This returns ConditionalReferenceWidgetDescriptionStyle.gif. <!-- | ||
* begin-user-doc --> <!-- end-user-doc --> | ||
* | ||
* @generated NOT | ||
*/ | ||
@Override | ||
public Object getImage(Object object) { | ||
return this.overlayImage(object, this.getResourceLocator().getImage("full/obj16/ConditionalStyle.svg")); | ||
} | ||
|
||
/** | ||
* <!-- begin-user-doc --> <!-- end-user-doc --> | ||
* | ||
* @generated | ||
*/ | ||
@Override | ||
protected boolean shouldComposeCreationImage() { | ||
return true; | ||
} | ||
|
||
/** | ||
* This returns the label text for the adapted class. <!-- begin-user-doc --> | ||
* <!-- end-user-doc --> | ||
* | ||
* @generated | ||
*/ | ||
@Override | ||
public String getText(Object object) { | ||
String label = ((ConditionalReferenceWidgetDescriptionStyle) object).getCondition(); | ||
return label == null || label.length() == 0 ? this.getString("_UI_ConditionalReferenceWidgetDescriptionStyle_type") | ||
: this.getString("_UI_ConditionalReferenceWidgetDescriptionStyle_type") + " " + label; | ||
} | ||
|
||
/** | ||
* This handles model notifications by calling {@link #updateChildren} to update | ||
* any cached children and by creating a viewer notification, which it passes to | ||
* {@link #fireNotifyChanged}. <!-- begin-user-doc --> <!-- end-user-doc --> | ||
* | ||
* @generated | ||
*/ | ||
@Override | ||
public void notifyChanged(Notification notification) { | ||
this.updateChildren(notification); | ||
|
||
switch (notification.getFeatureID(ConditionalReferenceWidgetDescriptionStyle.class)) { | ||
case ReferencePackage.CONDITIONAL_REFERENCE_WIDGET_DESCRIPTION_STYLE__FONT_SIZE: | ||
case ReferencePackage.CONDITIONAL_REFERENCE_WIDGET_DESCRIPTION_STYLE__ITALIC: | ||
case ReferencePackage.CONDITIONAL_REFERENCE_WIDGET_DESCRIPTION_STYLE__BOLD: | ||
case ReferencePackage.CONDITIONAL_REFERENCE_WIDGET_DESCRIPTION_STYLE__UNDERLINE: | ||
case ReferencePackage.CONDITIONAL_REFERENCE_WIDGET_DESCRIPTION_STYLE__STRIKE_THROUGH: | ||
this.fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); | ||
return; | ||
} | ||
super.notifyChanged(notification); | ||
} | ||
|
||
/** | ||
* This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing | ||
* the children that can be created under this object. <!-- begin-user-doc --> | ||
* <!-- end-user-doc --> | ||
* | ||
* @generated | ||
*/ | ||
@Override | ||
protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) { | ||
super.collectNewChildDescriptors(newChildDescriptors, object); | ||
} | ||
|
||
/** | ||
* Return the resource locator for this item provider's resources. <!-- | ||
* begin-user-doc --> <!-- end-user-doc --> | ||
* | ||
* @generated | ||
*/ | ||
@Override | ||
public ResourceLocator getResourceLocator() { | ||
return ReferenceEditPlugin.INSTANCE; | ||
} | ||
|
||
} |
Oops, something went wrong.