Example usage for org.eclipse.jface.viewers TableViewer getTable

List of usage examples for org.eclipse.jface.viewers TableViewer getTable

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers TableViewer getTable.

Prototype

public Table getTable() 

Source Link

Document

Returns this table viewer's table control.

Usage

From source file:org.apache.directory.studio.ldapbrowser.ui.editors.searchresult.SearchResultEditorCursor.java

License:Apache License

/**
 * Creates a new instance of SearchResultEditorCursor.
 * /* w w  w . jav  a 2 s.  com*/
 * @param viewer the viewer
 */
public SearchResultEditorCursor(TableViewer viewer) {
    super(viewer.getTable(), SWT.NONE);
    this.viewer = viewer;
    this.selectionChangesListenerList = new ArrayList<ISelectionChangedListener>();

    setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION));
    setForeground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));

    EventRegistry.addEntryUpdateListener(this, BrowserCommonActivator.getDefault().getEventRunner());

    initSelectionChecker();
    initSelectionProvider();
}

From source file:org.apache.directory.studio.schemaeditor.view.preferences.PluginPreferencePage.java

License:Apache License

/**
 * {@inheritDoc}/*from   ww  w. j  a  va2 s. c o m*/
 */
protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    // SchemaConnectors Group
    Group schemaConnectorsGroup = new Group(composite, SWT.NONE);
    schemaConnectorsGroup.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
    schemaConnectorsGroup.setLayout(new GridLayout(2, true));
    schemaConnectorsGroup.setText(Messages.getString("PluginPreferencePage.SchemaConnectors")); //$NON-NLS-1$

    // Available Schema Connectors Label
    Label availableSchemaConnectorsLabel = new Label(schemaConnectorsGroup, SWT.NONE);
    availableSchemaConnectorsLabel.setText(Messages.getString("PluginPreferencePage.AvailableConnectorsColon")); //$NON-NLS-1$

    // Description Label
    Label descriptionLabel = new Label(schemaConnectorsGroup, SWT.NONE);
    descriptionLabel.setText(Messages.getString("PluginPreferencePage.DescriptionColon")); //$NON-NLS-1$
    // SchemaConnectors TableViewer
    final TableViewer schemaConnectorsTableViewer = new TableViewer(schemaConnectorsGroup,
            SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
    GridData gridData = new GridData(SWT.FILL, SWT.NONE, true, false);
    gridData.heightHint = 125;
    schemaConnectorsTableViewer.getTable().setLayoutData(gridData);
    schemaConnectorsTableViewer.setContentProvider(new ArrayContentProvider());
    schemaConnectorsTableViewer.setLabelProvider(new LabelProvider() {
        public String getText(Object element) {
            return ((SchemaConnector) element).getName();
        }

        public Image getImage(Object element) {
            return Activator.getDefault().getImage(PluginConstants.IMG_SCHEMA_CONNECTOR);
        }
    });

    schemaConnectorsTableViewer.setComparator(new ViewerComparator(new Comparator<String>() {
        public int compare(String o1, String o2) {
            if ((o1 != null) && (o2 != null)) {
                return o1.compareToIgnoreCase(o2);
            }

            // Default
            return 0;
        }
    }));

    //      schemaConnectorsTableViewer.setComparator( new ViewerComparator( new Comparator<SchemaConnector>()
    //      {
    //          public int compare( SchemaConnector o1, SchemaConnector o2 )
    //          {
    //              String name1 = o1.getName();
    //              String name2 = o2.getName();
    //
    //              if ( ( name1 != null ) && ( name2 != null ) )
    //              {
    //                  return name1.compareToIgnoreCase( name2 );
    //              }
    //
    //              // Default
    //              return 0;
    //          }
    //      } ) );
    schemaConnectorsTableViewer.setInput(PluginUtils.getSchemaConnectors());

    // Description Text
    final Text descriptionText = new Text(schemaConnectorsGroup, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY);
    descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    schemaConnectorsTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            SchemaConnector schemaConnector = (SchemaConnector) ((StructuredSelection) schemaConnectorsTableViewer
                    .getSelection()).getFirstElement();

            if (schemaConnector != null) {
                descriptionText.setText(schemaConnector.getDescription());
            }
        }
    });

    return parent;
}

