Package com.lightdev.app.shtm

Examples of com.lightdev.app.shtm.SHTMLPanel


  public NoteManager(final MNoteController noteController) {
    this.noteController = noteController;
  }

  public void onDeselect(final NodeModel node) {
    final SHTMLPanel noteViewerComponent = noteController.getNoteViewerComponent();
    if (noteViewerComponent == null) {
      return;
    }
    noteViewerComponent.getDocument().removeDocumentListener(mNoteDocumentListener);
    saveNote(node);
    this.node = null;
  }
View Full Code Here


    Controller.getCurrentModeController().getController().getViewController().insertComponentIntoSplitPane(southPanel);
    if (requestFocus) {
      KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
      EventQueue.invokeLater(new Runnable() {
        public void run() {
          final SHTMLPanel htmlEditorPanel = getHtmlEditorPanel();
          htmlEditorPanel.getMostRecentFocusOwner().requestFocus();
          if (ResourceController.getResourceController().getBooleanProperty("goto_note_end_on_edit")) {
            final JEditorPane editorPane = htmlEditorPanel.getEditorPane();
            editorPane.setCaretPosition(editorPane.getDocument().getLength());
          }
        }
      });
    }
View Full Code Here

  void saveNote() {
    if (node == null) {
      return;
    }
    final SHTMLPanel noteViewerComponent = noteController.getNoteViewerComponent();
    if (noteViewerComponent == null) {
      return;
    }
    boolean editorContentEmpty = true;
    String documentText = noteViewerComponent.getDocumentText();
    documentText = HEAD.matcher(documentText).replaceFirst("");
    editorContentEmpty = HtmlUtils.isEmpty(documentText);
    Controller.getCurrentModeController().getMapController().removeNodeSelectionListener(this);
    if (noteViewerComponent.needsSaving()) {
      try {
        ignoreEditorUpdate = true;
        if (editorContentEmpty) {
          noteController.setNoteText(node, null);
        }
View Full Code Here

  void updateEditor() {
    if (ignoreEditorUpdate) {
      return;
    }
    final SHTMLPanel noteViewerComponent = noteController.getNoteViewerComponent();
    if (noteViewerComponent == null) {
      return;
    }
    final HTMLDocument document = noteViewerComponent.getDocument();
    document.removeDocumentListener(mNoteDocumentListener);
    try {
      final URL url = node.getMap().getURL();
      if (url != null) {
        document.setBase(url);
      }
      else {
        document.setBase(new URL("file: "));
      }
    }
    catch (final Exception e) {
    }
    noteController.setDefaultFont();
    final String note = node != null ? NoteModel.getNoteText(node) : null;
    if (note != null) {
      noteViewerComponent.setCurrentDocumentContent(note);
      noteController.setLastContentEmpty(false);
    }
    else if (!noteController.isLastContentEmpty()) {
      noteViewerComponent.setCurrentDocumentContent("");
      noteController.setLastContentEmpty(true);
    }
    document.addDocumentListener(mNoteDocumentListener);
  }
View Full Code Here

      return;
    }
    KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
    EventQueue.invokeLater(new Runnable() {
      public void run() {
        final SHTMLPanel htmlEditorPanel = noteController.getHtmlEditorPanel();
        if (! noteController.isNoteEditorShowing()) {
          noteController.showNotesPanel(true);
        }
        else {
          htmlEditorPanel.getMostRecentFocusOwner().requestFocusInWindow();
          if (ResourceController.getResourceController().getBooleanProperty("goto_note_end_on_edit")) {
            final JEditorPane editorPane = htmlEditorPanel.getEditorPane();
            editorPane.setCaretPosition(editorPane.getDocument().getLength());
          }
        }
      }
    });
View Full Code Here

  public Panel getToolbar(final String name){
    return new Panel(getController().getModeController().getUserInputListenerFactory().getToolBar(name));
  }

  public TextBox getNoteEditor(){
    SHTMLPanel panel = getShtmlPanel();
    return new TextBox(panel.getEditorPane());
  }
View Full Code Here

    SHTMLPanel panel = getShtmlPanel();
    return new TextBox(panel.getEditorPane());
  }

  public TextBox getNoteHtmlEditor(){
    SHTMLPanel panel = getShtmlPanel();
    return new TextBox(panel.getSourceEditorPane());
  }
View Full Code Here

  }

  private SHTMLPanel getShtmlPanel() {
    final UIComponent[] components = getUIComponents(SHTMLPanel.class);
    Assert.assertTrue(components.length == 1);
    SHTMLPanel panel = (SHTMLPanel)components[0].getAwtComponent();
    return panel;
  }
