Search in sources :

Example 56 with IStructuredContentProvider

use of org.eclipse.jface.viewers.IStructuredContentProvider in project knime-core by knime.

the class CredentialVariableTable method createViewer.

private TableViewer createViewer(final Composite parent) {
    TableViewer viewer = new TableViewer(parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    TableViewerColumn nameCol = new TableViewerColumn(viewer, SWT.NONE);
    nameCol.getColumn().setText(VAR_NAME);
    nameCol.getColumn().setWidth(100);
    TableViewerColumn loginCol = new TableViewerColumn(viewer, SWT.NONE);
    loginCol.getColumn().setText(VAR_LOGIN);
    loginCol.getColumn().setWidth(100);
    TableViewerColumn typeCol = new TableViewerColumn(viewer, SWT.NONE);
    typeCol.getColumn().setText(VAR_PASSWORD);
    typeCol.getColumn().setWidth(100);
    viewer.getTable().setHeaderVisible(true);
    viewer.getTable().setLinesVisible(true);
    viewer.setContentProvider(new IStructuredContentProvider() {

        @Override
        public Object[] getElements(final Object arg) {
            return ((List<Credentials>) arg).toArray();
        }

        @Override
        public void dispose() {
        // do nothing -> images are static
        }

        @Override
        public void inputChanged(final Viewer arg0, final Object arg1, final Object arg2) {
        // do nothing
        }
    });
    viewer.setLabelProvider(new WorkflowVariableLabelProvider());
    viewer.setInput(m_params);
    return viewer;
}
Also used : IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) Credentials(org.knime.core.node.workflow.Credentials)

Example 57 with IStructuredContentProvider

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

the class ElementWrapperCommitHandler method updateReference.

private void updateReference(String originalName) {
    DataModelMainPage page = getPage();
    String modifiedXpath = getModifiedXpath(page);
    if (modifiedXpath != null && !modifiedXpath.isEmpty()) {
        // $NON-NLS-1$
        int lastIndex = modifiedXpath.lastIndexOf("/");
        String originalXpath = originalName;
        originalXpath = modifiedXpath.substring(0, lastIndex + 1) + originalXpath;
        IStructuredContentProvider provider = (IStructuredContentProvider) page.getTreeViewer().getContentProvider();
        Object[] allForeignKeyRelatedInfos = Util.getAllForeignKeyRelatedInfos(page.getSite(), new ArrayList<Object>(), provider, new HashSet<Object>());
        Util.updateForeignKeyRelatedInfo(originalXpath, modifiedXpath, allForeignKeyRelatedInfos);
    }
}
Also used : DataModelMainPage(com.amalto.workbench.editors.DataModelMainPage) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider)

Example 58 with IStructuredContentProvider

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

