/*
   * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
   */
  public void createControl(Composite parent) {

    WidgetFactory factory = getWidgetFactory();

    final int gridDataStyle = GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL;
    final GridData fieldGridData = new GridData(gridDataStyle);

    Composite container = new Composite(parent, SWT.NULL);
    container.setBackground(parent.getBackground());
    container.setForeground(parent.getForeground());
    container.setLayout(new GridLayout(2, false));
    container.setLayoutData(fieldGridData);

    Label label = null;

    // Format code
    label = new Label(container, SWT.NULL);
    label.setText(Messages.getString("aaa.mdf.metadict.entity.sqlname.label"));
    label.setBackground(container.getBackground());
    mdSQLName = factory.createText(container, null);
    mdSQLName.setLayoutData(fieldGridData);
    mdSQLName.setEditable(false);

    // Format Finantial Function
    label = new Label(container, SWT.NULL);
    label.setText(Messages.getString("aaa.mdf.metadict.entity.name.label"));
    label.setBackground(container.getBackground());
    mdName = factory.createText(container, null);
    mdName.setLayoutData(fieldGridData);
    mdName.setEditable(false);

    initialize();
    setControl(container);
  }
  protected Control createListChangeControl(Composite parent) {
    GridData gd;
    Control control;
    if (composite == null) composite = new Composite(parent, SWT.NONE);
    composite.setBackground(parent.getBackground());
    GridLayout gridLayout = new GridLayout(3, false);
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.horizontalSpacing = 0;
    gridLayout.verticalSpacing = 0;
    composite.setLayout(gridLayout);

    Control listControl = createListControl(composite);
    gd = new GridData(GridData.FILL_BOTH);
    listControl.setLayoutData(gd);

    control = new Label(composite, SWT.NONE);
    control.setBackground(parent.getBackground());
    gd = new GridData();
    gd.widthHint = 5;
    control.setLayoutData(gd);

    control = getChangeControl(composite);

    return composite;
  }
  public Composite createControl(final Composite parent) {
    // Form form=tk.createForm(parent);
    // form.setLayoutData(SWTHelper.getFillGridData(1,true,1,false));
    // Composite ret=form.getBody();
    Composite ret = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;
    ret.setLayout(layout);
    ret.setBackground(parent.getBackground());

    ImageHyperlink hClr = tk.createImageHyperlink(ret, SWT.NONE); // $NON-NLS-1$
    hClr.setImage(Images.IMG_CLEAR.getImage());
    hClr.addHyperlinkListener(
        new HyperlinkAdapter() {

          @Override
          public void linkActivated(final HyperlinkEvent e) {
            clearValues();
          }
        });
    hClr.setBackground(parent.getBackground());

    Composite inner = new Composite(ret, SWT.NONE);
    GridLayout lRet = new GridLayout(fields.length, true);
    inner.setLayout(lRet);
    inner.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));

    for (String l : fields) {
      Hyperlink hl = tk.createHyperlink(inner, l, SWT.NONE);
      hl.addHyperlinkListener(
          new HyperlinkAdapter() {

            @Override
            public void linkActivated(final HyperlinkEvent e) {
              Hyperlink h = (Hyperlink) e.getSource();
              fireSortEvent(h.getText());
            }
          });
      hl.setBackground(parent.getBackground());
    }

    createSelectors(fields.length);
    for (int i = 0; i < selectors.length; i++) {
      selectors[i] = new ElexisText(tk.createText(inner, "", SWT.BORDER)); // $NON-NLS-1$
      selectors[i].addModifyListener(ml);
      selectors[i].addSelectionListener(sl);
      selectors[i].setToolTipText(
          Messages.getString("DefaultControlFieldProvider.enterFilter")); // $NON-NLS-1$
      selectors[i].setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
      SWTHelper.setSelectOnFocus((Text) selectors[i].getWidget());
    }

    return ret;
  }
  /**
   * Create the controls for selecting the controls we are going to export.
   *
   * @param workArea
   */
  private void createSettingsControls(Composite workArea) {
    final FormToolkit toolkit = new FormToolkit(workArea.getDisplay());
    workArea.addDisposeListener(e -> toolkit.dispose());
    final ScrolledForm form = toolkit.createScrolledForm(workArea);
    form.setBackground(workArea.getBackground());
    form.getBody().setLayout(new GridLayout());

    GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
    form.setLayoutData(layoutData);
    final ExpandableComposite expandable =
        toolkit.createExpandableComposite(form.getBody(), ExpandableComposite.TWISTIE);
    expandable.setText(IDEWorkbenchMessages.ChooseWorkspaceWithSettingsDialog_SettingsGroupName);
    expandable.setBackground(workArea.getBackground());
    expandable.setLayout(new GridLayout());
    expandable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    expandable.addExpansionListener(
        new IExpansionListener() {

          boolean notExpanded = true;

          @Override
          public void expansionStateChanged(ExpansionEvent e) {
            form.reflow(true);
            if (e.getState() && notExpanded) {
              getShell().setRedraw(false);
              Rectangle shellBounds = getShell().getBounds();
              int entriesToShow = Math.min(4, SettingsTransfer.getSettingsTransfers().length);

              shellBounds.height +=
                  convertHeightInCharsToPixels(entriesToShow) + IDialogConstants.VERTICAL_SPACING;
              getShell().setBounds(shellBounds);
              getShell().setRedraw(true);
              notExpanded = false;
            }
          }

          @Override
          public void expansionStateChanging(ExpansionEvent e) {
            // Nothing to do here

          }
        });

    Composite sectionClient = toolkit.createComposite(expandable);
    sectionClient.setLayout(new GridLayout());
    sectionClient.setBackground(workArea.getBackground());

    if (createButtons(toolkit, sectionClient)) expandable.setExpanded(true);

    expandable.setClient(sectionClient);
  }
