Search in sources :

Example 36 with ISelection

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

the class DeploymentComposite method addListeners.

private void addListeners() {
    groupIdCheckbox.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (groupIdCheckbox.getSelection()) {
                groupIdText.setEnabled(true);
                groupIdText.setText(groupId);
            } else {
                groupIdText.setEnabled(false);
                groupIdText.setText(defaultGroupId);
                // remove key, so will be default groupId
                Command cmd = new MavenDeploymentValueChangeCommand(process, MavenConstants.NAME_GROUP_ID, null);
                getCommandStack().execute(cmd);
            }
        }
    });
    groupIdText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            String currentGroupId = groupIdText.getText();
            if (currentGroupId != null && !currentGroupId.trim().equals("")) {
                //$NON-NLS-1$
                groupIdText.setBackground(getBackground());
                //$NON-NLS-1$
                groupIdText.setToolTipText("");
                if (!defaultGroupId.equals(currentGroupId)) {
                    groupId = currentGroupId;
                } else {
                    currentGroupId = null;
                }
                Command cmd = new MavenDeploymentValueChangeCommand(process, MavenConstants.NAME_GROUP_ID, currentGroupId);
                getCommandStack().execute(cmd);
            } else {
                groupIdText.setBackground(COLOR_RED);
                //$NON-NLS-1$
                groupIdText.setToolTipText(Messages.getString("DeploymentComposite.valueWarning"));
            }
        }
    });
    versionCheckbox.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (versionCheckbox.getSelection()) {
                versionText.setEnabled(true);
                versionText.setText(version);
            } else {
                versionText.setEnabled(false);
                versionText.setText(defaultVersion);
                // remove key, so will be default version
                Command cmd = new MavenDeploymentValueChangeCommand(process, MavenConstants.NAME_USER_VERSION, null);
                getCommandStack().execute(cmd);
            }
        }
    });
    versionText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            String currentVersion = versionText.getText();
            if (//$NON-NLS-1$
            currentVersion != null && !currentVersion.trim().equals("") && !MavenVersionUtils.isValidMavenVersion(currentVersion)) {
                //$NON-NLS-1$
                versionText.setToolTipText(Messages.getString("DeploymentComposite.valueWarning"));
                versionText.setBackground(COLOR_RED);
            } else {
                //$NON-NLS-1$
                versionText.setToolTipText("");
                versionText.setBackground(getBackground());
                if (!defaultVersion.equals(currentVersion)) {
                    version = currentVersion;
                } else {
                    currentVersion = null;
                }
                // if empty, remove it from job, else will set the new value
                Command cmd = new MavenDeploymentValueChangeCommand(process, MavenConstants.NAME_USER_VERSION, currentVersion);
                getCommandStack().execute(cmd);
            }
        }
    });
    buildTypeCombo.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            final ISelection selection = event.getSelection();
            if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
                final Object elem = ((IStructuredSelection) selection).getFirstElement();
                if (elem instanceof BuildType) {
                    Command cmd = new MavenDeploymentValueChangeCommand(process, TalendProcessArgumentConstant.ARG_BUILD_TYPE, ((BuildType) elem).getName());
                    getCommandStack().execute(cmd);
                }
            }
        }
    });
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ModifyEvent(org.eclipse.swt.events.ModifyEvent) MavenDeploymentValueChangeCommand(org.talend.designer.core.ui.editor.cmd.MavenDeploymentValueChangeCommand) Command(org.eclipse.gef.commands.Command) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) MavenDeploymentValueChangeCommand(org.talend.designer.core.ui.editor.cmd.MavenDeploymentValueChangeCommand) BuildType(org.talend.core.runtime.repository.build.BuildType) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 37 with ISelection

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

the class OutputDataMapTableView method createFiltersTable.

