protected void initColumnSelectorItems() {
    cornerPopup.removeAll();

    JCheckBoxMenuItem menuItem;

    for (int i = 0; i < realFieldsListTableModel.getColumnCount(); i++) {
      menuItem = new JCheckBoxMenuItem(realFieldsListTableModel.getColumnName(i));
      menuItem.setActionCommand(Integer.valueOf(i).toString());
      addMenuItemListener(menuItem);

      if (fieldsListTable != null) {
        menuItem.setState(fieldsListTableModel.isRealColumnVisible(i));

        if (i == 0) {
          menuItem.setEnabled(false);
        }
      } else {
        menuItem.setState(true);
      }

      cornerPopup.add(menuItem);
    }

    cornerPopup.pack();
  }
Example #2
0
 private static JMenuItem getMenuItem_ShowTabs() {
   final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem("Panel Tabs");
   menuItem.setAccelerator(MenuUtil.getAcceleratorKey(KeyEvent.VK_T));
   menuItem.setState(!prefs.getPrefBoolean(FPref.UI_HIDE_GAME_TABS));
   menuItem.addActionListener(getShowTabsAction(menuItem));
   return menuItem;
 }
 /** This implementation assumes, that invoker is of type <code>MapViewPane</code>. */
 @Override
 public void show(Component invoker, int x, int y) {
   pane = (MapViewPane) invoker;
   this.x = x;
   this.y = y;
   debugMenuItem.setState(pane.isDebugModeEnabled());
   super.show(invoker, x, y);
 }
Example #4
0
 public BaseTranslate() {
   menuItem = new JCheckBoxMenuItem();
   Mnemonics.setLocalizedText(menuItem, getName());
   menuItem.addActionListener(this);
   enabled = Preferences.isPreference(getPreferenceName());
   menuItem.setState(enabled);
   Core.getMainWindow().getMainMenu().getMachineTranslationMenu().add(menuItem);
 }
Example #5
0
  @Override
  /** {@inheritDoc} */
  protected void contentChanged(DiagramPane pane) {
    if (pane == null) {
      updateMenus(false);
      saveItem.setEnabled(false);
      container.updateToolBar(null);
    } else {
      saveItem.setEnabled(!pane.isSaved());
      numberingItem.setState(pane.getOptions().isNumberingEnabled());
      updateMenus(true);

      OrderingLevel level = pane.getOptions().getOrderingLevel();
      orderingOffItem.setState(level == OrderingLevel.OFF);
      orderingOverlapItem.setState(level == OrderingLevel.SUPPRESS_OVERLAP);
      container.updateToolBar(pane);
    }
  }
Example #6
0
 void setSelected(Object c, boolean sel) {
   if (c instanceof JToggleButton) {
     ((JToggleButton) c).setSelected(sel);
     return;
   }
   if (c instanceof JCheckBoxMenuItem) {
     ((JCheckBoxMenuItem) c).setState(sel);
     return;
   }
   // skip
 }
