Пример #1
0
  private void initComboTimezones(Composite parent) {
    comboViewer = new ComboViewer(this, SWT.READ_ONLY);
    Combo comboTimezones = comboViewer.getCombo();
    comboTimezones.setToolTipText("Timezone");
    comboTimezones.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    comboViewer.setContentProvider(ArrayContentProvider.getInstance());
    comboViewer.setLabelProvider(
        new LabelProvider() {

          @Override
          public String getText(Object element) {
            if (element instanceof TimeZone) {
              return ((TimeZone) element).getID();
            }
            return super.getText(element);
          }
        });
    comboViewer.setInput(getAvailableTimezones());
    comboViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {

          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            if (comboViewer.getSelection() instanceof IStructuredSelection) {
              final IStructuredSelection selection =
                  (IStructuredSelection) comboViewer.getSelection();
              if (!(selection.isEmpty())) {
                final TimeZone seletedTimezone = (TimeZone) selection.getFirstElement();
                calendarValue.setTimeZone(seletedTimezone);
              }
            }
          }
        });
  }
Пример #2
0
  private TableViewer createServerTable(Composite parent) {
    TableViewer tableViewer = new TableViewer(parent, SWT.SINGLE | SWT.FULL_SELECTION);
    Table serverTable = tableViewer.getTable();
    serverTable.setHeaderVisible(true);
    serverTable.setLinesVisible(true);
    serverTable.setLayoutData(new GridData(GridData.FILL_BOTH));

    TableColumn nameCol = new TableColumn(serverTable, SWT.LEFT);
    nameCol.setText(Messages.ServersView_NAME);
    nameCol.setWidth(150);

    TableColumn statusCol = new TableColumn(serverTable, SWT.LEFT);
    statusCol.setText(Messages.ServersView_STATUS);
    statusCol.setWidth(75);

    TableColumn typeColumn = new TableColumn(serverTable, SWT.LEFT);
    typeColumn.setText(Messages.ServersView_TYPE);
    typeColumn.setWidth(125);

    TableColumn hostColumn = new TableColumn(serverTable, SWT.LEFT);
    hostColumn.setText(Messages.GenericServersView_HOST);
    hostColumn.setWidth(150);

    TableColumn portColumn = new TableColumn(serverTable, SWT.LEFT);
    portColumn.setText(Messages.GenericServersView_PORT);
    portColumn.setWidth(50);

    WebServerCorePlugin.getDefault().getServerManager().addServerChangeListener(this);
    tableViewer.setLabelProvider(new ServerLabelProvider());
    tableViewer.setContentProvider(ArrayContentProvider.getInstance());
    tableViewer.setInput(WebServerCorePlugin.getDefault().getServerManager().getServers());

    ThemePlugin.getDefault().getControlThemerFactory().apply(tableViewer);
    return tableViewer;
  }
  private void configureRuntimeCombo() throws CoreException {
    if (Widgets.isDisposed(runtimeComboViewer)) {
      return;
    }

    String lastUsedRuntime = lastSelectedRuntime;
    List<String> runtimesList = new ArrayList<String>();
    String selectedRuntime = null;

    serverRuntimes = getServerRuntimes(null);
    runtimeComboViewer.setInput(ArrayContentProvider.getInstance());
    runtimesList.addAll(serverRuntimes.keySet());
    runtimesList.add(Messages.newProjectWizardRuntimePageNoRuntimeSelectedLabel);
    runtimeComboViewer.setInput(runtimesList);
    runtimeComboViewer.setSelection(
        new StructuredSelection(Messages.newProjectWizardRuntimePageNoRuntimeSelectedLabel));

    for (Map.Entry<String, IRuntime> entry : serverRuntimes.entrySet()) {
      IRuntime runtime = entry.getValue();
      if (lastUsedRuntime != null && lastUsedRuntime.equals(runtime.getId())) {
        selectedRuntime = lastUsedRuntime;
      }
    }

    if (selectedRuntime != null) {
      runtimeComboViewer.setSelection(new StructuredSelection(selectedRuntime));
    }
  }
Пример #4
0
  private void createViewer(Composite parent) {
    viewer =
        new TableViewer(
            parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    createColumns(parent, viewer);
    final Table table = viewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    viewer.setContentProvider(ArrayContentProvider.getInstance());
    WritableList input = new WritableList(ModelProvider.INSTANCE.getTasks(), Task.class);
    ViewerSupport.bind(
        viewer,
        input,
        BeanProperties.values(new String[] {"id", "name", "status", "date", "info"}));

    viewer.setInput(input);
    getSite().setSelectionProvider(viewer);

    MenuManager manager = fillMenu();
    viewer.getControl().setMenu(manager.createContextMenu(viewer.getControl()));

    GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    gridData.horizontalSpan = 2;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    viewer.getControl().setLayoutData(gridData);
  }
  /**
   * 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;
  }
Пример #6
0
  public FieldInfoViewer(Group group, int style) {
    tableViewer = new TableViewer(group, style);

    createColumns(group, tableViewer);
    tableViewer.getTable().setHeaderVisible(true);
    tableViewer.getTable().setLinesVisible(true);

    tableViewer.setContentProvider(ArrayContentProvider.getInstance());
  }
  public DirectoryPathsEditor(Composite parent, IProject project, PluginImageHelper imageHelper) {
    super(parent, SWT.NONE);
    this.project = project;

    // generated by WindowBuilder
    setLayout(new GridLayout(2, false));

    tblVwrDirectoryPaths = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);
    tblVwrDirectoryPaths.setLabelProvider(new RichLabelProvider(imageHelper));
    tblVwrDirectoryPaths.setContentProvider(ArrayContentProvider.getInstance());

    tblDirectoryPaths = tblVwrDirectoryPaths.getTable();
    tblDirectoryPaths.setHeaderVisible(true);
    tblDirectoryPaths.setLinesVisible(true);
    tblDirectoryPaths.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    TableViewerColumn tblclmnVwrPath = new TableViewerColumn(tblVwrDirectoryPaths, SWT.NONE);
    TableColumn tblclmnPath = tblclmnVwrPath.getColumn();
    tblclmnPath.setWidth(290);
    tblclmnPath.setResizable(true);
    tblclmnPath.setText(directories);
    tblclmnVwrPath.setLabelProvider(
        new ColumnLabelProvider() {
          @Override
          public String getText(Object element) {
            return element.toString();
          }
        });

    Composite composite = new Composite(this, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
    composite.setLayout(new GridLayout(1, false));

    btnAdd = new Button(composite, SWT.NONE);
    btnAdd.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnAdd.setText(add);

    btnRemove = new Button(composite, SWT.NONE);
    btnRemove.setEnabled(false);
    btnRemove.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnRemove.setText(remove);

    new Label(composite, SWT.NONE);

    btnUp = new Button(composite, SWT.NONE);
    btnUp.setEnabled(false);
    btnUp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnUp.setText(up);

    btnDown = new Button(composite, SWT.NONE);
    btnDown.setEnabled(false);
    btnDown.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnDown.setText(down);

    addEventListeners();
  }
  /**
   * @param composite
   * @return the 3rd column composite
   */
  private void createTypeCombo(Composite composite) {
    Label datatypeLabel = new Label(composite, SWT.NONE);
    datatypeLabel.setText(Messages.datatypeLabel);

    datatypeCombo = new ComboViewer(new Combo(composite, SWT.READ_ONLY | SWT.BORDER));
    datatypeCombo.setContentProvider(ArrayContentProvider.getInstance());
    datatypeCombo.setLabelProvider(
        new LabelProvider() {
          @Override
          public String getText(Object element) {
            if (element.equals(SimulationPackage.eINSTANCE.getSimulationBoolean())) {
              return Messages.SimulationBoolean;
            }
            if (element.equals(SimulationPackage.eINSTANCE.getSimulationLiteralData())) {
              return Messages.SimulationLiteralData;
            }
            if (element.equals(SimulationPackage.eINSTANCE.getSimulationNumberData())) {
              return Messages.SimulationNumberData;
            }
            return ((EClass) element).getName();
          }
        });
    datatypeCombo.setInput(getAvailableDataTypes());
    if (dataClass == null) {
      dataClass = SimulationPackage.eINSTANCE.getSimulationBoolean();
    }
    gd = new GridData();
    gd.horizontalAlignment = GridData.FILL;
    gd.verticalAlignment = GridData.CENTER;
    gd.widthHint = 150;
    datatypeCombo.getControl().setLayoutData(gd);

    if (data != null) {
      datatypeCombo.setSelection(new StructuredSelection(data.eClass()));
      datatypeCombo.getControl().setEnabled(false);
    } else {
      datatypeCombo.setSelection(new StructuredSelection(datatypeCombo.getElementAt(0)));
    }
    datatypeCombo.addSelectionChangedListener(
        new ISelectionChangedListener() {

          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            dataClass =
                (EClass) ((IStructuredSelection) datatypeCombo.getSelection()).getFirstElement();
            changeDataConfigurationComposite(dataClass);
            setPageComplete(isPageComplete());
          }
        });

    // context.bindValue(SWTObservables.observeText(isOtherBased),SWTObservables.observeText(datatypeCombo.getControl()));

  }
  private Control getConsumerTabControl(Composite tabFolder) {
    Composite composite = new Composite(tabFolder, SWT.NONE);
    GridLayout gl = new GridLayout(2, false);
    composite.setLayout(gl);

    _nameText = createLabelAndText(composite, Messages.label_name);

    _hostText = createLabelAndText(composite, Messages.label_hostStar);
    _portText = createLabelAndText(composite, Messages.label_port);
    _usernameText = createLabelAndText(composite, Messages.label_userName);
    _passwordText = createLabelAndText(composite, Messages.label_password);
    _passwordText.setEchoChar('*');
    _securedCheckbox = createCheckbox(composite, Messages.label_secured, 2);

    Group consumeGroup = new Group(composite, SWT.NONE);
    consumeGroup.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1));
    consumeGroup.setLayout(new GridLayout(2, false));
    consumeGroup.setText(Messages.label_consumerOptions);

    getToolkit().createLabel(consumeGroup, Messages.label_accountType, SWT.NONE);
    _accountTypeCombo = new ComboViewer(consumeGroup);
    _accountTypeCombo.getControl().setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
    _accountTypeCombo.setContentProvider(ArrayContentProvider.getInstance());
    _accountTypeCombo.setLabelProvider(new LabelProvider());
    MailConsumerAccountType[] accountTypes =
        new MailConsumerAccountType[] {MailConsumerAccountType.IMAP, MailConsumerAccountType.POP3};
    _accountTypeCombo.setInput(accountTypes);
    getToolkit().adapt(_accountTypeCombo.getControl(), true, true);

    _folderNameText = createLabelAndText(consumeGroup, Messages.label_folderName);
    _fetchSizeText = createLabelAndText(consumeGroup, Messages.label_fetchSize, 2);
    _unseenCheckbox = createCheckbox(consumeGroup, Messages.label_unreadOnly, 2);
    _deleteCheckbox = createCheckbox(consumeGroup, Messages.label_delete, 2);

    _opSelectorComposite = new OperationSelectorComposite(composite, SWT.NONE, this);
    _opSelectorComposite.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1));
    _opSelectorComposite.setLayout(new GridLayout(2, false));
    _opSelectorComposite.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            handleModify(_opSelectorComposite);
          }
        });

    return composite;
  }
