/**
  * This is the hook through which all menu items are created. It registers the result with the
  * menuitem hashtable so that it can be fetched with getMenuItem().
  *
  * @see #getMenuItem
  */
 protected JMenuItem createMenuItem(String cmd) {
   JMenuItem mi = new JMenuItem(getResourceString(cmd + labelSuffix));
   URL url = getResource(cmd + imageSuffix);
   if (url != null) {
     mi.setHorizontalTextPosition(JButton.RIGHT);
     mi.setIcon(new ImageIcon(url));
   }
   String astr = getResourceString(cmd + actionSuffix);
   if (astr == null) {
     astr = cmd;
   }
   mi.setActionCommand(astr);
   Action myaction = getAction(astr); // if this is a known action
   if (myaction != null) {
     mi.addActionListener(myaction);
     myaction.addPropertyChangeListener(createActionChangeListener(mi));
     // System.out.println("myaction not null: astr:"+astr+" enabled:"+myaction.isEnabled());
     mi.setEnabled(myaction.isEnabled());
   } else {
     System.err.println("Error:TextViewer: createMenuItem: myaction is null: astr:" + astr);
     // causes the item to be greyed out
     mi.setEnabled(false);
   }
   menuItems.put(cmd, mi);
   return mi;
 }
Beispiel #2
0
  public LightDevice() throws InvalidDescriptionException {
    super(new File(DESCRIPTION_FILE_NAME));
    setSSDPBindAddress(HostInterface.getInetAddress(HostInterface.IPV4_BITMASK, null));
    setHTTPBindAddress(HostInterface.getInetAddress(HostInterface.IPV4_BITMASK, null));

    Action getPowerAction = getAction("GetPower");
    getPowerAction.setActionListener(this);

    Action setPowerAction = getAction("SetPower");
    setPowerAction.setActionListener(this);

    ServiceList serviceList = getServiceList();
    Service service = serviceList.getService(0);
    service.setQueryListener(this);

    powerVar = getStateVariable("Power");

    Argument powerArg = getPowerAction.getArgument("Power");
    StateVariable powerState = powerArg.getRelatedStateVariable();
    AllowedValueList allowList = powerState.getAllowedValueList();
    for (int n = 0; n < allowList.size(); n++)
      System.out.println("[" + n + "] = " + allowList.getAllowedValue(n));

    AllowedValueRange allowRange = powerState.getAllowedValueRange();
    System.out.println("maximum = " + allowRange.getMaximum());
    System.out.println("minimum = " + allowRange.getMinimum());
    System.out.println("step = " + allowRange.getStep());
  }
  /**
   * Enable/disable an AbstractAction
   *
   * @param actionName the key that maps this action in actionTable
   * @param b true to enable or false to disable the action
   */
  public static synchronized void setActionEnabled(final Integer actionKey, final boolean b) {
    Action aa = actionTable.get(actionKey);

    if (aa != null) {
      aa.setEnabled(b);
    }
  }
  private void initAccelerator(Class<? extends Action> actionClass, JMenuItem mnuItem) {
    Action action = _session.getApplication().getActionCollection().get(actionClass);

    String accel = (String) action.getValue(Resources.ACCELERATOR_STRING);
    if (null != accel && 0 != accel.trim().length()) {
      mnuItem.setAccelerator(KeyStroke.getKeyStroke(accel));
    }
  }
 private void addButton(JPanel container, Action action, Hashtable actions, Icon icon) {
   String actionName = (String) action.getValue(Action.NAME);
   String actionCommand = (String) action.getValue(Action.ACTION_COMMAND_KEY);
   JButton button = new JButton(icon);
   button.setActionCommand(actionCommand);
   button.addActionListener(DeepaMehtaClientUtils.getActionByName(actionName, actions));
   container.add(button);
   toolbarButtons[buttonIndex++] = button;
 }
 public void adjustFeedback() {
   actionCancel.setEnabled(true);
   actionChooseNone.setEnabled(true);
   if (getSwingFocus() == null) {
     actionChooseSelected.setEnabled(false);
   } else {
     actionChooseSelected.setEnabled(true);
   }
 }
