Examples of FormToolkit


Examples of org.eclipse.ui.forms.widgets.FormToolkit


  @Override
  protected void createFormContent(IManagedForm managedForm) {
    ScrolledForm form = managedForm.getForm();
    FormToolkit toolkit = managedForm.getToolkit();
    toolkit.decorateFormHeading(form.getForm());
   
    form.setText(PAGE_TITLE);

    ColumnLayout layout = new ColumnLayout();
    layout.maxNumColumns = 2;
    form.getBody().setLayout(layout);
       
    // encoder section
    Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION|Section.TITLE_BAR|Section.TWISTIE|Section.EXPANDED);
    section.setText("ACL Roles");

        Composite sectionClient = toolkit.createComposite(section);
        section.setClient(sectionClient);
        GridLayout sectionLayout = new GridLayout();
        GridData fillHSpan = new GridData(GridData.FILL_HORIZONTAL);
        fillHSpan.horizontalSpan = 4;
       
        GridData prefSize = new GridData();
        prefSize.widthHint = 50;
       
        sectionLayout.numColumns = 2;
        sectionClient.setLayout(sectionLayout);   
       
        // create Table for remote actions
        _tblACLRoles = toolkit.createTable(sectionClient, SWT.BORDER|SWT.FULL_SELECTION);
        registerField("aclRoles", _tblACLRoles);
        _tblACLRoles.setHeaderVisible(true);         
        GridData tblLayoutData = new GridData(GridData.FILL_BOTH);
        tblLayoutData.verticalSpan = 2;
        tblLayoutData.minimumHeight = 200;
        _tblACLRoles.setLayoutData(tblLayoutData);              
       
        int tableWidth = 450;         
        _roleNameColumn = new TableColumn(_tblACLRoles, SWT.NONE)
        _roleNameColumn.setText("Role name");
        _roleNameColumn.setWidth((int)(tableWidth * 0.5));
       
        _assignDefaultManagerColumn = new TableColumn(_tblACLRoles, SWT.NONE);
        _assignDefaultManagerColumn.setText("Assign to default manager");
        _assignDefaultManagerColumn.setWidth((int)(tableWidth * 0.5));         

        _aclRolesModel = new ACLRolesModel(_model.getACLRoles());
        _aclRolesModel.addListener(new BeanListTableModelListener() {

      public void add(Object bean) {
        _model.fireModelChanged();         
      }

      public void remove(Object bean) {
        _model.fireModelChanged();       
      }

      public void update(Object bean) {
        _model.fireModelChanged();         
      }

      @SuppressWarnings("unchecked")
      public void refresh(List beans) {
        _model.fireModelChanged();       
      }
         
        });
       
        _tblViewerACLRoles = new TableViewer(_tblACLRoles);
       
        CellEditor[] editors = new CellEditor[2];
        editors[0] = new TextCellEditor(_tblACLRoles);       
        editors[1] = new CheckboxCellEditor(_tblACLRoles);
        _tblViewerACLRoles.setCellEditors(editors);
       
        BeanListTableModelCellModifier modifier = new BeanListTableModelCellModifier(_tblViewerACLRoles, _aclRolesModel);       
        modifier.setEditMode(1, BeanListTableModelCellModifier.EDIT_MODE_ON_SINGLE_CLICK);       
        _tblViewerACLRoles.setCellModifier(modifier);  
        _tblViewerACLRoles.setContentProvider(new BeanListTableModelContentProvider());
        _tblViewerACLRoles.setLabelProvider(new BeanListTableModelLabelProvider(_aclRolesModel));
        _tblViewerACLRoles.setInput(_aclRolesModel)
       

        GridData btnLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_FILL, false, false);
        _btnAddACLRole = toolkit.createButton(sectionClient, "add", SWT.PUSH);
        _btnAddACLRole.setLayoutData(btnLayout);
        _btnAddACLRole.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleAddACLRole();
      }

    });
       
        _btnRemoveACLRole = toolkit.createButton(sectionClient, "remove", SWT.PUSH);
        _btnRemoveACLRole.setLayoutData(btnLayout);
        _btnRemoveACLRole.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleRemoveACLRole();
      }
View Full Code Here

Examples of org.eclipse.ui.forms.widgets.FormToolkit


  @Override
  protected void createFormContent(IManagedForm managedForm) {
    ScrolledForm form = managedForm.getForm();
    FormToolkit toolkit = managedForm.getToolkit();
    toolkit.decorateFormHeading(form.getForm());
   
    WidgetFactory factory = new WidgetFactory(toolkit);
   
    form.setText(PAGE_TITLE);

    ColumnLayout layout = new ColumnLayout();
    layout.maxNumColumns = 2;
    form.getBody().setLayout(layout);
   
   
    if (!_model.hasPluginConfig()) {
      GridLayout gridLayout = new GridLayout(1, false);
      form.getBody().setLayout(gridLayout);
      toolkit.createLabel(form.getBody(), "This design is currently not configured to be used as WGA Plugin.");
      _btnCreatePluginConfig = toolkit.createButton(form.getBody(), "Create WGA Plugin Configuration", SWT.PUSH);
      _btnCreatePluginConfig.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
          handleCreatePluginConfig();
        }
      });
    } else {         
      // registration section
      Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION|Section.TITLE_BAR|Section.TWISTIE|Section.EXPANDED);
      section.setText("Registration");
 
          Composite sectionClient = toolkit.createComposite(section);
          section.setClient(sectionClient);
          GridLayout sectionLayout = new GridLayout();
          GridData fillHSpan = new GridData(GridData.FILL_HORIZONTAL);
          fillHSpan.horizontalSpan = 4;
          GridData fillH = new GridData(GridData.FILL_HORIZONTAL);
         
          GridData prefSize = new GridData();
          prefSize.widthHint = 50;
         
          sectionLayout.numColumns = 5;
          sectionClient.setLayout(sectionLayout);                     
       
          _txtUniqueName = factory.createText(sectionClient, "Unique Name:", "pluginUniqueName");
          _txtUniqueName.setLayoutData(fillHSpan);
          registerField("pluginUniqueName", _txtUniqueName);
         
          _txtVersion = factory.createText(sectionClient, "Version:", "pluginVersion");
          _txtVersion.setLayoutData(prefSize);
          registerField("pluginVersion", _txtVersion);
         
          _txtBuild = factory.createText(sectionClient, "Build", "pluginBuild");
          _txtBuild.setLayoutData(prefSize);
          registerField("pluginBuild", _txtBuild);
          factory.addFiller(sectionClient);
         
          _txtMinWGAVersion = factory.createText(sectionClient, "Minimum WGA Version:", "pluginWGAVersion");
          _txtMinWGAVersion.setLayoutData(prefSize);
          registerField("pluginWGAVersion", _txtMinWGAVersion);
          factory.addFiller(sectionClient, 3);
         
          _txtMinJavaVersion = factory.createText(sectionClient, "Minimum Java Version:", "pluginJavaVersion");
          _txtMinJavaVersion.setLayoutData(prefSize);
          registerField("pluginJavaVersion", _txtMinJavaVersion);
          factory.addFiller(sectionClient, 3);
       
        // information section
        section = toolkit.createSection(form.getBody(), Section.DESCRIPTION|Section.TITLE_BAR|Section.TWISTIE|Section.EXPANDED);
      section.setText("Information and Functionality");
 
          sectionClient = toolkit.createComposite(section);
          section.setClient(sectionClient);
          sectionLayout = new GridLayout();       
          sectionLayout.numColumns = 2;
          sectionClient.setLayout(sectionLayout);
         
          _txtTitle = factory.createText(sectionClient, "Title:", "pluginTitle");
          _txtTitle.setLayoutData(fillH);
          registerField("pluginTitle", _txtTitle);
         
          _txtVendor = factory.createText(sectionClient, "Vendor:", "pluginVendor");
          _txtVendor.setLayoutData(fillH)
          registerField("pluginVendor", _txtVendor);
         
          _txtVendorHomepage = factory.createText(sectionClient, "Vendor Homepage:", "pluginVendorHomepage");
          _txtVendorHomepage.setLayoutData(fillH);
          registerField("pluginVendorHomepage", _txtVendorHomepage);
         
          _txtDescription = factory.createTextArea(sectionClient, "Description:", "pluginDescription");
           GridData textBox = new GridData(GridData.FILL_BOTH);
           textBox.minimumHeight = 100;
          _txtDescription.setLayoutData(textBox);
          registerField("pluginDescription", _txtDescription)
         
          _txtPluginHomepage = factory.createText(sectionClient, "Plugin Homepage:", "pluginHomepage");
          _txtPluginHomepage.setLayoutData(fillH);
          registerField("pluginHomepage", _txtPluginHomepage);
         
          _comboAuthenticationSource = factory.createCombo(sectionClient, "Authentication source:", "pluginAuthenticationSource");
          registerField("pluginAuthenticationSource", _comboAuthenticationSource);
         
          _comboPersMode = factory.createCombo(sectionClient, "Personalisation mode:", "pluginPersonalisationMode");
          registerField("pluginPersonalisationMode", _comboPersMode);
         
          toolkit.createLabel(sectionClient, "Usage:");
         
          _chkUsageDesignProvider = toolkit.createButton(sectionClient, "Design Provider", SWT.CHECK);
          _chkUsageDesignProvider.setData("pluginUsageAsDesignProvider");
          registerField("pluginUsageAsDesignProvider", _chkUsageDesignProvider);
       
         
          toolkit.createLabel(sectionClient, "")
          _chkUsageAuthSource = toolkit.createButton(sectionClient, "Authentication Source", SWT.CHECK);
        _chkUsageAuthSource.setData("pluginUsageAsAuthenticationSource");
        registerField("pluginUsageAsAuthenticationSource", _chkUsageAuthSource);
       
        toolkit.createLabel(sectionClient, "");
        _chkUsageContentStore = toolkit.createButton(sectionClient, "Published WGA Content Store", SWT.CHECK);
          _chkUsageContentStore.setData("pluginUsageAsContentStore");
          _chkUsageContentStore.setData(SWTBotIDs.WIDGET_KEY, ResourceIDs.BUTTON_IN_DESGINPLUGIN_EDITOR);
          registerField("pluginUsageAsContentStore", _chkUsageContentStore);
         