View Full Code Here

      htmlEditorWindow.setBase(this);
      final String titleText;
      titleText = TextUtils.getText(title);
      htmlEditorWindow.getDialog().setTitle(titleText);
      htmlEditorWindow.setSplitEnabled(getEditControl().canSplit());
      final SHTMLPanel htmlEditorPanel = (htmlEditorWindow).getHtmlEditorPanel();
      final StringBuilder ruleBuilder = new StringBuilder(100);
      ruleBuilder.append("body {");
      if(font != null){
        ruleBuilder.append("font-family: ").append(font.getFamily()).append(";");
        final int fontSize = Math.round(font.getSize() / UITools.FONT_SCALE_FACTOR);
        ruleBuilder.append("font-size: ").append(fontSize).append("pt;");
        if (font.isItalic()) {
          ruleBuilder.append("font-style: italic; ");
        }
        if (font.isBold()) {
          ruleBuilder.append("font-weight: bold; ");
        }
      }
      if(textColor != null)
        ruleBuilder.append("color: ").append(ColorUtils.colorToString(textColor)).append(";");
        final Color bgColor = getBackground();
      ruleBuilder.append("background-color: ").append(ColorUtils.colorToString(bgColor)).append(";");
      ruleBuilder.append("}\n");
      ruleBuilder.append("p {margin-top:0;}\n");
      final HTMLDocument document = htmlEditorPanel.getDocument();
      final JEditorPane editorPane = htmlEditorPanel.getEditorPane();
      if(textColor != null){
        editorPane.setForeground(textColor);
        editorPane.setCaretColor(textColor);
      }
      final StyleSheet styleSheet = document.getStyleSheet();
      styleSheet.removeStyle("p");
      styleSheet.removeStyle("body");
      styleSheet.addRule(ruleBuilder.toString());
      final URL url = node.getMap().getURL();
      if (url != null) {
        document.setBase(url);
      }
      else {
        document.setBase(new URL("file: "));
      }
      htmlEditorPanel.setContentPanePreferredSize(preferredSize);
      htmlEditorWindow.getDialog().pack();
      if (ResourceController.getResourceController().getBooleanProperty("el__position_window_below_node")) {
        UITools.setDialogLocationUnder(htmlEditorWindow.getDialog(), node);
      }
      else {
        UITools.setDialogLocationRelativeTo(htmlEditorWindow.getDialog(), node);
      }
      String content = text;
      if (!HtmlUtils.isHtmlNode(content)) {
        content = HtmlUtils.plainToHTML(content);
      }
      htmlEditorPanel.setCurrentDocumentContent(content);
      final KeyEvent firstKeyEvent = MTextController.getController().getEventQueue().getFirstEvent();
      final JTextComponent currentPane = htmlEditorPanel.getEditorPane();
      if (currentPane == htmlEditorPanel.getMostRecentFocusOwner()) {
        redispatchKeyEvents(currentPane, firstKeyEvent);
        if (firstKeyEvent == null) {
          editorPane.setCaretPosition(htmlEditorPanel.getDocument().getLength());
        }
      }
      else{
        final EventBuffer keyEventDispatcher = MTextController.getController().getEventQueue();
        keyEventDispatcher.deactivate();
      }
      htmlEditorPanel.getMostRecentFocusOwner().requestFocus();
      htmlEditorWindow.show();
    }
    catch (final Exception ex) {
      LogUtils.severe("Loading of WYSIWYG HTML editor failed. Use the other editors instead.", ex);
    }
View Full Code Here

      public void initActions(SHTMLPanel panel) {
        panel.addAction("editLink", new SHTMLEditLinkAction((SHTMLPanelImpl) panel));
        panel.addAction("setLinkByFileChooser", new SHTMLSetLinkByFileChooserAction((SHTMLPanelImpl) panel));
      }
    });
      final SHTMLPanel shtmlPanel = SHTMLPanel.createSHTMLPanel();
      shtmlPanel.setOpenHyperlinkHandler(new ActionListener(){

      public void actionPerformed(ActionEvent pE) {
        try {
          UrlManager.getController().loadURL(new URI(pE.getActionCommand()));
        } catch (Exception e) {
          LogUtils.warn(e);
        }
      }});

      final JEditorPane editorPane = shtmlPanel.getEditorPane();
      editorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, false);
      fireEditorPaneCreated(editorPane, purpose);
           
    return shtmlPanel;
    }
View Full Code Here

TOP

Related Classes of com.lightdev.app.shtm.SHTMLPanel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.