/** * Gets the validation report from the validator. * * @param source the source text * @param path the source path * @return the report */ private static String getReport(String source, URI path) { StyleSheetParser parser = new StyleSheetParser(); ApplContext ac = new ApplContext("en"); // $NON-NLS-1$ ac.setProfile(APTANA_PROFILE); try { parser.parseStyleElement( ac, new ByteArrayInputStream(source.getBytes(IOUtil.UTF_8)), null, null, path.toURL(), 0); } catch (MalformedURLException e) { IdeLog.logError( CSSPlugin.getDefault(), MessageFormat.format(Messages.CSSValidator_ERR_InvalidPath, path), e); } catch (UnsupportedEncodingException e) { IdeLog.logError(CSSPlugin.getDefault(), e); } StyleSheet stylesheet = parser.getStyleSheet(); stylesheet.findConflicts(ac); StyleReport report = StyleReportFactory.getStyleReport( ac, "Title", stylesheet, "soap12", 2); // $NON-NLS-1$ //$NON-NLS-2$ ByteArrayOutputStream out = new ByteArrayOutputStream(); report.print(new PrintWriter(out)); return out.toString().replaceAll("m:", ""); // $NON-NLS-1$ //$NON-NLS-2$ }
/** * Download the remote content and store it the temp directory. * * @param URLs * @param progressMonitor */ public IStatus download(String[] URLs, IProgressMonitor progressMonitor) { if (URLs.length == 0) { String err = Messages.InstallerConfigurationProcessor_missingDownloadTargets; applyErrorAttributes(err); IdeLog.logError( PortalUIPlugin.getDefault(), "We expected an array of URLs, but got an empty array.", new Exception(err)); // $NON-NLS-1$ return new Status(IStatus.ERROR, PortalUIPlugin.PLUGIN_ID, err); } downloadedPaths = null; DownloadManager downloadManager = new DownloadManager(); List<URI> urlsList = new ArrayList<URI>(URLs.length); for (int i = 0; i < URLs.length; i++) { try { urlsList.add(new URI(urls[i])); } catch (URISyntaxException mue) { IdeLog.logError(PortalUIPlugin.getDefault(), mue); } } try { downloadManager.addURIs(urlsList); IStatus status = downloadManager.start(progressMonitor); if (status.isOK()) { downloadedPaths = downloadManager.getContentsLocations(); } return status; } catch (Exception e) { IdeLog.logError(PortalUIPlugin.getDefault(), e); } return Status.CANCEL_STATUS; }
/** * Install an extension directly into profile location * * @param extensionURL * @param extensionID * @param dir * @return boolean */ public static boolean installExtension(URL extensionURL, String extensionID, File dir) { dir = new File(dir, extensionID); if (dir.exists()) { return true; } if (!dir.mkdirs()) { return false; } File file = null; InputStream in = null; FileOutputStream out = null; try { file = File.createTempFile("ffe", ".zip"); // $NON-NLS-1$ //$NON-NLS-2$ in = extensionURL.openStream(); out = new FileOutputStream(file); byte[] buffer = new byte[0x1000]; int n; while ((n = in.read(buffer)) > 0) { out.write(buffer, 0, n); } } catch (IOException e) { IdeLog.logError(CorePlugin.getDefault(), e.getMessage(), e); if (file != null) { if (!file.delete()) { file.deleteOnExit(); } } return false; } finally { if (in != null) { try { in.close(); } catch (IOException e) { } } if (out != null) { try { out.close(); } catch (IOException e) { } } } try { ZipUtil.extract(file, dir, null); } catch (IOException e) { IdeLog.logError(CorePlugin.getDefault(), e.getMessage(), e); return false; } finally { if (!file.delete()) { file.deleteOnExit(); } } return true; }
/** * Locates a PHPDoc comment above the offset in the document specified. In case the given entry is * a parameter variable, the search for the documentation will include the documentation of the * parameter's wrapping function. * * @param entry * @param document * @param offset * @return A {@link PHPDocBlock}, or <code>null</code>. */ public static PHPDocBlock findFunctionPHPDocComment( IElementEntry entry, IDocument document, int offset) { boolean isParameter = ((entry.getValue() instanceof VariablePHPEntryValue) && ((VariablePHPEntryValue) entry.getValue()).isParameter()); if (entry.getModule() != null) { return findFunctionPHPDocComment(entry.getModule(), document, offset, isParameter); } // In case that the entry module is null, it's probably a PHP API documentation item, so // parse the right item. try { String entryPath = entry.getEntryPath(); if (entryPath != null) { InputStream stream = PHPBuiltins.getInstance().getBuiltinResourceStream(entryPath); if (stream != null) { BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); // $codepro.audit.disable // closeWhereCreated return innerParsePHPDoc(offset, reader, isParameter); } } } catch (Exception ex) { IdeLog.logError( PHPEditorPlugin.getDefault(), "Failed locating the PHP function doc", ex); // $NON-NLS-1$ return null; } return null; }
/** * Install an extension using linked method * * @param extensionURL * @param extensionID * @param dir * @return boolean */ public static boolean installLinkedExtension(URL extensionURL, String extensionID, File dir) { File file = new File(dir, extensionID); if (file.exists() && file.isDirectory()) { return true; } IPath base = CorePlugin.getDefault().getStateLocation().addTrailingSeparator(); boolean result = installExtension(extensionURL, extensionID, base.toFile()); if (result) { String linkedPath = base.append(extensionID).toOSString(); FileOutputStream out = null; try { out = new FileOutputStream(file); out.write(linkedPath.getBytes()); } catch (IOException e) { IdeLog.logError(CorePlugin.getDefault(), e.getMessage(), e); } finally { if (out != null) { try { out.close(); } catch (IOException e) { } } } } return result; }
/** * Makes a copy of the internal list of changed files so that iterating won't ever result in a * ConcurrentModificationException. try to avoid use if possible, since a deep copy is made which * can be expensive. This method populates the changedFiles collection lazily on first demand. * * @return */ public List<ChangedFile> changedFiles() { boolean isNull = false; synchronized (this.changedFilesLock) { isNull = (this.changedFiles == null); } if (isNull) { // Don't want to call back to fireIndexChangeEvent yet! IStatus status = refresh(false, null, new NullProgressMonitor()); if (!status.isOK()) { IdeLog.logError(GitPlugin.getDefault(), status.getMessage()); return Collections.emptyList(); } } synchronized (this.changedFilesLock) { if (this.changedFiles == null) { return Collections.emptyList(); } List<ChangedFile> copy = new ArrayList<ChangedFile>(this.changedFiles.size()); for (ChangedFile file : this.changedFiles) { copy.add(new ChangedFile(file)); } return copy; } }
/** * Process all metadata files via the metadata reader returned by createMetadataReader * * @param monitor * @param reader * @param resources */ private void loadMetadata(IProgressMonitor monitor, T reader, String... resources) { SubMonitor subMonitor = SubMonitor.convert(monitor, resources.length); for (String resource : resources) { URL url = FileLocator.find(this.getBundle(), new Path(resource), null); if (url != null) { InputStream stream = null; try { stream = url.openStream(); reader.loadXML(stream, url.toString()); } catch (Throwable t) { IdeLog.logError( CommonEditorPlugin.getDefault(), Messages.MetadataLoader_Error_Loading_Metadata + resource, t); } finally { if (stream != null) { try { stream.close(); } catch (IOException e) { } } } } subMonitor.worked(1); } subMonitor.done(); }
/* * @see IPainter#paint(int) */ public void paint(int reason) { if (fViewer == null) { return; } if (fViewer.getDocument() == null) { deactivate(false); return; } // initialization if (!fIsActive) { StyledText textWidget = fViewer.getTextWidget(); textWidget.addLineBackgroundListener(this); textWidget.addPaintListener(this); fPositionManager.managePosition(fCurrentLine); fIsActive = true; } // This forces redraw of the line highlight if (updateHighlightLine()) { // clear last line // Fix the background colors for tokens that didn't have the same as line! if (isOpaque() && !fLastLine.isDeleted() && fViewer instanceof ITextViewerExtension2) { ITextViewerExtension2 ext = (ITextViewerExtension2) fViewer; try { ext.invalidateTextPresentation(fLastLine.getOffset(), fLastLine.getLength()); } catch (Exception e) { IdeLog.logError(CommonEditorPlugin.getDefault(), e); } } drawHighlightLine(fLastLine); // draw new line drawHighlightLine(fCurrentLine); } }
/** * Loads our CSS profile. * * @throws IOException if profile loading fails */ private static void loadAptanaCSSProfile() { InputStream configStream = CSSValidator.class.getResourceAsStream(CONFIG_FILE); InputStream profilesStream = CSSValidator.class.getResourceAsStream(PROFILES_CONFIG_FILE); try { // loads our config PropertiesLoader.config.load(configStream); // loads our profile Utf8Properties profiles = new Utf8Properties(); profiles.load(profilesStream); // a hack, but no other way since PropertiesLoader provides no public access to stored // profiles Field field = PropertiesLoader.class.getDeclaredField("profiles"); // $NON-NLS-1$ field.setAccessible(true); field.set(null, profiles); } catch (Exception e) { IdeLog.logError(CSSPlugin.getDefault(), Messages.CSSValidator_ERR_FailToLoadProfile, e); } finally { try { configStream.close(); } catch (IOException e) { } try { profilesStream.close(); } catch (IOException e) { } } }
/** * Cache the installed application location and version in the preferences. * * @param installDir - The directory the application was installed to. * @param versionedFileLocation - Can be the URL that we grabbed the installer from, or any other * string that contains a version information in a form of x.y.z. * @param appName - The application name (e.g. xampp) */ @SuppressWarnings("unchecked") public void cacheVersion(String installDir, String versionedFileLocation, String appName) { IPreferenceStore preferenceStore = PortalUIPlugin.getDefault().getPreferenceStore(); String versions = preferenceStore.getString(IPortalPreferences.CACHED_VERSIONS_PROPERTY_NAME); Map<String, Map<String, String>> versionsMap = null; if (versions == null || versions.equals(StringUtil.EMPTY)) { versionsMap = new HashMap<String, Map<String, String>>(); } else { versionsMap = (Map<String, Map<String, String>>) JSON.parse(versions); } Map<String, String> appVersionMap = new HashMap<String, String>(); Version version = VersionUtil.parseVersion(versionedFileLocation); if (!VersionUtil.isEmpty(version)) { appVersionMap.put(IPortalPreferences.CACHED_VERSION_PROPERTY, version.toString()); appVersionMap.put(IPortalPreferences.CACHED_LOCATION_PROPERTY, installDir); versionsMap.put(appName.toLowerCase(), appVersionMap); preferenceStore.setValue( IPortalPreferences.CACHED_VERSIONS_PROPERTY_NAME, JSON.toString(versionsMap)); } else { IdeLog.logError( PortalUIPlugin.getDefault(), MessageFormat.format( "Could not cache the location and version for {0}. Install dir: {1}, versionedFileLocation: {2}", //$NON-NLS-1$ appName, installDir, versionedFileLocation), new Exception()); } }
/* * (non-Javadoc) * @see com.aptana.index.core.IIndexFileContributor#contributeFiles(java.net.URI) */ public Set<IFileStore> getFiles(URI containerURI) { IContainer[] containers = ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(containerURI); Set<IFileStore> result = new HashSet<IFileStore>(); if (containers != null && containers.length > 0) { for (IContainer container : containers) { if (container instanceof IProject) { IProject project = (IProject) container; Set<BuildPathEntry> entries = BuildPathManager.getInstance().getBuildPaths(project); if (entries != null) { for (BuildPathEntry entry : entries) { try { IFileStore fileStore = EFS.getStore(entry.getPath()); result.add(fileStore); } catch (CoreException e) { IdeLog.logError(BuildPathCorePlugin.getDefault(), e.getMessage(), e); } } } } } } return result; }
/** Start the server that listens on a socket for command line arguments. */ public static void startServer() { try { CommandLineArgsServer server = new CommandLineArgsServer(); server.start(); } catch (IOException e) { IdeLog.logError(CommandlineLauncherPlugin.getDefault(), e); } }
public IStatus unstageFiles(Collection<ChangedFile> unstageFiles) { if (CollectionsUtil.isEmpty(unstageFiles)) { // no-op, return OK return Status.OK_STATUS; } StringBuilder input = new StringBuilder(); for (ChangedFile file : unstageFiles) { input.append(file.indexInfo()); } IStatus result = repository.executeWithInput( input.toString(), "update-index", "-z", "--index-info"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (result == null) { return new Status( IStatus.ERROR, GitPlugin.PLUGIN_ID, "Failed to unstage files. Process failed to run."); //$NON-NLS-1$ } if (!result.isOK()) { IdeLog.logError( GitPlugin.getDefault(), MessageFormat.format("Failed to stage files: {0}", result.getMessage()), IDebugScopes.DEBUG); // $NON-NLS-1$ return result; } // Update the staged/unstaged flags in the passed in copy of changed files, and our internal // list of changed // files. ArrayList<ChangedFile> preFiles = new ArrayList<ChangedFile>(unstageFiles.size()); for (ChangedFile file : unstageFiles) { preFiles.add(new ChangedFile(file)); synchronized (this.changedFilesLock) { if (this.changedFiles != null) { int index = Collections.binarySearch(this.changedFiles, file); if (index >= 0) { ChangedFile orig = this.changedFiles.get(index); orig.hasUnstagedChanges = true; orig.hasStagedChanges = false; } } } file.hasUnstagedChanges = true; file.hasStagedChanges = false; } preFiles.trimToSize(); postIndexChange(preFiles, unstageFiles); return result; }
public IStatus stageFiles(Collection<ChangedFile> stageFiles) { if (CollectionsUtil.isEmpty(stageFiles)) { // no-op return Status.OK_STATUS; } StringBuffer input = new StringBuffer(stageFiles.size() * stageFiles.iterator().next().getPath().length()); for (ChangedFile file : stageFiles) { input.append(file.getPath()).append('\n'); } @SuppressWarnings("nls") IStatus result = repository.executeWithInput( input.toString(), "update-index", "--add", "--remove", "--stdin"); if (result == null) { return new Status( IStatus.ERROR, GitPlugin.PLUGIN_ID, "Failed to stage files. Process failed to run."); //$NON-NLS-1$; } if (!result.isOK()) { IdeLog.logError( GitPlugin.getDefault(), MessageFormat.format("Failed to stage files: {0}", result.getMessage()), IDebugScopes.DEBUG); // $NON-NLS-1$ return result; } ArrayList<ChangedFile> preFiles = new ArrayList<ChangedFile>(stageFiles.size()); // Update the staged/unstaged flags in the passed in copy of changed files, and our internal // list of changed // files. for (ChangedFile file : stageFiles) { preFiles.add(new ChangedFile(file)); synchronized (changedFilesLock) { if (this.changedFiles != null) { int index = Collections.binarySearch(this.changedFiles, file); if (index >= 0) { ChangedFile orig = this.changedFiles.get(index); orig.hasUnstagedChanges = false; orig.hasStagedChanges = true; } } } file.hasUnstagedChanges = false; file.hasStagedChanges = true; } preFiles.trimToSize(); postIndexChange(preFiles, stageFiles); return result; }
/** * Sets the scanner offset to the given offset. * * @param offset The offset to set * @throws IOException */ public void setOffset(int offset) { this.offset = offset; charReader.reset(offset); try { scanner.yyreset(charReader); scanner.setInScriptingState(); scanner.resetCommentList(); } catch (IOException e) { IdeLog.logError( PHPEplPlugin.getDefault(), "Error setting a PHP token-scanner offset", e); // $NON-NLS-1$ } }
/** * Returns the Shell command path. * * @return The shell command path. */ public static String getShellPath() { try { IPath path = ShellExecutable.getPath(); if (path != null) { return path.toOSString(); } } catch (CoreException e) { IdeLog.logError(ConfigurationsPlugin.getDefault(), e); } return null; }
protected void openIndexFile(boolean activatateEditor) { IFile indexFile = newProject.getFile("index.html"); // $NON-NLS-1$ if (indexFile.exists()) { IWorkbenchPage page = UIUtils.getActivePage(); if (page != null) { try { IDE.openEditor(page, indexFile, activatateEditor); } catch (PartInitException e) { IdeLog.logError( ProjectsPlugin.getDefault(), Messages.NewProjectWizard_ERR_OpeningIndex, e); } } } }
private void openIndexFile() { IFile indexFile = newProject.getFile("index.html"); // $NON-NLS-1$ if (indexFile.exists()) { IWorkbenchPage page = UIUtils.getActivePage(); if (page != null) { try { IDE.openEditor(page, indexFile); } catch (PartInitException e) { IdeLog.logError( SamplesUIPlugin.getDefault(), Messages.NewSampleProjectWizard_ERR_OpenIndexFile, e); } } } }
private ISourceLocator getDefaultSourceLocator() { if (fDefaultSourceLocator == null) { try { fDefaultSourceLocator = DebugPlugin.getDefault().getLaunchManager().newSourceLocator(DEFAULT_SOURCE_LOCATOR_ID); if (fDefaultSourceLocator instanceof ISourceLookupDirector) { ISourceLookupDirector sourceLookupDirector = (ISourceLookupDirector) fDefaultSourceLocator; sourceLookupDirector.initializeParticipants(); sourceLookupDirector.setSourceContainers( new ISourceContainer[] { new DefaultSourceContainer() { /* * (non-Javadoc) * @see org.eclipse.debug.core.sourcelookup.containers. * DefaultSourceContainer#createSourceContainers() */ @Override protected ISourceContainer[] createSourceContainers() throws CoreException { ISourcePathComputer sourcePathComputer = null; ISourceLookupDirector director = getDirector(); if (director != null) { sourcePathComputer = director.getSourcePathComputer(); } if (sourcePathComputer != null) { return sourcePathComputer.computeSourceContainers(null, null); } return EMPTY_CONTAINERS; } } }); ISourcePathComputer sourcePathComputer = DebugPlugin.getDefault() .getLaunchManager() .getSourcePathComputer(DEFAULT_SOURCE_PATH_COMPUTER_ID); sourceLookupDirector.setSourcePathComputer(sourcePathComputer); } } catch (CoreException e) { IdeLog.logError(JSDebugUIPlugin.getDefault(), e); } } return fDefaultSourceLocator; }
/** * Opens the internal help in the Studio's internal browser. * * @param url * @return A boolean value indicating a successful operations or not. */ public static boolean openHelpInBrowser(String url) { IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench != null) { IWorkbenchHelpSystem helpSystem = workbench.getHelpSystem(); URL resolvedURL = helpSystem.resolve(url, true); if (resolvedURL != null) { return openInBroswer( resolvedURL, true, IWorkbenchBrowserSupport.AS_EDITOR | IWorkbenchBrowserSupport.STATUS); } else { IdeLog.logError( UIPlugin.getDefault(), "Unable to resolve the Help URL for " + url); // $NON-NLS-1$ return false; } } return false; }
/** * Opens the internal HelpView and address it to the given doc url. * * @param url */ public static void openHelp(String url) { IWorkbenchPage page = getActivePage(); if (page != null) { try { IViewPart part = page.showView(HELP_VIEW_ID); if (part != null) { HelpView view = (HelpView) part; view.showHelp(url); } } catch (PartInitException e) { IdeLog.logError(UIPlugin.getDefault(), e); } } else { IdeLog.logWarning( UIPlugin.getDefault(), "Could not open the help view. Active page was null."); //$NON-NLS-1$ } }
private void incrementalBuild( List<IBuildParticipant> participants, IResourceDelta delta, IProgressMonitor monitor) { try { SubMonitor sub = SubMonitor.convert(monitor, 100); ResourceCollector collector = new ResourceCollector(); delta.accept(collector); indexProjectBuildPaths(sub.newChild(25)); // Notify of the removed files removeFiles(participants, collector.removedFiles, sub.newChild(5)); // Now build the new/updated files buildFiles(participants, collector.updatedFiles, sub.newChild(70)); } catch (CoreException e) { IdeLog.logError(BuildPathCorePlugin.getDefault(), e); } }
/** * Grabs the list of {@link IBuildPathEntry}s for a project and make sure the indices for them are * up-to-date. * * @param monitor */ private void indexProjectBuildPaths(IProgressMonitor monitor) { IProject project = getProjectHandle(); Set<IBuildPathEntry> entries = getBuildPathManager().getBuildPaths(project); SubMonitor sub = SubMonitor.convert(monitor, entries.size()); for (IBuildPathEntry entry : entries) { try { IFileStore fileStore = EFS.getStore(entry.getPath()); if (fileStore != null) { if (fileStore.fetchInfo().isDirectory()) { new IndexContainerJob(entry.getDisplayName(), entry.getPath()).run(sub.newChild(1)); } else { new IndexFileJob(entry.getDisplayName(), entry.getPath()).run(sub.newChild(1)); } } } catch (Throwable e) { IdeLog.logError(BuildPathCorePlugin.getDefault(), e); } } }
/** * Open a URL in a browser. * * @param url * @param internal In case true, the system will try to open the internal browser if it's * available. * @param style the Browser's style, in case an internal browser is requested. * @return A boolean value indicating a successful operations or not. */ public static boolean openInBroswer(URL url, boolean internal, int style) { IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench != null) { IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport(); try { if (internal && support.isInternalWebBrowserAvailable()) { support.createBrowser(style, INTERNAL_HELP_BROWSER_ID, null, null).openURL(url); } else { support.getExternalBrowser().openURL(url); } } catch (PartInitException e) { IdeLog.logError(UIPlugin.getDefault(), "Error opening the help", e); // $NON-NLS-1$ return false; } return true; } return false; }
public void lineGetBackground(LineBackgroundEvent event) { if (fViewer == null) { return; } final StyledText textWidget = fViewer.getTextWidget(); if (textWidget == null) { return; } try { final int offset = event.lineOffset; IDocument document = fViewer.getDocument(); int line = document.getLineOfOffset(offset); final IRegion lineRegion = document.getLineInformation(line); // Handle fully opaque line highlight here. A modified approach from CursorLinePainter. if (fEnabled && isOpaque() && isCurrentLine(line)) { // draw current line drawCurrentLine(event, lineRegion); return; } // Not drawing an opaque line highlight, so we need to do our normal line coloring here. // This extends the bg color out for a given line based on it's end scope. String endOfLineScope = getScopeManager().getScopeAtOffset(document, lineRegion.getLength() + offset); String commonPrefix = getScope(document, line, endOfLineScope); TextAttribute at = getCurrentTheme().getTextAttribute(commonPrefix); // if we have no color we need to extend to end of line, but this used to be the highlight // line, force the // theme bg color if (at.getBackground() == null && isOpaque() && fLastLine.includes(offset)) { event.lineBackground = getColorManager().getColor(getCurrentTheme().getBackground()); } else { event.lineBackground = at.getBackground(); } } catch (BadLocationException e) { IdeLog.logError(CommonEditorPlugin.getDefault(), e); } }
/* * @seeorg.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui. IWorkbenchWindow) * @since 3.1 */ public void windowActivated(IWorkbenchWindow window) { if (window == editor.getEditorSite().getWorkbenchWindow() && fMarkOccurrenceAnnotations && editor.isActiveEditor()) { fForcedMarkOccurrencesSelection = editor.getSelectionProvider().getSelection(); IModelElement sourceModule = editor.getSourceModule(); if (sourceModule != null && sourceModule.getElementType() == IModelElement.MODULE) { try { updateOccurrenceAnnotations( (ITextSelection) fForcedMarkOccurrencesSelection, SharedASTProvider.getAST( (ISourceModule) sourceModule, SharedASTProvider.WAIT_NO, editor.getProgressMonitor())); } catch (Exception e) { IdeLog.logError( PHPEditorPlugin.getDefault(), "PHP code-scanner - Update error", e); // $NON-NLS-1$ } } } }
public IStatus discardChangesForFiles(Collection<ChangedFile> discardFiles) { StringBuilder input = new StringBuilder(); for (ChangedFile file : discardFiles) { input.append(file.getPath()).append(NULL_DELIMITER); } IStatus result = repository.executeWithInput( input.toString(), "checkout-index", "--index", "--quiet", "--force", "-z", "--stdin"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ // //$NON-NLS-6$ if (result == null) { return new Status( IStatus.ERROR, GitPlugin.PLUGIN_ID, "Failed to revert files. Process failed to run."); //$NON-NLS-1$ } if (!result.isOK()) { IdeLog.logError( GitPlugin.getDefault(), MessageFormat.format("Failed to revert files: {0}", result.getMessage()), IDebugScopes.DEBUG); // $NON-NLS-1$ return result; } ArrayList<ChangedFile> preFiles = new ArrayList<ChangedFile>(discardFiles.size()); for (ChangedFile file : discardFiles) { preFiles.add(new ChangedFile(file)); file.hasUnstagedChanges = false; } preFiles.trimToSize(); postIndexChange(preFiles, discardFiles); return result; }
/** @see java.lang.Runnable#run() */ public void run() { if (server == null) { return; } while (server.isClosed() == false) { Socket clientSocket = null; try { clientSocket = server.accept(); BufferedReader r = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); BufferedWriter w = new BufferedWriter(new OutputStreamWriter(clientSocket.getOutputStream())); List<String> args = new LinkedList<String>(); while ((line = r.readLine()) != null) { args.add(line); } if (args.size() > 0) { // Process command line arguments CommandlineArgumentsHandler.processCommandLineArgs(args.toArray(new String[0])); } // Send ACK w.write("pong"); // $NON-NLS-1$ w.flush(); } catch (IOException e) { IdeLog.logError(CommandlineLauncherPlugin.getDefault(), e); } finally { if (clientSocket != null) { try { clientSocket.close(); } catch (IOException e) { // Ignore } } } } }
/** * Exports a sync state to a log file. * * @param logFile File to export the log into. * @param items Synchronized resources */ @SuppressWarnings("nls") public void export(File logFile, ISyncResource[] items) { DateFormat df = new SimpleDateFormat(); String date = df.format(new Date()); Writer writer = null; try { if (!logFile.exists()) { logFile.createNewFile(); } writer = new FileWriter(logFile, true); StringBuilder builder = new StringBuilder(); builder.append("File Transfer Log: " + date + FileUtil.NEW_LINE); for (ISyncResource iSyncResource : items) { if (iSyncResource.isSkipped()) { builder.append(" " + iSyncResource.getPath().toString() + ": Skipped"); } else { builder.append( " " + iSyncResource.getPath().toString() + ": " + getSyncState(iSyncResource.getSyncState())); } builder.append('\n'); } writer.write(builder.toString()); } catch (IOException e) { IdeLog.logError(SyncingUIPlugin.getDefault(), e); } finally { try { if (writer != null) { writer.close(); } } catch (IOException e) { // ignore } } }
/** * Finalize the installation by placing a .aptana file in the installed directory, specifying some * properties. * * @param installDir */ protected void finalizeInstallation(String installDir) { super.finalizeInstallation(installDir); File propertiesFile = new File(installDir, APTANA_PROPERTIES_FILE_NAME); Properties properties = new Properties(); properties.put("PYTHON_install", urls[0]); // $NON-NLS-1$ FileOutputStream fileOutputStream = null; try { fileOutputStream = new FileOutputStream(propertiesFile); properties.store( fileOutputStream, NLS.bind(Messages.InstallProcessor_aptanaInstallationComment, PYTHON)); } catch (IOException e) { IdeLog.logError(PortalUIPlugin.getDefault(), e); } finally { if (fileOutputStream != null) { try { fileOutputStream.flush(); fileOutputStream.close(); } catch (IOException e) { } } } }