Beispiel #7
0
  private Action getAction(String name) {
    for (Action action : sourceArea.getActions()) {
      if (name.equals(action.getValue(Action.NAME).toString())) {
        return action;
      }
    }

    return null;
  }
Beispiel #8
0
 public void clearActions() {
   final Set<Action> actions = myActions.keySet();
   for (Iterator<Action> iterator = actions.iterator(); iterator.hasNext(); ) {
     Action each = iterator.next();
     each.removePropertyChangeListener(this);
   }
   myActions.clear();
   myActionsPanel.removeAll();
 }
Beispiel #9
0
  /** Synchronizes the state of the actions to the current state of this host. */
  private void updateActions() {
    final DeviceController currentDeviceController = getDeviceController();

    final boolean deviceControllerSet = currentDeviceController != null;
    final boolean deviceCapturing = deviceControllerSet && currentDeviceController.isCapturing();
    final boolean deviceSetup =
        deviceControllerSet && !deviceCapturing && currentDeviceController.isSetup();

    getAction(CaptureAction.ID).setEnabled(deviceControllerSet);
    getAction(CancelCaptureAction.ID).setEnabled(deviceCapturing);
    getAction(RepeatCaptureAction.ID).setEnabled(deviceSetup);

    final boolean projectChanged = this.projectManager.getCurrentProject().isChanged();
    final boolean projectSavedBefore =
        this.projectManager.getCurrentProject().getFilename() != null;
    final boolean dataAvailable = this.dataContainer.hasCapturedData();

    getAction(SaveProjectAction.ID).setEnabled(projectChanged);
    getAction(SaveProjectAsAction.ID).setEnabled(projectSavedBefore && projectChanged);
    getAction(SaveDataFileAction.ID).setEnabled(dataAvailable);

    getAction(ZoomInAction.ID).setEnabled(dataAvailable);
    getAction(ZoomOutAction.ID).setEnabled(dataAvailable);
    getAction(ZoomDefaultAction.ID).setEnabled(dataAvailable);
    getAction(ZoomFitAction.ID).setEnabled(dataAvailable);

    final boolean triggerEnable = dataAvailable && this.dataContainer.hasTriggerData();
    getAction(GotoTriggerAction.ID).setEnabled(triggerEnable);

    // Update the cursor actions accordingly...
    final boolean enableCursors = dataAvailable && this.dataContainer.isCursorsEnabled();

    for (int c = 0; c < CapturedData.MAX_CURSORS; c++) {
      final boolean enabled = enableCursors && this.dataContainer.isCursorPositionSet(c);
      getAction(GotoNthCursorAction.getID(c)).setEnabled(enabled);
    }

    getAction(GotoFirstCursorAction.ID).setEnabled(enableCursors);
    getAction(GotoLastCursorAction.ID).setEnabled(enableCursors);

    getAction(SetCursorModeAction.ID).setEnabled(dataAvailable);
    getAction(SetCursorModeAction.ID)
        .putValue(Action.SELECTED_KEY, Boolean.valueOf(this.dataContainer.isCursorsEnabled()));

    boolean anyCursorSet = false;
    for (int c = 0; c < CapturedData.MAX_CURSORS; c++) {
      final boolean cursorPositionSet = this.dataContainer.isCursorPositionSet(c);
      anyCursorSet |= cursorPositionSet;

      final Action action = getAction(SetCursorAction.getCursorId(c));
      action.setEnabled(dataAvailable);
      action.putValue(Action.SELECTED_KEY, Boolean.valueOf(cursorPositionSet));
    }

    getAction(ClearCursors.ID).setEnabled(enableCursors && anyCursorSet);
  }
  public void setChannel(int chan) {
    currentChannel = chan;
    channelLabel.setText("Now tuned to channel: " + currentChannel);
    // enable/disable the Actions as appropriate

    downAction.setEnabled(currentChannel > MIN_CHANNEL);
    upAction.setEnabled(currentChannel < MAX_CHANNEL);
    gotoFavoriteAction.setEnabled(currentChannel != favoriteChannel);
    setFavoriteAction.setEnabled(currentChannel != favoriteChannel);
  }
