private void traverseToLeaves(
     final PackageDependenciesNode treeNode,
     final StringBuffer denyRules,
     final StringBuffer allowRules) {
   final Enumeration enumeration = treeNode.breadthFirstEnumeration();
   while (enumeration.hasMoreElements()) {
     PsiElement childPsiElement =
         ((PackageDependenciesNode) enumeration.nextElement()).getPsiElement();
     if (myIllegalDependencies.containsKey(childPsiElement)) {
       final Map<DependencyRule, Set<PsiFile>> illegalDeps =
           myIllegalDependencies.get(childPsiElement);
       for (final DependencyRule rule : illegalDeps.keySet()) {
         if (rule.isDenyRule()) {
           if (denyRules.indexOf(rule.getDisplayText()) == -1) {
             denyRules.append(rule.getDisplayText());
             denyRules.append("\n");
           }
         } else {
           if (allowRules.indexOf(rule.getDisplayText()) == -1) {
             allowRules.append(rule.getDisplayText());
             allowRules.append("\n");
           }
         }
       }
     }
   }
 }
예제 #2
0
  public Font toFont() {
    StringBuffer stringBuffer = new StringBuffer(getFont());
    String fontName = stringBuffer.substring(0, stringBuffer.indexOf("-"));
    stringBuffer = stringBuffer.delete(0, stringBuffer.indexOf("-") + 1);
    String dataStyle = stringBuffer.substring(0, stringBuffer.indexOf("-"));
    if (dataStyle.equalsIgnoreCase("PLAIN")) fontStyle = Font.PLAIN;
    else if (dataStyle.equalsIgnoreCase("BOLD")) fontStyle = Font.BOLD;
    else if (dataStyle.equalsIgnoreCase("")) fontStyle = Font.ITALIC;

    stringBuffer = stringBuffer.delete(0, stringBuffer.indexOf("-") + 1);
    int fontSize = Integer.parseInt(stringBuffer.toString());

    Font font = new Font(fontName, fontStyle, fontSize);
    return font;
  }
