Java Code Examples for org.eclipse.jface.viewers.ComboViewer#addSelectionChangedListener()

The following examples show how to use org.eclipse.jface.viewers.ComboViewer#addSelectionChangedListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExcelFileSelectionWizardPage.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Create the top composite of the page
 * 
 * @param composite
 * @param label
 */
private void createTopComposite( Composite composite, Label label )
{
	FormData data = new FormData( );
	data.left = new FormAttachment( label, 5 );
	data.right = new FormAttachment( 40, -5 );
	worksheetsCombo = new ComboViewer( composite, SWT.BORDER
			| SWT.READ_ONLY );
	worksheetsCombo.getControl( ).setLayoutData( data );
	worksheetsCombo.setContentProvider( new ArrayContentProvider( ) );
	worksheetsCombo.addSelectionChangedListener( this );
	worksheetsCombo.setLabelProvider( new LabelProvider( ) {

		public String getText( Object element )
		{
			return getFileName( element );
		}
	} );
	data = new FormData( );
	data.left = new FormAttachment( worksheetsCombo.getControl( ), 5 );
	data.top = new FormAttachment( 0, 5 );
}
 
Example 2
Source File: ContextValueControl.java    From depan with Apache License 2.0 6 votes vote down vote up
public ContextValueControl(Composite parent) {
  super(parent, SWT.NONE);
  setLayout(new FillLayout());

  viewer = new ComboViewer(this, SWT.READ_ONLY | SWT.FLAT);
  viewer.setContentProvider(new ArrayContentProvider());
  viewer.setLabelProvider(CONTROL_LABEL_PROVIDER);
  viewer.setComparator(new AlphabeticSorter(new ViewerObjectToString() {

      @Override
      public String getString(Object object) {
        return CONTROL_LABEL_PROVIDER.getText(object);
      }
    }));

  viewer.setInput(ContextKey.Base.values());

  listener = new ControlSelectionChangedListener();
  viewer.addSelectionChangedListener(listener);
}
 
Example 3
Source File: ComposeModeControl.java    From depan with Apache License 2.0 6 votes vote down vote up
public ComposeModeControl(Composite parent) {
  super(parent, SWT.NONE);
  setLayout(new FillLayout());

  viewer = new ComboViewer(this, SWT.READ_ONLY | SWT.FLAT);
  viewer.setContentProvider(new ArrayContentProvider());
  viewer.setLabelProvider(CONTROL_LABEL_PROVIDER);
  viewer.setComparator(new AlphabeticSorter(new ViewerObjectToString() {

      @Override
      public String getString(Object object) {
        return CONTROL_LABEL_PROVIDER.getText(object);
      }
    }));

  viewer.setInput(ComposeMode.values());

  listener = new ControlSelectionChangedListener();
  viewer.addSelectionChangedListener(listener);
}
 
Example 4
Source File: SectionList.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void createComponentViewer(Composite composite) {
	UI.formLabel(composite, toolkit, M.Component);
	componentViewer = new ComboViewer(composite);
	UI.gridData(componentViewer.getControl(), false, false).widthHint = 250;
	componentViewer.setContentProvider(ArrayContentProvider
			.getInstance());
	componentViewer.setLabelProvider(new ComponentLabel());
	componentViewer.setInput(ReportComponent.values());
	componentViewer.addSelectionChangedListener((evt) -> {
		ReportComponent c = Viewers.getFirst(evt.getSelection());
		if (c == null || c == ReportComponent.NONE)
			model.componentId = null;
			else
				model.componentId = c.getId();
			editor.setDirty(true);
		});
	if (model.componentId != null)
		componentViewer.setSelection(new StructuredSelection(
				ReportComponent.getForId(model.componentId)));
}
 
Example 5
Source File: ConfigConversionDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 创建文件类型列表
 * @param title
 * @param composite
 * @return ;
 */
private ComboViewer createConvertControl(String title, Composite composite) {
	Label positiveConvertLabel = new Label(composite, SWT.NONE);
	GridData positiveConvertLabelData = new GridData();
	positiveConvertLabelData.horizontalSpan = 2;
	positiveConvertLabelData.horizontalAlignment = SWT.CENTER;
	positiveConvertLabelData.grabExcessHorizontalSpace = true;
	positiveConvertLabel.setLayoutData(positiveConvertLabelData);
	positiveConvertLabel.setText(title);

	Label suportFormat = new Label(composite, SWT.NONE);
	suportFormat.setText("Suport Format");

	ComboViewer supportList = new ComboViewer(composite, SWT.READ_ONLY);
	GridData gridData = new GridData();
	gridData.horizontalAlignment = SWT.FILL;
	gridData.grabExcessHorizontalSpace = true;
	supportList.getCombo().setLayoutData(gridData);
	supportList.addSelectionChangedListener(new ISelectionChangedListener() {

		public void selectionChanged(SelectionChangedEvent event) {
			ISelection selection = event.getSelection();
			if (selection.isEmpty()) {
				okButton.setEnabled(false);
			} else {
				okButton.setEnabled(true);
			}
		}
	});

	return supportList;
}
 
