use of org.omegat.gui.exttrans.MTConfigDialog in project omegat by omegat-org.
the class MicrosoftTranslatorAzure method showConfigurationUI.
@Override
public void showConfigurationUI(Window parent) {
JCheckBox neuralCheckBox = new JCheckBox(OStrings.getString("MT_ENGINE_MICROSOFT_NEURAL_LABEL"));
neuralCheckBox.setSelected(isNeural());
MTConfigDialog dialog = new MTConfigDialog(parent, getName()) {
@Override
protected void onConfirm() {
String key = panel.valueField1.getText().trim();
boolean temporary = panel.temporaryCheckBox.isSelected();
setCredential(PROPERTY_SUBSCRIPTION_KEY, key, temporary);
System.setProperty(PROPERTY_NEURAL, Boolean.toString(neuralCheckBox.isSelected()));
Preferences.setPreference(PROPERTY_NEURAL, neuralCheckBox.isSelected());
}
};
dialog.panel.valueLabel1.setText(OStrings.getString("MT_ENGINE_MICROSOFT_SUBSCRIPTION_KEY_LABEL"));
dialog.panel.valueField1.setText(getCredential(PROPERTY_SUBSCRIPTION_KEY));
dialog.panel.valueLabel2.setVisible(false);
dialog.panel.valueField2.setVisible(false);
dialog.panel.temporaryCheckBox.setSelected(isCredentialStoredTemporarily(PROPERTY_SUBSCRIPTION_KEY));
dialog.panel.itemsPanel.add(neuralCheckBox);
dialog.show();
}
use of org.omegat.gui.exttrans.MTConfigDialog in project omegat by omegat-org.
the class MosesTranslate method showConfigurationUI.
@Override
public void showConfigurationUI(Window parent) {
MTConfigDialog dialog = new MTConfigDialog(parent, getName()) {
@Override
protected void onConfirm() {
String url = panel.valueField1.getText().trim();
System.setProperty(PROPERTY_MOSES_URL, url);
Preferences.setPreference(PROPERTY_MOSES_URL, url);
}
};
JLabel messageLabel = new JLabel();
JButton testButton = new JButton(OStrings.getString("MT_ENGINE_MOSES_TEST_BUTTON"));
testButton.addActionListener(e -> {
messageLabel.setText(OStrings.getString("MT_ENGINE_MOSES_TEST_TESTING"));
String url = dialog.panel.valueField1.getText().trim();
new SwingWorker<String, Void>() {
@Override
protected String doInBackground() throws Exception {
XmlRpcClient client = getClient(new URL(url));
Object response = client.execute("system.listMethods", (Object[]) null);
if (Arrays.asList(((Object[]) response)).contains("translate")) {
return OStrings.getString("MT_ENGINE_MOSES_TEST_RESULT_OK");
} else {
return OStrings.getString("MT_ENGINE_MOSES_TEST_RESULT_NO_TRANSLATE");
}
}
@Override
protected void done() {
String message = null;
try {
message = get();
} catch (ExecutionException e) {
message = e.getCause().getLocalizedMessage();
Logger.getLogger(getClass().getName()).log(Level.SEVERE, message, e);
} catch (Exception e) {
message = e.getLocalizedMessage();
Logger.getLogger(getClass().getName()).log(Level.SEVERE, message, e);
}
messageLabel.setText(message);
}
}.execute();
});
JPanel testPanel = new JPanel();
testPanel.setLayout(new BoxLayout(testPanel, BoxLayout.LINE_AXIS));
testPanel.add(testButton);
testPanel.add(messageLabel);
testPanel.setAlignmentX(0);
dialog.panel.itemsPanel.add(testPanel);
dialog.panel.valueLabel1.setText(OStrings.getString("MT_ENGINE_MOSES_URL_LABEL"));
dialog.panel.valueField1.setText(getServerUrl());
dialog.panel.valueField1.setColumns(20);
dialog.panel.valueLabel2.setVisible(false);
dialog.panel.valueField2.setVisible(false);
dialog.panel.temporaryCheckBox.setVisible(false);
dialog.show();
}
use of org.omegat.gui.exttrans.MTConfigDialog in project omegat by omegat-org.
the class DeepLTranslate method showConfigurationUI.
@Override
public void showConfigurationUI(Window parent) {
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);
}
};
dialog.panel.valueLabel1.setText(OStrings.getString("MT_ENGINE_DEEPL_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.show();
}
use of org.omegat.gui.exttrans.MTConfigDialog in project omegat by omegat-org.
the class YandexTranslate method showConfigurationUI.
@Override
public void showConfigurationUI(Window parent) {
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);
}
};
dialog.panel.valueLabel1.setText(OStrings.getString("MT_ENGINE_YANDEX_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.show();
}
Aggregations