Search in sources :

Example 71 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project liferay-ide by liferay.

the class WorkingSetGroup method _createControl.

private void _createControl(Composite container) {
    addToWorkingSetButton = new Button(container, SWT.CHECK);
    GridData gd_addToWorkingSetButton = new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1);
    gd_addToWorkingSetButton.verticalIndent = 12;
    addToWorkingSetButton.setLayoutData(gd_addToWorkingSetButton);
    addToWorkingSetButton.setSelection(true);
    addToWorkingSetButton.setData("name", "addToWorkingSetButton");
    addToWorkingSetButton.setText("Add project to working set");
    addToWorkingSetButton.setSelection(false);
    final Label workingsetLabel = new Label(container, SWT.NONE);
    GridData gd_workingsetLabel = new GridData();
    gd_workingsetLabel.horizontalIndent = 10;
    workingsetLabel.setLayoutData(gd_workingsetLabel);
    workingsetLabel.setEnabled(false);
    workingsetLabel.setData("name", "workingsetLabel");
    workingsetLabel.setText("Working set:");
    Combo workingsetCombo = new Combo(container, SWT.READ_ONLY);
    workingsetCombo.setEnabled(false);
    workingsetCombo.setData("name", "workingsetCombo");
    workingsetCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    _workingsetComboViewer = new ComboViewer(workingsetCombo);
    _workingsetComboViewer.setContentProvider(new IStructuredContentProvider() {

        public void dispose() {
        }

        public Object[] getElements(Object input) {
            if (input instanceof IWorkingSet[]) {
                return (IWorkingSet[]) input;
            } else if (input instanceof List<?>) {
                return new Object[] { input };
            } else if (input instanceof Set<?>) {
                return ((Set<?>) input).toArray();
            }
            return new IWorkingSet[0];
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
    });
    _workingsetComboViewer.setLabelProvider(new LabelProvider() {

        public void dispose() {
            _images.dispose();
            super.dispose();
        }

        @SuppressWarnings("deprecation")
        public Image getImage(Object element) {
            if (element instanceof IWorkingSet) {
                ImageDescriptor imageDescriptor = ((IWorkingSet) element).getImage();
                if (imageDescriptor != null) {
                    try {
                        return (Image) _images.create(imageDescriptor);
                    } catch (DeviceResourceException dre) {
                        return null;
                    }
                }
            }
            return super.getImage(element);
        }

        public String getText(Object element) {
            if (element instanceof IWorkingSet) {
                return ((IWorkingSet) element).getLabel();
            } else if (element instanceof List<?>) {
                StringBuffer sb = new StringBuffer();
                for (Object o : (List<?>) element) {
                    if (o instanceof IWorkingSet) {
                        if (sb.length() > 0) {
                            sb.append(", ");
                        }
                        sb.append(((IWorkingSet) o).getLabel());
                    }
                }
                return sb.toString();
            }
            return super.getText(element);
        }

        private ResourceManager _images = new LocalResourceManager(JFaceResources.getResources());
    });
    _workingsetComboViewer.setComparator(new ViewerComparator());
    final Button newWorkingSetButton = new Button(container, SWT.NONE);
    newWorkingSetButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    newWorkingSetButton.setData("name", "configureButton");
    newWorkingSetButton.setText("More...");
    newWorkingSetButton.setEnabled(false);
    newWorkingSetButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(final SelectionEvent e) {
            IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
            IWorkingSetSelectionDialog dialog = workingSetManager.createWorkingSetSelectionDialog(_shell, true, _working_set_ids.toArray(new String[0]));
            if (dialog.open() == Window.OK) {
                IWorkingSet[] workingSets = dialog.getSelection();
                selectWorkingSets(Arrays.asList(workingSets));
            }
        }
    });
    if (selectWorkingSets(_workingSets)) {
        addToWorkingSetButton.setSelection(true);
        workingsetLabel.setEnabled(true);
        _workingsetComboViewer.getCombo().setEnabled(true);
        newWorkingSetButton.setEnabled(true);
    }
    addToWorkingSetButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            boolean addToWorkingingSet = addToWorkingSetButton.getSelection();
            workingsetLabel.setEnabled(addToWorkingingSet);
            _workingsetComboViewer.getCombo().setEnabled(addToWorkingingSet);
            newWorkingSetButton.setEnabled(addToWorkingingSet);
            if (addToWorkingingSet) {
                updateConfiguration();
            } else {
                _workingSets.clear();
            }
        }
    });
    _workingsetComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            updateConfiguration();
        }
    });
}
Also used : LocalResourceManager(org.eclipse.jface.resource.LocalResourceManager) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Image(org.eclipse.swt.graphics.Image) Button(org.eclipse.swt.widgets.Button) DeviceResourceException(org.eclipse.jface.resource.DeviceResourceException) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IWorkingSetManager(org.eclipse.ui.IWorkingSetManager) IWorkingSetSelectionDialog(org.eclipse.ui.dialogs.IWorkingSetSelectionDialog) List(java.util.List) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) IWorkingSet(org.eclipse.ui.IWorkingSet) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ResourceManager(org.eclipse.jface.resource.ResourceManager) LocalResourceManager(org.eclipse.jface.resource.LocalResourceManager) ComboViewer(org.eclipse.jface.viewers.ComboViewer) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 72 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project mdw-designer by CenturyLinkCloud.

