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


Java Anchor类代码示例

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


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

示例1: HostedExtension

import org.eclipse.che.ide.api.constraints.Anchor; //导入依赖的package包/类
/** Create extension. */
@Inject
public HostedExtension(
    ActionManager actionManager,
    HostedResources resources,
    HostedLocalizationConstant localizationConstant,
    HttpSessionDestroyedInformer httpSessionDestroyedInformer,
    UnstagedChangesInformer unstagedChangesInformer,
    OpenDocsAction openDocsAction,
    TemporaryWorkspaceInformer temporaryWorkspaceInformer) {
  this.localizationConstant = localizationConstant;
  httpSessionDestroyedInformer.process();
  temporaryWorkspaceInformer.process();

  resources.hostedCSS().ensureInjected();

  actionManager.registerAction("warnOnClose", unstagedChangesInformer);

  DefaultActionGroup helpGroup =
      (DefaultActionGroup) actionManager.getAction(IdeActions.GROUP_HELP);

  actionManager.registerAction(localizationConstant.actionOpenDocsTitle(), openDocsAction);
  Constraints constraint = new Constraints(Anchor.BEFORE, "showAbout");
  helpGroup.add(openDocsAction, constraint);
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:26,代码来源:HostedExtension.java

示例2: ProfileExtension

import org.eclipse.che.ide.api.constraints.Anchor; //导入依赖的package包/类
/** Create extension. */
@Inject
public ProfileExtension(
    ActionManager actionManager,
    RedirectToDashboardAccountAction redirectToDashboardAccountAction,
    ProfileLocalizationConstant localizationConstant) {

  actionManager.registerAction(
      localizationConstant.redirectToDashboardAccountAction(), redirectToDashboardAccountAction);
  Constraints constraint = new Constraints(Anchor.FIRST, null);
  DefaultActionGroup profileActionGroup =
      (DefaultActionGroup) actionManager.getAction(IdeActions.GROUP_PROFILE);
  profileActionGroup.add(redirectToDashboardAccountAction, constraint);
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:15,代码来源:ProfileExtension.java

示例3: checkUnsorted

import org.eclipse.che.ide.api.constraints.Anchor; //导入依赖的package包/类
/**
 * This method checks unsorted map for actions, that depend on action, received in parameter. If
 * found ones, adds it
 *
 * @param unsortedMap - map with unsorted actions
 * @param action - action, that is a condition for actions in unsorted list
 * @param result - result list
 */
private void checkUnsorted(
    Map<Action, Constraints> unsortedMap, Action action, List<Action> result) {
  Iterator<Map.Entry<Action, Constraints>> itr = unsortedMap.entrySet().iterator();
  while (itr.hasNext()) {
    Map.Entry<Action, Constraints> entry = itr.next();

    String actionId = actionManager.getId(action);

    Action relatedAction = entry.getKey();
    Constraints relatedConstraints = entry.getValue();

    // if dependant action constraints match depends on our action
    // add it to result and remove from unsorted list
    if (relatedConstraints.relativeId.equals(actionId)) {
      if (relatedConstraints.myAnchor.equals(Anchor.BEFORE)) {
        result.add(result.indexOf(action), relatedAction);
      } else if (relatedConstraints.myAnchor.equals(Anchor.AFTER)) {
        result.add(result.indexOf(action) + 1, relatedAction);
      }
      itr.remove();
      // recursive call of this method, but now passing the 'relatedAction'
      // to find another actions, that related to 'relatedAction
      checkUnsorted(unsortedMap, relatedAction, result);
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:35,代码来源:DefaultActionGroup.java

示例4: getSortedActions

import org.eclipse.che.ide.api.constraints.Anchor; //导入依赖的package包/类
/**
 * Sorts actions depending on their constraints and their input order.
 *
 * @return An array of sorted actions
 */
// TODO: to complicate
private Action[] getSortedActions() {
  List<Action> result = new ArrayList<>();
  Map<Action, Constraints> unsortedMap = new LinkedHashMap<>();

  for (int i = 0; i < actionList.size(); i++) {

    Action action = actionList.get(i);
    Constraints constraints = constraintsList.get(i);

    // if action is added to result list, it needs to call
    // checkUnsorted method to look for another actions, that must be
    // before or after this action
    if (constraints.myAnchor.equals(Anchor.FIRST)) {
      result.add(0, action);
      checkUnsorted(unsortedMap, action, result);
    } else if (constraints.myAnchor.equals(Anchor.LAST)) {
      result.add(action);
      checkUnsorted(unsortedMap, action, result);
    } else {
      // find related action in result list, if found, add action
      // before or after it. If not, add to unsorted map
      int index = findIndex(constraints.relativeId, result, actionManager);
      if (index == -1) {
        unsortedMap.put(action, constraints);
      } else {
        if (constraints.myAnchor.equals(Anchor.BEFORE)) {
          result.add(index, action);
          checkUnsorted(unsortedMap, action, result);
        } else if (constraints.myAnchor.equals(Anchor.AFTER)) {
          result.add(index + 1, action);
          checkUnsorted(unsortedMap, action, result);
        }
      }
    }
  }
  // append left unsorted actions to the end
  result.addAll(unsortedMap.keySet());
  return result.toArray(new Action[result.size()]);
}
 
开发者ID:eclipse,项目名称:che,代码行数:46,代码来源:DefaultActionGroup.java

示例5: compare

import org.eclipse.che.ide.api.constraints.Anchor; //导入依赖的package包/类
@Override
public int compare(PartPresenter part1, PartPresenter part2) {
  String title1 = part1.getTitle();
  String title2 = part2.getTitle();
  Constraints constr1 = constraints.get(part1);
  Constraints constr2 = constraints.get(part2);

  if (constr1 == null && constr2 == null) {
    return 0;
  }

  if ((constr1 != null && constr1.myAnchor == Anchor.FIRST)
      || (constr2 != null && constr2.myAnchor == Anchor.LAST)) {
    return -1;
  }

  if ((constr2 != null && constr2.myAnchor == Anchor.FIRST)
      || (constr1 != null && constr1.myAnchor == Anchor.LAST)) {
    return 1;
  }

  if (constr1 != null && constr1.relativeId != null) {
    Anchor anchor1 = constr1.myAnchor;
    String relative1 = constr1.relativeId;
    if (anchor1 == Anchor.BEFORE && relative1.equals(title2)) {
      return -1;
    }
    if (anchor1 == Anchor.AFTER && relative1.equals(title2)) {
      return 1;
    }
  }

  if (constr2 != null && constr2.relativeId != null) {
    Anchor anchor2 = constr2.myAnchor;
    String relative2 = constr2.relativeId;
    if (anchor2 == Anchor.BEFORE && relative2.equals(title1)) {
      return 1;
    }
    if (anchor2 == Anchor.AFTER && relative2.equals(title1)) {
      return -1;
    }
  }

  if (constr1 != null && constr2 == null) {
    return 1;
  }
  if (constr1 == null) {
    return -1;
  }
  return 0;
}
 
开发者ID:eclipse,项目名称:che,代码行数:52,代码来源:PartsComparator.java


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