public String[] getGroupRoutes(String group) {
   LinkedHashSet<String> routes = new LinkedHashSet<String>();
   for (ApiDoc apiDoc : docs) {
     if (StringUtils.equals(group, apiDoc.group)) Collections.addAll(routes, apiDoc.routes);
   }
   return routes.toArray(new String[routes.size()]);
 }
  private ArrayList<LocatableHLayout> createTagLayouts() {
    ArrayList<LocatableHLayout> tagLayouts = new ArrayList<LocatableHLayout>(tags.size());

    for (final Tag tag : tags) {
      LocatableHLayout tagLayout = new LocatableHLayout(extendLocatorId(tag.getName()));
      tagLayout.setHeight(18);
      tagLayout.setHeight(16);

      HTMLFlow tagString =
          new HTMLFlow(
              "<nobr><a href=\""
                  + LinkManager.getTagLink(tag.toString())
                  + "\">"
                  + tag.toString()
                  + "</a></nobr>");
      tagString.setAutoWidth();
      tagLayout.addMember(tagString);

      if (!readOnly) {
        final LayoutSpacer spacer = new LayoutSpacer();
        spacer.setHeight(16);
        spacer.setWidth(16);

        final Img remove =
            new LocatableImg(
                tagLayout.extendLocatorId("Remove"), "[skin]/images/actions/remove.png", 16, 16);
        remove.setTooltip(MSG.view_tags_tooltip_1());
        remove.addClickHandler(
            new ClickHandler() {
              public void onClick(ClickEvent clickEvent) {
                tags.remove(tag);
                save();
              }
            });

        tagLayout.addMember(remove);
        tagLayout.addMember(spacer);
        remove.hide();

        tagLayout.addMouseOverHandler(
            new MouseOverHandler() {
              public void onMouseOver(MouseOverEvent mouseOverEvent) {
                remove.show();
                spacer.hide();
              }
            });
        tagLayout.addMouseOutHandler(
            new MouseOutHandler() {
              public void onMouseOut(MouseOutEvent mouseOutEvent) {
                spacer.show();
                remove.hide();
              }
            });
      }

      tagLayouts.add(tagLayout);
    }

    return tagLayouts;
  }
示例#3
0
  public String[] getAuthMechanisms(
      Context cx, URI req_uri, String realm, final String[] default_mechanisms) {
    final LinkedHashSet<String> result = new LinkedHashSet<String>(); // Order is important

    enumerateProperty(
        cx,
        "auth",
        new PropEnumerator() {
          public void handleProperty(Scriptable p, int s) {
            Object mechanism = p.get("mechanism", p);

            if (mechanism == null
                || mechanism == Scriptable.NOT_FOUND
                || mechanism == Context.getUndefinedValue()) {
              // Any mechanism is OK
              result.addAll(Arrays.asList(default_mechanisms));
            } else {
              result.add(Context.toString(mechanism).toLowerCase());
            }
          }
        },
        req_uri,
        realm,
        null);

    return result.toArray(new String[result.size()]);
  }
 public String[] getGroupNames() {
   LinkedHashSet<String> groups = new LinkedHashSet<String>();
   for (ApiDoc apiDoc : docs) {
     groups.add(apiDoc.group);
   }
   return groups.toArray(new String[groups.size()]);
 }