Пример #10
0
 @Override
 protected Control createDialogArea(Composite parent) {
   Composite main = new Composite(parent, SWT.NONE);
   GridLayoutFactory.fillDefaults().applyTo(main);
   GridDataFactory.fillDefaults().grab(true, true).applyTo(main);
   TableViewer tv = new TableViewer(main, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
   GridDataFactory.fillDefaults().grab(true, true).applyTo(tv.getControl());
   tv.setContentProvider(ArrayContentProvider.getInstance());
   tv.setLabelProvider(new CommitLabelProvider());
   Table table = tv.getTable();
   TableColumn c0 = new TableColumn(table, SWT.NONE);
   c0.setWidth(70);
   c0.setText(UIText.CommitSelectDialog_IdColumn);
   TableColumn c1 = new TableColumn(table, SWT.NONE);
   c1.setWidth(200);
   c1.setText(UIText.CommitSelectDialog_MessageColumn);
   TableColumn c2 = new TableColumn(table, SWT.NONE);
   c2.setWidth(200);
   c2.setText(UIText.CommitSelectDialog_AuthoColumn);
   TableColumn c3 = new TableColumn(table, SWT.NONE);
   c3.setWidth(150);
   c3.setText(UIText.CommitSelectDialog_DateColumn);
   tv.setInput(commits);
   table.setHeaderVisible(true);
   tv.addSelectionChangedListener(
       new ISelectionChangedListener() {
         @Override
         public void selectionChanged(SelectionChangedEvent event) {
           if (!event.getSelection().isEmpty())
             selected =
                 (RevCommit) ((IStructuredSelection) event.getSelection()).getFirstElement();
           else selected = null;
           getButton(OK).setEnabled(selected != null);
         }
       });
   tv.addDoubleClickListener(
       new IDoubleClickListener() {
         @Override
         public void doubleClick(DoubleClickEvent event) {
           okPressed();
         }
       });
   return main;
 }
Пример #11
0
  private void createFilesArea(Composite parent, FormToolkit toolkit, int span) {
    Section files = createSection(parent, toolkit, span);
    Composite filesArea = createSectionClient(files, toolkit);
    GridLayout filesAreaLayout = (GridLayout) filesArea.getLayout();
    filesAreaLayout.marginLeft = 0;
    filesAreaLayout.marginRight = 0;
    filesAreaLayout.marginTop = 0;
    filesAreaLayout.marginBottom = 0;

    CommitFileDiffViewer viewer =
        new CommitFileDiffViewer(
            filesArea,
            getSite(),
            SWT.MULTI
                | SWT.H_SCROLL
                | SWT.V_SCROLL
                | SWT.FULL_SELECTION
                | toolkit.getBorderStyle());
    // commit file diff viewer uses a nested composite with a stack layout
    // and so margins need to be applied to have form toolkit style borders
    toolkit.paintBordersFor(viewer.getTable().getParent());
    viewer.getTable().setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
    StackLayout viewerLayout = (StackLayout) viewer.getControl().getParent().getLayout();
    viewerLayout.marginHeight = 2;
    viewerLayout.marginWidth = 2;
    GridDataFactory.fillDefaults()
        .grab(true, true)
        .hint(SWT.DEFAULT, 80)
        .applyTo(viewer.getTable().getParent());
    viewer.setContentProvider(ArrayContentProvider.getInstance());
    viewer.setTreeWalk(getCommit().getRepository(), null);

    FileDiff[] diffs = getCommit().getDiffs();
    viewer.setInput(diffs);
    files.setText(
        MessageFormat.format(UIText.CommitEditorPage_SectionFiles, Integer.valueOf(diffs.length)));

    updateSectionClient(files, filesArea, toolkit);
  }
Пример #12
0
  @Override
  public Control createControl(Composite parent) {

    Composite body = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    body.setLayout(layout);

    // 1) Create pageable table with 10 items per page
    // This SWT Component create internally a SWT Table+JFace TreeViewer
    int pageSize = 10;
    pageableTable =
        new PageableTable(
            body,
            SWT.BORDER,
            SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL,
            pageSize,
            PageResultContentProvider.getInstance(),
            ResultAndNavigationPageGraphicsRendererFactory.getBlueFactory(),
            null);
    pageableTable.setLayoutData(new GridData(GridData.FILL_BOTH));

    // 2) Initialize the table viewer + SWT Table
    TableViewer viewer = pageableTable.getViewer();
    viewer.setContentProvider(ArrayContentProvider.getInstance());
    viewer.setLabelProvider(new LabelProvider());

    Table table = viewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    // 3) Create Table columns with sort of paginated list.
    createColumns(viewer);

    // 3) Set current page to 0 to refresh the table
    pageableTable.setPageLoader(NebulaWidgetServices.getInstance());
    pageableTable.setCurrentPage(0);

    return body;
  }
Пример #13
0
  @PostConstruct
  public void postConstruct(Composite parent) {
    devicesGroupsView = partService.findPart("dec-rcp.part.devices.groups");
    devicesView = partService.findPart("dec-rcp.part.devices.list");
    sensorsView = partService.findPart("dec-rcp.part.devices.sensors");

    FilterMatcher matcher = new FilterMatcher();
    FilteredTable table =
        new FilteredTable(
            parent,
            SWT.SINGLE | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION,
            matcher,
            true);
    viewer = table.getViewer();
    viewer.setContentProvider(ArrayContentProvider.getInstance());
    viewer
        .getTable()
        .addSelectionListener(
            new SensorsViewerSelectionListener(
                viewer,
                devicesGroupsView,
                devicesView,
                sensorsView,
                partService,
                selectionService,
                context));

    TableViewerColumn idColumnViewer = new TableViewerColumn(viewer, SWT.NONE);
    idColumnViewer.getColumn().setWidth(50);
    idColumnViewer.getColumn().setText("#");
    idColumnViewer.setLabelProvider(new IDColumnLabelProvider(viewer));

    TableViewerColumn deviceGroupsNameColumnViewer = new TableViewerColumn(viewer, SWT.NONE);
    deviceGroupsNameColumnViewer.getColumn().setWidth(800);
    deviceGroupsNameColumnViewer.getColumn().setText("Sensor Name");
    deviceGroupsNameColumnViewer.setLabelProvider(new NameColumnLabelProvider(viewer));
    viewer.getTable().setHeaderVisible(true);
  }
Пример #14
0
  private void createBranchesArea(Composite parent, FormToolkit toolkit, int span) {
    branchSection = createSection(parent, toolkit, span);
    Composite branchesArea = createSectionClient(branchSection, toolkit);

    branchViewer = new TableViewer(toolkit.createTable(branchesArea, SWT.V_SCROLL | SWT.H_SCROLL));
    GridDataFactory.fillDefaults()
        .grab(true, true)
        .hint(SWT.DEFAULT, 50)
        .applyTo(branchViewer.getControl());
    branchViewer.setSorter(new ViewerSorter());
    branchViewer.setLabelProvider(
        new GitLabelProvider() {

          public String getText(Object element) {
            return Repository.shortenRefName(super.getText(element));
          }
        });
    branchViewer.setContentProvider(ArrayContentProvider.getInstance());
    branchViewer.getTable().setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);

    fillBranches();

    updateSectionClient(branchSection, branchesArea, toolkit);
  }
  @SuppressWarnings({"unchecked", "rawtypes"})
  @Override
  protected void doCreateControls(final Composite parent, DataBindingContext dbc) {
    GridLayoutFactory.fillDefaults().numColumns(3).margins(10, 10).applyTo(parent);

    // userdoc link (JBIDE-20401)
    this.userdocLink = new StyledText(parent, SWT.WRAP); // text set in #showHideUserdocLink
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(3, 1).applyTo(userdocLink);
    showHideUserdocLink();
    IObservableValue userdocUrlObservable =
        BeanProperties.value(ConnectionWizardPageModel.PROPERTY_USERDOCURL).observe(pageModel);
    StyledTextUtils.emulateLinkAction(userdocLink, r -> onUserdocLinkClicked(userdocUrlObservable));
    userdocUrlObservable.addValueChangeListener(
        new IValueChangeListener() {

          @Override
          public void handleValueChange(ValueChangeEvent event) {
            showHideUserdocLink();
          }
        });

    IObservableValue connectionFactoryObservable =
        BeanProperties.value(ConnectionWizardPageModel.PROPERTY_CONNECTION_FACTORY)
            .observe(pageModel);

    // filler
    Label fillerLabel = new Label(parent, SWT.NONE);
    GridDataFactory.fillDefaults().span(3, 3).hint(SWT.DEFAULT, 6).applyTo(fillerLabel);

    // existing connections combo
    Label connectionLabel = new Label(parent, SWT.NONE);
    connectionLabel.setText("Connection:");
    GridDataFactory.fillDefaults()
        .align(SWT.LEFT, SWT.CENTER)
        .hint(100, SWT.DEFAULT)
        .applyTo(connectionLabel);
    Combo connectionCombo = new Combo(parent, SWT.DEFAULT);
    GridDataFactory.fillDefaults()
        .span(2, 1)
        .align(SWT.FILL, SWT.CENTER)
        .grab(true, false)
        .applyTo(connectionCombo);
    ComboViewer connectionComboViewer = new ComboViewer(connectionCombo);
    connectionComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    connectionComboViewer.setLabelProvider(new ConnectionColumLabelProvider());
    connectionComboViewer.setInput(pageModel.getAllConnections());
    Binding selectedConnectionBinding =
        ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(connectionComboViewer))
            .validatingAfterGet(
                new IsNotNullValidator(
                    ValidationStatus.cancel("You have to select or create a new connection.")))
            .to(
                BeanProperties.value(
                        ConnectionWizardPageModel.PROPERTY_SELECTED_CONNECTION, IConnection.class)
                    .observe(pageModel))
            .in(dbc);
    ControlDecorationSupport.create(
        selectedConnectionBinding,
        SWT.LEFT | SWT.TOP,
        null,
        new RequiredControlDecorationUpdater());

    // server type
    Label connectionFactoryLabel = new Label(parent, SWT.NONE);
    connectionFactoryLabel.setText("Server type:");
    GridDataFactory.fillDefaults()
        .align(SWT.LEFT, SWT.CENTER)
        .hint(100, SWT.DEFAULT)
        .applyTo(connectionFactoryLabel);
    Combo connectionFactoryCombo = new Combo(parent, SWT.DEFAULT);
    GridDataFactory.fillDefaults()
        .span(2, 1)
        .align(SWT.FILL, SWT.CENTER)
        .grab(true, false)
        .applyTo(connectionFactoryCombo);
    ComboViewer connectionFactoriesViewer = new ComboViewer(connectionFactoryCombo);
    connectionFactoriesViewer.setContentProvider(ArrayContentProvider.getInstance());
    connectionFactoriesViewer.setLabelProvider(
        new ColumnLabelProvider() {

          @Override
          public String getText(Object element) {
            if (!(element instanceof IConnectionFactory)) {
              return element.toString();
            } else {
              return ((IConnectionFactory) element).getName();
            }
          }
        });
    connectionFactoriesViewer.setInput(pageModel.getAllConnectionFactories());
    final IViewerObservableValue selectedServerType =
        ViewerProperties.singleSelection().observe(connectionFactoriesViewer);
    ValueBindingBuilder.bind(selectedServerType).to(connectionFactoryObservable).in(dbc);

    // server
    Button useDefaultServerCheckbox = new Button(parent, SWT.CHECK);
    useDefaultServerCheckbox.setText("Use default server");
    GridDataFactory.fillDefaults()
        .span(3, 1)
        .align(SWT.FILL, SWT.FILL)
        .applyTo(useDefaultServerCheckbox);
    ValueBindingBuilder.bind(WidgetProperties.selection().observe(useDefaultServerCheckbox))
        .to(
            BeanProperties.value(
                    ConnectionWizardPageModel.PROPERTY_USE_DEFAULT_HOST, IConnection.class)
                .observe(pageModel))
        .in(dbc);

    IObservableValue hasDefaultHostObservable =
        BeanProperties.value(ConnectionWizardPageModel.PROPERTY_HAS_DEFAULT_HOST)
            .observe(pageModel);
    ValueBindingBuilder.bind(WidgetProperties.enabled().observe(useDefaultServerCheckbox))
        .notUpdating(hasDefaultHostObservable)
        .in(dbc);

    Label serverLabel = new Label(parent, SWT.NONE);
    serverLabel.setText("Server:");
    GridDataFactory.fillDefaults()
        .align(SWT.LEFT, SWT.CENTER)
        .hint(100, SWT.DEFAULT)
        .applyTo(serverLabel);
    Combo serversCombo = new Combo(parent, SWT.BORDER);
    ComboViewer serversViewer = new ComboViewer(serversCombo);
    serversViewer.setContentProvider(new ObservableListContentProvider());
    serversViewer.setInput(
        BeanProperties.list(ConnectionWizardPageModel.PROPERTY_ALL_HOSTS).observe(pageModel));
    GridDataFactory.fillDefaults()
        .align(SWT.FILL, SWT.FILL)
        .grab(true, false)
        .applyTo(serversCombo);
    final IObservableValue serverUrlObservable = WidgetProperties.text().observe(serversCombo);
    serversCombo.addFocusListener(onServerFocusLost(serverUrlObservable));
    ValueBindingBuilder.bind(serverUrlObservable)
        .converting(new TrimTrailingSlashConverter())
        .to(BeanProperties.value(ConnectionWizardPageModel.PROPERTY_HOST).observe(pageModel))
        .in(dbc);

    MultiValidator serverUrlValidator =
        new MultiValidator() {

          @Override
          protected IStatus validate() {
            Object value = serverUrlObservable.getValue();
            if (!(value instanceof String) || StringUtils.isEmpty((String) value)) {
              return ValidationStatus.cancel("Please provide an OpenShift server url.");
            } else if (!UrlUtils.isValid((String) value)) {
              return ValidationStatus.error("Please provide a valid OpenShift server url.");
            }
            return ValidationStatus.ok();
          }
        };
    ControlDecorationSupport.create(
        serverUrlValidator, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
    dbc.addValidationStatusProvider(serverUrlValidator);

    ValueBindingBuilder.bind(WidgetProperties.enabled().observe(serversCombo))
        .notUpdatingParticipant()
        .to(
            BeanProperties.value(ConnectionWizardPageModel.PROPERTY_USE_DEFAULT_HOST)
                .observe(pageModel))
        .converting(new InvertingBooleanConverter())
        .in(dbc);

    // connect error
    dbc.addValidationStatusProvider(
        new MultiValidator() {
          IObservableValue observable =
              BeanProperties.value(
                      ConnectionWizardPageModel.PROPERTY_CONNECTED_STATUS, IStatus.class)
                  .observe(pageModel);

          @Override
          protected IStatus validate() {
            return (IStatus) observable.getValue();
          }
        });

    // connection editors
    Group authenticationDetailsGroup = new Group(parent, SWT.NONE);
    authenticationDetailsGroup.setText("Authentication");
    GridDataFactory.fillDefaults()
        .align(SWT.FILL, SWT.FILL)
        .span(3, 1)
        .applyTo(authenticationDetailsGroup);
    GridLayoutFactory.fillDefaults().margins(0, 0).applyTo(authenticationDetailsGroup);
    // additional nesting required because of https://bugs.eclipse.org/bugs/show_bug.cgi?id=478618
    Composite authenticationDetailsContainer = new Composite(authenticationDetailsGroup, SWT.None);
    GridDataFactory.fillDefaults()
        .align(SWT.FILL, SWT.FILL)
        .grab(true, true)
        .applyTo(authenticationDetailsContainer);
    this.connectionEditors =
        new ConnectionEditorsStackedView(
            connectionFactoryObservable, this, authenticationDetailsContainer, dbc);
    connectionEditors.createControls();

    // adv editors
    Composite advEditorContainer = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().margins(0, 0).applyTo(authenticationDetailsGroup);
    GridDataFactory.fillDefaults()
        .align(SWT.FILL, SWT.FILL)
        .span(3, 1)
        .grab(true, true)
        .applyTo(advEditorContainer);
    this.advConnectionEditors =
        new AdvancedConnectionEditorsStackedView(
            connectionFactoryObservable, pageModel, advEditorContainer, dbc);
    advConnectionEditors.createControls();
  }
  @Override
  public void createPartControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(new FillLayout(SWT.HORIZONTAL));

    Form frmServiosPrestados = formToolkit.createForm(container);
    formToolkit.paintBordersFor(frmServiosPrestados);
    frmServiosPrestados.setText("Servi\u00E7os Prestados");
    frmServiosPrestados.getBody().setLayout(new GridLayout(5, false));

    Label lblBuscar = new Label(frmServiosPrestados.getBody(), SWT.NONE);
    lblBuscar.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    formToolkit.adapt(lblBuscar, true, true);
    lblBuscar.setText("Buscar:");

    txtFiltro = new Text(frmServiosPrestados.getBody(), SWT.BORDER);
    txtFiltro.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent e) {
            filtro.setSearch(txtFiltro.getText());
            tvServicoPrestado.refresh();
          }
        });
    txtFiltro.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1));
    txtFiltro.setMessage("Filtro...");
    formToolkit.adapt(txtFiltro, true, true);

    Label lblPeriodoDe =
        formToolkit.createLabel(frmServiosPrestados.getBody(), "Per\u00EDodo de", SWT.NONE);
    lblPeriodoDe.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));

    txtDataInicial = new MecasoftText(frmServiosPrestados.getBody(), SWT.NONE);
    txtDataInicial.setOptions(MecasoftText.NUMEROS, 10);
    txtDataInicial.addChars(FormatterHelper.MECASOFTTXTDATA, new Integer[] {2, 4}, null, null);
    formToolkit.adapt(txtDataInicial);
    formToolkit.paintBordersFor(txtDataInicial);

    Calendar c = Calendar.getInstance();
    c.add(Calendar.MONTH, -1);
    txtDataInicial.setText(FormatterHelper.getDateFormatData().format(c.getTime()));

    Label lblAte = new Label(frmServiosPrestados.getBody(), SWT.NONE);
    formToolkit.adapt(lblAte, true, true);
    lblAte.setText("at\u00E9");

    txtDataFinal = new MecasoftText(frmServiosPrestados.getBody(), SWT.NONE);
    txtDataFinal.setOptions(MecasoftText.NUMEROS, 10);
    txtDataFinal.addChars(FormatterHelper.MECASOFTTXTDATA, new Integer[] {2, 4}, null, null);
    formToolkit.adapt(txtDataFinal);
    formToolkit.paintBordersFor(txtDataFinal);

    txtDataFinal.setText(FormatterHelper.getDateFormatData().format(new Date()));

    tvServicoPrestado =
        new TableViewer(frmServiosPrestados.getBody(), SWT.BORDER | SWT.FULL_SELECTION);
    tvServicoPrestado.addDoubleClickListener(
        new IDoubleClickListener() {
          public void doubleClick(DoubleClickEvent event) {
            try {
              IStructuredSelection selecao =
                  (IStructuredSelection) tvServicoPrestado.getSelection();

              if (selecao.isEmpty()) return;

              ServicoPrestado sp = (ServicoPrestado) selecao.getFirstElement();

              getSite()
                  .getPage()
                  .openEditor(new AbrirOrdemServicoEditorInput(sp), AbrirOrdemServicoEditor.ID);
            } catch (PartInitException e) {
              e.printStackTrace();
            }
          }
        });
    table = tvServicoPrestado.getTable();
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1));
    tvServicoPrestado.setContentProvider(ArrayContentProvider.getInstance());
    tvServicoPrestado.addFilter(filtro);
    formToolkit.paintBordersFor(table);

    TableViewerColumn tvcNumero = new TableViewerColumn(tvServicoPrestado, SWT.NONE);
    tvcNumero.setLabelProvider(
        new ColumnLabelProvider() {
          @Override
          public String getText(Object element) {
            return ((ServicoPrestado) element).getId().toString();
          }
        });
    TableColumn tblclmnNumero = tvcNumero.getColumn();
    tblclmnNumero.setWidth(100);
    tblclmnNumero.setText("N\u00FAmero");

    TableViewerColumn tvcCliente = new TableViewerColumn(tvServicoPrestado, SWT.NONE);
    tvcCliente.setLabelProvider(
        new ColumnLabelProvider() {
          @Override
          public String getText(Object element) {
            return ((ServicoPrestado) element).getCliente().getNomeFantasia();
          }
        });
    TableColumn tblclmnCliente = tvcCliente.getColumn();
    tblclmnCliente.setWidth(203);
    tblclmnCliente.setText("Cliente");

    TableViewerColumn tvcVeiculo = new TableViewerColumn(tvServicoPrestado, SWT.NONE);
    tvcVeiculo.setLabelProvider(
        new ColumnLabelProvider() {
          @Override
          public String getText(Object element) {
            return ((ServicoPrestado) element).getVeiculo().getModelo();
          }
        });
    TableColumn tblclmnVeculo = tvcVeiculo.getColumn();
    tblclmnVeculo.setWidth(148);
    tblclmnVeculo.setText("Ve\u00EDculo");

    TableViewerColumn tvcMecanico = new TableViewerColumn(tvServicoPrestado, SWT.NONE);
    tvcMecanico.setLabelProvider(
        new ColumnLabelProvider() {
          @Override
          public String getText(Object element) {
            service.setServicoPrestado((ServicoPrestado) element);
            StatusServico status = service.getServicoPrestado().getUltimoStatus();

            if (status != null) return status.getFuncionario().getNomeFantasia();

            return "Não há mecânico";
          }
        });
    TableColumn tblclmnMecnico = tvcMecanico.getColumn();
    tblclmnMecnico.setWidth(152);
    tblclmnMecnico.setText("Mec\u00E2nico");

    TableViewerColumn tvcStatus = new TableViewerColumn(tvServicoPrestado, SWT.NONE);
    tvcStatus.setLabelProvider(
        new ColumnLabelProvider() {
          @Override
          public String getText(Object element) {
            service.setServicoPrestado((ServicoPrestado) element);
            StatusServico status = service.getServicoPrestado().getUltimoStatus();

            if (status != null) return status.getStatus().getDescricao();

            return "Serviço não iniciado";
          }
        });
    TableColumn tblclmnStatusAtual = tvcStatus.getColumn();
    tblclmnStatusAtual.setWidth(137);
    tblclmnStatusAtual.setText("Status Atual");
    frmServiosPrestados.getToolBarManager().add(actionAtualizar);
    frmServiosPrestados.getToolBarManager().add(actionNovo);
    frmServiosPrestados.updateToolBar();
  }
