use of org.apache.syncope.ide.eclipse.plugin.dialogs.AddTemplateDialog in project syncope by apache.
the class SyncopeView method makeActions.
private void makeActions() {
loginAction = new Action() {
public void run() {
Shell shell = viewer.getControl().getShell();
LoginDialog dialog = new LoginDialog(shell);
dialog.create();
if (dialog.open() == Window.OK) {
String deploymentUrl = dialog.getDeploymentUrl();
String username = dialog.getUsername();
String password = dialog.getPassword();
vcp.deploymentUrl = deploymentUrl;
vcp.username = username;
vcp.password = password;
updateTreeViewer();
}
}
};
loginAction.setText(LOGIN_ACTION_TEXT);
loginAction.setToolTipText(LOGIN_ACTION_TOOLTIP_TEXT);
refreshAction = new Action() {
public void run() {
updateTreeViewer();
}
};
refreshAction.setText(REFRESH_ACTION_TEXT);
refreshAction.setToolTipText(REFRESH_ACTION_TOOLTIP_TEXT);
doubleClickAction = new Action() {
public void run() {
ISelection selection = viewer.getSelection();
Object obj = ((IStructuredSelection) selection).getFirstElement();
if (!(obj instanceof TreeParent)) {
openTemplateInEditor((TreeObject) obj);
} else {
viewer.expandToLevel(obj, 1);
}
}
};
readAction = new Action() {
public void run() {
ISelection selection = viewer.getSelection();
TreeObject obj = (TreeObject) ((IStructuredSelection) selection).getFirstElement();
openTemplateInEditor(obj);
}
};
readAction.setText(READ_ACTION_TEXT);
addAction = new Action() {
public void run() {
ISelection selection = viewer.getSelection();
TreeParent tp = (TreeParent) ((IStructuredSelection) selection).getFirstElement();
Shell shell = viewer.getControl().getShell();
AddTemplateDialog addTemplateDialog = new AddTemplateDialog(shell);
addTemplateDialog.create();
if (addTemplateDialog.open() == Window.OK) {
String key = addTemplateDialog.getKey();
try {
if (tp.getName().equals(MAIL_TEMPLATE_LABEL)) {
MailTemplateService mailTemplateService = SYNCOPE_CLIENT.getService(MailTemplateService.class);
MailTemplateTO mtto = new MailTemplateTO();
mtto.setKey(key);
mailTemplateService.create(mtto);
} else if (tp.getName().equals(REPORT_TEMPLATE_LABEL)) {
ReportTemplateService reportTemplateService = SYNCOPE_CLIENT.getService(ReportTemplateService.class);
ReportTemplateTO rtto = new ReportTemplateTO();
rtto.setKey(key);
reportTemplateService.create(rtto);
}
updateTreeViewer();
} catch (final SyncopeClientException e) {
if (e.toString().contains("EntityExists")) {
MessageDialog.openError(shell, "Template already exists", "A template named " + key + " already exists.");
}
}
}
}
};
addAction.setText(ADD_ACTION_TEXT);
removeAction = new Action() {
public void run() {
ISelection selection = viewer.getSelection();
TreeObject obj = (TreeObject) ((IStructuredSelection) selection).getFirstElement();
TreeParent tp = (TreeParent) vcp.getParent(obj);
if (MAIL_TEMPLATE_LABEL.equals(tp.getName())) {
MailTemplateService mailTemplateService = SYNCOPE_CLIENT.getService(MailTemplateService.class);
mailTemplateService.delete(obj.getName());
} else if (tp.getName().equals(REPORT_TEMPLATE_LABEL)) {
ReportTemplateService reportTemplateService = SYNCOPE_CLIENT.getService(ReportTemplateService.class);
reportTemplateService.delete(obj.getName());
}
updateTreeViewer();
}
};
removeAction.setText(REMOVE_ACTION_TEXT);
}
Aggregations