示例#5
0
  /**
   * Insert the method's description here. Creation date: (21.12.2000 22:24:23)
   *
   * @return boolean
   * @param object com.cosylab.vdct.graphics.objects.VisibleObject
   * @param zoomOnHilited sets the option whether the hilited object should be zoomed in
   */
  public boolean setAsHilited(VisibleObject object, boolean zoomOnHilited) {
    this.zoomOnHilited = zoomOnHilited;

    if (zoomOnHilited) {
      DrawingSurface.getInstance().repaint();
      hilitedObjects.clear();
      if (hilitedObject != null) {
        hilitedObjects.add(hilitedObject);
      }
    }

    if (object == null) {
      hilitedObjects.clear();
      hilitedObject = null;
      return false;
    }

    if (object != hilitedObject || hilitedObjects.size() == 1) {

      hilitedObject = object;

      // initialization
      hilitedObjects.clear();
      hilitedObjects.add(hilitedObject);
      Object obj = hilitedObject;

      // inlinks
      Vector outlinks = null;
      if (obj instanceof MultiInLink) {
        outlinks = ((MultiInLink) obj).getOutlinks();
      } else if (obj instanceof InLink) {
        outlinks = new Vector();
        outlinks.add(((InLink) obj).getOutput());
      }

      if (!zoomOnHilited) {
        if (outlinks != null)
          for (int i = 0; i < outlinks.size(); i++) {
            obj = outlinks.elementAt(i);
            hilitedObjects.add(obj);
            while (obj instanceof InLink) {
              obj = ((InLink) obj).getOutput();
              hilitedObjects.add(obj);
            }
          }

        // outLinks
        obj = hilitedObject;
        while (obj instanceof OutLink) {
          obj = ((OutLink) obj).getInput();
          hilitedObjects.add(obj);
        }
      }
      return true;
    } else return false;
  }
  @Override
  public PsiType[] guessTypeToCast(
      PsiExpression expr) { // TODO : make better guess based on control flow
    LinkedHashSet<PsiType> types = new LinkedHashSet<>();

    ContainerUtil.addIfNotNull(types, getControlFlowExpressionType(expr));
    addExprTypesWhenContainerElement(types, expr);
    addExprTypesByDerivedClasses(types, expr);

    return types.toArray(PsiType.createArray(types.size()));
  }
示例#7
0
  @Override
  public void execute() {
    Map<String, Set<CortexLinksMap>> links = new HashMap<String, Set<CortexLinksMap>>();
    Map<String, Set<String>> linkFilenames = new HashMap<String, Set<String>>();
    if (LINKS != null && !LINKS.isEmpty()) {
      for (CortexLinksMap cl : LINKS) {
        String name = cl.getCortexLinks().getColor(0).getSampleName();

        if (!links.containsKey(name)) {
          links.put(name, new HashSet<CortexLinksMap>());
          linkFilenames.put(name, new HashSet<String>());
        }

        links.get(name).add(cl);
        linkFilenames.get(name).add(cl.getCortexLinks().getCortexLinksFile().getAbsolutePath());
      }
      log.info("Loaded {} links", LINKS.size());

      for (CortexLinksMap clm : LINKS) {
        log.info(
            "  {}: {}",
            clm.getCortexLinks().getCortexLinksFile().getAbsolutePath(),
            clm.getCortexLinks().getNumLinks());
      }
    }

    log.info("Loaded {} graphs", GRAPHS.size());
    for (CortexGraph cg : GRAPHS) {
      String name = cg.getColor(0).getSampleName();
      graphs.put(cg.getCortexFile().getName(), cg);

      log.info(
          "  {}: {} {}", cg.getCortexFile().getName(), cg.getKmerSize(), linkFilenames.get(name));
    }

    loadContigs();
    log.info("Loaded {} contigs", contigs.size());

    log.info("Listening on port {}", PORT);

    try {
      HttpServer server = HttpServer.create(new InetSocketAddress(PORT), 0);
      server.createContext("/", new PageHandler());
      server.createContext("/graphlist", new GraphList());
      server.createContext("/search", new SearchHandler());
      server.createContext("/cr", new CtxRecordHandler());
      server.createContext("/links", new LinksHandler());
      server.setExecutor(null);
      server.start();
    } catch (IOException e) {
      throw new IndianaException("Unable to start server", e);
    }
  }
示例#8
0
 // ## operation setReactantTree(LinkedHashSet)
 public void setReactantTree(LinkedHashSet p_treeSet) {
   // #[ operation setReactantTree(LinkedHashSet)
   if (p_treeSet == null) throw new InvalidReactantTreeException();
   int size = p_treeSet.size();
   if (size == 0) throw new InvalidReactantTreeException();
   Iterator iter = p_treeSet.iterator();
   while (iter.hasNext()) {
     HierarchyTree tree = (HierarchyTree) iter.next();
     addReactantTree(tree);
   }
   return;
   // #]
 }
 public CommonProblemDescriptor[] getSelectedDescriptors() {
   final InspectionTool tool = getSelectedTool();
   if (getSelectionCount() == 0
       || !(tool instanceof DescriptorProviderInspection
           && !(tool instanceof CommonInspectionToolWrapper))) return EMPTY_DESCRIPTORS;
   final TreePath[] paths = getSelectionPaths();
   final LinkedHashSet<CommonProblemDescriptor> descriptors =
       new LinkedHashSet<CommonProblemDescriptor>();
   for (TreePath path : paths) {
     Object node = path.getLastPathComponent();
     traverseDescriptors((InspectionTreeNode) node, descriptors);
   }
   return descriptors.toArray(new CommonProblemDescriptor[descriptors.size()]);
 }
