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()]);
}
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);
}
}
Aggregations