use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class LayoutTplEditor method refreshDiagramModel.
protected void refreshDiagramModel() {
LayoutTplElement newElement = LayoutTplElementsFactory.INSTANCE.newLayoutTplFromFile(getFile(), _bootstrapStyle, _is62);
if (newElement == null) {
/*
* create an empty model for diagram in memory, but not write to
* source
*/
newElement = createEmptyDiagramModel();
}
Element model = getModelElement();
model.clear();
model.copy(newElement);
}
use of org.eclipse.sapphire.Element 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;
}
use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class WindowStateImageService method compute.
@Override
protected ImageData compute() {
String strWindowState = null;
Element element = context(Element.class);
ImageData imageData = null;
if (element instanceof CustomWindowState) {
CustomWindowState customWindowState = (CustomWindowState) element;
strWindowState = String.valueOf(customWindowState.getWindowState().content());
} else if (element instanceof WindowState) {
WindowState windowState = (WindowState) element;
strWindowState = windowState.getWindowState().content();
}
if ("MAXIMIZED".equalsIgnoreCase(strWindowState)) {
imageData = IMG_MAXIMIZED;
} else if ("MINIMIZED".equalsIgnoreCase(strWindowState)) {
imageData = IMG_MINIMIZED;
}
if (imageData == null) {
imageData = IMG_DEFAULT;
}
return imageData;
}
use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class LocaleBundleValidationService method compute.
public Status compute() {
Element modelElement = context(Element.class);
if (!modelElement.disposed() && modelElement instanceof SupportedLocales) {
IProject project = modelElement.adapt(IProject.class);
Portlet portlet = modelElement.nearest(Portlet.class);
IWorkspaceRoot wroot = ResourcesPlugin.getWorkspace().getRoot();
IClasspathEntry[] cpEntries = CoreUtil.getClasspathEntries(project);
if (cpEntries != null) {
String locale = modelElement.property(context(ValueProperty.class)).text(false);
Value<Path> resourceBundle = portlet.getResourceBundle();
if (locale == null) {
return Status.createErrorStatus(Resources.localeMustNotEmpty);
} else {
String bundleName = resourceBundle.text();
if ((resourceBundle != null) && (bundleName != null)) {
String localeString = PortletUtil.localeString(locale);
String ioFileName = PortletUtil.convertJavaToIoFileName(bundleName, RB_FILE_EXTENSION, localeString);
for (IClasspathEntry iClasspathEntry : cpEntries) {
if (IClasspathEntry.CPE_SOURCE == iClasspathEntry.getEntryKind()) {
IPath entryPath = wroot.getFolder(iClasspathEntry.getPath()).getLocation();
entryPath = entryPath.append(ioFileName);
IFile resourceBundleFile = wroot.getFileForLocation(entryPath);
if ((resourceBundleFile != null) && resourceBundleFile.exists()) {
return Status.createOkStatus();
} else {
return Status.createWarningStatus(Resources.bind(StringEscapeUtils.unescapeJava(Resources.noResourceBundle), new Object[] { locale, bundleName, localeString }));
}
}
}
}
}
}
}
return Status.createOkStatus();
}
use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class NameOrQnameValidationService method compute.
@Override
public Status compute() {
Element element = context(Element.class);
String elementLabel = element.type().getLabel(false, CapitalizationType.FIRST_WORD_ONLY, false);
QName iqName = null;
String name = null;
String nsURI = null;
String localPart = null;
if (element instanceof QName) {
iqName = (QName) element;
nsURI = iqName.getNamespaceURI().text(false);
localPart = iqName.getLocalPart().text(false);
}
if (isEmptyOrNull(name) && isEmptyOrNull(nsURI) && isEmptyOrNull(localPart)) {
return Status.createErrorStatus(Resources.bind(Resources.message, elementLabel));
} else if (isEmptyOrNull(name) && (isEmptyOrNull(nsURI) || isEmptyOrNull(localPart))) {
return Status.createErrorStatus(Resources.bind(Resources.invalidQname, elementLabel));
}
return Status.createOkStatus();
}
Aggregations