예제 #1
0
  /**
   * Creates component.
   *
   * @param collection collection to show.
   * @param treeMode <code>TRUE</code> to set tree mode by default.
   * @param readingLists <code>TRUE</code> if showing reading lists.
   */
  public CListTree(Collection collection, boolean treeMode, boolean readingLists) {
    this.collection = collection;
    this.readingLists = readingLists;

    itemListener = new CItemListener();

    setLayout(new BorderLayout());
    setTreeMode(treeMode);

    BBFormBuilder builder = new BBFormBuilder("p, 2dlu, p, 0:grow");

    JComboBox cbViewMode =
        new JComboBox(
            new Object[] {
              Strings.message("collections.viewmode.tree"),
              Strings.message("collections.viewmode.list")
            });
    cbViewMode.setSelectedIndex(treeMode ? 0 : 1);
    cbViewMode.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            JComboBox box = (JComboBox) e.getSource();
            boolean isTree = box.getSelectedIndex() == 0;
            setTreeMode(isTree);
          }
        });

    builder.append(Strings.message("collections.viewmode"), cbViewMode);
    builder.appendRelatedComponentsGapRow(2);

    add(builder.getPanel(), BorderLayout.NORTH);

    // Description area
    taDescription = new JEditorPane();
    Color back = taDescription.getBackground();
    taDescription.setEditable(false);
    taDescription.setBackground(back);
    taDescription.setEditorKit(new CustomHTMLEditorKit());

    HTMLDocument doc = (HTMLDocument) taDescription.getDocument();
    Style def = doc.getStyle("default");
    Font font = UIManager.getFont("TextArea.font");
    if (SystemUtils.IS_OS_MAC) font = UifUtilities.applyFontBias(font, -2);
    UifUtilities.setFontAttributes(doc.addStyle(TEXT_STYLE, def), font);

    builder = new BBFormBuilder("0:grow");
    builder.appendUnrelatedComponentsGapRow(2);
    builder.appendRow("p");

    builder.append(Strings.message("collections.description"), 1);
    builder.appendRelatedComponentsGapRow(2);
    builder.appendRow("50px");
    builder.append(taDescription, 1, CellConstraints.FILL, CellConstraints.FILL);

    add(builder.getPanel(), BorderLayout.SOUTH);
  }
  private void initComponents() {
    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

    messagePane.setBackground(contentPane.getBackground());
    messagePane.setEditorKit(new HTMLEditorKit());
    messagePane.setForeground(contentPane.getForeground());

    setSize(450, 360);

    // center the window
    int x = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() - getWidth()) / 2;
    int y = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() - getHeight()) / 2;
    setLocation(x, y);

    okButton.addActionListener(this);
  }
 public void actionPerformed(final AnActionEvent e) {
   @NonNls final String delim = "&nbsp;-&gt;&nbsp;";
   final StringBuffer buf = new StringBuffer();
   processDependencies(
       getSelectedScope(myLeftTree),
       getSelectedScope(myRightTree),
       new Processor<List<PsiFile>>() {
         public boolean process(final List<PsiFile> path) {
           if (buf.length() > 0) buf.append("<br>");
           buf.append(
               StringUtil.join(
                   path,
                   new Function<PsiFile, String>() {
                     public String fun(final PsiFile psiFile) {
                       return psiFile.getName();
                     }
                   },
                   delim));
           return true;
         }
       });
   final JEditorPane pane =
       new JEditorPane(UIUtil.HTML_MIME, "<html>" + buf.toString() + "</html>");
   pane.setForeground(Color.black);
   pane.setBackground(HintUtil.INFORMATION_COLOR);
   pane.setOpaque(true);
   final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(pane);
   final Dimension dimension = pane.getPreferredSize();
   scrollPane.setMinimumSize(new Dimension(dimension.width, dimension.height + 20));
   scrollPane.setPreferredSize(new Dimension(dimension.width, dimension.height + 20));
   JBPopupFactory.getInstance()
       .createComponentPopupBuilder(scrollPane, pane)
       .setTitle("Dependencies")
       .setMovable(true)
       .createPopup()
       .showInBestPositionFor(e.getDataContext());
 }
