Java Code Examples for org.eclipse.jface.dialogs.ProgressMonitorDialog

The following examples show how to use org.eclipse.jface.dialogs.ProgressMonitorDialog. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: MergeProcessor   Author: aposin   File: GitMergeUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Run the processor.
 * 
 * @param pmd     the monitor dialog
 * @param monitor the process monitor
 * @throws MergeUnitException
 * @throws SftpUtilException
 * @throws MergeCancelException
 */
private void run(final ProgressMonitorDialog pmd, final IProgressMonitor monitor)
		throws MergeUnitException, SftpUtilException, MergeCancelException {
	this.monitor = monitor;
	run(Messages.GitMergeUtil_createRepositoryDirectory, this::createLocalRepositoryIfNotExisting);
	run(Messages.GitMergeUtil_clone, this::cloneRepositoryIfNotExisting);

	run(Messages.GitMergeUtil_pull, this::pull);
	run(Messages.GitMergeUtil_evaluteCommitMessage, this::evaluteCommitMessage);
	run(Messages.GitMergeUtil_checkoutBranch, this::checkout);
	run(Messages.GitMergeUtil_checkStatus, this::checkStatus);
	run(Messages.GitMergeUtil_cherryPick, this::cherryPick);
	run(Messages.GitMergeUtil_commit, this::commit);

	// When pushed, no way of return
	pmd.setCancelable(false);
	run(Messages.GitMergeUtil_push, this::push);

	monitor.subTask(Messages.GitMergeUtil_moveMergeUnit);
	SftpUtil.getInstance().moveMergeUnitFromRemoteToDone(mergeUnit);
	monitor.worked(1);
}
 
Example #2
Source Project: MergeProcessor   Author: aposin   File: MergeTask.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Executes the merge in a separate minimal working copy.
 * 
 * @throws InterruptedException
 * @throws InvocationTargetException
 * @throws SvnClientException
 */
private void mergeInMinimalWorkingCopy() throws InvocationTargetException, InterruptedException {
	LogUtil.entering();
	final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shellProvider.getShell());
	Dashboard.setShellProgressMonitorDialog(pmd);
	pmd.run(true, true, monitor -> {
		try {
			boolean cancelled = MergeProcessorUtil.merge(pmd, monitor, configuration, mergeUnit);
			if (cancelled) {
				mergeUnit.setStatus(MergeUnitStatus.CANCELLED);
				MergeProcessorUtil.canceled(mergeUnit);
			} else {
				mergeUnit.setStatus(MergeUnitStatus.DONE);
			}
		} catch (Throwable e) {
			pmd.getShell().getDisplay().syncExec(() -> {
				MultiStatus status = createMultiStatus(e);
				ErrorDialog.openError(pmd.getShell(), "Error dusrching merge process",
						"An Exception occured during the merge process. The merge didn't run successfully.",
						status);
			});
		}

	});
	LogUtil.exiting();
}
 
