コード例 #1
0
    public void drop(DropTargetEvent event) {
      DropTarget dropTarget = (DropTarget) event.getSource();
      Item targetItem = (Item) event.item;

      MetadataColumn targetColumn = null;
      if (targetItem != null) {
        targetColumn = (MetadataColumn) targetItem.getData();
      }
      if (targetColumn != null) {}

      EList columns =
          ConnectionHelper.getTables(connection).toArray(new MetadataTable[0])[0].getColumns();
      int maxColumnsNumber =
          CoreUIPlugin.getDefault()
              .getPreferenceStore()
              .getInt(ITalendCorePrefConstants.MAXIMUM_AMOUNT_OF_COLUMNS_FOR_XML);
      if (columns.size() >= maxColumnsNumber) {
        MessageDialog.openWarning(
            treeViewer.getTree().getShell(),
            "Columns Overflow",
            "The amount of schema columns has reached the max value. Please increase the max value on Preference Page(/Talend/Metadata) if you want to add new columns.");
        return;
      }

      Control control = dropTarget.getControl();
      LocalDraggedData draggedData = LocalDataTransfer.getInstance().getDraggedData();
      List<Object> transferableObjs = draggedData.getTransferableEntryList();
      for (Object obj : transferableObjs) {
        if (obj instanceof FOXTreeNode) {
          FOXTreeNode treeNode = (FOXTreeNode) obj;
          calcuAddedColumns(treeNode, targetColumn, columns);
        }
      }

      tableViewer.setInput(columns);
      tableViewer.refresh();
      treeViewer.refresh();

      Display display = tree.getDisplay();
      Cursor cursor = new Cursor(display, SWT.CURSOR_WAIT);
      tree.getShell().setCursor(cursor);

      linker.valueChanged(targetItem);

      tree.getShell().setCursor(null);

      linker.updateLinksStyleAndControlsSelection(control, true);
      linker.updateConnection();
      linker.updateFormStatus();
    }
コード例 #2
0
  /**
   * Constructor for a TabbedPropertyComposite
   *
   * @param parent the parent widget.
   * @param factory the widget factory.
   * @param displayTitle if <code>true</code>, then the title bar will be displayed.
   */
  public TalendTabbedPropertyComposite(
      Composite parent,
      TabbedPropertySheetWidgetFactory factory,
      boolean displayTitle,
      boolean displayCompactToolbar) {
    super(parent, SWT.NO_FOCUS);
    this.factory = factory;
    this.displayTitle = displayTitle;
    this.displayCompactToolbar = displayCompactToolbar;

    createMainComposite();
    // CSS
    CoreUIPlugin.setCSSClass(this, this.getClass().getSimpleName());
  }
コード例 #3
0
 /**
  * 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());
   }
 }
コード例 #4
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;
    FormData data;
    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(0, 120);
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT - 2;
    btnEdit.setLayoutData(data);
    btnEdit.setData(NAME, ICON_SELECTION);
    btnEdit.setData(PARAMETER_NAME, param.getName());
    btnEdit.setEnabled(!param.isReadOnly());
    btnEdit.addSelectionListener(listenerSelection);

    DecoratedField dField =
        new DecoratedField(
            subComposite,
            SWT.NONE,
            new IControlCreator() {

              @Override
              public Control createControl(Composite parent, int style) {

                return new Label(parent, style);
              }
            });
    // revert btn
    Button btnRevert =
        getWidgetFactory()
            .createButton(
                subComposite,
                Messages.getString("IconSelectionController.Revert"),
                SWT.PUSH); //$NON-NLS-1$

    data = new FormData();
    data.left = new FormAttachment(btnEdit, 5);
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT - 2;
    btnRevert.setLayoutData(data);
    btnRevert.setData(NAME, ICON_REVERT);
    btnRevert.setData(PARAMETER_NAME, param.getName());
    btnRevert.setEnabled(!param.isReadOnly());
    btnRevert.addSelectionListener(listenerSelection);

    if (param.isRequired()) {
      FieldDecoration decoration =
          FieldDecorationRegistry.getDefault()
              .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
      dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }
    if (param.isRepositoryValueUsed()) {
      FieldDecoration decoration =
          FieldDecorationRegistry.getDefault()
              .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
      decoration.setDescription(
          Messages.getString("FileController.decoration.description")); // $NON-NLS-1$
      dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
    }

    Control cLayout = dField.getLayoutControl();
    filePathText = (Label) dField.getControl();
    String file = (String) elem.getPropertyValue(PARAMETER_NAME);
    if (file != null) {
      // ImageData imageData = new ImageData(file);
      // image = new Image(composite.getShell().getDisplay(), imageData);
      // filePathText.setImage(image);
    }

    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName(), 0);
    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 = 50;
    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(btnEdit, 0, SWT.CENTER);
    data.height = 34;
    data.width = 30;
    cLayout.setLayoutData(data);

    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return btnEdit;
  }
コード例 #5
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) {
    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;
  }