Search in sources :

Example 36 with ColumnSpec

use of com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec in project mdw-designer by CenturyLinkCloud.

the class ImportProjectSelectPage method createProjectListControls.

private void createProjectListControls(Composite parent, int ncol) {
    projectTableEditor = new TableEditor(null, TableEditor.TYPE_TABLE);
    // colspecs
    List<ColumnSpec> projectColSpecs = new ArrayList<>();
    ColumnSpec selectionColSpec = new ColumnSpec(PropertyEditor.TYPE_CHECKBOX, "Import/Overwrite", "import");
    selectionColSpec.width = 100;
    projectColSpecs.add(selectionColSpec);
    ColumnSpec projectColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Project", "project");
    projectColSpec.width = 250;
    projectColSpec.readOnly = true;
    projectColSpecs.add(projectColSpec);
    ColumnSpec noteColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Note", "note");
    noteColSpec.readOnly = true;
    noteColSpec.width = 150;
    projectColSpecs.add(noteColSpec);
    projectTableEditor.setColumnSpecs(projectColSpecs);
    projectTableEditor.setFillWidth(true);
    projectTableEditor.setModelUpdater(new TableModelUpdater() {

        public Object create() {
            return null;
        }

        @SuppressWarnings("rawtypes")
        public void updateModelValue(List tableValue) {
            List<WorkflowProject> selectedProjects = new ArrayList<>();
            for (WorkflowProject workflowProject : getProjectList()) {
                for (Object rowObj : tableValue) {
                    DefaultRowImpl row = (DefaultRowImpl) rowObj;
                    if (workflowProject.getName().equals(row.getColumnValue(1)) && ((Boolean) row.getColumnValue(0)).booleanValue())
                        selectedProjects.add(workflowProject);
                }
            }
            setProjectsToImport(selectedProjects);
            handleFieldChanged();
        }
    });
    projectTableEditor.render(parent, false);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = ncol;
    projectTableEditor.getTable().setLayoutData(gd);
}
Also used : DefaultRowImpl(com.centurylink.mdw.plugin.designer.properties.editor.TableEditor.DefaultRowImpl) ColumnSpec(com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec) TableModelUpdater(com.centurylink.mdw.plugin.designer.properties.editor.TableEditor.TableModelUpdater) ArrayList(java.util.ArrayList) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) TableEditor(com.centurylink.mdw.plugin.designer.properties.editor.TableEditor) GridData(org.eclipse.swt.layout.GridData) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ColumnSpec (com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec)36 ArrayList (java.util.ArrayList)22 TableEditor (com.centurylink.mdw.plugin.designer.properties.editor.TableEditor)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)6 GridData (org.eclipse.swt.layout.GridData)6 CellEditor (org.eclipse.jface.viewers.CellEditor)5 Table (org.eclipse.swt.widgets.Table)5 TableColumn (org.eclipse.swt.widgets.TableColumn)5 List (java.util.List)4 TableViewer (org.eclipse.jface.viewers.TableViewer)4 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 Event (org.eclipse.swt.widgets.Event)4 Listener (org.eclipse.swt.widgets.Listener)4 DefaultRowImpl (com.centurylink.mdw.plugin.designer.properties.editor.TableEditor.DefaultRowImpl)3 TableModelUpdater (com.centurylink.mdw.plugin.designer.properties.editor.TableEditor.TableModelUpdater)3 ValueChangeListener (com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener)3 ControlAdapter (org.eclipse.swt.events.ControlAdapter)3 ControlEvent (org.eclipse.swt.events.ControlEvent)3 ElementChangeEvent (com.centurylink.mdw.plugin.designer.model.ElementChangeEvent)2