the class ProcessExplorerActionGroup method createFilterToolbarAction.

private IAction createFilterToolbarAction() {
    IAction action = new Action() {

        @Override
        public void run() {
            IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
            List<String> options = new ArrayList<>();
            options.add(PreferenceConstants.PREFS_FILTER_PROCESSES_IN_PEX);
            options.add(PreferenceConstants.PREFS_FILTER_WORKFLOW_ASSETS_IN_PEX);
            options.add(PreferenceConstants.PREFS_FILTER_EVENT_HANDLERS_IN_PEX);
            options.add(PreferenceConstants.PREFS_SHOW_ACTIVITY_IMPLEMENTORS_IN_PEX);
            options.add(PreferenceConstants.PREFS_FILTER_TASK_TEMPLATES_IN_PEX);
            options.add(PreferenceConstants.PREFS_FILTER_ARCHIVED_ITEMS_IN_PEX);
            List<String> selected = new ArrayList<>();
            for (String option : options) {
                boolean show = !prefsStore.getBoolean(option);
                if (option.startsWith("Show"))
                    // means default is filtered
                    show = !show;
                if (show)
                    selected.add(option);
            }
            ListSelectionDialog lsd = new ListSelectionDialog(view.getSite().getShell(), options, new IStructuredContentProvider() {

                public Object[] getElements(Object inputElement) {
                    return ((List<?>) inputElement).toArray(new String[0]);
                }

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

                @Override
                public void dispose() {
                // do nothing
                }
            }, new ILabelProvider() {

                public void addListener(ILabelProviderListener listener) {
                // do nothing
                }

                public void removeListener(ILabelProviderListener listener) {
                // do nothing
                }

                public boolean isLabelProperty(Object element, String property) {
                    return false;
                }

                public void dispose() {
                // do nothing
                }

                public Image getImage(Object element) {
                    return null;
                }

                public String getText(Object element) {
                    if (PreferenceConstants.PREFS_FILTER_PROCESSES_IN_PEX.equals(element))
                        return "Processes";
                    else if (PreferenceConstants.PREFS_FILTER_WORKFLOW_ASSETS_IN_PEX.equals(element))
                        return "Assets";
                    else if (PreferenceConstants.PREFS_FILTER_EVENT_HANDLERS_IN_PEX.equals(element))
                        return "Event Handlers";
                    else if (PreferenceConstants.PREFS_SHOW_ACTIVITY_IMPLEMENTORS_IN_PEX.equals(element))
                        return "Activity Implementors";
                    else if (PreferenceConstants.PREFS_FILTER_TASK_TEMPLATES_IN_PEX.equals(element))
                        return "Task Templates";
                    else if (PreferenceConstants.PREFS_FILTER_ARCHIVED_ITEMS_IN_PEX.equals(element))
                        return "Archived Items";
                    else
                        return null;
                }
            }, "Workflow elements to display in Process Explorer");
            lsd.setTitle("Show Package Contents");
            lsd.setInitialSelections(selected.toArray(new String[0]));
            int res = lsd.open();
            if (res != Dialog.CANCEL) {
                Object[] results = lsd.getResult();
                for (String option : options) {
                    boolean show = false;
                    for (Object result : results) {
                        if (option.equals(result))
                            show = true;
                    }
                    if (option.startsWith("Filter"))
                        // default is to show
                        show = !show;
                    prefsStore.setValue(option, show);
                }
                view.handleApply();
            }
        }
    };
    action.setText("Filter Package Contents");
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "filter.package.contents");
    ImageDescriptor sortImageDesc = MdwPlugin.getImageDescriptor("icons/filter.gif");
    action.setImageDescriptor(sortImageDesc);
    return action;
}
Also used : WebLaunchAction(com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction) IAction(org.eclipse.jface.action.IAction) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) ArrayList(java.util.ArrayList) Viewer(org.eclipse.jface.viewers.Viewer) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) Image(org.eclipse.swt.graphics.Image) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ListSelectionDialog(org.eclipse.ui.dialogs.ListSelectionDialog)

Example 73 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project tmdm-studio-se by Talend.

the class XSDEditElementAction method doAction.

