Search in sources :

Example 1 with ExternalFileSelectionDialog

use of com.liferay.ide.ui.wizard.ExternalFileSelectionDialog in project liferay-ide by liferay.

the class CustomJSPsTableWizardSection method handleAddFromPortalButtonSelected.

protected void handleAddFromPortalButtonSelected() {
    if (FileUtil.notExists(portalDir)) {
        MessageDialog.openWarning(getShell(), Msgs.addJSP, Msgs.couldNotFindPortalRoot);
        return;
    }
    IPath rootPath = new Path(portalDir.getPath());
    JSPFileViewerFilter filter = new JSPFileViewerFilter(portalDir, new String[] { "html" });
    ExternalFileSelectionDialog dialog = new ExternalFileSelectionDialog(getShell(), filter, true, false);
    dialog.setTitle(Msgs.liferayCustomJSP);
    dialog.setMessage(Msgs.selectJSPToCustomize);
    dialog.setInput(portalDir);
    if (dialog.open() == Window.OK) {
        Object[] selected = dialog.getResult();
        for (int i = 0; i < selected.length; i++) {
            IPath filePath = Path.fromOSString(((File) selected[i]).getPath());
            addStringArray(new String[] { "/" + filePath.makeRelativeTo(rootPath).toPortableString() });
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) ExternalFileSelectionDialog(com.liferay.ide.ui.wizard.ExternalFileSelectionDialog) IPath(org.eclipse.core.runtime.IPath)

Example 2 with ExternalFileSelectionDialog

use of com.liferay.ide.ui.wizard.ExternalFileSelectionDialog in project liferay-ide by liferay.

the class PortalDeployExcludesSection method _handleAdd.

private void _handleAdd() {
    PluginPackageModel model = (PluginPackageModel) getPage().getModel();
    String[] excludeJars = model.getPortalDeloyExcludesJars();
    IProject project = getProject();
    IFolder docroot = CoreUtil.getDefaultDocrootFolder(project);
    SDK sdk = SDKUtil.getSDK(project);
    IPath sdkLocation = sdk.getLocation();
    String type;
    if (ProjectUtil.isPortletProject(project)) {
        type = "portlets";
    } else if (ProjectUtil.isHookProject(project)) {
        type = "hooks";
    } else if (ProjectUtil.isWebProject(project)) {
        type = "webs";
    } else {
        type = StringPool.EMPTY;
    }
    IPath serviceJarPath = sdkLocation.append(type).append(docroot.getFullPath());
    if (serviceJarPath != null) {
        Shell shell = getPage().getShell();
        PortalJarViewerFilter filter = new PortalJarViewerFilter(serviceJarPath.toFile(), new String[] { "WEB-INF", "WEB-INF/lib" }, excludeJars);
        ExternalFileSelectionDialog dialog = new ExternalFileSelectionDialog(shell, filter, true, false);
        dialog.setInput(serviceJarPath.toFile());
        dialog.create();
        if (dialog.open() == Window.OK) {
            Object[] selectedFiles = dialog.getResult();
            try {
                for (int i = 0; i < selectedFiles.length; i++) {
                    File jar = (File) selectedFiles[i];
                    if (jar.exists()) {
                        model.addPortalDeployExcludeJar(jar.getName());
                    }
                }
            } catch (Exception e) {
            }
        }
    } else {
        MessageDialog.openInformation(getPage().getShell(), Msgs.liferayPluginPackageEditor, Msgs.notDeterminePortalDirectory);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) IProject(org.eclipse.core.resources.IProject) ExternalFileSelectionDialog(com.liferay.ide.ui.wizard.ExternalFileSelectionDialog) Shell(org.eclipse.swt.widgets.Shell) PluginPackageModel(com.liferay.ide.portlet.core.PluginPackageModel) IPluginPackageModel(com.liferay.ide.portlet.core.IPluginPackageModel) SDK(com.liferay.ide.sdk.core.SDK) File(java.io.File) IFolder(org.eclipse.core.resources.IFolder)

Example 3 with ExternalFileSelectionDialog

use of com.liferay.ide.ui.wizard.ExternalFileSelectionDialog in project liferay-ide by liferay.

the class PortalJarsSection method _handleAdd.

private void _handleAdd() {
    PluginPackageModel model = (PluginPackageModel) getPage().getModel();
    String[] existingJars = model.getPortalDependencyJars();
    PluginPackageEditor editor = (PluginPackageEditor) getPage().getEditor();
    IPath portalDir = editor.getPortalDir();
    if (portalDir != null) {
        PortalJarViewerFilter filter = new PortalJarViewerFilter(portalDir.toFile(), new String[] { "WEB-INF", "WEB-INF/lib" }, existingJars);
        ExternalFileSelectionDialog dialog = new ExternalFileSelectionDialog(getPage().getShell(), filter, true, false);
        dialog.setInput(portalDir.toFile());
        dialog.create();
        if (dialog.open() == Window.OK) {
            Object[] selectedFiles = dialog.getResult();
            try {
                for (int i = 0; i < selectedFiles.length; i++) {
                    File jar = (File) selectedFiles[i];
                    if (jar.exists()) {
                        model.addPortalDependencyJar(jar.getName());
                    }
                }
            } catch (Exception e) {
            }
        }
    } else {
        MessageDialog.openInformation(getPage().getShell(), Msgs.liferayPluginPackageEditor, Msgs.notDeterminePortalDirectory);
    }
}
Also used : ExternalFileSelectionDialog(com.liferay.ide.ui.wizard.ExternalFileSelectionDialog) IPath(org.eclipse.core.runtime.IPath) IPluginPackageModel(com.liferay.ide.portlet.core.IPluginPackageModel) PluginPackageModel(com.liferay.ide.portlet.core.PluginPackageModel) File(java.io.File)

Example 4 with ExternalFileSelectionDialog

use of com.liferay.ide.ui.wizard.ExternalFileSelectionDialog in project liferay-ide by liferay.

the class PortalTldsSection method _handleAdd.

private void _handleAdd() {
    PluginPackageModel model = (PluginPackageModel) getPage().getModel();
    String[] existingTlds = model.getPortalDependencyTlds();
    PluginPackageEditor editor = (PluginPackageEditor) getPage().getEditor();
    IPath portalDir = editor.getPortalDir();
    if (portalDir != null) {
        Shell shell = getPage().getShell();
        PortalTldViewerFilter filter = new PortalTldViewerFilter(portalDir.toFile(), new String[] { "WEB-INF", "WEB-INF/tld" }, existingTlds);
        ExternalFileSelectionDialog dialog = new ExternalFileSelectionDialog(shell, filter, true, false);
        dialog.setInput(portalDir.toFile());
        dialog.create();
        if (dialog.open() == Window.OK) {
            Object[] selectedFiles = dialog.getResult();
            try {
                for (int i = 0; i < selectedFiles.length; i++) {
                    File tld = (File) selectedFiles[i];
                    if (tld.exists()) {
                        model.addPortalDependencyTld(tld.getName());
                    }
                }
            } catch (Exception e) {
            }
        }
    } else {
        MessageDialog.openInformation(getPage().getShell(), Msgs.liferayPluginPackageEditor, Msgs.notDeterminePortalDirectory);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) ExternalFileSelectionDialog(com.liferay.ide.ui.wizard.ExternalFileSelectionDialog) Shell(org.eclipse.swt.widgets.Shell) PluginPackageModel(com.liferay.ide.portlet.core.PluginPackageModel) IPluginPackageModel(com.liferay.ide.portlet.core.IPluginPackageModel) File(java.io.File)

Aggregations

ExternalFileSelectionDialog (com.liferay.ide.ui.wizard.ExternalFileSelectionDialog)4 IPath (org.eclipse.core.runtime.IPath)4 IPluginPackageModel (com.liferay.ide.portlet.core.IPluginPackageModel)3 PluginPackageModel (com.liferay.ide.portlet.core.PluginPackageModel)3 File (java.io.File)3 Shell (org.eclipse.swt.widgets.Shell)2 SDK (com.liferay.ide.sdk.core.SDK)1 IFolder (org.eclipse.core.resources.IFolder)1 IProject (org.eclipse.core.resources.IProject)1 Path (org.eclipse.core.runtime.Path)1