List of usage examples for java.awt.event MouseAdapter MouseAdapter
MouseAdapter
From source file:ca.sqlpower.swingui.enterprise.client.ServerProjectsManagerPanel.java
/** * This constructor creates a dialog for modifying and loading a project * from a single server designated by the given serverInfo parameter. * //from ww w .j a v a 2 s . c o m * @param serverInfo * Projects will be retrieved from this server based on the * information and displayed. The dialog will allow editing the * security as well as creating and deleting projects on this * server. * @param dialogOwner * The dialog to parent new dialogs to. * @param upf * A user prompter factory for displaying error and warning * messages to users. * @param closeAction * An action that will close the dialog or frame that this dialog * is contained in. * @param defaultFileDirectory * A default file directory to start looking for files in if the * user wants to upload a project. If null this will default to * the user's home directory. * @param cookieStore * A cookie store for HTTP requests. Used by the * {@link ClientSideSessionUtils}. */ public ServerProjectsManagerPanel(SPServerInfo serverInfo, Component dialogOwner, UserPrompterFactory upf, Action closeAction, File defaultFileDirectory, CookieStore cookieStore) { this.serverInfo = serverInfo; this.dialogOwner = dialogOwner; this.upf = upf; this.closeAction = closeAction; this.defaultFileDirectory = defaultFileDirectory; this.cookieStore = cookieStore; cookieStore.clear(); DefaultFormBuilder builder = new DefaultFormBuilder( new FormLayout("pref:grow, 5dlu, pref", "pref, pref, pref")); servers = null; projects = new JList(new DefaultListModel()); projects.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { refreshPanel(); if (e.getClickCount() == 2 && SwingUtilities.isLeftMouseButton(e)) { getOpenAction().actionPerformed(null); } } }); JScrollPane projectsPane = new JScrollPane(projects); projectsPane.setPreferredSize(new Dimension(250, 300)); CellConstraints cc = new CellConstraints(); builder.add(new JLabel(serverInfo.getName() + "'s projects:"), cc.xyw(1, 1, 2)); builder.nextLine(); builder.add(projectsPane, cc.xywh(1, 2, 1, 2)); DefaultFormBuilder buttonBarBuilder = new DefaultFormBuilder(new FormLayout("pref")); buttonBarBuilder.append(new JButton(refreshAction)); buttonBarBuilder.append(securityButton); buttonBarBuilder.append(new JButton(newAction)); buttonBarBuilder.append(openButton); buttonBarBuilder.append(new JButton(deleteAction)); buttonBarBuilder.append(new JButton(closeAction)); builder.add(buttonBarBuilder.getPanel(), cc.xy(3, 2)); builder.setDefaultDialogBorder(); panel = builder.getPanel(); }
From source file:com.mirth.connect.client.ui.DashboardPanel.java
/** * Makes the status table with all current server information. *///from w w w . j a v a 2 s.co m public void makeStatusTable() { List<String> columns = new ArrayList<String>(); for (DashboardColumnPlugin plugin : LoadedExtensions.getInstance().getDashboardColumnPlugins().values()) { if (plugin.isDisplayFirst()) { columns.add(plugin.getColumnHeader()); } } columns.addAll(Arrays.asList(defaultColumns)); for (DashboardColumnPlugin plugin : LoadedExtensions.getInstance().getDashboardColumnPlugins().values()) { if (!plugin.isDisplayFirst()) { columns.add(plugin.getColumnHeader()); } } DashboardTreeTableModel model = new DashboardTreeTableModel(); model.setColumnIdentifiers(columns); model.setNodeFactory(new DefaultDashboardTableNodeFactory()); for (DashboardTablePlugin plugin : LoadedExtensions.getInstance().getDashboardTablePlugins().values()) { dashboardTable = plugin.getTable(); if (dashboardTable != null) { break; } } defaultVisibleColumns.addAll(columns); if (dashboardTable == null) { dashboardTable = new MirthTreeTable("dashboardPanel", defaultVisibleColumns); } dashboardTable.setColumnFactory(new DashboardTableColumnFactory()); dashboardTable.setTreeTableModel(model); dashboardTable.setDoubleBuffered(true); dashboardTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); dashboardTable.setHorizontalScrollEnabled(true); dashboardTable.packTable(UIConstants.COL_MARGIN); dashboardTable.setRowHeight(UIConstants.ROW_HEIGHT); dashboardTable.setOpaque(true); dashboardTable.setRowSelectionAllowed(true); dashboardTable.setSortable(true); dashboardTable.putClientProperty("JTree.lineStyle", "Horizontal"); dashboardTable.setAutoCreateColumnsFromModel(false); dashboardTable.setShowGrid(true, true); dashboardTable.restoreColumnPreferences(); dashboardTable.setMirthColumnControlEnabled(true); dashboardTable.setTreeCellRenderer(new DefaultTreeCellRenderer() { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { JLabel label = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); TreePath path = dashboardTable.getPathForRow(row); if (path != null) { AbstractDashboardTableNode node = ((AbstractDashboardTableNode) path.getLastPathComponent()); if (node.isGroupNode()) { setIcon(UIConstants.ICON_GROUP); } else { DashboardStatus status = node.getDashboardStatus(); if (status.getStatusType() == StatusType.CHANNEL) { setIcon(UIConstants.ICON_CHANNEL); } else { setIcon(UIConstants.ICON_CONNECTOR); } } } return label; } }); dashboardTable.setLeafIcon(UIConstants.ICON_CONNECTOR); dashboardTable.setOpenIcon(UIConstants.ICON_CHANNEL); dashboardTable.setClosedIcon(UIConstants.ICON_CHANNEL); dashboardTableScrollPane.setViewportView(dashboardTable); dashboardTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent event) { checkSelectionAndPopupMenu(event); } @Override public void mouseReleased(MouseEvent event) { checkSelectionAndPopupMenu(event); } @Override public void mouseClicked(MouseEvent event) { int clickedRow = dashboardTable.rowAtPoint(new Point(event.getX(), event.getY())); if (clickedRow == -1) { return; } TreePath path = dashboardTable.getPathForRow(clickedRow); if (path != null && ((AbstractDashboardTableNode) path.getLastPathComponent()).isGroupNode()) { return; } if (event.getClickCount() >= 2 && dashboardTable.getSelectedRowCount() == 1 && dashboardTable.getSelectedRow() == clickedRow) { parent.doShowMessages(); } } }); dashboardTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { /* * MIRTH-3199: Only update the panel plugin if the selection is finished. This does * mean that the logs aren't updated live when adding to or removing from a * currently adjusting selection, but it's much more efficient when it comes to the * number of requests being done from the client. Plus, it actually will still * update while a selection is adjusting if the refresh interval on the dashboard * elapses. We can change this so that plugins are updated during a selection * adjustment, but it would first require a major rewrite of the connection log / * status column plugin. */ updatePopupMenu(!event.getValueIsAdjusting()); } }); }
From source file:com.peterbochs.sourceleveldebugger.SourceLevelDebugger3.java
private void initGUI() { try {/* w w w.ja v a2 s .c om*/ this.setPreferredSize(new java.awt.Dimension(975, 563)); { jMainSplitPane = new JSplitPane(); this.add(getJErrorLabel(), "errorLabel"); this.add(jMainSplitPane, "MAIN"); jMainSplitPane.setDividerLocation(200); { jPanel4 = new JPanel(); jMainSplitPane.add(jPanel4, JSplitPane.RIGHT); BorderLayout jPanel4Layout = new BorderLayout(); jPanel4.setLayout(jPanel4Layout); { jSplitPane3 = new JSplitPane(); jPanel4.add(jSplitPane3, BorderLayout.CENTER); jSplitPane3.setOrientation(JSplitPane.VERTICAL_SPLIT); jSplitPane3.setDividerLocation(500); { jPanel6 = new JPanel(); jSplitPane3.add(jPanel6, JSplitPane.TOP); jSplitPane3.add(getJInfoTabbedPane(), JSplitPane.BOTTOM); BorderLayout jPanel6Layout = new BorderLayout(); jPanel6.setLayout(jPanel6Layout); { jMainTabbedPane = new JMaximizableTabbedPane(); jPanel6.add(jMainTabbedPane, BorderLayout.CENTER); { jASMPanel = new JPanel(); jMainTabbedPane.addTab(MyLanguage.getString("ASM/C"), null, jASMPanel, null); jMainTabbedPane.addTab("Dwarf", null, getJDwarfPanel(), null); jMainTabbedPane.addTab("Code base", null, getCodeBasePanel(), null); jMainTabbedPane.addTab("Call Graph", null, getCallGraphPanel(), null); BorderLayout jASMPanelLayout = new BorderLayout(); jASMPanel.setLayout(jASMPanelLayout); { instructionTableScrollPane = new JScrollPane(); instructionTableScrollPane.getVerticalScrollBar() .addAdjustmentListener(new AdjustmentListener() { boolean isRunning; public void adjustmentValueChanged(AdjustmentEvent evt) { /* JScrollBar vbar = (JScrollBar) evt.getSource(); if (evt.getValueIsAdjusting()) { return; } if ((vbar.getValue() + vbar.getVisibleAmount()) == vbar.getMaximum()) { if (!isRunning) { try { isRunning = true; final CardLayout cl = (CardLayout) (peterBochsDebugger.jMainPanel.getLayout()); cl.show(peterBochsDebugger.jMainPanel, "Running Label"); // new Thread("update instruction thread") { // public void run() { // long address = Long.parseLong(instructionTable.getValueAt(instructionTable.getRowCount() - 1, 1).toString() // .substring(2), 16); // peterBochsDebugger.updateInstruction(address, true); // peterBochsDebugger.updateBreakpointTableColor(); //// cl.show(peterBochsDebugger.jMainPanel, peterBochsDebugger.currentPanel); // // isRunning = false; // } // }.start(); } catch (Exception ex) { } } }*/ } }); jASMPanel.add(instructionTableScrollPane, BorderLayout.CENTER); { instructionTable = new JTable(); instructionTableScrollPane.setViewportView(instructionTable); instructionTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); instructionTable .setModel(PeterBochsDebugger.instructionTable.getModel()); instructionTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); instructionTable.getTableHeader().setReorderingAllowed(false); instructionTable.getColumnModel().getColumn(0).setMaxWidth(20); instructionTable.getColumnModel().getColumn(1).setPreferredWidth(40); instructionTable.getColumnModel().getColumn(2).setPreferredWidth(200); instructionTable.getColumnModel().getColumn(3).setPreferredWidth(40); instructionTable.setShowGrid(false); instructionTable.setDefaultRenderer(String.class, new InstructionTableCellRenderer()); instructionTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { instructionTableMouseClicked(evt); } }); } } { jInstructionControlPanel = new JPanel(); jASMPanel.add(jInstructionControlPanel, BorderLayout.NORTH); { jInstructionComboBox = new JComboBox(); jInstructionControlPanel.add(jInstructionComboBox); jInstructionComboBox.setEditable(true); jInstructionComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jInstructionComboBoxActionPerformed(evt); } }); } { disassembleButton = new JButton(); jInstructionControlPanel.add(disassembleButton); disassembleButton.setText(MyLanguage.getString("Disassemble")); disassembleButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { disassembleButtonActionPerformed(evt); } }); } { disassembleCSEIPButton = new JButton(); jInstructionControlPanel.add(disassembleCSEIPButton); disassembleCSEIPButton .setText(MyLanguage.getString("Disassemble") + " cs:eip"); disassembleCSEIPButton.setEnabled(true); disassembleCSEIPButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { disassembleCSEIPButtonActionPerformed(evt); } }); } { jInstructionUpTenButton = new JButton(); jInstructionControlPanel.add(jInstructionUpTenButton); jInstructionUpTenButton .setIcon(new ImageIcon(getClass().getClassLoader().getResource( "com/peterbochs/icons/famfam_icons/arrow_up10.png"))); jInstructionUpTenButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jInstructionUpTenButtonActionPerformed(evt); } }); } { jInstructionUpButton = new JButton(); jInstructionControlPanel.add(jInstructionUpButton); jInstructionUpButton .setIcon(new ImageIcon(getClass().getClassLoader().getResource( "com/peterbochs/icons/famfam_icons/arrow_up1.png"))); jInstructionUpButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jInstructionUpButtonActionPerformed(evt); } }); } { jInstructionDownButton = new JButton(); jInstructionControlPanel.add(jInstructionDownButton); jInstructionDownButton .setIcon(new ImageIcon(getClass().getClassLoader().getResource( "com/peterbochs/icons/famfam_icons/arrow_down.png"))); jInstructionDownButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jInstructionDownButtonActionPerformed(evt); } }); } { jDiskButton = new JButton(); jInstructionControlPanel.add(jDiskButton); jDiskButton.setIcon(new ImageIcon(getClass().getClassLoader() .getResource("com/peterbochs/icons/famfam_icons/disk.png"))); jDiskButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton3ActionPerformed(evt); } }); } { jExcelButton = new JButton(); jInstructionControlPanel.add(jExcelButton); jInstructionControlPanel.add(getJSearchTextField()); jExcelButton.setIcon(new ImageIcon(getClass().getClassLoader() .getResource("com/peterbochs/icons/famfam_icons/excel.gif"))); { btnSearch = new JButton("Search"); jInstructionControlPanel.add(btnSearch); btnSearch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { btnSearchActionPerformed(evt); } }); } { onOffButton = new OnOffButton(); onOffButton.setSelected(true); onOffButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { InstructionTableModel model = (InstructionTableModel) PeterBochsDebugger.instructionTable .getModel(); if (e.getStateChange() == ItemEvent.SELECTED) { model.showAsmLevel = true; } else { model.showAsmLevel = false; } model.fireTableDataChanged(); } }); onOffButton.setPreferredSize(new Dimension(53, 18)); jInstructionControlPanel.add(onOffButton); } jExcelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton12ActionPerformed(evt); } }); } } } } } } } { jPanel1 = new JPanel(); jMainSplitPane.add(jPanel1, JSplitPane.LEFT); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); { jTabbedPane1 = new JMaximizableTabbedPane(); jPanel1.add(jTabbedPane1, BorderLayout.CENTER); jTabbedPane1.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { jTabbedPane1StateChanged(evt); } }); { jPanel3 = new JPanel(); BorderLayout jPanel3Layout = new BorderLayout(); jPanel3.setLayout(jPanel3Layout); jTabbedPane1.addTab("Symbol", null, getSymbolTablePanel(), null); jTabbedPane1.addTab(MyLanguage.getString("Project"), null, jPanel3, null); { jScrollPane1 = new JScrollPane(); jPanel3.add(jScrollPane1, BorderLayout.CENTER); jPanel3.add(getJProjectToolBar(), BorderLayout.NORTH); { projectTree = new JTree(); jScrollPane1.setViewportView(projectTree); projectTree.setModel(projectFilterTreeModel); projectTree.setShowsRootHandles(true); projectTree.setCellRenderer(new ProjectTreeRenderer()); projectTree.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { projectTreeMouseClicked(evt); } }); } } } } } } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.igormaznitsa.mindmap.swing.panel.MindMapPanel.java
public MindMapPanel(final MindMapPanelController controller) { super(null);//from www . j av a2s. c o m this.textEditorPanel.setLayout(new BorderLayout(0, 0)); this.controller = controller; this.config = new MindMapPanelConfig(controller.provideConfigForMindMapPanel(this), false); this.textEditor.setMargin(new Insets(5, 5, 5, 5)); this.textEditor.setBorder(BorderFactory.createEtchedBorder()); this.textEditor.setTabSize(4); this.textEditor.addKeyListener(new KeyAdapter() { @Override public void keyPressed(final KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_ENTER: { e.consume(); } break; case KeyEvent.VK_TAB: { if ((e.getModifiers() & ALL_SUPPORTED_MODIFIERS) == 0) { e.consume(); final Topic edited = elementUnderEdit.getModel(); final int[] topicPosition = edited.getPositionPath(); endEdit(true); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { final Topic theTopic = model.findForPositionPath(topicPosition); if (theTopic != null) { makeNewChildAndStartEdit(theTopic, null); } } }); } } break; default: break; } } @Override public void keyTyped(final KeyEvent e) { if (e.getKeyChar() == KeyEvent.VK_ENTER) { if ((e.getModifiers() & ALL_SUPPORTED_MODIFIERS) == 0) { e.consume(); endEdit(true); } else { e.consume(); textEditor.insert("\n", textEditor.getCaretPosition()); //NOI18N } } } @Override public void keyReleased(final KeyEvent e) { if (config.isKeyEvent(MindMapPanelConfig.KEY_CANCEL_EDIT, e)) { e.consume(); final Topic edited = elementUnderEdit == null ? null : elementUnderEdit.getModel(); endEdit(false); if (edited != null && edited.canBeLost()) { deleteTopics(edited); if (pathToPrevTopicBeforeEdit != null) { final int[] path = pathToPrevTopicBeforeEdit; pathToPrevTopicBeforeEdit = null; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { final Topic topic = model.findForPositionPath(path); if (topic != null) { select(topic, false); } } }); } } } } }); this.textEditor.getDocument().addDocumentListener(new DocumentListener() { private void updateEditorPanelSize(final Dimension newSize) { final Dimension editorPanelMinSize = textEditorPanel.getMinimumSize(); final Dimension newDimension = new Dimension(Math.max(editorPanelMinSize.width, newSize.width), Math.max(editorPanelMinSize.height, newSize.height)); textEditorPanel.setSize(newDimension); textEditorPanel.repaint(); } @Override public void insertUpdate(DocumentEvent e) { updateEditorPanelSize(textEditor.getPreferredSize()); } @Override public void removeUpdate(DocumentEvent e) { updateEditorPanelSize(textEditor.getPreferredSize()); } @Override public void changedUpdate(DocumentEvent e) { updateEditorPanelSize(textEditor.getPreferredSize()); } }); this.textEditorPanel.add(this.textEditor, BorderLayout.CENTER); super.setOpaque(true); final KeyAdapter keyAdapter = new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { if (config.isKeyEvent(MindMapPanelConfig.KEY_ADD_CHILD_AND_START_EDIT, e)) { if (!selectedTopics.isEmpty()) { makeNewChildAndStartEdit(selectedTopics.get(0), null); } } else if (config.isKeyEvent(MindMapPanelConfig.KEY_ADD_SIBLING_AND_START_EDIT, e)) { if (!hasActiveEditor() && hasOnlyTopicSelected()) { final Topic baseTopic = selectedTopics.get(0); makeNewChildAndStartEdit(baseTopic.getParent() == null ? baseTopic : baseTopic.getParent(), baseTopic); } } else if (config.isKeyEvent(MindMapPanelConfig.KEY_FOCUS_ROOT_OR_START_EDIT, e)) { if (!hasSelectedTopics()) { select(getModel().getRoot(), false); } else if (hasOnlyTopicSelected()) { startEdit((AbstractElement) selectedTopics.get(0).getPayload()); } } } @Override public void keyReleased(final KeyEvent e) { if (config.isKeyEvent(MindMapPanelConfig.KEY_DELETE_TOPIC, e)) { e.consume(); deleteSelectedTopics(); } else if (config.isKeyEventDetected(e, MindMapPanelConfig.KEY_FOCUS_MOVE_LEFT, MindMapPanelConfig.KEY_FOCUS_MOVE_RIGHT, MindMapPanelConfig.KEY_FOCUS_MOVE_UP, MindMapPanelConfig.KEY_FOCUS_MOVE_DOWN)) { e.consume(); processMoveFocusByKey(e); } } }; this.setFocusTraversalKeysEnabled(false); final MindMapPanel theInstance = this; final MouseAdapter adapter = new MouseAdapter() { @Override public void mouseEntered(final MouseEvent e) { setCursor(Cursor.getDefaultCursor()); } @Override public void mouseMoved(final MouseEvent e) { if (!controller.isMouseMoveProcessingAllowed(theInstance)) { return; } final AbstractElement element = findTopicUnderPoint(e.getPoint()); if (element == null) { setCursor(Cursor.getDefaultCursor()); setToolTipText(null); } else { final ElementPart part = element.findPartForPoint(e.getPoint()); setCursor(part == ElementPart.ICONS || part == ElementPart.COLLAPSATOR ? Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) : Cursor.getDefaultCursor()); if (part == ElementPart.ICONS) { final Extra<?> extra = element.getIconBlock().findExtraForPoint( e.getPoint().getX() - element.getBounds().getX(), e.getPoint().getY() - element.getBounds().getY()); if (extra != null) { setToolTipText(makeHtmlTooltipForExtra(extra)); } else { setToolTipText(null); } } else { setToolTipText(null); } } } @Override public void mousePressed(final MouseEvent e) { if (!controller.isMouseClickProcessingAllowed(theInstance)) { return; } try { if (e.isPopupTrigger()) { mouseDragSelection = null; MindMap theMap = model; AbstractElement element = null; if (theMap != null) { element = findTopicUnderPoint(e.getPoint()); } processPopUp(e.getPoint(), element); e.consume(); } else { endEdit(elementUnderEdit != null); mouseDragSelection = null; } } catch (Exception ex) { LOGGER.error("Error during mousePressed()", ex); } } @Override public void mouseReleased(final MouseEvent e) { if (!controller.isMouseClickProcessingAllowed(theInstance)) { return; } try { if (draggedElement != null) { draggedElement.updatePosition(e.getPoint()); if (endDragOfElement(draggedElement, destinationElement)) { updateView(true); } } else if (mouseDragSelection != null) { final List<Topic> covered = mouseDragSelection.getAllSelectedElements(model); if (e.isShiftDown()) { for (final Topic m : covered) { select(m, false); } } else if (e.isControlDown()) { for (final Topic m : covered) { select(m, true); } } else { removeAllSelection(); for (final Topic m : covered) { select(m, false); } } } else if (e.isPopupTrigger()) { mouseDragSelection = null; MindMap theMap = model; AbstractElement element = null; if (theMap != null) { element = findTopicUnderPoint(e.getPoint()); } processPopUp(e.getPoint(), element); e.consume(); } } catch (Exception ex) { LOGGER.error("Error during mouseReleased()", ex); } finally { mouseDragSelection = null; draggedElement = null; destinationElement = null; repaint(); } } @Override public void mouseDragged(final MouseEvent e) { if (!controller.isMouseMoveProcessingAllowed(theInstance)) { return; } scrollRectToVisible(new Rectangle(e.getX(), e.getY(), 1, 1)); if (!popupMenuActive) { if (draggedElement == null && mouseDragSelection == null) { final AbstractElement elementUnderMouse = findTopicUnderPoint(e.getPoint()); if (elementUnderMouse == null) { MindMap theMap = model; if (theMap != null) { final AbstractElement element = findTopicUnderPoint(e.getPoint()); if (controller.isSelectionAllowed(theInstance) && element == null) { mouseDragSelection = new MouseSelectedArea(e.getPoint()); } } } else if (controller.isElementDragAllowed(theInstance)) { if (elementUnderMouse.isMoveable()) { selectedTopics.clear(); final Point mouseOffset = new Point( (int) Math .round(e.getPoint().getX() - elementUnderMouse.getBounds().getX()), (int) Math .round(e.getPoint().getY() - elementUnderMouse.getBounds().getY())); draggedElement = new DraggedElement(elementUnderMouse, config, mouseOffset, e.isControlDown() || e.isMetaDown() ? DraggedElement.Modifier.MAKE_JUMP : DraggedElement.Modifier.NONE); draggedElement.updatePosition(e.getPoint()); findDestinationElementForDragged(); } else { draggedElement = null; } repaint(); } } else if (mouseDragSelection != null) { if (controller.isSelectionAllowed(theInstance)) { mouseDragSelection.update(e); } else { mouseDragSelection = null; } repaint(); } else if (draggedElement != null) { if (controller.isElementDragAllowed(theInstance)) { draggedElement.updatePosition(e.getPoint()); findDestinationElementForDragged(); } else { draggedElement = null; } repaint(); } } else { mouseDragSelection = null; } } @Override public void mouseWheelMoved(final MouseWheelEvent e) { if (controller.isMouseWheelProcessingAllowed(theInstance)) { mouseDragSelection = null; draggedElement = null; final MindMapPanelConfig theConfig = config; if (!e.isConsumed() && (theConfig != null && ((e.getModifiers() & theConfig.getScaleModifiers()) == theConfig .getScaleModifiers()))) { endEdit(elementUnderEdit != null); setScale( Math.max(0.3d, Math.min(getScale() + (SCALE_STEP * -e.getWheelRotation()), 10.0d))); updateView(false); e.consume(); } else { sendToParent(e); } } } @Override public void mouseClicked(final MouseEvent e) { if (!controller.isMouseClickProcessingAllowed(theInstance)) { return; } mouseDragSelection = null; draggedElement = null; MindMap theMap = model; AbstractElement element = null; if (theMap != null) { element = findTopicUnderPoint(e.getPoint()); } if (element != null) { final ElementPart part = element.findPartForPoint(e.getPoint()); if (part == ElementPart.COLLAPSATOR) { removeAllSelection(); if (element.isCollapsed()) { ((AbstractCollapsableElement) element).setCollapse(false); if ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0) { ((AbstractCollapsableElement) element).collapseAllFirstLevelChildren(); } } else { ((AbstractCollapsableElement) element).setCollapse(true); } invalidate(); fireNotificationMindMapChanged(); repaint(); } else if (part != ElementPart.ICONS && e.getClickCount() > 1) { startEdit(element); } else if (part == ElementPart.ICONS) { final Extra<?> extra = element.getIconBlock().findExtraForPoint( e.getPoint().getX() - element.getBounds().getX(), e.getPoint().getY() - element.getBounds().getY()); if (extra != null) { fireNotificationClickOnExtra(element.getModel(), e.getClickCount(), extra); } } else { if (!e.isControlDown()) { // only removeAllSelection(); select(element.getModel(), false); } else // group if (selectedTopics.isEmpty()) { select(element.getModel(), false); } else { select(element.getModel(), true); } } } } }; addMouseWheelListener(adapter); addMouseListener(adapter); addMouseMotionListener(adapter); addKeyListener(keyAdapter); this.textEditorPanel.setVisible(false); this.add(this.textEditorPanel); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopTree.java
@Override public void setItemClickAction(Action action) { if (this.doubleClickAction != action) { if (action != null) { if (itemClickListener == null) { itemClickListener = new MouseAdapter() { @Override/* www . jav a 2s. c om*/ public void mouseClicked(MouseEvent e) { if (isEditable()) { if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2 && doubleClickAction != null) { int rowForLocation = impl.getRowForLocation(e.getX(), e.getY()); TreePath pathForLocation = impl.getPathForRow(rowForLocation); if (pathForLocation != null) { impl.setSelectionPath(pathForLocation); doubleClickAction.actionPerform(DesktopTree.this); } } } } }; impl.addMouseListener(itemClickListener); impl.setToggleClickCount(0); } } else { impl.removeMouseListener(itemClickListener); impl.setToggleClickCount(2); itemClickListener = null; } this.doubleClickAction = action; } }
From source file:com.konifar.material_icon_generator.MaterialDesignIconGenerateDialog.java
private void initLabelLink(JLabel label, final String url) { label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); label.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent event) { if (event.getClickCount() > 0) { if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); try { URI uri = new URI(url); desktop.browse(uri); } catch (IOException e) { e.printStackTrace(); } catch (URISyntaxException e) { e.printStackTrace(); }/* w w w. j a v a 2 s. c o m*/ } } } }); }
From source file:net.minelord.gui.panes.IRCPane.java
public void connected() { SwingUtilities.invokeLater(new Runnable() { @Override//from w ww .j av a2s . co m public void run() { scroller.setBounds(scrollerWithoutTopicWithUserlist); scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); status = "Connected"; client.connectAlertListener(); TitledBorder title = BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Connected"); title.setTitleJustification(TitledBorder.RIGHT); userList = new JList(client.getUserList().toArray()); userScroller = new JScrollPane(userList); userScroller.setBounds(userScrollerWithoutTopic); userList.setBounds(0, 0, 210, 250); userList.setBackground(Color.gray); userList.setForeground(Color.gray.darker().darker().darker()); userScroller.setBorder(title); userScroller.getVerticalScrollBar().setUnitIncrement(5); scroller.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "")); if (client.getTopic().trim().length() > 0) { topic = new JLabel(client.getTopic()); scroller.setBounds(scrollerWithTopicWithUserlist); userScroller.setBounds(userScrollWithTopic); userList.setBounds(0, 0, 210, 225); title = BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Topic set by " + client.getTopicSetter()); title.setTitleJustification(TitledBorder.LEFT); topic.setBorder(title); topic.setBounds(topicBounds); add(topic); } else topic = new JLabel(""); input.setEnabled(true); input.requestFocus(); final JPopupMenu userPopup = new JPopupMenu(); JLabel breakLine = new JLabel("____"); JLabel help = new JLabel("Politely ask for help"); JLabel message = new JLabel("Message"); JLabel sortNormal = new JLabel("Normal"); JLabel sortAlphabetical = new JLabel("Alphabetical"); JLabel sortRoles = new JLabel("Roles"); help.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { userPopup.setVisible(false); sendMessage("/me kicks " + userList.getModel().getElementAt(userList.getSelectedIndex()) + " in the shins"); sendMessage("I need help you pleb"); } public void mouseReleased(MouseEvent e) { } }); message.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent paramMouseEvent) { userPopup.setVisible(false); input.setText("/msg " + userList.getModel().getElementAt(userList.getSelectedIndex()) + (input.getText().length() > 0 && input.getText().charAt(0) == ' ' ? input.getText() : " " + input.getText())); input.select(0, ("/msg " + userList.getModel().getElementAt(userList.getSelectedIndex()) + (input.getText().length() > 0 && input.getText().charAt(0) == ' ' ? "" : " ")) .length()); input.requestFocus(); } }); sortNormal.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent paramMouseEvent) { userPopup.setVisible(false); updateUserList(0); } }); sortAlphabetical.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent paramMouseEvent) { userPopup.setVisible(false); updateUserList(1); } }); sortRoles.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent paramMouseEvent) { userPopup.setVisible(false); updateUserList(2); } }); userPopup.add(help); userPopup.add(message); userPopup.add(breakLine); userPopup.add(sortNormal); userPopup.add(sortAlphabetical); userPopup.add(sortRoles); userList.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { check(e); } public void mouseReleased(MouseEvent e) { check(e); } public void check(MouseEvent e) { userList.setSelectedIndex(userList.locationToIndex(e.getPoint())); userPopup.show(userList, e.getX(), e.getY()); } }); add(userScroller); final JPopupMenu textPopup = new JPopupMenu(); JLabel copy = new JLabel("Copy"); copy.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent paramMouseEvent) { textPopup.setVisible(false); if (text.getSelectedText() != null && text.getSelectedText().length() != 0) { StringSelection selection = new StringSelection(text.getSelectedText()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(selection, selection); } } }); textPopup.add(copy); text.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) textPopup.show(text, e.getX(), e.getY()); } }); add(userScroller); repaint(); } }); }
From source file:org.pentaho.support.standalone.SDSupportUtility.java
/** * initializing UI// ww w . ja va2 s. co m * * @throws Exception */ public SDSupportUtility() throws Exception { prop = loadProperty(); setResizable(false); setTitle(SDConstant.PENT_SUP_WIZARD); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 665, 516); contentPane = new JPanel(); contentPane.setBackground(UIManager.getColor("Button.background")); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JLabel lblLastAttached = new JLabel("Last Attached"); lblLastAttached.setOpaque(false); lblLastAttached.setHorizontalAlignment(SwingConstants.LEFT); lblLastAttached.setBounds(322, 335, 127, 23); contentPane.add(lblLastAttached); JLabel lblPentahoCustomerSupport = new JLabel("Pentaho Customer Support Wizard"); lblPentahoCustomerSupport.setForeground(new Color(51, 51, 51)); lblPentahoCustomerSupport.setVerticalAlignment(SwingConstants.TOP); lblPentahoCustomerSupport.setHorizontalAlignment(SwingConstants.RIGHT); lblPentahoCustomerSupport.setFont(new Font("Tahoma", Font.BOLD, 23)); lblPentahoCustomerSupport.setBounds(130, 109, 506, 37); contentPane.add(lblPentahoCustomerSupport); JLabel lbllogo = new JLabel(); lbllogo.setIcon(new ImageIcon( SDSupportUtility.class.getResource("/org/pentaho/support/standalone/puc-login-logo.png"))); lbllogo.setBounds(10, 11, 409, 93); contentPane.add(lbllogo); chckbxNewCheckBoxEnvironment = new JCheckBox("Environment"); chckbxNewCheckBoxEnvironment.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.ENVIRONMENT); } else { ArgList.remove(SDConstant.ENVIRONMENT); } } }); chckbxNewCheckBoxEnvironment.setBounds(109, 268, 243, 23); contentPane.add(chckbxNewCheckBoxEnvironment); chckbxNewCheckBoxEnvironment.setOpaque(false); chckbxNewCheckBoxStructure = new JCheckBox("Structure Details"); chckbxNewCheckBoxStructure.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.STRUCT); } else { ArgList.remove(SDConstant.STRUCT); } } }); chckbxNewCheckBoxStructure.setBounds(377, 190, 248, 23); contentPane.add(chckbxNewCheckBoxStructure); chckbxNewCheckBoxStructure.setOpaque(false); chckbxLogs = new JCheckBox("Logs"); chckbxLogs.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.LOGS); } else { ArgList.remove(SDConstant.LOGS); } } }); chckbxLogs.setBounds(377, 164, 248, 23); contentPane.add(chckbxLogs); chckbxLogs.setOpaque(false); chckbxGetSecureFiles = new JCheckBox("Secure Files"); chckbxGetSecureFiles.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.SECURITY); } else { ArgList.remove(SDConstant.SECURITY); } } }); chckbxGetSecureFiles.setBounds(109, 190, 243, 23); contentPane.add(chckbxGetSecureFiles); chckbxGetSecureFiles.setOpaque(false); chckbxMd5 = new JCheckBox("MD5 Hash Value"); chckbxMd5.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.MD5); } else { ArgList.remove(SDConstant.MD5); } } }); chckbxMd5.setBounds(109, 216, 243, 23); contentPane.add(chckbxMd5); chckbxMd5.setOpaque(false); chckbxDbdetails = new JCheckBox("Datasource Details"); chckbxDbdetails.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.DATASOURCE); } else { ArgList.remove(SDConstant.DATASOURCE); } } }); chckbxDbdetails.setBounds(109, 294, 243, 23); contentPane.add(chckbxDbdetails); chckbxDbdetails.setOpaque(false); chckbxLicense = new JCheckBox("License File"); chckbxLicense.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.LICENSE); } else { ArgList.remove(SDConstant.LICENSE); } } }); chckbxLicense.setBounds(109, 164, 243, 23); contentPane.add(chckbxLicense); chckbxLicense.setOpaque(false); chckbxProcesslist = new JCheckBox("Running Process"); chckbxProcesslist.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.RUNNING_TASK); } else { ArgList.remove(SDConstant.RUNNING_TASK); } } }); chckbxProcesslist.setBounds(109, 242, 243, 23); contentPane.add(chckbxProcesslist); chckbxProcesslist.setOpaque(false); chckbxTomcatxml = new JCheckBox("XML files from Tomcat"); chckbxTomcatxml.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.FILE); tomcatXml = true; } else { ArgList.remove(SDConstant.FILE); tomcatXml = false; } } }); chckbxTomcatxml.setBounds(377, 242, 248, 23); contentPane.add(chckbxTomcatxml); chckbxTomcatxml.setOpaque(false); chckbxServerXml = new JCheckBox("XML files from Server"); chckbxServerXml.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.FILE); serverXml = true; } else { ArgList.remove(SDConstant.FILE); serverXml = false; } } }); chckbxServerXml.setBounds(377, 216, 248, 23); contentPane.add(chckbxServerXml); chckbxServerXml.setOpaque(false); chckbxGetBatfiles = new JCheckBox("Start up files from server"); chckbxGetBatfiles.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.FILE); serverBatFile = true; } else { ArgList.remove(SDConstant.FILE); serverBatFile = false; } } }); chckbxGetBatfiles.setBounds(377, 268, 248, 23); contentPane.add(chckbxGetBatfiles); chckbxGetBatfiles.setOpaque(false); chckbxServerproperties = new JCheckBox("Properites files from server"); chckbxServerproperties.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ArgList.add(SDConstant.FILE); serverProrperties = true; } else { ArgList.remove(SDConstant.FILE); serverProrperties = false; } } }); chckbxServerproperties.setBounds(377, 294, 248, 23); contentPane.add(chckbxServerproperties); chckbxServerproperties.setOpaque(false); btnNewButton = new JButton("Package"); btnNewButton.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { try { if (installType.equalsIgnoreCase("Manual")) { if (prop.getProperty(SDConstant.BI_TOM_PATH) == null) { JOptionPane.showMessageDialog(contentPane, SDConstant.ERROR_12, "Inane error", JOptionPane.ERROR_MESSAGE); } else { WEB_XML = new StringBuilder(); WEB_XML.append(prop.getProperty(SDConstant.BI_TOM_PATH)).append(File.separator) .append(SDConstant.WEB_APP).append(File.separator).append(SDConstant.PENTAHO) .append(File.separator).append(SDConstant.WEB_INF).append(File.separator) .append(SDConstant.WEB_XML); PENTAHO_SOLU_PATH = getSolutionPath("biserver", WEB_XML.toString()); prop.put(SDConstant.PENTAHO_SOLU_PATH, PENTAHO_SOLU_PATH); prop.put(SDConstant.BI_PATH, PENTAHO_SOLU_PATH); } } if (prop.getProperty(SDConstant.BI_PATH) == null) { JOptionPane.showMessageDialog(contentPane, SDConstant.ERROR_1, "Inane error", JOptionPane.ERROR_MESSAGE); } if (prop.getProperty(SDConstant.BI_TOM_PATH) == null) { JOptionPane.showMessageDialog(contentPane, SDConstant.ERROR_12, "Inane error", JOptionPane.ERROR_MESSAGE); } disableAll(); setBIServerPath(prop); final String data = textFieldBrowser.getText(); if (!data.equalsIgnoreCase(null)) { ArgList.add(SDConstant.BROWSER); } String[] array = new String[ArgList.size()]; int count = 0; for (int i = 0; i < ArgList.size(); i++) { String retName = ArgList.get(i); if (retName.equals("file")) { if (count == 0) { array[i] = retName; count++; } } else { array[i] = retName; } } ApplicationContext context = new ClassPathXmlApplicationContext(SDConstant.SPRNG_FILE_NAME); factory = (CofingRetrieverFactory) context.getBean("cofingRetrieverFactory"); ConfigRetreiver[] config = factory.getConfigRetrevier(array); ExecutorService service = Executors.newFixedThreadPool(10); for (final ConfigRetreiver configobj : config) { if (null != configobj) { configobj.setBISeverPath(prop); configobj.setServerName("biserver"); if (installType.equalsIgnoreCase("Installer")) { configobj.setInstallType("Installer"); } else if (installType.equalsIgnoreCase("Archive")) { configobj.setInstallType("Archive"); } else if (installType.equalsIgnoreCase("Manual")) { configobj.setInstallType("Manual"); } if (configobj instanceof FileRetriever) { configobj.setBidiXml(serverXml); configobj.setBidiBatFile(serverBatFile); configobj.setBidiProrperties(serverProrperties); configobj.setTomcatXml(tomcatXml); } if (configobj instanceof BrowserInfoRetriever) { configobj.setBrowserInfo(data); } service.execute(new Runnable() { public void run() { if (null != configobj) configobj.readAndSaveConfiguration(prop); } }); } } btnNewButton.setVisible(false); progressBar.setVisible(true); ProgressThread thread = new ProgressThread(); thread.setSupport(getSupport()); thread.setProp(prop); new Thread(thread).start(); service.shutdown(); } catch (Exception e1) { e1.printStackTrace(); } } }); chckbxSelectAll = new JCheckBox("Select/ De-select"); chckbxSelectAll.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { selectAll(); } else { deSelectAll(); } } }); chckbxSelectAll.setBounds(46, 138, 201, 23); chckbxSelectAll.setOpaque(false); contentPane.add(chckbxSelectAll); btnNewButton.setForeground(SystemColor.infoText); btnNewButton.setBounds(10, 430, 639, 37); contentPane.add(btnNewButton); chckbxServerproperties.setOpaque(false); JLabel lblAttach = new JLabel("Attach Artifact"); lblAttach.setHorizontalAlignment(SwingConstants.LEFT); lblAttach.setBounds(32, 335, 177, 23); contentPane.add(lblAttach); lblAttach.setOpaque(false); JButton btnNewButtonBrowse = new JButton("Browse"); btnNewButtonBrowse.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { saveSelectedFile(prop); JFrame parentFrame = new JFrame(); JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Specify a file to save"); fileChooser.setMultiSelectionEnabled(true); int userSelection = fileChooser.showSaveDialog(parentFrame); if (userSelection == JFileChooser.APPROVE_OPTION) { fileToSave = fileChooser.getSelectedFiles(); for (int i = 0; i < fileToSave.length; i++) { File file = fileToSave[i]; String artifactpath = file.getAbsolutePath(); File f = new File(artifactpath); String absolutefilename = f.getName(); String filename = ArtifactsDirectory.concat(absolutefilename); CopyFile artifactcopy = new CopyFile(artifactpath, filename); try { artifactcopy.copy(); } catch (Exception e1) { e1.printStackTrace(); } } uploadedFiles(); rowList = new JList(model); listScrollPane.setViewportView(rowList); panel.add(listScrollPane); } rowList.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { lblDelete.setVisible(true); } }); } }); btnNewButtonBrowse.setBounds(208, 335, 104, 23); contentPane.add(btnNewButtonBrowse); btnNewButtonBrowse.setOpaque(false); textFieldBrowser = new JTextField(); textFieldBrowser.setBounds(208, 364, 441, 23); contentPane.add(textFieldBrowser); textFieldBrowser.setColumns(10); progressBar = new JProgressBar(0, 100); progressBar.setBounds(8, 437, 639, 24); progressBar.setVisible(false); progressBar.setStringPainted(true); contentPane.add(progressBar); JLabel lblBrowserInformation = new JLabel("Browser Information"); lblBrowserInformation.setHorizontalAlignment(SwingConstants.LEFT); lblBrowserInformation.setLabelFor(textFieldBrowser); lblBrowserInformation.setBounds(32, 368, 174, 14); contentPane.add(lblBrowserInformation); panel = new JPanel(); panel.setBounds(423, 325, 127, 33); contentPane.add(panel); panel.setLayout(null); listScrollPane = new JScrollPane(); listScrollPane.setBounds(0, 0, 127, 33); panel.add(listScrollPane); lblDelete = new JLabel(""); lblDelete.setBounds(552, 325, 22, 23); lblDelete.setVisible(false); lblDelete.setIcon( new ImageIcon(SDSupportUtility.class.getResource("/org/pentaho/support/standalone/remove.png"))); contentPane.add(lblDelete); lblDelete.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int option = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete this file ?"); if (option == JOptionPane.YES_OPTION) { String sel = rowList.getSelectedValue().toString(); String selected = dir + "/" + sel; File fileExists = new File(selected); fileExists.delete(); model.remove(sel.indexOf(sel)); lblDelete.setVisible(false); } } }); JLabel instalType = new JLabel("Installation Type : "); instalType.setBounds(32, 395, 177, 23); instalType.setVisible(true); contentPane.add(instalType); ButtonGroup btnGrp = new ButtonGroup(); rdbtnInstaller = new JRadioButton("Installer"); rdbtnInstaller.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { installType = "Installer"; } }); rdbtnInstaller.setBounds(208, 395, 104, 23); rdbtnInstaller.setSelected(true); contentPane.add(rdbtnInstaller); btnGrp.add(rdbtnInstaller); rdbtnArchive = new JRadioButton("Archive"); rdbtnArchive.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { installType = "Archive"; } }); rdbtnArchive.setBounds(333, 395, 104, 23); contentPane.add(rdbtnArchive); btnGrp.add(rdbtnArchive); rdbtnManual = new JRadioButton("Manual"); rdbtnManual.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { installType = "Manual"; } }); rdbtnManual.setBounds(460, 395, 127, 27); contentPane.add(rdbtnManual); btnGrp.add(rdbtnManual); JLabel lblBackground = new JLabel(); lblBackground.setIcon(new ImageIcon( SDSupportUtility.class.getResource("/org/pentaho/support/standalone/login-crystal-bg.jpg"))); lblBackground.setBackground(SystemColor.controlHighlight); lblBackground.setHorizontalAlignment(SwingConstants.CENTER); lblBackground.setBounds(0, 0, 659, 488); contentPane.add(lblBackground); }
From source file:edu.ku.brc.af.tasks.subpane.formeditor.ViewSetSelectorPanel.java
/** * /*from w w w . j a v a 2s . c o m*/ */ @SuppressWarnings("unchecked") //$NON-NLS-1$ public ViewSetSelectorPanel(final BasicFormPreviewPanel previewPanel) { this.previewPanel = previewPanel; Vector<String> levelsVec = new Vector<String>(); SpecifyUser user = AppContextMgr.getInstance().getClassObject(SpecifyUser.class); @SuppressWarnings("unused") Hashtable<Discipline, Boolean> usedColTypes = new Hashtable<Discipline, Boolean>(); levelsVec.add(user.getUserType()); // for (Agent agent : user.getAgents()) // { // // XXX Commented Out // /*Discipline ct = agent.getDiscipline(); // if (usedColTypes.get(ct) == null) // { // levelsVec.add(ct.getName()); // usedColTypes.put(ct, true); // }*/ // } levelsVec.add("BackStop"); //$NON-NLS-1$ addBtn = UIHelper.createIconBtn("PlusSign", "", new ActionListener() { //$NON-NLS-1$ //$NON-NLS-2$ public void actionPerformed(ActionEvent arg0) { addControl(); } }); delBtn = UIHelper.createIconBtn("MinusSign", "", new ActionListener() { //$NON-NLS-1$ //$NON-NLS-2$ public void actionPerformed(ActionEvent arg0) { delControl(TYPE.SelectedObj); } }); ActionListener addViewAL = new ActionListener() { public void actionPerformed(ActionEvent e) { addView(); } }; ActionListener delViewAL = new ActionListener() { public void actionPerformed(ActionEvent e) { delView(); } }; viewControlPanel = new EditDeleteAddPanel(null, delViewAL, addViewAL); ActionListener addAltViewAL = new ActionListener() { public void actionPerformed(ActionEvent e) { addAltView(); } }; ActionListener delAltViewAL = new ActionListener() { public void actionPerformed(ActionEvent e) { delAltView(); } }; altViewControlPanel = new EditDeleteAddPanel(null, delAltViewAL, addAltViewAL); ActionListener addDefViewAL = new ActionListener() { public void actionPerformed(ActionEvent e) { addViewDef(); } }; ActionListener delDefViewAL = new ActionListener() { public void actionPerformed(ActionEvent e) { delViewDef(); } }; viewDefControlPanel = new EditDeleteAddPanel(null, delDefViewAL, addDefViewAL); ActionListener saveAL = new ActionListener() { public void actionPerformed(ActionEvent e) { save(); } }; EditDeleteAddPanel saveControlPanel = new EditDeleteAddPanel(null, null, saveAL); saveControlPanel.getAddBtn().setIcon(IconManager.getIcon("Save", IconManager.IconSize.Std16)); //$NON-NLS-1$ saveControlPanel.getAddBtn().setEnabled(true); setLayout(new BorderLayout()); levelsList = new JList(levelsVec); panel = new EditorPropPanel(controlHash, subcontrolHash, null, true, this); //panel.setFormViewDef(null); PanelBuilder pb = new PanelBuilder(new FormLayout("p,4px,p, 6px,10px,6px, p,6px,p, 6px,10px,6px, p,f:p:g", //$NON-NLS-1$ "p,2px,f:p:g,2px,p,10px,p,4px")); //$NON-NLS-1$ CellConstraints cc = new CellConstraints(); String[] labels = new String[] { "User Level", "ViewSets", " ", "Views", "AltViews", " ", "View Defs" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ int x = 1; for (String label : labels) { pb.add(createLabel(label, SwingConstants.CENTER), cc.xy(x, 1)); x += 2; } Color vsFGColor = new Color(224, 224, 224); Color vsBGColor = new Color(124, 124, 124); Dimension ps = new Dimension(200, 150); x = 1; JScrollPane sp = createScrollPane(levelsList); pb.add(sp, cc.xy(x, 3)); x += 2; viewSetsList = new JList(new DefaultListModel()); sp = createScrollPane(viewSetsList); sp.setPreferredSize(ps); pb.add(sp, cc.xy(x, 3)); x += 2; pb.add(new VerticalSeparator(vsFGColor, vsBGColor), cc.xy(x, 3)); x += 2; viewsList = new JList(new DefaultListModel()); sp = new JScrollPane(viewsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); sp.setPreferredSize(ps); pb.add(sp, cc.xy(x, 3)); x += 2; altViewsList = new JList(new DefaultListModel()); sp = createScrollPane(altViewsList); sp.setPreferredSize(ps); pb.add(sp, cc.xy(x, 3)); x += 2; pb.add(new VerticalSeparator(vsFGColor, vsBGColor), cc.xy(x, 3)); x += 2; viewDefsList = new JList(new DefaultListModel()); sp = createScrollPane(viewDefsList); sp.setPreferredSize(ps); pb.add(sp, cc.xy(x, 3)); x += 2; pb.add(saveControlPanel, cc.xy(1, 5)); //pb.add(createLabel(" "), cc.xy(3, 5)); //pb.add(createLabel(" "), cc.xy(5, 5)); pb.add(viewControlPanel, cc.xy(7, 5)); pb.add(altViewControlPanel, cc.xy(9, 5)); //pb.add(createLabel(" "), cc.xy(11, 5)); pb.add(viewDefControlPanel, cc.xy(13, 5)); pb.addSeparator("View Def Editor", cc.xywh(1, 7, 13, 1)); //$NON-NLS-1$ add(pb.getPanel(), BorderLayout.NORTH); pb = new PanelBuilder(new FormLayout("max(250px;p),4px,f:p:g", "t:p")); //$NON-NLS-1$ //$NON-NLS-2$ PanelBuilder inner = new PanelBuilder(new FormLayout("max(250px;p)", "t:p,2px,t:p")); //$NON-NLS-1$ //$NON-NLS-2$ tree = new JTree(); ((DefaultTreeModel) tree.getModel()).setRoot(null); sp = createScrollPane(tree); inner.add(sp, cc.xy(1, 1)); PanelBuilder btnPb = new PanelBuilder(new FormLayout("f:p:g,p,2px,p", "p")); //$NON-NLS-1$ //$NON-NLS-2$ btnPb.add(delBtn, cc.xy(2, 1)); btnPb.add(addBtn, cc.xy(4, 1)); inner.add(btnPb.getPanel(), cc.xy(1, 3)); pb.add(inner.getPanel(), cc.xy(1, 1)); pb.add(panel, cc.xy(3, 1)); add(pb.getPanel(), BorderLayout.CENTER); tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { treeSelected(); } }); levelsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { levelSelected(); } } }); viewSetsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { viewSetSelected(); } } }); viewsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { viewSelected(); } } }); altViewsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { altViewSelected(); } } }); viewDefsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { viewDefSelected(); } } }); tree.addMouseListener(new MouseAdapter() { protected void doPopup(MouseEvent e) { if (e.isPopupTrigger()) { int xc = e.getX(); int yc = e.getY(); TreePath path = tree.getPathForLocation(xc, yc); if (path != null) { tree.setSelectionPath(path); } treeSelected(); DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) tree.getSelectionModel() .getSelectionPath().getLastPathComponent(); if (selectedCell != null || selectedRow != null) { new TreePopupMenu((Component) e.getSource(), e, selectedCell); } else if (selectedNode.getUserObject() instanceof FormViewDef) { new TreePopupMenu((Component) e.getSource(), e); } } } public void mouseReleased(MouseEvent e) { doPopup(e); } public void mousePressed(MouseEvent e) { doPopup(e); } }); XStream xstream = new XStream(); xstream.alias("control", Control.class); //$NON-NLS-1$ xstream.useAttributeFor(Control.class, "type"); //$NON-NLS-1$ xstream.useAttributeFor(Attr.class, "type"); //$NON-NLS-1$ xstream.useAttributeFor(Attr.class, "name"); //$NON-NLS-1$ xstream.useAttributeFor(Attr.class, "required"); //$NON-NLS-1$ xstream.useAttributeFor(Attr.class, "defaultValue"); //$NON-NLS-1$ xstream.aliasAttribute("default", "defaultValue"); //$NON-NLS-1$ //$NON-NLS-2$ xstream.alias("uicontrols", Vector.class); //$NON-NLS-1$ xstream.alias("attr", Attr.class); //$NON-NLS-1$ xstream.alias("param", Param.class); //$NON-NLS-1$ xstream.alias("subcontrol", SubControl.class); //$NON-NLS-1$ xstream.aliasAttribute("desc", "desc"); //$NON-NLS-1$ //$NON-NLS-2$ xstream.aliasAttribute(Attr.class, "values", "values"); //$NON-NLS-1$ //$NON-NLS-2$ xstream.useAttributeFor(SubControl.class, "type"); //$NON-NLS-1$ try { controls = (Vector<Control>) xstream.fromXML(FileUtils.readFileToString(new File("UIControls.xml"))); //$NON-NLS-1$ for (Control control : controls) { controlHash.put(control.getType(), control); if (control.getSubcontrols() != null) { for (SubControl sc : control.getSubcontrols()) { //System.out.println(" ["+sc.getType()+"] "); subcontrolHash.put(sc.getType(), sc); } } } } catch (IOException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ViewSetSelectorPanel.class, ex); ex.printStackTrace(); } }
From source file:com.archivas.clienttools.arcmover.gui.panels.ProfilePanel.java
private void initializeMouseListener() { fileList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { onFileListSelectionChangedAction(e); }/*from ww w . j a v a 2 s . c om*/ }); fileList.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { onFileListMouseClicked(e); } public void mouseReleased(MouseEvent e) { onFileListMouseClicked(e); } public void mouseClicked(MouseEvent e) { // check if the user has double clicked on an item if (e.getClickCount() == 2) { onFileListMouseDoubleClicked(); } } }); }