Search in sources :

Example 6 with BinaryProjectRecord

use of com.liferay.ide.project.core.BinaryProjectRecord in project liferay-ide by liferay.

the class BinaryProjectsImportWizardPage method getProjectRecords.

@Override
public Object[] getProjectRecords() {
    List<BinaryProjectRecord> binaryProjectRecords = new ArrayList<>();
    for (int i = 0; i < selectedProjects.length; i++) {
        BinaryProjectRecord binaryProjectRecord = (BinaryProjectRecord) selectedProjects[i];
        if (isProjectInWorkspace(binaryProjectRecord.getLiferayPluginName())) {
            binaryProjectRecord.setConflicts(true);
        }
        binaryProjectRecords.add(binaryProjectRecord);
    }
    return binaryProjectRecords.toArray(new BinaryProjectRecord[binaryProjectRecords.size()]);
}
Also used : BinaryProjectRecord(com.liferay.ide.project.core.BinaryProjectRecord) ArrayList(java.util.ArrayList)

Example 7 with BinaryProjectRecord

use of com.liferay.ide.project.core.BinaryProjectRecord in project liferay-ide by liferay.

the class BinaryProjectsImportWizardPage method updateProjectsList.

@Override
public void updateProjectsList(String path) {
    if ((path == null) || (path.length() == 0)) {
        setMessage(StringPool.EMPTY);
        selectedProjects = new BinaryProjectRecord[0];
        projectsList.refresh(true);
        projectsList.setCheckedElements(selectedProjects);
        setPageComplete(ListUtil.isNotEmpty(projectsList.getCheckedElements()));
        lastPath = path;
        return;
    }
    // Check if the direcotry is the Plugins SDK folder
    String sdkLocationPath = sdkLocation.getText();
    if ((sdkLocationPath != null) && sdkLocationPath.equals(path)) {
        path = sdkLocationPath + "/dist";
    }
    final File directory = new File(path);
    long modified = directory.lastModified();
    if (path.equals(lastPath) && (lastModified == modified)) {
        if (selectedProjects.length == 0) {
            setMessage(StringPool.EMPTY, WARNING);
        }
        return;
    }
    lastPath = path;
    lastModified = modified;
    final boolean dirSelected = true;
    try {
        getContainer().run(true, true, new IRunnableWithProgress() {

            /*
					 * (non-Javadoc)
					 *
					 * @see IRunnableWithProgress#run(org .eclipse.core.runtime.IProgressMonitor)
					 */
            public void run(IProgressMonitor monitor) {
                monitor.beginTask(StringPool.EMPTY, 100);
                selectedProjects = new BinaryProjectRecord[0];
                Collection<File> projectBinaries = new ArrayList<>();
                monitor.worked(10);
                if (dirSelected && directory.isDirectory()) {
                    if (!ProjectImportUtil.collectBinariesFromDirectory(projectBinaries, directory, true, monitor)) {
                        return;
                    }
                    selectedProjects = new BinaryProjectRecord[projectBinaries.size()];
                    int index = 0;
                    monitor.worked(50);
                    monitor.subTask(StringPool.EMPTY);
                    for (File binaryFile : projectBinaries) {
                        selectedProjects[index++] = new BinaryProjectRecord(binaryFile);
                    }
                // for ( File liferayProjectDir : liferayProjectDirs ) {
                // selectedProjects[index++] = new ProjectRecord( liferayProjectDir );
                // }
                } else {
                    monitor.worked(60);
                }
                monitor.done();
            }
        });
    } catch (InvocationTargetException ite) {
        ProjectUI.logError(ite);
    } catch (InterruptedException ie) {
    // Nothing to do if the user interrupts.
    }
    projectsList.refresh(true);
    setPageComplete(ListUtil.isNotEmpty(projectsList.getCheckedElements()));
    if (selectedProjects.length == 0) {
        setMessage(StringPool.EMPTY, WARNING);
    }
    Object[] checkedBinaries = projectsList.getCheckedElements();
    if (ListUtil.isNotEmpty(checkedBinaries)) {
        selectedProjects = new BinaryProjectRecord[checkedBinaries.length];
        for (int i = 0; i < checkedBinaries.length; i++) {
            selectedProjects[i] = (BinaryProjectRecord) checkedBinaries[i];
        }
        getDataModel().setProperty(SELECTED_PROJECTS, selectedProjects);
    }
}
Also used : BinaryProjectRecord(com.liferay.ide.project.core.BinaryProjectRecord) StyledString(org.eclipse.jface.viewers.StyledString) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Collection(java.util.Collection) File(java.io.File)

Aggregations

BinaryProjectRecord (com.liferay.ide.project.core.BinaryProjectRecord)7 File (java.io.File)4 ArrayList (java.util.ArrayList)2 JarFile (java.util.jar.JarFile)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IPortletFramework (com.liferay.ide.project.core.IPortletFramework)1 ProjectRecord (com.liferay.ide.project.core.ProjectRecord)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Collection (java.util.Collection)1 JarEntry (java.util.jar.JarEntry)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 StyledString (org.eclipse.jface.viewers.StyledString)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1