//          _chkAllowContentAuthoring = factory.createCheckBox(sectionClient, "Further options:", "Allow Content Authoring", "allowContentAuthoring");
//          registerField("allowContentAuthoring", _chkAllowContentAuthoring);
         
          _chkClearPluginDatabaseOnUpdate = factory.createCheckBox(sectionClient, "", "Clear plugin database on update", "pluginClearDatabaseOnUpdate");
          registerField("pluginClearDatabaseOnUpdate", _chkClearPluginDatabaseOnUpdate);
         
          _chkDisableInit = factory.createCheckBox(sectionClient, "", "Do not execute init/ connect functionalities on plugin itself", "pluginDisableInit");
          registerField("pluginDisableInit", _chkDisableInit);
         
          // dependencies section
      section = toolkit.createSection(form.getBody(), Section.DESCRIPTION|Section.TITLE_BAR|Section.TWISTIE|Section.COMPACT);
      section.setText("Dependencies");
 
          sectionClient = toolkit.createComposite(section);
          section.setClient(sectionClient);
          sectionLayout = new GridLayout();                                     
          sectionLayout.numColumns = 2;
          sectionClient.setLayout(sectionLayout);
         

          _tblDependencies = toolkit.createTable(sectionClient, SWT.BORDER|SWT.FULL_SELECTION);
          _tblDependencies.setHeaderVisible(true);         
          GridData tblLayoutData = new GridData(GridData.FILL_BOTH);
          tblLayoutData.verticalSpan = 2;
          tblLayoutData.minimumHeight = 200;
          _tblDependencies.setLayoutData(tblLayoutData);  
          registerField("pluginDependencies", _tblDependencies);
         
          int tableWidth = 450;         
          _uniqueNameColumn = new TableColumn(_tblDependencies, SWT.NONE)
          _uniqueNameColumn.setText("Plugin unique name");
          _uniqueNameColumn.setWidth((int)(tableWidth * 0.8));
         
          _minVersionColumn = new TableColumn(_tblDependencies, SWT.NONE);
          _minVersionColumn.setText("Minimum version");
          _minVersionColumn.setWidth((int)(tableWidth * 0.2));         

          _pluginDependenciesModel = new PluginDependenciesModel(_model.getPluginDependencies());
          _pluginDependenciesModel.addListener(new BeanListTableModelListener() {

        public void add(Object bean) {
          _model.fireModelChanged();         
        }

        public void remove(Object bean) {
          _model.fireModelChanged();       
        }

        public void update(Object bean) {
          _model.fireModelChanged();         
        }
       

        @SuppressWarnings("unchecked")
        public void refresh(List beans) {
          _model.fireModelChanged();       
        }
           
          });
         
          _tblViewerPluginDependencies = new TableViewer(_tblDependencies);
         
          // text editors for both columns
          CellEditor[] editors = new CellEditor[2];
          editors[0] = new TextCellEditor(_tblDependencies);
          editors[1] = new TextCellEditor(_tblDependencies);         
          _tblViewerPluginDependencies.setCellEditors(editors);
         
          _tblViewerPluginDependencies.setCellModifier(new BeanListTableModelCellModifier(_tblViewerPluginDependencies, _pluginDependenciesModel));                                       
          _tblViewerPluginDependencies.setContentProvider(new BeanListTableModelContentProvider());
          _tblViewerPluginDependencies.setLabelProvider(new BeanListTableModelLabelProvider(_pluginDependenciesModel));
          _tblViewerPluginDependencies.setInput(_pluginDependenciesModel);
               

          GridData btnLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_FILL, false, false);
          _btnAddDependency = toolkit.createButton(sectionClient, "add", SWT.PUSH);
          _btnAddDependency.setLayoutData(btnLayout);
          _btnAddDependency.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
          handleAddDependency();
        }

      });
         
          //factory.addFiller(sectionClient);
         
          _btnRemoveDependency = toolkit.createButton(sectionClient, "remove", SWT.PUSH);
          _btnRemoveDependency.setLayoutData(btnLayout);
          _btnRemoveDependency.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
          handleRemoveDependency();
        }
View Full Code Here

Examples of org.eclipse.ui.forms.widgets.FormToolkit


  @Override
  protected void createFormContent(IManagedForm managedForm) {
    ScrolledForm form = managedForm.getForm();
    FormToolkit toolkit = managedForm.getToolkit();
    toolkit.decorateFormHeading(form.getForm());
   
    form.setText(PAGE_TITLE);

    ColumnLayout layout = new ColumnLayout();
    layout.maxNumColumns = 2;
    form.getBody().setLayout(layout);
       
    // encoder section
    Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION|Section.TITLE_BAR|Section.TWISTIE|Section.EXPANDED);
    section.setText("Design Shortcuts");

        Composite sectionClient = toolkit.createComposite(section);
        section.setClient(sectionClient);
        GridLayout sectionLayout = new GridLayout();
        GridData fillHSpan = new GridData(GridData.FILL_HORIZONTAL);
        fillHSpan.horizontalSpan = 4;
       
        GridData prefSize = new GridData();
        prefSize.widthHint = 50;
       
        sectionLayout.numColumns = 2;
        sectionClient.setLayout(sectionLayout);   
       
        // create Table
        _tblShortcuts = toolkit.createTable(sectionClient, SWT.BORDER|SWT.FULL_SELECTION);
        _tblShortcuts.setHeaderVisible(true);         
        GridData tblLayoutData = new GridData(GridData.FILL_BOTH);
        tblLayoutData.verticalSpan = 2;
        tblLayoutData.minimumHeight = 200;
        _tblShortcuts.setLayoutData(tblLayoutData);     
        registerField("shortcuts", _tblShortcuts);
       
        int tableWidth = 700;         
        _nameColumn = new TableColumn(_tblShortcuts, SWT.NONE)
        _nameColumn.setText("Shortcut");
        _nameColumn.setWidth((int)(tableWidth * 0.3));
       
        _typeColumn = new TableColumn(_tblShortcuts, SWT.NONE);
        _typeColumn.setText("Type");
        _typeColumn.setWidth((int)(tableWidth * 0.3));         

        _referenceColumn = new TableColumn(_tblShortcuts, SWT.NONE);
      _referenceColumn.setText("Reference");
      _referenceColumn.setWidth((int)(tableWidth * 0.3));

       
       
        _shortcutsModel = new ShortcutsModel(_model.getShortcuts());
        _shortcutsModel.addListener(new BeanListTableModelListener() {

      public void add(Object bean) {
        _model.fireModelChanged();         
      }

      public void remove(Object bean) {
        _model.fireModelChanged();       
      }

      public void update(Object bean) {
        _model.fireModelChanged();         
      }

      @SuppressWarnings("unchecked")
      public void refresh(List beans) {
        _model.fireModelChanged();       
      }
         
        });
       
        _tblViewerShortcuts = new TableViewer(_tblShortcuts);
             
        List<String> shortcutTypes = new ArrayList<String>();
        Iterator<ShortcutType> it = WGADesignConfigurationModel.SHORTCUTTYPES.values().iterator();
        _shortcutTypesByIndex = new HashMap<Integer, ShortcutType>();
        int i = 0;
        while (it.hasNext()) {
          ShortcutType type = it.next();
          shortcutTypes.add(type.getValue());
          _shortcutTypesByIndex.put(i, type);
          i++;
        }
       
        CellEditor[] editors = new CellEditor[5];
        editors[0] = new TextCellEditor(_tblShortcuts);       
        editors[1] = new ComboBoxCellEditor(_tblShortcuts, shortcutTypes.toArray(new String[0]), SWT.READ_ONLY);
       
        editors[2] = new TextCellEditor(_tblShortcuts);
        editors[3] = new TextCellEditor(_tblShortcuts);
        editors[4] = new TextCellEditor(_tblShortcuts);
       
        _tblViewerShortcuts.setCellEditors(editors);
       
        BeanListTableModelCellModifier modifier = new BeanListTableModelCellModifier(_tblViewerShortcuts, _shortcutsModel);       
        modifier.setEditMode(1, BeanListTableModelCellModifier.EDIT_MODE_ON_SINGLE_CLICK);       
        _tblViewerShortcuts.setCellModifier(modifier);  
        modifier.setValueMapper(1, new BeanListTableModelValueMapper() {

      public Object map(Object element, String property, Object value) {
        return  _shortcutTypesByIndex.get((Integer) value).getKey();
      }
         
        });
        _tblViewerShortcuts.setContentProvider(new BeanListTableModelContentProvider());
        _tblViewerShortcuts.setLabelProvider(new BeanListTableModelLabelProvider(_shortcutsModel));
        _tblViewerShortcuts.setInput(_shortcutsModel)
       

        GridData btnLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_FILL, false, false);
        _btnAddShortcut = toolkit.createButton(sectionClient, "add", SWT.PUSH);
        _btnAddShortcut.setLayoutData(btnLayout);
        _btnAddShortcut.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleAddShortcut();
      }

    });
       
        _btnRemoveShortcut = toolkit.createButton(sectionClient, "remove", SWT.PUSH);
        _btnRemoveShortcut.setLayoutData(btnLayout);
        _btnRemoveShortcut.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleRemoveShortcut();
      }
View Full Code Here