Example 6
Source File: ActivityTypeSelectionGridPropertySectionContribution.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createActivitySelectionCombo(Composite parent, TabbedPropertySheetWidgetFactory widgetFactory) {
    combo = new ComboViewer(parent, SWT.READ_ONLY);
    combo.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    combo.setContentProvider(new ArrayContentProvider());
    combo.setLabelProvider(new LabelProvider());
    combo.setInput(new String[]{ACTIVITY_TYPE__TASK,ACTIVITY_TYPE__SYSTEM,ACTIVITY_TYPE__CALL_ACTVITY,ACTIVITY_TYPE__RECEIVE_TASK,ACTIVITY_TYPE__SEND_TASK,ACTIVITY_TYPE__SERVICE_TASK,ACTIVITY_TYPE__SCRIPT_TASK});
    combo.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent arg0) {
            if (toBeConverted()) {
                EClass targetEClass = getTargetEClass();
                IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() ;
                if(editor instanceof ProcessDiagramEditor){
                    node = (GraphicalEditPart) ((IStructuredSelection)((ProcessDiagramEditor)editor).getDiagramGraphicalViewer().getSelection()).getFirstElement() ;
		GMFTools.convert(targetEClass, node, new BonitaNodesElementTypeResolver(),GMFTools.PROCESS_DIAGRAM);
		for(IViewReference vr : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences() ){
			if(vr.getId().startsWith("org.bonitasoft.studio.views.properties")){
				IViewPart viewPart = vr.getView(false) ;
				if(viewPart != null){
					IPropertySheetPage page = (IPropertySheetPage) viewPart.getAdapter(IPropertySheetPage.class);
					if(page != null){
						page.selectionChanged(editor, ((ProcessDiagramEditor)editor).getDiagramGraphicalViewer().getSelection());
					}
				}
			}
		}
                  }
            }

        }
    });


}
 
Example 7
Source File: JointDataSetPage.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * create right composite for page
 * 
 * @param composite
 */
private void createRightGroup( Composite composite )
{
	rightGroup = new Group( composite, SWT.NONE );
	rightGroup.setLayout( new FormLayout( ) );
	rightGroup.setLayoutData( new GridData( GridData.FILL_BOTH ) );

	FormData data = new FormData( );

	data.top = new FormAttachment( 0, 5 );
	data.left = new FormAttachment( 0, 5 );
	data.right = new FormAttachment( 100, -5 );
	data.bottom = new FormAttachment( 10, -5 );
	rightDataSetChooser = new ComboViewer( rightGroup, SWT.DROP_DOWN
			| SWT.READ_ONLY );
	rightDataSetChooser.getControl( ).setLayoutData( data );
	DataSetComboProvider provider = new DataSetComboProvider( );
	rightDataSetChooser.setContentProvider( provider );
	rightDataSetChooser.setLabelProvider( provider );
	rightDataSetChooser.setInput( dataSetList );
	rightDataSetChooser.addSelectionChangedListener( this );

	data = new FormData( );
	data.top = new FormAttachment( rightDataSetChooser.getControl( ), 10 );
	data.left = new FormAttachment( 0, 5 );
	data.right = new FormAttachment( 100, -5 );
	data.bottom = new FormAttachment( 100, -5 );
	rightColumnList = new ListViewer( rightGroup, SWT.V_SCROLL
			| SWT.H_SCROLL
			| SWT.BORDER );
	rightColumnList.getControl( ).setLayoutData( data );
	ColumnProvider colProvider = new ColumnProvider( );
	rightColumnList.setContentProvider( colProvider );
	rightColumnList.setLabelProvider( colProvider );
	rightColumnList.addSelectionChangedListener( this );
}
 
Example 8
Source File: JointDataSetPage.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * create left composite for page
 * 
 * @param composite
 */