Beispiel #11
0
 public void mouseEntered(MouseEvent evt) {
   if (evt.getSource() instanceof AbstractButton) {
     AbstractButton button = (AbstractButton) evt.getSource();
     Action action = button.getAction();
     if (action != null) {
       String message = (String) action.getValue("LongDescription");
       setMessage(message);
     }
   }
 }
 @Override
 public void show(Component c, int x, int y) {
   if (c instanceof JTextComponent) {
     JTextComponent textArea = (JTextComponent) c;
     boolean flg = Objects.nonNull(textArea.getSelectedText());
     cutAction.setEnabled(flg);
     copyAction.setEnabled(flg);
     deleteAction.setEnabled(flg);
     super.show(c, x, y);
   }
 }
  // inherit doc comment
  protected JPopupMenu createPopupMenu() {
    if (TABLE.getSelectionModel().isSelectionEmpty()) {
      return null;
    }

    JPopupMenu menu = new SkinPopupMenu();

    menu.add(new SkinMenuItem(LAUNCH_ACTION));
    if (getMediaType().equals(MediaType.getAudioMediaType())) {
      menu.add(new SkinMenuItem(LAUNCH_OS_ACTION));
    }
    if (hasExploreAction()) {
      menu.add(new SkinMenuItem(OPEN_IN_FOLDER_ACTION));
    }

    if (areAllSelectedFilesMP4s()) {
      menu.add(DEMUX_MP4_AUDIO_ACTION);
      DEMUX_MP4_AUDIO_ACTION.setEnabled(
          !((DemuxMP4AudioAction) DEMUX_MP4_AUDIO_ACTION).isDemuxing());
    }

    menu.add(new SkinMenuItem(CREATE_TORRENT_ACTION));

    if (areAllSelectedFilesPlayable()) {
      menu.add(createAddToPlaylistSubMenu());
    }

    menu.add(new SkinMenuItem(SEND_TO_FRIEND_ACTION));
    menu.add(new SkinMenuItem(SEND_TO_ITUNES_ACTION));

    menu.addSeparator();
    menu.add(new SkinMenuItem(DELETE_ACTION));
    menu.addSeparator();

    int[] rows = TABLE.getSelectedRows();
    boolean dirSelected = false;
    boolean fileSelected = false;

    for (int i = 0; i < rows.length; i++) {
      File f = DATA_MODEL.get(rows[i]).getFile();
      if (f.isDirectory()) {
        dirSelected = true;
        //				if (IncompleteFileManager.isTorrentFolder(f))
        //					torrentSelected = true;
      } else fileSelected = true;

      if (dirSelected && fileSelected) break;
    }

    DELETE_ACTION.setEnabled(true);
    LibraryFilesTableDataLine line = DATA_MODEL.get(rows[0]);
    menu.add(createSearchSubMenu(line));
    return menu;
  }
Beispiel #14
0
 private boolean proceedKeyEvent(KeyEvent event, KeyStroke stroke) {
   if (myInputMap.get(stroke) != null) {
     final Action action = myActionMap.get(myInputMap.get(stroke));
     if (action != null && action.isEnabled()) {
       action.actionPerformed(
           new ActionEvent(
               getContent(), event.getID(), "", event.getWhen(), event.getModifiers()));
       return true;
     }
   }
   return false;
 }