Examples of org.eclipse.ui.forms.widgets.FormToolkit


  @Override
  protected void createFormContent(IManagedForm managedForm) {
    ScrolledForm form = managedForm.getForm();
    FormToolkit toolkit = managedForm.getToolkit();
    toolkit.decorateFormHeading(form.getForm());
   
    WidgetFactory factory = new WidgetFactory(toolkit);
   
    form.setText(PAGE_TITLE);

    ColumnLayout layout = new ColumnLayout();
    layout.maxNumColumns = 2;
    form.getBody().setLayout(layout);
       

        GridLayout sectionLayout = new GridLayout();
        sectionLayout.numColumns = 2;
       
        GridData fillHSpan = new GridData(GridData.FILL_HORIZONTAL);
        fillHSpan.horizontalSpan = 4;
        GridData fillH = new GridData(GridData.FILL_HORIZONTAL);
       
        GridData prefSize = new GridData();
        prefSize.widthHint = 50;
       
        int tableWidth = 450;
        GridData tblLayoutData = new GridData(GridData.FILL_BOTH);
      tblLayoutData.verticalSpan = 2;
      tblLayoutData.minimumHeight = 200;
       
      GridData btnLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_FILL, true, false);
     
        // mediakeys section
    Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION|Section.TITLE_BAR|Section.TWISTIE|Section.EXPANDED);
    section.setText("Media Keys");

        Composite sectionClient = toolkit.createComposite(section);
        section.setClient(sectionClient);     
        sectionClient.setLayout(sectionLayout);   
       
        // create Table media keys
        _tblMediaKeys = toolkit.createTable(sectionClient, SWT.BORDER|SWT.FULL_SELECTION);
        _tblMediaKeys.setHeaderVisible(true);         
        _tblMediaKeys.setLayoutData(GridDataFactory.copyData(tblLayoutData));  
        registerField("mediaKeys", _tblMediaKeys);
               
        _mediaKeyColumn = new TableColumn(_tblMediaKeys, SWT.NONE);               
        _mediaKeyColumn.setText("Key");
        _mediaKeyColumn.setWidth((int)(tableWidth * 0.25));
       
        _mediaMimeTypeColumn = new TableColumn(_tblMediaKeys, SWT.NONE)
        _mediaMimeTypeColumn.setText("Mime type");
        _mediaMimeTypeColumn.setWidth((int)(tableWidth * 0.25));
       
        _mediaBinaryColumn = new TableColumn(_tblMediaKeys, SWT.NONE)
        _mediaBinaryColumn.setText("Binary output");
        _mediaBinaryColumn.setWidth((int)(tableWidth * 0.25));

       
        _mediaHTTPLoginColumn = new TableColumn(_tblMediaKeys, SWT.NONE)
        _mediaHTTPLoginColumn.setText("Use HTTP login");
        _mediaHTTPLoginColumn.setWidth((int)(tableWidth * 0.25));

        _mediaKeysModel = new MediaKeysModel(_model.getMediaKeys());
        _mediaKeysModel.addListener(new BeanListTableModelListener() {

      public void add(Object bean) {
        _model.fireModelChanged();         
      }

      public void remove(Object bean) {
        _model.fireModelChanged();       
      }

      public void update(Object bean) {
        _model.fireModelChanged();         
      }
     
      @SuppressWarnings("unchecked")
      public void refresh(List beans) {
        _model.fireModelChanged();       
      }
         
        });
       
        _tblViewerMediaKeys = new TableViewer(_tblMediaKeys);
       
        CellEditor[] editors = new CellEditor[4];
        editors[0] = new TextCellEditor(_tblMediaKeys);
        editors[1] = new TextCellEditor(_tblMediaKeys);
        editors[2] = new CheckboxCellEditor(_tblMediaKeys, SWT.CENTER);       
        editors[3] = new CheckboxCellEditor(_tblMediaKeys, SWT.CENTER);
        _tblViewerMediaKeys.setCellEditors(editors);
       
        BeanListTableModelCellModifier modifier = new BeanListTableModelCellModifier(_tblViewerMediaKeys, _mediaKeysModel);
        modifier.setEditMode(2, BeanListTableModelCellModifier.EDIT_MODE_ON_SINGLE_CLICK);
        modifier.setEditMode(3, BeanListTableModelCellModifier.EDIT_MODE_ON_SINGLE_CLICK);
        _tblViewerMediaKeys.setCellModifier(modifier);
       
        _tblViewerMediaKeys.setContentProvider(new BeanListTableModelContentProvider());
        _tblViewerMediaKeys.setLabelProvider(new BeanListTableModelLabelProvider(_mediaKeysModel));
        _tblViewerMediaKeys.setInput(_mediaKeysModel)
       

        _btnAddMediaKey = toolkit.createButton(sectionClient, "add", SWT.PUSH);
        _btnAddMediaKey.setLayoutData(btnLayout);
        _btnAddMediaKey.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleAddMediaKey();
      }

    });
       
        _btnRemoveMediaKey = toolkit.createButton(sectionClient, "remove", SWT.PUSH);
        _btnRemoveMediaKey.setLayoutData(btnLayout);
        _btnRemoveMediaKey.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleRemoveMediaKey();
      }
    });
       
    // encoder section
    section = toolkit.createSection(form.getBody(), Section.DESCRIPTION|Section.TITLE_BAR|Section.TWISTIE|Section.COMPACT);
    section.setText("Encoder Mappings");

        sectionClient = toolkit.createComposite(section);
        sectionClient.setLayout(sectionLayout);
        section.setClient(sectionClient);
       
        // create Table encoder mappings
        _tblEncoderMappings = toolkit.createTable(sectionClient, SWT.BORDER|SWT.FULL_SELECTION);
        _tblEncoderMappings.setHeaderVisible(true);                 
        _tblEncoderMappings.setLayoutData(GridDataFactory.copyData(tblLayoutData));   
        registerField("encoderMappings", _tblEncoderMappings);
         
        _encoderNameColumn = new TableColumn(_tblEncoderMappings, SWT.NONE)
        _encoderNameColumn.setText("Encoder name");
        _encoderNameColumn.setWidth((int)(tableWidth * 0.5));
       
        _encoderImplClassColumn = new TableColumn(_tblEncoderMappings, SWT.NONE);
        _encoderImplClassColumn.setText("Implementation class");
        _encoderImplClassColumn.setWidth((int)(tableWidth * 0.5));         

        _encoderMappingsModel = new EncoderMappingsModel(_model.getEncoderMappings());
        _encoderMappingsModel.addListener(new BeanListTableModelListener() {

      public void add(Object bean) {
        _model.fireModelChanged();         
      }

      public void remove(Object bean) {
        _model.fireModelChanged();       
      }

      public void update(Object bean) {
        _model.fireModelChanged();         
      }     

      @SuppressWarnings("unchecked")
      public void refresh(List beans) {
        _model.fireModelChanged();       
      }
         
        });
       
        _tblViewerEncoderMappings = new TableViewer(_tblEncoderMappings);
       
        // text editors for both columns
        editors = new CellEditor[2];
        editors[0] = new TextCellEditor(_tblEncoderMappings);
        editors[1] = new TextCellEditor(_tblEncoderMappings);         
        _tblViewerEncoderMappings.setCellEditors(editors);
       
        _tblViewerEncoderMappings.setCellModifier(new BeanListTableModelCellModifier(_tblViewerEncoderMappings, _encoderMappingsModel));                                       
        _tblViewerEncoderMappings.setContentProvider(new BeanListTableModelContentProvider());
        _tblViewerEncoderMappings.setLabelProvider(new BeanListTableModelLabelProvider(_encoderMappingsModel));
        _tblViewerEncoderMappings.setInput(_encoderMappingsModel)
       
        _btnAddEncoderMapping = toolkit.createButton(sectionClient, "add", SWT.PUSH);
        _btnAddEncoderMapping.setLayoutData(btnLayout);
        _btnAddEncoderMapping.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleAddEncoderMapping();
      }

    });
       
        _btnRemoveEncoderMapping = toolkit.createButton(sectionClient, "remove", SWT.PUSH);
        _btnRemoveEncoderMapping.setLayoutData(btnLayout);
      _btnRemoveEncoderMapping.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleRemoveEncoderMapping();
      }
    });

     
      // element section
    section = toolkit.createSection(form.getBody(), Section.DESCRIPTION|Section.TITLE_BAR|Section.TWISTIE|Section.COMPACT);
    section.setText("Element Mappings");

        sectionClient = toolkit.createComposite(section);
        section.setClient(sectionClient);     
        sectionLayout.numColumns = 2;
        sectionClient.setLayout(sectionLayout);   
       
        // create Table element mappings
        _tblElementMappings = toolkit.createTable(sectionClient, SWT.BORDER|SWT.FULL_SELECTION);
        _tblElementMappings.setHeaderVisible(true);         
        _tblElementMappings.setLayoutData(GridDataFactory.copyData(tblLayoutData))
        registerField("elementMappings", _tblElementMappings);
               
        _elementNameColumn = new TableColumn(_tblElementMappings, SWT.NONE)
        _elementNameColumn.setText("Element name");
        _elementNameColumn.setWidth((int)(tableWidth * 0.5));
       
        _elementImplClassColumn = new TableColumn(_tblElementMappings, SWT.NONE);
        _elementImplClassColumn.setText("Implementation class");
        _elementImplClassColumn.setWidth((int)(tableWidth * 0.5));         

        _elementMappingsModel = new ElementMappingsModel(_model.getElementMappings());
        _elementMappingsModel.addListener(new BeanListTableModelListener() {

      public void add(Object bean) {
        _model.fireModelChanged();         
      }

      public void remove(Object bean) {
        _model.fireModelChanged();       
      }

      public void update(Object bean) {
        _model.fireModelChanged();         
      }
     
      @SuppressWarnings("unchecked")
      public void refresh(List beans) {
        _model.fireModelChanged();       
      }
         
        });
       
        _tblViewerElementMappings = new TableViewer(_tblElementMappings);
       
        // text editors for both columns
        editors = new CellEditor[2];
        editors[0] = new TextCellEditor(_tblElementMappings);
        editors[1] = new TextCellEditor(_tblElementMappings);         
        _tblViewerElementMappings.setCellEditors(editors);
       
        _tblViewerElementMappings.setCellModifier(new BeanListTableModelCellModifier(_tblViewerElementMappings, _elementMappingsModel));                                       
        _tblViewerElementMappings.setContentProvider(new BeanListTableModelContentProvider());
        _tblViewerElementMappings.setLabelProvider(new BeanListTableModelLabelProvider(_elementMappingsModel));
        _tblViewerElementMappings.setInput(_elementMappingsModel)
       

        _btnAddElementMapping = toolkit.createButton(sectionClient, "add", SWT.PUSH);
        _btnAddElementMapping.setLayoutData(btnLayout);
        _btnAddElementMapping.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleAddElementMapping();
      }

    });
       
        _btnRemoveElementMapping = toolkit.createButton(sectionClient, "remove", SWT.PUSH);
        _btnRemoveElementMapping.setLayoutData(btnLayout);
        _btnRemoveElementMapping.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleRemoveElementMapping();
      }
View Full Code Here

