Search in sources :

Example 1 with IRepositoryFactory

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;
}
Also used : IRepositoryFactory(org.talend.core.repository.model.IRepositoryFactory) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 2 with IRepositoryFactory

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();
    }
}
Also used : LabelledCombo(org.talend.commons.ui.swt.formtools.LabelledCombo) IRepositoryFactory(org.talend.core.repository.model.IRepositoryFactory) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) LabelText(org.talend.commons.ui.swt.formtools.LabelText) Combo(org.eclipse.swt.widgets.Combo) LabelledCombo(org.talend.commons.ui.swt.formtools.LabelledCombo) DynamicChoiceBean(org.talend.core.repository.model.DynamicChoiceBean)

Example 3 with IRepositoryFactory

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();
    }
}
Also used : IRepositoryFactory(org.talend.core.repository.model.IRepositoryFactory)

Example 4 with IRepositoryFactory

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);
}
Also used : Project(org.talend.core.model.general.Project) IRepositoryFactory(org.talend.core.repository.model.IRepositoryFactory) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 5 with IRepositoryFactory

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);
}
Also used : RepositoryContext(org.talend.core.context.RepositoryContext) IRepositoryFactory(org.talend.core.repository.model.IRepositoryFactory) User(org.talend.core.model.properties.User) RecycleBinNodeConfiguration(org.talend.mdm.repository.core.impl.recyclebin.RecycleBinNodeConfiguration) IRepositoryResourceUtilExAdapter(org.talend.mdm.repository.utils.IRepositoryResourceUtilExAdapter) XmiResourceManager(org.talend.core.repository.utils.XmiResourceManager) ProjectManager(org.talend.repository.ProjectManager) Project(org.talend.core.model.general.Project) ImageRegistry(org.eclipse.jface.resource.ImageRegistry) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) IRepositoryNodeResourceProvider(org.talend.mdm.repository.core.IRepositoryNodeResourceProvider) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration) ResourceBundle(java.util.ResourceBundle) RepositoryResourceUtil(org.talend.mdm.repository.utils.RepositoryResourceUtil) CoreRuntimePlugin(org.talend.core.runtime.CoreRuntimePlugin) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) Before(org.junit.Before)

Aggregations

IRepositoryFactory (org.talend.core.repository.model.IRepositoryFactory)24 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)13 PersistenceException (org.talend.commons.exception.PersistenceException)11 Project (org.talend.core.model.general.Project)11 User (org.talend.core.model.properties.User)10 XmiResourceManager (org.talend.core.repository.utils.XmiResourceManager)10 IProject (org.eclipse.core.resources.IProject)7 EMFUtil (org.talend.commons.emf.EMFUtil)6 Status (org.talend.core.model.properties.Status)6 Before (org.junit.Before)5 RepositoryContext (org.talend.core.context.RepositoryContext)5 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)5 LabelText (org.talend.commons.ui.swt.formtools.LabelText)4 LabelledCombo (org.talend.commons.ui.swt.formtools.LabelledCombo)4 ResourceBundle (java.util.ResourceBundle)3 ImageRegistry (org.eclipse.jface.resource.ImageRegistry)3 Shell (org.eclipse.swt.widgets.Shell)3 LoginException (org.talend.commons.exception.LoginException)3 OperationCancelException (org.talend.commons.exception.OperationCancelException)3 CoreRuntimePlugin (org.talend.core.runtime.CoreRuntimePlugin)3