private void updateText() {
    StringBuilder sb = new StringBuilder();

    if (myShowSettingsBeforeRunCheckBox.isSelected()) {
      sb.append(ExecutionBundle.message("configuration.edit.before.run")).append(", ");
    }

    List<BeforeRunTask> tasks = myModel.getItems();
    if (!tasks.isEmpty()) {
      LinkedHashMap<BeforeRunTaskProvider, Integer> counter =
          new LinkedHashMap<BeforeRunTaskProvider, Integer>();
      for (BeforeRunTask task : tasks) {
        BeforeRunTaskProvider<BeforeRunTask> provider =
            BeforeRunTaskProvider.getProvider(
                myRunConfiguration.getProject(), task.getProviderId());
        if (provider != null) {
          Integer count = counter.get(provider);
          if (count == null) {
            count = task.getItemsCount();
          } else {
            count += task.getItemsCount();
          }
          counter.put(provider, count);
        }
      }
      for (Iterator<Map.Entry<BeforeRunTaskProvider, Integer>> iterator =
              counter.entrySet().iterator();
          iterator.hasNext(); ) {
        Map.Entry<BeforeRunTaskProvider, Integer> entry = iterator.next();
        BeforeRunTaskProvider provider = entry.getKey();
        String name = provider.getName();
        if (name.startsWith("Run ")) {
          name = name.substring(4);
        }
        sb.append(name);
        if (entry.getValue() > 1) {
          sb.append(" (").append(entry.getValue().intValue()).append(")");
        }
        if (iterator.hasNext()) sb.append(", ");
      }
    }
    if (sb.length() > 0) {
      sb.insert(0, ": ");
    }
    sb.insert(0, ExecutionBundle.message("before.launch.panel.title"));
    myListener.titleChanged(sb.toString());
  }
    private String buildLabelText(
        @NotNull final String text,
        @NotNull final Map<TextRange, ParameterInfoUIContextEx.Flag> flagsMap) {
      final StringBuilder labelText = new StringBuilder(text);
      final String disabledTag = FLAG_TO_TAG.get(ParameterInfoUIContextEx.Flag.DISABLE);

      final Map<Integer, Integer> faultMap = new HashMap<>();
      if (isDisabledBeforeHighlight) {
        final String tag = getTag(disabledTag);
        labelText.insert(0, tag);
        faultMap.put(0, tag.length());
      }

      for (Map.Entry<TextRange, ParameterInfoUIContextEx.Flag> entry : flagsMap.entrySet()) {
        final TextRange highlightRange = entry.getKey();
        final ParameterInfoUIContextEx.Flag flag = entry.getValue();

        final String tagValue = FLAG_TO_TAG.get(flag);
        final String tag = getTag(tagValue);

        int startOffset = highlightRange.getStartOffset();
        int endOffset = highlightRange.getEndOffset() + tag.length();

        for (Map.Entry<Integer, Integer> entry1 : faultMap.entrySet()) {
          if (entry1.getKey() < highlightRange.getStartOffset()) {
            startOffset += entry1.getValue();
          }
          if (entry1.getKey() < highlightRange.getEndOffset()) {
            endOffset += entry1.getValue();
          }
        }

        if (flag == ParameterInfoUIContextEx.Flag.HIGHLIGHT && isDisabledBeforeHighlight) {
          final String disableCloseTag = getClosingTag(disabledTag);
          labelText.insert(startOffset, disableCloseTag);
          faultMap.put(highlightRange.getStartOffset(), disableCloseTag.length());
        }

        labelText.insert(startOffset, tag);
        faultMap.put(highlightRange.getStartOffset(), tag.length());

        final String endTag = getClosingTag(tagValue);
        labelText.insert(endOffset, endTag);
        faultMap.put(highlightRange.getEndOffset(), endTag.length());
      }
      return XmlStringUtil.wrapInHtml(labelText);
    }
  public void removeEntryPoint(RefElement anEntryPoint) {
    if (anEntryPoint instanceof RefClass) {
      RefClass refClass = (RefClass) anEntryPoint;
      if (!refClass.isInterface()) {
        anEntryPoint = refClass.getDefaultConstructor();
      }
    }

    if (anEntryPoint == null) return;

    myTemporaryEntryPoints.remove(anEntryPoint);

    Set<Map.Entry<String, SmartRefElementPointer>> set = myPersistentEntryPoints.entrySet();
    String key = null;
    for (Map.Entry<String, SmartRefElementPointer> entry : set) {
      SmartRefElementPointer value = entry.getValue();
      if (value.getRefElement() == anEntryPoint) {
        key = entry.getKey();
        break;
      }
    }

    if (key != null) {
      myPersistentEntryPoints.remove(key);
      ((RefElementImpl) anEntryPoint).setEntry(false);
    }

    if (anEntryPoint.isPermanentEntry() && anEntryPoint.isValid()) {
      final Project project = anEntryPoint.getElement().getProject();
      final EntryPointsManagerImpl entryPointsManager = getInstance(project);
      if (this != entryPointsManager) {
        entryPointsManager.removeEntryPoint(anEntryPoint);
      }
    }
  }
 /**
  * Prepare branch descriptors for existing configuration
  *
  * @param target the target
  * @param roots the vcs root
  * @return the list of branch descriptors
  * @throws VcsException in case of error
  */
 private List<BranchDescriptor> prepareBranchDescriptors(
     BranchConfiguration target, List<VirtualFile> roots) throws VcsException {
   Map<String, String> map =
       target == null ? Collections.<String, String>emptyMap() : target.getReferences();
   List<BranchDescriptor> rc = new ArrayList<BranchDescriptor>();
   for (VirtualFile root : roots) {
     BranchDescriptor d = new BranchDescriptor();
     d.root = root;
     d.storedReference = map.remove(root.getPath());
     if (d.storedReference != null) {
       d.storedRoot = d.root.getPath();
     }
     d.currentReference = myConfig.describeRoot(root);
     if (d.storedReference != null && !myModify) {
       d.referenceToCheckout = d.storedReference;
     } else {
       d.referenceToCheckout = d.currentReference;
     }
     Branch.listAsStrings(myProject, root, false, true, d.existingBranches, null);
     Branch.listAsStrings(myProject, root, true, true, d.referencesToSelect, null);
     d.updateStatus();
     rc.add(d);
   }
   for (Map.Entry<String, String> m : map.entrySet()) {
     String root = m.getKey();
     String ref = m.getValue();
     BranchDescriptor d = new BranchDescriptor();
     d.storedReference = ref;
     d.storedRoot = root;
     d.referenceToCheckout = ref;
     d.updateStatus();
     rc.add(d);
   }
   return rc;
 }
  private void copyCustomSettingsFrom(@NotNull CodeStyleSettings from) {
    synchronized (myCustomSettings) {
      myCustomSettings.clear();

      for (final CustomCodeStyleSettings settings : from.getCustomSettingsValues()) {
        addCustomSettings((CustomCodeStyleSettings) settings.clone());
      }

      FIELD_TYPE_TO_NAME.copyFrom(from.FIELD_TYPE_TO_NAME);
      STATIC_FIELD_TYPE_TO_NAME.copyFrom(from.STATIC_FIELD_TYPE_TO_NAME);
      PARAMETER_TYPE_TO_NAME.copyFrom(from.PARAMETER_TYPE_TO_NAME);
      LOCAL_VARIABLE_TYPE_TO_NAME.copyFrom(from.LOCAL_VARIABLE_TYPE_TO_NAME);

      PACKAGES_TO_USE_IMPORT_ON_DEMAND.copyFrom(from.PACKAGES_TO_USE_IMPORT_ON_DEMAND);
      IMPORT_LAYOUT_TABLE.copyFrom(from.IMPORT_LAYOUT_TABLE);

      OTHER_INDENT_OPTIONS.copyFrom(from.OTHER_INDENT_OPTIONS);

      myAdditionalIndentOptions.clear();
      for (Map.Entry<FileType, IndentOptions> optionEntry :
          from.myAdditionalIndentOptions.entrySet()) {
        IndentOptions options = optionEntry.getValue();
        myAdditionalIndentOptions.put(optionEntry.getKey(), (IndentOptions) options.clone());
      }

      myCommonSettingsManager = from.myCommonSettingsManager.clone(this);
    }
  }