Example #3
Source Project: n4js   Author: eclipse   File: EclipseUtils.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Same as {@link #runInModalDialog(OperationCanceledManager, IRunnableWithProgress)}, but allows reacting to
 * exceptions.
 *
 * @param throwableHandler
 *            will be invoked on the runnable's thread in case the runnable throws an exception other than a
 *            {@link OperationCanceledManager#isOperationCanceledException(Throwable) cancellation exception}. May
 *            be <code>null</code> if no handling of exceptions is required.
 */
public static void runInModalDialog(OperationCanceledManager ocm, IRunnableWithProgress runnable,
		Consumer<Throwable> throwableHandler) {
	try {
		final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
		final ProgressMonitorDialog dlg = new ProgressMonitorDialog(shell);
		dlg.run(true, true, monitor -> {
			try {
				runnable.run(monitor);
			} catch (Throwable th) {
				// translate cancellation exceptions from Eclipse/Xtext to SWT/JFace world
				if (ocm.isOperationCanceledException(th)) {
					throw new InterruptedException();
				}
				if (throwableHandler != null) {
					throwableHandler.accept(th);
				}
				throw th;
			}
		});
	} catch (InvocationTargetException | InterruptedException e) {
		// ignore
	}
}
 
Example #4
Source Project: n4js   Author: eclipse   File: ExternalLibraryPreferencePage.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean performOk() {
	final MultiStatus multistatus = statusHelper
			.createMultiStatus("Status of importing target platform.");
	try {
		new ProgressMonitorDialog(getShell()).run(true, false, monitor -> {
			final IStatus status = store.save(monitor);
			if (!status.isOK()) {
				setMessage(status.getMessage(), ERROR);
				multistatus.merge(status);
			} else {
				updateInput(viewer, store.getLocations());
			}
		});
	} catch (final InvocationTargetException | InterruptedException exc) {
		multistatus.merge(statusHelper.createError("Error while building external libraries.", exc));
	}

	if (multistatus.isOK())
		return super.performOk();
	else
		return false;
}
 
Example #5
Source Project: hybris-commerce-eclipse-plugin   Author: SAP   File: ImportPlatformWizard.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Attaches the sources.
 */
private void attachSources()
{
	final File sourceArchive = page2.getSourceFile();	
	
	if (sourceArchive == null) 
	{
		return; //nothing to do
	}
	
	IRunnableWithProgress runner = ProjectSourceUtil.getRunner(sourceArchive);

	try
	{
		new ProgressMonitorDialog( getContainer().getShell() ).run( true, false, runner );

	}
	catch( InvocationTargetException | InterruptedException e )
	{
		Throwable t = (e instanceof InvocationTargetException) ? e.getCause() : e;
		MessageDialog.openError( getShell(), "Error attaching sources", t.toString() );
	}
	
}
 
Example #6
Source Project: gef   Author: eclipse   File: LoadFileAction.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void run(IAction action) {
	FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);

	dialog.setText("Select text file...");
	String sourceFile = dialog.open();
	if (sourceFile == null)
		return;
	ProgressMonitorDialog pd = new ProgressMonitorDialog(getShell());
	try {
		List<Type> types = TypeCollector.getData(new File(sourceFile), "UTF-8");
		pd.setBlockOnOpen(false);
		pd.open();
		pd.getProgressMonitor().beginTask("Generating cloud...", 200);
		TagCloudViewer viewer = getViewer();
		viewer.setInput(types, pd.getProgressMonitor());
		// viewer.getCloud().layoutCloud(pd.getProgressMonitor(), false);
	} catch (IOException e) {
		e.printStackTrace();
	} finally {
		pd.close();
	}
}
 
Example #7
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: GotoTypeAction.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run() {
	Shell shell= JavaPlugin.getActiveWorkbenchShell();
	SelectionDialog dialog= null;
	try {
		dialog= JavaUI.createTypeDialog(shell, new ProgressMonitorDialog(shell),
			SearchEngine.createWorkspaceScope(), IJavaElementSearchConstants.CONSIDER_ALL_TYPES, false);
	} catch (JavaModelException e) {
		String title= getDialogTitle();
		String message= PackagesMessages.GotoType_error_message;
		ExceptionHandler.handle(e, title, message);
		return;
	}

	dialog.setTitle(getDialogTitle());
	dialog.setMessage(PackagesMessages.GotoType_dialog_message);
	if (dialog.open() == IDialogConstants.CANCEL_ID) {
		return;
	}

	Object[] types= dialog.getResult();
	if (types != null && types.length > 0) {
		gotoType((IType) types[0]);
	}
}
 
Example #8
Source Project: tmxeditor8   Author: heartsome   File: TmxEditor.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void doFilter(final TmxEditorFilterBean filter) {
	TeActiveCellEditor.commit();
	final String srcSearchStr = getSearchText(srcSearchText);
	final String tgtSearchStr = getSearchText(tgtSearchText);
	IRunnableWithProgress progress = new IRunnableWithProgress() {
		@Override
		public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
			tmxDataAccess.loadDisplayTuIdentifierByFilter(monitor, filter, srcLangCode, tgtLangCode, srcSearchStr,
					tgtSearchStr);
		}
	};
	try {
		new ProgressMonitorDialog(Display.getDefault().getActiveShell()).run(true, true, progress);
	} catch (Exception e) {
		e.printStackTrace();
	}
	tmxEditorImpWithNattable.setSrcSearchStr(srcSearchStr);
	tmxEditorImpWithNattable.setTgtSearchStr(tgtSearchStr);
	tmxEditorImpWithNattable.getTable().setFocus();
	tmxEditorImpWithNattable.refrush();
	tmxEditorImpWithNattable.selectCell(getTgtColumnIndex(), 0);
}
 
