Search in sources :

Example 1 with LabelProvider

use of org.eclipse.jface.viewers.LabelProvider in project flux by eclipse.

the class SyncDownloadHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final Repository repository = org.eclipse.flux.core.Activator.getDefault().getRepository();
    final MessageConnector messagingConnector = org.eclipse.flux.core.Activator.getDefault().getMessageConnector();
    if (repository == null || messagingConnector == null) {
        return null;
    }
    final Shell shell = FluxUiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
    SyncDownloadSelectionDialog selectionDialog = new SyncDownloadSelectionDialog(shell, new LabelProvider(), messagingConnector, repository.getUsername());
    int result = selectionDialog.open();
    if (result == Dialog.OK) {
        Object[] selectedProjects = selectionDialog.getResult();
        for (Object selectedProject : selectedProjects) {
            if (selectedProject instanceof String) {
                DownloadProject downloadProject = new DownloadProject(messagingConnector, (String) selectedProject, repository.getUsername());
                downloadProject.run(new CompletionCallback() {

                    @Override
                    public void downloadFailed() {
                    }

                    @Override
                    public void downloadComplete(IProject project) {
                        repository.addProject(project);
                    }
                });
            }
        }
    }
    return null;
}
Also used : MessageConnector(org.eclipse.flux.client.MessageConnector) IProject(org.eclipse.core.resources.IProject) Repository(org.eclipse.flux.core.Repository) Shell(org.eclipse.swt.widgets.Shell) CompletionCallback(org.eclipse.flux.core.DownloadProject.CompletionCallback) LabelProvider(org.eclipse.jface.viewers.LabelProvider) DownloadProject(org.eclipse.flux.core.DownloadProject)

Example 2 with LabelProvider

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

the class NameAndLabelsTreeController method createControl.