Ejemplo n.º 6
0
 private GroovyTreeNode(GroovyTreeNode parent, GroovyNode node) {
   this.parent = parent;
   this.node = node;
   for (Map.Entry<String, String> entry : node.attributes().entrySet()) {
     children.add(new GroovyTreeNode(this, entry.getKey(), entry.getValue()));
   }
   if (node.getNodeValue() instanceof List) {
     string = node.getNodeName();
     toolTip = String.format("Size: %d", ((List) node.getNodeValue()).size());
   } else {
     String truncated = node.text();
     if (truncated.contains("\n") || truncated.length() >= MAX_LENGTH) {
       int index = truncated.indexOf('\n');
       if (index > 0) truncated = truncated.substring(0, index);
       if (truncated.length() >= MAX_LENGTH) truncated = truncated.substring(0, MAX_LENGTH);
       string = String.format("<html><b>%s</b> = %s ...</html>", node.getNodeName(), truncated);
       toolTip = tameTooltipText(node.text());
     } else {
       string = String.format("<html><b>%s</b> = %s</html>", node.getNodeName(), truncated);
       toolTip = truncated;
     }
   }
   if (this.node.getNodeValue() instanceof List) {
     for (Object sub : ((List) this.node.getNodeValue())) {
       GroovyNode subnode = (GroovyNode) sub;
       children.add(new GroovyTreeNode(this, subnode));
     }
     Collections.sort(children);
   }
 }