Example #9
Source Project: birt   Author: eclipse   File: MoveResourceAction.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Moves the specified source file to the specified target file.
 * 
 * @param srcFile
 *            the source file.
 * @param targetFile
 *            the target file
 * @exception InvocationTargetException
 *                if the run method must propagate a checked exception, it
 *                should wrap it inside an
 *                <code>InvocationTargetException</code>; runtime exceptions
 *                and errors are automatically wrapped in an
 *                <code>InvocationTargetException</code> by this method
 * @exception InterruptedException
 *                if the operation detects a request to cancel, using
 *                <code>IProgressMonitor.isCanceled()</code>, it should exit
 *                by throwing <code>InterruptedException</code>; this method
 *                propagates the exception
 */
private void moveFile( File srcFile, File targetFile )
		throws InvocationTargetException, InterruptedException
{
	if ( targetFile.exists( ) )
	{
		if ( !MessageDialog.openQuestion( getShell( ),
				Messages.getString( "MoveResourceAction.Dialog.Title" ), //$NON-NLS-1$
				Messages.getString( "MoveResourceAction.Dialog.Message" ) ) ) //$NON-NLS-1$
		{
			return;
		}

		new ProgressMonitorDialog( getShell( ) ).run( true,
				true,
				createDeleteRunnable( Arrays.asList( new File[]{
					targetFile
				} ) ) );
	}

	new ProgressMonitorDialog( getShell( ) ).run( true,
			true,
			createRenameFileRunnable( srcFile, targetFile ) );
}
 
Example #10
Source Project: birt   Author: eclipse   File: IDEOpenSampleReportAction.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private void refreshReportProject( final IProject project )
{
	WorkspaceModifyOperation op = new WorkspaceModifyOperation( ) {

		protected void execute( IProgressMonitor monitor )
				throws CoreException
		{
			project.refreshLocal( IResource.DEPTH_INFINITE, monitor );
		}
	};

	try
	{
		new ProgressMonitorDialog( composite.getShell( ) ).run( false,
				true,
				op );
	}
	catch ( Exception e )
	{
		ExceptionUtil.handle( e );
	}
}
 
Example #11
Source Project: Pydev   Author: fabioz   File: AsynchronousProgressMonitorDialog.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Test code below
 */
public static void main(String[] arg) {
    Shell shl = new Shell();
    ProgressMonitorDialog dlg = new AsynchronousProgressMonitorDialog(shl);

    long l = System.currentTimeMillis();
    try {
        dlg.run(true, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Testing", 100000);
                for (long i = 0; i < 100000 && !monitor.isCanceled(); i++) {
                    //monitor.worked(1);
                    monitor.setTaskName("Task " + i);
                }
            }
        });
    } catch (Exception e) {
        Log.log(e);
    }
    System.out.println("Took " + ((System.currentTimeMillis() - l)));
}
 
Example #12
Source Project: bonita-studio   Author: bonitasoft   File: Repository.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void rename(String newName) {
    try {
        new ProgressMonitorDialog(Display.getDefault().getActiveShell()).run(true, false,
                new WorkspaceModifyOperation() {

                    @Override
                    protected void execute(IProgressMonitor monitor)
                            throws CoreException, InvocationTargetException, InterruptedException {
                        closeAllEditors();
                        projectListeners.stream().forEach(l -> l.projectClosed(Repository.this, monitor));
                        disableBuild();
                        getProject().move(org.eclipse.core.runtime.Path.fromOSString(newName), true, monitor);
                        RepositoryManager.getInstance().setRepository(newName, monitor);
                    }
                });
    } catch (InvocationTargetException | InterruptedException e) {
        new BonitaErrorDialog(Display.getDefault().getActiveShell(), "Rename failed", e.getMessage(), e).open();
    }
}
 
