Java Code Examples for org.eclipse.swt.custom.BusyIndicator#showWhile()
The following examples show how to use
org.eclipse.swt.custom.BusyIndicator#showWhile() .
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: SortCommandHandler.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
@Override public boolean doCommand(final SortColumnCommand command) { final int columnIndex = command.getLayer().getColumnIndexByPosition(command.getColumnPosition()); final SortDirectionEnum newSortDirection = sortModel.getSortDirection(columnIndex).getNextSortDirection(); // Fire command - with busy indicator Runnable sortRunner = new Runnable() { public void run() { sortModel.sort(columnIndex, newSortDirection, command.isAccumulate()); } }; BusyIndicator.showWhile(null, sortRunner); // Fire event SortColumnEvent sortEvent = new SortColumnEvent(sortHeaderLayer, command.getColumnPosition()); sortHeaderLayer.fireLayerEvent(sortEvent); return true; }
Example 2
Source File: GcpLocalRunTab.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
private void updateProjectSelector() { Credential credential = accountSelector.getSelectedCredential(); if (credential == null) { projectSelector.setProjects(new ArrayList<GcpProject>()); return; } BusyIndicator.showWhile(projectSelector.getDisplay(), () -> { try { List<GcpProject> gcpProjects = projectRepository.getProjects(credential); projectSelector.setProjects(gcpProjects); } catch (ProjectRepositoryException e) { logger.log(Level.WARNING, "Could not retrieve GCP project information from server.", e); //$NON-NLS-1$ } }); }
Example 3
Source File: TmDbManagerDialog.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 执行查询 * @param sysDbOp * ; */ private void executeSearch(final SystemDBOperator sysDbOp) { BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() { public void run() { // 连接检查 if (!sysDbOp.checkDbConnection()) { MessageDialog.openInformation(getShell(), Messages.getString("dialog.TmDbManagerDialog.msgTitle"), Messages.getString("dialog.TmDbManagerDialog.msg1")); setLastSelectedServer(null); return; } // 获取数据库信息,包括名称和语言 List<DatabaseManagerDbListBean> temp = searchCurrServerDatabase(sysDbOp, currServer); currServerdbListInput.clear(); if (temp != null) { currServerdbListInput.addAll(temp); if (temp.size() > 0) { getDbTableViewer().setSelection(new StructuredSelection(temp.get(0))); } setLastSelectedServer(currServer.getId()); } } }); }
Example 4
Source File: HistoryDialog.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private void getLogEntries() { BusyIndicator.showWhile(Display.getCurrent(), new Runnable() { public void run() { try { if (remoteResource == null) { ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(resource); if ( localResource != null && !localResource.getStatus().isAdded() && localResource.getStatus().isManaged() ) { remoteResource = localResource.getBaseResource(); } } if (remoteResource != null) { if (SVNUIPlugin.getPlugin().getPreferenceStore().getBoolean(ISVNUIConstants.PREF_SHOW_TAGS_IN_REMOTE)) tagManager = new AliasManager(remoteResource.getUrl()); SVNRevision pegRevision = remoteResource.getRevision(); SVNRevision revisionEnd = new SVNRevision.Number(0); boolean stopOnCopy = store.getBoolean(ISVNUIConstants.PREF_STOP_ON_COPY); int entriesToFetch = store.getInt(ISVNUIConstants.PREF_LOG_ENTRIES_TO_FETCH); long limit = entriesToFetch; entries = getLogEntries(remoteResource, pegRevision, revisionStart, revisionEnd, stopOnCopy, limit + 1, tagManager); long entriesLength = entries.length; if (entriesLength > limit) { ILogEntry[] fetchedEntries = new ILogEntry[entries.length - 1]; for (int i = 0; i < entries.length - 1; i++) fetchedEntries[i] = entries[i]; entries = fetchedEntries; } else getNextEnabled = false; if (entries.length > 0) { ILogEntry lastEntry = entries[entries.length - 1]; long lastEntryNumber = lastEntry.getRevision().getNumber(); revisionStart = new SVNRevision.Number(lastEntryNumber - 1); } } } catch (TeamException e) { SVNUIPlugin.openError(Display.getCurrent().getActiveShell(), null, null, e); } } }); }
Example 5
Source File: ImportProjectWizardPage2.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * 重复树点击选择所有以及所有不选择按钮时执行的方法 */ private void checkRepeatTreeBtnSelectFunction(final boolean checkState){ BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() { public void run() { repeatElementTree.setCheckedAll(checkState); for(Object obj : repeatElementTree.getAllElement()){ if (obj instanceof ProjectResource) { ProjectResource proResourceElement = (ProjectResource) obj; proResourceElement.setNeedCover(repeatElementTree.getChecked(proResourceElement)); } } repeatElementTree.refresh(true); } }); }
Example 6
Source File: JavaWorkingSetPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Object[] getInitialTreeSelection() { final Object[][] result= new Object[1][]; BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() { public void run() { IStructuredSelection selection= fInitialSelection; if (selection == null) { IWorkbenchPage page= JavaPlugin.getActivePage(); if (page == null) return; IWorkbenchPart part= page.getActivePart(); if (part == null) return; try { selection= SelectionConverter.getStructuredSelection(part); } catch (JavaModelException e) { return; } } Object[] elements= selection.toArray(); for (int i= 0; i < elements.length; i++) { if (elements[i] instanceof IResource) { IJavaElement je= (IJavaElement)((IResource)elements[i]).getAdapter(IJavaElement.class); if (je != null && je.exists() && je.getJavaProject().isOnClasspath((IResource)elements[i])) elements[i]= je; } } result[0]= elements; } }); if (result[0] == null) return new Object[0]; return result[0]; }
Example 7
Source File: BusyIndicatorRunnableContext.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { BusyRunnable busyRunnable= new BusyRunnable(fork, runnable); BusyIndicator.showWhile(null, busyRunnable); Throwable throwable= busyRunnable.fThrowable; if (throwable instanceof InvocationTargetException) { throw (InvocationTargetException)throwable; } else if (throwable instanceof InterruptedException) { throw (InterruptedException)throwable; } }
Example 8
Source File: TraceTypePreferencePageViewer.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Create the filter viewer area and initialize the values * * @param parent * The parent * @return The created area */ public Composite create(Composite parent) { Composite composite = createFilterArea(parent); fIsEmpty = fEntries.iterator().hasNext(); BusyIndicator.showWhile(null, () -> { Iterable<@NonNull TraceTypeHelper> toCheck = Iterables.filter(fEntries, helper -> helper.isEnabled()); toCheck.forEach(handler -> checkElement(handler)); fTree.getViewer().expandAll(); for (TreeColumn column : fTree.getViewer().getTree().getColumns()) { column.pack(); } fTree.getViewer().collapseAll(); }); return composite; }
Example 9
Source File: EnableMemberFilterAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void run() { BusyIndicator.showWhile(fView.getSite().getShell().getDisplay(), new Runnable() { public void run() { fView.showMembersInHierarchy(isChecked()); } }); }
Example 10
Source File: TreeConflictsView.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public void refresh() { if (disposed || resource == null) return; BusyIndicator.showWhile(Display.getDefault(), new Runnable() { public void run() { folderList = new ArrayList(); treeConflicts = new ArrayList(); ISVNClientAdapter client = null; try { client = SVNWorkspaceRoot.getSVNResourceFor(resource).getRepository().getSVNClient(); ISVNStatus[] statuses = client.getStatus(resource.getLocation().toFile(), true, false, true); for (int i = 0; i < statuses.length; i++) { if (statuses[i].hasTreeConflict()) { SVNTreeConflict treeConflict = new SVNTreeConflict(statuses[i]); IResource treeConflictResource = treeConflict.getResource(); if (treeConflictResource instanceof IContainer && !folderList.contains(treeConflictResource)) { folderList.add(treeConflict); } if (!(treeConflictResource instanceof IContainer)) { IContainer parent = treeConflictResource.getParent(); if (parent != null && !(parent instanceof IWorkspaceRoot) && !folderList.contains(parent)) { folderList.add(parent); } } treeConflicts.add(treeConflict); } } treeViewer.refresh(); treeViewer.expandAll(); } catch (Exception e) { SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e); } finally { SVNWorkspaceRoot.getSVNResourceFor(resource).getRepository().returnSVNClient(client); } } }); }
Example 11
Source File: KeysPreferencePage.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
protected void performDefaults() { // Ask the user to confirm final String title = NewKeysPreferenceMessages.RestoreDefaultsMessageBoxText; final String message = NewKeysPreferenceMessages.RestoreDefaultsMessageBoxMessage; final boolean confirmed = MessageDialog.open(MessageDialog.CONFIRM, getShell(), title, message, SWT.SHEET); if (confirmed) { long startTime = 0L; if (DEBUG) { startTime = System.currentTimeMillis(); } fFilteredTree.setRedraw(false); BusyIndicator.showWhile(fFilteredTree.getViewer().getTree().getDisplay(), new Runnable() { public void run() { try { keyController.setDefaultBindings(fBindingService, lstRemove); } catch (NotDefinedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); fFilteredTree.setRedraw(true); if (DEBUG) { final long elapsedTime = System.currentTimeMillis() - startTime; Tracing.printTrace(TRACING_COMPONENT, "performDefaults:model in " //$NON-NLS-1$ + elapsedTime + "ms"); //$NON-NLS-1$ } } super.performDefaults(); }
Example 12
Source File: SortAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void run() { BusyIndicator.showWhile(fPage.getViewer().getControl().getDisplay(), new Runnable() { public void run() { fPage.setSortOrder(fSortOrder); } }); }
Example 13
Source File: ToggleCommentAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Implementation of the <code>IAction</code> prototype. Checks if the selected * lines are all commented or not and uncomments/comments them respectively. */ @Override public void run() { if (fOperationTarget == null || fDocumentPartitioning == null || fPrefixesMap == null) return; ITextEditor editor= getTextEditor(); if (editor == null) return; if (!validateEditorInputState()) return; final int operationCode; if (isSelectionCommented(editor.getSelectionProvider().getSelection())) operationCode= ITextOperationTarget.STRIP_PREFIX; else operationCode= ITextOperationTarget.PREFIX; Shell shell= editor.getSite().getShell(); if (!fOperationTarget.canDoOperation(operationCode)) { if (shell != null) MessageDialog.openError(shell, JavaEditorMessages.ToggleComment_error_title, JavaEditorMessages.ToggleComment_error_message); return; } Display display= null; if (shell != null && !shell.isDisposed()) display= shell.getDisplay(); BusyIndicator.showWhile(display, new Runnable() { public void run() { fOperationTarget.doOperation(operationCode); } }); }
Example 14
Source File: ResourceTree.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * 双击事件,若双击,自动展开该文件夹 */ public void doubleClick(final DoubleClickEvent event) { BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() { public void run() { ISelection selection = event.getSelection(); IStructuredSelection struSelection = (IStructuredSelection) selection; Object obj = struSelection.getFirstElement(); if (getExpandedState(obj)) { collapseToLevel(obj, 1); }else { expandToLevel(obj, 1); } } }); }
Example 15
Source File: KeysPreferencePage.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
protected void performDefaults() { // Ask the user to confirm final String title = NewKeysPreferenceMessages.RestoreDefaultsMessageBoxText; final String message = NewKeysPreferenceMessages.RestoreDefaultsMessageBoxMessage; final boolean confirmed = MessageDialog.open(MessageDialog.CONFIRM, getShell(), title, message, SWT.SHEET); if (confirmed) { long startTime = 0L; if (DEBUG) { startTime = System.currentTimeMillis(); } fFilteredTree.setRedraw(false); BusyIndicator.showWhile(fFilteredTree.getViewer().getTree().getDisplay(), new Runnable() { public void run() { try { keyController.setDefaultBindings(fBindingService, lstRemove); } catch (NotDefinedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); fFilteredTree.setRedraw(true); if (DEBUG) { final long elapsedTime = System.currentTimeMillis() - startTime; Tracing.printTrace(TRACING_COMPONENT, "performDefaults:model in " //$NON-NLS-1$ + elapsedTime + "ms"); //$NON-NLS-1$ } } super.performDefaults(); }
Example 16
Source File: EventPoolView.java From neoscada with Eclipse Public License 1.0 | 5 votes |
private void performDataChanged ( final Collection<Event> addedEvents ) { if ( addedEvents == null || addedEvents.isEmpty () ) { return; } final Set<DecoratedEvent> decoratedEvents = decorateEvents ( addedEvents ); for ( final DecoratedEvent event : decoratedEvents ) { final Variant source = event.getEvent ().getField ( Fields.SOURCE ); if ( source != null && !source.isNull () && source.asString ( "" ).length () > 0 ) //$NON-NLS-1$ { final String str = source.asString ( "" ); //$NON-NLS-1$ Set<DecoratedEvent> d = EventPoolView.this.poolMap.get ( str ); if ( d == null ) { d = new HashSet<DecoratedEvent> (); EventPoolView.this.poolMap.put ( str, d ); } d.add ( event ); } } // adding more events costs more time if ( addedEvents.size () > 10 ) { BusyIndicator.showWhile ( getSite ().getShell ().getDisplay (), new Runnable () { @Override public void run () { insertElements ( decoratedEvents ); } } ); } else { insertElements ( decoratedEvents ); } }
Example 17
Source File: ScriptRunToLineAdapter.java From birt with Eclipse Public License 1.0 | 4 votes |
public void runToLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ) throws CoreException { ITextEditor textEditor = getTextEditor( part ); if ( textEditor == null ) { return; } else { IEditorInput input = textEditor.getEditorInput( ); if ( input == null || !( input instanceof DebugJsInput ) ) { return; } DebugJsInput scriptInput = (DebugJsInput) input; IResource resource = (IResource) input.getAdapter( IResource.class ); if ( resource == null ) { resource = ScriptDebugUtil.getDefaultResource( ); } final IDocument document = textEditor.getDocumentProvider( ) .getDocument( input ); if ( document == null ) { return; } else { final int[] validLine = new int[1]; // final String[] typeName = new String[1]; final int[] lineNumber = new int[1]; final ITextSelection textSelection = (ITextSelection) selection; Runnable r = new Runnable( ) { public void run( ) { lineNumber[0] = textSelection.getStartLine( ) + 1; } }; BusyIndicator.showWhile( DebugUI.getStandardDisplay( ), r ); // TODO add the validLine to adjust if the line is validLine validLine[0] = lineNumber[0]; if ( validLine[0] == lineNumber[0] ) { ScriptLineBreakpoint point = new RunToLinebreakPoint( resource, scriptInput.getFile( ).getAbsolutePath( ), scriptInput.getId( ), lineNumber[0] ); point.setType( ScriptLineBreakpoint.RUNTOLINE ); if ( target instanceof IAdaptable ) { ScriptDebugTarget debugTarget = (ScriptDebugTarget) ( (IAdaptable) target ).getAdapter( IDebugTarget.class ); if ( debugTarget != null ) { debugTarget.breakpointAdded( point ); debugTarget.resume( ); } } } else { // invalid line return; } } } }
Example 18
Source File: RecordToSourceCoupler.java From tlaplus with MIT License | 4 votes |
private void performSourceCoupling(final ISelection selection, final boolean jumpToPCal, final boolean dueToArrowKeys) { if (selection != null && !selection.isEmpty()) { if (selection instanceof StructuredSelection) { final StructuredSelection structuredSelection = (StructuredSelection) selection; // on a double click there should not be multiple selections, // so taking the first element of the structured selection // should work final Object firstElement = structuredSelection.getFirstElement(); if (firstElement instanceof LoaderTLCState) { final LoaderTLCState loader = (LoaderTLCState) firstElement; // Loading more states can potentially block for a couple // seconds. Thus, give feedback to user. BusyIndicator.showWhile(Display.getCurrent(), new Runnable() { public void run() { loader.loadMore(); } }); } else if (firstElement instanceof IModuleLocatable) { final IModuleLocatable moduleLocatable = (IModuleLocatable) firstElement; Location location = moduleLocatable.getModuleLocation(); if (moduleLocatable instanceof ActionInformationItem) { ActionInformationItem aii = (ActionInformationItem) moduleLocatable; if (aii.hasDefinition()) { // Do not jump to a sub-actions identifier but to its actual definition if a // sub-action has a definition. Consider this partial spec: // ... // Next == \/ /\ x = 42 // /\ x' = 23 // \/ /\ x = 23 // /\ x' = 4711 // ... // getModuleLocation called on the ActionInformationItem for sub-action // "x = 42 /\ x' = 23" returns the location of "x = 42 /\ x' = 23" and not // that of "Next". // This relevant in the Sub-actions for next-state table of the Model Checking // Results page. location = aii.getDefinition(); } } if (location != null) { /* * jumpToNested will be true if the location could be * shown in a nested saved module editor. If it is * false, we jump to the regular TLA editor instead. */ Model model = ToolboxHandle.getCurrentSpec().getAdapter(TLCSpec.class).getModel(moduleLocatable .getModelName()); if (!TLCUIHelper.jumpToSavedLocation(location, model, blacklist)) { final IWorkbenchPart iwp; if (dueToArrowKeys || FocusRetentionPolicy.ALWAYS.equals(focusRetentionPolicy)) { iwp = partToRefocus; } else { iwp = null; } UIHelper.jumpToLocation(location, jumpToPCal, iwp); if (iwp != null) { viewer.getControl().getDisplay().asyncExec(() -> { viewer.getControl().forceFocus(); }); } } } } else if (!Platform.getWS().equals(Platform.WS_WIN32) && viewer instanceof TreeViewer) { // Windows has built-in expand/collapse on double click TreeViewer treeViewer = (TreeViewer) viewer; if (treeViewer.getExpandedState(firstElement)) { treeViewer.collapseToLevel(firstElement, 1); } else { treeViewer.expandToLevel(firstElement, 1); } } } } }
Example 19
Source File: CompletionProposalPopup.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
/** * Completes the common prefix of all proposals directly in the code. If no common prefix can be found, the proposal * popup is shown. * * @return an error message if completion failed. * @since 3.0 */ public String incrementalComplete() { if (Helper.okToUse(fProposalShell) && fFilteredProposals != null) { completeCommonPrefix(); } else { final Control control = fContentAssistSubjectControlAdapter.getControl(); if (fKeyListener == null) { fKeyListener = new ProposalSelectionListener(); } if (!Helper.okToUse(fProposalShell) && !control.isDisposed()) { fContentAssistSubjectControlAdapter.addKeyListener(fKeyListener); } BusyIndicator.showWhile(control.getDisplay(), new Runnable() { public void run() { fInvocationOffset = fContentAssistSubjectControlAdapter.getSelectedRange().x; fFilterOffset = fInvocationOffset; fFilteredProposals = computeProposals(fInvocationOffset, false); int count = (fFilteredProposals == null) ? 0: fFilteredProposals.length; if (count == 0) { // IM turned off for the moment, as it's annoying more than helpful to beep. // control.getDisplay().beep(); hide(); } else if ((count == 1)&& (canAutoInsert(fFilteredProposals[0]))) { insertProposal(fFilteredProposals[0],'\0', 0, fInvocationOffset); } else if (completeCommonPrefix()) { hide(); } else { fComputedProposals = fFilteredProposals; createPopup(fComputedProposals); } } }); } return getErrorMessage(); }
Example 20
Source File: CompareSvnPropertiesAction.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
public void execute(IAction action) { exception = null; IResource[] resources = getSelectedResources(); IPropertyProvider left = null; right = null; if (resources != null && resources.length > 0) { left = new PropertyCompareLocalResourceNode(resources[0], true, null); if (resources.length > 1) { right = new PropertyCompareLocalResourceNode(resources[1], true, null); } else { final ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[0]); BusyIndicator.showWhile(Display.getDefault(), new Runnable() { public void run() { try { right = new PropertyCompareRemoteResourceNode(svnResource.getRemoteResource(SVNRevision.HEAD), SVNRevision.HEAD, true, null); } catch (SVNException e) { exception = e; } } }); if (exception != null) { MessageDialog.openError(getShell(), Policy.bind("CompareSvnPropertiesAction.0"), exception.getMessage()); //$NON-NLS-1$ return; } } } else { ISVNRemoteResource[] remoteResources = getSelectedRemoteResources(); if (remoteResources != null && remoteResources.length > 0) { left = new PropertyCompareRemoteResourceNode(remoteResources[0], SVNRevision.HEAD, true, null); if (remoteResources.length > 1) { right = new PropertyCompareRemoteResourceNode(remoteResources[1], SVNRevision.HEAD, true, null); } } } ComparePropertiesDialog dialog = new ComparePropertiesDialog(getShell(), left, right); if (dialog.open() == ComparePropertiesDialog.OK) { CompareUI.openCompareEditorOnPage(dialog.getInput(), getTargetPage()); } }