use of org.eclipse.ui.progress.IProgressService in project liferay-ide by liferay.
the class AbstractLiferayTableViewCustomPart method _handleUpgradeEvent.
private void _handleUpgradeEvent() {
try {
IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
progressService.run(true, false, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
int count = _tableViewElements != null ? _tableViewElements.length : 0;
if (count == 0) {
UIUtil.async(new Runnable() {
@Override
public void run() {
String message = "No files that need to be upgraded were found.";
PageValidateEvent pe = new PageValidateEvent();
pe.setMessage(message);
pe.setType(PageValidateEvent.warning);
triggerValidationEvent(pe);
}
});
return;
}
int unit = 100 / count;
monitor.beginTask("Start to upgrade files.....", 100);
for (int i = 0; i < count; i++) {
monitor.worked(i + 1 * unit);
if (i == (count - 1)) {
monitor.worked(100);
}
LiferayUpgradeElement tableViewElement = _tableViewElements[i];
monitor.setTaskName("Upgrading files for " + tableViewElement.getProjectName());
if (tableViewElement.getUpgradeStatus() == true) {
continue;
}
try {
IProject project = tableViewElement.getProject();
doUpgrade(tableViewElement.getFile(), project);
if (project != null) {
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
final int loopNum = i;
UIUtil.async(new Runnable() {
@Override
public void run() {
tableViewElement.setUpgradeStatus(true);
_tableViewElements[loopNum] = tableViewElement;
tableViewer.setInput(_tableViewElements);
Stream.of(tableViewer.getTable().getColumns()).forEach(obj -> obj.pack());
tableViewer.refresh();
}
});
} catch (Exception e) {
ProjectCore.logError("Error upgrade files...... ", e);
}
}
}
});
} catch (Exception e) {
ProjectUI.logError(e);
}
}
use of org.eclipse.ui.progress.IProgressService in project liferay-ide by liferay.
the class InitConfigureProjectPage method importProject.
protected void importProject() throws CoreException {
String layout = dataModel.getLayout().content();
IPath location = PathBridge.create(dataModel.getSdkLocation().content());
if (_isAlreadyImported(location)) {
Stream.of(CoreUtil.getAllProjects()).forEach(this::_checkProjectType);
dataModel.setImportFinished(true);
return;
}
try {
IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
progressService.run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
try {
String newPath = "";
_backup(monitor);
_clearExistingProjects(location, monitor);
_deleteEclipseConfigFiles(location.toFile());
if (_isMavenProject(location.toPortableString())) {
ILiferayProjectImporter importer = LiferayCore.getImporter("maven");
List<IProject> projects = importer.importProjects(location.toPortableString(), monitor);
for (IProject project : projects) {
_checkProjectType(project);
}
} else {
if (layout.equals("Upgrade to Liferay Workspace")) {
_createLiferayWorkspace(location, monitor);
_removeIvyPrivateSetting(location.append("plugins-sdk"));
newPath = _renameProjectFolder(location);
IPath sdkLocation = new Path(newPath).append("plugins-sdk");
_deleteSDKLegacyProjects(sdkLocation);
ILiferayProjectImporter importer = LiferayCore.getImporter("gradle");
importer.importProjects(newPath, monitor);
if (dataModel.getDownloadBundle().content()) {
_createInitBundle(monitor);
}
_importSDKProject(sdkLocation, monitor);
dataModel.setConvertLiferayWorkspace(true);
} else {
_deleteEclipseConfigFiles(location.toFile());
_copyNewSDK(location, monitor);
_removeIvyPrivateSetting(location);
_deleteSDKLegacyProjects(location);
String serverName = dataModel.getLiferay70ServerName().content();
IServer server = ServerUtil.getServer(serverName);
newPath = _renameProjectFolder(location);
SDK sdk = SDKUtil.createSDKFromLocation(new Path(newPath));
sdk.addOrUpdateServerProperties(ServerUtil.getLiferayRuntime(server).getLiferayHome());
SDKUtil.openAsProject(sdk, monitor);
_importSDKProject(sdk.getLocation(), monitor);
}
}
dataModel.setImportFinished(true);
} catch (Exception e) {
ProjectUI.logError(e);
throw new InvocationTargetException(e, e.getMessage());
}
}
});
} catch (Exception e) {
ProjectUI.logError(e);
throw new CoreException(StatusBridge.create(Status.createErrorStatus(e.getMessage(), e)));
}
}
use of org.eclipse.ui.progress.IProgressService in project liferay-ide by liferay.
the class CustomJspConverter method doExecute.
public void doExecute(String[] projectPaths, String[] projectNames, String targetPath, boolean liferayWorkspace) {
Job job = new WorkspaceJob("Converting Jsp hook to fragments...") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
IStatus retval = Status.OK_STATUS;
try {
convertJspHookProject(projectPaths, projectNames, targetPath, monitor, liferayWorkspace);
String[] projectPaths = getConvertResult(resultPrefix);
if (ListUtil.isNotEmpty(projectPaths)) {
for (String path : projectPaths) {
ImportLiferayModuleProjectOp importOp = ImportLiferayModuleProjectOp.TYPE.instantiate();
importOp.setLocation(path);
if (importOp.validation().severity() != org.eclipse.sapphire.modeling.Status.Severity.ERROR) {
ImportLiferayModuleProjectOpMethods.execute(importOp, ProgressMonitorBridge.create(monitor));
}
}
refreshUI();
}
} catch (Exception e) {
retval = ProjectUI.createErrorStatus("Error in convert jsp", e);
}
return retval;
}
};
try {
IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
progressService.showInDialog(Display.getDefault().getActiveShell(), job);
job.schedule();
} catch (Exception e) {
}
}
use of org.eclipse.ui.progress.IProgressService in project jbosstools-hibernate by jbosstools.
the class HibernatePersistenceUnitClassesComposite method chooseType.
/**
* Prompts the user the Open Type dialog.
*
* @return Either the selected type or <code>null</code> if the user
* canceled the dialog
*/
private IType chooseType() {
IJavaProject javaProject = getJavaProject();
IJavaElement[] elements = new IJavaElement[] { javaProject };
IJavaSearchScope scope = SearchEngine.createJavaSearchScope(elements);
IProgressService service = PlatformUI.getWorkbench().getProgressService();
SelectionDialog typeSelectionDialog;
try {
typeSelectionDialog = JavaUI.createTypeDialog(getShell(), service, scope, IJavaElementSearchConstants.CONSIDER_CLASSES, false, // $NON-NLS-1$
"");
} catch (JavaModelException e) {
HibernateJptUIPlugin.logException(e);
return null;
}
typeSelectionDialog.setTitle(JptCommonUiMessages.CLASS_CHOOSER_PANE__DIALOG_TITLE);
typeSelectionDialog.setMessage(JptCommonUiMessages.CLASS_CHOOSER_PANE__DIALOG_MESSAGE);
if (typeSelectionDialog.open() == Window.OK) {
return (IType) typeSelectionDialog.getResult()[0];
}
return null;
}
use of org.eclipse.ui.progress.IProgressService in project netxms by netxms.
the class ConsoleJob method runInForeground.
/**
* Run job in foreground using IProgressService.busyCursorWhile
*
* @return true if job was successful
*/
public boolean runInForeground() {
passException = true;
IProgressService service = PlatformUI.getWorkbench().getProgressService();
boolean success = true;
try {
service.run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IStatus status = ConsoleJob.this.run(monitor);
if (!status.isOK()) {
throw new InvocationTargetException(status.getException());
}
}
});
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause == null)
cause = e;
// $NON-NLS-1$
MessageDialog.openError(null, Messages.get().ConsoleJob_ErrorDialogTitle, getErrorMessage() + ": " + cause.getLocalizedMessage());
} catch (InterruptedException e) {
}
return success;
}
Aggregations