Пример #17
0
    /** @see Composite#Composite(Composite, int) */
    public InstanceSelectorControl(Composite parent, int style) {
      super(parent, style);

      refreshImage =
          DataViewPlugin.getImageDescriptor("icons/refresh.gif").createImage(); // $NON-NLS-1$

      GridLayout layout = new GridLayout((spaceID == null) ? (4) : (3), false);
      layout.marginHeight = 2;
      layout.marginWidth = 3;
      setLayout(layout);

      // schema type selector
      if (spaceID == null) {
        schemaSpaces = new ComboViewer(this, SWT.READ_ONLY);
        schemaSpaces.setLabelProvider(
            new LabelProvider() {

              @Override
              public String getText(Object element) {
                if (element instanceof SchemaSpaceID) {
                  switch ((SchemaSpaceID) element) {
                    case SOURCE:
                      return Messages.InstanceServiceFeatureSelector_SourceReturnText;
                    case TARGET:
                      return Messages.InstanceServiceFeatureSelector_TargetReturnText;
                    default:
                      return Messages.InstanceServiceFeatureSelector_defaultReturnText;
                  }
                } else {
                  return super.getText(element);
                }
              }
            });
        schemaSpaces.setContentProvider(ArrayContentProvider.getInstance());
        schemaSpaces.setInput(new Object[] {SchemaSpaceID.SOURCE, SchemaSpaceID.TARGET});
        schemaSpaces.setSelection(new StructuredSelection(SchemaSpaceID.SOURCE));
      } else {
        schemaSpaces = null;
      }

      // feature type selector
      typeDefinitions = new ComboViewer(this, SWT.READ_ONLY);
      typeDefinitions.setContentProvider(ArrayContentProvider.getInstance());
      typeDefinitions.setComparator(new DefinitionComparator());
      typeDefinitions.setLabelProvider(new DefinitionLabelProvider(null));
      typeDefinitions.addSelectionChangedListener(
          new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
              updateSelection();
            }
          });

      // filter field
      filterField =
          new CQLFilterField(
              (selectedType == null) ? (null) : (selectedType), this, SWT.NONE, spaceID);
      filterField.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
      filterField.addListener(
          new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
              if (evt.getPropertyName().equals(TypeFilterField.PROPERTY_FILTER)) {
                updateSelection();
              }
            }
          });

      // refresh button
      /*
       * XXX disabled for now - Button refresh = new Button(this,
       * SWT.PUSH); refresh.setImage(refreshImage);
       * refresh.setToolTipText("Refresh"); refresh.setLayoutData(new
       * GridData(SWT.CENTER, SWT.CENTER, false, false));
       * refresh.addSelectionListener(new SelectionAdapter() {
       *
       * @Override public void widgetSelected(SelectionEvent e) {
       * updateSelection(); }
       *
       * });
       */

      // max count selector
      count = new ComboViewer(this, SWT.READ_ONLY);
      count.setContentProvider(ArrayContentProvider.getInstance());
      count.setInput(
          new Integer[] {
            Integer.valueOf(1),
            Integer.valueOf(2),
            Integer.valueOf(3),
            Integer.valueOf(4),
            Integer.valueOf(5)
          });
      count.setSelection(new StructuredSelection(Integer.valueOf(2)));
      count.addSelectionChangedListener(
          new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
              updateSelection();
            }
          });

      updateTypesSelection();

      if (schemaSpaces != null) {
        schemaSpaces.addSelectionChangedListener(
            new ISelectionChangedListener() {

              @Override
              public void selectionChanged(SelectionChangedEvent event) {
                updateTypesSelection();
              }
            });
      }

      // service listeners
      SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
      ss.addSchemaServiceListener(
          schemaListener =
              new SchemaServiceListener() {

                @Override
                public void schemaAdded(SchemaSpaceID spaceID, Schema schema) {
                  final Display display = PlatformUI.getWorkbench().getDisplay();
                  display.syncExec(
                      new Runnable() {

                        @Override
                        public void run() {
                          updateTypesSelection();
                        }
                      });
                }

                @Override
                public void schemasCleared(SchemaSpaceID spaceID) {
                  final Display display = PlatformUI.getWorkbench().getDisplay();
                  display.syncExec(
                      new Runnable() {

                        @Override
                        public void run() {
                          updateTypesSelection();
                        }
                      });
                }

                @Override
                public void mappableTypesChanged(
                    SchemaSpaceID spaceID, Collection<? extends TypeDefinition> types) {
                  final Display display = PlatformUI.getWorkbench().getDisplay();
                  display.syncExec(
                      new Runnable() {

                        @Override
                        public void run() {
                          updateTypesSelection();
                        }
                      });
                }
              });

      InstanceService is = PlatformUI.getWorkbench().getService(InstanceService.class);
      is.addListener(
          instanceListener =
              new InstanceServiceAdapter() {

                @Override
                public void datasetChanged(DataSet dataSet) {
                  final Display display = PlatformUI.getWorkbench().getDisplay();
                  display.syncExec(
                      new Runnable() {

                        @Override
                        public void run() {
                          updateTypesSelection();
                        }
                      });
                }
              });
    }
  /* (non-Javadoc)
   * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
   */
  @Override
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout(3, false));

    Group runtimeGrp = new Group(container, SWT.NONE);
    GridData runtimeGrpData = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1);
    runtimeGrp.setLayout(new GridLayout(3, false));
    runtimeGrp.setLayoutData(runtimeGrpData);
    runtimeGrp.setText(Messages.newProjectWizardRuntimePageRuntimeGroupLabel);

    Label runtimeLabel = new Label(runtimeGrp, SWT.NONE);
    GridData runtimeLabelData = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1);
    runtimeLabel.setLayoutData(runtimeLabelData);
    runtimeLabel.setText(Messages.newProjectWizardRuntimePageRuntimeLabel);

    runtimeComboViewer = new ComboViewer(runtimeGrp, SWT.NONE | SWT.READ_ONLY);
    runtimeComboViewer.setComparator(
        new ViewerComparator(
            new Comparator<String>() {

              @Override
              public int compare(String o1, String o2) {
                if (Messages.newProjectWizardRuntimePageNoRuntimeSelectedLabel.equals(o1)) {
                  return -1;
                }
                return o1.compareTo(o2);
              }
            }));

    GridData runtimeComboData = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
    runtimeComboViewer.getCombo().setLayoutData(runtimeComboData);
    runtimeComboViewer
        .getCombo()
        .setToolTipText(Messages.newProjectWizardRuntimePageRuntimeDescription);
    runtimeComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    runtimeComboViewer
        .getCombo()
        .addModifyListener(
            new ModifyListener() {
              /*
               * (non-Javadoc)
               * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
               */
              @Override
              public void modifyText(ModifyEvent e) {
                lastSelectedRuntime = runtimeComboViewer.getSelection().toString();
                preselectCamelVersionForRuntime(determineRuntimeCamelVersion(getSelectedRuntime()));
                validate();
              }
            });

    try {
      configureRuntimeCombo();
    } catch (CoreException ex) {
      ProjectTemplatesActivator.pluginLog().logError(ex);
    }

    Button runtimeNewButton = new Button(runtimeGrp, SWT.NONE);
    GridData runtimeNewButtonData = new GridData(SWT.FILL, SWT.CENTER, false, false);
    runtimeNewButton.setLayoutData(runtimeNewButtonData);
    runtimeNewButton.setText(Messages.newProjectWizardRuntimePageRuntimeNewButtonLabel);
    runtimeNewButton.setToolTipText(
        Messages.newProjectWizardRuntimePageRuntimeNewButtonDescription);
    runtimeNewButton.addSelectionListener(
        new SelectionAdapter() {
          /*
           * (non-Javadoc)
           * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
           */

          @Override
          public void widgetSelected(SelectionEvent e) {
            String[] oldRuntimes = runtimeComboViewer.getCombo().getItems();
            boolean created = ServerUIUtil.showNewRuntimeWizard(getShell(), null, null);
            if (created) {
              String[] newRuntimes = runtimeComboViewer.getCombo().getItems();
              String newRuntime = getNewRuntime(oldRuntimes, newRuntimes);
              if (newRuntime != null) {
                runtimeComboViewer.setSelection(new StructuredSelection(newRuntime));
              }
            }
          }
        });

    new Label(runtimeGrp, SWT.None);

    Group camelGrp = new Group(container, SWT.NONE);
    GridData camelGrpData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 20);
    camelGrp.setLayout(new GridLayout(3, false));
    camelGrp.setLayoutData(camelGrpData);
    camelGrp.setText(Messages.newProjectWizardRuntimePageCamelGroupLabel);

    Label camelVersionLabel = new Label(camelGrp, SWT.NONE);
    GridData camelLabelData = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1);
    camelVersionLabel.setLayoutData(camelLabelData);
    camelVersionLabel.setText(Messages.newProjectWizardRuntimePageCamelLabel);

    camelVersionCombo = new Combo(camelGrp, SWT.RIGHT | SWT.READ_ONLY);
    GridData camelComboData = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
    camelVersionCombo.setLayoutData(camelComboData);
    camelVersionCombo.setItems(getSupportedCamelVersions());
    camelVersionCombo.select(Math.max(camelVersionCombo.getItemCount() - 1, 0));
    camelVersionCombo.setToolTipText(Messages.newProjectWizardRuntimePageCamelDescription);
    camelVersionCombo.addSelectionListener(
        new SelectionAdapter() {
          /* (non-Javadoc)
           * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
           */
          @Override
          public void widgetSelected(SelectionEvent e) {
            validate();
          }
        });
    // TODO: leaving that out until we decide to support other camel versions than the ones we ship
    //		camelVersionCombo.addFocusListener(new FocusAdapter() {
    //			/* (non-Javadoc)
    //			 * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
    //			 */
    //			@Override
    //			public void focusLost(FocusEvent e) {
    //				super.focusLost(e);
    //				validate();
    //			}
    //
    //			/* (non-Javadoc)
    //			 * @see org.eclipse.swt.events.FocusAdapter#focusGained(org.eclipse.swt.events.FocusEvent)
    //			 */
    //			@Override
    //			public void focusGained(FocusEvent e) {
    //				super.focusGained(e);
    //				setPageComplete(false);
    //			}
    //		});

    new Label(camelGrp, SWT.None);

    warningIconLabel = new Label(camelGrp, SWT.None);
    GridData camelLblData = new GridData(SWT.FILL, SWT.TOP, false, true, 1, 20);
    camelLblData.verticalIndent = 20;
    warningIconLabel.setImage(getSWTImage(SWT.ICON_WARNING));
    warningIconLabel.setLayoutData(camelLblData);
    warningIconLabel.setVisible(false);

    camelInfoText = new StyledText(camelGrp, SWT.WRAP | SWT.MULTI);
    GridData camelInfoData = new GridData(SWT.FILL, SWT.TOP, true, true, 2, 20);
    camelInfoData.verticalIndent = 0;
    camelInfoData.heightHint = 150;
    camelInfoText.setLayoutData(camelInfoData);
    camelInfoText.setEnabled(false);
    camelInfoText.setEditable(false);
    camelInfoText.setBackground(container.getBackground());

    new Label(camelGrp, SWT.None);

    setControl(container);

    IRuntimeLifecycleListener listener =
        new IRuntimeLifecycleListener() {

          @Override
          public void runtimeRemoved(IRuntime runtime) {
            runInUIThread();
          }

          @Override
          public void runtimeChanged(IRuntime runtime) {
            runInUIThread();
          }

          @Override
          public void runtimeAdded(IRuntime runtime) {
            runInUIThread();
          }

          private void runInUIThread() {
            Display.getDefault()
                .asyncExec(
                    new Runnable() {

                      @Override
                      public void run() {
                        try {
                          configureRuntimeCombo();
                        } catch (CoreException ex) {
                          ProjectTemplatesActivator.pluginLog()
                              .logError("Unable to handle runtime change event", ex); // $NON-NLS-1$
                        }
                      }
                    });
          }
        };
    ServerCore.addRuntimeLifecycleListener(listener);
    validate();
  }
