public static String readString(InputStream is, String encoding) throws IOException { return readString(is, encoding, -1, null); }
public static byte[] readBytes(InputStream in) { ByteArrayOutputStream bos= new ByteArrayOutputStream(); try { while (true) { int c= in.read(); if (c == -1) break; bos.write(c); } } catch (IOException ex) { return null; } finally { Utilities.close(in); try { bos.close(); } catch (IOException x) { // silently ignored } } return bos.toByteArray(); }
public IActionBars getActionBars() { IActionBars actionBars = fContainer.getActionBars(); if (actionBars == null && !fContainerProvided) { // The old way to find the action bars return Utilities.findActionBars(fComposite); } return actionBars; }
List readOnlyFiles= getReadonlyFiles(resources); if (readOnlyFiles.size() == 0) return true; Map oldTimeStamps= createModificationStampMap(readOnlyFiles); String message= getString("ValidateEdit.error.unable_to_perform"); //$NON-NLS-1$ displayError(shell, title, status, message); return false; Map newTimeStamps= createModificationStampMap(readOnlyFiles); for (Iterator iter= oldTimeStamps.keySet().iterator(); iter.hasNext();) { IFile file= (IFile) iter.next(); CompareUIPlugin.getPluginId(), VALIDATE_EDIT_PROBLEM, getFormattedString("ValidateEdit.error.stillReadonly", file.getFullPath().toString()), //$NON-NLS-1$ null); modified= addStatus(modified, entry); } else if (! oldTimeStamps.get(file).equals(newTimeStamps.get(file))) { IStatus entry= new Status(IStatus.ERROR, CompareUIPlugin.getPluginId(), VALIDATE_EDIT_PROBLEM, getFormattedString("ValidateEdit.error.fileModified", file.getFullPath().toString()), //$NON-NLS-1$ null); modified= addStatus(modified, entry); String message= getString("ValidateEdit.error.unable_to_perform"); //$NON-NLS-1$ displayError(shell, title, modified, message);
private boolean isIgnoreWhitespace() { return Utilities.getBoolean(getCompareConfiguration(), CompareConfiguration.IGNORE_WHITESPACE, false); }
/** * Fires the given property change event to all listeners * registered with this compare editor input. * @param event the property change event * @since 3.3 */ protected void firePropertyChange(PropertyChangeEvent event) { Utilities.firePropertyChange(fListenerList, event); }
fMessage.setData(CompareUI.COMPARE_VIEWER_TITLE, Utilities.getString(fBundle, "title")); //$NON-NLS-1$ fLeftIsLocal= Utilities.getBoolean(cc, "LEFT_IS_LOCAL", false); //$NON-NLS-1$ fTextButton.setText(Utilities.getString(fBundle, "compareAsText")); //$NON-NLS-1$ fTextButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) {
int r= right.read(); if (l != r) { String format= Utilities.getString(fBundle, "diffMessageFormat"); //$NON-NLS-1$ message= MessageFormat.format(format, new String[] { Integer.toString(pos) } ); break; message= Utilities.getString(fBundle, "deleteConflictMessage"); //$NON-NLS-1$ } else if (left == null) { if (fLeftIsLocal) message= Utilities.getString(fBundle, "deletedMessage"); //$NON-NLS-1$ else message= Utilities.getString(fBundle, "addedMessage"); //$NON-NLS-1$ } else if (right == null) { if (fLeftIsLocal) message= Utilities.getString(fBundle, "addedMessage"); //$NON-NLS-1$ else message= Utilities.getString(fBundle, "deletedMessage"); //$NON-NLS-1$ message= Utilities.getString(fBundle, "errorMessage"); //$NON-NLS-1$ } catch (IOException ex) { message= Utilities.getString(fBundle, "errorMessage"); //$NON-NLS-1$ } finally { Utilities.close(left); Utilities.close(right);
if (monitor.isCanceled()) throw new OperationCanceledException(); setReadTimeout(connection, 60 * 1000); progress.setTaskName(PatchMessages.InputPatchPage_URLFetchingContent); String enc = connection.getContentEncoding(); if (enc == null) enc = ResourcesPlugin.getEncoding(); result[0] = Utilities.readString( connection.getInputStream(), enc, connection.getContentLength(),
fRight.resetLineBackground(); boolean ignoreWhiteSpace= Utilities.getBoolean(getCompareConfiguration(), CompareConfiguration.IGNORE_WHITESPACE, false); if (isPatchHunk()) { ITypedElement right = ((ICompareInput)getInput()).getRight(); isRight = right != null && Utilities.getAdapter(right, IHunk.class) != null; if (isRight) { sleft= new DocLineComparator(aDoc, toRegion(aRegion), ignoreWhiteSpace); e= (RangeDifference[]) result[0]; } catch (InvocationTargetException ex) { String title= Utilities.getString(bundle, "tooComplexError.title"); //$NON-NLS-1$ String format= Utilities.getString(bundle, "tooComplexError.format"); //$NON-NLS-1$ String msg= MessageFormat.format(format, new Object[] { Integer.toString(PlatformUI.getWorkbench().getProgressService().getLongOperationTime()/1000) } ); MessageDialog.openError(fComposite.getShell(), title, msg);
@Override public InputStream getContents() { return new ByteArrayInputStream(Utilities.getBytes(fContent, UTF_16)); } @Override
private boolean contentsEqual(Object o1, char contributor1, Object o2, char contributor2) { if (fStructureCreator != null) { boolean ignoreWhiteSpace = Utilities.getBoolean( getCompareConfiguration(), CompareConfiguration.IGNORE_WHITESPACE, false); ICompareFilter[] compareFilters = Utilities.getCompareFilters(getCompareConfiguration()); String s1, s2; if (compareFilters != null && compareFilters.length > 0 && fStructureCreator instanceof StructureCreator) { return ((StructureCreator) fStructureCreator).contentsEquals( o1, contributor1, o2, contributor2, ignoreWhiteSpace, compareFilters); } s1 = fStructureCreator.getContents(o1, ignoreWhiteSpace); s2 = fStructureCreator.getContents(o2, ignoreWhiteSpace); if (s1 == null || s2 == null) return false; return s1.equals(s2); } return false; }
@Override public IServiceLocator getServiceLocator() { IServiceLocator serviceLocator = fContainer.getServiceLocator(); if (serviceLocator == null && !fContainerProvided) { // The old way to find the service locator return Utilities.findSite(fComposite); } return serviceLocator; }
List<IResource> readOnlyFiles= getReadonlyFiles(resources); if (readOnlyFiles.size() == 0) return true; Map<IFile, Long> oldTimeStamps= createModificationStampMap(readOnlyFiles); String message= getString("ValidateEdit.error.unable_to_perform"); //$NON-NLS-1$ displayError(shell, title, status, message); return false; Map<IFile, Long> newTimeStamps= createModificationStampMap(readOnlyFiles); for (Map.Entry<IFile, Long> entry : newTimeStamps.entrySet()) { IFile file = entry.getKey(); CompareUIPlugin.getPluginId(), VALIDATE_EDIT_PROBLEM, getFormattedString("ValidateEdit.error.stillReadonly", file.getFullPath().toString()), //$NON-NLS-1$ null); modified= addStatus(modified, error); } else if (!oldTimeStamps.get(file).equals(newTimeStamp)) { IStatus error = new Status(IStatus.ERROR, CompareUIPlugin.getPluginId(), VALIDATE_EDIT_PROBLEM, getFormattedString("ValidateEdit.error.fileModified", file.getFullPath().toString()), //$NON-NLS-1$ null); modified= addStatus(modified, error); String message= getString("ValidateEdit.error.unable_to_perform"); //$NON-NLS-1$ displayError(shell, title, modified, message);
private boolean isIgnoreAncestor() { return Utilities.getBoolean(getCompareConfiguration(), ICompareUIConstants.PROP_IGNORE_ANCESTOR, false); }
/** * Sets the title which will be used when presenting the compare result. * This method must be called before the editor is opened. * * @param title the title to use for the CompareEditor */ public void setTitle(String title) { String oldTitle = fTitle; fTitle= title; Utilities.firePropertyChange(fListenerList, this, PROP_TITLE, oldTitle, title); }
aDoc= fAncestor.getDocument(); boolean ignoreWhiteSpace= Utilities.getBoolean(getCompareConfiguration(), CompareConfiguration.IGNORE_WHITESPACE, false); e= (RangeDifference[]) result[0]; } catch (InvocationTargetException ex) { String title= Utilities.getString(bundle, "tooComplexError.title"); //$NON-NLS-1$ String format= Utilities.getString(bundle, "tooComplexError.format"); //$NON-NLS-1$ String msg= MessageFormat.format(format, new Object[] { Integer.toString(progressService.getLongOperationTime()/1000) } ); MessageDialog.openError(fComposite.getShell(), title, msg);
int r= right.read(); if (l != r) { String format= Utilities.getString(fBundle, "diffMessageFormat"); //$NON-NLS-1$ message= MessageFormat.format(format, Integer.toString(pos) ); break; message= Utilities.getString(fBundle, "deleteConflictMessage"); //$NON-NLS-1$ } else if (left == null) { message= Utilities.getString(fBundle, compareConfiguration.isMirrored() ? "addedMessage" : "deletedMessage"); //$NON-NLS-1$ //$NON-NLS-2$ } else if (right == null) { message= Utilities.getString(fBundle, compareConfiguration.isMirrored() ? "deletedMessage" : "addedMessage"); //$NON-NLS-1$ //$NON-NLS-2$ message = Utilities.getString(fBundle, "errorMessage"); //$NON-NLS-1$ CompareUIPlugin.log(ex); } finally { Utilities.close(left); Utilities.close(right);
public InputStream getContents() { return new ByteArrayInputStream(Utilities.getBytes(fContent, UTF_16)); } public String getCharset() {
public IServiceLocator getServiceLocator() { IServiceLocator serviceLocator = fContainer.getServiceLocator(); if (serviceLocator == null && !fContainerProvided) { // The old way to find the service locator return Utilities.findSite(fComposite); } return serviceLocator; }