Example usage for javax.swing JInternalFrame setTitle

List of usage examples for javax.swing JInternalFrame setTitle

Introduction

In this page you can find the example usage for javax.swing JInternalFrame setTitle.

Prototype

@BeanProperty(preferred = true, description = "The text displayed in the title bar.")
public void setTitle(String title) 

Source Link

Document

Sets the JInternalFrame title.

Usage

From source file:guineu.modules.dataanalysis.PCA.PCADataset.java

public void run() {

    setStatus(TaskStatus.PROCESSING);//from w  w  w.j  a  v  a  2  s. c o  m

    logger.info("Computing projection plot");

    double[][] rawData = new double[selectedSamples.length][selectedRows.length];
    for (int rowIndex = 0; rowIndex < selectedRows.length; rowIndex++) {
        PeakListRow peakListRow = selectedRows[rowIndex];
        for (int fileIndex = 0; fileIndex < selectedSamples.length; fileIndex++) {
            String rawDataFile = selectedSamples[fileIndex];
            Object p = peakListRow.getPeak(rawDataFile);
            try {
                rawData[fileIndex][rowIndex] = (Double) p;
            } catch (Exception e) {
                // e.printStackTrace();
            }

        }
    }
    this.progress = 0.25f;

    int numComponents = xAxisPC;
    if (yAxisPC > numComponents) {
        numComponents = yAxisPC;
    }

    PCA pca = new PCA(selectedSamples.length, selectedRows.length);

    Matrix X = new Matrix(rawData, selectedSamples.length, selectedRows.length);

    String[] rowNames = new String[selectedRows.length];
    for (int j = 0; j < selectedRows.length; j++) {
        rowNames[j] = selectedRows[j].getName();
    }

    X = pca.center(X);
    X = pca.scale(X);
    pca.nipals(X, this.selectedSamples, rowNames, this.components);
    mainComponents = pca.getPCs();
    Collections.sort(mainComponents);
    if (status == TaskStatus.CANCELED) {
        return;
    }
    this.progress = 0.75f;

    for (PrincipleComponent comp : mainComponents) {
        this.totalVariation += comp.eigenValue;
    }

    if (mainComponents.size() > yAxisPC - 1) {
        component1Coords = mainComponents.get(xAxisPC - 1).eigenVector;
        component2Coords = mainComponents.get(yAxisPC - 1).eigenVector;

        Desktop desktop = GuineuCore.getDesktop();
        ProjectionPlotWindow newFrame = new ProjectionPlotWindow(this.datasetTitle, this, parameters);
        desktop.addInternalFrame(newFrame);

        if (this.showLoadings) {
            ChartPanel loadings = pca.loadingsplot(this.getXLabel(), this.getYLabel());
            JInternalFrame frame = new JInternalFrame();
            frame.setTitle("Principal Components Analysis: Loadings");
            frame.setResizable(true);
            frame.setClosable(true);
            frame.setMaximizable(true);
            frame.add(loadings, BorderLayout.CENTER);
            frame.setPreferredSize(new Dimension(700, 500));
            frame.pack();
            desktop.addInternalFrame(frame);
        }
    }
    this.progress = 1.0f;
    setStatus(TaskStatus.FINISHED);
    logger.info("Finished computing projection plot.");

}

From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java

protected JInternalFrame createFrame() {
    JInternalFrame frame = new JInternalFrame("Some frame");
    frame.setBounds(30, 30, 300, 300);/*from w  w w  .  j av a2s. c o  m*/
    frame.setTitle("Some frame");
    frame.setVisible(true);
    return frame;
}

From source file:mondrian.gui.Workbench.java

