Пример #1
1
 public int getTitleHeight(Component c) {
   int th = 21;
   int fh = getBorderInsets(c).top + getBorderInsets(c).bottom;
   if (c instanceof JDialog) {
     JDialog dialog = (JDialog) c;
     th = dialog.getSize().height - dialog.getContentPane().getSize().height - fh - 1;
     if (dialog.getJMenuBar() != null) {
       th -= dialog.getJMenuBar().getSize().height;
     }
   } else if (c instanceof JInternalFrame) {
     JInternalFrame frame = (JInternalFrame) c;
     th = frame.getSize().height - frame.getRootPane().getSize().height - fh - 1;
     if (frame.getJMenuBar() != null) {
       th -= frame.getJMenuBar().getSize().height;
     }
   } else if (c instanceof JRootPane) {
     JRootPane jp = (JRootPane) c;
     if (jp.getParent() instanceof JFrame) {
       JFrame frame = (JFrame) c.getParent();
       th = frame.getSize().height - frame.getContentPane().getSize().height - fh - 1;
       if (frame.getJMenuBar() != null) {
         th -= frame.getJMenuBar().getSize().height;
       }
     } else if (jp.getParent() instanceof JDialog) {
       JDialog dialog = (JDialog) c.getParent();
       th = dialog.getSize().height - dialog.getContentPane().getSize().height - fh - 1;
       if (dialog.getJMenuBar() != null) {
         th -= dialog.getJMenuBar().getSize().height;
       }
     }
   }
   return th;
 }
 public void actionPerformed(ActionEvent e) {
   final String S_ProcName = "actionPerformed";
   ICFCrmSchemaObj schemaObj = swingSchema.getSchema();
   if (schemaObj == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 0, "schemaObj");
   }
   ICFSecurityServiceTypeObj selectedInstance = getSwingFocusAsServiceType();
   if (selectedInstance != null) {
     String classCode = selectedInstance.getClassCode();
     if ("SVCT".equals(classCode)) {
       JInternalFrame frame =
           swingSchema.getServiceTypeFactory().newAskDeleteJInternalFrame(selectedInstance);
       ((ICFCrmSwingServiceTypeJPanelCommon) frame).setPanelMode(CFJPanel.PanelMode.View);
       frame.addInternalFrameListener(getViewEditInternalFrameListener());
       getDesktopPane().add(frame);
       frame.setVisible(true);
       frame.show();
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newUnsupportedClassException(
               getClass(),
               S_ProcName,
               "selectedInstance",
               selectedInstance,
               "ICFCrmServiceTypeObj");
     }
   }
 }
 public void actionPerformed(ActionEvent e) {
   final String S_ProcName = "actionPerformed";
   Container cont = getParent();
   while ((cont != null) && (!(cont instanceof JInternalFrame))) {
     cont = cont.getParent();
   }
   if (cont != null) {
     JInternalFrame frame = (JInternalFrame) cont;
     if (frame instanceof ICFSecuritySwingSecGroupFormJPanelCommon) {
       ICFSecuritySwingSecGroupFormJPanelCommon jpanelCommon =
           (ICFSecuritySwingSecGroupFormJPanelCommon) frame;
       jpanelCommon.setPanelMode(CFJPanel.PanelMode.Delete);
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newUnsupportedClassException(
               getClass(),
               S_ProcName,
               "frame",
               frame,
               "ICFSecuritySwingSecGroupFormJPanelCommon");
     }
     try {
       frame.setClosed(true);
     } catch (Exception x) {
     }
   }
 }
 public void actionPerformed(ActionEvent e) {
   final String S_ProcName = "actionPerformed";
   ICFSecuritySchemaObj schemaObj = swingSchema.getSchema();
   if (schemaObj == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 0, "schemaObj");
   }
   ICFSecurityHostNodeObj obj =
       (ICFSecurityHostNodeObj) schemaObj.getHostNodeTableObj().newInstance();
   ICFSecurityHostNodeEditObj edit = (ICFSecurityHostNodeEditObj) (obj.beginEdit());
   if (edit == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 0, "edit");
   }
   ICFSecurityClusterObj secCluster = schemaObj.getSecCluster();
   edit.setRequiredContainerCluster(secCluster);
   JInternalFrame frame = swingSchema.getHostNodeFactory().newViewEditJInternalFrame(obj);
   frame.addInternalFrameListener(getViewEditInternalFrameListener());
   ICFSecuritySwingHostNodeJPanelCommon jpanelCommon =
       (ICFSecuritySwingHostNodeJPanelCommon) frame;
   jpanelCommon.setPanelMode(CFJPanel.PanelMode.Add);
   getDesktopPane().add(frame);
   frame.setVisible(true);
   frame.show();
 }
 public void actionPerformed(ActionEvent e) {
   final String S_ProcName = "actionPerformed";
   Container cont = getParent();
   while ((cont != null) && (!(cont instanceof JInternalFrame))) {
     cont = cont.getParent();
   }
   if (cont != null) {
     JInternalFrame frame = (JInternalFrame) cont;
     if (frame instanceof ICFSecuritySwingISOCurrencyJPanelCommon) {
       ICFSecuritySwingISOCurrencyJPanelCommon jpanelCommon =
           (ICFSecuritySwingISOCurrencyJPanelCommon) frame;
       jpanelCommon.setPanelMode(CFJPanel.PanelMode.Unknown);
       ICFSecurityISOCurrencyEditObj editObj =
           (ICFSecurityISOCurrencyEditObj) jpanelCommon.getSwingFocusAsISOCurrency().getEdit();
       if (editObj != null) {
         editObj.endEdit();
       }
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newUnsupportedClassException(
               getClass(),
               S_ProcName,
               "frame",
               frame,
               "ICFSecuritySwingISOCurrencyJPanelCommon");
     }
     try {
       frame.setClosed(true);
     } catch (Exception x) {
     }
   }
 }
 public void actionPerformed(ActionEvent e) {
   final String S_ProcName = "actionPerformed";
   ICFInternetDomainBaseObj focus = getSwingFocusAsDomainBase();
   if (focus != null) {
     ICFInternetDomainBaseEditObj editObj = (ICFBamDomainBaseEditObj) focus.getEdit();
     if (editObj != null) {
       focus = editObj;
     }
     JInternalFrame frame = null;
     Container cont;
     JDesktopPane desktop;
     ICFBamTenantObj referencedObj =
         (ICFBamTenantObj) focus.getRequiredOwnerTenant(swingIsInitializing);
     if (referencedObj != null) {
       String classCode = referencedObj.getClassCode();
       if ("TENT".equals(classCode)) {
         frame = swingSchema.getTenantFactory().newViewEditJInternalFrame(referencedObj);
         cont = getParent();
         while ((cont != null) && (!(cont instanceof JInternalFrame))) {
           cont = cont.getParent();
         }
         if (cont != null) {
           JInternalFrame myInternalFrame = (JInternalFrame) cont;
           myInternalFrame.getDesktopPane().add(frame);
           frame.setVisible(true);
           frame.show();
         }
       } else {
         throw CFLib.getDefaultExceptionFactory()
             .newUnsupportedClassException(
                 getClass(), S_ProcName, "swingFocus", focus, "ICFBamTenantObj");
       }
     }
   }
 }