示例#10
0
 /** Removes duplicate roots that have been added as the result of a bug with *.egg handling. */
 private static boolean removeDuplicateClassRoots(
     @NotNull Sdk sdk, @NotNull SdkModificator modificator) {
   final List<VirtualFile> sourceRoots =
       Arrays.asList(sdk.getRootProvider().getFiles(OrderRootType.CLASSES));
   final LinkedHashSet<VirtualFile> uniqueRoots = new LinkedHashSet<VirtualFile>(sourceRoots);
   if (uniqueRoots.size() != sourceRoots.size()) {
     modificator.removeRoots(OrderRootType.CLASSES);
     for (VirtualFile root : uniqueRoots) {
       modificator.addRoot(root, OrderRootType.CLASSES);
     }
     return true;
   }
   return false;
 }
  public static ApiDocs scan(String... files) {
    try {
      result = new ApiDocs();
      LinkedHashSet<String> sources = new LinkedHashSet<String>();
      for (String file : files) findSourceFiles(sources, file);

      Main.execute(
          "borqs_server_api_doc_scanner",
          HttpApiDoclet.class.getName(),
          sources.toArray(new String[sources.size()]));
      return result;
    } finally {
      result = null;
    }
  }
 /**
  * Removes the timeout role from the given user. This does NOT create or manage any
  * storage/persistence, it only sets the user's roles
  *
  * @param user The user to remove the timeout role
  * @param server The server on which to remove the user from the timeout role
  * @param invocationChannel The channel to send messages on error
  */
 public boolean removeTimeoutRole(User user, Server server, Channel invocationChannel) {
   String serverId = server.getId();
   TempServerConfig serverConfig = serverStorage.get(serverId);
   if (serverConfig == null) {
     serverConfig = new TempServerConfig(serverId);
     serverStorage.put(serverId, serverConfig);
   }
   ServerTimeoutStorage storage = serverConfig.getServerTimeouts();
   String serverName = server.getName();
   if (storage != null && storage.getTimeoutRoleId() != null) {
     String timeoutRoleId = storage.getTimeoutRoleId();
     Role timeoutRole = apiClient.getRole(timeoutRoleId, server);
     if (timeoutRole != NO_ROLE) {
       //  Get roles
       Set<Role> userRoles =
           apiClient.getMemberRoles(apiClient.getUserMember(user, server), server);
       //  Delete the ban role
       LinkedHashSet<String> newRoles = new LinkedHashSet<>(userRoles.size() - 1);
       userRoles
           .stream()
           .map(Role::getId)
           .filter(s -> !timeoutRoleId.equals(s))
           .forEach(newRoles::add);
       //  Update
       apiClient.updateRoles(user, server, newRoles);
       return userRoles.size() == newRoles.size();
     } else {
       LOGGER.warn(
           "Timeout role ID {} for server {} ({}) does not exist",
           timeoutRoleId,
           serverName,
           serverId);
       apiClient.sendMessage(
           loc.localize("message.mod.timeout.bad_role", timeoutRoleId), invocationChannel);
     }
   } else {
     storage = new ServerTimeoutStorage();
     serverConfig.setServerTimeouts(storage);
     serverStorage.put(serverId, serverConfig);
     LOGGER.warn(
         "Timeout role for server {} ({}) is not configured",
         storage.getTimeoutRoleId(),
         serverName,
         serverId);
     apiClient.sendMessage(loc.localize("message.mod.timeout.not_configured"), invocationChannel);
   }
   return false;
 }
  public static BridgeInvocation_c[] getManyACT_BRGsOnR628(
      ActualParameter_c[] targets, ClassQueryInterface_c test, boolean loadComponent) {
    if (targets == null || targets.length == 0 || targets[0] == null)
      return new BridgeInvocation_c[0];

    LinkedHashSet<BridgeInvocation_c> elementsSet = new LinkedHashSet<BridgeInvocation_c>();
    for (int i = 0; i < targets.length; i++) {
      BridgeInvocation_c associate = targets[i].BridgeInvocation;
      if (targets[i] != null && associate != null && (test == null || test.evaluate(associate))) {
        if (elementsSet.add(associate)) {}
      }
    }

    BridgeInvocation_c[] result = new BridgeInvocation_c[elementsSet.size()];
    elementsSet.toArray(result);
    return result;
  }
  public static ComponentResultSet_c[] getManyPE_CRSsOnR8008(
      ComponentVisibility_c[] targets, ClassQueryInterface_c test, boolean loadComponent) {
    if (targets == null || targets.length == 0 || targets[0] == null)
      return new ComponentResultSet_c[0];

    LinkedHashSet<ComponentResultSet_c> elementsSet = new LinkedHashSet<ComponentResultSet_c>();
    for (int i = 0; i < targets.length; i++) {
      ComponentResultSet_c associate = targets[i].MakesUpAComponentResultSet;
      if (targets[i] != null && associate != null && (test == null || test.evaluate(associate))) {
        if (elementsSet.add(associate)) {}
      }
    }

    ComponentResultSet_c[] result = new ComponentResultSet_c[elementsSet.size()];
    elementsSet.toArray(result);
    return result;
  }