Esempio n. 5
0
  @Override
  protected Control createDialogArea(Composite parent) {
    updateTitle();
    final Composite composite = (Composite) super.createDialogArea(parent);
    composite.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE));
    final ScrolledComposite scrolledComposite =
        new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComposite.setBackground(composite.getBackground());
    scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setExpandHorizontal(true);

    final Composite content = new Composite(scrolledComposite, SWT.NONE);
    content.setBackground(composite.getBackground());
    GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(content);
    GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(content);

    try {
      if (view == null) {
        ECPSWTViewRenderer.INSTANCE.render(content, selection);
      } else {
        ECPSWTViewRenderer.INSTANCE.render(content, selection, view);
      }
    } catch (final ECPRendererException ex) {
      Activator.log(ex);
    }

    scrolledComposite.setContent(content);
    final Point point = content.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    content.setSize(point);
    scrolledComposite.setMinSize(point);

    objectChangeAdapter =
        new AdapterImpl() {

          /**
           * {@inheritDoc}
           *
           * @see
           *     org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification)
           */
          @Override
          public void notifyChanged(Notification msg) {
            super.notifyChanged(msg);
            updateTitle();
          }
        };
    selection.eAdapters().add(objectChangeAdapter);

    return composite;
  }
  /**
   * @param parent
   * @return
   */
  public Control createContents(Composite parent) {
    final FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    ScrolledForm sf = toolkit.createScrolledForm(parent);
    Composite comp = sf.getForm().getBody();
    comp.setLayout(new GridLayout(1, true));
    comp.setBackground(parent.getBackground());

    Section brandSection = toolkit.createSection(comp, Section.TITLE_BAR);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    brandSection.setLayoutData(gridData);
    brandSection.setText("Supported Interaction Types");

    Table table = new Table(comp, SWT.BORDER | SWT.FULL_SELECTION | SWT.CHECK | SWT.SINGLE);
    table.setHeaderVisible(true);
    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(1));
    table.setLayout(layout);
    TableColumn column = new TableColumn(table, SWT.NONE);
    column.setText("Interaction Type");
    column.setWidth(100);
    column.setResizable(true);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.heightHint = 200;
    table.setLayoutData(gd);

    viewer = new CheckboxTableViewer(table);
    viewer.setContentProvider(new InteractionTypeContentProvider());
    InteractionTypeLabelProvider labelProvider = new InteractionTypeLabelProvider();
    viewer.setLabelProvider(labelProvider);
    viewer.setCheckStateProvider(labelProvider);
    viewer.addCheckStateListener(this);
    viewer.setInput(this);

    return comp;
  }
