Java Code Examples for org.eclipse.swt.widgets.Composite#getStyle()

The following examples show how to use org.eclipse.swt.widgets.Composite#getStyle() . 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: DefinitionValueDialog.java    From M2Doc with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Control createCustomArea(Composite parent) {
    final Composite container = new Composite(parent, parent.getStyle());
    container.setLayout(new GridLayout(1, false));
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    if (definition instanceof BooleanDefinition) {
        createBooleanCustomArea((BooleanDefinition) definition, container);
    } else if (definition instanceof IntegerDefinition) {
        createIntegerCustomArea((IntegerDefinition) definition, container);
    } else if (definition instanceof ModelDefinition) {
        final AstValidator validator = new AstValidator(new ValidationServices(queryEnvironment));
        final Set<IType> acceptedTypes = properties.getVariableTypes(validator, queryEnvironment,
                properties.getVariables().get(definition.getKey()));
        createModelCustomArea(acceptedTypes, container);
    } else if (definition instanceof RealDefinition) {
        createRealCustomArea((RealDefinition) definition, container);
    } else if (definition instanceof StringDefinition) {
        createStringCustomArea((StringDefinition) definition, container);
    } else {
        throw new IllegalStateException("don't know what to do with " + definition);
    }

    return container;
}
 
Example 2
Source File: GenerationFileNamesPage.java    From M2Doc with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates the {@link Generation#getDefinitions() destination URI} composite.
 * 
 * @param gen
 *            the {@link Generation}
 * @param composite
 *            the container {@link Composite}
 * @param label
 *            the label
 * @param buttonListener
 *            the {@link Button} {@link Listener}
 * @return the created {@link Text}
 */
private Text createURIComposite(final Generation gen, final Composite composite, String label,
        Listener buttonListener) {
    final Composite uriComposite = new Composite(composite, composite.getStyle());
    uriComposite.setLayout(new GridLayout(3, false));
    uriComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
    final Label uriLabel = new Label(uriComposite, composite.getStyle());
    uriLabel.setText(label);
    final Text uriText = new Text(uriComposite, composite.getStyle());
    uriText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Button uriButton = new Button(uriComposite, SWT.BORDER);
    uriButton.setText("Browse");
    uriButton.addListener(SWT.Selection, buttonListener);

    return uriText;
}
 
Example 3
Source File: SelectRegisteredTemplatePage.java    From M2Doc with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void createControl(Composite parent) {
    final Composite container = new Composite(parent, parent.getStyle());
    setControl(container);
    container.setLayout(new FillLayout(SWT.HORIZONTAL | SWT.VERTICAL));

    final TreeViewer templatesTreeViewer = new TreeViewer(container, SWT.BORDER);
    templatesTreeViewer.setContentProvider(new CollectionContentProvider());
    templatesTreeViewer.setLabelProvider(new ColumnLabelProvider());
    final List<String> registeredTemplates = new ArrayList<>(TemplateRegistry.INSTANCE.getTemplates().keySet());
    Collections.sort(registeredTemplates);
    templatesTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            setSelectedTemplateURI(TemplateRegistry.INSTANCE.getTemplates()
                    .get(((IStructuredSelection) event.getSelection()).getFirstElement()));
            setPageComplete(selectedTemplateURI != null);
        }
    });
    templatesTreeViewer.setInput(registeredTemplates);
    setPageComplete(selectedTemplateURI != null);
}
 
Example 4
Source File: TemplateCustomPropertiesPage.java    From M2Doc with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void createControl(Composite parent) {

    final Composite container = new Composite(parent, parent.getStyle());
    setControl(container);
    container.setLayout(new GridLayout(1, false));

    final TabFolder tabFolder = new TabFolder(container, SWT.BORDER);
    tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    final CheckboxTableViewer tokenViewer = addTokenTabItem(tabFolder, registry, properties);
    addNSURITabItem(tabFolder, tokenViewer, properties);
    addServicesTabItem(tabFolder, tokenViewer, properties);
    if (!M2DocUtils.VERSION.equals(properties.getM2DocVersion())) {
        setMessage("M2Doc version mismatch: template version is " + properties.getM2DocVersion()
            + " and current M2Doc version is " + M2DocUtils.VERSION, IMessageProvider.WARNING);
    } else {
        setMessage("Select services and packages");
    }
}
 