private void createLeftGroup( Composite composite )
{
	leftGroup = new Group( composite, SWT.NONE );
	leftGroup.setLayout( new FormLayout( ) );
	leftGroup.setLayoutData( new GridData( GridData.FILL_BOTH ) );

	FormData data = new FormData( );

	data.top = new FormAttachment( 0, 5 );
	data.left = new FormAttachment( 0, 5 );
	data.right = new FormAttachment( 100, -5 );
	data.bottom = new FormAttachment( 10, -5 );

	leftDataSetChooser = new ComboViewer( leftGroup, SWT.DROP_DOWN
			| SWT.READ_ONLY );
	leftDataSetChooser.getCombo( ).setLayoutData( data );
	DataSetComboProvider provider = new DataSetComboProvider( );
	leftDataSetChooser.setContentProvider( provider );
	leftDataSetChooser.setLabelProvider( provider );
	leftDataSetChooser.setInput( dataSetList );
	leftDataSetChooser.addSelectionChangedListener( this );

	data = new FormData( );

	data.top = new FormAttachment( leftDataSetChooser.getCombo( ), 10 );
	data.left = new FormAttachment( 0, 5 );
	data.right = new FormAttachment( 100, -5 );
	data.bottom = new FormAttachment( 100, -5 );

	leftColumnList = new ListViewer( leftGroup, SWT.V_SCROLL
			| SWT.H_SCROLL
			| SWT.BORDER );
	leftColumnList.getControl( ).setLayoutData( data );
	ColumnProvider colProvider = new ColumnProvider( );
	leftColumnList.setContentProvider( colProvider );
	leftColumnList.setLabelProvider( colProvider );
	leftColumnList.addSelectionChangedListener( this );

}
 
Example 9
Source File: ConfigConversionDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 创建文件类型列表
 * @param title
 * @param composite
 * @return ;
 */
private ComboViewer createConvertControl(String title, Composite composite) {
	Label positiveConvertLabel = new Label(composite, SWT.NONE);
	GridData positiveConvertLabelData = new GridData();
	positiveConvertLabelData.horizontalSpan = 2;
	positiveConvertLabelData.horizontalAlignment = SWT.CENTER;
	positiveConvertLabelData.grabExcessHorizontalSpace = true;
	positiveConvertLabel.setLayoutData(positiveConvertLabelData);
	positiveConvertLabel.setText(title);

	Label suportFormat = new Label(composite, SWT.NONE);
	suportFormat.setText(Messages.getString("dialog.ConfigConversionDialog.suportFormat"));

	ComboViewer supportList = new ComboViewer(composite, SWT.READ_ONLY);
	GridData gridData = new GridData();
	gridData.horizontalAlignment = SWT.FILL;
	gridData.grabExcessHorizontalSpace = true;
	supportList.getCombo().setLayoutData(gridData);
	supportList.addSelectionChangedListener(new ISelectionChangedListener() {

		public void selectionChanged(SelectionChangedEvent event) {
			ISelection selection = event.getSelection();
			if (selection.isEmpty()) {
				okButton.setEnabled(false);
			} else {
				okButton.setEnabled(true);
			}
		}
	});

	return supportList;
}
 
Example 10
Source File: ConfigConversionDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 创建文件类型列表
 * @param title
 * @param composite
 * @return ;
 */
private ComboViewer createConvertControl(String title, Composite composite) {
	Label positiveConvertLabel = new Label(composite, SWT.NONE);
	GridData positiveConvertLabelData = new GridData();
	positiveConvertLabelData.horizontalSpan = 2;
	positiveConvertLabelData.horizontalAlignment = SWT.CENTER;
	positiveConvertLabelData.grabExcessHorizontalSpace = true;
	positiveConvertLabel.setLayoutData(positiveConvertLabelData);
	positiveConvertLabel.setText(title);

	Label suportFormat = new Label(composite, SWT.NONE);
	suportFormat.setText(Messages.getString("dialog.ConfigConversionDialog.suportFormat"));

	ComboViewer supportList = new ComboViewer(composite, SWT.READ_ONLY);
	GridData gridData = new GridData();
	gridData.horizontalAlignment = SWT.FILL;
	gridData.grabExcessHorizontalSpace = true;
	supportList.getCombo().setLayoutData(gridData);
	supportList.addSelectionChangedListener(new ISelectionChangedListener() {

		public void selectionChanged(SelectionChangedEvent event) {
			ISelection selection = event.getSelection();
			if (selection.isEmpty()) {
				okButton.setEnabled(false);
			} else {
				okButton.setEnabled(true);
			}
		}
	});

	return supportList;
}
 
