Examples of ToolbarItem


Examples of com.aelitis.azureus.ui.swt.toolbar.ToolBarItem

      MenuFactory.addMenuItem(viewMenu, SWT.RADIO, PREFIX_V3
          + ".view.asSimpleList", new Listener() {
        public void handleEvent(Event event) {
          ToolBarView tb = (ToolBarView) SkinViewManager.getByClass(ToolBarView.class);
          if (tb != null) {
            ToolBarItem item = tb.getToolBarItem("modeBig");
            if (item != null) {
              item.triggerToolBarItem();
            }
          }
        }
      });
      MenuFactory.addMenuItem(viewMenu, SWT.RADIO, PREFIX_V3
          + ".view.asAdvancedList", new Listener() {
        public void handleEvent(Event event) {
          ToolBarView tb = (ToolBarView) SkinViewManager.getByClass(ToolBarView.class);
          if (tb != null) {
            ToolBarItem item = tb.getToolBarItem("modeSmall");
            if (item != null) {
              item.triggerToolBarItem();
            }
          }
        }
      });

      viewMenu.addMenuListener(new MenuListener() {

        public void menuShown(MenuEvent e) {

          MenuItem sidebarMenuItem = MenuFactory.findMenuItem(viewMenu,
              PREFIX_V3 + ".view.sidebar");
          if (sidebarMenuItem != null) {
            MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
            if (mdi != null) {
              sidebarMenuItem.setSelection(mdi.isVisible());
            }
          }

          MenuItem itemShowText = MenuFactory.findMenuItem(viewMenu, PREFIX_V3
              + ".view.toolbartext");
          if (itemShowText != null) {
            ToolBarView tb = (ToolBarView) SkinViewManager.getByClass(ToolBarView.class);
            if (tb != null) {
              itemShowText.setSelection(tb.getShowText());
            }
          }

          MenuItem itemShowAsSimple = MenuFactory.findMenuItem(viewMenu,
              PREFIX_V3 + ".view.asSimpleList");
          if (itemShowAsSimple != null) {
            ToolBarView tb = (ToolBarView) SkinViewManager.getByClass(ToolBarView.class);
            if (tb != null) {
              ToolBarItem item = tb.getToolBarItem("modeBig");
              if (item != null && item.isEnabled()) {
                itemShowAsSimple.setEnabled(true);
                itemShowAsSimple.setSelection(item.getSkinButton().getSkinObject().getSuffix().contains(
                    "-down"));
              } else {
                itemShowAsSimple.setEnabled(false);
                itemShowAsSimple.setSelection(false);
              }
            }
          }
          MenuItem itemShowAsAdv = MenuFactory.findMenuItem(viewMenu, PREFIX_V3
              + ".view.asAdvancedList");
          if (itemShowAsAdv != null) {
            ToolBarView tb = (ToolBarView) SkinViewManager.getByClass(ToolBarView.class);
            if (tb != null) {
              ToolBarItem item = tb.getToolBarItem("modeSmall");
              if (item != null && item.isEnabled()) {
                itemShowAsAdv.setEnabled(true);
                itemShowAsAdv.setSelection(item.getSkinButton().getSkinObject().getSuffix().contains(
                    "-down"));
              } else {
                itemShowAsAdv.setSelection(false);
                itemShowAsAdv.setEnabled(false);
              }
View Full Code Here

Examples of com.aelitis.azureus.ui.swt.toolbar.ToolBarItem

  private void setupModeButtons() {
   
    ToolBarView tb = (ToolBarView) SkinViewManager.getByClass(ToolBarView.class);
    if (tb != null) {
      ToolBarItem itemModeSmall = tb.getToolBarItem("modeSmall");
      if (itemModeSmall != null) {
        itemModeSmall.getSkinButton().getSkinObject().switchSuffix(
            viewMode == MODE_BIGTABLE ? "" : "-down");
      }
      ToolBarItem itemModeBig = tb.getToolBarItem("modeBig");
      if (itemModeBig != null) {
        itemModeBig.getSkinButton().getSkinObject().switchSuffix(
            viewMode == MODE_BIGTABLE ? "-down" : "");
      }
    }
  }
View Full Code Here

Examples of com.aelitis.azureus.ui.swt.toolbar.ToolBarItem

    } else {
      debug("Can't use EMP. torrent says "
          + PlatformTorrentUtils.useEMP(torrent));
    }

    ToolBarItem btnPlay = null;
    ToolBarView tb = (ToolBarView) SkinViewManager.getByClass(ToolBarView.class);
    if (tb != null) {
      btnPlay = tb.getToolBarItem("play");
    }
    final ToolBarItem btn = btnPlay;
    if (btn != null) {
      btn.setEnabled(false);
    }

    boolean reenableButton = false;
    try {
      if (!PlayUtils.canProgressiveOrIsComplete(torrent)) {
        return;
      }

      File file;
      String sFile = null;

      EnhancedDownloadManager edm = DownloadManagerEnhancer.getSingleton().getEnhancedDownload(
          dm);
      if (edm != null) {
        boolean doProgressive = edm.getProgressiveMode();
        if (doProgressive && edm.getProgressivePlayETA() > 0) {
          return;
        }

        if (!doProgressive && dm.getNumFileInfos() > 1
            && PlatformTorrentUtils.getContentPrimaryFileIndex(torrent) == -1) {
          // multi-file torrent that we aren't progressive playing or useEMPing
          Utils.launch(dm.getSaveLocation().getAbsolutePath());
          reenableButton = true;
          PlatformTorrentUtils.setHasBeenOpened(dm, true);
          return;
        }

        file = edm.getPrimaryFile().getFile(true);
        sFile = file.getAbsolutePath();
      } else {
        sFile = dm.getDownloadState().getPrimaryFile();
        file = new File(sFile);
      }
     
      final String sfFile = sFile;

      String ext = FileUtil.getExtension(sFile);
     
      try {
        if (ext.equalsIgnoreCase(".exe")
            && DataSourceUtils.isPlatformContent(dm)
            && "Game".equalsIgnoreCase(PlatformTorrentUtils.getContentType(dm.getTorrent()))) {
          reenableButton = true;
          Utils.launch(sFile);
          PlatformTorrentUtils.setHasBeenOpened(dm, true);
          return;
        }
      } catch (Exception e) {
        Debug.out(e);
      }

      final String sPrefix = "v3.mb.openFile.";
     

      UIFunctionsSWT functionsSWT = UIFunctionsManagerSWT.getUIFunctionsSWT();
      if (functionsSWT == null) {
        return;
      }
     
      final Program program = Program.findProgram(ext);
      String sTextID;
      String sFileType;
      if (program == null) {
        sTextID = sPrefix + "text.unknown";
        sFileType = ext;
      } else {
        sTextID = sPrefix + "text.known";
        sFileType = program.getName();
      }
     
      String[] buttons = new String[(program == null ? 2 : 3)];
      buttons[0] = MessageText.getString(sPrefix + "button.guide");
      buttons[buttons.length-1] = MessageText.getString(sPrefix + "button.cancel");
     
      MessageBoxShell mb = null;
      if(program != null) {
        buttons[1] = MessageText.getString(sPrefix + "button.play");
        mb = new MessageBoxShell(MessageText.getString(sPrefix + "title"),
            MessageText.getString(sTextID, new String[] {
                  dm.getDisplayName(),
                  sFileType,
                  ext
                }), buttons, 0);
        mb.setRemember(sPrefix + ".remember_id", false, MessageText.getString(sPrefix
            + "remember"));
        mb.setRememberOnlyIfButton(1);
        mb.setRelatedObject(dm);
      } else {
        mb = new MessageBoxShell(MessageText.getString(sPrefix + "title"),
            MessageText.getString(sTextID, new String[] {
              dm.getDisplayName(),
              sFileType,
              ext
            }), buttons, 0);
        mb.setRelatedObject(dm);
      }

      reenableButton = false;
      mb.open(new UserPrompterResultListener() {
        public void prompterClosed(int i) {
          if(i == 0) {
            String url = MessageText.getString(sPrefix + "guideurl");
            if(UrlUtils.isURL(url)) {
              Utils.launch(url);
              return;
            }
          }
         
          if (i != 1 || program == null) {
            return;
          }
         
          boolean bComplete = dm.isDownloadComplete(false);
   
          if (bComplete) {
            if (btn != null) {
              btn.setEnabled(true);
            }
            runFile(dm.getTorrent(), file_index, sfFile);
          } else {
            if (btn != null) {
              btn.setEnabled(true);
            }
            try {
              playViaMediaServer(DownloadManagerImpl.getDownloadStatic(dm), file_index );
            } catch (DownloadException e) {
              Debug.out(e);
            }
          }
        }
      });
     
    } finally {
      if (btn != null && reenableButton) {
        btn.setEnabled(true);
      }
    }
  }
View Full Code Here

Examples of com.aelitis.azureus.ui.swt.toolbar.ToolBarItem

      } else {
        soGap = null;
      }
    }

    ToolBarItem item;

    if (!uiClassic) {
      // ==download
      item = new ToolBarItem("download", "image.button.download",
          "v3.MainWindow.button.download") {
        // @see com.aelitis.azureus.ui.swt.toolbar.ToolBarItem#triggerToolBarItem()
        public void triggerToolBarItem() {
          String viewID = SelectedContentManager.getCurrentySelectedViewID();
          if (viewID == null && triggerIViewToolBar(getId())) {
            return;
          }
          // This is for our CDP pages
          ISelectedContent[] sc = SelectedContentManager.getCurrentlySelectedContent();
          if (sc != null && sc.length == 1
              && (sc[0].getHash() != null || sc[0].getDownloadInfo() != null)) {
            TorrentListViewsUtils.downloadDataSource(sc[0], false,
                DLReferals.DL_REFERAL_TOOLBAR);
          }
        }
      };
      addToolBarItem(item);

      // ==play
      item = new ToolBarItem("play", "image.button.play", "iconBar.play") {
        // @see com.aelitis.azureus.ui.swt.toolbar.ToolBarItem#triggerToolBarItem()
        public void triggerToolBarItem() {
          String viewID = SelectedContentManager.getCurrentySelectedViewID();
          if (viewID == null && triggerIViewToolBar(getId())) {
            return;
          }
          ISelectedContent[] sc = SelectedContentManager.getCurrentlySelectedContent();
          if (sc != null && sc.length > 0 ) {
           
            if ( PlayUtils.canStreamDS(sc[0], sc[0].getFileIndex())){
              TorrentListViewsUtils.playOrStreamDataSource(sc[0],
                  DLReferals.DL_REFERAL_TOOLBAR, true, false);
            }else{
              TorrentListViewsUtils.playOrStreamDataSource(sc[0],
                DLReferals.DL_REFERAL_TOOLBAR, false, true);
            }
          }
        }
      };
      addToolBarItem(item);
     
      addSeperator((uiClassic ? "classic." : "") + "toolbar.area.item.sep",
          soMain);

      lastControl = null;

    } else {

      lastControl = null;

      // ==OPEN
      item = new ToolBarItem("open", "image.toolbar.open", "Button.add") {
        public void triggerToolBarItem() {
          TorrentOpener.openTorrentWindow();
        }
      };
      item.setAlwaysAvailable(true);
      addToolBarItem(item, "toolbar.area.sitem.left", so2nd);

      addSeperator(so2nd);

      // ==SEARCH
      item = new ToolBarItem("search", "search", "Button.search") {
        public void triggerToolBarItem() {
          UIFunctionsManagerSWT.getUIFunctionsSWT().promptForSearch();
        }
      };
      item.setAlwaysAvailable(true);
      addToolBarItem(item, "toolbar.area.sitem.right", so2nd);

      addSeperator((uiClassic ? "classic." : "") + "toolbar.area.item.sep3",
          so2nd);

      addNonToolBar("toolbar.area.sitem.left2", so2nd);
    }

    boolean first = true;

    // ==transcode
    if (!DeviceManagerUI.DISABLED) {
      item = new ToolBarItem("transcode", "image.button.transcode",
          "iconBar.transcode") {
        // @see com.aelitis.azureus.ui.swt.toolbar.ToolBarItem#triggerToolBarItem()
        public void triggerToolBarItem() {
          String viewID = SelectedContentManager.getCurrentySelectedViewID();
          if (viewID == null && triggerIViewToolBar(getId())) {
            return;
          }
          ISelectedContent[] contents = SelectedContentManager.getCurrentlySelectedContent();
          if (contents.length == 0) {
            return;
          }

          deviceSelected(contents, true);
        }
      };
      addToolBarItem(item, first ? "toolbar.area.sitem.left"
          : "toolbar.area.sitem", so2nd);
      first = false;
      addSeperator(so2nd);
    }

    // ==run
    item = new ToolBarItem("run", "image.toolbar.run", "iconBar.run") {
      public void triggerToolBarItem() {
        if (!triggerBasicToolBarItem(getId())) {
          DownloadManager[] dms = SelectedContentManager.getDMSFromSelectedContent();
          if (dms != null) {
            TorrentUtil.runDataSources(dms);

            for (int i = 0; i < dms.length; i++) {
              DownloadManager dm = dms[i];
              PlatformTorrentUtils.setHasBeenOpened(dm, true);
            }
          }
        }
      }
    };
    addToolBarItem(item, first ? "toolbar.area.sitem.left"
        : "toolbar.area.sitem", so2nd);
    first = false;
    //addToolBarItem(item, "toolbar.area.sitem", so2nd);
    addSeperator(so2nd);

    if (uiClassic) {
      // ==TOP
      item = new ToolBarItem("top", "image.toolbar.top", "iconBar.top") {
        public void triggerToolBarItem() {
          moveTop();
        }

        public boolean triggerToolBarItemHold() {
          return false;
        }
      };
      addToolBarItem(item, "toolbar.area.sitem", so2nd);
      addSeperator(so2nd);
    }

    // ==UP
    item = new ToolBarItem("up", "image.toolbar.up", "v3.iconBar.up") {
      public void triggerToolBarItem() {
        if (!AzureusCoreFactory.isCoreRunning()) {
          return;
        }
        if (!triggerBasicToolBarItem(getId())) {
          DownloadManager[] dms = SelectedContentManager.getDMSFromSelectedContent();
          if (dms != null) {
            Arrays.sort(dms, new Comparator<DownloadManager>() {
              public int compare(DownloadManager a, DownloadManager b) {
                return a.getPosition() - b.getPosition();
              }
            });
            GlobalManager gm = AzureusCoreFactory.getSingleton().getGlobalManager();
            for (int i = 0; i < dms.length; i++) {
              DownloadManager dm = dms[i];
              if (gm.isMoveableUp(dm)) {
                gm.moveUp(dm);
              }
            }
          }
        }
      }

      // @see com.aelitis.azureus.ui.swt.toolbar.ToolBarItem#triggerToolBarItemHold()
      public boolean triggerToolBarItemHold() {
        return moveTop();
      }
    };
    addToolBarItem(item, "toolbar.area.sitem", so2nd);
    addSeperator(so2nd);

    // ==down
    item = new ToolBarItem("down", "image.toolbar.down", "v3.iconBar.down") {
      public void triggerToolBarItem() {
        if (!AzureusCoreFactory.isCoreRunning()) {
          return;
        }

        if (!triggerBasicToolBarItem(getId())) {
          GlobalManager gm = AzureusCoreFactory.getSingleton().getGlobalManager();
          DownloadManager[] dms = SelectedContentManager.getDMSFromSelectedContent();
          if (dms != null) {
            Arrays.sort(dms, new Comparator<DownloadManager>() {
              public int compare(DownloadManager a, DownloadManager b) {
                return b.getPosition() - a.getPosition();
              }
            });
            for (int i = 0; i < dms.length; i++) {
              DownloadManager dm = dms[i];
              if (gm.isMoveableDown(dm)) {
                gm.moveDown(dm);
              }
            }
          }
        }
      }

      // @see com.aelitis.azureus.ui.swt.toolbar.ToolBarItem#triggerToolBarItemHold()
      public boolean triggerToolBarItemHold() {
        return moveBottom();
      }
    };
    addToolBarItem(item, "toolbar.area.sitem", so2nd);
    addSeperator(so2nd);

    if (uiClassic) {
      // ==BOTTOM
      item = new ToolBarItem("bottom", "image.toolbar.bottom", "iconBar.bottom") {
        public void triggerToolBarItem() {
          moveBottom();
        }

        public boolean triggerToolBarItemHold() {
          return false;
        }
      };
      addToolBarItem(item, "toolbar.area.sitem", so2nd);
      addSeperator(so2nd);
    }

    // ==start
    item = new ToolBarItem("start", "image.toolbar.start", "iconBar.start") {
      public void triggerToolBarItem() {
        if (!triggerBasicToolBarItem(getId())) {
          DownloadManager[] dms = SelectedContentManager.getDMSFromSelectedContent();
          if (dms != null) {
            TorrentUtil.queueDataSources(dms, true);
          }
        }
      }
    };
    addToolBarItem(item, "toolbar.area.sitem", so2nd);
    //SWTSkinObjectContainer so = (SWTSkinObjectContainer) item.getSkinButton().getSkinObject();
    //so.setDebugAndChildren(true);
    addSeperator(so2nd);

    // ==stop
    item = new ToolBarItem("stop", "image.toolbar.stop", "iconBar.stop") {
      public void triggerToolBarItem() {
        if (!triggerBasicToolBarItem(getId())) {
          ISelectedContent[] currentContent = SelectedContentManager.getCurrentlySelectedContent();
          TorrentUtil.stopDataSources(currentContent);
        }
      }
    };
    addToolBarItem(item, "toolbar.area.sitem", so2nd);
    addSeperator(so2nd);

    // ==remove
    item = new ToolBarItem("remove", "image.toolbar.remove", "iconBar.remove") {
      public void triggerToolBarItem() {
        if (!triggerBasicToolBarItem(getId())) {
          DownloadManager[] dms = SelectedContentManager.getDMSFromSelectedContent();
          TorrentUtil.removeDownloads(dms, null);
        }
      }
    };
    addToolBarItem(item, "toolbar.area.sitem.right", so2nd);

    ///////////////////////

    addSeperator((uiClassic ? "classic." : "") + "toolbar.area.item.sep3",
        so2nd);

    addNonToolBar("toolbar.area.sitem.left2", so2nd);

    // == mode big
    item = new ToolBarItem("modeBig", "image.toolbar.table_large",
        "v3.iconBar.view.big") {
      public void triggerToolBarItem() {
        triggerBasicToolBarItem(getId());
      }
      public void setEnabled(boolean enabled) {
        if (!enabled) {
          SWTSkinObject so = getSkinButton().getSkinObject();
          if (so != null && so.getSuffix().contains("-down")) {
            so.switchSuffix("");
          }
        }
        super.setEnabled(enabled);
      }
    };
    addToolBarItem(item, "toolbar.area.vitem.left", so2nd);

    SWTSkinObject soTitle = skin.getSkinObject("toolbar-item-title",
        item.getSkinButton().getSkinObject());
    if (soTitle instanceof SWTSkinObjectText) {
      ((SWTSkinObjectText) soTitle).setStyle(SWT.RIGHT);
    }

    addSeperator(so2nd);

    // == mode small
    item = new ToolBarItem("modeSmall", "image.toolbar.table_normal",
        "v3.iconBar.view.small") {
      public void triggerToolBarItem() {
        triggerBasicToolBarItem(getId());
      }

      public void setEnabled(boolean enabled) {
        if (!enabled) {
          SWTSkinObject so = getSkinButton().getSkinObject();
          if (so != null && so.getSuffix().contains("-down")) {
            so.switchSuffix("");
          }
        }
        super.setEnabled(enabled);
      }
    };
    addToolBarItem(item, "toolbar.area.vitem.right", so2nd);

    soTitle = skin.getSkinObject("toolbar-item-title",
        item.getSkinButton().getSkinObject());
    if (soTitle instanceof SWTSkinObjectText) {
      ((SWTSkinObjectText) soTitle).setStyle(SWT.LEFT);
    }

    //addSeperator(so2nd);
View Full Code Here

Examples of com.aelitis.azureus.ui.swt.toolbar.ToolBarItem

    Map<String, Boolean> mapNewToolbarStates = TorrentUtil.calculateToolbarStates(
        currentContent, viewID);
   
    for (String key : mapNewToolbarStates.keySet()) {
      Boolean enable = mapNewToolbarStates.get(key);
      ToolBarItem item = getToolBarItem(key);
      if (item != null) {
        item.setEnabled(enable);
      }
    }
  }
