use of org.eclipse.sapphire.ValueProperty in project liferay-ide by liferay.
the class CreateSrcFileActionHandler method _getSrcFile.
private IFile _getSrcFile() {
IFile retval = null;
ValueProperty valueProperty = ValueProperty.class.cast(property().definition());
Value<Path> value = getModelElement().property(valueProperty);
if ((value != null) && !CoreUtil.isNullOrEmpty(value.text())) {
IPath defaultSrcFolderPath = _getDefaultSrcFolderPath();
if (defaultSrcFolderPath != null) {
IPath filePath = defaultSrcFolderPath.append(value.text());
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
retval = root.getFile(filePath);
}
}
return retval;
}
use of org.eclipse.sapphire.ValueProperty in project liferay-ide by liferay.
the class CreateSrcFileActionHandler method run.
@Override
public Object run(Presentation context) {
IFile file = _getSrcFile();
try {
if (!file.exists()) {
InputStream defaultContentStream = new ByteArrayInputStream(StringPool.EMPTY.getBytes());
file.create(defaultContentStream, true, null);
try {
file.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (Exception e) {
HookUI.logError(e);
}
ValueProperty valueProperty = ValueProperty.class.cast(property().definition());
// do this so that the downstream properties can update their
// enablement/validation/etc.
Value<Object> value = getModelElement().property(valueProperty);
Object content = value.content();
value.clear();
value.write(content);
refreshEnablementState();
}
} catch (Exception e) {
HookUI.logError("Unable to create src file: " + file.getName(), e);
}
return null;
}
use of org.eclipse.sapphire.ValueProperty in project liferay-ide by liferay.
the class CreateDirectoryActionHandler method init.
@Override
public void init(SapphireAction action, ActionHandlerDef def) {
super.init(action, def);
Element element = getModelElement();
ValueProperty property = (ValueProperty) property().definition();
Listener listener = new FilteredListener<PropertyEvent>() {
@Override
public void handleTypedEvent(PropertyEvent event) {
refreshEnablementState();
}
};
element.attach(listener, property.name());
attach(new Listener() {
@Override
public void handle(Event event) {
if (event instanceof DisposeEvent) {
element.detach(listener, property.name());
}
}
});
}
use of org.eclipse.sapphire.ValueProperty in project liferay-ide by liferay.
the class CustomJspValidationService method compute.
@Override
public Status compute() {
Value<?> value = (Value<?>) context(Element.class).property(context(Property.class).definition());
ValueProperty property = value.definition();
String label = property.getLabel(true, CapitalizationType.NO_CAPS, false);
if (_isValueEmpty(value)) {
String msg = NLS.bind(Msgs.nonEmptyValueRequired, label);
return Status.createErrorStatus(msg);
} else if (!_isValidPortalJsp(value) && !_isValidProjectJsp(value)) {
String msg = NLS.bind(Msgs.customJspInvalidPath, label);
return Status.createErrorStatus(msg);
}
return Status.createOkStatus();
}
use of org.eclipse.sapphire.ValueProperty in project liferay-ide by liferay.
the class AbstractResourceBundleActionHandler method computeEnablementState.
/**
* (non-Javadoc)
*
* @see org.eclipse.sapphire.ui.SapphirePropertyEditorActionHandler#
* computeEnablementState()
*/
@Override
protected boolean computeEnablementState() {
boolean enabled = super.computeEnablementState();
if (enabled) {
Element element = getModelElement();
Property property = property();
IProject project = element.adapt(IProject.class);
String rbFile = element.property((ValueProperty) property.definition()).text();
if (rbFile != null) {
String ioFileName = PortletUtil.convertJavaToIoFileName(rbFile, GenericResourceBundlePathService.RB_FILE_EXTENSION);
enabled = !getFileFromClasspath(project, ioFileName);
} else {
enabled = false;
}
}
return enabled;
}
Aggregations