当前位置: 首页>>代码示例>>Java>>正文


Java CatchingConsumer类代码示例

本文整理汇总了Java中com.intellij.util.CatchingConsumer的典型用法代码示例。如果您正苦于以下问题:Java CatchingConsumer类的具体用法?Java CatchingConsumer怎么用?Java CatchingConsumer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CatchingConsumer类属于com.intellij.util包,在下文中一共展示了CatchingConsumer类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fetchPackageDetails

import com.intellij.util.CatchingConsumer; //导入依赖的package包/类
public static void fetchPackageDetails(@NotNull final String packageName, @NotNull final CatchingConsumer<String, Exception> consumer) {
  ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
    @Override
    public void run() {
      try {
        final String details = loadPackageDetails(packageName);
        consumer.consume(formatDetails(packageName, details));
      }
      catch (ExecutionException e) {
        consumer.consume(e);
      }
    }
  });
}
 
开发者ID:ktisha,项目名称:TheRPlugin,代码行数:15,代码来源:TheRPackagesUtil.java

示例2: valueChanged

import com.intellij.util.CatchingConsumer; //导入依赖的package包/类
@Override
public void valueChanged(ListSelectionEvent event) {
  myOptionsCheckBox.setEnabled(myPackages.getSelectedIndex() >= 0);
  myVersionCheckBox.setEnabled(myPackages.getSelectedIndex() >= 0);
  myOptionsCheckBox.setSelected(false);
  myVersionCheckBox.setSelected(false);
  myVersionComboBox.setEnabled(false);
  myOptionsField.setEnabled(false);
  myDescriptionTextArea.setText("<html><body style='text-align: center;padding-top:20px;'>Loading...</body></html>");
  final Object pyPackage = myPackages.getSelectedValue();
  if (pyPackage instanceof RepoPackage) {
    final String packageName = ((RepoPackage)pyPackage).getName();
    mySelectedPackageName = packageName;
    myVersionComboBox.removeAllItems();
    if (myVersionCheckBox.isEnabled()) {
      myController.fetchPackageVersions(packageName, new CatchingConsumer<List<String>, Exception>() {
        @Override
        public void consume(final List<String> releases) {
          ApplicationManager.getApplication().invokeLater(new Runnable() {
            @Override
            public void run() {
              if (myPackages.getSelectedValue() == pyPackage) {
                myVersionComboBox.removeAllItems();
                for (String release : releases) {
                  myVersionComboBox.addItem(release);
                }
              }
            }
          }, ModalityState.any());
        }

        @Override
        public void consume(Exception e) {
          LOG.info("Error retrieving releases", e);
        }
      });
    }
    myInstallButton.setEnabled(!myCurrentlyInstalling.contains(packageName));

    myController.fetchPackageDetails(packageName, new CatchingConsumer<String, Exception>() {
      @Override
      public void consume(final String details) {
        UIUtil.invokeLaterIfNeeded(new Runnable() {
          @Override
          public void run() {
            if (myPackages.getSelectedValue() == pyPackage) {
              myDescriptionTextArea.setText(details);
              myDescriptionTextArea.setCaretPosition(0);
            }/* else {
               do nothing, because other package gets selected
            }*/
          }
        });
      }

      @Override
      public void consume(Exception exception) {
        myDescriptionTextArea.setText("No information available");
        LOG.info("Error retrieving package details", exception);
      }
    });
  }
  else {
    myInstallButton.setEnabled(false);
    myDescriptionTextArea.setText("");
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:68,代码来源:ManagePackagesDialog.java

示例3: setLatestVersionsForInstalledPackages

import com.intellij.util.CatchingConsumer; //导入依赖的package包/类
private void setLatestVersionsForInstalledPackages() {
  final PackageManagementServiceEx serviceEx = getServiceEx();
  if (serviceEx == null) {
    return;
  }
  int packageCount = myPackagesTableModel.getRowCount();
  if (packageCount == 0) {
    onUpdateFinished();
  }
  final AtomicInteger inProgressPackageCount = new AtomicInteger(packageCount);
  for (int i = 0; i < packageCount; ++i) {
    final int finalIndex = i;
    final InstalledPackage pkg = getInstalledPackageAt(finalIndex);
    serviceEx.fetchLatestVersion(pkg, new CatchingConsumer<String, Exception>() {

      private void decrement() {
        if (inProgressPackageCount.decrementAndGet() == 0) {
          onUpdateFinished();
        }
      }

      @Override
      public void consume(Exception e) {
        UIUtil.invokeLaterIfNeeded(new Runnable() {
          @Override
          public void run() {
            decrement();
          }
        });
      }

      @Override
      public void consume(@Nullable final String latestVersion) {
        UIUtil.invokeLaterIfNeeded(new Runnable() {
          @Override
          public void run() {
            if (finalIndex < myPackagesTableModel.getRowCount()) {
              InstalledPackage p = getInstalledPackageAt(finalIndex);
              if (pkg == p) {
                myPackagesTableModel.setValueAt(latestVersion, finalIndex, 2);
              }
            }
            decrement();
          }
        });
      }
    });
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:50,代码来源:InstalledPackagesPanel.java

示例4: fetchPackageVersions

import com.intellij.util.CatchingConsumer; //导入依赖的package包/类
@Override
public void fetchPackageVersions(String packageName, CatchingConsumer<List<String>, Exception> consumer) {
  final List<String> versions = PyCondaPackageService.getInstance().getPackageVersions(packageName);
  Collections.sort(versions, Collections.reverseOrder(new PackageVersionComparator()));
  consumer.consume(versions);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:PyCondaManagementService.java

示例5: fetchPackageVersions

import com.intellij.util.CatchingConsumer; //导入依赖的package包/类
@Override
public void fetchPackageVersions(String s, CatchingConsumer<List<String>, Exception> consumer) {
  consumer.consume(ContainerUtil.<String>emptyList());
}
 
开发者ID:ktisha,项目名称:TheRPlugin,代码行数:5,代码来源:TheRPackageManagementService.java

示例6: fetchPackageDetails

import com.intellij.util.CatchingConsumer; //导入依赖的package包/类
@Override
public void fetchPackageDetails(String packageName, CatchingConsumer<String, Exception> consumer) {
  TheRPackagesUtil.fetchPackageDetails(packageName, consumer);
}
 
开发者ID:ktisha,项目名称:TheRPlugin,代码行数:5,代码来源:TheRPackageManagementService.java

示例7: valueChanged

import com.intellij.util.CatchingConsumer; //导入依赖的package包/类
@Override
public void valueChanged(ListSelectionEvent event) {
  myOptionsCheckBox.setEnabled(myPackages.getSelectedIndex() >= 0);
  myVersionCheckBox.setEnabled(myPackages.getSelectedIndex() >= 0);
  myOptionsCheckBox.setSelected(false);
  myVersionCheckBox.setSelected(false);
  myVersionComboBox.setEnabled(false);
  myOptionsField.setEnabled(false);
  myDescriptionTextArea.setText("<html><body style='text-align: center;padding-top:20px;'>Loading...</body></html>");
  final Object pyPackage = myPackages.getSelectedValue();
  if (pyPackage instanceof RepoPackage) {
    final String packageName = ((RepoPackage)pyPackage).getName();
    mySelectedPackageName = packageName;
    myVersionComboBox.removeAllItems();
    if (myVersionCheckBox.isEnabled()) {
      myController.fetchPackageVersions(packageName, new CatchingConsumer<List<String>, Exception>() {
        @Override
        public void consume(final List<String> releases) {
          ApplicationManager.getApplication().invokeLater(() -> {
            if (myPackages.getSelectedValue() == pyPackage) {
              myVersionComboBox.removeAllItems();
              for (String release : releases) {
                myVersionComboBox.addItem(release);
              }
            }
          }, ModalityState.any());
        }

        @Override
        public void consume(Exception e) {
          LOG.info("Error retrieving releases", e);
        }
      });
    }
    myInstallButton.setEnabled(!myCurrentlyInstalling.contains(packageName));

    myController.fetchPackageDetails(packageName, new CatchingConsumer<String, Exception>() {
      @Override
      public void consume(final String details) {
        UIUtil.invokeLaterIfNeeded(() -> {
          if (myPackages.getSelectedValue() == pyPackage) {
            myDescriptionTextArea.setText(details);
            myDescriptionTextArea.setCaretPosition(0);
          }/* else {
             do nothing, because other package gets selected
          }*/
        });
      }

      @Override
      public void consume(Exception exception) {
        UIUtil.invokeLaterIfNeeded(() -> myDescriptionTextArea.setText("No information available"));
        LOG.info("Error retrieving package details", exception);
      }
    });
  }
  else {
    myInstallButton.setEnabled(false);
    myDescriptionTextArea.setText("");
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:62,代码来源:ManagePackagesDialog.java

示例8: setLatestVersionsForInstalledPackages

import com.intellij.util.CatchingConsumer; //导入依赖的package包/类
private void setLatestVersionsForInstalledPackages() {
  final PackageManagementServiceEx serviceEx = getServiceEx();
  if (serviceEx == null) {
    return;
  }
  int packageCount = myPackagesTableModel.getRowCount();
  if (packageCount == 0) {
    onUpdateFinished();
  }
  final AtomicInteger inProgressPackageCount = new AtomicInteger(packageCount);
  for (int i = 0; i < packageCount; ++i) {
    final int finalIndex = i;
    final InstalledPackage pkg = getInstalledPackageAt(finalIndex);
    serviceEx.fetchLatestVersion(pkg, new CatchingConsumer<String, Exception>() {

      private void decrement() {
        if (inProgressPackageCount.decrementAndGet() == 0) {
          onUpdateFinished();
        }
      }

      @Override
      public void consume(Exception e) {
        UIUtil.invokeLaterIfNeeded(() -> decrement());
      }

      @Override
      public void consume(@Nullable final String latestVersion) {
        UIUtil.invokeLaterIfNeeded(() -> {
          if (finalIndex < myPackagesTableModel.getRowCount()) {
            InstalledPackage p = getInstalledPackageAt(finalIndex);
            if (pkg == p) {
              myPackagesTableModel.setValueAt(latestVersion, finalIndex, 2);
            }
          }
          decrement();
        });
      }
    });
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:42,代码来源:InstalledPackagesPanel.java

示例9: fetchPackageVersions

import com.intellij.util.CatchingConsumer; //导入依赖的package包/类
public abstract void fetchPackageVersions(String packageName, CatchingConsumer<List<String>, Exception> consumer); 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:2,代码来源:PackageManagementService.java

示例10: fetchPackageDetails

import com.intellij.util.CatchingConsumer; //导入依赖的package包/类
public abstract void fetchPackageDetails(String packageName, CatchingConsumer<String, Exception> consumer); 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:2,代码来源:PackageManagementService.java

示例11: fetchLatestVersion

import com.intellij.util.CatchingConsumer; //导入依赖的package包/类
public abstract void fetchLatestVersion(@NotNull InstalledPackage pkg, @NotNull final CatchingConsumer<String, Exception> consumer); 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:2,代码来源:PackageManagementServiceEx.java

示例12: fetchLatestVersion

import com.intellij.util.CatchingConsumer; //导入依赖的package包/类
public abstract void fetchLatestVersion(@Nonnull InstalledPackage pkg, @Nonnull final CatchingConsumer<String, Exception> consumer); 
开发者ID:consulo,项目名称:consulo,代码行数:2,代码来源:PackageManagementServiceEx.java


注:本文中的com.intellij.util.CatchingConsumer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。