Examples of org.eclipse.ui.forms.widgets.FormToolkit


  @Override
  protected void createFormContent(IManagedForm managedForm) {
    ScrolledForm form = managedForm.getForm();
    FormToolkit toolkit = managedForm.getToolkit();
    toolkit.decorateFormHeading(form.getForm());

    form.setText(PAGE_TITLE);

    ColumnLayout layout = new ColumnLayout();
    layout.maxNumColumns = 2;
    form.getBody().setLayout(layout);
       
    // publisher options section
    Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION|Section.TITLE_BAR|Section.TWISTIE|Section.EXPANDED);
    section.setText("Publisher options");

        Composite sectionClient = toolkit.createComposite(section);
        section.setClient(sectionClient);
        GridLayout sectionLayout = new GridLayout();
        GridData fillHSpan = new GridData(GridData.FILL_HORIZONTAL);
        fillHSpan.horizontalSpan = 4;

        sectionLayout.numColumns = 1;
        sectionClient.setLayout(sectionLayout);   
       
        _tablePublisherOptions = new EditableTableControl<PublisherOption>(sectionClient,SWT.NONE, SWT.FULL_SELECTION|SWT.BORDER);
        GridData tablePublisherOptionsLayoutData = new GridData(GridData.FILL_BOTH);
        tablePublisherOptionsLayoutData.minimumHeight = 200;
        _tablePublisherOptions.setLayoutData(tablePublisherOptionsLayoutData);
       
    // create columns
    String[] columnNames = new String[] { "Name", "Value" };
   
    // create model
    _publisherOptionsModel = new PublisherOptionsModel(_model.getPublisherOptions());
   
    _publisherOptionsModel.addListener(new BeanListTableModelListener() {

      public void add(Object bean) {
        _model.fireModelChanged();         
      }

      public void remove(Object bean) {
        _model.fireModelChanged();       
      }

      public void update(Object bean) {
        _model.fireModelChanged();         
      }     

      @SuppressWarnings("unchecked")
      public void refresh(List beans) {
        //_model.fireModelChanged();       
      }
         
        });
   
    _tablePublisherOptions.init(columnNames, _publisherOptionsModel);

   
    CellEditor[] editors = new CellEditor[2];
        editors[0] = new TextCellEditor(_tablePublisherOptions.getTable());
        editors[1] = new TextCellEditor(_tablePublisherOptions.getTable());
    _tablePublisherOptions.getTableViewer().setCellEditors(editors);
   
    toolkit.adapt(_tablePublisherOptions.getButton(EditableTableControl.BUTTON_ADD), true, true);
    toolkit.adapt(_tablePublisherOptions.getButton(EditableTableControl.BUTTON_REMOVE), true, true);
   
    _tablePublisherOptions.getButton(EditableTableControl.BUTTON_ADD).addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleAddPublisherOption();
      }
    });

    _tablePublisherOptions.getButton(EditableTableControl.BUTTON_REMOVE).addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleRemovePublisherOption();
      }
    });
   
    _tablePublisherOptions.getTable().addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        if (_tablePublisherOptions.getTable().getSelectionCount() > 0) {
          PublisherOption option = (PublisherOption) _tablePublisherOptions.getTable().getSelection()[0].getData();
          if (_publisherOptionsModel.isBeanEditable(option)) {
            _tablePublisherOptions.getButton(EditableTableControl.BUTTON_REMOVE).setEnabled(true);
          } else {
            _tablePublisherOptions.getButton(EditableTableControl.BUTTON_REMOVE).setEnabled(false);
          }
        }
      }
    });
       
       
    // remote actions section
    section = toolkit.createSection(form.getBody(), Section.DESCRIPTION|Section.TITLE_BAR|Section.TWISTIE|Section.EXPANDED);
    section.setText("Remote Actions");

        sectionClient = toolkit.createComposite(section);
        section.setClient(sectionClient);
        sectionLayout = new GridLayout();
        fillHSpan = new GridData(GridData.FILL_HORIZONTAL);
        fillHSpan.horizontalSpan = 4;
       
        GridData prefSize = new GridData();
        prefSize.widthHint = 50;
       
        sectionLayout.numColumns = 2;
        sectionClient.setLayout(sectionLayout);   
       
        // create Table for remote actions
        _tblRemoteActions = toolkit.createTable(sectionClient, SWT.BORDER|SWT.FULL_SELECTION);
        _tblRemoteActions.setHeaderVisible(true);         
        GridData tblLayoutData = new GridData(GridData.FILL_BOTH);
        tblLayoutData.verticalSpan = 2;
        tblLayoutData.minimumHeight = 200;
        _tblRemoteActions.setLayoutData(tblLayoutData);     
        registerField("remoteActions", _tblRemoteActions);
       
        int tableWidth = 450;         
        _actionModuleColumn = new TableColumn(_tblRemoteActions, SWT.NONE)
        _actionModuleColumn.setText("Action module");
        _actionModuleColumn.setWidth((int)(tableWidth * 0.3));
       
        _minAccessLevelColumn = new TableColumn(_tblRemoteActions, SWT.NONE);
        _minAccessLevelColumn.setText("Minimum access level");
        _minAccessLevelColumn.setWidth((int)(tableWidth * 0.3));         

        _callersColumn = new TableColumn(_tblRemoteActions, SWT.NONE);
      _callersColumn.setText("Callers (comma separated)");
      _callersColumn.setWidth((int)(tableWidth * 0.3));
       
        _remoteActionsModel = new RemoteActionsModel(_model.getRemoteActions());
        _remoteActionsModel.addListener(new BeanListTableModelListener() {

      public void add(Object bean) {
        _model.fireModelChanged();         
      }

      public void remove(Object bean) {
        _model.fireModelChanged();       
      }

      public void update(Object bean) {
        _model.fireModelChanged();         
      }
     

      @SuppressWarnings("unchecked")
      public void refresh(List beans) {
        _model.fireModelChanged();       
      }
         
        });
       
        _tblViewerRemoteActions = new TableViewer(_tblRemoteActions);
             
        List<String> accessLevelValues = new ArrayList<String>();
        List<AccessLevel> sortedAccessLevels = new ArrayList<AccessLevel>(WGADesignConfigurationModel.ACCESSLEVELS_REMOTE_ACTIONS.values());
        Collections.sort(sortedAccessLevels, new Comparator<AccessLevel>() {

      public int compare(AccessLevel o1, AccessLevel o2) {       
        return o1.getKey().compareTo(o2.getKey());
      }
         
        });
        Iterator<AccessLevel> it = sortedAccessLevels.iterator();
        _accessLevelByIndex = new HashMap<Integer, AccessLevel>();
        int i = 0;
        while (it.hasNext()) {
          AccessLevel level = it.next();
          accessLevelValues.add(level.getValue());
          _accessLevelByIndex.put(i, level);
          i++;
        }
       
        editors = new CellEditor[3];
        editors[0] = new TextCellEditor(_tblRemoteActions);       
        editors[1] = new ComboBoxCellEditor(_tblRemoteActions, accessLevelValues.toArray(new String[0]), SWT.READ_ONLY);
       
        editors[2] = new TextCellEditor(_tblRemoteActions);         
        _tblViewerRemoteActions.setCellEditors(editors);
       
        BeanListTableModelCellModifier modifier = new BeanListTableModelCellModifier(_tblViewerRemoteActions, _remoteActionsModel);       
        modifier.setEditMode(1, BeanListTableModelCellModifier.EDIT_MODE_ON_SINGLE_CLICK);       
        _tblViewerRemoteActions.setCellModifier(modifier);  
        modifier.setValueMapper(1, new BeanListTableModelValueMapper() {

      public Object map(Object element, String property, Object value) {
          if ((Integer)value == -1) {
              value = 0;
          }
        return  _accessLevelByIndex.get((Integer) value).getKey();
      }
         
        });
        _tblViewerRemoteActions.setContentProvider(new BeanListTableModelContentProvider());
        _tblViewerRemoteActions.setLabelProvider(new BeanListTableModelLabelProvider(_remoteActionsModel));
        _tblViewerRemoteActions.setInput(_remoteActionsModel)
       

        GridData btnLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_FILL, false, false);
        _btnAddRemoteAction = toolkit.createButton(sectionClient, "add", SWT.PUSH);
        _btnAddRemoteAction.setLayoutData(btnLayout);
        _btnAddRemoteAction.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleAddRemoteAction();
      }

    });
       
        _btnRemoveRemoteAction = toolkit.createButton(sectionClient, "remove", SWT.PUSH);
        _btnRemoveRemoteAction.setLayoutData(btnLayout);
        _btnRemoveRemoteAction.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleRemoveRemoteAction();
      }
View Full Code Here

Examples of org.eclipse.ui.forms.widgets.FormToolkit

        _model = (WGADesignConfigurationModelWrapper) model;
    }

    protected void createFormContent(IManagedForm managedForm) {
        ScrolledForm form = managedForm.getForm();
        FormToolkit toolkit = managedForm.getToolkit();
        toolkit.decorateFormHeading(form.getForm());
        form.setText(PAGE_TITLE);

        ColumnLayout layout = new ColumnLayout();
        layout.maxNumColumns = 2;
        form.getBody().setLayout(layout);

        Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION | Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
        section.setText("Modules");

        Composite sectionClient = toolkit.createComposite(section);
        section.setClient(sectionClient);
        GridLayout sectionLayout = new GridLayout();
        GridData fillHSpan = new GridData(GridData.FILL_HORIZONTAL);
        fillHSpan.horizontalSpan = 4;
View Full Code Here

Examples of org.eclipse.ui.forms.widgets.FormToolkit


  @Override
  protected void createFormContent(IManagedForm managedForm) {
    ScrolledForm form = managedForm.getForm();
    FormToolkit toolkit = managedForm.getToolkit();
    toolkit.decorateFormHeading(form.getForm());
   
    form.setText(PAGE_TITLE);

    ColumnLayout layout = new ColumnLayout();
    layout.maxNumColumns = 2;
    form.getBody().setLayout(layout);
       
    // encoder section
    Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION|Section.TITLE_BAR|Section.TWISTIE|Section.EXPANDED);
    section.setText("Remote Actions");

        Composite sectionClient = toolkit.createComposite(section);
        section.setClient(sectionClient);
        GridLayout sectionLayout = new GridLayout();
        GridData fillHSpan = new GridData(GridData.FILL_HORIZONTAL);
        fillHSpan.horizontalSpan = 4;
       
        GridData prefSize = new GridData();
        prefSize.widthHint = 50;
       
        sectionLayout.numColumns = 2;
        sectionClient.setLayout(sectionLayout);   
       
        // create Table for remote actions
        _tblRemoteActions = toolkit.createTable(sectionClient, SWT.BORDER|SWT.FULL_SELECTION);
        _tblRemoteActions.setHeaderVisible(true);         
        GridData tblLayoutData = new GridData(GridData.FILL_BOTH);
        tblLayoutData.verticalSpan = 2;
        tblLayoutData.minimumHeight = 200;
        _tblRemoteActions.setLayoutData(tblLayoutData);     
        registerField("remoteActions", _tblRemoteActions);
       
        int tableWidth = 450;         
        _actionModuleColumn = new TableColumn(_tblRemoteActions, SWT.NONE)
        _actionModuleColumn.setText("Action module");
        _actionModuleColumn.setWidth((int)(tableWidth * 0.3));
       
        _minAccessLevelColumn = new TableColumn(_tblRemoteActions, SWT.NONE);
        _minAccessLevelColumn.setText("Minimum access level");
        _minAccessLevelColumn.setWidth((int)(tableWidth * 0.3));         

        _callersColumn = new TableColumn(_tblRemoteActions, SWT.NONE);
      _callersColumn.setText("Callers (comma separated)");
      _callersColumn.setWidth((int)(tableWidth * 0.3));
       
        _remoteActionsModel = new RemoteActionsModel(_model.getRemoteActions());
        _remoteActionsModel.addListener(new BeanListTableModelListener() {

      public void add(Object bean) {
        _model.fireModelChanged();         
      }

      public void remove(Object bean) {
        _model.fireModelChanged();       
      }

      public void update(Object bean) {
        _model.fireModelChanged();         
      }
     

      @SuppressWarnings("unchecked")
      public void refresh(List beans) {
        _model.fireModelChanged();       
      }
         
        });
       
        _tblViewerRemoteActions = new TableViewer(_tblRemoteActions);
             
        List<String> accessLevelValues = new ArrayList<String>();
        List<AccessLevel> sortedAccessLevels = new ArrayList<AccessLevel>(WGADesignConfigurationModel.ACCESSLEVELS_REMOTE_ACTIONS.values());
        Collections.sort(sortedAccessLevels, new Comparator<AccessLevel>() {

      public int compare(AccessLevel o1, AccessLevel o2) {       
        return o1.getKey().compareTo(o2.getKey());
      }
         
        });
        Iterator<AccessLevel> it = sortedAccessLevels.iterator();
        _accessLevelByIndex = new HashMap<Integer, AccessLevel>();
        int i = 0;
        while (it.hasNext()) {
          AccessLevel level = it.next();
          accessLevelValues.add(level.getValue());
          _accessLevelByIndex.put(i, level);
          i++;
        }
       
        CellEditor[] editors = new CellEditor[3];
        editors[0] = new TextCellEditor(_tblRemoteActions);       
        editors[1] = new ComboBoxCellEditor(_tblRemoteActions, accessLevelValues.toArray(new String[0]), SWT.READ_ONLY);
       
        editors[2] = new TextCellEditor(_tblRemoteActions);         
        _tblViewerRemoteActions.setCellEditors(editors);
       
        BeanListTableModelCellModifier modifier = new BeanListTableModelCellModifier(_tblViewerRemoteActions, _remoteActionsModel);       
        modifier.setEditMode(1, BeanListTableModelCellModifier.EDIT_MODE_ON_SINGLE_CLICK);       
        _tblViewerRemoteActions.setCellModifier(modifier);  
        modifier.setValueMapper(1, new BeanListTableModelValueMapper() {

      public Object map(Object element, String property, Object value) {
        return  _accessLevelByIndex.get((Integer) value).getKey();
      }
         
        });
        _tblViewerRemoteActions.setContentProvider(new BeanListTableModelContentProvider());
        _tblViewerRemoteActions.setLabelProvider(new BeanListTableModelLabelProvider(_remoteActionsModel));
        _tblViewerRemoteActions.setInput(_remoteActionsModel)
       

        GridData btnLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_FILL, false, false);
        _btnAddRemoteAction = toolkit.createButton(sectionClient, "add", SWT.PUSH);
        _btnAddRemoteAction.setLayoutData(btnLayout);
        _btnAddRemoteAction.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleAddRemoteAction();
      }

    });
       
        _btnRemoveRemoteAction = toolkit.createButton(sectionClient, "remove", SWT.PUSH);
        _btnRemoveRemoteAction.setLayoutData(btnLayout);
        _btnRemoveRemoteAction.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleRemoveRemoteAction();
      }
