Exemplo n.º 1
0
 private void updateBgColor() {
   Iterator iter = controls.iterator();
   while (iter.hasNext()) {
     Control control = (Control) iter.next();
     control.setBackground(bgColors[bgIndex]);
   }
 }
  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;
  }
Exemplo n.º 3
0
  /**
   * {@inheritDoc} After the error remove is handled by its underlying {@link IEditErrorHandler},
   * the original style will be applied to the editor control.
   */
  @Override
  public void removeError(ICellEditor cellEditor) {
    super.removeError(cellEditor);

    if (this.errorStylingActive) {
      Control editorControl = cellEditor.getEditorControl();

      // reset the rendering information to normal
      editorControl.setBackground(originalBgColor);
      editorControl.setForeground(originalFgColor);
      editorControl.setFont(originalFont);

      // ensure to reset the stored original values so possible
      // dynamic rendering aspects are also covered
      originalBgColor = null;
      originalFgColor = null;
      originalFont = null;

      if (decorationProvider != null) {
        decorationProvider.hideDecoration();
      }

      this.errorStylingActive = false;
    }
  }
Exemplo n.º 4
0
  public void initControl(Control control) {
    control.setFont(iniAppearance.getFontGlobal());
    control.setBackground(iniAppearance.getColorBackground());
    control.setForeground(iniAppearance.getColorForeground());

    controls.add(control);
  }
Exemplo n.º 5
0
  /**
   * {@inheritDoc} After the error is handled by its underlying {@link IEditErrorHandler}, the
   * configured error style will be applied to the editor control.
   */
  @Override
  public void displayError(ICellEditor cellEditor, Exception e) {
    super.displayError(cellEditor, e);

    if (!this.errorStylingActive) {
      Control editorControl = cellEditor.getEditorControl();

      // store the current rendering information to be able to reset again
      originalBgColor = editorControl.getBackground();
      originalFgColor = editorControl.getForeground();
      originalFont = editorControl.getFont();

      // set the rendering information out of the error style
      editorControl.setBackground(
          this.errorStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
      editorControl.setForeground(
          this.errorStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
      editorControl.setFont(this.errorStyle.getAttributeValue(CellStyleAttributes.FONT));

      if (decorationProvider != null) {
        decorationProvider.showDecoration();
      }

      this.errorStylingActive = true;
    }
  }
Exemplo n.º 6
0
 private void updateControlState(List controls, boolean enabled) {
   for (Iterator it = controls.iterator(); it.hasNext(); ) {
     Control control = (Control) it.next();
     control.setEnabled(enabled);
     if (control instanceof Text || control instanceof CCombo)
       control.setBackground(enabled ? fComboEnabledColor : READONLY_BACKGROUNDCOLOR);
   }
 }
Exemplo n.º 7
0
  public void applyColor(ColorType type, RGB rgb) {
    Color newColor = new Color(SwtUtils.DISPLAY, rgb);
    Color oldColor = null;

    switch (type) {
      case BACKGROUND:
        {
          oldColor = iniAppearance.getColorBackground();

          for (Control control : controls) {
            if (control.isDisposed()) continue;

            control.setBackground(newColor);
          }
          for (Text chat : chatControls) {
            if (chat.isDisposed()) continue;

            chat.setBackground(newColor);
          }

          iniAppearance.setColorBackground(newColor);
          break;
        }
      case FOREGROUND:
        {
          oldColor = iniAppearance.getColorForeground();

          for (Control control : controls) {
            if (control.isDisposed()) continue;

            control.setForeground(newColor);
          }
          for (Text chat : chatControls) {
            if (chat.isDisposed()) continue;

            chat.setForeground(newColor);
          }

          iniAppearance.setColorForeground(newColor);
          break;
        }
      case LOG_BACKGROUND:
        {
          oldColor = iniAppearance.getColorLogBackground();

          for (StyledText text : logControls) {
            if (text.isDisposed()) continue;

            text.setBackground(newColor);
            text.setForeground(newColor);
          }

          iniAppearance.setColorLogBackground(newColor);
        }
    }

    if (oldColor != null) oldColor.dispose();
  }
 /** Overrides 'super' to pass the proper colors and font */
 @Override
 public void setContent(Control content) {
   super.setContent(content);
   if (content != null) {
     content.setForeground(getForeground());
     content.setBackground(getBackground());
     content.setFont(getFont());
   }
 }
 static void setColor(Composite composite, String indent, Color color, Color foreGorund) {
   if (composite == null) {
     return;
   }
   try {
     if (!composite.isDisposed()) {
       composite.setRedraw(false);
       if (composite instanceof ToolBar
           || composite instanceof Shell
           || composite instanceof CLabel
           || composite instanceof CTabFolder
           || composite instanceof CoolBar
           || composite instanceof CoolBar
           || composite instanceof CBanner
           || composite instanceof PageBook
           || composite instanceof ViewForm
           || composite instanceof Tree
           || composite instanceof StyledText
           || composite instanceof Table
           || composite.getClass().getName().startsWith("org.eclipse.jface")
           || composite.getClass().getName().startsWith("org.eclipse.ui.internal.layout")
           || composite.getClass().getName().startsWith("org.eclipse.ui.internal.FastViewBar")
           || composite
               .getClass()
               .getName()
               .startsWith("org.eclipse.ui.internal.progress.ProgressRegion")
           || composite.getClass().getName().startsWith("org.eclipse.swt.widgets.Canvas")
           || composite.getClass() == Composite.class) {
         composite.setBackground(color);
         composite.setForeground(foreGorund);
       } else {
         // System.out.println(indent +
         // composite.getClass().getName());
       }
       Control[] controls = composite.getChildren();
       for (Control control : controls) {
         if (!(control instanceof Composite)) {
           // System.out.println(indent + "Control " +
           // control.getClass().getName());
         }
         if (control instanceof Composite) {
           setColor((Composite) control, indent + " ", color, foreGorund);
         } else if (control instanceof Label
             || control instanceof CoolBar
             || control instanceof Sash
             || control instanceof ProgressBar
             || control instanceof Text) {
           control.setBackground(color);
           control.setForeground(foreGorund);
         }
       }
     }
   } finally {
     composite.setRedraw(true);
   }
 }
  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);
  }