Пример #7
0
 public void init() {
   // 向内部窗口中添加组件
   iframe.add(new JScrollPane(new JTextArea(8, 40)));
   desktop.setPreferredSize(new Dimension(400, 300));
   // 把虚拟桌面添加到JFrame窗口中
   jf.add(desktop);
   // 设置内部窗口的大小、位置
   iframe.reshape(0, 0, 300, 200);
   // 显示并选中内部窗口
   iframe.show();
   desktop.add(iframe);
   JPanel jp = new JPanel();
   deskBn.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           // 弹出内部对话框,以虚拟桌面作为父组件
           JOptionPane.showInternalMessageDialog(desktop, "属于虚拟桌面的对话框");
         }
       });
   internalBn.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           // 弹出内部对话框,以内部窗口作为父组件
           JOptionPane.showInternalMessageDialog(iframe, "属于内部窗口的对话框");
         }
       });
   jp.add(deskBn);
   jp.add(internalBn);
   jf.add(jp, BorderLayout.SOUTH);
   jf.pack();
   jf.setVisible(true);
 }
  /**
   * Reacts to property change events 'editorClosing', 'closeFrame', and 'name'.
   *
   * @param e the property change event.
   */
  public void propertyChange(PropertyChangeEvent e) {

    // Handles the removal of editor frames from desktop
    String name = e.getPropertyName();

    if ("editorClosing".equals(name)) {

      // find NewValue in String array, and remove
      for (int n = 0; n < sessionNodeKeys.size(); n++) {
        if (e.getNewValue().equals((sessionNodeKeys.get(n)))) {
          sessionNodeKeys.remove(n);
        }
      }
    } else if ("closeFrame".equals(e.getPropertyName())) {
      if (getFramesMap().containsKey(e.getSource())) {
        Object frameObject = getFramesMap().get(e.getSource());
        JInternalFrame frame = (JInternalFrame) frameObject;
        frame.setVisible(false);
        frame.dispose();
      }
    } else if ("name".equals(e.getPropertyName())) {
      if (getFramesMap().containsKey(e.getSource())) {
        Object frameObject = getFramesMap().get(e.getSource());
        JInternalFrame frame = (JInternalFrame) frameObject;
        String _name = (String) (e.getNewValue());
        frame.setTitle(_name);
        setMainTitle(_name);
      }
    }
  }
 public void mousePressed(MouseEvent e) {
   if (e.getButton() != MouseEvent.BUTTON1) {
     return;
   }
   if (e.getClickCount() != 2) {
     return;
   }
   JTable table = (JTable) e.getSource();
   Point p = e.getPoint();
   int row = table.rowAtPoint(p);
   if (row < 0) {
     return;
   }
   FinderTableModel model = getDataModel();
   ICFSecurityISOTimezoneObj o =
       (ICFSecurityISOTimezoneObj) model.getValueAt(row, COLID_ROW_HEADER);
   if (o == null) {
     return;
   }
   JInternalFrame frame = swingSchema.getISOTimezoneFactory().newViewEditJInternalFrame(o);
   ((ICFSecuritySwingISOTimezoneJPanelCommon) frame).setPanelMode(CFJPanel.PanelMode.View);
   if (frame == null) {
     return;
   }
   Container cont = getParent();
   while ((cont != null) && (!(cont instanceof JInternalFrame))) {
     cont = cont.getParent();
   }
   if (cont != null) {
     JInternalFrame myInternalFrame = (JInternalFrame) cont;
     myInternalFrame.getDesktopPane().add(frame);
     frame.setVisible(true);
     frame.show();
   }
 }
