Search in sources :

Example 26 with IViewPart

use of org.eclipse.ui.IViewPart in project translationstudio8 by heartsome.

the class MultiSelectionPropertyTester method test.

public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
    IProject curProject = null;
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window != null) {
        IWorkbenchPage page = window.getActivePage();
        if (page != null) {
            if (page.getActivePartReference() == null) {
                return false;
            }
            String partId = page.getActivePartReference().getId();
            if (partId.equals("net.heartsome.cat.common.ui.navigator.view")) {
                // 导航视图处于激活状态
                IViewPart viewPart = page.findView("net.heartsome.cat.common.ui.navigator.view");
                StructuredSelection selection = (StructuredSelection) viewPart.getSite().getSelectionProvider().getSelection();
                ArrayList<IFile> selectedIFileList = new ArrayList<IFile>();
                if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
                    List<?> lstObj = ((IStructuredSelection) selection).toList();
                    for (Object obj : lstObj) {
                        if (obj instanceof IFile) {
                            IFile file = (IFile) obj;
                            // Linux 下的文本文件无扩展名,因此要先判断扩展名是否为空
                            if (file.getFileExtension() == null || !CommonFunction.validXlfExtension(file.getFileExtension())) {
                                return false;
                            } else {
                                String xlfFolderPath = file.getProject().getFullPath().append(Constant.FOLDER_XLIFF).toOSString();
                                if (!file.getFullPath().toOSString().startsWith(xlfFolderPath)) {
                                    return false;
                                }
                                if (curProject == null) {
                                    curProject = file.getProject();
                                } else {
                                    if (curProject != file.getProject()) {
                                        return false;
                                    }
                                }
                                selectedIFileList.add(file);
                            }
                        } else if (obj instanceof IFolder) {
                            IFolder folder = (IFolder) obj;
                            String xlfFolderPath = folder.getProject().getFullPath().append(Constant.FOLDER_XLIFF).toOSString();
                            if (!folder.getFullPath().toOSString().startsWith(xlfFolderPath)) {
                                return false;
                            }
                            try {
                                ResourceUtils.getXliffs(folder, selectedIFileList);
                            } catch (CoreException e) {
                                logger.error(Messages.getString("propertyTester.MultiSelectionPropertyTester.logger1"), folder.getFullPath().toOSString(), e);
                            }
                            if (curProject == null) {
                                curProject = folder.getProject();
                            } else {
                                if (curProject != folder.getProject()) {
                                    return false;
                                }
                            }
                        }
                    }
                    CommonFunction.removeRepeateSelect(selectedIFileList);
                    if (selectedIFileList.size() < 2) {
                        return false;
                    }
                } else {
                    return false;
                }
            }
        } else {
            return false;
        }
    } else {
        return false;
    }
    return true;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) IFile(org.eclipse.core.resources.IFile) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IFolder(org.eclipse.core.resources.IFolder)

Example 27 with IViewPart

use of org.eclipse.ui.IViewPart in project tdi-studio-se by Talend.

the class DesignerCoreService method refreshComponentView.

