@NotNull @Override public Collection<? extends Configurable> createConfigurables(@NotNull DebuggerSettingsCategory category) { Getter<DebuggerSettings> settingsGetter = new Getter<DebuggerSettings>() { @Override public DebuggerSettings get() { return DebuggerSettings.getInstance(); } }; switch (category) { case GENERAL: return singletonList(SimpleConfigurable.create("reference.idesettings.debugger.launching", OptionsBundle.message("options.java.display.name"), DebuggerLaunchingConfigurable.class, settingsGetter)); case DATA_VIEWS: return createDataViewsConfigurable(); case STEPPING: return singletonList(SimpleConfigurable.create("reference.idesettings.debugger.stepping", OptionsBundle.message("options.java.display.name"), DebuggerSteppingConfigurable.class, settingsGetter)); case HOTSWAP: return singletonList(SimpleConfigurable.create("reference.idesettings.debugger.hotswap", OptionsBundle.message("options.java.display.name"), JavaHotSwapConfigurableUi.class, settingsGetter)); } return Collections.emptyList(); }
public static void setApplication(@NotNull Application instance, @NotNull Getter<FileTypeRegistry> fileTypeRegistryGetter, @NotNull Disposable parent) { final Application old = ourApplication; final Getter<FileTypeRegistry> oldFileTypeRegistry = FileTypeRegistry.ourInstanceGetter; Disposer.register(parent, new Disposable() { @Override public void dispose() { if (old != null) { // to prevent NPEs in threads still running setApplication(old); //noinspection AssignmentToStaticFieldFromInstanceMethod FileTypeRegistry.ourInstanceGetter = oldFileTypeRegistry; } } }); setApplication(instance); FileTypeRegistry.ourInstanceGetter = fileTypeRegistryGetter; }
public void prefferedSizeByContents(final int maximumLines) { if (getEditor1() == null && getEditor2() == null) return; if (getEditor1() != null) { getEditor1().getSettings().setAdditionalLinesCount(0); getEditor1().getSettings().setAdditionalPageAtBottom(false); } if (getEditor2() != null) { getEditor2().getSettings().setAdditionalLinesCount(0); getEditor2().getSettings().setAdditionalPageAtBottom(false); } myPanel.setPrefferedWidth(20); myPanel.setPreferredHeightGetter(new Getter<Integer>() { @Override public Integer get() { final int size1 = getEditor1() == null ? 10 : getEditor1().getComponent().getPreferredSize().height; final int size2 = getEditor2() == null ? 10 : getEditor2().getComponent().getPreferredSize().height; final int lineHeight = getEditor1() == null ? getEditor2().getLineHeight() : getEditor1().getLineHeight(); final int size = Math.max(size1, size2); if (maximumLines > 0) { return Math.min(size, maximumLines * lineHeight); } return size; } }); }
public DiffPanelOuterComponent(List<TextDiffType> diffTypes, @Nullable DiffRequest.ToolbarAddons toolbarAddons) { super(new BorderLayout()); myStatusBar = new DiffStatusBar(diffTypes); myBottomContainer = new JPanel(new BorderLayout()); myBottomContainer.add(myStatusBar, BorderLayout.SOUTH); add(myBottomContainer, BorderLayout.SOUTH); myDefaultActions = toolbarAddons; myToolbar = new DiffToolbarComponent(this); disableToolbar(false); myWrapper = new JPanel(new BorderLayout()); add(myWrapper, BorderLayout.CENTER); myDefaultHeight = new Getter<Integer>() { @Override public Integer get() { return 400; } }; myPreferredHeightGetter = myDefaultHeight; myPrefferedWidth = 600; }
public BackgroundTaskQueue(@Nullable final Project project, @NotNull String title, final Boolean forcedHeadlessMode) { myMonitor = Boolean.TRUE.equals(Boolean.getBoolean(ourMonitorFlag)) ? new BackgroundTasksMonitor(title) : new PlusMinus.Empty<String>(); final boolean headless = forcedHeadlessMode != null ? forcedHeadlessMode : ApplicationManager.getApplication().isHeadlessEnvironment(); final QueueProcessor.ThreadToUse threadToUse = headless ? QueueProcessor.ThreadToUse.POOLED : QueueProcessor.ThreadToUse.AWT; final PairConsumer<Pair<Task.Backgroundable, Getter<ProgressIndicator>>, Runnable> consumer = headless ? new BackgroundableHeadlessRunner() : new BackgroundableUnderProgressRunner(title, project, myMonitor); myProcessor = new QueueProcessor<Pair<Task.Backgroundable, Getter<ProgressIndicator>>>(consumer, true, threadToUse, new Condition<Object>() { @Override public boolean value(Object o) { if (project == null) return ApplicationManager.getApplication().isDisposed(); if (project.isDefault()) { return project.isDisposed(); } else { return !ApplicationManager.getApplication().isUnitTestMode() && !project.isOpen() || project.isDisposed(); } } }); }
public StepIntersection(Convertor<Data, TextRange> dataConvertor, Convertor<Area, TextRange> areasConvertor, final List<Area> areas, Getter<String> debugDocumentTextGetter) { myAreas = areas; myDebugDocumentTextGetter = debugDocumentTextGetter; myAreaIndex = 0; myDataConvertor = dataConvertor; myAreasConvertor = areasConvertor; myHackSearch = new HackSearch<Data, Area, TextRange>(myDataConvertor, myAreasConvertor, new Comparator<TextRange>() { @Override public int compare(TextRange o1, TextRange o2) { return o1.intersects(o2) ? 0 : o1.getStartOffset() < o2.getStartOffset() ? -1 : 1; } }); }
@Override public boolean hasAliveKey(boolean purgeDead) { boolean hasAliveInterval = false; for (int i = intervals.size() - 1; i >= 0; i--) { Getter<E> interval = intervals.get(i); if (interval.get() != null) { hasAliveInterval = true; if (purgeDead) { continue; } else { break; } } if (purgeDead) { myIntervalTree.assertUnderWriteLock(); removeIntervalInternal(i); } } return hasAliveInterval; }
private void showErrorsImpl(final boolean isEmpty, final Getter<VcsException> firstGetter, @NotNull final String tabDisplayName, final Consumer<VcsErrorViewPanel> viewFiller) { if (ApplicationManager.getApplication().isUnitTestMode()) { if (!isEmpty) { VcsException exception = firstGetter.get(); if (!handleCustom(exception)) { throw new RuntimeException(exception); } } return; } ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { if (myProject.isDisposed()) return; if (isEmpty) { removeContents(null, tabDisplayName); return; } final VcsErrorViewPanel errorTreeView = new VcsErrorViewPanel(myProject); openMessagesView(errorTreeView, tabDisplayName); viewFiller.consume(errorTreeView); } }); }
public ControlledCycle(final Project project, final Getter<Boolean> callback, @NotNull final String name, final int refreshInterval) { myRefreshInterval = (refreshInterval <= 0) ? ourRefreshInterval : refreshInterval; myActive = new AtomicBoolean(false); myRunnable = new Runnable() { boolean shouldBeContinued = true; public void run() { if (! myActive.get() || project.isDisposed()) return; try { shouldBeContinued = callback.get(); } catch (ProcessCanceledException e) { return; } catch (RuntimeException e) { LOG.info(e); } if (! shouldBeContinued) { myActive.set(false); } else { mySimpleAlarm.addRequest(myRunnable, myRefreshInterval); } } }; mySimpleAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, project); }
public UpdateRequestsQueue(final Project project, final AtomicReference<ScheduledExecutorService> executor, final Runnable delegate) { myProject = project; myExecutor = executor; myTrackHeavyLatch = Boolean.parseBoolean(System.getProperty(ourHeavyLatchOptimization)); myDelegate = delegate; myPlVcsManager = ProjectLevelVcsManager.getInstance(myProject); myStartupManager = StartupManager.getInstance(myProject); myLock = new Object(); myWaitingUpdateCompletionQueue = new ArrayList<Runnable>(); // not initialized myStarted = false; myStopped = false; myIsStoppedGetter = new Getter<Boolean>() { @Override public Boolean get() { return isStopped(); } }; }
private void setTodoHighlighting(final Document oldDocument, final Document document) { final ContentRevisionCache cache = ProjectLevelVcsManager.getInstance(myProject).getContentRevisionCache(); final List<Pair<TextRange,TextAttributes>> beforeTodoRanges = myBeforeNumber == null ? Collections.<Pair<TextRange,TextAttributes>>emptyList() : new TodoForBaseRevision(myProject, getBeforeFragments(), 1, myFileName, oldDocument.getText(), true, myFileType, new Getter<Object>() { @Override public Object get() { return cache.getCustom(myFilePath, myBeforeNumber); } }, new Consumer<Object>() { @Override public void consume(Object items) { cache.putCustom(myFilePath, myBeforeNumber, items); } }).execute(); final List<Pair<TextRange, TextAttributes>> afterTodoRanges = new TodoForExistingFile(myProject, getAfterFragments(), 1, myFileName, document.getText(), false, myFileType, myFile).execute(); setBeforeTodoRanges(beforeTodoRanges); setAfterTodoRanges(afterTodoRanges); }
public Result apply(final VirtualFile fileToPatch, final ApplyPatchContext context, final Project project, FilePath pathBeforeRename, Getter<CharSequence> baseContents, CommitContext commitContext) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("apply patch called for : " + fileToPatch.getPath()); } if (myPatch.isNewFile()) { applyCreate(project, fileToPatch, commitContext); } else if (myPatch.isDeletedFile()) { FileEditorManager.getInstance(project).closeFile(fileToPatch); fileToPatch.delete(this); } else { return applyChange(project, fileToPatch, pathBeforeRename, baseContents); } return SUCCESS; }
protected Result applyChange(Project project, final VirtualFile fileToPatch, FilePath pathBeforeRename, Getter<CharSequence> baseContents) throws IOException { try { ContentRevision contentRevision = myPatch.getShelvedBinaryFile().createChange(project).getAfterRevision(); if (contentRevision != null) { assert (contentRevision instanceof ShelvedBinaryContentRevision); byte[] binaryContent = ((ShelvedBinaryContentRevision)contentRevision).getBinaryContent(); //it may be new empty binary file fileToPatch.setBinaryContent(binaryContent != null ? binaryContent : ArrayUtil.EMPTY_BYTE_ARRAY); } } catch (VcsException e) { LOG.error("Couldn't apply shelved binary patch", e); return new Result(ApplyPatchStatus.FAILURE) { @Override public ApplyPatchForBaseRevisionTexts getMergeData() { return null; } }; } return SUCCESS; }
@Override public ExecutionResult execute(Executor executor, CommandLinePatcher... patchers) throws ExecutionException { final ProcessHandler processHandler = startProcess(patchers); final ConsoleView console = createAndAttachConsole(myConfiguration.getProject(), processHandler, executor); List<AnAction> actions = Lists .newArrayList(createActions(console, processHandler)); DefaultExecutionResult executionResult = new DefaultExecutionResult(console, processHandler, actions.toArray(new AnAction[actions.size()])); PyRerunFailedTestsAction rerunFailedTestsAction = new PyRerunFailedTestsAction(console); if (console instanceof SMTRunnerConsoleView) { rerunFailedTestsAction.init(((BaseTestsOutputConsoleView)console).getProperties()); rerunFailedTestsAction.setModelProvider(new Getter<TestFrameworkRunningModel>() { @Override public TestFrameworkRunningModel get() { return ((SMTRunnerConsoleView)console).getResultsViewer(); } }); } executionResult.setRestartActions(rerunFailedTestsAction, new ToggleAutoTestAction()); return executionResult; }
@Override public boolean isStorePlainTextPasswords(final String realm, SVNAuthentication auth) throws SVNException { if (USERNAME.equals(auth.getKind())) return true; final boolean superValue = super.isStorePlainTextPasswords(realm, auth); final boolean value = mySavePermissions.allowed() || superValue; if ((! value) && (! mySavePermissions.have())) { promptAndSaveWhenWeLackEncryption(realm, auth, new Getter<Boolean>() { @Override public Boolean get() { return myInteraction.promptForPlaintextPasswordSaving(myUrl, realm); } }); } return value; }
@Nullable public SVNAuthentication requestCredentials(final SVNURL repositoryUrl, final String type) { SVNAuthentication authentication = null; if (repositoryUrl != null) { final String realm = repositoryUrl.toDecodedString(); authentication = requestCredentials(realm, type, new Getter<SVNAuthentication>() { @Override public SVNAuthentication get() { return myVcs.getSvnConfiguration().getInteractiveManager(myVcs).getInnerProvider() .requestClientAuthentication(type, repositoryUrl, realm, null, null, true); } }); } if (authentication == null) { LOG.warn("Could not get authentication. Type - " + type + ", Url - " + repositoryUrl); } return authentication; }
/** * For every #createMockApplication there needs to be a corresponding call to * #disposeMockApplication when the test is complete. */ public static Disposable createMockApplication() { Disposable parentDisposable = getParentDisposableForCleanup(); final PluginMockApplication instance = new PluginMockApplication(parentDisposable); ApplicationManager.setApplication( instance, new Getter<FileTypeRegistry>() { @Override public FileTypeRegistry get() { return FileTypeManager.getInstance(); } }, parentDisposable); instance.registerService(EncodingManager.class, EncodingManagerImpl.class); return parentDisposable; }
public static void setApplication(@NotNull Application instance, @NotNull Getter<FileTypeRegistry> fileTypeRegistryGetter, @NotNull Getter<EncodingRegistry> encodingRegistryGetter, @NotNull Disposable parent) { final Application old = ourApplication; final Getter<FileTypeRegistry> oldFileTypeRegistry = FileTypeRegistry.ourInstanceGetter; final Getter<EncodingRegistry> oldEncodingRegistry = EncodingRegistry.ourInstanceGetter; Disposer.register(parent, new Disposable() { @Override public void dispose() { if (old != null) { // to prevent NPEs in threads still running setApplication(old); //noinspection AssignmentToStaticFieldFromInstanceMethod FileTypeRegistry.ourInstanceGetter = oldFileTypeRegistry; //noinspection AssignmentToStaticFieldFromInstanceMethod EncodingRegistry.ourInstanceGetter = oldEncodingRegistry; } } }); setApplication(instance); FileTypeRegistry.ourInstanceGetter = fileTypeRegistryGetter; EncodingRegistry.ourInstanceGetter = encodingRegistryGetter; }
public void initApplication() { //if (ApplicationManager.getApplication() instanceof MockApplicationEx) return; final MockApplicationEx instance = new MockApplicationEx(getTestRootDisposable()); ApplicationManager.setApplication(instance, new Getter<FileTypeRegistry>() { @Override public FileTypeRegistry get() { return FileTypeManager.getInstance(); } }, new Getter<EncodingRegistry>() { @Override public EncodingRegistry get() { return EncodingManager.getInstance(); } }, getTestRootDisposable()); getApplication().registerService(EncodingManager.class, EncodingManagerImpl.class); }
public Result apply(final VirtualFile fileToPatch, final ApplyPatchContext context, final Project project, FilePath pathBeforeRename, Getter<CharSequence> baseContents, CommitContext commitContext) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("apply patch called for : " + fileToPatch.getPath()); } context.addAffectedFile(getTarget(fileToPatch)); if (myPatch.isNewFile()) { applyCreate(fileToPatch, commitContext); } else if (myPatch.isDeletedFile()) { FileEditorManagerImpl.getInstance(project).closeFile(fileToPatch); fileToPatch.delete(this); } else { return applyChange(project, fileToPatch, pathBeforeRename, baseContents); } return SUCCESS; }
public ShowHistoryAction(final Getter<JTextComponent> textField, EditorSearchComponent editorSearchComponent) { super(editorSearchComponent); myTextField = textField; getTemplatePresentation().setIcon(AllIcons.Actions.Search); final String s = getTextField() == getEditorSearchComponent().getSearchField() ? "Search" : "Replace"; getTemplatePresentation().setDescription(s + " history"); getTemplatePresentation().setText(s + " History"); ArrayList<Shortcut> shortcuts = new ArrayList<Shortcut>(); if (getTextField() == getEditorSearchComponent().getSearchField()) { //ContainerUtil.addAll(shortcuts, ActionManager.getInstance().getAction(IdeActions.ACTION_FIND).getShortcutSet().getShortcuts()); ContainerUtil.addAll(shortcuts, ActionManager.getInstance().getAction("IncrementalSearch").getShortcutSet().getShortcuts()); } shortcuts.add(new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_DOWN_MASK), null)); registerCustomShortcutSet(new CustomShortcutSet(shortcuts.toArray(new Shortcut[shortcuts.size()])), getTextField()); }
public static SVNStatus convert(final String path, Status status, final Convertor<String, SVNInfo> infoGetter) throws SVNException { // no locks return new PortableStatus(createUrl(status.getUrl()), new File(path), NodeKindConvertor.convert(status.getNodeKind()), RevisionConvertor.convert(status.getRevision()), RevisionConvertor.convert(status.getLastChangedRevision()), status.getLastChangedDate(), status.getLastCommitAuthor(), convert(status.getTextStatus()), convert(status.getPropStatus()), convert(status.getRepositoryTextStatus()), convert(status.getRepositoryPropStatus()), status.isLocked(), status.isCopied(), status.isSwitched(), status.isFileExternal(), null, null, null, status.getChangelist(), WorkingCopyFormat.ONE_DOT_SEVEN.getFormat(), status.isConflicted(), new Getter<SVNInfo>() { @Override public SVNInfo get() { return infoGetter.convert(path); } }); }
private static boolean processFieldOrProperty(@NotNull DotNetTypeProxy proxy, @Nullable Getter<DotNetObjectValueProxy> objectValueMirrorGetter, @NotNull Processor<DotNetFieldOrPropertyProxy> processor) { DotNetFieldOrPropertyProxy[] fieldMirrors = DotNetDebuggerSearchUtil.getFieldAndProperties(proxy, true); for(DotNetFieldOrPropertyProxy fieldMirror : fieldMirrors) { if(!fieldMirror.isStatic() && objectValueMirrorGetter == null || fieldMirror.isStatic() && objectValueMirrorGetter != null) { continue; } if(isHiddenPropertyOrField(fieldMirror)) { continue; } if(!processor.process(fieldMirror)) { return false; } } return true; }
private void showErrorsImpl(final boolean isEmpty, final Getter<VcsException> firstGetter, @Nonnull final String tabDisplayName, final Consumer<VcsErrorViewPanel> viewFiller) { if (ApplicationManager.getApplication().isUnitTestMode()) { if (!isEmpty) { VcsException exception = firstGetter.get(); if (!handleCustom(exception)) { throw new RuntimeException(exception); } } return; } ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { if (myProject.isDisposed()) return; if (isEmpty) { removeContents(null, tabDisplayName); return; } final VcsErrorViewPanel errorTreeView = new VcsErrorViewPanel(myProject); openMessagesView(errorTreeView, tabDisplayName); viewFiller.consume(errorTreeView); } }); }
public ControlledCycle(final Project project, final Getter<Boolean> callback, @Nonnull final String name, final int refreshInterval) { myRefreshInterval = (refreshInterval <= 0) ? ourRefreshInterval : refreshInterval; myActive = new AtomicBoolean(false); myRunnable = new Runnable() { boolean shouldBeContinued = true; @Override public void run() { if (! myActive.get() || project.isDisposed()) return; try { shouldBeContinued = callback.get(); } catch (ProcessCanceledException e) { return; } catch (RuntimeException e) { LOG.info(e); } if (! shouldBeContinued) { myActive.set(false); } else { mySimpleAlarm.addRequest(myRunnable, myRefreshInterval); } } }; mySimpleAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, project); }
@Nonnull private LazyRefreshingSelfQueue<String> getQueue(final VcsRoot vcsRoot) { synchronized (myLock) { LazyRefreshingSelfQueue<String> queue = myRefreshingQueues.get(vcsRoot); if (queue != null) return queue; queue = new LazyRefreshingSelfQueue<>(new Getter<Long>() { public Long get() { return myVcsConfiguration.CHANGED_ON_SERVER_INTERVAL > 0 ? myVcsConfiguration.CHANGED_ON_SERVER_INTERVAL * 60000 : ourRottenPeriod; } }, new MyShouldUpdateChecker(vcsRoot), new MyUpdater(vcsRoot)); myRefreshingQueues.put(vcsRoot, queue); return queue; } }
public UpdateRequestsQueue(final Project project, @Nonnull ChangeListManagerImpl.Scheduler scheduler, final Runnable delegate) { myProject = project; myScheduler = scheduler; myTrackHeavyLatch = Boolean.parseBoolean(System.getProperty(ourHeavyLatchOptimization)); myDelegate = delegate; myPlVcsManager = ProjectLevelVcsManager.getInstance(myProject); myStartupManager = StartupManager.getInstance(myProject); myLock = new Object(); myWaitingUpdateCompletionQueue = new ArrayList<>(); // not initialized myStarted = false; myStopped = false; myIsStoppedGetter = new Getter<Boolean>() { @Override public Boolean get() { return isStopped(); } }; }