the class MenuEntryDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    // Should not really be here but well,....
    parent.getShell().setText(this.title);
    Composite composite = (Composite) super.createDialogArea(parent);
    GridLayout layout = (GridLayout) composite.getLayout();
    layout.numColumns = 3;
    // layout.verticalSpacing = 10;
    Label idLabel = new Label(composite, SWT.NONE);
    idLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    idLabel.setText(Messages.MenuEntryDialog_Id);
    if (this.isChanged) {
        idText = new Text(composite, SWT.NONE);
    } else {
        idText = new Text(composite, SWT.NONE | SWT.READ_ONLY);
    }
    idText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    ((GridData) idText.getLayoutData()).widthHint = 300;
    idText.setDoubleClickEnabled(false);
    Label contextLabel = new Label(composite, SWT.NONE);
    contextLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    contextLabel.setText(Messages.MenuEntryDialog_Context);
    contextText = new Text(composite, SWT.NONE);
    contextText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    contextText.setDoubleClickEnabled(false);
    Label applicationNameLabel = new Label(composite, SWT.NONE);
    applicationNameLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    applicationNameLabel.setText(Messages.MenuEntryDialog_Application);
    applicationNameText = new Text(composite, SWT.NONE);
    applicationNameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    Label iconPathLabel = new Label(composite, SWT.NONE);
    iconPathLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    iconPathLabel.setText(Messages.MenuEntryDialog_IconPath);
    // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ //$NON-NLS-5$
    iconPathText = new FileSelectWidget(composite, "", new String[] { "*.png", "*.gif", "*.jpg" }, "", true);
    // Labels
    descriptionsComposite = new Composite(composite, SWT.BORDER);
    descriptionsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
    descriptionsComposite.setLayout(new GridLayout(3, false));
    Label descriptionsLabel = new Label(descriptionsComposite, SWT.NULL);
    descriptionsLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
    descriptionsLabel.setText(Messages.MenuEntryDialog_MenuEntryLabels);
    languagesCombo = new Combo(descriptionsComposite, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.SINGLE);
    languagesCombo.setLayoutData(new GridData(SWT.BEGINNING, SWT.NONE, false, false, 1, 1));
    Set<String> languages = Util.lang2iso.keySet();
    for (Object element : languages) {
        String language = (String) element;
        languagesCombo.add(language);
    }
    languagesCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
        }
    });
    languagesCombo.select(0);
    labelText = new Text(descriptionsComposite, SWT.BORDER | SWT.SINGLE);
    labelText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    labelText.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
        }

        public void keyReleased(KeyEvent e) {
            if ((e.stateMask == 0) && (e.character == SWT.CR)) {
                String isoCode = Util.lang2iso.get(languagesCombo.getText());
                descriptionsMap.put(isoCode, labelText.getText());
                descriptionsViewer.refresh();
            }
        }
    });
    Button addLabelButton = new Button(descriptionsComposite, SWT.PUSH);
    addLabelButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
    addLabelButton.setImage(ImageCache.getCreatedImage(EImage.ADD_OBJ.getPath()));
    addLabelButton.setToolTipText(Messages.MenuEntryDialog_Add);
    addLabelButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
        }

        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            String isoCode = Util.lang2iso.get(languagesCombo.getText());
            descriptionsMap.put(isoCode, labelText.getText());
            descriptionsViewer.refresh();
        }
    });
    final String LANGUAGE = Messages.MenuEntryDialog_Language;
    final String LABEL = Messages.MenuEntryDialog_Label;
    descriptionsViewer = new TableViewer(descriptionsComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    descriptionsViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
    ((GridData) descriptionsViewer.getControl().getLayoutData()).heightHint = 100;
    // Set up the underlying table
    Table table = descriptionsViewer.getTable();
    // table.setLayoutData(new GridData(GridData.FILL_BOTH));
    new TableColumn(table, SWT.LEFT).setText(LANGUAGE);
    new TableColumn(table, SWT.CENTER).setText(LABEL);
    table.getColumn(0).setWidth(150);
    table.getColumn(1).setWidth(150);
    for (int i = 2, n = table.getColumnCount(); i < n; i++) {
        table.getColumn(i).pack();
    }
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    // Create the cell editors --> We actually discard those later: not natural for an user
    CellEditor[] editors = new CellEditor[2];
    editors[0] = new TextCellEditor(table);
    editors[1] = new TextCellEditor(table);
    descriptionsViewer.setCellEditors(editors);
    // set the content provider
    descriptionsViewer.setContentProvider(new IStructuredContentProvider() {

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        public Object[] getElements(Object inputElement) {
            // System.out.println("getElements() ");
            LinkedHashMap<String, String> descs = (LinkedHashMap<String, String>) inputElement;
            Set<String> languages = descs.keySet();
            ArrayList<DescriptionLine> lines = new ArrayList<DescriptionLine>();
            for (Object element : languages) {
                String language = (String) element;
                DescriptionLine line = new DescriptionLine(Util.iso2lang.get(language), descs.get(language));
                lines.add(line);
            }
            // we return an instance line made of a Sring and a boolean
            return lines.toArray(new DescriptionLine[lines.size()]);
        }
    });
    // set the label provider
    descriptionsViewer.setLabelProvider(new ITableLabelProvider() {

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

        public void dispose() {
        }

        public void addListener(ILabelProviderListener listener) {
        }

        public void removeListener(ILabelProviderListener listener) {
        }

        public String getColumnText(Object element, int columnIndex) {
            // System.out.println("getColumnText() "+columnIndex);
            DescriptionLine line = (DescriptionLine) element;
            switch(columnIndex) {
                case 0:
                    return line.getLanguage();
                case 1:
                    return line.getLabel();
            }
            // $NON-NLS-1$
            return "";
        }

        public Image getColumnImage(Object element, int columnIndex) {
            return null;
        }
    });
    // Set the column properties
    descriptionsViewer.setColumnProperties(new String[] { LANGUAGE, LABEL });
    // set the Cell Modifier
    descriptionsViewer.setCellModifier(new ICellModifier() {

        public boolean canModify(Object element, String property) {
            // if (INSTANCE_ACCESS.equals(property)) return true; Deactivated
            return false;
        }

        public void modify(Object element, String property, Object value) {
        // System.out.println("modify() "+element.getClass().getName()+": "+property+": "+value);
        // DescriptionLine line =
        // (DescriptionLine)((IStructuredSelection)instancesViewer.getSelection()).getFirstElement();
        // deactivated: editing in places is not natural for users
        }

        public Object getValue(Object element, String property) {
            // System.out.println("getValue() "+property);
            DescriptionLine line = (DescriptionLine) element;
            if (LANGUAGE.equals(property)) {
                return line.getLanguage();
            }
            if (LABEL.equals(property)) {
                return line.getLabel();
            }
            return null;
        }
    });
    // Listen for changes in the selection of the viewer to display additional parameters
    descriptionsViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
        }
    });
    // display for Delete Key events to delete an instance
    descriptionsViewer.getTable().addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
        }

        public void keyReleased(KeyEvent e) {
            // System.out.println("Table keyReleased() ");
            if ((e.stateMask == 0) && (e.character == SWT.DEL) && (descriptionsViewer.getSelection() != null)) {
                DescriptionLine line = (DescriptionLine) ((IStructuredSelection) descriptionsViewer.getSelection()).getFirstElement();
                String isoCode = Util.lang2iso.get(line.getLanguage());
                LinkedHashMap<String, String> descs = (LinkedHashMap<String, String>) descriptionsViewer.getInput();
                descs.remove(isoCode);
                descriptionsViewer.refresh();
            }
        }
    });
    descriptionsViewer.refresh();
    if (wsMenuEntry != null) {
        // $NON-NLS-1$
        idText.setText(wsMenuEntry.getId() == null ? "" : wsMenuEntry.getId());
        // $NON-NLS-1$
        contextText.setText(wsMenuEntry.getContext() == null ? "" : wsMenuEntry.getContext());
        // $NON-NLS-1$
        applicationNameText.setText(wsMenuEntry.getApplication() == null ? "" : wsMenuEntry.getApplication());
        // $NON-NLS-1$
        iconPathText.setFilename(wsMenuEntry.getIcon() == null ? "" : wsMenuEntry.getIcon());
        descriptionsViewer.setInput(descriptionsMap);
    }
    idText.setFocus();
    return composite;
}
Also used : Set(java.util.Set) ModifyListener(org.eclipse.swt.events.ModifyListener) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) Label(org.eclipse.swt.widgets.Label) ArrayList(java.util.ArrayList) Combo(org.eclipse.swt.widgets.Combo) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Image(org.eclipse.swt.graphics.Image) EImage(com.amalto.workbench.image.EImage) LinkedHashMap(java.util.LinkedHashMap) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) Button(org.eclipse.swt.widgets.Button) ICellModifier(org.eclipse.jface.viewers.ICellModifier) FileSelectWidget(com.amalto.workbench.widgets.FileSelectWidget) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Text(org.eclipse.swt.widgets.Text) TableColumn(org.eclipse.swt.widgets.TableColumn) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) TreeObject(com.amalto.workbench.models.TreeObject) KeyListener(org.eclipse.swt.events.KeyListener) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 59 with IStructuredContentProvider

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

