public BreakpointViewBase() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); mErrorDialog = new JDialog(SwingUtilities.windowForComponent(this), "Invalid input"); mErrorDialog.setModal(true); mErrorDialog.setSize(new Dimension(400, 100)); mErrorDialog.setLocationRelativeTo(SwingUtilities.windowForComponent(this)); }
static void subscribeTo(NavBarPanel panel) { if (panel.getClientProperty(LISTENER) != null) { unsubscribeFrom(panel); } final NavBarListener listener = new NavBarListener(panel); final Project project = panel.getProject(); panel.putClientProperty(LISTENER, listener); KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(listener); FileStatusManager.getInstance(project).addFileStatusListener(listener); PsiManager.getInstance(project).addPsiTreeChangeListener(listener); WolfTheProblemSolver.getInstance(project).addProblemListener(listener); ActionManager.getInstance().addAnActionListener(listener); final MessageBusConnection connection = project.getMessageBus().connect(); connection.subscribe(ProjectTopics.PROJECT_ROOTS, listener); connection.subscribe(NavBarModelListener.NAV_BAR, listener); connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, listener); panel.putClientProperty(BUS, connection); panel.addKeyListener(listener); if (panel.isInFloatingMode()) { final Window window = SwingUtilities.windowForComponent(panel); if (window != null) { window.addWindowFocusListener(listener); } } }
private void shoutAlert(Collection<ChatMessage> shouts) { Window window = SwingUtilities.windowForComponent(this); boolean windowActive = window.isActive(); if (windowActive) return; alertUser(shouts); }
private void onRemoveGraph() { // i18n[graph.delGraph=Do you really wish to delete this graph?] Window parent = SwingUtilities.windowForComponent(_desktopPane); int res = JOptionPane.showConfirmDialog(parent, s_stringMgr.getString("graph.delGraph")); if (res == JOptionPane.YES_OPTION) { _listener.removeRequest(); } }
/** Creates new form CSVParserOptions */ public CSVParserOptions(java.awt.Component parent) { super((JFrame) SwingUtilities.windowForComponent(parent), true); initComponents(); ModifiableJOptionPane.reverseOKCancel(ok, cancel); pack(); setLocationRelativeTo(parent); setVisible(true); }
@Override public Dimension getSize() { if (myPopup != null) { final Window popupWindow = SwingUtilities.windowForComponent(myContent); return popupWindow.getSize(); } else { return myForcedSize; } }
private void onRenameGraph() { // i18n[graph.newName=Please enter a new name] Window parent = SwingUtilities.windowForComponent(_desktopPane); String newName = JOptionPane.showInputDialog(parent, s_stringMgr.getString("graph.newName")); if (null != newName && 0 != newName.trim().length()) { _listener.renameRequest(newName); } }
/** Displays a panel which lets the user specify the seek details and then issues the seek. */ public void go(Object actor) { Component hintParent = (actor instanceof Component) ? SwingUtilities.windowForComponent((Component) actor) : null; UserSeek seek = new SeekPanel(hintParent).getSeek(); if (seek != null) { ((SeekConnection) getConn()).issueSeek(seek); saveSeekOptions(seek); } }
private void closeActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_closeActionPerformed /*if(!generated) { if(JOptionPane.showConfirmDialog(this, "Are you sure you want to close the window without generating?", "Are You Sure?", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) { return; } }*/ SwingUtilities.windowForComponent(this).dispose(); } // GEN-LAST:event_closeActionPerformed
private void connectButtonActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_connectButtonActionPerformed // TODO add your handling code here: if (client.connect( serverAdressTextField.getText(), serverPortTextField.getText(), usernameTextField.getText())) { Window window = SwingUtilities.windowForComponent((Component) evt.getSource()); window.dispose(); } } // GEN-LAST:event_connectButtonActionPerformed
@Override public void moveToFitScreen() { if (myPopup == null) return; final Window popupWindow = SwingUtilities.windowForComponent(myContent); Rectangle bounds = popupWindow.getBounds(); ScreenUtil.moveRectangleToFitTheScreen(bounds); setLocation(bounds.getLocation()); setSize(bounds.getSize(), false); }
private void setSizeAndDimensions( @NotNull JTable table, @NotNull JBPopup popup, @NotNull RelativePoint popupPosition, @NotNull List<UsageNode> data) { JComponent content = popup.getContent(); Window window = SwingUtilities.windowForComponent(content); Dimension d = window.getSize(); int width = calcMaxWidth(table); width = (int) Math.max(d.getWidth(), width); Dimension headerSize = ((AbstractPopup) popup).getHeaderPreferredSize(); width = Math.max((int) headerSize.getWidth(), width); width = Math.max(myWidth, width); if (myWidth == -1) myWidth = width; int newWidth = Math.max(width, d.width + width - myWidth); myWidth = newWidth; int rowsToShow = Math.min(30, data.size()); Dimension dimension = new Dimension(newWidth, table.getRowHeight() * rowsToShow); Rectangle rectangle = fitToScreen(dimension, popupPosition, table); dimension = rectangle.getSize(); Point location = window.getLocation(); if (!location.equals(rectangle.getLocation())) { window.setLocation(rectangle.getLocation()); } if (!data.isEmpty()) { TableScrollingUtil.ensureSelectionExists(table); } table.setSize(dimension); // table.setPreferredSize(dimension); // table.setMaximumSize(dimension); // table.setPreferredScrollableViewportSize(dimension); Dimension footerSize = ((AbstractPopup) popup).getFooterPreferredSize(); int newHeight = (int) (dimension.height + headerSize.getHeight() + footerSize.getHeight()) + 4 /* invisible borders, margins etc*/; Dimension newDim = new Dimension(dimension.width, newHeight); window.setSize(newDim); window.setMinimumSize(newDim); window.setMaximumSize(newDim); window.validate(); window.repaint(); table.revalidate(); table.repaint(); }
public static Window setSize(JComponent content, final Dimension size) { final Window popupWindow = SwingUtilities.windowForComponent(content); final Point location = popupWindow.getLocation(); popupWindow.setLocation(location.x, location.y); Insets insets = content.getInsets(); if (insets != null) { size.width += insets.left + insets.right; size.height += insets.top + insets.bottom; } content.setPreferredSize(size); popupWindow.pack(); return popupWindow; }
private void jButton1ActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed getwrk().startSimulation(); SimState tempState = (SimState) openStateJList.getSelectedValue(); SimState controlState = getwrk().getController().getState(); if (!openStateJList.isSelectionEmpty()) { // start simulation // getwrk().startSimulation(); // get Selected SimState and create new session Object[] tempObject = new Object[2]; controlState.setId(tempState.getId()); controlState.setDescription(tempState.getDescription()); controlState.setGlobalAccessFlag(tempState.getGlobalAccessFlag()); controlState.setReadWriteFlag(tempState.getReadWriteFlag()); controlState.setAvailableComponents(tempState.getAvailableComponents()); controlState.setUsedComponents(tempState.getUsedComponents()); controlState.setPlacedComponents(tempState.getPlacedComponents()); controlState.setSavedAt(tempState.getSavedAt()); controlState.setSimUser(tempState.getSimUser()); controlState.setChanged(); tempObject[0] = "OpenComponent"; controlState.notifyObservers(tempObject); // populate the JLists for available and used compomemts getwrk() .reloadListsOnOpen(tempState.getAvailableComponents(), tempState.getPlacedComponents()); getwrk().getController().setOpenDirective(true); getwrk().getRecentMenu().setEnabled(false); getwrk().getSessionDescLabel().setText(tempState.getDescription()); getwrk().getController().setSave(SimController.SaveState.Saved); stateListModel.removeAllElements(); // This delete all .klog files and creates new One for new write for getwrk() .getController() .createUndoRedoFile( "logger.klog"); // this line deletes exicsting log files to craete new klog file for // new work getwrk().getController().appendLoggerOpen(); } else { // JOptionPane.showMessageDialog(null, "You havent Selected Any Session To Open", // "Error", JOptionPane.OK_OPTION); OkOption okop = new OkOption(null, "KSimulator"); okop.setLabel1("You havent Selected Any Session To Open"); okop.setSize(300, 100); okop.showDialog(); getwrk().getController().closeState(); } SwingUtilities.windowForComponent(this).setVisible(false); } // GEN-LAST:event_jButton1ActionPerformed
private void changeButton_actionPerformed(ActionEvent e) { Color newColor = JColorChooser.showDialog( SwingUtilities.windowForComponent(this), PluginServices.getText(this, "choose_color"), color); if (newColor == null) { return; } setColor(newColor); fireActionPerformed(); }
public void actionPerformed(ActionEvent event) { Window window; String msg; if (model.isZoomUndoStackEmpty()) { window = SwingUtilities.windowForComponent((JToolBar) toolbar); msg = "Zoom Undo Stack is empty"; Dialogs.warn(window, msg); } else model.zoomUndo(); // Set toolbar buttons to reflect status if (toolbar != null) toolbar.resetZoomButtons(); if (Debug.isActive()) Debug.println("Action for Zoom Undo button."); }
public JDialog getDialogoSeleccionPropiedad(int index) { Window window = SwingUtilities.windowForComponent(CheckBoxMedida.this); if (this.dialogoSelector == null) { this.dialogoSelector = new JDialog(window, JDialog.ModalityType.APPLICATION_MODAL); this.dialogoSelector.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); this.dialogoSelector.setResizable(false); this.dialogoSelector.setLocationRelativeTo(window); } this.dialogoSelector.getContentPane().add(this.selectoresPropiedad.get(index)); this.dialogoSelector.setTitle(this.nombrePropiedad.get(index)); this.dialogoSelector.pack(); this.selectoresPropiedad.get(index).slider.requestFocusInWindow(); return this.dialogoSelector; }
private static void repaintMnemonics(@NotNull Component focusOwner, boolean pressed) { if (pressed != myAltPressed) return; Window window = SwingUtilities.windowForComponent(focusOwner); if (window != null) { for (Component component : window.getComponents()) { if (component instanceof JComponent) { for (JComponent c : UIUtil.findComponentsOfType((JComponent) component, JComponent.class)) { if ((c instanceof JLabel && ((JLabel) c).getDisplayedMnemonicIndex() != -1) || (c instanceof AbstractButton && ((AbstractButton) c).getDisplayedMnemonicIndex() != -1)) { c.repaint(); } } } } } }
protected BaseDialog createDialog(Component parent, String title) { BaseDialog dialog; Window window = (parent == null ? JOptionPane.getRootFrame() : SwingUtilities.windowForComponent(parent)); if (window instanceof Frame) { dialog = new BaseDialog((Frame) window, title, true); } else { dialog = new BaseDialog((Dialog) window, title, true); } dialog.setDialogMode(BaseDialog.OK_CANCEL_DIALOG); dialog.getBanner().setVisible(false); dialog.getContentPane().setLayout(new BorderLayout()); dialog.getContentPane().add("Center", this); dialog.pack(); dialog.setLocationRelativeTo(parent); return dialog; }
@Nullable private static Container getContainer(@Nullable final Component focusOwner) { if (focusOwner == null) return null; if (focusOwner.isLightweight()) { Container container = focusOwner.getParent(); while (container != null) { final Container parent = container.getParent(); if (parent instanceof JLayeredPane) break; if (parent != null && parent.isLightweight()) { container = parent; } else { break; } } return container; } return SwingUtilities.windowForComponent(focusOwner); }
// Tags laden -------------------------------------------------------------- public void editTags(ArrayList<AudioFile> audioFiles) { /* €nderungen vorhanden? */ // Sicherstellen, dass keine €nderungen verloren gehen. if (editorChanged) { int result = JOptionPane.showConfirmDialog( SwingUtilities.windowForComponent(this), "You have modified the currently selected audiofile(s)!\n" + "Would you like to save these changes?", "Save changes", JOptionPane.YES_NO_OPTION); switch (result) { case JOptionPane.YES_OPTION: saveTags(); break; } } /* Neue Files in den Editor laden: */ this.audioFiles = audioFiles; updateEditorControls(); }
private RelativePoint relativePointByQuickSearch(final DataContext dataContext) { Rectangle dominantArea = PlatformDataKeys.DOMINANT_HINT_AREA_RECTANGLE.getData(dataContext); if (dominantArea != null) { final Component focusedComponent = getWndManager().getFocusedComponent(myProject); Window window = SwingUtilities.windowForComponent(focusedComponent); JLayeredPane layeredPane; if (window instanceof JFrame) { layeredPane = ((JFrame) window).getLayeredPane(); } else if (window instanceof JDialog) { layeredPane = ((JDialog) window).getLayeredPane(); } else if (window instanceof JWindow) { layeredPane = ((JWindow) window).getLayeredPane(); } else { throw new IllegalStateException( "cannot find parent window: project=" + myProject + "; window=" + window); } return relativePointWithDominantRectangle(layeredPane, dominantArea); } return JBPopupFactory.getInstance().guessBestPopupLocation(dataContext); }
private void onTablesDroped(DropTargetDropEvent dtde) { try { Object transferData = dtde.getTransferable() .getTransferData(dtde.getTransferable().getTransferDataFlavors()[0]); if (transferData instanceof ObjectTreeDndTransfer) { ObjectTreeDndTransfer objectTreeDndTransfer = (ObjectTreeDndTransfer) transferData; if (false == objectTreeDndTransfer.getSessionIdentifier().equals(_session.getIdentifier())) { JOptionPane.showMessageDialog( SwingUtilities.windowForComponent(_desktopPane), s_stringMgr.getString("GraphDesktopController.tableDropedFormOtherSession")); return; } _listener.tablesDropped(objectTreeDndTransfer.getSelectedTables(), dtde.getLocation()); } } catch (Exception e) { throw new RuntimeException(e); } }
/** get the main window */ protected JFrame getWindow() { return (JFrame) SwingUtilities.windowForComponent(FACE_VIEW); }
@NotNull public ModalityState getModalityStateForComponent(@NotNull Component c) { Window window = c instanceof Window ? (Window) c : SwingUtilities.windowForComponent(c); if (window == null) return getNoneModalityState(); // ? return LaterInvocator.modalityStateForWindow(window); }
public static Component windowForComponent(Component c) { return SwingUtilities.windowForComponent(c); }
private void okActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_okActionPerformed generated = true; cutting.generate(); SwingUtilities.windowForComponent(this).dispose(); } // GEN-LAST:event_okActionPerformed
private void cancelOnOpenStateActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_cancelOnOpenStateActionPerformed getwrk().getController().closeState(); stateListModel.removeAllElements(); SwingUtilities.windowForComponent(this).setVisible(false); } // GEN-LAST:event_cancelOnOpenStateActionPerformed
public void init() { try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { // TODO Auto-generated catch block e.printStackTrace(); } Window window = SwingUtilities.windowForComponent(this); if (window instanceof JFrame) { JFrame frame = (JFrame) window; if (!frame.isResizable()) frame.setResizable(true); } try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); String connectionUrl = "jdbc:sqlserver://130.208.252.230:1433;databaseName=PROD_UPG_DATA;user=limsadmin;password=starlims;"; con = DriverManager.getConnection(connectionUrl); List<Proj> folders = getProjects(); model = createModel(folders); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } table.setAutoCreateRowSorter(true); if (model != null) table.setModel(model); Set<TableColumn> remcol = new HashSet<TableColumn>(); Enumeration<TableColumn> taben = table.getColumnModel().getColumns(); while (taben.hasMoreElements()) { TableColumn tc = taben.nextElement(); if (tc.getIdentifier().toString().startsWith("_")) { remcol.add(tc); } } for (TableColumn tc : remcol) { table.removeColumn(tc); } table .getSelectionModel() .addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (currentSelection != null) { Proj project = orderMap.get(currentSelection); if (project != null) { project._OrderComment = textarea.getText(); project._ResultComment = rtextarea.getText(); } } int r = table.getSelectedRow(); if (r != -1) { currentSelection = (String) table.getValueAt(r, 0); r = table.convertRowIndexToModel(r); String t = (String) model.getValueAt(r, 1); if (t != null) textarea.setText(t); else { textarea.setText(""); } t = (String) model.getValueAt(r, 2); if (t != null) rtextarea.setText(t); else { rtextarea.setText(""); } } } }); scrollpane.setViewportView(table); scrollarea.setViewportView(textarea); rscrollarea.setViewportView(rtextarea); vista.setAction( new AbstractAction("Vista") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { try { Proj project = orderMap.get(currentSelection); if (project != null) save(project, rtextarea.getText(), textarea.getText()); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); for (String s : fset) { combo.addItem(s); } combo.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { String s = (String) combo.getSelectedItem(); TableRowSorter<TableModel> trs = (TableRowSorter<TableModel>) table.getRowSorter(); String filterText = "(?i).*" + s + ".*"; trs.setRowFilter(RowFilter.regexFilter(filterText)); } }); JComponent comp = new JComponent() {}; comp.setLayout(new BorderLayout()); comp.add(scrollarea); comp.add(vista, BorderLayout.SOUTH); JComponent comp2 = new JComponent() {}; comp2.setLayout(new BorderLayout()); comp2.add(scrollpane); comp2.add(combo, BorderLayout.NORTH); rsplitpane.setTopComponent(rscrollarea); rsplitpane.setBottomComponent(comp); splitpane.setLeftComponent(comp2); splitpane.setRightComponent(rsplitpane); splitpane.setDividerLocation(0.33); this.add(splitpane); }
private void buildDialog() { Window window = SwingUtilities.windowForComponent(target.getEditComponent()); dialog = new JDialog(window, "Find / Replace"); dialog.setModal(false); JPanel panel = new JPanel(new BorderLayout()); findCombo = new JComboBox(); findCombo.setEditable(true); replaceCombo = new JComboBox(); replaceCombo.setEditable(true); // create inputs GridLayout gridLayout = new GridLayout(2, 2); gridLayout.setVgap(5); JPanel inputPanel = new JPanel(gridLayout); inputPanel.add(new JLabel("Find:")); inputPanel.add(findCombo); inputPanel.add(new JLabel("Replace with:")); inputPanel.add(replaceCombo); inputPanel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); // create direction panel ButtonGroup directionGroup = new ButtonGroup(); forwardButton = new JRadioButton("Forward", true); forwardButton.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); directionGroup.add(forwardButton); backwardButton = new JRadioButton("Backward"); backwardButton.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); directionGroup.add(backwardButton); JPanel directionPanel = new JPanel(new GridLayout(2, 1)); directionPanel.add(forwardButton); directionPanel.add(backwardButton); directionPanel.setBorder(BorderFactory.createTitledBorder("Direction")); // create scope panel ButtonGroup scopeGroup = new ButtonGroup(); allButton = new JRadioButton("All", true); allButton.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); selectedLinesButton = new JRadioButton("Selected Lines"); selectedLinesButton.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); scopeGroup.add(allButton); scopeGroup.add(selectedLinesButton); JPanel scopePanel = new JPanel(new GridLayout(2, 1)); scopePanel.add(allButton); scopePanel.add(selectedLinesButton); scopePanel.setBorder(BorderFactory.createTitledBorder("Scope")); // create options caseCheck = new JCheckBox("Case Sensitive"); caseCheck.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); wholeWordCheck = new JCheckBox("Whole Word"); wholeWordCheck.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); wrapCheck = new JCheckBox("Wrap Search"); wrapCheck.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); JPanel optionsPanel = new JPanel(new GridLayout(3, 1)); optionsPanel.add(caseCheck); optionsPanel.add(wholeWordCheck); optionsPanel.add(wrapCheck); optionsPanel.setBorder(BorderFactory.createTitledBorder("Options")); // create panel with options JPanel options = new JPanel(new GridLayout(1, 2)); JPanel radios = new JPanel(new GridLayout(2, 1)); radios.add(directionPanel); radios.add(scopePanel); options.add(optionsPanel); options.add(radios); options.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8)); // create buttons ButtonBarBuilder builder = new ButtonBarBuilder(); findButton = new JButton(new FindAction()); builder.addFixed(findButton); builder.addRelatedGap(); replaceButton = new JButton(new ReplaceAction()); builder.addFixed(replaceButton); builder.addRelatedGap(); replaceAllButton = new JButton(new ReplaceAllAction()); builder.addFixed(replaceAllButton); builder.addUnrelatedGap(); builder.addFixed(new JButton(new CloseAction())); builder.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); // tie it up! panel.add(inputPanel, BorderLayout.NORTH); panel.add(options, BorderLayout.CENTER); panel.add(builder.getPanel(), BorderLayout.SOUTH); dialog.getContentPane().add(panel); dialog.pack(); UISupport.initDialogActions(dialog, null, findButton); }