예제 #4
0
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Windows Form
   * Designer. Otherwise, retrieving design might not work properly. Tip: If you must revise this
   * method, please backup this GUI file for JFrameBuilder to retrieve your design properly in
   * future, before revising this method.
   */
  private void initializeComponent() {
    jLabel1 = new JLabel();
    jLabel2 = new JLabel();
    jLabel3 = new JLabel();
    jLabel4 = new JLabel();
    jLabel5 = new JLabel();
    jLabel6 = new JLabel("Pets");
    jLabel7 = new JLabel("Drinking");
    jLabel8 = new JLabel("Smoking");
    jButton1 = new JButton("Back");

    passion = new JEditorPane();
    passion1 = new JScrollPane();
    books = new JEditorPane();
    books1 = new JScrollPane();
    movies = new JEditorPane();
    movies1 = new JScrollPane();
    /*
    jTextField1 = new JTextField();
    jTextField2 = new JTextField();
    jTextField3 = new JTextField();
    */
    jTextField4 = new JTextField();
    jTextField5 = new JTextField();
    jTextField6 = new JTextField();
    jTextField7 = new JTextField();
    jTextField8 = new JTextField();

    passion1.setViewportView(passion);
    books1.setViewportView(books);
    movies1.setViewportView(movies);

    contentPane = (JPanel) this.getContentPane();

    // set editable false

    passion.setEditable(false);
    books.setEditable(false);
    movies.setEditable(false);
    jTextField4.setEditable(false);
    jTextField5.setEditable(false);
    jTextField6.setEditable(false);
    jTextField7.setEditable(false);
    jTextField8.setEditable(false);

    //
    // jLabel1
    //
    jLabel1.setText("Passion");
    //
    // jLabel2
    //
    jLabel2.setText("Books");
    //
    // jLabel3
    //
    jLabel3.setText("Movies");
    //
    // jLabel4
    //
    jLabel4.setText("Living");
    //
    // jLabel5
    //
    jLabel5.setText("Fashion");
    //
    // jTextField1
    //

    /*
    jTextField1.addActionListener(new ActionListener() {
    	public void actionPerformed(ActionEvent e)
    	{
    		jTextField1_actionPerformed(e);
    	}

    });
    //
    // jTextField2
    //

    jTextField2.addActionListener(new ActionListener() {
    	public void actionPerformed(ActionEvent e)
    	{
    		jTextField2_actionPerformed(e);
    	}

    });
    //
    // jTextField3
    //

    jTextField3.addActionListener(new ActionListener() {
    	public void actionPerformed(ActionEvent e)
    	{
    		jTextField3_actionPerformed(e);
    	}

    });

    */
    //
    // jTextField4
    //

    jTextField4.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            jTextField4_actionPerformed(e);
          }
        });
    //
    // jTextField5
    //

    jTextField5.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            jTextField5_actionPerformed(e);
          }
        });

    jButton1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            jButton1_actionPerformed(e);
          }
        });
    //
    // contentPane
    //
    contentPane.setLayout(null);
    contentPane.setBackground(new Color(158, 168, 237));
    addComponent(contentPane, jLabel1, 36, 97, 86, 26);
    addComponent(contentPane, jLabel2, 34, 238, 60, 18);
    addComponent(contentPane, jLabel3, 33, 373, 60, 18);
    addComponent(contentPane, jLabel4, 31, 440, 60, 18);
    addComponent(contentPane, jLabel5, 30, 484, 60, 18);
    addComponent(contentPane, jLabel6, 30, 527, 60, 18);
    addComponent(contentPane, jLabel7, 30, 567, 60, 18);
    addComponent(contentPane, jLabel8, 30, 612, 60, 18);
    addComponent(contentPane, passion1, 237, 59, 350, 96);
    addComponent(contentPane, books1, 236, 189, 350, 96);
    addComponent(contentPane, movies1, 236, 320, 350, 98);
    addComponent(contentPane, jTextField4, 237, 440, 350, 22);
    addComponent(contentPane, jTextField5, 237, 484, 350, 22);
    addComponent(contentPane, jTextField6, 237, 527, 350, 22);
    addComponent(contentPane, jTextField7, 237, 567, 350, 22);
    addComponent(contentPane, jTextField8, 237, 612, 350, 22);
    addComponent(contentPane, jButton1, 456, 654, 74, 25);

    //
    // viewprofile1
    //

    passion.setBackground(new Color(161, 247, 241));
    books.setBackground(new Color(244, 195, 103));
    movies.setBackground(new Color(239, 122, 247));
    jTextField4.setBackground(new Color(161, 247, 241));
    jTextField5.setBackground(new Color(244, 195, 103));
    jTextField6.setBackground(new Color(239, 122, 247));
    jTextField7.setBackground(new Color(161, 247, 241));
    jTextField8.setBackground(new Color(244, 195, 103));
    this.setTitle("viewprofile1 - extends JFrame");
    this.setLocation(new Point(0, 0));
    this.setSize(new Dimension(1024, 768));
  }
  public DocumentationComponent(
      final DocumentationManager manager, final AnAction[] additionalActions) {
    myManager = manager;
    myIsEmpty = true;
    myIsShown = false;

    myEditorPane =
        new JEditorPane(UIUtil.HTML_MIME, "") {
          @Override
          public Dimension getPreferredScrollableViewportSize() {
            if (getWidth() == 0 || getHeight() == 0) {
              setSize(MAX_WIDTH, MAX_HEIGHT);
            }
            Insets ins = myEditorPane.getInsets();
            View rootView = myEditorPane.getUI().getRootView(myEditorPane);
            rootView.setSize(
                MAX_WIDTH,
                MAX_HEIGHT); // Necessary! Without this line, size will not increase then you go
            // from small page to bigger one
            int prefHeight = (int) rootView.getPreferredSpan(View.Y_AXIS);
            prefHeight +=
                ins.bottom
                    + ins.top
                    + myScrollPane.getHorizontalScrollBar().getMaximumSize().height;
            return new Dimension(MAX_WIDTH, Math.max(MIN_HEIGHT, Math.min(MAX_HEIGHT, prefHeight)));
          }

          {
            enableEvents(AWTEvent.KEY_EVENT_MASK);
          }

          @Override
          protected void processKeyEvent(KeyEvent e) {
            KeyStroke keyStroke = KeyStroke.getKeyStrokeForEvent(e);
            ActionListener listener = myKeyboardActions.get(keyStroke);
            if (listener != null) {
              listener.actionPerformed(new ActionEvent(DocumentationComponent.this, 0, ""));
              e.consume();
              return;
            }
            super.processKeyEvent(e);
          }

          @Override
          protected void paintComponent(Graphics g) {
            GraphicsUtil.setupAntialiasing(g);
            super.paintComponent(g);
          }
        };
    DataProvider helpDataProvider =
        new DataProvider() {
          @Override
          public Object getData(@NonNls String dataId) {
            return PlatformDataKeys.HELP_ID.is(dataId) ? DOCUMENTATION_TOPIC_ID : null;
          }
        };
    myEditorPane.putClientProperty(DataManager.CLIENT_PROPERTY_DATA_PROVIDER, helpDataProvider);
    myText = "";
    myEditorPane.setEditable(false);
    myEditorPane.setBackground(HintUtil.INFORMATION_COLOR);
    myEditorPane.setEditorKit(UIUtil.getHTMLEditorKit());
    myScrollPane =
        new JBScrollPane(myEditorPane) {
          @Override
          protected void processMouseWheelEvent(MouseWheelEvent e) {
            if (!EditorSettingsExternalizable.getInstance().isWheelFontChangeEnabled()
                || !EditorUtil.isChangeFontSize(e)) {
              super.processMouseWheelEvent(e);
              return;
            }

            int change = Math.abs(e.getWheelRotation());
            boolean increase = e.getWheelRotation() <= 0;
            EditorColorsManager colorsManager = EditorColorsManager.getInstance();
            EditorColorsScheme scheme = colorsManager.getGlobalScheme();
            FontSize newFontSize = scheme.getQuickDocFontSize();
            for (; change > 0; change--) {
              if (increase) {
                newFontSize = newFontSize.larger();
              } else {
                newFontSize = newFontSize.smaller();
              }
            }

            if (newFontSize == scheme.getQuickDocFontSize()) {
              return;
            }

            scheme.setQuickDocFontSize(newFontSize);
            applyFontSize();
            setFontSizeSliderSize(newFontSize);
          }
        };
    myScrollPane.setBorder(null);
    myScrollPane.putClientProperty(DataManager.CLIENT_PROPERTY_DATA_PROVIDER, helpDataProvider);

    final MouseAdapter mouseAdapter =
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            myManager.requestFocus();
            myShowSettingsButton.hideSettings();
          }
        };
    myEditorPane.addMouseListener(mouseAdapter);
    Disposer.register(
        this,
        new Disposable() {
          @Override
          public void dispose() {
            myEditorPane.removeMouseListener(mouseAdapter);
          }
        });

    final FocusAdapter focusAdapter =
        new FocusAdapter() {
          @Override
          public void focusLost(FocusEvent e) {
            Component previouslyFocused =
                WindowManagerEx.getInstanceEx()
                    .getFocusedComponent(manager.getProject(getElement()));

            if (!(previouslyFocused == myEditorPane)) {
              if (myHint != null && !myHint.isDisposed()) myHint.cancel();
            }
          }
        };
    myEditorPane.addFocusListener(focusAdapter);

    Disposer.register(
        this,
        new Disposable() {
          @Override
          public void dispose() {
            myEditorPane.removeFocusListener(focusAdapter);
          }
        });

    setLayout(new BorderLayout());
    JLayeredPane layeredPane =
        new JBLayeredPane() {
          @Override
          public void doLayout() {
            final Rectangle r = getBounds();
            for (Component component : getComponents()) {
              if (component instanceof JScrollPane) {
                component.setBounds(0, 0, r.width, r.height);
              } else {
                int insets = 2;
                Dimension d = component.getPreferredSize();
                component.setBounds(r.width - d.width - insets, insets, d.width, d.height);
              }
            }
          }

          @Override
          public Dimension getPreferredSize() {
            Dimension editorPaneSize = myEditorPane.getPreferredScrollableViewportSize();
            Dimension controlPanelSize = myControlPanel.getPreferredSize();
            return new Dimension(
                Math.max(editorPaneSize.width, controlPanelSize.width),
                editorPaneSize.height + controlPanelSize.height);
          }
        };
    layeredPane.add(myScrollPane);
    layeredPane.setLayer(myScrollPane, 0);

    mySettingsPanel = createSettingsPanel();
    layeredPane.add(mySettingsPanel);
    layeredPane.setLayer(mySettingsPanel, JLayeredPane.POPUP_LAYER);
    add(layeredPane, BorderLayout.CENTER);
    setOpaque(true);
    myScrollPane.setViewportBorder(JBScrollPane.createIndentBorder());

    final DefaultActionGroup actions = new DefaultActionGroup();
    final BackAction back = new BackAction();
    final ForwardAction forward = new ForwardAction();
    actions.add(back);
    actions.add(forward);
    actions.add(myExternalDocAction = new ExternalDocAction());
    back.registerCustomShortcutSet(CustomShortcutSet.fromString("LEFT"), this);
    forward.registerCustomShortcutSet(CustomShortcutSet.fromString("RIGHT"), this);
    myExternalDocAction.registerCustomShortcutSet(CustomShortcutSet.fromString("UP"), this);
    if (additionalActions != null) {
      for (final AnAction action : additionalActions) {
        actions.add(action);
      }
    }

    myToolBar =
        ActionManager.getInstance()
            .createActionToolbar(ActionPlaces.JAVADOC_TOOLBAR, actions, true);

    myControlPanel = new JPanel();
    myControlPanel.setLayout(new BorderLayout());
    myControlPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM));
    JPanel dummyPanel = new JPanel();

    myElementLabel = new JLabel();

    dummyPanel.setLayout(new BorderLayout());
    dummyPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));

    dummyPanel.add(myElementLabel, BorderLayout.EAST);

    myControlPanel.add(myToolBar.getComponent(), BorderLayout.WEST);
    myControlPanel.add(dummyPanel, BorderLayout.CENTER);
    myControlPanel.add(myShowSettingsButton = new MyShowSettingsButton(), BorderLayout.EAST);
    myControlPanelVisible = false;

    final HyperlinkListener hyperlinkListener =
        new HyperlinkListener() {
          @Override
          public void hyperlinkUpdate(HyperlinkEvent e) {
            HyperlinkEvent.EventType type = e.getEventType();
            if (type == HyperlinkEvent.EventType.ACTIVATED) {
              manager.navigateByLink(DocumentationComponent.this, e.getDescription());
            }
          }
        };
    myEditorPane.addHyperlinkListener(hyperlinkListener);
    Disposer.register(
        this,
        new Disposable() {
          @Override
          public void dispose() {
            myEditorPane.removeHyperlinkListener(hyperlinkListener);
          }
        });

    registerActions();

    updateControlState();
  }
  public static JEditorPane initPane(
      @NonNls Html html, final HintHint hintHint, @Nullable final JLayeredPane layeredPane) {
    final Ref<Dimension> prefSize = new Ref<Dimension>(null);
    String htmlBody = UIUtil.getHtmlBody(html);
    @NonNls
    String text =
        "<html><head>"
            + UIUtil.getCssFontDeclaration(
                hintHint.getTextFont(),
                hintHint.getTextForeground(),
                hintHint.getLinkForeground(),
                hintHint.getUlImg())
            + "</head><body>"
            + htmlBody
            + "</body></html>";

    final boolean[] prefSizeWasComputed = {false};
    final JEditorPane pane =
        new JEditorPane() {
          @Override
          public Dimension getPreferredSize() {
            if (!prefSizeWasComputed[0] && hintHint.isAwtTooltip()) {
              JLayeredPane lp = layeredPane;
              if (lp == null) {
                JRootPane rootPane = UIUtil.getRootPane(this);
                if (rootPane != null) {
                  lp = rootPane.getLayeredPane();
                }
              }

              Dimension size;
              if (lp != null) {
                size = lp.getSize();
                prefSizeWasComputed[0] = true;
              } else {
                size = ScreenUtil.getScreenRectangle(0, 0).getSize();
              }
              int fitWidth = (int) (size.width * 0.8);
              Dimension prefSizeOriginal = super.getPreferredSize();
              if (prefSizeOriginal.width > fitWidth) {
                setSize(new Dimension(fitWidth, Integer.MAX_VALUE));
                Dimension fixedWidthSize = super.getPreferredSize();
                Dimension minSize = super.getMinimumSize();
                prefSize.set(
                    new Dimension(
                        fitWidth > minSize.width ? fitWidth : minSize.width,
                        fixedWidthSize.height));
              } else {
                prefSize.set(new Dimension(prefSizeOriginal));
              }
            }

            Dimension s =
                prefSize.get() != null ? new Dimension(prefSize.get()) : super.getPreferredSize();
            Border b = getBorder();
            if (b != null) {
              Insets insets = b.getBorderInsets(this);
              if (insets != null) {
                s.width += insets.left + insets.right;
                s.height += insets.top + insets.bottom;
              }
            }
            return s;
          }
        };

    final HTMLEditorKit.HTMLFactory factory =
        new HTMLEditorKit.HTMLFactory() {
          @Override
          public View create(Element elem) {
            AttributeSet attrs = elem.getAttributes();
            Object elementName = attrs.getAttribute(AbstractDocument.ElementNameAttribute);
            Object o =
                elementName != null ? null : attrs.getAttribute(StyleConstants.NameAttribute);
            if (o instanceof HTML.Tag) {
              HTML.Tag kind = (HTML.Tag) o;
              if (kind == HTML.Tag.HR) {
                return new CustomHrView(elem, hintHint.getTextForeground());
              }
            }
            return super.create(elem);
          }
        };

    HTMLEditorKit kit =
        new HTMLEditorKit() {
          @Override
          public ViewFactory getViewFactory() {
            return factory;
          }
        };
    pane.setEditorKit(kit);
    pane.setText(text);

    pane.setCaretPosition(0);
    pane.setEditable(false);

    if (hintHint.isOwnBorderAllowed()) {
      setBorder(pane);
      setColors(pane);
    } else {
      pane.setBorder(null);
    }

    if (!hintHint.isAwtTooltip()) {
      prefSizeWasComputed[0] = true;
    }

    final boolean opaque = hintHint.isOpaqueAllowed();
    pane.setOpaque(opaque);
    if (UIUtil.isUnderNimbusLookAndFeel() && !opaque) {
      pane.setBackground(UIUtil.TRANSPARENT_COLOR);
    } else {
      pane.setBackground(hintHint.getTextBackground());
    }

    return pane;
  }
