use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.
the class NewCustomJSPsHookWizardPage method createCustomJSPsGroup.
protected void createCustomJSPsGroup(Composite parent) {
Composite composite = SWTUtil.createTopComposite(parent, 2);
composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
jspItemsSection = new CustomJSPsTableWizardSection(composite, Msgs.jspFilesOverride, Msgs.jspFilePath, Msgs.add, Msgs.edit, Msgs.remove, new String[] { Msgs.add }, new String[] { Msgs.jspFilePath }, null, getDataModel(), CUSTOM_JSPS_ITEMS);
GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1);
gd.heightHint = 175;
jspItemsSection.setLayoutData(gd);
jspItemsSection.setCallback(new StringArrayTableWizardSectionCallback());
IProject project = CoreUtil.getProject(getDataModel().getStringProperty(PROJECT_NAME));
ILiferayProject liferayProject = LiferayCore.create(project);
if (liferayProject != null) {
ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
if (portal != null) {
IPath portalDir = portal.getAppServerPortalDir();
if (FileUtil.exists(portalDir)) {
jspItemsSection.setPortalDir(portalDir.toFile());
}
}
}
}
use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.
the class StrutsActionPathPossibleValuesService method initPossibleValuesService.
@Override
protected void initPossibleValuesService() {
super.initPossibleValuesService();
ILiferayProject liferayProject = LiferayCore.create(project());
if (liferayProject != null) {
ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
if (portal != null) {
_portalDir = portal.getAppServerPortalDir();
}
}
}
use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.
the class AddHookOperation method createCustomJSPs.
protected IStatus createCustomJSPs(IDataModel dm) {
IProject project = getTargetProject();
IFolder defaultWebappRootFolder = LiferayCore.create(IWebProject.class, project).getDefaultDocrootFolder();
String customJSPsFolder = dm.getStringProperty(CUSTOM_JSPS_FOLDER);
IPath fullPath = defaultWebappRootFolder.getFullPath();
String customFolderValue = fullPath.append(customJSPsFolder).toPortableString();
IWorkspaceRoot root = project.getWorkspace().getRoot();
IFolder customFolder = root.getFolder(new Path(customFolderValue));
try {
CoreUtil.prepareFolder(customFolder);
} catch (CoreException ce) {
return HookCore.createErrorStatus(ce);
}
List<String[]> customJsps = (List<String[]>) dm.getProperty(CUSTOM_JSPS_ITEMS);
ILiferayProject liferayProject = LiferayCore.create(getTargetProject());
ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
IStatus status = null;
if (portal != null) {
IPath portalDir = portal.getAppServerPortalDir();
if ((customJsps != null) && (portalDir != null)) {
for (String[] customJsp : customJsps) {
try {
IFile copiedFile = copyPortalJSPToProject(portalDir, customJsp[0], customFolder);
if (copiedFile != null) {
Set<IFile> jspFilesCreated = (Set<IFile>) dm.getProperty(CUSTOM_JSPS_FILES_CREATED);
jspFilesCreated.add(copiedFile);
dm.setProperty(CUSTOM_JSPS_FILES_CREATED, jspFilesCreated);
}
} catch (Exception e) {
HookCore.logError(e);
}
}
}
HookDescriptorHelper hookDescHelper = new HookDescriptorHelper(getTargetProject());
status = hookDescHelper.setCustomJSPDir(model);
if (model.getBooleanProperty(DISABLE_CUSTOM_JSP_FOLDER_VALIDATION)) {
HookUtil.configureJSPSyntaxValidationExclude(getTargetProject(), customFolder, true);
}
} else {
status = HookCore.createErrorStatus("Could not get portal info from project " + project.getName());
}
return status;
}
use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.
the class HookXmlEditor method doSave.
@Override
public void doSave(IProgressMonitor monitor) {
if (customModelDirty) {
Hook hook = getModelElement().nearest(Hook.class);
ElementList<CustomJsp> customJsps = hook.getCustomJsps();
ILiferayProject liferayProject = LiferayCore.create(getProject());
ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
if (portal != null) {
IPath portalDir = portal.getAppServerPortalDir();
if (portalDir != null) {
_copyCustomJspsToProject(portalDir, customJsps);
}
}
customModelDirty = false;
super.doSave(monitor);
firePropertyChange(IEditorPart.PROP_DIRTY);
ElementHandle<CustomJspDir> customJspDir = hook.getCustomJspDir();
if ((customJspDir != null) && !customJspDir.empty()) {
Value<Path> customJspPath = customJspDir.content().getValue();
Path path = customJspPath.content().makeRelative();
String customeJspValue = path.toPortableString();
_configureCustomJspValidation(getProject(), customeJspValue);
}
} else {
super.doSave(monitor);
}
}
use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.
the class CustomJspValidationService method _getPortalDir.
private IPath _getPortalDir() {
if (_portalDir == null) {
try {
Element element = context().find(Element.class);
IFile file = element.nearest(Hook.class).adapt(IFile.class);
IProject project = file.getProject();
ILiferayProject liferayProject = LiferayCore.create(project);
if (liferayProject != null) {
ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
if (portal != null) {
_portalDir = portal.getAppServerPortalDir();
}
}
} catch (Exception e) {
HookCore.logError(e);
}
}
return _portalDir;
}
Aggregations