-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
nickchecan
committed
Jan 16, 2025
1 parent
da29299
commit f8b7e88
Showing
4 changed files
with
163 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...ious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/OllamaLoginWizard.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.developer.nefarious.zjoule.plugin.login; | ||
|
||
import org.eclipse.jface.wizard.Wizard; | ||
import org.eclipse.swt.browser.Browser; | ||
|
||
import com.developer.nefarious.zjoule.plugin.login.pages.FirstOllamaLoginPage; | ||
import com.developer.nefarious.zjoule.plugin.login.pages.SecondOllamaLoginPage; | ||
|
||
public class OllamaLoginWizard extends Wizard { | ||
|
||
private Browser browser; | ||
|
||
public OllamaLoginWizard(final Browser browser) { | ||
this.browser = browser; | ||
|
||
setWindowTitle("Login to Ollama"); | ||
} | ||
|
||
@Override | ||
public void addPages() { | ||
addPage(new FirstOllamaLoginPage()); | ||
addPage(new SecondOllamaLoginPage()); | ||
} | ||
|
||
@Override | ||
public boolean performFinish() { | ||
// TemporaryMemoryOllamaConfig.getInstance().persist(); | ||
|
||
// SessionManager.login(browser); | ||
return true; | ||
} | ||
|
||
} |
74 changes: 74 additions & 0 deletions
74
...le.plugin/src/com/developer/nefarious/zjoule/plugin/login/pages/FirstOllamaLoginPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.developer.nefarious.zjoule.plugin.login.pages; | ||
|
||
import org.eclipse.jface.wizard.IWizardPage; | ||
import org.eclipse.jface.wizard.WizardPage; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.layout.GridData; | ||
import org.eclipse.swt.layout.GridLayout; | ||
import org.eclipse.swt.widgets.Composite; | ||
import org.eclipse.swt.widgets.Label; | ||
import org.eclipse.swt.widgets.Text; | ||
|
||
public class FirstOllamaLoginPage extends WizardPage { | ||
|
||
public static final String PAGE_ID = "Ollama Login First Page"; | ||
|
||
private Text endpointText; | ||
|
||
private Text errorText; | ||
|
||
public FirstOllamaLoginPage() { | ||
super(PAGE_ID); | ||
|
||
setTitle("Ollama Setup"); | ||
setDescription("Enter the host and port for the local Ollama instance."); | ||
setPageComplete(false); // Initially set the page as incomplete | ||
} | ||
|
||
@Override | ||
public void createControl(final Composite parent) { | ||
Composite container = new Composite(parent, SWT.NONE); | ||
container.setLayout(new GridLayout(2, false)); | ||
|
||
Label inputLabel = new Label(container, SWT.NONE); | ||
inputLabel.setText("Ollama Endpoint:"); | ||
|
||
endpointText = new Text(container, SWT.BORDER); | ||
endpointText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); | ||
endpointText.setText("http://localhost:11434"); | ||
|
||
// Hidden error text widget | ||
errorText = new Text(container, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP); | ||
GridData errorTextGridData = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1); | ||
errorText.setLayoutData(errorTextGridData); | ||
errorText.setForeground(container.getDisplay().getSystemColor(SWT.COLOR_RED)); | ||
errorText.setVisible(false); // Initially hidden | ||
|
||
setControl(container); | ||
} | ||
|
||
@Override | ||
public boolean canFlipToNextPage() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public IWizardPage getNextPage() { | ||
|
||
String input = endpointText.getText(); | ||
|
||
if (input == null || input.isEmpty() || input.isBlank()) { | ||
displayErrorMessage("Please, enter a local Ollama endpoint to proceed."); | ||
return null; | ||
} | ||
|
||
errorText.setVisible(false); | ||
return super.getNextPage(); // Proceed to the next page | ||
} | ||
|
||
private void displayErrorMessage(final String message) { | ||
errorText.setText(message); | ||
errorText.setVisible(true); | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
...e.plugin/src/com/developer/nefarious/zjoule/plugin/login/pages/SecondOllamaLoginPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.developer.nefarious.zjoule.plugin.login.pages; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.eclipse.jface.wizard.WizardPage; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.layout.GridData; | ||
import org.eclipse.swt.layout.GridLayout; | ||
import org.eclipse.swt.widgets.Combo; | ||
import org.eclipse.swt.widgets.Composite; | ||
import org.eclipse.swt.widgets.Label; | ||
|
||
public class SecondOllamaLoginPage extends WizardPage { | ||
|
||
public static final String PAGE_ID = "Ollama Login Second Page"; | ||
|
||
private Combo modelDropdown; | ||
|
||
private List<String> modelsForSelection = new ArrayList<>(); | ||
|
||
public SecondOllamaLoginPage() { | ||
super(PAGE_ID); | ||
|
||
setTitle("Ollama Setup"); | ||
setDescription("Select the Ollama model."); | ||
setPageComplete(false); // Initially set the page as incomplete | ||
} | ||
|
||
@Override | ||
public void createControl(Composite parent) { | ||
Composite container = new Composite(parent, SWT.NONE); | ||
container.setLayout(new GridLayout(2, false)); | ||
|
||
Label modelLabel = new Label(container, SWT.NONE); | ||
modelLabel.setText("Select the Model:"); | ||
|
||
modelDropdown = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY); | ||
modelDropdown.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); | ||
modelDropdown.addListener(SWT.Selection, event -> selectModel()); | ||
|
||
setControl(container); | ||
} | ||
|
||
private void selectModel() { | ||
setPageComplete(true); | ||
} | ||
|
||
public void setModelsForSelection(List<String> modelsForSelection) { | ||
modelDropdown.setItems(modelsForSelection.toArray(new String[0])); | ||
} | ||
|
||
} |