org.eclipse.swt.widgets.Button.getParent()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中org.eclipse.swt.widgets.Button.getParent()方法的一些代码示例,展示了Button.getParent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.getParent()方法的具体详情如下:
包路径:org.eclipse.swt.widgets.Button
类名称:Button
方法名:getParent

Button.getParent介绍

暂无

代码示例

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
public void widgetSelected(SelectionEvent e) {
  Button button = (Button) e.widget;
  Tag tag = (Tag) button.getData("Tag");
  if (button.getGrayed()) {
    button.setGrayed(false);
    button.setSelection(!button.getSelection());
    button.getParent().redraw();
  }
  boolean doTag = button.getSelection();
  trigger.tagButtonTriggered(tag, doTag);
  button.getParent().redraw();
  button.getParent().update();
}

代码示例来源:origin: heeckhau/mousefeed

/**
 * Is called when the {@link #invocationControlEnabledCheckbox} selection
 * changed.
 */
private void onInvocationControlEnabledCheckboxSelected() {
  final Button checkbox = invocationControlEnabledCheckbox;
  for (Control c : checkbox.getParent().getChildren()) {
    if (!c.equals(invocationControlEnabledCheckbox)) {
      c.setEnabled(isInvocationControlEnabled());
    }
  }
}

代码示例来源:origin: org.eclipse/org.eclipse.help.ui

private void updateEnableState(boolean enabled) {
  Composite container = masterButton.getParent();
  Control[] children = container.getChildren();
  boolean first = disabledStates.isEmpty();
  for (int i = 0; i < children.length; i++) {
    Control child = children[i];
    if (child == masterButton)
      continue;
    if (!enabled) {
      disabledStates.put(child, new Boolean(child.isEnabled()));
      child.setEnabled(false);
    } else {
      Boolean savedState = (Boolean) disabledStates.get(child);
      if (!first)
        child.setEnabled(savedState != null ? savedState
            .booleanValue() : true);
    }
  }
}

代码示例来源:origin: BiglySoftware/BiglyBT

button.getParent().redraw();

代码示例来源:origin: org.eclipse/org.eclipse.help.ui

public void run() {
    searchWordCombo.getControl().setEnabled(!searchInProgress);
    if (!searchInProgress)
      goButton.setEnabled(true);
    if (searchInProgress)
      goButton.setText(Messages.SearchPart_stop);
    else
      goButton.setText(Messages.SearchPart_go);
    parent.getForm().getForm().setBusy(searchInProgress);
    goButton.getParent().layout();
  }
}

代码示例来源:origin: BiglySoftware/BiglyBT

public boolean updateFields(List<Taggable> taggables) {
  List<Control> layoutChanges = new ArrayList<>();
  for (Button button : buttons) {
    Tag tag = (Tag) button.getData("Tag");
    if (tag == null) {
      continue;
    }
    String name = tag.getTagName(true);
    if (!button.getText().equals(name)) {
      button.setText(name);
      layoutChanges.add(button);
    }
    updateButtonState(tag, button, taggables);
    button.getParent().redraw();
  }
  if (layoutChanges.size() > 0) {
    cMainComposite.layout(layoutChanges.toArray(new Control[0]));
    return true;
  }
  return false;
}

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
  public void runSupport() {
    if (btnAnyTags == null || btnAnyTags.isDisposed()) {
      return;
    }
    boolean show = tags != null && tags.length > 1;
    btnAnyTags.setVisible(show);
    FormData fd = Utils.getFilledFormData();
    fd.height = show ? SWT.DEFAULT : 0;
    btnAnyTags.setLayoutData(fd);
    Composite cTop = btnAnyTags.getParent();
    cTop.getParent().layout(true, true);
  }
});

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples

/**
 * Append the Set/Get API controls to the "Other" group.
 */
