Example usage for org.eclipse.jface.viewers ComboViewer ComboViewer

List of usage examples for org.eclipse.jface.viewers ComboViewer ComboViewer

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers ComboViewer ComboViewer.

Prototype

public ComboViewer(Composite parent, int style) 

Source Link

Document

Creates a combo viewer on a newly-created combo control under the given parent.

Usage

From source file:de.bht.fpa.mail.s000000.common.filter.operator.ImportanceFilterOperatorComposite.java

License:Open Source License

public ImportanceFilterOperatorComposite(Composite parent) {
    super(parent, SWT.NONE);
    setLayout(new GridLayout(2, false));

    Combo comboOperation = new Combo(this, SWT.READ_ONLY);
    comboOperation.setItems(new String[] { FilterOperator.IS.value() });
    comboOperation.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
    comboOperation.select(0);/* www  . j a  v  a 2  s  . c om*/

    comboViewer = new ComboViewer(this, SWT.READ_ONLY);
    Combo comboValue = comboViewer.getCombo();
    comboValue.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
    comboViewer.setContentProvider(ArrayContentProvider.getInstance());
    comboViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            return ((Importance) element).value();
        }
    });
    comboViewer.setInput(new Importance[] { Importance.HIGH, Importance.NORMAL, Importance.LOW });

    operator = FilterOperator.IS;
}

From source file:de.bht.fpa.mail.s000000.common.filter.type.FilterTypeComponent.java

License:Open Source License

/**
 * Create the composite.// www .j ava 2s . c om
 * 
 * @param parent
 * @param style
 */
public FilterTypeComponent(final Composite parent) {
    super(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 0;
    setLayout(layout);

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

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

    filterTypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

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

    filterTypeComboViewer.setInput(FilterType.values());

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

    filterTypeComboViewer.setSelection(new StructuredSelection(FilterType.SENDER));
}

From source file:de.fhg.igd.mapviewer.server.wms.wizard.pages.BasicConfigurationWithWMSListPage.java

License:Open Source License

@Override
public void createComponent() {
    super.createComponent();

    Button storeWMS = new Button(getComposite(), SWT.PUSH);
    storeWMS.setText(Messages.WMSListConfigurationPage_2);

    // add new WMS to list and refresh
    storeWMS.addSelectionListener(new SelectionAdapter() {

        @Override//from w w  w.java 2  s  .c  o  m
        public void widgetSelected(SelectionEvent e) {
            // store WMS i UI list
            map.put(getServiceName(), getServiceURL());
            getListForUI(listUI);
            comboViewer.refresh();
        }
    });

    // free line
    new Text(getComposite(), SWT.NONE).setEditable(false);
    new Text(getComposite(), SWT.NONE).setEditable(false);
    new Text(getComposite(), SWT.NONE).setEditable(false);
    new Text(getComposite(), SWT.NONE).setEditable(false);
    new Text(getComposite(), SWT.NONE).setEditable(false);

    // add text and combo viewer
    Text text = new Text(getComposite(), SWT.NONE);
    text.setEditable(false);
    text.setText(Messages.WMSListConfigurationPage_0);

    // get a list of all WMS

    // get all WMS, storing as WMS Map Server
    Preferences PREF_SERVERS = new WMSMapServer().getPreferences();

    String[] prefs = null;
    try {
        prefs = PREF_SERVERS.childrenNames();

        // put all in map
        for (String current : prefs) {

            Preferences child = PREF_SERVERS.node(current);
            map.put(current, child.get("baseUrl", "baseUrl"));
        }

    } catch (BackingStoreException e) {
        log.warn(Messages.WMSListConfigurationPage_1, e); // $NON-NLS-1$
    }

    // get all WMS, storing as extension points
    IConfigurationElement[] allER = Platform.getExtensionRegistry()
            .getConfigurationElementsFor("de.fhg.igd.mapviewer.server.MapServer");

    for (IConfigurationElement current : allER) {
        String name = "";
        String url = "";

        // name is stored directly as attribute
        name = current.getAttribute("name");

        // url is stored as child
        for (IConfigurationElement child : current.getChildren()) {
            if (child.getAttribute("name").equals("baseUrl")) {
                url = child.getAttribute("value");
            }
        }
        // store everything into map
        if (name != null && !name.isEmpty() && url != null && !url.isEmpty()) {
            map.put(name, url);
        }
    }

    // show stored WMS as DropDown
    comboViewer = new ComboViewer(getComposite(), SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
    comboViewer.setContentProvider(new ArrayContentProvider());
    getListForUI(listUI);
    comboViewer.setInput(listUI);
    comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection.size() > 0) {
                String currentSelection = (String) selection.getFirstElement();
                name.setStringValue(currentSelection);
                location.setStringValue(map.get(currentSelection));
            }
        }
    });
}

From source file:de.fkoeberle.autocommit.message.ui.AdvancedPage.java

License:Open Source License

/**
 * Create contents of the editor part./*from  ww w  .ja  v  a2  s.  c  o m*/
 * 
 * @param parent
 */
