use of com.liferay.ide.core.IWebProject in project liferay-ide by liferay.
the class NewPortletWizard method openJavaClass.
@Override
protected void openJavaClass() {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject project = workspace.getRoot().getProject(getDataModel().getStringProperty(PROJECT_NAME));
if (getDataModel().getBooleanProperty(USE_DEFAULT_PORTLET_CLASS)) {
try {
String jspsFolder = getDataModel().getStringProperty(CREATE_JSPS_FOLDER);
// IDE-110 IDE-648
IWebProject webproject = LiferayCore.create(IWebProject.class, project);
if ((webproject != null) && (webproject.getDefaultDocrootFolder() != null)) {
IFolder defaultDocroot = webproject.getDefaultDocrootFolder();
IFile viewFile = defaultDocroot.getFile(new Path(jspsFolder + "/view.jsp"));
if (viewFile.exists()) {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
IDE.openEditor(page, viewFile, true);
return;
}
}
} catch (Exception e) {
// eat this exception this is just best effort
}
} else {
Map<String, String> settings = new Hashtable<>();
settings.put(CleanUpConstants.ORGANIZE_IMPORTS, CleanUpOptions.TRUE);
ImportsCleanUp importsCleanUp = new ImportsCleanUp(settings);
ICleanUp[] cleanUps = { importsCleanUp };
IJavaProject javaProject = JavaCore.create(project);
try {
IType type = javaProject.findType(getDataModel().getStringProperty(INewJavaClassDataModelProperties.QUALIFIED_CLASS_NAME));
ICompilationUnit cu = (ICompilationUnit) type.getParent();
ICompilationUnit[] units = { cu };
RefactoringExecutionStarter.startCleanupRefactoring(units, cleanUps, false, getShell(), false, "organize imports");
} catch (Exception e) {
}
super.openJavaClass();
}
}
use of com.liferay.ide.core.IWebProject in project liferay-ide by liferay.
the class PluginClasspathContainer method createContextClasspathEntry.
protected IClasspathEntry createContextClasspathEntry(String context) {
IClasspathEntry entry = null;
IFile serviceJar = ComponentUtil.findServiceJarForContext(context);
if (serviceJar.exists()) {
IWebProject webproject = LiferayCore.create(IWebProject.class, serviceJar.getProject());
if ((webproject != null) && (webproject.getDefaultDocrootFolder() != null)) {
IFolder defaultDocroot = webproject.getDefaultDocrootFolder();
IFolder serviceFolder = defaultDocroot.getFolder(new Path("WEB-INF/service"));
if (serviceFolder.exists()) {
entry = createClasspathEntry(serviceJar.getLocation(), serviceFolder.getLocation());
}
}
if (entry == null) {
entry = createClasspathEntry(serviceJar.getLocation(), null);
}
}
if (entry == null) {
IProject project = this.javaProject.getProject();
SDK sdk = SDKUtil.getSDK(project);
IPath sdkLocation = sdk.getLocation();
String type = StringPool.EMPTY;
if (ProjectUtil.isPortletProject(project)) {
type = "portlets";
} else if (ProjectUtil.isHookProject(project)) {
type = "hooks";
} else if (ProjectUtil.isExtProject(project)) {
type = "ext";
}
IPath contextPath = sdkLocation.append(type).append(context);
String libFolder = ISDKConstants.DEFAULT_DOCROOT_FOLDER + "/WEB-INF/lib";
IPath serviceJarPath = contextPath.append(libFolder).append(context + "-service.jar");
if (serviceJarPath.toFile().exists()) {
IPath servicePath = serviceJarPath.removeLastSegments(2).append("service");
entry = createClasspathEntry(serviceJarPath, servicePath.toFile().exists() ? servicePath : null);
}
}
return entry;
}
use of com.liferay.ide.core.IWebProject in project liferay-ide by liferay.
the class PluginPackageResourceListener method shouldProcessResourceDelta.
protected boolean shouldProcessResourceDelta(IResourceDelta delta) {
IPath fullPath = delta.getFullPath();
if ((fullPath.lastSegment() == null) || !fullPath.lastSegment().equals(ILiferayConstants.LIFERAY_PLUGIN_PACKAGE_PROPERTIES_FILE)) {
return false;
}
IProject project = CoreUtil.getLiferayProject(delta.getResource());
IWebProject lrproject = LiferayCore.create(IWebProject.class, project);
if (lrproject == null) {
return false;
}
Path path = new Path("WEB-INF/" + ILiferayConstants.LIFERAY_PLUGIN_PACKAGE_PROPERTIES_FILE);
IResource propertiesFile = lrproject.findDocrootResource(path);
if (FileUtil.notExists(propertiesFile)) {
return false;
}
IPath filePath = propertiesFile.getFullPath();
return filePath.equals(fullPath);
}
use of com.liferay.ide.core.IWebProject in project liferay-ide by liferay.
the class NewJSFPortletWizard method openJavaClass.
@Override
protected void openJavaClass() {
if (getDataModel().getBooleanProperty(CREATE_JSPS)) {
try {
String jspsFolder = getDataModel().getStringProperty(CREATE_JSPS_FOLDER);
String projectName = getDataModel().getStringProperty(PROJECT_NAME);
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject project = workspace.getRoot().getProject(projectName);
// IDE-110 IDE-648
IWebProject webproject = LiferayCore.create(IWebProject.class, project);
if ((webproject != null) && (webproject.getDefaultDocrootFolder() != null)) {
IFolder defaultDocroot = webproject.getDefaultDocrootFolder();
Path path = new Path(jspsFolder + "/view.xhtml");
IFile viewFile = defaultDocroot.getFile(path);
if (viewFile.exists()) {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
IDE.openEditor(page, viewFile, true);
return;
}
}
} catch (Exception e) {
// best effort
}
}
}
use of com.liferay.ide.core.IWebProject in project liferay-ide by liferay.
the class RemoteJSPBreakpointProvider method addBreakpoint.
@Override
public IStatus addBreakpoint(IDocument document, IEditorInput input, int editorLineNumber, int offset) throws CoreException {
// check if there is a valid position to set breakpoint
int pos = getValidPosition(document, editorLineNumber);
IStatus status = null;
if (pos >= 0) {
IResource res = getResourceFromInput(input);
if (res != null) {
String path = null;
// IDE-648 IDE-110
// get docroot relative path
final IWebProject lrproject = LiferayCore.create(IWebProject.class, res.getProject());
if (lrproject != null) {
final IFolder webappRoot = lrproject.getDefaultDocrootFolder();
if (webappRoot != null && webappRoot.exists()) {
IPath relativePath = res.getFullPath().makeRelativeTo(webappRoot.getFullPath());
if (relativePath != null && relativePath.segmentCount() > 0) {
// $NON-NLS-1$
path = "/" + relativePath.toPortableString();
}
}
IBreakpoint point = JDIDebugModel.createStratumBreakpoint(res, "JSP", res.getName(), path, getClassPattern(res), editorLineNumber, pos, pos, 0, true, null);
if (point == null) {
status = new Status(IStatus.ERROR, JSPUIPlugin.ID, IStatus.ERROR, "unsupported input type", null);
}
}
} else if (input instanceof IStorageEditorInput) {
// For non-resources, use the workspace root and a coordinated
// attribute that is used to
// prevent unwanted (breakpoint) markers from being loaded
// into the editors.
res = ResourcesPlugin.getWorkspace().getRoot();
String id = input.getName();
if (input instanceof IStorageEditorInput && ((IStorageEditorInput) input).getStorage() != null && ((IStorageEditorInput) input).getStorage().getFullPath() != null) {
id = ((IStorageEditorInput) input).getStorage().getFullPath().toString();
}
Map attributes = new HashMap();
attributes.put(StructuredResourceMarkerAnnotationModel.SECONDARY_ID_KEY, id);
String path = null;
IBreakpoint point = JDIDebugModel.createStratumBreakpoint(res, "JSP", input.getName(), path, getClassPattern(res), editorLineNumber, pos, pos, 0, true, // $NON-NLS-1$
attributes);
if (point == null) {
// $NON-NLS-1$
status = new Status(IStatus.ERROR, JSPUIPlugin.ID, IStatus.ERROR, "unsupported input type", null);
}
}
} else {
status = new Status(IStatus.INFO, JSPUIPlugin.ID, IStatus.INFO, JSPUIMessages.BreakpointNotAllowed, null);
}
if (status == null) {
status = new Status(IStatus.OK, JSPUIPlugin.ID, IStatus.OK, JSPUIMessages.OK, null);
}
return status;
}
Aggregations