Search in sources :

Example 11 with ItemVersionObject

use of org.talend.repository.model.ItemVersionObject in project tdi-studio-se by Talend.

the class VersionManagementPage method addItemElements.

@Override
protected void addItemElements(List<ItemVersionObject> elements) {
    if (elements == null || elements.isEmpty()) {
        return;
    }
    itemTable.setRedraw(false);
    final Color redColor = Display.getDefault().getSystemColor(SWT.COLOR_RED);
    for (final ItemVersionObject object : elements) {
        final TableItem tableItem = new TableItem(itemTable, SWT.NONE);
        tableItem.setData(object);
        Item item = object.getItem();
        IBaseLabelProvider labelProvider = treeViewer.getLabelProvider();
        Image itemsImage = null;
        if (labelProvider instanceof NavigatorDecoratingLabelProvider) {
            NavigatorDecoratingLabelProvider navigatorProvider = (NavigatorDecoratingLabelProvider) labelProvider;
            itemsImage = navigatorProvider.getImage(object.getRepositoryNode());
        } else {
            ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(item);
            itemsImage = getItemsImage(CoreImageProvider.getIcon(itemType));
        }
        tableItem.setImage(itemsImage);
        tableItem.setText(item.getProperty().getLabel());
        // old version
        tableItem.setText(1, object.getOldVersion());
        TableEditor versionEditor = null;
        if (isFixedVersion()) {
            String version = fixedVersionText.getText();
            tableItem.setText(2, version);
            if (VersionUtils.compareTo(version, object.getOldVersion()) > 0) {
                tableItem.setForeground(2, redColor);
            } else {
                tableItem.setForeground(2, Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
            }
        } else {
            // new version
            versionEditor = new TableEditor(itemTable);
            Composite versionComposit = new Composite(itemTable, SWT.NONE);
            GridLayout layout = new GridLayout(3, false);
            layout.horizontalSpacing = 1;
            layout.verticalSpacing = 0;
            layout.marginHeight = 0;
            layout.marginWidth = 0;
            versionComposit.setLayout(layout);
            final Text text = new Text(versionComposit, SWT.BORDER | SWT.READ_ONLY);
            GridData data = new GridData(GridData.FILL_HORIZONTAL);
            text.setLayoutData(data);
            text.setEditable(false);
            text.setText(object.getNewVersion());
            if (VersionUtils.compareTo(object.getNewVersion(), object.getOldVersion()) > 0) {
                text.setForeground(redColor);
            } else {
                text.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
            }
            Button tableMajorBtn = new Button(versionComposit, SWT.NONE);
            //$NON-NLS-1$
            tableMajorBtn.setText("M");
            //$NON-NLS-1$
            tableMajorBtn.setToolTipText(Messages.getString("VersionManagementDialog.MajorVersionTip"));
            Button tableMinorBtn = new Button(versionComposit, SWT.NONE);
            //$NON-NLS-1$
            tableMinorBtn.setText("m");
            //$NON-NLS-1$
            tableMinorBtn.setToolTipText(Messages.getString("VersionManagementDialog.MinorVersionTip"));
            tableMajorBtn.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    String version = object.getNewVersion();
                    version = VersionUtils.upMajor(version);
                    text.setText(version);
                    text.setForeground(redColor);
                    object.setNewVersion(version);
                }
            });
            tableMinorBtn.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    String version = object.getNewVersion();
                    version = VersionUtils.upMinor(version);
                    text.setText(version);
                    text.setForeground(redColor);
                    object.setNewVersion(version);
                }
            });
            versionEditor.minimumWidth = itemTable.getColumn(2).getWidth();
            versionEditor.setEditor(versionComposit, tableItem, 2);
        }
        TableEditor delEditor = new TableEditor(itemTable);
        Label delLabel = new Label(itemTable, SWT.CENTER);
        delLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
        delLabel.setImage(ImageProvider.getImage(EImage.DELETE_ICON));
        //$NON-NLS-1$
        delLabel.setToolTipText(Messages.getString("VersionManagementDialog.DeletedTip"));
        delLabel.pack();
        delLabel.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDown(MouseEvent e) {
                checkedObjects.remove(object);
                removeTableItem(tableItem);
                refreshCheckedTreeView();
                checkButtonsState();
                checkButtonsState(false);
            }
        });
        delEditor.minimumWidth = 25;
        delEditor.horizontalAlignment = SWT.CENTER;
        delEditor.setEditor(delLabel, tableItem, 3);
        if (isFixedVersion()) {
            tableItem.setData(ITEM_EDITOR_KEY, new TableEditor[] { delEditor });
        } else if (versionEditor != null) {
            tableItem.setData(ITEM_EDITOR_KEY, new TableEditor[] { versionEditor, delEditor });
        }
        itemTable.setRedraw(true);
    }
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) NavigatorDecoratingLabelProvider(org.eclipse.ui.internal.navigator.NavigatorDecoratingLabelProvider) Color(org.eclipse.swt.graphics.Color) TableItem(org.eclipse.swt.widgets.TableItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Text(org.eclipse.swt.widgets.Text) Image(org.eclipse.swt.graphics.Image) EImage(org.talend.commons.ui.runtime.image.EImage) TableEditor(org.eclipse.swt.custom.TableEditor) Item(org.talend.core.model.properties.Item) TableItem(org.eclipse.swt.widgets.TableItem) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) IBaseLabelProvider(org.eclipse.jface.viewers.IBaseLabelProvider) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ItemVersionObject(org.talend.repository.model.ItemVersionObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 12 with ItemVersionObject

use of org.talend.repository.model.ItemVersionObject in project tdi-studio-se by Talend.

the class VersionManagementPage method researchMaxVersion.

protected void researchMaxVersion() {
    String version = fixedVersionText.getText();
    if ("".equals(version.trim())) {
        //$NON-NLS-1$
        version = VersionUtils.DEFAULT_VERSION;
    }
    for (ItemVersionObject object : checkedObjects) {
        if (VersionUtils.compareTo(version, object.getOldVersion()) < 0) {
            version = object.getOldVersion();
        }
    }
    fixedVersionText.setText(version);
}
Also used : ItemVersionObject(org.talend.repository.model.ItemVersionObject)

Example 13 with ItemVersionObject

use of org.talend.repository.model.ItemVersionObject in project tdi-studio-se by Talend.

the class ItemsVersionConfirmDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    TableViewer viewer = new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.minimumHeight = 200;
    data.heightHint = 200;
    data.minimumWidth = 350;
    data.widthHint = 350;
    viewer.getControl().setLayoutData(data);
    final Table table = viewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    TableColumn column = new TableColumn(table, SWT.NONE);
    //$NON-NLS-1$
    column.setText(Messages.getString("VersionManagementDialog.Items"));
    column.setWidth(140);
    column = new TableColumn(table, SWT.NONE);
    //$NON-NLS-1$
    column.setText(Messages.getString("ItemsVersionChangedDialog.OriginalVersion"));
    column.setWidth(120);
    column = new TableColumn(table, SWT.NONE);
    //$NON-NLS-1$
    column.setText(Messages.getString("VersionManagementDialog.NewVersion"));
    column.setWidth(90);
    viewer.setContentProvider(ArrayContentProvider.getInstance());
    viewer.setLabelProvider(new ITableLabelProvider() {

        public Image getColumnImage(Object element, int columnIndex) {
            ItemVersionObject object = (ItemVersionObject) element;
            if (columnIndex == 0) {
                return ImageProvider.getImage(CoreImageProvider.getIcon(object.getItem()));
            }
            return null;
        }

        public String getColumnText(Object element, int columnIndex) {
            ItemVersionObject object = (ItemVersionObject) element;
            switch(columnIndex) {
                case 0:
                    return object.getItem().getProperty().getLabel();
                case 1:
                    return object.getOldVersion();
                case 2:
                    if (object.getOldVersion().equals(object.getNewVersion())) {
                        //$NON-NLS-1$
                        return "-";
                    }
                    return object.getNewVersion();
                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) {
        }
    });
    viewer.setInput(modifiedVersionItems);
    for (TableItem item : table.getItems()) {
        ItemVersionObject object = (ItemVersionObject) item.getData();
        if (!object.getOldVersion().equals(object.getNewVersion())) {
            item.setForeground(2, Display.getDefault().getSystemColor(SWT.COLOR_RED));
        }
    }
    return composite;
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) TableItem(org.eclipse.swt.widgets.TableItem) Image(org.eclipse.swt.graphics.Image) TableColumn(org.eclipse.swt.widgets.TableColumn) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) GridData(org.eclipse.swt.layout.GridData) ItemVersionObject(org.talend.repository.model.ItemVersionObject) ItemVersionObject(org.talend.repository.model.ItemVersionObject) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 14 with ItemVersionObject