Ejemplo n.º 7
0
 public static BiMap<Combo, Integer> getComboTuneMap() {
   int mod = getAsciiTuneMods();
   BiMap<Combo, Integer> map = HashBiMap.create();
   for (Map.Entry<Integer, Integer> entry : getAsciTuneMap().entrySet()) {
     map.put(new Combo(mod, entry.getKey()), entry.getValue());
   }
   return map;
 }
  @NotNull
  public static List<SymfonyInstallerVersion> getVersions(@NotNull String jsonContent) {

    JsonObject jsonObject = new JsonParser().parse(jsonContent).getAsJsonObject();

    List<SymfonyInstallerVersion> symfonyInstallerVersions = new ArrayList<>();

    // prevent adding duplicate version on alias names
    Set<String> aliasBranches = new HashSet<>();

    // get alias version, in most common order
    for (String s : new String[] {"latest", "lts"}) {
      JsonElement asJsonObject = jsonObject.get(s);
      if (asJsonObject == null) {
        continue;
      }

      String asString = asJsonObject.getAsString();
      aliasBranches.add(asString);

      symfonyInstallerVersions.add(
          new SymfonyInstallerVersion(s, String.format("%s (%s)", asString, s)));
    }

    List<SymfonyInstallerVersion> branches = new ArrayList<>();
    Set<Map.Entry<String, JsonElement>> entries = jsonObject.entrySet();
    for (Map.Entry<String, JsonElement> entry : entries) {
      if (!entry.getKey().matches("^\\d+\\.\\d+$")) {
        continue;
      }

      // "2.8.0-dev", "2.8.0-DEV" is not supported
      String asString = entry.getValue().getAsString();
      if (asString.matches(".*[a-zA-Z].*") || aliasBranches.contains(asString)) {
        continue;
      }

      branches.add(
          new SymfonyInstallerVersion(
              asString, String.format("%s (%s)", entry.getKey(), asString)));
    }

    branches.sort(Comparator.comparing(SymfonyInstallerVersion::getVersion));

    Collections.reverse(branches);

    symfonyInstallerVersions.addAll(branches);

    // we need reverse order for sorting them on version string
    List<SymfonyInstallerVersion> installableVersions = new ArrayList<>();
    for (JsonElement installable : jsonObject.getAsJsonArray("installable")) {
      installableVersions.add(new SymfonyInstallerVersion(installable.getAsString()));
    }
    Collections.reverse(installableVersions);

    symfonyInstallerVersions.addAll(installableVersions);
    return symfonyInstallerVersions;
  }
 private void rodytiAutoRinkinius() {
   zonaNeregAuto.setText("");
   for (Automobilis a : rg.neregAuto) zonaNeregAuto.append(a.toString() + "\n");
   zonaRegAuto.setText("");
   for (Map.Entry<String, Automobilis> me : rg.regAuto.entrySet())
     zonaRegAuto.append(String.format("%8s=%s\n", me.getKey(), me.getValue()));
   tfNeregKiekis.setText(Integer.toString(rg.neregAuto.size()));
   tfRegKiekis.setText(Integer.toString(rg.regAuto.size()));
 }