Exemplo n.º 11
0
  /*
   * @see org.eclipse.jface.text.source.IVerticalRulerColumn#createControl(org.eclipse.jface.text.source.CompositeRuler, org.eclipse.swt.widgets.Composite)
   */
  public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
    Control control = super.createControl(parentRuler, parentControl);

    // set background
    Color background = getCachedTextViewer().getTextWidget().getBackground();
    control.setBackground(background);

    // install hover listener
    control.addMouseTrackListener(
        new MouseTrackAdapter() {
          public void mouseExit(MouseEvent e) {
            if (clearCurrentAnnotation()) redraw();
          }
        });

    // install mouse move listener
    control.addMouseMoveListener(
        new MouseMoveListener() {
          public void mouseMove(MouseEvent e) {
            boolean redraw = false;
            ProjectionAnnotation annotation = findAnnotation(toDocumentLineNumber(e.y), false);
            if (annotation != fCurrentAnnotation) {
              if (fCurrentAnnotation != null) {
                fCurrentAnnotation.setRangeIndication(false);
                redraw = true;
              }
              fCurrentAnnotation = annotation;
              if (fCurrentAnnotation != null && !fCurrentAnnotation.isCollapsed()) {
                fCurrentAnnotation.setRangeIndication(true);
                redraw = true;
              }
            }
            if (redraw) redraw();
          }
        });
    return control;
  }
Exemplo n.º 12
0
  /**
   * set the properties
   *
   * @param bean
   * @param properties
   */
  protected void setBeanProperties(Object bean, Map<?, ?> properties) {

    if (bean instanceof Control) {
      Control control = (Control) bean;

      // set size of widget
      Object size = properties.remove("size");
      if (size != null) {
        setSize(control, size);
      }

      // set background of widget
      Object colorValue = properties.remove("background");
      if (colorValue != null) {
        Color background = getColor(control, colorValue);
        control.setBackground(background);
      }

      // set foreground of widget
      colorValue = properties.remove("foreground");
      if (colorValue != null) {
        Color foreground = getColor(control, colorValue);
        control.setForeground(foreground);
      }
    }
    for (final Iterator<?> iter = properties.entrySet().iterator(); iter.hasNext(); ) {
      final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) iter.next();
      final String property = entry.getKey().toString();
      final Object value = entry.getValue();
      try {
        InvokerHelper.setProperty(bean, property, value);

      } catch (final Exception e) {
        throw new RuntimeException(e);
      }
    }
  }
Exemplo n.º 13
0
 /**
  * Set the foreground and background colors of the control to the specified values. If the values
  * are null than ignore them.
  *
  * @param foreground Color
  * @param background Color
  */
 public static void setColors(Control control, Color foreground, Color background) {
   if (foreground != null) control.setForeground(foreground);
   if (background != null) control.setBackground(background);
 }