Example 5
Source File: M2DocOptionDialog.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createCustomArea(Composite parent) {
    final Composite container = new Composite(parent, parent.getStyle());
    container.setLayout(new GridLayout(2, false));
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    final ComboViewer combo = new ComboViewer(container, parent.getStyle());
    combo.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    combo.setLabelProvider(new LabelProvider());
    combo.setContentProvider(new CollectionContentProvider());
    combo.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            optionName = (String) ((IStructuredSelection) event.getSelection()).getFirstElement();
        }
    });
    final List<String> possibleOptions = getPossibleOptions(generation, option);

    combo.setInput(possibleOptions);
    combo.setSelection(new StructuredSelection(option.getName()));

    final Text text = new Text(container, SWT.BORDER);
    text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    text.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            optionValue = text.getText();
        }
    });
    if (option.getValue() != null) {
        text.setText(option.getValue());
    }

    return container;
}
 
Example 6
Source File: DefinitionValueDialog.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds a {@link Label} with the {@link Definition#getKey() definition name} and a {@link Text}.
 * 
 * @param def
 *            the {@link Definition}
 * @param container
 *            the container {@link Composite}
 * @return the created {@link Text}.
 */
private Text addLabelAndText(Definition def, Composite container) {
    final Composite composite = new Composite(container, container.getStyle());
    composite.setLayout(new GridLayout(2, false));
    composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    final Label label = new Label(composite, container.getStyle());
    label.setText(def.getKey() + " = ");
    final Text text = new Text(composite, container.getStyle());
    text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    return text;
}
 
Example 7
Source File: VariableAndOptionPage.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createControl(Composite parent) {

    final Composite container = new Composite(parent, parent.getStyle());
    setControl(container);
    container.setLayout(new GridLayout(1, false));

    final TabFolder tabFolder = new TabFolder(container, SWT.BORDER);
    tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    final TabItem variableTabItem = new TabItem(tabFolder, tabFolder.getStyle());
    variableTabItem.setText("Variables");
    final Composite variableContainer = new Composite(tabFolder, tabFolder.getStyle());
    variableTabItem.setControl(variableContainer);
    variablesTable = createVariablesTable(generation, variableContainer, adapterFactory,
            templateCustomPropertiesProvider);
    generationListener.setVariablesViewer(variablesTable);
    createVariablesButonComposite(generation, variableContainer, variablesTable);

    final TabItem optionTabItem = new TabItem(tabFolder, tabFolder.getStyle());
    optionTabItem.setText("Options (expert)");
    final Composite optionContainer = new Composite(tabFolder, tabFolder.getStyle());
    optionTabItem.setControl(optionContainer);
    optionContainer.setLayout(new GridLayout(2, false));
    optionsTable = createOptionsTable(generation, optionContainer);
    generationListener.setOptionsViewer(optionsTable);
    createOptionsButonComposite(generation, optionContainer, optionsTable);
    initializeGenerationVariableDefinition(generation);
}
 
Example 8
Source File: M2DocGenerationPage.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createControl(Composite parent) {
    final Composite pageComposite = new Composite(parent, parent.getStyle());
    pageComposite.setLayout(new GridLayout(1, false));

    generationNameText = createGenerationNameComposite(pageComposite);
    destinationNameText = createDestinationNameComposite(pageComposite);
    validationNameText = createValidationNameComposite(pageComposite);
    createLaunchGenerationComposite(pageComposite);

    validatePage();

    setControl(pageComposite);
}
 
Example 9
Source File: M2DocFileSelectionDialog.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createCustomArea(Composite parent) {
    final Composite container = new Composite(parent, parent.getStyle());
    container.setLayout(new GridLayout(1, false));
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    fileText = createFilePathComposite(container, defaultFileName);

    final TreeViewer containerTreeViewer = new TreeViewer(container, SWT.BORDER);
    Tree tree = containerTreeViewer.getTree();
    final GridData gdTable = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gdTable.minimumWidth = TABLE_MINIMUM_WIDTH;
    gdTable.minimumHeight = TABLE_MINIMUM_HEIGHT;
    tree.setLayoutData(gdTable);
    containerTreeViewer.setContentProvider(new WorkbenchContentProvider() {
        @Override
        public Object[] getChildren(Object element) {
            final List<Object> res = new ArrayList<>();
            for (Object obj : super.getChildren(element)) {
                if (obj instanceof IContainer
                    || (obj instanceof IFile && fileExtension.equals(((IFile) obj).getFileExtension()))) {
                    res.add(obj);
                }
            }
            return res.toArray();
        }
    });
    containerTreeViewer.setLabelProvider(new WorkbenchLabelProvider());
    containerTreeViewer.addSelectionChangedListener(new ContainerSelectionChangedListener());
    containerTreeViewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
    if (defaultFileName != null && !defaultFileName.isEmpty()) {
        final IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(defaultFileName));
        containerTreeViewer.setSelection(new StructuredSelection(file));
    }

    return container;
}
 
