Search in sources :

Example 1 with SchemaRoleAccessFilter

use of com.amalto.workbench.providers.datamodel.SchemaRoleAccessFilter in project tmdm-studio-se by Talend.

the class DataModelMainPage method createTypeTreeComp.

private void createTypeTreeComp(Composite parent) {
    Composite TypeSash = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = 0;
    TypeSash.setLayout(layout);
    TypeSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    TypeSash.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    Composite compInfo = new Composite(TypeSash, SWT.NONE);
    layout = new GridLayout();
    layout.verticalSpacing = 0;
    compInfo.setLayout(layout);
    compInfo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    compInfo.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    Composite compTypeTree = new Composite(TypeSash, SWT.NONE);
    GridLayout glCompTypeTree = new GridLayout();
    glCompTypeTree.verticalSpacing = 0;
    glCompTypeTree.marginWidth = 0;
    glCompTypeTree.marginHeight = 0;
    glCompTypeTree.horizontalSpacing = 0;
    compTypeTree.setLayout(glCompTypeTree);
    compTypeTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    compTypeTree.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    Label title = new Label(compInfo, SWT.VERTICAL);
    title.setText(Messages.DataModelTypes);
    title.setFont(FontUtils.getBoldFont(title.getFont()));
    Color blue = new Color(compInfo.getDisplay(), 0, 0, 255);
    title.setForeground(blue);
    title.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    ToolBar toolBarTypeTree = createToolbarOnComposite(compTypeTree);
    typesViewer = new TreeViewer(compTypeTree, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    typesViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    addToolItems2TypeTreeToolBar(toolBarTypeTree);
    toolBarTypeTree.pack();
    typesTreeContentProvider = new TypesTreeContentProvider(this.getSite(), xsdSchema);
    typesViewer.setContentProvider(typesTreeContentProvider);
    typesViewer.setFilters(new ViewerFilter[] { new SchemaRoleAccessFilter(null), new TypeNameFilter() });
    typesViewer.getTree().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent e) {
            isSchemaSelected = false;
        }
    });
    typesViewer.setLabelProvider(new TypesLabelProvider());
    typesViewer.setSorter(typeTreeSorter);
    // getViewSite());
    typesViewer.setInput(this.getSite());
    typesViewer.getTree().addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (isReadOnly()) {
                return;
            }
            IStructuredSelection selection = ((IStructuredSelection) typesViewer.getSelection());
            // delete
            if ((e.stateMask == 0) && (e.keyCode == SWT.DEL)) {
                deleteConceptWrapAction.regisExtraClassToDel(XSDComplexTypeDefinitionImpl.class);
                if (deleteConceptWrapAction.checkInDeletableType(selection.toArray())) {
                    deleteConceptWrapAction.prepareToDelSelectedItems(selection, viewer);
                    deleteConceptWrapAction.run();
                } else {
                    deleteConceptWrapAction.clearExtraClassToDel();
                    deleteConceptWrapAction.regisExtraClassToDel(XSDSimpleTypeDefinitionImpl.class);
                    if (deleteConceptWrapAction.checkInDeletableType(selection.toArray())) {
                        deleteConceptWrapAction.prepareToDelSelectedItems(selection, viewer);
                        deleteConceptWrapAction.run();
                    } else {
                        MessageDialog.openWarning(getSite().getShell(), Messages.Warning, Messages.SelectDeletableTry);
                    }
                }
            }
        }
    });
}
Also used : XSDSimpleTypeDefinitionImpl(org.eclipse.xsd.impl.XSDSimpleTypeDefinitionImpl) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) DescAnnotationComposite(com.amalto.workbench.widgets.DescAnnotationComposite) TypeNameFilter(com.amalto.workbench.providers.datamodel.TypeNameFilter) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Color(org.eclipse.swt.graphics.Color) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) TypesLabelProvider(com.amalto.workbench.providers.TypesLabelProvider) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TypesTreeContentProvider(com.amalto.workbench.providers.datamodel.TypesTreeContentProvider) XSDComplexTypeDefinitionImpl(org.eclipse.xsd.impl.XSDComplexTypeDefinitionImpl) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) SchemaRoleAccessFilter(com.amalto.workbench.providers.datamodel.SchemaRoleAccessFilter) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar)

Example 2 with SchemaRoleAccessFilter

use of com.amalto.workbench.providers.datamodel.SchemaRoleAccessFilter in project tmdm-studio-se by Talend.

the class DataModelMainPage method createSchemaTreeComp.