private void aboutMenuItemActionPerformed(ActionEvent evt) {
    try {//from   w w w  .  ja  v a  2s .c om
        JEditorPane jEditorPane = new JEditorPane(
                myClassLoader.getResource(getResourceConverter().getGUIReference("version")).toString());
        jEditorPane.setEditable(false);
        JScrollPane jScrollPane = new JScrollPane(jEditorPane);
        JPanel jPanel = new JPanel();
        jPanel.setLayout(new java.awt.BorderLayout());
        jPanel.add(jScrollPane, java.awt.BorderLayout.CENTER);

        JInternalFrame jf = new JInternalFrame();
        jf.setTitle("About");
        jf.getContentPane().add(jPanel);

        Dimension screenSize = this.getSize();
        int aboutW = 400;
        int aboutH = 300;
        int width = (screenSize.width / 2) - (aboutW / 2);
        int height = (screenSize.height / 2) - (aboutH / 2) - 100;
        jf.setBounds(width, height, aboutW, aboutH);
        jf.setClosable(true);

        desktopPane.add(jf);

        jf.setVisible(true);
        jf.show();
    } catch (Exception ex) {
        LOGGER.error("aboutMenuItemActionPerformed", ex);
    }
}

From source file:mondrian.gui.Workbench.java

private void newQueryMenuItemActionPerformed(ActionEvent evt) {
    JMenuItem schemaMenuItem = schemaWindowMap.get(desktopPane.getSelectedFrame());

    final JInternalFrame jf = new JInternalFrame();
    jf.setTitle(getResourceConverter().getString("workbench.new.MDXQuery.title", "MDX Query"));
    QueryPanel qp = new QueryPanel(this);

    jf.getContentPane().add(qp);//from   w  w w  . j a  v a 2  s  .  co  m
    jf.setBounds(0, 0, 500, 480);
    jf.setClosable(true);
    jf.setIconifiable(true);
    jf.setMaximizable(true);
    jf.setResizable(true);
    jf.setVisible(true);

    desktopPane.add(jf);
    jf.show();
    try {
        jf.setSelected(true);
    } catch (Exception ex) {
        // do nothing
        LOGGER.error("newQueryMenuItemActionPerformed.setSelected", ex);
    }

    // add the mdx frame to this set of mdx frames for cascading method
    mdxWindows.add(jf);

    // create mdx menu item
    final javax.swing.JMenuItem queryMenuItem = new javax.swing.JMenuItem();
    queryMenuItem.setText(getResourceConverter().getFormattedString("workbench.new.MDXQuery.menuitem",
            "{0} MDX", Integer.toString(windowMenuMapIndex)));
    queryMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            try {
                if (jf.isIcon()) {
                    jf.setIcon(false);
                } else {
                    jf.setSelected(true);
                }
            } catch (Exception ex) {
                LOGGER.error("queryMenuItem", ex);
            }
        }
    });

    // disable mdx frame close operation to provide our handler
    // to remove frame object from mdxframeset before closing
    jf.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

    jf.addInternalFrameListener(new InternalFrameAdapter() {
        public void internalFrameClosing(InternalFrameEvent e) {
            mdxWindows.remove(jf);
            jf.dispose();
            // follow this by removing file from schemaWindowMap
            windowMenu.remove(queryMenuItem);
            return;
        }
    });

    windowMenu.add(queryMenuItem, -1);
    windowMenu.add(jSeparator3, -1);
    windowMenu.add(cascadeMenuItem, -1);
    windowMenu.add(tileMenuItem, -1);
    windowMenu.add(minimizeMenuItem, -1);
    windowMenu.add(maximizeMenuItem, -1);
    windowMenu.add(closeAllMenuItem, -1);

    qp.setMenuItem(queryMenuItem);
    qp.setSchemaWindowMap(schemaWindowMap);
    qp.setWindowMenuIndex(windowMenuMapIndex++);

    if (schemaMenuItem != null) {
        qp.initConnection(schemaMenuItem.getText());
    } else {
        JOptionPane.showMessageDialog(this,
                getResourceConverter().getString("workbench.new.MDXQuery.no.selection",
                        "No Mondrian connection. Select a Schema to connect."),
                getResourceConverter().getString("workbench.new.MDXQuery.no.selection.title", "Alert"),
                JOptionPane.WARNING_MESSAGE);
    }
}

