List of usage examples for javax.swing JPanel setVisible
@BeanProperty(hidden = true, visualUpdate = true) public void setVisible(boolean aFlag)
From source file:org.ut.biolab.medsavant.client.query.QueryViewController.java
private List<JComponent> getComponentsFromQueryModel(SearchConditionGroupItem g, int depth) { List<JComponent> components = new ArrayList<JComponent>(); int w = 0;/* w w w . ja va 2s . c o m*/ for (final SearchConditionItem item : g.getItems()) { if (item instanceof SearchConditionGroupItem) { String addition = ""; if (item.getParent() != null) { addition = item.getRelation() + ""; } final JPanel p = ViewUtil.getClearPanel(); MigLayout ml = new MigLayout("wrap 1, hidemode 1, insets 2"); p.setLayout(ml); Border border = ViewUtil.getThickLeftLineBorder(); p.setBorder(border); final PillView pv = new PillView(true); pv.indent(depth); pv.setActivated(true); final ActionListener toggleGroupExpand = new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { expandedItemsMap.put((SearchConditionGroupItem) item, !p.isVisible()); p.setVisible(!p.isVisible()); pv.setText(getGroupTitle((SearchConditionGroupItem) item)); } }; pv.setExpandListener(toggleGroupExpand); pv.setPopupGenerator(new ConditionPopupGenerator() { @Override public JPopupMenu generatePopup() { final SearchConditionGroupItem groupItem = (SearchConditionGroupItem) item; final JPopupMenu m = new JPopupMenu(); if (!item.getParent().isFirstItem(item)) { if (item.getRelation() == QueryRelation.AND) { JMenuItem b = new JMenuItem("Change to \"or\""); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { item.setRelation(QueryRelation.OR); pv.setText(getGroupTitle(groupItem)); } }); m.add(b); } else { JMenuItem b = new JMenuItem("Change to \"and\""); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { item.setRelation(QueryRelation.AND); pv.setText(getGroupTitle(groupItem)); } }); m.add(b); } } JMenuItem delgroup = new JMenuItem("Delete"); delgroup.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { groupItem.getParent().removeItem(groupItem); refreshView(); expandedItemsMap.remove((SearchConditionGroupItem) item); } }); m.add(delgroup); return m; } }); SearchConditionGroupItem g2 = (SearchConditionGroupItem) item; pv.setText(getGroupTitle(g2)); Boolean exp = expandedItemsMap.get((SearchConditionGroupItem) item); if (exp == null) { p.setVisible(false); pv.collapse(); } else { p.setVisible(true); pv.expand(); } components.add(pv); for (JComponent c : getComponentsFromQueryModel((SearchConditionGroupItem) item, depth + 1)) { p.add(c, "left"); } components.add(p); w = pv.getMaximumSize().width; } else { SearchConditionItemView sciv = itemToViewMap.get(item); ((PillView) sciv).indent(depth); w = sciv.getMaximumSize().width; sciv.refresh(); components.add(sciv); } } if (w == 0) { w = BOTTOM_SEARCH_TEXTFIELD_WIDTH; } JComponent c = getInputFieldForGroup(g, w); components.add(c); return components; }
From source file:org.ut.biolab.medsavant.client.view.component.KeyValuePairPanel.java
public void addKey(final String key, boolean showExpand) { Color rowColor = Color.WHITE; if (keyKeyComponentMap.size() % 2 == 0) { rowColor = ViewUtil.getAlternateRowColor(); }/*from www. j a v a 2s. co m*/ if (newRowsGoIntoMoreSection) { keysInMoreSection.add(key); } rowColor = Color.white; String layoutConstraints = "insets 3 3 3 3, filly"; JPanel valuePanel = ViewUtil.getClearPanel(); valuePanel.setLayout(new MigLayout(layoutConstraints)); valuePanel.setBackground(rowColor); int i = 0; JPanel keyPanel = ViewUtil.getClearPanel(); keyPanel.setLayout(new MigLayout(layoutConstraints + ", alignx right, hmin 30")); keyPanel.setBackground(rowColor); final JLabel keyLabel = getKeyLabel(key); //keyLabel.setBorder(ViewUtil.getMediumBorder()); keyKeyComponentMap.put(key, keyLabel); if (showExpand) { keyLabel.setText("? " + key.toUpperCase()); keyLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); keyLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { toggleMoreVisibility(); if (keyLabel.getText().startsWith("?")) { keyLabel.setText("? " + key.toUpperCase()); } else { keyLabel.setText("? " + key.toUpperCase()); } } }); } keyPanel.add(keyLabel); keyLabel.setVisible(keysVisible); kvpPanel.add(keyPanel, incrementConstraintRow(i++)); kvpPanel.add(valuePanel, incrementConstraintRow(i++)); JPanel[] extraComponents = new JPanel[additionalColumns]; for (int j = 0; j < additionalColumns; j++) { JPanel panel = ViewUtil.getClearPanel(); panel.setBackground(rowColor); ViewUtil.applyHorizontalBoxLayout(panel); //panel.setBorder(border); //panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); extraComponents[j] = panel;//ViewUtil.getClearPanel(); kvpPanel.add(extraComponents[j], incrementConstraintRow(i++)); } // add hidden panel keyDetailConstraints.gridy++; keyDetailConstraints.gridy++; JPanel detailPanel = ViewUtil.getClearPanel(); detailPanel.setBackground(rowColor); //detailPanel.setBorder(ViewUtil.getTinyLineBorder()); detailPanel.setVisible(false); keyDetailComponentMap.put(key, detailPanel); kvpPanel.add(detailPanel, keyDetailConstraints); // update all constraints to skip a line for (int k = 0; k < 2 + additionalColumns; k++) { incrementConstraintRow(k); } keyValueComponentMap.put(key, valuePanel); keyExtraComponentsMap.put(key, extraComponents); setMoreVisibility(showingMore); }
From source file:org.ut.biolab.medsavant.client.view.component.KeyValuePairPanel.java
public void toggleDetailVisibility(String key, boolean visible) { JPanel p = keyDetailComponentMap.get(key); p.setVisible(visible); }
From source file:org.ut.biolab.medsavant.client.view.Menu.java
public void addSection(SectionView section) { final JPanel sectionPanel = ViewUtil.getClearPanel(); sectionPanel.setLayout(new BoxLayout(sectionPanel, BoxLayout.Y_AXIS)); sectionPanel.setVisible(false); //HoverButton sectionButton = new SectionButton(section, sectionPanel); //sectionButton.setSelectedColor(ViewUtil.getSecondaryMenuColor()); final JToggleButton sectionButton = ViewUtil.getTogglableIconButton(section.getIcon()); sectionButton.setName(section.getName()); sectionButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); sectionButton.addActionListener(new ActionListener() { @Override//from w w w. ja v a 2 s.c o m public void actionPerformed(ActionEvent ae) { primaryMenuButtons.setSelected(sectionButton.getModel(), true); if (previousSectionPanel != null) { previousSectionPanel.setVisible(false); } // Act as if we clicked the first sub-section button. ((SubSectionButton) sectionPanel.getComponent(0)).subSectionClicked(); sectionPanel.setVisible(true); previousSectionPanel = sectionPanel; primaryMenu.invalidate(); } }); ButtonGroup subSectionsGroup = new ButtonGroup(); for (SubSectionView v : section.getSubSections()) { subSectionViews.add(v); SubSectionButton subSectionButton = new SubSectionButton(v, subSectionsGroup); sectionPanel.add(subSectionButton); subSectionsGroup.add(subSectionButton); map.put(v, subSectionButton); } primaryMenuButtons.add(sectionButton); sectionPanel.add(Box.createVerticalStrut(50)); secondaryMenu.add(sectionPanel); primaryMenuSectionButtonContainer.add(ViewUtil.subTextComponent(sectionButton, section.getName())); primaryMenuSectionButtonContainer.add(ViewUtil.getLargeSeparator()); }
From source file:org.ut.biolab.medsavant.client.view.variants.BrowserPage.java
private void setupToolbarButtons(Savant savantInstance) { // Removed temporarily 06-08-2013, in preparation for 1.1 release. /*/*from www . j a v a 2 s . com*/ JButton button = new JButton(IconFactory.getInstance().getIcon(StandardIcon.FILTER)); button.setToolTipText("Restrict DNA IDs"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { gsc.setLocationRelativeTo(view); gsc.setVisible(true); } }); */ JPanel pluginToolbar = savantInstance.getPluginToolbar(); // Removed temporarily 06-08-2013, in preparation for 1.1 release. // pluginToolbar.add(button); try { String buttonStyle = "segmentedCapsule"; JButton dnaButton = new JButton(IconFactory.getInstance().getIcon(StandardIcon.BAMFILE)); dnaButton.setToolTipText("Open BAM File(s)"); dnaButton.putClientProperty("JButton.buttonType", buttonStyle); dnaButton.putClientProperty("JButton.segmentPosition", "only"); dnaButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (isDoneMappingIdsToBAMURLs) { GenericStringChooser bamFileChooser = new GenericStringChooser(sampleIdsHavingBams, "Open BAM File(s)"); bamFileChooser.setLocationRelativeTo(view); bamFileChooser.addListener(new Listener<SelectableListView.SelectionEvent>() { @Override public void handleEvent(SelectableListView.SelectionEvent event) { List selections = event.getSelections(); for (Object o : selections) { String url = dnaIDToURLMap.get(o.toString()); addTrackFromURLString(url, DataFormat.ALIGNMENT); } } }); bamFileChooser.setVisible(true); } else { DialogUtils.displayMessage("Still collecting alignment file URLs, try again soon."); } } }); pluginToolbar.add(dnaButton); pluginToolbar.setVisible(true); } catch (Exception e) { LOG.error("ERROR ", e); } }
From source file:savant.view.swing.Frame.java
/** * Get a panel for a plugin to draw on. If necessary, a new one will be * created.// w ww . j a va 2s .c o m */ @Override public JPanel getLayerCanvas(SavantPanelPlugin plugin, boolean mayCreate) { JPanel p = pluginLayers.get(plugin); if (p == null && mayCreate) { p = new JPanel(); p.setOpaque(false); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; c.weighty = 1.0; c.gridx = 0; c.gridy = 0; c.gridwidth = 3; c.gridheight = 2; jlp.add(p, c, 2); jlp.setLayer(p, 50); pluginLayers.put(plugin, p); if (plugin != null) { p.setVisible(plugin.isVisible()); } } return p; }
From source file:uiuc.dm.miningTools.ui.ParametersSelectionFrame.java
private void showPanel(JPanel panel) { if (panel != null) { panel.setVisible(true); } }
From source file:uiuc.dm.miningTools.ui.ParametersSelectionFrame.java
private void showPanel(JPanel panel, String title) { if (panel != null) { panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(title), BorderFactory.createEmptyBorder(5, 5, 5, 5))); panel.setVisible(true); }/*from ww w. j a v a 2 s. co m*/ }
From source file:uiuc.dm.miningTools.ui.ParametersSelectionFrame.java
private void hidePanel(JPanel panel) { if (panel != null) { panel.setBorder(null);// w w w . java 2s . co m panel.setVisible(false); if (miningFunctionSelectionPanel != null && panel == miningFunctionSelectionPanel) { if (functionCombo != null) { functionCombo.setSelectedIndex(0); } } } }
From source file:view.ImagePanel.java
public void refreshSignatureValidationListPanels() { for (JPanel jp : panelList) { remove(jp);//from ww w. j a v a 2s . co m } if (buf == null) { return; } if (pdfDocument != null) { if (svList != null) { Point p = getImageLocation(); for (final SignatureValidation sv : svList) { try { int pgNumber = sv.getPosList().get(0).page - 1; if (this.pageNumber == pgNumber) { for (AcroFields.FieldPosition pos : sv.getPosList()) { int p1 = (int) (p.x + (pos.position.getLeft() * scale)); int p2 = (int) (p.y + Math.floor((pdfDocument.getPage(pageNumber).getCropBox().getHeight() - pos.position.getTop()) * scale)); int p3 = (int) (pos.position.getWidth() * scale); int p4 = (int) (pos.position.getHeight() * scale); final JPanel jp1 = sv.getPanel(); jp1.setLocation(p1, p2); jp1.setSize(p3, p4); if (sv.equals(selectedSignature)) { jp1.setBackground(new Color(0, 0, 0, 45)); jp1.setBorder(new LineBorder(Color.BLACK, 1)); } else { jp1.setBackground(new Color(0, 0, 0, 0)); jp1.setBorder(null); } jp1.setVisible(true); jp1.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(java.awt.event.MouseEvent evt) { if (mainWindow.getWorkspacePanel() .getStatus() != WorkspacePanel.Status.SIGNING) { jp1.setCursor(new Cursor(Cursor.HAND_CURSOR)); jp1.setBackground(new Color(0, 0, 0, 45)); jp1.setBorder(new LineBorder(Color.BLACK, 1)); repaint(); } else { jp1.setCursor(null); } } @Override public void mouseExited(java.awt.event.MouseEvent evt) { if (mainWindow.getWorkspacePanel() .getStatus() != WorkspacePanel.Status.SIGNING) { if (selectedSignature == null) { jp1.setBackground(new Color(0, 0, 0, 0)); jp1.setBorder(null); repaint(); } else if (!selectedSignature.equals(sv)) { jp1.setBackground(new Color(0, 0, 0, 0)); jp1.setBorder(null); repaint(); } } } }); panelList.add(jp1); add(jp1); repaint(); } } } catch (Exception e) { } } } } }