Example #13
Source Project: elexis-3-core   Author: elexis   File: BillingProposalWizardDialog.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void okPressed(){
	ProgressMonitorDialog progress = new ProgressMonitorDialog(getShell());
	QueryProposalRunnable runnable = new QueryProposalRunnable();
	try {
		progress.run(true, true, runnable);
		if (runnable.isCanceled()) {
			return;
		} else {
			proposal = runnable.getProposal();
		}
	} catch (InvocationTargetException | InterruptedException e) {
		LoggerFactory.getLogger(BillingProposalWizardDialog.class)
			.error("Error running proposal query", e);
		MessageDialog.openError(getShell(), "Fehler",
			"Fehler beim Ausführen des Rechnungs-Vorschlags.");
		return;
	}
	
	super.okPressed();
}
 
Example #14
Source Project: elexis-3-core   Author: elexis   File: AcquireLockBlockingUi.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public static void aquireAndRun(IPersistentObject lockPo, ILockHandler handler){
	if (LocalLockServiceHolder.get().getStatus() == ILocalLockService.Status.STANDALONE) {
		handler.lockAcquired();
		return;
	}
	
	Display display = Display.getDefault();
	display.syncExec(new Runnable() {
		
		@Override
		public void run(){
			ProgressMonitorDialog progress =
				new ProgressMonitorDialog(display.getActiveShell());
			try {
				progress.run(true, true, new AcquireLockRunnable(lockPo, handler));
			} catch (InvocationTargetException | InterruptedException e) {
				logger.warn("Exception during acquire lock.", e);
			}
		}
	});
}
 
Example #15
Source Project: elexis-3-core   Author: elexis   File: AcquireLockBlockingUi.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public static void aquireAndRun(Identifiable identifiable, ILockHandler handler){
	Display display = Display.getDefault();
	display.syncExec(new Runnable() {
		
		@Override
		public void run(){
			ProgressMonitorDialog progress =
				new ProgressMonitorDialog(display.getActiveShell());
			try {
				progress.run(true, true, new AcquireLockRunnable(identifiable, handler));
			} catch (InvocationTargetException | InterruptedException e) {
				logger.warn("Exception during acquire lock.", e);
			}
		}
	});
}
 
Example #16
Source Project: elexis-3-core   Author: elexis   File: AcquireLockBlockingUi.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public static void aquireAndRun(Identifiable identifiable, ILockHandler handler){
	Display display = Display.getDefault();
	display.syncExec(new Runnable() {
		
		@Override
		public void run(){
			ProgressMonitorDialog progress =
				new ProgressMonitorDialog(display.getActiveShell());
			try {
				progress.run(true, true, new AcquireLockRunnable(identifiable, handler));
			} catch (InvocationTargetException | InterruptedException e) {
				logger.warn("Exception during acquire lock.", e);
			}
		}
	});
}
 
Example #17
Source Project: olca-app   Author: GreenDelta   File: ValidationView.java    License: Mozilla Public License 2.0 6 votes vote down vote up
public static void validate(Collection<INavigationElement<?>> selection) {
	IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	try {
		ValidationView instance = (ValidationView) page.showView("views.problems");
		List<ModelStatus> result = new ArrayList<>();
		ProgressMonitorDialog dialog = new ProgressMonitorDialog(UI.shell());
		dialog.run(true, true, (monitor) -> {
			monitor.beginTask(M.Initializing, IProgressMonitor.UNKNOWN);
			Set<CategorizedDescriptor> descriptors = Navigator.collectDescriptors(selection);
			DatabaseValidation validation = DatabaseValidation.with(monitor);
			result.addAll(validation.evaluate(descriptors));
		});
		StatusList[] model = createModel(result);
		instance.viewer.setInput(model);
		if (model.length == 0)
			MsgBox.info(M.DatabaseValidationCompleteNoErrorsWereFound);
	} catch (Exception e) {
		log.error("Error validating database", e);
	}
}
 
