private JPanel createDynamicCenterPanel(PrimitiveForm primitiveForm, DOTProperty property) {
    final JTable theTable = new JTable();
    PrimitiveFormPropertyPair pfpPair =
        new PrimitiveFormPropertyPair(primitiveForm.getName(), property);
    _dynamicTables.put(pfpPair, theTable);
    DOTPoint dotPoint = (DOTPoint) _dotDefinitionDialogFrame.getScratchDisplayObjectType();
    final DynamicDOTItemManager tableModel =
        (DynamicDOTItemManager) dotPoint.getTableModel(primitiveForm, property);
    theTable.setModel(tableModel);

    class NumberComparator implements Comparator<Number> {

      public int compare(Number o1, Number o2) {
        final double d1 = o1.doubleValue();
        final double d2 = o2.doubleValue();
        if (d1 < d2) {
          return -1;
        }
        if (d1 == d2) {
          return 0;
        }
        return 1;
      }
    }
    TableRowSorter<DynamicDOTItemManager> tableRowSorter =
        new TableRowSorter<DynamicDOTItemManager>();
    tableRowSorter.setModel(tableModel);
    tableRowSorter.setComparator(4, new NumberComparator());
    tableRowSorter.setComparator(5, new NumberComparator());
    theTable.setRowSorter(tableRowSorter);

    JButton newDOTItemButton = new JButton("Neue Zeile");
    newDOTItemButton.setEnabled(_dotDefinitionDialogFrame.isEditable());
    JButton deleteDOTItemButton = new JButton("Zeile löschen");
    deleteDOTItemButton.setEnabled(false);
    JButton showConflictsButton = new JButton("Zeige Konflikte");

    addButtonListeners(
        primitiveForm, property, newDOTItemButton, deleteDOTItemButton, showConflictsButton);
    addListSelectionListener(theTable, deleteDOTItemButton);

    JPanel dotButtonsPanel = new JPanel();
    dotButtonsPanel.setLayout(new SpringLayout());

    dotButtonsPanel.add(newDOTItemButton);
    dotButtonsPanel.add(deleteDOTItemButton);
    dotButtonsPanel.add(showConflictsButton);

    dotButtonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
    SpringUtilities.makeCompactGrid(dotButtonsPanel, 1, 5, 20);

    JPanel thePanel = new JPanel();
    thePanel.setLayout(new SpringLayout());
    thePanel.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.BLACK));
    thePanel.add(new JScrollPane(theTable));
    thePanel.add(dotButtonsPanel);
    SpringUtilities.makeCompactGrid(thePanel, 2, 20, 5);

    return thePanel;
  }