View Full Code Here

Examples of com.aelitis.azureus.ui.swt.toolbar.ToolBarItem

        can_stream |= (Boolean)mapStates.get( "stream" );
      }
     
      mapStates.put( "play", can_play | can_stream );

      ToolBarItem pitem = getToolBarItem( "play" );
     
      if ( pitem != null ){
     
        if ( can_stream ){
         
          pitem.setImageID( stream_permitted?"image.button.stream":"image.button.pstream" );
          pitem.setTextID( stream_permitted?"iconBar.stream":"iconBar.pstream" );

        }else{
         
          pitem.setImageID( "image.button.play" );
          pitem.setTextID( "iconBar.play" );
        }
      }
     
      for (int i = 0; i < allToolBarItems.length; i++) {
        ToolBarItem toolBarItem = allToolBarItems[i];
        if (toolBarItem.isAlwaysAvailable()) {
          toolBarItem.setEnabled(true);
        } else {
          Boolean b = mapStates.get(toolBarItem.getId());
          if (b == null) {
            b = false;
          }
          toolBarItem.setEnabled(b);
        }
      }
      return;
    }
  }
View Full Code Here

Examples of com.aelitis.azureus.ui.swt.toolbar.ToolBarItem

   */
  public void setShowText(boolean showText) {
    this.showText = showText;
    ToolBarItem[] allToolBarItems = getAllToolBarItems();
    for (int i = 0; i < allToolBarItems.length; i++) {
      ToolBarItem tbi = allToolBarItems[i];
      SWTSkinObject so = tbi.getSkinButton().getSkinObject();
      SWTSkinObject soTitle = skin.getSkinObject("toolbar-item-title", so);
      soTitle.setVisible(showText);
    }
  }
