Example usage for javax.swing JPopupMenu JPopupMenu

List of usage examples for javax.swing JPopupMenu JPopupMenu

Introduction

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

Prototype

public JPopupMenu() 

Source Link

Document

Constructs a JPopupMenu without an "invoker".

Usage

From source file:org.datacleaner.windows.AnalysisJobBuilderWindowImpl.java

private JComponent getWindowPanelContent() {
    if (_datastore != null) {
        setDatastore(_datastore);/*from w w w. j  ava2s.c  om*/
    }

    final SaveAnalysisJobActionListener saveAnalysisJobActionListener = _saveAnalysisJobActionListenerProvider
            .get();
    _saveButton.addActionListener(saveAnalysisJobActionListener);
    _saveAsButton.addActionListener(saveAnalysisJobActionListener);
    _saveAsButton.setActionCommand(SaveAnalysisJobActionListener.ACTION_COMMAND_SAVE_AS);

    // Run analysis
    _executeButton.addActionListener(execute(_analysisJobBuilder));

    _executionAlternativesButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            final JMenuItem executeNormallyMenutItem = WidgetFactory.createMenuItem("Run normally",
                    IconUtils.ACTION_EXECUTE);
            executeNormallyMenutItem.addActionListener(execute(_analysisJobBuilder));

            final JMenuItem executePreviewMenuItem = WidgetFactory.createMenuItem("Run first N records",
                    IconUtils.ACTION_PREVIEW);
            executePreviewMenuItem.addActionListener(executePreview());

            final JMenuItem executeSingleThreadedMenuItem = WidgetFactory.createMenuItem("Run single-threaded",
                    IconUtils.MODEL_ROW);
            executeSingleThreadedMenuItem.addActionListener(executeSingleThreaded());

            final JPopupMenu menu = new JPopupMenu();
            menu.add(executeNormallyMenutItem);
            menu.addSeparator();
            menu.add(executePreviewMenuItem);
            menu.add(executeSingleThreadedMenuItem);

            final int horizontalPosition = -1 * menu.getPreferredSize().width
                    + _executionAlternativesButton.getWidth();
            menu.show(_executionAlternativesButton, horizontalPosition,
                    _executionAlternativesButton.getHeight());
        }
    });

    final JButton newJobButton = createToolbarButton("New", IconUtils.MENU_NEW);
    newJobButton.addActionListener(_newAnalysisJobActionListenerProvider.get());

    final JButton openJobButton = createToolbarButton("Open", IconUtils.MENU_OPEN);
    openJobButton.addActionListener(_openAnalysisJobActionListenerProvider.get());

    final JToggleButton moreButton = createMoreMenuButton();

    final JButton logoButton = new JButton(imageManager.getImageIcon("images/menu/dc-logo-30.png"));
    logoButton.setToolTipText("About DataCleaner");
    logoButton.setBorder(new EmptyBorder(0, 4, 0, 10));
    logoButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            new AboutDialog(getWindowContext()).open();
        }
    });

    final JToolBar toolBar = WidgetFactory.createToolBar();
    toolBar.add(logoButton);
    toolBar.add(newJobButton);
    toolBar.add(openJobButton);
    toolBar.add(_saveButton);
    toolBar.add(_saveAsButton);
    toolBar.add(DCLabel.bright(" | "));
    toolBar.add(moreButton);

    toolBar.add(WidgetFactory.createToolBarSeparator());
    toolBar.add(_executeButton);
    toolBar.add(DCLabel.bright("|"));
    toolBar.add(_executionAlternativesButton);

    final JXStatusBar statusBar = WidgetFactory.createStatusBar(_statusLabel);
    statusBar.add(_classicViewButton);
    statusBar.add(_graphViewButton);
    statusBar.add(Box.createHorizontalStrut(10));

    final LicenceAndEditionStatusLabel statusLabel = new LicenceAndEditionStatusLabel(_glassPane);
    statusBar.add(statusLabel);

    final DCPanel toolBarPanel = new DCPanel(WidgetUtils.BG_COLOR_DARK);
    toolBarPanel.setLayout(new BorderLayout());
    toolBarPanel.add(toolBar, BorderLayout.CENTER);

    final DCPanel panel = new DCPersistentSizedPanel(_windowSizePreference);
    panel.setLayout(new BorderLayout());
    panel.add(toolBarPanel, BorderLayout.NORTH);
    panel.add(_leftPanel, BorderLayout.WEST);

    // newPanel.add(_tabbedPane, BorderLayout.NORTH);
    panel.add(_contentContainerPanel, BorderLayout.CENTER);

    panel.add(statusBar, BorderLayout.SOUTH);

    // invoke to trigger enablement/disablement of buttons.
    onSourceColumnsChanged();
    updateStatusLabel();

    WidgetUtils.centerOnScreen(this);
    return panel;
}