Ejemplo n.º 10
0
 public void printIdentified() {
   System.out.println("Identified elements follow");
   XMLOutputter outputter = new XMLOutputter();
   for (Map.Entry<String, XMLModelIdentifiable> stringXMLModelIdentifiableEntry :
       identifiedElements.entrySet()) {
     System.out.println("Original name: " + stringXMLModelIdentifiableEntry.getKey());
     stringXMLModelIdentifiableEntry.getValue().print(outputter, System.out);
   }
 }
 @Override
 @Nullable
 public ToolWindow getToolWindowByDescriptor(@NotNull final RunContentDescriptor descriptor) {
   for (Map.Entry<String, ContentManager> entry : myToolwindowIdToContentManagerMap.entrySet()) {
     if (getRunContentByDescriptor(entry.getValue(), descriptor) != null) {
       return ToolWindowManager.getInstance(myProject).getToolWindow(entry.getKey());
     }
   }
   return null;
 }
Ejemplo n.º 12
0
 @NotNull
 private static <K, V> Map<V, K> invertMap(@NotNull Map<K, V> map) {
   final Map<V, K> inverted = new HashMap<V, K>();
   for (Map.Entry<K, V> entry : map.entrySet()) {
     final V value = entry.getValue();
     if (!inverted.containsKey(value)) {
       inverted.put(value, entry.getKey());
     }
   }
   return inverted;
 }
  @NotNull
  public List<String> getDirNames() {
    final List<String> selectedDirs = new ArrayList<String>();

    for (Map.Entry<String, JCheckBox> entry : myCheckBoxes.entrySet()) {
      if (entry.getValue().isSelected()) {
        selectedDirs.add(entry.getKey());
      }
    }
    return selectedDirs;
  }
 private PropertiesFile getSelectedPropertiesFile() {
   if (mySelectedEditor == null) return null;
   PropertiesFile selectedFile = null;
   for (Map.Entry<PropertiesFile, Editor> entry : myEditors.entrySet()) {
     Editor editor = entry.getValue();
     if (editor == mySelectedEditor) {
       selectedFile = entry.getKey();
       break;
     }
   }
   return selectedFile;
 }
 @NotNull
 private Set<Usage> getReadOnlyUsages() {
   final Set<Usage> result = new THashSet<Usage>();
   final Set<Map.Entry<Usage, UsageNode>> usages = myUsageNodes.entrySet();
   for (Map.Entry<Usage, UsageNode> entry : usages) {
     Usage usage = entry.getKey();
     UsageNode node = entry.getValue();
     if (node != null && node != NULL_NODE && !node.isExcluded() && usage.isReadOnly()) {
       result.add(usage);
     }
   }
   return result;
 }
 @Nullable
 public InnerSearchableConfigurable findSubConfigurable(@NotNull final Class pageClass) {
   if (mySubPanelFactories == null) {
     buildConfigurables();
   }
   for (Map.Entry<ColorAndFontPanelFactory, InnerSearchableConfigurable> entry :
       mySubPanelFactories.entrySet()) {
     if (pageClass.isInstance(entry.getValue().createPanel().getSettingsPage())) {
       return entry.getValue();
     }
   }
   return null;
 }
  @Override
  public void dispose() {
    if (mySelectedEditor != null) {
      for (final Map.Entry<PropertiesFile, Editor> entry : myEditors.entrySet()) {
        if (mySelectedEditor.equals(entry.getValue())) {
          writeEditorPropertyValue(mySelectedEditor, entry.getKey(), null);
        }
      }
    }

    VirtualFileManager.getInstance().removeVirtualFileListener(myVfsListener);
    myDisposed = true;
    Disposer.dispose(myStructureViewComponent);
    releaseAllEditors();
  }
