Exemplo n.º 1
0
  private void createControls() {
    GridLayout gLayout = new GridLayout();
    gLayout.marginHeight = 0;
    gLayout.marginWidth = 0;
    gLayout.verticalSpacing = 0;
    shell.setLayout(gLayout);
    Utils.setShellIcon(shell);

    topPanel = new Composite(shell, SWT.NONE);
    topPanel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    GridLayout gLayout1 = new GridLayout();
    gLayout1.marginBottom = 10;
    topPanel.setLayout(gLayout1);
    topPanel.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    topPanel.setBackgroundMode(SWT.INHERIT_FORCE);

    Label separator1 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    contentPanel = new Composite(shell, SWT.NONE);
    contentPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    contentStackLayout = new StackLayout();
    contentPanel.setLayout(contentStackLayout);

    titleLabel = new Label(topPanel, SWT.NONE);
    titleLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    Utils.setFontHeight(titleLabel, 16, SWT.NORMAL);

    descriptionLabel = new Label(topPanel, SWT.WRAP);
    GridData gData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gData.horizontalIndent = 10;
    descriptionLabel.setLayoutData(gData);

    shell.layout(true, true);
  }
Exemplo n.º 2
0
  public void init(Shell parentShell) {
    shell = ShellFactory.createShell(parentShell, SWT.BORDER | SWT.TITLE | SWT.CLOSE | SWT.RESIZE);
    Utils.setShellIcon(shell);
    if (Constants.isOSX) monospace = new Font(shell.getDisplay(), "Courier", 12, SWT.NORMAL);
    else monospace = new Font(shell.getDisplay(), "Courier New", 8, SWT.NORMAL);

    shell.setText(
        MessageText.getString("window.welcome.title", new String[] {Constants.AZUREUS_VERSION}));

    display = shell.getDisplay();

    GridLayout layout = new GridLayout();
    shell.setLayout(layout);

    GridData data;

    cWhatsNew = new Composite(shell, SWT.BORDER);
    data = new GridData(GridData.FILL_BOTH);
    cWhatsNew.setLayoutData(data);
    cWhatsNew.setLayout(new FillLayout());

    Button bClose = new Button(shell, SWT.PUSH);
    bClose.setText(MessageText.getString("Button.close"));
    data = new GridData();
    data.widthHint = 70;
    data.horizontalAlignment = Constants.isOSX ? SWT.CENTER : SWT.RIGHT;
    bClose.setLayoutData(data);

    Listener closeListener =
        new Listener() {
          public void handleEvent(Event event) {
            close();
          }
        };

    bClose.addListener(SWT.Selection, closeListener);
    shell.addListener(SWT.Close, closeListener);

    shell.setDefaultButton(bClose);

    shell.addListener(
        SWT.Traverse,
        new Listener() {
          public void handleEvent(Event e) {
            if (e.character == SWT.ESC) {
              close();
            }
          }
        });

    shell.setSize(750, 500);
    Utils.centreWindow(shell);
    shell.layout();
    shell.open();
    pullWhatsNew(cWhatsNew);
  }
  /** Set initial size and layout for the window then open it */
  private void openWindow() {

    /*
     * Using initialMaxNumberOfPanels as a lower limit we exclude all other panels from the layout,
     * compute the window size, then finally we include all panels back into the layout
     *
     *  This ensures that the window will fit exactly the desired number of panels
     */
    Control[] controls = scrollChild.getChildren();
    for (int i = (initialMaxNumberOfPanels); i < controls.length; i++) {
      ((GridData) controls[i].getLayoutData()).exclude = true;
    }

    Point p = shell.computeSize(defaultShellWidth, SWT.DEFAULT);

    for (int i = 0; i < controls.length; i++) {
      ((GridData) controls[i].getLayoutData()).exclude = false;
    }
    formatLastPanel(null);
    scrollChild.layout();

    /*
     * Set the shell size if it's different that the computed size
     */
    if (false == shell.getSize().equals(p)) {
      shell.setSize(p);
      shell.layout(false);
    }

    /*
     * Centers the window
     */

    UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
    if (null == uiFunctions) {
      /*
       * Centers on the active monitor
       */
      Utils.centreWindow(shell);
    } else {
      /*
       * Centers on the main application window
       */
      Utils.centerWindowRelativeTo(shell, uiFunctions.getMainShell());
    }

    shell.open();
  }
  public void forceNotify(
      final int iconID,
      final String title,
      final String text,
      final String details,
      final Object[] relatedObjects,
      final int timeoutSecs) {

    Utils.execSWTThread(
        new AERunnable() {
          public void runSupport() {
            int swtIconID = SWT.ICON_INFORMATION;
            switch (iconID) {
              case STATUSICON_WARNING:
                swtIconID = SWT.ICON_WARNING;
                break;

              case STATUSICON_ERROR:
                swtIconID = SWT.ICON_ERROR;
                break;
            }

            new MessageSlideShell(
                SWTThread.getInstance().getDisplay(),
                swtIconID,
                title,
                text,
                details,
                relatedObjects,
                timeoutSecs);
          }
        });
  }
  public void setDisabled(final boolean disabled) {
    if (inSetDisabled || skinObject == null) {
      return;
    }
    inSetDisabled = true;
    try {
      if (disabled == isDisabled()) {
        return;
      }
      if (skinObject instanceof SWTSkinObjectButton) {
        lastDisabledState = disabled;
        Utils.execSWTThreadLater(
            100,
            new AERunnable() {
              public void runSupport() {
                if (lastDisabledState == isDisabled()) {
                  return;
                }
                ((SWTSkinObjectButton) skinObject).getControl().setEnabled(!lastDisabledState);
              }
            });
      }
      String suffix = disabled ? "-disabled" : "";
      skinObject.switchSuffix(suffix, 1, false);

      for (ButtonListenerAdapter l : listeners) {
        l.disabledStateChanged(SWTSkinButtonUtility.this, disabled);
      }
    } finally {
      inSetDisabled = false;
    }
  }
 public void setTextID(final String id) {
   if (skinObject == null) {
     return;
   }
   if (skinObject instanceof SWTSkinObjectButton) {
     ((SWTSkinObjectButton) skinObject).setText(MessageText.getString(id));
     return;
   }
   Utils.execSWTThreadLater(
       0,
       new AERunnable() {
         public void runSupport() {
           if (skinObject instanceof SWTSkinObjectText) {
             SWTSkinObjectText skinTextObject = (SWTSkinObjectText) skinObject;
             skinTextObject.setTextID(id);
           } else if (skinObject instanceof SWTSkinObjectContainer) {
             SWTSkinObject[] children = ((SWTSkinObjectContainer) skinObject).getChildren();
             if (children.length > 0 && children[0] instanceof SWTSkinObjectText) {
               SWTSkinObjectText skinTextObject = (SWTSkinObjectText) children[0];
               skinTextObject.setTextID(id);
             }
           }
           Utils.relayout(skinObject.getControl());
         }
       });
 }
 public void setImage(final String id) {
   if (skinObject == null) {
     return;
   }
   if (skinObject instanceof SWTSkinObjectButton) {
     // TODO implement
     return;
   }
   Utils.execSWTThread(
       new AERunnable() {
         public void runSupport() {
           if (imageViewID != null) {
             SWTSkinObject skinImageObject =
                 skinObject.getSkin().getSkinObject(imageViewID, skinObject);
             if (skinImageObject instanceof SWTSkinObjectImage) {
               ((SWTSkinObjectImage) skinImageObject).setImageByID(id, null);
               return;
             }
           }
           if (skinObject instanceof SWTSkinObjectImage) {
             SWTSkinObjectImage skinImageObject = (SWTSkinObjectImage) skinObject;
             skinImageObject.setImageByID(id, null);
           } else if (skinObject instanceof SWTSkinObjectContainer) {
             SWTSkinObject[] children = ((SWTSkinObjectContainer) skinObject).getChildren();
             if (children.length > 0 && children[0] instanceof SWTSkinObjectImage) {
               SWTSkinObjectImage skinImageObject = (SWTSkinObjectImage) children[0];
               skinImageObject.setImageByID(id, null);
             }
           }
         }
       });
 }
 // TODO : Tux Move to utils? Could you also add a "mode" or something that would be added to the
 // url
 // eg: &subscribe_mode=true
 public void doSearch(final String sSearchText) {
   Utils.execSWTThread(
       new AERunnable() {
         public void runSupport() {
           doSearch(sSearchText, false);
         }
       });
 }
 public void openView(final int viewID, final Object data) {
   Utils.execSWTThread(
       new AERunnable() {
         public void runSupport() {
           _openView(viewID, data);
         }
       });
 }