View Full Code Here

Examples of org.eclipse.ui.forms.widgets.FormToolkit


  @Override
  protected void createFormContent(IManagedForm managedForm) {
    ScrolledForm form = managedForm.getForm();
    FormToolkit toolkit = managedForm.getToolkit();
    toolkit.decorateFormHeading(form.getForm());
   
    form.setText(PAGE_TITLE);

    ColumnLayout layout = new ColumnLayout();
    layout.maxNumColumns = 2;
    form.getBody().setLayout(layout);
       
    // encoder section
    Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION|Section.TITLE_BAR|Section.TWISTIE|Section.EXPANDED);
    section.setText("Job Definitions");

        Composite sectionClient = toolkit.createComposite(section);
        section.setClient(sectionClient);
        GridLayout sectionLayout = new GridLayout();
        GridData fillHSpan = new GridData(GridData.FILL_HORIZONTAL);
        fillHSpan.horizontalSpan = 4;
       
        GridData prefSize = new GridData();
        prefSize.widthHint = 50;
       
        sectionLayout.numColumns = 2;
        sectionClient.setLayout(sectionLayout);   
       
        // create Table for remote actions
        _tblJobDefinitions = toolkit.createTable(sectionClient, SWT.BORDER|SWT.FULL_SELECTION);
        _tblJobDefinitions.setHeaderVisible(true);         
        GridData tblLayoutData = new GridData(GridData.FILL_BOTH);
        tblLayoutData.verticalSpan = 2;
        tblLayoutData.minimumHeight = 200;
        _tblJobDefinitions.setLayoutData(tblLayoutData);     
        registerField("jobDefinitions", _tblJobDefinitions);
       
        int tableWidth = 700;         
        _jobNameColumn = new TableColumn(_tblJobDefinitions, SWT.NONE)
        _jobNameColumn.setText("Name");
        _jobNameColumn.setWidth((int)(tableWidth * 0.2));
       
        _jobTypeColumn = new TableColumn(_tblJobDefinitions, SWT.NONE);
        _jobTypeColumn.setText("Type");
        _jobTypeColumn.setWidth((int)(tableWidth * 0.2));         

        _jobResourceColumn = new TableColumn(_tblJobDefinitions, SWT.NONE);
      _jobResourceColumn.setText("Resource");
      _jobResourceColumn.setWidth((int)(tableWidth * 0.2));
     
        _jobDescriptionColumn = new TableColumn(_tblJobDefinitions, SWT.NONE);
        _jobDescriptionColumn.setText("Description");
        _jobDescriptionColumn.setWidth((int)(tableWidth * 0.2));
       
        _jobScheduleColumn = new TableColumn(_tblJobDefinitions, SWT.NONE);
        _jobScheduleColumn.setText("CRON schedule");
        _jobScheduleColumn.setWidth((int)(tableWidth * 0.2));
       
       
        _jobDefinitionsModel = new JobDefinitionsModel(_model.getJobDefinitions());
        _jobDefinitionsModel.addListener(new BeanListTableModelListener() {

      public void add(Object bean) {
        _model.fireModelChanged();         
      }

      public void remove(Object bean) {
        _model.fireModelChanged();       
      }

      public void update(Object bean) {
        _model.fireModelChanged();         
      }

      @SuppressWarnings("unchecked")
      public void refresh(List beans) {
        _model.fireModelChanged();       
      }
         
        });
       
        _tblViewerJobDefinitions = new TableViewer(_tblJobDefinitions);
             
        List<String> jobTypes = new ArrayList<String>();
        Iterator<JobType> it = WGADesignConfigurationModel.JOBTYPES.values().iterator();
        _jobTypesByIndex = new HashMap<Integer, JobType>();
        int i = 0;
        while (it.hasNext()) {
          JobType type = it.next();
          jobTypes.add(type.getValue());
          _jobTypesByIndex.put(i, type);
          i++;
        }
       
        CellEditor[] editors = new CellEditor[5];
        editors[0] = new TextCellEditor(_tblJobDefinitions);       
        editors[1] = new ComboBoxCellEditor(_tblJobDefinitions, jobTypes.toArray(new String[0]), SWT.READ_ONLY);
       
        editors[2] = new TextCellEditor(_tblJobDefinitions);
        editors[3] = new TextCellEditor(_tblJobDefinitions);
        editors[4] = new TextCellEditor(_tblJobDefinitions);
       
        _tblViewerJobDefinitions.setCellEditors(editors);
       
        BeanListTableModelCellModifier modifier = new BeanListTableModelCellModifier(_tblViewerJobDefinitions, _jobDefinitionsModel);       
        modifier.setEditMode(1, BeanListTableModelCellModifier.EDIT_MODE_ON_SINGLE_CLICK);       
        _tblViewerJobDefinitions.setCellModifier(modifier);  
        modifier.setValueMapper(1, new BeanListTableModelValueMapper() {

      public Object map(Object element, String property, Object value) {
        return  _jobTypesByIndex.get((Integer) value).getKey();
      }
         
        });
        _tblViewerJobDefinitions.setContentProvider(new BeanListTableModelContentProvider());
        _tblViewerJobDefinitions.setLabelProvider(new BeanListTableModelLabelProvider(_jobDefinitionsModel));
        _tblViewerJobDefinitions.setInput(_jobDefinitionsModel)
       

        GridData btnLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_FILL, false, false);
        _btnAddJobDefinition = toolkit.createButton(sectionClient, "add", SWT.PUSH);
        _btnAddJobDefinition.setLayoutData(btnLayout);
        _btnAddJobDefinition.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleAddJobDefinition();
      }

    });
       
        _btnRemoveJobDefinition = toolkit.createButton(sectionClient, "remove", SWT.PUSH);
        _btnRemoveJobDefinition.setLayoutData(btnLayout);
        _btnRemoveJobDefinition.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleRemoveJobDefinition();
      }
View Full Code Here