From source file:org.apache.directory.studio.templateeditor.view.preferences.ColumnViewerSortColumnUtils.java

License:Apache License

/**
 * Adds a sort column to the table viewer.
 *
 * @param tableViewer/*from  w ww .ja  v a 2  s . c  o m*/
 *      the table viewer
 * @param tableColumn
 *      the table column
 */
public static void addSortColumn(TableViewer tableViewer, TableColumn tableColumn) {
    if (tableColumn == null) {
        return;
    }

    Table table = tableViewer.getTable();
    if (table == null) {
        return;
    }

    // Looking for the column index of the table column
    for (int columnIndex = 0; columnIndex < table.getColumnCount(); columnIndex++) {
        if (tableColumn.equals(table.getColumn(columnIndex))) {
            tableColumn.addSelectionListener(getHeaderListener(tableViewer, columnIndex));
        }
    }
}

From source file:org.apache.directory.studio.templateeditor.view.preferences.ColumnViewerSortColumnUtils.java

License:Apache License

/**
 * Updates the direction indicator as column is now the primary column.
 *
 * @param tableViewer//from   ww  w .j  a  v  a2s.c om
 *      the table viewer
 * @param tableColumn
 *      the table column
 */
protected static void updateDirectionIndicator(TableViewer tableViewer, TableColumn tableColumn) {
    tableViewer.getTable().setSortColumn(tableColumn);
    if (((ColumnsTableViewerComparator) tableViewer.getComparator())
            .getOrder() == ColumnsTableViewerComparator.ASCENDING) {
        tableViewer.getTable().setSortDirection(SWT.UP);
    } else {
        tableViewer.getTable().setSortDirection(SWT.DOWN);
    }
}

From source file:org.apache.sling.ide.eclipse.ui.views.JcrCellLabelProvider.java

License:Apache License

public JcrCellLabelProvider(TableViewer viewer) {
    this.viewer = viewer;

    Display display = viewer.getControl().getDisplay();

    greyColor = display.getSystemColor(SWT.COLOR_DARK_GRAY);
    normalColor = viewer.getTable().getForeground();
}

From source file:org.archicontribs.database.DBSelectModel.java

License:Open Source License