From source file:org.datavyu.controllers.component.TrackController.java

/**
 * Creates a new TrackController./*from  ww  w . jav  a 2s .  c o  m*/
 *
 * @param trackPainter the track painter for this controller to manage.
 */
public TrackController(final MixerModel mixerModel, final TrackPainter trackPainter) {
    isMoveable = true;

    view = new JPanel();
    view.setLayout(new MigLayout("fillx, ins 0", "[]0[]"));
    view.setBorder(BorderFactory.createLineBorder(TrackConstants.BORDER_COLOR, 1));

    this.trackPainter = trackPainter;

    this.mixerModel = mixerModel;
    trackModel = new TrackModel();
    trackModel.setState(TrackState.NORMAL);
    trackModel.clearBookmarks();
    trackModel.setLocked(false);

    trackPainter.setMixerView(mixerModel);
    trackPainter.setTrackModel(trackModel);

    mixerModel.getViewportModel().addPropertyChangeListener(this);

    listenerList = new EventListenerList();

    final TrackPainterListener painterListener = new TrackPainterListener();
    trackPainter.addMouseListener(painterListener);
    trackPainter.addMouseMotionListener(painterListener);

    menu = new JPopupMenu();
    menu.setName("trackPopUpMenu");

    setBookmarkMenuItem = new JMenuItem("Set bookmark");
    setBookmarkMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            TrackController.this.setBookmarkAction();
        }
    });

    clearBookmarkMenuItem = new JMenuItem("Clear bookmarks");
    clearBookmarkMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            TrackController.this.clearBookmarkAction();
        }
    });
    menu.add(setBookmarkMenuItem);
    menu.add(clearBookmarkMenuItem);

    trackPainter.add(menu);

    // Create the Header panel and its components
    trackLabel = new JLabel("", SwingConstants.CENTER);
    trackLabel.setName("trackLabel");
    trackLabel.setHorizontalAlignment(SwingConstants.CENTER);
    trackLabel.setHorizontalTextPosition(SwingConstants.CENTER);
    iconLabel = new JLabel("", SwingConstants.CENTER);
    iconLabel.setHorizontalAlignment(SwingConstants.CENTER);
    iconLabel.setHorizontalTextPosition(SwingConstants.CENTER);

    header = new JPanel(new MigLayout("ins 0, wrap 6"));
    header.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createMatteBorder(0, 0, 0, 1, TrackConstants.BORDER_COLOR),
            BorderFactory.createEmptyBorder(2, 2, 2, 2)));
    header.setBackground(Color.LIGHT_GRAY);

    // Normally I would use pushx instead of defining the width, but in this
    // case I defined the width because span combined with push makes the
    // first action icon cell push out as well. 136 was calculated from
    // 140 pixels minus 2 minus 2 (from the empty border defined above).
    header.add(trackLabel, "span 6, w 136!, center, growx");
    header.add(iconLabel, "span 6, w 136!, h 32!, center, growx");

    // Set up the button used for locking/unlocking track movement
    {
        lockUnlockButton = new JButton(TrackConstants.UNLOCK_ICON);
        lockUnlockButton.setName("lockUnlockButton");
        lockUnlockButton.setContentAreaFilled(false);
        lockUnlockButton.setBorderPainted(false);
        lockUnlockButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
                handleLockUnlockButtonEvent(e);
            }
        });

        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("width", Integer.toString(TrackConstants.ACTION_BUTTON_WIDTH));
        constraints.put("height", Integer.toString(TrackConstants.ACTION_BUTTON_HEIGHT));

        String template = "cell 0 2, w ${width}!, h ${height}!";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        header.add(lockUnlockButton, sub.replace(template));
    }

    // Set up the button used for hiding/showing a track's data viewer
    {
        visibleButton = new JButton(TrackConstants.VIEWER_HIDE_ICON);
        visibleButton.setName("visibleButton");
        visibleButton.setContentAreaFilled(false);
        visibleButton.setBorderPainted(false);
        visibleButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
                handleVisibleButtonEvent(e);
            }
        });

        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("width", Integer.toString(TrackConstants.ACTION_BUTTON_WIDTH));
        constraints.put("height", Integer.toString(TrackConstants.ACTION_BUTTON_HEIGHT));

        String template = "cell 1 2, w ${width}!, h ${height}!";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        header.add(visibleButton, sub.replace(template));
    }

    // Set up the button used for removing a track and its plugin
    {
        rubbishButton = new JButton(TrackConstants.DELETE_ICON);
        rubbishButton.setName("rubbishButton");
        rubbishButton.setContentAreaFilled(false);
        rubbishButton.setBorderPainted(false);
        rubbishButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
                handleDeleteButtonEvent(e);
            }
        });

        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("width", Integer.toString(TrackConstants.ACTION_BUTTON_WIDTH));
        constraints.put("height", Integer.toString(TrackConstants.ACTION_BUTTON_HEIGHT));

        String template = "cell 5 2, w ${width}!, h ${height}!";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        header.add(rubbishButton, sub.replace(template));
    }

    // Add the header to our layout.
    {
        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("width", Integer.toString(TrackConstants.HEADER_WIDTH));
        constraints.put("height", Integer.toString(TrackConstants.CARRIAGE_HEIGHT));

        String template = "w ${width}!, h ${height}!";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        view.add(header, sub.replace(template));
    }

    // Add the track carriage to our layout.
    {
        Map<String, String> constraints = Maps.newHashMap();
        constraints.put("height", Integer.toString(TrackConstants.CARRIAGE_HEIGHT));

        String template = "pushx, growx, h ${height}!";
        StrSubstitutor sub = new StrSubstitutor(constraints);

        view.add(trackPainter, sub.replace(template));
    }

    view.validate();
}

