예제 #1
0
 // {{{ updateMultiStatus() method
 private void updateMultiStatus() {
   if (multiStatus)
     multi.setIcon(
         GUIUtilities.loadIcon(jEdit.getProperty("hypersearch-results.multi.multiple.icon")));
   else
     multi.setIcon(
         GUIUtilities.loadIcon(jEdit.getProperty("hypersearch-results.multi.single.icon")));
 } // }}}
예제 #2
0
 // {{{ updateHighlightStatus() method
 private void updateHighlightStatus() {
   String prop = jEdit.getProperty(HIGHLIGHT_PROP);
   if (prop != null && !prop.isEmpty())
     highlight.setIcon(
         GUIUtilities.loadIcon(jEdit.getProperty("hypersearch-results.match.highlight.icon")));
   else
     highlight.setIcon(
         GUIUtilities.loadIcon(jEdit.getProperty("hypersearch-results.match.normal.icon")));
   resultTree.repaint();
 } // }}}
예제 #3
0
  // {{{ init() method
  private void init() {
    EditBus.addToBus(this);

    /* Setup panes */
    JPanel content = new JPanel(new BorderLayout(12, 12));
    content.setBorder(new EmptyBorder(12, 12, 12, 12));
    setContentPane(content);

    tabPane = new JTabbedPane();
    tabPane.addTab(jEdit.getProperty("manage-plugins.title"), manager = new ManagePanel(this));
    tabPane.addTab(
        jEdit.getProperty("update-plugins.title"), updater = new InstallPanel(this, true));
    tabPane.addTab(
        jEdit.getProperty("install-plugins.title"), installer = new InstallPanel(this, false));
    EditBus.addToBus(installer);
    content.add(BorderLayout.CENTER, tabPane);

    tabPane.addChangeListener(new ListUpdater());

    /* Create the buttons */
    Box buttons = new Box(BoxLayout.X_AXIS);

    ActionListener al = new ActionHandler();
    mgrOptions = new JButton(jEdit.getProperty("plugin-manager.mgr-options"));
    mgrOptions.addActionListener(al);
    pluginOptions = new JButton(jEdit.getProperty("plugin-manager.plugin-options"));
    pluginOptions.addActionListener(al);
    done = new JButton(jEdit.getProperty("plugin-manager.done"));
    done.addActionListener(al);

    buttons.add(Box.createGlue());
    buttons.add(mgrOptions);
    buttons.add(Box.createHorizontalStrut(6));
    buttons.add(pluginOptions);
    buttons.add(Box.createHorizontalStrut(6));
    buttons.add(done);
    buttons.add(Box.createGlue());

    getRootPane().setDefaultButton(done);

    content.add(BorderLayout.SOUTH, buttons);

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    setIconImage(GUIUtilities.getPluginIcon());

    pack();
    GUIUtilities.loadGeometry(this, parent, "plugin-manager");
    GUIUtilities.addSizeSaver(this, parent, "plugin-manager");
    setVisible(true);
  } // }}}
예제 #4
0
  public ActionBar(View view, boolean temp) {
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

    this.view = view;
    this.temp = temp;

    add(Box.createHorizontalStrut(2));

    JLabel label = new JLabel(jEdit.getProperty("view.action.prompt"));
    add(label);
    add(Box.createHorizontalStrut(12));
    add(action = new ActionTextField());
    action.setEnterAddsToHistory(false);
    Dimension max = action.getPreferredSize();
    max.width = Integer.MAX_VALUE;
    action.setMaximumSize(max);
    action.addActionListener(new ActionHandler());
    action.getDocument().addDocumentListener(new DocumentHandler());

    if (temp) {
      close = new RolloverButton(GUIUtilities.loadIcon("closebox.gif"));
      close.addActionListener(new ActionHandler());
      close.setToolTipText(jEdit.getProperty("view.action.close-tooltip"));
      add(close);
    }

    this.temp = temp;
  }
예제 #5
0
  // {{{ updatePluginList() method
  private void updatePluginList() {
    if (jEdit.getSettingsDirectory() == null && jEdit.getJEditHome() == null) {
      GUIUtilities.error(this, "no-settings", null);
      return;
    }
    if (!shouldUpdatePluginList()) {
      return;
    }

    ThreadUtilities.runInBackground(
        new Task() {
          @Override
          public void _run() {
            try {
              downloadingPluginList = true;
              setStatus(jEdit.getProperty("plugin-manager.list-download-connect"));
              pluginList = new PluginList(this);
            } finally {
              downloadingPluginList = false;
            }
            ThreadUtilities.runInDispatchThread(
                new Runnable() {
                  public void run() {
                    pluginListUpdated();
                  }
                });
          }
        });
  } // }}}