示例#2
1
  /**
   * Handles the move put from a Client.
   *
   * @param params is a String array containing the blocks to place
   */
  public void doMovePut(String[] params) {
    Map<Point, Block> moves = new HashMap<>();

    for (String move : params) {
      String[] moveArg = move.split("@");
      int blockId = Integer.parseInt(moveArg[0]);
      int moveX = Integer.parseInt(moveArg[1].split(",")[0]);
      int moveY = Integer.parseInt(moveArg[1].split(",")[1]);

      moves.put(new Point(moveX, moveY), new Block(blockId));
    }

    try {
      game.doMovePut(moves);
      System.out.println("[Server] (ClientHandler) - Current game situation:");
      System.out.println(game.getBoard().toString());
    } catch (InvalidMoveException e) {
      sendError(IProtocol.Error.MOVE_INVALID.ordinal() + " Invalid move");
      game.sendPlayerTurn();
    } catch (TilesUnownedException e) {
      sendError(
          IProtocol.Error.MOVE_TILES_UNOWNED.ordinal() + " Player tried to place unowned tile");
      game.sendPlayerTurn();
    } catch (NullPointerException e) {
      System.out.println("[Server] ClientHandler - Game ended during turn.");
    }
  }
  /** ***************************************************************************** */
  BddtHistoryBubble(BddtLaunchControl ctrl, BddtHistoryData hd) {
    history_data = hd;
    for_control = ctrl;
    history_graph = null;
    last_update = 0;
    update_needed = true;
    restart_needed = true;
    x_scale = 1;
    y_scale = 1;
    thread_colors = new HashMap<BumpThread, Color>();
    type_strokes = new EnumMap<LinkType, Stroke>(LinkType.class);
    type_strokes.put(
        LinkType.ENTER,
        new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1.0f, DOTTED, 0));
    type_strokes.put(
        LinkType.RETURN,
        new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1.0f, DASHED, 0));
    type_strokes.put(LinkType.NEXT, new BasicStroke(1));
    arrow_stroke = new BasicStroke(1);

    updateGraph();

    hd.addHistoryListener(this);

    setupPanel();

    draw_area.addMouseListener(new FocusOnEntry());
  }
  public HierarchyBrowserBaseEx(@NotNull Project project, @NotNull PsiElement element) {
    super(project);

    setHierarchyBase(element);

    myCardLayout = new CardLayout();
    myTreePanel = new JPanel(myCardLayout);

    createTrees(myType2TreeMap);

    final HierarchyBrowserManager.State state =
        HierarchyBrowserManager.getInstance(project).getState();
    for (String type : myType2TreeMap.keySet()) {
      myType2ScopeMap.put(type, state.SCOPE != null ? state.SCOPE : SCOPE_ALL);
    }

    final Enumeration<String> keys = myType2TreeMap.keys();
    while (keys.hasMoreElements()) {
      final String key = keys.nextElement();
      final JTree tree = myType2TreeMap.get(key);
      myOccurrenceNavigators.put(
          key,
          new OccurenceNavigatorSupport(tree) {
            @Override
            @Nullable
            protected Navigatable createDescriptorForNode(DefaultMutableTreeNode node) {
              final HierarchyNodeDescriptor descriptor = getDescriptor(node);
              if (descriptor == null) return null;
              PsiElement psiElement = getOpenFileElementFromDescriptor(descriptor);
              if (psiElement == null || !psiElement.isValid()) return null;
              final VirtualFile virtualFile = psiElement.getContainingFile().getVirtualFile();
              if (virtualFile == null) return null;
              return new OpenFileDescriptor(
                  psiElement.getProject(), virtualFile, psiElement.getTextOffset());
            }

            @Override
            public String getNextOccurenceActionName() {
              return getNextOccurenceActionNameImpl();
            }

            @Override
            public String getPreviousOccurenceActionName() {
              return getPrevOccurenceActionNameImpl();
            }
          });
      myTreePanel.add(ScrollPaneFactory.createScrollPane(tree), key);
    }

    final JPanel legendPanel = createLegendPanel();
    final JPanel contentPanel;
    if (legendPanel != null) {
      contentPanel = new JPanel(new BorderLayout());
      contentPanel.add(myTreePanel, BorderLayout.CENTER);
      contentPanel.add(legendPanel, BorderLayout.SOUTH);
    } else {
      contentPanel = myTreePanel;
    }
    buildUi(createToolbar(getActionPlace(), HELP_ID).getComponent(), contentPanel);
  }
 private GeoPoint[] sortPoints(GeoPoint... geoPoints) {
   Map<GeoPoint, Integer> pointCount = new LinkedHashMap<GeoPoint, Integer>();
   for (GeoPoint gp : geoPoints) {
     if (pointCount.containsKey(gp)) {
       pointCount.put(gp, pointCount.get(gp) + 1);
     } else {
       pointCount.put(gp, 1);
     }
   }
   GeoPoint center = null;
   GeoPoint end[] = new GeoPoint[2];
   GeoPoint side[] = new GeoPoint[4];
   int endIdx = 0;
   int sieIdx = 0;
   for (Map.Entry<GeoPoint, Integer> entry : pointCount.entrySet()) {
     switch (entry.getValue()) {
       case 4:
         assert center == null;
         center = entry.getKey();
         break;
       case 2:
         assert endIdx < end.length;
         end[endIdx++] = entry.getKey();
         break;
       case 1:
         assert sieIdx < side.length;
         side[sieIdx++] = entry.getKey();
         break;
     }
   }
   return new GeoPoint[] {center, end[0], side[0], side[1], end[1], side[3], side[2]};
 }
 static {
   FONT_NAME_TO_STYLE.put("AnkaCoder-b", Font.BOLD);
   FONT_NAME_TO_STYLE.put("AnkaCoder-i", Font.ITALIC);
   FONT_NAME_TO_STYLE.put("AnkaCoder-bi", Font.BOLD | Font.ITALIC);
   FONT_NAME_TO_STYLE.put("SourceCodePro-It", Font.ITALIC);
   FONT_NAME_TO_STYLE.put("SourceCodePro-BoldIt", Font.BOLD | Font.ITALIC);
 }
 public void checkWarnings() {
   highlightingTypes.put(
       WARNING_MARKER, new ExpectedHighlightingSet(HighlightSeverity.WARNING, false, true));
   highlightingTypes.put(
       END_LINE_WARNING_MARKER,
       new ExpectedHighlightingSet(HighlightSeverity.WARNING, true, true));
 }
 public void checkInfos() {
   highlightingTypes.put(
       INFO_MARKER, new ExpectedHighlightingSet(HighlightSeverity.INFORMATION, false, true));
   highlightingTypes.put(
       "inject",
       new ExpectedHighlightingSet(HighlightInfoType.INJECTED_FRAGMENT_SEVERITY, false, true));
 }
  public GridImpl(ViewContextEx viewContext, String sessionName) {
    myViewContext = viewContext;
    mySessionName = sessionName;

    Disposer.register(myViewContext, this);
    Disposer.register(this, myTopSplit);

    Placeholder left = new Placeholder();
    myPlaceInGrid2Cell.put(
        PlaceInGrid.left, new GridCellImpl(myViewContext, this, left, PlaceInGrid.left));
    Placeholder center = new Placeholder();
    myPlaceInGrid2Cell.put(
        PlaceInGrid.center, new GridCellImpl(myViewContext, this, center, PlaceInGrid.center));
    Placeholder right = new Placeholder();
    myPlaceInGrid2Cell.put(
        PlaceInGrid.right, new GridCellImpl(myViewContext, this, right, PlaceInGrid.right));
    Placeholder bottom = new Placeholder();
    myPlaceInGrid2Cell.put(
        PlaceInGrid.bottom, new GridCellImpl(myViewContext, this, bottom, PlaceInGrid.bottom));

    setContent(mySplitter);
    setOpaque(false);
    setFocusCycleRoot(true);

    myTopSplit.setFirstComponent(left);
    myTopSplit.setInnerComponent(center);
    myTopSplit.setLastComponent(right);
    myTopSplit.setMinSize(48);
    mySplitter.setFirstComponent(myTopSplit);
    mySplitter.setSecondComponent(bottom);
  }
