@Override
 public Image getImage(Object element) {
   if (isRecycleBin(element)) {
     RepositoryNode recyclebinNode = (RepositoryNode) element;
     if (recyclebinNode.getChildren().isEmpty()) {
       return ImageProvider.getImage(ECoreImage.RECYCLE_BIN_EMPTY_ICON);
     } else {
       return ImageProvider.getImage(ECoreImage.RECYCLE_BIN_FULL_ICON);
     }
   }
   return null; // if others, ignore
 }
Пример #2
0
 /**
  * Sets the isCompactView.
  *
  * @param isCompactView the isCompactView to set
  */
 public void setCompactView(boolean isCompactView) {
   this.isCompactView = isCompactView;
   if (displayCompactToolbar) {
     if (isCompactView) {
       getCompactButton().setImage(ImageProvider.getImage(EImage.COMPACT_VIEW));
       getTableButton().setImage(ImageProvider.getImage(EImage.NO_TABLE_VIEW));
     } else {
       getCompactButton().setImage(ImageProvider.getImage(EImage.NO_COMPACT_VIEW));
       getTableButton().setImage(ImageProvider.getImage(EImage.TABLE_VIEW));
     }
   }
 }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
   */
  public Image getImage(Object objects) {
    Node node = null;
    if (objects == null || objects.equals(StructuredSelection.EMPTY)) {
      return null;
    }
    if (!(objects instanceof IStructuredSelection)) {
      return null;
    }
    final boolean[] multiple = {false};
    Object object = getObject(objects, multiple);
    if (object == null) {
      return null;
    }

    if ((object instanceof NodeTreeEditPart)) {
      node = (Node) ((NodeTreeEditPart) object).getModel();
    } else {
      if (object instanceof NodeReturnsTreeEditPart) {
        node = lastNode;
      } else {
        if (object instanceof ProcessPart) {
          return ImageProvider.getImage(ECoreImage.PROCESS_ICON);
        }
        if (object instanceof ConnectionPart) {
          return ImageProvider.getImage(EImage.RIGHT_ICON);
        }
        if (object instanceof NoteEditPart) {
          return ImageProvider.getImage(ECoreImage.CODE_ICON);
        }
        if (object instanceof ConnLabelEditPart) {
          return ImageProvider.getImage(EImage.RIGHT_ICON);
        }
        if ((object instanceof NodeLabelEditPart)) {
          node = ((NodeContainer) ((NodeLabelEditPart) object).getParent().getModel()).getNode();
        }
        if (!(object instanceof NodePart)) {
          return null;
        }
        if (node == null) {
          node = (Node) ((NodePart) object).getModel();
        }
      }
    }
    if (lastNode != node) {
      lastNode = node;
    }
    return CoreImageProvider.getComponentIcon(node.getComponent(), ICON_SIZE.ICON_24);
  }
  private Button createAddPushButton(final Composite parent) {
    Button addPushButton = new Button(parent, SWT.PUSH);
    addPushButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            IContextParameter parameter = (IContextParameter) createNewEntry();
            if (parameter != null) {
              // set the source to built-in
              parameter.setSource(IContextParameter.BUILT_IN);
              modelManager.onContextAddParameter(getContextManager(), parameter);

              // see feature 4661: Add an option to propagate when add or remove a variable in a
              // repository
              // context to jobs/joblets.
              if (ContextUtils.isPropagateContextVariable() && getContextManager() != null) {
                IContextManager manager = getContextManager();
                if (manager != null && manager instanceof JobContextManager) {
                  JobContextManager jobManger = (JobContextManager) manager;
                  // set updated flag.
                  jobManger.setModified(true);
                  jobManger.addNewParameters(parameter.getName());
                }
              }
            }
          }
        });
    Image image = ImageProvider.getImage(EImage.ADD_ICON);
    addPushButton.setImage(image);
    return addPushButton;
  }