From source file:mondrian.gui.Workbench.java

private void newJDBCExplorerMenuItemActionPerformed(ActionEvent evt) {
    try {//  ww  w .  ja va 2s.c  o  m
        if (jdbcMetaData == null) {
            getNewJdbcMetadata();
        }

        final JInternalFrame jf = new JInternalFrame();

        jf.setTitle(getResourceConverter().getFormattedString("workbench.new.JDBCExplorer.title",
                "JDBC Explorer - {0} {1}", jdbcMetaData.getDatabaseProductName(),
                jdbcMetaData.getJdbcConnectionUrl()));
        getNewJdbcMetadata();

        JdbcExplorer jdbce = new JdbcExplorer(jdbcMetaData, this);

        jf.getContentPane().add(jdbce);
        jf.setBounds(0, 0, 500, 480);
        jf.setClosable(true);
        jf.setIconifiable(true);
        jf.setMaximizable(true);
        jf.setResizable(true);
        jf.setVisible(true);

        // create jdbc menu item
        final javax.swing.JMenuItem jdbcMenuItem = new javax.swing.JMenuItem();
        jdbcMenuItem.setText(getResourceConverter().getFormattedString("workbench.new.JDBCExplorer.menuitem",
                "{0} JDBC Explorer", Integer.toString(windowMenuMapIndex++)));
        jdbcMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                try {
                    if (jf.isIcon()) {
                        jf.setIcon(false);
                    } else {
                        jf.setSelected(true);
                    }
                } catch (Exception ex) {
                    LOGGER.error("queryMenuItem", ex);
                }
            }
        });

        jf.addInternalFrameListener(new InternalFrameAdapter() {
            public void internalFrameClosing(InternalFrameEvent e) {
                jdbcWindows.remove(jf);
                jf.dispose();
                // follow this by removing file from schemaWindowMap
                windowMenu.remove(jdbcMenuItem);
                return;
            }
        });

        desktopPane.add(jf);
        jf.setVisible(true);
        jf.show();

        try {
            jf.setSelected(true);
        } catch (Exception ex) {
            // do nothing
            LOGGER.error("newJDBCExplorerMenuItemActionPerformed.setSelected", ex);
        }

        jdbcWindows.add(jf);

        windowMenu.add(jdbcMenuItem, -1);
        windowMenu.add(jSeparator3, -1);
        windowMenu.add(cascadeMenuItem, -1);
        windowMenu.add(tileMenuItem, -1);
        windowMenu.add(minimizeMenuItem, -1);
        windowMenu.add(maximizeMenuItem, -1);
        windowMenu.add(closeAllMenuItem, -1);
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(this,
                getResourceConverter().getFormattedString("workbench.new.JDBCExplorer.exception",
                        "Database connection not successful.\n{0}", ex.getLocalizedMessage()),
                getResourceConverter().getString("workbench.new.JDBCExplorer.exception.title",
                        "Database Connection Error"),
                JOptionPane.ERROR_MESSAGE);
        LOGGER.error("newJDBCExplorerMenuItemActionPerformed", ex);
    }
}

From source file:mondrian.gui.Workbench.java