Пример #19
0
  protected void bindNestedPojoProperty(
      FormToolkit toolkit,
      final IMessageManager mmng,
      final IPropertyDescriptor complexProperty,
      Composite parent,
      Object value,
      PropertyDescriptor property,
      Class<?> complexType) {
    String labelText;
    String propertyName = property.getName();
    Class<?> propertyType = property.getPropertyType();
    labelText = capitalize(splitCamelCase(propertyName));
    if (complexProperty instanceof ComplexUnionPropertyDescriptor) {
      // lets fix up the background colour!
      Label label = new Label(parent, SWT.NONE);
      label.setText(labelText);
    } else {
      Label label = toolkit.createLabel(parent, labelText);
    }

    Control widget;
    Class refType = isBeanRef(value, propertyName);
    IObservable observable;
    if (boolean.class.isAssignableFrom(propertyType)
        || Boolean.class.isAssignableFrom(propertyType)) {
      Button checkbox = new Button(parent, SWT.CHECK | SWT.BORDER);
      widget = checkbox;
      ISWTObservableValue textValue = Forms.observe(checkbox);
      observable = textValue;
      Forms.bindPojoProperty(
          bindingContext,
          mmng,
          value,
          propertyName,
          isMandatory(value, propertyName),
          labelText,
          textValue,
          checkbox);
    } else if (refType != null) {
      Combo combo = new Combo(parent, SWT.NONE | SWT.BORDER);
      String[] beanRefs = getBeanRefs(refType);
      combo.setItems(beanRefs);
      toolkit.adapt(combo, true, true);
      widget = combo;

      ISWTObservableValue comboValue = WidgetProperties.selection().observe(combo);
      observable = comboValue;
      Forms.bindPojoProperty(
          bindingContext,
          mmng,
          value,
          propertyName,
          isMandatory(value, propertyName),
          labelText,
          comboValue,
          combo);
    } else if (isEndpointUri(value, propertyName)) {
      Combo combo = new Combo(parent, SWT.NONE | SWT.BORDER);
      combo.setItems(getEndpointUris());
      toolkit.adapt(combo, true, true);
      widget = combo;

      ISWTObservableValue comboValue = WidgetProperties.selection().observe(combo);
      observable = comboValue;
      Forms.bindPojoProperty(
          bindingContext,
          mmng,
          value,
          propertyName,
          isMandatory(value, propertyName),
          labelText,
          comboValue,
          combo);
    } else if (Enum.class.isAssignableFrom(propertyType)) {
      ComboViewer combo = new ComboViewer(parent, SWT.READ_ONLY | SWT.BORDER);
      combo.setContentProvider(ArrayContentProvider.getInstance());
      combo.setInput(getEnumValues((Class<? extends Enum>) propertyType));

      IViewerObservableValue comboValue = ViewersObservables.observeSingleSelection(combo);
      observable = comboValue;
      Control control = combo.getControl();
      Forms.bindPojoProperty(
          bindingContext,
          mmng,
          value,
          propertyName,
          isMandatory(value, propertyName),
          labelText,
          comboValue,
          control);

      toolkit.adapt(control, true, true);
      widget = control;

    } else {
      Text text = toolkit.createText(parent, "");
      widget = text;
      // text.setToolTipText(tooltip);
      ISWTObservableValue textValue = Forms.observe(text);
      observable = textValue;
      Forms.bindPojoProperty(
          bindingContext,
          mmng,
          value,
          propertyName,
          isMandatory(value, propertyName),
          labelText,
          textValue,
          text);
    }
    widget.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    if (observable != null && node != null) {
      observable.addChangeListener(
          new IChangeListener() {

            @Override
            public void handleChange(ChangeEvent event) {
              // lets notify the node that its changed
              String id = complexProperty.getId().toString();
              fireNodePropertyChangedEvent(id);
            }
          });
    }
  }
