import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
if (e instanceof ThreadDeath)
throw (ThreadDeath) e;
- new CmsFeedback(getDisplay().getActiveShell(), message, e).open();
+ new CmsFeedback(null, message, e).open();
}
public static void show(String message) {
- new CmsFeedback(getDisplay().getActiveShell(), message, null).open();
+ new CmsFeedback(null, message, null).open();
}
/** Tries to find a display */
- private static Display getDisplay() {
- try {
- Display display = Display.getCurrent();
- if (display != null)
- return display;
- else
- return Display.getDefault();
- } catch (Exception e) {
- return Display.getCurrent();
- }
- }
+// private static Display getDisplay() {
+// try {
+// Display display = Display.getCurrent();
+// if (display != null)
+// return display;
+// else
+// return Display.getDefault();
+// } catch (Exception e) {
+// return Display.getCurrent();
+// }
+// }
protected Control createDialogArea(Composite parent) {
parent.setLayout(new GridLayout(2, false));
--- /dev/null
+package org.argeo.cms.ui.dialogs;
+
+import org.argeo.cms.CmsMsg;
+import org.argeo.eclipse.ui.EclipseUiUtils;
+import org.argeo.eclipse.ui.Selected;
+import org.argeo.eclipse.ui.dialogs.LightweightDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+public class CmsMessageDialog extends LightweightDialog {
+ public final static int INFORMATION = 2;
+ public final static int QUESTION = 3;
+ public final static int WARNING = 4;
+ public final static int CONFIRM = 5;
+
+ private int kind;
+ private String message;
+
+ public CmsMessageDialog(Shell parentShell, String message, int kind) {
+ super(parentShell);
+ this.kind = kind;
+ this.message = message;
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ parent.setLayout(new GridLayout());
+
+ // message
+ Composite body = new Composite(parent, SWT.NONE);
+ GridLayout bodyGridLayout = new GridLayout();
+ bodyGridLayout.marginHeight = 20;
+ bodyGridLayout.marginWidth = 20;
+ body.setLayout(bodyGridLayout);
+ body.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ Label messageLbl = new Label(body, SWT.WRAP);
+ messageLbl.setFont(EclipseUiUtils.getBoldFont(parent));
+ if (message != null)
+ messageLbl.setText(message);
+
+ // buttons
+ Composite buttons = new Composite(parent, SWT.NONE);
+ buttons.setLayoutData(new GridData(SWT.END, SWT.FILL, true, false));
+ if (kind == INFORMATION || kind == WARNING) {
+ GridLayout layout = new GridLayout(1, true);
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ buttons.setLayout(layout);
+
+ Button close = new Button(buttons, SWT.FLAT);
+ close.setText(CmsMsg.close.lead());
+ close.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+ close.addSelectionListener((Selected) (e) -> closeShell(OK));
+ } else if (kind == CONFIRM || kind == QUESTION) {
+ GridLayout layout = new GridLayout(2, true);
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ buttons.setLayout(layout);
+
+ Button cancel = new Button(buttons, SWT.FLAT);
+ cancel.setText(CmsMsg.cancel.lead());
+ cancel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+ cancel.addSelectionListener((Selected) (e) -> closeShell(CANCEL));
+
+ Button ok = new Button(buttons, SWT.FLAT);
+ ok.setText(CmsMsg.ok.lead());
+ ok.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+ ok.addSelectionListener((Selected) (e) -> closeShell(OK));
+ }
+ // pack();
+ return messageLbl;
+ }
+
+ protected Point getInitialSize() {
+ return new Point(400, 200);
+ }
+
+ public static boolean open(int kind, Shell parent, String message) {
+ CmsMessageDialog dialog = new CmsMessageDialog(parent, message, kind);
+ return dialog.open() == 0;
+ }
+
+ public static boolean openConfirm(String message) {
+ return open(CONFIRM, Display.getCurrent().getActiveShell(), message);
+ }
+
+ public static void openInformation(String message) {
+ open(INFORMATION, Display.getCurrent().getActiveShell(), message);
+ }
+
+ public static boolean openQuestion(String message) {
+ return open(QUESTION, Display.getCurrent().getActiveShell(), message);
+ }
+
+ public static void openWarning(String message) {
+ open(WARNING, Display.getCurrent().getActiveShell(), message);
+ }
+
+}
import java.lang.reflect.InvocationTargetException;
import org.argeo.cms.CmsException;
+import org.argeo.cms.CmsMsg;
import org.argeo.cms.util.CmsUtils;
import org.argeo.eclipse.ui.EclipseUiUtils;
import org.argeo.eclipse.ui.Selected;
titleBar.setLayoutData(new GridData(SWT.BEGINNING, SWT.FILL, true, false));
updateTitleBar();
Button cancelButton = new Button(messageArea, SWT.FLAT);
- cancelButton.setText("Cancel");
+ cancelButton.setText(CmsMsg.cancel.lead());
cancelButton.setLayoutData(new GridData(SWT.END, SWT.TOP, false, false, 1, 3));
cancelButton.addSelectionListener((Selected) (e) -> closeShell(CANCEL));
message = new Label(messageArea, SWT.WRAP);
if (!singlePage) {
back = new Button(buttons, SWT.PUSH);
- back.setText("Back");
+ back.setText(CmsMsg.wizardBack.lead());
back.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
back.addSelectionListener((Selected) (e) -> backPressed());
next = new Button(buttons, SWT.PUSH);
- next.setText("Next");
+ next.setText(CmsMsg.wizardNext.lead());
next.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
next.addSelectionListener((Selected) (e) -> nextPressed());
}
finish = new Button(buttons, SWT.PUSH);
- finish.setText("Finish");
+ finish.setText(CmsMsg.wizardFinish.lead());
finish.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
finish.addSelectionListener((Selected) (e) -> finishPressed());
newPassword=New password
repeatNewPassword=Repeat new password
passwordChanged=Password changed
+
+close=Close
+cancel=Cancel
+ok=Ok
+
+wizardBack=Back
+wizardNext=Next
+wizardFinish=Finish
newPassword=Neues passwort
repeatNewPassword=Newes Passwort wiederholen
passwordChanged=Passwort geändert
+
+close=Schließen
+cancel=Abbrechen
+ok=Ok
+
+wizardBack=Zurück
+wizardNext=Nächstes
+wizardFinish=Fertig
newPassword=nouveau mot de passe
repeatNewPassword=répéter le nouveau mot de passe
passwordChanged=mot de passe changé
+
+close=Fermer
+cancel=Annuler
+ok=Ok
+
+wizardBack=Précédent
+wizardNext=Suivant
+wizardFinish=Terminer
import org.argeo.cms.i18n.Localized;
public enum CmsMsg implements Localized {
- username, password, login, logout, register, changePassword, currentPassword, newPassword, repeatNewPassword, passwordChanged;
-
-
+ username, password, login, logout, register,
+ // password
+ changePassword, currentPassword, newPassword, repeatNewPassword, passwordChanged,
+ // dialog
+ close, cancel, ok,
+ // wizard
+ wizardBack, wizardNext, wizardFinish;
}
package org.argeo.cms.i18n;
+import java.text.MessageFormat;
import java.util.Locale;
/** Localized object. */
return LocaleUtils.lead(this);
}
+ default String format(Object[] args) {
+ Locale locale = LocaleUtils.getCurrentLocale();
+ MessageFormat format = new MessageFormat(local(locale).toString(), locale);
+ return format.format(args);
+ }
+
default String lead(Locale locale) {
return LocaleUtils.lead(local(locale).toString(), locale);
}
log.debug("User directory " + userDirectory.getBaseDn() + " [" + u.getScheme() + "] enabled."
+ (realm != null ? " " + realm + " realm." : ""));
- if (isSystemRolesBaseDn(baseDn)) {
- if (userAdminReg != null)
- userAdminReg.unregister();
- // register self as main user admin
- Dictionary<String, Object> userAdminregProps = currentState();
- userAdminregProps.put(NodeConstants.CN, NodeConstants.DEFAULT);
- userAdminregProps.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
- userAdminReg = bc.registerService(UserAdmin.class, this, userAdminregProps);
- }
+ // if (isSystemRolesBaseDn(baseDn)) {
+ if (userAdminReg != null)
+ userAdminReg.unregister();
+ // register self as main user admin
+ Dictionary<String, Object> userAdminregProps = currentState();
+ userAdminregProps.put(NodeConstants.CN, NodeConstants.DEFAULT);
+ userAdminregProps.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
+ userAdminReg = bc.registerService(UserAdmin.class, this, userAdminregProps);
+ // }
}
@Override
block = shouldBlock;
}
+ public void pack() {
+ foregoundShell.pack();
+ }
+
private void runEventLoop(Shell loopShell) {
Display display;
if (foregoundShell == null) {