private void openSchemaFrame(File file, boolean newFile) {
    try {/*from  ww  w.j a  v  a2  s.  co  m*/
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

        if (!newFile) {
            // check if file not already open
            if (checkFileOpen(file)) {
                return;
            }
            // check if schema file exists
            if (!file.exists()) {
                JOptionPane.showMessageDialog(this,
                        getResourceConverter().getFormattedString("workbench.open.schema.not.found",
                                "{0} File not found.", file.getAbsolutePath()),
                        getResourceConverter().getString("workbench.open.schema.not.found.title", "Alert"),
                        JOptionPane.WARNING_MESSAGE);
                return;
            }
            // check if file is writable
            if (!file.canWrite()) {
                JOptionPane.showMessageDialog(this,
                        getResourceConverter().getFormattedString("workbench.open.schema.not.writeable",
                                "{0} is not writeable.", file.getAbsolutePath()),
                        getResourceConverter().getString("workbench.open.schema.not.writeable.title", "Alert"),
                        JOptionPane.WARNING_MESSAGE);
                return;
            }
            checkSchemaFile(file);
        }

        final JInternalFrame schemaFrame = new JInternalFrame();
        schemaFrame.setTitle(getResourceConverter().getFormattedString("workbench.open.schema.title",
                "Schema - {0}", file.getName()));

        getNewJdbcMetadata();

        schemaFrame.getContentPane().add(new SchemaExplorer(this, file, jdbcMetaData, newFile, schemaFrame));

        String errorOpening = ((SchemaExplorer) schemaFrame.getContentPane().getComponent(0)).getErrMsg();
        if (errorOpening != null) {
            JOptionPane.showMessageDialog(this,
                    getResourceConverter().getFormattedString("workbench.open.schema.error",
                            "Error opening schema - {0}.", errorOpening),
                    getResourceConverter().getString("workbench.open.schema.error.title", "Error"),
                    JOptionPane.ERROR_MESSAGE);
            schemaFrame.setClosed(true);
            return;
        }

        schemaFrame.setBounds(0, 0, 1000, 650);
        schemaFrame.setClosable(true);
        schemaFrame.setIconifiable(true);
        schemaFrame.setMaximizable(true);
        schemaFrame.setResizable(true);
        schemaFrame.setVisible(true);

        desktopPane.add(schemaFrame, javax.swing.JLayeredPane.DEFAULT_LAYER);
        schemaFrame.show();
        schemaFrame.setMaximum(true);

        displayWarningOnFailedConnection();

        final javax.swing.JMenuItem schemaMenuItem = new javax.swing.JMenuItem();
        schemaMenuItem.setText(windowMenuMapIndex++ + " " + file.getName());
        schemaMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                try {
                    if (schemaFrame.isIcon()) {
                        schemaFrame.setIcon(false);
                    } else {
                        schemaFrame.setSelected(true);
                    }
                } catch (Exception ex) {
                    LOGGER.error("schemaMenuItem", ex);
                }
            }
        });

        windowMenu.add(schemaMenuItem, 0);
        windowMenu.setEnabled(true);

        windowMenu.add(jSeparator3, -1);
        windowMenu.add(cascadeMenuItem, -1);
        windowMenu.add(tileMenuItem, -1);
        windowMenu.add(minimizeMenuItem, -1);
        windowMenu.add(maximizeMenuItem, -1);
        windowMenu.add(closeAllMenuItem, -1);

        // add the file details in menu map
        schemaWindowMap.put(schemaFrame, schemaMenuItem);
        updateMDXCatalogList();

        schemaFrame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

        schemaFrame.addInternalFrameListener(new InternalFrameAdapter() {
            public void internalFrameClosing(InternalFrameEvent e) {
                if (schemaFrame.getContentPane().getComponent(0) instanceof SchemaExplorer) {
                    SchemaExplorer se = (SchemaExplorer) schemaFrame.getContentPane().getComponent(0);
                    int response = confirmFrameClose(schemaFrame, se);
                    if (response == 3) { // not dirty
                        if (se.isNewFile()) {
                            se.getSchemaFile().delete();
                        }
                        // default case for no save and not dirty
                        schemaWindowMap.remove(schemaFrame);
                        updateMDXCatalogList();
                        schemaFrame.dispose();
                        windowMenu.remove(schemaMenuItem);
                    }
                }
            }
        });

        schemaFrame.setFocusable(true);
        schemaFrame.addFocusListener(new FocusAdapter() {
            public void focusGained(FocusEvent e) {
                if (schemaFrame.getContentPane().getComponent(0) instanceof SchemaExplorer) {
                    SchemaExplorer se = (SchemaExplorer) schemaFrame.getContentPane().getComponent(0);
                    // update view menu based on schemaframe who gained
                    // focus
                    viewXmlMenuItem.setSelected(se.isEditModeXML());
                }
            }

            public void focusLost(FocusEvent e) {
                if (schemaFrame.getContentPane().getComponent(0) instanceof SchemaExplorer) {
                    SchemaExplorer se = (SchemaExplorer) schemaFrame.getContentPane().getComponent(0);
                    // update view menu based on
                    viewXmlMenuItem.setSelected(se.isEditModeXML());
                }
            }
        });
        viewXmlMenuItem.setSelected(false);
    } catch (Exception ex) {
        LOGGER.error("openSchemaFrame", ex);
    } finally {
        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }
}

