Ejemplo n.º 1
0
  protected void showReload() {
    if (this.reloadControl == null) {
      this.reloadControl = new Composite(this, SWT.NONE);
      this.reloadControl.setLayout(LayoutUtil.createCompositeGrid(4));

      final Label label = new Label(this.reloadControl, SWT.WRAP);
      label.setText("The structure of the R element is changed (columns / data type).");
      label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 4, 1));

      {
        final Button button = new Button(this.reloadControl, SWT.PUSH);
        button.setLayoutData(
            LayoutUtil.hintWidth(new GridData(SWT.FILL, SWT.CENTER, false, false), button));
        button.setText("Refresh");
        button.setToolTipText("Refresh table with old structure");
        button.addSelectionListener(
            new SelectionAdapter() {
              @Override
              public void widgetSelected(final SelectionEvent e) {
                refresh();
              }
            });
      }
      {
        final Button button = new Button(this.reloadControl, SWT.PUSH);
        button.setLayoutData(
            LayoutUtil.hintWidth(new GridData(SWT.FILL, SWT.CENTER, false, false), button));
        button.setText("Reopen");
        button.setToolTipText("Reopen table with new structure");
        button.addSelectionListener(
            new SelectionAdapter() {
              @Override
              public void widgetSelected(final SelectionEvent e) {
                setInput(RDataTableComposite.this.input);
              }
            });
      }
      if (this.callbacks.isCloseSupported()) {
        final Button button = new Button(this.reloadControl, SWT.PUSH);
        button.setLayoutData(
            LayoutUtil.hintWidth(new GridData(SWT.FILL, SWT.CENTER, false, false), button));
        button.setText("Close");
        button.addSelectionListener(
            new SelectionAdapter() {
              @Override
              public void widgetSelected(final SelectionEvent e) {
                RDataTableComposite.this.callbacks.close();
              }
            });
      }
      //
      LayoutUtil.addSmallFiller(this.reloadControl, true);
    }
    this.layout.topControl = this.reloadControl;
    layout(true);
  }
Ejemplo n.º 2
0
  @Override
  protected void createBlockArea(final Composite pageComposite) {
    final Map<Preference<?>, String> prefs = new HashMap<>();

    prefs.put(TaskTagsPreferences.PREF_TAGS, TaskTagsPreferences.GROUP_ID);
    prefs.put(TaskTagsPreferences.PREF_PRIORITIES, TaskTagsPreferences.GROUP_ID);

    setupPreferenceManager(prefs);

    createImages();

    { // Table area
      final Composite composite = new Composite(pageComposite, SWT.NONE);
      composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
      composite.setLayout(LayoutUtil.createCompositeGrid(2));

      final Composite table = createTable(composite);
      table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

      this.listButtons =
          new ButtonGroup<TaskTag>(composite) {
            @Override
            protected TaskTag edit1(
                final TaskTag item, final boolean newItem, final Object parent) {
              final TaskTagsInputDialog dialog =
                  new TaskTagsInputDialog(
                      getShell(), item, newItem, TaskTagsConfigurationBlock.this.list);
              if (dialog.open() == Dialog.OK) {
                return dialog.getResult();
              }
              return null;
            }

            @Override
            public void updateState() {
              super.updateState();
              saveTaskTags();
            }
          };
      this.listButtons.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, true));
      this.listButtons.addAddButton(null);
      this.listButtons.addCopyButton(null);
      this.listButtons.addEditButton(null);
      this.listButtons.addDeleteButton(null);
      this.listButtons.addSeparator();
      this.listButtons.addDefaultButton(null);

      this.listButtons.connectTo(this.listViewer, this.list, this.defaultValue);
      this.listViewer.setInput(this.list);
    }

    updateControls();
  }
Ejemplo n.º 3
0
  @Override
  protected void createContent(final Composite parent) {
    this.contentComposite =
        new Composite(parent, SWT.NONE) {
          @Override
          public Point computeSize(final int width, final int height, final boolean changed) {
            return super.computeSize(width, height, changed || width != getSize().x);
          }
        };
    this.contentComposite.setBackgroundMode(SWT.INHERIT_FORCE);

    final GridLayout gridLayout = LayoutUtil.createCompositeGrid(2);
    gridLayout.horizontalSpacing = (int) ((gridLayout.horizontalSpacing) / 1.5);
    this.contentComposite.setLayout(gridLayout);

    final int vIndent = Math.max(1, LayoutUtil.defaultVSpacing() / 4);
    final int hIndent = Math.max(3, LayoutUtil.defaultHSpacing() / 2);

    { // Title image
      this.titleImage = new Label(this.contentComposite, SWT.NULL);
      final Image image = SharedUIResources.getImages().get(SharedUIResources.PLACEHOLDER_IMAGE_ID);
      this.titleImage.setImage(image);

      final GridData textGd = new GridData(SWT.FILL, SWT.TOP, false, false);
      this.titleText =
          new StyledText(this.contentComposite, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP) {
            @Override
            public Point computeSize(int width, final int height, final boolean changed) {
              if (!RElementInfoControl.this.layoutHint
                  && width <= 0
                  && RElementInfoControl.this.contentComposite.getSize().x > 0) {
                width =
                    RElementInfoControl.this.contentComposite.getSize().x
                        - LayoutUtil.defaultHMargin()
                        - RElementInfoControl.this.titleImage.getSize().x
                        - LayoutUtil.defaultHSpacing()
                        - 10;
              }

              final Point size = super.computeSize(width, -1, true);
              //					if (width >= 0) {
              //						size.x= Math.min(size.x, width);
              //					}
              return size;
            }
          };

      this.titleText.setFont(JFaceResources.getDialogFont());
      final GC gc = new GC(this.titleText);
      final FontMetrics fontMetrics = gc.getFontMetrics();
      final GridData imageGd = new GridData(SWT.FILL, SWT.TOP, false, false);
      imageGd.horizontalIndent = hIndent;
      final int textHeight = fontMetrics.getAscent() + fontMetrics.getLeading();
      final int imageHeight = image.getBounds().height;
      final int shift = Math.max(3, (int) ((fontMetrics.getDescent()) / 1.5));
      if (textHeight + shift < imageHeight) {
        imageGd.verticalIndent = vIndent + shift;
        textGd.verticalIndent = vIndent + (imageHeight - textHeight);
      } else {
        imageGd.verticalIndent = vIndent + (textHeight - imageHeight) + shift;
        textGd.verticalIndent = vIndent;
      }
      this.titleImage.setLayoutData(imageGd);
      this.titleText.setLayoutData(textGd);
      this.layoutWorkaround = true;

      gc.dispose();
    }

    this.infoText =
        new StyledText(
            this.contentComposite,
            this.mode == MODE_FOCUS
                ? (SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL)
                : (SWT.MULTI | SWT.READ_ONLY));
    this.infoText.setIndent(hIndent);
    this.infoText.setFont(JFaceResources.getFont(PREF_DETAIL_PANE_FONT));

    final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
    //		gd.widthHint= LayoutUtil.hintWidth(fInfoText, INFO_FONT, 50);
    this.infoText.setLayoutData(gd);

    setBackgroundColor(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    setForegroundColor(getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));

    if ((this.mode & MODE_FOCUS) != 0) {
      final ToolBarManager toolBarManager = getToolBarManager();
      contributeToActionBars(PlatformUI.getWorkbench(), toolBarManager, null);
    }

    updateInput();
  }