예제 #7
0
  protected void createAndShowGUI() {
    System.setProperty("swing.defaultlaf", UIManager.getSystemLookAndFeelClassName());

    image = DavGatewayTray.loadImage("tray.png");
    image2 = DavGatewayTray.loadImage(AwtGatewayTray.TRAY_ACTIVE_PNG);
    inactiveImage = DavGatewayTray.loadImage(AwtGatewayTray.TRAY_INACTIVE_PNG);

    mainFrame = new JFrame();
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.setTitle(BundleMessage.format("UI_DAVMAIL_GATEWAY"));
    mainFrame.setIconImage(image);

    JPanel errorPanel = new JPanel();
    errorPanel.setBorder(BorderFactory.createTitledBorder(BundleMessage.format("UI_LAST_MESSAGE")));
    errorPanel.setLayout(new BoxLayout(errorPanel, BoxLayout.X_AXIS));
    errorArea = new JTextPane();
    errorArea.setEditable(false);
    errorArea.setBackground(mainFrame.getBackground());
    errorLabel = new JLabel();
    errorPanel.add(errorLabel);
    errorPanel.add(errorArea);

    JPanel messagePanel = new JPanel();
    messagePanel.setBorder(BorderFactory.createTitledBorder(BundleMessage.format("UI_LAST_LOG")));
    messagePanel.setLayout(new BoxLayout(messagePanel, BoxLayout.X_AXIS));

    messageArea = new JTextPane();
    messageArea.setText(BundleMessage.format("LOG_STARTING_DAVMAIL"));
    messageArea.setEditable(false);
    messageArea.setBackground(mainFrame.getBackground());
    messagePanel.add(messageArea);

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(errorPanel);
    mainPanel.add(messagePanel);
    mainFrame.add(mainPanel);

    aboutFrame = new AboutFrame();
    settingsFrame = new SettingsFrame();
    buildMenu();

    mainFrame.setMinimumSize(new Dimension(400, 180));
    mainFrame.pack();
    // workaround MacOSX
    if (mainFrame.getSize().width < 400 || mainFrame.getSize().height < 180) {
      mainFrame.setSize(
          Math.max(mainFrame.getSize().width, 400), Math.max(mainFrame.getSize().height, 180));
    }
    // center frame
    mainFrame.setLocation(
        mainFrame.getToolkit().getScreenSize().width / 2 - mainFrame.getSize().width / 2,
        mainFrame.getToolkit().getScreenSize().height / 2 - mainFrame.getSize().height / 2);
    mainFrame.setVisible(true);

    // display settings frame on first start
    if (Settings.isFirstStart()) {
      settingsFrame.setVisible(true);
      settingsFrame.toFront();
      settingsFrame.requestFocus();
    }
  }
