use of org.eclipse.sapphire.Property in project liferay-ide by liferay.
the class ServiceImplJavaTypeConstraintService method initJavaTypeConstraintService.
@Override
protected void initJavaTypeConstraintService() {
super.initJavaTypeConstraintService();
Property property = context().find(Property.class);
JavaTypeConstraint javaTypeConstraintAnnotation = property.definition().getAnnotation(JavaTypeConstraint.class);
Set<JavaTypeKind> kind = EnumSet.noneOf(JavaTypeKind.class);
for (JavaTypeKind k : javaTypeConstraintAnnotation.kind()) {
kind.add(k);
}
_kinds = kind;
_behavior = javaTypeConstraintAnnotation.behavior();
_service = context(ServiceWrapper.class);
Listener listener = new FilteredListener<PropertyContentEvent>() {
@Override
public void handleTypedEvent(PropertyContentEvent event) {
refresh();
}
};
_service.attach(listener, "ServiceType");
}
use of org.eclipse.sapphire.Property in project liferay-ide by liferay.
the class PortletColumnsListener method handleTypedEvent.
@Override
protected void handleTypedEvent(PropertyContentEvent event) {
Property property = event.property();
Element element = property.element();
LayoutTplElement layouttpl = element.nearest(LayoutTplElement.class);
updateColumns(layouttpl, 1);
}
use of org.eclipse.sapphire.Property in project liferay-ide by liferay.
the class CreatePortletAppResourceBundleActionHandler method run.
/**
* (non-Javadoc)
*
* @see
* org.eclipse.sapphire.ui.SapphireActionHandler#run(org.eclipse.sapphire.ui.
* SapphireRenderingContext)
*/
@Override
protected Object run(Presentation context) {
Element element = getModelElement();
IProject project = element.adapt(IProject.class);
Property property = property();
Value<Path> resourceBundle = element.property((ValueProperty) property.definition());
String resourceBundleText = resourceBundle.text();
int index = resourceBundleText.lastIndexOf(".");
if (index == -1) {
index = resourceBundleText.length();
}
String packageName = resourceBundleText.substring(0, index);
String defaultRBFileName = PortletUtil.convertJavaToIoFileName(resourceBundleText, GenericResourceBundlePathService.RB_FILE_EXTENSION);
IFolder rbSourecFolder = getResourceBundleFolderLocation(project, defaultRBFileName);
IPath entryPath = rbSourecFolder.getLocation();
if (getModelElement() instanceof PortletApp) {
List<IFile> missingRBFiles = new ArrayList<>();
StringBuilder rbFileBuffer = new StringBuilder("#Portlet Application Resource Bundle \n");
IFile rbFile = wroot.getFileForLocation(entryPath.append(defaultRBFileName));
missingRBFiles.add(rbFile);
createFiles(context, project, packageName, missingRBFiles, rbFileBuffer);
setEnabled(false);
Property modelElement = getModelElement().property(property().definition());
modelElement.refresh();
}
return null;
}
use of org.eclipse.sapphire.Property in project liferay-ide by liferay.
the class CreatePortletAppResourceBundleActionHandler method init.
/**
* (non-Javadoc)
*
* @see
* org.eclipse.sapphire.ui.SapphirePropertyEditorActionHandler#init(org.eclipse.
* sapphire.ui.SapphireAction, ActionHandlerDef)
*/
@Override
public void init(SapphireAction action, ActionHandlerDef def) {
super.init(action, def);
Element element = getModelElement();
Property property = property();
listener = new FilteredListener<PropertyEvent>() {
@Override
protected void handleTypedEvent(PropertyEvent event) {
refreshEnablementState();
}
};
element.attach(listener, property.definition().name());
Listener listen = new Listener() {
@Override
public void handle(Event event) {
if (event instanceof DisposeEvent) {
PropertyDef definition = property().definition();
getModelElement().detach(listener, definition.name());
}
}
};
attach(listen);
}
use of org.eclipse.sapphire.Property in project liferay-ide by liferay.
the class PossibleValuesRadioButtonsGroupBinding method initialize.
@Override
@SuppressWarnings("unchecked")
protected void initialize(PropertyEditorPresentation propertyEditorPresentation, Control control) {
super.initialize(propertyEditorPresentation, control);
final PossibleValuesService possibleValuesService = propertyEditorPresentation.property().service(PossibleValuesService.class);
_possibleValues = new ArrayList<>(possibleValuesService.values());
_buttonsGroup = (RadioButtonsGroup) control;
final Property property = propertyEditorPresentation.property();
String auxTextProviderName = propertyEditorPresentation.part().getRenderingHint("possible.values.aux.text.provider", (String) null);
PossibleValuesAuxTextProvider auxTextProvider = null;
if (auxTextProviderName != null) {
try {
Bundle bundle = ProjectUI.getDefault().getBundle();
Class<PossibleValuesAuxTextProvider> providerClass = (Class<PossibleValuesAuxTextProvider>) bundle.loadClass(auxTextProviderName);
auxTextProvider = providerClass.newInstance();
} catch (Exception e) {
}
}
for (String possibleValue : _possibleValues) {
final ValueLabelService labelService = property.service(ValueLabelService.class);
final String possibleValueText = labelService.provide(possibleValue);
String auxText = propertyEditorPresentation.part().getRenderingHint(PropertyEditorDef.HINT_AUX_TEXT + "." + possibleValue, null);
if ((auxText == null) && (auxTextProvider != null)) {
auxText = auxTextProvider.getAuxText(element(), property.definition(), possibleValue);
}
ValueImageService imageService = property.service(ValueImageService.class);
ImageData imageData = imageService.provide(possibleValue);
SwtResourceCache resources = presentation().resources();
Image image = resources.image(imageData);
final Button button = this._buttonsGroup.addRadioButton(possibleValueText, auxText, image);
button.setData(possibleValue);
}
_buttonsGroup.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
updateModel();
updateTargetAttributes();
}
});
}
Aggregations