From source file:org.domainmath.gui.FileTreePanel.java

/**
 * Add popup menu./*from w w  w.j av a  2 s  . c o  m*/
 */
private void addPopupMenuToFileTree() {
    refreshItem = new JMenuItem(bundle.getString("fileTreeRefreshItem.text"));
    fileTree.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            addGlobalAction(e);

            if (SwingUtilities.isRightMouseButton(e)) {
                TreePath path = fileTree.getPathForLocation(e.getX(), e.getY());
                Rectangle pathBounds = fileTree.getUI().getPathBounds(fileTree, path);

                if (pathBounds != null && pathBounds.contains(e.getX(), e.getY())) {
                    JPopupMenu menu = new JPopupMenu();
                    File file = (File) fileTree.getLastSelectedPathComponent();
                    openItem = new JMenuItem(bundle.getString("fileTreeOpenItem.text"));
                    runScriptItem = new JMenuItem(bundle.getString("fileTreeRunItem.text"));
                    openOutsideItem = new JMenuItem(bundle.getString("fileTreeOpenOutsideItem.text"));
                    renameItem = new JMenuItem(bundle.getString("fileTreeRenameItem.text"));
                    deleteItem = new JMenuItem(bundle.getString("fileTreeDeleteItem.text"));

                    openItem.setAccelerator(keyOpenItem);
                    renameItem.setAccelerator(keyRenameItem);
                    deleteItem.setAccelerator(keyDeleteItem);
                    refreshItem.setAccelerator(keyRefreshItem);
                    menu.add(openItem);
                    menu.add(runScriptItem);
                    menu.add(openOutsideItem);
                    menu.addSeparator();
                    menu.add(renameItem);
                    menu.add(deleteItem);
                    menu.addSeparator();
                    menu.add(refreshItem);

                    fileTreeOpenItemActionPerformed(file);
                    fileTreeRunItemActionPerformed(file);
                    fileTreeOpenOutsideItemActionPerformed(file);
                    fileTreeRenameItemActionPerformed(fileTree.getSelectionPath());
                    fileTreeDeleteItemActionPerformed(fileTree.getSelectionModel().getSelectionPaths());
                    fileTreeRefreshItemActionPerformed((File) fileTree.getModel().getRoot());

                    if (file.isDirectory()) {
                        runScriptItem.setEnabled(false);
                    } else {
                        String name = file.getName();
                        if (!name.endsWith(".m")) {
                            runScriptItem.setEnabled(false);
                        }
                    }
                    menu.show(fileTree, e.getX(), e.getY());
                }
                if (pathBounds == null) {
                    JPopupMenu menu = new JPopupMenu();
                    newFolderItem = new JMenuItem(bundle.getString("fileTreeNewFolderItem.text"));
                    File file = (File) fileTree.getModel().getRoot();
                    menu.add(newFolderItem);
                    menu.add(refreshItem);

                    fileTreeNewFolderItemActionPerformed(file);
                    fileTreeRefreshItemActionPerformed(file);
                    menu.show(fileTree, e.getX(), e.getY());
                }
            }
        }
    });
}

