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;
 }
Esempio n. 2
0
 @Override
 public void setAction(Action pAction) {
   super.setAction(pAction);
   Icon icon = (Icon) pAction.getValue(GUIConstants.LARGE_ICON);
   if (icon != null) setIcon(icon);
   // setText("");
 }
Esempio n. 3
0
  /** Support cancelling an order's target acquisition process by hitting the escape key. */
  private void doAddKeyListener(JPanel gameDisplay) {
    Action action =
        new AbstractAction("Escape Handler") {
          public void actionPerformed(ActionEvent e) {
            if ((_actionInProgress != null) && (_actionInProgress instanceof TargetAction)) {
              ((TargetAction) _actionInProgress).cancelTargetAcquisition();
            }
          }
        };

    KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    gameDisplay.getActionMap().put(action.getValue(Action.NAME), action);
    gameDisplay
        .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put(keyStroke, action.getValue(Action.NAME));
  }
 private void init() {
   setTitle("Synchronization Results");
   // Add a OK button
   JPanel southPane = new JPanel();
   southPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 8, 8));
   JButton closeBtn = new JButton("Close");
   closeBtn.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           dispose();
         }
       });
   closeBtn.setMnemonic('C');
   closeBtn.setDefaultCapable(true);
   getRootPane().setDefaultButton(closeBtn);
   southPane.add(closeBtn);
   getContentPane().add(southPane, BorderLayout.SOUTH);
   // Initialize actions
   initUpdateFromDBAction();
   initCommitToDBAction();
   initShowComparisonAction();
   initClearRecordAction();
   // Add a toolbar
   JToolBar toolbar = new JToolBar();
   Insets insets = new Insets(0, 0, 0, 0);
   JButton updateFromDBBtn = toolbar.add(updateFromDBAction);
   updateFromDBBtn.setText((String) updateFromDBAction.getValue(Action.NAME));
   JButton commitToDBBtn = toolbar.add(commitToDBAction);
   commitToDBBtn.setText((String) commitToDBAction.getValue(Action.NAME));
   JButton showComparisonBtn = toolbar.add(showComparisonAction);
   showComparisonBtn.setText((String) showComparisonAction.getValue(Action.NAME));
   JButton clearRecordBtn = toolbar.add(clearRecordAction);
   clearRecordBtn.setText((String) clearRecordAction.getValue(Action.NAME));
   if (!GKApplicationUtilities.isMac()) {
     updateFromDBBtn.setMargin(insets);
     commitToDBBtn.setMargin(insets);
     showComparisonBtn.setMargin(insets);
     clearRecordBtn.setMargin(insets);
   }
   getContentPane().add(toolbar, BorderLayout.NORTH);
   setSize(600, 700);
   GKApplicationUtilities.center(this);
   setModal(true);
   isLocalHasUnexpIECommitAllowed =
       SynchronizationManager.getManager().isLocalHasUnexpIECommitAllowed();
 }
  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));
    }
  }
Esempio n. 6
0
 private void switchOn() {
   requestFocusInWindow();
   Action action = getAction();
   if (action != null) {
     Object message = action.getValue(Action.LONG_DESCRIPTION);
     mStatusLabel.setText(message.toString());
   }
 }
Esempio n. 7
0
  private Action getAction(String name) {
    for (Action action : sourceArea.getActions()) {
      if (name.equals(action.getValue(Action.NAME).toString())) {
        return action;
      }
    }

    return null;
  }
Esempio n. 8
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);
     }
   }
 }
Esempio n. 9
0
 @Override
 public void ioResult(IOServiceEvent e) {
   if (e.getState() == IOServiceEvent.MOUNT_SUCCESS
       || e.getState() == IOServiceEvent.MOUNT_FAILURE) {
     lumberjack.setFullModel(buildModel(e.getResolverBundle().getResolvers()));
     toggleAction.setEnabled(cpos != null);
     toggleAction.putValue(
         Action.SELECTED_KEY,
         (Boolean) toggleAction.getValue(Action.SELECTED_KEY) && cpos != null);
   }
 }
