use of org.knime.base.node.jsnippet.template.JavaSnippetTemplate in project knime-core by knime.
the class JavaSnippetNodeDialog method createTemplateInfoPanel.
/**
* The panel at the to with the "Create Template..." Button.
*/
private JPanel createTemplateInfoPanel(final boolean isPreview) {
final JButton addTemplateButton = new JButton("Create Template...");
addTemplateButton.addActionListener(e -> {
final Frame parent = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, addTemplateButton);
final JavaSnippetTemplate newTemplate = AddTemplateDialog.openUserDialog(parent, m_snippet, m_templateMetaCategory, JavaSnippetTemplateProvider.getDefault());
if (null != newTemplate) {
JavaSnippetTemplateProvider.getDefault().addTemplate(newTemplate);
// update the template UUID of the current snippet
m_settings.setTemplateUUID(newTemplate.getUUID());
final String loc = JavaSnippetTemplateProvider.getDefault().getDisplayLocation(newTemplate);
m_templateLocation.setText(loc);
JavaSnippetNodeDialog.this.getPanel().validate();
}
});
final JPanel templateInfoPanel = new JPanel(new BorderLayout());
m_templateLocation = new JLabel(getTemplateLocation());
if (isPreview) {
templateInfoPanel.add(m_templateLocation, BorderLayout.CENTER);
} else {
templateInfoPanel.add(addTemplateButton, BorderLayout.LINE_END);
}
templateInfoPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
return templateInfoPanel;
}
use of org.knime.base.node.jsnippet.template.JavaSnippetTemplate in project knime-core by knime.
the class JavaSnippetNodeDialog method getTemplateLocation.
/* Get the location of the template set in the settings. (empty string if none set) */
private String getTemplateLocation() {
final TemplateProvider<JavaSnippetTemplate> provider = JavaSnippetTemplateProvider.getDefault();
final String uuid = m_settings.getTemplateUUID();
final JavaSnippetTemplate template = null != uuid ? provider.getTemplate(UUID.fromString(uuid)) : null;
final String loc = null != template ? createTemplateLocationText(template) : "";
return loc;
}
Aggregations