public void setSwingDataCollection(Collection<ICFSecurityISOCountryObj> value) {
   final String S_ProcName = "setSwingDataCollection";
   swingDataCollection = value;
   if (swingDataCollection == null) {
     arrayOfISOCountry = new ICFSecurityISOCountryObj[0];
   } else {
     int len = value.size();
     arrayOfISOCountry = new ICFSecurityISOCountryObj[len];
     Iterator<ICFSecurityISOCountryObj> iter = swingDataCollection.iterator();
     int idx = 0;
     while (iter.hasNext() && (idx < len)) {
       arrayOfISOCountry[idx++] = iter.next();
     }
     if (idx < len) {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Collection iterator did not fully populate the array copy");
     }
     if (iter.hasNext()) {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Collection iterator had left over items when done populating array copy");
     }
     Arrays.sort(arrayOfISOCountry, compareISOCountryByQualName);
   }
   PickerTableModel tblDataModel = getDataModel();
   if (tblDataModel != null) {
     tblDataModel.fireTableDataChanged();
   }
 }
  public MainPanel() {
    super(new BorderLayout());
    JPanel p = new JPanel(new GridLayout(2, 1));
    final JComboBox<String> c0 = makeComboBox(true, false);
    final JComboBox<String> c1 = makeComboBox(false, false);
    final JComboBox<String> c2 = makeComboBox(true, true);
    final JComboBox<String> c3 = makeComboBox(false, true);

    p.add(makeTitlePanel("setEditable(false)", Arrays.asList(c0, c1)));
    p.add(makeTitlePanel("setEditable(true)", Arrays.asList(c2, c3)));
    p.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(p, BorderLayout.NORTH);
    add(
        new JButton(
            new AbstractAction("add") {
              @Override
              public void actionPerformed(ActionEvent e) {
                String str = new Date().toString();
                for (JComboBox<String> c : Arrays.asList(c0, c1, c2, c3)) {
                  MutableComboBoxModel<String> m = (MutableComboBoxModel<String>) c.getModel();
                  m.insertElementAt(str, m.getSize());
                }
              }
            }),
        BorderLayout.SOUTH);
    setPreferredSize(new Dimension(320, 240));
  }
Beispiel #3
0
  /**
   * Sets the output text.
   *
   * @param t output text
   * @param s text size
   */
  public final void setText(final byte[] t, final int s) {
    // remove invalid characters and compare old with new string
    int ns = 0;
    final int ts = text.size();
    final byte[] tt = text.text();
    boolean eq = true;
    for (int r = 0; r < s; ++r) {
      final byte b = t[r];
      // support characters, highlighting codes, tabs and newlines
      if (b >= ' ' || b <= TokenBuilder.MARK || b == 0x09 || b == 0x0A) {
        t[ns++] = t[r];
      }
      eq &= ns < ts && ns < s && t[ns] == tt[ns];
    }
    eq &= ns == ts;

    // new text is different...
    if (!eq) {
      text = new BaseXTextTokens(Arrays.copyOf(t, ns));
      rend.setText(text);
      scroll.pos(0);
    }
    if (undo != null) undo.store(t.length != ns ? Arrays.copyOf(t, ns) : t, 0);
    SwingUtilities.invokeLater(calc);
  }
  private static void patchGtkDefaults(UIDefaults defaults) {
    if (!UIUtil.isUnderGTKLookAndFeel()) return;

    Map<String, Icon> map =
        ContainerUtil.newHashMap(
            Arrays.asList(
                "OptionPane.errorIcon",
                "OptionPane.informationIcon",
                "OptionPane.warningIcon",
                "OptionPane.questionIcon"),
            Arrays.asList(
                AllIcons.General.ErrorDialog,
                AllIcons.General.InformationDialog,
                AllIcons.General.WarningDialog,
                AllIcons.General.QuestionDialog));
    // GTK+ L&F keeps icons hidden in style
    SynthStyle style = SynthLookAndFeel.getStyle(new JOptionPane(""), Region.DESKTOP_ICON);
    for (String key : map.keySet()) {
      if (defaults.get(key) != null) continue;

      Object icon = style == null ? null : style.get(null, key);
      defaults.put(key, icon instanceof Icon ? icon : map.get(key));
    }

    Color fg = defaults.getColor("Label.foreground");
    Color bg = defaults.getColor("Label.background");
    if (fg != null && bg != null) {
      defaults.put("Label.disabledForeground", UIUtil.mix(fg, bg, 0.5));
    }
  }
