Package org.eclipse.swt.widgets

Examples of org.eclipse.swt.widgets.CoolBar


    GridData gridData1 = new org.eclipse.swt.layout.GridData();
    gridData1.grabExcessHorizontalSpace = false;
    gridData1.verticalAlignment = org.eclipse.swt.layout.GridData.CENTER;
    gridData1.horizontalAlignment = org.eclipse.swt.layout.GridData.END;
   
    CoolBar buttonCoolBar = new CoolBar(bottomComposite, SWT.FLAT);
    buttonCoolBar.setLayoutData(gridData1);
   
    final ToolBar toolBar = new ToolBar(buttonCoolBar, SWT.FLAT);
   
    toolItemHistory = new ToolItem(toolBar,SWT.PUSH);
    toolItemHistory.setImage(GOIMIcons.getImage(GOIMIcons.CONTACT_HISTORY));
    toolItemHistory.setToolTipText("Open Chat History");
    toolItemHistory.addListener(SWT.Selection,new Listener() {
      public void handleEvent(Event event) {
        HistoryViewer.showHistoryOf(account,StringUtils.parseBareAddress(chat.getJID()));
      }
    });
   
    toolItemVCard = new ToolItem(toolBar,SWT.PUSH);
    toolItemVCard.setImage(GOIMIcons.getImage(GOIMIcons.CONTACT_VCARD));
    toolItemVCard.setToolTipText("Show VCard");
    toolItemVCard.addListener(SWT.Selection,new Listener() {
      public void handleEvent(Event event) {
        new vCardGUI(account, StringUtils.parseBareAddress(chat.getJID()));
      }
    });
   
    if(emoticons != null && emoticons.getIcons().size() > 0) {
      ToolItem toolItemSmileys = new ToolItem(toolBar, SWT.DROP_DOWN);
     
      toolItemSmileys.setImage(emoticons.getIcons().get(0).getImage());
      toolItemSmileys.setToolTipText("Add Emoticon");
      //toolItemSmileys.setText("abc");
     
      toolItemSmileys.addListener(SWT.Selection,new Listener() {

        public void handleEvent(Event event) {
          Rectangle bounds = ((ToolItem)event.widget).getBounds();
          Point loc = toolBar.toDisplay(bounds.x,bounds.y);
          final Shell shell = new Shell(toolBar.getShell(),SWT.RESIZE | SWT.BORDER);
          shell.setBounds(loc.x,loc.y,150,200);
          shell.setLayout(new FillLayout());
          final Tree tree = new Tree(shell,SWT.BORDER);
          for(IconDef iconDef : emoticons.getIcons()) {
            TreeItem item = new TreeItem(tree,SWT.NULL);
            item.setImage(iconDef.getImage());
            item.setText(iconDef.text.get(0));
//            item.setData("iconDef",iconDef);
            item.setData("text",iconDef.text.get(0));
          }
          shell.open();
          tree.forceFocus();
          tree.addListener(SWT.Selection, new Listener() {
            public void handleEvent(Event event) {
              if(tree.getSelectionCount() < 1) return;
              TreeItem item = tree.getSelection()[0];
//              IconDef iconDef = (IconDef)item.getData("iconDef");
//              chatInput.insert(iconDef.text.get(0));
              String text = (String)item.getData("text");
              chatInput.insert(text);
              chatInput.setSelection(chatInput.getSelection().x+text.length());
              shell.close();
            } });
          tree.addListener(SWT.FocusOut, new Listener() {
            public void handleEvent(Event event) {
              shell.close();
            }
           
          });
//          Menu menu = new Menu(((ToolItem)event.widget).getParent());
//          for(IconDef iconDef : emoticons.getIcons()) {
//            MenuItem menuItem = new MenuItem(menu,SWT.PUSH);
//            menuItem.setText(iconDef.text.get(0));
//            menuItem.setImage(iconDef.getImage());
//          }
//          menu.setVisible(true);
        } });
    }
   
    ToolItem toolItemBold = new ToolItem(toolBar, SWT.PUSH);
    toolItemBold.setToolTipText("Make Selected Text Bold");
    toolItemBold.setImage(GOIMIcons.getImage(GOIMIcons.CHATWINDOW_BOLD));

    ToolItem toolItemUnderline = new ToolItem(toolBar, SWT.PUSH);
    toolItemBold.setToolTipText("Make Selected Text Underlined");
    toolItemUnderline.setImage(GOIMIcons.getImage(GOIMIcons.CHATWINDOW_UNDERLINE));

    int totalx = 0;
    CoolItem coolItem = new CoolItem(buttonCoolBar, SWT.NULL);
    coolItem.setControl(toolBar);
    toolBar.pack();
    Point size = toolBar.getSize();
    size = coolItem.computeSize(size.x,size.y);
    totalx+=size.x;
    coolItem.setMinimumSize(size);
    coolItem.setPreferredSize(size);
   
    ToolBar sendToolBar = new ToolBar(buttonCoolBar, SWT.FLAT);
   
    ToolItem toolItemSend = new ToolItem(sendToolBar, SWT.PUSH);
    toolItemSend.setToolTipText("Send Input");
    toolItemSend.setText("Send");


    CoolItem sendCoolItem = new CoolItem(buttonCoolBar, SWT.NULL);
    sendCoolItem.setControl(sendToolBar);
    sendToolBar.pack();
    size = sendToolBar.getSize();
    size = sendCoolItem.computeSize(size.x, size.y);
    totalx+=size.x;
    sendCoolItem.setMinimumSize(size);
    sendCoolItem.setPreferredSize(size);
   
   
    //gridData1.minimumWidth = totalx + 30;
    gridData1.widthHint = totalx + 30;
    buttonCoolBar.pack();
   
    /*
    buttonComposite = new Composite(bottomComposite, SWT.NONE);
    buttonComposite.setLayoutData(gridData1);
    buttonComposite.setLayout(rowLayout);
View Full Code Here


        });
        clientArea = canvas.getClientArea();
    }

    private void createStatusBar(Composite parent) {
        this.statusBar = new CoolBar(parent, SWT.FLAT | SWT.HORIZONTAL);
        this.statusBar.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING,
            true, false));
        createStatisticBar(statusBar);
        this.statusBar.pack();
    }
View Full Code Here

    mainHolder = mc; //store main class
   
   
   
   
    topCoolBar = new CoolBar (mainHolder.getShell(), SWT.NONE);
    coolToolBar = new ToolBar (topCoolBar, SWT.FLAT);
   
    ToolItem coolToolItem = CreateNewToolButton("Nov� tisk", "filenew.png", new fileNewItemListener(mainHolder));
    coolToolItem = CreateNewToolButton("Nov� konvolut", "filenew2.png", new fileNewConvolutListener(mainHolder) );   
    CreateNewSeparator();
View Full Code Here

      orientation = (curSide == SWT.LEFT || curSide == SWT.RIGHT) ? SWT.VERTICAL  : SWT.HORIZONTAL;

      frame = new TrimFrame(wbw.getShell());
   
    // Create the necessary parts...
    cb = new CoolBar(frame.getComposite(), orientation | SWT.FLAT);
    ci = new CoolItem(cb, SWT.FLAT);

    // Create (and 'fill') the toolbar
    tbMgr = new ToolBarManager(orientation | SWT.FLAT);
   
View Full Code Here

   * <p>
   *
   * @return boolean true if children exist, false otherwise
   */
  protected boolean toolBarChildrenExist() {
    CoolBar coolBarControl = (CoolBar) getCoolBarControl();
    return coolBarControl.getItemCount() > 0;
  }