From source file:org.domainmath.gui.MainFrame.java

private void popupTab() {
    JPopupMenu popup = new JPopupMenu();
    JMenuItem pcloseItem = new JMenuItem("Close");
    JMenuItem pcloseAllItem = new JMenuItem("Close All");

    popup.add(pcloseItem);//from  w  w w.  j  av a 2s  . co m
    popup.add(pcloseAllItem);
    fileTab.addMouseListener(new MainFrame.PopupListener(popup));

    pcloseItem.addActionListener((ActionEvent e) -> {
        if (fileTab.getSelectedIndex() >= 0) {
            askSave(fileTab.getSelectedIndex());
        }
    });

    pcloseAllItem.addActionListener((ActionEvent e) -> {
        int i = fileTab.getTabCount() - 1;
        while (i != -1) {

            askSave(i);
            i--;
        }
    });
}

From source file:org.eclipse.birt.chart.device.swing.SwingEventHandler.java

/**
 * @param muv/*from  w  w w.  jav a  2s  .  c o  m*/
 * @param point
 */
private void openMultiULRs(MultiURLValues muv, Point point) {
    if (popupMenu != null && popupMenu.isValid()) {
        // Remove previous menu object.
        popupMenu.setVisible(false);
        ((JComponent) iun.peerInstance()).remove(popupMenu);
    }

    popupMenu = new JPopupMenu();

    // Create popup menu items.
    for (URLValue uv : muv.getURLValues()) {
        JMenuItem menuItem = new JMenuItem();
        popupMenu.add(menuItem);
        menuItem.setText(uv.getLabel().getCaption().getValue());
        if (uv.getTooltip() != null && uv.getTooltip().length() > 0)
            menuItem.setToolTipText(uv.getTooltip());
        URLMenuItemModel uim = new URLMenuItemModel();
        uim.setURLValue(uv);
        menuItem.setModel(uim);
        menuItem.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                URLValue urlValue = ((URLMenuItemModel) ((JMenuItem) e.getSource()).getModel()).getURLValue();
                openURL(urlValue);
            }
        });

    }

    // Show menu.
    popupMenu.show((JComponent) iun.peerInstance(), point.x, point.y);
}

From source file:org.eobjects.datacleaner.panels.DatabaseDriversPanel.java

private void updateComponents() {
    this.removeAll();
    final JToolBar toolBar = WidgetFactory.createToolBar();
    toolBar.add(WidgetFactory.createToolBarSeparator());

    final JButton addDriverButton = new JButton("Add database driver",
            imageManager.getImageIcon(IconUtils.ACTION_ADD));
    addDriverButton.addActionListener(new ActionListener() {
        @Override/* w w  w .ja v  a2  s .c om*/
        public void actionPerformed(ActionEvent e) {

            final JMenu menu = new JMenu("Automatic download and install");
            menu.setIcon(imageManager.getImageIcon("images/actions/download.png"));

            final List<DatabaseDriverDescriptor> drivers = _databaseDriverCatalog.getDatabaseDrivers();
            for (DatabaseDriverDescriptor dd : drivers) {
                final String[] urls = dd.getDownloadUrls();
                if (urls != null && _databaseDriverCatalog.getState(dd) == DatabaseDriverState.NOT_INSTALLED) {
                    final JMenuItem downloadAndInstallMenuItem = WidgetFactory
                            .createMenuItem(dd.getDisplayName(), dd.getIconImagePath());
                    downloadAndInstallMenuItem.addActionListener(createDownloadActionListener(dd));
                    menu.add(downloadAndInstallMenuItem);
                }
            }

            if (menu.getMenuComponentCount() == 0) {
                menu.setEnabled(false);
            }

            final JMenuItem localJarFilesMenuItem = WidgetFactory.createMenuItem("Local JAR file(s)...",
                    "images/filetypes/archive.png");
            localJarFilesMenuItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    AddDatabaseDriverDialog dialog = new AddDatabaseDriverDialog(_databaseDriverCatalog,
                            DatabaseDriversPanel.this, _windowContext, _userPreferences);
                    dialog.setVisible(true);
                }
            });

            final JPopupMenu popup = new JPopupMenu();
            popup.add(menu);
            popup.add(localJarFilesMenuItem);
            popup.show(addDriverButton, 0, addDriverButton.getHeight());
        }
    });
    toolBar.add(addDriverButton);

    final DCTable table = getDatabaseDriverTable();
    this.add(toolBar, BorderLayout.NORTH);
    this.add(table.toPanel(), BorderLayout.CENTER);
}

