Esempio n. 1
0
 private void setCyclicReload(MenuItem menuitem) {
   if (menuitem.getSelection()) {
     Runnable command =
         () -> {
           if (!AbstractTableDialog.this.shell.isDisposed()) {
             AbstractTableDialog.this.display.asyncExec(
                 () -> {
                   if (!AbstractTableDialog.this.shell.isDisposed()) {
                     AbstractTableDialog.this.reloadTable();
                   }
                 });
           } else {
             // ウインドウが消えていたらタスクをキャンセルする
             throw new ThreadDeath();
           }
         };
     // タスクがある場合キャンセル
     if (AbstractTableDialog.this.future != null) {
       AbstractTableDialog.this.future.cancel(false);
     }
     // 再読み込みするようにスケジュールする
     AbstractTableDialog.this.future =
         ThreadManager.getExecutorService()
             .scheduleWithFixedDelay(command, 1, 1, TimeUnit.SECONDS);
   } else {
     // タスクがある場合キャンセル
     if (AbstractTableDialog.this.future != null) {
       AbstractTableDialog.this.future.cancel(false);
     }
   }
 }
  private void updateMenuItem() {
    final MenuItem item = (MenuItem) this.widget;

    final boolean shouldBeEnabled = isEnabled();

    // disabled command + visibility follows enablement == disposed
    if (item.isDisposed()) {
      return;
    }

    String text = this.label;
    text = updateMnemonic(text);

    final String keyBindingText = null;
    if (text != null) {
      if (keyBindingText == null) {
        item.setText(text);
      } else {
        item.setText(text + '\t' + keyBindingText);
      }
    }

    if (item.getSelection() != this.checkedState) {
      item.setSelection(this.checkedState);
    }

    if (item.getEnabled() != shouldBeEnabled) {
      item.setEnabled(shouldBeEnabled);
    }
  }
Esempio n. 3
0
 private void switchMenuSelected(SelectionEvent e) {
   MenuItem selectedItem = (MenuItem) e.widget;
   int mode = !selectedItem.getSelection() ? 2 : (selectedItem == this.groupMenuItem) ? 0 : 1;
   this.setGroupMode(mode);
   // this.shipTable.getFilterMenu().setGroupMode(this.groupMode);
   if (this.changeEnabled) {
     this.shipTable.updateFilter(this.createFilter(), true);
     this.shipTable.getShell().layout();
   }
 }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.action.ContributionItem#update(java.lang.String)
   */
  public void update(String id) {
    if (widget != null) {
      if (widget instanceof MenuItem) {
        MenuItem item = (MenuItem) widget;

        String text = label;
        if (text == null) {
          if (command != null) {
            try {
              text = command.getCommand().getName();
            } catch (NotDefinedException e) {
              WorkbenchPlugin.log(
                  "Update item failed " //$NON-NLS-1$
                      + getId(),
                  e);
            }
          }
        }
        // TODO: [bm] key bindings
        //				text = updateMnemonic(text);
        //
        //				String keyBindingText = null;
        //				if (command != null) {
        //					TriggerSequence[] bindings = bindingService
        //							.getActiveBindingsFor(command);
        //					if (bindings.length > 0) {
        //						keyBindingText = bindings[0].format();
        //					}
        //				}
        //				if (text != null) {
        //					if (keyBindingText == null) {
        item.setText(text);
        //					} else {
        //						item.setText(text + '\t' + keyBindingText);
        //					}
        //				}

        updateIcons();
        if (item.getSelection() != checkedState) {
          item.setSelection(checkedState);
        }

        boolean shouldBeEnabled = isEnabled();
        if (item.getEnabled() != shouldBeEnabled) {
          item.setEnabled(shouldBeEnabled);
        }
      } else if (widget instanceof ToolItem) {
        ToolItem item = (ToolItem) widget;

        if (icon != null) {
          updateIcons();
        } else if (label != null) {
          item.setText(label);
        }

        if (tooltip != null) item.setToolTipText(tooltip);
        else {
          String text = label;
          if (text == null) {
            if (command != null) {
              try {
                text = command.getCommand().getName();
              } catch (NotDefinedException e) {
                WorkbenchPlugin.log(
                    "Update item failed " //$NON-NLS-1$
                        + getId(),
                    e);
              }
            }
          }
          if (text != null) {
            item.setToolTipText(text);
          }
        }

        if (item.getSelection() != checkedState) {
          item.setSelection(checkedState);
        }

        boolean shouldBeEnabled = isEnabled();
        if (item.getEnabled() != shouldBeEnabled) {
          item.setEnabled(shouldBeEnabled);
        }
      }
    }
  }