Example 11
Source File: SGenWizardPage2.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
private void createGeneratorCombo(Composite container) {
	Label lblGenerator = new Label(container, SWT.NONE);
	lblGenerator.setText("Generator");
	generatorCombo = new ComboViewer(container, SWT.READ_ONLY);
	generatorCombo.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	generatorCombo.setLabelProvider(new GeneratorDescriptorLabelProvider());
	generatorCombo.setContentProvider(new ArrayContentProvider());
	List<IGeneratorDescriptor> descriptors = Lists.newArrayList(GeneratorExtensions.getGeneratorDescriptors());
	Collections.sort(descriptors, CoreGenerator.generatorOrder);
	generatorCombo.setInput(descriptors);
	generatorCombo.getCombo().select(0);
	generatorCombo.addSelectionChangedListener(new ISelectionChangedListener() {
		public void selectionChanged(SelectionChangedEvent event) {
			Object element = ((IStructuredSelection) event.getSelection()).getFirstElement();
			if (element instanceof InstallMoreGeneratorsItem) {
				try {
					getContainer().run(true, true, (monitor) -> {
						((InstallMoreGeneratorsItem) element).openInstallWizard(monitor);
					});
				} catch (InvocationTargetException | InterruptedException e) {
					e.printStackTrace();
				}
				generatorCombo.getCombo().select(0);
			} else {
				refreshInput();
			}
		}

	});
	generatorCombo.add(new InstallMoreGeneratorsItem());
}
 
Example 12
Source File: FindingsDetailComposite.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public void createObservationComposite(){
	Label lblType = new Label(compositeType, SWT.NONE);
	lblType.setText("Datentyp");
	lblType.setLayoutData(minGd);
	comboInputData = new ComboViewer(compositeType, SWT.BORDER | SWT.READ_ONLY);
	ObservableListContentProvider contentProvider = new ObservableListContentProvider();
	comboInputData.setContentProvider(contentProvider);
	comboInputData.setLabelProvider(new ObservableMapLabelProvider(
		EMFProperties.value(ModelPackage.Literals.INPUT_DATA_NUMERIC__DATA_TYPE)
			.observeDetail(contentProvider.getKnownElements())));
	
	comboInputData.setContentProvider(ArrayContentProvider.getInstance());
	comboInputData.setLabelProvider(new ComboInputDataTypeLabelProvider());
	comboInputData.setInput(DataType.VALUES);
	
	compositeInputData = new Composite(compositeType, SWT.NONE);
	compositeInputData.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
	GridLayout gl = new GridLayout(2, false);
	gl.marginHeight = 0;
	gl.marginWidth = 0;
	compositeInputData.setLayout(gl);
	
	comboInputData.addSelectionChangedListener(new ISelectionChangedListener() {
		@Override
		public void selectionChanged(SelectionChangedEvent event){
			updateInputData(
				(DataType) ((StructuredSelection) event.getSelection()).getFirstElement());
			updateSize();
		}
	});
}
 
Example 13
Source File: ColumnFilterDialog.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void createExtendedArea(Composite parent) {
   super.createExtendedArea(parent);
   if (column.getSortDataType() == SortDataType.Date) {

      widgetComp = new Composite(parent, SWT.NONE);
      widgetComp.setLayout(new GridLayout(6, false));
      GridData gd = new GridData(GridData.FILL_HORIZONTAL);
      gd.horizontalSpan = 2;
      widgetComp.setLayoutData(gd);

      Label label = new Label(widgetComp, SWT.NONE);
      label.setText("Date Match: ");

      dateRangeTypeCombo = new ComboViewer(widgetComp, SWT.NONE);
      dateRangeTypeCombo.setContentProvider(new ArrayContentProvider());
      dateRangeTypeCombo.setLabelProvider(new LabelProvider() {

         @Override
         public String getText(Object element) {
            return ((DateRangeType) element).getDisplayName();
         }

      });
      dateRangeTypeCombo.setInput(DateRangeType.values());
      dateRangeTypeCombo.addSelectionChangedListener(event -> {
            String text2 = dateRangeTypeCombo.getCombo().getText();
            dateRangeType = DateRangeType.get(text2);
            updateDate2Composite();
      });

      date1Widget = new DateTime(widgetComp, SWT.CALENDAR);
      date1Widget.addListener(SWT.Selection, e-> setDate1Selection());

      // set initial date
      Calendar cal = Calendar.getInstance();
      cal.set(date1Widget.getYear(), date1Widget.getMonth(), date1Widget.getDay(), 0, 0);
      date1 = cal.getTime();

      time1Widget = new DateTime(widgetComp, SWT.TIME);
      time1Widget.addListener(SWT.Selection, e-> setDate1Selection());
      time1Widget.setHours(0);
      time1Widget.setMinutes(0);
      time1Widget.setSeconds(0);

   }
}
 