private void createContents() {
    DBPlugin.debug(DebugLevel.MainMethod, "+Entering DBSelectModel.createContents()");

    dialog = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
    dialog.setText(DBPlugin.pluginTitle);
    dialog.setSize(840, 470);/*from  ww  w  .j  a  v  a  2 s .  com*/
    dialog.setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - dialog.getSize().x) / 4,
            (Toolkit.getDefaultToolkit().getScreenSize().height - dialog.getSize().y) / 4);
    dialog.setLayout(null);
    dialog.addListener(SWT.Paint, setInitialValuesListener);

    /* ***************************** */
    /* * Selection of the database * */
    /* ***************************** */

    DBPlugin.createLabel(dialog, 10, 10, 60, 20, "Database :", SWT.NONE);

    database = new CCombo(dialog, SWT.BORDER);
    database.setBounds(70, 8, 340, 20);
    database.addSelectionListener(databaseModifyListener);
    try {
        Field field = CCombo.class.getDeclaredField("text");
        field.setAccessible(true);
        databaseTextArea = (Text) field.get(database);
        field.setAccessible(false);
    } catch (Exception err) {
        databaseTextArea = null;
    }

    DBPlugin.createButton(dialog, 420, 5, 130, 25, "Set Preferences ...", SWT.PUSH,
            setPreferencesButtonCallback);

    /* ***************************** */
    /* * Table with ids and names  * */
    /* ***************************** */

    Composite compositeId = DBPlugin.createComposite(dialog, 10, 60, 103, 18, SWT.BORDER);
    lblId = DBPlugin.createLabel(compositeId, 0, 0, 103, 18, "ID :", SWT.CENTER);
    lblId.addMouseListener(sortColumnsAdapter);
    id = DBPlugin.createText(dialog, 10, 40, 103, 21, "", SWT.BORDER);
    id.setTextLimit(8);
    id.addListener(SWT.Verify, verifyIdListener);

    Composite compositeName = DBPlugin.createComposite(dialog, 112, 60, 298, 18, SWT.BORDER);
    lblName = DBPlugin.createLabel(compositeName, 0, 0, 298, 18, "Name :", SWT.CENTER);
    lblName.addMouseListener(sortColumnsAdapter);
    name = DBPlugin.createText(dialog, 112, 40, 298, 21, "", SWT.BORDER);
    name.setTextLimit(255);

    ScrolledComposite compositeTblId = DBPlugin.createScrolledComposite(dialog, 10, 77, 400, 320,
            SWT.BORDER | SWT.V_SCROLL);

    TableViewer tableViewerId = new TableViewer(compositeTblId, SWT.FULL_SELECTION);
    tblId = tableViewerId.getTable();
    tblId.setLinesVisible(true);
    tblId.addListener(SWT.Selection, selectModelListener);
    // if Action is Import, then the double click is equivalent to the OK button
    if (action == Action.Import)
        tblId.addListener(SWT.MouseDoubleClick, new Listener() {
            public void handleEvent(Event event) {
                btnOK.notifyListeners(SWT.Selection, new Event());
            }
        });

    compositeTblId.setContent(tblId);
    compositeTblId.setMinSize(tblId.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    columnId = new TableColumn(tblId, SWT.NONE);
    columnId.setResizable(false);
    columnId.setMoveable(true);
    columnId.setWidth(100);
    columnId.setText("ID");
    columnId.setData(new Label[] { lblId, lblName }); // used by the sort callback

    columnName = new TableColumn(tblId, SWT.NONE);
    columnName.setResizable(false);
    columnName.setWidth(280);
    columnName.setText("Name");
    columnName.setData(new Label[] { lblName, lblId }); // used by the scroll callback

    /* ********************************** */
    /* * versions :                     * */
    /* *    if import --> table         * */
    /* *    if export --> radio buttons * */
    /* ********************************** */
    DBPlugin.createLabel(dialog, 420, 40, 55, 15, "Version :", SWT.NONE);
    if (action == Action.Import) {
        compositeVersion = DBPlugin.createScrolledComposite(dialog, 520, 40, 305, 92,
                SWT.BORDER | SWT.V_SCROLL);

        TableViewer tableViewerVersion = new TableViewer(compositeVersion, SWT.FULL_SELECTION);
        tblVersion = tableViewerVersion.getTable();
        tblVersion.setLinesVisible(true);
        tblVersion.addListener(SWT.Selection, new Listener() {
            public void handleEvent(Event e) {
                TableItem tableItem = tblVersion.getSelection()[0];
                name.setText(tableItem.getData("name") == null ? "" : (String) tableItem.getData("name"));
                purpose.setText(
                        tableItem.getData("purpose") == null ? "" : (String) tableItem.getData("purpose"));
                owner.setText(tableItem.getData("owner") == null ? "" : (String) tableItem.getData("owner"));
                note.setText(tableItem.getData("note") == null ? "" : (String) tableItem.getData("note"));
            }
        });

        TableColumn columnVersion = new TableColumn(tblVersion, SWT.NONE);
        columnVersion.setResizable(false);
        columnVersion.setWidth(95);
        columnVersion.setText("Version");

        TableColumn columnDate = new TableColumn(tblVersion, SWT.NONE);
        columnDate.setResizable(false);
        columnDate.setWidth(190);
        columnDate.setText("Date");
        compositeVersion.setContent(tblVersion);
        compositeVersion.setMinSize(tblVersion.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    } else { // if action == Action.Export
        versionGrp = DBPlugin.createGroup(dialog, 520, 35, 205, 102, SWT.NONE);

        checkActual = DBPlugin.createButton(versionGrp, 6, 18, 96, 16, "actual version :", SWT.RADIO, null);
        checkMinor = DBPlugin.createButton(versionGrp, 6, 37, 101, 16, "minor change :", SWT.RADIO, null);
        checkMajor = DBPlugin.createButton(versionGrp, 6, 56, 100, 16, "major change :", SWT.RADIO, null);
        checkCustom = DBPlugin.createButton(versionGrp, 6, 75, 111, 16, "custom version :", SWT.RADIO, null);

        actualVersion = DBPlugin.createText(versionGrp, 120, 18, 68, 15, "", SWT.None);
        minorVersion = DBPlugin.createText(versionGrp, 120, 37, 68, 15, "", SWT.None);
        majorVersion = DBPlugin.createText(versionGrp, 120, 56, 68, 15, "", SWT.None);
        customVersion = DBPlugin.createText(versionGrp, 120, 75, 68, 15, "", SWT.None);
        customVersion.addListener(SWT.Verify, validateCustomVersionListener);
    }

    /* ******************************** */
    /* * Release note, owner, purpose * */
    /* ******************************** */

    note = DBPlugin.createLabelledText(dialog, 426, 143, 89, 15, "Release note :", 305, 15, "", SWT.BORDER);
    owner = DBPlugin.createLabelledText(dialog, 426, 168, 89, 15, "Owner :", 150, 15, "", SWT.BORDER);
    purpose = DBPlugin.createLabelledText(dialog, 426, 193, 89, 15, "Purpose :", 305, 130, "",
            SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);

    /* ******************************** */
    /* * Import and Export groups     * */
    /* ******************************** */

    if (action == Action.Import) {
        DBPlugin.createLabel(dialog, 426, 335, 80, 15, "Import mode :", SWT.NONE);
        grpMode = DBPlugin.createGroup(dialog, 521, 325, 305, 30, SWT.NONE);

        btnStandalone = DBPlugin.createButton(grpMode, 6, 10, 96, 16, "Standalone", SWT.RADIO, null);
        btnStandalone.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                lblAutoDepth.setVisible(false);
                lblDepth.setVisible(false);
                scaleDepth.setVisible(false);
            }
        });

        btnShared = DBPlugin.createButton(grpMode, 150, 10, 96, 16, "Shared", SWT.RADIO, null);
        btnShared.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                lblAutoDepth.setVisible(true);
                lblDepth.setVisible(true);
                scaleDepth.setVisible(true);
            }
        });

        lblAutoDepth = DBPlugin.createLabel(dialog, 426, 375, 89, 15, "Auto depth :", SWT.NONE);
        lblDepth = DBPlugin.createLabel(dialog, 520, 375, 55, 15, "Infinite", SWT.NONE);
        scaleDepth = new Scale(dialog, SWT.NONE);
        scaleDepth.setSelection(100);
        scaleDepth.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                if (scaleDepth.getSelection() == 0)
                    lblDepth.setText("None");
                else if (scaleDepth.getSelection() == 100)
                    lblDepth.setText("Infinite");
                else
                    lblDepth.setText(Integer.toString(scaleDepth.getSelection()));
            }
        });
        scaleDepth.setBounds(581, 361, 244, 40);
    } else {
        DBPlugin.createLabel(dialog, 426, 335, 80, 15, "Export :", SWT.NONE);
        grpMode = DBPlugin.createGroup(dialog, 521, 325, 305, 30, SWT.NONE);

        btnExport = DBPlugin.createButton(grpMode, 6, 10, 96, 16, "Export", SWT.RADIO, null);
        btnDoNotExport = DBPlugin.createButton(grpMode, 150, 10, 96, 16, "Do not export", SWT.RADIO, null);
        btnExport.setSelection(true);
    }

    /* ******************************** */
    /* * action buttons               * */
    /* ******************************** */

    btnDelete = DBPlugin.createButton(dialog, 10, 409, 75, 25, "Delete", SWT.NONE, deleteButtonCallback);
    btnChangeId = DBPlugin.createButton(dialog, 100, 409, 75, 25, "Change ID", SWT.NONE, null);
    btnApplyFilter = DBPlugin.createButton(dialog, 190, 409, 75, 25, "Filter", SWT.NONE,
            applyFilterButtonCallback);
    btnOK = DBPlugin.createButton(dialog, 668, 409, 75, 25, action == Action.Import ? "Import" : "Export",
            SWT.PUSH, okButtonCallback);
    btnCancel = DBPlugin.createButton(dialog, 749, 409, 75, 25, "Cancel", SWT.NONE, cancelButtonCallback);

    /* ******************************** */
    /* * filters                      * */
    /* ******************************** */

    lblElements = DBPlugin.createLabel(dialog, 10, 446, 80, 15, "Elements :", SWT.NONE);
    lblElements.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
    lblElements.setBackground(GREY_COLOR);

    lblRelations = DBPlugin.createLabel(dialog, 10, 571, 80, 15, "Relationships :", SWT.NONE);
    lblRelations.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
    lblRelations.setBackground(GREY_COLOR);

    lblProperties = DBPlugin.createLabel(dialog, 485, 446, 80, 15, "Properties :", SWT.NONE);
    lblProperties.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
    lblProperties.setBackground(GREY_COLOR);

    Group ElementsGrp = DBPlugin.createGroup(dialog, 10, 455, 465, 107, SWT.NONE);
    ElementsGrp.setBackground(GREY_COLOR);

    lblEltLayer = DBPlugin.createLabel(ElementsGrp, 10, 5, 36, 15, "Layer :", SWT.NONE);
    lblEltLayer.setBackground(GREY_COLOR);

    DBPlugin.createLabel(ElementsGrp, 140, 5, 36, 15, "Type :", SWT.NONE).setBackground(GREY_COLOR);

    lblEltName = DBPlugin.createLabel(ElementsGrp, 285, 5, 44, 15, "Name :", SWT.NONE);
    lblEltName.setBackground(GREY_COLOR);

    comboEltLayer1 = DBPlugin.createCombo(ElementsGrp, 5, 20, 130, 23, ElementLayers, SWT.NONE);
    comboEltLayer1.addVerifyListener(new VerifyListener() {
        public void verifyText(VerifyEvent e) {
            if (e.character != 0)
                e.doit = false;
            if (!e.text.equals(oldComboEltLayer1Text)) {
                oldComboEltLayer1Text = e.text;
                comboEltType1.setText("");
                switch (e.text) {
                case "":
                case "Model":
                    comboEltType1.removeAll();
                    break;
                case "Business":
                    comboEltType1.setItems(BusinessLayer);
                    break;
                case "Application":
                    comboEltType1.setItems(ApplicationLayer);
                    break;
                case "Technology":
                    comboEltType1.setItems(TechnologyLayer);
                    break;
                case "Motivation":
                    comboEltType1.setItems(MotivationLayer);
                    break;
                case "Implementation":
                    comboEltType1.setItems(ImplementationLayer);
                    break;
                }
            }
        }
    });
    comboEltLayer2 = DBPlugin.createCombo(ElementsGrp, 5, 48, 130, 23, ElementLayers, SWT.NONE);
    comboEltLayer2.addVerifyListener(new VerifyListener() {
        public void verifyText(VerifyEvent e) {
            if (e.character != 0)
                e.doit = false;
        }
    });
    comboEltLayer3 = DBPlugin.createCombo(ElementsGrp, 5, 76, 130, 23, ElementLayers, SWT.NONE);
    comboEltLayer3.addVerifyListener(new VerifyListener() {
        public void verifyText(VerifyEvent e) {
            if (e.character != 0)
                e.doit = false;
        }
    });

    comboEltType1 = DBPlugin.createCombo(ElementsGrp, 140, 20, 140, 23, null, SWT.NONE);
    comboEltType1.addVerifyListener(new VerifyListener() {
        public void verifyText(VerifyEvent e) {
            if (e.character != 0)
                e.doit = false;
        }
    });

    comboEltType2 = DBPlugin.createCombo(ElementsGrp, 140, 48, 140, 23, null, SWT.NONE);
    comboEltType2.addVerifyListener(new VerifyListener() {
        public void verifyText(VerifyEvent e) {
            if (e.character != 0)
                e.doit = false;
        }
    });

    comboEltType3 = DBPlugin.createCombo(ElementsGrp, 140, 76, 140, 23, null, SWT.NONE);
    comboEltType3.addVerifyListener(new VerifyListener() {
        public void verifyText(VerifyEvent e) {
            if (e.character != 0)
                e.doit = false;
        }
    });

    txtEltName1 = DBPlugin.createText(ElementsGrp, 285, 21, 170, 21, "", SWT.BORDER);
    txtEltName2 = DBPlugin.createText(ElementsGrp, 285, 49, 170, 21, "", SWT.BORDER);
    txtEltName3 = DBPlugin.createText(ElementsGrp, 285, 77, 170, 21, "", SWT.BORDER);

    grpProperties = DBPlugin.createGroup(dialog, 485, 455, 338, 107, SWT.NONE);
    grpProperties.setBackground(GREY_COLOR);
    lblPropName = DBPlugin.createLabel(grpProperties, 10, 5, 36, 15, "Name :", SWT.NONE);
    lblPropName.setBackground(GREY_COLOR);
    lblPropValue = DBPlugin.createLabel(grpProperties, 140, 5, 44, 15, "Value :", SWT.NONE);
    lblPropValue.setBackground(GREY_COLOR);

    TxtPropName1 = DBPlugin.createText(grpProperties, 10, 21, 125, 21, "", SWT.BORDER);
    TxtPropName2 = DBPlugin.createText(grpProperties, 10, 49, 125, 21, "", SWT.BORDER);
    TxtPropName3 = DBPlugin.createText(grpProperties, 10, 77, 125, 21, "", SWT.BORDER);

    TxtPropValue1 = DBPlugin.createText(grpProperties, 140, 21, 188, 21, "", SWT.BORDER);
    TxtPropValue2 = DBPlugin.createText(grpProperties, 140, 49, 188, 21, "", SWT.BORDER);
    TxtPropValue3 = DBPlugin.createText(grpProperties, 140, 77, 188, 21, "", SWT.BORDER);

    grpRelations = DBPlugin.createGroup(dialog, 10, 580, 465, 111, SWT.NONE);
    grpRelations.setBackground(GREY_COLOR);

    lblRelType = DBPlugin.createLabel(grpRelations, 5, 5, 36, 15, "Type :", SWT.NONE);
    lblRelType.setBackground(GREY_COLOR);

    lblRelSource = DBPlugin.createLabel(grpRelations, 180, 5, 44, 15, "Source :", SWT.NONE);
    lblRelSource.setBackground(GREY_COLOR);
    lblRelTarget = DBPlugin.createLabel(grpRelations, 320, 5, 44, 15, "Target :", SWT.NONE);
    lblRelTarget.setBackground(GREY_COLOR);

    comboRelationship1 = DBPlugin.createCombo(grpRelations, 5, 20, 170, 23, Relationships, SWT.NONE);
    comboRelationship2 = DBPlugin.createCombo(grpRelations, 5, 48, 170, 23, Relationships, SWT.NONE);
    comboRelationship3 = DBPlugin.createCombo(grpRelations, 5, 76, 170, 23, Relationships, SWT.NONE);

    TxtSource1 = DBPlugin.createText(grpRelations, 180, 21, 135, 21, "", SWT.BORDER);
    TxtSource2 = DBPlugin.createText(grpRelations, 180, 49, 135, 21, "", SWT.BORDER);
    TxtSource3 = DBPlugin.createText(grpRelations, 180, 77, 135, 21, "", SWT.BORDER);

    TxtTarget1 = DBPlugin.createText(grpRelations, 320, 21, 135, 21, "", SWT.BORDER);
    TxtTarget2 = DBPlugin.createText(grpRelations, 320, 49, 135, 21, "", SWT.BORDER);
    TxtTarget3 = DBPlugin.createText(grpRelations, 320, 77, 135, 21, "", SWT.BORDER);

    DBPlugin.createLabel(dialog, 485, 550, 250, 50,
            "The search is not case sensitive.\nYou may use the '%' character as wildcard.", SWT.WRAP);

    btnResetFilter = DBPlugin.createButton(dialog, 669, 669, 75, 25, "Reset filter", SWT.NONE,
            ResetFilterListenerButtonCallback);

    btnCancelFilter = DBPlugin.createButton(dialog, 749, 669, 75, 25, "Cancel filter", SWT.NONE,
            CancelFilterListenerButtonCallback);

    //TODO : rework the tab list : the cancellbuttonfilter is not accessible when the filter is hidden !!!!!
    if (action == Action.Import) {
        dialog.getShell()
                .setTabList(new Control[] { id, name, compositeTblId, compositeVersion, note, owner, purpose,
                        grpMode, scaleDepth, btnDelete, btnChangeId, btnApplyFilter, ElementsGrp, grpProperties,
                        grpRelations, btnResetFilter, btnCancelFilter, btnOK, btnCancel });
    } else {
        dialog.getShell().setTabList(new Control[] { id, name, compositeTblId, versionGrp, note, owner, purpose,
                grpMode, btnDelete, btnChangeId, ElementsGrp, grpProperties, grpRelations, btnOK, btnCancel });
    }
    DBPlugin.debug(DebugLevel.MainMethod, "-Leaving DBSelectModel.createContents()");
}

