List of usage examples for javax.swing SwingConstants CENTER
int CENTER
To view the source code for javax.swing SwingConstants CENTER.
Click Source Link
From source file:uk.ac.ucl.cs.cmic.giftcloud.restserver.GiftCloudLoginDialog.java
public PasswordAuthentication getPasswordAuthentication(final String prompt) { // Set the default background colour to white UIManager UI = new UIManager(); UI.put("OptionPane.background", Color.white); UI.put("Panel.background", Color.white); String defaultUserName = ""; if (giftCloudProperties.getLastUserName().isPresent()) { defaultUserName = giftCloudProperties.getLastUserName().get(); }// w ww .j a va 2 s . co m // Create a panel for entering username and password final JPanel usernamePasswordPanel = new JPanel(new GridBagLayout()); final JLabel promptField = new JLabel(prompt, SwingConstants.CENTER); final JTextField usernameField = new JTextField(defaultUserName, 16); final JPasswordField passwordField = new JPasswordField(16); // Add a special listener to get the focus onto the username field when the component is created, or password if the username has already been populated from the default value if (StringUtils.isBlank(defaultUserName)) { usernameField.addAncestorListener(new RequestFocusListener()); } else { passwordField.addAncestorListener(new RequestFocusListener()); } usernamePasswordPanel.add(promptField, promptConstraint); usernamePasswordPanel.add(new JLabel("Username:"), labelConstraint); usernamePasswordPanel.add(usernameField, fieldConstraint); usernamePasswordPanel.add(new JLabel("Password:"), labelConstraint); usernamePasswordPanel.add(passwordField, fieldConstraint); // Show the login dialog final int returnValue = JOptionPane.showConfirmDialog(new JDialog(getFrame(parent)), usernamePasswordPanel, LOGIN_DIALOG_TITLE, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, icon); if (JOptionPane.OK_OPTION == returnValue) { giftCloudProperties.setLastUserName(usernameField.getText()); giftCloudProperties.setLastPassword(passwordField.getPassword()); giftCloudProperties.save(); return new PasswordAuthentication(usernameField.getText(), passwordField.getPassword()); } else { return null; } }
From source file:uk.ac.ucl.cs.cmic.giftcloud.uploadapp.ConfigurationDialog.java
ConfigurationDialog(final Component owner, final UploaderGuiController controller, final GiftCloudPropertiesFromApplication giftCloudProperties, final ProjectListModel projectListModel, final ResourceBundle resourceBundle, final GiftCloudDialogs giftCloudDialogs, final GiftCloudReporter reporter) { this.controller = controller; this.giftCloudProperties = giftCloudProperties; this.projectListModel = projectListModel; this.resourceBundle = resourceBundle; this.giftCloudDialogs = giftCloudDialogs; this.reporter = reporter; temporaryDropDownListModel = new TemporaryProjectListModel(projectListModel, giftCloudProperties.getLastProject()); componentToCenterDialogOver = owner; dialog = new JDialog(); dialog.setModal(true);// w w w. j a v a 2 s .c o m dialog.setResizable(false); // Call custom dialog close code when the close button is clicked dialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); dialog.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { closeDialog(); } }); dialog.setLocationRelativeTo(componentToCenterDialogOver); // without this, appears at TLHC rather then center of parent or screen dialog.setTitle(resourceBundle.getString("configurationDialogTitle")); final GridBagConstraints sectionTitleConstraints = new GridBagConstraints(); sectionTitleConstraints.gridx = 0; sectionTitleConstraints.gridy = 1; sectionTitleConstraints.gridwidth = 2; sectionTitleConstraints.weightx = 1; sectionTitleConstraints.weighty = 1; sectionTitleConstraints.anchor = GridBagConstraints.CENTER; sectionTitleConstraints.fill = GridBagConstraints.HORIZONTAL; final GridBagConstraints labelConstraints = new GridBagConstraints(); labelConstraints.gridx = 0; labelConstraints.gridy = 0; labelConstraints.gridwidth = 1; labelConstraints.weightx = 1; labelConstraints.weighty = 1; labelConstraints.anchor = GridBagConstraints.LINE_START; labelConstraints.fill = GridBagConstraints.NONE; final GridBagConstraints inputConstraints = new GridBagConstraints(); inputConstraints.gridx = 1; inputConstraints.gridy = 0; inputConstraints.gridwidth = 1; inputConstraints.weightx = 1; inputConstraints.weighty = 1; inputConstraints.anchor = GridBagConstraints.LINE_END; inputConstraints.fill = GridBagConstraints.HORIZONTAL; GridBagConstraints separatorConstraint = new GridBagConstraints(); separatorConstraint.weightx = 1.0; separatorConstraint.fill = GridBagConstraints.HORIZONTAL; separatorConstraint.gridwidth = GridBagConstraints.REMAINDER; // The panel containing the GIFT-Cloud server configuration final JPanel giftCloudServerPanel = new JPanel(); { GridBagLayout projectUploadlayout = new GridBagLayout(); giftCloudServerPanel.setLayout(projectUploadlayout); JLabel serverPanelLabel = new JLabel(resourceBundle.getString("configPanelServerConfig"), SwingConstants.CENTER); giftCloudServerPanel.add(serverPanelLabel, sectionTitleConstraints); // GIFT-Cloud server URL { labelConstraints.gridwidth = 1; labelConstraints.gridy = 2; final JLabel giftCloudServerLabel = new JLabel(resourceBundle.getString("giftCloudServerText"), SwingConstants.RIGHT); giftCloudServerLabel.setToolTipText(resourceBundle.getString("giftCloudServerTextToolTipText")); giftCloudServerPanel.add(giftCloudServerLabel, labelConstraints); giftCloudServerText = new AutoFocusTextField(giftCloudProperties.getGiftCloudUrl().orElse(""), textFieldLengthForGiftCloudServerUrl); inputConstraints.gridy = 2; giftCloudServerPanel.add(giftCloudServerText, inputConstraints); } // GIFT-Cloud username { labelConstraints.gridy = 3; final JLabel giftCloudUserNameLabel = new JLabel(resourceBundle.getString("giftCloudUsername"), SwingConstants.RIGHT); giftCloudUserNameLabel.setToolTipText(resourceBundle.getString("giftCloudUsernameToolTipText")); giftCloudServerPanel.add(giftCloudUserNameLabel, labelConstraints); final Optional<String> serverUrl = giftCloudProperties.getLastUserName(); final String initialServerText = serverUrl.isPresent() ? serverUrl.get() : ""; giftCloudUsernameText = new AutoFocusTextField(initialServerText); inputConstraints.gridy = 3; giftCloudServerPanel.add(giftCloudUsernameText, inputConstraints); } // GIFT-Cloud password { labelConstraints.gridy = 4; final JLabel giftCloudPasswordLabel = new JLabel(resourceBundle.getString("giftCloudPassword"), SwingConstants.RIGHT); giftCloudPasswordLabel.setToolTipText(resourceBundle.getString("giftCloudPasswordToolTipText")); giftCloudServerPanel.add(giftCloudPasswordLabel, labelConstraints); final Optional<char[]> password = giftCloudProperties.getLastPassword(); final char[] initialPassword = password.isPresent() ? password.get() : "".toCharArray(); giftCloudPasswordText = new JPasswordField(new String(initialPassword), 16); // Shouldn't create a String but there's no other way to initialize the password field inputConstraints.gridy = 4; giftCloudServerPanel.add(giftCloudPasswordText, inputConstraints); } // Project list { labelConstraints.gridy = 5; JLabel projectListLabel = new JLabel(resourceBundle.getString("giftCloudProjectLabelText"), SwingConstants.RIGHT); giftCloudServerPanel.add(projectListLabel, labelConstraints); inputConstraints.gridy = 5; projectList = new BackwardsCompatibleComboBox(); projectList.setEditable(false); projectList.setToolTipText(resourceBundle.getString("giftCloudProjectTooltip")); giftCloudServerPanel.add(projectList, inputConstraints); labelConstraints.gridx = 1; projectListWaitingLabel = new JLabel(resourceBundle.getString("giftCloudProjectWaitingLabelText"), SwingConstants.RIGHT); giftCloudServerPanel.add(projectListWaitingLabel, labelConstraints); labelConstraints.gridx = 0; } // Subject prefix { labelConstraints.gridy = 6; JLabel subjectPrefixLabel = new JLabel(resourceBundle.getString("configPanelListenerSubjectPrefix"), SwingConstants.RIGHT); subjectPrefixLabel .setToolTipText(resourceBundle.getString("configPanelListenerSubjectPrefixTooltip")); giftCloudServerPanel.add(subjectPrefixLabel, labelConstraints); inputConstraints.gridy = 6; final Optional<String> subjectPrefixText = giftCloudProperties.getSubjectPrefix(); subjectPrefixField = new AutoFocusTextField(subjectPrefixText.orElse("")); giftCloudServerPanel.add(subjectPrefixField, inputConstraints); } } // Local Dicom node configuration final JPanel listenerPanel = new JPanel(); { GridBagLayout listenerPanellayout = new GridBagLayout(); listenerPanel.setLayout(listenerPanellayout); JSeparator separator = new JSeparator(); listenerPanel.add(separator, separatorConstraint); JLabel listenerPanelLabel = new JLabel(resourceBundle.getString("configPanelListenerConfig"), SwingConstants.CENTER); listenerPanel.add(listenerPanelLabel, sectionTitleConstraints); { labelConstraints.gridy = 2; JLabel listeningAETitleJLabel = new JLabel(resourceBundle.getString("configPanelListenerAe"), SwingConstants.RIGHT); listeningAETitleJLabel.setToolTipText(resourceBundle.getString("configPanelListenerAeToolTip")); listenerPanellayout.setConstraints(listeningAETitleJLabel, labelConstraints); listenerPanel.add(listeningAETitleJLabel); inputConstraints.gridy = 2; final String listeningAETitleInitialText = giftCloudProperties.getListenerAETitle(); listeningAETitleField = new AutoFocusTextField(listeningAETitleInitialText); listenerPanellayout.setConstraints(listeningAETitleField, inputConstraints); listenerPanel.add(listeningAETitleField); } { labelConstraints.gridy = 3; JLabel listeningPortJLabel = new JLabel(resourceBundle.getString("configPanelListenerPort"), SwingConstants.RIGHT); listeningPortJLabel.setToolTipText(resourceBundle.getString("configPanelListenerPortToolTip")); listenerPanellayout.setConstraints(listeningPortJLabel, labelConstraints); listenerPanel.add(listeningPortJLabel); inputConstraints.gridy = 3; final int port = giftCloudProperties.getListeningPort(); final String portValue = Integer.toString(port); listeningPortField = new AutoFocusTextField(portValue); listenerPanellayout.setConstraints(listeningPortField, inputConstraints); listenerPanel.add(listeningPortField); } { labelConstraints.gridy = 4; JLabel patientListExportFolderLabel = new JLabel( resourceBundle.getString("configPanelListenerPatientListExportFolder"), SwingConstants.RIGHT); patientListExportFolderLabel.setToolTipText( resourceBundle.getString("configPanelListenerPatientListExportFolderTooltip")); listenerPanellayout.setConstraints(patientListExportFolderLabel, labelConstraints); listenerPanel.add(patientListExportFolderLabel); inputConstraints.gridy = 4; final Optional<String> patientListExportFolder = giftCloudProperties.getPatientListExportFolder(); patientListExportFolderField = new AutoFocusTextField(patientListExportFolder.orElse("")); listenerPanellayout.setConstraints(patientListExportFolderField, inputConstraints); listenerPanel.add(patientListExportFolderField); } // Patient list spreadsheet password { labelConstraints.gridy = 5; final JLabel patientListSpreadsheetPasswordLabel = new JLabel( resourceBundle.getString("configPanelListenerPatientListSpreadhsheetPassword"), SwingConstants.RIGHT); patientListSpreadsheetPasswordLabel.setToolTipText( resourceBundle.getString("configPanelListenerPatientListSpreadhsheetPasswordTooltip")); listenerPanel.add(patientListSpreadsheetPasswordLabel, labelConstraints); final Optional<char[]> password = giftCloudProperties.getPatientListPassword(); final char[] initialPassword = password.isPresent() ? password.get() : "".toCharArray(); patientListSpreadsheetPasswordField = new JPasswordField(new String(initialPassword), 16); // Shouldn't create a String but there's no other way to initialize the password field inputConstraints.gridy = 5; listenerPanel.add(patientListSpreadsheetPasswordField, inputConstraints); } } // Remote PACS configuration final JPanel remoteAEPanel = new JPanel(); { GridBagLayout pacsPanellayout = new GridBagLayout(); remoteAEPanel.setLayout(pacsPanellayout); JSeparator separator = new JSeparator(); remoteAEPanel.add(separator, separatorConstraint); JLabel remotePanelLabel = new JLabel(resourceBundle.getString("pacsPanelListenerConfig"), SwingConstants.CENTER); remoteAEPanel.add(remotePanelLabel, sectionTitleConstraints); { labelConstraints.gridy = 2; JLabel remoteAeTitleLabel = new JLabel(resourceBundle.getString("configPanelPacsAeTitle"), SwingConstants.RIGHT); remoteAeTitleLabel.setToolTipText(resourceBundle.getString("configPanelPacsAeTitleTooltip")); remoteAEPanel.add(remoteAeTitleLabel, labelConstraints); final Optional<String> pacsAeTitle = giftCloudProperties.getPacsAeTitle(); remoteAETitleField = new AutoFocusTextField(pacsAeTitle.isPresent() ? pacsAeTitle.get() : ""); inputConstraints.gridy = 2; remoteAEPanel.add(remoteAETitleField, inputConstraints); } { labelConstraints.gridy = 3; JLabel remoteAeHostLabel = new JLabel(resourceBundle.getString("configPanelPacsHostname"), SwingConstants.RIGHT); remoteAeHostLabel.setToolTipText(resourceBundle.getString("configPanelPacsHostnameTooltip")); remoteAEPanel.add(remoteAeHostLabel, labelConstraints); remoteAEHostName = new AutoFocusTextField(giftCloudProperties.getPacsHostName().orElse("")); inputConstraints.gridy = 3; remoteAEPanel.add(remoteAEHostName, inputConstraints); } { labelConstraints.gridy = 4; JLabel remoteAeTitleLabel = new JLabel(resourceBundle.getString("configPanelPacsPort"), SwingConstants.RIGHT); remoteAeTitleLabel.setToolTipText(resourceBundle.getString("configPanelPacsPortTooltip")); remoteAEPanel.add(remoteAeTitleLabel, labelConstraints); remoteAEPortField = new AutoFocusTextField(Integer.toString(giftCloudProperties.getPacsPort())); inputConstraints.gridy = 4; remoteAEPanel.add(remoteAEPortField, inputConstraints); } } // The panel containing the cancel and apply buttons JPanel buttonPanel = new JPanel(); JPanel closeButtonPanel = new JPanel(); { final GridBagLayout buttonPanellayout = new GridBagLayout(); buttonPanel.setLayout(buttonPanellayout); JSeparator separator = new JSeparator(); buttonPanel.add(separator, separatorConstraint); closeButtonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); JButton cancelButton = new JButton(resourceBundle.getString("cancelSettingsButtonLabelText")); cancelButton.setToolTipText(resourceBundle.getString("cancelSettingsButtonToolTipText")); closeButtonPanel.add(cancelButton); cancelButton.addActionListener(new CancelActionListener()); JButton applyButton = new JButton(resourceBundle.getString("applySettingsButtonLabelText")); applyButton.setToolTipText(resourceBundle.getString("applySettingsButtonToolTipText")); closeButtonPanel.add(applyButton); applyButton.addActionListener(new ApplyActionListener()); JButton closeButton = new JButton(resourceBundle.getString("closeSettingsButtonLabelText")); closeButton.setToolTipText(resourceBundle.getString("closeSettingsButtonToolTipText")); closeButtonPanel.add(closeButton); closeButton.addActionListener(new CloseActionListener()); final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 1; constraints.weightx = 1; constraints.weighty = 1; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.HORIZONTAL; buttonPanellayout.setConstraints(closeButtonPanel, constraints); buttonPanel.add(closeButtonPanel); } // The main panel of the configuration dialog JPanel configPanel = new JPanel(); { final GridBagLayout configPanelLayout = new GridBagLayout(); configPanel.setLayout(configPanelLayout); { final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; constraints.weightx = 1; constraints.weighty = 1; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.HORIZONTAL; configPanelLayout.setConstraints(giftCloudServerPanel, constraints); configPanel.add(giftCloudServerPanel); } { final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 1; constraints.weightx = 1; constraints.weighty = 1; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.HORIZONTAL; configPanelLayout.setConstraints(listenerPanel, constraints); configPanel.add(listenerPanel); } { final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 2; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.HORIZONTAL; configPanelLayout.setConstraints(remoteAEPanel, constraints); configPanel.add(remoteAEPanel); } { final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 3; constraints.insets = new Insets(5, 5, 5, 5); constraints.fill = GridBagConstraints.HORIZONTAL; configPanelLayout.setConstraints(buttonPanel, constraints); configPanel.add(buttonPanel); } } projectList.setModel(temporaryDropDownListModel); showProjectList(projectListModel.isEnabled()); // Create a listener to enable/disable the project list when it is set from the server. // The reason for this is that the project list is set after logging into the server, which can happen asynchronously after property changes have been applied. // If the server was configured in the dialog and apply clicked, it might take a few seconds for the project list to be updated, and we want it to become available when this happens projectListEnabledListener = new DropDownListModel.EnabledListener<Boolean>() { @Override public void statusChanged(final Boolean visibility) { showProjectList(projectListModel.isEnabled()); } }; projectListModel.addListener(projectListEnabledListener); GridBagLayout layout = new GridBagLayout(); dialog.setLayout(layout); Container content = dialog.getContentPane(); content.add(configPanel); dialog.pack(); dialog.setVisible(true); dialog.pack(); }
From source file:uk.ac.ucl.cs.cmic.giftcloud.uploadapp.GiftCloudDialogs.java
public void showMessage(final String message) throws HeadlessException { final JPanel messagePanel = new JPanel(new GridBagLayout()); final JEditorPane textField = new JEditorPane(); textField.setContentType("text/html"); textField.setText(message);//from w ww . j av a2s. c o m textField.setEditable(false); textField.setBackground(null); textField.setBorder(null); textField.setEditable(false); textField.setForeground(UIManager.getColor("Label.foreground")); textField.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true); textField.setFont(UIManager.getFont("Label.font")); textField.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (IOException e1) { // Ignore failure to launch URL } catch (URISyntaxException e1) { // Ignore failure to launch URL } } } } }); messagePanel.add(textField); textField.setAlignmentX(SwingConstants.CENTER); JOptionPane.showMessageDialog(mainFrame.getContainer(), messagePanel, applicationName, JOptionPane.INFORMATION_MESSAGE, icon); }
From source file:uk.ac.ucl.cs.cmic.giftcloud.uploadapp.GiftCloudDialogs.java
public void showError(final String message, final Optional<String> additionalText) throws HeadlessException { final JPanel messagePanel = new JPanel(new GridBagLayout()); final StringBuilder stringMessage = new StringBuilder(); stringMessage.append("<html>"); stringMessage.append(message);// ww w .j a v a 2 s .c om if (additionalText.isPresent()) { stringMessage.append("<br>"); stringMessage.append(additionalText.get()); } stringMessage.append("</html>"); messagePanel.add(new JLabel(stringMessage.toString(), SwingConstants.CENTER)); JOptionPane.showMessageDialog(mainFrame.getContainer(), messagePanel, applicationName, JOptionPane.ERROR_MESSAGE, icon); }
From source file:uk.chromis.pos.forms.JRootApp.java
/** * * @param props// w w w. ja va 2 s. c om * @return */ public int initApp(AppProperties props) { m_props = props; m_jPanelDown.setVisible(!AppConfig.getInstance().getBoolean("till.hideinfo")); // support for different component orientation languages. applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault())); // Database start int rc = INIT_FAIL_RETRY; while (rc == INIT_FAIL_RETRY) { rc = INIT_SUCCESS; try { session = AppViewConnection.createSession(m_props); } catch (BasicException e) { JOpenWarningDlg wDlg = new JOpenWarningDlg(e.getMessage(), AppLocal.getIntString("message.retryorconfig"), true, true); wDlg.setModal(true); wDlg.setVisible(true); rc = JOpenWarningDlg.CHOICE; } } if (rc != INIT_SUCCESS) { return rc; } m_dlSystem = (DataLogicSystem) getBean("uk.chromis.pos.forms.DataLogicSystem"); String sDBVersion = readDataBaseVersion(); if (!AppConfig.getInstance().getBoolean("chromis.tickettype") && sDBVersion != null) { UpdateTicketType.updateTicketType(); } if (!AppLocal.APP_VERSION.equals(sDBVersion)) { // Lets check if this is a historic version of the jar and it is in the database /* if (m_dlSystem.checkHistoricVersion(AppLocal.APP_VERSION) != 0) { StartupDialog dialog = new StartupDialog(); JFrame frame = new JFrame(""); JPanel dialogPanel = new JPanel(); dialogPanel.add(dialog); dialog.jTextArea1.setText("\n Unable to run Chromis. \n \n You are trying to run an incompatible version of Chromis." + "\n\n The database found is v" + sDBVersion); JOptionPane.showMessageDialog(frame, dialogPanel, "Incompatible version ", JOptionPane.PLAIN_MESSAGE); System.exit(1); } */ if (getDbVersion().equals("x")) { JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_DANGER, AppLocal.getIntString("message.databasenotsupported", session.DB.getName()))); } else { String changelog = (sDBVersion == null) || ("0.00".equals(sDBVersion)) ? "uk/chromis/pos/liquibase/create/chromis.xml" : "uk/chromis/pos/liquibase/upgradeorig/updatesystem.xml"; JProcessingDlg dlg = new JProcessingDlg( AppLocal.getIntString( sDBVersion == null ? "message.createdatabase" : "message.updatedatabase"), (sDBVersion == null), changelog); dlg.setModal(true); dlg.setVisible(true); if (JProcessingDlg.CHOICE == -1 || JProcessingDlg.DBFAILED) { session.close(); JOpenWarningDlg wDlg; if (!"".equals(JProcessingDlg.ERRORMSG)) { wDlg = new JOpenWarningDlg(JProcessingDlg.ERRORMSG, AppLocal.getIntString( sDBVersion == null ? "message.createfailure" : "message.updatefailure"), false, false); wDlg.setModal(true); wDlg.setVisible(true); } System.exit(0); } } } // Clear the cash drawer table as required, by setting try { if ("d".equals(getDbVersion())) { SQL = "DELETE FROM DRAWEROPENED WHERE OPENDATE < {fn TIMESTAMPADD(SQL_TSI_DAY ,-" + AppConfig.getInstance().getProperty("dbtable.retaindays") + ", CURRENT_TIMESTAMP)}"; } else { SQL = "DELETE FROM DRAWEROPENED WHERE OPENDATE < (NOW() - INTERVAL '" + AppConfig.getInstance().getProperty("dbtable.retaindays") + "' DAY)"; } stmt.execute(SQL); } catch (Exception e) { } m_propsdb = m_dlSystem.getResourceAsProperties(AppConfig.getInstance().getHost() + "/properties"); try { String sActiveCashIndex = m_propsdb.getProperty("activecash"); Object[] valcash = sActiveCashIndex == null ? null : m_dlSystem.findActiveCash(sActiveCashIndex); if (valcash == null || !AppConfig.getInstance().getHost().equals(valcash[0])) { setActiveCash(UUID.randomUUID().toString(), m_dlSystem.getSequenceCash(AppConfig.getInstance().getHost()) + 1, new Date(), null); m_dlSystem.execInsertCash(new Object[] { getActiveCashIndex(), AppConfig.getInstance().getHost(), getActiveCashSequence(), getActiveCashDateStart(), getActiveCashDateEnd(), 0 }); } else { setActiveCash(sActiveCashIndex, (Integer) valcash[1], (Date) valcash[2], (Date) valcash[3]); } } catch (BasicException e) { session.close(); JOpenWarningDlg wDlg = new JOpenWarningDlg(e.getMessage(), AppLocal.getIntString("message.retryorconfig"), false, true); wDlg.setModal(true); wDlg.setVisible(true); return JOpenWarningDlg.CHOICE; } m_sInventoryLocation = m_propsdb.getProperty("location"); if (m_sInventoryLocation == null) { m_sInventoryLocation = "0"; m_propsdb.setProperty("location", m_sInventoryLocation); m_dlSystem.setResourceAsProperties(AppConfig.getInstance().getHost() + "/properties", m_propsdb); } // setup the display m_TP = new DeviceTicket(this, m_props); // Inicializamos m_TTP = new TicketParser(getDeviceTicket(), m_dlSystem); printerStart(); // Inicializamos la bascula m_Scale = new DeviceScale(this, m_props); // Inicializamos la scanpal m_Scanner = DeviceScannerFactory.createInstance(m_props); new javax.swing.Timer(250, new PrintTimeAction()).start(); String sWareHouse; try { sWareHouse = m_dlSystem.findLocationName(m_sInventoryLocation); } catch (BasicException e) { sWareHouse = null; // no he encontrado el almacen principal } // Show Hostname, Warehouse and URL in taskbar String url; try { url = session.getURL(); } catch (SQLException e) { url = ""; } m_jHost.setText("<html>" + AppConfig.getInstance().getHost() + " - " + sWareHouse + "<br>" + url); // display the new logo if set String newLogo = AppConfig.getInstance().getProperty("start.logo"); if (newLogo != null) { if ("".equals(newLogo)) { jLabel1.setIcon( new javax.swing.ImageIcon(getClass().getResource("/uk/chromis/fixedimages/chromis.png"))); } else { jLabel1.setIcon(new javax.swing.ImageIcon(newLogo)); } } // change text under logo String newText = AppConfig.getInstance().getProperty("start.text"); if (newText != null) { if (newText.equals("")) { jLabel1.setText("<html><center>Chromis POS - The New Face of Open Source POS<br>" + "Copyright \u00A9 (c) 2015-2016Chromis <br>" + "<br>" + "http://www.chromis.co.uk<br>" + "<br>" + " Chromis POS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.<br>" + "<br>" + " Chromis POS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.<br>" + "<br>" + "You should have received a copy of the GNU General Public License along with Chromis POS. If not, see http://www.gnu.org/licenses/<br>" + "</center>"); } else { try { String newTextCode = new Scanner(new File(newText), "UTF-8").useDelimiter("\\A").next(); jLabel1.setText(newTextCode); } catch (Exception e) { } jLabel1.setAlignmentX(0.5F); jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jLabel1.setMaximumSize(new java.awt.Dimension(800, 1024)); jLabel1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); } } // Lets copy any database specific reports to the reports folder // Get the database version first File dbReportsSource = null; String currentPath = new File("").getAbsolutePath(); if (OSValidator.isMac()) { try { currentPath = new File( JRootApp.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()) .toString(); currentPath = currentPath.replaceAll("/chromispos.jar", ""); } catch (URISyntaxException ex) { currentPath = "/Applications/chromispos"; } } else { currentPath = System.getProperty("user.dir"); } switch (getDbVersion()) { case "d": dbReportsSource = new File(currentPath + "/reports/uk/chromis/derby"); break; case "m": dbReportsSource = new File(currentPath + "/reports/uk/chromis/mysql"); break; case "p": dbReportsSource = new File(currentPath + "/reports/uk/chromis/postgresql"); break; } File reportsDestination = new File(currentPath + "/reports/uk/chromis/reports"); try { File reportsSource = new File(currentPath + "/reports/uk/chromis/default"); FileUtils.copyDirectory(reportsSource, new File(currentPath + "/reports/uk/chromis/reports")); if ((dbReportsSource) != null) { FileUtils.copyDirectory(dbReportsSource, new File(currentPath + "/reports/uk/chromis/reports")); } } catch (IOException ex) { Logger.getLogger(JRootApp.class.getName()).log(Level.SEVERE, null, ex); } showLogin(); return INIT_SUCCESS; }
From source file:uk.chromis.pos.forms.JRootApp.java
private void listPeople() { try {/*from www . j a va2s .com*/ jScrollPane1.getViewport().setView(null); JFlowPanel jPeople = new JFlowPanel(); jPeople.applyComponentOrientation(getComponentOrientation()); java.util.List people = m_dlSystem.listPeopleVisible(); for (int i = 0; i < people.size(); i++) { AppUser user = (AppUser) people.get(i); JButton btn = new JButton(new AppUserAction(user)); btn.applyComponentOrientation(getComponentOrientation()); btn.setFocusPainted(false); btn.setFocusable(false); btn.setRequestFocusEnabled(false); btn.setMaximumSize(new Dimension(130, 60)); btn.setPreferredSize(new Dimension(130, 60)); btn.setMinimumSize(new Dimension(130, 60)); btn.setHorizontalAlignment(SwingConstants.CENTER); btn.setHorizontalTextPosition(AbstractButton.CENTER); btn.setVerticalTextPosition(AbstractButton.BOTTOM); jPeople.add(btn); } jScrollPane1.getViewport().setView(jPeople); } catch (BasicException ee) { } }
From source file:uk.chromis.pos.forms.JRootApp.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the FormEditor.//from ww w .ja v a 2s . co m */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { m_jPanelTitle = new javax.swing.JPanel(); m_jLblTitle = new javax.swing.JLabel(); poweredby = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); m_jPanelContainer = new javax.swing.JPanel(); m_jPanelLogin = new javax.swing.JPanel(); jPanel4 = new javax.swing.JPanel(); filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 10), new java.awt.Dimension(32767, 0)); jLabel1 = new javax.swing.JLabel(); jPanel5 = new javax.swing.JPanel(); m_jLogonName = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); jPanel8 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); jPanel1 = new javax.swing.JPanel(); m_txtKeys = new javax.swing.JTextField(); m_jClose = new javax.swing.JButton(); m_jPanelDown = new javax.swing.JPanel(); panelTask = new javax.swing.JPanel(); m_jHost = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); setEnabled(false); setPreferredSize(new java.awt.Dimension(1024, 768)); setLayout(new java.awt.BorderLayout()); m_jPanelTitle.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 1, 0, javax.swing.UIManager.getDefaults().getColor("Button.darkShadow"))); m_jPanelTitle.setLayout(new java.awt.BorderLayout()); m_jLblTitle.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N m_jLblTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); m_jLblTitle.setText("Window.Title"); m_jPanelTitle.add(m_jLblTitle, java.awt.BorderLayout.CENTER); poweredby.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); poweredby.setIcon( new javax.swing.ImageIcon(getClass().getResource("/uk/chromis/fixedimages/poweredby.png"))); // NOI18N poweredby.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5)); poweredby.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); poweredby.setMaximumSize(new java.awt.Dimension(222, 34)); poweredby.setPreferredSize(new java.awt.Dimension(180, 34)); poweredby.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { poweredbyMouseClicked(evt); } }); m_jPanelTitle.add(poweredby, java.awt.BorderLayout.LINE_END); jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jLabel2.setForeground(new java.awt.Color(102, 102, 102)); jLabel2.setPreferredSize(new java.awt.Dimension(280, 34)); jLabel2.setRequestFocusEnabled(false); m_jPanelTitle.add(jLabel2, java.awt.BorderLayout.LINE_START); add(m_jPanelTitle, java.awt.BorderLayout.NORTH); m_jPanelContainer.setLayout(new java.awt.CardLayout()); m_jPanelLogin.setLayout(new java.awt.BorderLayout()); jPanel4.setMinimumSize(new java.awt.Dimension(518, 177)); jPanel4.setPreferredSize(new java.awt.Dimension(518, 177)); jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.Y_AXIS)); jPanel4.add(filler2); jLabel1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/chromis/fixedimages/chromis.png"))); // NOI18N jLabel1.setText("<html><center>Chromis POS - The New Face of open source POS<br>" + "Copyright \u00A9 2015 Chromis <br>" + "http://www.chromis.co.uk<br>" + "<br>" + "Chromis POS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.<br>" + "<br>" + "Chromis POS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.<br>" + "<br>" + "You should have received a copy of the GNU General Public License along with Chromis POS. If not, see http://www.gnu.org/licenses/<br>" + "</center>"); jLabel1.setAlignmentX(0.5F); jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jLabel1.setMaximumSize(new java.awt.Dimension(800, 1024)); jLabel1.setMinimumSize(new java.awt.Dimension(518, 177)); jLabel1.setPreferredSize(new java.awt.Dimension(518, 177)); jLabel1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jPanel4.add(jLabel1); m_jPanelLogin.add(jPanel4, java.awt.BorderLayout.CENTER); jPanel5.setPreferredSize(new java.awt.Dimension(300, 400)); m_jLogonName.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); m_jLogonName.setLayout(new java.awt.BorderLayout()); jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5)); jPanel2.setPreferredSize(new java.awt.Dimension(100, 100)); jPanel2.setLayout(new java.awt.BorderLayout()); jPanel8.setLayout(new java.awt.GridLayout(0, 1, 5, 5)); jPanel2.add(jPanel8, java.awt.BorderLayout.NORTH); m_jLogonName.add(jPanel2, java.awt.BorderLayout.LINE_END); jScrollPane1.setBackground(new java.awt.Color(255, 255, 255)); jScrollPane1.setBorder(null); jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jScrollPane1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N m_txtKeys.setPreferredSize(new java.awt.Dimension(0, 0)); m_txtKeys.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { m_txtKeysKeyTyped(evt); } }); m_jClose.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N m_jClose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/chromis/images/exit.png"))); // NOI18N m_jClose.setText(AppLocal.getIntString("Button.Close")); // NOI18N m_jClose.setFocusPainted(false); m_jClose.setFocusable(false); m_jClose.setPreferredSize(new java.awt.Dimension(100, 50)); m_jClose.setRequestFocusEnabled(false); m_jClose.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { m_jCloseActionPerformed(evt); } }); org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout.createSequentialGroup() .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(m_txtKeys, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(m_jClose, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 289, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addContainerGap(24, Short.MAX_VALUE))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout.createSequentialGroup() .add(m_txtKeys, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(m_jClose, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))); org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel5Layout.createSequentialGroup().addContainerGap() .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(jScrollPane1)) .add(104, 104, 104) .add(m_jLogonName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(0, 0, Short.MAX_VALUE))); jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel5Layout.createSequentialGroup().add(15, 15, 15) .add(m_jLogonName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(434, 565, Short.MAX_VALUE)) .add(jPanel5Layout.createSequentialGroup().add(jScrollPane1) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addContainerGap())); m_jPanelLogin.add(jPanel5, java.awt.BorderLayout.EAST); m_jPanelContainer.add(m_jPanelLogin, "login"); add(m_jPanelContainer, java.awt.BorderLayout.CENTER); m_jPanelDown.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 0, 0, 0, javax.swing.UIManager.getDefaults().getColor("Button.darkShadow"))); m_jPanelDown.setLayout(new java.awt.BorderLayout()); m_jHost.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N m_jHost.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uk/chromis/images/display.png"))); // NOI18N m_jHost.setText("*Hostname"); panelTask.add(m_jHost); m_jPanelDown.add(panelTask, java.awt.BorderLayout.LINE_START); m_jPanelDown.add(jPanel3, java.awt.BorderLayout.LINE_END); add(m_jPanelDown, java.awt.BorderLayout.SOUTH); }
From source file:uk.nhs.cfh.dsp.srth.desktop.uiframework.app.impl.ModularDockingApplicationView.java
/** * Inits the components./* w ww .jav a 2 s.c o m*/ * @param view the ModularDockingApplicationView to register with the ApplicationService */ public synchronized void initComponents(ModularDockingApplicationView view) { // register self with applicationService and errorLogService within logger.debug("applicationService = " + applicationService); while (applicationService == null) { // idle in this thread try { this.wait(waitTime); } catch (InterruptedException e) { logger.warn("e.getMessage() = " + e.getMessage()); } } // register this modular view with applicationService applicationService.registerFrameView(view); mainPanel = new JPanel(new BorderLayout()); statusMessageLabel = new JLabel("Application started"); statusMessageLabel.setHorizontalAlignment(SwingConstants.LEFT); statusMessageLabel.setVerticalAlignment(SwingConstants.CENTER); busyLabel = new JXBusyLabel(new Dimension(18, 19)); BusyPainter painter = new BusyPainter(new RoundRectangle2D.Float(0, 0, 8.0f, 1.9f, 10.0f, 10.0f), new Ellipse2D.Float(2.5f, 2.5f, 14.0f, 14.0f)); painter.setTrailLength(4); painter.setPoints(16); painter.setFrame(4); busyLabel.setPreferredSize(new Dimension(18, 19)); busyLabel.setIcon(new EmptyIcon(18, 19)); busyLabel.setBusyPainter(painter); busyLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); // create progress bar progressBar = new JProgressBar(0, 100); progressBar.setVisible(false); progressBar.setName("progressBar"); // NOI18N mainPanel.setName("mainPanel"); // NOI18N statusMessageLabel.setName("statusMessageLabel"); // NOI18N busyLabel.setName("statusAnimationLabel"); // NOI18N // check workspace file exists createWorkspacePersistenceFile(); // create menuBar createMenuBar(); // create toolbar createToolBar(); // create status bar createStatusBar(); // set menubar setMenuBar(menuBar); // set toolbar setToolBar(toolBar); // set status bar setStatusBar(jxStatusBar); // create tool window initToolWindows(); // set tool window to main content setComponent(toolWindowManager); // create task monitor and exit listeners createTasMonitorAndExitListeners(); }
From source file:unikn.dbis.univis.visualization.graph.VGraph.java
/** * @param result The given resultset from the sql action. * @throws SQLException// ww w .j av a 2 s .co m */ public void fillChartData(VDimension dimension, ResultSet result, ResultSet testResult) throws SQLException { layout.setAlignment(SwingConstants.CENTER); ResultSetMetaData data = result.getMetaData(); int idPos = data.getColumnCount(); int namePos = idPos - 1; int bufferPos = namePos - 1; List<String> testList = new ArrayList<String>(); while (testResult.next()) { testList.add(testResult.getString(1)); } List<String> helpList = new ArrayList<String>(testList); if (root == null) { cellHistory.historize(); if (ChartType.BAR_CHART_VERTICAL.equals(chartType) || ChartType.BAR_CHART_HORIZONTAL.equals(chartType) || ChartType.AREA_CHART.equals(chartType)) { dataset = new DefaultCategoryDataset(); while (result.next()) { ((DefaultCategoryDataset) dataset).addValue(result.getInt(1), result.getString(namePos + 1), ""); } } else { dataset = new DefaultPieDataset(); while (result.next()) { ((DefaultPieDataset) dataset).setValue(result.getString(namePos + 1), result.getInt(1)); } } root = createVertex(rootHeadLine, ""); root.setCellId("root"); cache.insert(root); cellHistory.add(root); } else { cellHistory.historize(); String buffer = ""; if (ChartType.BAR_CHART_VERTICAL.equals(chartType) || ChartType.BAR_CHART_HORIZONTAL.equals(chartType) || ChartType.AREA_CHART.equals(chartType)) { while (result.next()) { String currentValue = result.getString(idPos); if (!buffer.equals(currentValue)) { if (!result.isFirst()) { if (!helpList.isEmpty()) { for (String missing : helpList) { ((DefaultCategoryDataset) dataset).addValue(0, missing, ""); } } } dataset = new DefaultCategoryDataset(); VGraphCell nextCell = createVertex( MessageResolver.getMessage("data_reference." + dimension.getI18nKey()) + " (" + result.getString(bufferPos) + ")", result.getString(idPos)); createEdges(nextCell, result.getString(idPos)); cache.insert(nextCell); cellHistory.add(nextCell); helpList = new ArrayList<String>(testList); } for (String available : testList) { if (result.getString(namePos).equals(available)) { helpList.remove(available); } } ((DefaultCategoryDataset) dataset).addValue(result.getInt(1), result.getString(namePos), ""); buffer = currentValue; if (result.isLast()) { if (!helpList.isEmpty()) { for (String missing : helpList) { ((DefaultCategoryDataset) dataset).addValue(0, missing, ""); } } } } } else { while (result.next()) { String currentValue = result.getString(idPos); LOG.info(result.getString(2)); if (!buffer.equals(currentValue)) { dataset = new DefaultPieDataset(); VGraphCell nextCell = createVertex( MessageResolver.getMessage("data_reference." + dimension.getI18nKey()) + " (" + result.getString(bufferPos) + ")", result.getString(idPos)); createEdges(nextCell, result.getString(idPos)); cache.insert(nextCell); cellHistory.add(nextCell); } ((DefaultPieDataset) dataset).setValue(result.getString(namePos), result.getInt(1)); buffer = currentValue; } } } layout.run(facade); facade.setOrdered(true); Map nested = facade.createNestedMap(true, true); cache.edit(nested); }