Examples of org.eclipse.ui.forms.widgets.FormToolkit

    }

    @Override
    protected void createFormContent(IManagedForm managedForm) {
        ScrolledForm form = managedForm.getForm();
        FormToolkit toolkit = managedForm.getToolkit();
        WidgetFactory factory = new WidgetFactory(toolkit);
       
        toolkit.decorateFormHeading(form.getForm());
        form.setText(PAGE_TITLE);

        GridLayout formLayout = new GridLayout(2, true);
        form.getBody().setLayout(formLayout);       
       
        // tree
        Section schemaSection = toolkit.createSection(form.getBody(), Section.DESCRIPTION | Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
        schemaSection.setText("Schema Definition");
        schemaSection.setLayoutData(new GridData(GridData.FILL_BOTH));
        // register schemaSection as error catcher
        registerField(WGASchemaDefinitionModel.PROPERTY_HINT_SCHEMADEF, schemaSection);
       
        Tree tree = toolkit.createTree(schemaSection, SWT.NONE);
        tree.setLayoutData(new GridData(GridData.FILL_BOTH));
        schemaSection.setClient(tree);
       
        final Menu menu = new Menu(Display.getCurrent().getActiveShell(), SWT.POP_UP);
        MenuItem itemNewContentTypeDefinition = new MenuItem(menu, SWT.PUSH);
        itemNewContentTypeDefinition.setText("Content Type Definition");
        itemNewContentTypeDefinition.addSelectionListener(new SelectionListener() {
           
            public void widgetSelected(SelectionEvent e) {
                WGContentTypeDefinition cType = _model.createContentTypeDefinition();
                _treeViewer.expandToLevel(cType, 1);
                _treeViewer.setSelection(new SingleStructuredSelection(cType));               
            }
           
            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });
        MenuItem itemNewAreaDefinition = new MenuItem(menu, SWT.PUSH);
        itemNewAreaDefinition.setText("Area Definition");
        itemNewAreaDefinition.addSelectionListener(new SelectionListener() {
           
            public void widgetSelected(SelectionEvent e) {
                WGAreaDefinition area = _model.createAreaDefinition();
                _treeViewer.expandToLevel(area, 1);
                _treeViewer.setSelection(new SingleStructuredSelection(area));               
            }
           
            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });
        MenuItem itemNewLanguageDefinition = new MenuItem(menu, SWT.PUSH);
        itemNewLanguageDefinition.setText("Language Definition");
        itemNewLanguageDefinition.addSelectionListener(new SelectionListener() {
           
            public void widgetSelected(SelectionEvent e) {
                WGLanguageDefinition lang = _model.createLanguageDefinition();
                _treeViewer.expandToLevel(lang, 1);
                _treeViewer.setSelection(new SingleStructuredSelection(lang));               
            }
           
            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });
       
       
        final ToolBar schemaSectionToolBar = new ToolBar(schemaSection, SWT.FLAT);
        final ToolItem schemaSectionItemNew = new ToolItem(schemaSectionToolBar, SWT.DROP_DOWN);
        schemaSectionItemNew.setText("new");
        schemaSectionItemNew.setImage(Plugin.getDefault().getImageRegistry().get(Plugin.IMAGE_SCHEMADEFINITION_ADD));
        schemaSectionItemNew.addListener(SWT.Selection, new Listener() {
            public void handleEvent(Event event) {

                  Rectangle rect = schemaSectionItemNew.getBounds();
                  Point pt = new Point(rect.x, rect.y + rect.height);
                  pt = schemaSectionToolBar.toDisplay(pt);
                  menu.setLocation(pt.x, pt.y);
                  menu.setVisible(true);

              }
           }
        );
        final ToolItem schemaSectionItemDelete = new ToolItem(schemaSectionToolBar, SWT.PUSH);
        schemaSectionItemDelete.setText("delete");
        schemaSectionItemDelete.setImage(Plugin.getDefault().getImageRegistry().get(Plugin.IMAGE_SCHEMADEFINITION_REMOVE));
        schemaSectionItemDelete.addSelectionListener(new SelectionListener() {
           
            public void widgetSelected(SelectionEvent e) {
                ISelection selection = _treeViewer.getSelection();
                if (selection instanceof TreeSelection) {
                    TreeSelection treeSelection = (TreeSelection) selection;
                    Object node = treeSelection.getFirstElement();
                    if (node instanceof WGSchemaDocumentDefinition) {
                        WGSchemaDocumentDefinition def = (WGSchemaDocumentDefinition)node;
                        String typeName = "Document Definition";
                        if (def instanceof WGContentTypeDefinition) {
                            typeName = "Content Type Definition";
                        } else if (def instanceof WGAreaDefinition) {
                            typeName = "Area Definition";
                        } else if (def instanceof WGLanguageDefinition) {
                            typeName = "Language Definition";
                        }
                        boolean result = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Delete " + typeName, "Delete " + typeName + " '" + def.getName() + "'?");
                        if (result) {
                            _model.removeSchemaDocumentDefintion(def);
                        }
                    } else if (node instanceof WGContentItemDefinition) {
                        WGContentItemDefinition def = (WGContentItemDefinition)node;
                        String typeName = "Item Definition";
                        boolean result = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Delete " + typeName, "Delete " + typeName + " '" + def.getName() + "'?");
                        if (result) {
                            _model.remove(def);
                        }
                    } else if (node instanceof WGMetaFieldDefinition) {
                        WGMetaFieldDefinition def = (WGMetaFieldDefinition)node;
                        String typeName = "Property";
                        boolean result = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Delete " + typeName, "Delete " + typeName + " '" + AddContentTypeMetaDefinitionDialog.METADATA_DEFINITION_LABELS.get(def.getName()) + "'?");
                        if (result) {
                            _model.remove(def);
                        }
                    }
                }
               
            }
           
            public void widgetDefaultSelected(SelectionEvent e) {
                // TODO Auto-generated method stub
               
            }
        });
       
        schemaSection.setTextClient(schemaSectionToolBar);
       
       
       
        _treeViewer = new TreeViewer(tree);
        _treeViewer.setContentProvider(new WGASchemaDefinitionContentProvider());              
        _treeViewer.setLabelProvider(new WGASchemaDefinitionLabelProvider());       
        _treeViewer.setComparator(new ViewerComparator() {

            @Override
            public int compare(Viewer viewer, Object e1, Object e2) {
                if (e1 != null && e2 != null) {
                    if (e1 instanceof WGMetaFieldDefinition && e2 instanceof WGMetaFieldDefinition) {
                        WGMetaFieldDefinition def1 = (WGMetaFieldDefinition) e1;
                        WGMetaFieldDefinition def2 = (WGMetaFieldDefinition) e2;
                        return AddContentTypeMetaDefinitionDialog.METADATA_DEFINITION_LABELS.get(def1.getName()).compareTo(AddContentTypeMetaDefinitionDialog.METADATA_DEFINITION_LABELS.get(def2.getName()));
                    } else if (e1 instanceof String && e2 instanceof String) {
                        if (e1.equals(WGASchemaDefinitionContentProvider.CONTENTTYPE_DEFINITIONS_ROOT)) {
                            return -1;
                        } else if (e1.equals(WGASchemaDefinitionContentProvider.AREA_DEFINITIONS_ROOT) && e2.equals(WGASchemaDefinitionContentProvider.LANGUAGE_DEFINITIONS_ROOT)) {
                            return -1;
                        } else {
                            return 1;
                        }                                                
                    } else if (e1 instanceof WGMetaFieldDefinition && e2 instanceof WGContentItemDefinition) {
                        return -1;
                    } else if (e1 instanceof WGContentItemDefinition && e2 instanceof WGMetaFieldDefinition) {
                        return 1;
                    } else if (e1 instanceof WGContentItemDefinition && e2 instanceof WGContentItemDefinition) {
                        WGContentItemDefinition def1 = (WGContentItemDefinition) e1;
                        WGContentItemDefinition def2 = (WGContentItemDefinition) e2;
                        if (def1.getName().startsWith("<") && !def2.getName().startsWith("<")) {
                            return 1;
                        } else if (def2.getName().startsWith("<") && !def1.getName().startsWith("<")) {
                            return -1;
                        } else {
                            return def1.getName().compareTo(def2.getName());
                        }
                    } else if (e1 instanceof WGContentTypeDefinition && e2 instanceof WGContentTypeDefinition) {
                        WGContentTypeDefinition def1 = (WGContentTypeDefinition) e1;
                        WGContentTypeDefinition def2 = (WGContentTypeDefinition) e2;
                        if (def1.getName().startsWith("<") && !def2.getName().startsWith("<")) {
                            return 1;
                        } else if (def2.getName().startsWith("<") && !def1.getName().startsWith("<")) {
                            return -1;
                        } else {
                            return def1.getName().compareTo(def2.getName());
                        }
                    } else if (e1 instanceof WGAreaDefinition && e2 instanceof WGAreaDefinition) {
                        WGAreaDefinition def1 = (WGAreaDefinition) e1;
                        WGAreaDefinition def2 = (WGAreaDefinition) e2;
                        if (def1.getName().startsWith("<") && !def2.getName().startsWith("<")) {
                            return 1;
                        } else if (def2.getName().startsWith("<") && !def1.getName().startsWith("<")) {
                            return -1;
                        } else {
                            return def1.getName().compareTo(def2.getName());
                        }
                    }  else if (e1 instanceof WGLanguageDefinition && e2 instanceof WGLanguageDefinition) {
                        WGLanguageDefinition def1 = (WGLanguageDefinition) e1;
                        WGLanguageDefinition def2 = (WGLanguageDefinition) e2;
                        if (def1.getName().startsWith("<") && !def2.getName().startsWith("<")) {
                            return 1;
                        } else if (def2.getName().startsWith("<") && !def1.getName().startsWith("<")) {
                            return -1;
                        } else {
                            return def1.getName().compareTo(def2.getName());
                        }
                    }
                   
                }
                return super.compare(viewer, e1, e2);
            }
           
        });
        _treeViewer.setInput(_model);      
        _treeViewer.addSelectionChangedListener(this);
                      
        // details
        _detailSection = toolkit.createSection(form.getBody(), Section.DESCRIPTION | Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
        _detailSection.setText("Details");
        _detailSection.setLayoutData(new GridData(GridData.FILL_BOTH));     

        // content type subform
        Composite subform = toolkit.createComposite(_detailSection);          
        GridLayout subformLayout = new GridLayout();       
        subformLayout.numColumns = 2;
        subform.setLayout(subformLayout);              
        Text txtName = factory.createText(subform, "Name:", "name");
        txtName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        factory.createCheckBox(subform, "Auto creation:", "Enabled", "autoCreate");

        Label lblActions = new Label(subform, SWT.NONE);
        lblActions.setText("Actions:");
        HyperlinkGroup actionGroup = new HyperlinkGroup(Display.getCurrent());
        Hyperlink defineMetas = new Hyperlink(subform, SWT.NONE);
        defineMetas.setText("add properties...");
        defineMetas.addHyperlinkListener(new IHyperlinkListener() {           
            public void linkExited(HyperlinkEvent e) {
            }
           
            public void linkEntered(HyperlinkEvent e) {              
            }
           
            public void linkActivated(HyperlinkEvent e) {
                handleAddMetaDataDefinition();               
            }
        });
        actionGroup.add(defineMetas);
       
        Label lbl = new Label(subform, SWT.NONE);
        Hyperlink defineItems = new Hyperlink(subform, SWT.NONE);
        defineItems.setText("add item definition...");
        defineItems.addHyperlinkListener(new IHyperlinkListener() {
           
            public void linkExited(HyperlinkEvent e) {
            }
           
            public void linkEntered(HyperlinkEvent e) {
            }
           
            public void linkActivated(HyperlinkEvent e) {
                handleAddItemDefinition();               
            }
        });
        actionGroup.add(defineItems);
       
        WGContentTypeDefinitionModel contentTypeDefinitionModel = new WGContentTypeDefinitionModel();
        contentTypeDefinitionModel.addListener(new BeanChangedListener<WGContentTypeDefinition>() {
            public void changed(WGContentTypeDefinition bean) {
                _treeViewer.refresh(bean, true);
                _model.fireModelChanged();
            }
        });               
        _subforms.put(SUBFORM_CONTENT_TYPE_DEFINITION, subform);
        _subformModels.put(SUBFORM_CONTENT_TYPE_DEFINITION, contentTypeDefinitionModel);
       
        // area subform
        subform = toolkit.createComposite(_detailSection);
        subformLayout = new GridLayout();  
        subformLayout.numColumns = 2;
        subform.setLayout(subformLayout);             
        txtName = factory.createText(subform, "Name:", "name");
        txtName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        factory.createCheckBox(subform, "Auto creation:", "Enabled", "autoCreate");

        WGAreaDefinitionModel areaDefintionModel = new WGAreaDefinitionModel();
        areaDefintionModel.addListener(new BeanChangedListener<WGAreaDefinition>() {
            public void changed(WGAreaDefinition bean) {
                _treeViewer.refresh(bean, true);
                _model.fireModelChanged();
            }           
        });
        _subforms.put(SUBFORM_AREA_DEFINITION, subform);
        _subformModels.put(SUBFORM_AREA_DEFINITION, areaDefintionModel);
       
        // language subform
        subform = toolkit.createComposite(_detailSection);
        subformLayout = new GridLayout();  
        subformLayout.numColumns = 2;
        subform.setLayout(subformLayout);             
        txtName = factory.createText(subform, "Name:", "name");
        txtName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        factory.createCheckBox(subform, "Auto creation:", "Enabled", "autoCreate");
       
        WGLanguageDefinitionModel languageDefinitionModel = new WGLanguageDefinitionModel();
        languageDefinitionModel.addListener(new BeanChangedListener<WGLanguageDefinition>() {
            public void changed(WGLanguageDefinition bean) {
                _treeViewer.refresh(bean, true);
                _model.fireModelChanged();
            }           
        });
        _subforms.put(SUBFORM_LANGUAGE_DEFINITION, subform);
        _subformModels.put(SUBFORM_LANGUAGE_DEFINITION, languageDefinitionModel);

        // item subform
        subform = toolkit.createComposite(_detailSection);
        subformLayout = new GridLayout();  
        subformLayout.numColumns = 2;
        subform.setLayout(subformLayout);
       
        Group parentGroup = createParentInformationGroup(subform);
        GridData parentInfoLayoutData = new GridData(GridData.FILL_HORIZONTAL);       
        parentInfoLayoutData.horizontalSpan = 2;
        parentGroup.setLayoutData(parentInfoLayoutData);
       
        txtName = factory.createText(subform, "Itemname:", "name");
        txtName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        Combo itemTypeCombo = factory.createCombo(subform, "Type:", "type");       
        _chkItemList = factory.createCheckBox(subform, "List:", "Enabled", "list");

        _lblInitialValues = new Label(subform, SWT.NONE);
        _lblInitialValues.setText("Initial values:");
        _lblInitialValues.setLayoutData(new GridData(SWT.NONE, SWT.BEGINNING, false, false));
       
        _initialValuesSection = toolkit.createSection(subform, Section.EXPANDED | Section.NO_TITLE);
       
        GridData initialValuesSectionLayoutData = new GridData(GridData.FILL_BOTH);
        _initialValuesSection.setLayoutData(initialValuesSectionLayoutData);

        // item subform - text values
        _initialTextValuesSectionClient = toolkit.createComposite(_initialValuesSection);
        _initialTextValuesSectionClient.setLayout(new FillLayout());
        _tblItemTextValues = new EditableTableControl<PrimitiveTypeBean<String>>(_initialTextValuesSectionClient, SWT.NONE);
        _itemTextValuesModel = new PrimitiveTypeBeanListTableModel<String>(true);
        _itemTextValuesModel.addListener(new BeanListTableModelListener() {
           
            public void update(Object bean) {
                _model.fireModelChanged();               
            }
           
            public void remove(Object bean) {
                _model.fireModelChanged();
            }
           
            public void refresh(List beans) {
            }
           
            public void add(Object bean) {
                _model.fireModelChanged();               
            }
        });
        _tblItemTextValues.init(new String[] {"#", "Value"}, _itemTextValuesModel);
        CellEditor[] cellEditors = new CellEditor[2];
        cellEditors[0] = null;
        cellEditors[1] = new TextCellEditor(_tblItemTextValues.getTable());
        _tblItemTextValues.getTableViewer().setCellEditors(cellEditors);
       
        _tblItemTextValues.getButton(EditableTableControl.BUTTON_ADD).addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
            public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                WGContentItemDefinitionModel model = (WGContentItemDefinitionModel)_subformModels.get(SUBFORM_CONTENT_ITEM_DEFINITION);
                if (_itemTextValuesModel.getBeans().size() > 0) {                   
                    _chkItemList.setSelection(true);
                    model.setList(true);
                }
                handleAdd(_tblItemTextValues, "");
            }
        });

        _tblItemTextValues.getButton(EditableTableControl.BUTTON_REMOVE).addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
            public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                handleRemove(_tblItemTextValues);
            }
        });
       
       
        // item subform - boolean values
        _initialBooleanValuesSectionClient = toolkit.createComposite(_initialValuesSection);
        _initialBooleanValuesSectionClient.setLayout(new FillLayout());
        _tblItemBooleanValues = new EditableTableControl<PrimitiveTypeBean<Boolean>>(_initialBooleanValuesSectionClient, SWT.NONE);
        _itemBooleanValuesModel = new PrimitiveTypeBeanListTableModel<Boolean>(true);
        _itemBooleanValuesModel.addListener(new BeanListTableModelListener() {
           
            public void update(Object bean) {
                _model.fireModelChanged();               
            }
           
            public void remove(Object bean) {
                _model.fireModelChanged();
            }
           
            public void refresh(List beans) {
            }
           
            public void add(Object bean) {
                _model.fireModelChanged();               
            }
        });
        _tblItemBooleanValues.init(new String[] {"#", "Value"}, _itemBooleanValuesModel);
        cellEditors = new CellEditor[2];
        cellEditors[0] = null;
        cellEditors[1] = new CheckboxCellEditor(_tblItemBooleanValues.getTable());
        _tblItemBooleanValues.getTableViewer().setCellEditors(cellEditors);       
       
        _tblItemBooleanValues.getButton(EditableTableControl.BUTTON_ADD).addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
            public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                WGContentItemDefinitionModel model = (WGContentItemDefinitionModel)_subformModels.get(SUBFORM_CONTENT_ITEM_DEFINITION);
                if (_itemBooleanValuesModel.getBeans().size() > 0) {                   
                    _chkItemList.setSelection(true);
                    model.setList(true);
                }
                handleAdd(_tblItemBooleanValues, false);               
            }
        });

        _tblItemBooleanValues.getButton(EditableTableControl.BUTTON_REMOVE).addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
            public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                handleRemove(_tblItemBooleanValues);
            }
        });
       
       
        // item subform - number values
        _initialNumberValuesSectionClient = toolkit.createComposite(_initialValuesSection);
        _initialNumberValuesSectionClient.setLayout(new FillLayout());
        _tblItemNumberValues = new EditableTableControl<PrimitiveTypeBean<Number>>(_initialNumberValuesSectionClient, SWT.NONE);        
        _itemNumberValuesModel = new PrimitiveTypeBeanListTableModel<Number>(true);
        _itemNumberValuesModel.addListener(new BeanListTableModelListener() {
           
            public void update(Object bean) {
                _model.fireModelChanged();               
            }
           
            public void remove(Object bean) {
                _model.fireModelChanged();
            }
           
            public void refresh(List beans) {
            }
           
            public void add(Object bean) {
                _model.fireModelChanged();               
            }
        });
        _tblItemNumberValues.init(new String[] {"#", "Value"}, _itemNumberValuesModel);
        cellEditors = new CellEditor[2];
        cellEditors[0] = null;
        cellEditors[1] = new DoubleValueCellEditor(_tblItemNumberValues.getTable());

        _tblItemNumberValues.getTableViewer().setCellEditors(cellEditors);
       
        _tblItemNumberValues.getButton(EditableTableControl.BUTTON_ADD).addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
            public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                WGContentItemDefinitionModel model = (WGContentItemDefinitionModel)_subformModels.get(SUBFORM_CONTENT_ITEM_DEFINITION);
                if (_itemNumberValuesModel.getBeans().size() > 0) {                   
                    _chkItemList.setSelection(true);
                    model.setList(true);
                }
                handleAdd(_tblItemNumberValues, 0);               
            }
        });

        _tblItemNumberValues.getButton(EditableTableControl.BUTTON_REMOVE).addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
            public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                handleRemove(_tblItemNumberValues);
            }
        });
       
       
       
        itemTypeCombo.addModifyListener(new ModifyListener() {
           
            public void modifyText(ModifyEvent e) {
                WGContentItemDefinitionModel model = (WGContentItemDefinitionModel)_subformModels.get(SUBFORM_CONTENT_ITEM_DEFINITION);
                WGContentItemDefinition.Type type = model.getType().getKey();
                if (type.equals(WGContentItemDefinition.Type.TEXT)) {
                    _initialValuesSection.setVisible(true);
                    _lblInitialValues.setVisible(true);
                    _itemTextValuesModel.bind(model.getInitialValues());
                    _initialTextValuesSectionClient.setVisible(true);
                    _initialBooleanValuesSectionClient.setVisible(false);
                    _initialNumberValuesSectionClient.setVisible(false);
                    _initialValuesSection.setClient(_initialTextValuesSectionClient);
                    _initialValuesSection.layout();
                } else if (type.equals(WGContentItemDefinition.Type.BOOLEAN)) {
                    _initialValuesSection.setVisible(true);
                    _lblInitialValues.setVisible(true);
                    _itemBooleanValuesModel.bind(model.getInitialValues());
                    _initialBooleanValuesSectionClient.setVisible(true);
                    _initialTextValuesSectionClient.setVisible(false);
                    _initialNumberValuesSectionClient.setVisible(false);
                    _initialValuesSection.setClient(_initialBooleanValuesSectionClient);
                    _initialValuesSection.layout();
                } else if (type.equals(WGContentItemDefinition.Type.NUMBER)) {
                    _initialValuesSection.setVisible(true);
                    _lblInitialValues.setVisible(true);
                    _itemNumberValuesModel.bind(model.getInitialValues());
                    _initialNumberValuesSectionClient.setVisible(true);
                    _initialBooleanValuesSectionClient.setVisible(false);
                    _initialTextValuesSectionClient.setVisible(false);     
                    _initialValuesSection.setClient(_initialNumberValuesSectionClient);
                    _initialValuesSection.layout();
                } else {
                    _initialValuesSection.setVisible(false);
                    _lblInitialValues.setVisible(false);
                }
               
            }
        });
       
        WGContentItemDefinitionModel contentItemDefinitionModel = new WGContentItemDefinitionModel(_model);       
        contentItemDefinitionModel.addListener(new BeanChangedListener<WGContentItemDefinition>() {
            public void changed(WGContentItemDefinition bean) {
                _treeViewer.refresh(bean, true);
                _model.fireModelChanged();
            }           
        });

       
        _subforms.put(SUBFORM_CONTENT_ITEM_DEFINITION, subform);
        _subformModels.put(SUBFORM_CONTENT_ITEM_DEFINITION, contentItemDefinitionModel);

        // content type meta data subforms
        // subform for description
        subform = toolkit.createComposite(_detailSection);
        subformLayout = new GridLayout();  
        subformLayout.numColumns = 2;
        subform.setLayout(subformLayout);       

        parentGroup = createParentInformationGroup(subform);
        parentInfoLayoutData = new GridData(GridData.FILL_HORIZONTAL);       
        parentInfoLayoutData.horizontalSpan = 2;
        parentGroup.setLayoutData(parentInfoLayoutData);
       
        txtName = factory.createText(subform, "Property:", "name");
        txtName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        txtName.setEditable(false);
        Text txtValue = factory.createTextArea(subform, "Description", "description");       
        GridData txtValueLayoutData = new GridData(GridData.FILL_BOTH);
        txtValueLayoutData.minimumHeight = 200;
        txtValue.setLayoutData(txtValueLayoutData)
       
        WGDescriptionMetaFieldDefinitionModel descriptionMetaFieldDefinitionModel = new WGDescriptionMetaFieldDefinitionModel(_model);
        descriptionMetaFieldDefinitionModel.addListener(new BeanChangedListener<WGMetaFieldDefinition>() {
            public void changed(WGMetaFieldDefinition bean) {
                _treeViewer.refresh(bean, true);
                _model.fireModelChanged();
            }
        });
       
        _subforms.put(SUBFORM_META_DESCRIPTION, subform);
        _subformModels.put(SUBFORM_META_DESCRIPTION, descriptionMetaFieldDefinitionModel);
       
        // subform for event scripts
        subform = toolkit.createComposite(_detailSection);
        subformLayout = new GridLayout();  
        subformLayout.numColumns = 2;
        subform.setLayout(subformLayout);       

        parentGroup = createParentInformationGroup(subform);
        parentInfoLayoutData = new GridData(GridData.FILL_HORIZONTAL);       
        parentInfoLayoutData.horizontalSpan = 2;
        parentGroup.setLayoutData(parentInfoLayoutData);
       
        txtName = factory.createText(subform, "Property:", "name");
        txtName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        txtName.setEditable(false);
        txtValue = factory.createTextArea(subform, "Scriptcode:", "code");       
        txtValueLayoutData = new GridData(GridData.FILL_BOTH);
        txtValueLayoutData.minimumHeight = 200;
        txtValue.setLayoutData(txtValueLayoutData)
       
        WGEventScriptMetaFieldDefinitionModel eventScriptMetaFieldDefinitionModel = new WGEventScriptMetaFieldDefinitionModel(_model);
        eventScriptMetaFieldDefinitionModel.addListener(new BeanChangedListener<WGMetaFieldDefinition>() {
            public void changed(WGMetaFieldDefinition bean) {
                _treeViewer.refresh(bean, true);
                _model.fireModelChanged();
            }
        });

       
        _subforms.put(SUBFORM_META_EVENTSCRIPT, subform);
        _subformModels.put(SUBFORM_META_EVENTSCRIPT, eventScriptMetaFieldDefinitionModel);
       
        // subform for layouts
        subform = toolkit.createComposite(_detailSection);
        subformLayout = new GridLayout();  
        subformLayout.numColumns = 3;
        subform.setLayout(subformLayout);
               
        parentGroup = createParentInformationGroup(subform);
        parentInfoLayoutData = new GridData(GridData.FILL_HORIZONTAL);       
        parentInfoLayoutData.horizontalSpan = 3;
        parentGroup.setLayoutData(parentInfoLayoutData);
       
        txtName = factory.createText(subform, "Property:", "name");
        txtName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        txtName.setEditable(false);
        factory.addFiller(subform);
        txtValue = factory.createText(subform, "Module:", "layout");              
        txtValue.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
       
        final Text fTxtLayout = txtValue;
        Button btnBrowseLayout = new Button(subform, SWT.PUSH);
        btnBrowseLayout.setText("browse ...");
        btnBrowseLayout.addSelectionListener(new SelectionListener() {
           
            public void widgetSelected(SelectionEvent e) {
                handleBrowserLayout(fTxtLayout)
            }
           
            public void widgetDefaultSelected(SelectionEvent e) {                            
            }
        });
        WGLayoutMetaFieldDefinitionModel layoutMetaFieldDefinitionModel = new WGLayoutMetaFieldDefinitionModel(_model);
        layoutMetaFieldDefinitionModel.addListener(new BeanChangedListener<WGMetaFieldDefinition>() {
            public void changed(WGMetaFieldDefinition bean) {
                _treeViewer.refresh(bean, true);
                _model.fireModelChanged();
            }
        });

       
        _subforms.put(SUBFORM_META_LAYOUT, subform);
        _subformModels.put(SUBFORM_META_LAYOUT, layoutMetaFieldDefinitionModel);
       
        // subform for allowed positions
        subform = toolkit.createComposite(_detailSection);
        subformLayout = new GridLayout();  
        subformLayout.numColumns = 2;
        subform.setLayout(subformLayout);
               
        parentGroup = createParentInformationGroup(subform);
        parentInfoLayoutData = new GridData(GridData.FILL_HORIZONTAL);       
        parentInfoLayoutData.horizontalSpan = 2;
        parentGroup.setLayoutData(parentInfoLayoutData);
       
        txtName = factory.createText(subform, "Property:", "name");
        txtName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        txtName.setEditable(false);
        Combo comboPositioning = factory.createCombo(subform, "Positions:", "positioning");              
        comboPositioning.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
       
        factory.addFiller(subform);
        _tblAllowedPositions = new EditableTableControl<PrimitiveTypeBean<String>>(subform, SWT.NONE);
        _allowedPositionsModel = new PrimitiveTypeBeanListTableModel<String>();
        _allowedPositionsModel.addListener(new BeanListTableModelListener() {
           
            public void update(Object bean) {
                _model.fireModelChanged();               
            }
           
            public void remove(Object bean) {
                _model.fireModelChanged();
            }
           
            public void refresh(List beans) {
            }
           
            public void add(Object bean) {
                _model.fireModelChanged();               
            }
        });
        _tblAllowedPositions.init(new String[] {"Name"}, _allowedPositionsModel);
        GridData tblLayoutData = new GridData(GridData.FILL_BOTH);
        tblLayoutData.minimumHeight = 200;
        _tblAllowedPositions.setLayoutData(tblLayoutData);
        cellEditors = new CellEditor[1];
        cellEditors[0] = new TextCellEditor(_tblAllowedPositions.getTable());
        _tblAllowedPositions.getTableViewer().setCellEditors(cellEditors);
       
        comboPositioning.addModifyListener(new ModifyListener() {
           
            public void modifyText(ModifyEvent e) {
                WGPositioningMetaFieldDefinitionModel model = (WGPositioningMetaFieldDefinitionModel)_subformModels.get(SUBFORM_META_POSITIONING);
                if (model.getPositioning().getKey().equals(WGContentType.POSITIONING_FIXEDPARENTS) || model.getPositioning().getKey().equals(WGContentType.POSITIONING_FIXEDPARENTTYPES)) {
                    _tblAllowedPositions.setVisible(true);
                    WGContentTypeDefinition cTypeDefinition = _model.findContentTypeDefinition(model.getBean());                   
                    ((PrimitiveTypeBeanListTableModel<String>)_tblAllowedPositions.getModel()).bind(model.getAllowedPositions(cTypeDefinition));
                } else {
                    _tblAllowedPositions.setVisible(false);
                }
            }
        });

        _tblAllowedPositions.getButton(EditableTableControl.BUTTON_ADD).addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
            public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                handleAdd(_tblAllowedPositions, "<value>");
            }
        });

        _tblAllowedPositions.getButton(EditableTableControl.BUTTON_REMOVE).addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
            public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                handleRemove(_tblAllowedPositions);
            }
        });
       
           
        WGPositioningMetaFieldDefinitionModel positioningMetaFieldDefinitionModel = new WGPositioningMetaFieldDefinitionModel(_model);
        positioningMetaFieldDefinitionModel.addListener(new BeanChangedListener<WGMetaFieldDefinition>() {
            public void changed(WGMetaFieldDefinition bean) {
                _treeViewer.refresh(bean, true);
                _model.fireModelChanged();
            }
        });

       
        _subforms.put(SUBFORM_META_POSITIONING, subform);
        _subformModels.put(SUBFORM_META_POSITIONING, positioningMetaFieldDefinitionModel);
       
       
        // subform for editors
        subform = toolkit.createComposite(_detailSection);
        subformLayout = new GridLayout();  
        subformLayout.numColumns = 2;
        subform.setLayout(subformLayout);
               
        parentGroup = createParentInformationGroup(subform);