Пример #10
0
  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);
    /* Jimmy: this is a bit buggy (frames get constant size)
    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;
  }
 public boolean isEnabled() {
   JInternalFrame iFrame = desktop.getSelectedFrame();
   if (iFrame != null) {
     return iFrame.isMaximizable();
   }
   return false;
 }
Пример #12
0
 public void disposeCurrentFrame() {
   if (currentFrame != null) {
     lastLocation = currentFrame.getLocation();
     currentFrame.setVisible(false);
     currentFrame.dispose();
     currentFrame = null;
   }
 }
 public void testRecordsFrameClosing()
     throws PropertyVetoException, InterruptedException, InvocationTargetException {
   JInternalFrame internalFrame = createInternalFrame();
   int initialListenerCount = internalFrameListenerCount(internalFrame);
   mockRecorder.expects(once()).method("record").with(eq(new InternalFrameShownEvent("title")));
   recorder.componentShown(internalFrame);
   mockRecorder.expects(once()).method("record").with(eq(new CloseInternalFrameEvent("title")));
   internalFrame.setClosed(true);
 }
 public void openInBox() {
   JInternalFrame doc = new MetalworksInBox();
   desktop.add(doc, DOCLAYER);
   try {
     doc.setVisible(true);
     doc.setSelected(true);
   } catch (java.beans.PropertyVetoException e2) {
   }
 }
Пример #15
0
  private synchronized void display(ExtSed sed) {

    manageAssociatedManagerWindows(sed);

    try {

      SpectrumContainer container =
          (SpectrumContainer) sed.getAttachment(IrisDisplayManager.FIT_MODEL);

      // There is no Sed attachment, so build a model manager and attach it.

      if (container == null) {
        if (buildAttachment(sed)) {
          return;
        }
      }

      // VAOPD-879: spectrum name must be identical with Sed name.
      if (container != null) {
        container.getSpectrum().setName(sed.getId());
      }

      // Now display the Sed.

      idm.display(sed, sed.getId());

      // and add its frame to the workspace.

      JInternalFrame frame = idm.getInternalFrame();

      // VAOPD-863
      frame.setTitle(sed.getId());

      if (container != null) {
        JFrame modelManagerFrame = container.getModelManager().getFrame();
        if (modelManagerFrame != null) {
          modelManagerFrame.setTitle(sed.getId());
        }
      }

      if (frame != currentFrame) {
        lastLocation = null;
        disposeCurrentFrame();
        currentFrame = frame;
        currentFrame.setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE);
        if (lastLocation != null) {
          currentFrame.setLocation(lastLocation);
        }
        frame.setTitle("Iris Visualizer");
        ws.addFrame(frame);
      }

    } catch (Exception ex) {
      LogEvent.getInstance().fire(this, new LogEntry("Error: " + ex.getMessage(), sed));
      Logger.getLogger("IrisVisualizer").log(Level.SEVERE, null, ex);
    }
  }
 public void openHelpWindow() {
   JInternalFrame help = new MetalworksHelp();
   desktop.add(help, HELPLAYER);
   try {
     help.setVisible(true);
     help.setSelected(true);
   } catch (java.beans.PropertyVetoException e2) {
   }
 }
 /**
  * Removes the desktopIcon from its parent and adds its frame to the parent.
  *
  * @param f the <code>JInternalFrame</code> to be de-iconified
  */
 public void deiconifyFrame(JInternalFrame f) {
   JInternalFrame.JDesktopIcon desktopIcon = f.getDesktopIcon();
   Container c = desktopIcon.getParent();
   JDesktopPane d = f.getDesktopPane();
   if (c != null && d != null) {
     c.add(f);
     // If the frame is to be restored to a maximized state make
     // sure it still fills the whole desktop.
     if (f.isMaximum()) {
       Rectangle desktopBounds = c.getBounds();
       if (f.getWidth() != desktopBounds.width || f.getHeight() != desktopBounds.height) {
         setBoundsForFrame(f, 0, 0, desktopBounds.width, desktopBounds.height);
       }
     }
     removeIconFor(f);
     if (f.isSelected()) {
       f.moveToFront();
       f.restoreSubcomponentFocus();
     } else {
       try {
         f.setSelected(true);
       } catch (PropertyVetoException e2) {
       }
     }
   }
 }
 public void testContextIsJFrameWhenInternalFrameIsShown() {
   JFrame frame = new JFrame();
   JInternalFrame internalFrame = new JInternalFrame();
   JTextField textField = new JTextField();
   setFocusManager(textField);
   internalFrame.getContentPane().add(textField);
   frame.getContentPane().add(internalFrame);
   windowContext.propertyChange(new PropertyChangeEvent(this, "focusOwner", null, textField));
   assertSame(frame, windowContext.activeWindow());
   assertSame(frame, windowContext.activeTopLevelWindow());
 }
