use of org.eclipse.core.runtime.IProgressMonitor in project generator by mybatis.
the class WorkspaceUtilities method createProject.
private static IProject createProject(String projectName) throws CoreException {
final IProject project = getWorkspaceRoot().getProject(projectName);
IWorkspaceRunnable create = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
project.create(null);
project.open(null);
}
};
getWorkspace().run(create, null);
return project;
}
use of org.eclipse.core.runtime.IProgressMonitor in project mechanoid by robotoworks.
the class NewMechanoidElementWizard method performFinish.
@Override
public boolean performFinish() {
final IPath newFilePath = createNewResourceFilePath();
onBeforeCreateElementResource();
WorkspaceModifyDelegatingOperation op = new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
mNewResource = createElementResource(monitor, newFilePath);
} catch (Exception e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
}
});
try {
getContainer().run(true, true, op);
selectAndReveal(mNewResource);
openResource(mNewResource);
} catch (InvocationTargetException e) {
Throwable realException = e.getTargetException();
MessageDialog.openError(getShell(), Messages.NewMechanoidElementWizard_Dialog_CreateResourceError_Title, realException.getMessage());
return false;
} catch (InterruptedException e) {
return false;
}
return true;
}
use of org.eclipse.core.runtime.IProgressMonitor in project gfm_viewer by satyagraha.
the class SchedulerDefault method scheduleTransformation.
@Override
public void scheduleTransformation(final File mdFile, final File htFile, final Callback<File> onDone) {
final String jobName = "Transforming: " + mdFile.getName();
Job job = new Job(jobName) {
@Override
protected IStatus run(IProgressMonitor monitor) {
IStatus status = Status.OK_STATUS;
try {
transformer.transformMarkdownFile(mdFile, htFile);
} catch (IOException e) {
status = new Status(Status.ERROR, pluginId, jobName, e);
}
return status;
}
};
job.setUser(false);
job.setSystem(false);
job.setPriority(Job.SHORT);
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
// refreshFile(htFile);
if (event.getResult().isOK()) {
if (onDone != null) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
onDone.onComplete(htFile);
}
});
}
} else {
// normal reporting has occurred
if (onDone != null) {
final Throwable exception = event.getResult().getException();
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
onDone.onError(htFile, exception);
}
});
}
}
}
});
job.schedule();
}
use of org.eclipse.core.runtime.IProgressMonitor in project dbeaver by serge-rider.
the class NavigatorHandlerCreateLink method createLink.
private void createLink(IWorkbenchWindow workbenchWindow, IFolder folder, String fsFolder) {
final File externalFolder = new File(fsFolder);
try {
final IFolder linkedFolder = folder.getFolder(externalFolder.getName());
workbenchWindow.run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
linkedFolder.createLink(externalFolder.toURI(), IResource.NONE, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
}
});
} catch (InvocationTargetException e) {
UIUtils.showErrorDialog(workbenchWindow.getShell(), "Create link", "Can't create link", e);
} catch (InterruptedException e) {
// skip
}
}
use of org.eclipse.core.runtime.IProgressMonitor in project dbeaver by serge-rider.
the class ProgressPageControl method createSearchControls.
private void createSearchControls() {
if (searchText != null) {
return;
}
hideControls(false);
((GridLayout) searchControlsComposite.getLayout()).numColumns = 2;
searchText = new Text(searchControlsComposite, SWT.BORDER);
UIUtils.addFocusTracker(DBeaverUI.getActiveWorkbenchWindow(), UIUtils.INLINE_WIDGET_EDITOR_ID, this.searchText);
if (curSearchText != null) {
searchText.setText(curSearchText);
searchText.setSelection(curSearchText.length());
}
//searchText.setBackground(searchNotFoundColor);
searchText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
searchText.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
switch(e.keyCode) {
case SWT.ESC:
cancelSearch(true);
break;
case SWT.CR:
case SWT.ARROW_UP:
case SWT.ARROW_DOWN:
if (childPageControl != null) {
childPageControl.setFocus();
}
e.doit = false;
//performSearch(SearchType.NEXT);
break;
}
}
});
searchText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
curSearchText = searchText.getText();
if (curSearchJob == null) {
curSearchJob = new UIJob(CoreMessages.controls_progress_page_job_search) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
performSearch(SearchType.NEXT);
curSearchJob = null;
return Status.OK_STATUS;
}
};
curSearchJob.schedule(200);
}
}
});
//ToolBar searchTools = new ToolBar(searchControlsComposite, SWT.HORIZONTAL);
if (searchToolbarManager == null) {
searchToolbarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
// Do not add prev/next buttons - they doesn't make sense now.
// Keep code just in case
/*
searchToolbarManager.add(ActionUtils.makeCommandContribution(
PlatformUI.getWorkbench(),
IWorkbenchActionDefinitionIds.FIND_NEXT,
null,
UIIcon.ARROW_DOWN));
searchToolbarManager.add(ActionUtils.makeCommandContribution(
PlatformUI.getWorkbench(),
IWorkbenchActionDefinitionIds.FIND_PREVIOUS,
null,
UIIcon.ARROW_UP));
*/
searchToolbarManager.add(new Action(CoreMessages.controls_progress_page_action_close, UIUtils.getShardImageDescriptor(ISharedImages.IMG_ELCL_REMOVE)) {
@Override
public void run() {
cancelSearch(true);
}
});
}
searchToolbarManager.createControl(searchControlsComposite);
searchControlsComposite.getParent().layout();
}
Aggregations