Example usage for javax.swing JPopupMenu show

List of usage examples for javax.swing JPopupMenu show

Introduction

In this page you can find the example usage for javax.swing JPopupMenu show.

Prototype

public void show(Component invoker, int x, int y) 

Source Link

Document

Displays the popup menu at the position x,y in the coordinate space of the component invoker.

Usage

From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java

private void selectionReportGroup(DBBrowserNode selectedNode, MouseEvent e) {
    if (e.getClickCount() == 2) {
        return;//  w w w .  ja  va 2s. co m
    }
    ImportReportAction importAction = new ImportReportAction();
    JPopupMenu popupMenu = new JPopupMenu();
    JMenuItem menuItem = new JMenuItem(importAction);
    popupMenu.add(menuItem);
    JMenuItem menuItem2 = new JMenuItem(new AddFolderAction(this, selectedNode, DBObject.FOLDER_REPORT));
    popupMenu.add(menuItem2);
    JMenuItem menuItem3 = new JMenuItem(new ValidateSqlsAction(selectedNode.getDBObject()));
    popupMenu.add(menuItem3);
    JMenuItem menuItem4 = new JMenuItem(new PublishBulkReportAction());
    popupMenu.add(menuItem4);
    JMenuItem menuItem5 = new JMenuItem(
            new DownloadBulkReportAction(FileReportPersistence.getReportsAbsolutePath()));
    popupMenu.add(menuItem5);

    popupMenu.show((Component) e.getSource(), e.getX(), e.getY());
}

From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java

private void selectionReport(DBBrowserNode selectedNode, MouseEvent e, boolean pressed) {
    OpenReportAction openAction = new OpenReportAction();
    openAction.setReportName(selectedNode.getDBObject().getName());
    openAction.setReportPath(selectedNode.getDBObject().getAbsolutePath());

    if (e.getClickCount() == 2) {
        if (pressed) {
            openAction.actionPerformed(new ActionEvent(e.getSource(), e.getID(), ""));
        }/*  w  w  w  . j a  v a  2 s  .  c o m*/
    } else {
        JPopupMenu popupMenu = new JPopupMenu();
        JMenuItem menuItem = new JMenuItem(openAction);
        popupMenu.add(menuItem);

        DeleteReportAction deleteAction = new DeleteReportAction(instance, selectedNode);
        JMenuItem menuItem2 = new JMenuItem(deleteAction);
        popupMenu.add(menuItem2);

        RenameReportAction renameAction = new RenameReportAction(instance, selectedNode);
        JMenuItem menuItem3 = new JMenuItem(renameAction);
        popupMenu.add(menuItem3);

        ExportReportAction exportAction = new ExportReportAction(instance, selectedNode);
        JMenuItem menuItem4 = new JMenuItem(exportAction);
        popupMenu.add(menuItem4);

        Report report = FormLoader.getInstance().load(selectedNode.getDBObject().getAbsolutePath(), false);
        JMenu runMenu = new JMenu(I18NSupport.getString("export"));
        Globals.setTreeReportAbsolutePath(selectedNode.getDBObject().getAbsolutePath());
        runMenu.add(new JMenuItem(new ExportToHtmlAction(report)));
        runMenu.add(new JMenuItem(new ExportToExcelAction(report)));
        runMenu.add(new JMenuItem(new ExportToPdfAction(report)));
        runMenu.add(new JMenuItem(new ExportToDocxAction(report)));
        runMenu.add(new JMenuItem(new ExportToRtfAction(report)));
        runMenu.add(new JMenuItem(new ExportToCsvAction(report)));
        runMenu.add(new JMenuItem(new ExportToTsvAction(report)));
        runMenu.add(new JMenuItem(new ExportToXmlAction(report)));
        runMenu.add(new JMenuItem(new ExportToTxtAction(report)));
        popupMenu.add(runMenu);

        PublishReportAction publishAction = new PublishReportAction(
                selectedNode.getDBObject().getAbsolutePath());
        JMenuItem menuItem5 = new JMenuItem(publishAction);
        popupMenu.add(menuItem5);

        JMenuItem menuItem6 = new JMenuItem(new ValidateSqlsAction(selectedNode.getDBObject()));
        popupMenu.add(menuItem6);

        JMenuItem menuItem7 = new JMenuItem(new AddToFavoritesAction(selectedNode.getDBObject()));
        popupMenu.add(menuItem7);

        popupMenu.show((Component) e.getSource(), e.getX(), e.getY());
    }
}

From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java

