org.eclipse.swt.widgets.Composite#getStyle ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Composite#getStyle ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: M2Doc   文件: DefinitionValueDialog.java
@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;
}
 
源代码2 项目: M2Doc   文件: GenerationFileNamesPage.java
/**
 * 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;
}
 
源代码3 项目: M2Doc   文件: SelectRegisteredTemplatePage.java
@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);
}
 
源代码4 项目: M2Doc   文件: TemplateCustomPropertiesPage.java
@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");
    }
}
 
源代码5 项目: M2Doc   文件: M2DocOptionDialog.java
@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;
}
 
源代码6 项目: M2Doc   文件: DefinitionValueDialog.java
/**
 * 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;
}
 
源代码7 项目: M2Doc   文件: VariableAndOptionPage.java
@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);
}
 
源代码8 项目: M2Doc   文件: M2DocGenerationPage.java
@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);
}
 
源代码9 项目: M2Doc   文件: M2DocFileSelectionDialog.java
@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;
}
 
源代码10 项目: M2Doc   文件: M2DocTypeSelectionDialog.java
@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;
}
 
源代码11 项目: M2Doc   文件: SelectRegistredTemplateDialog.java
@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;
}
 
源代码12 项目: M2Doc   文件: EObjectSelectionDialog.java
@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;
}
 
源代码13 项目: bonita-studio   文件: ManageJarDialog.java
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);
}
 
源代码14 项目: M2Doc   文件: VariableAndOptionPage.java
/**
 * 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;
}