示例#10
0
 public IconListRenderer(Config config, TokenLabUI ui) throws IOException {
   this.ui = ui;
   this.config = config;
   icons = new HashMap<Object, Icon>();
   icons.put(OK, IconCreator.createImageIcon(CHECK_ICON, OK));
   icons.put(NOTOK, IconCreator.createImageIcon(X_ICON, NOTOK));
 }
示例#11
0
 {
   cmdmap.put(
       "sz",
       new Console.Command() {
         public void run(Console cons, String[] args) {
           if (args.length == 3) {
             int w = Integer.parseInt(args[1]), h = Integer.parseInt(args[2]);
             p.setSize(w, h);
             pack();
             Utils.setprefc("wndsz", new Coord(w, h));
           } else if (args.length == 2) {
             if (args[1].equals("dyn")) {
               setResizable(true);
               Utils.setprefb("wndlock", false);
             } else if (args[1].equals("lock")) {
               setResizable(false);
               Utils.setprefb("wndlock", true);
             }
           }
         }
       });
   cmdmap.put(
       "fsmode",
       new Console.Command() {
         public void run(Console cons, String[] args) throws Exception {
           if (args.length == 3) {
             DisplayMode mode = findmode(Integer.parseInt(args[1]), Integer.parseInt(args[2]));
             if (mode == null) throw (new Exception("No such mode is available"));
             fsmode = mode;
             Utils.setprefc("fsmode", new Coord(mode.getWidth(), mode.getHeight()));
           }
         }
       });
   cmdmap.put(
       "fs",
       new Console.Command() {
         public void run(Console cons, String[] args) {
           if (args.length >= 2) {
             Runnable r;
             if (Utils.atoi(args[1]) != 0) {
               r =
                   new Runnable() {
                     public void run() {
                       setfs();
                     }
                   };
             } else {
               r =
                   new Runnable() {
                     public void run() {
                       setwnd();
                     }
                   };
             }
             getToolkit().getSystemEventQueue().invokeLater(r);
           }
         }
       });
 }
  /**
   * Сохраняет размер фрейма
   *
   * @param className объект класса, размер фрейма которого нужно перезаписать
   * @param size размер фрейма
   */
  void updateSizeWindow(Class className, Dimension size) {
    sizeWindows.put(className, size);

    // Запысываем размер основного фрейма, так как при его закрытии происходит остановка приложения
    sizeWindows.put(MainFrame.class, MonitoringMoney.mainFrame.getSize());

    writeData();
  }
  /**
   * Сохраняет координату фоейма
   *
   * @param className объект класса, позицию фрейма которого нужно перезаписать
   * @param position координата фрейма
   */
  void updateLocationWindow(Class className, Point position) {
    locationWindows.put(className, position);

    // Запысываем положение основного фрейма, так как при его закрытии происходит остановка
    // приложения
    locationWindows.put(MainFrame.class, MonitoringMoney.mainFrame.getLocation());

    writeData();
  }