Пример #20
0
  /**
   * Create the composite.
   *
   * @param parent
   * @param style
   */
  public FilterTypeComponent(final Composite parent) {
    super(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 0;
    setLayout(layout);

    filterTypeComboViewer = new ComboViewer(this, SWT.READ_ONLY);
    final Combo combo = filterTypeComboViewer.getCombo();
    combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));

    filterTypeComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    filterTypeComboViewer.setLabelProvider(
        new LabelProvider() {
          @Override
          public String getText(Object element) {
            if (!(element instanceof FilterType)) {
              throw new IllegalArgumentException();
            }
            return ((FilterType) element).value();
          }
        });

    filterTypeComboViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {

          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            if (stackLayout.topControl != null) {
              stackLayout.topControl.dispose();
            }
            FilterType selectedFilterType = getSelectedFilterType();
            switch (selectedFilterType) {
              case SENDER:
              case RECIPIENTS:
              case SUBJECT:
              case TEXT:
                filterOperatorComposite = new DefaultFilterOperatorComposite(filterPanel);
                break;
              case READ:
                filterOperatorComposite = new BooleanFilterOperatorComposite(filterPanel);
                break;
              case IMPORTANCE:
                filterOperatorComposite = new ImportanceFilterOperatorComposite(filterPanel);
                break;
              default:
                throw new IllegalArgumentException("Unknown filter type: " + selectedFilterType);
            }
            stackLayout.topControl = filterOperatorComposite;
            filterPanel.layout();
          }
        });

    filterTypeComboViewer.setInput(FilterType.values());

    filterPanel = new Composite(this, SWT.NONE);
    filterPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    stackLayout = new StackLayout();
    filterPanel.setLayout(stackLayout);

    filterTypeComboViewer.setSelection(new StructuredSelection(FilterType.SENDER));
  }
  /**
   * 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();
  }
Пример #22
0
  @Override
  public void createPartControl(Composite parent) {
    // add controls
    try {
      CWMetaInput input = (CWMetaInput) getEditorInput();
      CWScript document = new CWScript(input.getRootElement());
      List<CWParameter> documentParameters = document.getParameterList();
      String documentScript = document.getScript();

      /*GridLayout layout = new GridLayout();
      layout.numColumns = 1;
      parent.setLayout(layout);*/
      parent.setLayout(new FillLayout(SWT.VERTICAL));

      SashForm sashForm = new SashForm(parent, SWT.VERTICAL);

      // setup table
      final TableViewer tableViewer =
          new TableViewer(
              sashForm, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);

      // setup name column
      TableViewerColumn colName = new TableViewerColumn(tableViewer, SWT.NONE);
      colName.getColumn().setWidth(200);
      colName.getColumn().setText("Name");
      colName.setLabelProvider(
          new ColumnLabelProvider() {
            @Override
            public String getText(Object element) {
              return ((CWParameter) element).getName();
            }
          });

      // setup value column
      TableViewerColumn colValue = new TableViewerColumn(tableViewer, SWT.NONE);
      colValue.getColumn().setWidth(200);
      colValue.getColumn().setText("Type");
      colValue.setLabelProvider(
          new ColumnLabelProvider() {
            @Override
            public String getText(Object element) {
              return ((CWParameter) element).getType();
            }
          });

      final Table table = tableViewer.getTable();
      table.setHeaderVisible(true);
      table.setLinesVisible(true);

      tableViewer.setContentProvider(ArrayContentProvider.getInstance());
      tableViewer.setInput(documentParameters);

      /*GridData gridData = new GridData();
      gridData.verticalAlignment = GridData.FILL;
      gridData.horizontalSpan = 2;
      gridData.grabExcessHorizontalSpace = true;
      gridData.grabExcessVerticalSpace = true;
      gridData.horizontalAlignment = GridData.FILL;*/
      // tableViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

      // setup script text area
      final TextViewer textViewer = new TextViewer(sashForm, SWT.MULTI | SWT.V_SCROLL);
      textViewer.setDocument(new Document(documentScript));

      /*gridData = new GridData();
      gridData.verticalAlignment = GridData.FILL;
      gridData.horizontalSpan = 2;
      gridData.grabExcessHorizontalSpace = true;
      gridData.grabExcessVerticalSpace = true;
      gridData.horizontalAlignment = GridData.FILL;*/
      // textViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

      sashForm.setWeights(new int[] {1, 3});

    } catch (Exception ex) {
      System.out.println(ex);
    }
  }
  @Override
  protected Control createDialogArea(Composite parent) {
    Personne p = null;
    container = (Composite) super.createDialogArea(parent);
    container.setLayout(new GridLayout(1, false));

    Group gIdent = new Group(container, SWT.BORDER);
    gIdent.setText("Identité");
    gIdent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    gIdent.setLayout(new GridLayout(4, false));

    Label lblNom = new Label(gIdent, SWT.NONE);
    lblNom.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblNom.setText("Nom :");

    Text tNom = new Text(gIdent, SWT.BORDER);
    GridData gd_tNom = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    tNom.setLayoutData(gd_tNom);

    Label lblPreNom = new Label(gIdent, SWT.NONE);
    lblPreNom.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblPreNom.setText("Prénom :");

    Text tPreNom = new Text(gIdent, SWT.BORDER);
    GridData gd_tPreNom = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    tPreNom.setLayoutData(gd_tPreNom);

    if (nonConf.getPersonne() != null) {
      p = PersonneServiceImpl.getInstance().getPersonneById(nonConf.getPersonne().getIdPersonne());
      tNom.setText(p.getNom());
      tPreNom.setText(p.getPrenom());
    }
    tNom.setEnabled(false);
    tPreNom.setEnabled(false);

    final Group gDescription = new Group(container, SWT.BORDER);
    gDescription.setText("Description");
    gDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    gDescription.setLayout(new GridLayout(6, false));

    Label lblType = new Label(gDescription, SWT.NONE);
    lblType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblType.setText("Type :");

    comboType = new ComboViewer(gDescription, SWT.DROP_DOWN | SWT.READ_ONLY);
    comboType.setContentProvider(ArrayContentProvider.getInstance());
    comboType.setLabelProvider(new TypeNonConformiteLabelProvider());
    comboType.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    comboType.setInput(ReferentielServiceImpl.getInstance().getTypeNonConformite());
    comboType.addSelectionChangedListener(
        new ISelectionChangedListener() {

          public void selectionChanged(SelectionChangedEvent event) {
            TypeNonConformite typeNonConformite = null;
            ISelection selectiontypeNonConformite = comboType.getSelection();
            if (!selectiontypeNonConformite.isEmpty()) {
              IStructuredSelection structuredSelection =
                  (IStructuredSelection) selectiontypeNonConformite;
              typeNonConformite = (TypeNonConformite) structuredSelection.getFirstElement();
              comboCat.setInput(
                  ReferentielServiceImpl.getInstance()
                      .getCategorieNonConfByIdTypeNonConformite(
                          typeNonConformite.getIdTypeNonConformite()));
              comboSousCat.setInput(null);
            } else {
              comboCat.setInput(null);
              comboSousCat.setInput(null);
            }
            gDescription.pack();
          }
        });

    Label lblCat = new Label(gDescription, SWT.NONE);
    lblCat.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblCat.setText("Catégorie :");

    comboCat = new ComboViewer(gDescription, SWT.DROP_DOWN | SWT.READ_ONLY);
    comboCat.setContentProvider(ArrayContentProvider.getInstance());
    comboCat.setLabelProvider(new CategorieNonConformiteLabelProvider());
    comboCat.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    if (nonConf.getCategorie() != null) {
      comboCat.setInput(
          ReferentielServiceImpl.getInstance()
              .getCategorieNonConfByIdTypeNonConformite(
                  nonConf.getCategorie().getIdCategorieNonConformite()));

    } else {
      comboCat.setInput(null);
    }
    comboCat.addSelectionChangedListener(
        new ISelectionChangedListener() {

          public void selectionChanged(SelectionChangedEvent event) {
            CategorieNonConformite catNonConformite = null;
            ISelection selectioncatNonConformite = comboCat.getSelection();
            if (!selectioncatNonConformite.isEmpty()) {
              IStructuredSelection structuredSelection =
                  (IStructuredSelection) selectioncatNonConformite;
              catNonConformite = (CategorieNonConformite) structuredSelection.getFirstElement();
              comboSousCat.setInput(
                  ReferentielServiceImpl.getInstance()
                      .getSousCategorieNonConfByIdCategorieNonConformite(
                          catNonConformite.getIdCategorieNonConformite()));
            } else {
              comboSousCat.setInput(null);
            }
            gDescription.pack();
          }
        });

    Label lblSouCat = new Label(gDescription, SWT.NONE);
    lblSouCat.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblSouCat.setText("Sous-catégorie :");

    comboSousCat = new ComboViewer(gDescription, SWT.DROP_DOWN | SWT.READ_ONLY);
    comboSousCat.setContentProvider(ArrayContentProvider.getInstance());
    comboSousCat.setLabelProvider(new SousCategorieNonConformiteLabelProvider());
    comboSousCat.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    if (nonConf.getSousCategorie() != null) {
      comboSousCat.setInput(
          ReferentielServiceImpl.getInstance()
              .getSousCategorieNonConfByIdCategorieNonConformite(
                  nonConf.getSousCategorie().getIdSousCategorieNonConformite()));
    } else {
      comboSousCat.setInput(null);
    }

    Label lblAcc = new Label(gDescription, SWT.NONE);
    lblAcc.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblAcc.setText("Acceptation :");

    comboAcceptation = new Combo(gDescription, SWT.READ_ONLY);
    comboAcceptation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 5, 1));
    comboAcceptation.setItems(ApplicationContexte.acceptations);

    Label lblComm = new Label(gDescription, SWT.NONE);
    lblComm.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblComm.setText("Commentaire :");

    Text tCommentaire = new Text(gDescription, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
    GridData gd_tCommentaire = new GridData(SWT.FILL, SWT.CENTER, false, false, 5, 1);
    gd_tCommentaire.widthHint = 250;
    gd_tCommentaire.heightHint = 96;
    tCommentaire.setLayoutData(gd_tCommentaire);
    if (nonConf.getCommentaire() != null) {
      tCommentaire.setText(nonConf.getCommentaire());
    }

    Label lblDateDeLa = new Label(gDescription, SWT.NONE);
    lblDateDeLa.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblDateDeLa.setText("Date obs :");

    dObs = new FormattedText(gDescription, SWT.BORDER);
    dObs.setFormatter(new DateFormatter("dd/MM/yyyy"));
    GridData gridData_ddObs = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gridData_ddObs.widthHint = 75;
    dObs.getControl().setLayoutData(gridData_ddObs);
    if (nonConf.getDateObservation() != null) {
      dObs.setValue(nonConf.getDateObservation());
    }

    Label lblListPrelev = new Label(gDescription, SWT.NONE);
    lblListPrelev.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblListPrelev.setText("Associé au prélèvement :");

    listPrelevement = new ComboViewer(gDescription, SWT.DROP_DOWN | SWT.READ_ONLY);
    listPrelevement.setContentProvider(ArrayContentProvider.getInstance());
    listPrelevement.setLabelProvider(new PrelevementLabelProvider());
    listPrelevement
        .getCombo()
        .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    if (p != null) {
      java.util.List<Prelevement> prelevements =
          PrelevementServiceImpl.getInstance().findAllByidPersonne(p.getIdPersonne());
      listPrelevement.setInput(prelevements);
    } else {
      listPrelevement.setInput(null);
    }
    listPrelevement.addSelectionChangedListener(
        new ISelectionChangedListener() {

          public void selectionChanged(SelectionChangedEvent event) {
            Prelevement prelevement = null;
            ISelection selectionPrelevement = listPrelevement.getSelection();
            if (!selectionPrelevement.isEmpty()) {
              IStructuredSelection structuredSelection =
                  (IStructuredSelection) selectionPrelevement;
              prelevement = (Prelevement) structuredSelection.getFirstElement();
              List<Analyse> ana =
                  AnalyseServiceImpl.getInstance()
                      .findAllByidPrelevement(prelevement.getIdPrelevement());
              ana.add(new Analyse());
              listAnalyse.setInput(ana);
            } else {
              listAnalyse.setInput(null);
            }
            gDescription.pack();
          }
        });

    Label lblListAnalyse = new Label(gDescription, SWT.NONE);
    lblListAnalyse.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblListAnalyse.setText("pour l'analyse :");

    listAnalyse = new ComboViewer(gDescription, SWT.DROP_DOWN | SWT.READ_ONLY);
    listAnalyse.setContentProvider(ArrayContentProvider.getInstance());
    listAnalyse.setLabelProvider(new AnalyseLabelProvider());
    listAnalyse.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

    return container;
  }