Exemplo n.º 10
0
 private void rebuild() {
   Utils.execSWTThread(
       new Runnable() {
         public void run() {
           build();
         }
       });
 }
Exemplo n.º 11
0
 public void setWhatsNew() {
   Utils.execSWTThread(
       new AERunnable() {
         public void runSupport() {
           _setWhatsNew();
         }
       });
 }
Exemplo n.º 12
0
  public void runOnUIThread(final int ui_type, final Runnable runnable) {
    if (ui_type == UIInstance.UIT_SWT) {

      Utils.execSWTThread(runnable);

    } else {

      runnable.run();
    }
  }
Exemplo n.º 13
0
 // @see com.aelitis.azureus.ui.UIFunctions#setStatusText(java.lang.String)
 public void setStatusText(final String string) {
   Utils.execSWTThreadLater(
       0,
       new AERunnable() {
         public void runSupport() {
           IMainStatusBar sb = getMainStatusBar();
           if (sb != null) {
             sb.setStatusText(string);
           }
         }
       });
 }
Exemplo n.º 14
0
  private void openView(
      final String parentID,
      final Class<? extends UISWTViewEventListener> cla,
      String id,
      final Object data,
      final boolean closeable) {
    final MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
    if (mdi == null) {
      return;
    }

    if (id == null) {
      id = cla.getName();
      int i = id.lastIndexOf('.');
      if (i > 0) {
        id = id.substring(i + 1);
      }
    }

    UISWTViewCore viewFromID = mdi.getCoreViewFromID(id);
    if (viewFromID != null) {
      viewFromID.triggerEvent(UISWTViewEvent.TYPE_DATASOURCE_CHANGED, data);
      mdi.showEntryByID(id);
    }

    final String _id = id;
    Utils.execSWTThreadLater(
        0,
        new AERunnable() {

          public void runSupport() {
            if (mdi.showEntryByID(_id)) {
              return;
            }
            UISWTViewEventListener l = null;
            try {
              Constructor<?> constructor = cla.getConstructor(new Class[] {data.getClass()});
              l = (UISWTViewEventListener) constructor.newInstance(new Object[] {data});
            } catch (Exception e) {
            }

            try {
              if (l == null) {
                l = cla.newInstance();
              }
              mdi.createEntryFromEventListener(parentID, l, _id, closeable, data, null);
            } catch (Exception e) {
              Debug.out(e);
            }
            mdi.showEntryByID(_id);
          }
        });
  }