the class VariableDefinitionDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    parent.getShell().setText(title);
    Composite composite = (Composite) super.createDialogArea(parent);
    GridLayout layout = (GridLayout) composite.getLayout();
    layout.numColumns = 2;
    descriptionsViewer = new TableViewer(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    descriptionsViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    ((GridData) descriptionsViewer.getControl().getLayoutData()).heightHint = 100;
    // Set up the underlying table
    Table table = descriptionsViewer.getTable();
    final String columnTitle = Messages.VariableDefinitionDialog_AvailableVariables;
    new TableColumn(table, SWT.CENTER).setText(columnTitle);
    table.getColumn(0).setWidth(350);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    CellEditor[] editors = new CellEditor[1];
    editors[0] = new TextCellEditor(table);
    descriptionsViewer.setCellEditors(editors);
    descriptionsViewer.setContentProvider(new IStructuredContentProvider() {

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        public Object[] getElements(Object inputElement) {
            ArrayList<String> descs = (ArrayList<String>) inputElement;
            return descs.toArray();
        }
    });
    // set the label provider
    descriptionsViewer.setLabelProvider(new ITableLabelProvider() {

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

        public void dispose() {
        }

        public void addListener(ILabelProviderListener listener) {
        }

        public void removeListener(ILabelProviderListener listener) {
        }

        public String getColumnText(Object element, int columnIndex) {
            // return element.toString().toLowerCase();
            return element.toString();
        }

        public Image getColumnImage(Object element, int columnIndex) {
            return null;
        }
    });
    descriptionsViewer.setColumnProperties(new String[] { columnTitle });
    descriptionsViewer.setCellModifier(new ICellModifier() {

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

        public void modify(Object element, String property, Object value) {
        }

        public Object getValue(Object element, String property) {
            return element.toString();
        }
    });
    descriptionsViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            outPut = (String) selection.getFirstElement();
            getButton(IDialogConstants.OK_ID).setEnabled(true);
        }
    });
    descriptionsViewer.setInput(inputList);
    descriptionsViewer.refresh();
    return composite;
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ArrayList(java.util.ArrayList) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Image(org.eclipse.swt.graphics.Image) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) ICellModifier(org.eclipse.jface.viewers.ICellModifier) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 60 with IStructuredContentProvider

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

