コード例 #1
0
  /**
   * Create contents of the dialog
   *
   * @param parent
   */
  protected Control createDialogArea(Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    final GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    container.setLayout(gridLayout);

    final Label label = new Label(container, SWT.NONE);
    label.setText("查找:");

    text = new Text(container, SWT.BORDER);
    text.addModifyListener(
        new ModifyListener() {
          public void modifyText(final ModifyEvent e) {
            searchCondition = text.getText();
            StructuredSelection sel = (StructuredSelection) listViewer.getSelection();
            Object selObj = sel.isEmpty() ? null : sel.getFirstElement();
            listViewer.refresh();
            if (selObj != null) {
              sel = new StructuredSelection(selObj);
              listViewer.setSelection(sel);
            }
          }
        });
    text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    listViewer = new ListViewer(container, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
    listViewer.setContentProvider(new ListContentProvider());
    list = listViewer.getList();
    list.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    listViewer.addDoubleClickListener(
        new IDoubleClickListener() {
          public void doubleClick(final DoubleClickEvent event) {
            StructuredSelection sel = (StructuredSelection) event.getSelection();
            if (sel.isEmpty()) {
              return;
            }
            buttonPressed(IDialogConstants.OK_ID);
          }
        });
    listViewer.setInput(ProjectData.getActiveProject());

    List<SkillConfig> selObjs = new ArrayList<SkillConfig>();
    for (int id : selectedSkills) {
      try {
        SkillConfig q =
            (SkillConfig) ProjectData.getActiveProject().findObject(SkillConfig.class, id);
        if (q != null) {
          selObjs.add(q);
        }
      } catch (Exception e) {
      }
    }
    StructuredSelection sel = new StructuredSelection(selObjs);
    listViewer.setSelection(sel);

    return container;
  }
コード例 #2
0
 public void setBuff(int id, int level) {
   BuffConfig buff = (BuffConfig) ProjectData.getActiveProject().findObject(BuffConfig.class, id);
   if (buff != null) {
     buffId = id;
     buffLevel = level;
     String text = buff.toString() + " " + level + "级";
     textID.setText(text);
     textID.setToolTipText(textID.getText());
     if (modifyListener != null) {
       modifyListener.modifyText(null);
     }
   } else {
     buffId = id;
     buffLevel = level;
     textID.setText("无");
     if (modifyListener != null) {
       modifyListener.modifyText(null);
     }
   }
 }