View Full Code Here

      itemStyle |= SWT.DROP_DOWN;

    /*
     * Create the example widgets.
     */
    coolBar = new CoolBar(coolBarGroup, style);

    /* Create the push button toolbar cool item */
    ToolBar toolBar = new ToolBar(coolBar, toolBarStyle);
    ToolItem item = new ToolItem(toolBar, SWT.PUSH);
    item.setImage(instance.images[ControlExample.ciClosedFolder]);
View Full Code Here

        children[i] = combo;
      } else if (control.equals("Composite")) {
        Composite composite = new Composite(layoutComposite, SWT.BORDER);
        children[i] = composite;
      } else if (control.equals("CoolBar")) {
        CoolBar coolBar = new CoolBar(layoutComposite, SWT.NONE);
        ToolBar toolBar = new ToolBar(coolBar, SWT.BORDER);
        ToolItem item = new ToolItem(toolBar, 0);
        item.setText(LayoutExample.getResourceString("Item", new String[] { "1" }));
        item = new ToolItem(toolBar, 0);
        item.setText(LayoutExample.getResourceString("Item", new String[] { "2" }));
        CoolItem coolItem1 = new CoolItem(coolBar, 0);
        coolItem1.setControl(toolBar);
        toolBar = new ToolBar(coolBar, SWT.BORDER);
        item = new ToolItem(toolBar, 0);
        item.setText(LayoutExample.getResourceString("Item", new String[] { "3" }));
        item = new ToolItem(toolBar, 0);
        item.setText(LayoutExample.getResourceString("Item", new String[] { "4" }));
        CoolItem coolItem2 = new CoolItem(coolBar, 0);
        coolItem2.setControl(toolBar);
        Point size = toolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        coolItem1.setSize(coolItem1.computeSize(size.x, size.y));
        coolItem2.setSize(coolItem2.computeSize(size.x, size.y));
        coolBar.setSize(coolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        children[i] = coolBar;
      } else if (control.equals("Group")) {
        Group group = new Group(layoutComposite, SWT.NONE);
        group.setText(LayoutExample
            .getResourceString("Group_Index", new String[] { new Integer(i).toString() }));
View Full Code Here

   * and update the coolbar.
   */
  public void advise(boolean fromUpdate) {

    /* Retrieve Control if available */
    CoolBar barControl = null;
    if (fManager instanceof CoolBarManager)
      barControl = ((CoolBarManager) fManager).getControl();

    /* Disable Redraw to avoid Flicker */
    if (barControl != null && fromUpdate)
      barControl.getShell().setRedraw(false);

    try {

      /* First Remove All */
      fManager.removeAll();

      /* Load Toolbar Mode */
      CoolBarMode mode = CoolBarMode.values()[fPreferences.getInteger(DefaultPreferences.TOOLBAR_MODE)];

      /* Load and Add Items */
      int[] items = fPreferences.getIntegers(DefaultPreferences.TOOLBAR_ITEMS);
      if (items == null || items.length == 0)
        items = new int[] { CoolBarItem.SPACER.ordinal() };

      ToolBarManager currentToolBar = new ToolBarManager(mode == CoolBarMode.IMAGE_TEXT_HORIZONTAL ? (SWT.FLAT | SWT.RIGHT) : SWT.FLAT);
      for (int id : items) {
        final CoolBarItem item = CoolBarItem.values()[id];
        if (item != null) {

          /* Separator: Start a new Toolbar */
          if (item == CoolBarItem.SEPARATOR) {
            fManager.add(currentToolBar);
            currentToolBar = new ToolBarManager(mode == CoolBarMode.IMAGE_TEXT_HORIZONTAL ? (SWT.FLAT | SWT.RIGHT) : SWT.FLAT);
          }

          /* Spacer */
          else if (item == CoolBarItem.SPACER) {
            ActionContributionItem contribItem = new ActionContributionItem(new Action("") { //$NON-NLS-1$
                  @Override
                  public boolean isEnabled() {
                    return false;
                  }
                });
            currentToolBar.add(contribItem);
          }

          /* Any other Item */
          else {
            ActionContributionItem contribItem = new CoolBarActionContributionitem(item, getAction(item, mode, currentToolBar));
            contribItem.setId(item.getId());
            if (mode == CoolBarMode.IMAGE_TEXT_HORIZONTAL || mode == CoolBarMode.IMAGE_TEXT_VERTICAL)
              contribItem.setMode(ActionContributionItem.MODE_FORCE_TEXT);

            /* Add to Toolbar */
            currentToolBar.add(contribItem);
          }
        }
      }

      /* Add latest Toolbar Manager to Coolbar too */
      fManager.add(currentToolBar);

      /* Ensure Updates are properly Propagated */
      if (fromUpdate) {

        /* Update Overall Coolbar UI */
        fManager.update(true);
        if (barControl != null) {
          boolean isLocked = barControl.getLocked();
          barControl.setLocked(!isLocked);
          barControl.setLocked(isLocked);
        }

        /* Update Action UI */
        updateActions(OwlUI.getActivePart(fWindow));
      }
    } finally {
      if (barControl != null && fromUpdate)
        barControl.getShell().setRedraw(true);
    }
  }
View Full Code Here

     * @return the cool bar control
     */
    public CoolBar createControl(Composite parent) {
        Assert.isNotNull(parent);
        if (!coolBarExist()) {
            coolBar = new CoolBar(parent, itemStyle);
            coolBar.setMenu(getContextMenuControl());
            coolBar.setLocked(false);
            update(false);
        }
        return coolBar;
View Full Code Here

        CoolItem item = (CoolItem) event.widget;
        Control control = item.getControl();
        if ((control instanceof ToolBar) == false) {
            return;
        }
        CoolBar coolBar = item.getParent();
        ToolBar toolBar = (ToolBar) control;
        Rectangle toolBarBounds = toolBar.getBounds();
        ToolItem[] items = toolBar.getItems();
        ArrayList hidden = new ArrayList();
        for (int i = 0; i < items.length; ++i) {
            Rectangle itemBounds = items[i].getBounds();
            if (!((itemBounds.x + itemBounds.width <= toolBarBounds.width) && (itemBounds.y
                    + itemBounds.height <= toolBarBounds.height))) {
                hidden.add(items[i]);
            }
        }

        // Create a pop-up menu with items for each of the hidden buttons.
        if (chevronMenuManager != null) {
            chevronMenuManager.dispose();
        }
        chevronMenuManager = new MenuManager();
        for (Iterator i = hidden.iterator(); i.hasNext();) {
            ToolItem toolItem = (ToolItem) i.next();
            IContributionItem data = (IContributionItem) toolItem.getData();
            if (data instanceof ActionContributionItem) {
                ActionContributionItem contribution = new ActionContributionItem(
                        ((ActionContributionItem) data).getAction());
                chevronMenuManager.add(contribution);
            } else if (data instanceof SubContributionItem) {
                IContributionItem innerData = ((SubContributionItem) data)
                        .getInnerItem();
                if (innerData instanceof ActionContributionItem) {
                    ActionContributionItem contribution = new ActionContributionItem(
                            ((ActionContributionItem) innerData).getAction());
                    chevronMenuManager.add(contribution);
                }
            } else if (data.isSeparator()) {
                chevronMenuManager.add(new Separator());
            }
        }
        Menu popup = chevronMenuManager.createContextMenu(coolBar);
        Point chevronPosition = coolBar.toDisplay(event.x, event.y);
        popup.setLocation(chevronPosition.x, chevronPosition.y);
        popup.setVisible(true);
    }
View Full Code Here

TOP

Related Classes of org.eclipse.swt.widgets.CoolBar

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.