Search in sources :

Example 1 with OptionsManager

use of com.oxygenxml.git.options.OptionsManager in project oxygen-git-client-addon by oxygenxml.

the class ResetAllCredentialsAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    int result = PluginWorkspaceProvider.getPluginWorkspace().showConfirmDialog(TRANSLATOR.getTranslation(Tags.RESET_ALL_CREDENTIALS), TRANSLATOR.getTranslation(Tags.RESET_CREDENTIALS_CONFIRM_MESAGE), new String[] { "   " + TRANSLATOR.getTranslation(Tags.YES) + "   ", "   " + TRANSLATOR.getTranslation(Tags.NO) + "   " }, new int[] { 1, 0 });
    if (result == 1) {
        OptionsManager optManager = OptionsManager.getInstance();
        optManager.saveSshPassphare(null);
        optManager.saveGitCredentials(null);
        refreshSupport.call();
    }
}
Also used : OptionsManager(com.oxygenxml.git.options.OptionsManager)

Example 2 with OptionsManager

use of com.oxygenxml.git.options.OptionsManager in project oxygen-git-client-addon by oxygenxml.

the class SSHCapableUserCredentialsProvider method askUser.

/**
 * Presents the message to the user and returns the user's answer.
 *
 * @param promptText THe message.
 *
 * @return <code>true</code> if the user agrees with the message, <code>false</code> otherwise.
 */
private boolean askUser(String promptText) {
    OptionsManager optionsManager = OptionsManager.getInstance();
    Boolean response = optionsManager.getSshPromptAnswer(promptText);
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Look in cache for answer to: " + promptText + ", got " + response);
    }
    if (response == null) {
        // Ask the user.
        String[] options = new String[] { "   Yes   ", "   No   " };
        int[] optonsId = new int[] { 0, 1 };
        int result = PluginWorkspaceProvider.getPluginWorkspace().showConfirmDialog("Connection", promptText, options, optonsId);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Asked the user, answer: " + response);
        }
        if (result == 0) {
            // true tells the engine that we supplied the value.
            response = Boolean.TRUE;
        } else {
            response = Boolean.FALSE;
        }
        optionsManager.saveSshPrompt(promptText, response);
    }
    return response;
}
Also used : OptionsManager(com.oxygenxml.git.options.OptionsManager)

Example 3 with OptionsManager

use of com.oxygenxml.git.options.OptionsManager in project oxygen-git-client-addon by oxygenxml.

the class RefreshProjectTest method setUp.

@Override
protected void setUp() throws Exception {
    refreshedFolder = null;
    StandalonePluginWorkspace pluginWorkspace = Mockito.mock(StandalonePluginWorkspace.class);
    Mockito.when(pluginWorkspace.showConfirmDialog(Mockito.anyString(), Mockito.anyString(), Mockito.any(), Mockito.any())).thenReturn(0);
    PluginWorkspaceProvider.setPluginWorkspace(pluginWorkspace);
    OptionsManager optMngMock = PowerMockito.mock(OptionsManager.class);
    Whitebox.setInternalState(OptionsManager.class, "instance", optMngMock);
    PowerMockito.when(optMngMock.getSelectedRepository()).thenReturn(new File(localTestRepoPath).getAbsolutePath());
    ProjectController projectCtrlMock = Mockito.mock(ProjectController.class);
    Mockito.when(pluginWorkspace.getProjectManager()).thenReturn(projectCtrlMock);
    Mockito.doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            File[] filesToRefresh = (File[]) invocation.getArguments()[0];
            refreshedFolder = filesToRefresh[0];
            return null;
        }
    }).when(projectCtrlMock).refreshFolders(Mockito.any());
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) OptionsManager(com.oxygenxml.git.options.OptionsManager) StandalonePluginWorkspace(ro.sync.exml.workspace.api.standalone.StandalonePluginWorkspace) File(java.io.File) ProjectController(ro.sync.exml.workspace.api.standalone.project.ProjectController)

Example 4 with OptionsManager

use of com.oxygenxml.git.options.OptionsManager in project oxygen-git-client-addon by oxygenxml.

the class WorkingCopySelector2Test method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    // super.setUp(); already mock the plugin workspace. We will just contribute to it.
    StandalonePluginWorkspace pluginWorkspace = Mockito.mock(StandalonePluginWorkspace.class);
    Mockito.when(pluginWorkspace.showConfirmDialog(Mockito.anyString(), Mockito.anyString(), Mockito.any(), Mockito.any())).thenReturn(0);
    PluginWorkspaceProvider.setPluginWorkspace(pluginWorkspace);
    OptionsManager optMngMock = PowerMockito.mock(OptionsManager.class);
    Whitebox.setInternalState(OptionsManager.class, "instance", optMngMock);
    PowerMockito.when(optMngMock.getRepositoryEntries()).thenReturn(Arrays.asList(wcTree.getAbsolutePath(), badWcTree.getAbsolutePath()));
    PowerMockito.when(optMngMock.getSelectedRepository()).thenReturn(wcTree.getAbsolutePath());
    GitAccess.getInstance().createNewRepository(wcTree.getAbsolutePath());
    PowerMockito.doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            removedRepositories.add((String) invocation.getArguments()[0]);
            return null;
        }
    }).when(optMngMock).removeRepositoryLocation(Mockito.anyString());
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) OptionsManager(com.oxygenxml.git.options.OptionsManager) StandalonePluginWorkspace(ro.sync.exml.workspace.api.standalone.StandalonePluginWorkspace)

Example 5 with OptionsManager

use of com.oxygenxml.git.options.OptionsManager in project oxygen-git-client-addon by oxygenxml.

the class WorkingCopySelectorTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    StandalonePluginWorkspace pluginWorkspace = Mockito.mock(StandalonePluginWorkspace.class);
    Mockito.when(pluginWorkspace.showConfirmDialog(Mockito.anyString(), Mockito.anyString(), Mockito.any(), Mockito.any())).thenReturn(0);
    PluginWorkspaceProvider.setPluginWorkspace(pluginWorkspace);
    OptionsManager optMngMock = PowerMockito.mock(OptionsManager.class);
    Whitebox.setInternalState(OptionsManager.class, "instance", optMngMock);
    PowerMockito.when(optMngMock.getRepositoryEntries()).thenReturn(Arrays.asList("D:/folder/WC1", "D:/folder/WC2", "D:/folder_doi/WC"));
    PowerMockito.when(optMngMock.getSelectedRepository()).thenReturn("D:/folder/WC1");
}
Also used : OptionsManager(com.oxygenxml.git.options.OptionsManager) StandalonePluginWorkspace(ro.sync.exml.workspace.api.standalone.StandalonePluginWorkspace)

Aggregations

OptionsManager (com.oxygenxml.git.options.OptionsManager)5 StandalonePluginWorkspace (ro.sync.exml.workspace.api.standalone.StandalonePluginWorkspace)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 File (java.io.File)1 ProjectController (ro.sync.exml.workspace.api.standalone.project.ProjectController)1