use of eu.ggnet.dwoss.core.widget.auth.Guardian in project dwoss by gg-net.
the class WidgetProducers method guardian.
@Produces
public static Guardian guardian() {
Guardian g = localDl.lookup(Guardian.class);
LoggerFactory.getLogger(WidgetProducers.class).debug("guardian() produces " + g);
return g;
}
use of eu.ggnet.dwoss.core.widget.auth.Guardian in project dwoss by gg-net.
the class DwOssApplication method start.
/**
* Starting the Deutsche Warenwirtschaft Open Source application.
* The startup happens through the following steps:
* <ol>
* <li>Parameter validation via <a href="https://jcommander.org/">JCommander</a>. The required and optional parametes are defined here
* {@link ConnectionParameter}.</li>
* <li>Setting the LAF for Swing components via {@link LafMenuManager#loadAndSetUserLaf() }</li>
* <li>Displaying a placeholder main pane and the blocking login screen.
* <ul>
* <li>The login screen has no authentification system on visibility but the user can already type in his username and password.</li>
* <li>The guardian is set later and only then an authentification will happen, even if the user has pressed return before.</li>
* <li>A red/green circle in the ui displays the status of the guardian (red meaning not yet set).</li>
* </ul>
* </li>
* <li>Initialize the client backend, remote connections, saft core, and preparing the main view by wrapping the javafx pane in a swing frame.
* <ul>
* <li>{@link #initSeContainer() }</li>
* <li>{@link #initGlobalExceptionHandling() }</li>
* <li>{@link #initRemoteConnection(eu.ggnet.dwoss.assembly.client.support.ConnectionParameter) }</li>
* <li>{@link #initMainPane() }</li>
* <li>{@link #startSaftInitMainFrameAndWrapMainPane(javax.swing.JFrame, javafx.scene.layout.Pane, eu.ggnet.dwoss.assembly.client.support.ConnectionParameter)
* }</li>
* </ul>
* </li>
* <li>Activating the authentification in the login screen by calling {@link LoginScreenController#setAndActivateGuardian(eu.ggnet.saft.experimental.auth.Guardian)
* with the remote guardian</li>
* <li>Start the polling of server progress {@link MonitorManager#startPolling() }</li>
* <li>Initialize the session timeout and global keys for manual logout and relocation of windows. Ctrl+Shift+L for manual logout and Ctrl+Shift+R for
* relocation of all windows</li>
* </ol>
*
* @param primaryStage primaryStage of application.
* @throws Exception all possible exeptions.
*/
@Override
public void start(Stage primaryStage) throws Exception {
try {
// Parameter discovery is done here, cause a error will be shown via Ui.
ConnectionParameter cp = new ConnectionParameter();
JCommander.newBuilder().addObject(cp).programName(DwOssMain.class.getName()).build().parse(getParameters().getRaw().toArray(new String[] {}));
L.debug("start() parameters discovered: {}", cp);
LafMenuManager.loadAndSetUserLaf();
createAndShowMainPane(primaryStage);
// Creating the Swing MainFrame as long as we are in the Swing mode.
JFrame mainFrame = new JFrame();
LoginScreenController firstLoginScreen = createAndShowFirstLoginScreen(primaryStage, mainFrame);
CompletableFuture.runAsync(() -> {
container = initSeContainer();
instance = container.getBeanManager().createInstance();
saft = instance.select(Saft.class).get();
UiCore.initGlobal(saft);
}).thenRun(() -> initGlobalExceptionHandling()).thenRun(() -> initRemoteConnection(cp)).thenApply(v -> initMainPane()).thenAcceptAsync(mainView -> startSaftInitMainFrameAndWrapMainPane(mainFrame, mainView, cp), java.awt.EventQueue::invokeLater).thenRunAsync(() -> firstLoginScreen.setAndActivateGuardian(Dl.local().lookup(Guardian.class))).thenRun(() -> initOnceViews()).thenRun(() -> instance.select(MonitorManager.class).get().startPolling()).thenRun(() -> initSessionTimeoutAndManualLogoutKeys()).thenRun(() -> initRelocationKeys()).handle((v, ex) -> {
new DwFinalExceptionConsumer(null).accept(Optional.empty(), ex);
return null;
});
} catch (ParameterException e) {
// Sout is here correct.
System.out.println(e.getMessage());
System.out.println();
e.getJCommander().usage();
Alert a = new Alert(javafx.scene.control.Alert.AlertType.ERROR);
a.setTitle("Fehler beim Start");
a.setHeaderText("Fehler bei Start.");
a.setContentText("Es ist ein Fehler beim Start aufgetreten. Bitte Console und/oder Logs prüfen.");
a.show();
}
}
use of eu.ggnet.dwoss.core.widget.auth.Guardian in project dwoss by gg-net.
the class MandatorMetaDataController method initialize.
@Override
public void initialize(URL location, ResourceBundle resources) {
EnumSet<SalesChannel> visibleSalseChannels = EnumSet.complementOf(EnumSet.of(SalesChannel.UNKNOWN));
defaultSalesChannelsListView.setItems(visibleSalseChannels.stream().map(s -> new SelectableSalesChannel(s)).collect(Collectors.toCollection(() -> FXCollections.observableArrayList())));
defaultSalesChannelsListView.setCellFactory(CheckBoxListCell.forListView(SelectableSalesChannel::selectedProperty, new StringConverter<SelectableSalesChannel>() {
@Override
public String toString(SelectableSalesChannel t) {
return t.getSalesChannel().description;
}
@Override
public SelectableSalesChannel fromString(String string) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
}));
allowedSalesChannelsListView.setItems(visibleSalseChannels.stream().map(s -> new SelectableSalesChannel(s)).collect(Collectors.toCollection(() -> FXCollections.observableArrayList())));
allowedSalesChannelsListView.setCellFactory(CheckBoxListCell.forListView(SelectableSalesChannel::selectedProperty, new StringConverter<SelectableSalesChannel>() {
@Override
public String toString(SelectableSalesChannel t) {
return t.getSalesChannel().description;
}
@Override
public SelectableSalesChannel fromString(String string) {
// To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
}));
shippingConditionComboBox.getItems().setAll(ShippingCondition.values());
paymentConditionComboBox.getItems().setAll(PaymentCondition.values());
paymentMethodComboBox.getItems().setAll(PaymentMethod.values());
shippingConditionComboBox.setCellFactory((ListView<ShippingCondition> p) -> new FunctionListCell<>(i -> i.description));
shippingConditionComboBox.setButtonCell(new FunctionListCell<>(i -> i.description));
paymentConditionComboBox.setCellFactory((ListView<PaymentCondition> p) -> new FunctionListCell<>(i -> i.description));
paymentConditionComboBox.setButtonCell(new FunctionListCell<>(i -> i.description));
paymentMethodComboBox.setCellFactory((ListView<PaymentMethod> p) -> new FunctionListCell<>(i -> i.description));
paymentMethodComboBox.setButtonCell(new FunctionListCell<>(i -> i.description));
defaultCsd = Dl.local().lookup(CachedMandators.class).loadSalesdata();
defaultshippingConditionTextField.setText(defaultCsd.shippingCondition().description);
defaultpaymentConditionTextField.setText(defaultCsd.paymentCondition().description);
defaultpaymentMethodTextField.setText(defaultCsd.paymentMethod().description);
defaultSalesChannelsListView.getItems().forEach(i -> {
if (defaultCsd.allowedSalesChannels().contains(i.getSalesChannel()))
i.setSelected(true);
});
Guardian guardian = Dl.local().lookup(Guardian.class);
guardian.add(new NodeEnabler(AtomicRight.UPDATE_CUSTOMER_PAYMENT_CONDITION, paymentConditionComboBox));
guardian.add(new NodeEnabler(AtomicRight.UPDATE_CUSTOMER_PAYMENT_METHOD, paymentMethodComboBox));
guardian.add(new NodeEnabler(AtomicRight.UPDATE_CUSTOMER_SHIPPING_CONDITION, shippingConditionComboBox));
}
Aggregations