Example #1
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();
  }
Example #2
0
  protected void createButtonComponent(ApplicationFactory factory) {
    Composite buttonComposite = new Composite(this, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    buttonComposite.setLayoutData(gridData);
    factory.setComposite(buttonComposite);

    GridLayout gridLayout = new GridLayout(3, false);
    gridLayout.marginHeight = 0;
    gridLayout.horizontalSpacing = 15;
    gridLayout.verticalSpacing = 0;
    gridLayout.marginWidth = 10;
    buttonComposite.setLayout(gridLayout);

    Composite removeComposite = new Composite(buttonComposite, SWT.NONE);
    buttonComposite.setBackground(getBackground());
    removeComposite.setLayout(new GridLayout(2, false));
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    removeComposite.setLayoutData(gridData);

    factory.setComposite(removeComposite);

    /* butRemoveAll = factory.createButton(SWT.PUSH);
    butRemoveAll.setText(factory.getResources().getLabel("menuRemoveAll"));
    butRemoveAll.addSelectionListener(new SelectionAdapter(){
      @SuppressWarnings("unused")
      public void widgetSelected(SelectionEvent evt) {
        MessageBox msg = new MessageBox (getShell(), SWT.APPLICATION_MODAL | SWT.YES | SWT.NO);
        ClientRM clientRM = new ClientRM("HTMLExplorer");
        msg.setMessage(clientRM.getLabel("remove.all.message"));
        if(msg.open() != SWT.YES) return ;
        box.removeAll();
      }
    });
    //    butRemoveAll.setVisible(false);
    butRemoveAll.setFont(UIDATA.FONT_9);

    butUp = factory.createButton(SWT.PUSH);
    butUp.setText(factory.getResources().getLabel("menuUp"));
    butUp.addSelectionListener(new SelectionAdapter(){
      @SuppressWarnings("unused")
      public void widgetSelected(SelectionEvent evt) {
        box.up();
      }
    });
    butUp.setVisible(false);
    butUp.setFont(UIDATA.FONT_9);

    butDown = factory.createButton(SWT.PUSH);
    butDown.setText(factory.getResources().getLabel("menuDown"));
    butDown.addSelectionListener(new SelectionAdapter(){
      @SuppressWarnings("unused")
      public void widgetSelected(SelectionEvent evt) {
        box.down();
      }
    });
    butDown.setVisible(false);
    butDown.setFont(UIDATA.FONT_9);*/

    lblStatus = factory.createLabel(SWT.NONE);
    lblStatus.setBackground(getBackground());
    gridData = new GridData();
    gridData.minimumWidth = 180;
    lblStatus.setLayoutData(gridData);
    lblStatus.setFont(UIDATA.FONT_10B);
    lblStatus.setForeground(getDisplay().getSystemColor(SWT.COLOR_RED));

    butRemovePath = factory.createButton(SWT.PUSH);
    butRemovePath.setText(factory.getResources().getLabel("remove.path.yes"));
    butRemovePath.addSelectionListener(
        new SelectionAdapter() {
          @SuppressWarnings("unused")
          public void widgetSelected(SelectionEvent evt) {
            if (errorPath != null) {
              box.removePath(errorPath);
              clearInformation();
            }
            showErrorPath(null);
          }
        });
    butRemovePath.setVisible(false);
    butRemovePath.setFont(UIDATA.FONT_9);

    //    Label lblSuggest = factory.createLabel(SWT.NONE);
    //    lblSuggest.setBackground(getBackground());
    //    gridData = new GridData(GridData.FILL_HORIZONTAL);
    //    //    gridData.widthHint = 305;
    //    lblSuggest.setLayoutData(gridData);
    //    lblSuggest.setFont(UIDATA.FONT_10B);
    ////    lblSuggest.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLUE));
    //    lblSuggest.setText(factory.getLabel("suggest.tip"));

    factory.setComposite(buttonComposite);

    String butTip = factory.getLabel("butOk");
    final ToolbarResource resources = ToolbarResource.getInstance();
    butOk =
        resources.createIcon(
            factory.getComposite(),
            resources.getImageGo(),
            butTip,
            new HyperlinkAdapter() {
              @SuppressWarnings("unused")
              public void linkActivated(HyperlinkEvent e) {
                butOk.setImage(resources.getImageGo());
              }

              @SuppressWarnings("unused")
              public void linkExited(HyperlinkEvent e) {
                butOk.setImage(resources.getImageGo());
              }

              @SuppressWarnings("unused")
              public void linkEntered(HyperlinkEvent e) {
                butOk.setImage(resources.getImageGo());
              }
            });
    butOk.addMouseListener(
        new MouseAdapter() {
          @SuppressWarnings("unused")
          public void mouseUp(MouseEvent e) {
            invisibleComponent();
            clickOk();
          }

          @SuppressWarnings("unused")
          public void mouseDown(MouseEvent e) {
            butOk.setImage(resources.getImageGo1());
            butOk.redraw();
          }
        });

    butTip = factory.getLabel("butCancel");
    butCancel =
        resources.createIcon(
            factory.getComposite(),
            resources.getImageCancel(),
            butTip,
            new HyperlinkAdapter() {
              @SuppressWarnings("unused")
              public void linkActivated(HyperlinkEvent e) {
                butCancel.setImage(resources.getImageCancel());
              }

              @SuppressWarnings("unused")
              public void linkExited(HyperlinkEvent e) {
                butCancel.setImage(resources.getImageCancel());
              }

              @SuppressWarnings("unused")
              public void linkEntered(HyperlinkEvent e) {
                butCancel.setImage(resources.getImageCancel());
              }
            });
    butCancel.addMouseListener(
        new MouseAdapter() {
          @SuppressWarnings("unused")
          public void mouseUp(MouseEvent e) {
            invisibleComponent();
            clickCancel();
          }

          @SuppressWarnings("unused")
          public void mouseDown(MouseEvent e) {
            butCancel.setImage(resources.getImageCancel1());
            butCancel.redraw();
          }
        });

    //    factory.setComposite(bottom);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);

    /*  String url = "";
    try {
      Preferences prefs = Preferences.userNodeForPackage(HTMLExplorer.class);
      url  = prefs.get("url.address", "");
    } catch (Exception e) {
      url = "";
    }*/
    //    toolbar.setText(url);

    //    treeAddButton = new TreeAddButton(this);
    //    viewFunctions();
  }