Esempio n. 10
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);
 }
Esempio n. 11
0
    private void addAction(Action act) {

      if (m_appuser.hasPermission((String) act.getValue(AppUserView.ACTION_TASKNAME))) {
        // add the action
        Component c = taskGroup.add(act);
        c.setFocusable(false);
        // c.setRequestFocusEnabled(false);

        taskGroup.setVisible(true);

        if (m_actionfirst == null) {
          m_actionfirst = act;
        }
      }
    }
Esempio n. 12
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());
  }
Esempio n. 13
0
  private void configureRichTextAction(
      ISQLPanelAPI sqlPanelAPI,
      SquirrelRSyntaxTextArea rsEdit,
      String rtaKey,
      KeyStroke acceleratorKeyStroke,
      String acceleratorDescription,
      String shortDescription) {
    Action action = SquirreLRSyntaxTextAreaUI.getActionForName(rsEdit, rtaKey);
    action.putValue(Resources.ACCELERATOR_STRING, acceleratorDescription);

    action.putValue(Action.SHORT_DESCRIPTION, shortDescription);
    action.putValue(Action.MNEMONIC_KEY, 0);
    action.putValue(Action.ACCELERATOR_KEY, acceleratorKeyStroke);

    JMenuItem mnu = sqlPanelAPI.addToSQLEntryAreaMenu(action);
    mnu.setText((String) action.getValue(Action.SHORT_DESCRIPTION));
    _resources.configureMenuItem(action, mnu);
  }
Esempio n. 14
0
 /**
  * Retrieve an icon from the passed action for the specified key.
  *
  * @param action Action to retrieve icon from.
  * @param key Key that specified the icon.
  * @return The requested Icon or null.
  */
 protected Icon getIconFromAction(Action action, String key) {
   // Object obj = action.getValue(BaseAction.IBaseActionPropertyNames.ROLLOVER_ICON);
   Object obj = action.getValue(key);
   if (obj != null) {
     if (obj instanceof Icon) {
       return (Icon) obj;
     }
     StringBuffer msg = new StringBuffer();
     msg.append("Non icon object of type ")
         .append(obj.getClass().getName())
         .append(" was stored in an Action of type ")
         .append(action.getClass().getName())
         .append(" using the key ")
         .append(key)
         .append(".");
     s_log.error(msg.toString());
   }
   return null;
 }
  private OptionInfo getMenuInfo(Action each) {
    final String text = (String) each.getValue(Action.NAME);
    int mnemonic = -1;
    int mnemonicIndex = -1;
    StringBuilder plainText = new StringBuilder();
    for (int i = 0; i < text.length(); i++) {
      char ch = text.charAt(i);
      if (ch == '&' || ch == '_') {
        if (i + 1 < text.length()) {
          final char mnemonicsChar = text.charAt(i + 1);
          mnemonic = Character.toUpperCase(mnemonicsChar);
          mnemonicIndex = i;
        }
        continue;
      }
      plainText.append(ch);
    }

    return new OptionInfo(plainText.toString(), mnemonic, mnemonicIndex, this, each);
  }
Esempio n. 16
0
 protected void initialiseButton(Action action, AbstractButton btn) {
   if (btn != null) {
     btn.setRequestFocusEnabled(false);
     btn.setText("");
     String tt = null;
     if (action != null) {
       tt = (String) action.getValue(Action.SHORT_DESCRIPTION);
     }
     btn.setToolTipText(tt != null ? tt : "");
     if (action != null) {
       Icon icon = getIconFromAction(action, BaseAction.IBaseActionPropertyNames.ROLLOVER_ICON);
       if (icon != null) {
         btn.setRolloverIcon(icon);
         btn.setRolloverSelectedIcon(icon);
       }
       icon = getIconFromAction(action, BaseAction.IBaseActionPropertyNames.DISABLED_ICON);
       if (icon != null) {
         btn.setDisabledIcon(icon);
       }
     }
   }
 }
