⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resulttablemenulistener.java

📁 SANCHO
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
      tipLabelText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER));      namesComposite = new Composite(tipShell, SWT.NONE);      namesComposite.setLayout(WidgetFactory.createGridLayout(1, 0, 0, 0, 0, false));      namesComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));      createSeparator(namesComposite);      namesList = new List(namesComposite, SWT.H_SCROLL | SWT.V_SCROLL);      setColors(namesList);      createSeparator(tipShell);      Composite toolBarComposite = new Composite(tipShell, SWT.NONE);      toolBarComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));      toolBarComposite.setLayout(WidgetFactory.createGridLayout(3, 0, 0, 0, 0, false));      toolBarComposite.setBackground(namesList.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));      ToolBar leftToolBar = new ToolBar(toolBarComposite, SWT.FLAT);      setColors(leftToolBar);      leftToolBar.setLayoutData(new GridData(GridData.BEGINNING));      Composite strech = new Composite(toolBarComposite, SWT.NONE);      setColors(strech);      GridData gd = new GridData(GridData.FILL_BOTH);      gd.heightHint = 1;      strech.setLayoutData(gd);      ToolItem toolItem = new ToolItem(leftToolBar, SWT.NONE);      toolItem.setImage(SResources.getImage("down_arrow_green"));      toolItem.setToolTipText(SResources.getString("s.download"));      toolItem.addSelectionListener(new SelectionAdapter() {        public void widgetSelected(SelectionEvent s) {          downloadSingleFile(result);        }      });      toolBar = new ToolBar(toolBarComposite, SWT.FLAT);      setColors(toolBar);      toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));      addToolItem("bitzi", "mi.web.bitzi", WebServicesAction.BITZI);      //   addToolItem("jigle", "mi.web.jigle", WebServicesAction.JIGLE);      addToolItem("edonkey", "mi.web.filedonkey", WebServicesAction.FILEDONKEY);      //  addToolItem("sharereactor", "mi.web.srFakeCheck",      // WebServicesAction.SHAREREACTOR);      addToolItem("edonkey", "mi.web.donkeyFakes", WebServicesAction.DONKEY_FAKES);      popupMenu = new MenuManager(SResources.S_ES);      popupMenu.setRemoveAllWhenShown(true);      popupMenu.addMenuListener(this);      tipLabelText.setMenu(popupMenu.createContextMenu(tipShell));    }    public void createSeparator(Composite parent) {      new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));    }    public void setColors(Control control) {      control.setBackground(control.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));      control.setForeground(control.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));    }    public void addToolItem(String imageString, String toolTipString, final int type) {      ToolItem toolItem = new ToolItem(toolBar, SWT.NONE);      toolItem.setImage(SResources.getImage(imageString));      toolItem.setToolTipText(SResources.getString(toolTipString));      toolItem.addSelectionListener(new SelectionAdapter() {        public void widgetSelected(SelectionEvent arg0) {          String string;          switch (type) {            case WebServicesAction.JIGLE :              string = fileSize + ":" + md4;              break;            case WebServicesAction.SHAREREACTOR :            case WebServicesAction.DONKEY_FAKES :              string = ed2k;              break;            default :              string = md4;              break;          }          WebServicesAction.launch(type, string);          setVisible(false);        }      });    }    public void startTimer() {      if (timer != null)        timer.cancel();      timer = new Timer();      timer.scheduleAtFixedRate(new TimerTask() {        public void run() {          if (isVisible) // in other thread            display.asyncExec(new Runnable() { // maybe sync?                  public void run() {                    if (tipShell != null && !tipShell.isDisposed() && tipShell.isVisible()                        && !tipShell.getBounds().contains(display.getCursorLocation()))                      setVisible(false);                    //   display.post(SWT.MouseHover)                    // now check if cursor in the right place and no tooltip and delay met                  }                });        }      }, 0L, 1000L);    }    public void dispose() {      if (tipShell != null) {        tipShell.dispose();        tipShell = null;      }    }    public void activateHoverHelp(final Control control, final ICustomViewer cViewer) {      startTimer();      control.addMouseListener(new MouseAdapter() {        public void mouseDown(MouseEvent e) {          if (tipShell.isVisible())            setVisible(false);        }      });      control.addMouseTrackListener(new MouseTrackAdapter() {        public void mouseExit(MouseEvent e) {          if (tipShell.isVisible() && ((pt.x != e.x) && (pt.y != e.y)))            setVisible(false);          tipWidget = null;        }        public void mouseHover(MouseEvent event) {          if (event.widget == null)            return;          pt.x = event.x;          pt.y = event.y;          tipPosition = control.toDisplay(pt);          // curs w/in tt          Rectangle r = tipShell.getBounds();          r.x -= 10;          r.y -= 10;          r.width += 20;          r.height += 20;          if (tipShell.isVisible() && r.contains(tipPosition))            return;          Widget widget = event.widget;          Table table = (Table) widget;          int goodx1 = 0;          int goodx2 = 0;          boolean found = false;          for (int i = 0; i < table.getColumns().length; i++) {            if (cViewer.getColumnIDs()[i] == ResultTableView.NAME) {              goodx2 = goodx1 + table.getColumns()[i].getWidth();              found = true;              break;            } else              goodx1 += table.getColumns()[i].getWidth();          }          widget = table.getItem(pt);          if (widget == null) {            setVisible(false);            tipWidget = null;          }          if (widget == tipWidget)            return;          tipWidget = widget;          if (found && !((goodx1 < pt.x) && (pt.x < goodx2))) {            setVisible(false);            return;          }          // Create the tooltip on demand          TableItem tableItem = (TableItem) widget;          result = (Result) tableItem.getData();          tipLabelImage.setImage(result.getToolTipImage());          tipLabelImage.setText(result.getName());          md4 = SResources.S_ES;          ed2k = SResources.S_ES;          md4 = result.getMd4().toUpperCase();          ed2k = result.getED2K();          fileSize = String.valueOf(result.getSize());          // set the text/image for the tooltip          tipLabelText.setText(result.getToolTipContent());          namesList.removeAll();          namesList.pack();          GridData gridData = new GridData();          gridData.heightHint = 0;          gridData.widthHint = 0;          namesList.setLayoutData(gridData);          gridData = new GridData(GridData.FILL_HORIZONTAL);          gridData.heightHint = 0;          gridData.widthHint = 0;          namesComposite.setLayoutData(gridData);          //  namesComposite.pack();          tipShell.pack();          String[] originalNames = result.getNames();          if ((originalNames != null) && (originalNames.length > 1)) {            int numToDisplay = result.getNames().length;            numToDisplay = (numToDisplay > 6) ? 6 : numToDisplay;            String[] names = new String[originalNames.length];            System.arraycopy(originalNames, 0, names, 0, originalNames.length);            Arrays.sort(names, String.CASE_INSENSITIVE_ORDER);            gridData = new GridData(GridData.FILL_HORIZONTAL);            namesComposite.setLayoutData(gridData);            gridData = new GridData();            gridData.heightHint = numToDisplay * (charHeight);            gridData.widthHint = tipShell.getBounds().width;            namesList.setLayoutData(gridData);            for (int i = 0; i < names.length; i++)              namesList.add(names[i]);          } else {            gridData = new GridData();            gridData.heightHint = 0;            gridData.widthHint = 0;            namesList.setLayoutData(gridData);            gridData = new GridData(GridData.FILL_HORIZONTAL);            gridData.heightHint = 0;            namesComposite.setLayoutData(gridData);          }          // namesComposite.pack();          tipShell.pack();          setHoverLocation(tipShell, tipPosition);          setVisible(true);        }      });    }    private void setVisible(boolean b) {      tipShell.setVisible(b);      isVisible = b;    }    private void setHoverLocation(Shell shell, Point position) {      Rectangle displayBounds = shell.getDisplay().getBounds();      Rectangle shellBounds = shell.getBounds();      shellBounds.x = Math.max(Math.min(position.x, displayBounds.width - shellBounds.width), 0);      shellBounds.y = Math.max(Math.min(position.y, displayBounds.height - shellBounds.height), 0);      shell.setBounds(shellBounds);    }    public void menuAboutToShow(IMenuManager menuManager) {      menuManager.add(new CopyToolTipToClipboardAction());    }    public class CopyToolTipToClipboardAction extends Action {      public CopyToolTipToClipboardAction() {        super();        setText(SResources.getString("copy to clipboard"));        setImageDescriptor(SResources.getImageDescriptor("copy"));      }      public void run() {        if (result != null) {          MainWindow.copyToClipboard(result.getToolTip());        }      }    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -