use of org.omegat.gui.exttrans.MTConfigDialog in project omegat by omegat-org.
the class IBMWatsonTranslate method showConfigurationUI.
@Override
public void showConfigurationUI(Window parent) {
JPanel watsonPanel = new JPanel();
watsonPanel.setLayout(new java.awt.GridBagLayout());
watsonPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 15, 0));
watsonPanel.setAlignmentX(0.0F);
// Info about IAM authentication
JLabel iamAuthLabel = new JLabel(OStrings.getString("MT_ENGINE_IBMWATSON_IAM_AUTHENTICATION"));
GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth = 2;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 5);
watsonPanel.add(iamAuthLabel, gridBagConstraints);
// API URL
JLabel urlLabel = new JLabel(OStrings.getString("MT_ENGINE_IBMWATSON_URL"));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 5);
watsonPanel.add(urlLabel, gridBagConstraints);
JTextField urlField = new JTextField(Preferences.getPreferenceDefault(PROPERTY_URL, WATSON_URL));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.ipadx = 50;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 0);
urlLabel.setLabelFor(urlField);
watsonPanel.add(urlField, gridBagConstraints);
// Custom Model
JLabel modelIdLabel = new JLabel(OStrings.getString("MT_ENGINE_IBMWATSON_MODELID_LABEL"));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 5);
watsonPanel.add(modelIdLabel, gridBagConstraints);
JTextField modelIdField = new JTextField(Preferences.getPreferenceDefault(PROPERTY_MODEL, ""));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.ipadx = 50;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 0);
modelIdLabel.setLabelFor(modelIdField);
watsonPanel.add(modelIdField, gridBagConstraints);
MTConfigDialog dialog = new MTConfigDialog(parent, getName()) {
@Override
protected void onConfirm() {
boolean temporary = panel.temporaryCheckBox.isSelected();
String login = panel.valueField1.getText().trim();
setCredential(PROPERTY_LOGIN, login, temporary);
String password = panel.valueField2.getText().trim();
setCredential(PROPERTY_PASSWORD, password, temporary);
System.setProperty(PROPERTY_MODEL, modelIdField.getText());
Preferences.setPreference(PROPERTY_MODEL, modelIdField.getText());
System.setProperty(PROPERTY_URL, urlField.getText());
Preferences.setPreference(PROPERTY_URL, urlField.getText());
}
};
dialog.panel.valueLabel1.setText(OStrings.getString("MT_ENGINE_IBMWATSON_LOGIN_LABEL"));
dialog.panel.valueField1.setText(getCredential(PROPERTY_LOGIN));
dialog.panel.valueLabel2.setText(OStrings.getString("MT_ENGINE_IBMWATSON_PASSWORD_LABEL"));
dialog.panel.valueField2.setText(getCredential(PROPERTY_PASSWORD));
// TODO Apparently, the API URL can change if the user has their own instance.
dialog.panel.temporaryCheckBox.setSelected(isCredentialStoredTemporarily(PROPERTY_PASSWORD));
dialog.panel.itemsPanel.add(watsonPanel);
dialog.show();
}
use of org.omegat.gui.exttrans.MTConfigDialog in project omegat by omegat-org.
the class YandexCloudTranslate method showConfigurationUI.
@Override
public void showConfigurationUI(Window parent) {
JPanel extraPanel = new JPanel();
extraPanel.setAlignmentX(JComponent.LEFT_ALIGNMENT);
extraPanel.setLayout(new BoxLayout(extraPanel, BoxLayout.Y_AXIS));
extraPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 15, 0));
JCheckBox glossaryCheckBox = new JCheckBox(OStrings.getString("MT_ENGINE_YANDEX_CLOUD_GLOSSARY_CHECKBOX"));
extraPanel.add(glossaryCheckBox);
JCheckBox keepTagsCheckBox = new JCheckBox(OStrings.getString("MT_ENGINE_YANDEX_CLOUD_KEEP_TAGS_CHECKBOX"));
extraPanel.add(keepTagsCheckBox);
MTConfigDialog dialog = new MTConfigDialog(parent, getName()) {
@Override
protected void onConfirm() {
boolean temporary = panel.temporaryCheckBox.isSelected();
String folderId = panel.valueField1.getText().trim();
setCredential(PROPERTY_FOLDER_ID, folderId, temporary);
String oAuthToken = panel.valueField2.getText().trim();
setCredential(PROPERTY_OAUTH_TOKEN, oAuthToken, temporary);
Preferences.setPreference(PROPERTY_USE_GLOSSARY, glossaryCheckBox.isSelected());
Preferences.setPreference(PROPERTY_KEEP_TAGS, keepTagsCheckBox.isSelected());
}
};
dialog.panel.itemsPanel.add(extraPanel);
dialog.panel.valueLabel1.setText(OStrings.getString("MT_ENGINE_YANDEX_CLOUD_FOLDER_ID_LABEL"));
dialog.panel.valueField1.setText(getCredential(PROPERTY_FOLDER_ID));
dialog.panel.valueLabel2.setText(OStrings.getString("MT_ENGINE_YANDEX_CLOUD_OAUTH_TOKEN_LABEL"));
dialog.panel.valueField2.setText(getCredential(PROPERTY_OAUTH_TOKEN));
dialog.panel.temporaryCheckBox.setSelected(isCredentialStoredTemporarily(PROPERTY_OAUTH_TOKEN));
glossaryCheckBox.setSelected(Preferences.isPreferenceDefault(PROPERTY_USE_GLOSSARY, false));
keepTagsCheckBox.setSelected(Preferences.isPreferenceDefault(PROPERTY_KEEP_TAGS, true));
dialog.show();
}
use of org.omegat.gui.exttrans.MTConfigDialog in project omegat by omegat-org.
the class ApertiumTranslate method showConfigurationUI.
/**
* Show configuration UI.
* @param parent main window.
*/
@Override
public void showConfigurationUI(Window parent) {
JCheckBox unkCheckBox = new JCheckBox(OStrings.getString("APERTIUM_MARKUNKNOWN_LABEL"));
unkCheckBox.setSelected(useMarkUnknown());
JCheckBox apiCheckBox = new JCheckBox(OStrings.getString("APERTIUM_CUSTOM_SERVER_LABEL"));
apiCheckBox.setSelected(useCustomServer());
MTConfigDialog dialog = new MTConfigDialog(parent, getName()) {
@Override
protected void onConfirm() {
boolean temporary = panel.temporaryCheckBox.isSelected();
System.setProperty(PROPERTY_APERTIUM_MARKUNKNOWN, Boolean.toString(unkCheckBox.isSelected()));
Preferences.setPreference(PROPERTY_APERTIUM_MARKUNKNOWN, unkCheckBox.isSelected());
System.setProperty(PROPERTY_APERTIUM_SERVER_CUSTOM, Boolean.toString(apiCheckBox.isSelected()));
Preferences.setPreference(PROPERTY_APERTIUM_SERVER_CUSTOM, apiCheckBox.isSelected());
String server = panel.valueField1.getText().trim();
String apiKey = panel.valueField2.getText().trim();
if (!getCustomServerUrl().equals(server)) {
clearCache();
}
System.setProperty(PROPERTY_APERTIUM_SERVER_URL, server);
Preferences.setPreference(PROPERTY_APERTIUM_SERVER_URL, server);
setCredential(PROPERTY_APERTIUM_SERVER_KEY, apiKey, temporary);
}
};
Runnable updateOk = () -> {
boolean needsFields = apiCheckBox.isSelected();
boolean hasFields = !dialog.panel.valueField1.getText().trim().isEmpty();
boolean canConfirm = !needsFields || hasFields;
dialog.panel.okButton.setEnabled(canConfirm);
};
DocumentListener toggleOkButton = new DocumentListener() {
@Override
public void changedUpdate(DocumentEvent event) {
updateOk.run();
}
public void insertUpdate(DocumentEvent event) {
updateOk.run();
}
public void removeUpdate(DocumentEvent event) {
updateOk.run();
}
};
ItemListener toggleInterface = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent event) {
dialog.panel.valueLabel1.setEnabled(apiCheckBox.isSelected());
dialog.panel.valueLabel2.setEnabled(apiCheckBox.isSelected());
dialog.panel.valueField1.setEnabled(apiCheckBox.isSelected());
dialog.panel.valueField2.setEnabled(apiCheckBox.isSelected());
dialog.panel.temporaryCheckBox.setEnabled(apiCheckBox.isSelected());
updateOk.run();
}
};
apiCheckBox.addItemListener(toggleInterface);
dialog.panel.valueField1.getDocument().addDocumentListener(toggleOkButton);
dialog.panel.itemsPanel.add(unkCheckBox);
dialog.panel.itemsPanel.add(apiCheckBox, 1);
dialog.panel.valueLabel1.setText(OStrings.getString("APERTIUM_CUSTOM_SERVER_URL_LABEL"));
dialog.panel.valueField1.setText(getCustomServerUrl());
dialog.panel.valueField1.setColumns(CONFIG_URL_COLUMN_WIDTH);
dialog.panel.valueLabel2.setText(OStrings.getString("APERTIUM_CUSTOM_SERVER_KEY_LABEL"));
dialog.panel.valueField2.setText(getCredential(PROPERTY_APERTIUM_SERVER_KEY));
dialog.panel.temporaryCheckBox.setSelected(isCredentialStoredTemporarily(PROPERTY_APERTIUM_SERVER_KEY));
toggleInterface.itemStateChanged(null);
dialog.show();
}
use of org.omegat.gui.exttrans.MTConfigDialog in project omegat by omegat-org.
the class AbstractMyMemoryTranslate method showConfigurationUI.
/**
* Default configuration UI.
*/
@Override
public void showConfigurationUI(Window parent) {
MTConfigDialog dialog = new MTConfigDialog(parent, getName()) {
@Override
protected void onConfirm() {
String email = panel.valueField1.getText().trim();
boolean temporary = panel.temporaryCheckBox.isSelected();
setCredential(MYMEMORY_API_EMAIL, email, temporary);
}
};
dialog.panel.valueLabel1.setText(OStrings.getString("MT_ENGINE_MYMEMORY_EMAIL_LABEL"));
dialog.panel.valueField1.setText(getCredential(MYMEMORY_API_EMAIL));
dialog.panel.valueLabel2.setText(OStrings.getString("MT_ENGINE_MYMEMORY_API_KEY_LABEL"));
dialog.panel.valueField2.setText(getCredential(MYMEMORY_API_KEY));
dialog.panel.temporaryCheckBox.setSelected(isCredentialStoredTemporarily(MYMEMORY_API_EMAIL));
dialog.show();
}
use of org.omegat.gui.exttrans.MTConfigDialog in project omegat by omegat-org.
the class Google2Translate method showConfigurationUI.
/**
* Default configuration UI.
* @param parent main window.
*/
@Override
public void showConfigurationUI(Window parent) {
JCheckBox premiumCheckBox = new JCheckBox(OStrings.getString("MT_ENGINE_GOOGLE2_PREMIUM_LABEL"));
premiumCheckBox.setSelected(isPremium());
MTConfigDialog dialog = new MTConfigDialog(parent, getName()) {
@Override
protected void onConfirm() {
String key = panel.valueField1.getText().trim();
boolean temporary = panel.temporaryCheckBox.isSelected();
setCredential(PROPERTY_API_KEY, key, temporary);
System.setProperty(PROPERTY_PREMIUM_KEY, Boolean.toString(premiumCheckBox.isSelected()));
Preferences.setPreference(PROPERTY_PREMIUM_KEY, premiumCheckBox.isSelected());
}
};
dialog.panel.valueLabel1.setText(OStrings.getString("MT_ENGINE_GOOGLE2_API_KEY_LABEL"));
dialog.panel.valueField1.setText(getCredential(PROPERTY_API_KEY));
dialog.panel.valueLabel2.setVisible(false);
dialog.panel.valueField2.setVisible(false);
dialog.panel.temporaryCheckBox.setSelected(isCredentialStoredTemporarily(PROPERTY_API_KEY));
dialog.panel.itemsPanel.add(premiumCheckBox);
dialog.show();
}
Aggregations