Exemplo n.º 15
0
 // @see com.aelitis.azureus.ui.UIFunctions#setStatusText(int, java.lang.String,
 // com.aelitis.azureus.ui.UIStatusTextClickListener)
 public void setStatusText(
     final int statustype, final String string, final UIStatusTextClickListener l) {
   Utils.execSWTThreadLater(
       0,
       new AERunnable() {
         public void runSupport() {
           IMainStatusBar sb = getMainStatusBar();
           if (sb != null) {
             sb.setStatusText(statustype, string, l);
           }
         }
       });
 }
Exemplo n.º 16
0
  static final int toolbarToggle(int nextHandler, int theEvent, int userData) {
    int eventKind =
        ((Number) invoke(claOS, null, "GetEventKind", new Object[] {theEvent})).intValue();
    if (eventKind != kEventWindowToolbarSwitchMode) {
      return eventNotHandledErr;
    }

    int[] theWindow = new int[1];
    // int GetEventParameter(int inEvent, int inName, int inDesiredType,
    // int[] outActualType, int inBufferSize, int[] outActualSize, int[] outData);
    invoke(
        claOS,
        null,
        "GetEventParameter",
        new Class[] {
          int.class, int.class, int.class, int[].class, int.class, int[].class, int[].class
        },
        new Object[] {theEvent, kEventParamDirectObject, typeWindowRef, null, 4, null, theWindow});

    int[] theRoot = new int[1];
    invoke(claOS, null, "GetRootControl", new Object[] {theWindow[0], theRoot});
    final Widget widget = Display.getCurrent().findWidget(theRoot[0]);

    if (!(widget instanceof Shell)) {
      return eventNotHandledErr;
    }
    final Shell shellAffected = (Shell) widget;

    Utils.execSWTThread(
        new AERunnable() {
          public void runSupport() {
            int type;
            Long l = (Long) shellAffected.getData("OSX.ToolBarToggle");
            if (l == null || l.longValue() == 0) {
              type = SWT.Collapse;
            } else {
              type = SWT.Expand;
            }

            Event event = new Event();
            event.type = type;
            event.display = widget.getDisplay();
            event.widget = widget;
            shellAffected.notifyListeners(type, event);

            shellAffected.setData("OSX.ToolBarToggle", new Long(type == SWT.Collapse ? 1 : 0));
          }
        });

    return noErr;
  }
