Search in sources :

Example 6 with LabelProvider

use of org.eclipse.jface.viewers.LabelProvider in project tdi-studio-se by Talend.

the class HL7MultiSchemaUI method createCombo.

@Override
protected void createCombo(Composite parent) {
    createLabel(parent);
    metaTableViewer = new ComboViewer(parent, SWT.NONE);
    metaTableViewer.setContentProvider(new ArrayContentProvider());
    metaTableViewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof SegmentModel) {
                return ((SegmentModel) element).getSeg().getName();
            }
            return super.getText(element);
        }
    });
    final Combo combo = metaTableViewer.getCombo();
    GridData data = new GridData();
    data.widthHint = 60;
    combo.setLayoutData(data);
    combo.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            updateCurrentMetadataTable();
            linker.removeAllLinks();
            linker.getMainui().redrawLinkers();
            linker.getBackgroundRefresher().refreshBackground();
        }
    });
}
Also used : ComboViewer(org.eclipse.jface.viewers.ComboViewer) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Combo(org.eclipse.swt.widgets.Combo) SegmentModel(org.talend.designer.hl7.model.SegmentModel) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 7 with LabelProvider

use of org.eclipse.jface.viewers.LabelProvider in project tdi-studio-se by Talend.

the class ImportItemWizardPage method createErrorsList.

private void createErrorsList(Composite workArea) {
    Composite composite = new Composite(workArea, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.makeColumnsEqualWidth = false;
    layout.marginWidth = 0;
    composite.setLayout(layout);
    GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
    gridData.heightHint = 100;
    composite.setLayoutData(gridData);
    Label title = new Label(composite, SWT.NONE);
    //$NON-NLS-1$
    title.setText(Messages.getString("ImportItemWizardPage.ErrorsAndWarnings"));
    title.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    errorsList = new TableViewer(composite, SWT.BORDER);
    errorsList.getControl().setLayoutData(gridData);
    errorsList.setContentProvider(new IStructuredContentProvider() {

        @Override
        public void dispose() {
        }

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

        @Override
        public Object[] getElements(Object inputElement) {
            return errors.toArray();
        }
    });
    errorsList.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return element.toString();
        }
    });
    errorsList.setInput(this);
    errorsList.setSorter(new ViewerSorter());
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) ViewerSorter(org.eclipse.jface.viewers.ViewerSorter) TableViewer(org.eclipse.jface.viewers.TableViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) TableViewer(org.eclipse.jface.viewers.TableViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 8 with LabelProvider

use of org.eclipse.jface.viewers.LabelProvider in project tdi-studio-se by Talend.

the class LoadChartSetDialog method createChartSetViewer.

/**
     * Creates the chart set viewer.
     * 
     * @param parent The parent composite
     * @return The chart set viewer
     */
private TableViewer createChartSetViewer(Composite parent) {
    final TableViewer viewer = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = 300;
    viewer.getTable().setLayoutData(gridData);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            if (element.equals(defaultChartSet)) {
                return NLS.bind(Messages.defaultChartSet, defaultChartSet);
            }
            return super.getText(element);
        }
    });
    viewer.setInput(chartSets.toArray(new String[chartSets.size()]));
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            Object element = ((StructuredSelection) selection).getFirstElement();
            if (deleteButton != null) {
                deleteButton.setEnabled(!selection.isEmpty() && !predefinedChartSets.contains(element));
            }
            if (element != null) {
                chartSet = element.toString();
            } else {
                viewer.setSelection(new StructuredSelection(chartSet));
            }
        }
    });
    viewer.setSelection(new StructuredSelection(defaultChartSet));
    return viewer;
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 9 with LabelProvider

use of org.eclipse.jface.viewers.LabelProvider in project tesb-studio-se by Talend.

the class InitFinishMessageDialog method createMessageArea.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.dialogs.IconAndMessageDialog#createMessageArea(org.eclipse.swt.widgets.Composite)
     */
@Override
protected Control createMessageArea(Composite composite) {
    // create image
    Image image = getImage();
    if (image != null) {
        imageLabel = new Label(composite, SWT.NULL);
        image.setBackground(imageLabel.getBackground());
        imageLabel.setImage(image);
        GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING).applyTo(imageLabel);
    }
    Link link = new Link(composite, SWT.WRAP);
    link.setText("Local runtime serview has been started, totally installed bundles: <a href=\"#\">" + bundlesName.length + "</a>.");
    link.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ElementListSelectionDialog report = new ElementListSelectionDialog(getShell(), new LabelProvider());
            report.setTitle("Installed bundles:");
            report.setMessage("Search bundle (? = any character, * = any string):");
            report.setElements(bundlesName);
            report.open();
        }
    });
    return composite;
}
Also used : ElementListSelectionDialog(org.eclipse.ui.dialogs.ElementListSelectionDialog) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Image(org.eclipse.swt.graphics.Image) LabelProvider(org.eclipse.jface.viewers.LabelProvider) Link(org.eclipse.swt.widgets.Link)

Example 10 with LabelProvider

use of org.eclipse.jface.viewers.LabelProvider in project translationstudio8 by heartsome.

the class NewTermDbBaseInfoPage method createControl.