use of org.talend.repository.model.ItemVersionObject in project tdi-studio-se by Talend.

the class MavenVersionManagementProjectSettingPage method createItemVersionObject.

@Override
protected ItemVersionObject createItemVersionObject(RepositoryNode node, Property property) {
    String version = MavenVersionUtils.getItemMavenVersion(property);
    ItemVersionObject object = new ItemVersionObject(property, node, version);
    return object;
}
Also used : ItemVersionObject(org.talend.repository.model.ItemVersionObject)

Example 15 with ItemVersionObject

use of org.talend.repository.model.ItemVersionObject in project tdi-studio-se by Talend.

the class AbstractVersionManagementProjectSettingPage method checkButtonsState.

protected void checkButtonsState(boolean isEnable) {
    boolean flag = isEnable;
    TableItem[] items = itemTable.getItems();
    for (TableItem item : items) {
        if (item.getData() instanceof ItemVersionObject) {
            ItemVersionObject itemVersionObj = (ItemVersionObject) item.getData();
            RepositoryNode repositoryNode = itemVersionObj.getRepositoryNode();
            if (repositoryNode != null) {
                ERepositoryObjectType type = repositoryNode.getContentType();
                if (MavenVersionUtils.isVersioningType(type)) {
                    flag = true;
                    break;
                }
            }
        }
    }
    if (alldependcies != null) {
        alldependcies.setEnabled(flag);
    }
    if (subjobs != null) {
        subjobs.setEnabled(flag);
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) ItemVersionObject(org.talend.repository.model.ItemVersionObject) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Aggregations

ItemVersionObject (org.talend.repository.model.ItemVersionObject)15 TableItem (org.eclipse.swt.widgets.TableItem)8 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)7 PersistenceException (org.talend.commons.exception.PersistenceException)6 ArrayList (java.util.ArrayList)5 Item (org.talend.core.model.properties.Item)5 Relation (org.talend.core.model.relationship.Relation)4 Image (org.eclipse.swt.graphics.Image)3 GridData (org.eclipse.swt.layout.GridData)3 Composite (org.eclipse.swt.widgets.Composite)3 Property (org.talend.core.model.properties.Property)3 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)3 IRepositoryNode (org.talend.repository.model.IRepositoryNode)3 RepositoryNode (org.talend.repository.model.RepositoryNode)3 IProjectRepositoryNode (org.talend.repository.model.nodes.IProjectRepositoryNode)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IWorkspace (org.eclipse.core.resources.IWorkspace)2 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)2 CoreException (org.eclipse.core.runtime.CoreException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2