List of usage examples for javax.swing JLabel addMouseListener
public synchronized void addMouseListener(MouseListener l)
From source file:edu.harvard.i2b2.query.ui.TopPanel.java
public void addPanel() { int rightmostPosition = dataModel.lastLabelPosition(); JLabel label = new JLabel(); label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); label.setText("and"); label.setToolTipText("Click to change the relationship"); label.setBorder(javax.swing.BorderFactory.createEtchedBorder()); label.addMouseListener(new java.awt.event.MouseAdapter() { @Override//from ww w . j a va 2 s . c om public void mouseClicked(java.awt.event.MouseEvent evt) { jAndOrLabelMouseClicked(evt); } }); // jPanel1.add(label); // label.setBounds(rightmostPosition, 90, 30, 18); ConceptTreePanel panel = new ConceptTreePanel("Group " + (dataModel.getCurrentPanelCount() + 1), this); jPanel1.add(panel); panel.setBounds(rightmostPosition + 5, 0, 180, getParent().getHeight() - 100); jPanel1.setPreferredSize(new Dimension(rightmostPosition + 5 + 181 + 60, getHeight() - 100)); jScrollPane4.setViewportView(jPanel1); dataModel.addPanel(panel, label, rightmostPosition + 5 + 180); jScrollPane4.getHorizontalScrollBar().setValue(jScrollPane4.getHorizontalScrollBar().getMaximum()); jScrollPane4.getHorizontalScrollBar().setUnitIncrement(40); resizePanels(getParent().getWidth(), getParent().getHeight()); }
From source file:gate.gui.docview.AnnotationStack.java
/** * Draw the annotation stack in a JPanel with a GridBagLayout. *///from w w w.j a v a 2 s. c o m public void drawStack() { // clear the panel removeAll(); boolean textTooLong = text.length() > maxTextLength; int upperBound = text.length() - (maxTextLength / 2); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.BOTH; /********************** * First row of text * *********************/ gbc.gridwidth = 1; gbc.insets = new java.awt.Insets(10, 10, 10, 10); JLabel labelTitle = new JLabel("Context"); labelTitle.setOpaque(true); labelTitle.setBackground(Color.WHITE); labelTitle.setBorder(new CompoundBorder( new EtchedBorder(EtchedBorder.LOWERED, new Color(250, 250, 250), new Color(250, 250, 250).darker()), new EmptyBorder(new Insets(0, 2, 0, 2)))); labelTitle.setToolTipText("Expression and its context."); add(labelTitle, gbc); gbc.insets = new java.awt.Insets(10, 0, 10, 0); int expressionStart = contextBeforeSize; int expressionEnd = text.length() - contextAfterSize; // for each character for (int charNum = 0; charNum < text.length(); charNum++) { gbc.gridx = charNum + 1; if (textTooLong) { if (charNum == maxTextLength / 2) { // add ellipsis dots in case of a too long text displayed add(new JLabel("..."), gbc); // skip the middle part of the text if too long charNum = upperBound + 1; continue; } else if (charNum > upperBound) { gbc.gridx -= upperBound - (maxTextLength / 2) + 1; } } // set the text and color of the feature value JLabel label = new JLabel(text.substring(charNum, charNum + 1)); if (charNum >= expressionStart && charNum < expressionEnd) { // this part is matched by the pattern, color it label.setBackground(new Color(240, 201, 184)); } else { // this part is the context, no color label.setBackground(Color.WHITE); } label.setOpaque(true); // get the word from which belongs the current character charNum int start = text.lastIndexOf(" ", charNum); int end = text.indexOf(" ", charNum); String word = text.substring((start == -1) ? 0 : start, (end == -1) ? text.length() : end); // add a mouse listener that modify the query label.addMouseListener(textMouseListener.createListener(word)); add(label, gbc); } /************************************ * Subsequent rows with annotations * ************************************/ // for each row to display for (StackRow stackRow : stackRows) { String type = stackRow.getType(); String feature = stackRow.getFeature(); if (feature == null) { feature = ""; } String shortcut = stackRow.getShortcut(); if (shortcut == null) { shortcut = ""; } gbc.gridy++; gbc.gridx = 0; gbc.gridwidth = 1; gbc.insets = new Insets(0, 0, 3, 0); // add the header of the row JLabel annotationTypeAndFeature = new JLabel(); String typeAndFeature = type + (feature.equals("") ? "" : ".") + feature; annotationTypeAndFeature.setText(!shortcut.equals("") ? shortcut : stackRow.getSet() != null ? stackRow.getSet() + "#" + typeAndFeature : typeAndFeature); annotationTypeAndFeature.setOpaque(true); annotationTypeAndFeature.setBackground(Color.WHITE); annotationTypeAndFeature .setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.LOWERED, new Color(250, 250, 250), new Color(250, 250, 250).darker()), new EmptyBorder(new Insets(0, 2, 0, 2)))); if (feature.equals("")) { annotationTypeAndFeature.addMouseListener(headerMouseListener.createListener(type)); } else { annotationTypeAndFeature.addMouseListener(headerMouseListener.createListener(type, feature)); } gbc.insets = new java.awt.Insets(0, 10, 3, 10); add(annotationTypeAndFeature, gbc); gbc.insets = new java.awt.Insets(0, 0, 3, 0); // add all annotations for this row HashMap<Integer, TreeSet<Integer>> gridSet = new HashMap<Integer, TreeSet<Integer>>(); int gridyMax = gbc.gridy; for (StackAnnotation ann : stackRow.getAnnotations()) { gbc.gridx = ann.getStartNode().getOffset().intValue() - expressionStartOffset + contextBeforeSize + 1; gbc.gridwidth = ann.getEndNode().getOffset().intValue() - ann.getStartNode().getOffset().intValue(); if (gbc.gridx == 0) { // column 0 is already the row header gbc.gridwidth -= 1; gbc.gridx = 1; } else if (gbc.gridx < 0) { // annotation starts before displayed text gbc.gridwidth += gbc.gridx - 1; gbc.gridx = 1; } if (gbc.gridx + gbc.gridwidth > text.length()) { // annotation ends after displayed text gbc.gridwidth = text.length() - gbc.gridx + 1; } if (textTooLong) { if (gbc.gridx > (upperBound + 1)) { // x starts after the hidden middle part gbc.gridx -= upperBound - (maxTextLength / 2) + 1; } else if (gbc.gridx > (maxTextLength / 2)) { // x starts in the hidden middle part if (gbc.gridx + gbc.gridwidth <= (upperBound + 3)) { // x ends in the hidden middle part continue; // skip the middle part of the text } else { // x ends after the hidden middle part gbc.gridwidth -= upperBound - gbc.gridx + 2; gbc.gridx = (maxTextLength / 2) + 2; } } else { // x starts before the hidden middle part if (gbc.gridx + gbc.gridwidth < (maxTextLength / 2)) { // x ends before the hidden middle part // do nothing } else if (gbc.gridx + gbc.gridwidth < upperBound) { // x ends in the hidden middle part gbc.gridwidth = (maxTextLength / 2) - gbc.gridx + 1; } else { // x ends after the hidden middle part gbc.gridwidth -= upperBound - (maxTextLength / 2) + 1; } } } if (gbc.gridwidth == 0) { gbc.gridwidth = 1; } JLabel label = new JLabel(); Object object = ann.getFeatures().get(feature); String value = (object == null) ? " " : Strings.toString(object); if (value.length() > maxFeatureValueLength) { // show the full text in the tooltip label.setToolTipText((value.length() > 500) ? "<html><textarea rows=\"30\" cols=\"40\" readonly=\"readonly\">" + value.replaceAll("(.{50,60})\\b", "$1\n") + "</textarea></html>" : ((value.length() > 100) ? "<html><table width=\"500\" border=\"0\" cellspacing=\"0\">" + "<tr><td>" + value.replaceAll("\n", "<br>") + "</td></tr></table></html>" : value)); if (stackRow.getCrop() == CROP_START) { value = "..." + value.substring(value.length() - maxFeatureValueLength - 1); } else if (stackRow.getCrop() == CROP_END) { value = value.substring(0, maxFeatureValueLength - 2) + "..."; } else {// cut in the middle value = value.substring(0, maxFeatureValueLength / 2) + "..." + value.substring(value.length() - (maxFeatureValueLength / 2)); } } label.setText(value); label.setBackground(AnnotationSetsView.getColor(stackRow.getSet(), ann.getType())); label.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); label.setOpaque(true); label.addMouseListener(annotationMouseListener.createListener(stackRow.getSet(), type, String.valueOf(ann.getId()))); // show the feature values in the tooltip if (!ann.getFeatures().isEmpty()) { String width = (Strings.toString(ann.getFeatures()).length() > 100) ? "500" : "100%"; String toolTip = "<html><table width=\"" + width + "\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\">"; Color color = (Color) UIManager.get("ToolTip.background"); float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null); color = Color.getHSBColor(hsb[0], hsb[1], Math.max(0f, hsb[2] - hsb[2] * 0.075f)); // darken the color String hexColor = Integer.toHexString(color.getRed()) + Integer.toHexString(color.getGreen()) + Integer.toHexString(color.getBlue()); boolean odd = false; // alternate background color every other row List<Object> features = new ArrayList<Object>(ann.getFeatures().keySet()); //sort the features into alphabetical order Collections.sort(features, new Comparator<Object>() { @Override public int compare(Object o1, Object o2) { return o1.toString().compareToIgnoreCase(o2.toString()); } }); for (Object key : features) { String fv = Strings.toString(ann.getFeatures().get(key)); toolTip += "<tr align=\"left\"" + (odd ? " bgcolor=\"#" + hexColor + "\"" : "") + "><td><strong>" + key + "</strong></td><td>" + ((fv.length() > 500) ? "<textarea rows=\"20\" cols=\"40\" cellspacing=\"0\">" + StringEscapeUtils .escapeHtml(fv.replaceAll("(.{50,60})\\b", "$1\n")) + "</textarea>" : StringEscapeUtils.escapeHtml(fv).replaceAll("\n", "<br>")) + "</td></tr>"; odd = !odd; } label.setToolTipText(toolTip + "</table></html>"); } else { label.setToolTipText("No features."); } if (!feature.equals("")) { label.addMouseListener(annotationMouseListener.createListener(stackRow.getSet(), type, feature, Strings.toString(ann.getFeatures().get(feature)), String.valueOf(ann.getId()))); } // find the first empty row span for this annotation int oldGridy = gbc.gridy; for (int y = oldGridy; y <= (gridyMax + 1); y++) { // for each cell of this row where spans the annotation boolean xSpanIsEmpty = true; for (int x = gbc.gridx; (x < (gbc.gridx + gbc.gridwidth)) && xSpanIsEmpty; x++) { xSpanIsEmpty = !(gridSet.containsKey(x) && gridSet.get(x).contains(y)); } if (xSpanIsEmpty) { gbc.gridy = y; break; } } // save the column x and row y of the current value TreeSet<Integer> ts; for (int x = gbc.gridx; x < (gbc.gridx + gbc.gridwidth); x++) { ts = gridSet.get(x); if (ts == null) { ts = new TreeSet<Integer>(); } ts.add(gbc.gridy); gridSet.put(x, ts); } add(label, gbc); gridyMax = Math.max(gridyMax, gbc.gridy); gbc.gridy = oldGridy; } // add a button at the end of the row gbc.gridwidth = 1; if (stackRow.getLastColumnButton() != null) { // last cell of the row gbc.gridx = Math.min(text.length(), maxTextLength) + 1; gbc.insets = new Insets(0, 10, 3, 0); gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.WEST; add(stackRow.getLastColumnButton(), gbc); gbc.insets = new Insets(0, 0, 3, 0); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.CENTER; } // set the new gridy to the maximum row we put a value gbc.gridy = gridyMax; } if (lastRowButton != null) { // add a configuration button on the last row gbc.insets = new java.awt.Insets(0, 10, 0, 10); gbc.gridx = 0; gbc.gridy++; add(lastRowButton, gbc); } // add an empty cell that takes all remaining space to // align the visible cells at the top-left corner gbc.gridy++; gbc.gridx = Math.min(text.length(), maxTextLength) + 1; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.gridheight = GridBagConstraints.REMAINDER; gbc.weightx = 1; gbc.weighty = 1; add(new JLabel(""), gbc); validate(); updateUI(); }
From source file:edu.harvard.i2b2.query.ui.TopPanel.java
private void jMorePanelsButtonActionPerformed(java.awt.event.ActionEvent evt) { if (dataModel.hasEmptyPanels()) { JOptionPane.showMessageDialog(this, "Please use an existing empty panel before adding a new one."); return;// w w w. ja va2s . c o m } int rightmostPosition = dataModel.lastLabelPosition(); JLabel label = new JLabel(); label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); label.setText("and"); label.setToolTipText("Click to change the relationship"); label.setBorder(javax.swing.BorderFactory.createEtchedBorder()); label.addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mouseClicked(java.awt.event.MouseEvent evt) { jAndOrLabelMouseClicked(evt); } }); ConceptTreePanel panel = new ConceptTreePanel("Group " + (dataModel.getCurrentPanelCount() + 1), this); jPanel1.add(panel); panel.setBounds(rightmostPosition + 5, 0, 180, getParent().getHeight() - 100); jPanel1.setPreferredSize(new Dimension(rightmostPosition + 5 + 181 + 60, getHeight() - 100)); jScrollPane4.setViewportView(jPanel1); dataModel.addPanel(panel, label, rightmostPosition + 5 + 180); /* * System.out.println(jScrollPane4.getViewport().getExtentSize().width+":" * + jScrollPane4.getViewport().getExtentSize().height); * System.out.println * (jScrollPane4.getHorizontalScrollBar().getVisibleRect().width+":" * +jScrollPane4.getHorizontalScrollBar().getVisibleRect().height); * System * .out.println(jScrollPane4.getHorizontalScrollBar().getVisibleAmount * ()); * System.out.println(jScrollPane4.getHorizontalScrollBar().getValue()); */ jScrollPane4.getHorizontalScrollBar().setValue(jScrollPane4.getHorizontalScrollBar().getMaximum()); jScrollPane4.getHorizontalScrollBar().setUnitIncrement(40); // this.jScrollPane4.removeAll(); // this.jScrollPane4.setViewportView(jPanel1); // revalidate(); // jScrollPane3.setBounds(420, 0, 170, 300); // jScrollPane4.setBounds(20, 35, 335, 220); resizePanels(getParent().getWidth(), getParent().getHeight()); }
From source file:com.titan.mainframe.MainFrame.java
public MainFrame() { String osName = System.getProperty("os.name").toLowerCase(); if (osName.toLowerCase().contains("mac")) { com.apple.eawt.Application macApp = com.apple.eawt.Application.getApplication(); macApp.addApplicationListener(this); }/* w w w .ja v a2 s.com*/ addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { handleQuit(); } @Override public void windowOpened(WindowEvent e) { windowOpened = true; } }); setTitle("Titan " + Global.version); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); if (TitanSetting.getInstance().width == 0 || TitanSetting.getInstance().height == 0) { setBounds(TitanSetting.getInstance().x, TitanSetting.getInstance().y, 1200, 700); } else { setBounds(TitanSetting.getInstance().x, TitanSetting.getInstance().y, TitanSetting.getInstance().width, TitanSetting.getInstance().height); } setIconImage(new ImageIcon(getClass().getClassLoader().getResource("com/titan/image/titan_icon.png")) .getImage()); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(new BorderLayout(0, 0)); splitPane.setDividerLocation(TitanSetting.getInstance().mainframeDivX); contentPane.add(splitPane, BorderLayout.CENTER); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout(0, 0)); JLabel logoLabel = new JLabel(); logoLabel.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { mainContentPanel.removeAll(); mainContentPanel.add(welcomePanel, BorderLayout.CENTER); mainContentPanel.updateUI(); } }); // try { // BufferedImage b = ImageIO.read(MainFrame.class.getResource("/com/titan/image/titanLogo.png")); // Image i = b.getScaledInstance((int) (b.getWidth() * 0.6), (int) (b.getHeight() * 0.6), Image.SCALE_SMOOTH); logoLabel.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/titanLogo.png"))); // } catch (IOException e1) { // e1.printStackTrace(); // } // logoLabel.setMaximumSize(new Dimension(150, 150)); JPanel controlPanel = new JPanel(); controlPanel.setBackground(new Color(239, 249, 255)); controlPanel.setOpaque(true); panel.add(controlPanel, BorderLayout.CENTER); controlPanel.setLayout(new BorderLayout()); JScrollPane computeScrollPane = new JScrollPane(); tabbedPane.addTab("Compute", computeScrollPane); controlPanel.add(tabbedPane, BorderLayout.CENTER); serverTree = new JTree(); serverTree.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { // Object obj = mainContentPanel.getComponent(0); // if (obj instanceof VMMainPanel) { // ((MainPanel) obj).refresh(); // } } }); serverTree.setModel(computeTreeModel); serverTree.setCellRenderer(new ZoneTreeRenderer()); serverTree.setRootVisible(false); computeScrollPane.setViewportView(serverTree); updateComputeTree(); JScrollPane zoneScrollPane = new JScrollPane(); tabbedPane.addTab("Zone", zoneScrollPane); zoneTree = new JTree(); zoneTree.setModel(zoneTreeModel); zoneTree.setCellRenderer(new ZoneTreeRenderer()); zoneScrollPane.setViewportView(zoneTree); updateZoneTree(); splitPane.setLeftComponent(panel); splitPane.setRightComponent(mainContentPanel); mainContentPanel.setLayout(new BorderLayout(0, 0)); welcomePanel = new WelcomePanel(); mainContentPanel.add(welcomePanel, BorderLayout.CENTER); welcomePanel.setLayout(new BorderLayout(0, 0)); welcomePanel.add(mainScreenLabel, BorderLayout.CENTER); mainScreenLabel.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/mainscreen.png"))); JPanel panel_1 = new JPanel(); welcomePanel.add(panel_1, BorderLayout.SOUTH); JButton licenseButton = new JButton("License"); licenseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { InputStream in = MainFrame.class.getResourceAsStream("/com/titan/license.txt"); try { LicenseDialog dialog = new LicenseDialog(MainFrame.this, IOUtils.toString(in)); CommonLib.centerDialog(dialog); dialog.setVisible(true); } catch (IOException e1) { e1.printStackTrace(); } finally { IOUtils.closeQuietly(in); } } }); panel_1.add(licenseButton); ribbonPanel = new JPanel(); contentPane.add(ribbonPanel, BorderLayout.NORTH); ribbonPanel.setLayout(new BorderLayout(0, 0)); ribbonTabbedPane = new JTabbedPane(JTabbedPane.TOP); ribbonTabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { // if (!windowOpened) { // return; // } String tab = ribbonTabbedPane.getTitleAt(ribbonTabbedPane.getSelectedIndex()); if (tab.equals("Server")) { if (mainServerPanel == null || !mainServerPanel.serverPanel.jprogressBarDialog.isActive()) { SwingUtilities.invokeLater(new Runnable() { public void run() { mainContentPanel.removeAll(); mainServerPanel = new MainServerPanel(MainFrame.this); mainContentPanel.add(mainServerPanel, BorderLayout.CENTER); mainContentPanel.updateUI(); } }); } } else if (tab.equals("VM")) { SwingUtilities.invokeLater(new Runnable() { public void run() { mainContentPanel.removeAll(); mainContentPanel.add(new VMMainPanel(MainFrame.this), BorderLayout.CENTER); mainContentPanel.updateUI(); } }); } else if (tab.equals("Keystone")) { mainContentPanel.removeAll(); mainContentPanel.add(new KeystonePanel(MainFrame.this), BorderLayout.CENTER); mainContentPanel.updateUI(); } else if (tab.equals("Flavor")) { mainContentPanel.removeAll(); mainContentPanel.add(new FlavorPanel(MainFrame.this), BorderLayout.CENTER); mainContentPanel.updateUI(); } else if (tab.equals("Storage")) { mainContentPanel.removeAll(); mainContentPanel.add(new StoragePanel(MainFrame.this), BorderLayout.CENTER); mainContentPanel.updateUI(); } else if (tab.equals("Network")) { mainContentPanel.removeAll(); mainContentPanel.add(new SDNPanel(MainFrame.this), BorderLayout.CENTER); mainContentPanel.updateUI(); } else if (tab.equals("Setting")) { mainContentPanel.removeAll(); mainContentPanel.add(new SettingPanel(MainFrame.this), BorderLayout.CENTER); mainContentPanel.updateUI(); } } }); ribbonTabbedPane.putClientProperty("type", "ribbonType"); ribbonTabbedPane.setPreferredSize(new Dimension(1000, 140)); ribbonPanel.add(ribbonTabbedPane, BorderLayout.CENTER); serverPanel = new JRibbonPanel(); serverPanel.setLayout(new MigLayout("", "[][][][][][][][][][][][][][grow][]", "[grow][grow][]")); ribbonTabbedPane.addTab("Server", null, serverPanel, null); logoutButton = new JRibbonBigButton("Logout"); logoutButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { logout(); } }); rbnbgbtnAddServer = new JRibbonBigButton(); rbnbgbtnAddServer.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/add.png"))); rbnbgbtnAddServer.setText("Add Server"); serverPanel.add(rbnbgbtnAddServer, "cell 0 0 1 3,growy"); rbnbgbtnDeleteServer = new JRibbonBigButton(); rbnbgbtnDeleteServer .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/delete.png"))); rbnbgbtnDeleteServer.setText("Delete Server"); serverPanel.add(rbnbgbtnDeleteServer, "cell 1 0 1 3,growy"); logoutButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/logout.png"))); logoutButton.setVerticalTextPosition(SwingConstants.BOTTOM); logoutButton.setHorizontalTextPosition(SwingConstants.CENTER); serverPanel.add(logoutButton, "cell 14 0 1 3,growy"); vmPanel = new JRibbonPanel(); ribbonTabbedPane.addTab("VM", null, vmPanel, null); vmPanel.setLayout(new MigLayout("", "[][][][][][][][][][][][][][][grow][]", "[grow][grow][]")); launchButton = new JRibbonBigButton("Launch"); launchButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new LaunchInstanceDialog(MainFrame.this).setVisible(true); } }); launchButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/launch.png"))); launchButton.setVerticalTextPosition(SwingConstants.BOTTOM); launchButton.setHorizontalTextPosition(SwingConstants.CENTER); vmPanel.add(launchButton, "cell 0 0 1 3,growy"); pauseButton = new JRibbonButton("Pause"); pauseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.action("from titan: nova pause"); } }); pauseButton.setHorizontalAlignment(SwingConstants.LEFT); pauseButton.setIcon( new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/control_pause.png"))); vmPanel.add(pauseButton, "cell 2 0,growx"); stopButton = new JRibbonButton("Stop"); stopButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.action("from titan: nova stop"); } }); stopButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/stop.png"))); stopButton.setVerticalTextPosition(SwingConstants.BOTTOM); stopButton.setHorizontalTextPosition(SwingConstants.CENTER); vmPanel.add(stopButton, "cell 1 0 1 3,growy"); unpauseButton = new JRibbonButton("Unpause"); unpauseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.action("from titan: nova unpause"); } }); unpauseButton.setHorizontalAlignment(SwingConstants.LEFT); unpauseButton .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/control_play.png"))); suspendButton = new JRibbonButton("Suspend"); suspendButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.action("from titan: nova suspend"); } }); suspendButton.setHorizontalAlignment(SwingConstants.LEFT); suspendButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/disk.png"))); vmPanel.add(suspendButton, "cell 3 0,growx"); softRebootButton = new JRibbonButton("Soft reboot"); softRebootButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.action("from titan: nova soft-reboot"); } }); softRebootButton.setHorizontalAlignment(SwingConstants.LEFT); softRebootButton.setIcon(new ImageIcon( MainFrame.class.getResource("/com/titan/image/famfamfam/arrow_rotate_clockwise.png"))); selectAllVMButton = new JRibbonButton("Select all"); selectAllVMButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.selectAll(); } }); vmPanel.add(selectAllVMButton, "cell 4 0,growx"); vmPanel.add(softRebootButton, "cell 9 0,growx"); createMacroButton = new JRibbonButton("Create macro"); createMacroButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/add.png"))); createMacroButton.setHorizontalAlignment(SwingConstants.LEFT); setGroupNameButton = new JRibbonButton("Set group name"); setGroupNameButton.setHorizontalAlignment(SwingConstants.LEFT); setGroupNameButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.setGroupName(); } }); vmPanel.add(setGroupNameButton, "cell 10 0"); vmPanel.add(createMacroButton, "cell 13 0,growx"); ribbonSeparator_3 = new JRibbonSeparator(); vmPanel.add(ribbonSeparator_3, "cell 14 0 1 3,growy"); vmPanel.add(unpauseButton, "cell 2 1,growx"); remoteButton = new JRibbonButton("Remote"); remoteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.remote(); } }); remoteButton.setHorizontalAlignment(SwingConstants.LEFT); remoteButton.setIcon(new ImageIcon( MainFrame.class.getResource("/com/titan/image/famfamfam/application_osx_terminal.png"))); unselectAllButton = new JRibbonButton("Unselect all"); unselectAllButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.unselectAll(); } }); vmPanel.add(unselectAllButton, "cell 4 1,growx"); vmPanel.add(remoteButton, "cell 2 2,growx"); performanceMeterButton = new JRibbonButton("Performance meter"); performanceMeterButton .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/chart_curve.png"))); performanceMeterButton.setHorizontalAlignment(SwingConstants.LEFT); vmPanel.add(performanceMeterButton, "cell 13 1,growx"); resumeButton = new JRibbonButton("Resume"); resumeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.action("from titan: nova resume"); } }); resumeButton.setHorizontalAlignment(SwingConstants.LEFT); resumeButton .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/drive_disk.png"))); vmPanel.add(resumeButton, "cell 3 1,growx"); deleteButton = new JRibbonBigButton("Delete"); deleteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.action("from titan: nova delete"); } }); vmPanel.add(deleteButton, "cell 7 0 1 3,alignx center,growy"); deleteButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/delete.png"))); deleteButton.setVerticalTextPosition(SwingConstants.BOTTOM); deleteButton.setHorizontalTextPosition(SwingConstants.CENTER); logButton = new JRibbonBigButton("Log"); logButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.log(); } }); vmPanel.add(logButton, "cell 6 0 1 3,alignx center,growy"); logButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/log.png"))); logButton.setVerticalTextPosition(SwingConstants.BOTTOM); logButton.setHorizontalTextPosition(SwingConstants.CENTER); hardRebootButton = new JRibbonButton("Hard reboot"); hardRebootButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { VMMainPanel vmMainPanel = (VMMainPanel) mainContentPanel.getComponent(0); vmMainPanel.action("from titan: nova hard-reboot"); } }); hardRebootButton.setHorizontalAlignment(SwingConstants.LEFT); hardRebootButton .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/arrow_undo.png"))); ribbonSeparator = new JRibbonSeparator(); vmPanel.add(ribbonSeparator, "cell 5 0 1 3,alignx center,growy"); ribbonSeparator_1 = new JRibbonSeparator(); vmPanel.add(ribbonSeparator_1, "cell 8 0 1 3,alignx center,growy"); vmPanel.add(hardRebootButton, "cell 9 1,growx"); ribbonSeparator_2 = new JRibbonSeparator(); vmPanel.add(ribbonSeparator_2, "cell 11 0 1 3,grow"); macroButton = new JRibbonBigButton("Macro"); macroButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/code.png"))); macroButton.setVerticalTextPosition(SwingConstants.BOTTOM); macroButton.setHorizontalTextPosition(SwingConstants.CENTER); vmPanel.add(macroButton, "cell 12 0 1 3,growy"); snapshotButton = new JRibbonButton("Snapshot"); snapshotButton.setHorizontalAlignment(SwingConstants.LEFT); snapshotButton.setIcon( new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/application_cascade.png"))); vmPanel.add(snapshotButton, "cell 3 2,growx"); advanceButton = new JRibbonButton("Advance"); advanceButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); advanceButton.setHorizontalAlignment(SwingConstants.LEFT); advanceButton.setIcon(new ImageIcon( MainFrame.class.getResource("/com/titan/image/famfamfam/application_view_detail.png"))); vmPanel.add(advanceButton, "cell 9 2,growx"); executionMapButton = new JRibbonButton("Execution map"); executionMapButton.setIcon( new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/chart_organisation.png"))); executionMapButton.setHorizontalAlignment(SwingConstants.LEFT); vmPanel.add(executionMapButton, "cell 13 2,growx"); keystonePanel = new JRibbonPanel(); ribbonTabbedPane.addTab("Keystone", null, keystonePanel, null); keystonePanel.setLayout(new MigLayout("", "[][][][][][][][][][]", "[grow][][][][]")); addUserButton = new JRibbonBigButton("Add user"); addUserButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0); keystonePanel.addUser(); } }); addUserButton.setVerticalTextPosition(SwingConstants.BOTTOM); addUserButton.setHorizontalTextPosition(SwingConstants.CENTER); addUserButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/addUser.png"))); keystonePanel.add(addUserButton, "cell 0 0 1 3,growy"); editUserButton = new JRibbonButton("Edit user"); editUserButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); editUserButton.setHorizontalAlignment(SwingConstants.LEFT); editUserButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/pencil.png"))); keystonePanel.add(editUserButton, "cell 1 0,growx"); changePasswordButton = new JRibbonButton("Change password"); keystonePanel.add(changePasswordButton, "cell 2 0"); ribbonSeparator_4 = new JRibbonSeparator(); keystonePanel.add(ribbonSeparator_4, "cell 3 0 1 3,growy"); addRoleButton = new JRibbonBigButton("Add role"); addRoleButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0); keystonePanel.addRole(); } }); addRoleButton.setVerticalTextPosition(SwingConstants.BOTTOM); addRoleButton.setHorizontalTextPosition(SwingConstants.CENTER); addRoleButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/addRole.png"))); keystonePanel.add(addRoleButton, "cell 4 0 1 3,growy"); deleteUserButton = new JRibbonButton("Delete user"); deleteUserButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); deleteUserButton.setHorizontalAlignment(SwingConstants.LEFT); deleteUserButton .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png"))); editRoleButton = new JRibbonButton("Edit role"); editRoleButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); editRoleButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/pencil.png"))); editRoleButton.setHorizontalAlignment(SwingConstants.LEFT); keystonePanel.add(editRoleButton, "cell 5 0,growx"); ribbonSeparator_5 = new JRibbonSeparator(); keystonePanel.add(ribbonSeparator_5, "cell 6 0 1 3,growy"); createTenantButton = new JRibbonBigButton("Create tenant"); createTenantButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0); keystonePanel.createTenant(); } }); createTenantButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/add.png"))); createTenantButton.setVerticalTextPosition(SwingConstants.BOTTOM); createTenantButton.setHorizontalTextPosition(SwingConstants.CENTER); keystonePanel.add(createTenantButton, "cell 7 0 1 3,growy"); deleteTenantButton = new JRibbonBigButton("Delete tenant"); deleteTenantButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0); keystonePanel.deleteTenant(); } }); deleteTenantButton .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/delete.png"))); deleteTenantButton.setVerticalTextPosition(SwingConstants.BOTTOM); deleteTenantButton.setHorizontalTextPosition(SwingConstants.CENTER); keystonePanel.add(deleteTenantButton, "cell 8 0 1 3,growy"); keystonePanel.add(deleteUserButton, "cell 1 1,growx"); detailUserButton = new JRibbonButton("Detail user"); detailUserButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0); keystonePanel.showUserDetail(); } }); detailUserButton.setHorizontalAlignment(SwingConstants.LEFT); detailUserButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/zoom.png"))); keystonePanel.add(detailUserButton, "cell 1 2,growx"); btnDeleteRole = new JRibbonButton("Delete role"); btnDeleteRole.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0); keystonePanel.deleteRole(); } }); btnDeleteRole.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png"))); keystonePanel.add(btnDeleteRole, "cell 5 1,growx"); assignRoleButton = new JRibbonButton("Assign role"); assignRoleButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { KeystonePanel keystonePanel = (KeystonePanel) mainContentPanel.getComponent(0); keystonePanel.assignRole(); } }); assignRoleButton.setSelectedIcon( new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/user_add.png"))); keystonePanel.add(assignRoleButton, "cell 5 2,growx"); lblUser = new JRibbonLabel("user"); keystonePanel.add(lblUser, "cell 0 3 2 1,growx"); rbnlblRole = new JRibbonLabel("role"); keystonePanel.add(rbnlblRole, "cell 4 3 2 1,growx"); rbnlblTenant = new JRibbonLabel(); rbnlblTenant.setText("tenant"); keystonePanel.add(rbnlblTenant, "cell 7 3 2 1,growx"); flavorPanel = new JRibbonPanel(); ribbonTabbedPane.addTab("Flavor", null, flavorPanel, null); flavorPanel.setLayout(new MigLayout("", "[][]", "[grow][][][]")); rbnbgbtnCreateFlavor = new JRibbonBigButton(); rbnbgbtnCreateFlavor.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/add.png"))); rbnbgbtnCreateFlavor.setText("Create Flavor"); flavorPanel.add(rbnbgbtnCreateFlavor, "cell 0 0 1 3,growy"); btnDeleteFlavor = new JRibbonBigButton("Delete Flavor"); btnDeleteFlavor.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/delete.png"))); flavorPanel.add(btnDeleteFlavor, "cell 1 0 1 3,growy"); storagePanel = new JRibbonPanel(); ribbonTabbedPane.addTab("Storage", null, storagePanel, null); storagePanel.setLayout(new MigLayout("", "[][][][][][]", "[grow][][][]")); uploadImageButton = new JRibbonBigButton("Upload"); uploadImageButton.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/add.png"))); uploadImageButton.setVerticalTextPosition(SwingConstants.BOTTOM); uploadImageButton.setHorizontalTextPosition(SwingConstants.CENTER); storagePanel.add(uploadImageButton, "cell 0 0 1 3, growy"); btnDelete = new JRibbonButton("Delete"); btnDelete.setHorizontalAlignment(SwingConstants.LEFT); btnDelete.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png"))); storagePanel.add(btnDelete, "cell 1 0,growx"); ribbonSeparator_6 = new JRibbonSeparator(); storagePanel.add(ribbonSeparator_6, "cell 2 0 1 3,grow"); btnCreateVolume = new JRibbonBigButton("Create volume"); btnCreateVolume.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/add.png"))); btnCreateVolume.setVerticalTextPosition(SwingConstants.BOTTOM); btnCreateVolume.setHorizontalTextPosition(SwingConstants.CENTER); storagePanel.add(btnCreateVolume, "cell 3 0 1 3,growy"); btnDelete_1 = new JRibbonButton("Delete"); btnDelete_1.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png"))); btnDelete_1.setHorizontalAlignment(SwingConstants.LEFT); storagePanel.add(btnDelete_1, "cell 4 0,growx"); btnAttach = new JRibbonButton("Attach to vm"); btnAttach.setHorizontalAlignment(SwingConstants.LEFT); btnAttach.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/attach.png"))); storagePanel.add(btnAttach, "cell 5 0,growx"); btnChangeName = new JRibbonButton("Change name"); btnChangeName.setHorizontalAlignment(SwingConstants.LEFT); btnChangeName.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/pencil.png"))); storagePanel.add(btnChangeName, "cell 1 1,growx"); btnDetail = new JRibbonButton("Detail"); btnDetail.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/zoom.png"))); btnDetail.setHorizontalAlignment(SwingConstants.LEFT); storagePanel.add(btnDetail, "cell 4 1,growx"); btnDetachToVm = new JRibbonButton("Detach to vm"); btnDetachToVm.setHorizontalAlignment(SwingConstants.LEFT); btnDetachToVm.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/delete.png"))); storagePanel.add(btnDetachToVm, "cell 5 1,growx"); btnPublicprivate = new JRibbonButton("public/private"); btnPublicprivate.setHorizontalAlignment(SwingConstants.LEFT); btnPublicprivate.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/tick.png"))); storagePanel.add(btnPublicprivate, "cell 1 2,growx"); btnAddVolumeType = new JRibbonButton("Add volume type"); btnAddVolumeType.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/add.png"))); btnAddVolumeType.setHorizontalAlignment(SwingConstants.LEFT); storagePanel.add(btnAddVolumeType, "cell 4 2"); btnDeleteVolumeType = new JRibbonButton("Delete volume type"); btnDeleteVolumeType .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png"))); btnDeleteVolumeType.setHorizontalAlignment(SwingConstants.LEFT); storagePanel.add(btnDeleteVolumeType, "cell 5 2"); rbnlblImage = new JRibbonLabel(); rbnlblImage.setText("Image"); storagePanel.add(rbnlblImage, "cell 0 3 2 1,growx"); rbnlblVolume = new JRibbonLabel(); rbnlblVolume.setText("Volume"); storagePanel.add(rbnlblVolume, "cell 3 3 3 1,growx"); networkPanel = new JRibbonPanel(); ribbonTabbedPane.addTab("Network", null, networkPanel, null); settingPanel = new JRibbonPanel(); ribbonTabbedPane.addTab("Setting", null, settingPanel, null); settingPanel.setLayout(new MigLayout("", "[][][]", "[grow][grow][]")); rbnbgbtnSystemSetting = new JRibbonBigButton(); rbnbgbtnSystemSetting .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/systemSetting.png"))); rbnbgbtnSystemSetting.setText("System Setting"); settingPanel.add(rbnbgbtnSystemSetting, "cell 0 0 1 3,growy"); rbnbgbtnDatabase = new JRibbonBigButton(); rbnbgbtnDatabase .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/ribbon/database.png"))); rbnbgbtnDatabase.setText("Database"); settingPanel.add(rbnbgbtnDatabase, "cell 1 0 1 3,growy"); rbnbtnAddGroup = new JRibbonButton(); rbnbtnAddGroup.setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/add.png"))); rbnbtnAddGroup.setText("Add Group"); settingPanel.add(rbnbtnAddGroup, "cell 2 0"); rbnbtnEditGroup = new JRibbonButton(); rbnbtnEditGroup .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/pencil.png"))); rbnbtnEditGroup.setText("Edit Group"); settingPanel.add(rbnbtnEditGroup, "cell 2 1"); rbnbtnDeleteGroup = new JRibbonButton(); rbnbtnDeleteGroup .setIcon(new ImageIcon(MainFrame.class.getResource("/com/titan/image/famfamfam/cross.png"))); rbnbtnDeleteGroup.setText("Delete Group"); settingPanel.add(rbnbtnDeleteGroup, "cell 2 2"); logoPanel = new JRibbonPanel(); ribbonPanel.add(logoPanel, BorderLayout.WEST); logoPanel.setLayout(new BorderLayout(0, 0)); logoPanel.add(logoLabel, BorderLayout.CENTER); setLocationRelativeTo(null); new Thread(new TitanServerUpdateThread()).start(); }
From source file:edu.harvard.i2b2.query.ui.MainPanel.java
public void addPanel() { int rightmostPosition = dataModel.lastLabelPosition(); JLabel label = new JLabel(); label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); label.setText("and"); label.setToolTipText("Click to change the relationship"); label.setBorder(javax.swing.BorderFactory.createEtchedBorder()); label.addMouseListener(new java.awt.event.MouseAdapter() { @Override/*from ww w . ja v a2 s . c o m*/ public void mouseClicked(java.awt.event.MouseEvent evt) { jAndOrLabelMouseClicked(evt); } }); // jPanel1.add(label); // label.setBounds(rightmostPosition, 90, 30, 18); GroupPanel panel = new GroupPanel("Group " + (dataModel.getCurrentPanelCount() + 1), this); jPanel1.add(panel); panel.setBounds(rightmostPosition + 5, 0, 180, getParent().getHeight() - 100); jPanel1.setPreferredSize(new Dimension(rightmostPosition + 5 + 181 + 60, getHeight() - 100)); jScrollPane4.setViewportView(jPanel1); dataModel.addPanel(panel, label, rightmostPosition + 5 + 180); jScrollPane4.getHorizontalScrollBar().setValue(jScrollPane4.getHorizontalScrollBar().getMaximum()); jScrollPane4.getHorizontalScrollBar().setUnitIncrement(40); resizePanels(getParent().getWidth(), getParent().getHeight()); }
From source file:edu.harvard.i2b2.query.ui.MainPanel.java
private void jMorePanelsButtonActionPerformed(java.awt.event.ActionEvent evt) { if (dataModel.hasEmptyPanels()) { JOptionPane.showMessageDialog(this, "Please use an existing empty panel before adding a new one."); return;//from ww w.j av a 2 s . com } int rightmostPosition = dataModel.lastLabelPosition(); JLabel label = new JLabel(); label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); label.setText("and"); label.setToolTipText("Click to change the relationship"); label.setBorder(javax.swing.BorderFactory.createEtchedBorder()); label.addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mouseClicked(java.awt.event.MouseEvent evt) { jAndOrLabelMouseClicked(evt); } }); GroupPanel panel = new GroupPanel("Group " + (dataModel.getCurrentPanelCount() + 1), this); jPanel1.add(panel); panel.setBounds(rightmostPosition + 5, 0, 180, getParent().getHeight() - 100); jPanel1.setPreferredSize(new Dimension(rightmostPosition + 5 + 181 + 60, getHeight() - 100)); jScrollPane4.setViewportView(jPanel1); dataModel.addPanel(panel, label, rightmostPosition + 5 + 180); /* * System.out.println(jScrollPane4.getViewport().getExtentSize().width+":" * + jScrollPane4.getViewport().getExtentSize().height); * System.out.println * (jScrollPane4.getHorizontalScrollBar().getVisibleRect().width+":" * +jScrollPane4.getHorizontalScrollBar().getVisibleRect().height); * System * .out.println(jScrollPane4.getHorizontalScrollBar().getVisibleAmount * ()); * System.out.println(jScrollPane4.getHorizontalScrollBar().getValue()); */ jScrollPane4.getHorizontalScrollBar().setValue(jScrollPane4.getHorizontalScrollBar().getMaximum()); jScrollPane4.getHorizontalScrollBar().setUnitIncrement(40); // this.jScrollPane4.removeAll(); // this.jScrollPane4.setViewportView(jPanel1); // revalidate(); // jScrollPane3.setBounds(420, 0, 170, 300); // jScrollPane4.setBounds(20, 35, 335, 220); resizePanels(getParent().getWidth(), getParent().getHeight()); }
From source file:edu.ku.brc.specify.plugins.PartialDateUI.java
@Override public void setParent(final FormViewObj parent) { this.parent = parent; JLabel lbl = parent.getLabelFor(this); if (lbl != null && StringUtils.isNotEmpty(dateFieldName)) { DBTableInfo tblInfo = DBTableIdMgr.getInstance().getByClassName(parent.getView().getClassName()); if (tblInfo != null) { final DBFieldInfo fi = tblInfo.getFieldByName(dateFieldName); if (fi != null) { title = fi.getTitle();/* w w w . ja v a 2 s.c om*/ isRequired = fi.isRequired(); if (uivs[0] instanceof ValFormattedTextFieldSingle) { ((ValFormattedTextFieldSingle) uivs[0]).setRequired(isRequired); } else { for (UIValidatable uiv : uivs) { ((ValFormattedTextField) uiv).setRequired(isRequired); } } if (StringUtils.isNotEmpty(fi.getTitle())) { lbl.setText(fi.getTitle() + ":"); if (isRequired) { lbl.setFont(lbl.getFont().deriveFont(Font.BOLD)); } } if (lbl != null) { lbl.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { super.mouseClicked(e); if (e.getClickCount() == 2) { JOptionPane.showMessageDialog(UIRegistry.getMostRecentWindow(), "<html>" + fi.getDescription(), UIRegistry.getResourceString("FormViewObj.UNOTES"), JOptionPane.INFORMATION_MESSAGE); } } }); } } else { log.error("PartialDateUI - Couldn't find date field [" + dateFieldName + "] in data obj View: " + parent.getView().getName()); } } } }
From source file:gui.GW2EventerGui.java
/** * Creates new form GW2EventerGui//w w w .j a va2 s.c o m */ public GW2EventerGui() { this.guiIcon = new ImageIcon(ClassLoader.getSystemResource("media/icon.png")).getImage(); if (System.getProperty("os.name").startsWith("Windows")) { this.OS = "Windows"; this.isWindows = true; } else { this.OS = "Other"; this.isWindows = false; } if (this.isWindows == true) { this.checkIniDir(); } initComponents(); this.speakQueue = new LinkedList(); this.speakRunnable = new Runnable() { @Override public void run() { String path = System.getProperty("user.home") + "\\.gw2eventer"; File f; String sentence; while (!speakQueue.isEmpty()) { f = new File(path + "\\tts.vbs"); if (!f.exists() && !f.isDirectory()) { sentence = (String) speakQueue.poll(); try { Writer writer = new OutputStreamWriter( new FileOutputStream( System.getProperty("user.home") + "\\.gw2eventer\\tts.vbs"), "ISO-8859-15"); BufferedWriter fout = new BufferedWriter(writer); fout.write("Dim Speak"); fout.newLine(); fout.write("Set Speak=CreateObject(\"sapi.spvoice\")"); fout.newLine(); fout.write("Speak.Speak \"" + sentence + "\""); fout.close(); Runtime rt = Runtime.getRuntime(); try { if (sentence.length() > 0) { Process p = rt.exec(System.getProperty("user.home") + "\\.gw2eventer\\tts.bat"); } } catch (IOException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } } catch (FileNotFoundException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } try { Thread.sleep(3000); } catch (InterruptedException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } } else { try { Thread.sleep(1000); } catch (InterruptedException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } } } } }; this.matchIds = new HashMap(); this.matchId = "2-6"; this.matchIdColor = "green"; this.jLabelNewVersion.setVisible(false); this.updateInformed = false; Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation(screenSize.width / 2 - this.getSize().width / 2, (screenSize.height / 2 - this.getSize().height / 2) - 20); double width = screenSize.getWidth(); double height = screenSize.getHeight(); if ((width == 1280) && (height == 720 || height == 768 || height == 800)) { this.setExtendedState(this.MAXIMIZED_BOTH); //this.setLocation(0, 0); } JSpinner.NumberEditor jsEditor = (JSpinner.NumberEditor) this.jSpinnerRefreshTime.getEditor(); DefaultFormatter formatter = (DefaultFormatter) jsEditor.getTextField().getFormatter(); formatter.setAllowsInvalid(false); /* jsEditor = (JSpinner.NumberEditor)this.jSpinnerOverlayX.getEditor(); formatter = (DefaultFormatter) jsEditor.getTextField().getFormatter(); formatter.setAllowsInvalid(false); jsEditor = (JSpinner.NumberEditor)this.jSpinnerOverlayY.getEditor(); formatter = (DefaultFormatter) jsEditor.getTextField().getFormatter(); formatter.setAllowsInvalid(false); */ this.workingButton = this.jButtonRefresh; this.refreshSelector = this.jCheckBoxAutoRefresh; this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { apiManager.saveSettingstoFile(); System.exit(0); } }); this.pushGui = new PushGui(this, true, "", ""); this.pushGui.setIconImage(guiIcon); this.donateGui = new DonateGui(this, true); this.donateGui.setIconImage(guiIcon); this.infoGui = new InfoGui(this, true); this.infoGui.setIconImage(guiIcon); this.feedbackGui = new FeedbackGui(this, true); this.feedbackGui.setIconImage(guiIcon); this.overlayGui = new OverlayGui(this); this.initOverlayGui(); this.settingsOverlayGui = new SettingsOverlayGui(this); this.initSettingsOverlayGui(); this.wvwOverlayGui = new WvWOverlayGui(this); this.initWvwOverlayGui(); this.language = "en"; this.worldID = "2206"; //Millersund [DE] this.setTranslations(); this.eventLabels = new ArrayList(); this.eventLabelsTimer = new ArrayList(); this.homeWorlds = new HashMap(); this.preventSystemSleep = true; for (int i = 1; i <= EVENT_COUNT; i++) { try { Field f = getClass().getDeclaredField("labelEvent" + i); JLabel l = (JLabel) f.get(this); l.setPreferredSize(new Dimension(70, 28)); //l.setToolTipText(""); //int width2 = l.getX(); //int height2 = l.getY(); //System.out.println("$coords .= \"{\\\"x\\\": \\\""+ width2 + "\\\", \\\"y\\\": \\\""+ height2 + "\\\"},\\n\";"); this.eventLabels.add(l); final int ii = i; l.addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mousePressed(java.awt.event.MouseEvent evt) { showSoundSelector(ii); } }); f = getClass().getDeclaredField("labelTimer" + i); l = (JLabel) f.get(this); l.setEnabled(true); l.setVisible(false); l.setForeground(Color.green); //int width2 = l.getX(); //int height2 = l.getY(); //System.out.println("$coords2 .= \"{\\\"x\\\": \\\""+ width2 + "\\\", \\\"y\\\": \\\""+ height2 + "\\\"},\\n\";"); this.eventLabelsTimer.add(l); } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } } int[] disabledEvents = { 6, 8, 11, 12, 17, 18, 19, 20, 21, 22 }; for (int i = 0; i < disabledEvents.length; i++) { Field f; JLabel l; try { f = getClass().getDeclaredField("labelEvent" + disabledEvents[i]); l = (JLabel) f.get(this); l.setEnabled(false); l.setVisible(false); f = getClass().getDeclaredField("labelTimer" + disabledEvents[i]); l = (JLabel) f.get(this); l.setEnabled(false); l.setVisible(false); } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } } this.lastPush = new Date(); if (this.apiManager == null) { this.apiManager = new ApiManager(this, this.jSpinnerRefreshTime, this.jCheckBoxAutoRefresh.isSelected(), this.eventLabels, this.language, this.worldID, this.homeWorlds, this.jComboBoxHomeWorld, this.jLabelServer, this.jLabelWorking, this.jCheckBoxPlaySounds.isSelected(), this.workingButton, this.refreshSelector, this.eventLabelsTimer, this.jComboBoxLanguage, this.overlayGui, this.jCheckBoxWvWOverlay); } //this.wvwMatchReader = new WvWMatchReader(this.matchIds, this.jCheckBoxWvW); //this.wvwMatchReader.start(); this.preventSleepMode(); this.runUpdateService(); this.runPushService(); this.runTips(); //this.runTest(); }
From source file:userinterface.properties.GUIGraphHandler.java
public void plotNewFunction() { JDialog dialog;/* w ww. j av a 2s . c o m*/ JRadioButton radio2d, radio3d, newGraph, existingGraph; JTextField functionField, seriesName; JButton ok, cancel; JComboBox<String> chartOptions; JLabel example; //init all the fields of the dialog dialog = new JDialog(GUIPrism.getGUI()); radio2d = new JRadioButton("2D"); radio3d = new JRadioButton("3D"); newGraph = new JRadioButton("New Graph"); existingGraph = new JRadioButton("Exisiting"); chartOptions = new JComboBox<String>(); functionField = new JTextField(); ok = new JButton("Plot"); cancel = new JButton("Cancel"); seriesName = new JTextField(); example = new JLabel("<html><font size=3 color=red>Example:</font><font size=3>x/2 + 5</font></html>"); example.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { example.setCursor(new Cursor(Cursor.HAND_CURSOR)); example.setForeground(Color.BLUE); } @Override public void mouseExited(MouseEvent e) { example.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); example.setForeground(Color.BLACK); } @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (radio2d.isSelected()) { functionField.setText("x/2 + 5"); } else { functionField.setText("x+y+5"); } functionField.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); functionField.setForeground(Color.BLACK); } } }); //set dialog properties dialog.setSize(400, 350); dialog.setTitle("Plot a new function"); dialog.setModal(true); dialog.setLayout(new BoxLayout(dialog.getContentPane(), BoxLayout.Y_AXIS)); dialog.setLocationRelativeTo(GUIPrism.getGUI()); //add every component to their dedicated panels JPanel graphTypePanel = new JPanel(new FlowLayout()); graphTypePanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Function type")); graphTypePanel.add(radio2d); graphTypePanel.add(radio3d); JPanel functionFieldPanel = new JPanel(new BorderLayout()); functionFieldPanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Function")); functionFieldPanel.add(functionField, BorderLayout.CENTER); functionFieldPanel.add(example, BorderLayout.SOUTH); JPanel chartSelectPanel = new JPanel(); chartSelectPanel.setLayout(new BoxLayout(chartSelectPanel, BoxLayout.Y_AXIS)); chartSelectPanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Plot function to")); JPanel radioPlotPanel = new JPanel(new FlowLayout()); radioPlotPanel.add(newGraph); radioPlotPanel.add(existingGraph); JPanel chartOptionsPanel = new JPanel(new FlowLayout()); chartOptionsPanel.add(chartOptions); chartSelectPanel.add(radioPlotPanel); chartSelectPanel.add(chartOptionsPanel); JPanel bottomControlPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); bottomControlPanel.add(ok); bottomControlPanel.add(cancel); JPanel seriesNamePanel = new JPanel(new BorderLayout()); seriesNamePanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Series name")); seriesNamePanel.add(seriesName, BorderLayout.CENTER); // add all the panels to the dialog dialog.add(graphTypePanel); dialog.add(functionFieldPanel); dialog.add(chartSelectPanel); dialog.add(seriesNamePanel); dialog.add(bottomControlPanel); // do all the enables and set properties radio2d.setSelected(true); newGraph.setSelected(true); chartOptions.setEnabled(false); functionField.setText("Add function expression here...."); functionField.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 15)); functionField.setForeground(Color.GRAY); seriesName.setText("New function"); ok.setMnemonic('P'); cancel.setMnemonic('C'); example.setToolTipText("click to try out"); ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok"); ok.getActionMap().put("ok", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { ok.doClick(); } }); cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); cancel.getActionMap().put("cancel", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { cancel.doClick(); } }); boolean found = false; for (int i = 0; i < theTabs.getTabCount(); i++) { if (theTabs.getComponentAt(i) instanceof Graph) { chartOptions.addItem(getGraphName(i)); found = true; } } if (!found) { existingGraph.setEnabled(false); chartOptions.setEnabled(false); } //add all the action listeners radio2d.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (radio2d.isSelected()) { radio3d.setSelected(false); if (chartOptions.getItemCount() > 0) { existingGraph.setEnabled(true); chartOptions.setEnabled(true); } example.setText( "<html><font size=3 color=red>Example:</font><font size=3>x/2 + 5</font></html>"); } } }); radio3d.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (radio3d.isSelected()) { radio2d.setSelected(false); newGraph.setSelected(true); existingGraph.setEnabled(false); chartOptions.setEnabled(false); example.setText("<html><font size=3 color=red>Example:</font><font size=3>x+y+5</font></html>"); } } }); newGraph.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (newGraph.isSelected()) { existingGraph.setSelected(false); chartOptions.setEnabled(false); } } }); existingGraph.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (existingGraph.isSelected()) { newGraph.setSelected(false); chartOptions.setEnabled(true); } } }); ok.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String function = functionField.getText(); Expression expr = null; try { expr = GUIPrism.getGUI().getPrism().parseSingleExpressionString(function); expr = (Expression) expr.accept(new ASTTraverseModify() { @Override public Object visit(ExpressionIdent e) throws PrismLangException { return new ExpressionConstant(e.getName(), TypeDouble.getInstance()); } }); expr.typeCheck(); expr.semanticCheck(); } catch (PrismLangException e1) { // for copying style JLabel label = new JLabel(); // html content in our case the error we want to show JEditorPane ep = new JEditorPane("text/html", "<html> There was an error parsing the function. To read about what built-in" + " functions are supported <br>and some more information on the functions, visit " + "<a href='http://www.prismmodelchecker.org/manual/ThePRISMLanguage/Expressions'>Prism expressions site</a>." + "<br><br><font color=red>Error: </font>" + e1.getMessage() + " </html>"); // handle link events ep.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (IOException | URISyntaxException e1) { e1.printStackTrace(); } } } }); ep.setEditable(false); ep.setBackground(label.getBackground()); // show the error dialog JOptionPane.showMessageDialog(dialog, ep, "Parse Error", JOptionPane.ERROR_MESSAGE); return; } if (radio2d.isSelected()) { ParametricGraph graph = null; if (newGraph.isSelected()) { graph = new ParametricGraph(""); } else { for (int i = 0; i < theTabs.getComponentCount(); i++) { if (theTabs.getTitleAt(i).equals(chartOptions.getSelectedItem())) { graph = (ParametricGraph) theTabs.getComponent(i); } } } dialog.dispose(); defineConstantsAndPlot(expr, graph, seriesName.getText(), newGraph.isSelected(), true); } else if (radio3d.isSelected()) { try { expr = (Expression) expr.accept(new ASTTraverseModify() { @Override public Object visit(ExpressionIdent e) throws PrismLangException { return new ExpressionConstant(e.getName(), TypeDouble.getInstance()); } }); expr.semanticCheck(); expr.typeCheck(); } catch (PrismLangException e1) { e1.printStackTrace(); } if (expr.getAllConstants().size() < 2) { JOptionPane.showMessageDialog(dialog, "There are not enough variables in the function to plot a 3D chart!", "Error", JOptionPane.ERROR_MESSAGE); return; } // its always a new graph ParametricGraph3D graph = new ParametricGraph3D(expr); dialog.dispose(); defineConstantsAndPlot(expr, graph, seriesName.getText(), true, false); } dialog.dispose(); } }); cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); // we will show info about the function when field is out of focus functionField.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { if (!functionField.getText().equals("")) { return; } functionField.setText("Add function expression here...."); functionField.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 15)); functionField.setForeground(Color.GRAY); } @Override public void focusGained(FocusEvent e) { if (!functionField.getText().equals("Add function expression here....")) { return; } functionField.setForeground(Color.BLACK); functionField.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); functionField.setText(""); } }); // show the dialog dialog.setVisible(true); }
From source file:Clavis.Windows.WShedule.java
public synchronized void create() { initComponents();// www . ja va 2 s. c o m this.setModal(true); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { close(); } }); this.setTitle(lingua.translate("Registos de emprstimo para o recurso") + ": " + lingua.translate(mat.getTypeOfMaterialName()).toLowerCase() + " " + lingua.translate(mat.getDescription())); KeyQuest.addtoPropertyListener(jPanelInicial, true); String dat = new TimeDate.Date().toString(); String[] auxiliar = prefs.get("datainicio", dat).split("/"); if (auxiliar[0].length() > 1) { if (auxiliar[0].charAt(0) == '0') { auxiliar[0] = auxiliar[0].replaceFirst("0", ""); } } if (auxiliar[1].length() > 1) { if (auxiliar[1].charAt(0) == '0') { auxiliar[1] = auxiliar[1].replaceFirst("0", ""); } } if (auxiliar[2].length() > 1) { if (auxiliar[2].charAt(0) == '0') { auxiliar[2] = auxiliar[2].replaceFirst("0", ""); } } inicio = new TimeDate.Date(Integer.valueOf(auxiliar[0]), Integer.valueOf(auxiliar[1]), Integer.valueOf(auxiliar[2])); auxiliar = prefs.get("datafim", dat).split("/"); if (auxiliar[0].length() > 1) { if (auxiliar[0].charAt(0) == '0') { auxiliar[0] = auxiliar[0].replaceFirst("0", ""); } } if (auxiliar[1].length() > 1) { if (auxiliar[1].charAt(0) == '0') { auxiliar[1] = auxiliar[1].replaceFirst("0", ""); } } if (auxiliar[2].length() > 1) { if (auxiliar[2].charAt(0) == '0') { auxiliar[2] = auxiliar[2].replaceFirst("0", ""); } } fim = new TimeDate.Date(Integer.valueOf(auxiliar[0]), Integer.valueOf(auxiliar[1]), Integer.valueOf(auxiliar[2])); SimpleDateFormat sdf = new SimpleDateFormat("dd/M/yyyy"); Date date; try { date = sdf.parse(fim.toString()); } catch (ParseException ex) { date = new Date(); } jXDatePickerFim.setDate(date); try { date = sdf.parse(inicio.toString()); } catch (ParseException ex) { date = new Date(); } jXDatePickerInicio.setDate(date); andamento = 0; if (DataBase.DataBase.testConnection(url)) { DataBase.DataBase db = new DataBase.DataBase(url); java.util.List<Keys.Request> requisicoes = Clavis.RequestList .simplifyRequests(db.getRequestsByMaterialByDateInterval(mat, inicio, fim)); db.close(); estado = lingua.translate("Todos"); DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel(); if (requisicoes.size() > 0) { valores = new String[requisicoes.size()][4]; lista = new java.util.ArrayList<>(); requisicoes.stream().map((req) -> { if (mat.getMaterialTypeID() == 1) { valores[andamento][0] = req.getPerson().getName(); valores[andamento][1] = req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0); valores[andamento][2] = req.getBeginDate().toString(); String[] multipla = req.getActivity().split(":::"); if (multipla.length > 1) { Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); valores[andamento][3] = lingua.translate(multipla[0]) + ""; } else { valores[andamento][3] = lingua.translate(req.getActivity()); } if (valores[andamento][3].equals("")) { valores[andamento][3] = lingua.translate("Sem descrio"); } Object[] ob = { req.getPerson().getName(), req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0), req.getBeginDate().toString(), valores[andamento][3], req.getSubject().getName() }; modelo.addRow(ob); } else { valores[andamento][0] = req.getPerson().getName(); valores[andamento][1] = req.getBeginDate().toString(); valores[andamento][2] = req.getEndDate().toString(); String[] multipla = req.getActivity().split(":::"); if (multipla.length > 1) { Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); valores[andamento][3] = multipla[0]; } else { valores[andamento][3] = lingua.translate(req.getActivity()); } if (valores[andamento][3].equals("")) { valores[andamento][3] = lingua.translate("Sem descrio"); } Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(), req.getEndDate().toString(), valores[andamento][3] }; modelo.addRow(ob); } return req; }).map((req) -> { lista.add(req); return req; }).forEach((_item) -> { andamento++; }); } } jComboBoxEstado.setSelectedIndex(prefs.getInt("comboboxvalue", 0)); String[] opcoes = { lingua.translate("Ver detalhes da requisio"), lingua.translate("Ver requisices com a mesma data"), lingua.translate("Ver requisices com o mesmo estado") }; ActionListener[] eventos = new ActionListener[opcoes.length]; eventos[0] = (ActionEvent r) -> { Border border = BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(new org.jdesktop.swingx.border.DropShadowBorder(Color.BLACK, 3, 0.5f, 6, false, false, true, true), BorderFactory.createLineBorder(Color.BLACK, 1)), BorderFactory.createEmptyBorder(0, 10, 0, 10)); int val = jTable1.getSelectedRow(); Keys.Request req = lista.get(val); javax.swing.JPanel pan = new javax.swing.JPanel(null); pan.setPreferredSize(new Dimension(500, 300)); pan.setBounds(0, 20, 500, 400); pan.setBackground(Components.MessagePane.BACKGROUND_COLOR); javax.swing.JLabel lrecurso1 = new javax.swing.JLabel(lingua.translate("Recurso") + ": "); lrecurso1.setBounds(10, 20, 120, 26); lrecurso1.setFocusable(true); lrecurso1.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso1); javax.swing.JLabel lrecurso11 = new javax.swing.JLabel( lingua.translate(req.getMaterial().getTypeOfMaterialName()) + " " + lingua.translate(req.getMaterial().getDescription())); lrecurso11.setBounds(140, 20, 330, 26); lrecurso11.setBorder(border); pan.add(lrecurso11); javax.swing.JLabel lrecurso2 = new javax.swing.JLabel(lingua.translate("Utilizador") + ": "); lrecurso2.setBounds(10, 50, 120, 26); lrecurso2.setFocusable(true); lrecurso2.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso2); javax.swing.JLabel lrecurso22 = new javax.swing.JLabel(req.getPerson().getName()); lrecurso22.setBounds(140, 50, 330, 26); lrecurso22.setBorder(border); pan.add(lrecurso22); javax.swing.JLabel lrecurso3 = new javax.swing.JLabel(lingua.translate("Data inicial") + ": "); lrecurso3.setBounds(10, 80, 120, 26); lrecurso3.setFocusable(true); lrecurso3.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso3); javax.swing.JLabel lrecurso33 = new javax.swing.JLabel( req.getBeginDate().toStringWithMonthWord(lingua)); lrecurso33.setBounds(140, 80, 330, 26); lrecurso33.setBorder(border); pan.add(lrecurso33); javax.swing.JLabel lrecurso4 = new javax.swing.JLabel(lingua.translate("Data final") + ": "); lrecurso4.setBounds(10, 110, 120, 26); lrecurso4.setFocusable(true); lrecurso4.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso4); javax.swing.JLabel lrecurso44 = new javax.swing.JLabel(req.getEndDate().toStringWithMonthWord(lingua)); lrecurso44.setBounds(140, 110, 330, 26); lrecurso44.setBorder(border); pan.add(lrecurso44); javax.swing.JLabel lrecurso5 = new javax.swing.JLabel(lingua.translate("Atividade") + ": "); lrecurso5.setBounds(10, 140, 120, 26); lrecurso5.setFocusable(true); lrecurso5.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso5); javax.swing.JLabel lrecurso55; if (req.getActivity().equals("")) { lrecurso55 = new javax.swing.JLabel(lingua.translate("Sem descrio")); } else { String[] saux = req.getActivity().split(":::"); String atividade; boolean situacao = false; if (saux.length > 1) { situacao = true; atividade = saux[0]; } else { atividade = req.getActivity(); } if (req.getSubject().getId() > 0) { lrecurso55 = new javax.swing.JLabel( lingua.translate(atividade) + ": " + req.getSubject().getName()); } else { lrecurso55 = new javax.swing.JLabel(lingua.translate(atividade)); } if (situacao) { Components.PopUpMenu pop = new Components.PopUpMenu(saux, lingua); pop.create(); lrecurso55.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { pop.show(e.getComponent(), e.getX(), e.getY()); } @Override public void mouseExited(MouseEvent e) { pop.setVisible(false); } }); } } lrecurso55.setBounds(140, 140, 330, 26); lrecurso55.setBorder(border); pan.add(lrecurso55); int distancia = 170; if (req.getBeginDate().isBigger(req.getEndDate()) == 0) { javax.swing.JLabel lrecurso6 = new javax.swing.JLabel(lingua.translate("Horrio") + ": "); lrecurso6.setBounds(10, distancia, 120, 26); lrecurso6.setFocusable(true); lrecurso6.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso6); javax.swing.JLabel lrecurso66 = new javax.swing.JLabel( req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0)); lrecurso66.setBounds(140, distancia, 330, 26); lrecurso66.setBorder(border); pan.add(lrecurso66); distancia = 200; } if (req.getBeginDate().isBigger(req.getEndDate()) == 0) { javax.swing.JLabel lrecurso7 = new javax.swing.JLabel(lingua.translate("Dia da semana") + ": "); lrecurso7.setBounds(10, distancia, 120, 26); lrecurso7.setFocusable(true); lrecurso7.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso7); javax.swing.JLabel lrecurso77 = new javax.swing.JLabel( lingua.translate(req.getWeekDay().perDayName())); lrecurso77.setBounds(140, distancia, 330, 26); lrecurso77.setBorder(border); pan.add(lrecurso77); if (distancia == 200) { distancia = 230; } else { distancia = 200; } } if (req.isTerminated() || req.isActive()) { javax.swing.JLabel lrecurso8 = new javax.swing.JLabel(lingua.translate("Levantamento") + ": "); lrecurso8.setBounds(10, distancia, 120, 26); lrecurso8.setFocusable(true); lrecurso8.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso8); javax.swing.JLabel lrecurso88; if ((req.getLiftDate() != null) && (req.getLiftTime() != null)) { lrecurso88 = new javax.swing.JLabel(req.getLiftDate().toString() + " " + lingua.translate("s") + " " + req.getLiftTime().toString(0)); } else { lrecurso88 = new javax.swing.JLabel(lingua.translate("sem dados para apresentar")); } lrecurso88.setBounds(140, distancia, 330, 26); lrecurso88.setBorder(border); pan.add(lrecurso88); switch (distancia) { case 200: distancia = 230; break; case 230: distancia = 260; break; default: distancia = 200; break; } } if (req.isTerminated()) { javax.swing.JLabel lrecurso9 = new javax.swing.JLabel(lingua.translate("Entrega") + ": "); lrecurso9.setBounds(10, distancia, 120, 26); lrecurso9.setFocusable(true); lrecurso9.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso9); javax.swing.JLabel lrecurso99; if ((req.getDeliveryDate() != null) && (req.getDeliveryTime() != null)) { lrecurso99 = new javax.swing.JLabel(req.getDeliveryDate().toString() + " " + lingua.translate("s") + " " + req.getDeliveryTime().toString(0)); } else { lrecurso99 = new javax.swing.JLabel(lingua.translate("sem dados para apresentar")); } lrecurso99.setBounds(140, distancia, 330, 26); lrecurso99.setBorder(border); pan.add(lrecurso99); switch (distancia) { case 200: distancia = 230; break; case 230: distancia = 260; break; case 260: distancia = 290; break; default: distancia = 200; break; } } Components.MessagePane mensagem = new Components.MessagePane(this, Components.MessagePane.INFORMACAO, Clavis.KeyQuest.getSystemColor(), lingua.translate(""), 500, 400, pan, "", new String[] { lingua.translate("Voltar") }); mensagem.showMessage(); }; eventos[1] = (ActionEvent r) -> { String val = jTable1.getModel().getValueAt(jTable1.getSelectedRow(), 2).toString(); SimpleDateFormat sdf_auxiliar = new SimpleDateFormat("dd/MM/yyyy"); Date data_auxiliar; try { data_auxiliar = sdf_auxiliar.parse(val); Calendar cal = Calendar.getInstance(); cal.setTime(data_auxiliar); int dia = cal.get(Calendar.DAY_OF_MONTH); int mes = cal.get(Calendar.MONTH) + 1; int ano = cal.get(Calendar.YEAR); inicio = new TimeDate.Date(dia, mes, ano); fim = new TimeDate.Date(dia, mes, ano); } catch (ParseException ex) { data_auxiliar = new Date(); } jXDatePickerFim.setDate(data_auxiliar); jXDatePickerInicio.setDate(data_auxiliar); refreshTable(jComboBoxEstado.getSelectedIndex()); }; eventos[2] = (ActionEvent r) -> { String val = jTable1.getModel().getValueAt(jTable1.getSelectedRow(), 3).toString(); for (int i = 0; i < jComboBoxEstado.getItemCount(); i++) { if (jComboBoxEstado.getItemAt(i).equals(val)) { jComboBoxEstado.setSelectedIndex(i); } } }; KeyStroke[] strokes = new KeyStroke[opcoes.length]; strokes[0] = KeyStroke.getKeyStroke(KeyEvent.VK_R, Event.CTRL_MASK); strokes[1] = KeyStroke.getKeyStroke(KeyEvent.VK_D, Event.CTRL_MASK); strokes[2] = KeyStroke.getKeyStroke(KeyEvent.VK_E, Event.CTRL_MASK); Components.PopUpMenu pop = new Components.PopUpMenu(opcoes, eventos, strokes); pop.create(); mouseaction = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { java.awt.Point ponto = new java.awt.Point(e.getX(), e.getY()); if (jTable1.rowAtPoint(ponto) > -1) { jTable1.setRowSelectionInterval(jTable1.rowAtPoint(ponto), jTable1.rowAtPoint(new java.awt.Point(e.getX(), e.getY()))); } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { if (jTable1.getSelectedRow() >= 0) { java.awt.Point ponto = new java.awt.Point(e.getX(), e.getY()); if (jTable1.rowAtPoint(ponto) > -1) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } } }; jTable1.addMouseListener(mouseaction); }