Example #1
0
  /** Initializes the call button. */
  private void initCallButton() {
    List<ProtocolProviderService> telephonyProviders = CallManager.getTelephonyProviders();

    if (telephonyProviders != null && telephonyProviders.size() > 0) {
      if (callButton.getParent() != null) return;

      callButton.setAlignmentX(JButton.CENTER_ALIGNMENT);

      callButton.setMnemonic(
          GuiActivator.getResources().getI18nMnemonic("service.gui.CALL_CONTACT"));

      buttonPanel.add(callButton);

      callButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              String searchText = parentWindow.getCurrentSearchText();

              if (searchText == null) return;

              CallManager.createCall(searchText, callButton);
            }
          });
    } else {
      buttonPanel.remove(callButton);
    }
  }
Example #2
0
  /**
   * Updates the text area to take into account the new search text.
   *
   * @param searchText the search text to update
   */
  private void updateTextArea(String searchText) {
    if (callButton.getParent() != null) {
      textArea.setText(
          GuiActivator.getResources()
              .getI18NString(
                  "service.gui.NO_CONTACTS_FOUND", new String[] {'"' + searchText + '"'}));

      this.revalidate();
      this.repaint();
    }
  }
Example #3
0
 public void actionPerformed(ActionEvent evt) {
   Component parent = extensionButton.getParent();
   while ((parent != null) && !(parent instanceof Frame)) parent = parent.getParent();
   String newExtensions =
       JOptionPane.showInputDialog(
           parent,
           "Edit the extension list.\nSeparate extensions by commas.\n\n",
           filter.getExtensionString());
   if ((newExtensions != null) && !newExtensions.trim().equals("")) {
     newExtensions = newExtensions.replaceAll("\\s", "");
     filter.setExtensions(newExtensions);
     extensionButton.setText(filter.getDescription());
     properties.setProperty("extensions", filter.getExtensionString());
     directoryPane.reloadTree();
   }
 }
  private LabeledComponent getGroupLabeledComponent() {
    if (groupLabeledComponent == null) {
      ListPanel pnl = getGroupListPanel();
      groupLabeledComponent = new LabeledComponent("Queries", new JScrollPane(pnl));
      groupLabeledComponent.setBorder(
          BorderFactory.createCompoundBorder(
              BorderFactory.createEmptyBorder(0, 2, 0, 2),
              BorderFactory.createLoweredBevelBorder()));

      JButton btn2 =
          groupLabeledComponent.addHeaderButton(
              new AbstractAction("Add Negated Query", Icons.getAddQueryLibraryIcon()) {
                public void actionPerformed(ActionEvent e) {
                  addNegatedQueryComponent();
                }
              });
      btn2.setText("Add Negated Query");
      // have to change the sizes to show the text
      final Dimension dim2 = new Dimension(100, btn2.getPreferredSize().height);
      btn2.setMinimumSize(dim2);
      btn2.setPreferredSize(dim2);
      btn2.setMaximumSize(dim2);

      JButton btn =
          groupLabeledComponent.addHeaderButton(
              new AbstractAction("Add another query", Icons.getAddQueryLibraryIcon()) {
                public void actionPerformed(ActionEvent e) {
                  addQueryComponent();
                }
              });
      btn.setText("Add Query");
      // have to change the sizes to show the text
      final Dimension dim = new Dimension(100, btn.getPreferredSize().height);
      btn.setMinimumSize(dim);
      btn.setPreferredSize(dim);
      btn.setMaximumSize(dim);

      btnAndQuery = new JRadioButton("Match All ", false);
      btnOrQuery = new JRadioButton("Match Any ", true);
      btn.getParent().add(btnAndQuery);
      btn.getParent().add(btnOrQuery);
      ButtonGroup group = new ButtonGroup();
      group.add(btnAndQuery);
      group.add(btnOrQuery);
    }
    return groupLabeledComponent;
  }
  /**
   * Returns the <code>GTKStyle</code> to use based on the <code>Region</code> id
   *
   * @param c this parameter isn't used, may be null.
   * @param id of the region to get the style.
   */
  public synchronized SynthStyle getStyle(JComponent c, Region id) {
    WidgetType wt = GTKNativeEngine.getWidgetType(c, id);

    Object key = null;
    if (id == Region.SCROLL_BAR) {
      // The style/insets of a scrollbar can depend on a number of
      // factors (see GTKStyle.getScrollBarInsets()) so use a
      // complex key here.
      if (c != null) {
        JScrollBar sb = (JScrollBar) c;
        boolean sp = (sb.getParent() instanceof JScrollPane);
        boolean horiz = (sb.getOrientation() == JScrollBar.HORIZONTAL);
        boolean ltr = sb.getComponentOrientation().isLeftToRight();
        boolean focusable = sb.isFocusable();
        key = new ComplexKey(wt, sp, horiz, ltr, focusable);
      }
    } else if (id == Region.CHECK_BOX || id == Region.RADIO_BUTTON) {
      // The style/insets of a checkbox or radiobutton can depend
      // on the component orientation, so use a complex key here.
      if (c != null) {
        boolean ltr = c.getComponentOrientation().isLeftToRight();
        key = new ComplexKey(wt, ltr);
      }
    } else if (id == Region.BUTTON) {
      // The style/insets of a button can depend on whether it is
      // default capable or in a toolbar, so use a complex key here.
      if (c != null) {
        JButton btn = (JButton) c;
        boolean toolButton = (btn.getParent() instanceof JToolBar);
        boolean defaultCapable = btn.isDefaultCapable();
        key = new ComplexKey(wt, toolButton, defaultCapable);
      }
    }
    if (key == null) {
      // Otherwise, just use the WidgetType as the key.
      key = wt;
    }

    GTKStyle result = stylesCache.get(key);
    if (result == null) {
      result = isNativeGtk ? new GTKNativeStyle(defaultFont, wt) : new GTKDefaultStyle(defaultFont);
      stylesCache.put(key, result);
    }

    return result;
  }