示例#15
0
  public static Graphnode_c[] getManyDIM_NDsOnR19(
      FloatingText_c[] targets, ClassQueryInterface_c test, boolean loadComponent) {
    if (targets == null || targets.length == 0 || targets[0] == null) return new Graphnode_c[0];

    LinkedHashSet<Graphnode_c> elementsSet = new LinkedHashSet<Graphnode_c>();
    for (int i = 0; i < targets.length; i++) {
      if (loadComponent && targets[i] != null && targets[i].IsSupertypeGraphnode == null)
        targets[i].loadProxy();
      Graphnode_c associate = targets[i].IsSupertypeGraphnode;
      if (targets[i] != null && associate != null && (test == null || test.evaluate(associate))) {
        if (elementsSet.add(associate)) {}
      }
    }

    Graphnode_c[] result = new Graphnode_c[elementsSet.size()];
    elementsSet.toArray(result);
    return result;
  }
示例#16
0
 @NotNull
 @Override
 public List<Instruction> getReversedInstructions() {
   LinkedHashSet<Instruction> traversedInstructions = Sets.newLinkedHashSet();
   PseudocodeTraverserKt.traverseFollowingInstructions(
       sinkInstruction, traversedInstructions, BACKWARD, null);
   if (traversedInstructions.size() < instructions.size()) {
     List<Instruction> simplyReversedInstructions = Lists.newArrayList(instructions);
     Collections.reverse(simplyReversedInstructions);
     for (Instruction instruction : simplyReversedInstructions) {
       if (!traversedInstructions.contains(instruction)) {
         PseudocodeTraverserKt.traverseFollowingInstructions(
             instruction, traversedInstructions, BACKWARD, null);
       }
     }
   }
   return Lists.newArrayList(traversedInstructions);
 }
 private static void ensureEverythingVisibleAdded(
     LookupImpl lookup,
     final LinkedHashSet<LookupElement> model,
     Iterator<LookupElement> byRelevance) {
   JList list = lookup.getList();
   final boolean testMode = ApplicationManager.getApplication().isUnitTestMode();
   final int limit =
       Math.max(list.getLastVisibleIndex(), model.size())
           + ourUISettings.MAX_LOOKUP_LIST_HEIGHT * 3;
   addSomeItems(
       model,
       byRelevance,
       new Condition<LookupElement>() {
         @Override
         public boolean value(LookupElement lastAdded) {
           return !testMode && model.size() >= limit;
         }
       });
 }
  public static ComponentInComponent_c[] getManyCN_CICsOnR4203(
      Component_c[] targets, ClassQueryInterface_c test, boolean loadComponent) {
    if (targets == null || targets.length == 0 || targets[0] == null)
      return new ComponentInComponent_c[0];

    LinkedHashSet<ComponentInComponent_c> elementsSet = new LinkedHashSet<ComponentInComponent_c>();
    for (int i = 0; i < targets.length; i++) {
      if (loadComponent
          && targets[i] != null
          && targets[i].IsNestedThroughComponentInComponent == null) targets[i].loadProxy();
      ComponentInComponent_c associate = targets[i].IsNestedThroughComponentInComponent;
      if (targets[i] != null && associate != null && (test == null || test.evaluate(associate))) {
        if (elementsSet.add(associate)) {
          if (loadComponent) {
            associate.loadProxy();
          }
        }
      }
    }

    ComponentInComponent_c[] result = new ComponentInComponent_c[elementsSet.size()];
    elementsSet.toArray(result);
    return result;
  }
  @Nullable
  static String filterBadPlugins(
      List<? extends IdeaPluginDescriptor> result, final Map<String, String> disabledPluginNames) {
    final Map<PluginId, IdeaPluginDescriptor> idToDescriptorMap =
        new HashMap<PluginId, IdeaPluginDescriptor>();
    final StringBuffer message = new StringBuffer();
    boolean pluginsWithoutIdFound = false;
    for (Iterator<? extends IdeaPluginDescriptor> it = result.iterator(); it.hasNext(); ) {
      final IdeaPluginDescriptor descriptor = it.next();
      final PluginId id = descriptor.getPluginId();
      if (id == null) {
        pluginsWithoutIdFound = true;
      }
      if (idToDescriptorMap.containsKey(id)) {
        message.append("<br>");
        message.append(IdeBundle.message("message.duplicate.plugin.id"));
        message.append(id);
        it.remove();
      } else if (descriptor.isEnabled()) {
        idToDescriptorMap.put(id, descriptor);
      }
    }
    addModulesAsDependents(idToDescriptorMap);
    final List<String> disabledPluginIds = new ArrayList<String>();
    final LinkedHashSet<String> faultyDescriptors = new LinkedHashSet<String>();
    for (final Iterator<? extends IdeaPluginDescriptor> it = result.iterator(); it.hasNext(); ) {
      final IdeaPluginDescriptor pluginDescriptor = it.next();
      checkDependants(
          pluginDescriptor,
          new Function<PluginId, IdeaPluginDescriptor>() {
            @Override
            public IdeaPluginDescriptor fun(final PluginId pluginId) {
              return idToDescriptorMap.get(pluginId);
            }
          },
          new Condition<PluginId>() {
            @Override
            public boolean value(final PluginId pluginId) {
              if (!idToDescriptorMap.containsKey(pluginId)) {
                pluginDescriptor.setEnabled(false);
                if (!pluginId.getIdString().startsWith(MODULE_DEPENDENCY_PREFIX)) {
                  faultyDescriptors.add(pluginId.getIdString());
                  disabledPluginIds.add(pluginDescriptor.getPluginId().getIdString());
                  message.append("<br>");
                  final String name = pluginDescriptor.getName();
                  final IdeaPluginDescriptor descriptor = idToDescriptorMap.get(pluginId);
                  String pluginName;
                  if (descriptor == null) {
                    pluginName = pluginId.getIdString();
                    if (disabledPluginNames.containsKey(pluginName)) {
                      pluginName = disabledPluginNames.get(pluginName);
                    }
                  } else {
                    pluginName = descriptor.getName();
                  }

                  message.append(
                      getDisabledPlugins().contains(pluginId.getIdString())
                          ? IdeBundle.message("error.required.plugin.disabled", name, pluginName)
                          : IdeBundle.message(
                              "error.required.plugin.not.installed", name, pluginName));
                }
                it.remove();
                return false;
              }
              return true;
            }
          });
    }
    if (!disabledPluginIds.isEmpty()) {
      myPlugins2Disable = disabledPluginIds;
      myPlugins2Enable = faultyDescriptors;
      message.append("<br>");
      message.append("<br>").append("<a href=\"" + DISABLE + "\">Disable ");
      if (disabledPluginIds.size() == 1) {
        final PluginId pluginId2Disable = PluginId.getId(disabledPluginIds.iterator().next());
        message.append(
            idToDescriptorMap.containsKey(pluginId2Disable)
                ? idToDescriptorMap.get(pluginId2Disable).getName()
                : pluginId2Disable.getIdString());
      } else {
        message.append("not loaded plugins");
      }
      message.append("</a>");
      boolean possibleToEnable = true;
      for (String descriptor : faultyDescriptors) {
        if (disabledPluginNames.get(descriptor) == null) {
          possibleToEnable = false;
          break;
        }
      }
      if (possibleToEnable) {
        message
            .append("<br>")
            .append("<a href=\"" + ENABLE + "\">Enable ")
            .append(
                faultyDescriptors.size() == 1
                    ? disabledPluginNames.get(faultyDescriptors.iterator().next())
                    : " all necessary plugins")
            .append("</a>");
      }
      message.append("<br>").append("<a href=\"" + EDIT + "\">Open plugin manager</a>");
    }
    if (pluginsWithoutIdFound) {
      message.append("<br>");
      message.append(IdeBundle.message("error.plugins.without.id.found"));
    }
    if (message.length() > 0) {
      message.insert(0, IdeBundle.message("error.problems.found.loading.plugins"));
      return message.toString();
    }
    return null;
  }
  @Override
  public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file)
      throws IncorrectOperationException {
    if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;

    PsiMethod[] constructors = myClass.getConstructors();
    if (constructors.length == 0) {
      final AddDefaultConstructorFix defaultConstructorFix = new AddDefaultConstructorFix(myClass);
      ApplicationManager.getApplication()
          .runWriteAction(
              new Runnable() {
                @Override
                public void run() {
                  defaultConstructorFix.invoke(project, editor, file);
                }
              });
      constructors = myClass.getConstructors();
    }
    Arrays.sort(
        constructors,
        new Comparator<PsiMethod>() {
          @Override
          public int compare(PsiMethod c1, PsiMethod c2) {
            final PsiMethod cc1 = RefactoringUtil.getChainedConstructor(c1);
            final PsiMethod cc2 = RefactoringUtil.getChainedConstructor(c2);
            if (cc1 == c2) return 1;
            if (cc2 == c1) return -1;
            if (cc1 == null) {
              return cc2 == null ? 0 : compare(c1, cc2);
            } else {
              return cc2 == null ? compare(cc1, c2) : compare(cc1, cc2);
            }
          }
        });
    final ArrayList<PsiMethod> constrs =
        filterConstructorsIfFieldAlreadyAssigned(constructors, getField());
    if (constrs.size() > 1) {
      final PsiMethodMember[] members = new PsiMethodMember[constrs.size()];
      int i = 0;
      for (PsiMethod constructor : constrs) {
        members[i++] = new PsiMethodMember(constructor);
      }
      final List<PsiMethodMember> elements;
      if (ApplicationManager.getApplication().isUnitTestMode()) {
        elements = Arrays.asList(members);
      } else {
        final MemberChooser<PsiMethodMember> chooser =
            new MemberChooser<PsiMethodMember>(members, false, true, project);
        chooser.setTitle("Choose constructors to add parameter to");
        chooser.show();
        elements = chooser.getSelectedElements();
        if (elements == null) return;
      }

      for (PsiMethodMember member : elements) {
        if (!addParameterToConstructor(
            project, file, editor, member.getElement(), new PsiField[] {getField()})) break;
      }

    } else if (!constrs.isEmpty()) {
      final Collection<SmartPsiElementPointer<PsiField>> fieldsToFix = getFieldsToFix();
      try {
        final PsiMethod constructor = constrs.get(0);
        final LinkedHashSet<PsiField> fields = new LinkedHashSet<PsiField>();
        getFieldsToFix().add(myField);
        for (SmartPsiElementPointer<PsiField> elementPointer : fieldsToFix) {
          final PsiField field = elementPointer.getElement();
          if (field != null
              && isAvailable(field)
              && filterConstructorsIfFieldAlreadyAssigned(new PsiMethod[] {constructor}, field)
                  .contains(constructor)) {
            fields.add(field);
          }
        }
        if (constrs.size() == constructors.length
            && fields.size() > 1
            && !ApplicationManager.getApplication().isUnitTestMode()) {
          PsiFieldMember[] members = new PsiFieldMember[fields.size()];
          int i = 0;
          for (PsiField field : fields) {
            members[i++] = new PsiFieldMember(field);
          }
          MemberChooser<PsiElementClassMember> chooser =
              new MemberChooser<PsiElementClassMember>(members, false, true, project);
          chooser.setTitle("Choose Fields to Generate Constructor Parameters for");
          chooser.show();
          if (chooser.getExitCode() != DialogWrapper.OK_EXIT_CODE) return;
          final List<PsiElementClassMember> selectedElements = chooser.getSelectedElements();
          if (selectedElements == null) return;
          fields.clear();
          for (PsiElementClassMember member : selectedElements) {
            fields.add((PsiField) member.getElement());
          }
        }

        addParameterToConstructor(
            project,
            file,
            editor,
            constructor,
            constrs.size() == constructors.length
                ? fields.toArray(new PsiField[fields.size()])
                : new PsiField[] {getField()});
      } finally {
        fieldsToFix.clear();
      }
    }
  }
 private void setComboboxModel(
     final JComboBox comboBox,
     final VirtualFile initialTargetDirectorySourceRoot,
     final VirtualFile oldSelection,
     final ProjectFileIndex fileIndex,
     final VirtualFile[] sourceRoots,
     final Project project,
     final boolean forceIncludeAll,
     final Pass<String> updateErrorMessage) {
   final LinkedHashSet<PsiDirectory> targetDirectories = new LinkedHashSet<PsiDirectory>();
   final HashMap<PsiDirectory, String> pathsToCreate = new HashMap<PsiDirectory, String>();
   MoveClassesOrPackagesUtil.buildDirectoryList(
       new PackageWrapper(PsiManager.getInstance(project), getTargetPackage()),
       sourceRoots,
       targetDirectories,
       pathsToCreate);
   if (!forceIncludeAll && targetDirectories.size() > pathsToCreate.size()) {
     targetDirectories.removeAll(pathsToCreate.keySet());
   }
   final ArrayList<DirectoryChooser.ItemWrapper> items =
       new ArrayList<DirectoryChooser.ItemWrapper>();
   DirectoryChooser.ItemWrapper initial = null;
   DirectoryChooser.ItemWrapper oldOne = null;
   for (PsiDirectory targetDirectory : targetDirectories) {
     DirectoryChooser.ItemWrapper itemWrapper =
         new DirectoryChooser.ItemWrapper(targetDirectory, pathsToCreate.get(targetDirectory));
     items.add(itemWrapper);
     final VirtualFile sourceRootForFile =
         fileIndex.getSourceRootForFile(targetDirectory.getVirtualFile());
     if (sourceRootForFile == initialTargetDirectorySourceRoot) {
       initial = itemWrapper;
     } else if (sourceRootForFile == oldSelection) {
       oldOne = itemWrapper;
     }
   }
   items.add(NULL_WRAPPER);
   final DirectoryChooser.ItemWrapper selection =
       chooseSelection(initialTargetDirectorySourceRoot, fileIndex, items, initial, oldOne);
   final ComboBoxModel model = comboBox.getModel();
   if (model instanceof CollectionComboBoxModel) {
     boolean sameModel = model.getSize() == items.size();
     if (sameModel) {
       for (int i = 0; i < items.size(); i++) {
         final DirectoryChooser.ItemWrapper oldItem =
             (DirectoryChooser.ItemWrapper) model.getElementAt(i);
         final DirectoryChooser.ItemWrapper itemWrapper = items.get(i);
         if (!areItemsEquivalent(oldItem, itemWrapper)) {
           sameModel = false;
           break;
         }
       }
     }
     if (sameModel) {
       if (areItemsEquivalent(
           (DirectoryChooser.ItemWrapper) comboBox.getSelectedItem(), selection)) {
         return;
       }
     }
   }
   updateErrorMessage(updateErrorMessage, fileIndex, selection);
   Collections.sort(
       items,
       new Comparator<DirectoryChooser.ItemWrapper>() {
         @Override
         public int compare(DirectoryChooser.ItemWrapper o1, DirectoryChooser.ItemWrapper o2) {
           if (o1 == NULL_WRAPPER) return -1;
           if (o2 == NULL_WRAPPER) return 1;
           return o1.getRelativeToProjectPath().compareToIgnoreCase(o2.getRelativeToProjectPath());
         }
       });
   comboBox.setModel(new CollectionComboBoxModel(items, selection));
 }
