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;
}
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);
}
}
}
}
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();
}
}
}
}
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);
}
}
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();
}
}
}
Aggregations