public Component add(JInternalFrame frame) { JInternalFrame[] array = getAllFrames(); Point p; int w; int h; Component retval = super.add(frame); checkDesktopSize(); if (array.length > 0) { p = array[0].getLocation(); p.x = p.x + FRAME_OFFSET; p.y = p.y + FRAME_OFFSET; } else { p = new Point(0, 0); } frame.setLocation(p.x, p.y); if (frame.isResizable()) { w = getWidth() - (getWidth() / 3); h = getHeight() - (getHeight() / 3); if (w < frame.getMinimumSize().getWidth()) w = (int) frame.getMinimumSize().getWidth(); if (h < frame.getMinimumSize().getHeight()) h = (int) frame.getMinimumSize().getHeight(); frame.setSize(w, h); } moveToFront(frame); frame.setVisible(true); try { frame.setSelected(true); } catch (PropertyVetoException e) { frame.toBack(); } return retval; }
/** sort frames top-down-left-right */ private void handleSwingTabAction(int delta) { JInternalFrame[] frames = getSwingDesktopPane().getAllFrames(); TreeMap<Integer, JInternalFrame> sortedMap = new TreeMap<Integer, JInternalFrame>(); for (JInternalFrame f : frames) { if (f.isVisible()) { int tabIndex = f.getX() * 100000 + f.getY(); if (delta < 0) { tabIndex = -tabIndex; } sortedMap.put(tabIndex, f); } } JInternalFrame next = null; if (sortedMap.size() > 0) { ArrayList<JInternalFrame> list = new ArrayList<JInternalFrame>(sortedMap.values()); int nextIndex = 0; JInternalFrame selectedFrame = getSwingDesktopPane().getSelectedFrame(); if (selectedFrame != null) { nextIndex = (list.indexOf(selectedFrame) + 1) % list.size(); } next = list.get(nextIndex); } if (next != null) { try { next.setSelected(true); } catch (PropertyVetoException ve) { } } }
/** * Abre el Caso de Uso e inicia su ejecución para las ventanas * VentanaActualizarTiposGenericoContable y VentanaActualizarTiposGenerico * * @param nombreClaseVentana Nombre de la Clase de la Ventana que se va a mostrar. * @param nombreClaseGenerica Nombre de la Clase que se va a actualizar. * @param titulo Nombre de la parte del título que indica actividad (no poner todo completo, solo * lo que se está actualizando). La ventana mostrará: "Actualizar " + titulo. * @return Referencia a la ventana creada. */ public JInternalFrame iniciarCUGenerico(Class claseVentana, Class claseGenerica, String titulo) { JInternalFrame ventana = null; try { // Instanciar el CU. ventana = (JInternalFrame) claseVentana.newInstance(); VentanaMenuPrincipal.getInstancia().getPanelPrincipal().add(ventana); // Establece la posicion de la ventana. generarPosicionVentana(); ventana.setLocation(getPosicionXVentana(), getPosicionYVentana()); // Muestra la ventana. ventana.setVisible(true); // Intenta establecer a la ventana como seleccionada, // Si no puede, lanza imprime la excepcion en la salida estandar. try { ventana.setSelected(true); } catch (java.beans.PropertyVetoException e) { log.warn("Error al establecer ventana como seleccionada.", e); } InterfazTipoGenerico tg = (InterfazTipoGenerico) claseGenerica.newInstance(); ((VentanaActualizarTipos) ventana).opcionActualizarTipos(titulo, tg); log.debug( "Iniciado CU Genérico: " + claseVentana.getName() + " - Para la Clase: " + claseGenerica.getName()); } catch (InstantiationException ex) { log.error("No se pudo instanciar la clase", ex); } catch (IllegalAccessException ex) { log.error("No se pudo instanciar la clase", ex); } return ventana; }
public void openInBox() { JInternalFrame doc = new MetalworksInBox(); desktop.add(doc, DOCLAYER); try { doc.setVisible(true); doc.setSelected(true); } catch (java.beans.PropertyVetoException e2) { } }
public void openHelpWindow() { JInternalFrame help = new MetalworksHelp(); desktop.add(help, HELPLAYER); try { help.setVisible(true); help.setSelected(true); } catch (java.beans.PropertyVetoException e2) { } }
/** * Used to unset the focus of all the views. This is for the situation when a network is focused * but the network doesn't have a view. */ protected void unsetFocus() { for (JInternalFrame f : networkViewMap.values()) { try { f.setSelected(false); } catch (PropertyVetoException pve) { logger.info("NetworkViewManager: Couldn't unset focus for internal frame."); } } }
private void setState(JDesktopPane dp, String state) { if (state == CLOSE) { JInternalFrame f = dp.getSelectedFrame(); if (f == null) { return; } f.doDefaultCloseAction(); } else if (state == MAXIMIZE) { // maximize the selected frame JInternalFrame f = dp.getSelectedFrame(); if (f == null) { return; } if (!f.isMaximum()) { if (f.isIcon()) { try { f.setIcon(false); f.setMaximum(true); } catch (PropertyVetoException pve) { } } else { try { f.setMaximum(true); } catch (PropertyVetoException pve) { } } } } else if (state == MINIMIZE) { // minimize the selected frame JInternalFrame f = dp.getSelectedFrame(); if (f == null) { return; } if (!f.isIcon()) { try { f.setIcon(true); } catch (PropertyVetoException pve) { } } } else if (state == RESTORE) { // restore the selected minimized or maximized frame JInternalFrame f = dp.getSelectedFrame(); if (f == null) { return; } try { if (f.isIcon()) { f.setIcon(false); } else if (f.isMaximum()) { f.setMaximum(false); } f.setSelected(true); } catch (PropertyVetoException pve) { } } }
public void actionPerformed(ActionEvent event) { if (frame == null) { displayNewWindow(); } else { try { frame.setSelected(true); } catch (PropertyVetoException ex) {; // pas grave } } }
private void jCheckBox1ActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jCheckBox1ActionPerformed javax.swing.JInternalFrame other = new AmmendMainStockCategoryintfr(connectDB, pConnDB); this.getParent().add(other, javax.swing.JLayeredPane.DEFAULT_LAYER); try { other.setSelected(true); } catch (java.beans.PropertyVetoException pvt) { } other.setVisible(true); // Add your handling code here: } // GEN-LAST:event_jCheckBox1ActionPerformed
/** * Shows the correct database table, specified by the parameter (0 or 1). * * @param database a byte value indicating which database table to show */ public void showTable(byte database) { if (database == (byte) 0) { JInternalFrame i = (JInternalFrame) childFrame(); desktop.add(i); try { i.setSelected(true); } catch (PropertyVetoException e1) { e1.printStackTrace(); } } else { JInternalFrame i = (JInternalFrame) employeeFrame(); desktop.add(i); try { i.setSelected(true); } catch (PropertyVetoException e1) { e1.printStackTrace(); } } }
public void testPlaysEvent() throws Exception { Mock mockComponentFinder = mock(ComponentFinder.class); JInternalFrame internalFrame = createInternalFrame(); mockComponentFinder .expects(once()) .method("findInternalFrame") .will(returnValue(internalFrame)); internalFrame.setSelected(false); new CloseInternalFrameEvent("title") .play(null, (ComponentFinder) mockComponentFinder.proxy(), null, null); assertTrue(internalFrame.isClosed()); }
// Aqui no creo que deba ir un TaskFrame por si se quiere activar otro tipo de JinternalFrame public void activateFrame(JInternalFrame frame) { frame.moveToFront(); frame.requestFocus(); try { frame.setSelected(true); if (!(frame instanceof TaskFrame)) { frame.setMaximum(false); } } catch (PropertyVetoException e) { warnUser(StringUtil.stackTrace(e)); } }
private void displayNewWindow() { try { frame = new DefaultQuarantineWindow(getGuiContext(), guiData, userId, new ListDataSource()); frame.addInternalFrameListener(cleanUpListener); getDesktopPane().add(frame); frame.pack(); frame.setVisible(true); frame.setSelected(true); } catch (Exception ex) { ErrorDialog.show(getDesktopPane(), "Impossible d'afficher la liste", ex); } }
/** * maximizes the internal frame to the viewport bounds rather than the desktop bounds * * @param f the internal frame being maximized */ public void maximizeFrame(JInternalFrame f) { Rectangle p = desktopPane.getScrollPaneRectangle(); f.setNormalBounds(f.getBounds()); setBoundsForFrame(f, p.x, p.y, p.width, p.height); try { f.setSelected(true); } catch (PropertyVetoException pve) { System.out.println(pve.getMessage()); } removeIconFor(f); }
public void activateFrame(JInternalFrame f) { JInternalFrame currentFrame = currentFrameRef != null ? currentFrameRef.get() : null; try { super.activateFrame(f); if (currentFrame != null && f != currentFrame) { // If the current frame is maximized, transfer that // attribute to the frame being activated. if (currentFrame.isMaximum() && (f.getClientProperty("JInternalFrame.frameType") != "optionDialog")) { // Special case. If key binding was used to select next // frame instead of minimizing the icon via the minimize // icon. if (!currentFrame.isIcon()) { currentFrame.setMaximum(false); if (f.isMaximizable()) { if (!f.isMaximum()) { f.setMaximum(true); } else if (f.isMaximum() && f.isIcon()) { f.setIcon(false); } else { f.setMaximum(false); } } } } if (currentFrame.isSelected()) { currentFrame.setSelected(false); } } if (!f.isSelected()) { f.setSelected(true); } } catch (PropertyVetoException e) { } if (f != currentFrame) { currentFrameRef = new WeakReference(f); } }
private void focusLastFrame() { for (int i = listMkWindow.size() - 1; i >= 0; i--) { JRootPane rootPaneJanela = SwingUtilities.getRootPane(listMkWindow.get(i)); Container parentContainer = rootPaneJanela.getParent(); if (parentContainer instanceof JInternalFrame) { JInternalFrame internalFrame = (JInternalFrame) parentContainer; desktopPane.getDesktopManager().activateFrame(internalFrame); try { internalFrame.setSelected(true); } catch (PropertyVetoException ex) { logger.error("Erro foco ulma janela", ex); } break; } } }
private void cargarFormulario(Class<?> aClass){ try { //Variable JInternalFrame view ; //Buscar instancia view = buscarInstancia(aClass); //Crear instancia if(view == null){ view = (JInternalFrame)Class.forName(aClass.getName()).newInstance(); desktopPane.add(view) } //Mostrar formulario view.setVisible(true); view.setSelected(true); } catch ( Excepetion e){
public void toFront() { // if( lala ) { // System.out.println( "toFront" ); // new Exception().printStackTrace(); // } // if (w != null) { w.toFront(); } else if (jif != null) { jif.toFront(); try { jif.setSelected(true); } catch (PropertyVetoException e) { /* ignored */ } } else { throw new IllegalStateException(); } }
// aqui se añade los internalframe al destop pane private void agregarMarcoInterno(JInternalFrame marco) { marco.setLocation(xSigMarco, ySigMarco); marco.setVisible(true); jDesktopPane.add(marco); try { marco.setSelected(true); } catch (PropertyVetoException ex) { } if (distanciaEntreMarcos == 0) distanciaEntreMarcos = marco.getHeight() - marco.getContentPane().getHeight(); xSigMarco += distanciaEntreMarcos; ySigMarco += distanciaEntreMarcos; if (xSigMarco + marco.getWidth() > jDesktopPane.getWidth()) xSigMarco = 0; if (ySigMarco + marco.getHeight() > jDesktopPane.getHeight()) ySigMarco = 0; }
@Override public void metadataElementSelected( final MetadataElement metadataElement, final int clickCount) { setSelectedProductNode(metadataElement); final JInternalFrame frame = visatApp.findInternalFrame(metadataElement); if (frame != null) { try { frame.setSelected(true); } catch (PropertyVetoException ignored) { // ok } return; } // if (clickCount == 2) { // final ExecCommand command = // visatApp.getCommandManager().getExecCommand(ShowMetadataViewAction.ID); // command.execute(metadataElement); // } }
@Override public void vectorDataSelected(final VectorDataNode vectorDataNode, int clickCount) { setSelectedProductNode(vectorDataNode); setSelectedVectorDataNode(vectorDataNode); final JInternalFrame frame = visatApp.findInternalFrame(vectorDataNode); if (frame != null) { try { frame.setSelected(true); } catch (PropertyVetoException ignored) { // ok } return; } // if (clickCount == 2) { // final ExecCommand command = // visatApp.getCommandManager().getExecCommand(ShowPlacemarkViewAction.ID); // command.execute(vectorDataNode); // } }
private void rasterDataNodeSelected(final RasterDataNode raster, final int clickCount) { setSelectedProductNode(raster); final JInternalFrame[] internalFrames = visatApp.findInternalFrames(raster); JInternalFrame frame = null; for (final JInternalFrame internalFrame : internalFrames) { final int numRasters = ((ProductSceneView) internalFrame.getContentPane()).getNumRasters(); if (numRasters == 1) { frame = internalFrame; break; } } if (frame != null) { try { frame.setSelected(true); } catch (PropertyVetoException ignored) { // ok } } else if (clickCount == 2) { final ExecCommand command = visatApp.getCommandManager().getExecCommand("showImageView"); command.execute(clickCount); } }
public JInternalFrame employeeFrame() { JInternalFrame f = new JInternalFrame(); f = new JInternalFrame( "Employee Database", false, // Resizable true, // Closable true, // Maximizable true); // Iconifiable f.setLayout(new BorderLayout()); JScrollPane sp = new JScrollPane(employeeTable()); sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); sp.setBorder(BorderFactory.createTitledBorder("Employees")); f.add(buttonPanel(false), BorderLayout.NORTH); f.add(sp); // f.setLocation(loc); f.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE); f.setFrameIcon(images.loadImage("Images/menubar/database_icon.png")); f.addInternalFrameListener(this); if (osp.isLowResolution()) f.setSize(550, 282); else if (osp.isMidResolution()) f.setSize(550, 282); else f.setSize(850, 500); // Width, Height f.setVisible(true); try { f.setSelected(true); } catch (PropertyVetoException e1) { e1.printStackTrace(); } return f; }
public static void init( JInternalFrame comp, Thing thing, Container parent, ActionContext actionContext) { JComponentCreator.init(comp, thing, parent, actionContext); String title = JavaCreator.createText(thing, "title", actionContext); if (title != null) { comp.setTitle(title); } Boolean closable = JavaCreator.createBoolean(thing, "closable"); if (closable != null) { comp.setClosable(closable); } Boolean closed = JavaCreator.createBoolean(thing, "closed"); if (closed != null) { try { comp.setClosed(closed); } catch (PropertyVetoException e) { e.printStackTrace(); } } Cursor cursor = AwtCreator.createCursor(thing, "cursor", actionContext); if (cursor != null) { comp.setCursor(cursor); } Integer defaultCloseOperation = null; String d = thing.getString("defaultCloseOperation"); if ("DO_NOTHING_ON_CLOSE".equals(d)) { defaultCloseOperation = JInternalFrame.DO_NOTHING_ON_CLOSE; } else if ("HIDE_ON_CLOSE".equals(d)) { defaultCloseOperation = JInternalFrame.HIDE_ON_CLOSE; } else if ("DISPOSE_ON_CLOSE".equals(d)) { defaultCloseOperation = JInternalFrame.DISPOSE_ON_CLOSE; } if (defaultCloseOperation != null) { comp.setDefaultCloseOperation(defaultCloseOperation); } Boolean focusCycleRoot = JavaCreator.createBoolean(thing, "focusCycleRoot"); if (focusCycleRoot != null) { comp.setFocusCycleRoot(focusCycleRoot); } Icon frameIcon = SwingCreator.createIcon(thing, "frameIcon", actionContext); if (frameIcon != null) { comp.setFrameIcon(frameIcon); } Boolean setIcon = JavaCreator.createBoolean(thing, "setIcon"); if (setIcon != null) { try { comp.setIcon(setIcon); } catch (PropertyVetoException e) { e.printStackTrace(); } } Boolean iconifiable = JavaCreator.createBoolean(thing, "iconifiable"); if (iconifiable != null) { comp.setIconifiable(iconifiable); } Integer layer = JavaCreator.createInteger(thing, "layer"); if (layer != null) { comp.setLayer(layer); } Boolean maximizable = JavaCreator.createBoolean(thing, "maximizable"); if (maximizable != null) { comp.setMaximizable(maximizable); } Boolean maximum = JavaCreator.createBoolean(thing, "maximum"); if (maximum != null) { try { comp.setMaximum(maximum); } catch (PropertyVetoException e) { e.printStackTrace(); } } Boolean resizable = JavaCreator.createBoolean(thing, "resizable"); if (resizable != null) { comp.setResizable(resizable); } Boolean selected = JavaCreator.createBoolean(thing, "selected"); if (selected != null) { try { comp.setSelected(selected); } catch (PropertyVetoException e) { e.printStackTrace(); } } }
/** Invoked when an action occurs. */ public void actionPerformed(ActionEvent e) { String actionCmd = e.getActionCommand(); if (actionCmd.equals("cancel")) { closeForm(); } if (actionCmd.equals("new_branch")) { int index = Configurator.getIntProperty("newBranch", 0, "gui-forms"); DefaultForm form = Gui.getForm(index); if (form != null && !form.isClosed()) { form.pack(); try { form.setSelected(true); } catch (java.beans.PropertyVetoException ev) { } } else { BranchForm branchForm = new BranchForm(index, null); } } if (actionCmd.equals("checkout")) { boolean selected = false; for (int i = 0; i < myBranches.length; i++) { TableModel model = branchTable.getModel(); Boolean checked = (Boolean) model.getValueAt(i, 0); if (Boolean.TRUE.equals(checked)) selected = true; } int selectedRow = branchTable.getSelectedRow(); if (selected || (!selected && selectedRow >= 0)) checkoutItems(selected, selectedRow); else { showNoSectionMessage(); } } if (actionCmd.equals("edit")) { Point formLocation = null; int selectedRow = branchTable.getSelectedRow(); if (selectedRow >= 0) { Branch branchToEdit = (Branch) myBranches[selectedRow]; int editBranchIndex = Configurator.getIntProperty("editBranch", 0, "gui-forms"); JInternalFrame form = Gui.getForm(editBranchIndex); if (form != null && !form.isClosed()) { int switch_frame = getEditOpenedDialog(); if (switch_frame == JOptionPane.YES_OPTION) { formLocation = form.getLocation(); form.dispose(); BranchForm editBranch = new BranchForm(editBranchIndex, branchToEdit, selectedRow, formLocation); } else { try { form.setSelected(true); } catch (java.beans.PropertyVetoException ev) { } } } else { BranchForm editBranch = new BranchForm(editBranchIndex, branchToEdit, selectedRow, formLocation); } } // if(selectedRow>=0) else { showNoEditSelectionMessage(); } } if (actionCmd.equals("delete")) { boolean selected = false; for (int i = 0; i < myBranches.length; i++) { TableModel model = branchTable.getModel(); Boolean checked = (Boolean) model.getValueAt(i, 0); if (Boolean.TRUE.equals(checked)) selected = true; } int selectedRow = branchTable.getSelectedRow(); if (selected || (!selected && selectedRow >= 0)) deleteItems(selected, selectedRow); else { showNoDeleteSelectionMessage(); } } if (actionCmd.equals("branch_content")) { boolean selected = false; for (int i = 0; i < myBranches.length; i++) { TableModel model = branchTable.getModel(); Boolean checked = (Boolean) model.getValueAt(i, 0); if (Boolean.TRUE.equals(checked)) selected = true; } int selectedRow = branchTable.getSelectedRow(); if (selected || (!selected && selectedRow >= 0)) listItems(selected, selectedRow); else { showNoListcontentSection(); } } if (actionCmd.equals("select_all")) { selectAll(); } if (actionCmd.equals("select_all_pop")) { selectAllPop(); } }
@Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("about")) { new About_Controller().showView(); } else if (e.getActionCommand().equals("checkupdate")) { } else if (e.getActionCommand().equals("exit")) { System.exit(0); } else if (e.getActionCommand().equals("faq")) { } else if (e.getActionCommand().equals("help")) { // Open a general information window JTextArea textArea = new JTextArea(); addContent(textArea, new File_System_Controller().getModel().findFile("README.txt")); textArea.setEditable(false); textArea.setCaretPosition(java.awt.Frame.NORMAL); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); JScrollPane sc = new JScrollPane(textArea); sc.setPreferredSize(new Dimension(540, 250)); // Width, Height sc.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); String[] option = {lang_model.getValue(124)}; JOptionPane.showOptionDialog( f, sc, lang_model.getValue(33), JOptionPane.OK_OPTION, JOptionPane.QUESTION_MESSAGE, null, option, option[0]); } else if (e.getActionCommand().equals("newchild")) { JInternalFrame i = (JInternalFrame) new Child_Controller().showView(); desktop.add(i); try { i.setSelected(true); } catch (PropertyVetoException e1) { e1.printStackTrace(); } } else if (e.getActionCommand().equals("newemployee")) { JInternalFrame i = (JInternalFrame) new Employee_Controller().showView(); desktop.add(i); try { i.setSelected(true); } catch (PropertyVetoException e1) { e1.printStackTrace(); } } else if (e.getActionCommand().equals("newaccount")) { new Account_View().show(); } else if (e.getActionCommand().equals("properties")) { new Properties_Controller().showView(); } else if (e.getActionCommand().equals("reportbug")) { new Bug_Report_Controller().showView(); } else if (e.getActionCommand().equals("viewdatabase")) { new Table_Controller(desktop).showMenu(); } else if (e.getActionCommand().equals("viewchilddatabase")) { new Table_Controller(desktop).showView((byte) 0); } else if (e.getActionCommand().equals("viewemployeedatabase")) { new Table_Controller(desktop).showView((byte) 1); } }