示例#14
0
 static {
   HEADING_LIST.put("H1 head line", 35);
   HEADING_LIST.put("H2 head line", 30);
   HEADING_LIST.put("H3 head line", 25);
   HEADING_LIST.put("H4 head line", 20);
   HEADING_LIST.put("H5 head line", 15);
   HEADING_LIST.put("Paragraph", 10);
   HEADING_LIST.put("Quote", 10);
 }
示例#15
0
 private static void initIconTypeMap() {
   ICON_TYPE_MAP = new HashMap<String, Integer>();
   ICON_TYPE_MAP.put("gtk-menu", Integer.valueOf(1));
   ICON_TYPE_MAP.put("gtk-small-toolbar", Integer.valueOf(2));
   ICON_TYPE_MAP.put("gtk-large-toolbar", Integer.valueOf(3));
   ICON_TYPE_MAP.put("gtk-button", Integer.valueOf(4));
   ICON_TYPE_MAP.put("gtk-dnd", Integer.valueOf(5));
   ICON_TYPE_MAP.put("gtk-dialog", Integer.valueOf(6));
 }
 private void setEnabled(IdeaPluginDescriptor ideaPluginDescriptor, final boolean enabled) {
   final Collection<String> disabledPlugins = PluginManager.getDisabledPlugins();
   final PluginId pluginId = ideaPluginDescriptor.getPluginId();
   if (!enabled && !disabledPlugins.contains(pluginId.toString())) {
     myEnabled.put(pluginId, null);
   } else {
     myEnabled.put(pluginId, enabled);
   }
 }
 {
   cursors.put(1, Cursor.N_RESIZE_CURSOR);
   cursors.put(2, Cursor.W_RESIZE_CURSOR);
   cursors.put(4, Cursor.S_RESIZE_CURSOR);
   cursors.put(8, Cursor.E_RESIZE_CURSOR);
   cursors.put(3, Cursor.NW_RESIZE_CURSOR);
   cursors.put(9, Cursor.NE_RESIZE_CURSOR);
   cursors.put(6, Cursor.SW_RESIZE_CURSOR);
   cursors.put(12, Cursor.SE_RESIZE_CURSOR);
 }
示例#18
0
 public NewBotDialog(DarkBotMCUI ui) {
   super(ui);
   this.ui = ui;
   optionsUIs = new HashMap<String, BotOptionsUI>();
   optionsUIs.put("Regular", new RegularBotOptionsUI());
   optionsUIs.put("Spambot", new SpamBotOptionsUI());
   initComponents();
   updateSelectedBotType();
   typeComboBox.setModel(new DefaultComboBoxModel(optionsUIs.keySet().toArray()));
   setVisible(true);
 }
示例#19
0
文件: MoveATub.java 项目: wwake/dpij
 private static Map<String, String> tubMachine() {
   if (tubMachine == null) {
     tubMachine = new HashMap<>();
     tubMachine.put("T502", "Mixer-2201");
     tubMachine.put("T503", "Mixer-2201");
     tubMachine.put("T504", "Mixer-2201");
     tubMachine.put("T101", "StarPress-2402");
     tubMachine.put("T102", "StarPress-2402");
   }
   return tubMachine;
 }