From source file:org.eobjects.datacleaner.panels.WelcomePanel.java

@Inject
protected WelcomePanel(AnalyzerBeansConfiguration configuration,
        AnalysisJobBuilderWindow analysisJobBuilderWindow, DCGlassPane glassPane,
        Provider<OptionsDialog> optionsDialogProvider, InjectorBuilder injectorBuilder,
        OpenAnalysisJobActionListener openAnalysisJobActionListener,
        DatabaseDriverCatalog databaseDriverCatalog, UserPreferences userPreferences) {
    super();//from w ww .  j  a v a  2s  . c o m
    _openAnalysisJobActionListener = openAnalysisJobActionListener;
    _configuration = configuration;
    _datastorePanels = new ArrayList<DatastorePanel>();
    _datastoreCatalog = (MutableDatastoreCatalog) configuration.getDatastoreCatalog();
    _analysisJobBuilderWindow = analysisJobBuilderWindow;
    _glassPane = glassPane;
    _optionsDialogProvider = optionsDialogProvider;
    _injectorBuilder = injectorBuilder;
    _databaseDriverCatalog = databaseDriverCatalog;
    _userPreferences = userPreferences;

    _browseJobsButton = new JButton("Browse jobs",
            imageManager.getImageIcon(IconUtils.MENU_OPEN, IconUtils.ICON_SIZE_SMALL));
    _browseJobsButton.setMargin(new Insets(1, 1, 1, 4));
    _browseJobsButton.addActionListener(openAnalysisJobActionListener);

    // initialize "analyze" button
    _analyzeButton = new JButton("Build job",
            imageManager.getImageIcon(IconUtils.MODEL_JOB, IconUtils.ICON_SIZE_SMALL));
    _analyzeButton.setMargin(new Insets(1, 1, 1, 1));
    _analyzeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            for (DatastorePanel datastorePanel : _datastorePanels) {
                if (datastorePanel.isSelected()) {
                    Datastore datastore = datastorePanel.getDatastore();

                    // open the connection here, to make any connection
                    // issues apparent early
                    try (DatastoreConnection datastoreConnection = datastore.openConnection()) {
                        datastoreConnection.getDataContext().getSchemaNames();
                        _analysisJobBuilderWindow.setDatastore(datastore);
                    }
                    return;
                }
            }
        }
    });

    // initialize search text field
    _searchDatastoreTextField = WidgetFactory.createTextField("Search/filter datastores");
    _searchDatastoreTextField
            .setBorder(new CompoundBorder(new EmptyBorder(4, 0, 0, 0), WidgetUtils.BORDER_THIN));
    _searchDatastoreTextField.setOpaque(false);
    _searchDatastoreTextField.getDocument().addDocumentListener(new DCDocumentListener() {
        @Override
        protected void onChange(DocumentEvent event) {
            String text = _searchDatastoreTextField.getText();
            if (StringUtils.isNullOrEmpty(text)) {
                // when there is no search query, set all datastores
                // visible
                for (DatastorePanel datastorePanel : _datastorePanels) {
                    datastorePanel.setVisible(true);
                }
            } else {
                // do a case insensitive search
                text = text.trim().toLowerCase();
                for (DatastorePanel datastorePanel : _datastorePanels) {
                    String name = datastorePanel.getDatastore().getName().toLowerCase();
                    datastorePanel.setVisible(name.indexOf(text) != -1);
                }
                selectFirstVisibleDatastore();
            }
        }
    });
    _searchDatastoreTextField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                clickAnalyzeButton();
            } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                selectNextVisibleDatastore();
            } else if (e.getKeyCode() == KeyEvent.VK_UP) {
                selectPreviousVisibleDatastore();
            }
        }
    });

    setLayout(new VerticalLayout(4));

    add(Box.createVerticalStrut(10));

    final DCLabel jobsHeaderLabel = DCLabel.dark("Jobs");
    jobsHeaderLabel.setFont(WidgetUtils.FONT_HEADER1);
    add(jobsHeaderLabel);

    _jobsListPanel = new DCPanel();
    final GridLayout jobsListLayout = new GridLayout(1, MAX_JOB_PANELS);
    jobsListLayout.setHgap(10);
    _jobsListPanel.setBorder(new EmptyBorder(10, 10, 4, 0));
    _jobsListPanel.setLayout(jobsListLayout);

    final List<FileObject> recentJobFiles = getRecentJobFiles();

    updateJobsListPanel(recentJobFiles);

    add(_jobsListPanel);

    _moreRecentJobsButton = new JButton("More",
            imageManager.getImageIcon(IconUtils.FILE_FOLDER, IconUtils.ICON_SIZE_SMALL));
    _moreRecentJobsButton.setMargin(new Insets(1, 1, 1, 4));
    if (recentJobFiles.size() <= MAX_JOB_PANELS) {
        _moreRecentJobsButton.setEnabled(false);
    } else {
        _moreRecentJobsButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                final JPopupMenu popup = new JPopupMenu();
                for (int i = 3; i < recentJobFiles.size(); i++) {
                    final FileObject jobFile = recentJobFiles.get(i);
                    final JMenuItem menuItem = new OpenAnalysisJobMenuItem(jobFile,
                            _openAnalysisJobActionListener);
                    popup.add(menuItem);
                }
                popup.show(_moreRecentJobsButton, 0, _moreRecentJobsButton.getHeight());
            }
        });
    }

    final DCPanel jobsButtonPanel = new DCPanel();
    jobsButtonPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 0));
    jobsButtonPanel.add(_moreRecentJobsButton);
    jobsButtonPanel.add(_browseJobsButton);
    add(jobsButtonPanel);

    add(Box.createVerticalStrut(40));

    final DCLabel datastoreHeaderLabel = DCLabel.dark("Datastores");
    datastoreHeaderLabel.setFont(WidgetUtils.FONT_HEADER1);
    add(datastoreHeaderLabel);

    final DCLabel registerNewDatastoreLabel = DCLabel.dark("Register new:");
    registerNewDatastoreLabel.setFont(WidgetUtils.FONT_HEADER2);

    final DCPanel newDatastorePanel = new DCPanel();
    newDatastorePanel.setLayout(new VerticalLayout(4));
    newDatastorePanel.setBorder(new EmptyBorder(10, 10, 10, 0));
    newDatastorePanel.add(registerNewDatastoreLabel);
    newDatastorePanel.add(createNewDatastorePanel());

    add(newDatastorePanel);

    _datastoreListPanel = new DCPanel();
    _datastoreListPanel.setLayout(new VerticalLayout(4));
    _datastoreListPanel.setBorder(new EmptyBorder(10, 10, 4, 0));
    add(_datastoreListPanel);
    updateDatastores();

    final DCPanel datastoresButtonPanel = new DCPanel();
    datastoresButtonPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    datastoresButtonPanel.setBorder(new EmptyBorder(0, 10, 0, 0));
    datastoresButtonPanel.add(_analyzeButton);
    add(datastoresButtonPanel);
}