Example #18
Source Project: olca-app   Author: GreenDelta   File: CheckoutAction.java    License: Mozilla Public License 2.0 6 votes vote down vote up
private void doCheckout(Commit commit) throws Exception {
	ProgressMonitorDialog dialog = new ProgressMonitorDialog(UI.shell());
	dialog.run(true, false, new IRunnableWithProgress() {

		@Override
		public void run(IProgressMonitor m) throws InvocationTargetException, InterruptedException {
			try {
				FetchNotifierMonitor monitor = new FetchNotifierMonitor(m, M.CheckingOutCommit);
				RepositoryClient client = Database.getRepositoryClient();
				client.checkout(commit.id, monitor);
			} catch (WebRequestException e) {
				throw new InvocationTargetException(e, e.getMessage());
			}
		}
	});
}
 
Example #19
Source Project: n4js   Author: eclipse   File: ProjectCompareTree.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a new default comparison of all API / implementation projects in the default workspace (i.e. the one
 * accessed via {@link IN4JSCore}) and shows this comparison in the widget.
 */
public void setComparison() {
	final ProgressMonitorDialog dlg = new ProgressMonitorDialog(getTree().getShell());
	try {
		dlg.run(false, false, new IRunnableWithProgress() {
			@Override
			public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
				setComparison(monitor);
			}
		});
	} catch (InvocationTargetException | InterruptedException e) {
		// ignore
	}
}
 
Example #20
Source Project: n4js   Author: eclipse   File: N4JSPackageJsonQuickfixProviderExtension.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private Collection<? extends IChange> wrapWithMonitor(String msg, String errMsg,
		Function<IProgressMonitor, IStatus> f) throws Exception {

	MultiStatus multiStatus = statusHelper.createMultiStatus(msg);
	new ProgressMonitorDialog(UIUtils.getShell()).run(true, false, (monitor) -> {
		try {
			IStatus status = f.apply(monitor);
			multiStatus.merge(status);
		} catch (Exception e) {
			multiStatus.merge(statusHelper.createError(errMsg, e));
		}
	});

	if (!multiStatus.isOK()) {
		N4JSActivator.getInstance().getLog().log(multiStatus);
		UIUtils.getDisplay().asyncExec(new Runnable() {
			@Override
			public void run() {
				String title = "Failed: " + msg;
				String descr = StatusUtils.getErrorMessage(multiStatus, true);
				ErrorDialog.openError(UIUtils.getShell(), title, descr, multiStatus);
			}
		});
	}

	return Collections.emptyList();
}
 
Example #21
Source Project: uml2solidity   Author: UrsZeidler   File: InstalledSolidityCompilerPreferencePage.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected void search() {
	DirectoryDialog directoryDialog = new DirectoryDialog(getShell());
	directoryDialog.setText("search solc ");
	String open = directoryDialog.open();

	final File file = new File(open);
	final Set<SolC> list = new HashSet<SolC>();

	IRunnableWithProgress withProgress = new IRunnableWithProgress() {

		@Override
		public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
			monitor.beginTask("file:" + file.getAbsolutePath(), IProgressMonitor.UNKNOWN);
			searchAndAdd(file, list, monitor);
			monitor.done();
		}
	};

	try {
		new ProgressMonitorDialog(getShell()).run(true, true, withProgress);
		installedSolCs.addAll(list);
		fCompilerList.setInput(installedSolCs.toArray());
	} catch (InvocationTargetException | InterruptedException e) {
		Activator.logError("", e);
	}

}
 
Example #22
Source Project: hybris-commerce-eclipse-plugin   Author: SAP   File: AttachSourcesWizard.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean performFinish()
{
	if (!page.validatePage()) 
	{
		MessageDialog
		.openError(
				getShell(),
				"Unreadable or non-existing file specified",
				"Please make sure the archive you selected is readable to the current user and exists." );
		// and ... abort
		return false;
	}
	
	File sourceArchive = page.getSourceFile();
	IRunnableWithProgress runner = ProjectSourceUtil.getRunner(sourceArchive);

	try
	{
		new ProgressMonitorDialog( getContainer().getShell() ).run( true, false, runner );

	}
	catch( InvocationTargetException | InterruptedException e )
	{
		Throwable t = (e instanceof InvocationTargetException) ? e.getCause() : e;
		MessageDialog.openError( getShell(), "Error attaching sources", t.toString() );
	}
	
	return true;
}
 