Ejemplo n.º 18
0
 private static Map<String, MultiValueOption<?>> getMultiValueOptions(
     String prefix, Options options) {
   Map<String, MultiValueOption<?>> result = new HashMap<String, MultiValueOption<?>>();
   for (Option option : options.getOptions()) {
     if (option instanceof MultiValueOption) {
       result.put(
           prefix + option.getName().replace(MultiValueOption.SUFFIX, ""),
           (MultiValueOption) option);
     }
   }
   for (Map.Entry<String, Options> entry : options.getChildOptions().entrySet()) {
     result.putAll(getMultiValueOptions(prefix + entry.getKey() + ".", entry.getValue()));
   }
   return result;
 }
Ejemplo n.º 19
0
 private static void applySystemFonts(UIDefaults defaults) {
   try {
     String fqn = UIUtil.getSystemLookAndFeelClassName();
     Object systemLookAndFeel = Class.forName(fqn).newInstance();
     final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults");
     superMethod.setAccessible(true);
     final UIDefaults systemDefaults = (UIDefaults) superMethod.invoke(systemLookAndFeel);
     for (Map.Entry<Object, Object> entry : systemDefaults.entrySet()) {
       if (entry.getValue() instanceof Font) {
         defaults.put(entry.getKey(), entry.getValue());
       }
     }
   } catch (Exception e) {
     log(e);
   }
 }
Ejemplo n.º 20
0
 WordListModel(ASDGrammar grammar) {
   Set entrySet = grammar.lexicon().entrySet();
   ArrayList words = new ArrayList(entrySet.size());
   for (Iterator it = entrySet.iterator(); it.hasNext(); ) {
     Map.Entry e = (Map.Entry) it.next();
     String word = (String) e.getKey();
     words.add(word);
   }
   Object[] wordArray = words.toArray();
   if (words.size() > 1)
     //       Arrays.sort(wordArray);
     Arrays.sort(wordArray, new WordComparator());
   for (int j = 0; j < wordArray.length; j++) {
     this.addElement((String) wordArray[j]);
   }
 }
  @Override
  @NotNull
  public Set<Usage> getExcludedUsages() {
    Set<Usage> result = new THashSet<Usage>();
    for (Map.Entry<Usage, UsageNode> entry : myUsageNodes.entrySet()) {
      UsageNode node = entry.getValue();
      Usage usage = entry.getKey();
      if (node == NULL_NODE || node == null) {
        continue;
      }
      if (node.isExcluded()) {
        result.add(usage);
      }
    }

    return result;
  }
Ejemplo n.º 22
0
  private void PrettyPrint(File file, TreeMap<String, Long> sortedMap) {

    //        Long size = 0L;
    //        ArrayList<Long> values = new ArrayList<Long>(sortedMap.values());

    Long total = 0L;
    for (Long value : sortedMap.values()) {
      total = total + value; // Can also be done by total += value;
    }

    log.append(file.getName() + ": " + readableFileSize(total) + "\n\n");
    for (Map.Entry<String, Long> entry : sortedMap.entrySet()) {
      log.append("[ " + readableFileSize(entry.getValue()) + " ]");
      log.append(" --> " + entry.getKey() + "\n");
    }
    //        log.append(sortedMap + "\n");
  }
Ejemplo n.º 23
0
 /** Draw the entire panel from the state */
 @SuppressWarnings("rawtypes")
 public void drawState() {
   // clear();
   Map.Entry entry;
   Point pt;
   Color col;
   synchronized (state) {
     for (Iterator it = state.entrySet().iterator(); it.hasNext(); ) {
       entry = (Map.Entry) it.next();
       pt = (Point) entry.getKey();
       col = (Color) entry.getValue();
       gr.setColor(col);
       gr.fillOval(pt.x, pt.y, 10, 10);
     }
   }
   repaint();
 }