Exemplo n.º 17
0
  // @see com.aelitis.azureus.ui.swt.UIFunctionsSWT#closeDownloadBars()
  public void closeDownloadBars() {
    try {
      Utils.execSWTThreadLater(
          0,
          new AERunnable() {
            public void runSupport() {
              MiniBarManager.getManager().closeAll();
            }
          });

    } catch (Exception e) {
      Logger.log(new LogEvent(LOGID, "closeDownloadBars", e));
    }
  }
Exemplo n.º 18
0
  // @see com.aelitis.azureus.ui.UIFunctions#bringToFront(boolean)
  public void bringToFront(final boolean tryTricks) {
    Utils.execSWTThread(
        new AERunnable() {
          public void runSupport() {
            try {
              // this will force active and set !minimized after PW test
              mainWindow.setVisible(true, tryTricks);

            } catch (Exception e) {
              Logger.log(new LogEvent(LOGID, "bringToFront", e));
            }
          }
        });
  }
Exemplo n.º 19
0
  // @see com.aelitis.azureus.ui.swt.UIFunctionsSWT#addPluginView(java.lang.String,
  // org.gudy.azureus2.ui.swt.plugins.UISWTViewEventListener)
  public void addPluginView(final String viewID, final UISWTViewEventListener l) {
    try {

      Utils.execSWTThread(
          new AERunnable() {
            public void runSupport() {
              PluginsMenuHelper.getInstance().addPluginView(viewID, l);
            }
          });

    } catch (Exception e) {
      Logger.log(new LogEvent(LOGID, "addPluginView", e));
    }
  }
 public void progress(final int percent) {
   Utils.execSWTThread(
       new AERunnable() {
         public void runSupport() {
           int pct = percent == 100 ? 99 : percent;
           if (soInstallPct != null) {
             soInstallPct.setText(
                 MessageText.getString("dlg.auth.install.pct", new String[] {"" + pct}));
           }
           if (progressBar != null && !progressBar.isDisposed()) {
             // never reach 100%!
             progressBar.setSelection(pct);
           }
         }
       });
 }