Example 14
Source File: CordovaPluginItem.java    From thym with Eclipse Public License 1.0 4 votes vote down vote up
private void createContent(){
	GridLayout layout = new GridLayout(3, false);
	layout.marginLeft = 7;
	layout.marginTop = 2;
	layout.marginBottom = 2;
	setLayout(layout);
	Composite versionContainer = new Composite(this, SWT.NULL);
	GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.BEGINNING).span(1, 2).applyTo(versionContainer);
	GridLayoutFactory.fillDefaults().spacing(1, 1).numColumns(2).applyTo(versionContainer);
	
	Combo versionCombo = new Combo(versionContainer, SWT.READ_ONLY);
	versionComboViewer = new ComboViewer(versionCombo);
	versionComboViewer.setContentProvider(new IStructuredContentProvider() {
		
		@Override
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
		}
		@Override
		public void dispose() {
		}
		@Override
		public Object[] getElements(Object inputElement) {
			List<CordovaRegistryPluginVersion> versions = getData().getVersions();
			return versions.toArray();
		}
	});
	versionComboViewer.setLabelProvider(new LabelProvider(){
		@Override
		public String getText(Object element) {
			CordovaRegistryPluginVersion ver = (CordovaRegistryPluginVersion)element;
			return ver.getVersion();
		}
	});
	versionComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
		
		@Override
		public void selectionChanged(SelectionChangedEvent event) {
			IStructuredSelection selection = (IStructuredSelection)event.getSelection();
			CordovaRegistryPluginVersion selectedVersion = (CordovaRegistryPluginVersion) selection.getFirstElement();
			modifyVersionSelection(selectedVersion);
			
		}
	});
	versionComboViewer.setInput(getData().getVersions());
	versionComboViewer.setSelection(new StructuredSelection(getLatestCordovaRegistryPluginVersion()));
	
	GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(versionCombo);
	modifyVersionSelection(null);
	
	nameLabel = new Label(this, SWT.NONE);
	GridDataFactory.fillDefaults().grab(true, false).align(SWT.BEGINNING, SWT.CENTER).applyTo(nameLabel);
	nameLabel.setFont(resources.getSmallHeaderFont());
	nameLabel.setText(getData().getName());
	
	description = new Label(this, SWT.NULL | SWT.WRAP);
	GridDataFactory.fillDefaults().grab(true, false).span(3, 1).hint(100, SWT.DEFAULT).applyTo(description);
	
	final Composite detailsContainer = new Composite(this, SWT.INHERIT_NONE);
	GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER ).span(3, 1).applyTo(detailsContainer);
	GridLayoutFactory.fillDefaults().numColumns(2).applyTo(detailsContainer);
	licenseLbl = new Label(detailsContainer, SWT.NONE);
	licenseLbl.setFont(resources.getSubTextFont());
	GridDataFactory.fillDefaults().grab(true, false).applyTo(licenseLbl);
	setDescriptionText(getData().getDescription());
	licenseLbl.setText("License:"+getData().getLatestVersion().getLicense());
	
	Label separator = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
	GridDataFactory.fillDefaults()
	.indent(0, 2)
	.grab(true, false)
	.span(3, 1)
	.align(SWT.FILL, SWT.BEGINNING)
	.applyTo(separator);
}
 
Example 15
Source File: GWTJUnitSettingsTab.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
protected void createGWTJUnitSettingsComponent(Composite parent) {
  Group group = SWTFactory.createGroup(parent, "GWT JUnit Settings", 2, 1,
      GridData.FILL_HORIZONTAL);

  SWTFactory.createLabel(group, "Log level:", 1);
  logLevelComboViewer = new ComboViewer(group, SWT.READ_ONLY);
  logLevelComboViewer.setContentProvider(new ArrayContentProvider());
  logLevelComboViewer.setLabelProvider(new DefaultComboLabelProvider());
  logLevelComboViewer.setInput(LogLevelArgumentProcessor.LOG_LEVELS);
  // logLevelComboViewer.setSelection(new StructuredSelection("DEBUG"));
  logLevelComboViewer.addSelectionChangedListener(settingChangedListener);

  SWTFactory.createLabel(group, "Output style:", 1);
  outputStyleComboViewer = new ComboViewer(group, SWT.READ_ONLY);
  outputStyleComboViewer.setContentProvider(new ArrayContentProvider());
  outputStyleComboViewer.setLabelProvider(new DefaultComboLabelProvider());
  outputStyleComboViewer.setInput(GWTLaunchConstants.OUTPUT_STYLES);
  // outputStyleComboViewer.setSelection(new StructuredSelection("PRETTY"));
  outputStyleComboViewer.addSelectionChangedListener(settingChangedListener);

  notHeadlessButton = SWTFactory.createCheckButton(group,
      "Display the log window and browser windows (useful for debugging)",
      null, true, 2);
  notHeadlessButton.addSelectionListener(settingChangedListener);

  webModeButton = SWTFactory.createCheckButton(group,
      "Run tests in production mode", null, false, 2);
  webModeButton.addSelectionListener(settingChangedListener);

  standardsModeButton = SWTFactory.createCheckButton(group,
      "Use standards mode", null, false, 2);
  standardsModeButton.addSelectionListener(settingChangedListener);
  GridData standardsModeButtonData = new GridData(SWT.BEGINNING,
      SWT.BEGINNING, false, false, 2, 1);
  standardsModeButton.setLayoutData(standardsModeButtonData);

  SWTFactory.createLabel(group, "Output directory:", 1);
  outputDirectoryField = new Text(group, SWT.BORDER);
  outputDirectoryField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  outputDirectoryField.addModifyListener(settingChangedListener);
}
 