Beispiel #5
0
 private static void assertModuleLibDepPath(
     LibraryOrderEntry lib, OrderRootType type, List<String> paths) {
   if (paths == null) return;
   assertUnorderedPathsAreEqual(Arrays.asList(lib.getRootUrls(type)), paths);
   // also check the library because it may contain slight different set of urls (e.g. with
   // duplicates)
   assertUnorderedPathsAreEqual(Arrays.asList(lib.getLibrary().getUrls(type)), paths);
 }
  /**
   * setupPlayZone.
   *
   * @param p a {@link arcane.ui.PlayArea} object.
   * @param c an array of {@link forge.Card} objects.
   */
  public static void setupPlayZone(PlayArea p, Card c[]) {
    List<Card> tmp, diff;
    tmp = new ArrayList<Card>();
    for (arcane.ui.CardPanel cpa : p.cardPanels) tmp.add(cpa.gameCard);
    diff = new ArrayList<Card>(tmp);
    diff.removeAll(Arrays.asList(c));
    if (diff.size() == p.cardPanels.size()) p.clear();
    else {
      for (Card card : diff) {
        p.removeCardPanel(p.getCardPanel(card.getUniqueNumber()));
      }
    }
    diff = new ArrayList<Card>(Arrays.asList(c));
    diff.removeAll(tmp);

    arcane.ui.CardPanel toPanel = null;
    for (Card card : diff) {
      toPanel = p.addCard(card);
      Animation.moveCard(toPanel);
    }

    for (Card card : c) {
      toPanel = p.getCardPanel(card.getUniqueNumber());
      if (card.isTapped()) {
        toPanel.tapped = true;
        toPanel.tappedAngle = arcane.ui.CardPanel.TAPPED_ANGLE;
      } else {
        toPanel.tapped = false;
        toPanel.tappedAngle = 0;
      }
      toPanel.attachedPanels.clear();
      if (card.isEnchanted()) {
        ArrayList<Card> enchants = card.getEnchantedBy();
        for (Card e : enchants) {
          arcane.ui.CardPanel cardE = p.getCardPanel(e.getUniqueNumber());
          if (cardE != null) toPanel.attachedPanels.add(cardE);
        }
      }

      if (card.isEquipped()) {
        ArrayList<Card> enchants = card.getEquippedBy();
        for (Card e : enchants) {
          arcane.ui.CardPanel cardE = p.getCardPanel(e.getUniqueNumber());
          if (cardE != null) toPanel.attachedPanels.add(cardE);
        }
      }

      if (card.isEnchanting()) {
        toPanel.attachedToPanel = p.getCardPanel(card.getEnchanting().get(0).getUniqueNumber());
      } else if (card.isEquipping()) {
        toPanel.attachedToPanel = p.getCardPanel(card.getEquipping().get(0).getUniqueNumber());
      } else toPanel.attachedToPanel = null;

      toPanel.setCard(toPanel.gameCard);
    }
    p.invalidate();
    p.repaint();
  }