Exemplo n.º 14
0
  @Override
  public void createPartControl(Composite parent) {
    // CREATE CONTROLS
    Composite mainPanel = new Composite(parent, SWT.NONE);
    Control filterPanel = filterPart.createControl(mainPanel, 5, 5);
    Tree tree = new Tree(mainPanel, SWT.FULL_SELECTION | SWT.MULTI);
    filterPanel.setBackground(tree.getBackground());

    viewer = new TreeViewer(tree);
    viewer.setContentProvider(contentProvider);
    ColumnViewerToolTipSupport.enableFor(viewer);

    viewer.setLabelProvider(new RepositoryTreeLabelProvider(false));
    getViewSite().setSelectionProvider(viewer);

    createActions();

    JpmPreferences jpmPrefs = new JpmPreferences();
    final boolean showJpmOnClick =
        jpmPrefs.getBrowserSelection() != JpmPreferences.PREF_BROWSER_EXTERNAL;

    // LISTENERS
    filterPart.addPropertyChangeListener(
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent event) {
            String filter = (String) event.getNewValue();
            updatedFilter(filter);
          }
        });
    ViewerDropAdapter dropAdapter =
        new ViewerDropAdapter(viewer) {
          @Override
          public boolean validateDrop(Object target, int operation, TransferData transferType) {
            if (canDrop(target, transferType)) return true;

            boolean valid = false;
            if (target instanceof RepositoryPlugin) {
              if (((RepositoryPlugin) target).canWrite()) {

                if (URLTransfer.getInstance().isSupportedType(transferType)) return true;

                if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) {
                  ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
                  if (selection instanceof IStructuredSelection) {
                    for (Iterator<?> iter = ((IStructuredSelection) selection).iterator();
                        iter.hasNext(); ) {
                      Object element = iter.next();
                      if (element instanceof RepositoryBundle
                          || element instanceof RepositoryBundleVersion) {
                        valid = true;
                        break;
                      }
                      if (element instanceof IFile) {
                        valid = true;
                        break;
                      }
                      if (element instanceof IAdaptable) {
                        IFile file = (IFile) ((IAdaptable) element).getAdapter(IFile.class);
                        if (file != null) {
                          valid = true;
                          break;
                        }
                      }
                    }
                  }
                } else {
                  valid = true;
                }
              }
            }
            return valid;
          }

          @Override
          public void dragEnter(DropTargetEvent event) {
            super.dragEnter(event);
            event.detail = DND.DROP_COPY;
          }

          @Override
          public boolean performDrop(Object data) {
            if (RepositoriesView.this.performDrop(
                getCurrentTarget(), getCurrentEvent().currentDataType)) {
              viewer.refresh(getCurrentTarget(), true);
              return true;
            }

            boolean copied = false;
            if (URLTransfer.getInstance().isSupportedType(getCurrentEvent().currentDataType)) {
              try {
                URL url =
                    new URL(
                        (String)
                            URLTransfer.getInstance()
                                .nativeToJava(getCurrentEvent().currentDataType));
                File tmp = File.createTempFile("dwnl", ".jar");
                IO.copy(url, tmp);
                copied =
                    addFilesToRepository((RepositoryPlugin) getCurrentTarget(), new File[] {tmp});
              } catch (Exception e) {
                return false;
              }
            } else if (data instanceof String[]) {
              String[] paths = (String[]) data;
              File[] files = new File[paths.length];
              for (int i = 0; i < paths.length; i++) {
                files[i] = new File(paths[i]);
              }
              copied = addFilesToRepository((RepositoryPlugin) getCurrentTarget(), files);
            } else if (data instanceof IResource[]) {
              IResource[] resources = (IResource[]) data;
              File[] files = new File[resources.length];
              for (int i = 0; i < resources.length; i++) {
                files[i] = resources[i].getLocation().toFile();
              }
              copied = addFilesToRepository((RepositoryPlugin) getCurrentTarget(), files);
            } else if (data instanceof IStructuredSelection) {
              File[] files = convertSelectionToFiles((IStructuredSelection) data);
              if (files != null && files.length > 0)
                copied = addFilesToRepository((RepositoryPlugin) getCurrentTarget(), files);
            }
            return copied;
          }
        };
    dropAdapter.setFeedbackEnabled(false);
    dropAdapter.setExpandEnabled(false);

    viewer.addDropSupport(
        DND.DROP_COPY | DND.DROP_MOVE,
        new Transfer[] {
          URLTransfer.getInstance(),
          FileTransfer.getInstance(),
          ResourceTransfer.getInstance(),
          LocalSelectionTransfer.getTransfer()
        },
        dropAdapter);
    viewer.addDragSupport(
        DND.DROP_COPY | DND.DROP_MOVE,
        new Transfer[] {LocalSelectionTransfer.getTransfer()},
        new SelectionDragAdapter(viewer));

    viewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            boolean writableRepoSelected = false;
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            Object element = selection.getFirstElement();
            if (element instanceof RepositoryPlugin) {
              RepositoryPlugin repo = (RepositoryPlugin) element;
              writableRepoSelected = repo.canWrite();
            }
            addBundlesAction.setEnabled(writableRepoSelected);
          }
        });
    tree.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent ev) {
            Object element = ((IStructuredSelection) viewer.getSelection()).getFirstElement();
            if (element instanceof ContinueSearchElement) {
              try {
                getViewSite()
                    .getPage()
                    .showView(
                        Plugin.JPM_BROWSER_VIEW_ID,
                        null,
                        showJpmOnClick ? IWorkbenchPage.VIEW_ACTIVATE : IWorkbenchPage.VIEW_CREATE);
              } catch (PartInitException e) {
                Plugin.getDefault().getLog().log(e.getStatus());
              }
            }
          }
        });
    viewer.addDoubleClickListener(
        new IDoubleClickListener() {
          @Override
          public void doubleClick(DoubleClickEvent event) {
            if (!event.getSelection().isEmpty()) {
              IStructuredSelection selection = (IStructuredSelection) event.getSelection();
              Object element = selection.getFirstElement();
              if (element instanceof IAdaptable) {
                URI uri = (URI) ((IAdaptable) element).getAdapter(URI.class);
                if (uri != null) {
                  IWorkbenchPage page = getSite().getPage();
                  try {
                    IFileStore fileStore = EFS.getLocalFileSystem().getStore(uri);
                    IDE.openEditorOnFileStore(page, fileStore);
                  } catch (PartInitException e) {
                    logger.logError("Error opening editor for " + uri, e);
                  }
                }
              } else if (element instanceof ContinueSearchElement) {
                ContinueSearchElement searchElement = (ContinueSearchElement) element;
                try {
                  JpmPreferences jpmPrefs = new JpmPreferences();
                  if (jpmPrefs.getBrowserSelection() == JpmPreferences.PREF_BROWSER_EXTERNAL)
                    getViewSite()
                        .getWorkbenchWindow()
                        .getWorkbench()
                        .getBrowserSupport()
                        .getExternalBrowser()
                        .openURL(new URL("https://www.jpm4j.org/" + searchElement.getFilter()));
                  else
                    getViewSite()
                        .getPage()
                        .showView(Plugin.JPM_BROWSER_VIEW_ID, null, IWorkbenchPage.VIEW_VISIBLE);
                } catch (PartInitException e) {
                  Plugin.getDefault().getLog().log(e.getStatus());
                } catch (MalformedURLException e) {
                  // ignore
                }
              }
            }
          }
        });

    createContextMenu();

    // LOAD
    Central.onWorkspaceInit(
        new Function<Workspace, Void>() {
          @Override
          public Void run(Workspace a) {
            final List<RepositoryPlugin> repositories = RepositoryUtils.listRepositories(true);
            SWTConcurrencyUtil.execForControl(
                viewer.getControl(),
                true,
                new Runnable() {
                  @Override
                  public void run() {
                    viewer.setInput(repositories);
                  }
                });
            return null;
          }
        });

    // LAYOUT
    GridLayout layout = new GridLayout(1, false);
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    mainPanel.setLayout(layout);

    tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    filterPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    // Toolbar
    createActions();
    fillToolBar(getViewSite().getActionBars().getToolBarManager());

    // Register as repository listener
    registration =
        Activator.getDefault()
            .getBundleContext()
            .registerService(RepositoryListenerPlugin.class, this, null);
  }
 public static void setBackground(Control c, Color color) {
   c.setBackground(color);
   if (c instanceof Composite)
     for (Control child : ((Composite) c).getChildren()) setBackground(child, color);
 }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl()
   */
  @Override
  public Control createControl(
      final Composite subComposite,
      final IElementParameter param,
      final int numInRow,
      final int nbInRow,
      final int top,
      final Control lastControl) {
    if (param.getDisplayName().startsWith("!!")) { // $NON-NLS-1$
      if (param.getFieldType() == EParameterFieldType.MODULE_LIST) {
        param.setDisplayName(EParameterName.MODULE_LIST.getDisplayName());
      }
    }

    DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, cbCtrl);
    if (param.isRequired()) {
      FieldDecoration decoration =
          FieldDecorationRegistry.getDefault()
              .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
      dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }

    Control cLayout = dField.getLayoutControl();
    CCombo combo = (CCombo) dField.getControl();

    combo.setEditable(false);
    cLayout.setBackground(subComposite.getBackground());
    combo.setEnabled(!param.isReadOnly());
    combo.addSelectionListener(listenerSelection);
    if (elem instanceof Node) {
      combo.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }

    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
    FormData data = new FormData();
    if (lastControl != null) {
      data.left = new FormAttachment(lastControl, 0);
    } else {
      data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }
    data.top = new FormAttachment(0, top);
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
      labelLabel.setAlignment(SWT.RIGHT);
    }
    // *********************
    data = new FormData();
    int currentLabelWidth = STANDARD_LABEL_WIDTH;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    gc.dispose();

    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
      currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }

    if (numInRow == 1) {
      if (lastControl != null) {
        data.left = new FormAttachment(lastControl, currentLabelWidth);
      } else {
        data.left = new FormAttachment(0, currentLabelWidth);
      }

    } else {
      data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);

    Button btnEdit = getWidgetFactory().createButton(subComposite, "", SWT.PUSH); // $NON-NLS-1$
    btnEdit.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));

    data = new FormData();
    data.left = new FormAttachment(cLayout, 0, SWT.RIGHT);
    data.right =
        new FormAttachment(
            cLayout, ITabbedPropertyConstants.HSPACE + STANDARD_BUTTON_WIDTH, SWT.RIGHT);
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT - 2;
    btnEdit.setLayoutData(data);
    btnEdit.setData(NAME, MODULE);
    btnEdit.setData(PARAMETER_NAME, param.getName());
    btnEdit.setEnabled(!param.isReadOnly());
    btnEdit.addSelectionListener(listenerSelection);

    // **********************
    hashCurControls.put(param.getName(), combo);
    hashCurControls.put(param.getName() + BUTTON_EDIT, btnEdit);
    updateData();
    // this.dynamicTabbedPropertySection.updateColumnList(null);

    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return cLayout;
  }