From source file:mondrian.gui.Workbench.java

/**
 * Updates the JdbcMetaData for each SchemaExplorer contained in each Schema
 * Frame currently opened based on the JDBC preferences entered.
 *//*from w  ww  . jav  a2s  . c  o  m*/
private void resetWorkbench() {
    getNewJdbcMetadata();

    Iterator<JInternalFrame> theSchemaFrames = schemaWindowMap.keySet().iterator();
    while (theSchemaFrames.hasNext()) {
        JInternalFrame theSchemaFrame = theSchemaFrames.next();
        SchemaExplorer theSchemaExplorer = (SchemaExplorer) theSchemaFrame.getContentPane().getComponent(0);
        File theFile = theSchemaExplorer.getSchemaFile();
        checkSchemaFile(theFile);
        theSchemaExplorer.resetMetaData(jdbcMetaData);
        theSchemaExplorer.getTreeUpdater().update();
        theSchemaFrame.updateUI();
    }
    // EC: If the JDBC preferences entered then display a warning.
    displayWarningOnFailedConnection();

    for (JInternalFrame jdbcFrame : jdbcWindows) {
        JdbcExplorer explorer = (JdbcExplorer) jdbcFrame.getContentPane().getComponent(0);
        explorer.resetMetaData(jdbcMetaData);

        jdbcFrame.setTitle(getResourceConverter().getFormattedString("workbench.new.JDBCExplorer.title",
                "JDBC Explorer - {0} {1}", jdbcMetaData.getDatabaseProductName(),
                jdbcMetaData.getJdbcConnectionUrl()));

        explorer.getTreeUpdater().update();
        explorer.updateUI();
    }
}

From source file:com.g2inc.scap.editor.gui.windows.EditorMainWindow.java