Esempio n. 7
0
  public TreeMapLegend(
      Composite parent,
      TreeMap<TaxonomyNode> treeMap,
      TaxonomyModel model,
      TaxonomyNodeRenderer renderer) {
    super(parent, SWT.NONE);

    this.model = model;
    this.renderer = renderer;

    setBackground(parent.getBackground());

    RowLayout layout = new RowLayout(SWT.HORIZONTAL);
    layout.wrap = true;
    layout.pack = true;
    layout.justify = false;
    setLayout(layout);

    treeMap.addSelectionChangeListener(
        new ISelectionChangeListener<TaxonomyNode>() {
          @Override
          public void selectionChanged(
              ITreeModel<IRectangle<TaxonomyNode>> model,
              IRectangle<TaxonomyNode> rectangle,
              String label) {
            TreeMapLegend.this.selectionChanged(model);
          }
        });
  }
  /** @param form2 */
  private Composite getPageHeader(Composite parent) {
    final Composite header = new Composite(parent, SWT.FILL);
    final FormLayout layout = new FormLayout();
    layout.marginHeight = 5;
    layout.marginWidth = 5;
    header.setLayout(layout);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(header);

    header.setBackground(parent.getBackground());

    final Label titleImage = new Label(header, SWT.FILL);
    final ImageDescriptor imageDescriptor =
        ImageDescriptor.createFromURL(
            Activator.getDefault().getBundle().getResource("icons/view.png")); // $NON-NLS-1$
    titleImage.setImage(new Image(parent.getDisplay(), imageDescriptor.getImageData()));
    final FormData titleImageData = new FormData();
    final int imageOffset = -titleImage.computeSize(SWT.DEFAULT, SWT.DEFAULT).y / 2;
    titleImageData.top = new FormAttachment(50, imageOffset);
    titleImageData.left = new FormAttachment(0, 10);
    titleImage.setLayoutData(titleImageData);

    final Label title = new Label(header, SWT.WRAP);
    title.setText("View Editor"); // $NON-NLS-1$
    titleFont = new Font(title.getDisplay(), getDefaultFontName(title), 12, SWT.BOLD);
    title.setFont(titleFont);
    title.setForeground(getTitleColor(parent));
    final FormData titleData = new FormData();
    title.setLayoutData(titleData);
    titleData.left = new FormAttachment(titleImage, 5, SWT.DEFAULT);

    return header;
  }
