Search in sources :

Example 1 with ListViewer

use of org.eclipse.jface.viewers.ListViewer in project tdi-studio-se by Talend.

the class LoginProjectPage method instantiateControl.

@Override
public void instantiateControl(Composite container) {
    /**
         * 1. Create all the control first
         */
    //$NON-NLS-1$
    String execute = Messages.getString("LoginProjectPage.execute");
    // Image openImage = ImageProvider.getImage(ERepositoryImages.OPEN_PROJECT_ICON);
    // Connection Area
    title = new Label(container, SWT.NONE);
    title.setFont(LoginDialogV2.fixedFont);
    //$NON-NLS-1$
    title.setText(Messages.getString("LoginProjectPage.title"));
    connectionManageArea = new Composite(container, SWT.NONE);
    connectionsViewer = new ComboViewer(connectionManageArea, SWT.READ_ONLY);
    connectionsViewer.getControl().setFont(LoginDialogV2.fixedFont);
    manageButton = new Button(connectionManageArea, SWT.NONE);
    manageButton.setFont(LoginDialogV2.fixedFont);
    manageButton.setBackground(backgroundColor);
    //$NON-NLS-1$
    manageButton.setText(Messages.getString("LoginProjectPage.manage"));
    // Project Operation Area
    projectOperationArea = new Composite(container, SWT.NONE);
    // Existing Project Area
    selectExistingProject = new Button(projectOperationArea, SWT.RADIO);
    selectExistingProject.setFont(LoginDialogV2.fixedFont);
    selectExistingProject.setBackground(backgroundColor);
    //$NON-NLS-1$
    selectExistingProject.setText(Messages.getString("LoginProjectPage.selectProject"));
    projectListArea = new Composite(projectOperationArea, SWT.NONE);
    projectViewer = new ListViewer(projectListArea, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    projectViewer.getControl().setFont(LoginDialogV2.fixedFont);
    projectViewer.setContentProvider(ArrayContentProvider.getInstance());
    projectViewer.setLabelProvider(new ProjectLabelProvider());
    projectViewer.setSorter(new ViewerSorter());
    // Branch Area
    branchArea = new Composite(projectListArea, SWT.NONE);
    branchLabel = new Label(branchArea, SWT.NONE);
    branchLabel.setFont(LoginDialogV2.fixedFont);
    //$NON-NLS-1$
    branchLabel.setText(Messages.getString("LoginProjectPage.Branch"));
    branchesViewer = new ComboViewer(branchArea, SWT.READ_ONLY);
    branchesViewer.getControl().setFont(LoginDialogV2.fixedFont);
    branchesViewer.setContentProvider(ArrayContentProvider.getInstance());
    branchesViewer.setLabelProvider(new LabelProvider());
    refreshProjectButton = new Button(branchArea, SWT.NONE);
    refreshProjectButton.setFont(LoginDialogV2.fixedFont);
    refreshProjectButton.setBackground(backgroundColor);
    refreshProjectButton.setImage(ImageProvider.getImage(EImage.REFRESH_ICON));
    // Create New Project
    createNewProject = new Button(projectOperationArea, SWT.RADIO);
    createNewProject.setFont(LoginDialogV2.fixedFont);
    createNewProject.setBackground(backgroundColor);
    //$NON-NLS-1$
    createNewProject.setText(Messages.getString("LoginProjectPage.createNewProject"));
    newProjectName = new Text(projectOperationArea, SWT.BORDER);
    newProjectName.setFont(LoginDialogV2.fixedFont);
    newProjectName.setBackground(backgroundColor);
    executeCreateNewProject = new Button(projectOperationArea, SWT.NONE);
    executeCreateNewProject.setFont(LoginDialogV2.fixedFont);
    //$NON-NLS-1$
    executeCreateNewProject.setText(Messages.getString("LoginProjectPage.create"));
    executeCreateNewProject.setBackground(backgroundColor);
    // Import Demo Project
    importDemoProject = new Button(projectOperationArea, SWT.RADIO);
    importDemoProject.setFont(LoginDialogV2.fixedFont);
    importDemoProject.setBackground(backgroundColor);
    //$NON-NLS-1$
    importDemoProject.setText(Messages.getString("LoginProjectPage.importDemoProject"));
    executeImportDemoProject = new Button(projectOperationArea, SWT.NONE);
    executeImportDemoProject.setFont(LoginDialogV2.fixedFont);
    // executeImportDemoProject.setImage(openImage);
    executeImportDemoProject.setText(execute);
    executeImportDemoProject.setBackground(backgroundColor);
    // Import Local Project
    importLocalProject = new Button(projectOperationArea, SWT.RADIO);
    importLocalProject.setFont(LoginDialogV2.fixedFont);
    importLocalProject.setBackground(backgroundColor);
    //$NON-NLS-1$
    importLocalProject.setText(Messages.getString("LoginProjectPage.importLocalProject"));
    executeImportLocalProject = new Button(projectOperationArea, SWT.NONE);
    executeImportLocalProject.setFont(LoginDialogV2.fixedFont);
    // executeImportLocalProject.setImage(openImage);
    executeImportLocalProject.setText(execute);
    executeImportLocalProject.setBackground(backgroundColor);
    // Create SandBox Project
    createSandBoxProject = new Button(projectOperationArea, SWT.RADIO);
    createSandBoxProject.setFont(LoginDialogV2.fixedFont);
    createSandBoxProject.setBackground(backgroundColor);
    //$NON-NLS-1$
    createSandBoxProject.setText(Messages.getString("LoginProjectPage.createSandBoxProject.title"));
    executeCreateSandBoxProject = new Button(projectOperationArea, SWT.NONE);
    executeCreateSandBoxProject.setFont(LoginDialogV2.fixedFont);
    // executeCreateSandBoxProject.setImage(openImage);
    executeCreateSandBoxProject.setText(execute);
    executeCreateSandBoxProject.setBackground(backgroundColor);
    super.instantiateControl(container);
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) Composite(org.eclipse.swt.widgets.Composite) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Button(org.eclipse.swt.widgets.Button) Label(org.eclipse.swt.widgets.Label) ViewerSorter(org.eclipse.jface.viewers.ViewerSorter) Text(org.eclipse.swt.widgets.Text) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 2 with ListViewer

use of org.eclipse.jface.viewers.ListViewer in project tdi-studio-se by Talend.

the class SetupProcessDependenciesRoutinesDialog method createTabFolderField.

private void createTabFolderField(Composite parent) {
    // tab
    folder = new CTabFolder(parent, SWT.NONE);
    folder.setLayoutData(new GridData(GridData.FILL_BOTH));
    folder.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateButtons();
        }
    });
    userTabItem = new CTabItem(folder, SWT.NONE);
    //$NON-NLS-1$
    userTabItem.setText(Messages.getString("SetupProcessDependenciesRoutinesDialog.userRoutineLabel"));
    systemTabItem = new CTabItem(folder, SWT.NONE);
    //$NON-NLS-1$
    systemTabItem.setText(Messages.getString("SetupProcessDependenciesRoutinesDialog.systemRoutineLabel"));
    folder.setSelection(userTabItem);
    folder.setSimple(false);
    ISelectionChangedListener listListener = new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            updateButtons();
        }
    };
    // user
    Composite userComposite = new Composite(folder, SWT.NONE);
    userComposite.setLayout(new GridLayout());
    userComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    userViewer = new ListViewer(userComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    userViewer.setLabelProvider(new RoutineRecordLabelProvider());
    userViewer.setContentProvider(ArrayContentProvider.getInstance());
    userViewer.setInput(userRoutines);
    userViewer.getList().setLayoutData(new GridData(GridData.FILL_BOTH));
    userViewer.addSelectionChangedListener(listListener);
    userTabItem.setControl(userComposite);
    // system
    Composite systemComposite = new Composite(folder, SWT.NONE);
    systemComposite.setLayout(new GridLayout());
    systemComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    systemViewer = new ListViewer(systemComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    systemViewer.setLabelProvider(new RoutineRecordLabelProvider());
    systemViewer.setContentProvider(ArrayContentProvider.getInstance());
    systemViewer.setInput(systemRoutines);
    systemViewer.getList().setLayoutData(new GridData(GridData.FILL_BOTH));
    systemViewer.addSelectionChangedListener(listListener);
    systemTabItem.setControl(systemComposite);
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) GridLayout(org.eclipse.swt.layout.GridLayout) CTabFolder(org.eclipse.swt.custom.CTabFolder) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) CTabItem(org.eclipse.swt.custom.CTabItem)