示例#20
0
 public void registerSeverity(@NotNull SeverityBasedTextAttributes info, Color renderColor) {
   final HighlightSeverity severity = info.getType().getSeverity(null);
   myMap.put(severity.getName(), info);
   if (renderColor != null) {
     myRendererColors.put(severity.getName(), renderColor);
   }
   myOrderMap = null;
   HighlightDisplayLevel.registerSeverity(
       severity, getHighlightInfoTypeBySeverity(severity).getAttributesKey());
   severitiesChanged();
 }
 @Nullable
 private FrameworkSupportNode createNode(
     final FrameworkSupportInModuleProvider provider,
     final Map<String, FrameworkSupportNode> nodes,
     final Map<FrameworkGroup<?>, FrameworkGroupNode> groupNodes,
     List<FrameworkSupportNodeBase> roots,
     List<FrameworkSupportInModuleProvider> providers,
     Set<String> associated,
     Map<String, FrameworkSupportNodeBase> associatedNodes) {
   String id = provider.getFrameworkType().getId();
   FrameworkSupportNode node = nodes.get(id);
   if (node != null || associatedNodes.containsKey(id)) {
     return node;
   }
   String underlyingTypeId = provider.getFrameworkType().getUnderlyingFrameworkTypeId();
   FrameworkSupportNodeBase parentNode = null;
   final FrameworkGroup<?> group = provider.getFrameworkType().getParentGroup();
   if (underlyingTypeId != null) {
     FrameworkSupportInModuleProvider parentProvider =
         FrameworkSupportUtil.findProvider(underlyingTypeId, providers);
     if (parentProvider == null) {
       LOG.info("Cannot find id = " + underlyingTypeId);
       return null;
     }
     parentNode =
         createNode(
             parentProvider, nodes, groupNodes, roots, providers, associated, associatedNodes);
   } else if (group != null) {
     parentNode = groupNodes.get(group);
     if (parentNode == null) {
       FrameworkGroupNode groupNode = new FrameworkGroupNode(group, null);
       if (associated.contains(groupNode.getId())) {
         associatedNodes.put(groupNode.getId(), groupNode);
       } else {
         groupNodes.put(group, groupNode);
         parentNode = groupNode;
         roots.add(groupNode);
       }
     }
   }
   node = new FrameworkSupportNode(provider, parentNode, myModel, this);
   if (associated.contains(id)) {
     associatedNodes.put(id, node);
   } else {
     nodes.put(id, node);
     if (parentNode == null) {
       roots.add(node);
     }
   }
   return node;
 }
  protected void initFonts() {
    String editorFontName = getEditorFontName();
    int editorFontSize = getEditorFontSize();

    myFallbackFontName =
        FontPreferences.getFallbackName(editorFontName, editorFontSize, myParentScheme);
    if (myFallbackFontName != null) {
      editorFontName = myFallbackFontName;
    }
    Font plainFont = new Font(editorFontName, Font.PLAIN, editorFontSize);
    Font boldFont = new Font(editorFontName, Font.BOLD, editorFontSize);
    Font italicFont = new Font(editorFontName, Font.ITALIC, editorFontSize);
    Font boldItalicFont = new Font(editorFontName, Font.BOLD | Font.ITALIC, editorFontSize);

    myFonts.put(EditorFontType.PLAIN, plainFont);
    myFonts.put(EditorFontType.BOLD, boldFont);
    myFonts.put(EditorFontType.ITALIC, italicFont);
    myFonts.put(EditorFontType.BOLD_ITALIC, boldItalicFont);

    String consoleFontName = getConsoleFontName();
    int consoleFontSize = getConsoleFontSize();

    Font consolePlainFont = new Font(consoleFontName, Font.PLAIN, consoleFontSize);
    Font consoleBoldFont = new Font(consoleFontName, Font.BOLD, consoleFontSize);
    Font consoleItalicFont = new Font(consoleFontName, Font.ITALIC, consoleFontSize);
    Font consoleBoldItalicFont =
        new Font(consoleFontName, Font.BOLD | Font.ITALIC, consoleFontSize);

    myFonts.put(EditorFontType.CONSOLE_PLAIN, consolePlainFont);
    myFonts.put(EditorFontType.CONSOLE_BOLD, consoleBoldFont);
    myFonts.put(EditorFontType.CONSOLE_ITALIC, consoleItalicFont);
    myFonts.put(EditorFontType.CONSOLE_BOLD_ITALIC, consoleBoldItalicFont);
  }
 private String setup(
     String text,
     boolean isDisabled,
     boolean isStrikeout,
     Color background,
     @Nullable TextRange range) {
   Map<TextRange, ParameterInfoUIContextEx.Flag> flagsMap = new TreeMap<>(TEXT_RANGE_COMPARATOR);
   if (range != null) flagsMap.put(range, ParameterInfoUIContextEx.Flag.HIGHLIGHT);
   if (isDisabled)
     flagsMap.put(TextRange.create(0, text.length()), ParameterInfoUIContextEx.Flag.DISABLE);
   if (isStrikeout)
     flagsMap.put(TextRange.create(0, text.length()), ParameterInfoUIContextEx.Flag.STRIKEOUT);
   return setup(text, flagsMap, background);
 }
  public static ColorSampleLookupValue[] getColors() {
    if (ourColors == null) {
      synchronized (ColorSampleLookupValue.class) {
        if (ourColors == null) {
          ourColorNameToHexCodeMap = new HashMap<String, String>(25);
          ourHexCodeToColorNameMap = new HashMap<String, String>(25);
          List<ColorSampleLookupValue> colorsList = new LinkedList<ColorSampleLookupValue>();
          StringTokenizer tokenizer = new StringTokenizer(systemColorsString, "\n");

          while (tokenizer.hasMoreTokens()) {
            String name = tokenizer.nextToken();
            colorsList.add(new ColorSampleLookupValue(name, name, false));
            tokenizer.nextToken();
          }

          tokenizer = new StringTokenizer(standardColorsString, ", \n");
          HashMap<String, String> standardColors = new HashMap<String, String>();

          while (tokenizer.hasMoreTokens()) {
            String name = tokenizer.nextToken();
            String value = tokenizer.nextToken();
            standardColors.put(name, name);
            ourColorNameToHexCodeMap.put(name, value);
            ourHexCodeToColorNameMap.put(value, name);

            colorsList.add(new ColorSampleLookupValue(name, value, true));
          }

          tokenizer = new StringTokenizer(colorsString, " \t\n");

          while (tokenizer.hasMoreTokens()) {
            String name = tokenizer.nextToken();
            String hexValue = tokenizer.nextToken();

            tokenizer.nextToken(); // skip rgb

            if (!standardColors.containsKey(name)) {
              colorsList.add(new ColorSampleLookupValue(name, hexValue, false));
              ourColorNameToHexCodeMap.put(name, hexValue);
              ourHexCodeToColorNameMap.put(hexValue, name);
            }
          }

          colorsList.toArray(ourColors = new ColorSampleLookupValue[colorsList.size()]);
        }
      }
    }
    return ourColors;
  }