From source file:org.axdt.asdoc.ui.preferences.DocTableFieldEditor.java

License:Open Source License

protected TableViewer createTableViewer(Composite parent) {
    Composite tableComp = new Composite(parent, SWT.NONE);
    tableComp.setLayout(new TableColumnLayout());

    TableViewer tableViewer = new TableViewer(tableComp, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.getTable().setHeaderVisible(true);
    tableViewer.getTable().setLinesVisible(true);

    createTableViwerColumn(tableViewer, "Name", new ColumnLabelProvider() {
        @Override//from ww  w . jav  a 2  s . c  om
        public String getText(Object element) {
            if (element instanceof DocItem) {
                DocItem item = (DocItem) element;
                return item.name;
            }
            return super.getText(element);
        }
    }, new ColumnWeightData(1, 50, true));

    createTableViwerColumn(tableViewer, "Url", new ColumnLabelProvider() {
        @Override
        public String getText(Object element) {
            if (element instanceof DocItem) {
                DocItem item = (DocItem) element;
                return item.url;
            }
            return super.getText(element);
        }
    }, new ColumnWeightData(5, 250, true));
    return tableViewer;
}

From source file:org.bbaw.pdr.ae.view.concurrences.view.ConcurrenceHeadView.java

License:Open Source License

/**
 * Gets the selection adapter.//from w ww  . j a v  a2s .c o m
 * @param tableViewer the table viewer
 * @param column the column
 * @param index the index
 * @return the selection adapter
 */
final SelectionAdapter getSelectionAdapter(final TableViewer tableViewer, final TableColumn column,
        final int index) {
    SelectionAdapter selectionAdapter = new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            ((PdrObjectViewComparator) tableViewer.getComparator()).setColumn(index);
            int dir = tableViewer.getTable().getSortDirection();
            if (tableViewer.getTable().getSortColumn() == column) {
                dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
            } else {

                dir = SWT.DOWN;
            }
            tableViewer.getTable().setSortDirection(dir);
            tableViewer.getTable().setSortColumn(column);
            tableViewer.refresh();
        }
    };
    return selectionAdapter;
}