Esempio n. 9
0
 @Override
 public void createPartControl(Composite parent) {
   this.parent = parent;
   backgroundColor = parent.getBackground();
   new SyncViewDropTarget(this, parent);
   if (instance.current() == null) setDefaultName();
 }
  private void createLabel(Composite c, int span, String content, Image image, LabelAttributes la) {
    if (content == null && image == null) return;

    Label l = new Label(c, la.getFontStyle());
    GridData gd = new GridData();
    gd.verticalSpan = span;
    gd.horizontalIndent = 5;
    if (content != null) l.setText(content);

    if (image != null) l.setImage(image);
    if (la.getForegroundColor() != null)
      l.setForeground(new Color(DisplayManager.getDefaultDisplay(), la.getForegroundColor()));

    Font initialFont = l.getFont();
    FontData[] fontData = initialFont.getFontData();
    for (int i = 0; i < fontData.length; i++) {
      fontData[i].setHeight(la.getFontSize());
      fontData[i].setStyle(la.getFontStyle());
    }
    Font newFont = new Font(DisplayManager.getDefaultDisplay(), fontData[0]);
    l.setFont(newFont);
    l.pack();

    l.setBackground(c.getBackground());
    l.setLayoutData(gd);
  }
  private void updateLink() {
    if (meControl != null) {
      meControl.dispose();
    }
    if (labelWidget != null) {
      labelWidget.dispose();
    }

    EObject opposite = (EObject) getModelElement().eGet(eReference);
    if (opposite != null) {
      MELinkControlFactory meLinkControlFactory = new MELinkControlFactory();
      meControl =
          meLinkControlFactory.createMELinkControl(
              getItemPropertyDescriptor(), opposite, getModelElement(), getContext());
      meControl.createControl(
          linkArea,
          style,
          getItemPropertyDescriptor(),
          opposite,
          getModelElement(),
          getToolkit(),
          getContext());
    } else {
      labelWidget = getToolkit().createLabel(linkArea, "(Not Set)");
      labelWidget.setBackground(parent.getBackground());
      labelWidget.setForeground(parent.getShell().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
    }
    linkArea.layout(true);
    composite.layout(true);
  }
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite panel = new Composite(parent, SWT.NONE);
    panel.setLayout(new GridLayout());
    GridData panelData = new GridData(GridData.FILL_BOTH);
    panel.setLayoutData(panelData);

    Group selectedGroup =
        WidgetFactory.createGroup(
            panel, "Selected Translator", GridData.FILL_HORIZONTAL); // $NON-NLS-1$
    selectedGroup.setLayout(new GridLayout(2, false));

    this.translatorNameText =
        WidgetFactory.createTextField(selectedGroup, GridData.FILL_HORIZONTAL, UNDEFINED);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = convertHeightInCharsToPixels(1);
    this.translatorNameText.setLayoutData(data);
    this.translatorNameText.setEditable(false);
    this.translatorNameText.setBackground(panel.getBackground());
    this.translatorNameText.setText(UNDEFINED);

    super.createDialogArea(panel);

    this.statusMessageLabel = new MessageLabel(panel);
    GridData statusData = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = convertHeightInCharsToPixels(1);
    this.statusMessageLabel.setLayoutData(statusData);
    this.statusMessageLabel.setEnabled(false);
    this.statusMessageLabel.setText(UNDEFINED);

    getTreeViewer().expandToLevel(3);

    return panel;
  }
  void resize() {
    Point size = comp.getSize();
    Image oldBackgroundImage = backgroundImage;
    backgroundImage = new Image(comp.getDisplay(), size.x, size.y);
    GC gc = new GC(backgroundImage);
    comp.getParent().drawBackground(gc, 0, 0, size.x, size.y, 0, 0);
    Color background = comp.getBackground();
    Color border = comp.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
    RGB backgroundRGB = background.getRGB();
    // TODO naive and hard coded, doesn't deal with high contrast, etc.
    Color gradientTop =
        new Color(
            comp.getDisplay(),
            backgroundRGB.red + 12,
            backgroundRGB.green + 10,
            backgroundRGB.blue + 10);
    int h = size.y;
    int curveStart = 0;
    int curve_width = 5;

    int[] curve =
        new int[] {
          0, h, 1, h, 2, h - 1, 3, h - 2, 3, 2, 4, 1, 5, 0,
        };
    int[] line1 = new int[curve.length + 4];
    int index = 0;
    int x = curveStart;
    line1[index++] = x + 1;
    line1[index++] = h;
    for (int i = 0; i < curve.length / 2; i++) {
      line1[index++] = x + curve[2 * i];
      line1[index++] = curve[2 * i + 1];
    }
    line1[index++] = x + curve_width;
    line1[index++] = 0;

    int[] line2 = new int[line1.length];
    index = 0;
    for (int i = 0; i < line1.length / 2; i++) {
      line2[index] = line1[index++] - 1;
      line2[index] = line1[index++];
    }

    // custom gradient
    gc.setForeground(gradientTop);
    gc.setBackground(background);
    gc.drawLine(4, 0, size.x, 0);
    gc.drawLine(3, 1, size.x, 1);
    gc.fillGradientRectangle(2, 2, size.x - 2, size.y - 3, true);
    gc.setForeground(background);
    gc.drawLine(2, size.y - 1, size.x, size.y - 1);
    gradientTop.dispose();

    gc.setForeground(border);
    gc.drawPolyline(line2);
    gc.dispose();
    comp.setBackgroundImage(backgroundImage);
    if (oldBackgroundImage != null) oldBackgroundImage.dispose();
  }
  /**
   * Creates the {@link #type} selection widget for changing the type of the current <code>
   * AdaptiveTreeComposite</code>. These widgets are
   *
   * @param client The client <code>Composite</code> that should contain the type selection widgets.
   * @return The <code>Composite</code> that contains the type selection widgets.
   */
  private Composite createTypeComposite(Composite client) {

    // Get the client's background color.
    Color backgroundColor = client.getBackground();

    // Create the type sub-section Composite that will contain the
    // type label and combo (dropdown).
    Composite typeComposite = new Composite(client, SWT.NONE);
    typeComposite.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, true));
    typeComposite.setBackground(backgroundColor);

    // Set the layout of the Composite to a vertical fill layout.
    // This ensures the type Label is above the Combo and that both
    // consume all available space.
    FillLayout typeCompositeLayout = new FillLayout(SWT.VERTICAL);
    typeCompositeLayout.marginHeight = 5;
    typeCompositeLayout.marginWidth = 3;
    typeCompositeLayout.spacing = 5;
    typeComposite.setLayout(typeCompositeLayout);

    // Add the type Label and an empty Combo.
    Label typeLabel = new Label(typeComposite, SWT.NONE);
    typeLabel.setText("Type:");
    typeLabel.setBackground(backgroundColor);

    // Create the ComboViewer for selecting the adaptive type.
    type = new ComboViewer(typeComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
    type.getCombo().setBackground(backgroundColor);
    // Use an ArrayContentProvider so we can set the List of type Strings as
    // input to the ComboViewer.
    type.setContentProvider(ArrayContentProvider.getInstance());
    // The labels for each value should just be their String value.
    type.setLabelProvider(
        new LabelProvider() {
          @Override
          public String getText(Object element) {
            return (element != null ? element.toString() : "");
          }
        });

    // Add a listener to set the type of the AdaptiveTreeComposite when the
    // Combo's selection changes.
    ISelectionChangedListener listener =
        new ISelectionChangedListener() {
          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
              IStructuredSelection s = (IStructuredSelection) selection;
              String type = (String) s.getFirstElement();
              ((AdaptiveTreeComposite) tree).setType(type);
            }
          }
        };
    type.addSelectionChangedListener(listener);

    return typeComposite;
  }
 public ContextComposite(
     Composite parent, IContextManager contextManager, boolean isRepositoryContext) {
   super(parent, SWT.NONE);
   this.contextManager = contextManager;
   this.isRepositoryContext = isRepositoryContext;
   this.setBackground(parent.getBackground());
   this.setLayout(new GridLayout());
   initializeUI();
 }
 /**
  * Creates gradientLabel
  *
  * @see
  *     org.eclipse.jface.viewers.DialogCellEditor#createContents(org.eclipse.swt.widgets.Composite)
  */
 protected Control createContents(Composite cell) {
   Color bg = cell.getBackground();
   composite = new Composite(cell, getStyle());
   composite.setBackground(bg);
   composite.setLayout(new GradientCellLayout());
   gradientLabel = new Label(composite, SWT.LEFT);
   gradientLabel.setBackground(bg);
   gradientLabel.setFont(cell.getFont());
   return composite;
 }
  protected Control createContents(Composite parent) {
    Composite composite = createScrolledComposite(parent);

    String description = Messages.JSFPreferences_RootPage_Description;
    Text text = new Text(composite, SWT.READ_ONLY);
    // some themes on GTK have different background colors for Text and Labels
    text.setBackground(composite.getBackground());
    text.setText(description);

    setSize(composite);
    return composite;
  }
  /**
   * Creates the templates viewer.
   *
   * @param composite the composite
   */
  private void createTemplatesViewer(Composite composite) {
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
    templateTableViewer = CheckboxTableViewer.newCheckList(composite, SWT.NO_BACKGROUND);
    templateTableViewer.getTable().setBackground(composite.getBackground());
    templateTableViewer.getTable().setLayoutData(data);
    templateTableViewer.getTable().setEnabled(true);

    templateTableViewer.setContentProvider(new ModelTemplatesContentProvider());
    templateTableViewer.setLabelProvider(new ModelTemplatesLabelProvider());
    templateTableViewer.getControl().setEnabled(true);

    templateTableViewer.getTable().setLayout(new GridLayout());
  }
    private Composite createComposite() {
      final Composite parent = getDetailContainer();
      final Composite composite = new Composite(parent, SWT.NONE);
      composite.setBackground(parent.getBackground());

      final GridLayout gridLayout = GridLayoutFactory.fillDefaults().create();
      // gridLayout.marginTop = 7;
      // gridLayout.marginLeft = 5;
      composite.setLayout(gridLayout);
      GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(composite);
      // .indent(10, 10)
      composite.layout(true, true);
      return composite;
    }
  public void createControl(Composite parent) {
    viewer = new GalleryViewer();

    EditDomain editDomain = new EditDomain();
    editDomain.installTool(GEF.TOOL_SELECT, new TemplateGallerySelectTool());
    viewer.setEditDomain(editDomain);

    Properties properties = viewer.getProperties();
    properties.set(GalleryViewer.Horizontal, Boolean.TRUE);
    properties.set(GalleryViewer.Wrap, Boolean.TRUE);
    properties.set(GalleryViewer.TitlePlacement, GalleryViewer.TITLE_BOTTOM);
    properties.set(GalleryViewer.SingleClickToOpen, Boolean.TRUE);
    properties.set(GalleryViewer.SolidFrames, true);
    properties.set(GalleryViewer.FlatFrames, true);
    properties.set(GalleryViewer.ImageConstrained, true);
    properties.set(GalleryViewer.ImageStretched, true);
    properties.set(
        GalleryViewer.Layout,
        new GalleryLayout(
            GalleryLayout.ALIGN_CENTER,
            GalleryLayout.ALIGN_TOPLEFT,
            10,
            10,
            new Insets(5, 15, 5, 15)));
    properties.set(GalleryViewer.FrameContentSize, new Dimension(FRAME_WIDTH, FRAME_HEIGHT));
    properties.set(GalleryViewer.ContentPaneBorderWidth, 1);
    properties.set(GalleryViewer.ContentPaneBorderColor, ColorUtils.getColor("#cccccc"));

    Control control = viewer.createControl(parent);
    control.setBackground(parent.getBackground());
    control.setForeground(parent.getForeground());

    viewer.setLabelProvider(new TemplateLabelProvider());

    viewer.setInput(getViewerInput());

    viewer.addOpenListener(
        new IOpenListener() {
          public void open(OpenEvent event) {
            if (normalOrEditMode) {
              if (!templateOpening) handleTemplateSelected(event.getSelection());
            }
          }
        });

    MindMapUI.getResourceManager().addResourceManagerListener(this);

    setControl(control);
  }
 /**
  * Constructor.
  *
  * @param parent
  * @param style
  */
 public ContextNebulaGridComposite(Composite parent, IContextModelManager manager) {
   super(parent, SWT.NONE);
   modelManager = manager;
   buttonList = new ArrayList<Button>();
   this.helper = new ContextManagerHelper(manager.getContextManager());
   this.setLayout(GridLayoutFactory.swtDefaults().spacing(0, 0).create());
   initializeUI();
   // for bug TDI-32674 to set different bgColor of ContextView and RepositoryContextComposite.
   if (modelManager instanceof ContextComposite
       && ((ContextComposite) modelManager).isRepositoryContext()) {
     this.setBackground(parent.getBackground());
   } else {
     // CSS
     CoreUIPlugin.setCSSClass(this, this.getClass().getSimpleName());
   }
 }