Beispiel #7
0
  private static boolean matchFramework(
      ProjectCategory projectCategory, FrameworkSupportInModuleProvider framework) {

    FrameworkRole[] roles = framework.getRoles();
    if (roles.length == 0) return true;

    List<FrameworkRole> acceptable = Arrays.asList(projectCategory.getAcceptableFrameworkRoles());
    return ContainerUtil.intersects(Arrays.asList(roles), acceptable);
  }
    /**
     * Removes specific rows from the list of reading lists.
     *
     * @param aRows rows to remove.
     */
    public void removeRows(int[] aRows) {
      Arrays.sort(aRows);

      java.util.List<ReadingList> newLists = new ArrayList<ReadingList>(Arrays.asList(lists));
      for (int i = aRows.length - 1; i >= 0; i--) {
        newLists.remove(aRows[i]);
      }

      setLists(newLists.toArray(new ReadingList[newLists.size()]));
    }
 @Override
 public String toString() {
   return "UpdaterState toSelect"
       + Arrays.asList(myToSelect)
       + " toExpand="
       + Arrays.asList(myToExpand)
       + " processingNow="
       + isProcessingNow()
       + " canRun="
       + myCanRunRestore;
 }
 Entry[] getParents() {
   List<Entry> list = new ArrayList<Entry>();
   getParents(list);
   Entry[] array = list.toArray(new Entry[list.size()]);
   Arrays.sort(array, new StandardUtilities.StringCompare<Entry>(true));
   return array;
 }
  @SuppressWarnings("OverlyBroadCatchBlock")
  private void multiCast(@NotNull Method method, Object[] args) {
    try {
      method.invoke(myBus.syncPublisher(AppTopics.FILE_DOCUMENT_SYNC), args);
    } catch (ClassCastException e) {
      LOG.error("Arguments: " + Arrays.toString(args), e);
    } catch (Exception e) {
      LOG.error(e);
    }

    // Allows pre-save document modification
    for (FileDocumentManagerListener listener : getListeners()) {
      try {
        method.invoke(listener, args);
      } catch (Exception e) {
        LOG.error(e);
      }
    }

    // stripping trailing spaces
    try {
      method.invoke(myTrailingSpacesStripper, args);
    } catch (Exception e) {
      LOG.error(e);
    }
  }
 public void loadData(boolean forceReload) {
   ICFFreeSwitchSchemaObj schemaObj = swingSchema.getSchema();
   if ((containingCluster == null) || forceReload) {
     CFSecurityAuthorization auth = schemaObj.getAuthorization();
     long containingClusterId = auth.getSecClusterId();
     containingCluster = schemaObj.getClusterTableObj().readClusterByIdIdx(containingClusterId);
   }
   if ((listOfTenant == null) || forceReload) {
     arrayOfTenant = null;
     listOfTenant =
         schemaObj
             .getTenantTableObj()
             .readTenantByClusterIdx(containingCluster.getRequiredId(), swingIsInitializing);
     if (listOfTenant != null) {
       Object objArray[] = listOfTenant.toArray();
       if (objArray != null) {
         int len = objArray.length;
         arrayOfTenant = new ICFSecurityTenantObj[len];
         for (int i = 0; i < len; i++) {
           arrayOfTenant[i] = (ICFSecurityTenantObj) objArray[i];
         }
         Arrays.sort(arrayOfTenant, compareTenantByQualName);
       }
     }
   }
 }
  /**
   * When the user has to specify file names, he can use wildcards (*, ?). This methods handles the
   * usage of these wildcards.
   *
   * @param path The path were to search
   * @param s Wilcards
   * @param sort Set to true will sort file names
   * @return An array of String which contains all files matching <code>s</code> in current
   *     directory.
   */
  public static String[] getWildCardMatches(String path, String s, boolean sort) {
    if (s == null) return null;

    String files[];
    String filesThatMatch[];
    String args = new String(s.trim());
    ArrayList filesThatMatchVector = new ArrayList();

    if (path == null) path = getUserDirectory();

    files = (new File(path)).list();
    if (files == null) return null;

    for (int i = 0; i < files.length; i++) {
      if (match(args, files[i])) {
        File temp = new File(getUserDirectory(), files[i]);
        filesThatMatchVector.add(new String(temp.getName()));
      }
    }

    Object[] o = filesThatMatchVector.toArray();
    filesThatMatch = new String[o.length];
    for (int i = 0; i < o.length; i++) filesThatMatch[i] = o[i].toString();
    o = null;
    filesThatMatchVector = null;

    if (sort) Arrays.sort(filesThatMatch);

    return filesThatMatch;
  }
  /**
   * This method initializes this
   *
   * @return void
   */
  private void initialize() {
    this.setSize(380, 400);
    this.setContentPane(getJContentPane());

    // Add the drag button and feedback square to the drag layer of the
    // frame's LayeredPane.
    this.getLayeredPane().add(getDragButton(), JLayeredPane.DRAG_LAYER);
    this.getLayeredPane().add(getHighlightBorder(), JLayeredPane.DRAG_LAYER);

    this.setJMenuBar(getJJMenuBar());
    this.setTitle("Picture Puzzle");
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Set up the lists of buttons, correct orders and current order
    buttons = new ArrayList<Object>(Arrays.asList(getJPanel().getComponents()));
    correct = new ArrayList<String>(16);
    for (int i = 1; i <= 16; i++) {
      // Add the icons in correct order
      icons[i - 1] = new ImageIcon(path + i + ".jpg");
      correct.add(String.valueOf(i));
    }
    current = new ArrayList<String>(correct);
    solution = false;
    shuffle();
  }