Пример #5
0
 /**
  * DOC xqliu Comment method "initDialog".
  *
  * @param object
  * @param cancelFlag
  * @param message
  */
 private void initDialog(Object object, boolean cancelFlag, String message) {
   this.source = object;
   this.canCancel = cancelFlag;
   setDefaultImage(ImageProvider.getImage(ECoreImage.CONTEXT_ICON));
   setHelpAvailable(false);
   setTitle(TITLE);
   setMessage(message);
 }
  public CreateFolderAction() {
    super();
    this.setText(Messages.getString("CreateFolderAction.action.title")); // $NON-NLS-1$
    this.setToolTipText(Messages.getString("CreateFolderAction.action.toolTipText")); // $NON-NLS-1$

    Image folderImg = ImageProvider.getImage(ECoreImage.FOLDER_CLOSE_ICON);
    this.setImageDescriptor(OverlayImageProvider.getImageWithNew(folderImg));
  }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
  */
 public Image getImage(Object element) {
   Image i = null;
   if (element instanceof SQLEditorAllProposal) {
     i = ((SQLEditorAllProposal) element).getImage();
     if (i != null) {
       return i;
     }
   }
   return ImageProvider.getImage(sqlEditor);
 }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
  */
 public Image getColumnImage(Object element, int columnIndex) {
   if (columnIndex == 0) {
     if (element instanceof IContainerEntry) {
       return ((IContainerEntry) element).getImage();
     }
   } else if (columnIndex == 1) {
     if (element instanceof Problem) {
       return ImageProvider.getImage(EImage.ERROR_SMALL);
     }
   }
   return null;
 }
  protected void paintGrid(
      Graphics g,
      IFigure f,
      org.eclipse.draw2d.geometry.Point origin,
      int distanceX,
      int distanceY) {
    FreeformFigure ff = (FreeformFigure) this.getParent();
    Rectangle clientArea = getClientArea();
    Rectangle bounds = ff.getFreeformExtent().getCopy();
    bounds.union(clientArea.x, clientArea.y, clientArea.width, clientArea.height);
    ff.setFreeformBounds(bounds);

    Rectangle original = g.getClip(Rectangle.SINGLETON);

    Rectangle clip =
        new Rectangle(
            original.x - original.x % distanceX,
            original.y - original.y % distanceY,
            original.width + Math.abs(original.x % distanceX),
            original.height + Math.abs(original.y % distanceY));
    if (distanceX > 0 && distanceY > 0) {
      if (origin.x >= clip.x) {
        while (origin.x - distanceX >= clip.x) {
          origin.x -= distanceX;
        }
      } else {
        while (origin.x < clip.x) {
          origin.x += distanceX;
        }
      }

      if (origin.y >= clip.y) {
        while (origin.y - distanceY >= clip.y) {
          origin.y -= distanceY;
        }
      } else {
        while (origin.y < clip.y) {
          origin.y += distanceY;
        }
      }

      for (int i = origin.x; i < clip.x + clip.width; i += distanceX) {
        for (int j = origin.y; j < clip.y + clip.height; j += distanceY) {
          // g.drawPoint(i, j);
          int re = Math.abs(i - j);
          if (re / distanceY % 2 == 0) {
            g.drawImage(ImageProvider.getImage(EImage.CHESS_GRAY), i, j);
          }
        }
      }
    }
  }
  private Button createSelectContextVariablesPushButton(final Composite parent) {
    Button selectContextVariablesPushButton = new Button(parent, SWT.PUSH);
    Image image = ImageProvider.getImage(ECoreImage.CONTEXT_ICON);
    selectContextVariablesPushButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            SelectRepositoryContextDialog dialog =
                new SelectRepositoryContextDialog(
                    getContextModelManager(), parent.getShell(), helper);
            if (dialog.open() == Dialog.OK) {
              // ADD msjian TDQ-9629: if the current perspective is dataprofiling, change all to
              // builtin context
              IWorkbenchPage activePage =
                  PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
              if (activePage != null) {
                if ("org.talend.dataprofiler.DataProfilingPerspective"
                    .equals(activePage.getPerspective().getId())) { // $NON-NLS-1$
                  IContextManager contextManager = getContextModelManager().getContextManager();
                  if (contextManager instanceof JobContextManager) {
                    JobContextManager jobContextManager = (JobContextManager) contextManager;
                    jobContextManager.setModified(true);
                  }

                  List<IContext> listContext = contextManager.getListContext();
                  if (listContext != null) {
                    for (IContext context : listContext) {
                      List<IContextParameter> contextParameterList =
                          context.getContextParameterList();
                      if (contextParameterList != null) {
                        for (IContextParameter contextParameter : contextParameterList) {
                          contextParameter.setSource(IContextParameter.BUILT_IN);
                        }
                      }
                    }
                  }

                  contextManager.fireContextsChangedEvent();
                }
              }
              // TDQ-9629~

              refresh();
            }
          }
        });
    selectContextVariablesPushButton.setImage(image);
    return selectContextVariablesPushButton;
  }
  private Button createRemovePushButton(final Composite parent) {
    Button removePushButton = new Button(parent, SWT.PUSH);
    removePushButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {

            IStructuredSelection sel = treeTable.getSelection();

            if (treeTable.getSelection() != null) {

              Object[] obj = new Object[sel.toList().size()];

              int i = 0;
              for (Object node : sel.toList().toArray()) {
                if (node instanceof ContextTreeNode) {
                  obj[i++] = ((ContextTreeNode) node).getTreeData();
                }
              }

              for (Object object : obj) { // multi delete
                if (object == null) {
                  return;
                }
                if (object instanceof ContextTableTabParentModel) {
                  ContextTableTabParentModel parentModel = (ContextTableTabParentModel) object;
                  removeParentModelInGroupBySource(parentModel);
                } else if (object instanceof ContextTableTabChildModel) {
                  ContextTableTabChildModel childModel = (ContextTableTabChildModel) object;
                  removeChildModelInGroupBySource(childModel);
                }
              }
              modelManager.refresh();
              setButtonEnableState();

              if (!treeTable.getSelection().isEmpty()) {
                treeTable.clearSelection();
              }
            }
          }
        });

    Image image = ImageProvider.getImage(EImage.DELETE_ICON);
    removePushButton.setImage(image);
    return removePushButton;
  }
  private Button createMoveDownPushButton(final Composite parent) {
    Button moveDownPushButton = new Button(parent, SWT.PUSH);
    Image image = ImageProvider.getImage(EImage.DOWN_ICON);
    moveDownPushButton.setImage(image);
    moveDownPushButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            IStructuredSelection sel = treeTable.getSelection();
            if (ContextManagerHelper.changeContextOrder(sel, modelManager, false)) {
              setButtonEnableState();
            }
          }
        });
    return moveDownPushButton;
  }
  private void createNatTable() {
    ContextTreeTable.TControl tControl = treeTable.createTable(contextTableComp);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(tControl.getControl());

    configContext = new ConfigureContextAction(modelManager, this.getShell());
    contextConfigButton = new Button(contextTableComp, SWT.NULL);
    GridData addContextGridData = new GridData();
    addContextGridData.verticalAlignment = SWT.TOP;
    contextConfigButton.setLayoutData(addContextGridData);
    contextConfigButton.setImage(ImageProvider.getImage(EImage.ADD_ICON));
    contextConfigButton.setToolTipText(configContext.getText());
    contextConfigButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            configContext.run();
          }
        });
  }