예제 #8
0
  private void updateList(final List<WCInfo> infoList) {
    myPanel.removeAll();
    final Insets nullIndent = new Insets(1, 3, 1, 0);
    final GridBagConstraints gb =
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(2, 2, 0, 0),
            0,
            0);
    gb.insets.left = 4;
    myPanel.add(myRefreshLabel, gb);
    gb.insets.left = 1;

    final LocalFileSystem lfs = LocalFileSystem.getInstance();
    final Insets topIndent = new Insets(10, 3, 0, 0);
    for (final WCInfo wcInfo : infoList) {
      final VirtualFile vf = lfs.refreshAndFindFileByIoFile(new File(wcInfo.getPath()));
      final VirtualFile root = (vf == null) ? wcInfo.getVcsRoot() : vf;

      final JEditorPane editorPane = new JEditorPane(UIUtil.HTML_MIME, "");
      editorPane.setEditable(false);
      editorPane.setFocusable(true);
      editorPane.setBackground(UIUtil.getPanelBackground());
      editorPane.addHyperlinkListener(
          new HyperlinkListener() {
            @Override
            public void hyperlinkUpdate(HyperlinkEvent e) {
              if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                if (CONFIGURE_BRANCHES.equals(e.getDescription())) {
                  if (!checkRoot(root, wcInfo.getPath(), " invoke Configure Branches")) return;
                  BranchConfigurationDialog.configureBranches(myProject, root, true);
                } else if (FIX_DEPTH.equals(e.getDescription())) {
                  final int result =
                      Messages.showOkCancelDialog(
                          myVcs.getProject(),
                          "You are going to checkout into '"
                              + wcInfo.getPath()
                              + "' with 'infinity' depth.\n"
                              + "This will update your working copy to HEAD revision as well.",
                          "Set working copy infinity depth",
                          Messages.getWarningIcon());
                  if (result == 0) {
                    // update of view will be triggered by roots changed event
                    SvnCheckoutProvider.checkout(
                        myVcs.getProject(),
                        new File(wcInfo.getPath()),
                        wcInfo.getRootUrl(),
                        SVNRevision.HEAD,
                        SVNDepth.INFINITY,
                        false,
                        null,
                        wcInfo.getFormat());
                  }
                } else if (CHANGE_FORMAT.equals(e.getDescription())) {
                  changeFormat(wcInfo);
                } else if (MERGE_FROM.equals(e.getDescription())) {
                  if (!checkRoot(root, wcInfo.getPath(), " invoke Merge From")) return;
                  mergeFrom(wcInfo, root, editorPane);
                }
              }
            }

            private boolean checkRoot(
                VirtualFile root, final String path, final String actionName) {
              if (root == null) {
                Messages.showWarningDialog(
                    myProject, "Invalid working copy root: " + path, "Can not " + actionName);
                return false;
              }
              return true;
            }
          });
      editorPane.setBorder(null);
      editorPane.setText(formatWc(wcInfo));

      final JPanel copyPanel = new JPanel(new GridBagLayout());

      final GridBagConstraints gb1 =
          new GridBagConstraints(
              0,
              0,
              1,
              1,
              0,
              0,
              GridBagConstraints.NORTHWEST,
              GridBagConstraints.NONE,
              nullIndent,
              0,
              0);
      gb1.insets.top = 1;
      gb1.gridwidth = 3;

      gb.insets = topIndent;
      gb.fill = GridBagConstraints.HORIZONTAL;
      ++gb.gridy;

      final JPanel contForCopy = new JPanel(new BorderLayout());
      contForCopy.add(copyPanel, BorderLayout.WEST);
      myPanel.add(contForCopy, gb);

      copyPanel.add(editorPane, gb1);
      gb1.insets = nullIndent;
    }

    myPanel.revalidate();
    myPanel.repaint();
  }