示例#22
0
  @Transactional
  public DayGrid updateDayGid(DayGrid dayGrid, String profile) throws ParseException {

    Set<EmplacementDTO> blocs = dayGrid.getBlocs();
    if (blocs != null) {
      for (Iterator<EmplacementDTO> iterator = blocs.iterator(); iterator.hasNext(); ) {
        EmplacementDTO emplacementDTO = iterator.next();
        Set<RubriqueDTO> rubriqueDTOSet = emplacementDTO.getRubrique();
        if (rubriqueDTOSet != null) {
          for (Iterator<RubriqueDTO> rubriqueDTOIterator = rubriqueDTOSet.iterator();
              rubriqueDTOIterator.hasNext(); ) {
            RubriqueDTO rubriqueDTO = rubriqueDTOIterator.next();
            rubriqueLoggingService.updateEmplacementRubriqueForDay(
                emplacementDTO.getId(),
                emplacementDTO.getName(),
                emplacementDTO.getPosition(),
                rubriqueDTO.getId(),
                profile,
                dayGrid.getId());

            LinkedHashSet<CommunicationGroupDTO> communicationGroups =
                rubriqueDTO.getCommunicationGroups();
            for (Iterator<CommunicationGroupDTO> communicationGroupDTOIterator =
                    communicationGroups.iterator();
                communicationGroupDTOIterator.hasNext(); ) {
              CommunicationGroupDTO communicationGroupDTO = communicationGroupDTOIterator.next();
              LinkedHashSet<CommunicationDTO> communicationDTOs =
                  communicationGroupDTO.getCommunications();
              if (communicationDTOs != null && communicationDTOs.size() > 0) {
                List<String> communicationIdsToDeactivate = Lists.newArrayList();
                List<String> communicationIdsToActivate = Lists.newArrayList();
                for (Iterator<CommunicationDTO> communicationDTOIterator =
                        communicationDTOs.iterator();
                    communicationDTOIterator.hasNext(); ) {
                  CommunicationDTO communicationDTO = communicationDTOIterator.next();
                  if (isToday(dayGrid.getDate())) {
                    if (communicationDTO.isDeactivated()
                        && !communicationLoggingService.isDeactivatedCommunicationLogging(
                            communicationDTO.getCommunicationLoggingId())) {
                      communicationIdsToDeactivate.add(communicationDTO.getIdArrowCommunication());
                    }
                    if (!communicationDTO.isDeactivated()
                        && communicationLoggingService.isDeactivatedCommunicationLogging(
                            communicationDTO.getCommunicationLoggingId())) {
                      communicationIdsToActivate.add(communicationDTO.getIdArrowCommunication());
                    }
                  }
                  // update communicationLogging
                  communicationLoggingService.updateCommunicationLoggingForCommunicationAndDay(
                      communicationDTO.getIdCommunication(),
                      dayGrid.getId(),
                      communicationDTO.getPriority(),
                      communicationGroupDTO.getId(),
                      communicationGroupDTO.getLabel(),
                      communicationDTO.getNbAffichageMax(),
                      communicationDTO.getNbJourAffichageMax(),
                      communicationDTO.getNbClicMax(),
                      communicationDTO.getNbJourClicMax(),
                      communicationDTO.isDeactivated());
                }
                if (isToday(dayGrid.getDate())) {
                  if (CollectionUtils.isNotEmpty(communicationIdsToDeactivate)) {
                    deactivateCommunicationsInstantaneously(
                        dayGrid.getDate(), communicationIdsToDeactivate);
                  }
                  if (CollectionUtils.isNotEmpty(communicationIdsToActivate)) {
                    activateCommunicationsInstantaneously(
                        dayGrid.getDate(), communicationIdsToActivate);
                  }
                }
              }
            }
          }
        }
      }
    }

    return dayGrid;
  }