Example #23
/**
 * Workhorse to do the actual import of the projects into this workspace.
 */
private void synchronizePlatform()
{
	boolean autobuildEnabled = isAutoBuildEnabled();
	enableAutoBuild( false );
	final boolean fixClasspath = page1.isFixClasspath();
	final boolean removeHybrisBuilder = page1.isRemoveHybrisGenerator();
	final boolean createWorkingSets = page1.isCreateWorkingSets();
	final boolean useMultiThread = page1.isUseMultiThread();
	final boolean skipJarScanning = page1.isSkipJarScanning();
		
	Preferences preferences = InstanceScope.INSTANCE.getNode("com.hybris.hyeclipse.preferences");
	final String platformDir = preferences.get("platform_home", null);
	
	if (platformDir == null)
	{
		throw new IllegalStateException("not platform has been set, try importing again");
	}
	
	IRunnableWithProgress importer = new IRunnableWithProgress()
	{
		public void run( IProgressMonitor monitor ) throws InvocationTargetException
		{
			List<IProject> projects = Arrays.asList( ResourcesPlugin.getWorkspace().getRoot().getProjects() );
			synchronizePlatform( monitor, projects, new File(platformDir), fixClasspath, removeHybrisBuilder, createWorkingSets, useMultiThread, skipJarScanning);
		}
	};
	try
	{
		new ProgressMonitorDialog( getContainer().getShell() ).run( true, false, importer );
	}
	catch( InvocationTargetException | InterruptedException e )
	{
		Activator.logError("Failed to synchronize platform", e);
		Throwable t = (e instanceof InvocationTargetException) ? e.getCause() : e;
		MessageDialog.openError( this.page1.getControl().getShell(), "Error", t.toString() );
		enableAutoBuild( autobuildEnabled );
	}
	enableAutoBuild( autobuildEnabled );
}
 
Example #24
Source Project: hybris-commerce-eclipse-plugin   Author: SAP   File: CreateWorkingSetWizard.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean performFinish() {
	if (!page.validatePage()) {
		MessageDialog.openError(getShell(), "Not option selected", "Select at least one option");
		// and ... abort
		return false;
	}

	final boolean createFromLocalExtensions = page.getCreateFromLocalExtensions().getSelection();
	final boolean createFromExtensionDirectories = page.getCreateFromExtensionDirectories().getSelection();

	IRunnableWithProgress importer = new IRunnableWithProgress() {
		public void run(IProgressMonitor monitor) throws InvocationTargetException {

			if (createFromLocalExtensions) {
				WorkingSetsUtils.organizeWorkingSetsFromLocalExtensions(monitor);
			}
			if (createFromExtensionDirectories) {
				WorkingSetsUtils.organizeWorkingSetsFromExtensionDirectories(monitor);
			}
		}
	};

	try {
		new ProgressMonitorDialog(getContainer().getShell()).run(true, false, importer);
	} catch (InvocationTargetException | InterruptedException e) {
		Throwable t = (e instanceof InvocationTargetException) ? e.getCause() : e;
		MessageDialog.openError(this.page.getControl().getShell(), "Error", t.toString());
	}
	return true;
}
 
Example #25
Source Project: ermasterr   Author: roundrop   File: AbstractExportDialog.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void perfomeOK() throws Exception {
    try {
        final ProgressMonitorDialog monitor = new ProgressMonitorDialog(getShell());

        final ExportWithProgressManager manager = getExportWithProgressManager(settings.getExportSetting());

        manager.init(diagram, getBaseDir());

        final ExportManagerRunner runner = new ExportManagerRunner(manager);

        monitor.run(true, true, runner);

        if (runner.getException() != null) {
            throw runner.getException();
        }

        if (openAfterSavedButton != null && openAfterSavedButton.getSelection()) {
            final File openAfterSaved = openAfterSaved();

            final URI uri = openAfterSaved.toURI();

            final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

            if (openWithExternalEditor()) {
                IDE.openEditor(page, uri, IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID, true);

            } else {
                final IFileStore fileStore = EFS.getStore(uri);
                IDE.openEditorOnFileStore(page, fileStore);
            }
        }

        // there is a case in another project
        diagram.getEditor().refreshProject();

    } catch (final InterruptedException e) {
        throw new InputException();
    }
}
 