Пример #14
0
  private void configureAutoIndexColumn(
      TableViewerCreator<IMetadataColumn> tableViewerCreator, Table table) {
    TableViewerCreatorColumn<IMetadataColumn, Boolean> column =
        new TableViewerCreatorColumn<IMetadataColumn, Boolean>(tableViewerCreator);
    column.setBeanPropertyAccessors(
        new IBeanPropertyAccessors<IMetadataColumn, Boolean>() {

          @Override
          public Boolean get(IMetadataColumn bean) {
            if (bean instanceof MetadataColumnExt) {
              MetadataColumnExt columnExt = (MetadataColumnExt) bean;
              return columnExt.getData().isAutoIndexed();
            }
            return false;
          }

          @Override
          public void set(IMetadataColumn bean, Boolean value) {
            if (bean instanceof MetadataColumnExt) {
              MetadataColumnExt columnExt = (MetadataColumnExt) bean;
              columnExt.getData().setAutoIndexed(value);
            }
          }
        });
    String title = "Auto indexed"; // TODO: Internationalize this
    column.setTitle(title);
    column.setToolTipHeader(title);
    column.setModifiable(true);
    column.setWidth(76);
    column.setDisplayedValue("");
    column.setTableColumnSelectionListener(
        new CheckColumnSelectionListener(column, tableViewerCreator));
    column.setImageHeader(ImageProvider.getImage(EImage.CHECKED_ICON));
    CheckboxTableEditorContent checkbox = new CheckboxTableEditorContent();
    checkbox.setToolTipText(title);
    column.setTableEditorContent(checkbox);
  }
  // TODO the implementation of this method is horrible and creating too many widgets
  // table/column renderer/editor should be used instead should be used instead
  protected void addInstallButtons() {
    final AtomicInteger enabledButtonCount = new AtomicInteger(0);
    tableViewerCreator.getTableViewer().getControl().setRedraw(false);
    final Table table = tableViewerCreator.getTable();
    manualInstallButtonMap = new HashMap<ModuleToInstall, Button>();
    ILibrariesService librariesService = LibManagerUiPlugin.getDefault().getLibrariesService();

    disposePreviousEditors();
    for (final TableItem item : table.getItems()) {
      TableEditor editor = new TableEditor(table);
      installButtonsEditors.add(editor);
      Control control = null;
      Object obj = item.getData();
      if (obj instanceof ModuleToInstall) {
        final ModuleToInstall data = (ModuleToInstall) obj;
        boolean isInstalled = false;
        try {
          isInstalled =
              librariesService.getLibraryStatus(data.getName()) == ELibraryInstallStatus.INSTALLED;
        } catch (BusinessException e1) { // log the error and consider as unsinstalled
          log.error(e1);
        }
        boolean hasDownloadUrl = data.getUrl_description() != null;
        if (!MavenConstants.DOWNLOAD_MANUAL.equals(
            data.getDistribution())) { // add the button to download
          final Button button = new Button(table, SWT.FLAT);
          control = button;
          enabledButtonCount.incrementAndGet();
          button.setText(
              Messages.getString("ExternalModulesInstallDialog_Download")); // $NON-NLS-1$
          button.setData(item);
          button.addSelectionListener(
              new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                  table.select(table.indexOf(item));
                  launchIndividualDownload(enabledButtonCount, data, button);
                }
              });
          button.setEnabled(!isInstalled);
          button.setToolTipText(data.toString());
        } else { // add the link for manual download
          Composite composite = new Composite(table, SWT.NONE);
          composite.setBackground(color);
          control = composite;
          GridLayout layout = new GridLayout(hasDownloadUrl ? 2 : 1, false);
          layout.marginHeight = 0;
          layout.verticalSpacing = 1;
          composite.setLayout(layout);
          if (hasDownloadUrl) {
            Link openLink = new Link(composite, SWT.NONE);
            GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(openLink);
            openLink.setBackground(color);
            // openLink.setLayoutData(gData);
            openLink.setText(
                "<a href=\"\">"
                    + Messages.getString("ExternalModulesInstallDialog.openInBrowser")
                    + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            openLink.addSelectionListener(
                new SelectionAdapter() {

                  @Override
                  public void widgetSelected(final SelectionEvent e) {
                    // Program.launch(data.getUrl_description());
                    openURL(data.getUrl_description());
                  }
                });
          } // else no download URL so just add the install buttonb
          enabledButtonCount.incrementAndGet();
          Button importButton = new Button(composite, SWT.FLAT);
          importButton.setImage(ImageProvider.getImage(ECoreImage.IMPORT_JAR));
          importButton.setToolTipText(
              Messages.getString("ImportExternalJarAction.title")); // $NON-NLS-1$
          importButton.addSelectionListener(
              new ImportButtonSelectionListener(enabledButtonCount, item));
          manualInstallButtonMap.put(data, importButton);
          GridDataFactory.fillDefaults()
              .align(SWT.RIGHT, SWT.CENTER)
              .grab(true, false)
              .applyTo(importButton);
          importButton.setEnabled(!isInstalled);
          importButton.setToolTipText(data.toString());
        }
        editor.grabHorizontal = true;
        editor.setEditor(control, item, tableViewerCreator.getColumns().indexOf(installcolumn));
        editor.layout();
        // url
        editor = new TableEditor(table);
        installButtonsEditors.add(editor);
        Composite composite = new Composite(table, SWT.NONE);
        composite.setBackground(color);
        // GridLayout layout = new GridLayout();
        FormLayout layout = new FormLayout();
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        composite.setLayout(layout);
        FormData gData = new FormData();
        gData.left = new FormAttachment(0);
        gData.right = new FormAttachment(100);
        gData.top = new FormAttachment(composite, 0, SWT.CENTER);
        final Link openLink = new Link(composite, SWT.NONE);
        openLink.setLayoutData(gData);
        openLink.setBackground(color);
        gData.height = new GC(composite).stringExtent(" ").y; // $NON-NLS-1$
        openLink.setText(
            "<a href=\"\">"
                + (hasDownloadUrl ? data.getUrl_description() : "")
                + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$
        openLink.addSelectionListener(
            new SelectionAdapter() {

              @Override
              public void widgetSelected(final SelectionEvent e) {
                // Program.launch(data.getUrl_description());
                openURL(data.getUrl_description());
              }
            });
        editor.grabHorizontal = true;
        // editor.minimumHeight = 20;
        editor.setEditor(composite, item, tableViewerCreator.getColumns().indexOf(urlcolumn));
        editor.layout();
      }
    }
    tableViewerCreator.getTableViewer().getTable().layout();
    tableViewerCreator.getTableViewer().refresh(true);
    tableViewerCreator.getTableViewer().getControl().setRedraw(true);
  }
 public AddButton() {
   super(ImageProvider.getImage(EImage.ADD_ICON));
 }
 public RemoveButton() {
   super(ImageProvider.getImage(EImage.MINUS_ICON));
 }
 public MoveUpButton() {
   super(ImageProvider.getImage(EImage.UP_ICON));
 }
  /**
   * DOC smallet ConnectionsComposite constructor comment.
   *
   * @param parent
   * @param style
   */
  public ConnectionFormComposite(
      Composite parent,
      int style,
      ConnectionsListComposite connectionsListComposite,
      ConnectionsDialog dialog) {
    super(parent, style);
    this.dialog = dialog;
    this.connectionsListComposite = connectionsListComposite;

    toolkit = new FormToolkit(this.getDisplay());
    toolkit.setBackground(ColorConstants.white);
    Composite formBody = toolkit.createComposite(this);
    formBody.setBackground(ColorConstants.white);

    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    setLayout(layout);
    formBody.setLayoutData(new GridData(GridData.FILL_BOTH));

    formBody.setLayout(new GridLayout(3, false));
    GridDataFactory formDefaultFactory = GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER);
    // Repository
    Label repositoryLabel =
        toolkit.createLabel(
            formBody, Messages.getString("connections.form.field.repository")); // $NON-NLS-1$
    formDefaultFactory.copy().applyTo(repositoryLabel);

    repositoryCombo = new ComboViewer(formBody, SWT.BORDER | SWT.READ_ONLY);
    repositoryCombo.setContentProvider(ArrayContentProvider.getInstance());
    repositoryCombo.setLabelProvider(new RepositoryFactoryLabelProvider());
    formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(repositoryCombo.getControl());

    // Name
    Label nameLabel =
        toolkit.createLabel(
            formBody, Messages.getString("connections.form.field.name")); // $NON-NLS-1$
    formDefaultFactory.copy().applyTo(nameLabel);

    nameText = toolkit.createText(formBody, "", SWT.BORDER); // $NON-NLS-1$
    formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(nameText);

    // Comment
    Label descriptionLabel =
        toolkit.createLabel(
            formBody, Messages.getString("connections.form.field.description")); // $NON-NLS-1$
    formDefaultFactory.copy().applyTo(descriptionLabel);

    descriptionText = toolkit.createText(formBody, "", SWT.BORDER); // $NON-NLS-1$
    formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(descriptionText);

    // User
    IBrandingService brandingService =
        (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    boolean usesMailCheck = brandingService.getBrandingConfiguration().isUseMailLoginCheck();
    Label userLabel;
    if (usesMailCheck) {
      userLabel =
          toolkit.createLabel(
              formBody, Messages.getString("connections.form.field.username")); // $NON-NLS-1$
    } else {
      userLabel =
          toolkit.createLabel(
              formBody, Messages.getString("connections.form.field.usernameNoMail")); // $NON-NLS-1$
    }

    formDefaultFactory.copy().applyTo(userLabel);

    userText = toolkit.createText(formBody, "", SWT.BORDER); // $NON-NLS-1$
    formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(userText);

    // Password
    passwordLabel =
        toolkit.createLabel(
            formBody, Messages.getString("connections.form.field.password")); // $NON-NLS-1$
    formDefaultFactory.copy().applyTo(passwordLabel);

    passwordText = toolkit.createText(formBody, "", SWT.PASSWORD | SWT.BORDER); // $NON-NLS-1$
    formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(passwordText);

    Label workSpaceLabel =
        toolkit.createLabel(
            formBody, Messages.getString("ConnectionFormComposite.WORKSPACE")); // $NON-NLS-1$
    formDefaultFactory.copy().applyTo(workSpaceLabel);

    Composite wsCompo = toolkit.createComposite(formBody);
    GridLayout wsCompoLayout = new GridLayout(2, false);
    wsCompoLayout.marginHeight = 0;
    wsCompoLayout.marginWidth = 0;

    wsCompo.setLayout(wsCompoLayout);
    formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(wsCompo);

    workSpaceText = toolkit.createText(wsCompo, "", SWT.BORDER); // $NON-NLS-1$
    formDefaultFactory.copy().grab(true, false).applyTo(workSpaceText);

    workSpaceButton = toolkit.createButton(wsCompo, null, SWT.PUSH);
    workSpaceButton.setToolTipText(
        Messages.getString("ConnectionFormComposite.SELECT_WORKSPACE")); // $NON-NLS-1$
    workSpaceButton.setImage(ImageProvider.getImage(EImage.THREE_DOTS_ICON));
    GridDataFactory.fillDefaults().applyTo(workSpaceButton);

    List<IRepositoryFactory> availableRepositories = getUsableRepositoryProvider();
    for (IRepositoryFactory current : availableRepositories) {
      Map<String, LabelText> list = new HashMap<String, LabelText>();
      Map<String, LabelText> listRequired = new HashMap<String, LabelText>();
      Map<String, Button> listButtons = new HashMap<String, Button>();
      Map<String, LabelledCombo> listChoices = new HashMap<String, LabelledCombo>();
      dynamicControls.put(current, list);
      dynamicRequiredControls.put(current, listRequired);
      dynamicButtons.put(current, listButtons);
      dynamicChoices.put(current, listChoices);

      for (final DynamicChoiceBean currentChoiceBean : current.getChoices()) {
        Label label = toolkit.createLabel(formBody, currentChoiceBean.getName());
        formDefaultFactory.copy().applyTo(label);

        Combo combo = new Combo(formBody, SWT.BORDER | SWT.READ_ONLY);
        for (String label1 : currentChoiceBean.getChoices().values()) {
          combo.add(label1);
        }

        formDefaultFactory.copy().grab(true, false).applyTo(combo);

        listChoices.put(currentChoiceBean.getId(), new LabelledCombo(label, combo));
      }

      for (DynamicFieldBean currentField : current.getFields()) {
        int textStyle = SWT.BORDER;
        if (currentField.isPassword()) {
          textStyle = textStyle | SWT.PASSWORD;
        }
        Label label = toolkit.createLabel(formBody, currentField.getName());
        formDefaultFactory.copy().align(SWT.FILL, SWT.CENTER).applyTo(label);

        Text text = toolkit.createText(formBody, "", textStyle); // $NON-NLS-1$

        formDefaultFactory.copy().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(text);
        LabelText labelText = new LabelText(label, text);
        if (currentField.isRequired()) {
          listRequired.put(currentField.getId(), labelText);
        }
        list.put(currentField.getId(), labelText);
      }

      for (final DynamicButtonBean currentButtonBean : current.getButtons()) {
        Button button = new Button(formBody, SWT.PUSH);
        button.setText(currentButtonBean.getName());
        button.addSelectionListener(new DelegateSelectionListener(currentButtonBean));
        formDefaultFactory.copy().align(SWT.RIGHT, SWT.CENTER).applyTo(button);

        listButtons.put(currentButtonBean.getId(), button);
      }
    }

    Label seperator = new Label(formBody, SWT.NONE);
    seperator.setVisible(false);
    GridData seperatorGridData = new GridData();
    seperatorGridData.horizontalSpan = 3;
    seperatorGridData.heightHint = 0;
    seperator.setLayoutData(seperatorGridData);
    Label placeHolder = new Label(formBody, SWT.NONE);
    // add delete buttons
    deleteProjectsButton = new Button(formBody, SWT.NONE);
    deleteProjectsButton.setText(
        Messages.getString("ConnectionFormComposite.deleteExistingProject")); // $NON-NLS-1$
    GridData deleteButtonGridData = new GridData();
    deleteButtonGridData.widthHint = LoginDialogV2.getNewButtonSize(deleteProjectsButton).x;
    deleteButtonGridData.horizontalSpan = 2;
    deleteProjectsButton.setLayoutData(deleteButtonGridData);

    addListeners();
    addWorkSpaceListener();
    fillLists();
    showHideDynamicsControls();
    showHideTexts();
    // validateFields();
  }