View Full Code Here

Examples of org.eclipse.ui.forms.widgets.FormToolkit


  @Override
  protected void createFormContent(IManagedForm managedForm) {
    ScrolledForm form = managedForm.getForm();
    FormToolkit toolkit = managedForm.getToolkit();
    toolkit.decorateFormHeading(form.getForm());
   
    WidgetFactory factory = new WidgetFactory(toolkit);
   
    form.setText(PAGE_TITLE);

    ColumnLayout layout = new ColumnLayout();
    layout.maxNumColumns = 2;
    form.getBody().setLayout(layout);
   
    // general section
    Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION|Section.TITLE_BAR|Section.TWISTIE|Section.EXPANDED);
    section.setText("General");

        Composite sectionClient = toolkit.createComposite(section);
        section.setClient(sectionClient);
        GridLayout sectionLayout = new GridLayout();
        GridData fillHSpan = new GridData(GridData.FILL_HORIZONTAL);
        fillHSpan.horizontalSpan = 2;
        GridData fillH = new GridData(GridData.FILL_HORIZONTAL);
       
        sectionLayout.numColumns = 3;
        sectionClient.setLayout(sectionLayout);
       
       
        _lblDirectory = factory.createLabel(sectionClient, "Directory", "designDirectory");       
        _lblDirectory.setLayoutData(fillHSpan);
       