Пример #24
0
  public void createControl(Composite parent) {
    final RepositoryUtil util = Activator.getDefault().getRepositoryUtil();
    Composite main = new Composite(parent, SWT.NONE);
    // use zero spacing to save some real estate here
    GridLayoutFactory.fillDefaults().spacing(0, 0).applyTo(main);

    final Button internalModeButton = new Button(main, SWT.CHECK);
    internalModeButton.setText(UIText.ExistingOrNewPage_InternalModeCheckbox);
    internalModeButton.setToolTipText(UIText.ExistingOrNewPage_CreationInWorkspaceWarningTooltip);
    internalModeButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            internalMode = internalModeButton.getSelection();
            updateControls();
          }
        });

    externalComposite = new Composite(main, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(externalComposite);
    externalComposite.setLayout(new GridLayout(3, false));

    new Label(externalComposite, SWT.NONE)
        .setText(UIText.ExistingOrNewPage_ExistingRepositoryLabel);
    final Combo existingRepoCombo = new Combo(externalComposite, SWT.READ_ONLY);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(existingRepoCombo);
    final ComboViewer v = new ComboViewer(existingRepoCombo);
    v.setContentProvider(new RepoComboContentProvider());
    v.setLabelProvider(new RepoComboLabelProvider());
    v.setInput(new Object());
    // the default ViewerSorter seems to do the right thing
    // i.e. sort as String
    v.setSorter(new ViewerSorter());

    existingRepoCombo.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            selectedRepository = null;
            IStructuredSelection sel = (IStructuredSelection) v.getSelection();
            setRepository((Repository) sel.getFirstElement());
            updateControls();
          }
        });

    Button createRepoWizard = new Button(externalComposite, SWT.PUSH);
    createRepoWizard.setText(UIText.ExistingOrNewPage_CreateRepositoryButton);
    createRepoWizard.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            NewRepositoryWizard wiz = new NewRepositoryWizard(true);
            if (new WizardDialog(getShell(), wiz).open() == Window.OK) {
              v.refresh();
              selectedRepository = wiz.getCreatedRepository();
              v.setSelection(new StructuredSelection(selectedRepository));
              updateControls();
            }
          }
        });

    new Label(externalComposite, SWT.NONE).setText(UIText.ExistingOrNewPage_WorkingDirectoryLabel);
    workDir = new Text(externalComposite, SWT.BORDER | SWT.READ_ONLY);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(workDir);
    GridDataFactory.fillDefaults().applyTo(workDir);
    // leave the space between the "Create" and "Browse" buttons empty (i.e.
    // do not fill to the right border
    new Label(externalComposite, SWT.NONE);

    new Label(externalComposite, SWT.NONE).setText(UIText.ExistingOrNewPage_RelativePathLabel);
    relPath = new Text(externalComposite, SWT.BORDER);
    relPath.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            updateControls();
          }
        });

    GridDataFactory.fillDefaults().grab(true, false).applyTo(relPath);
    browseRepository = new Button(externalComposite, SWT.PUSH);
    browseRepository.setEnabled(false);
    browseRepository.setText(UIText.ExistingOrNewPage_BrowseRepositoryButton);
    browseRepository.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dlg = new DirectoryDialog(getShell());
            dlg.setFilterPath(selectedRepository.getWorkTree().getPath());
            String directory = dlg.open();
            if (directory != null) {
              setRelativePath(directory);
              updateControls();
            }
          }
        });

    Table projectMoveTable =
        new Table(externalComposite, SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK | SWT.BORDER);
    projectMoveViewer = new CheckboxTableViewer(projectMoveTable);
    GridDataFactory.fillDefaults().span(3, 1).grab(true, true).applyTo(projectMoveTable);

    TableColumn tc;
    tc = new TableColumn(projectMoveTable, SWT.NONE);
    tc.setText(UIText.ExistingOrNewPage_ProjectNameColumnHeader);
    tc.setWidth(100);

    tc = new TableColumn(projectMoveTable, SWT.NONE);
    tc.setText(UIText.ExistingOrNewPage_CurrentLocationColumnHeader);
    tc.setWidth(250);

    tc = new TableColumn(projectMoveTable, SWT.NONE);
    tc.setText(UIText.ExistingOrNewPage_NewLocationTargetHeader);
    tc.setWidth(350);

    projectMoveTable.setHeaderVisible(true);
    projectMoveViewer.setContentProvider(ArrayContentProvider.getInstance());
    projectMoveViewer.setLabelProvider(moveProjectsLabelProvider);
    projectMoveViewer.setInput(myWizard.projects);
    projectMoveViewer.addCheckStateListener(
        new ICheckStateListener() {
          public void checkStateChanged(CheckStateChangedEvent event) {
            updateControls();
          }
        });
    TableItem[] children = projectMoveViewer.getTable().getItems();
    for (int i = 0; i < children.length; i++) {
      TableItem item = children[i];
      IProject data = (IProject) item.getData();
      RepositoryFinder repositoryFinder = new RepositoryFinder(data);
      repositoryFinder.setFindInChildren(false);
      try {
        Collection<RepositoryMapping> find = repositoryFinder.find(new NullProgressMonitor());
        if (find.size() != 1) item.setChecked(true);
      } catch (CoreException e1) {
        item.setText(2, e1.getMessage());
      }
    }

    parentRepoComposite = new Composite(main, SWT.NONE);
    parentRepoComposite.setLayout(new GridLayout(3, false));
    GridDataFactory.fillDefaults().grab(true, true).applyTo(parentRepoComposite);

    tree = new Tree(parentRepoComposite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK);
    viewer = new CheckboxTreeViewer(tree);
    tree.setHeaderVisible(true);
    tree.setLayout(new GridLayout());
    tree.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(3, 1).create());
    viewer.addCheckStateListener(
        new ICheckStateListener() {

          public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getChecked()) {
              ProjectAndRepo checkable = (ProjectAndRepo) event.getElement();
              for (TreeItem ti : tree.getItems()) {
                if (ti.getItemCount() > 0
                    || ((ProjectAndRepo) ti.getData()).getRepo().equals("")) // $NON-NLS-1$
                ti.setChecked(false);
                for (TreeItem subTi : ti.getItems()) {
                  IProject project = ((ProjectAndRepo) subTi.getData()).getProject();
                  if (checkable.getProject() != null
                      && !subTi.getData().equals(checkable)
                      && checkable.getProject().equals(project)) subTi.setChecked(false);
                }
              }
            }
          }
        });
    TreeColumn c1 = new TreeColumn(tree, SWT.NONE);
    c1.setText(UIText.ExistingOrNewPage_HeaderProject);
    c1.setWidth(100);
    TreeColumn c2 = new TreeColumn(tree, SWT.NONE);
    c2.setText(UIText.ExistingOrNewPage_HeaderLocation);
    c2.setWidth(400);
    TreeColumn c3 = new TreeColumn(tree, SWT.NONE);
    c3.setText(UIText.ExistingOrNewPage_HeaderRepository);
    c3.setWidth(200);
    boolean allProjectsInExistingRepos = true;
    for (IProject project : myWizard.projects) {
      RepositoryFinder repositoryFinder = new RepositoryFinder(project);
      repositoryFinder.setFindInChildren(false);
      try {
        Collection<RepositoryMapping> mappings;
        mappings = repositoryFinder.find(new NullProgressMonitor());
        Iterator<RepositoryMapping> mi = mappings.iterator();
        RepositoryMapping m = mi.hasNext() ? mi.next() : null;
        if (m == null) {
          // no mapping found, enable repository creation
          TreeItem treeItem = new TreeItem(tree, SWT.NONE);
          updateProjectTreeItem(treeItem, project);
          treeItem.setText(1, project.getLocation().toOSString());
          treeItem.setText(2, ""); // $NON-NLS-1$
          treeItem.setData(new ProjectAndRepo(project, "")); // $NON-NLS-1$
          allProjectsInExistingRepos = false;
        } else if (!mi.hasNext()) {
          // exactly one mapping found
          TreeItem treeItem = new TreeItem(tree, SWT.NONE);
          updateProjectTreeItem(treeItem, project);
          treeItem.setText(1, project.getLocation().toOSString());
          fillTreeItemWithGitDirectory(m, treeItem, false);
          treeItem.setData(new ProjectAndRepo(project, m.getGitDirAbsolutePath().toOSString()));
          treeItem.setChecked(true);
        } else {
          TreeItem treeItem = new TreeItem(tree, SWT.NONE);
          updateProjectTreeItem(treeItem, project);
          treeItem.setText(1, project.getLocation().toOSString());
          treeItem.setData(new ProjectAndRepo(project, "")); // $NON-NLS-1$

          TreeItem treeItem2 = new TreeItem(treeItem, SWT.NONE);
          updateProjectTreeItem(treeItem2, project);
          fillTreeItemWithGitDirectory(m, treeItem2, true);
          treeItem2.setData(new ProjectAndRepo(project, m.getGitDirAbsolutePath().toOSString()));
          while (mi.hasNext()) { // fill in additional mappings
            m = mi.next();
            treeItem2 = new TreeItem(treeItem, SWT.NONE);
            updateProjectTreeItem(treeItem2, project);
            fillTreeItemWithGitDirectory(m, treeItem2, true);
            treeItem2.setData(
                new ProjectAndRepo(
                    m.getContainer().getProject(), m.getGitDirAbsolutePath().toOSString()));
          }
          treeItem.setExpanded(true);
          allProjectsInExistingRepos = false;
        }
      } catch (CoreException e) {
        TreeItem treeItem2 = new TreeItem(tree, SWT.BOLD | SWT.ITALIC);
        treeItem2.setText(e.getMessage());
      }
    }

    createRepo = new Button(parentRepoComposite, SWT.PUSH);
    createRepo.setLayoutData(GridDataFactory.fillDefaults().create());
    createRepo.setText(UIText.ExistingOrNewPage_CreateButton);
    createRepo.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            File gitDir = new File(repositoryToCreate.getText(), Constants.DOT_GIT);
            try {
              Repository repository = FileRepositoryBuilder.create(gitDir);
              repository.create();
              for (IProject project : getProjects(false).keySet()) {
                // If we don't refresh the project directories right
                // now we won't later know that a .git directory
                // exists within it and we won't mark the .git
                // directory as a team-private member. Failure
                // to do so might allow someone to delete
                // the .git directory without us stopping them.
                // (Half lie, we should optimize so we do not
                // refresh when the .git is not within the project)
                //
                if (!gitDir.toString().contains("..")) // $NON-NLS-1$
                project.refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor());
              }
              util.addConfiguredRepository(gitDir);
            } catch (IOException e1) {
              String msg =
                  NLS.bind(
                      UIText.ExistingOrNewPage_ErrorFailedToCreateRepository, gitDir.toString());
              org.eclipse.egit.ui.Activator.handleError(msg, e1, true);
            } catch (CoreException e2) {
              String msg =
                  NLS.bind(UIText.ExistingOrNewPage_ErrorFailedToRefreshRepository, gitDir);
              org.eclipse.egit.ui.Activator.handleError(msg, e2, true);
            }
            for (TreeItem ti : tree.getSelection()) {
              IPath projectPath = new Path(ti.getText(1));
              IPath gitPath = new Path(gitDir.toString());
              IPath relative = gitPath.makeRelativeTo(projectPath);
              ti.setText(2, relative.toOSString());
              ((ProjectAndRepo) ti.getData()).repo = gitDir.toString();
              ti.setChecked(true);
            }
            updateControls();
          }
        });
    repositoryToCreate = new Text(parentRepoComposite, SWT.SINGLE | SWT.BORDER);
    repositoryToCreate.setLayoutData(
        GridDataFactory.fillDefaults().grab(true, false).span(1, 1).create());
    repositoryToCreate.addListener(
        SWT.Modify,
        new Listener() {
          public void handleEvent(Event e) {
            if (repositoryToCreate.getText().equals("")) { // $NON-NLS-1$
              createRepo.setEnabled(false);
              return;
            }
            IPath fromOSString = Path.fromOSString(repositoryToCreate.getText());
            createRepo.setEnabled(
                minumumPath.matchingFirstSegments(fromOSString) == fromOSString.segmentCount());
          }
        });
    dotGitSegment = new Label(parentRepoComposite, SWT.NONE);
    dotGitSegment.setEnabled(false);
    dotGitSegment.setText(File.separatorChar + Constants.DOT_GIT);
    dotGitSegment.setLayoutData(
        GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).create());

    tree.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            tree.select((TreeItem) e.item);
            updateControls();
          }
        });

    Dialog.applyDialogFont(main);
    setControl(main);

    if (allProjectsInExistingRepos) {
      internalMode = true;
      internalModeButton.setSelection(true);
      updateControls();
    }
  }