Example #26
Source Project: gama   Author: gama-platform   File: SyntaxErrorsView.java    License: GNU General Public License v3.0 5 votes vote down vote up
static void build() {

		final ProgressMonitorDialog dialog = new ProgressMonitorDialog(WorkbenchHelper.getShell());
		dialog.setBlockOnOpen(false);
		dialog.setCancelable(false);
		dialog.setOpenOnRun(true);
		try {
			dialog.run(true, false, monitor -> doBuild(monitor));
		} catch (InvocationTargetException | InterruptedException e1) {
			e1.printStackTrace();
		}
	}
 
Example #27
Source Project: APICloud-Studio   Author: apicloudcom   File: RepositoriesView.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
  * this is called whenever a new repository location is added for example
  * or when user wants to refresh
  */
 protected void refreshViewer(Object object, boolean refreshRepositoriesFolders) {
     if (treeViewer == null) return;
     if (refreshRepositoriesFolders) {
     	IRunnableWithProgress runnable = new IRunnableWithProgress() {
	public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
             	SVNProviderPlugin.getPlugin().getRepositories().refreshRepositoriesFolders(monitor);
	}
     	};
         try {
	new ProgressMonitorDialog(getShell()).run(true, false, runnable);
} catch (Exception e) {
          SVNUIPlugin.openError(getShell(), null, null, e, SVNUIPlugin.LOG_TEAM_EXCEPTIONS);
}
     }
     if (object == null) treeViewer.refresh();
     else {
     	if (object instanceof ISVNRemoteFolder) {
     		ISVNRemoteFolder parent = ((ISVNRemoteFolder)object).getParent();
     		if (parent == null) {
     			treeViewer.refresh();
     			return;
     		}
     	}
     	treeViewer.refresh(object); 
     }
 }
 
Example #28
Source Project: APICloud-Studio   Author: apicloudcom   File: ChooseUrlDialog.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void refreshRepositoriesFolders() {
  	IRunnableWithProgress runnable = new IRunnableWithProgress() {
	public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
          	SVNProviderPlugin.getPlugin().getRepositories().refreshRepositoriesFolders(monitor);
  			needsRefresh = false;
	}
  	};
      try {
	new ProgressMonitorDialog(getShell()).run(true, false, runnable);
} catch (Exception e) {
          SVNUIPlugin.openError(getShell(), null, null, e, SVNUIPlugin.LOG_TEAM_EXCEPTIONS);
}    	
  }
 
Example #29
Source Project: erflute   Author: dbflute-session   File: ExportToImageAction.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void save(IEditorPart editorPart, GraphicalViewer viewer, String saveFilePath) {
    final ProgressMonitorDialog monitor = new ProgressMonitorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
    try {
        if (outputImage(monitor, viewer, saveFilePath) != -1) {
            Activator.showMessageDialog("dialog.message.export.finish");
        }
    } catch (final InterruptedException e) {}
}
 
Example #30
public static void startCutRefactoring(final Object[] elements, final Shell shell) throws InterruptedException, InvocationTargetException {
	JavaDeleteProcessor processor= new JavaDeleteProcessor(elements);
	processor.setSuggestGetterSetterDeletion(false);
	processor.setQueries(new ReorgQueries(shell));
	Refactoring refactoring= new DeleteRefactoring(processor);
	int stopSeverity= RefactoringCore.getConditionCheckingFailedSeverity();
	new RefactoringExecutionHelper(refactoring, stopSeverity, RefactoringSaveHelper.SAVE_NOTHING, shell, new ProgressMonitorDialog(shell)).perform(false, false);
}