use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class OpenPortletResourceAction method openPortletJavaClass.
/**
* @param file
*/
protected void openPortletJavaClass(IFile file) {
Element modelElement = ((PortletNode) selectedNode).getModel();
if (modelElement instanceof Portlet) {
Portlet portlet = (Portlet) modelElement;
JavaTypeName portletClassFile = portlet.getPortletClass().content();
Runnable run = new Runnable() {
public void run() {
IJavaProject project = JavaCore.create(file.getProject());
String fullyQualifiedName = portletClassFile.qualified();
try {
IType type = project.findType(fullyQualifiedName);
if ((type != null) && type.exists()) {
IResource resource = type.getResource();
if (resource instanceof IFile) {
IFile javaFile = (IFile) resource;
IEditorDescriptor editorDescriptor = findEditor(javaFile);
IEditorPart editorPart = null;
if (editorDescriptor != null) {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
try {
editorPart = page.findEditor(new FileEditorInput(javaFile));
if (editorPart == null) {
editorPart = page.openEditor(new FileEditorInput(javaFile), editorDescriptor.getId());
}
} catch (Exception e) {
MessageDialog.openError(page.getWorkbenchWindow().getShell(), Msgs.errorOpeningFile, e.getMessage());
}
}
}
}
} catch (JavaModelException jme) {
PortletUIPlugin.logError(jme);
}
}
};
Display.getDefault().asyncExec(run);
}
}
use of org.eclipse.sapphire.Element 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.Element 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.Element in project liferay-ide by liferay.
the class CreatePortletResourceBundleActionHandler 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();
listener = new FilteredListener<PropertyEvent>() {
@Override
protected void handleTypedEvent(PropertyEvent event) {
refreshEnablementState();
}
};
element.attach(listener, property().name());
element.attach(listener, Portlet.PROP_SUPPORTED_LOCALES.name());
element.attach(listener, Portlet.PROP_SUPPORTED_LOCALES.name() + "/" + SupportedLocales.PROP_SUPPORTED_LOCALE.name());
Listener listen = new Listener() {
public void handle(Event event) {
if (event instanceof DisposeEvent) {
getModelElement().detach(listener, property().name());
getModelElement().detach(listener, Portlet.PROP_SUPPORTED_LOCALES.name());
getModelElement().detach(listener, Portlet.PROP_SUPPORTED_LOCALES.name() + "/" + SupportedLocales.PROP_SUPPORTED_LOCALE.name());
}
}
};
attach(listen);
}
use of org.eclipse.sapphire.Element in project liferay-ide by liferay.
the class QNamesPossibleValuesService method compute.
/**
* (non-Javadoc)
*
* @see org.eclipse.sapphire.modeling.PossibleValuesService#fillPossibleValues(java.
* util.SortedSet)
*/
@Override
protected void compute(Set<String> values) {
Element Element = context(Element.class);
// values.add( param( "0" ) );
PortletApp portletApp = context(Element.class).nearest(PortletApp.class);
if (Element instanceof EventDefinitionRef) {
ElementList<EventDefinition> eventDefs = portletApp.getEventDefinitions();
for (EventDefinition eventDefinition : eventDefs) {
if ((eventDefinition.getNamespaceURI().content() != null) && (eventDefinition.getLocalPart().content() != null)) {
values.add(getQName(eventDefinition.getNamespaceURI().content(false), eventDefinition.getLocalPart().content()));
}
}
} else if (Element instanceof SupportedPublicRenderParameter) {
ElementList<PublicRenderParameter> publicRenderParameters = portletApp.getPublicRenderParameters();
for (PublicRenderParameter publicRenderParam : publicRenderParameters) {
if ((publicRenderParam.getNamespaceURI().content() != null) && (publicRenderParam.getLocalPart().content() != null)) {
values.add(getQName(publicRenderParam.getNamespaceURI().content(false), publicRenderParam.getLocalPart().content()));
}
}
}
}
Aggregations