protected void createFiltersTable() {
    this.extendedTableViewerForFilters = new AbstractExtendedTableViewer<FilterTableEntry>(((OutputTable) abstractDataMapTable).getTableFiltersEntriesModel(), centerComposite) {

        @Override
        protected void createColumns(TableViewerCreator<FilterTableEntry> tableViewerCreator, Table table) {
            createFiltersColumns(tableViewerCreator);
        }

        /*
             * (non-Javadoc)
             * 
             * @see
             * org.talend.commons.ui.swt.extended.macrotable.AbstractExtendedTableViewer#setTableViewerCreatorOptions
             * (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)
             */
        @Override
        protected void setTableViewerCreatorOptions(TableViewerCreator<FilterTableEntry> newTableViewerCreator) {
            super.setTableViewerCreatorOptions(newTableViewerCreator);
            newTableViewerCreator.setColumnsResizableByDefault(false);
            newTableViewerCreator.setBorderVisible(false);
            newTableViewerCreator.setLayoutMode(LAYOUT_MODE.FILL_HORIZONTAL);
            newTableViewerCreator.setKeyboardManagementForCellEdition(true);
            // tableViewerCreatorForColumns.setUseCustomItemColoring(this.getDataMapTable()
            // instanceof
            // AbstractInOutTable);
            newTableViewerCreator.setFirstColumnMasked(true);
        }
    };
    tableViewerCreatorForFilters = this.extendedTableViewerForFilters.getTableViewerCreator();
    this.extendedTableViewerForFilters.setCommandStack(mapperManager.getCommandStack());
    tableForConstraints = tableViewerCreatorForFilters.getTable();
    tableForConstraintsGridData = new GridData(GridData.FILL_HORIZONTAL);
    tableForConstraints.setLayoutData(tableForConstraintsGridData);
    boolean tableConstraintsVisible = false;
    if (abstractDataMapTable instanceof OutputTable) {
        tableConstraintsVisible = ((OutputTable) abstractDataMapTable).getFilterEntries().size() > 0;
    }
    tableForConstraintsGridData.exclude = !tableConstraintsVisible;
    tableForConstraints.setVisible(tableConstraintsVisible);
    if (!mapperManager.componentIsReadOnly()) {
        new DragNDrop(mapperManager, tableForConstraints, false, true);
    }
    tableViewerCreatorForFilters.addCellValueModifiedListener(new ITableCellValueModifiedListener() {

        public void cellValueModified(TableCellValueModifiedEvent e) {
            unselectAllEntriesIfErrorDetected(e);
        }
    });
    final TableViewer tableViewer = tableViewerCreatorForFilters.getTableViewer();
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            selectThisDataMapTableView();
            UIManager uiManager = mapperManager.getUiManager();
            uiManager.selectLinks(OutputDataMapTableView.this, uiManager.extractSelectedTableEntries(selection), false, false);
        }
    });
    tableForConstraints.addListener(SWT.KeyDown, new Listener() {

        public void handleEvent(Event event) {
            processEnterKeyDown(tableViewerCreatorForFilters, event);
        }
    });
    tableViewerCreatorForFilters.setLabelProvider(new DefaultTableLabelProvider(tableViewerCreatorForFilters) {

        @Override
        public Color getBackground(Object element, int columnIndex) {
            return getBackgroundCellColor(tableViewerCreator, element, columnIndex);
        }

        @Override
        public Color getForeground(Object element, int columnIndex) {
            return getForegroundCellColor(tableViewerCreator, element, columnIndex);
        }
    });
    initShowMessageErrorListener(tableForConstraints);
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) Table(org.eclipse.swt.widgets.Table) AbstractInOutTable(org.talend.designer.mapper.model.table.AbstractInOutTable) OutputTable(org.talend.designer.mapper.model.table.OutputTable) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) FocusListener(org.eclipse.swt.events.FocusListener) Listener(org.eclipse.swt.widgets.Listener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Color(org.eclipse.swt.graphics.Color) FilterTableEntry(org.talend.designer.mapper.model.tableentry.FilterTableEntry) UIManager(org.talend.designer.mapper.managers.UIManager) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) OutputTable(org.talend.designer.mapper.model.table.OutputTable) DragNDrop(org.talend.designer.mapper.ui.dnd.DragNDrop) GridData(org.eclipse.swt.layout.GridData) ISelection(org.eclipse.jface.viewers.ISelection) DefaultTableLabelProvider(org.talend.commons.ui.runtime.swt.tableviewer.behavior.DefaultTableLabelProvider) FocusEvent(org.eclipse.swt.events.FocusEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) Event(org.eclipse.swt.widgets.Event) TableViewer(org.eclipse.jface.viewers.TableViewer) AbstractExtendedTableViewer(org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer)