@Override
public void createFormContent(IManagedForm managedForm) {
    super.createFormContent(managedForm);
    FormToolkit toolkit = managedForm.getToolkit();
    ScrolledForm scrolledForm = managedForm.getForm();
    Composite body = scrolledForm.getBody();
    toolkit.decorateFormHeading(scrolledForm.getForm());
    toolkit.paintBordersFor(body);

    scrolledForm.setText("Advanced");
    Composite parent = scrolledForm.getBody();
    parent.setLayout(new FillLayout(SWT.HORIZONTAL));
    Composite container = toolkit.createComposite(parent);
    container.setLayout(new GridLayout(1, false));

    Composite header = toolkit.createComposite(container);
    header.setLayout(new GridLayout(2, false));

    Label generateLabel = toolkit.createLabel(header, "Generate:");
    generateLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));

    final ComboViewer comboViewer = new ComboViewer(header, SWT.READ_ONLY);
    final Combo combo = comboViewer.getCombo();
    toolkit.adapt(combo, true, true);

    GridData comboLayoutData = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    comboLayoutData.widthHint = 315;
    combo.setLayoutData(comboLayoutData);
    comboViewer.addSelectionChangedListener(new ComboSelectionListener(combo, comboViewer));

    comboViewer.setContentProvider(new ObservableListContentProvider());
    comboViewer.setLabelProvider(new DefaultProfileLabelProvider());
    comboViewer.setInput(model.getProfiles());

    ProfileComboBoxUpdater profileComboBoxUpdater = new ProfileComboBoxUpdater(comboViewer);
    model.addCurrentProfileListener(new ProfileComboBoxUpdater(comboViewer));
    profileComboBoxUpdater.currentProfileChanged();

    SashForm sashForm = new SashForm(container, SWT.NONE);
    sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    toolkit.adapt(sashForm, false, false);

    Section leftSection = managedForm.getToolkit().createSection(sashForm, Section.TWISTIE | Section.TITLE_BAR);
    managedForm.getToolkit().paintBordersFor(leftSection);
    leftSection.setText("Used commit message factories:");

    Composite leftComposite = managedForm.getToolkit().createComposite(leftSection, SWT.NONE);
    managedForm.getToolkit().paintBordersFor(leftComposite);
    leftSection.setClient(leftComposite);
    leftComposite.setLayout(new GridLayout(1, false));

    final TableViewer usedFactoriesTableViewer = new TableViewer(leftComposite, SWT.BORDER | SWT.MULTI);
    usedFactoriesTable = usedFactoriesTableViewer.getTable();
    usedFactoriesTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    usedFactoriesTableViewer.setContentProvider(new ObservableListContentProvider());
    usedFactoriesTableViewer.setLabelProvider(new FactoryLabelProvider());
    usedFactoriesTableViewer.setInput(model.getFactoryDescriptions());

    Section middleSection = managedForm.getToolkit().createSection(sashForm,
            Section.TWISTIE | Section.TITLE_BAR);
    managedForm.getToolkit().paintBordersFor(middleSection);
    middleSection.setText("Unused commit message factories:");

    Composite middleComposite = managedForm.getToolkit().createComposite(middleSection, SWT.NONE);
    managedForm.getToolkit().paintBordersFor(middleComposite);
    middleSection.setClient(middleComposite);
    middleComposite.setLayout(new GridLayout(1, false));

    TableViewer unusedFactoriesTableViewer = new TableViewer(middleComposite, SWT.BORDER | SWT.MULTI);
    unusedFactoriesTable = unusedFactoriesTableViewer.getTable();
    unusedFactoriesTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    unusedFactoriesTableViewer.setContentProvider(new ObservableListContentProvider());
    unusedFactoriesTableViewer.setLabelProvider(new FactoryLabelProvider());
    unusedFactoriesTableViewer.setInput(model.getUnusedFactoryDescriptions());

    addDragAndDropSupport(usedFactoriesTableViewer, unusedFactoriesTableViewer);

    usedFactoriesTableViewer.addSelectionChangedListener(new FactoriesSelectionListener(CMFList.USED,
            usedFactoriesTableViewer, unusedFactoriesTableViewer, toolkit));
    unusedFactoriesTableViewer.addSelectionChangedListener(new FactoriesSelectionListener(CMFList.UNUSED,
            unusedFactoriesTableViewer, usedFactoriesTableViewer, toolkit));

    Section rightSection = managedForm.getToolkit().createSection(sashForm,
            Section.TWISTIE | Section.TITLE_BAR);
    managedForm.getToolkit().paintBordersFor(rightSection);
    rightSection.setText("Selected commit message factories:");

    Composite rightComposite = managedForm.getToolkit().createComposite(rightSection, SWT.NONE);
    managedForm.getToolkit().paintBordersFor(rightComposite);
    rightSection.setClient(rightComposite);
    rightComposite.setLayout(new GridLayout(1, false));

    final ScrolledComposite scrolledComposite = new ScrolledComposite(rightComposite,
            SWT.V_SCROLL | SWT.BORDER);
    scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    toolkit.adapt(scrolledComposite);
    factoriesComposite = new Composite(scrolledComposite, SWT.NONE);
    scrolledComposite.setContent(factoriesComposite);
    toolkit.adapt(factoriesComposite);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    factoriesComposite.setLayout(layout);
    scrolledComposite.addControlListener(new ControlAdapter() {
        @Override
        public void controlResized(ControlEvent e) {
            Rectangle r = scrolledComposite.getClientArea();
            factoriesComposite.setSize(factoriesComposite.computeSize(r.width, SWT.DEFAULT));
            factoriesComposite.layout();
        }
    });
    scrolledComposite.setAlwaysShowScrollBars(true);
    sashForm.setWeights(new int[] { 180, 180, 350 });
    /*
     * Expand after generating it's content so that content gets properly
     * shown:
     */
    leftSection.setExpanded(true);
    middleSection.setExpanded(true);
    rightSection.setExpanded(true);
}