Esempio n. 17
0
  public static boolean notifyAction(
      final Action action,
      final KeyStroke keyStroke,
      final KeyEvent keyEvent,
      final Object sender,
      final int modifiers) {
    if (action == null || !action.isEnabled()) {
      return false;
    }
    Object command = action.getValue(Action.ACTION_COMMAND_KEY);
    if (command == null && !(action instanceof ActionProxy)) {
      char keyChar = keyEvent.getKeyChar();
      if (keyChar != KeyEvent.CHAR_UNDEFINED) {
        command = String.valueOf(keyChar);
      }
    }

    action.actionPerformed(
        new ActionEvent(
            sender, ActionEvent.ACTION_PERFORMED, (String) command, keyEvent.getWhen(), modifiers));

    return true;
  }
Esempio n. 18
0
  /**
   * Registers the keystroke of the given action as "command" of the given component.
   *
   * <p>This code is based on the Sulky-tools, found at &lt;http://github.com/huxi/sulky&gt;.
   *
   * @param aComponent the component that should react on the keystroke, cannot be <code>null</code>
   *     ;
   * @param aAction the action of the keystroke, cannot be <code>null</code>;
   * @param aCommandName the name of the command to register the keystore under.
   */
  public static void registerKeystroke(
      final JComponent aComponent, final Action aAction, final String aCommandName) {
    final KeyStroke keyStroke = (KeyStroke) aAction.getValue(Action.ACCELERATOR_KEY);
    if (keyStroke == null) {
      return;
    }

    InputMap inputMap = aComponent.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap actionMap = aComponent.getActionMap();
    inputMap.put(keyStroke, aCommandName);
    actionMap.put(aCommandName, aAction);

    inputMap = aComponent.getInputMap(JComponent.WHEN_FOCUSED);
    Object value = inputMap.get(keyStroke);
    if (value != null) {
      inputMap.put(keyStroke, aCommandName);
    }

    inputMap = aComponent.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    value = inputMap.get(keyStroke);
    if (value != null) {
      inputMap.put(keyStroke, aCommandName);
    }
  }
  /** Watch for new actions & changes in the actions. */
  public void execute() {

    Iterator iter;

    // ********* Check for the servlet being added ***********
    if (servlet == null) {
      iter = servletSubscription.getAddedCollection().iterator();
      if (iter.hasNext()) {
        servlet = (ActionMonitorServlet) iter.next();
        logger.debug("**** Saw new ActionMonitorServlet");
      }
    }

    // ********* Check for actions being added ***********
    iter = actionsSubscription.getAddedCollection().iterator();
    while (iter.hasNext()) {
      Action a = (Action) iter.next();
      if (servlet != null) {
        servlet.addAction(a);
      }

      // At least temp for testing -- next 7 lines
      String target = "noTargets";
      Iterator it = null;
      Collection c = a.getTargets();
      if (c != null) {
        it = a.getTargets().iterator();
        if (it != null && it.hasNext()) {
          MessageAddress ma = (MessageAddress) it.next();
          if (ma != null) target = ma.toString();
          else target = "null msgAddr";
        } else target = "noTarget";
      }
      logger.debug(
          "[AgentId="
              + agentId
              + "]**** Saw new Action["
              + ActionUtils.getAssetID(a)
              + "], with ActionRecord = "
              + a.getValue()
              + " UID="
              + a.getUID()
              + " src="
              + a.getSource()
              + ",tgt="
              + target);
    }

    // ********* Check for changes in our modes ************
    iter = actionsSubscription.getChangedCollection().iterator();
    while (iter.hasNext()) {
      Action a = (Action) iter.next();
      if (servlet != null) {
        servlet.changedAction(a);
      }
      logger.debug(
          "[AgentId="
              + agentId
              + "]**** Saw changed Action["
              + ActionUtils.getAssetID(a)
              + "], with ActionRecord = "
              + a.getValue()
              + " UID="
              + a.getUID());
    }

    // Emit # of action wrappers on BB
    int size = actionsSubscription.getCollection().size();
    logger.debug(
        "[AgentId=" + agentId + "]**** Total # of Action objects on BB right now = " + size);
  }
