コード例 #1
0
  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;
    }
  }
コード例 #2
0
  public SWTSkinButtonUtility(SWTSkinObject skinObject, String imageViewID) {
    this.skinObject = skinObject;
    this.imageViewID = imageViewID;

    if (skinObject == null) {
      Debug.out("Can't make button out of null skinObject");
      return;
    }
    if (skinObject.getControl() == null) {
      Debug.out("Can't make button out of null skinObject control");
      return;
    }

    if (skinObject instanceof SWTSkinObjectButton) {
      return;
    }

    Listener l =
        new Listener() {
          boolean bDownPressed;

          private TimerEvent timerEvent;

          public void handleEvent(Event event) {
            if (event.type == SWT.MouseDown) {
              if (timerEvent == null) {
                timerEvent =
                    SimpleTimer.addEvent(
                        "MouseHold",
                        SystemTime.getOffsetTime(1000),
                        new TimerEventPerformer() {
                          public void perform(TimerEvent event) {
                            timerEvent = null;

                            if (!bDownPressed) {
                              return;
                            }
                            bDownPressed = false;

                            boolean stillPressed = true;
                            for (ButtonListenerAdapter l : listeners) {
                              stillPressed &= !l.held(SWTSkinButtonUtility.this);
                            }
                            bDownPressed = stillPressed;
                          }
                        });
              }
              bDownPressed = true;
              return;
            } else {
              if (timerEvent != null) {
                timerEvent.cancel();
                timerEvent = null;
              }
              if (!bDownPressed) {
                return;
              }
            }

            bDownPressed = false;

            if (isDisabled()) {
              return;
            }

            for (ButtonListenerAdapter l : listeners) {
              l.pressed(
                  SWTSkinButtonUtility.this, SWTSkinButtonUtility.this.skinObject, event.stateMask);
            }
          }
        };
    if (skinObject instanceof SWTSkinObjectContainer) {
      Utils.addListenerAndChildren((Composite) skinObject.getControl(), SWT.MouseUp, l);
      Utils.addListenerAndChildren((Composite) skinObject.getControl(), SWT.MouseDown, l);
    } else {
      skinObject.getControl().addListener(SWT.MouseUp, l);
      skinObject.getControl().addListener(SWT.MouseDown, l);
    }
  }
コード例 #3
0
 public boolean isDisabled() {
   return skinObject == null ? true : skinObject.getSuffix().indexOf("-disabled") >= 0;
 }
コード例 #4
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();
  }