@Override
public Control createControl(Composite subComposite, final IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
    FormData data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.top = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.bottom = new FormAttachment(100, 0);
    Composite parentComp = new Composite(subComposite, SWT.NONE);
    parentComp.setLayoutData(data);
    parentComp.setLayout(new GridLayout());
    ElementsSelectionComposite<NamedThing> selectionComposite = new ElementsSelectionComposite<NamedThing>(parentComp) {

        @Override
        protected IBaseLabelProvider getLabelProvider() {
            return new LabelProvider() {

                @Override
                public String getText(Object obj) {
                    NamedThing nal = (NamedThing) obj;
                    return nal.getDisplayName();
                }

                @Override
                public Image getImage(Object obj) {
                    return null;
                }
            };
        }

        ;

        @Override
        protected void doSelectionChanged() {
            param.setValue(getSelectedElements());
        }

        @Override
        protected List<String> getSelectedElementLabels() {
            List<String> labels = new ArrayList<>();
            Object value = param.getValue();
            if (value instanceof List) {
                List<?> values = (List<?>) value;
                for (Object valueObj : values) {
                    if (valueObj instanceof NamedThing) {
                        labels.add(((NamedThing) valueObj).getName());
                    }
                }
                return labels;
            }
            return null;
        }

        @Override
        protected List<NamedThing> getInitSelectedElements(List<String> selectedElementLabels) {
            List<NamedThing> selectedElements = new ArrayList<>();
            List<NamedThing> viewerDatas = getViewerData();
            for (NamedThing viewerData : viewerDatas) {
                if (selectedElementLabels.contains(viewerData.getName())) {
                    selectedElements.add(viewerData);
                }
            }
            return selectedElements;
        }
    }.setShowToolbar(true).create();
    selectionComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    if (param instanceof GenericElementParameter) {
        selectionComposite.setViewerData(ComponentsUtils.getFormalPossibleValues((GenericElementParameter) param));
    }
    selectionComposite.setCheckedState();
    return parentComp;
}
Also used : FormData(org.eclipse.swt.layout.FormData) ElementsSelectionComposite(org.talend.core.ui.composite.ElementsSelectionComposite) ElementsSelectionComposite(org.talend.core.ui.composite.ElementsSelectionComposite) Composite(org.eclipse.swt.widgets.Composite) ArrayList(java.util.ArrayList) NamedThing(org.talend.daikon.NamedThing) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) GenericElementParameter(org.talend.designer.core.generic.model.GenericElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) IBaseLabelProvider(org.eclipse.jface.viewers.IBaseLabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 3 with LabelProvider

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

the class NameAndLabelsDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    Composite comp = new Composite(composite, SWT.NONE);
    comp.setLayoutData(new GridData(GridData.FILL_BOTH));
    comp.setLayout(new GridLayout());
    selectionComposite = new ElementsSelectionComposite<NamedThing>(comp) {

        @Override
        protected IBaseLabelProvider getLabelProvider() {
            return new LabelProvider() {

                @Override
                public String getText(Object obj) {
                    NamedThing nal = (NamedThing) obj;
                    return nal.getDisplayName();
                }

                @Override
                public Image getImage(Object obj) {
                    return null;
                }
            };
        }

        ;
    }.setMultipleSelection(false).create();
    selectionComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    selectionComposite.setViewerData(nameAndLabels);
    Composite customComposite = new Composite(comp, SWT.NONE);
    customComposite.setLayout(new GridLayout());
    customComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Button useCustomBtn = new Button(customComposite, SWT.CHECK);
    //$NON-NLS-1$
    useCustomBtn.setText(Messages.getString("NameAndLabelsDialog.custom.button"));
    useCustomBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateFieldsStatus(useCustomBtn.getSelection());
        }
    });
    //$NON-NLS-1$
    customObjNameText = new LabelledText(customComposite, Messages.getString("NameAndLabelsDialog.custom.text"));
    updateFieldsStatus(useCustomBtn.getSelection());
    if (!isInWizard) {
        // set empty quotes to show the user he should fill the name between quotes
        //$NON-NLS-1$
        customObjNameText.setText("\"\"");
    }
    return composite;
}
Also used : LabelledText(org.talend.commons.ui.swt.formtools.LabelledText) ElementsSelectionComposite(org.talend.core.ui.composite.ElementsSelectionComposite) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) NamedThing(org.talend.daikon.NamedThing) Image(org.eclipse.swt.graphics.Image) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) IBaseLabelProvider(org.eclipse.jface.viewers.IBaseLabelProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IBaseLabelProvider(org.eclipse.jface.viewers.IBaseLabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 4 with LabelProvider

use of org.eclipse.jface.viewers.LabelProvider 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 5 with LabelProvider

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

the class ContextParameterPage method createControl.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
     */
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    container.setLayout(layout);
    GridData data;
    // Name
    Label nameLabel = new Label(container, SWT.NONE);
    //$NON-NLS-1$
    nameLabel.setText(Messages.getString("ContextParameterPage.name"));
    nameText = new Text(container, SWT.BORDER);
    nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // Comment
    Label commentLabel = new Label(container, SWT.NONE);
    //$NON-NLS-1$
    commentLabel.setText(Messages.getString("ContextParameterPage.comment"));
    commentLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    commentText = new Text(container, SWT.BORDER | SWT.MULTI | SWT.WRAP);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 60;
    commentText.setLayoutData(data);
    // Type
    Label typeLabel = new Label(container, SWT.NONE);
    //$NON-NLS-1$
    typeLabel.setText(Messages.getString("ContextParameterPage.type"));
    typeViewer = new ComboViewer(container, SWT.BORDER | SWT.READ_ONLY);
    typeViewer.setContentProvider(ArrayContentProvider.getInstance());
    typeViewer.setLabelProvider(new LabelProvider());
    typeViewer.setInput(MetadataTalendType.getCxtParameterTalendTypesLabels());
    typeViewer.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // Prompt
    Label promptLabel = new Label(container, SWT.NONE);
    //$NON-NLS-1$
    promptLabel.setText(Messages.getString("ContextParameterPage.prompt"));
    promptText = new Text(container, SWT.BORDER);
    promptText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // Prompt
    new Label(container, SWT.NONE);
    promptBtn = new Button(container, SWT.CHECK);
    //$NON-NLS-1$
    promptBtn.setText(Messages.getString("ContextParameterPage.shouldPrompt"));
    // Default
    Label defaultLabel = new Label(container, SWT.NONE);
    //$NON-NLS-1$
    defaultLabel.setText(Messages.getString("ContextParameterPage.defaultValue"));
    defaultText = new Text(container, SWT.BORDER);
    defaultText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    setControl(container);
    updateContent();
    addListeners();
    updatePageComplete();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Aggregations

LabelProvider (org.eclipse.jface.viewers.LabelProvider)25 GridData (org.eclipse.swt.layout.GridData)17 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)12 GridLayout (org.eclipse.swt.layout.GridLayout)11 Composite (org.eclipse.swt.widgets.Composite)11 ComboViewer (org.eclipse.jface.viewers.ComboViewer)10 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 Label (org.eclipse.swt.widgets.Label)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)7 Button (org.eclipse.swt.widgets.Button)7 Combo (org.eclipse.swt.widgets.Combo)7 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)6 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)6 Text (org.eclipse.swt.widgets.Text)6 ArrayList (java.util.ArrayList)5 ISelection (org.eclipse.jface.viewers.ISelection)5 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)5 Image (org.eclipse.swt.graphics.Image)5 List (java.util.List)4