use of com.archimatetool.templates.model.ITemplate in project archi by archimatetool.
the class TemplateManagerDialog method openTemplate.
/**
* Add a Template file
*/
protected void openTemplate() {
FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
dialog.setText(Messages.TemplateManagerDialog_13);
// $NON-NLS-1$ //$NON-NLS-2$
dialog.setFilterExtensions(new String[] { "*" + fTemplateManager.getTemplateFileExtension(), "*.*" });
String path = dialog.open();
if (path == null) {
return;
}
final File file = new File(path);
if (hasUserTemplate(file)) {
MessageDialog.openInformation(getShell(), Messages.TemplateManagerDialog_16, Messages.TemplateManagerDialog_17);
return;
}
BusyIndicator.showWhile(null, new Runnable() {
@Override
public void run() {
try {
ITemplate template = fTemplateManager.createTemplate(file);
template.setFile(file);
fTemplateManager.addUserTemplate(template);
fTableViewer.refresh();
} catch (IOException ex) {
MessageDialog.openError(getShell(), Messages.TemplateManagerDialog_18, ex.getMessage());
}
}
});
}
use of com.archimatetool.templates.model.ITemplate in project archi by archimatetool.
the class TemplateManagerDialogDragDropHandler method copy.
private void copy(ITemplateGroup parent) {
IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
// From Table to Tree
for (Object o : selection.toArray()) {
if (o instanceof ITemplate) {
if (!parent.getTemplates().contains(o)) {
parent.addTemplate((ITemplate) o);
}
}
}
fTreeViewer.refresh();
}
use of com.archimatetool.templates.model.ITemplate in project archi by archimatetool.
the class ArchimateTemplateManager method loadInbuiltTemplates.
@Override
protected ITemplateGroup loadInbuiltTemplates() {
ITemplateGroup group = new TemplateGroup(Messages.ArchimateTemplateManager_2);
File folder = ArchiTemplatesPlugin.INSTANCE.getTemplatesFolder();
if (folder.exists()) {
for (File file : folder.listFiles()) {
if (file.getName().toLowerCase().endsWith(ARCHIMATE_TEMPLATE_FILE_EXTENSION)) {
ITemplate template = new ArchimateModelTemplate();
template.setFile(file);
group.addTemplate(template);
}
}
}
return group;
}
use of com.archimatetool.templates.model.ITemplate in project archi by archimatetool.
the class NewCanvasFromTemplateWizard method performFinish.
@Override
public boolean performFinish() {
// Get template
ITemplate template = fMainPage.getSelectedTemplate();
if (template == null) {
return false;
}
getContainer().getShell().setVisible(false);
fErrorMessage = null;
final File zipFile = template.getFile();
if (zipFile != null && zipFile.exists()) {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
@Override
public void run() {
try {
fErrorMessage = null;
// $NON-NLS-1$
File tmp = File.createTempFile("~architemplate", null);
tmp.deleteOnExit();
File file = ZipUtils.extractZipEntry(zipFile, TemplateManager.ZIP_ENTRY_MODEL, tmp);
if (file != null && file.exists()) {
createNewCanvasFromTemplate(file);
} else {
fErrorMessage = Messages.NewCanvasFromTemplateWizard_1;
}
tmp.delete();
} catch (Exception ex) {
ex.printStackTrace();
// $NON-NLS-1$
fErrorMessage = Messages.NewCanvasFromTemplateWizard_2 + " " + ex.getMessage();
}
}
});
}
if (fErrorMessage != null) {
MessageDialog.openError(getShell(), Messages.NewCanvasFromTemplateWizard_3, fErrorMessage);
getContainer().getShell().setVisible(true);
}
return fErrorMessage == null;
}
use of com.archimatetool.templates.model.ITemplate in project archi by archimatetool.
the class CanvasTemplateManager method loadInbuiltTemplates.
@Override
protected ITemplateGroup loadInbuiltTemplates() {
ITemplateGroup group = new TemplateGroup(Messages.CanvasTemplateManager_0);
File folder = CanvasEditorPlugin.INSTANCE.getTemplatesFolder();
if (folder.exists()) {
for (File file : folder.listFiles()) {
if (file.getName().toLowerCase().endsWith(CANVAS_TEMPLATE_FILE_EXTENSION)) {
ITemplate template = new CanvasModelTemplate();
template.setFile(file);
group.addTemplate(template);
}
}
}
return group;
}
Aggregations