use of net.parostroj.timetable.utils.AttributeReference in project grafikon by jub77.
the class OutputTemplateDialog method initComponents.
private void initComponents() {
javax.swing.JPanel controlPanel = new javax.swing.JPanel();
javax.swing.JPanel buttonPanel = new javax.swing.JPanel();
((FlowLayout) buttonPanel.getLayout()).setAlignment(FlowLayout.RIGHT);
okButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE);
controlPanel.setLayout(new java.awt.BorderLayout());
// NOI18N
okButton.setText(ResourceLoader.getString("button.ok"));
okButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
okButtonActionPerformed(evt);
}
});
buttonPanel.add(okButton);
// NOI18N
cancelButton.setText(ResourceLoader.getString("button.cancel"));
cancelButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
buttonPanel.add(cancelButton);
controlPanel.add(buttonPanel, BorderLayout.EAST);
getContentPane().add(controlPanel, java.awt.BorderLayout.SOUTH);
JPanel leftPanel = new JPanel();
controlPanel.add(leftPanel, BorderLayout.WEST);
// NOI18N
JButton importTextsButton = new JButton(ResourceLoader.getString("ot.button.import.texts"));
importTextsButton.addActionListener(event -> {
importTextFromTemplate();
});
leftPanel.add(importTextsButton);
// NOI18N
JButton attachmentsButton = new JButton(ResourceLoader.getString("ot.button.attachments"));
leftPanel.add(attachmentsButton);
attachmentsButton.addActionListener(evt -> {
EditAttachmentsDialog dialog = EditAttachmentsDialog.newInstance(GuiComponentUtils.getWindow(this), true, attachmentChooser);
dialog.setLocationRelativeTo(this);
dialog.showDialog(template);
});
// NOI18N
JButton writeTemplateOutputButton = new JButton(ResourceLoader.getString("ot.button.output"));
leftPanel.add(writeTemplateOutputButton);
writeTemplateOutputButton.setEnabled(this.templateWriter != null);
writeTemplateOutputButton.addActionListener(evt -> {
OutputTemplate tempTemplate = this.createTempOutputTemplate();
if (tempTemplate != null) {
templateWriter.accept(tempTemplate);
}
});
tabbedPane = new javax.swing.JTabbedPane(javax.swing.JTabbedPane.TOP);
tabbedPane.addChangeListener(e -> {
if (scriptEditBox != null) {
scriptEditBox.closeSearchDialog();
}
if (textTemplateEditBox != null) {
textTemplateEditBox.closeSearchDialog();
}
});
getContentPane().add(tabbedPane, BorderLayout.CENTER);
javax.swing.JPanel templatePanel = new javax.swing.JPanel();
// NOI18N
tabbedPane.addTab(ResourceLoader.getString("ot.tab.template"), null, templatePanel, null);
templatePanel.setLayout(new BorderLayout(0, 0));
textTemplateEditBox = new net.parostroj.timetable.gui.components.TextTemplateEditBox2();
templatePanel.add(textTemplateEditBox);
// NOI18N
textTemplateEditBox.setTemplateFont(new java.awt.Font("Monospaced", 0, 12));
textTemplateEditBox.setColumns(80);
textTemplateEditBox.setRows(25);
textTemplateEditBox.setVisibleTemplateLanguageChange(false);
javax.swing.JPanel verifyPanel = new javax.swing.JPanel();
templatePanel.add(verifyPanel, BorderLayout.SOUTH);
FlowLayout flowLayout1 = (FlowLayout) verifyPanel.getLayout();
flowLayout1.setAlignment(FlowLayout.LEFT);
keyTextField = new javax.swing.JTextField(15);
outputComboBox = new javax.swing.JComboBox<>();
outputComboBox.setPrototypeDisplayValue("MMMMMM");
outputTypeComboBox = new javax.swing.JComboBox<>();
outputTypeComboBox.setPrototypeDisplayValue("MMMMMMMMMMM");
outputComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
String output = (String) e.getItem();
if (template != null) {
template.setAttribute(OutputTemplate.ATTR_OUTPUT, output);
}
outputTypeComboBox.removeAllItems();
for (String type : OutputFactory.newInstance(output).getOutputTypes()) {
outputTypeComboBox.addItem(type);
}
if (template != null) {
if (OUTPUTS_WITH_TEMPLATE.contains(output)) {
updateValues(false);
} else {
updateValues(true);
}
}
}
}
});
verifyPanel.add(keyTextField);
verifyPanel.add(outputComboBox);
verifyPanel.add(outputTypeComboBox);
verifyButton = new javax.swing.JButton();
// NOI18N
verifyButton.setText(ResourceLoader.getString("ot.button.verify"));
verifyButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
verifyButtonActionPerformed(evt);
}
});
verifyPanel.add(verifyButton);
javax.swing.JLabel suffixLabel = new javax.swing.JLabel(ResourceLoader.getString("ot.extension") + ":");
verifyPanel.add(suffixLabel);
extensionTextField = new javax.swing.JTextField();
verifyPanel.add(extensionTextField);
extensionTextField.setColumns(10);
selectionTypeComboBox = new JComboBox<>();
ModelObjectTypeWrapperDelegate motwd = new ModelObjectTypeWrapperDelegate();
selectionTypeComboBox.addItem(Wrapper.getWrapper(null, motwd));
for (ModelObjectType type : ModelObjectType.values()) {
selectionTypeComboBox.addItem(Wrapper.getWrapper(type, motwd));
}
JLabel selectionLabel = new JLabel(ResourceLoader.getString("ot.selection.type") + ":");
verifyPanel.add(selectionLabel);
verifyPanel.add(selectionTypeComboBox);
javax.swing.JPanel scriptPanel = new javax.swing.JPanel();
// NOI18N
tabbedPane.addTab(ResourceLoader.getString("ot.tab.script"), null, scriptPanel, null);
scriptPanel.setLayout(new BorderLayout(0, 0));
scriptEditBox = new ScriptEditBox();
scriptPanel.add(scriptEditBox);
scriptEditBox.setScriptFont(new Font("Monospaced", Font.PLAIN, 12));
scriptEditBox.setRows(15);
scriptEditBox.setColumns(60);
EditLocalizedStringListAddRemovePanel<AttributeReference<LocalizedString>> localizePanel = new EditLocalizedStringListAddRemovePanel<>(5, false);
localizePanel.setModelProvider(i18nProvider);
localizePanel.setPath(new Path("this"));
localizePanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
// NOI18N
tabbedPane.addTab(ResourceLoader.getString("ot.tab.localization"), null, localizePanel, null);
setupPanel = new AttributesPanel();
setupPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
tabbedPane.addTab(ResourceLoader.getString("ot.tab.setup"), null, setupPanel, null);
JPanel namePanel = new JPanel();
namePanel.setBorder(new EmptyBorder(5, 5, 5, 5));
namePanel.setLayout(new BorderLayout(0, 0));
// NOI18N
tabbedPane.addTab(ResourceLoader.getString("ot.name"), null, namePanel, null);
EditLocalizedStringPanel nameEditPanel = new EditLocalizedStringPanel(5);
nameEditPanel.setModelProvider(nameProvider);
nameEditPanel.setPath(new Path("this"));
namePanel.add(nameEditPanel, BorderLayout.CENTER);
JPanel descriptionPanel = new JPanel();
descriptionPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
descriptionPanel.setLayout(new BorderLayout(0, 0));
// NOI18N
tabbedPane.addTab(ResourceLoader.getString("ot.tab.description"), null, descriptionPanel, null);
descriptionTextArea = new EditLocalizedStringMultilinePanel(5, 5);
// same font as script area
descriptionTextArea.setFont(scriptEditBox.getScriptFont());
descriptionPanel.add(descriptionTextArea);
scriptCheckBox = new javax.swing.JCheckBox();
scriptCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean isScript = scriptCheckBox.isSelected();
scriptEditBox.setEnabled(isScript);
extensionTextField.setEnabled(!isScript);
if (isScript) {
extensionTextField.setText(null);
try {
scriptEditBox.setScript(Script.createScript(DEFAULT_OUTPUT_SCRIPT, Script.Language.GROOVY));
} catch (GrafikonException e1) {
log.error("Error creating script.", e);
}
} else {
scriptEditBox.setScript(null);
}
}
});
scriptEditBox.addComponentToEditBox(scriptCheckBox);
pack();
}
Aggregations