the class ViewBrowserMainPage method createCharacteristicsContent.

@Override
protected void createCharacteristicsContent(FormToolkit toolkit, Composite charComposite) {
    try {
        Label vbeLabel = toolkit.createLabel(charComposite, Messages.ViewBrowserMainPage_ViewableElements, SWT.NULL);
        vbeLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
        Label sbeLabel = toolkit.createLabel(charComposite, Messages.ViewBrowserMainPage_SearchableElements, SWT.NULL);
        sbeLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
        viewableBEsList = new List(charComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
        viewableBEsList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        ((GridData) viewableBEsList.getLayoutData()).heightHint = 100;
        searchableBEsList = new List(charComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
        searchableBEsList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        ((GridData) searchableBEsList.getLayoutData()).heightHint = 100;
        Label wcLabel = toolkit.createLabel(charComposite, Messages.ViewBrowserMainPage_Conditions, SWT.NULL);
        wcLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 2, 1));
        wcListViewer = new ListViewer(charComposite, SWT.BORDER);
        wcListViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
        ((GridData) wcListViewer.getControl().getLayoutData()).minimumHeight = 100;
        wcListViewer.setContentProvider(new IStructuredContentProvider() {

            public void dispose() {
            }

            public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            }

            public Object[] getElements(Object inputElement) {
                return ((WSView) inputElement).getWhereConditions().toArray();
            }
        });
        wcListViewer.setLabelProvider(new ILabelProvider() {

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

            public String getText(Object element) {
                WSWhereCondition wc = (WSWhereCondition) element;
                // $NON-NLS-1$
                String text = wc.getLeftPath() + " ";
                if (wc.getOperator().equals(WSWhereOperator.CONTAINS)) {
                    // $NON-NLS-1$
                    text += "Contains";
                } else if (wc.getOperator().equals(WSWhereOperator.CONTAINS_SENTENCE)) {
                    // $NON-NLS-1$
                    text += "contains the sentence";
                } else if (wc.getOperator().equals(WSWhereOperator.EQUALS)) {
                    // $NON-NLS-1$
                    text += "=";
                } else if (wc.getOperator().equals(WSWhereOperator.GREATER_THAN)) {
                    // $NON-NLS-1$
                    text += ">";
                } else if (wc.getOperator().equals(WSWhereOperator.GREATER_THAN_OR_EQUAL)) {
                    // $NON-NLS-1$
                    text += ">=";
                } else if (wc.getOperator().equals(WSWhereOperator.JOIN)) {
                    // $NON-NLS-1$
                    text += "Joins With";
                } else if (wc.getOperator().equals(WSWhereOperator.LOWER_THAN)) {
                    // $NON-NLS-1$
                    text += "<";
                } else if (wc.getOperator().equals(WSWhereOperator.LOWER_THAN_OR_EQUAL)) {
                    // $NON-NLS-1$
                    text += "<=";
                } else if (wc.getOperator().equals(WSWhereOperator.NOT_EQUALS)) {
                    // $NON-NLS-1$
                    text += "!=";
                } else if (wc.getOperator().equals(WSWhereOperator.STARTSWITH)) {
                    // $NON-NLS-1$
                    text += "Starts With";
                } else if (wc.getOperator().equals(WSWhereOperator.EMPTY_NULL)) {
                    // $NON-NLS-1$
                    text += "Is Empty Or Null";
                } else if (wc.getOperator().equals(WSWhereOperator.FULLTEXTSEARCH)) {
                    // $NON-NLS-1$
                    text += "whole content contains";
                }
                // $NON-NLS-1$
                text += " ";
                if (!wc.getOperator().equals(WSWhereOperator.JOIN)) {
                    // $NON-NLS-1$
                    text += "\"";
                }
                text += wc.getRightValueOrPath();
                if (!wc.getOperator().equals(WSWhereOperator.JOIN)) {
                    // $NON-NLS-1$
                    text += "\"";
                }
                // $NON-NLS-1$
                text += " ";
                if (wc.getStringPredicate().equals(WSStringPredicate.AND)) {
                    // $NON-NLS-1$
                    text += "[and]";
                } else if (wc.getStringPredicate().equals(WSStringPredicate.NONE)) {
                    // $NON-NLS-1$
                    text += "";
                } else if (wc.getStringPredicate().equals(WSStringPredicate.OR)) {
                    // $NON-NLS-1$
                    text += "[or]";
                } else if (wc.getStringPredicate().equals(WSStringPredicate.NOT)) {
                    // $NON-NLS-1$
                    text += "[not]";
                }
                return text;
            }

            public void addListener(ILabelProviderListener listener) {
            }

            public void dispose() {
            }

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

            public void removeListener(ILabelProviderListener listener) {
            }
        });
        int columns = 6;
        Composite resultsGroup = this.getNewSectionComposite(Messages.ViewBrowserMainPage_SearchAndResults);
        resultsGroup.setLayout(new GridLayout(columns, false));
        Composite createComposite = toolkit.createComposite(resultsGroup);
        GridLayout layout = new GridLayout(3, false);
        layout.marginWidth = 0;
        createComposite.setLayout(layout);
        createComposite.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
        Label containerLabel = toolkit.createLabel(createComposite, Messages.ViewBrowserMainPage_Container, SWT.NULL);
        containerLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
        dataClusterCombo = new Combo(createComposite, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.SINGLE);
        dataClusterCombo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
        ((GridData) dataClusterCombo.getLayoutData()).minimumWidth = 100;
        clusterTypeCombo = new Combo(createComposite, SWT.READ_ONLY | SWT.SINGLE);
        GridData typeLayout = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1);
        typeLayout.horizontalIndent = 10;
        clusterTypeCombo.setLayoutData(typeLayout);
        Label searchOnLabel = toolkit.createLabel(resultsGroup, Messages.ViewBrowserMainPage_SearchOn, SWT.NULL);
        GridData layoutData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
        layoutData.horizontalIndent = 20;
        searchOnLabel.setLayoutData(layoutData);
        searchItemCombo = new Combo(resultsGroup, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.SINGLE);
        searchItemCombo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
        ((GridData) searchItemCombo.getLayoutData()).minimumWidth = 100;
        searchItemCombo.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (FULL_TEXT.equals(searchItemCombo.getText())) {
                    matchAllWordsBtn.setEnabled(true);
                } else {
                    matchAllWordsBtn.setSelection(false);
                    matchAllWordsBtn.setEnabled(false);
                }
            }
        });
        // $NON-NLS-1$
        searchText = toolkit.createText(resultsGroup, "", SWT.BORDER);
        searchText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        searchText.addKeyListener(new KeyListener() {

            public void keyPressed(KeyEvent e) {
            }

            public void keyReleased(KeyEvent e) {
                if ((e.stateMask == 0) && (e.character == SWT.CR)) {
                    ViewBrowserMainPage.this.resultsViewer.setInput(getResults());
                }
            }
        });
        Button bSearch = toolkit.createButton(resultsGroup, Messages.ViewBrowserMainPage_Search, SWT.CENTER);
        bSearch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
        bSearch.addListener(SWT.Selection, new Listener() {

            public void handleEvent(Event event) {
                ViewBrowserMainPage.this.resultsViewer.setInput(getResults());
            }
        });
        matchAllWordsBtn = toolkit.createButton(resultsGroup, Messages.ViewBrowserMainPage_MatchWholeSentence, SWT.CHECK);
        matchAllWordsBtn.setSelection(true);
        // $NON-NLS-1$
        resultsLabel = toolkit.createLabel(resultsGroup, "", SWT.NULL);
        GridData resultLayoutData = new GridData(SWT.LEFT, SWT.CENTER, false, false, columns - 1, 1);
        resultLayoutData.widthHint = 100;
        resultsLabel.setLayoutData(resultLayoutData);
        resultsViewer = new TableViewer(resultsGroup);
        resultsViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, columns, 1));
        ((GridData) resultsViewer.getControl().getLayoutData()).heightHint = 500;
        resultsViewer.setContentProvider(new ArrayContentProvider());
        resultsViewer.setLabelProvider(new XMLTableLabelProvider());
        resultsViewer.addDoubleClickListener(new IDoubleClickListener() {

            public void doubleClick(DoubleClickEvent event) {
                resultsViewer.setSelection(event.getSelection());
                try {
                    new DOMViewAction(ViewBrowserMainPage.this.getSite().getShell(), resultsViewer).run();
                } catch (Exception e) {
                    MessageDialog.openError(ViewBrowserMainPage.this.getSite().getShell(), Messages._Error, Messages.bind(Messages.ViewBrowserMainPage_ErrorMsg, e.getClass().getName(), e.getLocalizedMessage()));
                }
            }
        });
        hookContextMenu();
        addListener();
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) IXObjectModelListener(com.amalto.workbench.models.IXObjectModelListener) IMenuListener(org.eclipse.jface.action.IMenuListener) Listener(org.eclipse.swt.widgets.Listener) KeyListener(org.eclipse.swt.events.KeyListener) Label(org.eclipse.swt.widgets.Label) TableViewer(org.eclipse.jface.viewers.TableViewer) ListViewer(org.eclipse.jface.viewers.ListViewer) Viewer(org.eclipse.jface.viewers.Viewer) Combo(org.eclipse.swt.widgets.Combo) Image(org.eclipse.swt.graphics.Image) WSView(com.amalto.workbench.webservices.WSView) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(org.eclipse.swt.widgets.List) ArrayList(java.util.ArrayList) ListViewer(org.eclipse.jface.viewers.ListViewer) WSWhereCondition(com.amalto.workbench.webservices.WSWhereCondition) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) XtentisException(com.amalto.workbench.utils.XtentisException) MalformedURLException(java.net.MalformedURLException) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) KeyEvent(org.eclipse.swt.events.KeyEvent) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TreeObject(com.amalto.workbench.models.TreeObject) KeyListener(org.eclipse.swt.events.KeyListener) TableViewer(org.eclipse.jface.viewers.TableViewer)

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