예제 #3
0
    public void execute() {
      if (!isEditable() || !isEnabled()) {
        return;
      }
      int position = lastClickPoint != null ? viewToModel(lastClickPoint) : getCaretPosition();
      lastClickPoint = null;
      Document document = getDocument();
      String selectedText = getSelectedText();

      try {
        if (selectedText != null && !CommonUtil.isEmpty(selectedText)) {
          String trimmed = selectedText.trim();
          if (trimmed.startsWith("<!--") && trimmed.endsWith("-->")) {
            StringBuffer buffer = new StringBuffer(selectedText);
            int pos = buffer.indexOf("<!--");
            buffer.delete(pos, pos + 4);
            pos = buffer.lastIndexOf("-->");
            buffer.delete(pos, pos + 3);
            replaceSelection(buffer.toString());
          } else {
            String newSelection = "<!--" + selectedText + "-->";
            replaceSelection(newSelection);
          }
        } else {
          final int docLen = document.getLength();
          int fromIndex = Math.max(0, getText(0, position).lastIndexOf('\n'));
          int toIndex = getText(fromIndex + 1, docLen - position).indexOf('\n');
          toIndex = toIndex < 0 ? docLen : fromIndex + toIndex;
          String textToComment = getText(fromIndex, toIndex - fromIndex + 1);

          if (textToComment.startsWith("\n")) {
            textToComment = textToComment.substring(1);
            fromIndex++;
          }
          if (textToComment.endsWith("\n")) {
            textToComment = textToComment.substring(0, textToComment.length() - 1);
            toIndex--;
          }
          String trimmed = textToComment.trim();
          if (trimmed.startsWith("<!--") && trimmed.endsWith("-->")) {
            int pos = textToComment.lastIndexOf("-->");
            document.remove(fromIndex + pos, 3);
            pos = textToComment.indexOf("<!--");
            document.remove(fromIndex + pos, 4);
          } else {
            document.insertString(Math.min(toIndex + 1, docLen), "-->", null);
            document.insertString(fromIndex, "<!--", null);
          }
        }
      } catch (BadLocationException e1) {
        e1.printStackTrace();
      }
    }
  /**
   * Makes the label clickable or makes it unclickable. Clickable label features bold and underlined
   * text
   *
   * @param clickable Is the label clickable
   * @param action Action to be performed on click
   * @param rolloverIcon Icon to display on rollover
   * @since Jun 13, 2006 2:00:57 AM
   */
  public void setClickable(
      final boolean clickable, final ActionListener action, final Icon rolloverIcon) {
    if (clickable) {
      //  Set the action
      this.action = action;

      //  Set the offIcon;
      this.offIcon = getIcon();
      setIcon(offIcon);

      //  Add a Mouse Listener
      addMouseListener(this);

      //  Set the text (Undelined and Bolded)
      setText(
          new StringBuffer("<html><b><u>").append(getText()).append("</u></b></html>").toString());

      //  Set the rollover icon
      this.rolloverIcon = rolloverIcon;

      //  Init the Color and Mouse Cursor
      setForeground(offColor);
    } else {
      // Set the action to null
      this.action = null;

      // Remove the Mouse Listener
      removeMouseListener(this);

      //  Change the text back to normal
      final StringBuffer textBuffer = new StringBuffer(getText());
      final int msgEnd = textBuffer.indexOf("</u></b></html>");
      setText(textBuffer.substring(12, msgEnd));

      //  Set the rollover icon
      this.rolloverIcon = null;
    }

    // Repaint the Label
    repaint();
  }
  public static boolean parse(StringBuffer pattern, GElementTMOperation gop) {
    TMOperation op = gop.getOperation();
    String s = pattern.toString();

    if (s.startsWith(TMOperation.OPS_LEFT_UNTIL)) {
      pattern.delete(0, 2);
      gop.setLabel(TMOperation.OPS_LEFT_UNTIL + pattern.charAt(0));
      op.setOperation(TMOperation.OP_LEFT_UNTIL);
      op.setParameter(pattern.substring(0, 1));
      pattern.deleteCharAt(0);
    } else if (s.startsWith(TMOperation.OPS_LEFT_UNTIL_NOT)) {
      pattern.delete(0, 2);
      gop.setLabel(TMOperation.OPS_LEFT_UNTIL_NOT + pattern.charAt(0));
      op.setOperation(TMOperation.OP_LEFT_UNTIL_NOT);
      op.setParameter(pattern.substring(0, 1));
      pattern.deleteCharAt(0);
    } else if (s.startsWith(TMOperation.OPS_LEFT)) {
      pattern.deleteCharAt(0);
      gop.setLabel(TMOperation.OPS_LEFT);
      op.setOperation(TMOperation.OP_LEFT);
    } else if (s.startsWith(TMOperation.OPS_RIGHT_UNTIL)) {
      pattern.delete(0, 2);
      gop.setLabel(TMOperation.OPS_RIGHT_UNTIL + pattern.charAt(0));
      op.setOperation(TMOperation.OP_RIGHT_UNTIL);
      op.setParameter(pattern.substring(0, 1));
      pattern.deleteCharAt(0);
    } else if (s.startsWith(TMOperation.OPS_RIGHT_UNTIL_NOT)) {
      pattern.delete(0, 2);
      gop.setLabel(TMOperation.OPS_RIGHT_UNTIL_NOT + pattern.charAt(0));
      op.setOperation(TMOperation.OP_RIGHT_UNTIL_NOT);
      op.setParameter(pattern.substring(0, 1));
      pattern.deleteCharAt(0);
    } else if (s.startsWith(TMOperation.OPS_RIGHT)) {
      pattern.deleteCharAt(0);
      gop.setLabel(TMOperation.OPS_RIGHT);
      op.setOperation(TMOperation.OP_RIGHT);
    } else if (s.startsWith(TMOperation.OPS_OUTPUT)) {
      gop.setLabel(TMOperation.OPS_OUTPUT);
      op.setOperation(TMOperation.OP_OUTPUT);
      pattern.deleteCharAt(0);
    } else if (s.startsWith(TMOperation.OPS_YES)) {
      gop.setLabel(TMOperation.OPS_YES);
      op.setOperation(TMOperation.OP_YES);
      pattern.deleteCharAt(0);
    } else if (s.startsWith(TMOperation.OPS_NO)) {
      gop.setLabel(TMOperation.OPS_NO);
      op.setOperation(TMOperation.OP_NO);
      pattern.deleteCharAt(0);
    } else if (s.startsWith(TMOperation.OPS_CALL)) {
      pattern.deleteCharAt(0); // consume M
      pattern.deleteCharAt(0); // consume [
      String machineName = pattern.substring(0, pattern.indexOf("]"));
      pattern.delete(0, pattern.indexOf("]") + 1);

      op.setOperation(TMOperation.OP_CALL);
      op.setParameter(machineName);
      gop.setLabel(TMOperation.OP_CALL + "[" + op.getParameter() + "]");
    } else {
      op.setOperation(TMOperation.OP_WRITE);
      if (s.startsWith(TMMachine.SYMBOL_VAR)) {
        op.setParameter(pattern.substring(0, 2));
        pattern.delete(0, 2);
      } else {
        op.setParameter(pattern.substring(0, 1));
        pattern.deleteCharAt(0);
      }
      gop.setLabel(op.getParameter());
    }

    return true;
  }