Example 16
Source File: MessageFlowContribution.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void createControl(final Composite mainComposite, TabbedPropertySheetWidgetFactory widgetFactory,
        ExtensibleGridPropertySection extensibleGridPropertySection) {
    chooseEventCombo = new ComboViewer(mainComposite, SWT.READ_ONLY);
    chooseEventCombo.getCombo().setLayoutData(GridDataFactory.fillDefaults().hint(200, SWT.DEFAULT).grab(true, false).create());
    chooseEventCombo.setContentProvider(new EMFListFeatureTreeContentProvider(ProcessPackage.Literals.THROW_MESSAGE_EVENT__EVENTS));
    chooseEventCombo.setLabelProvider(new EMFFeatureLabelProvider(ProcessPackage.Literals.ELEMENT__NAME));
    chooseEventCombo.setInput(messageFlow.getSource());

    if(messageFlow != null && chooseEventCombo !=null && !chooseEventCombo.getCombo().isDisposed()  && messageFlow.getName() != null){
        if(!(messageFlow.getSource() == null || messageFlow.getTarget() == null)){
            chooseEventCombo.setInput(messageFlow.getSource());

            Message foundEvent = ModelHelper.findEvent(messageFlow.getSource(), messageFlow.getTarget().getEvent());
            if(foundEvent != null){
                chooseEventCombo.setSelection(new StructuredSelection(foundEvent));
            }
            previousEvent = foundEvent ;
        }
    }

    chooseEventCombo.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            Message eventObject = (Message) ((StructuredSelection)event.getSelection()).getFirstElement();
            CompoundCommand cc = new CompoundCommand() ;
            cc.append(new SetCommand(editingDomain, messageFlow, ProcessPackage.Literals.ELEMENT__NAME, eventObject.getName()));
            cc.append(new SetCommand(editingDomain, messageFlow.getTarget(), ProcessPackage.Literals.ABSTRACT_CATCH_MESSAGE_EVENT__EVENT, eventObject.getName()));
            cc.append(new SetCommand(editingDomain,eventObject, ProcessPackage.Literals.MESSAGE__TARGET_ELEMENT_EXPRESSION,ExpressionHelper.createConstantExpression(messageFlow.getTarget().getName(), String.class.getName())));
            cc.append(new SetCommand(editingDomain,eventObject, ProcessPackage.Literals.MESSAGE__TARGET_PROCESS_EXPRESSION,ExpressionHelper.createConstantExpression(ModelHelper.getParentProcess(messageFlow.getTarget()).getName(),String.class.getName())));

            if(previousEvent != null && !previousEvent.equals(eventObject)){
                cc.append(new SetCommand(editingDomain,previousEvent, ProcessPackage.Literals.MESSAGE__TARGET_ELEMENT_EXPRESSION,null));
                cc.append(new SetCommand(editingDomain,previousEvent, ProcessPackage.Literals.MESSAGE__TARGET_PROCESS_EXPRESSION,null));
            }
            editingDomain.getCommandStack().execute(cc) ;
        }
    });

}
 
Example 17
Source File: IterationPropertySection.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void createInputForDataGroup(final TabbedPropertySheetWidgetFactory widgetFactory,
        final Composite dataContent) {
    final Group inputGroup = widgetFactory.createGroup(dataContent, Messages.input);
    inputGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    inputGroup.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).spacing(5, 3).create());

    final Label inputListlabel = widgetFactory.createLabel(inputGroup, Messages.inputList + " *");
    inputListlabel.setLayoutData(GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).create());

    final ControlDecoration inputListlabelDecoration = new ControlDecoration(inputListlabel, SWT.RIGHT);
    inputListlabelDecoration.setMarginWidth(-3);
    inputListlabelDecoration.setDescriptionText(Messages.inputListHint);
    inputListlabelDecoration.setImage(Pics.getImage(PicsConstants.hint));

    final ComboViewer inputListComboViewer = createComboViewer(widgetFactory, inputGroup,
            new ObservableListContentProviderWithProposalListenersForPool());
    inputListComboViewer.getControl().setLayoutData(
            GridDataFactory.fillDefaults().grab(true, false).hint(200, SWT.DEFAULT).indent(5, 0).create());
    inputListComboViewer.addFilter(new ListDataFilter());
    inputListComboViewer.setSorter(new DataViewerSorter());
    final IViewerObservableValue observeSingleSelection = ViewersObservables
            .observeSingleSelection(inputListComboViewer);
    final IObservableValue selectionObservable = ViewersObservables.observeSingleSelection(selectionProvider);
    final IObservableValue observeInputCollectionValue = CustomEMFEditObservables.observeDetailValue(
            Realm.getDefault(), selectionObservable,
            ProcessPackage.Literals.MULTI_INSTANTIABLE__COLLECTION_DATA_TO_MULTI_INSTANTIATE);

    selectionObservable.addValueChangeListener(createInputValueChanged(inputListComboViewer, observeSingleSelection,
            observeInputCollectionValue, false));

    inputListComboViewer.addSelectionChangedListener(createComboSelectionListener(inputListComboViewer, false));
    inputListComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            updateReturnTypeFromSelectedInputCollection(inputListComboViewer);
        }

    });
    context.bindValue(observeSingleSelection, observeInputCollectionValue);

    final Label label = widgetFactory.createLabel(inputGroup, "");
    label.setImage(Pics.getImage("icon-arrow-down.png"));
    label.setLayoutData(GridDataFactory.fillDefaults().span(3, 1).align(SWT.CENTER, SWT.CENTER).create());

    createIteratorControl(widgetFactory, inputGroup);
}
 
Example 18
Source File: JSEditor.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public void createPartControl( Composite parent )
{
	Composite child = this.initEditorLayout( parent );

	// Script combo
	cmbExprListViewer = new ComboViewer( cmbExpList );
	JSExpListProvider provider = new JSExpListProvider( );
	cmbExprListViewer.setContentProvider( provider );
	cmbExprListViewer.setLabelProvider( provider );
	cmbExprListViewer.setData( VIEWER_CATEGORY_KEY, VIEWER_CATEGORY_CONTEXT );

	// SubFunctions combo
	JSSubFunctionListProvider subProvider = new JSSubFunctionListProvider( this );

	// also add subProvider as listener of expr viewer.
	cmbExprListViewer.addSelectionChangedListener( subProvider );

	cmbSubFunctions.addListener( CustomChooserComposite.DROPDOWN_EVENT,
			new Listener( ) {

				public void handleEvent( Event event )
				{
					cmbSubFunctions.deselectAll( );

					ScriptParser parser = new ScriptParser( getEditorText( ) );

					Collection<IScriptMethodInfo> coll = parser.getAllMethodInfo( );

					for ( Iterator<IScriptMethodInfo> itr = coll.iterator( ); itr.hasNext( ); )
					{
						IScriptMethodInfo mtd = itr.next( );

						cmbSubFunctions.markSelection( METHOD_DISPLAY_INDENT
								+ mtd.getName( ) );
					}
				}

			} );

	cmbSubFunctionsViewer = new TextComboViewer( cmbSubFunctions );
	cmbSubFunctionsViewer.setContentProvider( subProvider );
	cmbSubFunctionsViewer.setLabelProvider( subProvider );
	cmbSubFunctionsViewer.addSelectionChangedListener( subProvider );
	cmbSubFunctionsViewer.addSelectionChangedListener( propertyDefnChangeListener );

	// Initialize the model for the document.
	Object model = getModel( );
	if ( model != null )
	{
		cmbExpList.setVisible( true );
		cmbSubFunctions.setVisible( true );
		setComboViewerInput( model );
	}
	else
	{
		setComboViewerInput( Messages.getString( "JSEditor.Input.trial" ) ); //$NON-NLS-1$
	}
	cmbExprListViewer.addSelectionChangedListener( palettePage.getSupport( ) );
	cmbExprListViewer.addSelectionChangedListener( propertyDefnChangeListener );

	scriptEditor.createPartControl( child );
	scriptValidator = new ScriptValidator( getViewer( ) );

	disableEditor( );

	SourceViewer viewer = getViewer( );
	IDocument document = viewer == null ? null : viewer.getDocument( );

	if ( document != null )
	{
		IDocumentUndoManager undoManager = DocumentUndoManagerRegistry.getDocumentUndoManager( document );

		if ( undoManager != null )
		{
			undoManager.addDocumentUndoListener( undoListener );
		}
		document.addDocumentListener( documentListener );
	}
}
 