Exemplo n.º 21
0
 /**
  * @param keyPrefix
  * @param details may not get displayed
  * @param textParams
  */
 public void showErrorMessage(
     final String keyPrefix, final String details, final String[] textParams) {
   Utils.execSWTThread(
       new AERunnable() {
         public void runSupport() {
           Shell mainShell = getMainShell();
           if (mainShell.getDisplay().getActiveShell() != null || mainShell.isFocusControl()) {
             new MessageSlideShell(
                 Display.getCurrent(), SWT.ICON_ERROR, keyPrefix, details, textParams, -1);
           } else {
             MessageBoxShell mb = new MessageBoxShell(SWT.OK, keyPrefix, textParams);
             mb.open(null);
           }
         }
       });
 }
Exemplo n.º 22
0
  private void delete() {
    Utils.disposeComposite(panel);

    TagManager tm = TagManagerFactory.getTagManager();

    tm.removeTagManagerListener(this);

    for (TagType tt : tm.getTagTypes()) {

      tt.removeTagTypeListener(this);
    }

    if (mpg != null) {

      mpg.dispose();
    }
  }
Exemplo n.º 23
0
  protected AssociationChecker(final PlatformManager _platform) {
    platform = _platform;

    display = SWTThread.getInstance().getDisplay();

    if (display.isDisposed()) {

      return;
    }

    Utils.execSWTThread(
        new AERunnable() {
          public void runSupport() {
            check();
          }
        });
  }
    public int report(IProgressReport progressReport) {

      if (true == isAutoRemove
          && false == progressReport.isActive()
          && !progressReport.isInErrorState()) {
        if (null != panel && false == panel.isDisposed()) {
          ProgressReportingManager.getInstance().remove(panel.getProgressReporter());

          Utils.execSWTThread(
              new AERunnable() {
                public void runSupport() {
                  panel.dispose();
                }
              });
        }
        return RETVAL_OK_TO_DISPOSE;
      }
      return RETVAL_OK;
    }
Exemplo n.º 25
0
 public void removeBuddy(final AvatarWidget widget) {
   Utils.execSWTThreadLater(
       0,
       new AERunnable() {
         public void runSupport() {
           avatarWidgets.remove(widget);
           widget.dispose(
               true,
               new AvatarWidget.AfterDisposeListener() {
                 public void disposed() {
                   avatarsPanel.setSize(avatarsPanel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true));
                   if (avatarWidgets.size() < 1) {
                     showNoBuddiesPanel(true);
                   }
                 }
               });
         }
       });
 }
Exemplo n.º 26
0
  public void refreshTorrentMenu() {
    if (!isTorrentMenuVisible) {
      return;
    }
    try {
      Utils.execSWTThread(
          new AERunnable() {
            public void runSupport() {
              final MenuItem torrentItem =
                  MenuFactory.findMenuItem(
                      mainWindow.getMainMenu().getMenu(IMenuConstants.MENU_ID_MENU_BAR),
                      MenuFactory.MENU_ID_TORRENT,
                      false);

              if (null != torrentItem) {

                DownloadManager[] dms = SelectedContentManager.getDMSFromSelectedContent();

                final DownloadManager[] dm_final = dms;
                final boolean detailed_view_final = false;
                if (null == dm_final) {
                  torrentItem.setEnabled(false);
                } else {
                  TableView<?> tv = SelectedContentManager.getCurrentlySelectedTableView();

                  torrentItem.getMenu().setData("TableView", tv);
                  torrentItem.getMenu().setData("downloads", dm_final);
                  torrentItem
                      .getMenu()
                      .setData("is_detailed_view", Boolean.valueOf(detailed_view_final));
                  torrentItem.setEnabled(true);
                }
              }
            }
          });

    } catch (Exception e) {
      Logger.log(new LogEvent(LOGID, "refreshTorrentMenu", e));
    }
  }