Example 38 with ISelection

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

the class MemoryRuntimeComposite method initRuntimeGraphs.

private void initRuntimeGraphs(final Composite parent) {
    ISelection processContextSelection = viewPart.getSite().getSelectionProvider() == null ? null : viewPart.getSelection();
    setExpandHorizontal(true);
    setExpandVertical(true);
    FormData layouData = new FormData();
    layouData.left = new FormAttachment(0, 0);
    layouData.right = new FormAttachment(100, 0);
    layouData.top = new FormAttachment(0, 0);
    layouData.bottom = new FormAttachment(100, 0);
    this.setBackground(parent.getBackground());
    this.setLayout(new FormLayout());
    setLayoutData(layouData);
    monitorComposite = new Composite(this, SWT.NULL);
    FormData baseData = new FormData();
    baseData.left = new FormAttachment(0, 0);
    baseData.right = new FormAttachment(100, 0);
    baseData.top = new FormAttachment(0, 0);
    baseData.bottom = new FormAttachment(100, 0);
    monitorComposite.setLayout(new FormLayout());
    monitorComposite.setLayoutData(layouData);
    setContent(monitorComposite);
    Group topGroup = createTopGroup(monitorComposite);
    runtimeButton = new Button(topGroup, SWT.PUSH);
    if (processContext != null) {
        setRuntimeButtonByStatus(!processContext.isMonitoring());
    } else {
        setRuntimeButtonByStatus(true);
    }
    runtimeButton.setEnabled(true);
    GridData runButtonData = new GridData();
    Point execSize = null;
    execSize = computeSize(runtimeButton.getText());
    runButtonData.widthHint = execSize.x + 70;
    runtimeButton.setLayoutData(runButtonData);
    gcCheckButton = new Button(topGroup, SWT.CHECK);
    GridData gcCheckButtonData = new GridData();
    gcCheckButtonData.grabExcessHorizontalSpace = false;
    gcCheckButton.setLayoutData(gcCheckButtonData);
    gcCheckButton.setEnabled(true);
    gcCheckButton.setSelection(isGCSelected);
    Label periodLabel = new Label(topGroup, SWT.NULL);
    //$NON-NLS-1$
    periodLabel.setText(Messages.getString("ProcessView.moniorPeriod"));
    periodLabel.setBackground(getBackground());
    GridData periodLabelData = new GridData();
    execSize = computeSize(periodLabel.getText());
    periodLabelData.widthHint = execSize.x;
    periodLabelData.grabExcessHorizontalSpace = false;
    periodLabelData.horizontalAlignment = GridData.BEGINNING;
    periodLabel.setLayoutData(periodLabelData);
    periodCombo = new Combo(topGroup, SWT.READ_ONLY);
    GridData periodData = new GridData();
    execSize = computeSize("Select");
    periodData.widthHint = execSize.x;
    periodData.grabExcessHorizontalSpace = false;
    periodData.horizontalAlignment = GridData.BEGINNING;
    periodData.minimumWidth = execSize.x;
    periodCombo.setLayoutData(periodData);
    periodCombo.setItems(new String[] { "Select", "30 sec", "60 sec", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    "120 sec" });
    periodCombo.setEnabled(isGCSelected);
    if (isGCSelected) {
        periodCombo.select(periodComboSelectionIndex);
    } else {
        periodCombo.select(0);
        periodComboSelectionIndex = 0;
    }
    contextCombo = new ComboViewer(topGroup, SWT.BORDER | SWT.READ_ONLY);
    contextCombo.getCombo().setLayout(new FormLayout());
    GridData contextComboData = new GridData();
    contextComboData.grabExcessHorizontalSpace = true;
    contextComboData.horizontalAlignment = GridData.END;
    //$NON-NLS-N$
    execSize = computeSize("Default");
    contextComboData.minimumWidth = execSize.x;
    contextCombo.getCombo().setLayoutData(contextComboData);
    contextCombo.setContentProvider(ArrayContentProvider.getInstance());
    contextCombo.setLabelProvider(new ContextNameLabelProvider());
    initContextInput();
    chartComposite = new RuntimeGraphcsComposite(monitorComposite, processContextSelection, SWT.NULL);
    FormLayout rgcLayout = new FormLayout();
    FormData charLayData = new FormData();
    charLayData.left = new FormAttachment(0, 10);
    charLayData.right = new FormAttachment(100, 0);
    charLayData.top = new FormAttachment(topGroup, 60, SWT.BOTTOM);
    charLayData.bottom = new FormAttachment(100, 0);
    chartComposite.setLayout(rgcLayout);
    chartComposite.setLayoutData(charLayData);
}
Also used : FormData(org.eclipse.swt.layout.FormData) FormLayout(org.eclipse.swt.layout.FormLayout) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) AbstractRuntimeGraphcsComposite(org.talend.designer.runtime.visualization.views.AbstractRuntimeGraphcsComposite) RuntimeGraphcsComposite(org.talend.designer.runtime.visualization.views.RuntimeGraphcsComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Point(org.eclipse.swt.graphics.Point) Button(org.eclipse.swt.widgets.Button) ComboViewer(org.eclipse.jface.viewers.ComboViewer) AbstractRuntimeGraphcsComposite(org.talend.designer.runtime.visualization.views.AbstractRuntimeGraphcsComposite) RuntimeGraphcsComposite(org.talend.designer.runtime.visualization.views.RuntimeGraphcsComposite) ISelection(org.eclipse.jface.viewers.ISelection) GridData(org.eclipse.swt.layout.GridData) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 39 with ISelection

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

the class AttributeSelectionDialog method okPressed.

/*
     * @see Dialog#okPressed()
     */
@Override
protected void okPressed() {
    ISelection selection = viewer.getSelection();
    if (!(selection instanceof IStructuredSelection)) {
        return;
    }
    IStructuredSelection structuredSelection = (IStructuredSelection) selection;
    for (Object item : structuredSelection.toArray()) {
        if (!(item instanceof AttributeNode)) {
            continue;
        }
        AttributeNode node = (AttributeNode) item;
        MBeanAttribute mBeanAttribute = new MBeanAttribute(node.getObjectName(), node.getQualifiedName(), node.getRgb());
        selectedAttributes.add(mBeanAttribute);
    }
    super.okPressed();
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 40 with ISelection

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

the class LoadChartSetDialog method createChartSetViewer.

/**
     * Creates the chart set viewer.
     * 
     * @param parent The parent composite
     * @return The chart set viewer
     */
private TableViewer createChartSetViewer(Composite parent) {
    final TableViewer viewer = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = 300;
    viewer.getTable().setLayoutData(gridData);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            if (element.equals(defaultChartSet)) {
                return NLS.bind(Messages.defaultChartSet, defaultChartSet);
            }
            return super.getText(element);
        }
    });
    viewer.setInput(chartSets.toArray(new String[chartSets.size()]));
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            Object element = ((StructuredSelection) selection).getFirstElement();
            if (deleteButton != null) {
                deleteButton.setEnabled(!selection.isEmpty() && !predefinedChartSets.contains(element));
            }
            if (element != null) {
                chartSet = element.toString();
            } else {
                viewer.setSelection(new StructuredSelection(chartSet));
            }
        }
    });
    viewer.setSelection(new StructuredSelection(defaultChartSet));
    return viewer;
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Aggregations

ISelection (org.eclipse.jface.viewers.ISelection)306 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)183 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)44 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)41 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)40 GridData (org.eclipse.swt.layout.GridData)40 SelectionEvent (org.eclipse.swt.events.SelectionEvent)34 ArrayList (java.util.ArrayList)33 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)30 IEditorPart (org.eclipse.ui.IEditorPart)30 Composite (org.eclipse.swt.widgets.Composite)29 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)29 WizardDialog (org.eclipse.jface.wizard.WizardDialog)26 IResource (org.eclipse.core.resources.IResource)24 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)24 TableViewer (org.eclipse.jface.viewers.TableViewer)24 IFile (org.eclipse.core.resources.IFile)23 GridLayout (org.eclipse.swt.layout.GridLayout)23 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)23 TreeViewer (org.eclipse.jface.viewers.TreeViewer)22