Exemplo n.º 17
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl()
   */
  @Override
  public Control createControl(
      final Composite subComposite,
      final IElementParameter param,
      final int numInRow,
      final int nbInRow,
      final int top,
      final Control lastControl) {
    this.curParameter = param;
    this.paramFieldType = param.getFieldType();
    int nbLines = param.getNbLines();

    DecoratedField dField =
        new DecoratedField(
            subComposite,
            SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP,
            new SelectAllTextControlCreator());
    if (param.isRequired()) {
      FieldDecoration decoration =
          FieldDecorationRegistry.getDefault()
              .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
      dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }
    Control cLayout = dField.getLayoutControl();
    Text text = (Text) dField.getControl();

    editionControlHelper.register(param.getName(), text);

    FormData d = (FormData) text.getLayoutData();
    if (getAdditionalHeightSize() != 0) {
      nbLines += this.getAdditionalHeightSize() / text.getLineHeight();
    }
    d.height = text.getLineHeight() * nbLines;
    FormData data;
    text.getParent().setSize(subComposite.getSize().x, text.getLineHeight() * nbLines);
    cLayout.setBackground(subComposite.getBackground());
    // for bug 7580
    if (!(text instanceof Text)) {
      text.setEnabled(!param.isReadOnly());
    } else {
      text.setEditable(!param.isReadOnly());
    }
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
    FontData fontData = new FontData(fontType);
    Font font = new Font(null, fontData);
    addResourceDisposeListener(text, font);
    text.setFont(font);
    if (elem instanceof Node) {
      text.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    addDragAndDropTarget(text);

    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
    data = new FormData();
    if (lastControl != null) {
      data.left = new FormAttachment(lastControl, 0);
    } else {
      data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }
    data.top = new FormAttachment(0, top);
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
      labelLabel.setAlignment(SWT.RIGHT);
    }
    // *********************
    data = new FormData();
    int currentLabelWidth = STANDARD_LABEL_WIDTH;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    gc.dispose();

    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
      currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }

    if (numInRow == 1) {
      if (lastControl != null) {
        data.left = new FormAttachment(lastControl, currentLabelWidth);
      } else {
        data.left = new FormAttachment(0, currentLabelWidth);
      }

    } else {
      data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    // **********************
    hashCurControls.put(param.getName(), text);

    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);

    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return null;
  }
 private void setBackGroundWhite(Control control) {
   control.setBackground(this.display.getSystemColor(SWT.COLOR_WHITE));
 }