Esempio n. 22
0
  @Override
  public Composite createControl(Composite parent, DashboardResources resources) {
    Composite heading = new Composite(parent, SWT.NONE);
    heading.setBackground(parent.getBackground());
    FillLayout layout = new FillLayout();
    layout.marginWidth = 5;
    layout.marginHeight = 10;
    heading.setLayout(layout);

    title = new Label(heading, SWT.NONE);
    title.setFont(resources.getBoldFont());
    title.setForeground(resources.getHeadingColor());
    title.setText(getWidget().getLabel());

    return heading;
  }
  /**
   * Creates the composite holding the details.
   *
   * @param parent the parent
   * @return the right panel/detail composite
   */
  protected ScrolledComposite createRightPanelContent(Composite parent) {
    rightPanel = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
    rightPanel.setShowFocusedControl(true);
    rightPanel.setExpandVertical(true);
    rightPanel.setExpandHorizontal(true);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(rightPanel);
    rightPanel.setLayout(GridLayoutFactory.fillDefaults().create());
    rightPanel.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));

    container = new Composite(rightPanel, SWT.FILL);
    container.setLayout(GridLayoutFactory.fillDefaults().create());
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(container);
    container.setBackground(rightPanel.getBackground());

    /* The header */
    final Composite header = new Composite(container, SWT.FILL);
    final GridLayout headerLayout = GridLayoutFactory.fillDefaults().create();
    headerLayout.marginWidth = 5;
    header.setLayout(headerLayout);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(header);
    header.setBackground(rightPanel.getBackground());

    final Label label = new Label(header, SWT.WRAP);
    label.setText("Details"); // $NON-NLS-1$
    detailsFont = new Font(label.getDisplay(), getDefaultFontName(label), 10, SWT.BOLD);
    label.setFont(detailsFont);
    label.setForeground(getTitleColor(parent));
    label.setBackground(header.getBackground());

    rightPanelContainerComposite = new Composite(container, SWT.FILL);
    rightPanelContainerComposite.setLayout(GridLayoutFactory.fillDefaults().create());
    GridDataFactory.fillDefaults()
        .align(SWT.FILL, SWT.FILL)
        .grab(true, true)
        .applyTo(rightPanelContainerComposite);
    rightPanelContainerComposite.setBackground(rightPanel.getBackground());

    rightPanel.setContent(container);

    rightPanel.layout();
    container.layout();

    final Point point = container.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    rightPanel.setMinSize(point);

    return rightPanel;
  }
 public DateControl(Composite parent) {
   super(parent, SWT.NONE);
   setBackground(parent.getBackground());
   GridLayout layout = UIUtil.gridLayout(this, 2, 0, 0);
   layout.horizontalSpacing = 1;
   text = UIUtil.newText(this, "", new TextChanged());
   UIControlUtil.increaseFontSize(text, -2);
   GridData gd = new GridData();
   gd.widthHint = 50;
   text.setLayoutData(gd);
   button =
       UIUtil.newImageButton(
           this,
           SharedImages.getImage(SharedImages.icons.x16.basic.CALENDAR_POPUP),
           new ButtonListener(),
           null);
 }
 protected void setInvalid(String message, Control... controls) {
   // restore the old color on all previous error composites
   for (Composite composite : currentErrorComposites.keySet()) {
     composite.setBackground(currentErrorComposites.get(composite));
   }
   currentErrorComposites.clear();
   // set the red error color on all new composites for each control
   for (Control control : controls) {
     if (errorBorderComposites.containsKey(control)) {
       Composite composite = errorBorderComposites.get(control);
       currentErrorComposites.put(composite, composite.getBackground());
       composite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
     }
   }
   setErrorMessage(message);
   setValid(false);
 }