Пример #19
0
 MyDesktop() {
   // fr1 = new JInternalFrame("FlowLayout", true, true);
   fr1.setBounds(10, 10, 150, 150);
   Container c = fr1.getContentPane();
   c.setLayout(new FlowLayout());
   c.add(new JButton("1"));
   c.add(new JButton("2"));
   c.add(new JButton("3"));
   c.add(new JButton("4"));
   add(fr1, 0);
 }
 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());
 }
Пример #21
0
 // 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));
   }
 }
Пример #22
0
 @Override
 protected JComponent createControl() {
   JComponent pageComponentControl = getPageComponent().getControl();
   if (pageComponentControl.getName() == null) {
     nameComponent(pageComponentControl, "Control");
   }
   internalFrame = new JInternalFrame();
   configureControl();
   internalFrame.getContentPane().add(pageComponentControl, BorderLayout.CENTER);
   internalFrame.addInternalFrameListener(new InternalFrameHandler());
   nameComponent(internalFrame, "Pane");
   return internalFrame;
 }
 public void actionPerformed(ActionEvent e) {
   Container cont = getParent();
   while ((cont != null) && (!(cont instanceof JInternalFrame))) {
     cont = cont.getParent();
   }
   if (cont != null) {
     JInternalFrame frame = (JInternalFrame) cont;
     try {
       frame.setClosed(true);
     } catch (Exception x) {
     }
   }
 }
  /**
   * 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 SessionEditor getFrontmostSessionEditor() {
    JInternalFrame[] allFrames = desktopPane.getAllFramesInLayer(0);

    if (allFrames.length == 0) {
      return null;
    }

    JInternalFrame frontmostFrame = allFrames[0];
    Object o = frontmostFrame.getContentPane().getComponents()[0];

    boolean isSessionEditor = o instanceof SessionEditor;
    return isSessionEditor ? (SessionEditor) o : null;
  }
  /** Returns true iff there exist a session in the desktop. */
  private boolean existsSession() {
    JInternalFrame[] allFrames = desktopPane.getAllFramesInLayer(0);

    for (JInternalFrame allFrame : allFrames) {
      Object o = allFrame.getContentPane().getComponents()[0];

      if (o instanceof SessionEditor) {
        return true;
      }
    }

    return false;
  }