Esempio n. 20
0
 void updateAction(Action action) {
   final LinkLabel label = myActions.get(action);
   label.setVisible(action.isEnabled());
   label.setText((String) action.getValue(Action.NAME));
   label.setToolTipText((String) action.getValue(Action.SHORT_DESCRIPTION));
 }
Esempio n. 21
0
  // ------------------------------------------------------------------------
  TextViewer(JFrame inParentFrame) {
    // super(true); //is double buffered - only for panels

    textViewerFrame = this;
    parentFrame = inParentFrame;
    lastViewedDirStr = "";
    lastViewedFileStr = "";

    setTitle(resources.getString("Title"));
    addWindowListener(new AppCloser());
    pack();
    setSize(500, 600);

    warningPopup = new WarningDialog(this);
    okCancelPopup = new WarningDialogOkCancel(this);
    messagePopup = new MessageDialog(this);
    okCancelMessagePopup = new MessageDialogOkCancel(this);

    // Force SwingSet to come up in the Cross Platform L&F
    try {
      UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
      // If you want the System L&F instead, comment out the above line and
      // uncomment the following:
      // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception exc) {
      String errstr = "TextViewer:Error loading L&F: " + exc;
      warningPopup.display(errstr);
    }

    Container cf = getContentPane();
    cf.setBackground(Color.lightGray);
    // Border etched=BorderFactory.createEtchedBorder();
    // Border title=BorderFactory.createTitledBorder(etched,"TextViewer");
    // cf.setBorder(title);
    cf.setLayout(new BorderLayout());

    // create the embedded JTextComponent
    editor1 = createEditor();
    editor1.setFont(new Font("monospaced", Font.PLAIN, 12));
    // aa -added next line
    setPlainDocument((PlainDocument) editor1.getDocument()); // sets doc1

    // install the command table
    commands = new Hashtable();
    Action[] actions = getActions();
    for (int i = 0; i < actions.length; i++) {
      Action a = actions[i];
      commands.put(a.getValue(Action.NAME), a);
      // System.out.println("Debug:TextViewer: actionName:"+a.getValue(Action.NAME));
    }
    // editor1.setPreferredSize(new Dimension(,));
    // get setting from user preferences
    if (UserPref.keymapType.equals("Word")) {
      editor1 = updateKeymapForWord(editor1);
    } else {
      editor1 = updateKeymapForEmacs(editor1);
    }

    scroller1 = new JScrollPane();
    viewport1 = scroller1.getViewport();
    viewport1.add(editor1);
    scroller1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scroller1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    try {
      String vpFlag = resources.getString("ViewportBackingStore");
      Boolean bs = new Boolean(vpFlag);
      viewport1.setBackingStoreEnabled(bs.booleanValue());
    } catch (MissingResourceException mre) {
      System.err.println("TextViewer:missing resource:" + mre.getMessage());
      // just use the viewport1 default
    }

    menuItems = new Hashtable();

    menubar = createMenubar();

    lowerPanel = new JPanel(true); // moved double buffering to here
    lowerPanel.setLayout(new BorderLayout());
    lowerPanel.add("North", createToolbar());
    lowerPanel.add("Center", scroller1);

    cf.add("North", menubar);
    cf.add("Center", lowerPanel);
    cf.add("South", createStatusbar());

    // for the find/search utilities
    mySearchDialog = new SearchDialog(this);

    // System.out.println("Debug:TextViewer: end of TextViewer constructor");

  }