From source file:de.fxworld.generationgap.ui.properties.GapPropertyPage.java

License:Open Source License

/**
 * Create contents of the property page.
 * @param parent/*from   ww w  .java2 s  .  co m*/
 */
@Override
public Control createContents(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);

    if (configuration != null) {
        container.setLayout(new GridLayout(2, false));

        Label lblGenerate = new Label(container, SWT.NONE);
        lblGenerate.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
        lblGenerate.setText("Generate:");

        generateEditButton = new Button(container, SWT.CHECK);
        generateEditButton.setText("Generate Edit");
        new Label(container, SWT.NONE);

        generateEditorButton = new Button(container, SWT.CHECK);
        generateEditorButton.setText("GenerateEditor");
        new Label(container, SWT.NONE);

        generateCustomClassesButton = new Button(container, SWT.CHECK);
        generateCustomClassesButton.setText("Generate Custom Classes");

        Label lblNewLabel = new Label(container, SWT.NONE);
        lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
        lblNewLabel.setText("Target for CustomClasses:");

        customClassTargetComboViewer = new ComboViewer(container, SWT.READ_ONLY);
        Combo customClassTargetCombo = customClassTargetComboViewer.getCombo();
        customClassTargetCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        customClassTargetComboViewer.setLabelProvider(new SourceFolderContentProvider());
        customClassTargetComboViewer.setContentProvider(new SourceFolderContentProvider());

        Label lblNewLabel_1 = new Label(container, SWT.NONE);
        lblNewLabel_1.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
        lblNewLabel_1.setText("Source folders to clear:");

        sourceFolderCleanTableViewer = CheckboxTableViewer.newCheckList(container,
                SWT.BORDER | SWT.FULL_SELECTION);
        Table sourceFolderCleanTable = sourceFolderCleanTableViewer.getTable();
        sourceFolderCleanTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        sourceFolderCleanTableViewer.setLabelProvider(new SourceFolderContentProvider());
        sourceFolderCleanTableViewer.setContentProvider(new SourceFolderContentProvider());

        Label lblNewLabel_2 = new Label(container, SWT.NONE);
        lblNewLabel_2.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
        lblNewLabel_2.setText("Generator Models:");

        generatorModelTableViewer = CheckboxTableViewer.newCheckList(container,
                SWT.BORDER | SWT.FULL_SELECTION);
        Table generatorModelTable = generatorModelTableViewer.getTable();
        generatorModelTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        generatorModelTableViewer.setLabelProvider(new GenModelContentProvider());
        generatorModelTableViewer.setContentProvider(new GenModelContentProvider());

        initData();
    } else {
        container.setLayout(new GridLayout(1, false));

        Label label = new Label(container, SWT.NONE);
        label.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, false, 1, 1));
        label.setText("The selected Project is not a Java Project.");
    }

    return container;
}

From source file:de.innot.avreclipse.ui.views.avrdevice.AVRDeviceView.java

License:Open Source License

/**
 * Create, layout and initialize the controls of this viewer
 *//*w  w w .  j a  v a 2s .  c  o m*/
@Override
public void createPartControl(Composite parent) {

    fViewParent = parent;

    // All listeners that are need to unregistered on dispose()
    fProviderChangeListener = new ProviderChangeListener();
    fWorkbenchSelectionListener = new WorkbenchSelectionListener();

    // Get the default AVRiohDeviceDescriptionProvider
    // TODO: once more than one DeviceDescriptionProvider exist,
    // this has to be changed.
    dmprovider = AVRiohDeviceDescriptionProvider.getDefault();

    if (dmprovider != null)
        // setup ourself as a change listener for the
        // DeviceDescriptionProvider
        dmprovider.addProviderChangeListener(fProviderChangeListener); // ProviderChangeListener

    fViewParent.setLayout(new GridLayout());

    // TODO: TreeColumn Map is dependent on devicemodelprovider
    fTreeColumns = new HashMap<String, List<TreeColumn>>();

    // Layout the top part, which consists of the MCU Type selection Combo
    // and a composite of the sources Labels and Texts
    // The Combo gets 33% of the space, the sources composite the other 67%
    GridLayout gl = new GridLayout(3, true);
    gl.marginHeight = 0;
    gl.marginWidth = 0;

    fTop = new Composite(fViewParent, SWT.NONE);
    fTop.setLayout(gl);
    fTop.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));

    fCombo = new ComboViewer(fTop, SWT.READ_ONLY | SWT.DROP_DOWN);
    fCombo.getControl().setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
    fCombo.setContentProvider(new DeviceListContentProvider());
    fCombo.setLabelProvider(new ComboLabelProvider());

    // register the combo as a Selection Provider
    getSite().setSelectionProvider(fCombo);

    fSourcesComposite = new Composite(fTop, SWT.NONE);
    fSourcesComposite.setLayout(new RowLayout());
    fSourcesComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 2, 1));
    new Label(fSourcesComposite, SWT.NONE).setText("source:");

    // The bottom part consists of a TabFolder Control which will take all
    // space not used by the top part.
    fTabFolder = new CTabFolder(fViewParent, SWT.BORDER);
    fTabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    fCombo.addSelectionChangedListener(new ComboSelectionChangedListener());
    fTabFolder.addSelectionListener(new TabFolderSelectionListener());

    // This will -in turn- cause all the data sub-widgets to be
    // initialized and displayed
    providerChanged();

    // Activate the Workbench selection listener
    getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(fWorkbenchSelectionListener);

}