예제 #6
0
    @Override
    public void actionPerformed(ActionEvent evt) {
      Object source = evt.getSource();
      if (source == highlight) {
        String prop = jEdit.getProperty(HIGHLIGHT_PROP);
        Font f = (resultTree != null) ? resultTree.getFont() : UIManager.getFont("Tree.font");
        SyntaxStyle style =
            new StyleEditor(
                    jEdit.getActiveView(),
                    HtmlUtilities.parseHighlightStyle(prop, f),
                    "hypersearch")
                .getStyle();
        if (style != null) jEdit.setProperty(HIGHLIGHT_PROP, GUIUtilities.getStyleString(style));
        updateHighlightStatus();
      } else if (source == clear) {
        removeAllNodes();
      } else if (source == multi) {
        multiStatus = !multiStatus;
        updateMultiStatus();

        if (!multiStatus) {
          for (int i = resultTreeRoot.getChildCount() - 2; i >= 0; i--) {
            resultTreeModel.removeNodeFromParent((MutableTreeNode) resultTreeRoot.getChildAt(i));
          }
        }
      } else if (source == stop) {
        jEdit.setTemporaryProperty("hyperSearch-stopButton", "true");
      }
    }
예제 #7
0
    @Override
    public void mouseReleased(MouseEvent evt) {
      if (evt.getClickCount() % 2 != 0 && !GUIUtilities.isMiddleButton(evt.getModifiers())) return;

      int row = parentDirectories.locationToIndex(evt.getPoint());
      if (row != -1) {
        Object obj = parentDirectories.getModel().getElementAt(row);
        if (obj instanceof VFSFile) {
          VFSFile dirEntry = (VFSFile) obj;
          if (!GUIUtilities.isPopupTrigger(evt)) {
            browser.setDirectory(dirEntry.getPath());
            if (browser.getMode() == VFSBrowser.BROWSER) focusOnFileView();
          }
        }
      }
    }