Esempio n. 26
0
 /**
  * Creates a link.
  *
  * @param parent
  * @param text
  * @param tooltip
  * @param url
  */
 private void createLink(Composite parent, String text, String tooltip, final String url) {
   Link link = new Link(parent, SWT.NONE);
   link.setLayoutData(SWTUtil.createFillHorizontallyGridData());
   link.setText(text);
   link.setToolTipText(tooltip);
   link.setBackground(parent.getBackground());
   link.addListener(
       SWT.Selection,
       new Listener() {
         public void handleEvent(Event event) {
           try {
             Program.launch(url);
           } catch (Exception e) {
             /* Ignore*/
           }
         }
       });
 }
Esempio n. 27
0
  protected void createComponent(Composite parent) {
    toolBar = new ToolBar(parent, SWT.FLAT | SWT.WRAP | SWT.LEFT);
    toolBar.setBackground(parent.getBackground());

    // The listener can not be disposed by its own, so we can dispose it manually
    // when the component that used it don't need it anymore
    toolBar.addDisposeListener(
        new DisposeListener() {
          @Override
          public void widgetDisposed(DisposeEvent e) {
            colorLabelProvider.dispose();
          }
        });
    foreButton = new ToolItem(toolBar, SWT.PUSH);
    if (section.getElement().isEditable()) {
      foreButton.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
              ColorDialog cd = new ColorDialog(toolBar.getShell());
              cd.setText(pDescriptor.getDisplayName());
              AlfaRGB rgb =
                  (AlfaRGB) section.getElement().getPropertyActualValue(pDescriptor.getId());
              cd.setRGB(rgb == null ? null : rgb);
              boolean useTransparency = true;
              if (pDescriptor instanceof ColorPropertyDescriptor) {
                useTransparency = ((ColorPropertyDescriptor) pDescriptor).supportsTransparency();
              }
              if (useTransparency) {
                AlfaRGB newColor = cd.openAlfaRGB();
                if (newColor != null) {
                  changeProperty(section, pDescriptor.getId(), newColor);
                }
              } else {
                RGB newColor = cd.openRGB();
                if (newColor != null) {
                  changeProperty(section, pDescriptor.getId(), AlfaRGB.getFullyOpaque(newColor));
                }
              }
            }
          });
    }
    foreButton.setToolTipText(pDescriptor.getDescription());
    toolBar.pack();
  }
