示例#1
0
 private JPanel createPreviewPanel() {
   JPanel p = new JPanel();
   p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
   _screenshot = new PatternPaneScreenshot(_simg);
   createMarginBox(p, _screenshot);
   p.add(Box.createVerticalStrut(5));
   p.add(_screenshot.createControls());
   p.add(Box.createVerticalStrut(5));
   p.add(msgApplied[tabSequence]);
   p.doLayout();
   return p;
 }
示例#2
0
 private void actionPerformedUpdates(Window _parent) {
   boolean tempDirty = isDirty();
   if (paneNaming.isDirty()) {
     String filename = paneNaming.getAbsolutePath();
     String oldFilename = _imgBtn.getFilename();
     if (FileManager.exists(filename)) {
       String name = FileManager.getName(filename);
       int ret =
           JOptionPane.showConfirmDialog(
               _parent,
               SikuliIDEI18N._I("msgFileExists", name),
               SikuliIDEI18N._I("dlgFileExists"),
               JOptionPane.WARNING_MESSAGE,
               JOptionPane.YES_NO_OPTION);
       if (ret != JOptionPane.YES_OPTION) {
         return;
       }
     }
     try {
       FileManager.xcopy(oldFilename, filename, null);
       (new File(oldFilename)).delete();
       _imgBtn.setFilename(filename);
     } catch (IOException ioe) {
       Debug.error("renaming failed: " + oldFilename + " " + filename);
       Debug.error(ioe.getMessage());
     }
     paneNaming.updateFilename();
     addDirty(true);
   }
   addDirty(
       _imgBtn.setParameters(
           _screenshot.isExact(), _screenshot.getSimilarity(), _screenshot.getNumMatches()));
   addDirty(_imgBtn.setTargetOffset(_tarOffsetPane.getTargetOffset()));
   Debug.log(2, "update: " + _imgBtn.toString());
   if (isDirty() || tempDirty) {
     int i = _imgBtn.getWindow().getTabbedPane().getSelectedIndex();
     _imgBtn.getWindow().setMessageApplied(i, true);
     _imgBtn.repaint();
   }
 }
示例#3
0
  private void init(EditorPatternButton imgBtn, boolean exact, float similarity, int numMatches) {
    setTitle(_I("winPatternSettings"));
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    _imgBtn = imgBtn;
    Point pos = imgBtn.getLocationOnScreen();
    Debug.log(4, "pattern window: " + pos);
    setLocation(pos.x + imgBtn.getWidth(), pos.y);

    takeScreenshot();
    Container c = getContentPane();
    c.setLayout(new BorderLayout());

    tabPane = new JTabbedPane();
    tabPane.setPreferredSize(new Dimension(790, 700));
    msgApplied = new JLabel[tabMax];

    msgApplied[tabSequence] = new JLabel("...");
    paneNaming = new PatternPaneNaming(_imgBtn, msgApplied[tabSequence++]);
    tabPane.addTab(_I("tabNaming"), paneNaming);

    msgApplied[tabSequence] = new JLabel("...");
    panePreview = createPreviewPanel();
    tabSequence++;
    tabPane.addTab(_I("tabMatchingPreview"), panePreview);

    msgApplied[tabSequence] = new JLabel("...");
    paneTarget = createTargetPanel();
    tabSequence++;
    tabPane.addTab(_I("tabTargetOffset"), paneTarget);

    c.add(tabPane, BorderLayout.CENTER);
    c.add(createButtons(), BorderLayout.SOUTH);
    c.doLayout();
    pack();
    try {
      _screenshot.setParameters(_imgBtn.getFilename(), exact, similarity, numMatches);
    } catch (Exception e) {
      Debug.error(me + "Problem while setting up pattern pane\n%s", e.getMessage());
    }
    setDirty(false);
    setVisible(true);
  }