Beispiel #15
0
 /** Configures a JCheckBoxMenuItem for an Action. */
 public static void configureJCheckBoxMenuItem(final JCheckBoxMenuItem mi, final Action a) {
   mi.setSelected((Boolean) a.getValue(Actions.SELECTED_KEY));
   PropertyChangeListener propertyHandler =
       new PropertyChangeListener() {
         public void propertyChange(PropertyChangeEvent evt) {
           if (evt.getPropertyName().equals(Actions.SELECTED_KEY)) {
             mi.setSelected((Boolean) a.getValue(Actions.SELECTED_KEY));
           }
         }
       };
   a.addPropertyChangeListener(propertyHandler);
   mi.putClientProperty("actionPropertyHandler", propertyHandler);
 }
  public FilterPanel init(
      final ReadablePreset.ReadableVoice voice, TableExclusiveSelectionContext tsc)
      throws ParameterException, DeviceException {
    this.setLayout(new FlowLayout());
    final List filterIds =
        voice
            .getPreset()
            .getDeviceParameterContext()
            .getVoiceContext()
            .getIdsForCategory(ParameterCategories.VOICE_FILTER);

    filterModels = new ReadableParameterModel[filterIds.size()];

    try {
      for (int i = 0, j = filterIds.size(); i < j; i++)
        filterModels[i] = voice.getParameterModel((Integer) filterIds.get(i));
    } catch (IllegalParameterIdException e) {
      ZUtilities.zDisposeCollection(Arrays.asList(filterModels));
      throw e;
    }

    Action ra =
        new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            try {
              voice
                  .getPreset()
                  .refreshVoiceParameters(
                      voice.getVoiceNumber(),
                      (Integer[]) filterIds.toArray(new Integer[filterIds.size()]));
            } catch (PresetException e1) {
              e1.printStackTrace();
            }
          }
        };
    ra.putValue("tip", "Refresh Filter");

    FilterParameterTableModel model = new FilterParameterTableModel(filterModels);

    RowHeaderedAndSectionedTablePanel ampPanel;
    VoiceParameterTable vpt =
        new VoiceParameterTable(voice, ParameterCategories.VOICE_FILTER, model, "Filter");
    tsc.addTableToContext(vpt);
    ampPanel =
        new RowHeaderedAndSectionedTablePanel()
            .init(vpt, "Show Filter", UIColors.getTableBorder(), ra);
    this.add(ampPanel);
    return this;
  }
Beispiel #17
0
 public void caretUpdate(CaretEvent e) {
   // when the cursor moves on _textView
   // this method will be called. Then, we
   // must determine what the line number is
   // and update the line number view
   Element root = textView.getDocument().getDefaultRootElement();
   int line = root.getElementIndex(e.getDot());
   root = root.getElement(line);
   int col = root.getElementIndex(e.getDot());
   lineNumberView.setText(line + ":" + col);
   // if text is selected then enable copy and cut
   boolean isSelection = e.getDot() != e.getMark();
   copyAction.setEnabled(isSelection);
   cutAction.setEnabled(isSelection);
 }
    public void actionPerformed(ActionEvent e) {
      int selIndexBefore = getSelectedIndex();
      myDefaultAction.actionPerformed(e);
      int selIndexCurrent = getSelectedIndex();
      if (selIndexBefore != selIndexCurrent) {
        return;
      }
      if (myFocusNext && selIndexCurrent == 0) {
        return;
      }

      KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
      Container container = kfm.getCurrentFocusCycleRoot();
      FocusTraversalPolicy policy = container.getFocusTraversalPolicy();
      if (policy == null) {
        policy = kfm.getDefaultFocusTraversalPolicy();
      }
      Component next =
          myFocusNext
              ? policy.getComponentAfter(container, PaletteItemsComponent.this)
              : policy.getComponentBefore(container, PaletteItemsComponent.this);
      if (next instanceof PaletteGroupComponent) {
        clearSelection();
        next.requestFocus();
        ((PaletteGroupComponent) next).scrollRectToVisible(next.getBounds());
      }
    }
Beispiel #19
0
 public void activate() {
   // arranco la primera opcion
   if (m_actionfirst != null) {
     m_actionfirst.actionPerformed(null);
     m_actionfirst = null;
   }
 }
