Search in sources :

Example 31 with FormData

use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.

the class DescriptionSection method createControls.

@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
    super.createControls(parent, aTabbedPropertySheetPage);
    Composite composite = getWidgetFactory().createFlatFormComposite(parent);
    FormData data;
    //$NON-NLS-1$
    descriptionText = getWidgetFactory().createText(composite, "", SWT.MULTI);
    data = new FormData();
    data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
    data.height = NB_LINES * descriptionText.getLineHeight();
    descriptionText.setLayoutData(data);
    addFocusListener(descriptionText);
    //$NON-NLS-1$
    CLabel labelLabel = getWidgetFactory().createCLabel(composite, Messages.getString("DescriptionSection.Label"));
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(descriptionText, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(descriptionText, 0, SWT.TOP);
    labelLabel.setLayoutData(data);
    addFocusListenerToChildren(composite);
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) Composite(org.eclipse.swt.widgets.Composite) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 32 with FormData

use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.

the class NameSection method createControls.

@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
    super.createControls(parent, aTabbedPropertySheetPage);
    composite = getWidgetFactory().createFlatFormComposite(parent);
    FormData data;
    //$NON-NLS-1$
    nameText = getWidgetFactory().createText(composite, "");
    data = new FormData();
    data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
    data.right = new FormAttachment(50, 0);
    data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
    nameText.setLayoutData(data);
    addFocusListener(nameText);
    nameText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            IStatus status = evaluateTextField();
            if (status.getSeverity() == IStatus.ERROR) {
                errorLabel.setText(status.getMessage());
                errorLabel.setVisible(true);
            } else {
                errorLabel.setVisible(false);
            }
        }
    });
    //$NON-NLS-1$
    CLabel labelLabel = getWidgetFactory().createCLabel(composite, Messages.getString("NameSection.Name"));
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(nameText, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(nameText, 0, SWT.CENTER);
    labelLabel.setLayoutData(data);
    //$NON-NLS-1$
    errorLabel = getWidgetFactory().createCLabel(composite, "");
    data = new FormData();
    data.left = new FormAttachment(nameText, ITabbedPropertyConstants.HSPACE * 3);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(nameText, 0, SWT.CENTER);
    errorLabel.setLayoutData(data);
    errorLabel.setImage(ImageProvider.getImage(EImage.ERROR_ICON));
    errorLabel.setVisible(false);
    addFocusListenerToChildren(composite);
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) ModifyEvent(org.eclipse.swt.events.ModifyEvent) IStatus(org.eclipse.core.runtime.IStatus) ModifyListener(org.eclipse.swt.events.ModifyListener) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 33 with FormData

use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.

the class LoginProjectPage method refreshCreateNewProjectVisible.

protected void refreshCreateNewProjectVisible(boolean visible) {
    createNewProject.setVisible(visible);
    FormData formData = (FormData) createNewProject.getLayoutData();
    if (visible) {
        formData.height = -1;
        formData.bottom.offset = -1 * TAB_VERTICAL_PADDING_LEVEL_1;
    } else {
        formData.height = 0;
        formData.bottom.offset = 0;
    }
}
Also used : FormData(org.eclipse.swt.layout.FormData)

Example 34 with FormData

use of org.eclipse.swt.layout.FormData in project tesb-studio-se by Talend.

the class ConfigOptionController method createControl.

@Override
public Control createControl(Composite subComposite, IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
    //$NON-NLS-1$
    Button theBtn = getWidgetFactory().createButton(subComposite, "", SWT.PUSH);
    theBtn.setBackground(subComposite.getBackground());
    if (param.getDisplayName().equals("")) {
        //$NON-NLS-1$
        theBtn.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));
    } else {
        theBtn.setText(param.getDisplayName());
    }
    FormData data = new FormData();
    if (isInWizard()) {
        if (lastControl != null) {
            data.right = new FormAttachment(lastControl, 0);
        } else {
            data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
        }
    } else {
        if (lastControl != null) {
            data.left = new FormAttachment(lastControl, 0);
        } else {
            data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
        }
    }
    data.top = new FormAttachment(0, top);
    theBtn.setLayoutData(data);
    theBtn.setEnabled(!param.isReadOnly());
    theBtn.setData(param);
    hashCurControls.put(param.getName(), theBtn);
    theBtn.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Command cmd = createCommand((Button) e.getSource());
            executeCommand(cmd);
        }
    });
    Point initialSize = theBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    Display.getDefault().asyncExec(new Runnable() {

        @Override
        public void run() {
            refresh(param, true);
        }
    });
    return theBtn;
}
Also used : FormData(org.eclipse.swt.layout.FormData) Button(org.eclipse.swt.widgets.Button) Command(org.eclipse.gef.commands.Command) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Point(org.eclipse.swt.graphics.Point) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 35 with FormData