private void selectionChartGroup(DBBrowserNode selectedNode, MouseEvent e) {
    if (e.getClickCount() == 2) {
        return;/* www . j a v a 2 s.c  o  m*/
    }
    JPopupMenu popupMenu = new JPopupMenu();
    ImportChartAction importAction = new ImportChartAction();
    JMenuItem menuItem = new JMenuItem(importAction);
    popupMenu.add(menuItem);
    JMenuItem menuItem2 = new JMenuItem(new AddFolderAction(this, selectedNode, DBObject.FOLDER_CHART));
    popupMenu.add(menuItem2);
    JMenuItem menuItem3 = new JMenuItem(new ValidateSqlsAction(selectedNode.getDBObject()));
    popupMenu.add(menuItem3);
    JMenuItem menuItem4 = new JMenuItem(new PublishBulkChartAction());
    popupMenu.add(menuItem4);
    JMenuItem menuItem5 = new JMenuItem(
            new DownloadBulkChartAction(FileReportPersistence.getChartsAbsolutePath()));
    popupMenu.add(menuItem5);

    popupMenu.show((Component) e.getSource(), e.getX(), e.getY());
}

From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java

private void selectionChart(DBBrowserNode selectedNode, MouseEvent e, boolean pressed) {
    OpenChartAction openAction = new OpenChartAction();
    openAction.setChartName(selectedNode.getDBObject().getName());
    openAction.setChartPath(selectedNode.getDBObject().getAbsolutePath());

    if (e.getClickCount() == 2) {
        if (pressed) {
            openAction.actionPerformed(new ActionEvent(e.getSource(), e.getID(), ""));
        }/*from   ww  w  .  j  a  v a2s  .c  om*/

    } else {
        JPopupMenu popupMenu = new JPopupMenu();
        JMenuItem menuItem = new JMenuItem(openAction);
        popupMenu.add(menuItem);

        DeleteChartAction deleteAction = new DeleteChartAction(instance, selectedNode);
        JMenuItem menuItem2 = new JMenuItem(deleteAction);
        popupMenu.add(menuItem2);

        RenameChartAction renameAction = new RenameChartAction(instance, selectedNode);
        JMenuItem menuItem3 = new JMenuItem(renameAction);
        popupMenu.add(menuItem3);

        ExportChartAction exportAction = new ExportChartAction(instance, selectedNode);
        JMenuItem menuItem4 = new JMenuItem(exportAction);
        popupMenu.add(menuItem4);

        Chart chart = ChartUtil.loadChart(selectedNode.getDBObject().getAbsolutePath());
        PreviewChartAction previewHTML5Action = new PreviewChartAction(ChartRunner.GRAPHIC_FORMAT,
                ChartRunner.HTML5_TYPE, I18NSupport.getString("preview.html5"));
        previewHTML5Action.setChart(chart);
        popupMenu.add(previewHTML5Action);
        PreviewChartAction previewFlashAction = new PreviewChartAction(ChartRunner.GRAPHIC_FORMAT,
                ChartRunner.FLASH_TYPE, I18NSupport.getString("preview.flash"));
        previewFlashAction.setChart(chart);
        popupMenu.add(previewFlashAction);
        previewFlashAction.setEnabled(!ChartType.hasNoFlashSupport(chart.getType().getType()));
        PreviewChartAction previewImageAction = new PreviewChartAction(ChartRunner.IMAGE_FORMAT,
                ChartRunner.NO_TYPE, I18NSupport.getString("preview.image"));
        previewImageAction.setChart(chart);
        popupMenu.add(previewImageAction);

        PublishChartAction publishAction = new PublishChartAction(selectedNode.getDBObject().getAbsolutePath());
        JMenuItem menuItem5 = new JMenuItem(publishAction);
        popupMenu.add(menuItem5);

        JMenuItem menuItem6 = new JMenuItem(new ValidateSqlsAction(selectedNode.getDBObject()));
        popupMenu.add(menuItem6);

        JMenuItem menuItem7 = new JMenuItem(new AddToFavoritesAction(selectedNode.getDBObject()));
        popupMenu.add(menuItem7);

        popupMenu.show((Component) e.getSource(), e.getX(), e.getY());
    }
}

From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java