示例#25
0
 /**
  * Tries to calculate given line's indent column assuming that there might be a comment at the
  * given indent offset (see {@link #getCommentPrefix(IElementType)}).
  *
  * @param line target line
  * @param indentOffset start indent offset to use for the given line
  * @param lineEndOffset given line's end offset
  * @param fallbackColumn column to return if it's not possible to apply comment-specific indent
  *     calculation rules
  * @return given line's indent column to use
  */
 private int calcIndent(int line, int indentOffset, int lineEndOffset, int fallbackColumn) {
   final HighlighterIterator it = myEditor.getHighlighter().createIterator(indentOffset);
   IElementType tokenType = it.getTokenType();
   Language language = tokenType.getLanguage();
   TokenSet comments = myComments.get(language);
   if (comments == null) {
     ParserDefinition definition = LanguageParserDefinitions.INSTANCE.forLanguage(language);
     if (definition != null) {
       comments = definition.getCommentTokens();
     }
     if (comments == null) {
       return fallbackColumn;
     } else {
       myComments.put(language, comments);
     }
   }
   if (comments.contains(tokenType) && indentOffset == it.getStart()) {
     String prefix = COMMENT_PREFIXES.get(tokenType);
     if (prefix == null) {
       prefix = getCommentPrefix(tokenType);
     }
     if (!NO_COMMENT_INFO_MARKER.equals(prefix)) {
       final int indentInsideCommentOffset =
           CharArrayUtil.shiftForward(
               myChars, indentOffset + prefix.length(), lineEndOffset, " \t");
       if (indentInsideCommentOffset < lineEndOffset) {
         int indent = myEditor.calcColumnNumber(indentInsideCommentOffset, line);
         indentAfterUncomment.put(line, indent - prefix.length());
         return indent;
       }
     }
   }
   return fallbackColumn;
 }