From source file:org.bbaw.pdr.ae.view.main.preferences.FacetedAspectSearchPage.java

License:Open Source License

/**
 * Gets the selection adapter.// www  . ja  va 2 s. c  o  m
 * @param tableViewer the table viewer
 * @param column the column
 * @param index the index
 * @return the selection adapter
 */
private SelectionAdapter getSelectionAdapter(final TableViewer tableViewer, final TableColumn column,
        final int index) {
    SelectionAdapter selectionAdapter = new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            ((FavoriteMarkupComparator) tableViewer.getComparator()).setColumn(index);
            int dir = tableViewer.getTable().getSortDirection();
            if (tableViewer.getTable().getSortColumn() == column) {
                dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
            } else {

                dir = SWT.DOWN;
            }
            tableViewer.getTable().setSortDirection(dir);
            tableViewer.getTable().setSortColumn(column);
            tableViewer.refresh();
        }
    };
    return selectionAdapter;
}

From source file:org.bonitasoft.studio.actors.ui.wizard.page.AbstractOrganizationWizardPage.java

License:Open Source License

protected StructuredViewer createViewer(Composite parent) {
    Composite viewerComposite = new Composite(parent, SWT.NONE);
    viewerComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create());
    viewerComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).equalWidth(true).margins(0, 0)
            .spacing(0, 5).create());//from  w  ww  .  j a  v a  2s  .c om

    final Text searchBox = new Text(viewerComposite, SWT.SEARCH | SWT.ICON_SEARCH | SWT.BORDER | SWT.CANCEL);
    searchBox.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    searchBox.setMessage(Messages.search);

    final TableViewer tableViewer = new TableViewer(viewerComposite,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
    tableViewer.getTable()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 270).create());
    tableViewer.getTable().setLinesVisible(true);
    tableViewer.getTable().setHeaderVisible(true);
    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            return viewerSelect(element, searchQuery);
        }
    });

    searchBox.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            searchQuery = searchBox.getText();
            tableViewer.refresh();
        }

    });

    return tableViewer;
}