Ejemplo n.º 24
0
 /**
  * \ Draw saved State (color dots on panel) on WhiteBoard
  *
  * @param outstream
  * @throws IOException
  */
 public void writeState(OutputStream outstream) throws IOException {
   if (state == null) return;
   synchronized (state) {
     DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(outstream));
     // DataOutputStream dos=new DataOutputStream(outstream);
     dos.writeInt(state.size());
     for (Map.Entry<Point, Color> entry : state.entrySet()) {
       Point point = entry.getKey();
       Color col = entry.getValue();
       dos.writeInt(point.x);
       dos.writeInt(point.x);
       dos.writeInt(col.getRGB());
     }
     dos.flush();
     System.out.println("wrote " + state.size() + " elements");
   }
 }
Ejemplo n.º 25
0
  /**
   * Makes a POST request and returns the server response.
   *
   * @param urlString the URL to post to
   * @param nameValuePairs a map of name/value pairs to supply in the request.
   * @return the server reply (either from the input stream or the error stream)
   */
  public static String doPost(String urlString, Map<String, String> nameValuePairs)
      throws IOException {
    URL url = new URL(urlString);
    URLConnection connection = url.openConnection();
    connection.setDoOutput(true);

    PrintWriter out = new PrintWriter(connection.getOutputStream());

    boolean first = true;
    for (Map.Entry<String, String> pair : nameValuePairs.entrySet()) {
      if (first) first = false;
      else out.print('&');
      String name = pair.getKey();
      String value = pair.getValue();
      out.print(name);
      out.print('=');
      out.print(URLEncoder.encode(value, "UTF-8"));
    }

    out.close();

    Scanner in;
    StringBuilder response = new StringBuilder();
    try {
      in = new Scanner(connection.getInputStream());
    } catch (IOException e) {
      if (!(connection instanceof HttpURLConnection)) throw e;
      InputStream err = ((HttpURLConnection) connection).getErrorStream();
      if (err == null) throw e;
      in = new Scanner(err);
    }

    while (in.hasNextLine()) {
      response.append(in.nextLine());
      response.append("\n");
    }

    in.close();
    return response.toString();
  }
Ejemplo n.º 26
0
  private static void patchHiDPI(UIDefaults defaults) {
    if (!JBUI.isHiDPI()) return;

    List<String> myIntKeys = Arrays.asList("Tree.leftChildIndent", "Tree.rightChildIndent");
    List<String> patched = new ArrayList<String>();
    for (Map.Entry<Object, Object> entry : defaults.entrySet()) {
      Object value = entry.getValue();
      String key = entry.getKey().toString();
      if (value instanceof DimensionUIResource) {
        entry.setValue(JBUI.size((DimensionUIResource) value).asUIResource());
      } else if (value instanceof InsetsUIResource) {
        entry.setValue(JBUI.insets(((InsetsUIResource) value)).asUIResource());
      } else if (value instanceof Integer) {
        if (key.endsWith(".maxGutterIconWidth") || myIntKeys.contains(key)) {
          if (!"true".equals(defaults.get(key + ".hidpi.patched"))) {
            entry.setValue(Integer.valueOf(JBUI.scale((Integer) value)));
            patched.add(key);
          }
        }
      }
    }
    for (String key : patched) {
      defaults.put(key + ".hidpi.patched", "true");
    }
  }
Ejemplo n.º 27
0
    void populateTable(HashMap data) {
      String key, strval = "<null>";
      Object val;
      int num_rows = 0;
      Map.Entry entry;

      if (data == null) return;
      num_rows = data.size();
      clearTable();

      if (num_rows > 0) {
        for (Iterator it = data.entrySet().iterator(); it.hasNext(); ) {
          entry = (Map.Entry) it.next();
          key = (String) entry.getKey();
          val = entry.getValue();
          if (val != null) strval = val.toString();
          table_model.addRow(new Object[] {key, strval});
        }
        table_model.fireTableRowsInserted(0, num_rows - 1);
        validate();
      }
    }