Exemplo n.º 27
0
  public void updateBuddy(final VuzeBuddy buddy) {
    if (buddy instanceof VuzeBuddySWT) {

      Utils.execSWTThreadLater(
          0,
          new AERunnable() {

            public void runSupport() {
              AvatarWidget widget = findWidget(buddy);
              if (null != widget) {
                widget.setVuzeBuddy((VuzeBuddySWT) buddy);
              } else {
                /*
                 * If not found yet then we create the avatar for it; this really should not happen
                 * but we'll handle it just in case
                 */
                addBuddy(buddy);
              }
            }
          });
    }
  }
Exemplo n.º 28
0
  public void reportProgress(String licence_key, String install, final int percent) {
    if (FAKE_DELAY) {
      try {
        Thread.sleep(80);
      } catch (InterruptedException e) {
      }
    }

    Utils.execSWTThread(
        new AERunnable() {
          public void runSupport() {
            int pct = percent == 100 ? 99 : percent;
            if (soInstallPct != null) {
              soInstallPct.setText(
                  MessageText.getString("dlg.auth.install.pct", new String[] {"" + pct}));
            }
            if (progressBar != null && !progressBar.isDisposed()) {
              // never reach 100%!
              progressBar.setSelection(pct);
            }
          }
        });
  }
Exemplo n.º 29
0
  public void addBuddy(final VuzeBuddy buddy) {
    if (buddy instanceof VuzeBuddySWT) {
      Utils.execSWTThreadLater(
          0,
          new AERunnable() {
            public void runSupport() {
              AvatarWidget widget = findWidget(buddy);
              if (widget == null) {
                if (soNoBuddies != null) {
                  soNoBuddies.setVisible(false);
                }
                createBuddyControls(avatarsPanel, (VuzeBuddySWT) buddy);
                avatarsPanel.layout();
                Point size = avatarsPanel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
                avatarsPanel.setSize(size);
              }
            }
          });

    } else {
      Debug.out("Wrong type VuzeBuddy... must be of type VuzeBuddySWT");
    }
  }
Exemplo n.º 30
0
  public void shareTorrent(final SelectedContentV3 currentContent, final String referer) {

    PlatformBuddyMessenger.startShare(
        referer, currentContent.isPlatformContent() ? currentContent.getHash() : null);

    if (!VuzeBuddyManager.isEnabled()) {
      VuzeBuddyManager.showDisabledDialog();
      return;
    }

    // TODO : Gudy : make sure that this private detection method is reliable enough
    if (currentContent.getDM() != null
        && (TorrentUtils.isReallyPrivate(currentContent.getDM().getTorrent()))) {
      Utils.openMessageBox(Utils.findAnyShell(), SWT.OK, "v3.share.private", (String[]) null);
      return;
    }

    SWTLoginUtils.waitForLogin(
        new SWTLoginUtils.loginWaitListener() {
          public void loginComplete() {
            if (null != sharePage) {
              try {
                // sharePage.setShareItem(currentContent, referer);

                ShareWizard wizard =
                    new ShareWizard(
                        UIFunctionsManagerSWT.getUIFunctionsSWT().getMainShell(),
                        SWT.DIALOG_TRIM | SWT.RESIZE);
                wizard.setText("Vuze - Wizard");
                wizard.setSize(500, 550);

                com.aelitis.azureus.ui.swt.shells.friends.SharePage newSharePage =
                    (com.aelitis.azureus.ui.swt.shells.friends.SharePage)
                        wizard.getPage(com.aelitis.azureus.ui.swt.shells.friends.SharePage.ID);
                newSharePage.setShareItem(currentContent, referer);

                /*
                 * Opens a centered free-floating shell
                 */

                UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
                if (null == uiFunctions) {
                  /*
                   * Centers on the active monitor
                   */
                  Utils.centreWindow(wizard.getShell());
                } else {
                  /*
                   * Centers on the main application window
                   */
                  Utils.centerWindowRelativeTo(wizard.getShell(), uiFunctions.getMainShell());
                }

                wizard.open();

              } catch (Exception e) {
                e.printStackTrace();
              }
            }
          }
        });
  }