From source file:org.eobjects.datacleaner.panels.WelcomePanel.java

private DCPanel createNewDatastorePanel() {
    final DCPanel panel = new DCPanel();
    panel.setBorder(WidgetUtils.BORDER_LIST_ITEM);
    panel.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
    panel.add(createNewDatastoreButton("CSV file",
            "Comma-separated values (CSV) file (or file with other separators)", IconUtils.CSV_IMAGEPATH,
            CsvDatastore.class, CsvDatastoreDialog.class));
    panel.add(createNewDatastoreButton("Excel spreadsheet",
            "Microsoft Excel spreadsheet. Either .xls (97-2003) or .xlsx (2007+) format.",
            IconUtils.EXCEL_IMAGEPATH, ExcelDatastore.class, ExcelDatastoreDialog.class));
    panel.add(createNewDatastoreButton("Access database", "Microsoft Access database file (.mdb).",
            IconUtils.ACCESS_IMAGEPATH, AccessDatastore.class, AccessDatastoreDialog.class));
    panel.add(createNewDatastoreButton("SAS library", "A directory of SAS library files (.sas7bdat).",
            IconUtils.SAS_IMAGEPATH, SasDatastore.class, SasDatastoreDialog.class));
    panel.add(createNewDatastoreButton("DBase database", "DBase database file (.dbf)",
            IconUtils.DBASE_IMAGEPATH, DbaseDatastore.class, DbaseDatastoreDialog.class));
    panel.add(createNewDatastoreButton("Fixed width file",
            "Text file with fixed width values. Each value spans a fixed amount of text characters.",
            IconUtils.FIXEDWIDTH_IMAGEPATH, FixedWidthDatastore.class, FixedWidthDatastoreDialog.class));
    panel.add(createNewDatastoreButton("XML file", "Extensible Markup Language file (.xml)",
            IconUtils.XML_IMAGEPATH, XmlDatastore.class, XmlDatastoreDialog.class));
    panel.add(createNewDatastoreButton("JSON file", "JavaScript Object NOtation file (.json).",
            IconUtils.JSON_IMAGEPATH, JsonDatastore.class, JsonDatastoreDialog.class));
    panel.add(//from ww w. j av a 2 s.c o  m
            createNewDatastoreButton("OpenOffice.org Base database", "OpenOffice.org Base database file (.odb)",
                    IconUtils.ODB_IMAGEPATH, OdbDatastore.class, OdbDatastoreDialog.class));

    panel.add(Box.createHorizontalStrut(10));

    panel.add(createNewDatastoreButton("Salesforce.com", "Connect to a Salesforce.com account",
            IconUtils.SALESFORCE_IMAGEPATH, SalesforceDatastore.class, SalesforceDatastoreDialog.class));
    panel.add(createNewDatastoreButton("SugarCRM", "Connect to a SugarCRM system",
            IconUtils.SUGAR_CRM_IMAGEPATH, SugarCrmDatastore.class, SugarCrmDatastoreDialog.class));

    panel.add(Box.createHorizontalStrut(10));

    panel.add(createNewDatastoreButton("MongoDB database", "Connect to a MongoDB database",
            IconUtils.MONGODB_IMAGEPATH, MongoDbDatastore.class, MongoDbDatastoreDialog.class));

    panel.add(createNewDatastoreButton("CouchDB database", "Connect to an Apache CouchDB database",
            IconUtils.COUCHDB_IMAGEPATH, CouchDbDatastore.class, CouchDbDatastoreDialog.class));

    panel.add(createNewDatastoreButton("HBase database", "Connect to an Apache HBase database",
            IconUtils.HBASE_IMAGEPATH, HBaseDatastore.class, HBaseDatastoreDialog.class));

    // set of databases that are displayed directly on panel
    final Set<String> databaseNames = new HashSet<String>();

    createDefaultDatabaseButtons(panel, databaseNames);

    final JButton moreDatastoreTypesButton = new JButton("More",
            imageManager.getImageIcon(IconUtils.FILE_FOLDER, IconUtils.ICON_SIZE_SMALL));
    moreDatastoreTypesButton.setMargin(new Insets(1, 1, 1, 4));
    moreDatastoreTypesButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            final JPopupMenu popup = new JPopupMenu();

            // installed databases
            final List<DatabaseDriverDescriptor> databaseDrivers = _databaseDriverCatalog
                    .getInstalledWorkingDatabaseDrivers();
            for (DatabaseDriverDescriptor databaseDriver : databaseDrivers) {
                final String databaseName = databaseDriver.getDisplayName();
                if (!databaseNames.contains(databaseName)) {
                    final String imagePath = databaseDriver.getIconImagePath();
                    final ImageIcon icon = imageManager.getImageIcon(imagePath, IconUtils.ICON_SIZE_SMALL);
                    final JMenuItem menuItem = WidgetFactory.createMenuItem(databaseName, icon);
                    menuItem.addActionListener(createJdbcActionListener(databaseName));
                    popup.add(menuItem);
                }
            }

            // custom/other jdbc connection
            {
                final ImageIcon icon = imageManager.getImageIcon(IconUtils.GENERIC_DATASTORE_IMAGEPATH,
                        IconUtils.ICON_SIZE_SMALL);
                final JMenuItem menuItem = WidgetFactory.createMenuItem("Other database", icon);
                menuItem.addActionListener(createJdbcActionListener(null));
                popup.add(menuItem);
            }

            // composite datastore
            final JMenuItem compositeMenuItem = WidgetFactory.createMenuItem("Composite datastore",
                    imageManager.getImageIcon(IconUtils.COMPOSITE_IMAGEPATH, IconUtils.ICON_SIZE_SMALL));
            compositeMenuItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    new CompositeDatastoreDialog(_datastoreCatalog,
                            _analysisJobBuilderWindow.getWindowContext()).setVisible(true);
                }
            });

            final JMenuItem databaseDriversMenuItem = WidgetFactory.createMenuItem("Manage database drivers...",
                    imageManager.getImageIcon(IconUtils.MENU_OPTIONS, IconUtils.ICON_SIZE_SMALL));
            databaseDriversMenuItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    OptionsDialog dialog = _optionsDialogProvider.get();
                    dialog.selectDatabaseDriversTab();
                    dialog.setVisible(true);
                }
            });

            popup.add(databaseDriversMenuItem);
            popup.add(new JSeparator(JSeparator.HORIZONTAL));
            popup.add(compositeMenuItem);
            popup.setBorder(WidgetUtils.BORDER_THIN);

            popup.show(moreDatastoreTypesButton, 0, moreDatastoreTypesButton.getHeight());
        }
    });

    panel.add(Box.createHorizontalStrut(10));
    panel.add(moreDatastoreTypesButton);

    return panel;
}