Пример #27
0
  private JInternalFrame _startJFXImpuestosCRUD() {
    frame = new JInternalFrame("Administrador de impuestos");
    final JFXPanel fxPanel = new JFXPanel();

    frame.setClosable(true);
    frame.add(fxPanel);
    frame.setVisible(true);

    Herramientas.panelCatalogo(frame);
    Principal.getEscritorio().getPanelEscritorio().add(frame);
    frame.setSize(706, 518);
    frame.setPreferredSize(new Dimension(706, 518));
    frame.setResizable(true);
    frame.setVisible(true);
    Herramientas.centrarVentana(frame);
    Herramientas.iconificable(frame);
    frame.toFront();

    Platform.runLater(
        new Runnable() {
          @Override
          public void run() {
            Scene scene = null;
            try {
              scene = initImpuestosCRUD();
              scene.setFill(null);
              fxPanel.setScene(scene);
            } catch (IOException e) {

            }
          }
        });

    return frame;
  }
 public void mousePressed(MouseEvent e) {
   if (e.getButton() != MouseEvent.BUTTON1) {
     return;
   }
   if (e.getClickCount() != 2) {
     return;
   }
   JTable table = (JTable) e.getSource();
   Point p = e.getPoint();
   int row = table.rowAtPoint(p);
   if (row < 0) {
     return;
   }
   PickerTableModel model = getDataModel();
   ICFInternetISOCountryObj o =
       (ICFInternetISOCountryObj) model.getValueAt(row, COLID_ROW_HEADER);
   invokeWhenChosen.choseISOCountry(o);
   try {
     Container cont = getParent();
     while ((cont != null) && (!(cont instanceof JInternalFrame))) {
       cont = cont.getParent();
     }
     if (cont != null) {
       ((JInternalFrame) cont).setClosed(true);
     }
   } catch (Exception x) {
   }
 }
 @RunsInCurrentThread
 private static void validateCanMaximize(JInternalFrame internalFrame) {
   validateIsShowingOrIconified(internalFrame);
   if (!internalFrame.isMaximizable())
     throw new IllegalStateException(
         concat("The JInternalFrame <", format(internalFrame), "> is not maximizable"));
 }
 @RunsInCurrentThread
 private static void validateCanClose(JInternalFrame internalFrame) {
   validateIsShowing(internalFrame);
   if (!internalFrame.isClosable())
     throw new IllegalStateException(
         concat("The JInternalFrame <", format(internalFrame), "> is not closable"));
 }