Beispiel #15
0
 // Sorts labels from the mapping.  We may get rid of this later perhaps.
 String[] revisedLabels(HashMap map) {
   // Sort labels
   String[] labels = new String[map.size()];
   labels = (String[]) (map.keySet().toArray(labels));
   Arrays.sort(labels);
   return labels;
 }
  private void updateJabberUsers(boolean removeUsersNotInRoster) {
    LOG.debug("Roster changed - update user model");
    Set<User> currentUsers = new HashSet<>(Arrays.asList(myUserModel.getAllUsers()));
    for (RosterEntry rosterEntry : getRoster().getEntries()) {
      User user = addJabberUserToUserModelOrUpdateInfo(rosterEntry);
      currentUsers.remove(user);
    }

    if (removeUsersNotInRoster) {
      removeUsers(currentUsers);
    }

    if (LOG.isDebugEnabled()) {
      LOG.debug("Roster synchronized: " + Arrays.asList(myUserModel.getAllUsers()));
    }
  }
  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");
    }
  }
  private void sort() {
    final Locale loc = getLocale();
    final Collator collator = Collator.getInstance(loc);
    final Comparator<Locale> comp =
        new Comparator<Locale>() {
          public int compare(Locale a, Locale b) {
            return collator.compare(a.getDisplayName(loc), b.getDisplayName(loc));
          }
        };
    Arrays.sort(locales, comp);
    setModel(
        new ComboBoxModel<Locale>() {
          public Locale getElementAt(int i) {
            return locales[i];
          }

          public int getSize() {
            return locales.length;
          }

          public void addListDataListener(ListDataListener l) {}

          public void removeListDataListener(ListDataListener l) {}

          public Locale getSelectedItem() {
            return selected >= 0 ? locales[selected] : null;
          }

          public void setSelectedItem(Object anItem) {
            if (anItem == null) selected = -1;
            else selected = Arrays.binarySearch(locales, (Locale) anItem, comp);
          }
        });
    setSelectedItem(selected);
  }
 public MyTableModel() {
   Vector<Vector<String>> rowData = new Vector<Vector<String>>();
   for (int i = 0; i < 1; i++) {
     Vector<String> colData = new Vector<String>(Arrays.asList("players.txt"));
     rowData.add(colData);
   }
 }
  public static int[] calculateVectorSpace(BufferedImage image) {
    clusters = createClusters(image);
    int[] vectorSpace = new int[IMAGE_WIDTH * IMAGE_HEIGHT];
    Arrays.fill(vectorSpace, -1);

    boolean refineNeeded = true;
    int loops = 0;
    while (refineNeeded) {
      refineNeeded = false;
      loops++;

      for (int y = 0; y < IMAGE_HEIGHT; y++) {
        for (int x = 0; x < IMAGE_WIDTH; x++) {
          int pixel = image.getRGB(x, y);
          Cluster cluster = getMinCluster(pixel);

          if (vectorSpace[IMAGE_WIDTH * y + x] != cluster.getId()) {
            if (vectorSpace[IMAGE_WIDTH * y + x] != -1) {
              clusters[vectorSpace[IMAGE_WIDTH * y + x]].removePixel(pixel);
            }
            cluster.addPixel(pixel);
            refineNeeded = true;
            vectorSpace[IMAGE_WIDTH * y + x] = cluster.getId();
          }
        }
      }
    }

    System.out.println("Took " + loops + " loops.");
    return vectorSpace;
  }