Пример #25
0
  @Override
  public void createPartControl(Composite parent) {

    initInputs();

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));

    Label lblDataModel = new Label(composite, SWT.NONE);
    lblDataModel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblDataModel.setText("Data Model :");

    cvDataModel = new ComboViewer(composite, SWT.NONE);
    cvDataModel.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    cvDataModel.setContentProvider(ArrayContentProvider.getInstance());

    // TODO : use scope generated label provider
    cvDataModel.setLabelProvider(
        new LabelProvider() {

          @Override
          public String getText(Object element) {
            if (element instanceof IDataModel) {
              return ((IDataModel) element).getName();
            }
            return "";
          }
        });

    cvDataModel.setInput(dataManager.getAllDataModels());

    //		refreshBtn = new Button(composite, SWT.PUSH);
    //		refreshBtn.setImage(Activator.getImageDescriptor("icons/refresh.gif").createImage());
    //
    //		refreshBtn.setToolTipText("Refresh View");

    Label lblScope = new Label(composite, SWT.NONE);
    lblScope.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblScope.setText("Scope :");

    cvScope = new ComboViewer(composite, SWT.NONE);
    cvScope.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    cvScope.setContentProvider(ArrayContentProvider.getInstance());

    // TODO : use scope generated label provider
    cvScope.setLabelProvider(
        new LabelProvider() {

          @Override
          public String getText(Object element) {
            if (element instanceof Scope) {
              return ((Scope) element).getName();
            }
            return "";
          }
        });

    cvScope.setInput(scopes);

    viewer = new TreeViewer(composite, SWT.BORDER);
    viewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
    viewer.setContentProvider(
        new ITreeContentProvider() {

          @Override
          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}

          @Override
          public void dispose() {}

          @Override
          public boolean hasChildren(Object element) {
            //				if (element instanceof AbstractElement) {
            //					 EList<EAttribute> eAllAttributes = ((AbstractElement)
            // element).eClass().getEAllAttributes();
            //					for (EAttribute eAttribute : eAllAttributes) {
            //						if	(((AbstractElement) element).eGet(eAttribute, true) != null) {
            //							return true;
            //						}
            //					}
            //				}
            return false;
          }

          @Override
          public Object getParent(Object element) {
            return null;
          }

          @Override
          public Object[] getElements(Object inputElement) {
            return ArrayContentProvider.getInstance().getElements(inputElement);
          }

          @Override
          public Object[] getChildren(Object parentElement) {
            //				Collection<Object> result = new ArrayList<Object>();
            //				if (parentElement instanceof AbstractElement) {
            //					EList<EAttribute> eAllAttributes = ((AbstractElement)
            // parentElement).eClass().getEAllAttributes();
            //					for (EAttribute eAttribute : eAllAttributes) {
            //						value = ((AbstractElement) parentElement).eGet(eAttribute, true);
            //					}
            //				}
            return null;
          }
        });
    viewer.setLabelProvider(
        new LabelProvider() {

          @Override
          public String getText(Object element) {
            return DataUtil.getLabel(element);
          }
        });
    viewer.setInput(requirements);

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE;

    Transfer[] transfers;
    transfers = new Transfer[] {PluginTransfer.getInstance()};

    DragRequirementSourceAdapter listener = new DragRequirementSourceAdapter(viewer);
    ZigguratInject.inject(listener);
    viewer.addDragSupport(dndOperations, transfers, listener);
    getViewSite().setSelectionProvider(viewer);

    makeActions();
    contributeToActionBars();
    hookListeners();
  }
  @Override
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    setControl(container);
    container.setLayout(new FormLayout());

    Composite targetContainer = new Composite(container, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(4).applyTo(targetContainer);

    lblPrimaryAccount = new Label(targetContainer, SWT.NONE);
    lblPrimaryAccount.setText(Messages.ColumnAccount);
    Combo cmbAccount = new Combo(targetContainer, SWT.READ_ONLY);
    primaryAccount = new ComboViewer(cmbAccount);
    primaryAccount.setContentProvider(ArrayContentProvider.getInstance());
    primaryAccount.setInput(client.getActiveAccounts());
    primaryAccount.addSelectionChangedListener(e -> checkEntriesAndRefresh(allEntries));

    lblSecondaryAccount = new Label(targetContainer, SWT.NONE);
    lblSecondaryAccount.setText(Messages.LabelTransferTo);
    lblSecondaryAccount.setVisible(false);
    Combo cmbAccountTarget = new Combo(targetContainer, SWT.READ_ONLY);
    secondaryAccount = new ComboViewer(cmbAccountTarget);
    secondaryAccount.setContentProvider(ArrayContentProvider.getInstance());
    secondaryAccount.setInput(client.getActiveAccounts());
    secondaryAccount.getControl().setVisible(false);

    lblPrimaryPortfolio = new Label(targetContainer, SWT.NONE);
    lblPrimaryPortfolio.setText(Messages.ColumnPortfolio);
    Combo cmbPortfolio = new Combo(targetContainer, SWT.READ_ONLY);
    primaryPortfolio = new ComboViewer(cmbPortfolio);
    primaryPortfolio.setContentProvider(ArrayContentProvider.getInstance());
    primaryPortfolio.setInput(client.getActivePortfolios());
    primaryPortfolio.addSelectionChangedListener(e -> checkEntriesAndRefresh(allEntries));

    lblSecondaryPortfolio = new Label(targetContainer, SWT.NONE);
    lblSecondaryPortfolio.setText(Messages.LabelTransferTo);
    lblSecondaryPortfolio.setVisible(false);
    Combo cmbPortfolioTarget = new Combo(targetContainer, SWT.READ_ONLY);
    secondaryPortfolio = new ComboViewer(cmbPortfolioTarget);
    secondaryPortfolio.setContentProvider(ArrayContentProvider.getInstance());
    secondaryPortfolio.setInput(client.getActivePortfolios());
    secondaryPortfolio.getControl().setVisible(false);

    preselectDropDowns();

    cbConvertToDelivery = new Button(container, SWT.CHECK);
    cbConvertToDelivery.setText(Messages.LabelConvertBuySellIntoDeliveryTransactions);

    Composite compositeTable = new Composite(container, SWT.NONE);
    Composite errorTable = new Composite(container, SWT.NONE);

    //
    // form layout
    //

    FormDataFactory.startingWith(targetContainer) //
        .top(new FormAttachment(0, 0))
        .left(new FormAttachment(0, 0))
        .right(new FormAttachment(100, 0))
        .thenBelow(cbConvertToDelivery) //
        .thenBelow(compositeTable)
        .right(targetContainer)
        .bottom(new FormAttachment(70, 0)) //
        .thenBelow(errorTable)
        .right(targetContainer)
        .bottom(new FormAttachment(100, 0));

    //
    // table & columns
    //

    TableColumnLayout layout = new TableColumnLayout();
    compositeTable.setLayout(layout);

    tableViewer = new TableViewer(compositeTable, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    tableViewer.setContentProvider(new SimpleListContentProvider());

    Table table = tableViewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    addColumns(tableViewer, layout);
    attachContextMenu(table);

    layout = new TableColumnLayout();
    errorTable.setLayout(layout);
    errorTableViewer = new TableViewer(errorTable, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    errorTableViewer.setContentProvider(new SimpleListContentProvider());

    table = errorTableViewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    addColumnsExceptionTable(errorTableViewer, layout);
  }
Пример #27
0
  @Override
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    setControl(container);
    GridLayoutFactory.fillDefaults().numColumns(3).applyTo(container);

    Label lblAcc = new Label(container, SWT.NULL);
    lblAcc.setText(Messages.ColumnAccount);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(lblAcc);

    final Text accountName = new Text(container, SWT.BORDER | SWT.SINGLE);
    GridDataFactory.fillDefaults()
        .grab(true, false)
        .align(SWT.FILL, SWT.CENTER)
        .applyTo(accountName);

    Button button = new Button(container, SWT.PUSH);
    button.setText(Messages.NewFileWizardButtonAdd);
    GridDataFactory.fillDefaults().applyTo(button);

    Composite tableContainer = new Composite(container, SWT.NONE);
    GridDataFactory.fillDefaults().span(3, 1).grab(true, true).applyTo(tableContainer);
    TableColumnLayout layout = new TableColumnLayout();
    tableContainer.setLayout(layout);

    tViewer = new TableViewer(tableContainer);

    button.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            String acnName = accountName.getText();
            if (acnName.length() > 0) {
              Account currentAccount = new Account();
              currentAccount.setName(acnName);
              client.addAccount(currentAccount);
              tViewer.refresh();

              accountName.setText(""); // $NON-NLS-1$
              accountName.setFocus();
            }
          }
        });

    Table table = tViewer.getTable();
    table.setHeaderVisible(true);
    table.setEnabled(false);

    tViewer.setContentProvider(ArrayContentProvider.getInstance());
    tViewer.setInput(client.getAccounts());
    TableViewerColumn aCol = new TableViewerColumn(tViewer, SWT.NONE);
    layout.setColumnData(aCol.getColumn(), new ColumnWeightData(50));
    aCol.getColumn().setText(Messages.ColumnAccount);
    aCol.setLabelProvider(
        new ColumnLabelProvider() {
          @Override
          public String getText(Object element) {
            return ((Account) element).getName();
          }

          @Override
          public Image getImage(Object element) {
            return PortfolioPlugin.image(PortfolioPlugin.IMG_ACCOUNT);
          }
        });
    container.pack();
    setPageComplete(true);
  }
  @Override
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    container.setLayout(layout);

    layersTable = new TableViewer(container, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    layersTable.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
    layersTable.setContentProvider(ArrayContentProvider.getInstance());
    layersTable.getTable().setHeaderVisible(true);
    layersTable.getTable().setLinesVisible(true);

    TableViewerColumn layerColumn = new TableViewerColumn(layersTable, SWT.NONE);
    layerColumn.getColumn().setText("Layer");
    layerColumn.getColumn().setWidth(300);
    layerColumn.setLabelProvider(
        new ColumnLabelProvider() {
          @Override
          public String getText(Object element) {
            LayerDescriptor layer = (LayerDescriptor) element;
            return layer.getName();
          }
        });

    TableViewerColumn namePatternColumn = new TableViewerColumn(layersTable, SWT.NONE);
    namePatternColumn.getColumn().setWidth(300);
    namePatternColumn.getColumn().setText("Exception super type");
    namePatternColumn.setLabelProvider(
        new ColumnLabelProvider() {

          @Override
          public String getText(Object element) {
            LayerDescriptor layer = (LayerDescriptor) element;
            return layer.getExceptionSuperType();
          }
        });
    namePatternColumn.setEditingSupport(
        new EditingSupport(layersTable) {

          @Override
          protected boolean canEdit(Object element) {
            return true;
          }

          @Override
          protected CellEditor getCellEditor(Object element) {
            TypeSelectionExtension extension =
                new TypeSelectionExtension() {

                  @Override
                  public ISelectionStatusValidator getSelectionValidator() {
                    return new ISelectionStatusValidator() {
                      @Override
                      public IStatus validate(Object[] selection) {
                        if (selection.length == 1) {
                          try {
                            IType type = (IType) selection[0];
                            ITypeHierarchy hierarchy =
                                type.newSupertypeHierarchy(new NullProgressMonitor());
                            IType curr = type;
                            while (curr != null) {
                              if ("java.lang.Throwable"
                                  .equals(curr.getFullyQualifiedName('.'))) { // $NON-NLS-1$
                                return Status.OK_STATUS;
                              }
                              curr = hierarchy.getSuperclass(curr);
                            }
                          } catch (JavaModelException e) {
                            Status status =
                                new Status(
                                    IStatus.ERROR,
                                    JQAEclipsePlugin.PLUGIN_ID,
                                    e.getLocalizedMessage(),
                                    e);
                            JQAEclipsePlugin.getDefault().getLog().log(status);
                            return Status.CANCEL_STATUS;
                          }
                        }
                        return new Status(
                            IStatus.ERROR,
                            JQAEclipsePlugin.PLUGIN_ID,
                            "Selected item is not an exception");
                      }
                    };
                  }
                };
            return new TypeCellEditor(
                layersTable.getTable(),
                ThrowingDefinitionWizardPage.this.getContainer(),
                IJavaSearchConstants.CLASS,
                "*Exception",
                extension);
          }

          @Override
          protected Object getValue(Object element) {
            return ((LayerDescriptor) element).getExceptionSuperType();
          }

          @Override
          protected void setValue(Object element, Object value) {
            ((LayerDescriptor) element).setExceptionSuperType((String) value);
            layersTable.refresh(element, true);
          }
        });
    layersTable.setInput(getArchitectureDescriptor().getLayers());
    setControl(container);
    ((WizardDialog) getContainer()).addPageChangedListener(this);
  }
  public PropertyValueSelectionComposite(
      Composite parent,
      int style,
      String label,
      ListenableProperty property2,
      String[] strings,
      String eventAdminName) {
    super(parent, style);
    property = property2;
    list = strings;
    this.eventAdminName = eventAdminName;

    GridLayoutFactory.fillDefaults().numColumns(2).applyTo(this);
    GridDataFactory.fillDefaults().applyTo(this);

    Label lbl = new Label(this, SWT.NONE | SWT.CENTER);
    lbl.setText(label);

    viewer = new ComboViewer(parent, SWT.READ_ONLY);
    // the ArrayContentProvider  object does not store any state,
    // therefore you can re-use instances
    viewer.setContentProvider(ArrayContentProvider.getInstance());
    viewer.setLabelProvider(
        new LabelProvider() {
          @Override
          public String getText(Object element) {
            if (element instanceof String) {
              return (String) element;
            }
            return super.getText(element);
          }
        });
    viewer.setInput(strings);
    // react to the selection change of the viewer
    // note that the viewer returns the actual object
    viewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          // implement property change by this viewer
          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection.size() > 0 && selection != currentSelection) {
              String firstElement = (String) selection.getFirstElement();
              if (property.getPropertyName().equals(LocalProperties.GDA_DATAWRITER_DIR)) {
                File file = new File(firstElement);
                if (file.exists() && file.isDirectory()) {
                  property.set(firstElement);
                  currentSelection = selection;
                  InterfaceProvider.getTerminalPrinter()
                      .print(
                          "Data Directory changed to "
                              + LocalProperties.get(LocalProperties.GDA_DATAWRITER_DIR));
                  logger.info(
                      "Data directory changed to {}",
                      LocalProperties.get(LocalProperties.GDA_DATAWRITER_DIR));
                } else {
                  InterfaceProvider.getTerminalPrinter()
                      .print(firstElement + " is not a data directory.");
                  logger.info("{} is not a data directory.", firstElement);
                }
              } else {
                property.set(firstElement);
                currentSelection = selection;
                InterfaceProvider.getTerminalPrinter()
                    .print(
                        "Property "
                            + property.getPropertyName()
                            + " changed to "
                            + LocalProperties.get(property.getPropertyName()));
                logger.info(
                    "Property {} changed to {}",
                    property.getPropertyName(),
                    LocalProperties.get(property.getPropertyName()));
              }
            }
          }
        });
  }
