org.eclipse.jface.dialogs.ProgressMonitorDialog Java Examples

The following examples show how to use org.eclipse.jface.dialogs.ProgressMonitorDialog. 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 File: GitMergeUtil.java    From MergeProcessor with 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 File: BillingProposalWizardDialog.java    From elexis-3-core with 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 #3
Source File: Repository.java    From bonita-studio with 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 #4
Source File: AcquireLockBlockingUi.java    From elexis-3-core with 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 #5
Source File: AcquireLockBlockingUi.java    From elexis-3-core with 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 #6
Source File: AsynchronousProgressMonitorDialog.java    From Pydev with 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 #7
Source File: AcquireLockBlockingUi.java    From elexis-3-core with 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 #8
Source File: IDEOpenSampleReportAction.java    From birt with 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 #9
Source File: MoveResourceAction.java    From birt with 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 File: TmxEditor.java    From tmxeditor8 with 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 #11
Source File: GotoTypeAction.java    From Eclipse-Postfix-Code-Completion with 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 #12
Source File: ValidationView.java    From olca-app with 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 #13
Source File: CheckoutAction.java    From olca-app with 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 #14
Source File: LoadFileAction.java    From gef with 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 #15
Source File: ImportPlatformWizard.java    From hybris-commerce-eclipse-plugin with 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 #16
Source File: MergeTask.java    From MergeProcessor with 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 #17
Source File: EclipseUtils.java    From n4js with 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 #18
Source File: ExternalLibraryPreferencePage.java    From n4js with 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 #19
Source File: AbstractExportDialog.java    From ermasterr with 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 #20
Source File: MainWindow.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Shows a progress dialog.
 *
 * @param text
 * @param worker
 */
public void showProgressDialog(final String text, final Worker<?> worker) {
    try {
        new ProgressMonitorDialog(shell).run(true, true, worker);
    } catch (final Exception e) {
        worker.setError(e);
    }
}
 
Example #21
Source File: EngineConfigurationIT.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    new ProgressMonitorDialog(Display.getDefault().getActiveShell()).run(true, false, monitor -> {
        try {
            session = BOSEngineManager.getInstance().loginDefaultTenant(Repository.NULL_PROGRESS_MONITOR);
            platformSession = BOSEngineManager.getInstance().loginPlatform(Repository.NULL_PROGRESS_MONITOR);
        } catch (Exception e) {
            throw new InvocationTargetException(e);
        }
    });
}
 
Example #22
Source File: LocalMapReduceLaunchTabGroup.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
private void createRow(final Composite parent, Composite panel,
    final Text text) {
  text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  Button button = new Button(panel, SWT.BORDER);
  button.setText("Browse...");
  button.addListener(SWT.Selection, new Listener() {
    public void handleEvent(Event arg0) {
      try {
        AST ast = AST.newAST(3);

        SelectionDialog dialog = JavaUI.createTypeDialog(parent.getShell(),
            new ProgressMonitorDialog(parent.getShell()), SearchEngine
                .createWorkspaceScope(),
            IJavaElementSearchConstants.CONSIDER_CLASSES, false);
        dialog.setMessage("Select Mapper type (implementing )");
        dialog.setBlockOnOpen(true);
        dialog.setTitle("Select Mapper Type");
        dialog.open();

        if ((dialog.getReturnCode() == Window.OK)
            && (dialog.getResult().length > 0)) {
          IType type = (IType) dialog.getResult()[0];
          text.setText(type.getFullyQualifiedName());
          setDirty(true);
        }
      } catch (JavaModelException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  });
}
 
Example #23
Source File: Repository.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void runMigrationInDialog() {
    try {
        new ProgressMonitorDialog(
                Display.getDefault().getActiveShell())
                        .run(true, false, migrationRunnable());
    } catch (InvocationTargetException | InterruptedException e) {
        CommonRepositoryPlugin.getDefault().openErrorDialog(
                Display.getDefault().getActiveShell(),
                Messages.migrationFailedMessage, e);
    }
}
 
Example #24
Source File: PySelectInterpreter.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public void setInterpreterInfosWithProgressDialog(IInterpreterManager interpreterManager,
        final IInterpreterInfo[] interpreterInfos, Shell shell) {
    //this is the default interpreter
    ProgressMonitorDialog monitorDialog = new AsynchronousProgressMonitorDialog(shell);
    monitorDialog.setBlockOnOpen(false);

    try {
        IRunnableWithProgress operation = new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor)
                    throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Restoring PYTHONPATH", IProgressMonitor.UNKNOWN);
                try {
                    Set<String> interpreterNamesToRestore = new HashSet<>(); // i.e.: don't restore the PYTHONPATH (only order was changed).
                    interpreterManager.setInfos(interpreterInfos, interpreterNamesToRestore, monitor);
                } finally {
                    monitor.done();
                }
            }
        };

        monitorDialog.run(true, true, operation);

    } catch (Exception e) {
        Log.log(e);
    }
}
 
Example #25
Source File: ExportToImageAction.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void save(IEditorPart editorPart, GraphicalViewer viewer,
		String saveFilePath) {

	ProgressMonitorDialog monitor = new ProgressMonitorDialog(PlatformUI
			.getWorkbench().getActiveWorkbenchWindow().getShell());

	try {
		if (outputImage(monitor, viewer, saveFilePath) != -1) {
			Activator.showMessageDialog("dialog.message.export.finish");
		}
	} catch (InterruptedException e) {
	}
}
 
Example #26
Source File: LocalMapReduceLaunchTabGroup.java    From RDFS with Apache License 2.0 5 votes vote down vote up
private void createRow(final Composite parent, Composite panel,
    final Text text) {
  text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  Button button = new Button(panel, SWT.BORDER);
  button.setText("Browse...");
  button.addListener(SWT.Selection, new Listener() {
    public void handleEvent(Event arg0) {
      try {
        AST ast = AST.newAST(3);

        SelectionDialog dialog = JavaUI.createTypeDialog(parent.getShell(),
            new ProgressMonitorDialog(parent.getShell()), SearchEngine
                .createWorkspaceScope(),
            IJavaElementSearchConstants.CONSIDER_CLASSES, false);
        dialog.setMessage("Select Mapper type (implementing )");
        dialog.setBlockOnOpen(true);
        dialog.setTitle("Select Mapper Type");
        dialog.open();

        if ((dialog.getReturnCode() == Window.OK)
            && (dialog.getResult().length > 0)) {
          IType type = (IType) dialog.getResult()[0];
          text.setText(type.getFullyQualifiedName());
          setDirty(true);
        }
      } catch (JavaModelException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  });
}
 
Example #27
Source File: ProjectCompareTree.java    From n4js with 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 #28
Source File: N4JSPackageJsonQuickfixProviderExtension.java    From n4js with 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 #29
Source File: InstalledSolidityCompilerPreferencePage.java    From uml2solidity with 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 #30
Source File: AttachSourcesWizard.java    From hybris-commerce-eclipse-plugin with 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;
}