private void selectionDatabase(TreePath selPath, DBBrowserNode selectedNode, MouseEvent e) {
    if (e.getClickCount() == 2) {
        return;/* w w w. j  av a 2  s  . c  o m*/
    }
    boolean connected = false;
    String name = selectedNode.getDBObject().getName();
    DataSourceManager manager = DefaultDataSourceManager.getInstance();
    DataSource ds = manager.getDataSource(name);
    if (ds.getStatus() == DataSourceType.CONNECTED) {
        connected = true;
    } else {
        connected = false;
    }

    // try to create source directory (may not exists if we copy datasource.xml)
    (new File(FileReportPersistence.CONNECTIONS_DIR + File.separator + name + File.separator
            + FileReportPersistence.QUERIES_FOLDER)).mkdirs();
    (new File(FileReportPersistence.CONNECTIONS_DIR + File.separator + name + File.separator
            + FileReportPersistence.REPORTS_FOLDER)).mkdirs();
    (new File(FileReportPersistence.CONNECTIONS_DIR + File.separator + name + File.separator
            + FileReportPersistence.CHARTS_FOLDER)).mkdirs();

    JPopupMenu popupMenu = new JPopupMenu();
    JMenuItem menuItem = new JMenuItem(new DataSourceConnectAction(instance, selPath));
    popupMenu.add(menuItem);
    if (connected) {
        menuItem.setEnabled(false);
    } else {
        menuItem.setEnabled(true);
    }

    JMenuItem menuItem2 = new JMenuItem(new DataSourceDisconnectAction(instance, selectedNode));
    popupMenu.add(menuItem2);
    if (connected) {
        menuItem2.setEnabled(true);
    } else {
        menuItem2.setEnabled(false);
    }

    JMenuItem menuItem5 = new JMenuItem(new DataSourceViewInfoAction(selectedNode));
    popupMenu.add(menuItem5);

    JMenuItem menuItem3 = new JMenuItem(new DataSourceEditAction(instance, selectedNode));
    popupMenu.add(menuItem3);
    if (connected) {
        menuItem3.setEnabled(false);
    } else {
        menuItem3.setEnabled(true);
    }

    JMenuItem menuItem4 = new JMenuItem(new DataSourceDeleteAction(instance, selectedNode));
    popupMenu.add(menuItem4);
    if (connected) {
        menuItem4.setEnabled(false);
    } else {
        menuItem4.setEnabled(true);
    }

    if (!DefaultDataSourceManager.memoryDataSources()) {
        JMenuItem menuItem6 = new JMenuItem(new DataSourceSchemaSelectionAction(instance, selectedNode));
        popupMenu.add(menuItem6);
    }

    popupMenu.show((Component) e.getSource(), e.getX(), e.getY());
}

From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java

private void selectionTableOrView(DBBrowserNode selectedNode, MouseEvent e) {
    boolean isTable = true;
    if (selectedNode.getDBObject().getType() == DBObject.VIEW) {
        isTable = false;//from ww  w.j  a va 2  s. c o  m
    }
    ViewTableColumnsInfoAction infoAction = new ViewTableColumnsInfoAction(selectedNode.getDBObject(), isTable);
    if (e.getClickCount() == 2) {
        infoAction.actionPerformed(null);
    } else {
        JPopupMenu popupMenu = new JPopupMenu();
        JMenuItem menuItem = new JMenuItem(infoAction);
        popupMenu.add(menuItem);
        popupMenu.show((Component) e.getSource(), e.getX(), e.getY());
    }
}

From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java

private void selectionProcedure(DBBrowserNode selectedNode, MouseEvent e) {

    ViewProcedureColumnsInfoAction infoAction = new ViewProcedureColumnsInfoAction(selectedNode.getDBObject());
    if (e.getClickCount() == 2) {
        infoAction.actionPerformed(null);
    } else {//from w w  w . j  a va 2 s .  co  m
        JPopupMenu popupMenu = new JPopupMenu();
        JMenuItem menuItem = new JMenuItem(infoAction);
        popupMenu.add(menuItem);
        JMenuItem menuItem2 = new JMenuItem(new ValidateProceduresAction(selectedNode.getDBObject()));
        popupMenu.add(menuItem2);
        popupMenu.show((Component) e.getSource(), e.getX(), e.getY());
    }
}

From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java

private void selectionProcedureGroup(DBBrowserNode selectedNode, MouseEvent e) {
    if (e.getClickCount() == 2) {
        return;/*from w ww. j  a  va2 s .  c  o  m*/
    }
    ValidateProceduresAction validateAction = new ValidateProceduresAction();
    JPopupMenu popupMenu = new JPopupMenu();
    JMenuItem menuItem = new JMenuItem(validateAction);
    popupMenu.add(menuItem);
    NamePatternAction patternAction = new NamePatternAction(NamePatternAction.PROCEDURE_NAME_PATTERN);
    JMenuItem menuItem2 = new JMenuItem(patternAction);
    popupMenu.add(menuItem2);
    popupMenu.show((Component) e.getSource(), e.getX(), e.getY());
}

From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java

private void selectionTablesGroup(DBBrowserNode selectedNode, MouseEvent e) {
    if (e.getClickCount() == 2) {
        return;//from w  w  w.j  av  a 2s .co m
    }
    JPopupMenu popupMenu = new JPopupMenu();
    NamePatternAction patternAction = new NamePatternAction(NamePatternAction.TABLE_NAME_PATTERN);
    JMenuItem menuItem = new JMenuItem(patternAction);
    popupMenu.add(menuItem);
    popupMenu.show((Component) e.getSource(), e.getX(), e.getY());
}

From source file:ro.nextreports.designer.querybuilder.DBBrowserTree.java

private void selectionViewsGroup(DBBrowserNode selectedNode, MouseEvent e) {
    if (e.getClickCount() == 2) {
        return;//from  w w  w . j  a  va 2 s.c  om
    }
    JPopupMenu popupMenu = new JPopupMenu();
    NamePatternAction patternAction = new NamePatternAction(NamePatternAction.VIEW_NAME_PATTERN);
    JMenuItem menuItem = new JMenuItem(patternAction);
    popupMenu.add(menuItem);
    popupMenu.show((Component) e.getSource(), e.getX(), e.getY());
}