Esempio n. 28
0
  /**
   * Create the link to the element
   *
   * @see
   *     org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
   * @param parent the parent composite
   * @return the hyperlink control
   */
  @Override
  protected Control createCustomArea(Composite parent) {
    FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    Hyperlink hyperLink = toolkit.createHyperlink(parent, label, SWT.UNDERLINE_LINK);
    hyperLink.setBackground(parent.getBackground());
    hyperLink.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false));
    if (allowNavigation) {
      hyperLink.addHyperlinkListener(
          new HyperlinkAdapter() {

            @Override
            public void linkActivated(HyperlinkEvent e) {
              navigateToElement();
              okPressed();
            }
          });
    }
    return hyperLink;
  }
  /**
   * Creates the sashform for the master detail colums.
   *
   * @param parent the parent
   * @return the sash
   */
  protected SashForm createSash(Composite parent) {
    /* THe contents of the composite */
    final Composite sashComposite = new Composite(parent, SWT.FILL);
    final GridLayout sashLayout = GridLayoutFactory.fillDefaults().create();
    sashLayout.marginWidth = 5;
    sashComposite.setLayout(sashLayout);
    GridDataFactory.fillDefaults()
        .align(SWT.FILL, SWT.FILL)
        .grab(true, true)
        .applyTo(sashComposite);

    final SashForm sash = new SashForm(sashComposite, SWT.HORIZONTAL);

    sash.setBackground(parent.getBackground());
    GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(sash);
    GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(sash);
    sash.setSashWidth(5);
    return sash;
  }
  /**
   * Create the buttons for the settings transfer.
   *
   * @param toolkit
   * @param sectionClient
   * @return boolean <code>true</code> if any were selected
   */
  private boolean createButtons(FormToolkit toolkit, Composite sectionClient) {

    IConfigurationElement[] settings = SettingsTransfer.getSettingsTransfers();

    String[] enabledSettings =
        getEnabledSettings(
            IDEWorkbenchPlugin.getDefault().getDialogSettings().getSection(WORKBENCH_SETTINGS));

    for (int i = 0; i < settings.length; i++) {
      final IConfigurationElement settingsTransfer = settings[i];
      final Button button =
          toolkit.createButton(sectionClient, settings[i].getAttribute(ATT_NAME), SWT.CHECK);

      String helpId = settings[i].getAttribute(ATT_HELP_CONTEXT);

      if (helpId != null) PlatformUI.getWorkbench().getHelpSystem().setHelp(button, helpId);

      if (enabledSettings != null && enabledSettings.length > 0) {

        String id = settings[i].getAttribute(ATT_ID);
        for (int j = 0; j < enabledSettings.length; j++) {
          if (enabledSettings[j].equals(id)) {
            button.setSelection(true);
            selectedSettings.add(settingsTransfer);
            break;
          }
        }
      }

      button.setBackground(sectionClient.getBackground());
      button.addSelectionListener(
          new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              if (button.getSelection()) selectedSettings.add(settingsTransfer);
              else selectedSettings.remove(settingsTransfer);
            }
          });
    }
    return enabledSettings != null && enabledSettings.length > 0;
  }