class AnimeIcon implements Icon {
  private static final Color ELLIPSE_COLOR = new Color(.5f, .5f, .5f);
  private static final double R = 2d;
  private static final double SX = 1d;
  private static final double SY = 1d;
  private static final int WIDTH = (int) (R * 8 + SX * 2);
  private static final int HEIGHT = (int) (R * 8 + SY * 2);
  private final List<Shape> list =
      new ArrayList<Shape>(
          Arrays.asList(
              new Ellipse2D.Double(SX + 3 * R, SY + 0 * R, 2 * R, 2 * R),
              new Ellipse2D.Double(SX + 5 * R, SY + 1 * R, 2 * R, 2 * R),
              new Ellipse2D.Double(SX + 6 * R, SY + 3 * R, 2 * R, 2 * R),
              new Ellipse2D.Double(SX + 5 * R, SY + 5 * R, 2 * R, 2 * R),
              new Ellipse2D.Double(SX + 3 * R, SY + 6 * R, 2 * R, 2 * R),
              new Ellipse2D.Double(SX + 1 * R, SY + 5 * R, 2 * R, 2 * R),
              new Ellipse2D.Double(SX + 0 * R, SY + 3 * R, 2 * R, 2 * R),
              new Ellipse2D.Double(SX + 1 * R, SY + 1 * R, 2 * R, 2 * R)));

  private boolean isRunning;

  public void next() {
    if (isRunning) {
      list.add(list.remove(0));
    }
  }

  public void setRunning(boolean isRunning) {
    this.isRunning = isRunning;
  }

  @Override
  public void paintIcon(Component c, Graphics g, int x, int y) {
    Graphics2D g2 = (Graphics2D) g.create();
    g2.setPaint(Objects.nonNull(c) ? c.getBackground() : Color.WHITE);
    g2.fillRect(x, y, getIconWidth(), getIconHeight());
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setColor(ELLIPSE_COLOR);
    g2.translate(x, y);
    int size = list.size();
    for (int i = 0; i < size; i++) {
      float alpha = isRunning ? (i + 1) / (float) size : .5f;
      g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
      g2.fill(list.get(i));
    }
    // g2.translate(-x, -y);
    g2.dispose();
  }

  @Override
  public int getIconWidth() {
    return WIDTH;
  }

  @Override
  public int getIconHeight() {
    return HEIGHT;
  }
}
Beispiel #22
0
 /** List results by alphabetical name */
 private void listByProgramName() {
   int nresult = datasets.size();
   String res[] = new String[nresult];
   for (int i = 0; i < nresult; i++) res[i] = (String) datasets.getElementAt(i);
   Arrays.sort(res);
   datasets.removeAllElements();
   for (int i = 0; i < nresult; i++) datasets.addElement(res[i]);
 }