예제 #9
0
  public JBLabel setCopyable(boolean copyable) {
    if (copyable ^ myEditorPane != null) {
      if (myEditorPane == null) {
        final JLabel ellipsisLabel = new JBLabel("...");
        myIconLabel = new JLabel(getIcon());
        myEditorPane =
            new JEditorPane() {
              @Override
              public void paint(Graphics g) {
                Dimension size = getSize();
                boolean paintEllipsis = getPreferredSize().width > size.width && !myMultiline;

                if (!paintEllipsis) {
                  super.paint(g);
                } else {
                  Dimension ellipsisSize = ellipsisLabel.getPreferredSize();
                  int endOffset = size.width - ellipsisSize.width;
                  try {
                    // do not paint half of the letter
                    endOffset = modelToView(viewToModel(new Point(endOffset, 0)) - 1).x;
                  } catch (BadLocationException ignore) {
                  }
                  Shape oldClip = g.getClip();
                  g.clipRect(0, 0, endOffset, size.height);

                  super.paint(g);
                  g.setClip(oldClip);

                  g.translate(endOffset, 0);
                  ellipsisLabel.setSize(ellipsisSize);
                  ellipsisLabel.paint(g);
                  g.translate(-endOffset, 0);
                }
              }
            };
        myEditorPane.addFocusListener(
            new FocusAdapter() {
              @Override
              public void focusLost(FocusEvent e) {
                if (myEditorPane == null) return;
                int caretPosition = myEditorPane.getCaretPosition();
                myEditorPane.setSelectionStart(caretPosition);
                myEditorPane.setSelectionEnd(caretPosition);
              }
            });
        myEditorPane.setContentType("text/html");
        myEditorPane.setEditable(false);
        myEditorPane.setBackground(UIUtil.TRANSPARENT_COLOR);
        myEditorPane.setOpaque(false);
        myEditorPane.setBorder(null);
        myEditorPane.setText(getText());
        checkMultiline();
        myEditorPane.setCaretPosition(0);
        UIUtil.putClientProperty(
            myEditorPane, UIUtil.NOT_IN_HIERARCHY_COMPONENTS, Collections.singleton(ellipsisLabel));
        updateStyle(myEditorPane);
        setLayout(new BorderLayout(getIconTextGap(), 0));
        add(myIconLabel, BorderLayout.WEST);
        add(myEditorPane, BorderLayout.CENTER);
      } else {
        removeAll();
        myEditorPane = null;
        myIconLabel = null;
      }
    }
    return this;
  }
예제 #10
0
 public void setEditorBackground(Color c) {
   editor.setBackground(c);
 }