Example #6
0
  /**
   * Creates the <tt>UnknownContactPanel</tt> by specifying the parent window.
   *
   * @param window the parent window
   */
  public UnknownContactPanel(MainFrame window) {
    super(new BorderLayout());

    this.parentWindow = window;

    TransparentPanel mainPanel = new TransparentPanel(new BorderLayout());

    this.add(mainPanel, BorderLayout.NORTH);

    if (!ConfigurationUtils.isAddContactDisabled()) {
      initAddContactButton();
    }

    initCallButton();

    initSMSButton();

    initTextArea();
    mainPanel.add(textArea, BorderLayout.CENTER);

    if (callButton.getParent() != null) {
      textArea.setText(
          GuiActivator.getResources()
              .getI18NString(
                  "service.gui.NO_CONTACTS_FOUND",
                  new String[] {'"' + parentWindow.getCurrentSearchText() + '"'}));
    } else {
      textArea.setText(
          GuiActivator.getResources().getI18NString("service.gui.NO_CONTACTS_FOUND_SHORT"));
    }

    if (buttonPanel.getComponentCount() > 0) {
      TransparentPanel southPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER));
      southPanel.add(buttonPanel);

      mainPanel.add(southPanel, BorderLayout.SOUTH);
    }

    loadSkin();
  }
 public final void setApply(boolean state) {
   applyBtn.setEnabled(state);
   closeCancelBtn.setText(state ? CANCEL : CLOSE);
   closeCancelBtn.getParent().validate();
 }
  public void paintComponent(Graphics g) {
    if (getFrame() != null) {
      setState(getFrame().getExtendedState());
    }
    JRootPane rootPane = getRootPane();
    Window window = getWindow();
    boolean leftToRight =
        (window == null)
            ? rootPane.getComponentOrientation().isLeftToRight()
            : window.getComponentOrientation().isLeftToRight();
    boolean isSelected = (window == null) ? true : window.isActive();
    int width = getWidth();
    int height = getHeight();

    Color background;
    Color foreground;
    Color darkShadow;

    if (isSelected) {
      background = UIUtil.getPanelBackground(); // myActiveBackground;
      foreground = myActiveForeground;
      darkShadow = Gray._73; // myActiveShadow;
    } else {
      background = UIUtil.getPanelBackground(); // myInactiveBackground;
      foreground = myInactiveForeground;
      darkShadow = myInactiveShadow;
    }

    g.setColor(background);
    g.fillRect(0, 0, width, height);

    // g.setColor(darkShadow);
    // g.drawLine(0, height - 1, width, height - 1);
    // g.drawLine(0, 0, 0, 0);
    // g.drawLine(width - 1, 0, width - 1, 0);

    int xOffset = leftToRight ? 5 : width - 5;

    if (getWindowDecorationStyle() == JRootPane.FRAME) {
      xOffset += leftToRight ? IMAGE_WIDTH + 5 : -IMAGE_WIDTH - 5;
    }

    String theTitle = getTitle();
    if (theTitle != null) {
      FontMetrics fm = SwingUtilities2.getFontMetrics(rootPane, g);

      g.setColor(foreground);

      int yOffset = ((height - fm.getHeight()) / 2) + fm.getAscent();

      Rectangle rect = new Rectangle(0, 0, 0, 0);
      if (myIconifyButton != null && myIconifyButton.getParent() != null) {
        rect = myIconifyButton.getBounds();
      }
      int titleW;

      if (leftToRight) {
        if (rect.x == 0) {
          rect.x = window.getWidth() - window.getInsets().right - 2;
        }
        titleW = rect.x - xOffset - 4;
        theTitle = SwingUtilities2.clipStringIfNecessary(rootPane, fm, theTitle, titleW);
      } else {
        titleW = xOffset - rect.x - rect.width - 4;
        theTitle = SwingUtilities2.clipStringIfNecessary(rootPane, fm, theTitle, titleW);
        xOffset -= SwingUtilities2.stringWidth(rootPane, fm, theTitle);
      }
      int titleLength = SwingUtilities2.stringWidth(rootPane, fm, theTitle);
      if (myIdeMenu == null) {
        SwingUtilities2.drawString(rootPane, g, theTitle, xOffset, yOffset);
        xOffset += leftToRight ? titleLength + 5 : -5;
      }
    }

    int w = width;
    int h = height;
    h--;
    g.setColor(UIManager.getColor("MenuBar.darcula.borderColor"));
    g.drawLine(0, h, w, h);
    h--;
    g.setColor(UIManager.getColor("MenuBar.darcula.borderShadowColor"));
    g.drawLine(0, h, w, h);
  }
  private void setState(int state, boolean updateRegardless) {
    Window wnd = getWindow();

    if (wnd != null && getWindowDecorationStyle() == JRootPane.FRAME) {
      if (myState == state && !updateRegardless) {
        return;
      }
      Frame frame = getFrame();

      if (frame != null) {
        JRootPane rootPane = getRootPane();

        if (((state & Frame.MAXIMIZED_BOTH) != 0)
            && (rootPane.getBorder() == null || (rootPane.getBorder() instanceof UIResource))
            && frame.isShowing()) {
          rootPane.setBorder(null);
        } else if ((state & Frame.MAXIMIZED_BOTH) == 0) {
          // This is a croak, if state becomes bound, this can
          // be nuked.
          rootPaneUI.installBorder(rootPane);
        }
        if (frame.isResizable()) {
          if ((state & Frame.MAXIMIZED_BOTH) != 0) {
            updateToggleButton(myRestoreAction, myMinimizeIcon);
            myMaximizeAction.setEnabled(false);
            myRestoreAction.setEnabled(true);
          } else {
            updateToggleButton(myMaximizeAction, myMaximizeIcon);
            myMaximizeAction.setEnabled(true);
            myRestoreAction.setEnabled(false);
          }
          if (myToggleButton.getParent() == null || myIconifyButton.getParent() == null) {
            add(myToggleButton);
            add(myIconifyButton);
            revalidate();
            repaint();
          }
          myToggleButton.setText(null);
        } else {
          myMaximizeAction.setEnabled(false);
          myRestoreAction.setEnabled(false);
          if (myToggleButton.getParent() != null) {
            remove(myToggleButton);
            revalidate();
            repaint();
          }
        }
      } else {
        // Not contained in a Frame
        myMaximizeAction.setEnabled(false);
        myRestoreAction.setEnabled(false);
        myIconifyAction.setEnabled(false);
        remove(myToggleButton);
        remove(myIconifyButton);
        revalidate();
        repaint();
      }
      myCloseAction.setEnabled(true);
      myState = state;
    }
  }
Example #10
0
 private boolean isStuck() {
   return (unstickButton.getParent() != null);
 }