private void processEnabled() { if (myIsEnabled.asBoolean()) { ToolTipManager.sharedInstance().setEnabled(false); } else { ToolTipManager.sharedInstance().setEnabled(true); } }
private static JTree createTree() { JTree resultsTree = new JTree(); resultsTree.setName("TREEVIEW"); resultsTree.setRootVisible(false); resultsTree.setEditable(false); resultsTree.setShowsRootHandles(true); resultsTree.setCellRenderer(new FailureCellRenderer()); ToolTipManager tipManager = ToolTipManager.sharedInstance(); tipManager.registerComponent(resultsTree); resultsTree.addKeyListener(new EnterPressListener()); return resultsTree; }
public FriendTree(LeftSidebar sb, RobonoboFrame frame) { super(new FriendTreeModel(frame), frame); this.sideBar = sb; getModel().setTree(this); normalFont = RoboFont.getFont(12, false); boldFont = RoboFont.getFont(12, true); setName("robonobo.playlist.tree"); setAlignmentX(0.0f); setRootVisible(true); collapseRow(0); rootIcon = createImageIcon("/icon/friends.png"); addFriendsIcon = createImageIcon("/icon/add_friends.png"); friendIcon = createImageIcon("/icon/friend.png"); playlistIcon = createImageIcon("/icon/playlist.png"); libraryIcon = createImageIcon("/icon/home.png"); // Special playlist icons specIcons.put("loves", createImageIcon("/icon/heart-small.png")); specIcons.put("radio", createImageIcon("/icon/radio-small.png")); setCellRenderer(new CellRenderer()); setSelectionModel(new SelectionModel()); getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); addTreeSelectionListener(new SelectionListener()); // This is required for tooltips to work ToolTipManager.sharedInstance().registerComponent(this); }
public BulkDownloadPanel(WorldWindow wwd) { this.wwd = wwd; // Init retievable list this.retrievables = new ArrayList<BulkRetrievablePanel>(); // Layers for (Layer layer : this.wwd.getModel().getLayers()) { if (layer instanceof BulkRetrievable) this.retrievables.add(new BulkRetrievablePanel((BulkRetrievable) layer)); } // Elevation models CompoundElevationModel cem = (CompoundElevationModel) wwd.getModel().getGlobe().getElevationModel(); for (ElevationModel elevationModel : cem.getElevationModels()) { if (elevationModel instanceof BulkRetrievable) this.retrievables.add(new BulkRetrievablePanel((BulkRetrievable) elevationModel)); } // Init sector selector this.selector = new SectorSelector(wwd); this.selector.setInteriorColor(new Color(1f, 1f, 1f, 0.1f)); this.selector.setBorderColor(new Color(1f, 0f, 0f, 0.5f)); this.selector.setBorderWidth(3); this.selector.addPropertyChangeListener( SectorSelector.SECTOR_PROPERTY, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { updateSector(); } }); JPopupMenu.setDefaultLightWeightPopupEnabled(false); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); this.initComponents(); }
/** * Initializes custom contact action buttons. * * @param contactActionButtons the list of buttons to initialize * @param gridX the X grid of the first button * @param xBounds the x bounds of the first button * @return the new grid X coordinate after adding all the buttons */ private int initGroupActionButtons( Collection<SIPCommButton> contactActionButtons, int gridX, int xBounds) { // Reinit the labels to take the whole horizontal space. addLabels(gridX + contactActionButtons.size()); Iterator<SIPCommButton> actionsIter = contactActionButtons.iterator(); while (actionsIter.hasNext()) { final SIPCommButton actionButton = actionsIter.next(); // We need to explicitly remove the buttons from the tooltip manager, // because we're going to manager the tooltip ourselves in the // DefaultTreeContactList class. We need to do this in order to have // a different tooltip for every button and for non button area. ToolTipManager.sharedInstance().unregisterComponent(actionButton); if (customActionButtonsUIGroup == null) customActionButtonsUIGroup = new LinkedList<JButton>(); customActionButtonsUIGroup.add(actionButton); xBounds += addButton(actionButton, ++gridX, xBounds, false); } return gridX; }
public MagicGlassPane() { super(null); setOpaque(false); enableEvents(AWTEvent.MOUSE_EVENT_MASK); enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK); enableEvents(AWTEvent.MOUSE_WHEEL_EVENT_MASK); ToolTipManager.sharedInstance().registerComponent(this); }
static { // Put JOGL version information into system properties to // assist in debugging. Package joglPackage = Package.getPackage("javax.media.opengl"); System.setProperty("jogl.specification.version", joglPackage.getSpecificationVersion()); System.setProperty("jogl.implementation.version", joglPackage.getImplementationVersion()); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); }
@Override public void dispose() { if (myUsagePreviewPanel != null) { UsageViewSettings.getInstance().PREVIEW_USAGES_SPLITTER_PROPORTIONS = ((Splitter) myUsagePreviewPanel.getParent()).getProportion(); myUsagePreviewPanel = null; } isDisposed = true; ToolTipManager.sharedInstance().unregisterComponent(myTree); }
public IvusFrame(World world) { OrbitView view = (world != null) ? new OrbitView(world) : new OrbitView(); view.setAxesOrientation(AxesOrientation.XRIGHT_YOUT_ZDOWN); ViewCanvas canvas = new ViewCanvas(view); canvas.setView(view); ModeManager mm = new ModeManager(); mm.add(canvas); OrbitViewMode ovm = new OrbitViewMode(mm); SelectDragMode sdm = new SelectDragMode(mm); JPopupMenu.setDefaultLightWeightPopupEnabled(false); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('F'); Action exitAction = new AbstractAction("Exit") { private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent event) { System.exit(0); } }; JMenuItem exitItem = fileMenu.add(exitAction); exitItem.setMnemonic('x'); JMenu modeMenu = new JMenu("Mode"); modeMenu.setMnemonic('M'); JMenuItem ovmItem = new ModeMenuItem(ovm); modeMenu.add(ovmItem); JMenuItem sdmItem = new ModeMenuItem(sdm); modeMenu.add(sdmItem); JMenuBar menuBar = new JMenuBar(); menuBar.add(fileMenu); menuBar.add(modeMenu); JToolBar toolBar = new JToolBar(SwingConstants.VERTICAL); toolBar.setRollover(true); JToggleButton ovmButton = new ModeToggleButton(ovm); toolBar.add(ovmButton); JToggleButton sdmButton = new ModeToggleButton(sdm); toolBar.add(sdmButton); ovm.setActive(true); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setSize(new Dimension(SIZE, SIZE)); this.add(canvas, BorderLayout.CENTER); this.add(toolBar, BorderLayout.WEST); this.setJMenuBar(menuBar); }
public ReferencePropertyWidget(boolean containedByListReferenceGUI) { this.containedByListReferenceGUI = containedByListReferenceGUI; // get Options m_comboBox = new JComboBox(); m_comboBox.setEditable(false); m_comboBox.setPreferredSize(new Dimension(300, 20)); // m_comboBox.setMinimumSize(new Dimension(260, 20)); m_comboBox.setMaximumSize(new Dimension(Short.MAX_VALUE, 20)); KeyStroke controlT = KeyStroke.getKeyStroke("control SPACE"); getTextField().getInputMap().put(controlT, controlT); getTextField().getActionMap().put(controlT, new CodeCompleteAction()); ToolTipManager.sharedInstance().registerComponent(m_comboBox); }
@Override public void dispose() { synchronized (lock) { isDisposed = true; ToolTipManager.sharedInstance().unregisterComponent(myTree); myModelTracker.removeListener(this); myUpdateAlarm.cancelAllRequests(); if (myUsagePreviewPanel != null) { UsageViewSettings.getInstance().PREVIEW_USAGES_SPLITTER_PROPORTIONS = ((Splitter) myUsagePreviewPanel.getParent()).getProportion(); myUsagePreviewPanel = null; } } }
public UpdateAssetGUI() { try { PluginMgrClient.init(); mclient = new MasterMgrClient(); queue = new QueueMgrClient(); plug = PluginMgrClient.getInstance(); log = LogMgr.getInstance(); pAssetManager = new TreeMap<String, AssetInfo>(); project = "lr"; charList = new TreeMap<String, String>(); setsList = new TreeMap<String, String>(); propsList = new TreeMap<String, String>(); potentialUpdates = new TreeSet<String>(); pSubstituteFields = new TreeMap<String, LinkedList<JBooleanField>>(); /* load the look-and-feel */ { try { SynthLookAndFeel synth = new SynthLookAndFeel(); synth.load( LookAndFeelLoader.class.getResourceAsStream("synth.xml"), LookAndFeelLoader.class); UIManager.setLookAndFeel(synth); } catch (java.text.ParseException ex) { log.log( LogMgr.Kind.Ops, LogMgr.Level.Severe, "Unable to parse the look-and-feel XML file (synth.xml):\n" + " " + ex.getMessage()); System.exit(1); } catch (UnsupportedLookAndFeelException ex) { log.log( LogMgr.Kind.Ops, LogMgr.Level.Severe, "Unable to load the Pipeline look-and-feel:\n" + " " + ex.getMessage()); System.exit(1); } } /* application wide UI settings */ { JPopupMenu.setDefaultLightWeightPopupEnabled(false); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); } } catch (PipelineException ex) { ex.printStackTrace(); } // end try/catch } // end constructor
public TunePanel() { setOpaque(true); ToolTipManager.sharedInstance().setInitialDelay(1000); addMouseMotionListener( new MouseMotionListener() { public void mouseMoved(MouseEvent e) { renderer.updateHighlight(e.getX(), e.getY()); setToolTipText(renderer.getToolTipText(e.getX(), e.getY())); repaint(); } public void mouseDragged(MouseEvent e) {} }); }
synchronized void popup(int x, int y, Component component, String text) { invalidate(); textLabel.setText(text); textLabel.setForeground(ToolTipManager.getInstance().foreground); textLabel.setBackground(ToolTipManager.getInstance().background); validate(); pack(); try { if (x != -1 && y != -1) { setLocation(x + 8, y + 8); } else { Point p = component.getLocationOnScreen(); Dimension s = component.getSize(); setLocation(p.x + 8, p.y + s.height + 8); } setVisible(true); toFront(); lastShow = System.currentTimeMillis(); dismissed = false; } catch (IllegalComponentStateException icse) { } }
protected void initTree() { if (myWasTreeInitialized) return; myWasTreeInitialized = true; super.initTree(); new TreeSpeedSearch( myTree, new Convertor<TreePath, String>() { public String convert(final TreePath treePath) { return ((MyNode) treePath.getLastPathComponent()).getDisplayName(); } }, true); ToolTipManager.sharedInstance().registerComponent(myTree); myTree.setCellRenderer(new ProjectStructureElementRenderer(myContext)); }
private JPanel createToolPanel() { configurationOverrideCombo.setModel(configurationOverrideModel); final int preferredHeight = configurationOverrideCombo.getPreferredSize().height; configurationOverrideCombo.setPreferredSize(new Dimension(250, preferredHeight)); configurationOverrideCombo.setMaximumSize(new Dimension(350, preferredHeight)); treeModel = new ResultTreeModel(); resultsTree = new Tree(treeModel); resultsTree.setRootVisible(false); final TreeSelectionListener treeSelectionListener = new ToolWindowSelectionListener(); resultsTree.addTreeSelectionListener(treeSelectionListener); final MouseListener treeMouseListener = new ToolWindowMouseListener(); resultsTree.addMouseListener(treeMouseListener); resultsTree.setCellRenderer(new ResultTreeRenderer()); progressLabel = new JLabel(" "); progressBar = new JProgressBar(JProgressBar.HORIZONTAL); progressBar.setMinimum(0); final Dimension progressBarSize = new Dimension(100, progressBar.getPreferredSize().height); progressBar.setMinimumSize(progressBarSize); progressBar.setPreferredSize(progressBarSize); progressBar.setMaximumSize(progressBarSize); progressPanel = new JToolBar(JToolBar.HORIZONTAL); progressPanel.add(Box.createHorizontalStrut(4)); progressPanel.add(new JLabel(CheckStyleBundle.message("plugin.toolwindow.override"))); progressPanel.add(Box.createHorizontalStrut(4)); progressPanel.add(configurationOverrideCombo); progressPanel.add(Box.createHorizontalStrut(4)); progressPanel.addSeparator(); progressPanel.add(Box.createHorizontalStrut(4)); progressPanel.add(progressLabel); progressPanel.add(Box.createHorizontalGlue()); progressPanel.setFloatable(false); progressPanel.setBackground(UIManager.getColor("Panel.background")); progressPanel.setBorder(null); final JPanel toolPanel = new JPanel(new BorderLayout()); toolPanel.add(new JBScrollPane(resultsTree), BorderLayout.CENTER); toolPanel.add(progressPanel, BorderLayout.NORTH); ToolTipManager.sharedInstance().registerComponent(resultsTree); return toolPanel; }
// =============================================================== // =============================================================== private void buildTree() { // Create the nodes. root = new DefaultMutableTreeNode(server); createThreadsNodes(); // Create the tree that allows one selection at a time. getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); // Create Tree and Tree model treeModel = new DefaultTreeModel(root); setModel(treeModel); // Enable tool tips. ToolTipManager.sharedInstance().registerComponent(this); // Set the icon for leaf nodes. renderer = new TangoRenderer(); setCellRenderer(renderer); // Listen for collapse tree addTreeExpansionListener( new TreeExpansionListener() { public void treeCollapsed(TreeExpansionEvent e) { // collapsedPerformed(e); } public void treeExpanded(TreeExpansionEvent e) { // expandedPerformed(e); } }); // Add Action listener addMouseListener( new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { treeMousePressed(evt); } public void mouseReleased(java.awt.event.MouseEvent evt) { treeMouseReleased(evt); } public void mouseClicked(java.awt.event.MouseEvent evt) { treeMouseClicked(evt); } }); }
private static Component getTipWindow() { try { Field tipWindowField = ToolTipManager.class.getDeclaredField("tipWindow"); tipWindowField.setAccessible(true); Popup value = (Popup) tipWindowField.get(ToolTipManager.sharedInstance()); Field componentField = Popup.class.getDeclaredField("component"); componentField.setAccessible(true); return (Component) componentField.get(value); } catch (Exception e) { throw new RuntimeException("getToolTipComponent failed", e); } }
/** Constructor. */ public DatasetTreeView() { // the catalog tree tree = new JTree() { public JToolTip createToolTip() { return new MultilineTooltip(); } }; tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode(null, false))); tree.setCellRenderer(new MyTreeCellRenderer()); tree.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent e) { int selRow = tree.getRowForLocation(e.getX(), e.getY()); if (selRow != -1) { TreeNode node = (TreeNode) tree.getLastSelectedPathComponent(); if (node instanceof VariableNode) { VariableIF v = ((VariableNode) node).var; firePropertyChangeEvent(new PropertyChangeEvent(this, "Selection", null, v)); } } if ((selRow != -1) && (e.getClickCount() == 2)) { // acceptSelected(); } } }); tree.putClientProperty("JTree.lineStyle", "Angled"); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setToggleClickCount(1); ToolTipManager.sharedInstance().registerComponent(tree); // layout setLayout(new BorderLayout()); add(new JScrollPane(tree), BorderLayout.CENTER); }
/** Inializes button tool tips. */ private void initButtonToolTips() { callButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.CALL_CONTACT")); callVideoButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.VIDEO_CALL")); desktopSharingButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.SHARE_DESKTOP")); chatButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.SEND_MESSAGE")); addContactButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.ADD_CONTACT")); // We need to explicitly remove the buttons from the tooltip manager, // because we're going to manager the tooltip ourselves in the // DefaultTreeContactList class. We need to do this in order to have // a different tooltip for every button and for non button area. ToolTipManager ttManager = ToolTipManager.sharedInstance(); ttManager.unregisterComponent(callButton); ttManager.unregisterComponent(callVideoButton); ttManager.unregisterComponent(desktopSharingButton); ttManager.unregisterComponent(chatButton); ttManager.unregisterComponent(addContactButton); }
static { // The following is required to use Swing menus with the heavyweight canvas used by World Wind. ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); JPopupMenu.setDefaultLightWeightPopupEnabled(false); }
private void makeResponsive(ToolTipManager toolTipManager) { toolTipManager.setInitialDelay(20); toolTipManager.setReshowDelay(10); toolTipManager.setDismissDelay(10000); }
/** @param type True for an online tree */ public RosterTree(Backend backend, Jeti main, boolean onlineTree, TreeModel model) { super(model); this.onlineTree = onlineTree; this.backend = backend; this.main = main; ToolTipManager.sharedInstance().registerComponent(this); setRootVisible(false); setToggleClickCount(0); // set expanding on mouseclicks of because // detection needed for single or double click javax.swing.plaf.basic.BasicTreeUI basicTreeUI = (javax.swing.plaf.basic.BasicTreeUI) getUI(); basicTreeUI.setRightChildIndent(1); basicTreeUI.setLeftChildIndent(1); basicTreeUI.setExpandedIcon(null); basicTreeUI.setCollapsedIcon(null); putClientProperty("JTree.lineStyle", "None"); createPopupMenu(); createGroupPopupMenu(); if (System.getProperty("os.name").startsWith("Mac")) { setCellRenderer(new MacRenderer()); if (onlineTree) { treeExpander = new TreeExpander(this, model); } } else setCellRenderer(new MyRenderer()); addMouseListener( new MouseAdapter() { TreePath lastTreePath; // save tree path for single click event // timer needed to check if double or single mouseclick Timer timer = new Timer( 300, new ActionListener() { public void actionPerformed(ActionEvent e) { if (isExpanded(lastTreePath)) collapsePath(lastTreePath); else expandPath(lastTreePath); timer.stop(); } }); public void mousePressed(MouseEvent e) { TreePath selPath = getPathForLocation(e.getX(), e.getY()); if (selPath != null) { setSelectionPath(selPath); Object o = selPath.getLastPathComponent(); if (o instanceof JIDStatusGroup) { // group maybeShowGroupPopup(e, (JIDStatusGroup) o); if (SwingUtilities.isLeftMouseButton(e)) { if (isExpanded(selPath)) collapsePath(selPath); else expandPath(selPath); } } else { JIDStatusGroup group = null; if (o instanceof PrimaryJIDStatus) group = ((JIDStatusGroup) selPath.getPathComponent(selPath.getPathCount() - 2)); else if (o instanceof JIDStatus) group = ((JIDStatusGroup) selPath.getPathComponent(selPath.getPathCount() - 3)); else return; maybeShowPopup(e, (JIDStatus) o, group); // cde if (SwingUtilities.isLeftMouseButton(e)) { lastTreePath = selPath; // check if double or single mouseclick, needed // because double click= 2 single clicks if (timer.isRunning()) { timer.stop(); sendChat((JIDStatus) o); } else { timer.restart(); } } } } } public void mouseReleased(MouseEvent e) { TreePath selPath = getPathForLocation(e.getX(), e.getY()); if (selPath != null) { Object o = selPath.getLastPathComponent(); if (o instanceof JIDStatusGroup) { // group maybeShowGroupPopup(e, (JIDStatusGroup) o); } if (o instanceof PrimaryJIDStatus) { JIDStatusGroup group = ((JIDStatusGroup) selPath.getPathComponent(selPath.getPathCount() - 2)); maybeShowPopup(e, (PrimaryJIDStatus) o, group); } else if (o instanceof JIDStatus) { JIDStatusGroup group = ((JIDStatusGroup) selPath.getPathComponent(selPath.getPathCount() - 3)); maybeShowPopup(e, (JIDStatus) o, group); } } } public void mouseExited(MouseEvent e) { // if (popupPanel !=null) popupPanel.dispose(); // timer.stop(); clearSelection(); // weg als multi select? } }); addMouseMotionListener( new MouseMotionAdapter() { public void mouseMoved(MouseEvent e) { // if (popupPanel !=null) popupPanel.dispose(); // timer.stop(); TreePath selPath = getPathForLocation(e.getX(), e.getY()); if (selPath != null) { Object o = selPath.getLastPathComponent(); if (o instanceof PrimaryJIDStatus || o instanceof JIDStatus) setSelectionPath(selPath); /* * if(o instanceof JIDStatus2) { // * timer.init(e.getPoint(),(JIDStatus)o); * setSelectionPath(selPath); } */ } } }); // setOpaque(false); }
protected DomModelTreeView( DomElement rootElement, DomManager manager, SimpleTreeStructure treeStructure) { myDomManager = manager; myRootElement = rootElement; myTree = new SimpleTree(new DefaultTreeModel(new DefaultMutableTreeNode())); myTree.setRootVisible(isRootVisible()); myTree.setShowsRootHandles(true); myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); ToolTipManager.sharedInstance().registerComponent(myTree); TreeUtil.installActions(myTree); myBuilder = new AbstractTreeBuilder( myTree, (DefaultTreeModel) myTree.getModel(), treeStructure, WeightBasedComparator.INSTANCE, false); Disposer.register(this, myBuilder); myBuilder.setNodeDescriptorComparator(null); myBuilder.initRootNode(); add(myTree, BorderLayout.CENTER); myTree.addTreeExpansionListener( new TreeExpansionListener() { @Override public void treeExpanded(TreeExpansionEvent event) { final SimpleNode simpleNode = myTree.getNodeFor(event.getPath()); if (simpleNode instanceof AbstractDomElementNode) { ((AbstractDomElementNode) simpleNode).setExpanded(true); } } @Override public void treeCollapsed(TreeExpansionEvent event) { final SimpleNode simpleNode = myTree.getNodeFor(event.getPath()); if (simpleNode instanceof AbstractDomElementNode) { ((AbstractDomElementNode) simpleNode).setExpanded(false); simpleNode.update(); } } }); myDomManager.addDomEventListener( new DomChangeAdapter() { @Override protected void elementChanged(DomElement element) { if (element.isValid()) { queueUpdate(DomUtil.getFile(element).getVirtualFile()); } else if (element instanceof DomFileElement) { final XmlFile xmlFile = ((DomFileElement) element).getFile(); queueUpdate(xmlFile.getVirtualFile()); } } }, this); final Project project = myDomManager.getProject(); DomElementAnnotationsManager.getInstance(project) .addHighlightingListener( new DomElementAnnotationsManager.DomHighlightingListener() { @Override public void highlightingFinished(@NotNull DomFileElement element) { if (element.isValid()) { queueUpdate(DomUtil.getFile(element).getVirtualFile()); } } }, this); myTree.setPopupGroup(getPopupActions(), DOM_MODEL_TREE_VIEW_POPUP); }
private void turnOnToolTips() { ToolTipManager toolTipManager = ToolTipManager.sharedInstance(); makeResponsive(toolTipManager); toolTipManager.registerComponent(this); }
/** * Constructs a simple frame with the specified world and orientation. * * @param world the world view. * @param ao the axes orientation. */ public RSFFrame(World world, AxesOrientation ao) { super(new PlotPanel()); if (world == null) world = new World(); if (ao == null) ao = AxesOrientation.XRIGHT_YOUT_ZDOWN; _world = world; _view = new OrbitView(_world); _view.setAxesOrientation(ao); _canvas = new ViewCanvas(); _canvas.setView(_view); _canvas.setBackground(Color.WHITE); _points = new ArrayList<PointGroup>(); _lines = new ArrayList<LineGroup>(); _d = null; _tpx = null; _tpy = null; _ipg = null; _etc = null; _coord = null; ModeManager mm = new ModeManager(); mm.add(_canvas); OrbitViewMode ovm = new OrbitViewMode(mm); SelectDragMode sdm = new SelectDragMode(mm); JPopupMenu.setDefaultLightWeightPopupEnabled(false); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('F'); Action exitAction = new AbstractAction("Exit") { public void actionPerformed(ActionEvent event) { System.exit(0); } }; Action cubeAction = new AbstractAction("Add Cube") { public void actionPerformed(ActionEvent event) { String filename = chooseFile("."); if (filename != null) addRSFCube(filename); } }; Action lineAction = new AbstractAction("Add Line") { public void actionPerformed(ActionEvent event) { String filename = chooseFile("."); if (filename != null) addRSFLine(filename); } }; Action pointAction = new AbstractAction("Add Points") { public void actionPerformed(ActionEvent event) { String filename = chooseFile("."); if (filename != null) addRSFPoint(filename); } }; Action loadViewAction = new AbstractAction("Load Viewpoint") { public void actionPerformed(ActionEvent event) { String filename = chooseFile("."); if (filename != null) loadView(filename); } }; Action saveViewAction = new AbstractAction("Save Viewpoint") { public void actionPerformed(ActionEvent event) { JFileChooser chooser = new JFileChooser(new File(".")); int returnVal = chooser.showSaveDialog(new JFrame()); String filename = null; if (returnVal == JFileChooser.APPROVE_OPTION) { filename = chooser.getSelectedFile().getPath(); saveView(filename); } } }; Action saveFrameAction = new AbstractAction("Save to PNG") { public void actionPerformed(ActionEvent event) { JFileChooser chooser = new JFileChooser(new File(".")); int returnVal = chooser.showSaveDialog(new JFrame()); String filename = null; if (returnVal == JFileChooser.APPROVE_OPTION) { filename = chooser.getSelectedFile().getPath(); saveFrametoPNG(filename); } } }; JMenuItem cubeItem = fileMenu.add(cubeAction); cubeItem.setMnemonic('C'); JMenuItem lineItem = fileMenu.add(lineAction); lineItem.setMnemonic('L'); JMenuItem pointItem = fileMenu.add(pointAction); pointItem.setMnemonic('P'); JMenuItem saveViewItem = fileMenu.add(saveViewAction); saveViewItem.setMnemonic('V'); JMenuItem loadViewItem = fileMenu.add(loadViewAction); loadViewItem.setMnemonic('I'); JMenuItem saveFrameItem = fileMenu.add(saveFrameAction); saveFrameItem.setMnemonic('S'); JMenuItem exitItem = fileMenu.add(exitAction); exitItem.setMnemonic('X'); JMenu colorMenu = new JMenu("Color"); Action jetAction = new AbstractAction("Jet") { public void actionPerformed(ActionEvent event) { _color = ColorList.JET; setColorMap(); } }; Action prismAction = new AbstractAction("Prism") { public void actionPerformed(ActionEvent event) { _color = ColorList.PRISM; setColorMap(); } }; Action grayAction = new AbstractAction("Gray") { public void actionPerformed(ActionEvent event) { _color = ColorList.GRAY; setColorMap(); } }; Action rwbAction = new AbstractAction("Red-White-Blue") { public void actionPerformed(ActionEvent event) { _color = ColorList.RWB; setColorMap(); } }; colorMenu.add(jetAction); colorMenu.add(prismAction); colorMenu.add(grayAction); colorMenu.add(rwbAction); JMenu clipMenu = new JMenu("% Clip"); Action clipUp = new AbstractAction("Set max pclip") { public void actionPerformed(ActionEvent event) { String value = JOptionPane.showInputDialog(new JFrame(), "Percentile Clip Max (0-100.0):", _pmax); try { _pmax = Float.parseFloat(value); if (_pmax > 100.0f) _pmax = 100.0f; if (_pmax < _pmin) _pmax = _pmin + 1.0f; System.out.printf("pclip: (%f,%f) \n", _pmin, _pmax); _ipg.setPercentiles(_pmin, _pmax); } catch (Exception e) { System.out.println(e); } } }; Action clipDown = new AbstractAction("Set min pclip") { public void actionPerformed(ActionEvent event) { String value = JOptionPane.showInputDialog( new JFrame(), String.format("Percentile Clip Min (0-%f):", _pmax), _pmin); try { _pmin = Float.parseFloat(value); if (_pmin < 0.0f) _pmin = 0.0f; if (_pmin > _pmax) _pmin = _pmax - 1.0f; System.out.printf("pclip: (%f,%f) \n", _pmin, _pmax); _ipg.setPercentiles(_pmin, _pmax); } catch (Exception e) { System.out.println(e); } } }; clipMenu.add(clipUp); clipMenu.add(clipDown); JMenu modeMenu = new JMenu("Mode"); modeMenu.setMnemonic('M'); JMenuItem ovmItem = new JMenuItem(ovm); modeMenu.add(ovmItem); JMenuItem sdmItem = new JMenuItem(sdm); modeMenu.add(sdmItem); JMenu tensorMenu = new JMenu("Tensor"); Action tenLoadAction = new AbstractAction("Load Tensors") { public void actionPerformed(ActionEvent event) { String filename = chooseFile("."); if (filename != null) loadTensors(filename); } }; Action tenCoordLoadAction = new AbstractAction("Load Tensor Coordinates") { public void actionPerformed(ActionEvent event) { String filename = chooseFile("."); if (filename != null) loadTensorCoords(filename); } }; Action showTenAction = new AbstractAction("Show Tensors at Coordinates") { public void actionPerformed(ActionEvent event) { String filename; int sel; if (_ipg == null) { sel = JOptionPane.showConfirmDialog( null, "An RSF Cube (Image) needs to be loaded. " + " Would you like to load one?", "Notice", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (sel == JOptionPane.OK_OPTION) { filename = chooseFile("."); if (filename != null) addRSFCube(filename); } else { JOptionPane.showConfirmDialog( null, "Cannot load tensors because an RFC cube was not loaded.", "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); return; } } if (_coord == null) { sel = JOptionPane.showConfirmDialog( null, "The tensors coordinates need to be loaded. " + " Would you like to load them?", "Notice", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (sel == JOptionPane.OK_OPTION) { filename = chooseFile("."); if (filename != null) loadCoord(filename); } else { JOptionPane.showConfirmDialog( null, "Error loading coordinates.", "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); return; } } if (_etc == null) { sel = JOptionPane.showConfirmDialog( null, "The tensors at coordinates need to be loaded. " + " Would you like to load them?", "Notice", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (sel == JOptionPane.OK_OPTION) { filename = chooseFile("."); if (filename != null) loadTensorCoords(filename); return; } else { JOptionPane.showConfirmDialog( null, "Cannot show tensors because the tensors at coordinates" + " were not loaded.", "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); return; } } /* if(_d == null) { sel = JOptionPane.showConfirmDialog(null, "The tensors need to be loaded. " + " Would you like to load them?", "Notice", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if(sel == JOptionPane.OK_OPTION) { filename = chooseFile("."); if (filename != null) loadTensors(filename); } else { JOptionPane.showConfirmDialog(null, "Cannot show tensors because the tensors were not loaded.", "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); return; } } if(_etg == null) { sel = JOptionPane.showConfirmDialog(null, "The tensor coordinates need to be loaded. " + " Would you like to load them?", "Notice", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if(sel == JOptionPane.OK_OPTION) { filename = chooseFile("."); if (filename != null) loadTensorCoords(filename); return; } else { JOptionPane.showConfirmDialog(null, "Cannot show tensors because the tensor coordinates" + " were not loaded.", "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); return; } } */ _world.addChild(_etg); } }; Action hideTenAction = new AbstractAction("Hide Tensors at Coordinates") { public void actionPerformed(ActionEvent event) { if (_etg != null) _world.removeChild(_etg); } }; Action showTenPanAction = new AbstractAction("Show Tensor Panels") { public void actionPerformed(ActionEvent event) { String filename; int sel; if (_ipg == null) { sel = JOptionPane.showConfirmDialog( null, "An RSF Cube (Image) needs to be loaded. " + " Would you like to load one?", "Notice", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (sel == JOptionPane.OK_OPTION) { filename = chooseFile("."); if (filename != null) addRSFCube(filename); } else { JOptionPane.showConfirmDialog( null, "Cannot load tensors because an RFC cube was not loaded.", "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); return; } } if (_d == null) { sel = JOptionPane.showConfirmDialog( null, "The tensors need to be loaded. " + " Would you like to load them?", "Notice", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (sel == JOptionPane.OK_OPTION) { filename = chooseFile("."); if (filename != null) loadTensors(filename); addRSFTensorEllipsoids(); } else { JOptionPane.showConfirmDialog( null, "Cannot show tensors because the tensors were not loaded.", "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); return; } } else if (_tpx == null || _tpy == null) { addRSFTensorEllipsoids(); } else { ImagePanel ipx = _ipg.getImagePanel(Axis.X); ImagePanel ipy = _ipg.getImagePanel(Axis.Y); ipx.getFrame().addChild(_tpx); ipy.getFrame().addChild(_tpy); } } }; Action hideTenPanAction = new AbstractAction("Hide Tensor Panels") { public void actionPerformed(ActionEvent event) { if (_tpx != null) { ImagePanel ipx = _ipg.getImagePanel(Axis.X); ipx.getFrame().removeChild(_tpx); } if (_tpy != null) { ImagePanel ipy = _ipg.getImagePanel(Axis.Y); ipy.getFrame().removeChild(_tpy); } } }; JMenuItem tensorItem0 = tensorMenu.add(tenLoadAction); tensorItem0.setMnemonic('L'); JMenuItem tensorItem2 = tensorMenu.add(tenCoordLoadAction); tensorItem2.setMnemonic('C'); JMenuItem tensorItem1 = tensorMenu.add(showTenPanAction); tensorItem1.setMnemonic('T'); JMenuItem tensorItem5 = tensorMenu.add(hideTenPanAction); tensorItem5.setMnemonic('R'); JMenuItem tensorItem4 = tensorMenu.add(showTenAction); tensorItem4.setMnemonic('S'); JMenuItem tensorItem3 = tensorMenu.add(hideTenAction); tensorItem3.setMnemonic('H'); JMenuBar menuBar = new JMenuBar(); menuBar.add(fileMenu); menuBar.add(modeMenu); menuBar.add(tensorMenu); menuBar.add(colorMenu); menuBar.add(clipMenu); JToolBar toolBar = new JToolBar(SwingConstants.VERTICAL); toolBar.setRollover(true); JToggleButton ovmButton = new ModeToggleButton(ovm); toolBar.add(ovmButton); JToggleButton sdmButton = new ModeToggleButton(sdm); toolBar.add(sdmButton); _cb = new ColorBar(); _cb.setWidthMinimum(45); _cb.setFont(_cb.getFont().deriveFont(18.f)); // _ipg.addColorMapListener(_cb); ovm.setActive(true); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setSize(new Dimension(SIZE, SIZE)); this.add(_canvas, BorderLayout.CENTER); this.add(toolBar, BorderLayout.WEST); this.add(_cb, BorderLayout.EAST); this.setJMenuBar(menuBar); this.setVisible(true); }
@NotNull private JTree createTree() { DefaultMutableTreeNode root = new DefaultMutableTreeNode(); final Tree tree = new Tree(new DefaultTreeModel(root)) /* { @Override protected void paintComponent(Graphics g) { DuplicateNodeRenderer.paintDuplicateNodesBackground(g, this); super.paintComponent(g); } }*/; tree.setOpaque(false); tree.setToggleClickCount(-1); SliceUsageCellRenderer renderer = new SliceUsageCellRenderer(); renderer.setOpaque(false); tree.setCellRenderer(renderer); UIUtil.setLineStyleAngled(tree); tree.setRootVisible(false); tree.setShowsRootHandles(true); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setSelectionPath(new TreePath(root.getPath())); // ActionGroup group = // (ActionGroup)ActionManager.getInstance().getAction(IdeActions.GROUP_METHOD_HIERARCHY_POPUP); // PopupHandler.installPopupHandler(tree, group, ActionPlaces.METHOD_HIERARCHY_VIEW_POPUP, // ActionManager.getInstance()); EditSourceOnDoubleClickHandler.install(tree); new TreeSpeedSearch(tree); TreeUtil.installActions(tree); ToolTipManager.sharedInstance().registerComponent(tree); myAutoScrollToSourceHandler.install(tree); tree.getSelectionModel() .addTreeSelectionListener( new TreeSelectionListener() { @Override public void valueChanged(final TreeSelectionEvent e) { treeSelectionChanged(); } }); tree.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (KeyEvent.VK_ENTER == e.getKeyCode()) { List<Navigatable> navigatables = getNavigatables(); if (navigatables.isEmpty()) return; for (Navigatable navigatable : navigatables) { if (navigatable instanceof AbstractTreeNode && ((AbstractTreeNode) navigatable).getValue() instanceof Usage) { navigatable = (Usage) ((AbstractTreeNode) navigatable).getValue(); } if (navigatable.canNavigateToSource()) { navigatable.navigate(false); if (navigatable instanceof Usage) { ((Usage) navigatable).highlightInEditor(); } } } e.consume(); } } }); tree.addTreeWillExpandListener( new TreeWillExpandListener() { @Override public void treeWillCollapse(TreeExpansionEvent event) {} @Override public void treeWillExpand(TreeExpansionEvent event) { TreePath path = event.getPath(); SliceNode node = fromPath(path); node.calculateDupNode(); } }); return tree; }
/** Initializes the layout and the ribbon. */ private void initRibbon() { this.setLayout(new RibbonFrameLayout()); this.ribbon = new JRibbon(this); this.add(this.ribbon, BorderLayout.NORTH); // this.keyTipManager = new KeyTipManager(this); Toolkit.getDefaultToolkit() .addAWTEventListener( new AWTEventListener() { private boolean prevAltModif = false; @Override public void eventDispatched(AWTEvent event) { Object src = event.getSource(); if (src instanceof Component) { Component c = (Component) src; if ((c == JRibbonFrame.this) || (SwingUtilities.getWindowAncestor(c) == JRibbonFrame.this)) { if (event instanceof KeyEvent) { KeyEvent keyEvent = (KeyEvent) event; // System.out.println(keyEvent.getID() + ":" // + keyEvent.getKeyCode()); switch (keyEvent.getID()) { case KeyEvent.KEY_PRESSED: // if (keyEvent.getKeyCode() == // KeyEvent.VK_ESCAPE) { // keyTipManager.showPreviousChain(); // } break; case KeyEvent.KEY_RELEASED: boolean wasAltModif = prevAltModif; prevAltModif = keyEvent.getModifiersEx() == InputEvent.ALT_DOWN_MASK; if (wasAltModif && keyEvent.getKeyCode() == KeyEvent.VK_ALT) break; char keyChar = keyEvent.getKeyChar(); if (Character.isLetter(keyChar) || Character.isDigit(keyChar)) { // System.out.println("Will handle key press " // + keyChar); KeyTipManager.defaultManager().handleKeyPress(keyChar); } if ((keyEvent.getKeyCode() == KeyEvent.VK_ALT) || (keyEvent.getKeyCode() == KeyEvent.VK_F10)) { if (keyEvent.getModifiers() != 0 || keyEvent.getModifiersEx() != 0) break; boolean hadPopups = !PopupPanelManager.defaultManager().getShownPath().isEmpty(); PopupPanelManager.defaultManager().hidePopups(null); if (hadPopups || KeyTipManager.defaultManager().isShowingKeyTips()) { KeyTipManager.defaultManager().hideAllKeyTips(); } else { KeyTipManager.defaultManager().showRootKeyTipChain(JRibbonFrame.this); } } if (keyEvent.getKeyCode() == KeyEvent.VK_ESCAPE) { // System.out.println("In KTM"); KeyTipManager.defaultManager().showPreviousChain(); } break; } } if (event instanceof MouseEvent) { MouseEvent mouseEvent = (MouseEvent) event; switch (mouseEvent.getID()) { case MouseEvent.MOUSE_CLICKED: case MouseEvent.MOUSE_DRAGGED: case MouseEvent.MOUSE_PRESSED: case MouseEvent.MOUSE_RELEASED: KeyTipManager.defaultManager().hideAllKeyTips(); } } } } } }, AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK); final KeyTipLayer keyTipLayer = new KeyTipLayer(); JRootPane rootPane = this.getRootPane(); JLayeredPane layeredPane = rootPane.getLayeredPane(); final LayoutManager currLM = rootPane.getLayout(); rootPane.setLayout( new LayoutManager() { @Override public void addLayoutComponent(String name, Component comp) { currLM.addLayoutComponent(name, comp); } @Override public void layoutContainer(Container parent) { currLM.layoutContainer(parent); JRibbonFrame ribbonFrame = JRibbonFrame.this; if (ribbonFrame.getRootPane().getWindowDecorationStyle() != JRootPane.NONE) keyTipLayer.setBounds(ribbonFrame.getRootPane().getBounds()); else keyTipLayer.setBounds(ribbonFrame.getRootPane().getContentPane().getBounds()); } @Override public Dimension minimumLayoutSize(Container parent) { return currLM.minimumLayoutSize(parent); } @Override public Dimension preferredLayoutSize(Container parent) { return currLM.preferredLayoutSize(parent); } @Override public void removeLayoutComponent(Component comp) { currLM.removeLayoutComponent(comp); } }); // layeredPane.setLayout(new OverlayLayout(layeredPane)); layeredPane.add(keyTipLayer, (Integer) (JLayeredPane.DEFAULT_LAYER + 60)); this.addWindowListener( new WindowAdapter() { @Override public void windowDeactivated(WindowEvent e) { // hide all key tips on window deactivation KeyTipManager keyTipManager = KeyTipManager.defaultManager(); if (keyTipManager.isShowingKeyTips()) { keyTipManager.hideAllKeyTips(); } } }); KeyTipManager.defaultManager() .addKeyTipListener( new KeyTipManager.KeyTipListener() { @Override public void keyTipsHidden(KeyTipEvent event) { if (event.getSource() == JRibbonFrame.this) keyTipLayer.setVisible(false); } @Override public void keyTipsShown(KeyTipEvent event) { if (event.getSource() == JRibbonFrame.this) keyTipLayer.setVisible(true); } }); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); JPopupMenu.setDefaultLightWeightPopupEnabled(false); super.setIconImages(Arrays.asList(FlamingoUtilities.getBlankImage(16, 16))); }
public FavoritesTreeViewPanel(Project project, String helpId, String name) { super(new BorderLayout()); myProject = project; myHelpId = helpId; myListName = name; myFavoritesTreeStructure = new FavoritesTreeStructure(project, myListName); DefaultMutableTreeNode root = new DefaultMutableTreeNode(); root.setUserObject(myFavoritesTreeStructure.getRootElement()); final DefaultTreeModel treeModel = new DefaultTreeModel(root); myTree = new DnDAwareTree(treeModel); myBuilder = new FavoritesViewTreeBuilder( myProject, myTree, treeModel, myFavoritesTreeStructure, myListName); TreeUtil.installActions(myTree); UIUtil.setLineStyleAngled(myTree); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); myTree.setLargeModel(true); new TreeSpeedSearch(myTree); ToolTipManager.sharedInstance().registerComponent(myTree); myTree.setCellRenderer( new NodeRenderer() { public void customizeCellRenderer( JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { super.customizeCellRenderer(tree, value, selected, expanded, leaf, row, hasFocus); if (value instanceof DefaultMutableTreeNode) { final DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; // only favorites roots to explain final Object userObject = node.getUserObject(); if (userObject instanceof FavoritesTreeNodeDescriptor) { final FavoritesTreeNodeDescriptor favoritesTreeNodeDescriptor = (FavoritesTreeNodeDescriptor) userObject; AbstractTreeNode treeNode = favoritesTreeNodeDescriptor.getElement(); final ItemPresentation presentation = treeNode.getPresentation(); String locationString = presentation.getLocationString(); if (locationString != null && locationString.length() > 0) { append(" (" + locationString + ")", SimpleTextAttributes.GRAY_ATTRIBUTES); } else if (node.getParent() != null && node.getParent().getParent() == null) { final String location = favoritesTreeNodeDescriptor.getLocation(); if (location != null && location.length() > 0) { append(" (" + location + ")", SimpleTextAttributes.GRAY_ATTRIBUTES); } } } } } }); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree); myTreePopupHandler = CustomizationUtil.installPopupHandler( myTree, IdeActions.GROUP_FAVORITES_VIEW_POPUP, ActionPlaces.FAVORITES_VIEW_POPUP); add(scrollPane, BorderLayout.CENTER); // add(createActionsToolbar(), BorderLayout.NORTH); EditSourceOnDoubleClickHandler.install(myTree); EditSourceOnEnterKeyHandler.install(myTree); myCopyPasteDelegator = new CopyPasteDelegator(myProject, this) { @NotNull protected PsiElement[] getSelectedElements() { return getSelectedPsiElements(); } }; }
/** * Everytime a frame ist reloaded, this Method is called by org.wings.plaf.css1.Util. Then * setFocus must be called, bacause the ids of the Components change at that time. */ public ScriptListener[] getScriptListeners() { ToolTipManager.sharedInstance().installListener(this); setFocus(); return (ScriptListener[]) super.getListeners(ScriptListener.class); }