private void initFilemenu() {
    final EditorMainWindow parentWinRef = this;

    exitMenuItem.addActionListener(new ActionListener() {
        @Override/*from  w ww  .j  av a 2  s .  co  m*/
        public void actionPerformed(ActionEvent e) {
            parentWinRef.dispose();
        }
    });

    openOvalMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            final JFileChooser fc = new JFileChooser();
            fc.setDialogType(JFileChooser.OPEN_DIALOG);

            File lastOpenedFrom = guiProps.getLastOpenedFromFile();

            // Set current directory
            fc.setCurrentDirectory(lastOpenedFrom);

            FileFilter ff = new OcilOrOvalFilesFilter("OVAL");
            fc.setFileFilter(ff);
            fc.setFileSelectionMode(JFileChooser.FILES_ONLY);

            int ret = fc.showOpenDialog(EditorMainWindow.getInstance());

            if (ret == JFileChooser.APPROVE_OPTION) {
                File f = fc.getSelectedFile();
                File parent = f.getAbsoluteFile().getParentFile();
                guiProps.setLastOpenedFrom(parent.getAbsolutePath());
                guiProps.save();

                openFile(f, SCAPDocumentClassEnum.OVAL);
            }
        }
    });

    saveMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            // get the currently open window
            JInternalFrame selectedWin = desktopPane.getSelectedFrame();

            if (selectedWin != null) {
                SCAPDocument scapDoc = null;

                Document dom = null;
                String filename = null;

                if (selectedWin instanceof OvalEditorForm) {
                    OvalEditorForm oef = (OvalEditorForm) selectedWin;
                    scapDoc = oef.getDocument();
                    dom = scapDoc.getDoc();
                    filename = scapDoc.getFilename();
                } else if (selectedWin instanceof CPEDictionaryEditorForm) {
                    CPEDictionaryEditorForm cef = (CPEDictionaryEditorForm) selectedWin;
                    scapDoc = cef.getDocument();
                    dom = scapDoc.getDoc();
                    filename = scapDoc.getFilename();
                }

                if (dom != null) {
                    // since this is a save operation, not save as, we won't
                    // prompt the user for where to store the file

                    try {
                        scapDoc.save();
                        ((EditorForm) selectedWin).setDirty(false);
                    } catch (Exception e) {
                        String message = "An error occured trying to save to file " + filename + ": "
                                + e.getMessage();
                        EditorUtil.showMessageDialog(parentWinRef, message,
                                EditorMessages.SAVE_ERROR_DIALOG_TITLE, JOptionPane.ERROR_MESSAGE);
                    }
                }
            }
        }
    });

    saveAsMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            // get the currently open window
            JInternalFrame selectedWin = desktopPane.getSelectedFrame();

            if (selectedWin != null) {
                SCAPDocument scapDoc = null;
                Document dom = null;
                String filename = null;
                String windowTitle = null;

                if (selectedWin instanceof OvalEditorForm) {
                    windowTitle = OvalEditorForm.WINDOW_TITLE_BASE;
                    OvalEditorForm oef = (OvalEditorForm) selectedWin;
                    scapDoc = oef.getDocument();
                    dom = scapDoc.getDoc();
                    filename = scapDoc.getFilename();
                } else if (selectedWin instanceof CPEDictionaryEditorForm) {
                    windowTitle = CPEDictionaryEditorForm.WINDOW_TITLE_BASE;
                    CPEDictionaryEditorForm cef = (CPEDictionaryEditorForm) selectedWin;
                    scapDoc = cef.getDocument();
                    dom = scapDoc.getDoc();
                    filename = scapDoc.getFilename();
                } else {
                    return;
                }

                if (dom != null) {
                    String newFilename = null;
                    SCAPDocumentTypeEnum docType = scapDoc.getDocumentType();

                    FileSaveAsWizard saveAsWiz = new FileSaveAsWizard(EditorMainWindow.getInstance(), true,
                            docType);

                    //saveAsWiz.pack();
                    saveAsWiz.setLocationRelativeTo(EditorMainWindow.getInstance());
                    saveAsWiz.setVisible(true);

                    if (saveAsWiz.wasCancelled()) {
                        return;
                    }

                    newFilename = saveAsWiz.getFilename();

                    try {
                        scapDoc.setFilename(newFilename);
                        scapDoc.saveAs(newFilename);

                        EditorUtil.markActiveWindowDirty(EditorMainWindow.getInstance(), false);
                        ((EditorForm) selectedWin).refreshRootNode();

                    } catch (Exception e) {
                        LOG.error(e.getMessage(), e);

                        EditorUtil.showMessageDialog(parentWinRef, "An error occured trying to save to file "
                                + newFilename + ": " + e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE);
                        return;
                    }

                    SCAPContentManager scm = SCAPContentManager.getInstance();

                    if (scm != null) {
                        scm.removeDocument(filename);
                        scm.addDocument(newFilename, scapDoc);
                        selectedWin.setTitle(windowTitle + (new File(newFilename)).getAbsolutePath());
                    } else {
                        LOG.error("SCM instance is null here!");
                    }
                }
            }
        }
    });

    newXCCDFFromOvalMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            //generateXccdfFromOvalOrOcil("OVAL");
            final JFileChooser fc = new JFileChooser();
            fc.setDialogType(JFileChooser.OPEN_DIALOG);
            File lastOpenedFrom = guiProps.getLastOpenedFromFile();

            // Set current directory
            fc.setCurrentDirectory(lastOpenedFrom);
            FileFilter ff = new OcilOrOvalFilesFilter("OVAL");
            fc.setFileFilter(ff);
            fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int ret = fc.showOpenDialog(EditorMainWindow.getInstance());
            if (ret == JFileChooser.APPROVE_OPTION) {
                File f = fc.getSelectedFile();
                File parent = f.getAbsoluteFile().getParentFile();
                guiProps.setLastOpenedFrom(parent.getAbsolutePath());
                guiProps.save();
                try {
                    InputStream is = this.getClass().getClassLoader().getResourceAsStream("oval-to-xccdf.xsl");
                    File xsltfile = new File("oval-to-xccdf.xsl");
                    OutputStream outputStream = new FileOutputStream(xsltfile);
                    IOUtils.copy(is, outputStream);
                    outputStream.close();
                    OvalToXCCDF1.ovalToXccdf(f, xsltfile);
                    xsltfile.delete();
                    String reverseDNS = JOptionPane.showInputDialog("reverse_DNS:");
                    if (reverseDNS == null || reverseDNS.length() == 0) {
                        JOptionPane.showMessageDialog(null, "Enter the reverse_DNS", "alert",
                                JOptionPane.ERROR_MESSAGE);
                    } else {
                        JFileChooser fc1 = new JFileChooser();
                        fc1.setCurrentDirectory(f);
                        int ret1 = fc1.showSaveDialog(EditorMainWindow.getInstance());
                        if (ret1 == JFileChooser.APPROVE_OPTION) {
                            File savefile = fc1.getSelectedFile();
                            is = this.getClass().getClassLoader().getResourceAsStream("xccdf_1.1_to_1.2.xsl");
                            xsltfile = new File("oval-to-xccdf.xsl");
                            outputStream = new FileOutputStream(xsltfile);
                            IOUtils.copy(is, outputStream);
                            outputStream.close();
                            File temp = new File("temp.xml");
                            XCCDF1to2.xccdf12(savefile, reverseDNS, xsltfile, temp);
                            JOptionPane.showMessageDialog(null,
                                    "XCCDF File Created: " + savefile.getAbsolutePath(), "XCCDF Created",
                                    JOptionPane.PLAIN_MESSAGE);
                            xsltfile.delete();
                            temp.delete();
                            temp = null;
                        }

                    }

                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (URISyntaxException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (TransformerException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                //  openFile(f, SCAPDocumentClassEnum.OVAL);
            }

        }

    });

    newOvalMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            CreateOvalWizard wiz = new CreateOvalWizard(true);
            wiz.setName("create_oval_wizard");
            wiz.pack();
            wiz.setVisible(true);

            if (!wiz.wasCancelled()) {
                // User has been through the wizard to select
                // 1. an Oval schema version (eg, OVAL55)
                // 2. one or more platforms (eg, "windows", "solaris", etc)
                // 3. a file name for the new Oval file
                // Now we are ready to actually create the file
                String createdFilename = createNewOvalDocument(wiz);

                if (createdFilename == null) {
                    LOG.error("newOvalMenuItem.actionlistener: Created filename was null!");
                    return;
                }

                File f = new File(createdFilename);

                guiProps.setLastOpenedFromFile(f.getParentFile());
                guiProps.save();

                SCAPContentManager scm = SCAPContentManager.getInstance();

                if (scm != null) {
                    OvalDefinitionsDocument dd = (OvalDefinitionsDocument) scm.getDocument(f.getAbsolutePath());

                    openFile(dd);
                }
            }
            wiz.setVisible(false);
            wiz.dispose();
        }
    });

    /* wizModeMenuItem.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        WizardModeWindow wizModeWin = new WizardModeWindow();
            
        EditorMainWindow emw = EditorMainWindow.getInstance();
        JDesktopPane emwDesktopPane = emw.getDesktopPane();
            
        wizModeWin.setTitle("Wizard Mode");
        wizModeWin.pack();
            
        wizModeWin.addInternalFrameListener(new WeakInternalFrameListener(EditorMainWindow.getInstance()));
            
        Dimension dpDim = emwDesktopPane.getSize();
        int x = (dpDim.width - wizModeWin.getWidth()) / 2;
        int y = (dpDim.height - wizModeWin.getHeight()) / 2;
            
        wizModeWin.setLocation(x, y);
        emwDesktopPane.add(wizModeWin);
        wizModeWin.setVisible(true);
            
        setWizMode(true);
    }
     });*/

    ugMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (Desktop.isDesktopSupported()) {
                Desktop desktop = Desktop.getDesktop();
                InputStream resource = this.getClass().getResourceAsStream("/User_Guide.pdf");
                try {
                    File userGuideFile = File.createTempFile("UserGuide", ".pdf");
                    userGuideFile.deleteOnExit();
                    OutputStream out = new FileOutputStream(userGuideFile);
                    try {
                        // copy contents from resource to out
                        IOUtils.copy(resource, out);
                    } catch (IOException ex) {
                        JOptionPane.showMessageDialog(null, "Couldn't copy between streams.");
                    } finally {
                        out.close();
                    }
                    desktop.open(userGuideFile);
                } catch (IOException ex) {
                    JOptionPane.showMessageDialog(null, "Could not call Open on desktop object.");
                } finally {
                    try {
                        if (resource != null) {
                            resource.close();
                        }
                    } catch (IOException ex) {
                        LOG.error("Error displaying user guide", ex);
                        JOptionPane.showMessageDialog(null, "Desktop not supported. Cannot open user guide.");
                    }
                }
            } else {
                JOptionPane.showMessageDialog(null, "Desktop not supported. Cannot open user guide.");
            }
        }
    });

}