From source file:de.justi.yagw2api.explorer.rcp.map.WorldMapViewPart.java

License:Apache License

/**
 * Create contents of the view part.//from w  ww  . j  a  va 2s.  c o  m
 *
 * @param parent
 */
@Override
public void createPartControl(final Composite parent) {

    parent.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    parent.setLayout(new GridLayout(2, false));

    Composite cmpBasicControls = new Composite(parent, SWT.NONE);
    cmpBasicControls.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
    cmpBasicControls.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    cmpBasicControls.setLayout(new GridLayout(4, false));

    CLabel lblZoom = new CLabel(cmpBasicControls, SWT.NONE);
    lblZoom.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    lblZoom.setText("Zoom");

    this.txtZoom = new Text(cmpBasicControls, SWT.BORDER | SWT.READ_ONLY | SWT.RIGHT);

    this.btnZoomIn = new Button(cmpBasicControls, SWT.FLAT | SWT.CENTER);
    this.btnZoomIn.setText("+");
    this.btnZoomIn.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            WorldMapViewPart.this.zoomIn();
        }
    });

    this.btnZoomOut = new Button(cmpBasicControls, SWT.FLAT | SWT.CENTER);
    this.btnZoomOut.setSize(25, 25);
    this.btnZoomOut.setText("-");
    this.btnZoomOut.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            WorldMapViewPart.this.zoomOut();
        }
    });

    CLabel lblFloor = new CLabel(cmpBasicControls, SWT.NONE);
    lblFloor.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    lblFloor.setText("Floor");

    this.cmbFloorViewer = new ComboViewer(cmpBasicControls, SWT.READ_ONLY);
    Combo cmbFloor = this.cmbFloorViewer.getCombo();
    cmbFloor.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    this.cmbFloorViewer.setContentProvider(this.floorContentProvider);
    this.cmbFloorViewer.addSelectionChangedListener(this.selectionProvider);
    this.cmbFloorViewer.setLabelProvider(new TypeSafeViewerLabelProvider<ContinentFloor>(ContinentFloor.class) {
        @Override
        protected String getTypeSafeText(final ContinentFloor element) {
            return String.valueOf(element.getIndex());
        }
    });

    CLabel lblContinent = new CLabel(cmpBasicControls, SWT.NONE);
    lblContinent.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    lblContinent.setText("Continent");

    this.cmbContinentViewer = new ComboViewer(cmpBasicControls, SWT.READ_ONLY);
    Combo cmbContinent = this.cmbContinentViewer.getCombo();
    cmbContinent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    this.cmbContinentViewer.setContentProvider(this.continentContentProvier);
    this.cmbContinentViewer.setLabelProvider(new TypeSafeViewerLabelProvider<Continent>(Continent.class) {
        @Override
        protected String getTypeSafeText(final Continent element) {
            return element.getName();
        }
    });
    this.cmbContinentViewer.setInput(this.wrapper);
    this.cmbContinentViewer.addSelectionChangedListener(this.selectionProvider);

    this.map = new MapWidget(parent, this.wrapper);
    GridLayout gridLayout = (GridLayout) this.map.getLayout();
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    this.map.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
    this.map.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));

    this.createActions();
    this.initializeToolBar();
    this.initializeMenu();
}

From source file:de.justi.yagw2api.explorer.rcp.wvw.MapDetailsViewPart.java

License:Apache License

/**
 * Create contents of the view part.//w ww  .java  2s .  c  o m
 *
 * @param parent
 */