예제 #8
0
  // {{{ showFilePopup() method
  private void showFilePopup(VFSFile[] files, Component comp, Point point) {
    popup = new BrowserCommandsMenu(browser, files);
    // for the parent directory right-click; on the click we select
    // the clicked item, but when the popup goes away we select the
    // currently showing directory.
    popup.addPopupMenuListener(
        new PopupMenuListener() {
          public void popupMenuCanceled(PopupMenuEvent e) {}

          public void popupMenuWillBecomeVisible(PopupMenuEvent e) {}

          public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            // we use SwingUtilities.invokeLater()
            // so that the action is executed before
            // the popup is hidden.
            EventQueue.invokeLater(
                new Runnable() {
                  public void run() {
                    int index = parentDirectories.getModel().getSize() - 1;
                    parentDirectories.setSelectedIndex(index);
                  }
                });
          }
        });
    GUIUtilities.showPopupMenu(popup, comp, point.x, point.y);
  } // }}}
  public CompleteWordList(
      View view,
      String word,
      Vector completions,
      Point location,
      String noWordSep,
      boolean isGlobalSearch) {
    super(view);
    this.isGlobalSearch = isGlobalSearch;
    this.noWordSep = noWordSep;

    setContentPane(
        new JPanel(new BorderLayout()) {
          /**
           * Returns if this component can be traversed by pressing the Tab key. This returns false.
           */
          public boolean isManagingFocus() {
            return false;
          }

          /** Makes the tab key work in Java 1.4. */
          public boolean getFocusTraversalKeysEnabled() {
            return false;
          }
        });

    this.view = view;
    this.textArea = view.getTextArea();
    this.buffer = view.getBuffer();
    this.word = word;

    words = new JList(completions);

    words.setVisibleRowCount(Math.min(completions.size(), 8));

    words.addMouseListener(new MouseHandler());
    words.setSelectedIndex(0);
    words.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    words.setCellRenderer(new Renderer());

    // stupid scrollbar policy is an attempt to work around
    // bugs people have been seeing with IBM's JDK -- 7 Sep 2000
    JScrollPane scroller =
        new JScrollPane(
            words, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

    getContentPane().add(scroller, BorderLayout.CENTER);

    GUIUtilities.requestFocus(this, words);

    pack();
    setLocation(location);
    show();

    KeyHandler keyHandler = new KeyHandler();
    addKeyListener(keyHandler);
    words.addKeyListener(keyHandler);
    view.setKeyEventInterceptor(keyHandler);
  }
예제 #10
0
  /**
   * Called when en-/decrypt button or Enter key is pressed.
   *
   * <p>Encrypts or decrypts the given files with the given parameters.
   *
   * @see org.gjt.sp.jedit.gui.EnhancedDialog#ok()
   */
  @Override
  public void ok() {
    try {
      GUIUtilities.saveGeometry(this, "cipher.file-crypter");

      if (overwriteRadioButton.isSelected()) {
        newFileHandling = NewFileHandling.OVERWRITE;
      } else if (otherDirectoryRadioButton.isSelected()) {
        newFileHandling = NewFileHandling.OTHER_DIRECTORY;
      } else {
        newFileHandling = NewFileHandling.SUFFIX;
      }

      jEdit.setProperty("options.cipher.file-crypter.new-file-handling", newFileHandling.name());
      jEdit.setProperty("options.cipher.file-crypter.directory", directoryTextField.getText());
      jEdit.setProperty("options.cipher.file-crypter.suffix", suffixTextField.getText());
      jEdit.propertiesChanged();
      jEdit.saveSettings();

      cipher = CipherPlugin.getCipher(cipherOptionPane.getCipherName());
      if (null == cipher) {
        return;
      }
      additionalInformation = CipherPlugin.getAdditionalInformation(cipher);
      if (null == additionalInformation) {
        return;
      }
      PasswordDialog passwordDialog = PasswordDialog.newInstance();
      password = passwordDialog.getPassword();
      if (null == password) {
        return;
      }

      if (!cryptFiles("", files)) {
        GUIUtilities.error(
            this,
            encrypt
                ? "cipher.error.error-while-encrypting-files"
                : "cipher.error.error-while-decrypting-files",
            null);
      }
    } finally {
      dispose();
    }
  }
예제 #11
0
 /**
  * Invoked when an action occurs.
  *
  * @param ae The {@code ActionEvent} of the action that occured
  * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
  */
 public void actionPerformed(@Nullable ActionEvent ae) {
   String[] chosenDirectories =
       GUIUtilities.showVFSFileDialog(
           jEdit.getActiveView(), directoryTextField.getText(), CHOOSE_DIRECTORY_DIALOG, false);
   if (null != chosenDirectories) {
     directoryTextField.setText(chosenDirectories[0]);
     directoryTextField.setCaretPosition(0);
   }
 }
예제 #12
0
  /**
   * The FilePropertiesDialog's constructor
   *
   * @param view The view
   * @param browser The VFSBrowser
   */
  public FilePropertiesDialog(View view, VFSBrowser browser, VFSFile[] files) {
    super(view, jEdit.getProperty("vfs.browser.properties.title"), true);
    GUIUtilities.loadGeometry(this, "propdialog");

    this.browser = browser;

    if (files.length > 0) selectedFiles = files;
    else selectedFiles = browser.getSelectedFiles();
    local = selectedFiles[0];
    createAndShowGUI();
  } // }}}
예제 #13
0
  // {{{ ok() method
  @Override
  public void ok() {
    if (nameTextField != null) {
      VFSFile vfsFile = browser.getSelectedFiles()[0];
      if ((vfsFile.getVFS().getCapabilities() & VFS.RENAME_CAP) != 0) {
        browser.rename(vfsFile, nameTextField.getText());
      }
    }

    GUIUtilities.saveGeometry(this, "propdialog");
    setVisible(false);
  } // }}}
 private AbstractButton makeCustomButton(String name, ActionListener listener) {
   String toolTip = jEdit.getProperty(name.concat(".label"));
   AbstractButton b = new RolloverButton(GUIUtilities.loadIcon(jEdit.getProperty(name + ".icon")));
   if (listener != null) {
     b.addActionListener(listener);
     b.setEnabled(true);
   } else {
     b.setEnabled(false);
   }
   b.setToolTipText(toolTip);
   return b;
 }
예제 #15
0
  /** Initializes this {@code FileCrypter} and shows it. */
  private void init() {
    cipherOptionPane.init();
    ItemListener changeListener = new DetailsEnablerAndDisabler();
    otherDirectoryRadioButton.addItemListener(changeListener);
    suffixRadioButton.addItemListener(changeListener);
    chooseDirectoryButton.addActionListener(new DirectoryChooser());
    cryptButton.addActionListener(new Crypter());

    pack();
    GUIUtilities.loadGeometry(this, "cipher.file-crypter");
    setVisible(true);
  }
예제 #16
0
    // {{{ mousePressed() method
    @Override
    public void mousePressed(MouseEvent evt) {
      if (evt.isConsumed()) return;

      TreePath path1 = resultTree.getPathForLocation(evt.getX(), evt.getY());
      if (path1 == null) return;

      resultTree.setSelectionPath(path1);
      if (GUIUtilities.isPopupTrigger(evt)) showPopupMenu(evt);
      else {
        goToSelectedNode(M_OPEN);
      }
    } // }}}
예제 #17
0
 // {{{ handleMessage() method
 public void handleMessage(EBMessage msg) {
   if (msg instanceof PluginUpdate) {
     PluginUpdate pmsg = (PluginUpdate) msg;
     if (pmsg.getWhat() == PluginUpdate.LOADED || pmsg.getWhat() == PluginUpdate.UNLOADED) {
       if (!pmsg.isExiting()) {
         if (!queuedTOCReload) queueTOCReload();
         queuedTOCReload = true;
       }
     }
   } else if (msg instanceof PropertiesChanged) {
     GUIUtilities.initContinuousLayout(splitter);
   }
 } // }}}
예제 #18
0
    // {{{ mousePressed() method
    @Override
    public void mousePressed(MouseEvent evt) {
      Point p = evt.getPoint();
      if (evt.getSource() != table) {
        p.x -= table.getX();
        p.y -= table.getY();
      }

      int row = table.rowAtPoint(p);
      int column = table.columnAtPoint(p);
      if (column == 0 && row != -1) {
        VFSDirectoryEntryTableModel.Entry entry =
            (VFSDirectoryEntryTableModel.Entry) table.getModel().getValueAt(row, 0);
        if (FileCellRenderer.ExpansionToggleBorder.isExpansionToggle(entry.level, p.x)) {
          table.toggleExpanded(row);
          return;
        }
      }

      if (GUIUtilities.isMiddleButton(evt.getModifiers())) {
        if (row == -1) /* nothing */ ;
        else if (evt.isShiftDown()) table.getSelectionModel().addSelectionInterval(row, row);
        else table.getSelectionModel().setSelectionInterval(row, row);
      } else if (GUIUtilities.isPopupTrigger(evt)) {
        if (popup != null && popup.isVisible()) {
          popup.setVisible(false);
          popup = null;
          return;
        }

        if (row == -1) showFilePopup(null, table, evt.getPoint());
        else {
          if (!table.getSelectionModel().isSelectedIndex(row))
            table.getSelectionModel().setSelectionInterval(row, row);
          showFilePopup(getSelectedFiles(), table, evt.getPoint());
        }
      }
    } // }}}
예제 #19
0
 // NOTE used in scripts
 public static ImageIcon loadIcon(String path) {
   if (path != null && path.endsWith(".icon")) path = getProperty(path);
   if (nullOrEmpty(path)) return null;
   try {
     if (path.startsWith("/")) return iconFrom(path);
     else if (!insideJEdit()) {
       path = pathCombine("/org/gjt/sp/jedit/icons/themes/tango", path);
       return iconFrom(path);
     } else return (ImageIcon) GUIUtilities.loadIcon(path);
   } catch (Exception e) {
     path = "/org/gjt/sp/jedit/icons/themes/tango/22x22/emblems/emblem-unreadable.png";
     return iconFrom(path);
   }
 }
예제 #20
0
 public void actionPerformed(ActionEvent evt) {
   JDialog parent = GUIUtilities.getParentDialog(ColorWellButton.this);
   JDialog dialog;
   if (parent != null) {
     dialog = new ColorPickerDialog(parent, jEdit.getProperty("colorChooser.title"), true);
   } else {
     dialog =
         new ColorPickerDialog(
             JOptionPane.getFrameForComponent(ColorWellButton.this),
             jEdit.getProperty("colorChooser.title"),
             true);
   }
   dialog.pack();
   dialog.setVisible(true);
 }
예제 #21
0
    @Override
    public void actionPerformed(ActionEvent evt) {
      if (pluginModel.isDownloadingList()) return;

      boolean downloadSource = jEdit.getBooleanProperty("plugin-manager.downloadSource");
      boolean installUser = jEdit.getBooleanProperty("plugin-manager.installUser");
      Roster roster = new Roster();
      String installDirectory;
      if (installUser) {
        installDirectory = MiscUtilities.constructPath(jEdit.getSettingsDirectory(), "jars");
      } else {
        installDirectory = MiscUtilities.constructPath(jEdit.getJEditHome(), "jars");
      }

      int length = pluginModel.entries.size();
      int instcount = 0;
      for (int i = 0; i < length; i++) {
        Entry entry = (Entry) pluginModel.entries.get(i);
        if (entry.install) {
          entry.plugin.install(roster, installDirectory, downloadSource);
          if (updates)
            entry
                .plugin
                .getCompatibleBranch()
                .satisfyDependencies(roster, installDirectory, downloadSource);
          instcount++;
        }
      }

      if (roster.isEmpty()) return;

      boolean cancel = false;
      if (updates && roster.getOperationCount() > instcount)
        if (GUIUtilities.confirm(
                window,
                "install-plugins.depend",
                null,
                JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.WARNING_MESSAGE)
            == JOptionPane.CANCEL_OPTION) cancel = true;

      if (!cancel) {
        new PluginManagerProgress(window, roster);

        roster.performOperationsInAWTThread(window);
        pluginModel.update();
      }
    }
예제 #22
0
    // {{{ deselectParents() method
    private void deselectParents(Entry entry) {
      Entry[] parents = entry.getParents();

      if (parents.length == 0) return;

      String[] args = {entry.name};
      int result = GUIUtilities.listConfirm(window, "plugin-manager.dependency", args, parents);
      if (result != JOptionPane.OK_OPTION) {
        entry.install = true;
        return;
      }

      for (int i = 0; i < parents.length; i++) parents[i].install = false;

      fireTableRowsUpdated(0, getRowCount() - 1);
    } // }}}
예제 #23
0
  // {{{ userInput() method
  protected void userInput(char ch) {
    lastActionCount = 0;

    JEditTextArea textArea = view.getTextArea();

    /* Buffer buffer = view.getBuffer();
    if(!buffer.insideCompoundEdit())
    	buffer.beginCompoundEdit(); */

    if (repeatCount == 1) textArea.userInput(ch);
    else {
      // stop people doing dumb stuff like C+ENTER 100 C+n
      if (repeatCount > REPEAT_COUNT_THRESHOLD) {
        Object[] pp = {String.valueOf(ch), repeatCount};

        if (GUIUtilities.confirm(
                view,
                "large-repeat-count.user-input",
                pp,
                JOptionPane.WARNING_MESSAGE,
                JOptionPane.YES_NO_OPTION)
            != JOptionPane.YES_OPTION) {
          repeatCount = 1;
          view.getStatus().setMessage(null);
          return;
        }
      }

      JEditBuffer buffer = view.getBuffer();
      try {
        if (repeatCount != 1) buffer.beginCompoundEdit();
        for (int i = 0; i < repeatCount; i++) textArea.userInput(ch);
      } finally {
        if (repeatCount != 1) buffer.endCompoundEdit();
      }
    }

    Macros.Recorder recorder = view.getMacroRecorder();

    if (recorder != null) {
      recorder.recordInput(repeatCount, ch, textArea.isOverwriteEnabled());
    }

    repeatCount = 1;
  } // }}}
예제 #24
0
    // {{{ actionPerformed() method
    @Override
    public void actionPerformed(ActionEvent ae) {

      path =
          jEdit.getProperty(
              PluginManager.PROPERTY_PLUGINSET, jEdit.getSettingsDirectory() + File.separator);
      String[] selectedFiles =
          GUIUtilities.showVFSFileDialog(
              InstallPanel.this.window, jEdit.getActiveView(), path, VFSBrowser.OPEN_DIALOG, false);
      if (selectedFiles == null || selectedFiles.length != 1) return;

      path = selectedFiles[0];
      boolean success = loadPluginSet(path);
      if (success) {
        jEdit.setProperty(PluginManager.PROPERTY_PLUGINSET, path);
      }
      updateUI();
    } // }}}
예제 #25
0
  public static void error(final Component comp, final String error, final Object[] args) {

    if (SwingUtilities.isEventDispatchThread()) {
      GUIUtilities.error(comp, error, args);
      return;
    }

    VFSManager.error = true;

    runInAWTThread(
        new Runnable() {
          public void run() {
            VFSManager.error = false;

            if (comp == null || !comp.isShowing()) GUIUtilities.error(null, error, args);
            else GUIUtilities.error(comp, error, args);
          }
        });
  }
예제 #26
0
 @Override
 public void mousePressed(MouseEvent evt) {
   int row = parentDirectories.locationToIndex(evt.getPoint());
   if (row != -1) {
     Object obj = parentDirectories.getModel().getElementAt(row);
     if (obj instanceof VFSFile) {
       VFSFile dirEntry = (VFSFile) obj;
       if (GUIUtilities.isPopupTrigger(evt)) {
         if (popup != null && popup.isVisible()) {
           popup.setVisible(false);
           popup = null;
         } else {
           parentDirectories.setSelectedIndex(row);
           showFilePopup(new VFSFile[] {dirEntry}, parentDirectories, evt.getPoint());
         }
       }
     }
   }
 }
예제 #27
0
    public void actionPerformed(ActionEvent evt) {
      Font font;

      JDialog dialog = GUIUtilities.getParentDialog(FontSelector.this);
      if (dialog == null) {
        font =
            new FontSelectorDialog(
                    JOptionPane.getFrameForComponent(FontSelector.this),
                    getFont(),
                    FontSelector.this)
                .getSelectedFont();
      } else {
        font = new FontSelectorDialog(dialog, getFont(), FontSelector.this).getSelectedFont();
      }

      if (font != null) {
        setFont(font);
        updateText();
      }
    }
예제 #28
0
    CompletionPopup(String[] actions) {
      super(view);

      setContentPane(
          new JPanel(new BorderLayout()) {

            public boolean isManagingFocus() {
              return false;
            }

            public boolean getFocusTraversalKeysEnabled() {
              return false;
            }
          });

      list = new CompletionList(actions);
      list.setVisibleRowCount(8);
      list.addMouseListener(new MouseHandler());
      list.setSelectedIndex(0);
      list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

      JScrollPane scroller =
          new JScrollPane(
              list,
              ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
              ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

      getContentPane().add(scroller, BorderLayout.CENTER);

      GUIUtilities.requestFocus(this, list);

      pack();
      Point p = new Point(0, -getHeight());
      SwingUtilities.convertPointToScreen(p, action);
      setLocation(p);
      setVisible(true);

      KeyHandler keyHandler = new KeyHandler();
      addKeyListener(keyHandler);
      list.addKeyListener(keyHandler);
    }
예제 #29
0
    public void actionPerformed(ActionEvent evt) {
      Object source = evt.getSource();
      if (source instanceof JRadioButton) updateEnabled();
      if (source == ok) ok();
      else if (source == cancel) cancel();
      else if (source == combo) updateList();
      else if (source == fileButton) {
        String directory;
        if (fileIcon == null) directory = null;
        else directory = MiscUtilities.getParentOfPath(fileIcon);
        String paths[] =
            GUIUtilities.showVFSFileDialog(null, directory, VFSBrowser.OPEN_DIALOG, false);
        if (paths == null) return;

        fileIcon = "file:" + paths[0];

        try {
          fileButton.setIcon(new ImageIcon(new URL(fileIcon)));
        } catch (MalformedURLException mf) {
          Log.log(Log.ERROR, this, mf);
        }
        fileButton.setText(MiscUtilities.getFileName(fileIcon));
      }
    }
예제 #30
0
    // {{{ mouseClicked() method
    @Override
    public void mouseClicked(MouseEvent evt) {
      Point p = evt.getPoint();
      int row = table.rowAtPoint(p);
      int column = table.columnAtPoint(p);
      if (row == -1) return;
      if (column == 0) {
        VFSDirectoryEntryTableModel.Entry entry =
            (VFSDirectoryEntryTableModel.Entry) table.getModel().getValueAt(row, 0);
        if (FileCellRenderer.ExpansionToggleBorder.isExpansionToggle(entry.level, p.x)) {
          return;
        }
      }

      if ((evt.getModifiers() & InputEvent.BUTTON1_MASK) != 0 && evt.getClickCount() % 2 == 0) {
        browser.filesActivated(
            evt.isShiftDown() ? VFSBrowser.M_OPEN_NEW_VIEW : VFSBrowser.M_OPEN, true);
      } else if (GUIUtilities.isMiddleButton(evt.getModifiers())) {
        if (evt.isShiftDown()) table.getSelectionModel().addSelectionInterval(row, row);
        else table.getSelectionModel().setSelectionInterval(row, row);
        browser.filesActivated(
            evt.isShiftDown() ? VFSBrowser.M_OPEN_NEW_VIEW : VFSBrowser.M_OPEN, true);
      }
    } // }}}