/**
	 * Create contents of the wizard.
	 * @param parent
	 */
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout(1, false));
    setControl(container);
    int labelWidth = 100;
    GridData gdLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gdLabel.widthHint = labelWidth;
    Group dbGroup1 = new Group(container, SWT.NONE);
    dbGroup1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    dbGroup1.setLayout(new GridLayout(2, false));
    dbGroup1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1));
    dbGroup1.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.dbGroup1"));
    Label label = new Label(dbGroup1, SWT.RIGHT);
    label.setLayoutData(gdLabel);
    label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.lblType"));
    dbTypeComboViewer = new ComboViewer(dbGroup1, SWT.READ_ONLY);
    Combo combo = dbTypeComboViewer.getCombo();
    combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    // //
    label = new Label(dbGroup1, SWT.RIGHT);
    label.setLayoutData(gdLabel);
    label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.dbNameText"));
    dbNameText = new Text(dbGroup1, SWT.BORDER);
    dbNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    label = new Label(dbGroup1, SWT.RIGHT);
    label.setLayoutData(gdLabel);
    label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.instanceText"));
    instanceText = new Text(dbGroup1, SWT.BORDER);
    instanceText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    dbTypeComboViewer.setContentProvider(new ArrayContentProvider());
    dbTypeComboViewer.setInput(dbTypeList);
    dbTypeComboViewer.setLabelProvider(new LabelProvider() {

        public String getText(Object element) {
            SystemDBOperator dbOp = (SystemDBOperator) element;
            String dbType = dbOp.getDBConfig().getDefaultType();
            if (dbType.equals(Constants.DBTYPE_MYSQL)) {
                dbType = Constants.DBTYPE_MYSQL_FOR_UI;
            } else if (dbType.equals(Constants.DBTYPE_MSSQL2005)) {
                dbType = Constants.DBTYPE_MSSQL2005_FOR_UI;
            } else if (dbType.equals(Constants.DBTYPE_SQLITE)) {
                dbType = Messages.getString("tb.dbtype.sqlite");
            }
            return dbType;
        }
    });
    dbTypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection != null && selection instanceof IStructuredSelection) {
                IStructuredSelection sel = (IStructuredSelection) selection;
                Object selObj = sel.getFirstElement();
                if (selObj != null && selObj instanceof SystemDBOperator) {
                    SystemDBOperator selDbOp = (SystemDBOperator) selObj;
                    dbTypeChangeEvent(selDbOp);
                }
            }
        }
    });
    Group dbGroup = new Group(container, SWT.NONE);
    dbGroup.setLayout(new GridLayout(5, false));
    dbGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1));
    dbGroup.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.dbGroup"));
    label = new Label(dbGroup, SWT.RIGHT);
    label.setLayoutData(gdLabel);
    label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.hostText"));
    hostText = new Text(dbGroup, SWT.BORDER);
    hostText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    label = new Label(dbGroup, SWT.RIGHT);
    label.setLayoutData(gdLabel);
    label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.portText"));
    portText = new Text(dbGroup, SWT.BORDER);
    new Label(dbGroup, SWT.NONE);
    label = new Label(dbGroup, SWT.RIGHT);
    label.setLayoutData(gdLabel);
    label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.locationText"));
    locationText = new Text(dbGroup, SWT.BORDER);
    locationText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    locationText.setEnabled(false);
    borwserBtn = new Button(dbGroup, SWT.NONE);
    borwserBtn.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.borwserBtn"));
    borwserBtn.setEnabled(false);
    borwserBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            DirectoryDialog dlg = new DirectoryDialog(getShell());
            String path = dlg.open();
            if (path != null) {
                locationText.setText(path);
            }
        }
    });
    Group authorityGroup = new Group(container, SWT.NONE);
    authorityGroup.setLayout(new GridLayout(2, false));
    authorityGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1));
    authorityGroup.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.authorityGroup"));
    label = new Label(authorityGroup, SWT.RIGHT);
    label.setLayoutData(gdLabel);
    label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.usernameText"));
    usernameText = new Text(authorityGroup, SWT.BORDER);
    usernameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    label = new Label(authorityGroup, SWT.RIGHT);
    label.setLayoutData(gdLabel);
    label.setText(Messages.getString("wizard.NewTermDbBaseInfoPage.passwordText"));
    passwordText = new Text(authorityGroup, SWT.BORDER | SWT.PASSWORD);
    passwordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    initDataBindings();
    if (this.dbOp != null) {
        dbTypeComboViewer.setSelection(new StructuredSelection(this.dbOp));
    } else {
        dbTypeComboViewer.setSelection(new StructuredSelection(dbTypeList.get(0)));
    }
    IStatus state = validator();
    if (!state.isOK()) {
        setErrorMessage(state.getMessage());
        setPageComplete(false);
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) IStatus(org.eclipse.core.runtime.IStatus) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) SystemDBOperator(net.heartsome.cat.database.SystemDBOperator) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ISelection(org.eclipse.jface.viewers.ISelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LabelProvider(org.eclipse.jface.viewers.LabelProvider) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Aggregations

LabelProvider (org.eclipse.jface.viewers.LabelProvider)25 GridData (org.eclipse.swt.layout.GridData)17 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)12 GridLayout (org.eclipse.swt.layout.GridLayout)11 Composite (org.eclipse.swt.widgets.Composite)11 ComboViewer (org.eclipse.jface.viewers.ComboViewer)10 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 Label (org.eclipse.swt.widgets.Label)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)7 Button (org.eclipse.swt.widgets.Button)7 Combo (org.eclipse.swt.widgets.Combo)7 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)6 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)6 Text (org.eclipse.swt.widgets.Text)6 ArrayList (java.util.ArrayList)5 ISelection (org.eclipse.jface.viewers.ISelection)5 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)5 Image (org.eclipse.swt.graphics.Image)5 List (java.util.List)4