Search in sources :

Example 6 with Convertor

use of com.intellij.util.containers.Convertor in project intellij-community by JetBrains.

the class MergePanel2 method setDiffRequest.

public void setDiffRequest(DiffRequest data) {
    setTitle(data.getWindowTitle());
    disposeMergeList();
    for (int i = 0; i < EDITORS_COUNT; i++) {
        getEditorPlace(i).setDocument(null);
    }
    LOG.assertTrue(!myDuringCreation);
    myDuringCreation = true;
    myProvider.putData(data.getGenericData());
    try {
        myData = data;
        String[] titles = myData.getContentTitles();
        for (int i = 0; i < myEditorsPanels.length; i++) {
            LabeledComponent editorsPanel = myEditorsPanels[i];
            editorsPanel.getLabel().setText(titles[i].isEmpty() ? " " : titles[i]);
        }
        createMergeList();
        data.customizeToolbar(myPanel.resetToolbar());
        myPanel.registerToolbarActions();
        if (data instanceof MergeRequestImpl && myBuilder != null) {
            Convertor<DialogWrapper, Boolean> preOkHook = new Convertor<DialogWrapper, Boolean>() {

                @Override
                public Boolean convert(DialogWrapper dialog) {
                    ChangeCounter counter = ChangeCounter.getOrCreate(myMergeList);
                    int changes = counter.getChangeCounter();
                    int conflicts = counter.getConflictCounter();
                    if (changes == 0 && conflicts == 0)
                        return true;
                    return Messages.showYesNoDialog(dialog.getRootPane(), DiffBundle.message("merge.dialog.apply.partially.resolved.changes.confirmation.message", changes, conflicts), DiffBundle.message("apply.partially.resolved.merge.dialog.title"), Messages.getQuestionIcon()) == Messages.YES;
                }
            };
            ((MergeRequestImpl) data).setActions(myBuilder, this, preOkHook);
        }
    } finally {
        myDuringCreation = false;
    }
}
Also used : MergeRequestImpl(com.intellij.openapi.diff.impl.mergeTool.MergeRequestImpl) ChangeCounter(com.intellij.openapi.diff.impl.incrementalMerge.ChangeCounter) LabeledComponent(com.intellij.openapi.ui.LabeledComponent) DiffDividerPaint(com.intellij.openapi.diff.impl.splitter.DiffDividerPaint) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) Convertor(com.intellij.util.containers.Convertor)

Example 7 with Convertor

use of com.intellij.util.containers.Convertor in project intellij-community by JetBrains.

the class GithubCreatePullRequestWorker method showTargetDialog.

@Nullable
public ForkInfo showTargetDialog() {
    if (myAvailableForks == null) {
        try {
            myAvailableForks = GithubUtil.computeValueInModal(myProject, myCurrentBranch, indicator -> getAvailableForks(indicator));
        } catch (ProcessCanceledException ignore) {
        }
    }
    Convertor<String, ForkInfo> getForkPath = user -> GithubUtil.computeValueInModal(myProject, "Access to GitHub", indicator -> findRepositoryByUser(indicator, user));
    GithubSelectForkDialog dialog = new GithubSelectForkDialog(myProject, myAvailableForks, getForkPath);
    DialogManager.show(dialog);
    if (!dialog.isOK()) {
        return null;
    }
    return dialog.getPath();
}
Also used : Change(com.intellij.openapi.vcs.changes.Change) VirtualFile(com.intellij.openapi.vfs.VirtualFile) GithubApiUtil(org.jetbrains.plugins.github.api.GithubApiUtil) Task(com.intellij.openapi.progress.Task) GitCompareBranchesDialog(git4idea.ui.branch.GitCompareBranchesDialog) GithubRepo(org.jetbrains.plugins.github.api.data.GithubRepo) Logger(com.intellij.openapi.diagnostic.Logger) VcsException(com.intellij.openapi.vcs.VcsException) GitRepository(git4idea.repo.GitRepository) GitCommit(git4idea.GitCommit) Git(git4idea.commands.Git) GithubSelectForkDialog(org.jetbrains.plugins.github.ui.GithubSelectForkDialog) CancellationException(java.util.concurrent.CancellationException) Collection(java.util.Collection) GithubFullPath(org.jetbrains.plugins.github.api.GithubFullPath) GithubPullRequest(org.jetbrains.plugins.github.api.data.GithubPullRequest) GitCommandResult(git4idea.commands.GitCommandResult) GitChangeUtils(git4idea.changes.GitChangeUtils) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) VcsCommitMetadata(com.intellij.vcs.log.VcsCommitMetadata) Nullable(org.jetbrains.annotations.Nullable) GithubOperationCanceledException(org.jetbrains.plugins.github.exceptions.GithubOperationCanceledException) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) List(java.util.List) ServiceManager(com.intellij.openapi.components.ServiceManager) ApplicationManager(com.intellij.openapi.application.ApplicationManager) NotNull(org.jetbrains.annotations.NotNull) Couple(com.intellij.openapi.util.Couple) FutureTask(java.util.concurrent.FutureTask) Callable(java.util.concurrent.Callable) ContainerUtil(com.intellij.util.containers.ContainerUtil) org.jetbrains.plugins.github.util(org.jetbrains.plugins.github.util) ArrayList(java.util.ArrayList) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) GitFetcher(git4idea.update.GitFetcher) GitHistoryUtils(git4idea.history.GitHistoryUtils) Project(com.intellij.openapi.project.Project) DialogManager(git4idea.DialogManager) GitLocalBranch(git4idea.GitLocalBranch) GithubBranch(org.jetbrains.plugins.github.api.data.GithubBranch) GitRemote(git4idea.repo.GitRemote) StringUtil(com.intellij.openapi.util.text.StringUtil) Convertor(com.intellij.util.containers.Convertor) GithubRepoDetailed(org.jetbrains.plugins.github.api.data.GithubRepoDetailed) IOException(java.io.IOException) GitCommitCompareInfo(git4idea.util.GitCommitCompareInfo) ExecutionException(java.util.concurrent.ExecutionException) Pair(com.intellij.openapi.util.Pair) GitFetchResult(git4idea.update.GitFetchResult) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) GithubSelectForkDialog(org.jetbrains.plugins.github.ui.GithubSelectForkDialog) Nullable(org.jetbrains.annotations.Nullable)