View Full Code Here

Examples of com.aelitis.azureus.ui.swt.toolbar.ToolBarItem

  private static class toolbarButtonListener
    extends ButtonListenerAdapter
  {
    public void pressed(SWTSkinButtonUtility buttonUtility,
        SWTSkinObject skinObject, int stateMask) {
      ToolBarItem item = (ToolBarItem) buttonUtility.getSkinObject().getData(
          "toolbaritem");
      item.triggerToolBarItem();
    }
View Full Code Here

Examples of com.aelitis.azureus.ui.swt.toolbar.ToolBarItem

          "toolbaritem");
      item.triggerToolBarItem();
    }

    public boolean held(SWTSkinButtonUtility buttonUtility) {
      ToolBarItem item = (ToolBarItem) buttonUtility.getSkinObject().getData(
          "toolbaritem");
      buttonUtility.getSkinObject().switchSuffix("", 0, false, true);

      boolean triggerToolBarItemHold = item.triggerToolBarItemHold();
      return triggerToolBarItemHold;
    }
View Full Code Here

Examples of com.aelitis.azureus.ui.swt.toolbar.ToolBarItem

      return triggerToolBarItemHold;
    }

    public void disabledStateChanged(SWTSkinButtonUtility buttonUtility,
        boolean disabled) {
      ToolBarItem item = (ToolBarItem) buttonUtility.getSkinObject().getData(
          "toolbaritem");
      item.setEnabled(!disabled);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.