Beispiel #23
0
  private TreeModel buildModel(Object[] resolvers) {
    TreeModel fullModel = null;
    DefaultMutableTreeNode top = new DefaultMutableTreeNode(Tr.t("root"));

    try {
      cpos = null;
      for (Object resolver : resolvers) {
        if (resolver instanceof ColorPository) {
          cpos = (ColorPository) resolver;
          GraphCellRenderer graphCellRenderer = new GraphCellRenderer(cpos);
          colors.setCellRenderer(graphCellRenderer);
          break;
        }
      }
      Collection<ColorPository.ClassRecord> classes = cpos.getClasses();
      String[] classNames = new String[classes.size()];
      Iterator<ColorPository.ClassRecord> it = classes.iterator();
      int count = 0;
      while (it.hasNext()) {
        classNames[count] = it.next().name;
        count++;
      }
      Arrays.sort(classNames);

      for (String className : classNames) {
        ColorPository.ColorRecord[] colors = cpos.enumerateColors(className);
        String[] colorNames = new String[colors.length];
        for (int a = 0; a < colorNames.length; a++) {
          colorNames[a] = colors[a].name;
        }
        Arrays.sort(colorNames);

        DefaultMutableTreeNode tn = new DefaultMutableTreeNode(className);
        top.add(tn);
        for (String colorName : colorNames) {
          tn.add(new DefaultMutableTreeNode(colorName));
        }
      }

      fullModel = new DefaultTreeModel(top);
    } catch (Exception e) {
      fullModel = new DefaultTreeModel(new DefaultMutableTreeNode(Tr.t("root.failed")));
      // e.printStackTrace();
    }
    return fullModel;
  }
 @Nullable
 public String extractDeprecationMessage() {
   PyStatementList statementList = getStatementList();
   if (statementList == null) {
     return null;
   }
   return extractDeprecationMessage(Arrays.asList(statementList.getStatements()));
 }
  /**
   * Updates the Table based on the selection of the given table. Perform lookups to remove any
   * store files from the shared folder view and to only display store files in the store view
   */
  void updateTableFiles(DirectoryHolder dirHolder) {
    if (dirHolder == null) {
      return;
    }

    if (dirHolder instanceof MediaTypeSavedFilesDirectoryHolder) {
      MediaType mediaType = ((MediaTypeSavedFilesDirectoryHolder) dirHolder).getMediaType();
      setMediaType(mediaType);

      if (mediaType.equals(MediaType.getAudioMediaType())) {
        UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_AUDIO);
      } else if (mediaType == MediaType.getImageMediaType()) {
        UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_PICTURES);
      } else if (mediaType == MediaType.getDocumentMediaType()) {
        UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_DOCUMENTS);
      } else if (mediaType == MediaType.getVideoMediaType()) {
        UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_VIDEOS);
      } else if (mediaType == MediaType.getTorrentMediaType()) {
        UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_TORRENTS);
      } else if (mediaType == MediaType.getProgramMediaType()) {
        UXStats.instance().log(UXAction.LIBRARY_BROWSE_FILE_TYPE_APPLICATIONS);
      }
    } else {
      setMediaType(MediaType.getAnyTypeMediaType());
    }
    clearTable();

    List<List<File>> partitionedFiles = split(100, Arrays.asList(dirHolder.getFiles()));

    for (List<File> partition : partitionedFiles) {
      final List<File> fPartition = partition;

      BackgroundExecutorService.schedule(
          new Runnable() {

            @Override
            public void run() {
              for (final File file : fPartition) {
                GUIMediator.safeInvokeLater(
                    new Runnable() {
                      public void run() {
                        addUnsorted(file);
                      }
                    });
              }

              GUIMediator.safeInvokeLater(
                  new Runnable() {
                    public void run() {
                      LibraryMediator.instance().getLibrarySearch().addResults(fPartition.size());
                    }
                  });
            }
          });
    }

    forceResort();
  }
Beispiel #26
0
  /**
   * removes comments, processes commands drawbot shouldn't have to handle.
   *
   * @param line command to send
   * @return true if the robot is ready for another command to be sent.
   */
  public boolean ProcessLine(String line) {
    // tool change request?
    String[] tokens = line.split("\\s");

    // tool change?
    if (Arrays.asList(tokens).contains("M06") || Arrays.asList(tokens).contains("M6")) {
      for (int i = 0; i < tokens.length; ++i) {
        if (tokens[i].startsWith("T")) {
          JOptionPane.showMessageDialog(
              null, "Please change to tool #" + tokens[i].substring(1) + " and click OK.");
        }
      }
      // still ready to send
      return true;
    }

    // end of program?
    if (tokens[0] == "M02" || tokens[0] == "M2") {
      Halt();
      return false;
    }

    // other machine code to ignore?
    if (tokens[0].startsWith("M")) {
      Log("<font color='pink'>" + line + "</font>\n");
      return true;
    }

    // contains a comment?  if so remove it
    int index = line.indexOf('(');
    if (index != -1) {
      String comment = line.substring(index + 1, line.lastIndexOf(')'));
      line = line.substring(0, index).trim();
      Log("<font color='grey'>* " + comment + "</font\n");
      if (line.length() == 0) {
        // entire line was a comment.
        return true; // still ready to send
      }
    }

    // send relevant part of line to the robot
    SendLineToRobot(line);

    return false;
  }
  /**
   * Begins the in-place refactoring operation.
   *
   * @return true if the in-place refactoring was successfully started, false if it failed to start
   *     and a dialog should be shown instead.
   */
  public boolean startInplaceIntroduceTemplate() {
    final boolean replaceAllOccurrences = isReplaceAllOccurrences();
    final Ref<Boolean> result = new Ref<>();
    CommandProcessor.getInstance()
        .executeCommand(
            myProject,
            () -> {
              final String[] names = suggestNames(replaceAllOccurrences, getLocalVariable());
              final V variable = createFieldToStartTemplateOn(replaceAllOccurrences, names);
              boolean started = false;
              if (variable != null) {
                int caretOffset = getCaretOffset();
                myEditor.getCaretModel().moveToOffset(caretOffset);
                myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);

                final LinkedHashSet<String> nameSuggestions = new LinkedHashSet<>();
                nameSuggestions.add(variable.getName());
                nameSuggestions.addAll(Arrays.asList(names));
                initOccurrencesMarkers();
                setElementToRename(variable);
                updateTitle(getVariable());
                started = super.performInplaceRefactoring(nameSuggestions);
                if (started) {
                  onRenameTemplateStarted();
                  myDocumentAdapter =
                      new DocumentAdapter() {
                        @Override
                        public void documentChanged(DocumentEvent e) {
                          if (myPreview == null) return;
                          final TemplateState templateState =
                              TemplateManagerImpl.getTemplateState(myEditor);
                          if (templateState != null) {
                            final TextResult value =
                                templateState.getVariableValue(
                                    InplaceRefactoring.PRIMARY_VARIABLE_NAME);
                            if (value != null) {
                              updateTitle(getVariable(), value.getText());
                            }
                          }
                        }
                      };
                  myEditor.getDocument().addDocumentListener(myDocumentAdapter);
                  updateTitle(getVariable());
                  if (TemplateManagerImpl.getTemplateState(myEditor) != null) {
                    myEditor.putUserData(ACTIVE_INTRODUCE, this);
                  }
                }
              }
              result.set(started);
              if (!started) {
                finish(true);
              }
            },
            getCommandName(),
            getCommandName());
    return result.get();
  }
