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


Java ObjectUtils.tryCast方法代码示例

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


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

示例1: getKeyValue

import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
public static YAMLKeyValue getKeyValue(YAMLFile yamlFile, List<String> key) {
    YAMLDocument document = (YAMLDocument) yamlFile.getDocuments().get(0);
    YAMLMapping mapping = (YAMLMapping) ObjectUtils.tryCast(document.getTopLevelValue(), YAMLMapping.class);
    for (int i = 0; i < key.size(); ++i) {
        if (mapping == null) {
            return null;
        }
        YAMLKeyValue keyValue = null;
        for (YAMLKeyValue each : mapping.getKeyValues()) {
            if (each.getKeyText().equals(key.get(i))) {
                keyValue = each;
                break;
            }
        }

        if (keyValue == null || i + 1 == key.size()) {
            return keyValue;
        }

        mapping = ObjectUtils.tryCast(keyValue.getValue(), YAMLMapping.class);
    }

    throw new IllegalStateException("Should have returned from the loop");
}
 
开发者ID:PioBeat,项目名称:GravSupport,代码行数:25,代码来源:GravYAMLUtils.java

示例2: compute

import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
@SuppressWarnings("Duplicates")
@Nullable
@Override
public Result<String> compute() {
  List<Object> dependencies = new LinkedList<Object>();
  for(JsonFile configFile : findConfigFiles()) {
    dependencies.add(configFile);
    JsonStringLiteral jsonValue = ObjectUtils.tryCast(
        JsonPsiUtil.findPropertyValue(configFile.getTopLevelValue(),"storesDirectory"), JsonStringLiteral.class);
    if(jsonValue == null)
      continue;
    return Result.create(createValue(jsonValue.getValue()), configFile);
  }
  dependencies.add(tracker.getValue());
  return Result.create(createValue(null), dependencies);
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:17,代码来源:StoresDirectoryProvider.java

示例3: getListCellRendererComponent

import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
  list.putClientProperty(SwingUtilities2.AA_TEXT_PROPERTY_KEY, AntialiasingType.getAAHintForSwingComponent());
  Component result = myWrappee.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
  if (!myHandler.getExpandedItems().contains(index)) return result;
  Rectangle bounds = result.getBounds();
  ExpandedItemRendererComponentWrapper wrapper = ExpandedItemRendererComponentWrapper.wrap(result);
  if (UIUtil.getClientProperty(list, ExpandableItemsHandler.EXPANDED_RENDERER) == Boolean.TRUE) {
    JComponent res = ObjectUtils.tryCast(result, JComponent.class);
    if (res != null && UIUtil.getClientProperty(res, ExpandableItemsHandler.USE_RENDERER_BOUNDS) == Boolean.TRUE) {
      Insets insets = wrapper.getInsets();
      bounds.translate(-insets.left, -insets.top);
      bounds.grow(insets.left + insets.right, insets.top + insets.bottom);
      wrapper.setBounds(bounds);
      UIUtil.putClientProperty(wrapper, ExpandableItemsHandler.USE_RENDERER_BOUNDS, true);
    }
  }
  return wrapper;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ExpandedItemListCellRendererWrapper.java

示例4: paintOnComponentUnderViewport

import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
private void paintOnComponentUnderViewport(Component component, Graphics g) {
  JBViewport viewport = ObjectUtils.tryCast(myOwner, JBViewport.class);
  if (viewport == null || viewport.getView() != component || viewport.isPaintingNow()) return;

  // We're painting a component which has a viewport as it's ancestor.
  // As the viewport paints status text, we'll erase it, so we need to schedule a repaint for the viewport with status text's bounds.
  // But it causes flicker, so we paint status text over the component first and then schedule the viewport repaint.

  Rectangle textBoundsInViewport = getTextComponentBound();

  int xInOwner = textBoundsInViewport.x - component.getX();
  int yInOwner = textBoundsInViewport.y - component.getY();
  Rectangle textBoundsInOwner = new Rectangle(xInOwner, yInOwner, textBoundsInViewport.width, textBoundsInViewport.height);
  doPaintStatusText(g, textBoundsInOwner);

  viewport.repaint(textBoundsInViewport);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:StatusText.java

示例5: handleSelect

import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
@Override
public void handleSelect(boolean handleFinalChoices, InputEvent e) {
  final Object selectedValue = getList().getSelectedValue();
  final ActionPopupStep actionPopupStep = ObjectUtils.tryCast(getListStep(), ActionPopupStep.class);

  if (actionPopupStep != null) {
    KeepingPopupOpenAction dontClosePopupAction = getActionByClass(selectedValue, actionPopupStep, KeepingPopupOpenAction.class);
    if (dontClosePopupAction != null) {
      actionPopupStep.performAction((AnAction)dontClosePopupAction, e != null ? e.getModifiers() : 0);
      for (ActionItem item : actionPopupStep.myItems) {
        updateActionItem(item);
      }
      getList().repaint();
      return;
    }
  }

  super.handleSelect(handleFinalChoices, e);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PopupFactoryImpl.java

示例6: handleToggleAction

import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
protected void handleToggleAction() {
  final Object[] selectedValues = getList().getSelectedValues();

  ListPopupStep<Object> listStep = getListStep();
  final ActionPopupStep actionPopupStep = ObjectUtils.tryCast(listStep, ActionPopupStep.class);
  if (actionPopupStep == null) return;

  List<ToggleAction> filtered = ContainerUtil.mapNotNull(selectedValues, new Function<Object, ToggleAction>() {
    @Override
    public ToggleAction fun(Object o) {
      return getActionByClass(o, actionPopupStep, ToggleAction.class);
    }
  });

  for (ToggleAction action : filtered) {
    actionPopupStep.performAction(action, 0);
  }

  for (ActionItem item : actionPopupStep.myItems) {
    updateActionItem(item);
  }

  getList().repaint();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:PopupFactoryImpl.java

示例7: findPackageJsonFile

import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
@Nullable
protected JsonFile findPackageJsonFile() {
  VirtualFile packageVFile = project.getBaseDir().findChild("package.json");
  if (packageVFile == null)
    return null;
  return ObjectUtils.tryCast(PsiManager.getInstance(project).findFile(packageVFile), JsonFile.class);
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:8,代码来源:BaseConfigurationProvider.java

示例8: findMainJsFile

import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
@Nullable
protected JSFile findMainJsFile(@NotNull JsonFile packageJsonFile) {
  final JsonStringLiteralImpl value = ObjectUtils.tryCast(JsonPsiUtil.findPropertyValue(
      packageJsonFile.getTopLevelValue(), "main"), JsonStringLiteralImpl.class);
  if (value == null)
    return null;

  VirtualFile mainJsVFile = packageJsonFile.getVirtualFile().getParent().findFileByRelativePath(value.getValue());
  if (mainJsVFile == null)
    return null;

  return ObjectUtils.tryCast(PsiManager.getInstance(project).findFile(mainJsVFile), JSFile.class);
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:14,代码来源:BaseConfigurationProvider.java

示例9: findConfigFiles

import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
@NotNull
protected JsonFile[] findConfigFiles() {
  VirtualFile configDir = project.getBaseDir().findChild("config");
  if(configDir == null)
    return new JsonFile[0];
  List<JsonFile> files = new LinkedList<JsonFile>();
  PsiManager psiManager = PsiManager.getInstance(project);
  for(VirtualFile file : configDir.getChildren()) {
    JsonFile jsonFile = ObjectUtils.tryCast(psiManager.findFile(file), JsonFile.class);
    if(jsonFile != null)
      files.add(jsonFile);
  }
  return files.toArray(new JsonFile[files.size()]);
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:15,代码来源:BaseConfigurationProvider.java

示例10: findComponentTemplate

import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
@Nullable
public static PsiFile findComponentTemplate(@NotNull final Project project, @NotNull String name) {
  Collection<VirtualFile> virtualFiles =
      FileBasedIndex.getInstance().getContainingFiles(FilenameIndex.NAME, CatberryConstants.CAT_COMPONENT_JSON,
          GlobalSearchScope.allScope(project));
  CatberryProjectConfigurationManager manager = CatberryProjectConfigurationManager.getInstance(project);
  final TemplateEngine engine = manager.getTemplateEngine();
  if(engine == null)
    return null;
  for (VirtualFile virtualFile : virtualFiles) {
    JsonFile psiFile = (JsonFile) PsiManager.getInstance(project).findFile(virtualFile);
    if (psiFile != null) {
      JsonStringLiteralImpl value = ObjectUtils.tryCast(JsonPsiUtil.findPropertyValue(
          psiFile.getTopLevelValue(), "name"), JsonStringLiteralImpl.class);
      if (value == null || !name.equals(value.getValue()))
        continue;

      String template = "./" + CatberryConstants.DEFAULT_TEMPLATE_PREFIX + engine.getExtension();
      value = ObjectUtils.tryCast(JsonPsiUtil.findPropertyValue(
          psiFile.getTopLevelValue(), "template"), JsonStringLiteralImpl.class);
      if (value != null)
        template = value.getValue();

      VirtualFile f = psiFile.getVirtualFile().getParent();
      f = f.findFileByRelativePath(template);
      return f != null ? PsiManager.getInstance(project).findFile(f) : null;
    }
  }
  return null;
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:31,代码来源:CatberryComponentUtils.java

示例11: getApplicationRuntime

import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
protected T getApplicationRuntime(DeploymentNode node) {
  Deployment deployment = getDeployment(node);
  if (deployment == null) {
    return null;
  }
  DeploymentRuntime deploymentRuntime = deployment.getRuntime();
  return ObjectUtils.tryCast(deploymentRuntime, getApplicationRuntimeClass());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ApplicationActionBase.java

示例12: getCustomComponent

import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
private JComponent getCustomComponent(AnAction action) {
  Presentation presentation = myPresentationFactory.getPresentation(action);
  JComponent customComponent = ObjectUtils.tryCast(presentation.getClientProperty(CustomComponentAction.CUSTOM_COMPONENT_PROPERTY), JComponent.class);
  if (customComponent == null) {
    customComponent = ((CustomComponentAction)action).createCustomComponent(presentation);
    presentation.putClientProperty(CustomComponentAction.CUSTOM_COMPONENT_PROPERTY, customComponent);
  }
  if (customComponent instanceof JCheckBox) {
    customComponent.setBorder(JBUI.Borders.empty(0, 9, 0, 0));
  }
  tweakActionComponentUI(customComponent);
  return customComponent;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:ActionToolbarImpl.java

示例13: doSelectPackage

import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
private void doSelectPackage(@Nullable String packageName) {
  PackagesModel packagesModel = ObjectUtils.tryCast(myPackages.getModel(), PackagesModel.class);
  if (packageName == null || packagesModel == null) {
    return;
  }
  for (int i = 0; i < packagesModel.getSize(); i++) {
    RepoPackage repoPackage = packagesModel.getElementAt(i);
    if (packageName.equals(repoPackage.getName())) {
      myPackages.setSelectedIndex(i);
      myPackages.ensureIndexIsVisible(i);
      break;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ManagePackagesDialog.java

示例14: findElement

import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
@Nullable
@Override
protected Object findElement(String s) {
  String string = s.trim();

  XDebuggerTreeNode node = ObjectUtils.tryCast(myComponent.getLastSelectedPathComponent(), XDebuggerTreeNode.class);
  if (node == null) {
    node = ObjectUtils.tryCast(myComponent.getModel().getRoot(), XDebuggerTreeNode.class);
    if (node == null) {
      return null;
    }
  }
  return findPath(string, node, true);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:XDebuggerTreeSpeedSearch.java

示例15: attachExecutionConsole

import com.intellij.util.ObjectUtils; //导入方法依赖的package包/类
@NotNull
@Override
public ExecutionConsole attachExecutionConsole(@NotNull final ExternalSystemTask task,
                                               @NotNull final Project project,
                                               @NotNull final ExternalSystemRunConfiguration configuration,
                                               @NotNull final Executor executor,
                                               @NotNull final ExecutionEnvironment env,
                                               @NotNull final ProcessHandler processHandler) throws ExecutionException {
  final GradleConsoleProperties properties = new GradleConsoleProperties(configuration, executor);
  myExecutionConsole = (SMTRunnerConsoleView)SMTestRunnerConnectionUtil.createAndAttachConsole(
    configuration.getSettings().getExternalSystemId().getReadableName(), processHandler, properties);

  TestTreeRenderer originalRenderer =
    ObjectUtils.tryCast(myExecutionConsole.getResultsViewer().getTreeView().getCellRenderer(), TestTreeRenderer.class);
  if (originalRenderer != null) {
    originalRenderer.setAdditionalRootFormatter(new SMRootTestProxyFormatter() {
      @Override
      public void format(@NotNull SMTestProxy.SMRootTestProxy testProxy, @NotNull TestTreeRenderer renderer) {
        final TestStateInfo.Magnitude magnitude = testProxy.getMagnitudeInfo();
        if (magnitude == TestStateInfo.Magnitude.RUNNING_INDEX) {
          renderer.clear();
          renderer.append(GradleBundle.message(
                            "gradle.test.runner.ui.tests.tree.presentation.labels.waiting.tests"),
                          SimpleTextAttributes.REGULAR_ATTRIBUTES
          );
        }
        else if (!testProxy.isInProgress() && testProxy.isEmptySuite()) {
          renderer.clear();
          renderer.append(GradleBundle.message(
                            "gradle.test.runner.ui.tests.tree.presentation.labels.no.tests.were.found"),
                          SimpleTextAttributes.REGULAR_ATTRIBUTES
          );
        }
      }
    });
  }
  return myExecutionConsole;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:GradleTestsExecutionConsoleManager.java


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