⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jextframe.java

📁 java写的多功能文件编辑器
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
    else      stopAutoSave();    if (Jext.getBooleanProperty("tips"))    {      String tip;      try      {        tip = "Tip: " + Jext.getProperty("tip." + (Math.abs(new Random().nextInt()) %                                         Integer.parseInt(Jext.getProperty("tip.count"))));      } catch(Exception e) {        tip = status.getText();      }      status.setText(' ' + tip);    }    if (triggerPanes)      triggerTabbedPanes();    splitEditor();    loadButtonsProperties();    loadConsoleProperties();    loadTextAreaProperties();    getTextArea().setParentTitle();    fireJextEvent(JextEvent.PROPERTIES_CHANGED);  }  public void loadButtonsProperties()  {    toolBar.setGrayed(Jext.getBooleanProperty("toolbar.gray"));    toolBar.setVisible(Jext.getBooleanProperty("toolbar"));    // buttons colors    JextButton.setHighlightColor(GUIUtilities.parseColor(Jext.getProperty("buttons.highlightColor")));    JextHighlightButton.setHighlightColor(GUIUtilities.parseColor(Jext.getProperty("buttons.highlightColor")));    JextToggleButton.setHighlightColor(GUIUtilities.parseColor(Jext.getProperty("buttons.highlightColor")));  }  /**   * Hides or shows the left and top tabbed panes.   */  public void triggerTabbedPanes()  {    boolean leftShow = Jext.getBooleanProperty("leftPanel.show");    if (leftShow && vTabbedPane.getTabCount() > 0)    {      //if (split.getDividerSize() == 0)      if (split.getLeftComponent() instanceof VoidComponent)      {        split.setDividerSize(_dividerSize);        split.setLeftComponent(leftFrame);        split.resetToPreferredSizes();      }    } else {      //if (split.getDividerSize() != 0)      if (! (split.getLeftComponent() instanceof VoidComponent))      {        split.setDividerSize(0);        split.setLeftComponent(new VoidComponent());        split.resetToPreferredSizes();      }    }    boolean topShow = Jext.getBooleanProperty("topPanel.show");    if (topShow && hTabbedPane.getTabCount() > 0)    {      if (splitter.getDividerSize() == 0)      {        splitter.setDividerSize(_dividerSize);        splitter.setTopComponent(consolesFrame);        splitter.resetToPreferredSizes();        splitter.setBottomComponent(split);        // SPLITTER BUG FIX        // If console enabled add splitter back to centerPane and make it visible.        centerPane.add(BorderLayout.CENTER, splitter);        centerPane.validate();        splitter.setVisible(true);      }    } else {      if (splitter.getDividerSize() != 0)      {        splitter.setDividerSize(0);        splitter.setTopComponent(new VoidComponent());        splitter.resetToPreferredSizes();        // SPLITTER BUG FIX        // Since the console isn't visible and setDividerSize isn't hiding the        // splitter then remove the splitter and add split to the centerPane.        centerPane.remove(splitter);        centerPane.add(BorderLayout.CENTER, split);        centerPane.validate();      }      topShow = false;    }    //if (leftShow)    //  split.setBorder(topShow ? null : new MatteBorder(1, 0, 0, 0, Color.gray));    //else    //  split.setBorder(null);  }  /**   * Splits/unsplits editor according to the property "editor.splitted".   */  public void splitEditor()  {    if (Jext.getBooleanProperty("editor.splitted"))    {      //if (split.getRightComponent() != textAreaSplitter)      if (rightFrame.getContent() != textAreaSplitter)      {        //split.remove(textAreasPane);        textAreaSplitter.setTopComponent(textAreasPane);        //split.setRightComponent(textAreaSplitter);        rightFrame.setContent(textAreaSplitter);        textAreaSplitter.setDividerLocation(0.5);      }      textAreaSplitter.setOrientation("Horizontal".equals(                                      Jext.getProperty("editor.splitted.orientation")) ?                                      JSplitPane.HORIZONTAL_SPLIT : JSplitPane.VERTICAL_SPLIT);      updateSplittedTextArea(getTextArea());    } else {      textAreaSplitter.remove(textAreasPane);      rightFrame.setContent(textAreasPane);      //split.setRightComponent(textAreasPane);      rightFrame.validate();      JextTextArea textArea = getTextArea();      if (textArea != null)      {        textArea.grabFocus();        textArea.requestFocus();      }    }  }  /**   * Load console properties states from the properties file.   * Should never been called directly.   */  public void loadConsoleProperties()  {    if (console != null)    {      String promptPattern = Jext.getProperty("console.prompt");      if (promptPattern != null && !promptPattern.equals(console.getPromptPattern()))      {        console.setPromptPattern(promptPattern);        console.displayPrompt();      }      console.setErrorColor(GUIUtilities.parseColor(Jext.getProperty("console.errorColor")));      console.setPromptColor(GUIUtilities.parseColor(Jext.getProperty("console.promptColor")));      console.setOutputColor(GUIUtilities.parseColor(Jext.getProperty("console.outputColor")));      console.setInfoColor(GUIUtilities.parseColor(Jext.getProperty("console.infoColor")));      console.setBgColor(GUIUtilities.parseColor(Jext.getProperty("console.bgColor")));      console.setSelectionColor(GUIUtilities.parseColor(Jext.getProperty("console.selectionColor")));    }  }  /**   * Load text area properties states from the properties file.   * Should never been called directly.   */  public void loadTextAreaProperties()  {    loadTextArea(splittedTextArea);    splittedTextArea.setElectricScroll(0);    workspaces.loadTextAreas();  }  /**   * Load a given text area properties from the user settings.   * @param textArea The text area which has to be set   */  public void loadTextArea(JextTextArea textArea)  {    try    {      textArea.setTabSize(Integer.parseInt(Jext.getProperty("editor.tabSize")));    } catch (NumberFormatException nf) {      textArea.setTabSize(8);      Jext.setProperty("editor.tabSize", "8");    }    try    {      textArea.setElectricScroll(Integer.parseInt(Jext.getProperty("editor.autoScroll")));    } catch (NumberFormatException nf) {      textArea.setElectricScroll(0);    }    String newLine = Jext.getProperty("editor.newLine");    if (newLine == null)      Jext.setProperty("editor.newLine", System.getProperty("line.separator"));    try    {      textArea.setFontSize(Integer.parseInt(Jext.getProperty("editor.fontSize")));    } catch (NumberFormatException nf) {      textArea.setFontSize(12);      Jext.setProperty("editor.fontSize", "12");    }    try    {      textArea.setFontStyle(Integer.parseInt(Jext.getProperty("editor.fontStyle")));    } catch (NumberFormatException nf) {      textArea.setFontStyle(0);      Jext.setProperty("editor.fontStyle", "0");    }    textArea.setFontName(Jext.getProperty("editor.font"));    org.gjt.sp.jedit.textarea.TextAreaPainter painter = textArea.getPainter();    try    {      painter.setLinesInterval(Integer.parseInt(Jext.getProperty("editor.linesInterval")));    } catch (NumberFormatException nf) {      painter.setLinesInterval(0);    }    try    {      painter.setWrapGuideOffset(Integer.parseInt(Jext.getProperty("editor.wrapGuideOffset")));    } catch (NumberFormatException nf) {      painter.setWrapGuideOffset(0);    }    painter.setAntiAliasingEnabled(Jext.getBooleanProperty("editor.antiAliasing"));    painter.setLineHighlightEnabled(Jext.getBooleanProperty("editor.lineHighlight"));    painter.setEOLMarkersPainted(Jext.getBooleanProperty("editor.eolMarkers"));    painter.setBlockCaretEnabled(Jext.getBooleanProperty("editor.blockCaret"));    painter.setLinesIntervalHighlightEnabled(Jext.getBooleanProperty("editor.linesIntervalEnabled"));    painter.setWrapGuideEnabled(Jext.getBooleanProperty("editor.wrapGuideEnabled"));    painter.setBracketHighlightColor(GUIUtilities.parseColor(Jext.getProperty("editor.bracketHighlightColor")));    painter.setLineHighlightColor(GUIUtilities.parseColor(Jext.getProperty("editor.lineHighlightColor")));    painter.setHighlightColor(GUIUtilities.parseColor(Jext.getProperty("editor.highlightColor")));    painter.setEOLMarkerColor(GUIUtilities.parseColor(Jext.getProperty("editor.eolMarkerColor")));    painter.setCaretColor(GUIUtilities.parseColor(Jext.getProperty("editor.caretColor")));    painter.setSelectionColor(GUIUtilities.parseColor(Jext.getProperty("editor.selectionColor")));    painter.setBackground(GUIUtilities.parseColor(Jext.getProperty("editor.bgColor")));    painter.setForeground(GUIUtilities.parseColor(Jext.getProperty("editor.fgColor")));    painter.setLinesIntervalHighlightColor(GUIUtilities.parseColor(Jext.getProperty("editor.linesHighlightColor")));    painter.setWrapGuideColor(GUIUtilities.parseColor(Jext.getProperty("editor.wrapGuideColor")));    loadGutter(textArea.getGutter());    loadStyles(painter);    if (textArea.isNew() && textArea.isEmpty())      textArea.setColorizing(Jext.getProperty("editor.colorize.mode"));    textArea.putClientProperty("InputHandler.homeEnd",                               new Boolean(Jext.getBooleanProperty("editor.smartHomeEnd")));    textArea.setCaretBlinkEnabled(Jext.getBooleanProperty("editor.blinkingCaret"));    textArea.setParentTitle();    textArea.repaint();  }  // loads the text area's gutter properties  private void loadGutter(Gutter gutter)  {    try    {      int width = Integer.parseInt(Jext.getProperty("textArea.gutter.width"));      gutter.setGutterWidth(width);    } catch(NumberFormatException nf) { }    gutter.setCollapsed("yes".equals(Jext.getProperty("textArea.gutter.collapsed")));    gutter.setLineNumberingEnabled(!"no".equals(Jext.getProperty("textArea.gutter.lineNumbers")));    try    {      int interval = Integer.parseInt(Jext.getProperty("textArea.gutter.highlightInterval"));      gutter.setHighlightInterval(interval);    } catch(NumberFormatException nf) {}    gutter.setAntiAliasingEnabled(Jext.getBooleanProperty("editor.antiAliasing"));    gutter.setBackground(GUIUtilities.parseColor(Jext.getProperty("textArea.gutter.bgColor")));    gutter.setForeground(GUIUtilities.parseColor(Jext.getProperty("textArea.gutter.fgColor")));    gutter.setHighlightedForeground(GUIUtilities.parseColor(Jext.getProperty("textArea.gutter.highlightColor")));    gutter.setCaretMark(GUIUtilities.parseColor(Jext.getProperty("textArea.gutter.caretMarkColor")));    gutter.setAnchorMark(GUIUtilities.parseColor(Jext.getProperty("textArea.gutter.anchorMarkColor")));    gutter.setSelectionMark(GUIUtilities.parseColor(Jext.getProperty("textArea.gutter.selectionMarkColor")));    String alignment = Jext.getProperty("textArea.gutter.numberAlignment");    if ("right".equals(alignment))      gutter.setLineNumberAlignment(Gutter.RIGHT);    else if ("center".equals(alignment))      gutter.setLineNumberAlignment(Gutter.CENTER);    else      gutter.setLineNumberAlignment(Gutter.LEFT);    try    {      int width = Integer.parseInt(Jext.getProperty("textArea.gutter.borderWidth"));      gutter.setBorder(width, GUIUtilities.parseColor(Jext.getProperty("textArea.gutter.borderColor")));    } catch(NumberFormatException nf) { }    try    {      String fontname = Jext.getProperty("textArea.gutter.font");      int fontsize = Integer.parseInt(Jext.getProperty("textArea.gutter.fontSize"));      int fontstyle = Integer.parseInt(Jext.getProperty("textArea.gutter.fontStyle"));      gutter.setFont(new Font(fontname, fontstyle, fontsize));    } catch(NumberFormatException nf) { }  }  // loads the syntax colorizing styles properties. This method  // is called by loadTextArea() and exists only to separate the  // code because loadTextArea() was becoming confusing  private void loadStyles(TextAreaPainter painter)  {    try    {      SyntaxStyle[] styles = new SyntaxStyle[Token.ID_COUNT];      styles[Token.COMMENT1] = GUIUtilities.parseStyle(Jext.getProperty("editor.style.comment1"));      styles[Token.COMMENT2] = GUIUtilities.parseStyle(Jext.getProperty("editor.style.comment2"));      styles[Token.KEYWORD1] = GUIUtilities.parseStyle(Jext.getProperty("editor.style.keyword1"));      styles[Token.KEYWORD2] = GUIUtilities.parseStyle(Jext.getProperty("editor.style.keyword2"));      styles[Token.KEYWORD3] = GUIUtilities.parseStyle(Jext.getProperty("editor.style.keyword3"));      styles[Token.LITERAL1] = GUIUtilities.parseStyle(Jext.getProperty("editor.style.literal1"));      styles[Token.LITERAL2] = GUIUtilities.parseStyle(Jext.getProperty("editor.style.literal2"));      styles[Token.OPERATOR] = GUIUtilities.parseStyle(Jext.getProperty("editor.style.operator"));      styles[Token.INVALID] = GUIUtilities.parseStyle(Jext.getProperty("editor.style.invalid"));      styles[Token.LABEL] = GUIUtilities.parseStyle(Jext.getProperty("editor.style.label"));      styles[Token.METHOD] = GUIUtilities.parseStyle(Jext.getProperty("editor.style.method"));      painter.setStyles(styles);    } catch(Exception e) { }  }  private void registerPlugins()  {    Plugin[] plugins = Jext.getPlugins();    for (int i = 0; i < plugins.length; i++)    {      if (plugins[i] instanceof RegisterablePlugin)        try        {          ((RegisterablePlugin) plugins[i]).register(this);        } catch (Throwable t) {          System.err.println("#--Exception occurred while registering plugin:");          t.printStackTrace();        }      if (plugins[i] instanceof ProjectManagement)        addProjectManagement(((ProjectManagement)plugins[i]));    }  }  /**   * Recreates the plugins menu.   */  public void updatePluginsMenu()  {    if (pluginsMenu == null)      return;    if (pluginsMenu.getMenuComponentCount() != 0)      pluginsMenu.removeAll();    Plugin[] plugins = Jext.getPlugins();    if (plugins.length == 0) //if (pluginArray.length == 0)    {      pluginsMenu.add(GUIUtilities.loadMenuItem(Jext.getProperty("no.plugins"), null,                                                 null, false));      return;    }    Vector _pluginsMenus = new Vector();    Vector _pluginsMenuItems = new Vector();    for (int i = 0; i < plugins.length; i++)    {      String pluginModes = Jext.getProperty("plugin." + plugins[i].getClass().getName() + ".modes");      if (pluginModes == null)  // and therefore it is a permanent plugin      {        try        {          plugins[i].createMenuItems(this, _pluginsMenus, _pluginsMenuItems);        } catch (Throwable t) {          System.err.println("#--Exception while constructing menu items:");          t.printStackTrace();        }      }    }    for (int i = 0; i < _pluginsMenus.size(); i++)      pluginsMenu.add((JMenu) _pluginsMenus.elementAt(i));    for (int i = 0; i < _pluginsMenuItems.size(); i++)      pluginsMenu.add((JMenuItem) _pluginsMenuItems.elementAt(i));    if (pluginsMenu.getItemCount() == 0)      pluginsMenu.add(GUIUtilities.loadMenuItem(Jext.getProperty("no.plugins"), null,                                                null, false));    freeze();  }  /**   * Start the auto saving function. If the <code>Thread</code>   * used for the auto save is <code>null</code>, we need to   * create it.   */  public void startAutoSave()  {    if (auto == null)      auto = new AutoSave(this);  }  /**   * Stop the auto saving function. We just interrupt the   * <code>Thread</code> and then 'kill' it.   */  public void stopAutoSave()  {    if (auto != null)    {      auto.interrupt();      auto = null;    }  }  /**   * Update status label which displays informations about caret's position.   * @param textArea The text area which caret status has to be updated   */  public void updateStatus(JextTextArea textArea)  {    int off = textArea.getCaretPosition();    Element map = textArea.getDocument().getDefaultRootElement();    int currLine = map.getElementIndex(off);    Element lineElement = map.getElement(currLine);    int start = lineElement.getStartOffset();    int end = lineElement.getEndOffset();    int numLines = map.getElementCount();    status.setText(new StringBuffer().append(' ').append(off - start + 1).append(':')                   .append(end - start).append(" - ").append(currLine + 1).append('/')                   .append(numLines).append(" - [ ").append(textArea.getLineTermName()).append(" ] - ")                   .append(((currLine + 1) * 100) / numLines)                   .append('%').toString());  }  /**   * Display status of a given text area.   * @param textArea The text area which status has to be displayed   */  public void setStatus(JextTextArea textArea) //this one changes the message label, not status one!  {    StringBuffer text = new StringBuffer();    if (textArea.isEditable())    {      text.append(textArea.isDirty() ? Jext.getProperty("editor.modified") : "");    } else      text.append(Jext.getProperty("editor.readonly"));    if (textArea.oneClick != null)    {      if (text.length() > 0)        text.append(" : ");      text.append("one click!");    }    String _text = text.toString();    if (_text.length() > 0)      message.setText('(' + _text + ')');    else      message.setText("");  }  /**   * Makes the given text area being considered as non modified.   */  public void resetStatus(JextTextArea textArea)  {    textArea.clean();//TODO for line-end patch    message.setText("");    textAreasPane.setCleanIcon(textArea);  }  /**   * When the user create a new file, we need to reset some stuffs   * such as the bottom labels and the tab icon.   * @param textArea The text area which was cleared   */  public void setNew(JextTextArea textArea)  {    message.setText(textArea.isEditable() ? "" : Jext.getProperty("editor.readonly"));    textAreasPane.setCleanIcon(textArea);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -