Java Code Examples for org.eclipse.jface.viewers.TableViewer#setContentProvider()

The following examples show how to use org.eclipse.jface.viewers.TableViewer#setContentProvider() . 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: ConnectionSelectionPage.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void createControl(Composite parent) {
	Composite composite = new Composite(parent, SWT.NONE);
	GridLayout layout = new GridLayout();
	layout.numColumns = 1;
	layout.horizontalSpacing = 5;
	layout.verticalSpacing = 7;
	composite.setLayout(layout);
	GridData data = new GridData(GridData.FILL_HORIZONTAL);
	composite.setLayoutData(data);
	
	connViewer = new TableViewer(composite, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
	connViewer.setContentProvider(ArrayContentProvider.getInstance());
	connViewer.setLabelProvider(new ConnLabelProvider());
	connViewer.setInput(connections);
	connViewer.getTable().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
	connViewer.addSelectionChangedListener((SelectionChangedEvent event) -> {
		connection = (CodewindConnection)connViewer.getStructuredSelection().getFirstElement();
		validate();
	});
	
	// Add Context Sensitive Help
	PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, CodewindUIPlugin.MAIN_CONTEXTID);

	setControl(composite);
}
 
Example 2
Source File: SelectDependencyDialog.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Control createDialogArea(final Composite parent) {
    final Composite composite = (Composite) super.createDialogArea(parent);

    dependenciesViewer = new TableViewer(composite, SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY | SWT.MULTI);
    dependenciesViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    dependenciesViewer.setContentProvider(new ArrayContentProvider());
    dependenciesViewer.setLabelProvider(adapterLabelProvider);

    final List<EObject> input = new ArrayList<EObject>();
    for (final Expression e : filteredExpression) {
        final EList<EObject> referencedElements = e.getReferencedElements();
        if (!referencedElements.isEmpty()) {
            final EObject element = referencedElements.get(0);
            input.add(ExpressionHelper.createDependencyFromEObject(element));
        }
    }

    dependenciesViewer.setInput(input);
    return composite;
}
 
Example 3
Source File: AdditionalResourcesConfigurationWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createViewer(Composite parent) {
    viewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE);
    viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    ColumnViewerToolTipSupport.enableFor(viewer);
    viewer.setUseHashlookup(true);
    viewer.getTable().setHeaderVisible(true);
    viewer.getTable().setLinesVisible(true);

    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(1, true));
    layout.addColumnData(new ColumnWeightData(1, true));
    viewer.getTable().setLayout(layout);

    createNameColumn();
    createFileColumn();

    viewer.setContentProvider(new ArrayContentProvider());
}
 
Example 4
Source File: SelectDataWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void createBusinessVariableTableViewerComposite(final Composite parent, final DataBindingContext dbc) {
    businessVariableTableViewerComposite = new Composite(parent, SWT.NONE);
    businessVariableTableViewerComposite.setLayout(GridLayoutFactory.swtDefaults().create());
    businessVariableTableViewerComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    final TableViewer businessDataTableViewer = new TableViewer(businessVariableTableViewerComposite,
            SWT.BORDER | SWT.SINGLE | SWT.NO_FOCUS | SWT.H_SCROLL
                    | SWT.V_SCROLL);
    businessDataTableViewer.getTable().setLayout(GridLayoutFactory.fillDefaults().create());
    businessDataTableViewer.getTable()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(200, 100).create());
    final ObservableListContentProvider contentProvider = new ObservableListContentProvider();
    businessDataTableViewer.setContentProvider(contentProvider);
    final IObservableSet knownElements = contentProvider.getKnownElements();
    final IObservableMap[] labelMaps = EMFObservables.observeMaps(knownElements,
            new EStructuralFeature[] { ProcessPackage.Literals.ELEMENT__NAME,
                    ProcessPackage.Literals.DATA__MULTIPLE,
                    ProcessPackage.Literals.JAVA_OBJECT_DATA__CLASS_NAME });
    businessDataTableViewer
            .setLabelProvider(new BusinessObjectDataStyledLabelProvider(businessObjectStore, labelMaps));
    businessDataTableViewer
            .setInput(new WritableList(availableBusinessData, ProcessPackage.Literals.BUSINESS_OBJECT_DATA));
    final IViewerObservableValue observeSingleSelection = ViewersObservables
            .observeSingleSelection(businessDataTableViewer);
    dbc.bindValue(observeSingleSelection, selectedDataObservable);
    businessVariableButton.addSelectionListener(createBusinessVariableSelectionAdapter());
}
 
Example 5
Source File: DBConnectorsPreferencePage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createDriverManager(Composite parent) {

        final Composite driverManagerComposite = new Composite(parent, SWT.NONE);
        driverManagerComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());
        driverManagerComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

        driverManagerViewer = new TableViewer(driverManagerComposite, SWT.BORDER | SWT.FULL_SELECTION);
        TableLayout tableLayout = new TableLayout();
        tableLayout.addColumnData(new ColumnWeightData(1));
        driverManagerViewer.getTable().setLayout(tableLayout);
        driverManagerViewer.getTable().setLinesVisible(true);
        driverManagerViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
        driverManagerViewer.setContentProvider(new DatabaseDriversContentProvider());
        TableViewerColumn column = new TableViewerColumn(driverManagerViewer, SWT.FILL);
        column.setLabelProvider(driversLabelProvider);
        createButtonsPart(driverManagerComposite);
        createAutomaticallyAddDriverButton(driverManagerComposite);
    }
 
Example 6
Source File: ExportConfigurationWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void createControl(Composite parent) {
	Composite mainComposite = new Composite(parent, SWT.NONE) ;
	mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()) ;
	mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(20,20).create()) ;
	
	databindingContext = new DataBindingContext() ;
	
	final TableViewer viewer = new TableViewer(mainComposite, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE ) ;
	viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()) ;
	viewer.setContentProvider(new ArrayContentProvider()) ;
	viewer.setLabelProvider(new ActionLabelProvider()) ;
	viewer.setInput(getConfigurationExporterContributions()) ;
	
	UpdateValueStrategy startegy = new UpdateValueStrategy() ;
	startegy.setBeforeSetValidator(new IValidator() {
		
		@Override
		public IStatus validate(Object value) {
			if(value  instanceof IAction){
				return Status.OK_STATUS ;
			}
			return ValidationStatus.error(Messages.mustSelectExportError);
		}
	}) ;

	
	WizardPageSupport.create(this,databindingContext) ;
	databindingContext.bindValue(ViewersObservables.observeSingleSelection(viewer), PojoObservables.observeValue(this, "action"),startegy,null) ;

	
	setControl(mainComposite) ;
}
 
Example 7
Source File: View.java    From codeexamples-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createPartControl(Composite parent) {
	viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
	viewer.getTable().setLinesVisible(true);

	TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
	column.setLabelProvider(new StringLabelProvider());

	viewer.getTable().getColumn(0).setWidth(200);
	
	viewer.setContentProvider(ArrayContentProvider.getInstance());
	
	// Provide the input to the ContentProvider
	viewer.setInput(createInitialDataModel());
}
 
Example 8
Source File: ParameterPropertySection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createParameterComposite(final Composite parent) {
    final Composite parameterComposite = getWidgetFactory().createComposite(parent);
    parameterComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    parameterComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());

    final Composite buttonsComposite = getWidgetFactory().createComposite(parameterComposite, SWT.NONE);
    buttonsComposite.setLayout(GridLayoutFactory.fillDefaults().spacing(0, 3).create());
    buttonsComposite.setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).create());

    createAddParameterButton(buttonsComposite);
    updateButton = createUpdateParameterButton(buttonsComposite);
    createRemoveParameterButton(buttonsComposite);

    parameterTableViewer = new TableViewer(widgetFactory.createTable(parameterComposite,
            GTKStyleHandler.removeBorderFlag(SWT.BORDER | SWT.MULTI | SWT.NO_FOCUS | SWT.H_SCROLL | SWT.V_SCROLL)));
    parameterTableViewer.getTable().setLayout(GridLayoutFactory.fillDefaults().create());
    getWidgetFactory().adapt(parameterTableViewer.getTable(), false, false);
    parameterTableViewer.getTable()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(200, 100).create());
    parameterTableViewer.setSorter(new ViewerSorter());
    parameterTableViewer.addDoubleClickListener(this);
    parameterTableViewer.addSelectionChangedListener(this);
    parameterTableViewer.getTable().addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.DEL) {
                e.doit = false;
                remove();
            }
        }
    });

    parameterTableViewer.setContentProvider(new ArrayContentProvider());
    parameterTableViewer.setLabelProvider(new ParameterStyledLabelProvider());
    ColumnViewerToolTipSupport.enableFor(parameterTableViewer, ToolTip.RECREATE);
}
 
Example 9
Source File: EnvironmentVariablesTable.java    From Eclipse-Environment-Variables with MIT License 5 votes vote down vote up
public EnvironmentVariablesTable(final Composite parent) {
	super(parent, SWT.NONE);

	final TableColumnLayout tableColumnLayout = new TableColumnLayout();
	setLayout(tableColumnLayout);

	labelProvider = new TableLabelProvider();

	viewer = new TableViewer(this, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
	viewer.setColumnProperties(new String[] { getKeyName(), getValueName() });

	table = viewer.getTable();
	table.setLinesVisible(true);
	table.setHeaderVisible(true);
	viewer.setLabelProvider(labelProvider);
	try {
		viewer.setContentProvider(new TableContentProvider(vars));
	} catch (final Exception e) {
		// noop
	}
	createColumns(tableColumnLayout, viewer.getTable());

	final CellEditor[] editors = new CellEditor[] { new TextCellEditor(table), new TextCellEditor(table) };

	// Assign the cell editors to the viewer
	viewer.setCellEditors(editors);
	viewer.setCellModifier(new TableCellModifier(viewer));
}
 
Example 10
Source File: RnDialogs.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent){
	Composite ret = new Composite(parent, SWT.NONE);
	ret.setLayout(new GridLayout());
	ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
	Label lblSelectState = new Label(ret, SWT.NONE);
	lblSelectState.setText(Messages.RnDialogs_pleaseNewStateForMulti);
	
	cbStates = new Combo(ret, SWT.READ_ONLY);
	cbStates.setItems(RnStatus.getStatusTexts());
	cbStates.setVisibleItemCount(RnStatus.getStatusTexts().length);
	cbStates.select(rechnungen.get(0).getStatus());
	cbStates.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	
	tableViewer = new TableViewer(ret, SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
	GridData gd_Table = new GridData();
	gd_Table.grabExcessHorizontalSpace = true;
	gd_Table.horizontalSpan = 1;
	gd_Table.minimumHeight = 150;
	gd_Table.heightHint = 150;
	tableViewer.getTable().setLayoutData(gd_Table);
	tableViewer.getTable().setHeaderVisible(true);
	tableViewer.getTable().setLinesVisible(false);
	
	tableViewer.setContentProvider(new ArrayContentProvider());
	TableViewerColumn colRnNumber = new TableViewerColumn(tableViewer, SWT.NONE);
	colRnNumber.getColumn().setWidth(200);
	colRnNumber.getColumn().setText(Messages.RnDialogs_invoiceNumber);
	colRnNumber.setLabelProvider(new ColumnLabelProvider());
	
	tableViewer.setInput(rnNumbers);
	
	return ret;
}
 
Example 11
Source File: ContractPropertySectionTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_bindRemoveButtonEnablement_convert_boolean_value() throws Exception {
    section.init(new WritableValue(aContract().build(), Contract.class));
    final Button removeButton = new Button(parent, SWT.PUSH);
    final TableViewer inputsTableViewer = new TableViewer(parent);
    inputsTableViewer.setLabelProvider(new LabelProvider());
    inputsTableViewer.setContentProvider(ArrayContentProvider.getInstance());
    inputsTableViewer.setInput(Arrays.asList("item"));
    section.bindRemoveButtonEnablement(removeButton, inputsTableViewer);
    assertThat(removeButton.isEnabled()).isFalse();
    assertThat(inputsTableViewer.getSelection().isEmpty()).isTrue();
    inputsTableViewer.setSelection(new StructuredSelection("item"));
    assertThat(removeButton.isEnabled()).isTrue();
    assertThat(inputsTableViewer.getSelection().isEmpty()).isFalse();
}
 
Example 12
Source File: AddOrEditSrxConfigDialog.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 创建映身
 * @param tparent
 *            ;
 */
private void createMapGroup(Composite tparent, GridData groupData, GridLayout groupLayout) {
	Group group = new Group(tparent, SWT.BORDER);
	group.setLayoutData(groupData);
	group.setLayout(groupLayout);
	group.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.group"));

	mapTableViewer = new TableViewer(group, SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL
			| SWT.MULTI);
	mapTable = mapTableViewer.getTable();
	mapTable.setLinesVisible(true);
	mapTable.setHeaderVisible(true);

	GridDataFactory.fillDefaults().span(4, SWT.DEFAULT).grab(true, true).applyTo(mapTable);
	mapTableViewer.setLabelProvider(new TableViewerLabelProvider());
	mapTableViewer.setContentProvider(new ArrayContentProvider());

	String[] columnNames = new String[] { Messages.getString("srx.AddOrEditSrxConfigDialog.columnNames1"),
			Messages.getString("srx.AddOrEditSrxConfigDialog.columnNames2") };
	int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT };
	for (int i = 0; i < columnNames.length; i++) {
		TableColumn tableColumn = new TableColumn(mapTable, columnAlignments[i]);
		tableColumn.setText(columnNames[i]);
		tableColumn.setWidth(50);
	}
	refreshTableWidth(mapTable);

	mapAddBtn = new Button(group, SWT.NONE);
	mapAddBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.mapAddBtn"));
	setButtonLayoutData(mapAddBtn);

	mapEditBtn = new Button(group, SWT.NONE);
	mapEditBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.mapEditBtn"));
	setButtonLayoutData(mapEditBtn);

	mapDeleteBtn = new Button(group, SWT.NONE);
	mapDeleteBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.mapDeleteBtn"));
	setButtonLayoutData(mapDeleteBtn);

	new Label(group, SWT.NONE);

	mapTableViewer.addDoubleClickListener(new IDoubleClickListener() {
		public void doubleClick(DoubleClickEvent event) {
			editMapRules();
		}
	});
}
 
Example 13
Source File: DataExpressionEditor.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Control createExpressionEditor(final Composite parent, final EMFDataBindingContext ctx) {
    mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults()
            .grab(true, true).create());
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());

    Label filler = new Label(mainComposite, SWT.NONE); // filler
    filler.setLayoutData(
            GridDataFactory.fillDefaults().span(2, 1).indent(0, -LayoutConstants.getSpacing().y + 1).create());

    viewer = new TableViewer(mainComposite, SWT.FULL_SELECTION | SWT.BORDER
            | SWT.SINGLE | SWT.V_SCROLL);
    viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    final TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(100, false));
    viewer.getTable().setLayout(layout);
    viewer.getTable().setLayoutData(
            GridDataFactory.fillDefaults().grab(true, true).span(2, 1).create());

    final TableViewerColumn columnViewer = new TableViewerColumn(viewer, SWT.NONE);
    final TableColumn column = columnViewer.getColumn();
    column.setText(Messages.name);

    final TableColumnSorter sorter = new TableColumnSorter(viewer);
    sorter.setColumn(column);

    viewer.getTable().setHeaderVisible(true);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new DataStyledTreeLabelProvider());

    viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            if (!event.getSelection().isEmpty()) {
                DataExpressionEditor.this.fireSelectionChanged();
            }
        }
    });

    addExpressionButton = new Button(mainComposite, SWT.FLAT);
    addExpressionButton.setLayoutData(GridDataFactory.fillDefaults()
            .align(SWT.LEFT, SWT.CENTER).hint(85, SWT.DEFAULT).create());
    addExpressionButton.setText(Messages.addData);

    createReturnTypeComposite(mainComposite);

    return mainComposite;
}
 
Example 14
Source File: ImportFileWizardPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected Composite doCreateControls(Composite parent, DataBindingContext dbc) {
    final Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).margins(0, 0).extendedMargins(10, 10, 10, 0).create());

    final Group transfoGroup = new Group(mainComposite, SWT.NONE);
    transfoGroup.setText(Messages.fileFormat);
    transfoGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(3, 1).create());
    transfoGroup.setLayout(new GridLayout(2, true));

    final TableViewer importList = new TableViewer(transfoGroup, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    importList.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    importList.setContentProvider(ArrayContentProvider.getInstance());
    importList.setComparator(new ImporterPriorityDisplayComparator());
    importList.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object item) {
            return ((ImporterFactory) item).getName();
        }
    });

    final List<ImporterFactory> allAvailableImports = ImporterRegistry.getInstance().getAllAvailableImports();
    importList.setInput(allAvailableImports);

    final IObservableValue importerFactoryObservable = PojoObservables.observeValue(importFileData, "importerFactory");
    importerFactoryObservable.setValue(importList.getElementAt(0));

    dbc.bindValue(ViewersObservables.observeSingleSelection(importList), importerFactoryObservable,
            updateValueStrategy().withValidator(mandatoryValidator(Messages.fileFormat)).create(),
            updateValueStrategy().create());

    final Composite descComposite = new Composite(transfoGroup, SWT.NONE);
    descComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).spacing(5, 3).create());
    descComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create());

    final Label importDescriptionLabel = new Label(descComposite, SWT.NONE);
    importDescriptionLabel.setText(Messages.importDescriptionLabel);

    final Label descriptionImage = new Label(descComposite, SWT.NONE);
    descriptionImage.setLayoutData(GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.FILL).create());

    final Label separator = new Label(descComposite, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    final Label descriptionLabel = new Label(descComposite, SWT.WRAP);
    descriptionLabel.setLayoutData(GridDataFactory.fillDefaults().hint(230, SWT.DEFAULT).grab(false, true).create());

    updatePanel(importFileData.getImporterFactory(), descriptionImage, descriptionLabel);

    doCreateAdditionalControls(mainComposite, dbc);

    final Label fileLabel = new Label(mainComposite, SWT.NONE);
    fileLabel.setText(Messages.selectFileToImport);

    final Text text = new Text(mainComposite, SWT.BORDER);
    text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    final IObservableValue filePathObservable = PojoObservables.observeValue(importFileData, "filePath");
    dbc.bindValue(SWTObservables.observeText(text, SWT.Modify), filePathObservable,
            updateValueStrategy().withValidator(pathValidator(Messages.selectFileToImport).overrideMessage(Messages.invalidFilePath)).create(),
            updateValueStrategy().create());

    final Button browseButton = new Button(mainComposite, SWT.PUSH);
    browseButton.setText(Messages.browseButton_label);
    browseButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            final String file = openFileDialog();
            if (file != null) {
                text.setText(file);
                if (new File(file).exists()) {
                    savePath(new File(file).getParentFile().getAbsolutePath());
                }
            }
        }
    });

    importList.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            updatePanel((ImporterFactory) importerFactoryObservable.getValue(), descriptionImage, descriptionLabel);
        }

    });
    importList.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent arg0) {
            updatePanel((ImporterFactory) importerFactoryObservable.getValue(), descriptionImage, descriptionLabel);
            browseButton.notifyListeners(SWT.Selection, null);
        }
    });

    return mainComposite;
}
 
Example 15
Source File: ProjectSettingLanguagePage.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 创建组件
 * @param comp
 *            ;
 */
public void createControl(Composite comp) {
	Composite canSelectComp = new Composite(comp, SWT.NONE);
	canSelectComp.setLayout(new GridLayout(1, false));
	canSelectComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

	canSelectTableViewer = new TableViewer(canSelectComp, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI
			| SWT.FULL_SELECTION);
	GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
	gridData.widthHint = 150;
	gridData.heightHint = 180;
	canSelectTableViewer.getTable().setLayoutData(gridData);

	canSelectTableViewer.setLabelProvider(new LanguageLabelProvider());
	canSelectTableViewer.setContentProvider(new ArrayContentProvider());
	canSelectTableViewer.setInput(canSelectInput);
	canSelectTableViewer.getTable().addListener(SWT.MouseDoubleClick, this);

	Composite selBtnComp = new Composite(comp, SWT.NONE);
	selBtnComp.setLayout(new GridLayout(1, false));
	selBtnComp.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1));

	addBtn = new Button(selBtnComp, SWT.NONE);
	addBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
	addBtn.setText(Messages.getString("projectsetting.ProjectSettingLanguagePage.addBtn"));
	addBtn.addListener(SWT.Selection, this);

	deleteBtn = new Button(selBtnComp, SWT.NONE);
	deleteBtn.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
	deleteBtn.setText(Messages.getString("projectsetting.ProjectSettingLanguagePage.deleteBtn"));
	deleteBtn.addListener(SWT.Selection, this);

	deleteAllBtn = new Button(selBtnComp, SWT.NONE);
	deleteAllBtn.setText(Messages.getString("projectsetting.ProjectSettingLanguagePage.deleteAllBtn"));
	deleteAllBtn.addListener(SWT.Selection, this);

	Composite hasSelComp = new Composite(comp, SWT.NONE);
	hasSelComp.setLayout(new GridLayout(1, false));
	hasSelComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));

	hasSelTableViewer = new TableViewer(hasSelComp, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
	hasSelTableViewer.getTable().setLayoutData(gridData);
	hasSelTableViewer.setLabelProvider(new LanguageLabelProvider());
	hasSelTableViewer.setContentProvider(new ArrayContentProvider());
	hasSelTableViewer.setInput(hasSelectedList);
	hasSelTableViewer.getTable().addListener(SWT.MouseDoubleClick, this);
}
 
Example 16
Source File: AddOrEditSrxConfigDialog.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 创建语言规则配置
 * @param tparent
 *            ;
 */
private void createLanguageGroup(Composite tparent, GridData groupData, GridLayout groupLayout) {
	Group group = new Group(tparent, SWT.BORDER);
	group.setLayoutData(groupData);
	group.setLayout(groupLayout);
	group.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.groupLang"));

	langTableViewer = new TableViewer(group, SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL
			| SWT.MULTI);
	langTable = langTableViewer.getTable();
	langTable.setLinesVisible(true);
	langTable.setHeaderVisible(true);

	GridDataFactory.fillDefaults().span(4, SWT.DEFAULT).grab(true, true).applyTo(langTable);
	langTableViewer.setLabelProvider(new TableViewerLabelProvider());
	langTableViewer.setContentProvider(new ArrayContentProvider());

	String[] columnNames = new String[] { Messages.getString("srx.AddOrEditSrxConfigDialog.langColumnNames1"),
			Messages.getString("srx.AddOrEditSrxConfigDialog.langColumnNames2") };
	int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT };
	for (int i = 0; i < columnNames.length; i++) {
		TableColumn tableColumn = new TableColumn(langTable, columnAlignments[i]);
		tableColumn.setText(columnNames[i]);
		tableColumn.setWidth(50);
	}
	refreshTableWidth(langTable);

	langAddBtn = new Button(group, SWT.NONE);
	langAddBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.langAddBtn"));
	setButtonLayoutData(langAddBtn);

	langEditBtn = new Button(group, SWT.NONE);
	langEditBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.langEditBtn"));
	setButtonLayoutData(langEditBtn);

	langDeleteBtn = new Button(group, SWT.NONE);
	langDeleteBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.langDeleteBtn"));
	setButtonLayoutData(langDeleteBtn);

	new Label(group, SWT.NONE);

	langTableViewer.addDoubleClickListener(new IDoubleClickListener() {
		public void doubleClick(DoubleClickEvent event) {
			editLangRules();
		}
	});
}
 
Example 17
Source File: JavaExpressionEditor.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Control createExpressionEditor(final Composite parent, final EMFDataBindingContext ctx) {
    mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(true).create());

    final Label filler = (new Label(mainComposite, SWT.NONE));
    filler.setLayoutData(
            GridDataFactory.fillDefaults().indent(0, -LayoutConstants.getSpacing().y + 1).span(2, 1).create());

    viewer = new TableViewer(mainComposite, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);

    final TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(100, false));
    viewer.getTable().setLayout(layout);
    viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    final TableViewerColumn columnViewer = new TableViewerColumn(viewer, SWT.NONE);
    final TableColumn column = columnViewer.getColumn();
    column.setText(Messages.name);

    final TableColumnSorter sorter = new TableColumnSorter(viewer);
    sorter.setColumn(column);

    viewer.getTable().setHeaderVisible(true);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new DataStyledTreeLabelProvider());

    viewer.addPostSelectionChangedListener(event -> {
        if (!event.getSelection().isEmpty()) {
            javaTreeviewer.getTree().setEnabled(true);

            data = (Data) ((IStructuredSelection) event.getSelection()).getFirstElement();
            String className = null;

            if (data.isMultiple()) {
                className = List.class.getName();
            } else if (data instanceof JavaObjectData) {
                className = ((JavaObjectData) data).getClassName();
            }
            if (className != null) {
                javaTreeviewer.setInput(className);
                if (editorInputExpression != null && editorInputExpression.isReturnTypeFixed()) {
                    javaTreeviewer.addFilter(showOnlyMethodWithReturnType(editorInputExpression.getReturnType()));
                }
                javaTreeviewer.expandAll();
                javaTreeviewer.getTree().setFocus();
                javaTreeviewer.getTree().getShell().layout(true, true);
                JavaExpressionEditor.this.fireSelectionChanged();
            }
        }
    });

    createBrowseJavaObjectForReadExpression(mainComposite);
    createReturnTypeComposite(parent);

    return mainComposite;
}
 
Example 18
Source File: LockRepeatedSegmentResultDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create contents of the dialog.
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
	Composite container = (Composite) super.createDialogArea(parent);
	container.setLayout(new GridLayout(1, false));

	Composite composite = new Composite(container, SWT.NONE);
	GridLayout gl_composite = new GridLayout(1, false);
	gl_composite.verticalSpacing = 0;
	gl_composite.marginWidth = 0;
	gl_composite.marginHeight = 0;
	composite.setLayout(gl_composite);
	composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

	tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
	Table table = tableViewer.getTable();

	GridData tableGd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
	tableGd.heightHint = 220;
	table.setLayoutData(tableGd);

	table.setLinesVisible(true);
	table.setHeaderVisible(true);

	String[] clmnTitles = new String[] { Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles1"),
			Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles2"),
			Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles3"),
			Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles4"),
			Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles5"),
			Messages.getString("dialog.LockRepeatedSegmentResultDialog.clmnTitles6") };
	int[] clmnBounds = { 60, 200, 100, 110, 110, 110 };
	for (int i = 0; i < clmnTitles.length; i++) {
		createTableViewerColumn(tableViewer, clmnTitles[i], clmnBounds[i], i);
	}

	tableViewer.setLabelProvider(new TableViewerLabelProvider());
	tableViewer.setContentProvider(new ArrayContentProvider());
	tableViewer.setInput(this.getTableViewerInput());

	return container;
}
 
Example 19
Source File: AddOrEditSrxConfigDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 创建映身
 * @param tparent
 *            ;
 */
private void createMapGroup(Composite tparent, GridData groupData, GridLayout groupLayout) {
	Group group = new Group(tparent, SWT.BORDER);
	group.setLayoutData(groupData);
	group.setLayout(groupLayout);
	group.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.group"));

	mapTableViewer = new TableViewer(group, SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL
			| SWT.MULTI);
	mapTable = mapTableViewer.getTable();
	mapTable.setLinesVisible(true);
	mapTable.setHeaderVisible(true);

	GridDataFactory.fillDefaults().span(4, SWT.DEFAULT).grab(true, true).applyTo(mapTable);
	mapTableViewer.setLabelProvider(new TableViewerLabelProvider());
	mapTableViewer.setContentProvider(new ArrayContentProvider());

	String[] columnNames = new String[] { Messages.getString("srx.AddOrEditSrxConfigDialog.columnNames1"),
			Messages.getString("srx.AddOrEditSrxConfigDialog.columnNames2") };
	int[] columnAlignments = new int[] { SWT.LEFT, SWT.LEFT };
	for (int i = 0; i < columnNames.length; i++) {
		TableColumn tableColumn = new TableColumn(mapTable, columnAlignments[i]);
		tableColumn.setText(columnNames[i]);
		tableColumn.setWidth(50);
	}
	refreshTableWidth(mapTable);

	mapAddBtn = new Button(group, SWT.NONE);
	mapAddBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.mapAddBtn"));
	setButtonLayoutData(mapAddBtn);

	mapEditBtn = new Button(group, SWT.NONE);
	mapEditBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.mapEditBtn"));
	setButtonLayoutData(mapEditBtn);

	mapDeleteBtn = new Button(group, SWT.NONE);
	mapDeleteBtn.setText(Messages.getString("srx.AddOrEditSrxConfigDialog.mapDeleteBtn"));
	setButtonLayoutData(mapDeleteBtn);

	new Label(group, SWT.NONE);

	mapTableViewer.addDoubleClickListener(new IDoubleClickListener() {
		public void doubleClick(DoubleClickEvent event) {
			editMapRules();
		}
	});
}
 
Example 20
Source File: USBLogviewer.java    From Flashtool with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Create contents of the dialog.
 */
private void createContents() {
	shlUSBLogviewer = new Shell(getParent(), getStyle());
	shlUSBLogviewer.setSize(710, 475);
	shlUSBLogviewer.setText("USB Log Viewer");
	shlUSBLogviewer.setLayout(new FormLayout());
	
	btnClose = new Button(shlUSBLogviewer, SWT.NONE);
	FormData fd_btnClose = new FormData();
	fd_btnClose.bottom = new FormAttachment(100, -10);
	fd_btnClose.right = new FormAttachment(100, -10);
	btnClose.setLayoutData(fd_btnClose);
	btnClose.setText("Close");
	
	compositeTable = new Composite(shlUSBLogviewer, SWT.NONE);
	compositeTable.setLayout(new FillLayout(SWT.HORIZONTAL));
	FormData fd_compositeTable = new FormData();
	
	fd_compositeTable.right = new FormAttachment(100, -10);
	fd_compositeTable.left = new FormAttachment(0, 10);
	fd_compositeTable.bottom = new FormAttachment(btnClose, -6);
	compositeTable.setLayoutData(fd_compositeTable);
	
	tableViewer = new TableViewer(compositeTable,SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.SINGLE);
	tableViewer.setContentProvider(new VectorContentProvider());
	tableViewer.setLabelProvider(new VectorLabelProvider());

	table = tableViewer.getTable();
	TableColumn[] columns = new TableColumn[2];
	columns[0] = new TableColumn(table, SWT.NONE);
	columns[0].setText("Action");
	columns[1] = new TableColumn(table, SWT.NONE);
	columns[1].setText("Parameter");
	table.setHeaderVisible(true);
	table.setLinesVisible(true);
	TableSorter sort = new TableSorter(tableViewer);
	Composite compositeSource = new Composite(shlUSBLogviewer, SWT.NONE);
	compositeSource.setLayout(new GridLayout(3, false));
	FormData fd_compositeSource = new FormData();
	fd_compositeSource.top = new FormAttachment(0, 10);
	fd_compositeSource.left = new FormAttachment(0, 10);
	fd_compositeSource.right = new FormAttachment(100, -10);
	compositeSource.setLayoutData(fd_compositeSource);
	
	fd_compositeTable.top = new FormAttachment(compositeSource, 6);
	
	lblLogfile = new Label(compositeSource, SWT.BORDER);
	lblLogfile.setText("USB Log file :");
	
	textLogFile = new Text(compositeSource, SWT.BORDER);
	textLogFile.setEditable(false);
	GridData gd_textLogFile = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
	gd_textLogFile.widthHint = 471;
	textLogFile.setLayoutData(gd_textLogFile);
	
	btnLogFile = new Button(compositeSource, SWT.NONE);
	btnLogFile.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	btnLogFile.setText("...");
	
	Label lblSinfolder = new Label(compositeSource, SWT.NONE);
	GridData gd_lblSinfolder = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
	gd_lblSinfolder.widthHint = 110;
	lblSinfolder.setLayoutData(gd_lblSinfolder);
	lblSinfolder.setText("Source folder :");
	
	textSinFolder = new Text(compositeSource, SWT.BORDER);
	textSinFolder.setEditable(false);
	GridData gd_textSinFolder = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
	gd_textSinFolder.widthHint = 509;
	textSinFolder.setLayoutData(gd_textSinFolder);
	
	btnSourceFolder = new Button(compositeSource, SWT.NONE);
	GridData gd_btnSourceFolder = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
	gd_btnSourceFolder.widthHint = 46;
	btnSourceFolder.setLayoutData(gd_btnSourceFolder);
	btnSourceFolder.setText("...");
	btnParse = new Button(shlUSBLogviewer, SWT.NONE);
	FormData fd_btnParse = new FormData();
	fd_btnParse.bottom = new FormAttachment(100,-10);
	fd_btnParse.right = new FormAttachment(btnClose, -6);
	btnParse.setLayoutData(fd_btnParse);
	btnParse.setText("Parse");

}