Пример #30
0
  private void createDecoratedTextField(
      final IPropertyDescriptor descriptor,
      FormToolkit toolkit,
      Composite parent,
      final IMessageManager mmng) {

    final Object id = descriptor.getId();
    String labelText = descriptor.getDisplayName();
    String tooltip = Tooltips.tooltip(id.toString());
    GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    boolean isDescription = NODE_DESCRIPTION.equals(id);
    Control widget;

    boolean isComplexProperty = descriptor instanceof ComplexPropertyDescriptor;
    boolean isUnionProperty = descriptor instanceof ComplexUnionPropertyDescriptor;
    if (isComplexProperty) {
      widget =
          bindNestedComplexProperties(
              toolkit,
              parent,
              mmng,
              (ComplexPropertyDescriptor) descriptor,
              id,
              labelText,
              tooltip);
    } else {
      Label label = toolkit.createLabel(parent, labelText);
      label.setToolTipText(tooltip);

      if (isDescription) {
        label.setLayoutData(gd);
      }
      if (isUnionProperty) {
        widget =
            bindNestedComplexUnionProperties(
                toolkit,
                parent,
                mmng,
                id,
                labelText,
                tooltip,
                (ComplexUnionPropertyDescriptor) descriptor);
      } else if (descriptor instanceof ExpressionPropertyDescriptor) {
        // lets create a composite and add a text are and a combo box
        // ExpandableComposite composite =
        // toolkit.createExpandableComposite(parent, SWT.HORIZONTAL);
        Composite composite = toolkit.createComposite(parent);
        GridLayout layout = new GridLayout(3, false);
        zeroMargins(layout);
        composite.setLayout(layout);
        widget = composite;

        Text text = toolkit.createText(composite, "", SWT.BORDER);
        text.setToolTipText(tooltip);

        gd = new GridData(GridData.FILL_HORIZONTAL);
        // gd.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
        // gd.horizontalAlignment = SWT.LEFT;
        // gd.verticalIndent = 0;
        // gd.verticalAlignment = GridData.FILL;
        text.setLayoutData(gd);
        ISWTObservableValue textValue = Forms.observe(text);

        // NOTE this code only works if the LanguageExpressionBean is
        // not
        // replaced under our feet!
        final LanguageExpressionBean expression =
            LanguageExpressionBean.bindToNodeProperty(node, id);
        final String expressionPropertyName = "expression";
        Forms.bindBeanProperty(
            bindingContext,
            mmng,
            expression,
            expressionPropertyName,
            isMandatory(expression, expressionPropertyName),
            expressionPropertyName,
            textValue,
            text);

        String languageLabel = EditorMessages.propertiesLanguageTitle;
        toolkit.createLabel(composite, languageLabel);
        // toolkit.createSeparator(composite, SWT.SEPARATOR);

        Combo combo = new Combo(composite, SWT.NONE | SWT.BORDER);
        combo.setItems(new Languages().languageArray());
        toolkit.adapt(combo, true, true);

        ISWTObservableValue comboValue = WidgetProperties.selection().observe(combo);
        Forms.bindBeanProperty(
            bindingContext,
            mmng,
            expression,
            "language",
            isMandatory(expression, "language"),
            languageLabel,
            comboValue,
            combo);

        String language = expression.getLanguage();
        if (language == null) {
          language = CamelModelHelper.getDefaultLanguageName();
          expression.setLanguage(language);
        }

        // now lets forward property events to the node
        expression.addPropertyChangeListener(
            new PropertyChangeListener() {
              /*
               * (non-Javadoc)
               *
               * @see
               * java.beans.PropertyChangeListener#propertyChange(java
               * .beans .PropertyChangeEvent)
               */
              @Override
              public void propertyChange(PropertyChangeEvent event) {
                node.firePropertyChange(id.toString(), null, expression);
              }
            });
      } else {
        String propertyName = getPropertyName(id);
        Class refType = isBeanRef(node, propertyName);
        if (refType != null) {
          Combo combo = new Combo(parent, SWT.NONE | SWT.BORDER);
          String[] beanRefs = getBeanRefs(refType);
          combo.setItems(beanRefs);
          toolkit.adapt(combo, true, true);
          widget = combo;

          ISWTObservableValue comboValue = WidgetProperties.selection().observe(combo);
          Forms.bindBeanProperty(
              bindingContext,
              mmng,
              node,
              propertyName,
              isMandatory(node, propertyName),
              labelText,
              comboValue,
              combo);
        } else if (isEndpointUri(node, propertyName)) {
          Combo combo = new Combo(parent, SWT.NONE | SWT.BORDER);
          combo.setItems(getEndpointUris());
          toolkit.adapt(combo, true, true);
          widget = combo;

          ISWTObservableValue comboValue = WidgetProperties.selection().observe(combo);
          Forms.bindBeanProperty(
              bindingContext,
              mmng,
              node,
              propertyName,
              isMandatory(node, propertyName),
              labelText,
              comboValue,
              combo);
        } else if (descriptor instanceof BooleanPropertyDescriptor) {
          Button checkbox = new Button(parent, SWT.CHECK);
          widget = checkbox;
          ISWTObservableValue textValue = Forms.observe(checkbox);
          Forms.bindBeanProperty(
              bindingContext,
              mmng,
              node,
              propertyName,
              isMandatory(node, propertyName),
              labelText,
              textValue,
              checkbox);
        } else if (descriptor instanceof ListPropertyDescriptor) {
          if (CamelModelHelper.isPropertyListOFSetHeaders(id)) {
            Control control = bindSetHeaderTable(toolkit, parent, id);
            widget = control;
          } else {
            Control control = bindListOfValues(toolkit, parent, id);
            widget = control;
          }
        } else if (descriptor instanceof EnumPropertyDescriptor) {
          EnumPropertyDescriptor enumProperty = (EnumPropertyDescriptor) descriptor;
          ComboViewer combo = new ComboViewer(parent, SWT.READ_ONLY | SWT.BORDER);
          combo.setContentProvider(ArrayContentProvider.getInstance());
          combo.setInput(getEnumValues(enumProperty.getEnumType()));

          IViewerObservableValue comboValue = ViewersObservables.observeSingleSelection(combo);
          Control control = combo.getControl();
          Forms.bindBeanProperty(
              bindingContext,
              mmng,
              node,
              propertyName,
              isMandatory(node, propertyName),
              labelText,
              comboValue,
              control);

          toolkit.adapt(control, true, true);
          widget = control;
        } else {
          Text text;
          if (isDescription) {
            text =
                toolkit.createText(
                    parent, "", SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL);
          } else {
            text = toolkit.createText(parent, "", SWT.BORDER);
          }
          text.setToolTipText(tooltip);
          widget = text;
          ISWTObservableValue textValue = Forms.observe(text);
          Forms.bindBeanProperty(
              bindingContext,
              mmng,
              node,
              propertyName,
              isMandatory(node, propertyName),
              labelText,
              textValue,
              text);
        }
      }
    }
    boolean isComplexOrUnion = isComplexProperty || isUnionProperty;
    if (isDescription || isComplexOrUnion) {
      gd = new GridData(GridData.FILL_BOTH);
      gd.heightHint = 90;
      gd.grabExcessVerticalSpace = true;
      gd.grabExcessHorizontalSpace = true;
      if (isComplexOrUnion) {
        gd.heightHint = -1;
      }
      if (isComplexProperty) {
        gd.horizontalSpan = 2;
      }

    } else {
      gd = new GridData(GridData.FILL_HORIZONTAL);
    }
    gd.widthHint = 250;
    widget.setLayoutData(gd);
  }