Example 10
Source File: M2DocTypeSelectionDialog.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createCustomArea(Composite parent) {
    final Composite container = new Composite(parent, parent.getStyle());
    container.setLayout(new GridLayout(1, false));
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    final FilteredTree filteredTree = new FilteredTree(container, SWT.BORDER, new PatternFilter(), true);
    final TreeViewer treeViewer = filteredTree.getViewer();
    final Tree tree = treeViewer.getTree();
    final GridData gdTable = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gdTable.minimumWidth = TABLE_MINIMUM_WIDTH;
    gdTable.minimumHeight = TABLE_MINIMUM_HEIGHT;
    tree.setLayoutData(gdTable);
    treeViewer.setContentProvider(new CollectionContentProvider());
    treeViewer.setLabelProvider(new LabelProvider());
    treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            final Object selected = ((IStructuredSelection) event.getSelection()).getFirstElement();
            selectedType = (String) selected;
        }
    });
    treeViewer.setInput(getAvailableTypes(nsURIs));
    if (defaultType != null) {
        treeViewer.setSelection(new StructuredSelection(defaultType));
    }

    return container;
}
 
Example 11
Source File: SelectRegistredTemplateDialog.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createCustomArea(Composite parent) {
    final Composite container = new Composite(parent, parent.getStyle());
    container.setLayout(new GridLayout(1, false));
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    final TableViewer templatesTreeViewer = new TableViewer(container, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    Table table = templatesTreeViewer.getTable();
    final GridData gdTable = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gdTable.minimumWidth = TABLE_MINIMUM_WIDTH;
    gdTable.minimumHeight = TABLE_MINIMUM_HEIGHT;
    table.setLayoutData(gdTable);
    templatesTreeViewer.setContentProvider(new CollectionContentProvider());
    templatesTreeViewer.setLabelProvider(new ColumnLabelProvider());
    final List<String> registeredTemplates = new ArrayList<>(TemplateRegistry.INSTANCE.getTemplates().keySet());
    Collections.sort(registeredTemplates);
    templatesTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            templateURI = TemplateRegistry.INSTANCE.getTemplates()
                    .get(((IStructuredSelection) event.getSelection()).getFirstElement());
        }
    });
    templatesTreeViewer.setInput(registeredTemplates);

    return container;
}
 
Example 12
Source File: EObjectSelectionDialog.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createCustomArea(Composite parent) {
    final Composite container = new Composite(parent, parent.getStyle());
    container.setLayout(new GridLayout(1, false));
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    final Set<IType> acceptedTypes = new HashSet<>();
    for (EClass eCls : acceptedEClasses) {
        acceptedTypes.add(new EClassifierType(queryEnvironment, eCls));
    }
    createModelCustomArea(acceptedTypes, container);

    return container;
}
 
Example 13
Source File: ManageJarDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createLeftButtonPanel(final Composite composite) {
    final Composite leftPanel = new Composite(composite, composite.getStyle());
    leftPanel.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    leftPanel.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).spacing(0, 3).create());
    addImportJarButton(leftPanel);
    addRemoveJarButton(leftPanel);
}
 
Example 14
Source File: VariableAndOptionPage.java    From M2Doc with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Creates the {@link Generation#getOptions() options} {@link TableViewer}.
 * 
 * @param gen
 *            the {@link Generation}
 * @param composite
 *            the container {@link Composite}
 * @param factory
 *            the {@link AdapterFactory}
 * @param provider
 *            the {@link ITemplateCustomPropertiesProvider}
 * @return the created {@link TableViewer}
 */
private TableViewer createVariablesTable(final Generation gen, Composite composite, AdapterFactory factory,
        ITemplateCustomPropertiesProvider provider) {
    composite.setLayout(new GridLayout(2, false));
    TableViewer res = new TableViewer(composite, SWT.MULTI);
    Table table = res.getTable();
    table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    res.getTable().setHeaderVisible(true);
    TableViewerColumn nameColumn = new TableViewerColumn(res, composite.getStyle());
    nameColumn.getColumn().setText("Variable name");
    nameColumn.getColumn().setWidth(WIDTH);
    TableViewerColumn valueColumn = new TableViewerColumn(res, composite.getStyle());
    valueColumn.getColumn().setText("Variable value");
    valueColumn.getColumn().setWidth(WIDTH);
    res.setContentProvider(new IStructuredContentProvider() {

        @Override
        public Object[] getElements(Object inputElement) {
            return ((Generation) inputElement).getDefinitions().toArray();
        }

        @Override
        public void dispose() {
            // nothing to do here
        }

        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            // nothing to do here
        }

    });
    nameColumn.setLabelProvider(new CellLabelProvider() {
        @Override
        public void update(ViewerCell cell) {
            final Definition definition = (Definition) cell.getElement();
            cell.setText(definition.getKey());
        }
    });
    valueColumn.setLabelProvider(new VariableValueCellLabelProvider(factory));

    res.setInput(gen);

    return res;
}