Beispiel #20
0
  @SuppressWarnings("OverridableMethodCallInConstructor")
  Notepad() {
    super(true);

    // Trying to set Nimbus look and feel
    try {
      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (Exception ignored) {
    }

    setBorder(BorderFactory.createEtchedBorder());
    setLayout(new BorderLayout());

    // create the embedded JTextComponent
    editor = createEditor();
    // Add this as a listener for undoable edits.
    editor.getDocument().addUndoableEditListener(undoHandler);

    // install the command table
    commands = new HashMap<Object, Action>();
    Action[] actions = getActions();
    for (Action a : actions) {
      commands.put(a.getValue(Action.NAME), a);
    }

    JScrollPane scroller = new JScrollPane();
    JViewport port = scroller.getViewport();
    port.add(editor);

    String vpFlag = getProperty("ViewportBackingStore");
    if (vpFlag != null) {
      Boolean bs = Boolean.valueOf(vpFlag);
      port.setScrollMode(bs ? JViewport.BACKINGSTORE_SCROLL_MODE : JViewport.BLIT_SCROLL_MODE);
    }

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add("North", createToolbar());
    panel.add("Center", scroller);
    add("Center", panel);
    add("South", createStatusbar());
  }
 /**
  * The disconnect method will stop the eventreplayer, and send null to the other peers, to stop
  * their reading from their streams. The GUI-menu is updated appropriately.
  */
 public void disconnect() {
   setTitle("Disconnected");
   active = false;
   if (connected == true) {
     er.stopStreamToQueue();
     ert.interrupt();
     setDocumentFilter(null);
     connected = false;
     setLocked(false);
   }
   deregisterOnPort();
   Disconnect.setEnabled(false);
   Connect.setEnabled(true);
   Listen.setEnabled(true);
   Save.setEnabled(true);
   SaveAs.setEnabled(true);
 }
Beispiel #22
0
 /** Unconfigures a JCheckBoxMenuItem for an Action. */
 public static void unconfigureJCheckBoxMenuItem(JCheckBoxMenuItem mi, Action a) {
   PropertyChangeListener propertyHandler =
       (PropertyChangeListener) mi.getClientProperty("actionPropertyHandler");
   if (propertyHandler != null) {
     a.removePropertyChangeListener(propertyHandler);
     mi.putClientProperty("actionPropertyHandler", null);
   }
 }
  /**
   * Mouse Listener methods.
   *
   * <p>spv
   */
  public void mouseTriggered(MouseEvent me) {
    if (me.isPopupTrigger()) {
      actionJumpToError.setEnabled(parseError != null && parseError.hasLineNumbers());
      ((GUIMultiModel) handler.getGUIPlugin()).doEnables();

      contextPopup.show(me.getComponent(), me.getX(), me.getY());
    }
  }
  /**
   * Handles the selection rows in the library window, enabling or disabling buttons and chat menu
   * items depending on the values in the selected rows.
   *
   * @param row the index of the first row that is selected
   */
  public void handleSelection(int row) {
    int[] sel = TABLE.getSelectedRows();
    if (sel.length == 0) {
      handleNoSelection();
      return;
    }

    File selectedFile = getFile(sel[0]);

    //  always turn on Launch, Delete, Magnet Lookup, Bitzi Lookup
    LAUNCH_ACTION.setEnabled(true);
    LAUNCH_OS_ACTION.setEnabled(true);
    DELETE_ACTION.setEnabled(true);

    if (selectedFile != null && !selectedFile.getName().endsWith(".torrent")) {
      CREATE_TORRENT_ACTION.setEnabled(sel.length == 1);
    }

    if (selectedFile != null) {
      SEND_TO_FRIEND_ACTION.setEnabled(sel.length == 1);

      if (getMediaType().equals(MediaType.getAnyTypeMediaType())) {
        boolean atLeastOneIsPlayable = false;

        for (int i : sel) {
          File f = getFile(i);
          if (MediaPlayer.isPlayableFile(f) || hasExtension(f.getAbsolutePath(), "mp4")) {
            atLeastOneIsPlayable = true;
            break;
          }
        }

        SEND_TO_ITUNES_ACTION.setEnabled(atLeastOneIsPlayable);
      } else {
        SEND_TO_ITUNES_ACTION.setEnabled(
            getMediaType().equals(MediaType.getAudioMediaType())
                || hasExtension(selectedFile.getAbsolutePath(), "mp4"));
      }
    }

    if (sel.length == 1 && selectedFile.isFile() && selectedFile.getParentFile() != null) {
      OPEN_IN_FOLDER_ACTION.setEnabled(true);
    } else {
      OPEN_IN_FOLDER_ACTION.setEnabled(false);
    }

    if (sel.length == 1) {
      LibraryMediator.instance().getLibraryCoverArt().setFile(selectedFile);
    }

    //        boolean anyBeingShared = isAnyBeingShared();
    //        WIFI_SHARE_ACTION.setEnabled(!anyBeingShared);
    //        WIFI_UNSHARE_ACTION.setEnabled(!anyBeingShared);
  }
  public ToolBarFrame() {
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    // add a panel for color change

    panel = new JPanel();
    add(panel, BorderLayout.CENTER);

    // set up actions

    Action blueAction = new ColorAction("Blue", new ImageIcon("blue-ball.gif"), Color.BLUE);
    Action yellowAction = new ColorAction("Yellow", new ImageIcon("yellow-ball.gif"), Color.YELLOW);
    Action redAction = new ColorAction("Red", new ImageIcon("red-ball.gif"), Color.RED);

    Action exitAction =
        new AbstractAction("Exit", new ImageIcon("exit.gif")) {
          public void actionPerformed(ActionEvent event) {
            System.exit(0);
          }
        };
    exitAction.putValue(Action.SHORT_DESCRIPTION, "Exit");

    // populate tool bar

    JToolBar bar = new JToolBar();
    bar.add(blueAction);
    bar.add(yellowAction);
    bar.add(redAction);
    bar.addSeparator();
    bar.add(exitAction);
    add(bar, BorderLayout.NORTH);

    // populate menu

    JMenu menu = new JMenu("Color");
    menu.add(yellowAction);
    menu.add(blueAction);
    menu.add(redAction);
    menu.add(exitAction);
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(menu);
    setJMenuBar(menuBar);
  }
 public Action getNewFolderAction() {
   if (newFolderAction == null) {
     newFolderAction = new NewFolderAction();
     // Note: Don't return null for readOnly, it might
     // break older apps.
     if (readOnly) {
       newFolderAction.setEnabled(false);
     }
   }
   return newFolderAction;
 }
 private void saveFile(String fileName) {
   try {
     FileWriter w = new FileWriter(fileName);
     area1.write(w);
     w.close();
     currentFile = fileName;
     changed = false;
     Save.setEnabled(false);
   } catch (IOException e) {
   }
 }
Beispiel #28
0
 /** This is the hook through which all menu items are created. */
 protected JMenuItem createMenuItem(String cmd) {
   JMenuItem mi = new JMenuItem(getResourceString(cmd + labelSuffix));
   URL url = getResource(cmd + imageSuffix);
   if (url != null) {
     mi.setHorizontalTextPosition(JButton.RIGHT);
     mi.setIcon(new ImageIcon(url));
   }
   String astr = getProperty(cmd + actionSuffix);
   if (astr == null) {
     astr = cmd;
   }
   mi.setActionCommand(astr);
   Action a = getAction(astr);
   if (a != null) {
     mi.addActionListener(a);
     a.addPropertyChangeListener(createActionChangeListener(mi));
     mi.setEnabled(a.isEnabled());
   } else {
     mi.setEnabled(false);
   }
   return mi;
 }
Beispiel #29
0
  public void redoAction() {
    try {
      if (undoMgr.canRedo()) {
        redoAction.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "Redo"));

        setRedoItem();
      } else {
        java.awt.Toolkit.getDefaultToolkit().beep();
      }
    } catch (CannotUndoException ex) {
      ex.printStackTrace();
    }
  }
Beispiel #30
-1
  public boolean actionControlReceived(Action action) {
    String actionName = action.getName();

    boolean ret = false;

    if (actionName.equals("GetPower") == true) {
      String state = getPowerState();
      Argument powerArg = action.getArgument("Power");
      powerArg.setValue(state);
      ret = true;
    }
    if (actionName.equals("SetPower") == true) {
      Argument powerArg = action.getArgument("Power");
      String state = powerArg.getValue();
      setPowerState(state);
      state = getPowerState();
      Argument resultArg = action.getArgument("Result");
      resultArg.setValue(state);
      ret = true;
    }

    comp.repaint();

    return ret;
  }