Example 8 with Convertor

use of com.intellij.util.containers.Convertor in project android by JetBrains.

the class ApkDiffPanel method createUIComponents.

private void createUIComponents() {
    myTreeModel = new DefaultTreeModel(new LoadingNode());
    myTree = new Tree(myTreeModel);
    myTree.setShowsRootHandles(true);
    // show root node only when showing LoadingNode
    myTree.setRootVisible(true);
    myTree.setPaintBusy(true);
    Convertor<TreePath, String> convertor = new Convertor<TreePath, String>() {

        @Override
        public String convert(TreePath path) {
            ApkEntry e = ApkEntry.fromNode(path.getLastPathComponent());
            if (e == null) {
                return null;
            }
            return e.getPath();
        }
    };
    TreeSpeedSearch treeSpeedSearch = new TreeSpeedSearch(myTree, convertor, true);
    ColumnTreeBuilder builder = new ColumnTreeBuilder(myTree).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("File").setPreferredWidth(600).setHeaderAlignment(SwingConstants.LEADING).setRenderer(new NameRenderer(treeSpeedSearch))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Old Size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.TRAILING).setRenderer(new SizeRenderer(ApkDiffEntry::getOldSize))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("New Size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.TRAILING).setRenderer(new SizeRenderer(ApkDiffEntry::getNewSize))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Diff Size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.TRAILING).setRenderer(new SizeRenderer(ApkEntry::getSize)));
    myColumnTreePane = (JScrollPane) builder.build();
}
Also used : SizeRenderer(com.android.tools.idea.apk.viewer.ApkViewPanel.SizeRenderer) NameRenderer(com.android.tools.idea.apk.viewer.ApkViewPanel.NameRenderer) TreeSpeedSearch(com.intellij.ui.TreeSpeedSearch) LoadingNode(com.intellij.ui.LoadingNode) ApkEntry(com.android.tools.idea.apk.viewer.ApkEntry) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Convertor(com.intellij.util.containers.Convertor) TreePath(javax.swing.tree.TreePath) ColumnTreeBuilder(com.android.tools.adtui.common.ColumnTreeBuilder) Tree(com.intellij.ui.treeStructure.Tree)

Aggregations

Convertor (com.intellij.util.containers.Convertor)8 Pair (com.intellij.openapi.util.Pair)3 TreeSpeedSearch (com.intellij.ui.TreeSpeedSearch)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 Tree (com.intellij.ui.treeStructure.Tree)2 TreePath (javax.swing.tree.TreePath)2 ColumnTreeBuilder (com.android.tools.adtui.common.ColumnTreeBuilder)1 ApkEntry (com.android.tools.idea.apk.viewer.ApkEntry)1 NameRenderer (com.android.tools.idea.apk.viewer.ApkViewPanel.NameRenderer)1 SizeRenderer (com.android.tools.idea.apk.viewer.ApkViewPanel.SizeRenderer)1 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)1 NodeRenderer (com.intellij.ide.util.treeView.NodeRenderer)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 ServiceManager (com.intellij.openapi.components.ServiceManager)1 Logger (com.intellij.openapi.diagnostic.Logger)1 ChangeCounter (com.intellij.openapi.diff.impl.incrementalMerge.ChangeCounter)1 MergeRequestImpl (com.intellij.openapi.diff.impl.mergeTool.MergeRequestImpl)1 DiffDividerPaint (com.intellij.openapi.diff.impl.splitter.DiffDividerPaint)1 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1