示例#26
0
  /**
   * ** Returns an I18N instance based on the specified package name and Locale ** @param pkgName
   * The resource package name ** @param loc The Locale resource from with the localized text is
   * loaded
   */
  public static I18N getI18N(String pkgName, Locale loc) {
    if (pkgName != null) {
      loc = I18N.getLocale(loc);

      /* get package map for specific Locale */
      Map<String, I18N> packageMap = localeMap.get(loc);
      if (packageMap == null) {
        packageMap = new HashMap<String, I18N>();
        localeMap.put(loc, packageMap);
      }

      /* get I18N instance for package */
      I18N i18n = packageMap.get(pkgName);
      if (i18n == null) {
        i18n = new I18N(pkgName, loc);
        packageMap.put(pkgName, i18n);
      }
      return i18n;

    } else {

      /* no package specified */
      return null;
    }
  }
示例#27
0
  @NotNull
  private InlineProgressIndicator createInlineDelegate(
      @NotNull TaskInfo info, @NotNull ProgressIndicatorEx original, final boolean compact) {
    final Collection<InlineProgressIndicator> inlines = myOriginal2Inlines.get(original);
    if (inlines != null) {
      for (InlineProgressIndicator eachInline : inlines) {
        if (eachInline.isCompact() == compact) return eachInline;
      }
    }

    final InlineProgressIndicator inline = new MyInlineProgressIndicator(compact, info, original);

    myInline2Original.put(inline, original);
    myOriginal2Inlines.put(original, inline);

    if (compact) {
      inline
          .getComponent()
          .addMouseListener(
              new MouseAdapter() {
                @Override
                public void mousePressed(MouseEvent e) {
                  handle(e);
                }

                @Override
                public void mouseReleased(MouseEvent e) {
                  handle(e);
                }
              });
    }

    return inline;
  }
 private synchronized void startAnimation(
     JComponent component, Part part, State startState, State endState, long millis) {
   boolean isForwardAndReverse = false;
   if (endState == State.DEFAULTED) {
     isForwardAndReverse = true;
   }
   Map<Part, AnimationState> map = animationStateMap.get(component);
   if (millis <= 0) {
     if (map != null) {
       map.remove(part);
       if (map.size() == 0) {
         animationStateMap.remove(component);
       }
     }
     return;
   }
   if (map == null) {
     map = new EnumMap<Part, AnimationState>(Part.class);
     animationStateMap.put(component, map);
   }
   map.put(part, new AnimationState(startState, millis, isForwardAndReverse));
   if (!timer.isRunning()) {
     timer.start();
   }
 }
示例#29
0
 public Map<String, ValidationResult.Option> getResult() {
   Map<String, ValidationResult.Option> result = new HashMap<String, ValidationResult.Option>();
   for (Item each : myItems) {
     result.put(each.validationResult.path, each.option);
   }
   return result;
 }
  @Override
  public void saveAllDocuments() {
    ApplicationManager.getApplication().assertIsDispatchThread();

    myMultiCaster.beforeAllDocumentsSaving();
    if (myUnsavedDocuments.isEmpty()) return;

    final Map<Document, IOException> failedToSave = new HashMap<Document, IOException>();
    final Set<Document> vetoed = new HashSet<Document>();
    while (true) {
      int count = 0;

      for (Document document : myUnsavedDocuments) {
        if (failedToSave.containsKey(document)) continue;
        if (vetoed.contains(document)) continue;
        try {
          doSaveDocument(document);
        } catch (IOException e) {
          //noinspection ThrowableResultOfMethodCallIgnored
          failedToSave.put(document, e);
        } catch (SaveVetoException e) {
          vetoed.add(document);
        }
        count++;
      }

      if (count == 0) break;
    }

    if (!failedToSave.isEmpty()) {
      handleErrorsOnSave(failedToSave);
    }
  }