void createSetGetGroup() {
  /*
   * Create the button to access set/get API functionality.
   */
  final String [] methodNames = getMethodNames ();
  if (methodNames != null) {
    final Button setGetButton = new Button (otherGroup, SWT.PUSH);
    setGetButton.setText (ControlExample.getResourceString ("Set_Get"));
    setGetButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    setGetButton.addSelectionListener (widgetSelectedAdapter(e -> {
      if (getExampleWidgets().length >  0) {
        if (setGetDialog == null) {
          setGetDialog = createSetGetDialog(methodNames);
        }
        Point pt = setGetButton.getLocation();
        pt = display.map(setGetButton.getParent(), null, pt);
        setGetDialog.setLocation(pt.x, pt.y);
        setGetDialog.open();
      }
    }));
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench.texteditor

event.stateMask= e.stateMask;
if ((button.getStyle() & SWT.RADIO) != 0) {
  Composite buttonParent= button.getParent();
  if (buttonParent != null) {
    Control[] children= buttonParent.getChildren();

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.workbench.texteditor

event.stateMask= e.stateMask;
if ((button.getStyle() & SWT.RADIO) != 0) {
  Composite buttonParent= button.getParent();
  if (buttonParent != null) {
    Control[] children= buttonParent.getChildren();

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

private void showMenu(Button button, IContributionItem menuContribution) {
    Menu menu = new Menu(button);
    Point p = button.getLocation();
    p.y = p.y + button.getSize().y;
    p = button.getParent().toDisplay(p);

    menu.setLocation(p);
    menuContribution.fill(menu, 0);
    menu.setVisible(true);
  }
}

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
  public void handleEvent(Event event) {
    int idx;
    if (event.widget instanceof Composite) {
      Long l = (Long) event.widget.getData("INDEX");
      idx = l.intValue();
    } else {
      Composite c = ((Control) event.widget).getParent();
      Long l = (Long) c.getData("INDEX");
      idx = l.intValue();
    }
    for (int i = 0; i < buttons.length; i++) {
      boolean selected = idx == i;
      Composite c = buttons[i].getParent();
      c.setBackground(
          selected ? Colors.getSystemColor(c.getDisplay(), SWT.COLOR_LIST_SELECTION) : null);
      Color fg = selected ? Colors.getSystemColor(c.getDisplay(), SWT.COLOR_LIST_SELECTION_TEXT) : null;
      Control[] children = c.getChildren();
      for (int j = 0; j < children.length; j++) {
        Control control = children[j];
        control.setForeground(fg);
      }
      buttons[i].setSelection(selected);
    }
  }
};

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

/**
 * {@inheritDoc}
 * <p>
 * The implementation in {@link #Dialog} also moves the
 * {@link Shell#getDefaultButton() default button} in the
 * {@link #createButtonBar(Composite) button bar} to the right
 * if that's required by the
 * {@link Display#getDismissalAlignment() platform convention}.
 * </p>
 */
@Override
protected void initializeBounds() {
  Shell shell = getShell();
  if (shell != null) {
    if (shell.getDisplay().getDismissalAlignment() == SWT.RIGHT) {
      // make the default button the right-most button
      Button defaultButton = shell.getDefaultButton();
      if (defaultButton != null
          && isContained(buttonBar, defaultButton)) {
        defaultButton.moveBelow(null);
        defaultButton.getParent().layout();
      }
    }
  }
  super.initializeBounds();
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt.q07

void renderInitialization( Button button ) throws IOException {
 JSWriter writer = JSWriter.getWriterFor( button );
 writer.newWidget( QX_TYPE, PARAM_RADIO );
 ControlLCAUtil.writeStyleFlags( button );
 WidgetLCAUtil.writeStyleFlag( button, SWT.RADIO, "RADIO" );
 if( ( button.getParent().getStyle() & SWT.NO_RADIO_GROUP ) != 0 ) {
  writer.set( "noRadioGroup", true );
 }
 ButtonLCAUtil.writeWrap( button );
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

/**
 * {@inheritDoc}
 * <p>
 * The implementation in {@link #Dialog} also moves the
 * {@link Shell#getDefaultButton() default button} in the
 * {@link #createButtonBar(Composite) button bar} to the right
 * if that's required by the
 * {@link Display#getDismissalAlignment() platform convention}.
 * </p>
 */
@Override
protected void initializeBounds() {
  // UI guidelines:
  // https://developer.gnome.org/hig/stable/dialogs.html.en#primary-buttons
  // https://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/OSXHIGuidelines/WindowDialogs.html#//apple_ref/doc/uid/20000957-CH43-SW5
  // https://msdn.microsoft.com/en-us/library/windows/desktop/dn742499(v=vs.85).aspx#win_dialog_box_image25
  Shell shell = getShell();
  if (shell != null) {
    if (shell.getDisplay().getDismissalAlignment() == SWT.RIGHT) {
      // make the default button the right-most button
      Button defaultButton = shell.getDefaultButton();
      if (defaultButton != null
          && isContained(buttonBar, defaultButton)) {
        defaultButton.moveBelow(null);
        defaultButton.getParent().layout();
      }
    }
  }
  super.initializeBounds();
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples

final Composite parent1 = button.getParent();
Rectangle bounds = button.getBounds();
Point point = parent1.toDisplay(new Point(bounds.x, bounds.y));

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples

colorButton.addListener(SWT.Selection, event -> {
  final Button button = (Button) event.widget;
  final Composite parent1 = button.getParent();
  Rectangle bounds = button.getBounds();
  Point point = parent1.toDisplay(new Point(bounds.x, bounds.y));

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples

colorButton.addListener(SWT.Selection, event -> {
  final Button button = (Button) event.widget;
  final Composite parent1 = button.getParent();
  Rectangle bounds = button.getBounds();
  Point point = parent1.toDisplay(new Point(bounds.x, bounds.y));

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

@Override
public void renderInitialization( Button button ) throws IOException {
 RemoteObject remoteObject = createRemoteObject( button, TYPE );
 remoteObject.setHandler( new ButtonOperationHandler( button ) );
 remoteObject.set( "parent", getId( button.getParent() ) );
 remoteObject.set( "style", createJsonArray( getStyles( button, ALLOWED_STYLES ) ) );
 renderProperty( button, PROP_MARKUP_ENABLED, isMarkupEnabledFor( button ), false );
}

代码示例来源:origin: org.xworker/xworker_swt

public static void setButtonSelection(ActionContext actionContext){
  Event event = actionContext.getObject("event");
  Button button = (Button) event.widget;
  
  Composite parent = button.getParent();
  ActionContext parentContext = (ActionContext) parent.getData("parentContext");
  Thing thing = (Thing) parent.getData("thing");
  
  if(parentContext == null || thing == null){
    //当前事物并不是InjectableComposite或相应变量丢失
    return;
  }
  
  //弹出帮助小精灵,通过帮助小精灵设置子控件
  Action action = World.getInstance().getAction("xworker.ide.worldExplorer.swt.SimpleExplorer/@shell1/@mainComposite/@mainCoolBar1/@mainCollItem/@mainToolBar/@commandAssistorItem/@listeners/@openCommander/@openAssistor");
  action.run(actionContext);
  
  //连接帮助小精灵
  InteractiveUI ui = (InteractiveUI) parent.getData(InteractiveUI.DATA_KEY);
  InteractiveListener interactiveListener = Designer.getInteractiveListener(ui.getListenerName());
  if(interactiveListener != null){
    interactiveListener.connected(ui);
    ui.setInteractiveListener(interactiveListener);                        //ui.addListener();
  }
}

相关文章

Button类方法