use of org.talend.core.repository.model.IRepositoryFactory in project tdi-studio-se by Talend.
the class ConnectionFormComposite method getRepository.
public IRepositoryFactory getRepository() {
IRepositoryFactory repositoryFactory = null;
IStructuredSelection sel = (IStructuredSelection) repositoryCombo.getSelection();
repositoryFactory = (IRepositoryFactory) sel.getFirstElement();
return repositoryFactory;
}
use of org.talend.core.repository.model.IRepositoryFactory in project tdi-studio-se by Talend.
the class ConnectionFormComposite method fillFields.
private void fillFields() {
if (connection != null) {
removeListeners();
String repositoryId = connection.getRepositoryId();
if (repositoryId == null || "".equals(repositoryId)) {
if (getRepository() != null) {
connection.setRepositoryId(getRepository().getId());
} else {
connection.setRepositoryId(RepositoryConstants.REPOSITORY_LOCAL_ID);
}
}
IRepositoryFactory repositoriyById = RepositoryFactoryProvider.getRepositoriyById(repositoryId);
repositoryCombo.setSelection(new StructuredSelection(new Object[] { repositoriyById }));
if (getRepository() != null) {
Map<String, LabelText> map = dynamicControls.get(getRepository());
for (String fieldKey : map.keySet()) {
LabelText current = map.get(fieldKey);
String string = connection.getDynamicFields().get(fieldKey);
//$NON-NLS-1$
current.setText(string == null ? "" : string);
}
Map<String, LabelledCombo> map2 = dynamicChoices.get(getRepository());
for (String fieldKey : map2.keySet()) {
Combo combo = map2.get(fieldKey).getCombo();
String value = connection.getDynamicFields().get(fieldKey);
combo.deselectAll();
for (DynamicChoiceBean dynamicChoiceBean : getRepository().getChoices()) {
if (dynamicChoiceBean.getId().equals(fieldKey)) {
combo.select(dynamicChoiceBean.getChoiceIndex(value));
}
}
}
}
//$NON-NLS-1$
nameText.setText((connection.getName() == null ? "" : connection.getName()));
//$NON-NLS-1$
descriptionText.setText((connection.getDescription() == null ? "" : connection.getDescription()));
//$NON-NLS-1$
userText.setText((connection.getUser() == null ? "" : connection.getUser()));
//$NON-NLS-1$
passwordText.setText((connection.getPassword() == null ? "" : connection.getPassword()));
workSpaceText.setText(//$NON-NLS-1$
("".equals(connection.getWorkSpace()) || connection.getWorkSpace() == null) ? getRecentWorkSpace() : connection.getWorkSpace());
addListeners();
}
}
use of org.talend.core.repository.model.IRepositoryFactory in project tdi-studio-se by Talend.
the class ConnectionFormComposite method showHideTexts.
private void showHideTexts() {
if (passwordText != null && !passwordText.isDisposed()) {
boolean enablePasswordField = false;
if (connection != null) {
IRepositoryFactory factory = RepositoryFactoryProvider.getRepositoriyById(connection.getRepositoryId());
if (factory != null && factory.isAuthenticationNeeded()) {
enablePasswordField = true;
}
} else if (getRepository() != null && RepositoryConstants.REPOSITORY_REMOTE_ID.equals(getRepository().getId())) {
enablePasswordField = true;
}
if (enablePasswordField) {
passwordText.setBackground(LoginDialogV2.WHITE_COLOR);
} else {
//$NON-NLS-1$
passwordText.setText("");
passwordText.setBackground(LoginDialogV2.GREY_COLOR);
}
passwordText.setEnabled(enablePasswordField);
passwordText.setEditable(enablePasswordField);
hideControl(passwordText, !enablePasswordField, false);
hideControl(passwordLabel, !enablePasswordField, false);
passwordText.getParent().layout();
}
}
use of org.talend.core.repository.model.IRepositoryFactory in project tmdm-studio-se by Talend.
the class TreeViewerListener method saveState.
@Override
public void saveState(IMemento aMemento) {
super.saveState(aMemento);
Project currentProject = ProjectManager.getInstance().getCurrentProject();
org.talend.core.model.properties.Project emfProject = currentProject.getEmfProject();
if (emfProject != null && emfProject.eResource() == null) {
IRepositoryFactory rfactory = ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider();
if (rfactory != null) {
try {
rfactory.reloadProject(currentProject);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
}
}
}
CommandManager.getInstance().saveState(aMemento);
}
use of org.talend.core.repository.model.IRepositoryFactory in project tmdm-studio-se by Talend.
the class AbstractSimpleAddActionTest method setUp.
@Before
public void setUp() throws Exception {
ResourceBundle rb = mock(ResourceBundle.class);
// $NON-NLS-1$
stub(method(ResourceBundle.class, "getBundle", String.class)).toReturn(rb);
PowerMockito.mockStatic(JFaceResources.class);
ImageRegistry registry = mock(ImageRegistry.class);
when(JFaceResources.getImageRegistry()).thenReturn(registry);
PowerMockito.mockStatic(CoreRuntimePlugin.class);
CoreRuntimePlugin coreRuntimePlugin = mock(CoreRuntimePlugin.class);
when(CoreRuntimePlugin.getInstance()).thenReturn(coreRuntimePlugin);
IProxyRepositoryFactory repositoryFactory = mock(IProxyRepositoryFactory.class);
when(CoreRuntimePlugin.getInstance().getProxyRepositoryFactory()).thenReturn(repositoryFactory);
RepositoryContext ontextMock = mock(RepositoryContext.class);
when(repositoryFactory.getRepositoryContext()).thenReturn(ontextMock);
PowerMockito.mockStatic(ProjectManager.class);
ProjectManager pmMock = mock(ProjectManager.class);
Project pMock = mock(Project.class);
User userMock = mock(User.class);
// $NON-NLS-1$
when(userMock.getLogin()).thenReturn("a@b.cn");
when(pMock.getAuthor()).thenReturn(userMock);
when(pmMock.getCurrentProject()).thenReturn(pMock);
when(ProjectManager.getInstance()).thenReturn(pmMock);
when(ontextMock.getUser()).thenReturn(userMock);
IRepositoryResourceUtilExAdapter mockAdapter = PowerMockito.mock(IRepositoryResourceUtilExAdapter.class);
PowerMockito.mockStatic(ExAdapterManager.class);
PowerMockito.when(ExAdapterManager.getAdapter(new RepositoryResourceUtil(), IRepositoryResourceUtilExAdapter.class)).thenReturn(mockAdapter);
RecycleBinNodeConfiguration recycleBinNodeConfiguration = mock(RecycleBinNodeConfiguration.class);
PowerMockito.whenNew(RecycleBinNodeConfiguration.class).withNoArguments().thenReturn(recycleBinNodeConfiguration);
PowerMockito.mockStatic(ProxyRepositoryFactory.class);
ProxyRepositoryFactory proxyRepositoryFactory = mock(ProxyRepositoryFactory.class);
when(ProxyRepositoryFactory.getInstance()).thenReturn(proxyRepositoryFactory);
IRepositoryFactory repositoryFactoryMock = mock(IRepositoryFactory.class);
when(proxyRepositoryFactory.getRepositoryFactoryFromProvider()).thenReturn(repositoryFactoryMock);
XmiResourceManager xmiResourceManager = mock(XmiResourceManager.class);
when(repositoryFactoryMock.getResourceManager()).thenReturn(xmiResourceManager);
PowerMockito.mockStatic(RepositoryNodeConfigurationManager.class);
IRepositoryNodeConfiguration rncMock = mock(IRepositoryNodeConfiguration.class);
when(RepositoryNodeConfigurationManager.getConfiguration((Item) anyObject())).thenReturn(rncMock);
IRepositoryNodeResourceProvider resourceProviderM = mock(IRepositoryNodeResourceProvider.class);
when(rncMock.getResourceProvider()).thenReturn(resourceProviderM);
when(resourceProviderM.needSaveReferenceFile()).thenReturn(true);
when(repositoryFactory.isEditableAndLockIfPossible((Item) anyObject())).thenReturn(true);
}
Aggregations