@Override
public IStatus doAction() {
    try {
        ISelection selection = page.getTreeViewer().getSelection();
        XSDElementDeclaration decl = (XSDElementDeclaration) ((IStructuredSelection) selection).getFirstElement();
        ArrayList<Object> objList = new ArrayList<Object>();
        IStructuredContentProvider provider = (IStructuredContentProvider) page.getTreeViewer().getContentProvider();
        String oldName = decl.getName();
        InputDialog id = new InputDialog(page.getSite().getShell(), Messages.XSDEditElementAction_EditElement, Messages.XSDEditElementAction_EnterNameForElement, oldName, new EditXSDEleDecNameValidator(schema));
        id.setBlockOnOpen(true);
        int ret = id.open();
        if (ret == Window.CANCEL) {
            return Status.CANCEL_STATUS;
        }
        Object[] objs = Util.getAllObject(page.getSite(), objList, provider);
        Object[] allForeignKeyRelatedInfos = Util.getAllForeignKeyRelatedInfos(page.getSite(), new ArrayList<Object>(), provider, new HashSet<Object>());
        decl.setName(id.getValue());
        decl.updateElement();
        Util.updateReference(decl, objs, allForeignKeyRelatedInfos, oldName, id.getValue());
        // change unique key with new name of concept
        EList list = decl.getIdentityConstraintDefinitions();
        XSDIdentityConstraintDefinition toUpdate = null;
        for (Iterator iter = list.iterator(); iter.hasNext(); ) {
            XSDIdentityConstraintDefinition icd = (XSDIdentityConstraintDefinition) iter.next();
            if (icd.getName().equals(oldName)) {
                toUpdate = icd;
                break;
            }
        }
        if (toUpdate != null) {
            toUpdate.setName(id.getValue());
            toUpdate.updateElement();
        }
        page.refresh();
        page.markDirty();
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(page.getSite().getShell(), Messages._Error, Messages.bind(Messages.XSDEditElementAction_ErrorEditElement, e.getLocalizedMessage()));
        return Status.CANCEL_STATUS;
    }
    return Status.OK_STATUS;
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) ArrayList(java.util.ArrayList) EditXSDEleDecNameValidator(com.amalto.workbench.utils.inputvalidator.EditXSDEleDecNameValidator) EList(org.eclipse.emf.common.util.EList) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) Iterator(java.util.Iterator) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition)

Example 74 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project tmdm-studio-se by Talend.

the class XSDEditParticleAction method updateReference.

private void updateReference(String originalXpath) {
    XSDElementDeclaration decl = (XSDElementDeclaration) selParticle.getContent();
    // $NON-NLS-1$
    int lastIndex = originalXpath.lastIndexOf("/");
    String newXpath = decl.getName();
    newXpath = originalXpath.substring(0, lastIndex + 1) + newXpath;
    IStructuredContentProvider provider = (IStructuredContentProvider) page.getTreeViewer().getContentProvider();
    Object[] allForeignKeyRelatedInfos = Util.getAllForeignKeyRelatedInfos(page.getSite(), new ArrayList<Object>(), provider, new HashSet<Object>());
    Util.updateForeignKeyRelatedInfo(originalXpath, newXpath, allForeignKeyRelatedInfos);
}
Also used : XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider)

Example 75 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project tmdm-studio-se by Talend.

the class XSDDeleteConceptAction method isCommonReferedBy.

private boolean isCommonReferedBy(XSDElementDeclaration decl) {
    List<Object> objList = new ArrayList<Object>();
    IStructuredContentProvider elementContentProvider = (IStructuredContentProvider) page.getTreeViewer().getContentProvider();
    Object[] objs = Util.getAllObject(page.getSite(), objList, elementContentProvider);
    objList.clear();
    IStructuredContentProvider typeContentProvider = (IStructuredContentProvider) page.getTypesViewer().getContentProvider();
    Object[] typeElems = Util.getAllObject(page.getSite(), objList, typeContentProvider);
    boolean referencedBy = Util.isReferencedBy(decl, objs) || Util.isReferencedBy(decl, typeElems);
    return referencedBy;
}
Also used : ArrayList(java.util.ArrayList) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider)

Aggregations

IStructuredContentProvider (org.eclipse.jface.viewers.IStructuredContentProvider)99 Viewer (org.eclipse.jface.viewers.Viewer)77 Composite (org.eclipse.swt.widgets.Composite)58 GridData (org.eclipse.swt.layout.GridData)54 TableViewer (org.eclipse.jface.viewers.TableViewer)45 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)43 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)42 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)40 GridLayout (org.eclipse.swt.layout.GridLayout)40 LabelProvider (org.eclipse.jface.viewers.LabelProvider)32 Image (org.eclipse.swt.graphics.Image)29 Button (org.eclipse.swt.widgets.Button)28 Label (org.eclipse.swt.widgets.Label)28 SelectionEvent (org.eclipse.swt.events.SelectionEvent)26 Table (org.eclipse.swt.widgets.Table)24 ArrayList (java.util.ArrayList)23 ComboViewer (org.eclipse.jface.viewers.ComboViewer)19 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)19 ILabelProviderListener (org.eclipse.jface.viewers.ILabelProviderListener)18 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)18