Example 19
Source File: CatchEventEventSelectionContribution.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void createControl(final Composite composite,
        final TabbedPropertySheetWidgetFactory widgetFactory,
        final ExtensibleGridPropertySection extensibleGridPropertySection) {
    combo = new ComboViewer(composite, SWT.NONE);
    combo.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    combo.setLabelProvider(new EventLabelProvider());
    combo.setContentProvider(ArrayContentProvider.getInstance());
    combo.addFilter(new ViewerFilter() {

        @Override
        public boolean select(final Viewer viewer, final Object parentElement, final Object element) {
            if (element instanceof EventObject) {
                final ThrowMessageEvent source = ((Message) element).getSource();
                if (eObject != null) {
                    if (source != null) {
                        final AbstractProcess parentProcessOfSourceMessage = ModelHelper.getParentProcess(source);
                        if (parentProcessOfSourceMessage != null
                                && parentProcessOfSourceMessage.equals(ModelHelper.getParentProcess(eObject))) {
                            return false;
                        }
                    }
                }
            }
            return true;
        }
    });
    final List<Message> events = retrievePossibleMessageEvents();

    combo.setInput(events);
    if (eObject.getEvent() != null) {
        combo.getCombo().setText(eObject.getEvent());
        oldEventName = combo.getCombo().getText();
    }
    combo.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent arg0) {
            handleSelectionChanged();
        }
    });

    combo.getCombo().addListener(SWT.Modify, new Listener() {

        @Override
        public void handleEvent(final Event event) {
            handleSelectionChanged();
        }
    });
}
 
Example 20
Source File: SimpleFileSetsEditor.java    From eclipse-cs with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Control createContents(Composite parent) throws CheckstylePluginException {

  mController = new Controller();

  // group composite containing the config settings
  Group configArea = new Group(parent, SWT.NULL);
  configArea.setText(Messages.SimpleFileSetsEditor_titleSimpleConfig);
  configArea.setLayout(new FormLayout());

  this.mBtnManageConfigs = new Button(configArea, SWT.PUSH);
  this.mBtnManageConfigs.setText(Messages.SimpleFileSetsEditor_btnManageConfigs);
  this.mBtnManageConfigs.addSelectionListener(mController);
  FormData fd = new FormData();
  fd.top = new FormAttachment(0, 3);
  fd.right = new FormAttachment(100, -3);
  this.mBtnManageConfigs.setLayoutData(fd);

  mComboViewer = new ComboViewer(configArea);
  mComboViewer.getCombo().setVisibleItemCount(10);
  mComboViewer.setContentProvider(new CheckConfigurationContentProvider());
  mComboViewer.setLabelProvider(new CheckConfigurationLabelProvider());
  mComboViewer.setComparator(new CheckConfigurationViewerSorter());
  mComboViewer.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  mComboViewer.addSelectionChangedListener(mController);
  fd = new FormData();
  fd.left = new FormAttachment(0, 3);
  fd.top = new FormAttachment(0, 3);
  fd.right = new FormAttachment(mBtnManageConfigs, -3, SWT.LEFT);
  // fd.right = new FormAttachment(100, -3);
  mComboViewer.getCombo().setLayoutData(fd);

  // Description
  Label lblConfigDesc = new Label(configArea, SWT.LEFT);
  lblConfigDesc.setText(Messages.SimpleFileSetsEditor_lblDescription);
  fd = new FormData();
  fd.left = new FormAttachment(0, 3);
  fd.top = new FormAttachment(mComboViewer.getCombo(), 3, SWT.BOTTOM);
  fd.right = new FormAttachment(100, -3);
  lblConfigDesc.setLayoutData(fd);

  this.mTxtConfigDescription = new Text(configArea,
          SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.VERTICAL);
  fd = new FormData();
  fd.left = new FormAttachment(0, 3);
  fd.top = new FormAttachment(lblConfigDesc, 0, SWT.BOTTOM);
  fd.right = new FormAttachment(100, -3);
  fd.bottom = new FormAttachment(100, -3);
  this.mTxtConfigDescription.setLayoutData(fd);

  // init the check configuration combo
  mComboViewer.setInput(mPropertyPage.getProjectConfigurationWorkingCopy());
  if (mDefaultFileSet.getCheckConfig() != null) {
    mComboViewer.setSelection(new StructuredSelection(mDefaultFileSet.getCheckConfig()));
  }

  return configArea;
}