Example #7
0
 private void createWindowsMenu() {
   windowsMenu = new JMenu("Windows");
   menuBar.add(windowsMenu);
   showCmdsItem = new JCheckBoxMenuItem("Show Commands");
   showCmdsItem.setState(true);
   windowsMenu.add(showCmdsItem);
   showResultsItem = new JCheckBoxMenuItem("Show Results");
   showResultsItem.setState(true);
   windowsMenu.add(showResultsItem);
   showTraceItem = new JCheckBoxMenuItem("Show Trace Output");
   showTraceItem.setState(true);
   windowsMenu.add(showTraceItem);
   tileItem = new JMenuItem("Tile");
   tileItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           MainWindow.this.tile();
         }
       });
   windowsMenu.add(tileItem);
 }
    public static void makeMenuBar(JFrame frame, final AirspaceBuilderController controller) {
      JMenuBar menuBar = new JMenuBar();
      final JCheckBoxMenuItem resizeNewShapesItem;
      final JCheckBoxMenuItem enableEditItem;

      JMenu menu = new JMenu("File");
      {
        JMenuItem item = new JMenuItem("Open...");
        item.setAccelerator(
            KeyStroke.getKeyStroke(
                KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.setActionCommand(OPEN);
        item.addActionListener(controller);
        menu.add(item);

        item = new JMenuItem("Open URL...");
        item.setActionCommand(OPEN_URL);
        item.addActionListener(controller);
        menu.add(item);

        item = new JMenuItem("Save...");
        item.setAccelerator(
            KeyStroke.getKeyStroke(
                KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.setActionCommand(SAVE);
        item.addActionListener(controller);
        menu.add(item);

        menu.addSeparator();

        item = new JMenuItem("Load Demo Shapes");
        item.setActionCommand(OPEN_DEMO_AIRSPACES);
        item.addActionListener(controller);
        menu.add(item);
      }
      menuBar.add(menu);

      menu = new JMenu("Shape");
      {
        JMenu subMenu = new JMenu("New");
        for (final AirspaceFactory factory : defaultAirspaceFactories) {
          JMenuItem item = new JMenuItem(factory.toString());
          item.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  controller.createNewEntry(factory);
                }
              });
          subMenu.add(item);
        }
        menu.add(subMenu);

        resizeNewShapesItem = new JCheckBoxMenuItem("Fit new shapes to viewport");
        resizeNewShapesItem.setActionCommand(SIZE_NEW_SHAPES_TO_VIEWPORT);
        resizeNewShapesItem.addActionListener(controller);
        resizeNewShapesItem.setState(controller.isResizeNewShapesToViewport());
        menu.add(resizeNewShapesItem);

        enableEditItem = new JCheckBoxMenuItem("Enable shape editing");
        enableEditItem.setActionCommand(ENABLE_EDIT);
        enableEditItem.addActionListener(controller);
        enableEditItem.setState(controller.isEnableEdit());
        menu.add(enableEditItem);
      }
      menuBar.add(menu);

      menu = new JMenu("Selection");
      {
        JMenuItem item = new JMenuItem("Deselect");
        item.setAccelerator(
            KeyStroke.getKeyStroke(
                KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.setActionCommand(CLEAR_SELECTION);
        item.addActionListener(controller);
        menu.add(item);

        item = new JMenuItem("Delete");
        item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
        item.setActionCommand(REMOVE_SELECTED);
        item.addActionListener(controller);
        menu.add(item);
      }
      menuBar.add(menu);

      frame.setJMenuBar(menuBar);

      controller.addPropertyChangeListener(
          new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent e) {
              if (SIZE_NEW_SHAPES_TO_VIEWPORT.equals((e.getPropertyName()))) {
                resizeNewShapesItem.setSelected(controller.isResizeNewShapesToViewport());
              } else if (ENABLE_EDIT.equals(e.getPropertyName())) {
                enableEditItem.setSelected(controller.isEnableEdit());
              }
            }
          });
    }
    @Override
    public void run() {
      if (androidMode.getSDK() == null) return;

      final Devices devices = Devices.getInstance();
      java.util.List<Device> deviceList = devices.findMultiple(false);
      Device selectedDevice = devices.getSelectedDevice();

      if (deviceList.size() == 0) {
        // if (deviceMenu.getItem(0).isEnabled()) {
        if (0 < deviceMenu.getItemCount()) {
          deviceMenu.removeAll();
          JMenuItem noDevicesItem = new JMenuItem("No connected devices");
          noDevicesItem.setEnabled(false);
          deviceMenu.add(noDevicesItem);
        }
        devices.setSelectedDevice(null);
      } else {
        deviceMenu.removeAll();

        if (selectedDevice == null) {
          selectedDevice = deviceList.get(0);
          devices.setSelectedDevice(selectedDevice);
        } else {
          // check if selected device is still connected
          boolean found = false;
          for (Device device : deviceList) {
            if (device.equals(selectedDevice)) {
              found = true;
              break;
            }
          }

          if (!found) {
            selectedDevice = deviceList.get(0);
            devices.setSelectedDevice(selectedDevice);
          }
        }

        for (final Device device : deviceList) {
          final JCheckBoxMenuItem deviceItem = new JCheckBoxMenuItem(device.getName());
          deviceItem.setEnabled(true);

          if (device.equals(selectedDevice)) deviceItem.setState(true);

          // prevent checkboxmenuitem automatic state changing onclick
          deviceItem.addChangeListener(
              new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                  if (device.equals(devices.getSelectedDevice())) deviceItem.setState(true);
                  else deviceItem.setState(false);
                }
              });

          deviceItem.addActionListener(
              new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                  devices.setSelectedDevice(device);

                  for (int i = 0; i < deviceMenu.getItemCount(); i++) {
                    ((JCheckBoxMenuItem) deviceMenu.getItem(i)).setState(false);
                  }

                  deviceItem.setState(true);
                }
              });

          deviceMenu.add(deviceItem);
        }
      }
    }
  private void updateSdkMenu(final JMenu sdkMenu) {
    try {
      ArrayList<AndroidSDK.SDKTarget> targets = androidMode.getSDK().getAvailableSdkTargets();

      if (targets.size() != 0) sdkMenu.removeAll();

      AndroidSDK.SDKTarget lowestTargetAvailable = null;
      JCheckBoxMenuItem lowestTargetMenuItem = null;

      String savedTargetVersion = Preferences.get("android.sdk.version");
      boolean savedTargetSet = false;

      for (final AndroidSDK.SDKTarget target : targets) {
        if (target.version < 11) {
          // We do not support API level less than 11
          continue;
        }
        final JCheckBoxMenuItem item =
            new JCheckBoxMenuItem("API " + target.name + " (" + target.version + ")");

        if (savedTargetSet == false
            && (lowestTargetAvailable == null || lowestTargetAvailable.version > target.version)) {
          lowestTargetAvailable = target;
          lowestTargetMenuItem = item;
        }

        if (Integer.toString(target.version).equals(savedTargetVersion)) {
          AndroidBuild.setSdkTarget(target, sketch);
          item.setState(true);
          savedTargetSet = true;
        }

        item.addChangeListener(
            new ChangeListener() {
              @Override
              public void stateChanged(ChangeEvent e) {
                if (target.name.equals(AndroidBuild.sdkName)) item.setState(true);
                else item.setState(false);
              }
            });

        item.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                AndroidBuild.setSdkTarget(target, sketch);

                for (int i = 0; i < sdkMenu.getItemCount(); i++) {
                  ((JCheckBoxMenuItem) sdkMenu.getItem(i)).setState(false);
                }

                item.setState(true);
              }
            });

        sdkMenu.add(item);
      }

      if (!savedTargetSet) {
        AndroidBuild.setSdkTarget(lowestTargetAvailable, sketch);
        lowestTargetMenuItem.setState(true);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Example #11
0
 private static JMenuItem getMenuItem_ShowBackgroundImage() {
   final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem("Background Image");
   menuItem.setState(prefs.getPrefBoolean(FPref.UI_MATCH_IMAGE_VISIBLE));
   menuItem.addActionListener(getShowBackgroundImageAction(menuItem));
   return menuItem;
 }