Search in sources :

Example 1 with CustomProjectSelectionDialog

use of com.liferay.ide.project.ui.dialog.CustomProjectSelectionDialog in project liferay-ide by liferay.

the class CustomJspPage method _runConvertAction.

private void _runConvertAction() {
    CustomProjectSelectionDialog dialog = new CustomProjectSelectionDialog(UIUtil.getActiveShell());
    dialog.setProjects(_getHookProjects());
    URL imageUrl = bundle.getEntry("/icons/e16/hook.png");
    Image hookImage = ImageDescriptor.createFromURL(imageUrl).createImage();
    dialog.setImage(hookImage);
    dialog.setTitle("Custom JSP Hook Project");
    dialog.setMessage("Select Custom JSP Hook Project");
    List<IProject> hookProjects = new ArrayList<>();
    if (dialog.open() == Window.OK) {
        final Object[] selectedProjects = dialog.getResult();
        if (selectedProjects != null) {
            for (Object project : selectedProjects) {
                if (project instanceof IJavaProject) {
                    IJavaProject p = (IJavaProject) project;
                    hookProjects.add(p.getProject());
                }
            }
        }
    }
    int size = hookProjects.size();
    if (size < 1) {
        return;
    }
    String[] sourcePaths = new String[size];
    String[] projectNames = new String[size];
    for (int i = 0; i < size; i++) {
        IProject hookProject = hookProjects.get(i);
        sourcePaths[i] = hookProject.getLocation().toOSString();
        projectNames[i] = hookProject.getName();
    }
    CustomJspConverter converter = new CustomJspConverter();
    IRuntime liferay70Runtime = _getLiferay70Runtime();
    if (liferay70Runtime == null) {
        MessageDialog.openError(Display.getDefault().getActiveShell(), "Convert Error", "Couldn't find Liferay 7.x Runtime.");
        return;
    }
    String liferay62ServerLocation = _getLiferay62ServerLocation();
    if (liferay62ServerLocation == null) {
        MessageDialog.openError(Display.getDefault().getActiveShell(), "Convert Error", "Couldn't find Liferay 6.2 Runtime.");
        return;
    }
    converter.setLiferay70Runtime(liferay70Runtime);
    converter.setLiferay62ServerLocation(liferay62ServerLocation);
    converter.setUi(this);
    Value<Path> convertedProjectLocation = dataModel.getConvertedProjectLocation();
    String targetPath = convertedProjectLocation.content().toPortableString();
    boolean liferayWorkapce = false;
    if (targetPath.equals(_defaultLocation) && _hasLiferayWorkspace) {
        liferayWorkapce = true;
    }
    converter.doExecute(sourcePaths, projectNames, targetPath, liferayWorkapce);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) ArrayList(java.util.ArrayList) StyledString(org.eclipse.jface.viewers.StyledString) Image(org.eclipse.swt.graphics.Image) CustomProjectSelectionDialog(com.liferay.ide.project.ui.dialog.CustomProjectSelectionDialog) URL(java.net.URL) IProject(org.eclipse.core.resources.IProject) IRuntime(org.eclipse.wst.server.core.IRuntime) IJavaProject(org.eclipse.jdt.core.IJavaProject)

Aggregations

CustomProjectSelectionDialog (com.liferay.ide.project.ui.dialog.CustomProjectSelectionDialog)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 IProject (org.eclipse.core.resources.IProject)1 IPath (org.eclipse.core.runtime.IPath)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 StyledString (org.eclipse.jface.viewers.StyledString)1 Path (org.eclipse.sapphire.modeling.Path)1 Image (org.eclipse.swt.graphics.Image)1 IRuntime (org.eclipse.wst.server.core.IRuntime)1