//      _lblDesignKey = factory.createLabel(sectionClient, "Design key:", "designKey");
//      _lblDesignKey.setLayoutData(fillHSpan);
     
      _txtInitScript= factory.createText(sectionClient, "Initialisation script:", "initScript");
      _txtInitScript.setLayoutData(fillH);
      registerField("initScript", _txtInitScript);
     
      _btnBrowseInitScript = toolkit.createButton(sectionClient, "...", SWT.PUSH);
      _btnBrowseInitScript.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleBrowseInitScript();
      }
    });
     
      _txtConnectionScript= factory.createText(sectionClient, "Connection script:", "connectionScript");
      _txtConnectionScript.setLayoutData(fillH);
      registerField("connectionScript", _txtConnectionScript);
     
      _btnBrowseConnectionScript = toolkit.createButton(sectionClient, "...", SWT.PUSH);
      _btnBrowseConnectionScript.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleBrowseConnectionScript();
      }
    });
     
      _txtDisconnectionScript= factory.createText(sectionClient, "Disconnection script:", "disconnectionScript");
      _txtDisconnectionScript.setLayoutData(fillH);
      registerField("disconnectionScript", _txtDisconnectionScript);
           
      _btnBrowseDisconnectionScript = toolkit.createButton(sectionClient, "...", SWT.PUSH);
      _btnBrowseDisconnectionScript.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleBrowseDisconnectionScript();
      }
    });     
      _txtDisconnectionScript.addPaintListener(new PaintListener() {

      public void paintControl(PaintEvent e) {
        _btnBrowseDisconnectionScript.setEnabled(_txtDisconnectionScript.isEnabled());       
      }
       
      });

     
      _comboDefaultAccessLevel = factory.createCombo(sectionClient, "Default access level:", "defaultAccessLevel");
      factory.addFiller(sectionClient);
      registerField("defaultAccessLevel", _comboDefaultAccessLevel);
         
      _comboAnonymousAccessLevel = factory.createCombo(sectionClient, "Anonymous access level:", "anonymousAccessLevel");
      factory.addFiller(sectionClient);
      registerField("anonymousAccessLevel", _comboAnonymousAccessLevel);
     
      _comboVersionCompliance = factory.createCombo(sectionClient, "Developed for WGA version:", "versionCompliance");
      factory.addFiller(sectionClient)
      registerField("versionCompliance", _comboVersionCompliance);     
     
      // libraries section
      section = toolkit.createSection(form.getBody(), Section.DESCRIPTION|Section.TITLE_BAR|Section.TWISTIE|Section.COMPACT);
    section.setText("Libraries");

        sectionClient = toolkit.createComposite(section);
        section.setClient(sectionClient);
        sectionLayout = new GridLayout();       
        sectionLayout.numColumns = 3;
        sectionClient.setLayout(sectionLayout);
     
        _chkStaticClasspath = factory.createCheckBox(sectionClient, "Prevent reloading of java libraries", "Enabled", "staticClasspath");
      registerField("staticClasspath", _chkStaticClasspath);
       
        GridData fillBoth = new GridData(GridData.FILL_BOTH);
        fillBoth.minimumHeight = 100;
        fillBoth.verticalSpan = 2;
        fillBoth.horizontalSpan = 2;
        _lstLibraries = new List(sectionClient, SWT.BORDER|SWT.MULTI);
        _lstLibraries.setLayoutData(fillBoth);
        _lstLibraries.setItems(_model.getLibraryNames());
       
        _btnAddLibrary = toolkit.createButton(sectionClient, "add...", SWT.PUSH);
        _btnAddLibrary.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleAddLibrary();
      }
    });
       
        GridData btnLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_FILL, false, false);
        _btnAddLibrary.setLayoutData(btnLayout);
       
        //factory.addFiller(sectionClient);
       
        _btnRemoveLibrary = toolkit.createButton(sectionClient, "remove...", SWT.PUSH);
       
        _btnRemoveLibrary.setLayoutData(btnLayout);       
        _btnRemoveLibrary.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
      public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
        handleRemoveLibrary();
      }
    });
       

       
       
        // publishing section
      section = toolkit.createSection(form.getBody(), Section.DESCRIPTION|Section.TITLE_BAR|Section.TWISTIE|Section.EXPANDED);
    section.setText("Publishing");

        sectionClient = toolkit.createComposite(section);
        section.setClient(sectionClient);
        sectionLayout = new GridLayout();       
        sectionLayout.numColumns = 2;
        sectionClient.setLayout(sectionLayout);
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.