private void createSchemaTreeComp(Composite parent) {
    Composite schemaSash = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = 0;
    schemaSash.setLayout(layout);
    schemaSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    schemaSash.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    Composite compInfo = new Composite(schemaSash, SWT.NONE);
    layout = new GridLayout();
    layout.verticalSpacing = 0;
    compInfo.setLayout(layout);
    compInfo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    compInfo.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    Composite compSchemaTree = new Composite(schemaSash, SWT.NONE);
    GridLayout glCompSchemaTree = new GridLayout();
    glCompSchemaTree.verticalSpacing = 0;
    glCompSchemaTree.marginWidth = 0;
    glCompSchemaTree.marginHeight = 0;
    glCompSchemaTree.horizontalSpacing = 0;
    compSchemaTree.setLayout(glCompSchemaTree);
    compSchemaTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    compSchemaTree.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    Label title = new Label(compInfo, SWT.VERTICAL);
    title.setText(Messages.DataModelEntities);
    title.setFont(FontUtils.getBoldFont(title.getFont()));
    Color blue = new Color(compInfo.getDisplay(), 0, 0, 255);
    title.setForeground(blue);
    title.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    ToolBar toolBarSchemaTree = createToolbarOnComposite(compSchemaTree);
    viewer = new TreeViewer(compSchemaTree, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    addToolItems2SchemaTreeToolBar(toolBarSchemaTree);
    toolBarSchemaTree.pack();
    drillDownAdapter = new DrillDownAdapter(viewer);
    schemaTreeContentProvider = new SchemaTreeContentProvider(this.getSite(), xsdSchema);
    viewer.setContentProvider(schemaTreeContentProvider);
    viewer.setFilters(new ViewerFilter[] { new SchemaRoleAccessFilter(null), new SchemaNameFilter(), new SchemaUniqueElementFilter() });
    viewer.getTree().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent e) {
            isSchemaSelected = true;
        }
    });
    viewer.setLabelProvider(new XSDTreeLabelProvider());
    viewer.setSorter(schemaTreeSorter);
    // getViewSite());
    viewer.setInput(this.getSite());
    viewer.getTree().addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (isReadOnly()) {
                return;
            }
            IStructuredSelection selection = ((IStructuredSelection) viewer.getSelection());
            // delete
            if ((e.stateMask == 0) && (e.keyCode == SWT.DEL)) {
                if (deleteConceptWrapAction.checkInDeletableType(selection.toArray())) {
                    deleteConceptWrapAction.prepareToDelSelectedItems(selection, viewer);
                    deleteConceptWrapAction.run();
                } else {
                    MessageDialog.openWarning(getSite().getShell(), Messages.Warning, Messages.SelectDeletableTry);
                }
            }
        }
    });
    viewer.setComparer(new ElementComparer());
}
Also used : DrillDownAdapter(org.eclipse.ui.part.DrillDownAdapter) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) DescAnnotationComposite(com.amalto.workbench.widgets.DescAnnotationComposite) XSDTreeLabelProvider(com.amalto.workbench.providers.XSDTreeLabelProvider) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IElementComparer(org.eclipse.jface.viewers.IElementComparer) Color(org.eclipse.swt.graphics.Color) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) SchemaNameFilter(com.amalto.workbench.providers.datamodel.SchemaNameFilter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SchemaTreeContentProvider(com.amalto.workbench.providers.datamodel.SchemaTreeContentProvider) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) SchemaRoleAccessFilter(com.amalto.workbench.providers.datamodel.SchemaRoleAccessFilter) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SchemaUniqueElementFilter(com.amalto.workbench.providers.datamodel.SchemaUniqueElementFilter)

Aggregations

SchemaRoleAccessFilter (com.amalto.workbench.providers.datamodel.SchemaRoleAccessFilter)2 DescAnnotationComposite (com.amalto.workbench.widgets.DescAnnotationComposite)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2 KeyAdapter (org.eclipse.swt.events.KeyAdapter)2 KeyEvent (org.eclipse.swt.events.KeyEvent)2 MouseAdapter (org.eclipse.swt.events.MouseAdapter)2 MouseEvent (org.eclipse.swt.events.MouseEvent)2 Color (org.eclipse.swt.graphics.Color)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 Label (org.eclipse.swt.widgets.Label)2 ToolBar (org.eclipse.swt.widgets.ToolBar)2 TypesLabelProvider (com.amalto.workbench.providers.TypesLabelProvider)1 XSDTreeLabelProvider (com.amalto.workbench.providers.XSDTreeLabelProvider)1 SchemaNameFilter (com.amalto.workbench.providers.datamodel.SchemaNameFilter)1 SchemaTreeContentProvider (com.amalto.workbench.providers.datamodel.SchemaTreeContentProvider)1 SchemaUniqueElementFilter (com.amalto.workbench.providers.datamodel.SchemaUniqueElementFilter)1 TypeNameFilter (com.amalto.workbench.providers.datamodel.TypeNameFilter)1