From source file:org.esa.nest.dat.views.polarview.PolarView.java

@Override
public JPopupMenu createPopupMenu(MouseEvent event) {
    final JPopupMenu popup = new JPopupMenu();

    final JMenuItem itemNext = createMenuItem("Next");
    popup.add(itemNext);/* w w w .  ja  va2 s  . c om*/
    itemNext.setEnabled(currentRecord < numRecords);

    final JMenuItem itemPrev = createMenuItem("Previous");
    popup.add(itemPrev);
    itemPrev.setEnabled(currentRecord > 0);

    final JMenuItem itemColourScale = createMenuItem("Colour Scale");
    popup.add(itemColourScale);

    final JMenu unitMenu = new JMenu("Unit");
    popup.add(unitMenu);

    if (waveProductType == WaveProductType.WAVE_SPECTRA) {
        createCheckedMenuItem(unitTypes[Unit.AMPLITUDE.ordinal()], unitMenu, graphUnit == Unit.AMPLITUDE);
        createCheckedMenuItem(unitTypes[Unit.INTENSITY.ordinal()], unitMenu, graphUnit == Unit.INTENSITY);
    } else {
        createCheckedMenuItem(unitTypes[Unit.REAL.ordinal()], unitMenu, graphUnit == Unit.REAL);
        createCheckedMenuItem(unitTypes[Unit.IMAGINARY.ordinal()], unitMenu, graphUnit == Unit.IMAGINARY);
        createCheckedMenuItem(unitTypes[Unit.AMPLITUDE.ordinal()], unitMenu, graphUnit == Unit.AMPLITUDE);
        createCheckedMenuItem(unitTypes[Unit.INTENSITY.ordinal()], unitMenu, graphUnit == Unit.INTENSITY);
    }

    final JMenuItem itemExportReadout = createMenuItem("Export Readouts");
    popup.add(itemExportReadout);

    popup.setLabel("Justification");
    popup.setBorder(new BevelBorder(BevelBorder.RAISED));
    popup.addPopupMenuListener(this);
    popup.show(this, event.getX(), event.getY());

    return popup;
}