@Override
public void createPartControl(final Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    container.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    container.setLayout(new GridLayout(2, false));
    {
        CLabel lblMatch = new CLabel(container, SWT.NONE);
        lblMatch.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
        lblMatch.setText("Match");
    }
    {
        this.matchSelectionComboViewer = new ComboViewer(container, SWT.READ_ONLY);
        this.matchSelectionComboViewer.addSelectionChangedListener(this.selectionProvider);
        this.matchSelectionComboViewer
                .setLabelProvider(new TypeSafeViewerLabelProvider<WVWMatch>(WVWMatch.class) {
                    @Override
                    protected String getTypeSafeText(final WVWMatch element) {
                        return element.getRedWorld().getWorldLocation() + ": "
                                + element.getRedWorld().getName().get() + " vs. "
                                + element.getGreenWorld().getName().get() + " vs. "
                                + element.getBlueWorld().getName().get();
                    }
                });
        this.matchSelectionCombo = this.matchSelectionComboViewer.getCombo();
        this.matchSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        this.matchSelectionComboViewer.setContentProvider(new MatchesContentProvider());
        this.matchSelectionComboViewer.setInput(Activator.getDefault().getWVW());
        this.matchSelectionComboViewer.addSelectionChangedListener(this);
    }
    {
        CLabel lblMap = new CLabel(container, SWT.NONE);
        lblMap.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
        lblMap.setText("Map");
    }
    {
        this.mapSelectionComboViewer = new ComboViewer(container, SWT.READ_ONLY);
        this.mapSelectionComboViewer.addSelectionChangedListener(this.selectionProvider);
        this.mapSelectionComboViewer.setLabelProvider(new TypeSafeViewerLabelProvider<WVWMap>(WVWMap.class) {
            @Override
            protected String getTypeSafeText(final WVWMap element) {
                final String fallback = element.getType().getLabel(Activator.getDefault().getLocale())
                        .or(element.getType().toString());
                if (element.getMatch().isPresent()) {
                    if (element.getType().isRed()) {
                        return element.getMatch().get().getRedWorld().getName().or(fallback);
                    } else if (element.getType().isGreen()) {
                        return element.getMatch().get().getGreenWorld().getName().or(fallback);
                    } else if (element.getType().isBlue()) {
                        return element.getMatch().get().getBlueWorld().getName().or(fallback);
                    } else {
                        return fallback;
                    }
                } else {
                    return fallback;
                }
            }
        });
        this.mapSelectionCombo = this.mapSelectionComboViewer.getCombo();
        this.mapSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        this.mapSelectionComboViewer.setContentProvider(new MatchMapsContentProvider());
        this.mapSelectionComboViewer.addSelectionChangedListener(this);
    }
    {
        Composite composite = new Composite(container, SWT.NONE);
        composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
        TableColumnLayout tcl_composite = new TableColumnLayout();
        composite.setLayout(tcl_composite);
        {
            this.mapObjectivesTableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION);
            this.mapObjectivesTable = this.mapObjectivesTableViewer.getTable();
            this.mapObjectivesTable.setHeaderVisible(true);
            this.mapObjectivesTable.setLinesVisible(true);
            {
                TableViewerColumn tableViewerColumn = new TableViewerColumn(this.mapObjectivesTableViewer,
                        SWT.NONE);
                tableViewerColumn.setLabelProvider(new OwningWorldMatchingObjectiveColumnLabelProvider() {
                    @Override
                    protected String getTypeSafeText(final WVWObjective element) {
                        return OBJECTIVE_2_STRING.apply(element);
                    }
                });
                new TypeSafeTableViewerColumnSorter<WVWObjective>(tableViewerColumn, WVWObjective.class) {
                    @Override
                    protected Object getTypeSafeValue(final WVWObjective o) {
                        return OBJECTIVE_2_STRING.apply(o);
                    }
                };
                TableColumn tblclmnName = tableViewerColumn.getColumn();
                tcl_composite.setColumnData(tblclmnName,
                        new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
                tblclmnName.setText("Name");
            }
            {
                TableViewerColumn tableViewerColumn = new TableViewerColumn(this.mapObjectivesTableViewer,
                        SWT.NONE);
                tableViewerColumn.setLabelProvider(new OwningWorldMatchingObjectiveColumnLabelProvider() {
                    @Override
                    protected String getTypeSafeText(final WVWObjective element) {
                        return element.getType().getLabel();
                    }
                });
                new TypeSafeTableViewerColumnSorter<WVWObjective>(tableViewerColumn, WVWObjective.class) {
                    @Override
                    protected Object getTypeSafeValue(final WVWObjective o) {
                        return o.getType().getLabel();
                    }
                };
                TableColumn tblclmnType = tableViewerColumn.getColumn();
                tcl_composite.setColumnData(tblclmnType,
                        new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
                tblclmnType.setText("Type");
            }
            {
                TableViewerColumn tableViewerColumn = new TableViewerColumn(this.mapObjectivesTableViewer,
                        SWT.NONE);
                tableViewerColumn.setLabelProvider(new OwningWorldMatchingObjectiveColumnLabelProvider() {
                    @Override
                    protected String getTypeSafeText(final WVWObjective element) {
                        return String.valueOf(element.getType().getPoints());
                    }

                });
                new TypeSafeTableViewerColumnSorter<WVWObjective>(tableViewerColumn, WVWObjective.class) {
                    @Override
                    protected Object getTypeSafeValue(final WVWObjective o) {
                        return o.getType().getPoints();
                    }
                };
                TableColumn tblclmnValue = tableViewerColumn.getColumn();
                tcl_composite.setColumnData(tblclmnValue,
                        new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
                tblclmnValue.setText("Value");
            }
            {
                TableViewerColumn tableViewerColumn = new TableViewerColumn(this.mapObjectivesTableViewer,
                        SWT.NONE);
                tableViewerColumn.setLabelProvider(new OwningWorldMatchingObjectiveColumnLabelProvider() {
                    @Override
                    protected String getTypeSafeText(final WVWObjective element) {
                        return WORLD_2_STRING.apply(element.getOwner());
                    }
                });
                new TypeSafeTableViewerColumnSorter<WVWObjective>(tableViewerColumn, WVWObjective.class) {
                    @Override
                    protected Object getTypeSafeValue(final WVWObjective o) {
                        return WORLD_2_STRING.apply(o.getOwner());
                    }
                };
                TableColumn tblclmnOwner = tableViewerColumn.getColumn();
                tcl_composite.setColumnData(tblclmnOwner,
                        new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
                tblclmnOwner.setText("Owner");
            }
            {
                TableViewerColumn tableViewerColumn = new TableViewerColumn(this.mapObjectivesTableViewer,
                        SWT.NONE);
                tableViewerColumn.setLabelProvider(new OwningWorldMatchingObjectiveColumnLabelProvider() {
                    @Override
                    protected String getTypeSafeText(final WVWObjective element) {
                        return GUILD_2_STRING.apply(element.getClaimedByGuild());
                    }
                });
                new TypeSafeTableViewerColumnSorter<WVWObjective>(tableViewerColumn, WVWObjective.class) {
                    @Override
                    protected Object getTypeSafeValue(final WVWObjective o) {
                        return GUILD_2_STRING.apply(o.getClaimedByGuild());
                    }
                };
                TableColumn tblclmnClaimed = tableViewerColumn.getColumn();
                tcl_composite.setColumnData(tblclmnClaimed,
                        new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
                tblclmnClaimed.setText("Claimed");
            }
            {
                TableViewerColumn tableViewerColumn = new TableViewerColumn(this.mapObjectivesTableViewer,
                        SWT.NONE);
                tableViewerColumn.setLabelProvider(new OwningWorldMatchingObjectiveColumnLabelProvider() {
                    @Override
                    protected String getTypeSafeText(final WVWObjective element) {
                        return WVWUIConstants.DURATION_FORMAT.apply(Duration
                                .of(element.getRemainingBuffDuration(TimeUnit.SECONDS), ChronoUnit.SECONDS));

                    }
                });
                new TypeSafeTableViewerColumnSorter<WVWObjective>(tableViewerColumn, WVWObjective.class) {
                    @Override
                    protected Object getTypeSafeValue(final WVWObjective o) {
                        return o.getRemainingBuffDuration(TimeUnit.SECONDS);
                    }
                };
                TableColumn tblclmnBuff = tableViewerColumn.getColumn();
                tcl_composite.setColumnData(tblclmnBuff,
                        new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
                tblclmnBuff.setText("Buff");
            }
            this.mapObjectivesTableViewer.setContentProvider(new MapObjectivesContentProvider());
        }
    }

    this.createActions();
    this.initializeToolBar();
    this.initializeMenu();

    this.initializeAutoRefresh();
}

From source file:de.justi.yagw2api.explorer.rcp.wvw.MatchDetailsViewPart.java

License:Apache License

/**
 * Create contents of the view part./*from   www  .ja v a  2s. c  o m*/
 *
 * @param parent
 */
@Override
public void createPartControl(final Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    container.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    container.setLayout(new GridLayout(2, false));
    {
        CLabel lblNewLabel = new CLabel(container, SWT.NONE);
        lblNewLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
        lblNewLabel.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
        lblNewLabel.setText("Match");
    }
    {
        this.matchSelectionComboViewer = new ComboViewer(container, SWT.READ_ONLY);
        this.matchSelectionComboViewer
                .setLabelProvider(new TypeSafeViewerLabelProvider<WVWMatch>(WVWMatch.class) {
                    @Override
                    protected String getTypeSafeText(final WVWMatch element) {
                        return element.getRedWorld().getWorldLocation() + ": "
                                + element.getRedWorld().getName().get() + " vs. "
                                + element.getGreenWorld().getName().get() + " vs. "
                                + element.getBlueWorld().getName().get();
                    }
                });
        this.matchSelectionComboViewer.setContentProvider(this.contentProvider);
        this.matchSelectionComboViewer.setInput(Activator.getDefault().getWVW());
        this.matchSelectionComboViewer.addSelectionChangedListener(this);
        this.matchSelectionComboViewer.addSelectionChangedListener(this.selectionProvider);
        this.matchSelectionCombo = this.matchSelectionComboViewer.getCombo();
        this.matchSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
        {
            Composite composite = new Composite(container, SWT.NONE);
            composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
            TableColumnLayout tcl_composite = new TableColumnLayout();
            composite.setLayout(tcl_composite);
            {
                this.mapsTableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION);
                this.mapsTableViewer.addSelectionChangedListener(this.selectionProvider);
                this.mapsTable = this.mapsTableViewer.getTable();
                this.mapsTable.setHeaderVisible(true);
                this.mapsTable.setLinesVisible(true);
                {
                    TableViewerColumn tableViewerColumn = new TableViewerColumn(this.mapsTableViewer, SWT.NONE);
                    tableViewerColumn.setLabelProvider(new TypeSafeColumnLabelProvider<WVWMap>(WVWMap.class) {
                        @Override
                        public String getTypeSafeText(final WVWMap element) {
                            final String fallback = element.getType()
                                    .getLabel(Activator.getDefault().getLocale())
                                    .or(element.getType().toString());
                            if (element.getMatch().isPresent()) {
                                if (element.getType().isRed()) {
                                    return element.getMatch().get().getRedWorld().getName().or(fallback);
                                } else if (element.getType().isGreen()) {
                                    return element.getMatch().get().getGreenWorld().getName().or(fallback);
                                } else if (element.getType().isBlue()) {
                                    return element.getMatch().get().getBlueWorld().getName().or(fallback);
                                } else {
                                    return fallback;
                                }
                            } else {
                                return fallback;
                            }
                        }

                        @Override
                        protected Color getTypeSafeBackground(final WVWMap element) {
                            if (element.getType().isRed()) {
                                return SWTResourceManager.getColor(WVWUIConstants.RGB_RED_WORLD_BG);
                            } else if (element.getType().isGreen()) {
                                return SWTResourceManager.getColor(WVWUIConstants.RGB_GREEN_WORLD_BG);
                            } else if (element.getType().isBlue()) {
                                return SWTResourceManager.getColor(WVWUIConstants.RGB_BLUE_WORLD_BG);
                            } else {
                                return super.getTypeSafeBackground(element);
                            }
                        }

                        @Override
                        protected Color getTypeSafeForeground(final WVWMap element) {
                            if (element.getType().isRed()) {
                                return SWTResourceManager.getColor(WVWUIConstants.RGB_RED_WORLD_FG);
                            } else if (element.getType().isGreen()) {
                                return SWTResourceManager.getColor(WVWUIConstants.RGB_GREEN_WORLD_FG);
                            } else if (element.getType().isBlue()) {
                                return SWTResourceManager.getColor(WVWUIConstants.RGB_BLUE_WORLD_FG);
                            } else {
                                return super.getTypeSafeForeground(element);
                            }
                        }
                    });
                    new TypeSafeTableViewerColumnSorter<WVWMap>(tableViewerColumn, WVWMap.class) {
                        @Override
                        protected String getTypeSafeValue(final WVWMap o) {
                            return o.getType().toString();
                        }
                    };
                    TableColumn tblclmnMap = tableViewerColumn.getColumn();
                    tcl_composite.setColumnData(tblclmnMap,
                            new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
                    tblclmnMap.setText("Map");
                }
                final TableColumn tblclmnRedpoints;
                final TableColumn tblclmnGreenpoints;
                final TableColumn tblclmnBluepoints;
                final TableColumn tblclmnRedtick;
                final TableColumn tblclmnGreentick;
                final TableColumn tblclmnBluetick;
                {
                    TableViewerColumn tableViewerColumn = new TableViewerColumn(this.mapsTableViewer, SWT.NONE);
                    tableViewerColumn.setLabelProvider(new FixedColoredTypeSafeColumnLabelProvider<WVWMap>(
                            WVWMap.class, WVWUIConstants.RGB_RED_WORLD_BG, WVWUIConstants.RGB_RED_WORLD_FG) {
                        @Override
                        public String getTypeSafeText(final WVWMap element) {
                            return WVWUIConstants.NUMBER_FORMAT_POINTS
                                    .format(element.getScores().getRedScore());
                        }
                    });
                    new TypeSafeTableViewerColumnSorter<WVWMap>(tableViewerColumn, WVWMap.class) {
                        @Override
                        protected Integer getTypeSafeValue(final WVWMap o) {
                            return o.getScores().getRedScore();
                        }
                    };
                    tblclmnRedpoints = tableViewerColumn.getColumn();
                    tcl_composite.setColumnData(tblclmnRedpoints,
                            new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
                    tblclmnRedpoints.setText("Red-Points");
                }
                {
                    TableViewerColumn tableViewerColumn = new TableViewerColumn(this.mapsTableViewer, SWT.NONE);
                    tableViewerColumn
                            .setLabelProvider(new FixedColoredTypeSafeColumnLabelProvider<WVWMap>(WVWMap.class,
                                    WVWUIConstants.RGB_GREEN_WORLD_BG, WVWUIConstants.RGB_GREEN_WORLD_FG) {
                                @Override
                                public String getTypeSafeText(final WVWMap element) {
                                    return WVWUIConstants.NUMBER_FORMAT_POINTS
                                            .format(element.getScores().getGreenScore());
                                }
                            });
                    new TypeSafeTableViewerColumnSorter<WVWMap>(tableViewerColumn, WVWMap.class) {
                        @Override
                        protected Integer getTypeSafeValue(final WVWMap o) {
                            return o.getScores().getGreenScore();
                        }
                    };
                    tblclmnGreenpoints = tableViewerColumn.getColumn();
                    tcl_composite.setColumnData(tblclmnGreenpoints,
                            new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
                    tblclmnGreenpoints.setText("Green-Points");
                }
                {
                    TableViewerColumn tableViewerColumn = new TableViewerColumn(this.mapsTableViewer, SWT.NONE);
                    tableViewerColumn.setLabelProvider(new FixedColoredTypeSafeColumnLabelProvider<WVWMap>(
                            WVWMap.class, WVWUIConstants.RGB_BLUE_WORLD_BG, WVWUIConstants.RGB_BLUE_WORLD_FG) {
                        @Override
                        public String getTypeSafeText(final WVWMap element) {
                            return WVWUIConstants.NUMBER_FORMAT_POINTS
                                    .format(element.getScores().getBlueScore());
                        }
                    });
                    new TypeSafeTableViewerColumnSorter<WVWMap>(tableViewerColumn, WVWMap.class) {
                        @Override
                        protected Integer getTypeSafeValue(final WVWMap o) {
                            return o.getScores().getBlueScore();
                        }
                    };
                    tblclmnBluepoints = tableViewerColumn.getColumn();
                    tcl_composite.setColumnData(tblclmnBluepoints,
                            new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
                    tblclmnBluepoints.setText("Blue-Points");
                }
                {
                    TableViewerColumn tableViewerColumn = new TableViewerColumn(this.mapsTableViewer, SWT.NONE);
                    tableViewerColumn.setLabelProvider(new FixedColoredTypeSafeColumnLabelProvider<WVWMap>(
                            WVWMap.class, WVWUIConstants.RGB_RED_WORLD_BG, WVWUIConstants.RGB_RED_WORLD_FG) {
                        @Override
                        public String getTypeSafeText(final WVWMap element) {
                            return WVWUIConstants.NUMBER_FORMAT_POINTS.format(element.calculateRedTick());
                        }
                    });
                    new TypeSafeTableViewerColumnSorter<WVWMap>(tableViewerColumn, WVWMap.class) {
                        @Override
                        protected Integer getTypeSafeValue(final WVWMap o) {
                            return o.calculateRedTick();
                        }
                    };
                    tblclmnRedtick = tableViewerColumn.getColumn();
                    tcl_composite.setColumnData(tblclmnRedtick,
                            new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
                    tblclmnRedtick.setText("Red-Tick");
                }
                {
                    TableViewerColumn tableViewerColumn = new TableViewerColumn(this.mapsTableViewer, SWT.NONE);
                    tableViewerColumn
                            .setLabelProvider(new FixedColoredTypeSafeColumnLabelProvider<WVWMap>(WVWMap.class,
                                    WVWUIConstants.RGB_GREEN_WORLD_BG, WVWUIConstants.RGB_GREEN_WORLD_FG) {
                                @Override
                                public String getTypeSafeText(final WVWMap element) {
                                    return WVWUIConstants.NUMBER_FORMAT_POINTS
                                            .format(element.calculateGreenTick());
                                }
                            });
                    new TypeSafeTableViewerColumnSorter<WVWMap>(tableViewerColumn, WVWMap.class) {
                        @Override
                        protected Integer getTypeSafeValue(final WVWMap o) {
                            return o.calculateGreenTick();
                        }
                    };
                    tblclmnGreentick = tableViewerColumn.getColumn();
                    tcl_composite.setColumnData(tblclmnGreentick,
                            new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
                    tblclmnGreentick.setText("Green-Tick");
                }
                {
                    TableViewerColumn tableViewerColumn = new TableViewerColumn(this.mapsTableViewer, SWT.NONE);
                    tableViewerColumn.setLabelProvider(new FixedColoredTypeSafeColumnLabelProvider<WVWMap>(
                            WVWMap.class, WVWUIConstants.RGB_BLUE_WORLD_BG, WVWUIConstants.RGB_BLUE_WORLD_FG) {
                        @Override
                        public String getTypeSafeText(final WVWMap element) {
                            return WVWUIConstants.NUMBER_FORMAT_POINTS.format(element.calculateBlueTick());
                        }
                    });
                    new TypeSafeTableViewerColumnSorter<WVWMap>(tableViewerColumn, WVWMap.class) {
                        @Override
                        protected Integer getTypeSafeValue(final WVWMap o) {
                            return o.calculateBlueTick();
                        }
                    };
                    tblclmnBluetick = tableViewerColumn.getColumn();
                    tcl_composite.setColumnData(tblclmnBluetick,
                            new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
                    tblclmnBluetick.setText("Blue-Tick");
                }
                this.mapsTableViewer
                        .setContentProvider(new ContentProvider(tblclmnRedpoints, tblclmnGreenpoints,
                                tblclmnBluepoints, tblclmnRedtick, tblclmnGreentick, tblclmnBluetick));
            }
        }
    }

    this.createActions();
    this.initializeToolBar();
    this.initializeMenu();
}

From source file:de.jwi.ostendoplugin.views.ComboInputDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);

    ComboViewer comboViewer = new ComboViewer(composite, 0);
    comboViewer.add(data);//from   w w w  . j a v  a2  s. co m

    return composite;
}