Example 3 with ListViewer

use of org.eclipse.jface.viewers.ListViewer in project tdi-studio-se by Talend.

the class SetupProcessDependenciesRoutinesDialog method createButtonField.

private void createButtonField(Composite parent) {
    Composite btnComposite = new Composite(parent, SWT.NONE);
    btnComposite.setLayout(new GridLayout());
    GridData layoutData = new GridData(GridData.FILL_VERTICAL);
    layoutData.verticalAlignment = SWT.CENTER;
    btnComposite.setLayoutData(layoutData);
    addBtn = new Button(btnComposite, SWT.PUSH);
    addBtn.setImage(ImageProvider.getImage(EImage.ADD_ICON));
    addBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ListViewer currentViewer = getCurrentViewer();
            if (currentViewer == null) {
                return;
            }
            boolean system = (currentViewer == systemViewer);
            List<RoutineItemRecord> currentRecords = getCurrentRecords();
            ShowRoutineItemsDialog dialog = new ShowRoutineItemsDialog(getShell(), allRoutineItems, currentRecords, system);
            if (dialog.open() == Window.OK) {
                Property[] selectedItems = dialog.getSelectedItems();
                List<Property> needAddedItems = new ArrayList<Property>();
                // filter
                for (Property p : selectedItems) {
                    boolean found = false;
                    for (RoutineItemRecord record : currentRecords) {
                        if (system) {
                            found = p.getLabel().equals(record.getLabel());
                        } else {
                            found = p.getId().equals(record.getId());
                        }
                    }
                    if (!found) {
                        needAddedItems.add(p);
                    }
                }
                // create
                for (Property p : needAddedItems) {
                    RoutineItemRecord newOne = new RoutineItemRecord();
                    newOne.setId(p.getId());
                    newOne.setLabel(p.getLabel());
                    newOne.setName(p.getLabel());
                    newOne.setVersion(p.getVersion());
                    currentRecords.add(newOne);
                }
                //
                currentViewer.setInput(currentRecords);
                currentViewer.refresh();
                updateButtons();
            }
        }
    });
    delBtn = new Button(btnComposite, SWT.PUSH);
    delBtn.setImage(ImageProvider.getImage(EImage.DELETE_ICON));
    delBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ListViewer currentViewer = getCurrentViewer();
            List<RoutineItemRecord> currentRecords = getCurrentRecords();
            if (currentViewer != null && !((IStructuredSelection) currentViewer.getSelection()).isEmpty()) {
                Iterator iterator = ((IStructuredSelection) currentViewer.getSelection()).iterator();
                int index = 0;
                while (iterator.hasNext()) {
                    Object selectedRecord = iterator.next();
                    if (currentRecords != null && selectedRecord != null) {
                        index = currentRecords.indexOf(selectedRecord);
                        currentRecords.remove(selectedRecord);
                        if (index > currentRecords.size() - 1) {
                            index = currentRecords.size() - 1;
                        } else if (index < 0) {
                            index = 0;
                        }
                    }
                }
                currentViewer.setInput(currentRecords);
                currentViewer.getList().select(index);
                currentViewer.refresh();
            }
            updateButtons();
        }
    });
    upBtn = new Button(btnComposite, SWT.PUSH);
    upBtn.setImage(ImageProvider.getImage(EImage.UP_ICON));
    upBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveDatas(true);
        }
    });
    downBtn = new Button(btnComposite, SWT.PUSH);
    downBtn.setImage(ImageProvider.getImage(EImage.DOWN_ICON));
    downBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveDatas(false);
        }
    });
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property)