From source file:org.esa.snap.graphbuilder.rcp.dialogs.support.GraphPanel.java

private void checkPopup(MouseEvent e) {
    if (e.isPopupTrigger()) {

        final JPopupMenu popup = new JPopupMenu();
        popup.add(addMenu);// w w w  .  jav a  2 s . c  o m

        if (selectedNode != null) {
            final JMenuItem item = new JMenuItem("Delete");
            popup.add(item);
            item.setHorizontalTextPosition(JMenuItem.RIGHT);
            item.addActionListener(this);

            final NodeSource[] sources = selectedNode.getNode().getSources();
            if (sources.length > 0) {
                final JMenu removeSourcedMenu = new JMenu("Remove Source");
                for (NodeSource ns : sources) {
                    final JMenuItem nsItem = new JMenuItem(ns.getSourceNodeId());
                    removeSourcedMenu.add(nsItem);
                    nsItem.setHorizontalTextPosition(JMenuItem.RIGHT);
                    nsItem.addActionListener(removeSourceListener);
                }
                popup.add(removeSourcedMenu);
            }
        }

        if (!graphEx.getGraphNodeList().isGraphComplete()) {
            final JMenuItem connectItem = new JMenuItem("Connect Graph", null);
            connectItem.setHorizontalTextPosition(JMenuItem.RIGHT);
            connectItem.addActionListener(connectListener);
            popup.add(connectItem);
        }

        popup.setLabel("Justification");
        popup.setBorder(new BevelBorder(BevelBorder.RAISED));
        popup.addPopupMenuListener(this);
        popup.show(this, e.getX(), e.getY());
        showRightClickHelp = false;
    }
}