public void runViewUpdate(final Runnable runnable, final boolean preserveExpansion) { if (Utils.canUpdateViewer(getViewer()) || isPerformingBackgroundUpdate()) { internalRunViewUpdate(runnable, preserveExpansion); } else { if (Thread.currentThread() != getEventHandlerJob().getThread()) { // Run view update should only be called from the UI thread or // the update handler thread. // We will log the problem for now and make it an assert later TeamUIPlugin.log( IStatus.WARNING, "View update invoked from invalid thread", new TeamException( "View update invoked from invalid thread")); //$NON-NLS-1$ //$NON-NLS-2$ } final Control ctrl = getViewer().getControl(); if (ctrl != null && !ctrl.isDisposed()) { ctrl.getDisplay() .syncExec( new Runnable() { public void run() { if (!ctrl.isDisposed()) { BusyIndicator.showWhile( ctrl.getDisplay(), new Runnable() { public void run() { internalRunViewUpdate(runnable, preserveExpansion); } }); } } }); } } }
public synchronized void setIdentityRepository() { IdentityRepository[] repositories = getPluggedInIdentityRepositries(); String[] selected = Utils.getSelectedSSHAgent().split(","); // $NON-NLS-1$ IdentityRepository irepo = null; for (int i = 0; i < selected.length; i++) { for (int j = 0; j < repositories.length; j++) { IdentityRepository _irepo = repositories[j]; if (selected[i].equals(_irepo.getName()) && _irepo.getStatus() == IdentityRepository.RUNNING) { irepo = _irepo; break; } } if (irepo != null) break; } if (irepo != null) { jsch.setIdentityRepository(irepo); } else { // set the internal default IdentityRepository jsch.setIdentityRepository(null); } }
private static void generateP2FinalCall( AntScript script, String productFileLocation, String versionAdvice) { script.printTab(); script.print("<p2.generator "); // $NON-NLS-1$ script.printAttribute( "append", Utils.getPropertyFormat(PROPERTY_P2_APPEND), true); // $NON-NLS-1$ script.printAttribute( "flavor", Utils.getPropertyFormat(PROPERTY_P2_FLAVOR), true); // $NON-NLS-1$ script.printAttribute( "compress", Utils.getPropertyFormat(PROPERTY_P2_COMPRESS), true); // $NON-NLS-1$ script.printAttribute( "metadataRepository", Utils.getPropertyFormat(PROPERTY_P2_METADATA_REPO), true); //$NON-NLS-1$ script.printAttribute( "artifactRepository", Utils.getPropertyFormat(PROPERTY_P2_ARTIFACT_REPO), true); //$NON-NLS-1$ script.printAttribute( "metadataRepositoryName", Utils.getPropertyFormat(PROPERTY_P2_METADATA_REPO_NAME), true); //$NON-NLS-1$ script.printAttribute( "artifactRepositoryName", Utils.getPropertyFormat(PROPERTY_P2_ARTIFACT_REPO_NAME), true); //$NON-NLS-1$ script.printAttribute( "publishArtifacts", Utils.getPropertyFormat(PROPERTY_P2_PUBLISH_ARTIFACTS), true); //$NON-NLS-1$ script.printAttribute("mode", "final", true); // $NON-NLS-1$ //$NON-NLS-2$ if (productFileLocation != null) { script.printAttribute("productFile", productFileLocation, true); // $NON-NLS-1$ if (versionAdvice != null) script.printAttribute("versionAdvice", versionAdvice, true); // $NON-NLS-1$ } else { script.printAttribute( "root", Utils.getPropertyFormat(PROPERTY_P2_ROOT_NAME), true); // $NON-NLS-1$ script.printAttribute( "rootVersion", Utils.getPropertyFormat(PROPERTY_P2_ROOT_VERSION), true); // $NON-NLS-1$ } script.println("/>"); // $NON-NLS-1$ }
/** * Forces the viewer to update the labels for queued elemens whose label has changed during this * round of changes. This method should only be invoked in the UI thread. */ protected void firePendingLabelUpdates() { if (!Utils.canUpdateViewer(getViewer())) return; try { Object[] updates = pendingLabelUpdates.toArray(new Object[pendingLabelUpdates.size()]); updateLabels(updates); } finally { pendingLabelUpdates.clear(); } }
@Override public void run() { if (status != null && !status.isOK()) { ErrorDialog.openError( Utils.getShell(null), null, TeamUIMessages.RefreshSubscriberJob_3, status); } else if (gotoAction != null) { gotoAction.run(); } }
/* * Method that can be called from the UI thread to update the view model. */ private void internalRunViewUpdate(final Runnable runnable, boolean preserveExpansion) { StructuredViewer viewer = getViewer(); IResource[] expanded = null; IResource[] selected = null; try { if (Utils.canUpdateViewer(viewer)) { viewer.getControl().setRedraw(false); if (preserveExpansion) { expanded = provider.getExpandedResources(); selected = provider.getSelectedResources(); } if (viewer instanceof AbstractTreeViewer && additionsMap == null) additionsMap = new HashMap(); } runnable.run(); } finally { if (Utils.canUpdateViewer(viewer)) { try { if (additionsMap != null && !additionsMap.isEmpty() && Utils.canUpdateViewer(viewer)) { for (Iterator iter = additionsMap.keySet().iterator(); iter.hasNext(); ) { ISynchronizeModelElement parent = (ISynchronizeModelElement) iter.next(); if (Policy.DEBUG_SYNC_MODELS) { System.out.println("Adding child view items of " + parent.getName()); // $NON-NLS-1$ } Set toAdd = (Set) additionsMap.get(parent); ((AbstractTreeViewer) viewer).add(parent, toAdd.toArray(new Object[toAdd.size()])); } additionsMap = null; } if (expanded != null) { provider.expandResources(expanded); } if (selected != null) { provider.selectResources(selected); } } finally { viewer.getControl().setRedraw(true); } } } ISynchronizeModelElement root = provider.getModelRoot(); if (root instanceof SynchronizeModelElement) ((SynchronizeModelElement) root).fireChanges(); }
@Override public String getToolTipText() { if (status != null && !status.isOK()) { return status.getMessage(); } if (gotoAction != null) { return gotoAction.getToolTipText(); } return Utils.shortenText( SynchronizeView.MAX_NAME_LENGTH, RefreshParticipantJob.this.getName()); }
/* (non-Javadoc) * @see org.eclipse.team.internal.core.BackgroundEventHandler#doDispatchEvents(org.eclipse.core.runtime.IProgressMonitor) */ protected boolean doDispatchEvents(IProgressMonitor monitor) throws TeamException { // Fire label changed dispatchEarly = false; if (pendingLabelUpdates.isEmpty()) { return false; } else { Utils.asyncExec( new Runnable() { public void run() { firePendingLabelUpdates(); } }, getViewer()); return true; } }
protected void generateMetadataTarget() { if (configScriptGenerator.haveP2Bundles()) { script.printTargetDeclaration(TARGET_P2_METADATA, null, TARGET_P2_METADATA, null, null); ProductFile product = configScriptGenerator.getProductFile(); String productPath = null; if (product != null) { File productFile = new File(product.getLocation()); String modLocation = getProductDir() + productFile.getName(); script.printAvailableTask(PROPERTY_P2_PRODUCT_MOD, modLocation, modLocation); script.printProperty(PROPERTY_P2_PRODUCT_MOD, product.getLocation()); productPath = Utils.getPropertyFormat(PROPERTY_P2_PRODUCT_MOD); } script.printProperty(PROPERTY_P2_APPEND, "true"); // $NON-NLS-1$ script.printProperty(PROPERTY_P2_COMPRESS, "false"); // $NON-NLS-1$ script.printProperty(PROPERTY_P2_METADATA_REPO_NAME, ""); // $NON-NLS-1$ script.printProperty(PROPERTY_P2_ARTIFACT_REPO_NAME, ""); // $NON-NLS-1$ String versionAdvice = null; if (versionsList && product != null) { if (product.useFeatures()) versionAdvice = getWorkingDirectory() + '/' + DEFAULT_FEATURE_VERSION_FILENAME_PREFIX + PROPERTIES_FILE_SUFFIX; else versionAdvice = getWorkingDirectory() + '/' + DEFAULT_PLUGIN_VERSION_FILENAME_PREFIX + PROPERTIES_FILE_SUFFIX; } generateP2FinalCall(script, productPath, versionAdvice); script.printTargetEnd(); } }
/* * Forces the viewer to update the labels for the given elements */ private void updateLabels(Object[] elements) { StructuredViewer tree = getViewer(); if (Utils.canUpdateViewer(tree)) { tree.update(elements, null); } }
public void loadPrivateKeys() { current_pkeys = Utils.loadPrivateKeys(getJSch(), current_pkeys); setNeedToLoadKeys(false); }