Example 4 with ListViewer

use of org.eclipse.jface.viewers.ListViewer in project tdi-studio-se by Talend.

the class SetupProcessDependenciesRoutinesDialog method moveDatas.

private void moveDatas(boolean up) {
    ListViewer viewer = getCurrentViewer();
    List<RoutineItemRecord> records = getCurrentRecords();
    if (viewer != null && records != null && records.size() > 1) {
        int selectionIndex = viewer.getList().getSelectionIndex();
        final int size = records.size();
        if (selectionIndex > -1 && selectionIndex < size) {
            int newIndex = selectionIndex;
            RoutineItemRecord movedRecord = records.remove(selectionIndex);
            if (movedRecord != null) {
                if (up) {
                    if (selectionIndex == 0) {
                        newIndex = size - 1;
                    } else {
                        newIndex = selectionIndex - 1;
                    }
                } else {
                    if (selectionIndex == size - 1) {
                        newIndex = 0;
                    } else {
                        newIndex = selectionIndex + 1;
                    }
                }
                records.add(newIndex, movedRecord);
                viewer.setInput(records);
                viewer.refresh();
                viewer.getList().setSelection(newIndex);
            }
        }
    }
    updateButtons();
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer)

Example 5 with ListViewer

use of org.eclipse.jface.viewers.ListViewer in project translationstudio8 by heartsome.