@Override
public void refreshComponentView() {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IViewPart view = page.findView(ComponentSettingsView.ID);
    if (view == null) {
        // don't do anything. before it made the view appear for nothing even in other product like DQ.
        return;
    }
    if (view != null && view instanceof ComponentSettingsView) {
        ComponentSettingsView settingView = (ComponentSettingsView) view;
        Element element = settingView.getElement();
        if (element != null) {
            settingView.cleanDisplay();
            settingView.setElement(element);
        }
    }
    List<ComponentSettingsView> otherViews = JobTemplateViewsAndProcessUtil.getInstance().getAllViews();
    if (otherViews == null || otherViews.isEmpty()) {
        return;
    }
    for (ComponentSettingsView v : otherViews) {
        if (v.getParent() != null && !v.getParent().isDisposed()) {
            Element elem = v.getElement();
            if (elem != null) {
                v.cleanDisplay();
                v.setElement(elem);
            }
        }
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) Element(org.talend.core.model.process.Element) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ComponentSettingsView(org.talend.designer.core.ui.views.properties.ComponentSettingsView)

Example 28 with IViewPart

use of org.eclipse.ui.IViewPart in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method refreshJobSettingsView.

/**
     * Added by Marvin Wang on July 30, 2012 for refreshing the tab of Job view.
     */
protected void refreshJobSettingsView() {
    IViewPart viewPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(IJobSettingsView.ID);
    if (viewPart != null && viewPart instanceof JobSettingsView) {
        JobSettingsView jobView = (JobSettingsView) viewPart;
        TalendPropertyTabDescriptor currentSelectedTab = jobView.getCurrentSelectedTab();
        if (currentSelectedTab != null) {
            IDynamicProperty dc = currentSelectedTab.getPropertyComposite();
            if (dc != null) {
                dc.refresh();
            }
        }
    }
}
Also used : IJobSettingsView(org.talend.repository.ui.views.IJobSettingsView) JobSettingsView(org.talend.designer.core.ui.views.jobsettings.JobSettingsView) IViewPart(org.eclipse.ui.IViewPart) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) TalendPropertyTabDescriptor(org.talend.core.ui.properties.tab.TalendPropertyTabDescriptor)

Example 29 with IViewPart

use of org.eclipse.ui.IViewPart in project tdi-studio-se by Talend.

the class ContextRepositoryCommand method refreshContextView.

/**
     * qzhang Comment method "refreshContextView".
     */
private void refreshContextView() {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IViewPart view2 = page.findView(ContextsView.CTX_ID_DESIGNER);
    if (view2 instanceof ContextsView) {
        ((ContextsView) view2).updateContextView(contextItem == null);
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) ContextsView(org.talend.designer.core.ui.views.contexts.ContextsView) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 30 with IViewPart

use of org.eclipse.ui.IViewPart in project tdi-studio-se by Talend.

the class ConnectionPart method setSelected.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#setSelected(int)
     */
@Override
public void setSelected(final int value) {
    super.setSelected(value);
    List cl = this.getChildren();
    for (int i = 0; i < cl.size(); i++) {
        if (((EditPart) cl.get(i)).getSelected() != value) {
            ((EditPart) cl.get(i)).setSelected(value);
        }
    }
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (value == SELECTED_PRIMARY) {
        IViewPart view = page.findView(ComponentSettingsView.ID);
        if (view != null) {
            ComponentSettingsView compSettings = (ComponentSettingsView) view;
            compSettings.setElement((Connection) getModel());
            CodeView.refreshCodeView((Connection) getModel());
        }
    } else if (value == SELECTED_NONE) {
        IViewPart view = page.findView(ComponentSettingsView.ID);
        if (view != null) {
            ComponentSettingsView compSettings = (ComponentSettingsView) view;
            compSettings.cleanDisplay();
        }
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) AbstractConnectionEditPart(org.eclipse.gef.editparts.AbstractConnectionEditPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ArrayList(java.util.ArrayList) List(java.util.List) ComponentSettingsView(org.talend.designer.core.ui.views.properties.ComponentSettingsView)

Aggregations

IViewPart (org.eclipse.ui.IViewPart)95 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)52 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)38 IEditorPart (org.eclipse.ui.IEditorPart)31 PartInitException (org.eclipse.ui.PartInitException)25 IViewReference (org.eclipse.ui.IViewReference)23 IFile (org.eclipse.core.resources.IFile)15 ArrayList (java.util.ArrayList)14 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)14 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)14 IEditorInput (org.eclipse.ui.IEditorInput)11 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)10 IXliffEditor (net.heartsome.cat.ts.ui.editors.IXliffEditor)10 ITermViewPart (net.heartsome.cat.ts.ui.view.ITermViewPart)10 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)10 Shell (org.eclipse.swt.widgets.Shell)9 IEditorReference (org.eclipse.ui.IEditorReference)9 XLFHandler (net.heartsome.cat.ts.core.file.XLFHandler)8 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)8 IProject (org.eclipse.core.resources.IProject)8