예제 #11
0
  /**
   * Constructor, initialises the editor components.
   *
   * @param initialText The initial text to be displayed in the editor.
   * @param handler The GUI handler for this component.
   */
  public GUITextModelEditor(String initialText, GUIMultiModelHandler handler) {
    this.handler = handler;
    setLayout(new BorderLayout());

    // Setup the editor with it's custom editor kits. To switch between
    // editor kits just use setContentType() for the desired content type.
    editor =
        new JEditorPane() {
          @Override
          public String getToolTipText(MouseEvent event) {
            if (parseError != null) {
              try {
                int offset = this.viewToModel(new Point(event.getX(), event.getY()));

                int startOffset =
                    computeDocumentOffset(parseError.getBeginLine(), parseError.getBeginColumn());
                int endOffset =
                    computeDocumentOffset(parseError.getEndLine(), parseError.getEndColumn()) + 1;

                if (offset >= startOffset && offset <= endOffset) return parseError.getMessage();
              } catch (BadLocationException e) {
              }
            }

            return null;
          }
        };

    editor.setToolTipText("dummy");

    editor.setEditorKitForContentType("text/prism", new PrismEditorKit(handler));
    editor.setEditorKitForContentType("text/pepa", new PepaEditorKit(handler));
    // The default editor kit is the Prism one.
    editor.setContentType("text/prism");
    editor.setBackground(Color.white);
    editor.addMouseListener(editorMouseListener);
    editor.setEditable(true);
    editor.setText(initialText);
    editor.getDocument().addDocumentListener(this);
    editor.addCaretListener(
        new CaretListener() {
          public void caretUpdate(CaretEvent e) {
            GUITextModelEditor.this
                .handler
                .getGUIPlugin()
                .getSelectionChangeHandler()
                .notifyListeners(new GUIEvent(1));
          }
        });
    editor.getDocument().putProperty(PlainDocument.tabSizeAttribute, new Integer(4));

    editor.addMouseListener(this);
    errorHighlightPainter =
        new DefaultHighlighter.DefaultHighlightPainter(new Color(255, 192, 192));
    undoManager = new GUIUndoManager(GUIPrism.getGUI());
    undoManager.setLimit(200);

    // Setup the scrollpane
    editorScrollPane = new JScrollPane(editor);
    add(editorScrollPane, BorderLayout.CENTER);
    gutter = new GUITextModelEditorGutter(editor);

    // Get the 'show line numbers' setting to determine
    // if the line numbers should be shown.
    showLineNumbersSetting =
        handler
            .getGUIPlugin()
            .getPrism()
            .getSettings()
            .getBoolean(PrismSettings.MODEL_SHOW_LINE_NUMBERS);
    if (showLineNumbersSetting) {
      editorScrollPane.setRowHeaderView(gutter);
    }

    // Add a Prism settings listener to catch changes made to the
    // 'show line numbers' setting.
    handler
        .getGUIPlugin()
        .getPrism()
        .getSettings()
        .addSettingsListener(
            new PrismSettingsListener() {
              public void notifySettings(PrismSettings settings) {
                // Check if the setting has changed.
                if (settings.getBoolean(PrismSettings.MODEL_SHOW_LINE_NUMBERS)
                    != showLineNumbersSetting) {
                  showLineNumbersSetting = !showLineNumbersSetting;
                  if (showLineNumbersSetting) {
                    editorScrollPane.setRowHeaderView(gutter);
                  } else {
                    editorScrollPane.setRowHeaderView(null);
                  }
                }
              }
            });

    // initialize the actions for the context menu
    initActions();

    // method to initialize the context menu popup
    initContextMenu();

    InputMap inputMap = editor.getInputMap();
    inputMap.clear();

    inputMap.put(
        KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
        "prism_undo");
    inputMap.put(
        KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
        "prism_undo");
    inputMap.put(
        KeyStroke.getKeyStroke(KeyEvent.VK_Y, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
        "prism_redo");
    inputMap.put(
        KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
        "prism_selectall");
    inputMap.put(
        KeyStroke.getKeyStroke(KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
        "prism_delete");
    inputMap.put(
        KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
        "prism_cut");
    inputMap.put(
        KeyStroke.getKeyStroke(
            KeyEvent.VK_Z,
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()
                | java.awt.event.InputEvent.SHIFT_MASK),
        "prism_redo");
    inputMap.put(
        KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
        "prism_paste");
    inputMap.put(
        KeyStroke.getKeyStroke(KeyEvent.VK_E, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
        "prism_jumperr");

    ActionMap actionMap = editor.getActionMap();
    actionMap.put("prism_undo", GUIPrism.getClipboardPlugin().getUndoAction());
    actionMap.put("prism_redo", GUIPrism.getClipboardPlugin().getRedoAction());
    actionMap.put("prism_selectall", GUIPrism.getClipboardPlugin().getSelectAllAction());
    actionMap.put("prism_cut", GUIPrism.getClipboardPlugin().getCutAction());
    actionMap.put("prism_copy", GUIPrism.getClipboardPlugin().getCopyAction());
    actionMap.put("prism_paste", GUIPrism.getClipboardPlugin().getPasteAction());
    actionMap.put("prism_delete", GUIPrism.getClipboardPlugin().getDeleteAction());
    actionMap.put("prism_jumperr", actionJumpToError);

    // Attempt to programmatically allow all accelerators
    /*ArrayList plugins = ((GUIMultiModel)handler.getGUIPlugin()).getGUI().getPlugins();
    Iterator it = plugins.iterator();

    while (it.hasNext())
    {
    	GUIPlugin plugin = ((GUIPlugin)it.next());
    	System.out.println(plugin.getName());
    	JMenu firstMenu = plugin.getMenu();

    	Stack<MenuElement> menuStack = new Stack<MenuElement>();

    	menuStack.add(firstMenu);

    	while (!menuStack.empty())
    	{
    		MenuElement menu = menuStack.pop();

    		if (menu instanceof JMenuItem)
    		{
    			JMenuItem menuItem = ((JMenuItem)menu);

    			KeyStroke accelerator = menuItem.getAccelerator();
    			Action action = menuItem.getAction();

    			if (action != null && accelerator != null && menuItem.getText() != null)
    			{
    				System.out.println(menuItem.getText() + " " + menuItem.getName());
    				inputMap.put(accelerator, "prism_" + menuItem.getText());
    				actionMap.put("prism_" + menuItem.getText(), action);
    			}
    		}

    		MenuElement[] subelements = menu.getSubElements();

    		if (subelements != null)
    		{
    			for (int i = 0; i < subelements.length; i++)
    				menuStack.push(subelements[i]);
    		}
    	}
    }*/

    editor.getDocument().addUndoableEditListener(undoManager);
    editor
        .getDocument()
        .addUndoableEditListener(
            new UndoableEditListener() {
              public void undoableEditHappened(UndoableEditEvent e) {
                System.out.println("adding undo edit");
              }
            });
  }
예제 #12
0
  public void initializeMainView(
      final SuperAdapter superAdapter,
      Container contentPane,
      Dimension bigPanelDim,
      Dimension panelDim) {
    contentPane.setLayout(new BorderLayout());

    final JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    contentPane.add(mainPanel, BorderLayout.CENTER);
    mainPanel.setBackground(Color.white);

    final JPanel toolbarPanel = new JPanel();
    toolbarPanel.setBorder(null);

    toolbarPanel.setLayout(new GridBagLayout());
    mainPanel.add(toolbarPanel, BorderLayout.NORTH);

    JPanel bigPanel = new JPanel();
    bigPanel.setLayout(new BorderLayout());
    bigPanel.setBackground(Color.white);

    bigPanel.setPreferredSize(new Dimension(bigPanelDim));
    bigPanel.setMaximumSize(new Dimension(bigPanelDim));
    bigPanel.setMinimumSize(new Dimension(bigPanelDim));

    JPanel bottomPanel = new JPanel();
    bottomPanel.setBackground(Color.white);

    JMenuBar menuBar = null;
    try {
      menuBar = superAdapter.createMenuBar();
    } catch (Exception e) {
      e.printStackTrace();
    }
    assert menuBar != null;
    contentPane.add(menuBar, BorderLayout.NORTH);

    GridBagConstraints toolbarConstraints = new GridBagConstraints();
    toolbarConstraints.anchor = GridBagConstraints.LINE_START;
    toolbarConstraints.fill = GridBagConstraints.HORIZONTAL;
    toolbarConstraints.gridx = 0;
    toolbarConstraints.gridy = 0;
    toolbarConstraints.weightx = 0.1;

    // --- Chromosome panel ---
    JPanel chrSelectionPanel = new JPanel();
    toolbarPanel.add(chrSelectionPanel, toolbarConstraints);

    chrSelectionPanel.setBorder(LineBorder.createGrayLineBorder());

    chrSelectionPanel.setLayout(new BorderLayout());

    JPanel chrLabelPanel = new JPanel();
    JLabel chrLabel = new JLabel("Chromosomes");
    chrLabel.setHorizontalAlignment(SwingConstants.CENTER);
    chrLabelPanel.setBackground(HiCGlobals.backgroundColor);
    chrLabelPanel.setLayout(new BorderLayout());
    chrLabelPanel.add(chrLabel, BorderLayout.CENTER);
    chrSelectionPanel.add(chrLabelPanel, BorderLayout.PAGE_START);

    JPanel chrButtonPanel = new JPanel();
    chrButtonPanel.setBackground(new Color(238, 238, 238));
    chrButtonPanel.setLayout(new BoxLayout(chrButtonPanel, BoxLayout.X_AXIS));

    // ---- chrBox1 ----
    chrBox1 = new JComboBox<Chromosome>();
    chrBox1.setModel(
        new DefaultComboBoxModel<Chromosome>(new Chromosome[] {new Chromosome(0, "All", 0)}));
    chrBox1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            chrBox1ActionPerformed(e);
          }
        });
    chrBox1.setPreferredSize(new Dimension(95, 70));
    chrButtonPanel.add(chrBox1);

    // ---- chrBox2 ----
    chrBox2 = new JComboBox<Chromosome>();
    chrBox2.setModel(
        new DefaultComboBoxModel<Chromosome>(new Chromosome[] {new Chromosome(0, "All", 0)}));
    chrBox2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            chrBox2ActionPerformed(e);
          }
        });
    chrBox2.setPreferredSize(new Dimension(95, 70));
    chrButtonPanel.add(chrBox2);

    // ---- refreshButton ----
    refreshButton = new JideButton();
    refreshButton.setIcon(
        new ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Refresh24.gif")));
    refreshButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            superAdapter.safeRefreshButtonActionPerformed();
          }
        });
    refreshButton.setPreferredSize(new Dimension(24, 24));
    chrButtonPanel.add(refreshButton);

    chrBox1.setEnabled(false);
    chrBox2.setEnabled(false);
    refreshButton.setEnabled(false);
    chrSelectionPanel.add(chrButtonPanel, BorderLayout.CENTER);

    chrSelectionPanel.setMinimumSize(new Dimension(200, 70));
    chrSelectionPanel.setPreferredSize(new Dimension(210, 70));

    // ======== Display Option Panel ========
    JPanel displayOptionPanel = new JPanel();
    displayOptionPanel.setBackground(new Color(238, 238, 238));
    displayOptionPanel.setBorder(LineBorder.createGrayLineBorder());
    displayOptionPanel.setLayout(new BorderLayout());
    JPanel displayOptionLabelPanel = new JPanel();
    displayOptionLabelPanel.setBackground(HiCGlobals.backgroundColor);
    displayOptionLabelPanel.setLayout(new BorderLayout());

    JLabel displayOptionLabel = new JLabel("Show");
    displayOptionLabel.setHorizontalAlignment(SwingConstants.CENTER);
    displayOptionLabelPanel.add(displayOptionLabel, BorderLayout.CENTER);
    displayOptionPanel.add(displayOptionLabelPanel, BorderLayout.PAGE_START);
    JPanel displayOptionButtonPanel = new JPanel();
    displayOptionButtonPanel.setBorder(new EmptyBorder(0, 10, 0, 10));
    displayOptionButtonPanel.setLayout(new GridLayout(1, 0, 20, 0));
    displayOptionComboBox = new JComboBox<MatrixType>();
    displayOptionComboBox.setModel(
        new DefaultComboBoxModel<MatrixType>(new MatrixType[] {MatrixType.OBSERVED}));
    displayOptionComboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            superAdapter.safeDisplayOptionComboBoxActionPerformed();
            normalizationComboBox.setEnabled(!isWholeGenome());
          }
        });
    displayOptionButtonPanel.add(displayOptionComboBox);
    displayOptionPanel.add(displayOptionButtonPanel, BorderLayout.CENTER);
    displayOptionPanel.setMinimumSize(new Dimension(140, 70));
    displayOptionPanel.setPreferredSize(new Dimension(140, 70));
    displayOptionPanel.setMaximumSize(new Dimension(140, 70));

    toolbarConstraints.gridx = 1;
    toolbarConstraints.weightx = 0.1;
    toolbarPanel.add(displayOptionPanel, toolbarConstraints);
    displayOptionComboBox.setEnabled(false);

    // ======== Normalization Panel ========
    JPanel normalizationPanel = new JPanel();
    normalizationPanel.setBackground(new Color(238, 238, 238));
    normalizationPanel.setBorder(LineBorder.createGrayLineBorder());
    normalizationPanel.setLayout(new BorderLayout());

    JPanel normalizationLabelPanel = new JPanel();
    normalizationLabelPanel.setBackground(HiCGlobals.backgroundColor);
    normalizationLabelPanel.setLayout(new BorderLayout());

    JLabel normalizationLabel = new JLabel("Normalization");
    normalizationLabel.setHorizontalAlignment(SwingConstants.CENTER);
    normalizationLabelPanel.add(normalizationLabel, BorderLayout.CENTER);
    normalizationPanel.add(normalizationLabelPanel, BorderLayout.PAGE_START);

    JPanel normalizationButtonPanel = new JPanel();
    normalizationButtonPanel.setBorder(new EmptyBorder(0, 10, 0, 10));
    normalizationButtonPanel.setLayout(new GridLayout(1, 0, 20, 0));
    normalizationComboBox = new JComboBox<String>();
    normalizationComboBox.setModel(
        new DefaultComboBoxModel<String>(new String[] {NormalizationType.NONE.getLabel()}));
    normalizationComboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            superAdapter.safeNormalizationComboBoxActionPerformed(e);
          }
        });
    normalizationButtonPanel.add(normalizationComboBox);
    normalizationPanel.add(normalizationButtonPanel, BorderLayout.CENTER);
    normalizationPanel.setPreferredSize(new Dimension(180, 70));
    normalizationPanel.setMinimumSize(new Dimension(140, 70));

    toolbarConstraints.gridx = 2;
    toolbarConstraints.weightx = 0.1;
    toolbarPanel.add(normalizationPanel, toolbarConstraints);
    normalizationComboBox.setEnabled(false);

    // ======== Resolution Panel ========
    hiCPanel = new JPanel();
    hiCPanel.setBackground(Color.white);
    hiCPanel.setLayout(new HiCLayout());
    bigPanel.add(hiCPanel, BorderLayout.CENTER);

    JPanel wrapGapPanel = new JPanel();
    wrapGapPanel.setBackground(Color.white);
    wrapGapPanel.setMaximumSize(new Dimension(5, 5));
    wrapGapPanel.setMinimumSize(new Dimension(5, 5));
    wrapGapPanel.setPreferredSize(new Dimension(5, 5));
    wrapGapPanel.setBorder(LineBorder.createBlackLineBorder());
    bigPanel.add(wrapGapPanel, BorderLayout.EAST);

    // splitPanel.insertPane(hiCPanel, 0);
    // splitPanel.setBackground(Color.white);

    // ---- rulerPanel2 ----
    JPanel topPanel = new JPanel();
    topPanel.setBackground(Color.green);
    topPanel.setLayout(new BorderLayout());
    hiCPanel.add(topPanel, BorderLayout.NORTH);
    trackLabelPanel = new TrackLabelPanel(superAdapter.getHiC());
    trackLabelPanel.setBackground(Color.white);
    hiCPanel.add(trackLabelPanel, HiCLayout.NORTH_WEST);

    trackPanelX = new TrackPanel(superAdapter, superAdapter.getHiC(), TrackPanel.Orientation.X);
    trackPanelX.setMaximumSize(new Dimension(4000, 50));
    trackPanelX.setPreferredSize(new Dimension(1, 50));
    trackPanelX.setMinimumSize(new Dimension(1, 50));
    trackPanelX.setVisible(false);
    topPanel.add(trackPanelX, BorderLayout.NORTH);

    rulerPanelX = new HiCRulerPanel(superAdapter.getHiC());
    rulerPanelX.setMaximumSize(new Dimension(4000, 50));
    rulerPanelX.setMinimumSize(new Dimension(1, 50));
    rulerPanelX.setPreferredSize(new Dimension(1, 50));
    rulerPanelX.setBorder(null);
    topPanel.add(rulerPanelX, BorderLayout.SOUTH);

    // ---- rulerPanel1 ----
    JPanel leftPanel = new JPanel();
    leftPanel.setBackground(Color.white);
    leftPanel.setLayout(new BorderLayout());
    hiCPanel.add(leftPanel, BorderLayout.WEST);

    trackPanelY = new TrackPanel(superAdapter, superAdapter.getHiC(), TrackPanel.Orientation.Y);
    trackPanelY.setMaximumSize(new Dimension(50, 4000));
    trackPanelY.setPreferredSize(new Dimension(50, 1));
    trackPanelY.setMinimumSize(new Dimension(50, 1));
    trackPanelY.setVisible(false);
    leftPanel.add(trackPanelY, BorderLayout.WEST);

    rulerPanelY = new HiCRulerPanel(superAdapter.getHiC());
    rulerPanelY.setMaximumSize(new Dimension(50, 4000));
    rulerPanelY.setPreferredSize(new Dimension(50, 800));
    rulerPanelY.setBorder(null);
    rulerPanelY.setMinimumSize(new Dimension(50, 1));
    leftPanel.add(rulerPanelY, BorderLayout.EAST);

    // ---- heatmapPanel ----
    // Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
    // int panelSize = screenDimension.height - 210;

    int panelWidth = (int) panelDim.getWidth();
    int panelHeight = (int) panelDim.getHeight();
    System.err.println("Window W: " + panelWidth + " H" + panelHeight);

    JPanel wrapHeatmapPanel = new JPanel(new BorderLayout());
    wrapHeatmapPanel.setMaximumSize(new Dimension(panelDim));
    wrapHeatmapPanel.setMinimumSize(new Dimension(panelDim));
    wrapHeatmapPanel.setPreferredSize(new Dimension(panelDim));
    wrapHeatmapPanel.setBackground(Color.BLUE);
    wrapHeatmapPanel.setVisible(true);

    heatmapPanel = new HeatmapPanel(superAdapter);
    heatmapPanel.setMaximumSize(new Dimension(panelWidth - 5, panelHeight - 5));
    heatmapPanel.setMinimumSize(new Dimension(panelWidth - 5, panelHeight - 5));
    heatmapPanel.setPreferredSize(new Dimension(panelWidth - 5, panelHeight - 5));
    heatmapPanel.setBackground(Color.white);

    wrapHeatmapPanel.add(heatmapPanel, BorderLayout.CENTER);

    // hiCPanel.setMaximumSize(new Dimension(panelWidth, panelHeight));
    // hiCPanel.setMinimumSize(new Dimension(panelWidth, panelHeight));
    // hiCPanel.setPreferredSize(new Dimension(panelWidth, panelHeight));

    hiCPanel.add(wrapHeatmapPanel, BorderLayout.CENTER);

    // ======== Resolution Slider Panel ========

    // Resolution  panel
    resolutionSlider = new ResolutionControl(superAdapter);
    resolutionSlider.setPreferredSize(new Dimension(200, 70));
    resolutionSlider.setMinimumSize(new Dimension(150, 70));

    toolbarConstraints.gridx = 3;
    toolbarConstraints.weightx = 0.1;
    toolbarPanel.add(resolutionSlider, toolbarConstraints);

    // ======== Color Range Panel ========
    colorRangePanel = new JColorRangePanel(superAdapter, heatmapPanel, preDefMapColor);

    toolbarConstraints.gridx = 4;
    toolbarConstraints.weightx = 0.5;
    toolbarPanel.add(colorRangePanel, toolbarConstraints);

    goPanel = new GoToPanel(superAdapter);
    toolbarConstraints.gridx = 5;
    toolbarConstraints.weightx = 0.25;
    toolbarPanel.add(goPanel, toolbarConstraints);
    // not sure this is working
    // toolbarPanel.setPreferredSize(new Dimension(panelHeight,100));
    toolbarPanel.setEnabled(false);

    // ======== Right side panel ========

    JPanel rightSidePanel = new JPanel(new BorderLayout()); // (new BorderLayout());
    rightSidePanel.setBackground(Color.white);
    rightSidePanel.setPreferredSize(new Dimension(210, 1000));
    rightSidePanel.setMaximumSize(new Dimension(10000, 10000));

    // ======== Bird's view mini map ========

    JPanel thumbPanel = new JPanel();
    thumbPanel.setLayout(new BorderLayout());

    // ---- thumbnailPanel ----
    thumbnailPanel = new ThumbnailPanel(superAdapter);
    thumbnailPanel.setBackground(Color.white);
    thumbnailPanel.setMaximumSize(new Dimension(210, 210));
    thumbnailPanel.setMinimumSize(new Dimension(210, 210));
    thumbnailPanel.setPreferredSize(new Dimension(210, 210));

    //        JPanel gapPanel = new JPanel();
    //        gapPanel.setMaximumSize(new Dimension(1, 1));
    //        rightSidePanel.add(gapPanel,BorderLayout.WEST);
    thumbPanel.add(thumbnailPanel, BorderLayout.CENTER);
    thumbPanel.setBackground(Color.white);
    rightSidePanel.add(thumbPanel, BorderLayout.NORTH);

    // ========= mouse hover text ======
    JPanel tooltipPanel = new JPanel(new BorderLayout());
    tooltipPanel.setBackground(Color.white);
    tooltipPanel.setPreferredSize(new Dimension(210, 490));
    mouseHoverTextPanel = new JEditorPane();
    mouseHoverTextPanel.setEditable(false);
    mouseHoverTextPanel.setContentType("text/html");
    mouseHoverTextPanel.setFont(new Font("sans-serif", 0, 20));
    mouseHoverTextPanel.setBackground(Color.white);
    mouseHoverTextPanel.setBorder(null);
    int mouseTextY = rightSidePanel.getBounds().y + rightSidePanel.getBounds().height;

    // *Dimension prefSize = new Dimension(210, 490);
    Dimension prefSize = new Dimension(210, 390);
    mouseHoverTextPanel.setPreferredSize(prefSize);

    JScrollPane tooltipScroller = new JScrollPane(mouseHoverTextPanel);
    tooltipScroller.setBackground(Color.white);
    tooltipScroller.setBorder(null);

    tooltipPanel.setPreferredSize(new Dimension(210, 500));
    tooltipPanel.add(tooltipScroller);
    tooltipPanel.setBounds(new Rectangle(new Point(0, mouseTextY), prefSize));
    tooltipPanel.setBackground(Color.white);
    tooltipPanel.setBorder(null);

    rightSidePanel.add(tooltipPanel, BorderLayout.CENTER);

    // compute preferred size
    Dimension preferredSize = new Dimension();
    for (int i = 0; i < rightSidePanel.getComponentCount(); i++) {
      Rectangle bounds = rightSidePanel.getComponent(i).getBounds();
      preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
      preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
    }
    Insets insets = rightSidePanel.getInsets();
    preferredSize.width += insets.right + 20;
    preferredSize.height += insets.bottom;
    rightSidePanel.setMinimumSize(preferredSize);
    rightSidePanel.setPreferredSize(preferredSize);
    mainPanel.add(bigPanel, BorderLayout.CENTER);
    mainPanel.add(rightSidePanel, BorderLayout.EAST);
  }