Пример #20
0
 @Override
 public Image getImage() {
   return ImageProvider.getImage(ECoreImage.PROJECT_ICON);
 }
  /*
   * (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;
  }
  /*
   * (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;
  }
Пример #23
0
  /** Create the contents in the main composite. */
  protected void createMainContents() {
    if (displayTitle) {
      title = new TabbedPropertyTitle(mainComposite, factory);

      FormData data = new FormData();
      data.left = new FormAttachment(0, 0);
      if (displayCompactToolbar) {
        data.right = new FormAttachment(90, 0);
      } else {
        data.right = new FormAttachment(100, 0);
      }
      data.top = new FormAttachment(0, 0);
      title.setLayoutData(data);

      if (displayCompactToolbar) {
        toolBarComposite = new Composite(mainComposite, SWT.NONE);
        compactButton = new Button(toolBarComposite, SWT.PUSH);
        compactButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
        compactButton.setToolTipText(
            Messages.getString(
                "TalendTabbedPropertyComposite.compactButton.toolTip")); //$NON-NLS-1$

        tableButton = new Button(toolBarComposite, SWT.PUSH);
        tableButton.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
        tableButton.setToolTipText(
            Messages.getString("TalendTabbedPropertyComposite.tableButton.toolTip")); // $NON-NLS-1$

        if (isCompactView()) {
          compactButton.setImage(ImageProvider.getImage(EImage.COMPACT_VIEW));
          tableButton.setImage(ImageProvider.getImage(EImage.NO_TABLE_VIEW));
        } else {
          compactButton.setImage(ImageProvider.getImage(EImage.NO_COMPACT_VIEW));
          tableButton.setImage(ImageProvider.getImage(EImage.TABLE_VIEW));
        }

        Rectangle compactRectangle = compactButton.getBounds();
        tableButton.setBounds(compactRectangle);

        compactButton.setVisible(false);
        tableButton.setVisible(false);

        data = new FormData();
        data.left = new FormAttachment(title, 0);
        data.top = new FormAttachment(0, -5);
        toolBarComposite.setLayoutData(data);
        GridData gridData = new GridData();
        gridData.horizontalAlignment = SWT.RIGHT;
        gridData.verticalAlignment = SWT.TOP;
        compactButton.setData(gridData);
        tableButton.setData(gridData);

        GridLayout layout = new GridLayout();
        layout.numColumns = 2;
        layout.horizontalSpacing = 0;
        layout.verticalSpacing = 0;
        layout.makeColumnsEqualWidth = true;
        toolBarComposite.setLayout(layout);
        toolBarComposite.setBackground(title.getBackground());
      }
    }

    leftComposite = factory.createComposite(mainComposite, SWT.NO_FOCUS);
    leftComposite.setLayout(new FormLayout());

    scrolledComposite =
        factory.createScrolledComposite(mainComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_FOCUS);
    scrolledComposite.setLayout(new FormLayout());

    FormData formData = new FormData();
    formData.left = new FormAttachment(leftComposite, 0);
    formData.right = new FormAttachment(100, 0);
    if (displayTitle) {
      formData.top = new FormAttachment(title, 0);
    } else {
      formData.top = new FormAttachment(0, 0);
    }
    formData.bottom = new FormAttachment(100, 0);
    scrolledComposite.setLayoutData(formData);

    formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(scrolledComposite, 0);
    if (displayTitle) {
      formData.top = new FormAttachment(title, 0);
    } else {
      formData.top = new FormAttachment(0, 0);
    }
    formData.bottom = new FormAttachment(100, 0);
    leftComposite.setLayoutData(formData);

    tabComposite = factory.createComposite(scrolledComposite, SWT.NO_FOCUS);
    tabComposite.setLayout(new FormLayout());
    tabComposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

    scrolledComposite.setContent(tabComposite);
    scrolledComposite.setAlwaysShowScrollBars(false);
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setExpandHorizontal(true);

    listComposite = new TalendTabbedPropertyList(leftComposite, factory);
    formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.top = new FormAttachment(0, 0);
    formData.bottom = new FormAttachment(100, 0);
    listComposite.setLayoutData(formData);

    FormData data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(0, 0);
    data.bottom = new FormAttachment(100, 0);
    tabComposite.setLayoutData(data);
  }
 public MoveDownButton() {
   super(ImageProvider.getImage(EImage.DOWN_ICON));
 }
 /**
  * DOC talend MoveUpTreeNodeButton constructor comment.
  *
  * @param parent
  * @param extendedViewer
  * @param tooltip
  * @param image
  */
 public MoveUpTreeNodeButton(Composite parent, FOXManager manager) {
   super(parent, manager, "Move up", ImageProvider.getImage(EImage.UP_ICON));
 }
 public CreatePigudfAction() {
   setText(Messages.getString("CreatePigudfAction.actionName")); // $NON-NLS-1$
   Image folderImg = ImageProvider.getImage(ECoreImage.ROUTINE_ICON);
   this.setImageDescriptor(OverlayImageProvider.getImageWithNew(folderImg));
 }