Beispiel #28
0
 {
   for (myjava.gui.syntax.Painter painter : myjava.gui.syntax.Painter.getPainters()) {
     painterComboBox.addItem(painter);
     EntryListPanel panel = new EntryListPanel(painter);
     listPanelSet.add(panel);
     centerPanel.add(panel, painter.getName());
   }
   componentSet.addAll(Arrays.asList(matchBracket, painterComboBox, centerPanel));
 }
Beispiel #29
0
 private void resetButtonStatus() {
   for (JButton b : Arrays.asList(deleteButton, copyButton)) {
     ButtonModel m = b.getModel();
     m.setRollover(false);
     m.setArmed(false);
     m.setPressed(false);
     m.setSelected(false);
   }
 }
  private class LibraryTableInvocationHandler implements InvocationHandler, ProxyDelegateAccessor {
    private final LibraryTable myDelegateTable;

    @NonNls
    private final Set<String> myCheckedNames =
        new HashSet<>(Arrays.asList("removeLibrary" /*,"createLibrary"*/));

    LibraryTableInvocationHandler(LibraryTable table) {
      myDelegateTable = table;
    }

    @Override
    public Object invoke(Object object, Method method, Object[] params) throws Throwable {
      final boolean needUpdate = myCheckedNames.contains(method.getName());
      try {
        final Object result = method.invoke(myDelegateTable, unwrapParams(params));
        if (result instanceof Library) {
          return Proxy.newProxyInstance(
              getClass().getClassLoader(),
              new Class[] {result instanceof LibraryEx ? LibraryEx.class : Library.class},
              new LibraryInvocationHandler((Library) result));
        } else if (result instanceof LibraryTable.ModifiableModel) {
          return Proxy.newProxyInstance(
              getClass().getClassLoader(),
              new Class[] {LibraryTableBase.ModifiableModel.class},
              new LibraryTableModelInvocationHandler((LibraryTable.ModifiableModel) result));
        }
        if (result instanceof Library[]) {
          Library[] libraries = (Library[]) result;
          for (int idx = 0; idx < libraries.length; idx++) {
            Library library = libraries[idx];
            libraries[idx] =
                (Library)
                    Proxy.newProxyInstance(
                        getClass().getClassLoader(),
                        new Class[] {
                          library instanceof LibraryEx ? LibraryEx.class : Library.class
                        },
                        new LibraryInvocationHandler(library));
          }
        }
        return result;
      } catch (InvocationTargetException e) {
        throw e.getCause();
      } finally {
        if (needUpdate) {
          updateOrderEntriesInEditors(true);
        }
      }
    }

    @Override
    public Object getDelegate() {
      return myDelegateTable;
    }
  }