Package javax.swing

Examples of javax.swing.JPopupMenu


                                                UserPreferences preferences,
                                                final HomeController controller) {
    JComponent catalogView = (JComponent)controller.getFurnitureCatalogController().getView();
    if (catalogView != null) {
      // Create catalog view popup menu
      JPopupMenu catalogViewPopup = new JPopupMenu();
      addActionToPopupMenu(ActionType.COPY, catalogViewPopup);
      catalogViewPopup.addSeparator();
      addActionToPopupMenu(ActionType.DELETE, catalogViewPopup);
      catalogViewPopup.addSeparator();
      addActionToPopupMenu(ActionType.ADD_HOME_FURNITURE, catalogViewPopup);
      addActionToPopupMenu(ActionType.MODIFY_FURNITURE, catalogViewPopup);
      catalogViewPopup.addSeparator();
      addActionToPopupMenu(ActionType.IMPORT_FURNITURE, catalogViewPopup);
      SwingTools.hideDisabledMenuItems(catalogViewPopup);
      catalogView.setComponentPopupMenu(catalogViewPopup);
 
      preferences.addPropertyChangeListener(UserPreferences.Property.FURNITURE_CATALOG_VIEWED_IN_TREE,
          new FurnitureCatalogViewChangeListener(this, catalogView));
      if (catalogView instanceof Scrollable) {
        catalogView = new HomeScrollPane(catalogView);
      }
    }
   
    // Configure furniture view
    JComponent furnitureView = (JComponent)controller.getFurnitureController().getView();
    if (furnitureView != null) {
      // Set default traversal keys of furniture view
      KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
      furnitureView.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
          focusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
      furnitureView.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
          focusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
 
      // Create furniture view popup menu
      JPopupMenu furnitureViewPopup = new JPopupMenu();
      addActionToPopupMenu(ActionType.UNDO, furnitureViewPopup);
      addActionToPopupMenu(ActionType.REDO, furnitureViewPopup);
      furnitureViewPopup.addSeparator();
      addActionToPopupMenu(ActionType.CUT, furnitureViewPopup);
      addActionToPopupMenu(ActionType.COPY, furnitureViewPopup);
      addActionToPopupMenu(ActionType.PASTE, furnitureViewPopup);
      furnitureViewPopup.addSeparator();
      addActionToPopupMenu(ActionType.DELETE, furnitureViewPopup);
      addActionToPopupMenu(ActionType.SELECT_ALL, furnitureViewPopup);
      furnitureViewPopup.addSeparator();
      addActionToPopupMenu(ActionType.MODIFY_FURNITURE, furnitureViewPopup);
      addActionToPopupMenu(ActionType.GROUP_FURNITURE, furnitureViewPopup);
      addActionToPopupMenu(ActionType.UNGROUP_FURNITURE, furnitureViewPopup);
      furnitureViewPopup.addSeparator();
      furnitureViewPopup.add(createFurnitureSortMenu(home, preferences));
      furnitureViewPopup.add(createFurnitureDisplayPropertyMenu(home, preferences));
      SwingTools.hideDisabledMenuItems(furnitureViewPopup);
      furnitureView.setComponentPopupMenu(furnitureViewPopup);
 
      if (furnitureView instanceof Scrollable) {
        JScrollPane furnitureScrollPane = new HomeScrollPane(furnitureView);
View Full Code Here


  private JComponent createPlanView3DPane(final Home home, UserPreferences preferences,
                                          final HomeController controller) {
    JComponent planView = (JComponent)controller.getPlanController().getView();
    if (planView != null) {
      // Create plan view popup menu
      JPopupMenu planViewPopup = new JPopupMenu();
      addActionToPopupMenu(ActionType.UNDO, planViewPopup);
      addActionToPopupMenu(ActionType.REDO, planViewPopup);
      planViewPopup.addSeparator();
      addActionToPopupMenu(ActionType.CUT, planViewPopup);
      addActionToPopupMenu(ActionType.COPY, planViewPopup);
      addActionToPopupMenu(ActionType.PASTE, planViewPopup);
      planViewPopup.addSeparator();
      addActionToPopupMenu(ActionType.DELETE, planViewPopup);
      addActionToPopupMenu(ActionType.SELECT_ALL, planViewPopup);
      planViewPopup.addSeparator();
      addToggleActionToPopupMenu(ActionType.SELECT,
          this.selectToggleModel, true, planViewPopup);
      addToggleActionToPopupMenu(ActionType.PAN,
          this.panToggleModel, true, planViewPopup);
      addToggleActionToPopupMenu(ActionType.CREATE_WALLS,
          this.createWallsToggleModel, true, planViewPopup);
      addToggleActionToPopupMenu(ActionType.CREATE_ROOMS,
          this.createRoomsToggleModel, true, planViewPopup);
      addToggleActionToPopupMenu(ActionType.CREATE_DIMENSION_LINES,
          this.createDimensionLinesToggleModel, true, planViewPopup);
      addToggleActionToPopupMenu(ActionType.CREATE_LABELS,
          this.createLabelsToggleModel, true, planViewPopup);
      planViewPopup.addSeparator();
      JMenuItem lockUnlockBasePlanMenuItem = createLockUnlockBasePlanMenuItem(home, true);
      if (lockUnlockBasePlanMenuItem != null) {
        planViewPopup.add(lockUnlockBasePlanMenuItem);
      }
      addActionToPopupMenu(ActionType.MODIFY_FURNITURE, planViewPopup);
      addActionToPopupMenu(ActionType.GROUP_FURNITURE, planViewPopup);
      addActionToPopupMenu(ActionType.UNGROUP_FURNITURE, planViewPopup);
      addActionToPopupMenu(ActionType.MODIFY_COMPASS, planViewPopup);
      addActionToPopupMenu(ActionType.MODIFY_WALL, planViewPopup);
      addActionToPopupMenu(ActionType.REVERSE_WALL_DIRECTION, planViewPopup);
      addActionToPopupMenu(ActionType.SPLIT_WALL, planViewPopup);
      addActionToPopupMenu(ActionType.MODIFY_ROOM, planViewPopup);
      addActionToPopupMenu(ActionType.MODIFY_LABEL, planViewPopup);
      planViewPopup.add(createTextStyleMenu(home, preferences, true));
      planViewPopup.addSeparator();
      JMenuItem importModifyBackgroundImageMenuItem = createImportModifyBackgroundImageMenuItem(home, true);
      if (importModifyBackgroundImageMenuItem != null) {
        planViewPopup.add(importModifyBackgroundImageMenuItem);
      }
      JMenuItem hideShowBackgroundImageMenuItem = createHideShowBackgroundImageMenuItem(home, true);
      if (hideShowBackgroundImageMenuItem != null) {
        planViewPopup.add(hideShowBackgroundImageMenuItem);
      }
      addActionToPopupMenu(ActionType.DELETE_BACKGROUND_IMAGE, planViewPopup);
      planViewPopup.addSeparator();
      addActionToPopupMenu(ActionType.ZOOM_OUT, planViewPopup);
      addActionToPopupMenu(ActionType.ZOOM_IN, planViewPopup);
      planViewPopup.addSeparator();
      addActionToPopupMenu(ActionType.EXPORT_TO_SVG, planViewPopup);
      SwingTools.hideDisabledMenuItems(planViewPopup);
      planView.setComponentPopupMenu(planViewPopup);
     
      if (planView instanceof Scrollable) {
        final JScrollPane planScrollPane = new HomeScrollPane(planView);
        setPlanRulersVisible(planScrollPane, controller, preferences.isRulersVisible());
        final JComponent lockUnlockBasePlanButton = createLockUnlockBasePlanButton(home);
        if (lockUnlockBasePlanButton != null) {
          planScrollPane.setCorner(JScrollPane.UPPER_LEADING_CORNER, lockUnlockBasePlanButton);
          planScrollPane.addPropertyChangeListener("componentOrientation",
              new PropertyChangeListener () {
                public void propertyChange(PropertyChangeEvent ev) {
                  if (lockUnlockBasePlanButton.getParent() != null) {
                    planScrollPane.setCorner(JScrollPane.UPPER_LEADING_CORNER, lockUnlockBasePlanButton);
                  }
                }
              });
        }
        // Add a listener to update rulers visibility in preferences
        preferences.addPropertyChangeListener(UserPreferences.Property.RULERS_VISIBLE,
            new RulersVisibilityChangeListener(this, planScrollPane, controller));
        // Restore viewport position if it exists
        final JViewport viewport = planScrollPane.getViewport();
        Integer viewportX = (Integer)home.getVisualProperty(PLAN_VIEWPORT_X_VISUAL_PROPERTY);
        Integer viewportY = (Integer)home.getVisualProperty(PLAN_VIEWPORT_Y_VISUAL_PROPERTY);
        if (viewportX != null && viewportY != null) {
          viewport.setViewPosition(new Point(viewportX, viewportY));
        }
        viewport.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent ev) {
              Point viewportPosition = viewport.getViewPosition();
              controller.setVisualProperty(PLAN_VIEWPORT_X_VISUAL_PROPERTY, viewportPosition.x);
              controller.setVisualProperty(PLAN_VIEWPORT_Y_VISUAL_PROPERTY, viewportPosition.y);
            }
          });
        planView = planScrollPane;
      }
    }

    // Configure 3D view
    JComponent view3D = (JComponent)controller.getHomeController3D().getView();
    if (view3D != null) {
      view3D.setPreferredSize(planView != null
          ? planView.getPreferredSize()
          : new Dimension(400, 400));
      view3D.setMinimumSize(new Dimension(0, 0));
     
      // Create 3D view popup menu
      JPopupMenu view3DPopup = new JPopupMenu();
      addToggleActionToPopupMenu(ActionType.VIEW_FROM_TOP,
          this.viewFromTopToggleModel, true, view3DPopup);
      addToggleActionToPopupMenu(ActionType.VIEW_FROM_OBSERVER,
          this.viewFromObserverToggleModel, true, view3DPopup);
      addActionToPopupMenu(ActionType.STORE_POINT_OF_VIEW, view3DPopup);
      view3DPopup.add(createGoToPointOfViewMenu(home, preferences, controller));
      view3DPopup.addSeparator();
      JMenuItem attachDetach3DViewMenuItem = createAttachDetach3DViewMenuItem(controller, true);
      if (attachDetach3DViewMenuItem != null) {
        view3DPopup.add(attachDetach3DViewMenuItem);
      }
      addActionToPopupMenu(ActionType.MODIFY_3D_ATTRIBUTES, view3DPopup);
      view3DPopup.addSeparator();
      addActionToPopupMenu(ActionType.CREATE_PHOTO, view3DPopup);
      addActionToPopupMenu(ActionType.CREATE_VIDEO, view3DPopup);
      view3DPopup.addSeparator();
      addActionToPopupMenu(ActionType.EXPORT_TO_OBJ, view3DPopup);
      SwingTools.hideDisabledMenuItems(view3DPopup);
      view3D.setComponentPopupMenu(view3DPopup);
     
      if (view3D instanceof Scrollable) {
View Full Code Here

        if (treePath == null) {
            return;
        }

        // create the popup and menus
        JPopupMenu popup = new JPopupMenu();
        JMenuItem  menuItem;
        String     menus[] = new String[] {
            "Select", "Delete", "Update", "Insert"
        };

        // loop throught the menus we want to create, making a PopupListener
        // for each one
        for (int i = 0; i < menus.length; i++) {
            PopupListener popupListener = new PopupListener(menus[i],
                treePath);
            String title = popupListener.toString();

            if (title == null) {
                return;
            }

            // Some of the menu names can be quite long (especially insert).
            // If it's too long, abbreviate it
            if (title.length() > 40) {
                title = title.substring(0, 40) + "...";
            }

            menuItem = new JMenuItem(title);

            menuItem.addActionListener(popupListener);
            popup.add(menuItem);
        }

        popup.show(e.getComponent(), e.getX(), e.getY());
    }
View Full Code Here

  /**
   * A popup menu listener that displays only enabled menu items.
   */
  private static class MenuItemsVisibilityListener implements PopupMenuListener {
    public void popupMenuWillBecomeVisible(PopupMenuEvent ev) {       
      JPopupMenu popupMenu = (JPopupMenu)ev.getSource();
      // Make visible only enabled menu items  
      for (int i = 0; i < popupMenu.getComponentCount(); i++) {
        Component component = popupMenu.getComponent(i);
        if (component instanceof JMenu) {
          component.setVisible(containsEnabledItems((JMenu)component));
        } else if (component instanceof JMenuItem) {
          component.setVisible(component.isEnabled());
        }
      }
      hideUselessSeparators(popupMenu);
      // Ensure at least one item is visible
      boolean allItemsInvisible = true;
      for (int i = 0; i < popupMenu.getComponentCount(); i++) {
        if (popupMenu.getComponent(i).isVisible()) {
          allItemsInvisible = false;
          break;
        }
      } 
      if (allItemsInvisible) {
        popupMenu.getComponent(0).setVisible(true);
      }
    }
View Full Code Here

    this.model = model;
   
    table = new JLogTable(model, logEntryDetail, bSort);
    scrollpane = new JScrollPane(table);
   
    popup = new JPopupMenu() {
    {
      add(new JMenuItem("Copy log to clipboard") {
    {
      addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
View Full Code Here

 
        @Override
        public void mouseReleased(MouseEvent ev) {
          if (!retargetMouseEventToNavigationPanelChildren(ev)) {
            if (ev.isPopupTrigger()) {
              JPopupMenu componentPopupMenu = getComponentPopupMenu();
              if (componentPopupMenu != null) {
                componentPopupMenu.show(HomeComponent3D.this, ev.getX(), ev.getY());
              }
            }
          }
        }
View Full Code Here

    _analysisJobBuilder = analysisJobBuilder;
  }
 
  @Override
  public final void actionPerformed(ActionEvent e) {
    JPopupMenu popup = new JPopupMenu();

    for (final AnalyzerBeanDescriptor<?> descriptor : getDescriptors()) {
      JMenuItem outputWriterMenuItem = new DescriptorMenuItem(descriptor);
      outputWriterMenuItem.addActionListener(new ActionListener() {
        @SuppressWarnings("unchecked")
        @Override
        public void actionPerformed(ActionEvent e) {
          Class<? extends RowProcessingAnalyzer<?>> beanClass = (Class<? extends RowProcessingAnalyzer<?>>) descriptor
              .getComponentClass();

          RowProcessingAnalyzerJobBuilder<? extends RowProcessingAnalyzer<?>> ajb = _analysisJobBuilder
              .addRowProcessingAnalyzer(beanClass);

          configure(_analysisJobBuilder, ajb);

          ajb.onConfigurationChanged();
        }
      });
      popup.add(outputWriterMenuItem);
    }

    JComponent component = (JComponent) e.getSource();
    popup.show(component, 0, component.getHeight());
  }
View Full Code Here

      reorderColumnsButton.addMouseListener(buttonMouseListener);
      reorderColumnsButton.addActionListener(new ReorderColumnsActionListener(_propertyDescriptor, _beanJobBuilder));
      panel.add(reorderColumnsButton);
    }

    _popup = new JPopupMenu();

    // the invoker is not being set because it causes an unwanted Frame
    // focus, which may cause interruptions because the mouse is only
    // hovered.
    // _popup.setInvoker(_parent);
View Full Code Here

    final JButton moreDatastoreTypesButton = new JButton("more");
    moreDatastoreTypesButton.setMargin(new Insets(1, 1, 1, 1));
    moreDatastoreTypesButton.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        final JPopupMenu popup = new JPopupMenu();

        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);
          }
        }

        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("images/menu/options.png", 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);
View Full Code Here

          UsageLogger.getInstance().log("Save DataSet as CSV file");
        }
      }
    });

    JPopupMenu popup = new JPopupMenu();
    popup.add(saveAsDatastoreItem);
    popup.add(saveAsCsvItem);
    JComponent source = (JComponent) event.getSource();
    popup.show(source, 0, source.getHeight());
  }
View Full Code Here

TOP

Related Classes of javax.swing.JPopupMenu

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.