use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.

the class VersionSection method createControls.

@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
    super.createControls(parent, aTabbedPropertySheetPage);
    composite = getWidgetFactory().createFlatFormComposite(parent);
    tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    final Table table = tableViewer.getTable();
    TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    final String[] columnProperties = new String[] { //$NON-NLS-1$
    Messages.getString("VersionSection.Version"), //$NON-NLS-1$
    Messages.getString("VersionSection.CreationDate"), Messages.getString("VersionSection.ModificationDate"), //$NON-NLS-1$ //$NON-NLS-2$ 
    Messages.getString("VersionSection.Status") };
    final TableColumn column1 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnPixelData(125, true));
    column1.setText(columnProperties[0]);
    final TableColumn column2 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnPixelData(125, true));
    column2.setText(columnProperties[1]);
    final TableColumn column3 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnPixelData(125, true));
    column3.setText(columnProperties[2]);
    final TableColumn column4 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnWeightData(1, 150, true));
    column4.setText(columnProperties[3]);
    tableViewer.setColumnProperties(columnProperties);
    Object layoutData = parent.getLayoutData();
    if (layoutData instanceof GridData) {
        GridData gridData = (GridData) layoutData;
        gridData.grabExcessVerticalSpace = true;
        gridData.verticalAlignment = SWT.FILL;
    }
    FormData formData = new FormData();
    formData.left = new FormAttachment(0);
    formData.top = new FormAttachment(0);
    formData.right = new FormAttachment(100);
    formData.bottom = new FormAttachment(100);
    table.setLayoutData(formData);
    tableViewer.setContentProvider(new IStructuredContentProvider() {

        public Object[] getElements(Object inputElement) {
            IRepositoryViewObject repositoryObject = ((IRepositoryViewObject) inputElement);
            if (repositoryObject.getProperty() == null) {
                return null;
            }
            RepositoryNode parentRepositoryNode = RepositoryNodeUtilities.getParentRepositoryNodeFromSelection(repositoryObject);
            try {
                List<IRepositoryViewObject> allVersion = ProxyRepositoryFactory.getInstance().getAllVersion(repositoryObject.getId());
                Collections.sort(allVersion, new IRepositoryObjectComparator());
                Object[] objects = new Object[allVersion.size()];
                for (int i = 0; i < objects.length; i++) {
                    IRepositoryViewObject repositoryObjectVersion = allVersion.get(i);
                    RepositoryNode repositoryNode = createRepositoryNode(parentRepositoryNode, repositoryObjectVersion);
                    objects[i] = repositoryNode;
                }
                return objects;
            } catch (PersistenceException e) {
                return null;
            }
        }

        private RepositoryNode createRepositoryNode(RepositoryNode parentRepositoryNode, IRepositoryViewObject repositoryObjectVersion) {
            ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(repositoryObjectVersion.getProperty().getItem());
            RepositoryNode repositoryNode = new RepositoryNode(repositoryObjectVersion, parentRepositoryNode, ENodeType.REPOSITORY_ELEMENT);
            repositoryNode.setProperties(EProperties.CONTENT_TYPE, itemType);
            repositoryNode.setProperties(EProperties.LABEL, repositoryObjectVersion.getLabel());
            return repositoryNode;
        }

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
    });
    tableViewer.setLabelProvider(new ITableLabelProvider() {

        public Image getColumnImage(Object element, int columnIndex) {
            return null;
        }

        public String getColumnText(Object element, int columnIndex) {
            RepositoryNode repositoryNode = (RepositoryNode) element;
            switch(columnIndex) {
                case 0:
                    return repositoryNode.getObject().getVersion();
                case 1:
                    if (repositoryNode.getObject().getCreationDate() != null) {
                        return FORMATTER.format(repositoryNode.getObject().getCreationDate());
                    } else {
                        return null;
                    }
                case 2:
                    if (repositoryNode.getObject().getModificationDate() != null) {
                        return FORMATTER.format(repositoryNode.getObject().getModificationDate());
                    } else {
                        return null;
                    }
                case 3:
                    if (repositoryNode.getObject().getStatusCode() != null) {
                        return repositoryNode.getObject().getStatusCode();
                    } else {
                        return null;
                    }
                default:
                    return null;
            }
        }

        public void addListener(ILabelProviderListener listener) {
        }

        public void dispose() {
        }

        public boolean isLabelProperty(Object element, String property) {
            return false;
        }

        public void removeListener(ILabelProviderListener listener) {
        }
    });
    //$NON-NLS-1$
    MenuManager menuMgr = new MenuManager("#PopUp");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager mgr) {
            ISelection selection = tableViewer.getSelection();
            if (selection instanceof IStructuredSelection) {
                IStructuredSelection structuredSelection = (IStructuredSelection) selection;
                List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
                for (ITreeContextualAction action : contextualsActions) {
                    if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
                        action.init(null, structuredSelection);
                        if (action.isVisible()) {
                            mgr.add(action);
                        }
                    }
                }
            }
        }
    });
    Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
    tableViewer.getControl().setMenu(menu);
    Listener sortListener = new Listener() {

        private int direction = 1;

        public void handleEvent(Event e) {
            final TableColumn column = (TableColumn) e.widget;
            if (column == table.getSortColumn()) {
                direction = -direction;
            }
            if (direction == 1) {
                table.setSortDirection(SWT.DOWN);
            } else {
                table.setSortDirection(SWT.UP);
            }
            table.setSortColumn(column);
            tableViewer.setSorter(new ViewerSorter() {

                int index = 0;

                @Override
                public void sort(Viewer viewer, Object[] elements) {
                    while (index < table.getColumns().length && table.getColumn(index) != column) {
                        index++;
                    }
                    super.sort(viewer, elements);
                }

                @Override
                public int compare(Viewer viewer, Object e1, Object e2) {
                    ITableLabelProvider labelProvider = (ITableLabelProvider) tableViewer.getLabelProvider();
                    String columnText = labelProvider.getColumnText(e1, index) != null ? labelProvider.getColumnText(e1, index) : //$NON-NLS-1$
                    "";
                    String columnText2 = labelProvider.getColumnText(e2, index) != null ? labelProvider.getColumnText(e2, index) : //$NON-NLS-1$
                    "";
                    return getComparator().compare(columnText, columnText2) * direction;
                }
            });
        }
    };
    column1.addListener(SWT.Selection, sortListener);
    column2.addListener(SWT.Selection, sortListener);
    column3.addListener(SWT.Selection, sortListener);
    column4.addListener(SWT.Selection, sortListener);
    table.setSortColumn(column1);
    table.setSortDirection(SWT.DOWN);
    aTabbedPropertySheetPage.getSite().setSelectionProvider(this);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Listener(org.eclipse.swt.widgets.Listener) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) IMenuListener(org.eclipse.jface.action.IMenuListener) ViewerSorter(org.eclipse.jface.viewers.ViewerSorter) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ITreeContextualAction(org.talend.commons.ui.swt.actions.ITreeContextualAction) Image(org.eclipse.swt.graphics.Image) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) ISelection(org.eclipse.jface.viewers.ISelection) List(java.util.List) Menu(org.eclipse.swt.widgets.Menu) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) TableLayout(org.eclipse.jface.viewers.TableLayout) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormData(org.eclipse.swt.layout.FormData) Table(org.eclipse.swt.widgets.Table) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) RepositoryNode(org.talend.repository.model.RepositoryNode) TableColumn(org.eclipse.swt.widgets.TableColumn) IMenuListener(org.eclipse.jface.action.IMenuListener) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Event(org.eclipse.swt.widgets.Event) IRepositoryObject(org.talend.core.model.repository.IRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IMenuManager(org.eclipse.jface.action.IMenuManager) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

FormData (org.eclipse.swt.layout.FormData)1050 FormAttachment (org.eclipse.swt.layout.FormAttachment)999 FormLayout (org.eclipse.swt.layout.FormLayout)667 Label (org.eclipse.swt.widgets.Label)554 Button (org.eclipse.swt.widgets.Button)550 SelectionEvent (org.eclipse.swt.events.SelectionEvent)477 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)433 Composite (org.eclipse.swt.widgets.Composite)423 Text (org.eclipse.swt.widgets.Text)420 ModifyListener (org.eclipse.swt.events.ModifyListener)360 Shell (org.eclipse.swt.widgets.Shell)358 ModifyEvent (org.eclipse.swt.events.ModifyEvent)356 Listener (org.eclipse.swt.widgets.Listener)356 Event (org.eclipse.swt.widgets.Event)355 Display (org.eclipse.swt.widgets.Display)342 ShellEvent (org.eclipse.swt.events.ShellEvent)331 ShellAdapter (org.eclipse.swt.events.ShellAdapter)324 TextVar (org.pentaho.di.ui.core.widget.TextVar)234 ColumnInfo (org.pentaho.di.ui.core.widget.ColumnInfo)224 TableView (org.pentaho.di.ui.core.widget.TableView)219