public SvnSupportOptions(final Long version) { myVersion = version; // will be set to SvnSupportOptions.CHANGELIST_SUPPORT after sync if (myVersion == null || myVersion.longValue() < SvnSupportOptions.CHANGELIST_SUPPORT) { myVersion = SvnSupportOptions.UPGRADE_TO_15_VERSION_ASKED; } }
private void altCommitToOriginal(@NotNull DocumentEvent e) { final PsiFile origPsiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(myOrigDocument); String newText = myNewDocument.getText(); // prepare guarded blocks LinkedHashMap<String, String> replacementMap = new LinkedHashMap<String, String>(); int count = 0; for (RangeMarker o : ContainerUtil.reverse(((DocumentEx) myNewDocument).getGuardedBlocks())) { String replacement = o.getUserData(REPLACEMENT_KEY); String tempText = "REPLACE" + (count++) + Long.toHexString(StringHash.calc(replacement)); newText = newText.substring(0, o.getStartOffset()) + tempText + newText.substring(o.getEndOffset()); replacementMap.put(tempText, replacement); } // run preformat processors final int hostStartOffset = myAltFullRange.getStartOffset(); myEditor.getCaretModel().moveToOffset(hostStartOffset); for (CopyPastePreProcessor preProcessor : Extensions.getExtensions(CopyPastePreProcessor.EP_NAME)) { newText = preProcessor.preprocessOnPaste(myProject, origPsiFile, myEditor, newText, null); } myOrigDocument.replaceString(hostStartOffset, myAltFullRange.getEndOffset(), newText); // replace temp strings for guarded blocks for (String tempText : replacementMap.keySet()) { int idx = CharArrayUtil.indexOf( myOrigDocument.getCharsSequence(), tempText, hostStartOffset, myAltFullRange.getEndOffset()); myOrigDocument.replaceString(idx, idx + tempText.length(), replacementMap.get(tempText)); } // JAVA: fix occasional char literal concatenation fixDocumentQuotes(myOrigDocument, hostStartOffset - 1); fixDocumentQuotes(myOrigDocument, myAltFullRange.getEndOffset()); // reformat PsiDocumentManager.getInstance(myProject).commitDocument(myOrigDocument); Runnable task = () -> { try { CodeStyleManager.getInstance(myProject) .reformatRange(origPsiFile, hostStartOffset, myAltFullRange.getEndOffset(), true); } catch (IncorrectOperationException e1) { // LOG.error(e); } }; DocumentUtil.executeInBulk(myOrigDocument, true, task); PsiElement newInjected = InjectedLanguageManager.getInstance(myProject) .findInjectedElementAt(origPsiFile, hostStartOffset); DocumentWindow documentWindow = newInjected == null ? null : InjectedLanguageUtil.getDocumentWindow(newInjected); if (documentWindow != null) { myEditor.getCaretModel().moveToOffset(documentWindow.injectedToHost(e.getOffset())); myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); } }
public long getHttpTimeout() { initServers(); final String timeout = myConfigFile.getDefaultGroup().getTimeout(); try { return Long.parseLong(timeout) * 1000; } catch (NumberFormatException e) { return 0; } }
@SuppressWarnings({"HardCodedStringLiteral"}) public void readExternal(Element element) throws InvalidDataException { DefaultJDOMExternalizer.readExternal(this, element); List elems = element.getChildren("addpath"); LOG.debug(elems.toString()); ADD_PATHS = new String[elems.size()]; for (int i = 0; i < elems.size(); i++) { Element elem = (Element) elems.get(i); ADD_PATHS[i] = elem.getAttributeValue("path"); } Element configurationDirectory = element.getChild("configuration"); if (configurationDirectory != null) { myConfigurationDirectory = configurationDirectory.getText(); Attribute defaultAttr = configurationDirectory.getAttribute("useDefault"); try { myIsUseDefaultConfiguration = defaultAttr != null && defaultAttr.getBooleanValue(); } catch (DataConversionException e) { myIsUseDefaultConfiguration = false; } } else { myIsUseDefaultConfiguration = true; } // compatibility: this setting was moved from .iws to global settings List urls = element.getChildren("checkoutURL"); for (Object url1 : urls) { Element child = (Element) url1; String url = child.getText(); if (url != null) { SvnApplicationSettings.getInstance().addCheckoutURL(url); } } myIsKeepLocks = element.getChild("keepLocks") != null; myRemoteStatus = element.getChild("remoteStatus") != null; myUpgradeMode = element.getChild("upgradeMode") != null ? element.getChild("upgradeMode").getText() : null; final Element useProxy = element.getChild("myIsUseDefaultProxy"); if (useProxy == null) { myIsUseDefaultProxy = false; } else { myIsUseDefaultProxy = Boolean.parseBoolean(useProxy.getText()); } final Element supportedVersion = element.getChild("supportedVersion"); if (supportedVersion != null) { try { mySupportOptions = new SvnSupportOptions(Long.parseLong(supportedVersion.getText().trim())); } catch (NumberFormatException e) { mySupportOptions = new SvnSupportOptions(null); } } final Attribute maxAnnotateRevisions = element.getAttribute("maxAnnotateRevisions"); if (maxAnnotateRevisions != null) { try { myMaxAnnotateRevisions = maxAnnotateRevisions.getIntValue(); } catch (DataConversionException e) { // } final Attribute acceleration = element.getAttribute("myUseAcceleration"); if (acceleration != null) { try { myUseAcceleration = UseAcceleration.valueOf(acceleration.getValue()); } catch (IllegalArgumentException e) { // } } } final Attribute autoUpdateAfterCommit = element.getAttribute("myAutoUpdateAfterCommit"); if (autoUpdateAfterCommit != null) { myAutoUpdateAfterCommit = Boolean.parseBoolean(autoUpdateAfterCommit.getValue()); } final Attribute cleanupRun = element.getAttribute(CLEANUP_ON_START_RUN); if (cleanupRun != null) { myCleanupRun = Boolean.parseBoolean(cleanupRun.getValue()); } final Attribute treeConflictMergeNewFilesPlace = element.getAttribute("TREE_CONFLICT_MERGE_THEIRS_NEW_INTO_OLD_PLACE"); final Attribute protocols = element.getAttribute("SSL_PROTOCOLS"); if (protocols != null) { try { SSL_PROTOCOLS = SSLProtocols.valueOf(protocols.getValue()); } catch (IllegalArgumentException e) { // } } if (treeConflictMergeNewFilesPlace != null) { TREE_CONFLICT_MERGE_THEIRS_NEW_INTO_OLD_PLACE = Boolean.parseBoolean(treeConflictMergeNewFilesPlace.getValue()); } }
private String getTimeStamp() { if (!myFile.isValid()) return ""; return Long.toString(myFile.getTimeStamp()); }