Ejemplo n.º 28
0
 private static JFreeChart[] createPresenceCharts(
     Stats.RecordStats recordStats, String which, String name) {
   if (recordStats == null) return null;
   int bars = recordStats.frequencies.size();
   JFreeChart[] charts;
   if (bars > MAX_BAR_CHART_SIZE) {
     charts = new JFreeChart[bars / MAX_BAR_CHART_SIZE + 1];
   } else {
     charts = new JFreeChart[1];
   }
   Iterator<Map.Entry<Path, Stats.Histogram>> entryWalk =
       recordStats.frequencies.entrySet().iterator();
   int chartSize = bars / charts.length;
   for (int walk = 0; walk < charts.length; walk++) {
     DefaultCategoryDataset data = new DefaultCategoryDataset();
     if (walk == charts.length - 1) chartSize = MAX_BAR_CHART_SIZE;
     for (int count = 0; count < chartSize; count++) {
       if (!entryWalk.hasNext()) continue;
       Map.Entry<Path, Stats.Histogram> histogramEntry = entryWalk.next();
       data.addValue(
           histogramEntry.getValue().absent, "Absent", histogramEntry.getKey().getTail());
       data.addValue(
           histogramEntry.getValue().present, "Present", histogramEntry.getKey().getTail());
     }
     charts[walk] =
         finishBarChart(
             ChartFactory.createBarChart(
                 String.format("Fields presence in %s of %s", which, name),
                 "Field",
                 "Record count",
                 data,
                 PlotOrientation.VERTICAL,
                 true,
                 true,
                 false));
   }
   return charts;
 }
  private ActionCallback processAjusted(
      final Map<Object, Condition> adjusted, final Set<Object> originallySelected) {
    final ActionCallback result = new ActionCallback();

    final Set<Object> allSelected = myUi.getSelectedElements();

    Set<Object> toSelect = new HashSet<Object>();
    for (Map.Entry<Object, Condition> entry : adjusted.entrySet()) {
      if (entry.getValue().value(entry.getKey())) continue;

      for (final Object eachSelected : allSelected) {
        if (isParentOrSame(entry.getKey(), eachSelected)) continue;
        toSelect.add(entry.getKey());
      }
      if (allSelected.isEmpty()) {
        toSelect.add(entry.getKey());
      }
    }

    final Object[] newSelection = ArrayUtil.toObjectArray(toSelect);

    if (newSelection.length > 0) {
      myUi._select(
          newSelection,
          new Runnable() {
            @Override
            public void run() {
              final Set<Object> hangByParent = new HashSet<Object>();
              processUnsuccessfulSelections(
                  newSelection,
                  new Function<Object, Object>() {
                    @Override
                    public Object fun(final Object o) {
                      if (myUi.isInStructure(o) && !adjusted.get(o).value(o)) {
                        hangByParent.add(o);
                      } else {
                        addAdjustedSelection(o, adjusted.get(o), null);
                      }
                      return null;
                    }
                  },
                  originallySelected);

              processHangByParent(hangByParent).notify(result);
            }
          },
          false,
          true,
          true);
    } else {
      result.setDone();
    }

    return result;
  }
Ejemplo n.º 30
0
  public void prefixIdentifiedNames(String prefix, Map<String, String> special, boolean keepID) {
    if (special == null) {
      special = new HashMap<String, String>();
    }

    for (Map.Entry<String, XMLModelIdentifiable> stringXMLModelIdentifiableEntry :
        identifiedElements.entrySet()) {
      String newName;
      if (special.containsKey(stringXMLModelIdentifiableEntry.getKey())) { // assign a special name
        newName = special.get(stringXMLModelIdentifiableEntry.getKey());
        if (keepID) {
          stringXMLModelIdentifiableEntry.getValue().restoreDefinition();
        } else {
          stringXMLModelIdentifiableEntry.getValue().removeDefinition();
        }
      } else {
        newName = prefix + stringXMLModelIdentifiableEntry.getKey();
      }
      stringXMLModelIdentifiableEntry.getValue().rename(newName);
    }
  }