the class NewProjectWizardSourceFilePage method createControl.

/**
	 * Create contents of the wizard.
	 * @param parent
	 */
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout(1, false));
    setControl(container);
    fileListViewer = new ListViewer(container, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
    fileListViewer.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    fileListViewer.setContentProvider(new ArrayContentProvider());
    fileListViewer.setInput(srcFileList);
    if (this.converterCaller != null) {
        final Button btnConvert = new Button(container, SWT.CHECK);
        btnConvert.setText(Messages.getString("wizard.NewProjectWizardSourceFilePage.btnConvert"));
        btnConvert.setSelection(true);
        isOpenConverter = true;
        btnConvert.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                isOpenConverter = btnConvert.getSelection();
            }
        });
    }
    Composite composite = new Composite(container, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));
    composite.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false, 1, 1));
    Button addBtn = new Button(composite, SWT.NONE);
    addBtn.setText(Messages.getString("wizard.NewProjectWizardSourceFilePage.addBtn"));
    addBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            FileDialog dlg = new FileDialog(getShell(), SWT.MULTI);
            // CONVERTEREXTENTION
            String[] supExtentions = new String[] { "*.mif;*.idml;*.inx;*.xlf;*.rtf;*.po;*.properties;*.js;*.mqxlz;*.doc;*.xls;*.ppt;" + "*.docx;*.xlsx;*.pptx;*.odt;*.ods;*.odp;*.odg;*.rtf;*.sdlxliff;*.ttx;*.htm;*.html;*.txt;*.resx;*.rc;*.xml;*.txml", "*.*" };
            dlg.setFilterExtensions(supExtentions);
            if (dlg.open() != null) {
                String[] files = dlg.getFileNames();
                for (int i = 0; i < files.length; i++) {
                    StringBuffer buf = new StringBuffer(dlg.getFilterPath());
                    buf.append(File.separator);
                    buf.append(files[i]);
                    String file = buf.toString();
                    if (!srcFileList.contains(file)) {
                        srcFileList.add(file);
                    }
                }
                fileListViewer.refresh();
            }
        }
    });
    Button deleteBtn = new Button(composite, SWT.NONE);
    deleteBtn.setText(Messages.getString("wizard.NewProjectWizardSourceFilePage.deleteBtn"));
    deleteBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selections = (IStructuredSelection) fileListViewer.getSelection();
            Iterator<?> it = selections.iterator();
            while (it.hasNext()) {
                String file = (String) it.next();
                srcFileList.remove(file);
            }
            fileListViewer.refresh();
        }
    });
}
Also used : ListViewer(org.eclipse.jface.viewers.ListViewer) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) FileDialog(org.eclipse.swt.widgets.FileDialog)

Aggregations

ListViewer (org.eclipse.jface.viewers.ListViewer)67 Composite (org.eclipse.swt.widgets.Composite)49 Viewer (org.eclipse.jface.viewers.Viewer)34 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)30 GridData (org.eclipse.swt.layout.GridData)28 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)27 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)26 FillLayout (org.eclipse.swt.layout.FillLayout)26 TableViewer (org.eclipse.jface.viewers.TableViewer)23 TreeViewer (org.eclipse.jface.viewers.TreeViewer)23 GridLayout (org.eclipse.swt.layout.GridLayout)22 AdapterFactoryContentProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider)21 Table (org.eclipse.swt.widgets.Table)21 Tree (org.eclipse.swt.widgets.Tree)21 ViewerPane (org.eclipse.emf.common.ui.ViewerPane)20 AdapterFactoryTreeEditor (org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor)20 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)20 ControlAdapter (org.eclipse.swt.events.ControlAdapter)20 ControlEvent (org.eclipse.swt.events.ControlEvent)20 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)19