コード例 #1
0
 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());
         }
       });
 }
コード例 #2
0
  public void addSelectionListener(ButtonListenerAdapter listener) {
    if (skinObject instanceof SWTSkinObjectButton) {
      ((SWTSkinObjectButton) skinObject).addSelectionListener(listener);
      return;
    }

    if (listeners.contains(listener)) {
      return;
    }
    listeners.add(listener);
  }
コード例 #3
0
  // @see com.aelitis.azureus.ui.swt.UIFunctionsSWT#showCoreWaitDlg()
  public Shell showCoreWaitDlg() {
    final SkinnedDialog closeDialog =
        new SkinnedDialog(
            "skin3_dlg_coreloading",
            "coreloading.body",
            SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);

    closeDialog.setTitle(MessageText.getString("dlg.corewait.title"));
    SWTSkin skin = closeDialog.getSkin();
    SWTSkinObjectButton soButton = (SWTSkinObjectButton) skin.getSkinObject("close");

    final SWTSkinObjectText soWaitTask = (SWTSkinObjectText) skin.getSkinObject("task");

    final SWTSkinObject soWaitProgress = skin.getSkinObject("progress");
    if (soWaitProgress != null) {
      soWaitProgress
          .getControl()
          .addPaintListener(
              new PaintListener() {
                public void paintControl(PaintEvent e) {
                  Control c = (Control) e.widget;
                  Point size = c.getSize();
                  e.gc.setBackground(ColorCache.getColor(e.display, "#23a7df"));
                  Object data = soWaitProgress.getData("progress");
                  if (data instanceof Long) {
                    int waitProgress = ((Long) data).intValue();
                    int breakX = size.x * waitProgress / 100;
                    e.gc.fillRectangle(0, 0, breakX, size.y);
                    e.gc.setBackground(ColorCache.getColor(e.display, "#cccccc"));
                    e.gc.fillRectangle(breakX, 0, size.x - breakX, size.y);
                  }
                }
              });
    }

    if (!AzureusCoreFactory.isCoreRunning()) {
      final Initializer initializer = Initializer.getLastInitializer();
      if (initializer != null) {
        initializer.addListener(
            new InitializerListener() {
              public void reportPercent(final int percent) {
                Utils.execSWTThread(
                    new AERunnable() {
                      public void runSupport() {
                        if (soWaitProgress != null && !soWaitProgress.isDisposed()) {
                          soWaitProgress.setData("progress", new Long(percent));
                          soWaitProgress.getControl().redraw();
                          soWaitProgress.getControl().update();
                        }
                      }
                    });
                if (percent > 100) {
                  initializer.removeListener(this);
                }
              }

              public void reportCurrentTask(String currentTask) {
                if (soWaitTask != null && !soWaitTask.isDisposed()) {
                  soWaitTask.setText(currentTask);
                }
              }
            });
      }
    }

    if (soButton != null) {
      soButton.addSelectionListener(
          new ButtonListenerAdapter() {
            public void pressed(
                SWTSkinButtonUtility buttonUtility, SWTSkinObject skinObject, int stateMask) {
              closeDialog.close();
            }
          });
    }

    closeDialog.addCloseListener(
        new SkinnedDialogClosedListener() {
          public void skinDialogClosed(SkinnedDialog dialog) {}
        });

    closeDialog.open();
    return closeDialog.getShell();
  }