public DeleteContentsDialog(Browser _browser, String domain, String[] _ids, String[] titles) {
    this.domain = domain;
    this.browser = _browser;
    this.ids = _ids;
    shell = new Shell(browser.getShell(), SWT.CLOSE | SWT.RESIZE | SWT.APPLICATION_MODAL);
    ClientRM clientRM = DeleteDomainPlugin.getResources();
    ApplicationFactory factory = new ApplicationFactory(shell, clientRM, getClass().getName());
    shell.setText(factory.getLabel("title"));
    factory.setComposite(shell);
    shell.setLayout(new GridLayout(1, false));

    shell.addShellListener(
        new ShellAdapter() {
          public void shellClosed(ShellEvent e) {
            new ShellSetter(DeleteContentsDialog.class, shell);
            shell.dispose();
          }
        });

    factory.setComposite(shell);

    RefsDecoder decoder = new RefsDecoder();

    butTitles = new Button[titles.length];
    //    selectors = new DeleteSingleArticleSelector[10];
    for (int i = 0; i < butTitles.length; i++) {
      titles[i] = new String(decoder.decode(titles[i].toCharArray()));
      butTitles[i] = new Button(shell, SWT.CHECK);
      butTitles[i].setSelection(true);
      butTitles[i].setToolTipText(clientRM.getLabel("itemDeleteTooltip"));
      butTitles[i].setText(titles[i]);
      butTitles[i].setLayoutData(new GridData());
    }

    Composite bottom = new Composite(shell, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    // gridData.horizontalSpan = 2;
    bottom.setLayoutData(gridData);
    RowLayout rowLayout = new RowLayout();
    bottom.setLayout(rowLayout);
    rowLayout.justify = true;
    factory.setComposite(bottom);

    factory.createButton(
        "butDeletDomain",
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent evt) {
            deleteDomain();
          }
        });

    SelectionAdapter syncListener =
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent evt) {
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < ids.length; i++) {
              if (!butTitles[i].getSelection()) continue;
              if (builder.length() > 0) builder.append('\n');
              builder.append(ids[i]);
            }
            DeleteContentPlugin.delete(browser, builder.toString());
            shell.dispose();
          }
        };

    factory.createButton("butOk", syncListener);

    factory.createButton(
        "butClose",
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent evt) {
            new ShellSetter(DeleteContentsDialog.class, shell);
            shell.dispose();
          }
        });

    Rectangle displayRect = UIDATA.DISPLAY.getBounds();
    int x = (displayRect.width - 350) / 2;
    int y = (displayRect.height - 300) / 2;
    shell.setImage(browser.getShell().getImage());
    new ShellGetter(DeleteContentsDialog.class, shell, 550, 350, x, y);
    shell.open();
  }
示例#2
0
  public RenameDialog(Shell parent, SourcesHandler handler, CopySource copy) {
    dialog = new Shell(parent, SWT.DIALOG_TRIM | SWT.CLOSE | SWT.APPLICATION_MODAL);
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = 10;
    formLayout.marginHeight = 10;
    formLayout.spacing = 10;
    dialog.setLayout(formLayout);

    this.copySource = copy;
    this.handler = handler;

    ApplicationFactory factory = new ApplicationFactory(dialog, "Creator", getClass().getName());

    Label label = factory.createLabel("name"); // new Label (dialog, SWT.NONE);
    FormData data = new FormData();
    label.setLayoutData(data);

    Button cancel = factory.createButton("cancel");
    data = new FormData();
    data.width = 60;
    data.right = new FormAttachment(100, 0);
    data.bottom = new FormAttachment(100, 0);
    cancel.setLayoutData(data);
    cancel.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("unused")
          public void widgetSelected(SelectionEvent e) {
            dialog.close();
          }
        });

    final Text text = new Text(dialog, SWT.BORDER);
    text.setText(copySource.getSrcNames()[0]);
    data = new FormData();
    data.width = 200;
    data.left = new FormAttachment(label, 0, SWT.DEFAULT);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(label, 0, SWT.CENTER);
    data.bottom = new FormAttachment(cancel, 0, SWT.DEFAULT);
    text.setLayoutData(data);

    Button ok = new Button(factory.getComposite(), SWT.PUSH);
    ;
    ok.setText("Ok");
    data = new FormData();
    data.width = 60;
    data.right = new FormAttachment(cancel, 0, SWT.DEFAULT);
    data.bottom = new FormAttachment(100, 0);
    ok.setLayoutData(data);
    ok.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("unused")
          public void widgetSelected(SelectionEvent e) {
            rename(text.getText());
          }
        });

    Rectangle displayRect = UIDATA.DISPLAY.getBounds();
    int x = (displayRect.width - 350) / 2;
    int y = (displayRect.height - 300) / 2;
    dialog.setImage(parent.getImage());
    dialog.setLocation(x, y);

    dialog.setDefaultButton(ok);
    dialog.pack();
    //    XPWindowTheme.setWin32Theme(dialog);
    dialog.open();
  }