From source file:org.docx4all.ui.main.WordMLEditor.java

public void updateInternalFrame(FileObject oldFile, FileObject newFile) {
    if (oldFile.equals(newFile)) {
        return;/*ww w .j  a v a2  s  .  c om*/
    }

    String fileUri = oldFile.getName().getURI();
    JInternalFrame iframe = _iframeMap.remove(fileUri);
    if (iframe != null) {
        fileUri = newFile.getName().getURI();
        iframe.putClientProperty(WordMLDocument.FILE_PATH_PROPERTY, fileUri);
        iframe.setTitle(newFile.getName().getBaseName());
    }
}

From source file:org.en.tealEye.guiMain.MainAppFrame.java

public void insertInternalFrame(ExtendedJPanelImpl name) {
    ExtendedJPanelImpl jPanelImpl;//from  ww  w  .j  ava2s.c  o m
    try {
        jPanelImpl = name;
        panelMap.put(name.getName(), name);
        JInternalFrame jInternalFrame = new JInternalFrame();
        jInternalFrame.setSize(400, 300);
        jInternalFrame.setName(jPanelImpl.getName());
        jInternalFrame.setTitle(jPanelImpl.getTitle());
        jInternalFrame.getContentPane().add(new JScrollPane(jPanelImpl));
        jInternalFrame.setIconifiable(true);
        jInternalFrame.setMaximizable(true);
        jInternalFrame.setResizable(true);
        jInternalFrame.setClosable(true);
        jInternalFrame.addInternalFrameListener(windowController);
        frameMap.put(jInternalFrame.getName(), jInternalFrame);
        desktop.add(jInternalFrame);
        desktop.getDesktopManager().activateFrame(jInternalFrame);
        desktop.getDesktopManager().maximizeFrame(jInternalFrame);
        jInternalFrame.moveToFront();
        jInternalFrame.setSelected(true);
        jInternalFrame.setVisible(true);
        jInternalFrame.validate();
        activeFrameMenu.addFrameButton(jPanelImpl.getName());
        menuController.setActiveFrameName(jInternalFrame.getName());
    } catch (Exception e) {
        log.error("cannot open panel " + name, e);
    }

}