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


Java Condition类代码示例

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


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

示例1: withProjectClassCondition

import com.intellij.openapi.util.Condition; //导入依赖的package包/类
public static Condition<PsiElement> withProjectClassCondition(@Nullable String conditionClass, Condition<PsiElement> psiElementCondition) {
	if (conditionClass == null) {
		return psiElementCondition;
	} else {
		final Condition<PsiElement> finalPsiElementCondition = psiElementCondition;

		return psiElement -> {
			if (finalPsiElementCondition.value(psiElement)) {
				final Project project = psiElement.getProject();
				PsiFile psiFile = psiElement.getContainingFile().getOriginalFile();
				VirtualFile virtualFile = psiFile.getVirtualFile();
				Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(virtualFile);
				assert module != null;
				return JavaPsiFacade.getInstance(project).findClass(conditionClass, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, true)) != null;
			} else {
				return false;
			}
		};
	}
}
 
开发者ID:xylo,项目名称:intellij-postfix-templates,代码行数:21,代码来源:CustomJavaStringPostfixTemplate.java

示例2: buildStep

import com.intellij.openapi.util.Condition; //导入依赖的package包/类
private static ListPopupStep buildStep(@NotNull final List<Pair<AnAction, KeyStroke>> actions, final DataContext ctx) {
  return new BaseListPopupStep<Pair<AnAction, KeyStroke>>("Choose an action", ContainerUtil.findAll(actions, new Condition<Pair<AnAction, KeyStroke>>() {
    @Override
    public boolean value(Pair<AnAction, KeyStroke> pair) {
      final AnAction action = pair.getFirst();
      final Presentation presentation = action.getTemplatePresentation().clone();
      AnActionEvent event = new AnActionEvent(null, ctx,
                                              ActionPlaces.UNKNOWN,
                                              presentation,
                                              ActionManager.getInstance(),
                                              0);

      ActionUtil.performDumbAwareUpdate(action, event, true);
      return presentation.isEnabled() && presentation.isVisible();
    }
  })) {
    @Override
    public PopupStep onChosen(Pair<AnAction, KeyStroke> selectedValue, boolean finalChoice) {
      invokeAction(selectedValue.getFirst(), ctx);
      return FINAL_CHOICE;
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:IdeKeyEventDispatcher.java

示例3: findLocalVarnames

import com.intellij.openapi.util.Condition; //导入依赖的package包/类
public static List<HackVarname> findLocalVarnames(HackVarname var)
{
    List<HackVarname> result = new ArrayList<HackVarname>();

    Condition<PsiElement> parentCheck = psiElement
            -> psiElement instanceof HackFunctionDefinition || psiElement instanceof HackClassMemberDeclaration;
    PsiElement parentFunction = PsiTreeUtil.findFirstParent(var, false, parentCheck);
    Collection<HackVarname> siblingVars = PsiTreeUtil.findChildrenOfType(parentFunction, HackVarname.class);

    for (HackVarname sibling : siblingVars) {
        if (var.getText().equals(sibling.getText())) {
            result.add(sibling);
        }
    }

    return result;
}
 
开发者ID:k-jackson,项目名称:jetbrains-hacklang,代码行数:18,代码来源:HackUtil.java

示例4: reportCommittedRevisions

import com.intellij.openapi.util.Condition; //导入依赖的package包/类
private void reportCommittedRevisions(Set<String> feedback, String committedRevisions) {
  final Project project = mySvnVcs.getProject();
  final String message = SvnBundle.message("status.text.comitted.revision", committedRevisions);
  if (feedback == null) {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
                                                      public void run() {
                                                        new VcsBalloonProblemNotifier(project, message, MessageType.INFO).run();
                                                      }
                                                    }, new Condition<Object>() {
      @Override
      public boolean value(Object o) {
        return (! project.isOpen()) || project.isDisposed();
      }
    });
  } else {
    feedback.add("Subversion: " + message);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:SvnCheckinEnvironment.java

示例5: createTree

import com.intellij.openapi.util.Condition; //导入依赖的package包/类
@NotNull
@Override
public Tree createTree(@NotNull Pair<XValue, String> descriptor) {
  final XDebuggerTree tree = new XDebuggerTree(myProject, myProvider, myPosition, XDebuggerActions.INSPECT_TREE_POPUP_GROUP, myMarkers);
  final XValueNodeImpl root = new XValueNodeImpl(tree, null, descriptor.getSecond(), descriptor.getFirst());
  tree.setRoot(root, true);
  tree.setSelectionRow(0);
  // expand root on load
  tree.expandNodesOnLoad(new Condition<TreeNode>() {
    @Override
    public boolean value(TreeNode node) {
      return node == root;
    }
  });
  return tree;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:XDebuggerTreeCreator.java

示例6: registerExecuteAction

import com.intellij.openapi.util.Condition; //导入依赖的package包/类
/**
 * todo This API doesn't look good, but it is much better than force client to know low-level details
 */
public static AnAction registerExecuteAction(@NotNull LanguageConsoleView console,
                                             @NotNull final Consumer<String> executeActionHandler,
                                             @NotNull String historyType,
                                             @Nullable String historyPersistenceId,
                                             @Nullable Condition<LanguageConsoleView> enabledCondition) {
  ConsoleExecuteAction.ConsoleExecuteActionHandler handler = new ConsoleExecuteAction.ConsoleExecuteActionHandler(true) {
    @Override
    void doExecute(@NotNull String text, @NotNull LanguageConsoleView consoleView) {
      executeActionHandler.consume(text);
    }
  };

  ConsoleExecuteAction action = new ConsoleExecuteAction(console, handler, enabledCondition);
  action.registerCustomShortcutSet(action.getShortcutSet(), console.getConsoleEditor().getComponent());
  new ConsoleHistoryController(historyType, historyPersistenceId, console).install();
  return action;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:LanguageConsoleBuilder.java

示例7: getUsages

import com.intellij.openapi.util.Condition; //导入依赖的package包/类
@NotNull
public Set<UsageDescriptor> getUsages() {
  final IdeaPluginDescriptor[] plugins = PluginManagerCore.getPlugins();
  final List<IdeaPluginDescriptor> nonBundledEnabledPlugins = ContainerUtil.filter(plugins, new Condition<IdeaPluginDescriptor>() {
    public boolean value(final IdeaPluginDescriptor d) {
      return d.isEnabled() && !d.isBundled() && d.getPluginId() != null;
    }
  });

  return ContainerUtil.map2Set(nonBundledEnabledPlugins, new Function<IdeaPluginDescriptor, UsageDescriptor>() {
    @Override
    public UsageDescriptor fun(IdeaPluginDescriptor descriptor) {
      return new UsageDescriptor(descriptor.getPluginId().getIdString(), 1);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:NonBundledPluginsUsagesCollector.java

示例8: DeviceChooserDialog

import com.intellij.openapi.util.Condition; //导入依赖的package包/类
public DeviceChooserDialog(@NotNull AndroidFacet facet,
                           @NotNull IAndroidTarget projectTarget,
                           boolean multipleSelection,
                           @Nullable String[] selectedSerials,
                           @Nullable Condition<IDevice> filter) {
  super(facet.getModule().getProject(), true);
  setTitle(AndroidBundle.message("choose.device.dialog.title"));

  getOKAction().setEnabled(false);

  myDeviceChooser = new DeviceChooser(multipleSelection, getOKAction(), facet, projectTarget, filter);
  Disposer.register(myDisposable, myDeviceChooser);
  myDeviceChooser.addListener(new DeviceChooserListener() {
    @Override
    public void selectedDevicesChanged() {
      updateOkButton();
    }
  });

  init();
  myDeviceChooser.init(selectedSerials);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:DeviceChooserDialog.java

示例9: createAddActions

import com.intellij.openapi.util.Condition; //导入依赖的package包/类
public void createAddActions(DefaultActionGroup group,
                             final JComponent parent,
                             final Consumer<Sdk> updateTree,
                             @Nullable Condition<SdkTypeId> filter) {
  final SdkType[] types = SdkType.getAllTypes();
  for (final SdkType type : types) {
    if (filter != null && !filter.value(type)) continue;
    final AnAction addAction = new DumbAwareAction(type.getPresentableName(), null, type.getIconForAddAction()) {
      @Override
      public void actionPerformed(@NotNull AnActionEvent e) {
        doAdd(parent, type, updateTree);
      }
    };
    group.add(addAction);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ProjectSdksModel.java

示例10: reportException

import com.intellij.openapi.util.Condition; //导入依赖的package包/类
private void reportException(final String htmlContent) {
  Runnable balloonShower = new Runnable() {
    @Override
    public void run() {
      Balloon balloon = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(htmlContent, MessageType.WARNING, null).
        setShowCallout(false).setHideOnClickOutside(true).setHideOnAction(true).setHideOnFrameResize(true).setHideOnKeyOutside(true).
        createBalloon();
      final Rectangle rect = myPanel.getPanel().getBounds();
      final Point p = new Point(rect.x + rect.width - 100, rect.y + 50);
      final RelativePoint point = new RelativePoint(myPanel.getPanel(), p);
      balloon.show(point, Balloon.Position.below);
      Disposer.register(myProject != null ? myProject : ApplicationManager.getApplication(), balloon);
    }
  };
  ApplicationManager.getApplication().invokeLater(balloonShower, new Condition() {
    @Override
    public boolean value(Object o) {
      return !(myProject == null || myProject.isDefault()) && ((!myProject.isOpen()) || myProject.isDisposed());
    }
  }
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:DirDiffTableModel.java

示例11: getInstance

import com.intellij.openapi.util.Condition; //导入依赖的package包/类
/**
 * @param currentRepository Current repository, which means the repository of the currently open or selected file.
 */
public static HgBranchPopup getInstance(@NotNull Project project, @NotNull HgRepository currentRepository) {

  HgRepositoryManager manager = HgUtil.getRepositoryManager(project);
  HgProjectSettings hgProjectSettings = ServiceManager.getService(project, HgProjectSettings.class);
  HgMultiRootBranchConfig hgMultiRootBranchConfig = new HgMultiRootBranchConfig(manager.getRepositories());

  Condition<AnAction> preselectActionCondition = new Condition<AnAction>() {
    @Override
    public boolean value(AnAction action) {
      return false;
    }
  };
  return new HgBranchPopup(currentRepository, manager, hgMultiRootBranchConfig, hgProjectSettings,
                           preselectActionCondition);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:HgBranchPopup.java

示例12: removeNonExistentFiles

import com.intellij.openapi.util.Condition; //导入依赖的package包/类
@Nullable
public CustomResourceBundleState removeNonExistentFiles(final VirtualFileManager virtualFileManager) {
  final List<String> existentFiles = ContainerUtil.filter(myFileUrls, new Condition<String>() {
    @Override
    public boolean value(String url) {
      return virtualFileManager.findFileByUrl(url) != null;
    }
  });
  if (existentFiles.isEmpty()) {
    return null;
  }
  final CustomResourceBundleState customResourceBundleState = new CustomResourceBundleState();
  customResourceBundleState.myFileUrls.addAll(existentFiles);
  customResourceBundleState.myBaseName = myBaseName;
  return customResourceBundleState;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:CustomResourceBundleState.java

示例13: getPropertiesFilesWithoutTranslation

import com.intellij.openapi.util.Condition; //导入依赖的package包/类
public List<PropertiesFile> getPropertiesFilesWithoutTranslation(final ResourceBundle resourceBundle, final Set<String> keys) {
  final PropertiesFile defaultPropertiesFile = resourceBundle.getDefaultPropertiesFile();
  return ContainerUtil.filter(resourceBundle.getPropertiesFiles(), new Condition<PropertiesFile>() {
    @Override
    public boolean value(PropertiesFile propertiesFile) {
      if (defaultPropertiesFile.equals(propertiesFile)) {
        return false;
      }
      for (String key : keys) {
        if (propertiesFile.findPropertyByKey(key) == null && !myState.getIgnoredSuffixes().contains(PropertiesUtil.getSuffix(propertiesFile))) {
          return true;
        }
      }
      return false;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:IgnoredPropertiesFilesSuffixesManager.java

示例14: getSelectedFilesScope

import com.intellij.openapi.util.Condition; //导入依赖的package包/类
@Nullable
private static SearchScope getSelectedFilesScope(final Project project, @Nullable DataContext dataContext) {
  final VirtualFile[] filesOrDirs = dataContext == null ? null : CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
  if (filesOrDirs != null) {
    final List<VirtualFile> selectedFiles = ContainerUtil.filter(filesOrDirs, new Condition<VirtualFile>() {
      @Override
      public boolean value(VirtualFile file) {
        return !file.isDirectory();
      }
    });
    if (!selectedFiles.isEmpty()) {
      return new DelegatingGlobalSearchScope(GlobalSearchScope.filesScope(project, selectedFiles)) {
        @NotNull
        @Override
        public String getDisplayName() {
          return "Selected Files";
        }
      };
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:PredefinedSearchScopeProviderImpl.java

示例15: chooseFirstTimeItems

import com.intellij.openapi.util.Condition; //导入依赖的package包/类
private Iterator<String> chooseFirstTimeItems(String path) {
  if (path == null) {
    return emptyIterator();
  }
  final StringTokenizer tokenizer = new StringTokenizer(path, File.pathSeparator);
  // in JDK 1.5 StringTokenizer implements Enumeration<Object> rather then Enumeration<String>, need to convert
  final Enumeration<String> en = new Enumeration<String>() {
    @Override
    public boolean hasMoreElements() {
      return tokenizer.hasMoreElements();
    }

    @Override
    public String nextElement() {
      return (String)tokenizer.nextElement();
    }
  };
  return FilteringIterator.create(iterate(en), new Condition<String>() {
    @Override
    public boolean value(String element) {
      element = element.trim();
      return !element.isEmpty() && !myPathSet.contains(element);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:PathsList.java


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