List of usage examples for java.text DateFormat MEDIUM
int MEDIUM
To view the source code for java.text DateFormat MEDIUM.
Click Source Link
From source file:com.bizosys.hsearch.index.IndexReaderTest.java
public void testModifiedBefore() throws Exception { String id = "ID023"; DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT); HDocument doc1 = new HDocument(ANONYMOUS); doc1.key = "Id 1 : " + id; doc1.title = "My Trading balance as 234.00"; doc1.modifiedOn = new Date(); IndexWriter.getInstance().insert(doc1, acc, isMultiClient); String myBirth = new Long(format.parse("Feb 05, 1977 8:00 PM").getTime()).toString(); QueryResult res1 = IndexReader.getInstance() .search(new QueryContext(acc, "modifiedb:" + myBirth + " balance")); assertEquals(0, res1.teasers.length); String future = new Long(format.parse("Feb 05, 2121 8:00 PM").getTime()).toString(); QueryResult res2 = IndexReader.getInstance() .search(new QueryContext(acc, "modifiedb:" + future + " balance")); assertEquals(1, res2.teasers.length); IndexWriter.getInstance().delete(ANONYMOUS, doc1.key, isMultiClient); }
From source file:mitm.common.security.certificate.GenerateTestCertificates.java
/** * Generate a certificate without an email but with S/MIME extended key usage * /*from w w w . j av a 2 s. c om*/ * @throws Exception */ private void generateCertificateNoEmail() throws Exception { X509CertificateBuilder certificateBuilder = securityFactory.createX509CertificateBuilder(); String encodedPrivateKey = "30820277020100300d06092a864886f70d0101010500048202613082025d" + "0201000281810086246af6ba05ff48133e66771615a3e70742ff52d60db8" + "a4d808e73369d0c689fc21a2691ee7297311ad840fb7be841d813991f84e" + "9590f20a6e4d284d4d3775e646d7aed3a7142159281c9d0171bb98c1a659" + "b930f1e158df079136804d89864c0484e4f15482fa4c3b64c3ac58091dc4" + "83766b0283c2bd7c8ad12aa19c3b45020301000102818018291f0ae95e83" + "285c2ef50da5f0a7e0c8b20c82c3031daab32e8755ff4d17356b3033ac73" + "60775abe685e4ce66f6e24524e28386d0f0b584d00a8ed055f4f09ad206d" + "22f72a9b8b7724a43b42f0239c44e9db007652d1abf59e9d51731fda6153" + "3dd996c06af7761326ac57645be68f3ccc8a665aca9efc37d781c058e98f" + "51024100e294e1a1ddc5dbb20d09ef2113a1ddd864c444191c1b51917b69" + "fb9718fe6adb5bd29e9603c63d189ee79e194fa9c1484f9a5792f9a29b49" + "44f5efc403cd4fbb024100978f09d7c6a74c9a446510f203996b253df437" + "94c66e76209570ee5de5c33ee9cc09b75d06543d5b8127b7c9511253bcbf" + "2c74c0270c24ca36494954b02870ff024050a19eb1d594059c951b45e7c5" + "6ec2ddb0ee4f358855086ff7353dfd053df494df56526d1c26bdb3374941" + "6fcc73a27eb3253fa8e40143b58d3edff6274c36e502410088b05dfd38d2" + "3c5949e428f34ce1ba6bbd439c3956f9db1a2a0dcf3dea723c349a6c0cef" + "1e3d2d957097c4bf119a48e18b3dea123f65496d02a6f8372425653b0241" + "00bf58e07f459aa53487e6fb3b40caf2055e181c8505d2deb29cffffbde3" + "aeb5ccd0f2c353b47fe53cd3b488be85acaf55956a678ff6e37cca327f1b" + "b82044be77"; String encodedPublicKey = "30819f300d06092a864886f70d010101050003818d003081890281810086" + "246af6ba05ff48133e66771615a3e70742ff52d60db8a4d808e73369d0c6" + "89fc21a2691ee7297311ad840fb7be841d813991f84e9590f20a6e4d284d" + "4d3775e646d7aed3a7142159281c9d0171bb98c1a659b930f1e158df0791" + "36804d89864c0484e4f15482fa4c3b64c3ac58091dc483766b0283c2bd7c" + "8ad12aa19c3b450203010001"; PrivateKey privateKey = decodePrivateKey(encodedPrivateKey); PublicKey publicKey = decodePublicKey(encodedPublicKey); X500PrincipalBuilder subjectBuilder = new X500PrincipalBuilder(); subjectBuilder.setCommonName("No email"); subjectBuilder.setCountryCode("NL"); subjectBuilder.setLocality("Amsterdam"); subjectBuilder.setState("NH"); X500Principal subject = subjectBuilder.buildPrincipal(); Set<KeyUsageType> keyUsage = new TreeSet<KeyUsageType>(); keyUsage.add(KeyUsageType.DIGITALSIGNATURE); keyUsage.add(KeyUsageType.KEYENCIPHERMENT); keyUsage.add(KeyUsageType.NONREPUDIATION); Set<ExtendedKeyUsageType> extendedKeyUsage = new TreeSet<ExtendedKeyUsageType>(); extendedKeyUsage.add(ExtendedKeyUsageType.CLIENTAUTH); extendedKeyUsage.add(ExtendedKeyUsageType.EMAILPROTECTION); BigInteger serialNumber = new BigInteger("115fce43c64c3a7547678e8f0b67559", 16); Date now = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK) .parse("21-Nov-2007 11:39:35"); certificateBuilder.setSubject(subject); certificateBuilder.setKeyUsage(keyUsage, true); certificateBuilder.setExtendedKeyUsage(extendedKeyUsage, false); certificateBuilder.setNotBefore(DateUtils.addDays(now, -20)); certificateBuilder.setNotAfter(DateUtils.addYears(now, 20)); certificateBuilder.setPublicKey(publicKey); certificateBuilder.setSerialNumber(serialNumber); certificateBuilder.setSignatureAlgorithm("SHA1WithRSAEncryption"); certificateBuilder.addSubjectKeyIdentifier(true); X509Certificate certificate = certificateBuilder.generateCertificate(caPrivateKey, caCertificate); assertNotNull(certificate); certificates.add(certificate); Certificate[] chain = new Certificate[] { certificate, caCertificate, rootCertificate }; keyStore.setKeyEntry("noEmail", privateKey, null, chain); }
From source file:org.nuxeo.ecm.core.storage.dbs.DBSSession.java
@Override public Document importDocument(String id, Document parent, String name, String typeName, Map<String, Serializable> properties) throws DocumentException { String parentId = parent == null ? null : parent.getUUID(); boolean isProxy = typeName.equals(CoreSession.IMPORT_PROXY_TYPE); Map<String, Serializable> props = new HashMap<String, Serializable>(); Long pos = null; // TODO pos DBSDocumentState docState;/*from w w w . j a v a 2s .c om*/ if (isProxy) { // check that target exists and find its typeName String targetId = (String) properties.get(CoreSession.IMPORT_PROXY_TARGET_ID); if (targetId == null) { throw new DocumentException("Cannot import proxy " + id + " with null target"); } State targetState = transaction.getStateForRead(targetId); if (targetState == null) { throw new DocumentException("Cannot import proxy " + id + " with missing target " + targetId); } String versionSeriesId = (String) properties.get(CoreSession.IMPORT_PROXY_VERSIONABLE_ID); docState = addProxyState(id, parentId, name, pos, targetId, versionSeriesId); } else { // version & live document props.put(KEY_LIFECYCLE_POLICY, properties.get(CoreSession.IMPORT_LIFECYCLE_POLICY)); props.put(KEY_LIFECYCLE_STATE, properties.get(CoreSession.IMPORT_LIFECYCLE_STATE)); // compat with old lock import @SuppressWarnings("deprecation") String key = (String) properties.get(CoreSession.IMPORT_LOCK); if (key != null) { String[] values = key.split(":"); if (values.length == 2) { String owner = values[0]; Calendar created = new GregorianCalendar(); try { created.setTimeInMillis( DateFormat.getDateInstance(DateFormat.MEDIUM).parse(values[1]).getTime()); } catch (ParseException e) { // use current date } props.put(KEY_LOCK_OWNER, owner); props.put(KEY_LOCK_CREATED, created); } } Serializable importLockOwnerProp = properties.get(CoreSession.IMPORT_LOCK_OWNER); if (importLockOwnerProp != null) { props.put(KEY_LOCK_OWNER, importLockOwnerProp); } Serializable importLockCreatedProp = properties.get(CoreSession.IMPORT_LOCK_CREATED); if (importLockCreatedProp != null) { props.put(KEY_LOCK_CREATED, importLockCreatedProp); } props.put(KEY_MAJOR_VERSION, properties.get(CoreSession.IMPORT_VERSION_MAJOR)); props.put(KEY_MINOR_VERSION, properties.get(CoreSession.IMPORT_VERSION_MINOR)); Boolean isVersion = trueOrNull(properties.get(CoreSession.IMPORT_IS_VERSION)); props.put(KEY_IS_VERSION, isVersion); if (TRUE.equals(isVersion)) { // version props.put(KEY_VERSION_SERIES_ID, properties.get(CoreSession.IMPORT_VERSION_VERSIONABLE_ID)); props.put(KEY_VERSION_CREATED, properties.get(CoreSession.IMPORT_VERSION_CREATED)); props.put(KEY_VERSION_LABEL, properties.get(CoreSession.IMPORT_VERSION_LABEL)); props.put(KEY_VERSION_DESCRIPTION, properties.get(CoreSession.IMPORT_VERSION_DESCRIPTION)); // TODO maybe these should be recomputed at end of import: props.put(KEY_IS_LATEST_VERSION, trueOrNull(properties.get(CoreSession.IMPORT_VERSION_IS_LATEST))); props.put(KEY_IS_LATEST_MAJOR_VERSION, trueOrNull(properties.get(CoreSession.IMPORT_VERSION_IS_LATEST_MAJOR))); } else { // live document props.put(KEY_BASE_VERSION_ID, properties.get(CoreSession.IMPORT_BASE_VERSION_ID)); props.put(KEY_IS_CHECKED_IN, trueOrNull(properties.get(CoreSession.IMPORT_CHECKED_IN))); } docState = createChildState(id, parentId, name, pos, typeName); } for (Entry<String, Serializable> entry : props.entrySet()) { docState.put(entry.getKey(), entry.getValue()); } return getDocument(docState, false); // not readonly }
From source file:org.sakaiproject.evaluation.logic.EvalEmailsLogicImpl.java
public EvalEmailMessage makeEmailMessage(String messageTemplate, String subjectTemplate, EvalEvaluation eval, EvalGroup group, String includeConstant) { // replace the text of the template with real values Map<String, String> replacementValues = new HashMap<>(); replacementValues.put("EvalTitle", eval.getTitle()); // use a date which is related to the current users locale DateFormat df;/*from ww w . j a v a 2 s. c o m*/ boolean useDateTime = (Boolean) settings.get(EvalSettings.EVAL_USE_DATE_TIME); if (useDateTime) { // show date and time if date/time enabled df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, commonLogic.getUserLocale(commonLogic.getCurrentUserId())); } else { df = DateFormat.getDateInstance(DateFormat.MEDIUM, commonLogic.getUserLocale(commonLogic.getCurrentUserId())); } replacementValues.put("EvalStartDate", df.format(eval.getStartDate())); String dueDate = "--------"; if (eval.getDueDate() != null) { dueDate = df.format(eval.getDueDate()); } replacementValues.put("EvalDueDate", dueDate); String viewDate; if (eval.getViewDate() != null) { viewDate = df.format(eval.getViewDate()); } else { viewDate = dueDate; } replacementValues.put("EvalResultsDate", viewDate); // https://bugs.caret.cam.ac.uk/browse/CTL-1505 - no titles for empty or adhoc groups String groupTitle; if (group == null || group.title == null || EvalConstants.GROUP_TYPE_ADHOC.equals(group.type)) { groupTitle = ""; } else if (EvalConstants.GROUP_TYPE_ADHOC.equals(group.type)) { groupTitle = "Adhoc Group"; } else { groupTitle = group.title; } replacementValues.put("EvalGroupTitle", groupTitle); replacementValues.put("HelpdeskEmail", getFromEmailOrFail(eval)); // setup the opt-in, opt-out, and add questions variables int addItems = ((Integer) settings.get(EvalSettings.INSTRUCTOR_ADD_ITEMS_NUMBER)); if (!eval.getInstructorOpt().equals(EvalConstants.INSTRUCTOR_REQUIRED) || (addItems > 0)) { if (eval.getInstructorOpt().equals(EvalConstants.INSTRUCTOR_OPT_IN)) { // if eval is opt-in notify instructors that they may opt in replacementValues.put("ShowOptInText", "true"); } else if (eval.getInstructorOpt().equals(EvalConstants.INSTRUCTOR_OPT_OUT)) { // if eval is opt-out notify instructors that they may opt out replacementValues.put("ShowOptOutText", "true"); } if (addItems > 0) { // if eval allows instructors to add questions notify instructors they may add questions replacementValues.put("ShowAddItemsText", "true"); } } Boolean canEditResponses = (Boolean) settings.get(EvalSettings.STUDENT_MODIFY_RESPONSES); if (canEditResponses == null) { if (EvalUtils.safeBool(eval.getModifyResponsesAllowed(), false)) { replacementValues.put("ShowAllowEditResponsesText", "true"); } else { replacementValues.put("ShowAllowEditResponsesText", "false"); } } else if (canEditResponses) { replacementValues.put("ShowAllowEditResponsesText", "true"); } else { replacementValues.put("ShowAllowEditResponsesText", "false"); } // ensure that the if-then variables are set to false if they are unset if (!replacementValues.containsKey("ShowAddItemsText")) { replacementValues.put("ShowAddItemsText", "false"); } if (!replacementValues.containsKey("ShowOptInText")) { replacementValues.put("ShowOptInText", "false"); } if (!replacementValues.containsKey("ShowOptOutText")) { replacementValues.put("ShowOptOutText", "false"); } if (!replacementValues.containsKey("ShowAllowEditResponsesText")) { replacementValues.put("ShowAllowEditResponsesText", "false"); } if (!replacementValues.containsKey("InProgress")) { replacementValues.put("InProgress", (EvalConstants.EVAL_INCLUDE_IN_PROGRESS.equals(includeConstant) ? "true" : "false")); } // generate URLs to the evaluation // generate URLs to the evaluation String evalEntityURL = null; if (group != null && group.evalGroupId != null) { // get the URL directly to the evaluation with group context included EvalAssignGroup assignGroup = evaluationService.getAssignGroupByEvalAndGroupId(eval.getId(), group.evalGroupId); if (assignGroup != null) { evalEntityURL = commonLogic.getEntityURL(assignGroup); } } if (evalEntityURL == null) { // just get the URL to the evaluation without group context evalEntityURL = commonLogic.getEntityURL(eval); } // all URLs are identical because the user permissions determine access uniquely replacementValues.put("URLtoTakeEval", evalEntityURL); replacementValues.put("URLtoAddItems", evalEntityURL); replacementValues.put("URLtoOptIn", evalEntityURL); replacementValues.put("URLtoOptOut", evalEntityURL); replacementValues.put("URLtoViewResults", commonLogic.getEntityURL(EvalReportsEntityProvider.ENTITY_PREFIX, eval.getId().toString())); replacementValues.put("URLtoSystem", commonLogic.getServerUrl()); // these are values which are not handled - these are just placeholders -https://bugs.caret.cam.ac.uk/browse/CTL-1604 replacementValues.put("EarliestEvalDueDate", dueDate); replacementValues.put("EvalCLE", commonLogic.getConfigurationSetting("ui.service", "Sakai")); replacementValues.put("EvalToolTitle", "Evaluation System"); replacementValues.put("EvalSite", groupTitle); replacementValues.put("MyWorkspaceDashboard", evalEntityURL); String timeStamp = df.format(new Date()); replacementValues.put("TimeStamp", timeStamp); //handle the username variable if we can get the user String name = ""; try { String currentUserId = commonLogic.getCurrentUserId(); EvalUser user = commonLogic.getEvalUserById(currentUserId); name = user.displayName; } catch (Exception e) { //not populating the username variable with anything proper. We could not get a valid user. } replacementValues.put("UserName", name); String message = TextTemplateLogicUtils.processTextTemplate(messageTemplate, replacementValues); String subject = null; if (subjectTemplate != null) { subject = TextTemplateLogicUtils.processTextTemplate(subjectTemplate, replacementValues); } return new EvalEmailMessage(subjectTemplate, messageTemplate, subject, message); }
From source file:org.hoteia.qalingo.core.web.mvc.factory.impl.BackofficeViewBeanFactoryImpl.java
/** * @throws Exception/*from w w w . ja va 2s . c o m*/ * */ public UserViewBean buildUserViewBean(final RequestData requestData, final User user) throws Exception { final HttpServletRequest request = requestData.getRequest(); final UserViewBean userViewBean = new UserViewBean(); userViewBean.setId(user.getId()); userViewBean.setLogin(user.getLogin()); userViewBean.setFirstname(user.getFirstname()); userViewBean.setLastname(user.getLastname()); userViewBean.setEmail(user.getEmail()); userViewBean.setPassword(user.getPassword()); userViewBean.setActive(user.isActive()); DateFormat dateFormat = requestUtil.getFormatDate(requestData, DateFormat.MEDIUM, DateFormat.MEDIUM); if (user.getDateCreate() != null) { userViewBean.setDateCreate(dateFormat.format(user.getDateCreate())); } else { userViewBean.setDateCreate(Constants.NOT_AVAILABLE); } if (user.getDateUpdate() != null) { userViewBean.setDateUpdate(dateFormat.format(user.getDateUpdate())); } else { userViewBean.setDateUpdate(Constants.NOT_AVAILABLE); } final Set<UserGroup> userGroups = user.getUserGroups(); for (Iterator<UserGroup> iteratorUserGroup = userGroups.iterator(); iteratorUserGroup.hasNext();) { UserGroup userGroup = (UserGroup) iteratorUserGroup.next(); String keyUserGroup = userGroup.getCode(); String valueUserGroup = userGroup.getName(); userViewBean.getUserGroups().put(keyUserGroup, valueUserGroup); final Set<UserRole> userRoles = userGroup.getGroupRoles(); for (Iterator<UserRole> iteratorUserRole = userRoles.iterator(); iteratorUserRole.hasNext();) { UserRole userRole = (UserRole) iteratorUserRole.next(); String keyUserRole = userRole.getCode() + " (" + userGroup.getCode() + ")"; String valueUserRole = userRole.getName(); userViewBean.getUserRoles().put(keyUserRole, valueUserRole); final Set<UserPermission> rolePermissions = userRole.getRolePermissions(); for (Iterator<UserPermission> iteratorUserPermission = rolePermissions .iterator(); iteratorUserPermission.hasNext();) { UserPermission userPermission = (UserPermission) iteratorUserPermission.next(); String keyUserPermission = userPermission.getCode() + " (" + userRole.getCode() + ")"; String valueUserPermission = userPermission.getName(); userViewBean.getUserPermissions().put(keyUserPermission, valueUserPermission); } } } final Set<UserConnectionLog> connectionLogs = user.getConnectionLogs(); for (Iterator<UserConnectionLog> iteratorUserConnectionLog = connectionLogs .iterator(); iteratorUserConnectionLog.hasNext();) { UserConnectionLog userConnectionLog = (UserConnectionLog) iteratorUserConnectionLog.next(); UserConnectionLogValueBean userConnectionLogValueBean = new UserConnectionLogValueBean(); userConnectionLogValueBean.setDate(dateFormat.format(userConnectionLog.getLoginDate())); userConnectionLogValueBean.setHost(Constants.NOT_AVAILABLE); if (StringUtils.isNotEmpty(userConnectionLog.getHost())) { userConnectionLogValueBean.setHost(userConnectionLog.getHost()); } userConnectionLogValueBean.setPublicAddress(Constants.NOT_AVAILABLE); if (StringUtils.isNotEmpty(userConnectionLog.getPublicAddress())) { userConnectionLogValueBean.setPublicAddress(userConnectionLog.getPublicAddress()); } userConnectionLogValueBean.setPrivateAddress(Constants.NOT_AVAILABLE); if (StringUtils.isNotEmpty(userConnectionLog.getPrivateAddress())) { userConnectionLogValueBean.setPublicAddress(userConnectionLog.getPrivateAddress()); } userViewBean.getUserConnectionLogs().add(userConnectionLogValueBean); } final List<String> excludedPatterns = new ArrayList<String>(); excludedPatterns.add("form"); userViewBean.setBackUrl(requestUtil.getLastRequestUrl(request, excludedPatterns)); userViewBean.setUserDetailsUrl(backofficeUrlService.generateUrl(BoUrls.USER_DETAILS, requestData, user)); userViewBean.setUserEditUrl(backofficeUrlService.generateUrl(BoUrls.USER_EDIT, requestData, user)); userViewBean.setPersonalDetailsUrl( backofficeUrlService.generateUrl(BoUrls.PERSONAL_DETAILS, requestData, user)); userViewBean.setPersonalEditUrl(backofficeUrlService.generateUrl(BoUrls.PERSONAL_EDIT, requestData, user)); return userViewBean; }
From source file:mitm.common.security.certificate.GenerateTestCertificates.java
/** * Generate a certificate with email in subject but not in AltNames * /*from w ww .j a va 2 s . com*/ * @throws Exception */ private void generateCertificateEmailInSubjectNotInAltNames() throws Exception { X509CertificateBuilder certificateBuilder = securityFactory.createX509CertificateBuilder(); String encodedPrivateKey = "30820276020100300d06092a864886f70d0101010500048202603082025c" + "02010002818100d101622e0d0d3edb037b595281d54029fb4d5c0bc2025f" + "d378f7098b6cdf3a90450978cac7b699ab1457c361384d38278f62a2a3a0" + "42988d7ce079170c942ee8b6cbbf2cd2f85be52bd686f4b0d344c24d6acb" + "47f926034bfe312353893499bcb6eb6f9aa6e8b203768c93579c93e3234c" + "0a345dcfa5e0a3434a205f87dc6ec50203010001028180423a7d00f8b3cc" + "ca1bd5575d94b49d6b702d7850657ed91caac5252a202ab0650ceb4e727b" + "4c7a6f42b7f8ba72dbcd4283e60e81690411512c53f92afb9a6d2e4fd74d" + "bc4c34b73575e60b4e656f23f730a08436fb32bd89c44f120a73757e8fde" + "63a12fd9e7860406604acbf006fd235573be8bfb4ffcb3e55f2785cbb009" + "a1024100f90a4dbd692dd5948472e5d589fe52c58f85e5ec778ab22cf965" + "557e6ad46e08ff8e532e800fe58643c1eae5ef8c3bf1e3f746c0e51f8f97" + "4bfeed4dcdd89d69024100d6d8a918fffc750e02ecd443139515ce624e68" + "24b808f244e0aabcf00f5323fb0dfe54ffa56b1fcd5b90f6ddff639fea7b" + "0843debed0088a0f7dd42cb8802efd024075b569091dad8c45a654a84d45" + "ebef3371a2d809ec76a1c0a02045487b35eccc53fdf15309347a47fbbeac" + "4801f146640e5bd2155a3690a7f2438be63a6528010240772d644fcbe03d" + "0672b4f0e1ec80ecc1b96288fea55fc11458141e0e8451b849d16f5db31a" + "0d9c6c8bf894187d4cc42e8be4ffd115c3cc98d9131199651725f9024100" + "c74bca53cdd2650796285a3cd9ad48f25e9308532fa3ce3f366abe2a9e5c" + "b55dc7a1a7c9d6d30070eeb1584505e493a39515a3e306ed8299ccfcbc02" + "32984aef"; String encodedPublicKey = "30819f300d06092a864886f70d010101050003818d0030818902818100d1" + "01622e0d0d3edb037b595281d54029fb4d5c0bc2025fd378f7098b6cdf3a" + "90450978cac7b699ab1457c361384d38278f62a2a3a042988d7ce079170c" + "942ee8b6cbbf2cd2f85be52bd686f4b0d344c24d6acb47f926034bfe3123" + "53893499bcb6eb6f9aa6e8b203768c93579c93e3234c0a345dcfa5e0a343" + "4a205f87dc6ec50203010001"; PrivateKey privateKey = decodePrivateKey(encodedPrivateKey); PublicKey publicKey = decodePublicKey(encodedPublicKey); X500PrincipalBuilder subjectBuilder = new X500PrincipalBuilder(); String email = "test@example.com"; subjectBuilder.setCommonName("Email in Subject not in AltNames"); subjectBuilder.setEmail(email); subjectBuilder.setCountryCode("NL"); subjectBuilder.setLocality("Amsterdam"); subjectBuilder.setState("NH"); X500Principal subject = subjectBuilder.buildPrincipal(); Set<KeyUsageType> keyUsage = new TreeSet<KeyUsageType>(); keyUsage.add(KeyUsageType.DIGITALSIGNATURE); keyUsage.add(KeyUsageType.KEYENCIPHERMENT); keyUsage.add(KeyUsageType.NONREPUDIATION); Set<ExtendedKeyUsageType> extendedKeyUsage = new TreeSet<ExtendedKeyUsageType>(); extendedKeyUsage.add(ExtendedKeyUsageType.CLIENTAUTH); extendedKeyUsage.add(ExtendedKeyUsageType.EMAILPROTECTION); BigInteger serialNumber = new BigInteger("115fceb7f46b98775dbb8287965f838", 16); Date now = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK) .parse("21-Nov-2007 11:40:35"); certificateBuilder.setSubject(subject); certificateBuilder.setKeyUsage(keyUsage, true); certificateBuilder.setExtendedKeyUsage(extendedKeyUsage, false); certificateBuilder.setNotBefore(DateUtils.addDays(now, -20)); certificateBuilder.setNotAfter(DateUtils.addYears(now, 20)); certificateBuilder.setPublicKey(publicKey); certificateBuilder.setSerialNumber(serialNumber); certificateBuilder.setSignatureAlgorithm("SHA1WithRSAEncryption"); certificateBuilder.addSubjectKeyIdentifier(true); X509Certificate certificate = certificateBuilder.generateCertificate(caPrivateKey, caCertificate); assertNotNull(certificate); certificates.add(certificate); Certificate[] chain = new Certificate[] { certificate, caCertificate, rootCertificate }; keyStore.setKeyEntry("emailInSubjectNotInAltNames", privateKey, null, chain); }
From source file:org.tinymediamanager.ui.movies.dialogs.MovieEditorDialog.java
/** * Create the dialog./*from w ww . j av a 2 s .c o m*/ * * @param movie * the movie * @param inQueue * the in queue */ public MovieEditorDialog(Movie movie, boolean inQueue) { super(BUNDLE.getString("movie.edit"), "movieEditor"); //$NON-NLS-1$ setBounds(5, 5, 950, 650); movieToEdit = movie; ids = MediaIdTable.convertIdMapToEventList(movieToEdit.getIds()); for (MediaFile mf : movie.getMediaFiles()) { mediaFiles.add(new MediaFile(mf)); } getContentPane().setLayout(new BorderLayout()); { JPanel panelPath = new JPanel(); getContentPane().add(panelPath, BorderLayout.NORTH); panelPath.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("15px"), FormFactory.RELATED_GAP_ROWSPEC, })); JLabel lblMoviePathT = new JLabel(BUNDLE.getString("metatag.path")); //$NON-NLS-1$ panelPath.add(lblMoviePathT, "2, 2, left, top"); lblMoviePath = new JLabel(""); TmmFontHelper.changeFont(lblMoviePath, 1.166, Font.BOLD); panelPath.add(lblMoviePath, "5, 2, left, top"); } JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.NORTH); getContentPane().add(tabbedPane, BorderLayout.CENTER); /** * DetailsPanel 1 */ { details1Panel.setBorder(new EmptyBorder(5, 5, 5, 5)); details1Panel.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(40dlu;default)"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("7dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("25dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("24dlu"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("7dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu:grow(2)"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("50px:grow"), FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("15dlu"), FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("fill:50dlu:grow"), FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("50px"), FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("fill:default:grow"), })); { JLabel lblTitle = new JLabel(BUNDLE.getString("metatag.title")); //$NON-NLS-1$ details1Panel.add(lblTitle, "2, 4, right, default"); } { tfTitle = new JTextField(); details1Panel.add(tfTitle, "4, 4, 15, 1, fill, default"); tfTitle.setColumns(10); } { // JLabel lblPoster = new JLabel(""); lblPoster = new ImageLabel(); lblPoster.setAlternativeText(BUNDLE.getString("image.notfound.poster")); //$NON-NLS-1$ lblPoster.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.POSTER, movieList.getDefaultArtworkScrapers(), lblPoster, null, null, MediaType.MOVIE); dialog.setLocationRelativeTo(MainWindow.getActiveInstance()); dialog.setVisible(true); } }); lblPoster.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); details1Panel.add(lblPoster, "22, 4, 3, 23, fill, fill"); } { JLabel lblOriginalTitle = new JLabel(BUNDLE.getString("metatag.originaltitle")); //$NON-NLS-1$ details1Panel.add(lblOriginalTitle, "2, 6, right, default"); } { tfOriginalTitle = new JTextField(); details1Panel.add(tfOriginalTitle, "4, 6, 15, 1, fill, top"); tfOriginalTitle.setColumns(10); } { JLabel lblSorttitle = new JLabel(BUNDLE.getString("metatag.sorttitle")); //$NON-NLS-1$ details1Panel.add(lblSorttitle, "2, 8, right, default"); } { tfSorttitle = new JTextField(); details1Panel.add(tfSorttitle, "4, 8, 15, 1, fill, default"); tfSorttitle.setColumns(10); } { JLabel lblTagline = new JLabel(BUNDLE.getString("metatag.tagline")); //$NON-NLS-1$ details1Panel.add(lblTagline, "2, 10, right, top"); } { JScrollPane scrollPaneTagline = new JScrollPane(); tpTagline = new JTextPane(); scrollPaneTagline.setViewportView(tpTagline); details1Panel.add(scrollPaneTagline, "4, 10, 15, 1, fill, fill"); } { JLabel lblYear = new JLabel(BUNDLE.getString("metatag.year")); //$NON-NLS-1$ details1Panel.add(lblYear, "2, 12, right, default"); } { spYear = new YearSpinner(); details1Panel.add(spYear, "4, 12, fill, top"); } { JLabel lblRuntime = new JLabel(BUNDLE.getString("metatag.runtime")); //$NON-NLS-1$ details1Panel.add(lblRuntime, "8, 12, right, default"); } { spRuntime = new JSpinner(); details1Panel.add(spRuntime, "10, 12, fill, default"); } { JLabel lblMin = new JLabel(BUNDLE.getString("metatag.minutes")); //$NON-NLS-1$ details1Panel.add(lblMin, "12, 12"); } { JLabel lblRating = new JLabel(BUNDLE.getString("metatag.rating")); //$NON-NLS-1$ details1Panel.add(lblRating, "16, 12, right, default"); } { spRating = new JSpinner(); details1Panel.add(spRating, "18, 12"); } spRating.setModel(new SpinnerNumberModel(movie.getRating(), 0.0, 10.0, 0.1)); { JLabel lblReleaseDate = new JLabel(BUNDLE.getString("metatag.releasedate")); //$NON-NLS-1$ details1Panel.add(lblReleaseDate, "2, 14, right, default"); } { dpReleaseDate = new DatePicker(movie.getReleaseDate()); details1Panel.add(dpReleaseDate, "4, 14"); } { JLabel lblCertification = new JLabel(BUNDLE.getString("metatag.certification")); //$NON-NLS-1$ details1Panel.add(lblCertification, "8, 14, right, default"); } cbCertification = new JComboBox(); details1Panel.add(cbCertification, "10, 14, 3, 1, fill, default"); { JLabel lblTop = new JLabel(BUNDLE.getString("metatag.top250")); //$NON-NLS-1$ details1Panel.add(lblTop, "16, 14, right, default"); } { spTop250 = new JSpinner(); details1Panel.add(spTop250, "18, 14"); } spTop250.setValue(movie.getTop250()); { JLabel lblIds = new JLabel("Ids"); details1Panel.add(lblIds, "2, 16, right, bottom"); } { JScrollPane scrollPaneIds = new JScrollPane(); details1Panel.add(scrollPaneIds, "4, 16, 9, 5, fill, fill"); { tableIds = new MediaIdTable(ids, ScraperType.MOVIE); scrollPaneIds.setViewportView(tableIds); } } { JButton btnAddId = new JButton(""); btnAddId.setAction(new AddIdAction()); btnAddId.setIcon(IconManager.LIST_ADD); btnAddId.setMargin(new Insets(2, 2, 2, 2)); details1Panel.add(btnAddId, "2, 18, right, top"); } { JButton btnRemoveId = new JButton(""); btnRemoveId.setAction(new RemoveIdAction()); btnRemoveId.setIcon(IconManager.LIST_REMOVE); btnRemoveId.setMargin(new Insets(2, 2, 2, 2)); details1Panel.add(btnRemoveId, "2, 20, right, top"); } { JLabel lblSpokenLanguages = new JLabel(BUNDLE.getString("metatag.spokenlanguages")); //$NON-NLS-1$ details1Panel.add(lblSpokenLanguages, "2, 22, right, default"); } { tfSpokenLanguages = new JTextField(); details1Panel.add(tfSpokenLanguages, "4, 22, fill, default"); tfSpokenLanguages.setColumns(10); } { JLabel lblCountry = new JLabel(BUNDLE.getString("metatag.country")); //$NON-NLS-1$ details1Panel.add(lblCountry, "8, 22, right, default"); } { tfCountry = new JTextField(); details1Panel.add(tfCountry, "10, 22, 3, 1, fill, default"); tfCountry.setColumns(10); } { JLabel lblMovieSet = new JLabel(BUNDLE.getString("metatag.movieset")); //$NON-NLS-1$ details1Panel.add(lblMovieSet, "2, 24, right, default"); } { cbMovieSet = new JComboBox(); cbMovieSet.addItem(""); details1Panel.add(cbMovieSet, "4, 24, 9, 1, fill, default"); } { JLabel lblDateAdded = new JLabel(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$ details1Panel.add(lblDateAdded, "2, 26, right, default"); } { spDateAdded = new JSpinner(new SpinnerDateModel()); // JSpinner.DateEditor timeEditor = new JSpinner.DateEditor(spDateAdded, // "dd.MM.yyyy HH:mm:ss"); // spDateAdded.setEditor(timeEditor); details1Panel.add(spDateAdded, "4, 26"); } spDateAdded.setValue(movie.getDateAdded()); JLabel lblWatched = new JLabel(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$ details1Panel.add(lblWatched, "8, 26, right, default"); { cbWatched = new JCheckBox(""); details1Panel.add(cbWatched, "10, 26"); } cbWatched.setSelected(movie.isWatched()); lblWatched.setLabelFor(cbWatched); { JLabel lblSourceT = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$ details1Panel.add(lblSourceT, "2, 28, right, default"); } { cbSource = new JComboBox(MediaSource.values()); details1Panel.add(cbSource, "4, 28, fill, default"); } cbSource.setSelectedItem(movie.getMediaSource()); { final JLabel lblEditionT = new JLabel(BUNDLE.getString("metatag.edition")); //$NON-NLS-1$ details1Panel.add(lblEditionT, "8, 28, right, default"); } { cbEdition = new JComboBox(MovieEdition.values()); details1Panel.add(cbEdition, "10, 28, 3, 1, fill, default"); } { JLabel lblVideod = new JLabel(BUNDLE.getString("metatag.3d")); //$NON-NLS-1$ details1Panel.add(lblVideod, "16, 28, right, default"); } { chckbxVideo3D = new JCheckBox(""); details1Panel.add(chckbxVideo3D, "18, 28"); } chckbxVideo3D.setSelected(movie.isVideoIn3D()); { JLabel lblPlot = new JLabel(BUNDLE.getString("metatag.plot")); //$NON-NLS-1$ details1Panel.add(lblPlot, "2, 30, right, top"); } { JScrollPane scrollPanePlot = new JScrollPane(); details1Panel.add(scrollPanePlot, "4, 30, 15, 1, fill, fill"); { tpPlot = new JTextPane(); scrollPanePlot.setViewportView(tpPlot); } } { lblFanart = new ImageLabel(); lblFanart.setAlternativeText(BUNDLE.getString("image.notfound.fanart")); //$NON-NLS-1$ lblFanart.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); lblFanart.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.FANART, movieList.getDefaultArtworkScrapers(), lblFanart, extrathumbs, extrafanarts, MediaType.MOVIE); dialog.setLocationRelativeTo(MainWindow.getActiveInstance()); dialog.setVisible(true); } }); details1Panel.add(lblFanart, "22, 30, 3, 5, fill, fill"); } lblFanart.setImagePath(movie.getArtworkFilename(MediaFileType.FANART)); { JLabel lblDirector = new JLabel(BUNDLE.getString("metatag.director")); //$NON-NLS-1$ details1Panel.add(lblDirector, "2, 32, right, default"); } { tfDirector = new JTextField(); details1Panel.add(tfDirector, "4, 32, 15, 1, fill, top"); tfDirector.setColumns(10); } { JLabel lblWriter = new JLabel(BUNDLE.getString("metatag.writer")); //$NON-NLS-1$ details1Panel.add(lblWriter, "2, 34, right, default"); } { tfWriter = new JTextField(); details1Panel.add(tfWriter, "4, 34, 15, 1, fill, top"); tfWriter.setColumns(10); } { JLabel lblCompany = new JLabel(BUNDLE.getString("metatag.production")); //$NON-NLS-1$ details1Panel.add(lblCompany, "2, 36, right, top"); } { JScrollPane scrollPaneProduction = new JScrollPane(); details1Panel.add(scrollPaneProduction, "4, 36, 15, 1, fill, fill"); tfProductionCompanies = new JTextPane(); scrollPaneProduction.setViewportView(tfProductionCompanies); } tabbedPane.addTab(BUNDLE.getString("metatag.details"), details1Panel); //$NON-NLS-1$ } /** * DetailsPanel 2 */ { tabbedPane.addTab(BUNDLE.getString("metatag.details2"), details2Panel); //$NON-NLS-1$ details2Panel.setBorder(new EmptyBorder(5, 5, 5, 5)); details2Panel.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(40dlu;default)"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("50px:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("100px:grow"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("fill:default"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow(2)"), })); { JLabel lblActors = new JLabel(BUNDLE.getString("metatag.actors")); //$NON-NLS-1$ details2Panel.add(lblActors, "2, 2, right, default"); } { JScrollPane scrollPane = new JScrollPane(); details2Panel.add(scrollPane, "4, 2, 1, 11"); tableActors = new JTable(); tableActors.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); scrollPane.setViewportView(tableActors); } { JLabel lblProducers = new JLabel(BUNDLE.getString("metatag.producers")); //$NON-NLS-1$ details2Panel.add(lblProducers, "6, 2, right, default"); } { JScrollPane scrollPane = new JScrollPane(); details2Panel.add(scrollPane, "8, 2, 1, 11"); tableProducers = new JTable(); tableProducers.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); scrollPane.setViewportView(tableProducers); } { JButton btnAddActor = new JButton(BUNDLE.getString("cast.actor.add")); //$NON-NLS-1$ btnAddActor.setMargin(new Insets(2, 2, 2, 2)); btnAddActor.setAction(new AddActorAction()); btnAddActor.setIcon(IconManager.LIST_ADD); details2Panel.add(btnAddActor, "2, 4, right, top"); } { JButton btnAddProducer = new JButton((String) null); btnAddProducer.setMargin(new Insets(2, 2, 2, 2)); btnAddProducer.setAction(new AddProducerAction()); btnAddProducer.setIcon(IconManager.LIST_ADD); details2Panel.add(btnAddProducer, "6, 4, right, top"); } { JButton btnRemoveActor = new JButton(BUNDLE.getString("cast.actor.remove")); //$NON-NLS-1$ btnRemoveActor.setMargin(new Insets(2, 2, 2, 2)); btnRemoveActor.setAction(new RemoveActorAction()); btnRemoveActor.setIcon(IconManager.LIST_REMOVE); details2Panel.add(btnRemoveActor, "2,6, right, top"); } { JButton btnRemoveProducer = new JButton((String) null); btnRemoveProducer.setMargin(new Insets(2, 2, 2, 2)); btnRemoveProducer.setAction(new RemoveProducerAction()); btnRemoveProducer.setIcon(IconManager.LIST_REMOVE); details2Panel.add(btnRemoveProducer, "6, 6, right, top"); } { JButton btnMoveActorUp = new JButton((String) null); btnMoveActorUp.setMargin(new Insets(2, 2, 2, 2)); btnMoveActorUp.setAction(new MoveActorUpAction()); btnMoveActorUp.setIcon(IconManager.ARROW_UP); details2Panel.add(btnMoveActorUp, "2, 8, right, top"); } { JButton btnMoveProducerUp = new JButton((String) null); btnMoveProducerUp.setMargin(new Insets(2, 2, 2, 2)); btnMoveProducerUp.setAction(new MoveProducerUpAction()); btnMoveProducerUp.setIcon(IconManager.ARROW_UP); details2Panel.add(btnMoveProducerUp, "6, 8, right, top"); } { JButton btnMoveActorDown = new JButton((String) null); btnMoveActorDown.setMargin(new Insets(2, 2, 2, 2)); btnMoveActorDown.setAction(new MoveActorDownAction()); btnMoveActorDown.setIcon(IconManager.ARROW_DOWN); details2Panel.add(btnMoveActorDown, "2, 10, right, top"); } { JButton btnMoveProducerDown = new JButton((String) null); btnMoveProducerDown.setMargin(new Insets(2, 2, 2, 2)); btnMoveProducerDown.setAction(new MoveProducerDownAction()); btnMoveProducerDown.setIcon(IconManager.ARROW_DOWN); details2Panel.add(btnMoveProducerDown, "6, 10, right, top"); } { JLabel lblGenres = new JLabel(BUNDLE.getString("metatag.genre")); //$NON-NLS-1$ details2Panel.add(lblGenres, "2, 14, right, default"); } { JScrollPane scrollPaneGenres = new JScrollPane(); details2Panel.add(scrollPaneGenres, "4, 14, 1, 5"); { listGenres = new JList(); scrollPaneGenres.setViewportView(listGenres); } } { JLabel lblTags = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$ details2Panel.add(lblTags, "6, 14, right, default"); } { JScrollPane scrollPaneTags = new JScrollPane(); details2Panel.add(scrollPaneTags, "8, 14, 1, 5"); listTags = new JList(); scrollPaneTags.setViewportView(listTags); } { JButton btnAddGenre = new JButton(""); btnAddGenre.setAction(new AddGenreAction()); btnAddGenre.setIcon(IconManager.LIST_ADD); btnAddGenre.setMargin(new Insets(2, 2, 2, 2)); details2Panel.add(btnAddGenre, "2, 16, right, top"); } { JButton btnAddTag = new JButton(""); btnAddTag.setAction(new AddTagAction()); btnAddTag.setIcon(IconManager.LIST_ADD); btnAddTag.setMargin(new Insets(2, 2, 2, 2)); details2Panel.add(btnAddTag, "6, 16, right, top"); } { JButton btnRemoveGenre = new JButton(""); btnRemoveGenre.setAction(new RemoveGenreAction()); btnRemoveGenre.setMargin(new Insets(2, 2, 2, 2)); btnRemoveGenre.setIcon(IconManager.LIST_REMOVE); details2Panel.add(btnRemoveGenre, "2, 18, right, top"); } { JButton btnRemoveTag = new JButton(""); btnRemoveTag.setAction(new RemoveTagAction()); btnRemoveTag.setIcon(IconManager.LIST_REMOVE); btnRemoveTag.setMargin(new Insets(2, 2, 2, 2)); details2Panel.add(btnRemoveTag, "6, 18, right, top"); } { cbGenres = new AutocompleteComboBox(MediaGenres.values()); details2Panel.add(cbGenres, "4, 20"); } { cbTags = new AutocompleteComboBox(movieList.getTagsInMovies()); details2Panel.add(cbTags, "8, 20"); } { JLabel lblTrailer = new JLabel(BUNDLE.getString("metatag.trailer")); //$NON-NLS-1$ details2Panel.add(lblTrailer, "2, 22, right, default"); } { JScrollPane scrollPaneTrailer = new JScrollPane(); details2Panel.add(scrollPaneTrailer, "4, 22, 5, 5"); tableTrailer = new JTable(); tableTrailer.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); scrollPaneTrailer.setViewportView(tableTrailer); } { JButton btnAddTrailer = new JButton(""); btnAddTrailer.setAction(new AddTrailerAction()); btnAddTrailer.setIcon(IconManager.LIST_ADD); btnAddTrailer.setMargin(new Insets(2, 2, 2, 2)); details2Panel.add(btnAddTrailer, "2, 24, right, top"); } { JButton btnRemoveTrailer = new JButton(""); btnRemoveTrailer.setAction(new RemoveTrailerAction()); btnRemoveTrailer.setIcon(IconManager.LIST_REMOVE); btnRemoveTrailer.setMargin(new Insets(2, 2, 2, 2)); details2Panel.add(btnRemoveTrailer, "2, 26, right, top"); } } /** * extra artwork pane */ { JPanel artworkPanel = new JPanel(); tabbedPane.addTab(BUNDLE.getString("metatag.extraartwork"), null, artworkPanel, null); //$NON-NLS-1$ artworkPanel.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("150px:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("50px:grow(2)"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("50px:grow(2)"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("200px:grow(2)"), FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), })); { JLabel lblLogoT = new JLabel(BUNDLE.getString("mediafiletype.logo")); //$NON-NLS-1$ artworkPanel.add(lblLogoT, "2, 2"); } { lblLogo = new ImageLabel(); lblLogo.setAlternativeText(BUNDLE.getString("image.notfound.logo")); //$NON-NLS-1$ lblLogo.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.LOGO, movieList.getDefaultArtworkScrapers(), lblLogo, null, null, MediaType.MOVIE); dialog.setLocationRelativeTo(MainWindow.getActiveInstance()); dialog.setVisible(true); } }); lblLogo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); artworkPanel.add(lblLogo, "2, 4, fill, fill"); } { final JLabel lblClearlogoT = new JLabel(BUNDLE.getString("mediafiletype.clearlogo")); //$NON-NLS-1$ artworkPanel.add(lblClearlogoT, "4, 2"); } { lblClearlogo = new ImageLabel(); lblClearlogo.setAlternativeText(BUNDLE.getString("image.notfound.clearlogo")); //$NON-NLS-1$ lblClearlogo.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.CLEARLOGO, movieList.getDefaultArtworkScrapers(), lblClearlogo, null, null, MediaType.MOVIE); dialog.setLocationRelativeTo(MainWindow.getActiveInstance()); dialog.setVisible(true); } }); lblClearlogo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); artworkPanel.add(lblClearlogo, "4, 4, fill, fill"); } { JLabel lblBannerT = new JLabel(BUNDLE.getString("mediafiletype.banner")); //$NON-NLS-1$ artworkPanel.add(lblBannerT, "2, 6"); } { lblBanner = new ImageLabel(); lblBanner.setAlternativeText(BUNDLE.getString("image.notfound.banner")); //$NON-NLS-1$ lblBanner.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.BANNER, movieList.getDefaultArtworkScrapers(), lblBanner, null, null, MediaType.MOVIE); dialog.setLocationRelativeTo(MainWindow.getActiveInstance()); dialog.setVisible(true); } }); lblBanner.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); artworkPanel.add(lblBanner, "2, 8, 3, 1, fill, fill"); } { JLabel lblClearartT = new JLabel("ClearArt"); artworkPanel.add(lblClearartT, "2, 10"); } { lblClearart = new ImageLabel(); lblClearart.setAlternativeText(BUNDLE.getString("image.notfound.clearart")); //$NON-NLS-1$ lblClearart.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.CLEARART, movieList.getDefaultArtworkScrapers(), lblClearart, null, null, MediaType.MOVIE); dialog.setLocationRelativeTo(MainWindow.getActiveInstance()); dialog.setVisible(true); } }); lblClearart.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); artworkPanel.add(lblClearart, "2, 12, fill, fill"); } { JLabel lblThumbT = new JLabel("Thumb"); artworkPanel.add(lblThumbT, "4, 10"); } { lblThumb = new ImageLabel(); lblThumb.setAlternativeText(BUNDLE.getString("image.notfound.thumb")); //$NON-NLS-1$ lblThumb.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.THUMB, movieList.getDefaultArtworkScrapers(), lblThumb, null, null, MediaType.MOVIE); dialog.setLocationRelativeTo(MainWindow.getActiveInstance()); dialog.setVisible(true); } }); lblThumb.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); artworkPanel.add(lblThumb, "4, 12, fill, fill"); } { JLabel lblDiscT = new JLabel("Disc"); artworkPanel.add(lblDiscT, "6, 10"); } { lblDisc = new ImageLabel(); lblDisc.setAlternativeText(BUNDLE.getString("image.notfound.disc")); //$NON-NLS-1$ lblDisc.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.DISC, movieList.getDefaultArtworkScrapers(), lblDisc, null, null, MediaType.MOVIE); dialog.setLocationRelativeTo(MainWindow.getActiveInstance()); dialog.setVisible(true); } }); lblDisc.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); artworkPanel.add(lblDisc, "6, 12, fill, fill"); } } /** * Media Files */ { mediaFilesPanel = new MediaFileEditorPanel(mediaFiles); tabbedPane.addTab(BUNDLE.getString("metatag.mediafiles"), null, mediaFilesPanel, null); //$NON-NLS-1$ } /** * Button pane */ { JPanel bottomPane = new JPanel(); getContentPane().add(bottomPane, BorderLayout.SOUTH); bottomPane.setLayout(new FormLayout( new ColumnSpec[] { ColumnSpec.decode("371px:grow"), FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, })); JPanel buttonPane = new JPanel(); bottomPane.add(buttonPane, "2, 2, left, top"); EqualsLayout layout = new EqualsLayout(5); layout.setMinWidth(100); buttonPane.setLayout(layout); { JButton okButton = new JButton(BUNDLE.getString("Button.ok")); //$NON-NLS-1$ buttonPane.add(okButton, "2, 1, fill, top"); okButton.setAction(new ChangeMovieAction()); okButton.setActionCommand("OK"); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton(BUNDLE.getString("Button.cancel")); //$NON-NLS-1$ buttonPane.add(cancelButton, "4, 1, fill, top"); cancelButton.setAction(new DiscardAction()); cancelButton.setActionCommand("Cancel"); } if (inQueue) { JButton btnAbort = new JButton(BUNDLE.getString("Button.abortqueue")); //$NON-NLS-1$ btnAbort.setAction(new AbortQueueAction()); buttonPane.add(btnAbort, "6, 1, fill, top"); } } initDataBindings(); { int year = 0; try { year = Integer.parseInt(movieToEdit.getYear()); } catch (Exception ignored) { } SimpleDateFormat dateFormat = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.MEDIUM); for (Certification cert : Certification .getCertificationsforCountry(MovieModuleManager.MOVIE_SETTINGS.getCertificationCountry())) { cbCertification.addItem(cert); } tfTitle.setText(movieToEdit.getTitle()); tfOriginalTitle.setText(movieToEdit.getOriginalTitle()); tfSorttitle.setText(movieToEdit.getSortTitle()); tpTagline.setText(movieToEdit.getTagline()); tpPlot.setText(movieToEdit.getPlot()); tpPlot.setCaretPosition(0); tfDirector.setText(movieToEdit.getDirector()); tfWriter.setText(movieToEdit.getWriter()); lblPoster.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.POSTER)); tfProductionCompanies.setText(movieToEdit.getProductionCompany()); spRuntime.setValue(movieToEdit.getRuntime()); cbEdition.setSelectedItem(movieToEdit.getEdition()); tfSpokenLanguages.setText(movieToEdit.getSpokenLanguages()); tfCountry.setText(movieToEdit.getCountry()); spYear.setValue(year); cbCertification.setSelectedItem(movieToEdit.getCertification()); lblMoviePath.setText(movieToEdit.getPath()); lblLogo.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.LOGO)); lblClearlogo.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.CLEARLOGO)); lblClearart.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.CLEARART)); lblThumb.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.THUMB)); lblDisc.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.DISCART)); lblBanner.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.BANNER)); for (MovieActor origCast : movieToEdit.getActors()) { MovieActor actor = new MovieActor(); actor.setName(origCast.getName()); actor.setCharacter(origCast.getCharacter()); actor.setThumbUrl(origCast.getThumbUrl()); cast.add(actor); } for (MovieProducer origProducer : movieToEdit.getProducers()) { MovieProducer producer = new MovieProducer(); producer.setName(origProducer.getName()); producer.setRole(origProducer.getRole()); producer.setThumbUrl(origProducer.getThumbUrl()); producers.add(producer); } for (MediaGenres genre : movieToEdit.getGenres()) { genres.add(genre); } for (MovieTrailer trailer : movieToEdit.getTrailer()) { trailers.add(trailer); } for (String tag : movieToEdit.getTags()) { if (StringUtils.isNotBlank(tag)) { tags.add(tag); } } extrathumbs.addAll(movieToEdit.getExtraThumbs()); extrafanarts.addAll(movieToEdit.getExtraFanarts()); for (MovieSet movieSet : movieList.getSortedMovieSetList()) { cbMovieSet.addItem(movieSet); if (movieToEdit.getMovieSet() == movieSet) { cbMovieSet.setSelectedItem(movieSet); } } } // adjust columnn titles - we have to do it this way - thx to windowbuilder pro tableActors.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.name")); //$NON-NLS-1$ tableActors.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.role")); //$NON-NLS-1$ tableProducers.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.name")); //$NON-NLS-1$ tableProducers.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.role")); //$NON-NLS-1$ tableTrailer.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.nfo")); //$NON-NLS-1$ tableTrailer.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.name")); //$NON-NLS-1$ tableTrailer.getColumnModel().getColumn(2).setHeaderValue(BUNDLE.getString("metatag.source")); //$NON-NLS-1$ tableTrailer.getColumnModel().getColumn(3).setHeaderValue(BUNDLE.getString("metatag.quality")); //$NON-NLS-1$ tableTrailer.getColumnModel().getColumn(4).setHeaderValue(BUNDLE.getString("metatag.url")); //$NON-NLS-1$ // adjust table columns tableTrailer.getColumnModel().getColumn(0).setMaxWidth(55); // implement listener to simulate button group tableTrailer.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { // click on the checkbox if (arg0.getColumn() == 0) { int row = arg0.getFirstRow(); MovieTrailer changedTrailer = trailers.get(row); // if flag inNFO was changed, change all other trailers flags if (changedTrailer.getInNfo()) { for (MovieTrailer trailer : trailers) { if (trailer != changedTrailer) { trailer.setInNfo(Boolean.FALSE); } } } } } }); }
From source file:org.springsource.ide.eclipse.dashboard.internal.ui.editors.DashboardMainPage.java
private void displayUpdate(final SyndEntry entry, String severity, Composite composite, int pos, Control[] children) {//w ww. j a va2s . c o m ImageHyperlink link; FormText text; if (pos < children.length / 2) { link = (ImageHyperlink) children[pos * 2]; link.setVisible(true); text = (FormText) children[pos * 2 + 1]; text.setVisible(true); } else { link = toolkit.createImageHyperlink(composite, SWT.NONE); text = new FormText(composite, SWT.WRAP | SWT.MULTI | SWT.NO_BACKGROUND | SWT.NO_FOCUS); text.setHyperlinkSettings(toolkit.getHyperlinkGroup()); final TableWrapData data = new TableWrapData(); data.indent = UPDATE_INDENTATION; data.maxWidth = updateSection.getSize().x - UPDATE_TEXT_WRAP_INDENT; text.setLayoutData(data); text.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { data.maxWidth = updateSection.getSize().x - UPDATE_TEXT_WRAP_INDENT; } }); text.setBackground(toolkit.getColors().getBackground()); text.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { if (e.data instanceof String) { TasksUiUtil.openUrl((String) e.data); } } }); } link.setText(entry.getTitle()); TableWrapData linkData = new TableWrapData(); if ("important".equals(severity)) { link.setImage(StsUiImages.getImage(StsUiImages.IMPORTANT)); linkData.indent = 0; } else if ("warning".equals(severity)) { link.setImage(StsUiImages.getImage(StsUiImages.WARNING)); linkData.indent = 0; } else { // link.setImage(IdeUiPlugin.getImage(ICON_BLOG_BLANK)); linkData.indent = UPDATE_INDENTATION - 1; } link.setLayoutData(linkData); link.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { String url = entry.getLink(); if (url == null) { return; } TasksUiUtil.openUrl(url); } }); String description = getDescription(entry); if (entry.getPublishedDate() != null && description.endsWith("</p></form>")) { String dateString = DateFormat.getDateInstance(DateFormat.MEDIUM).format(entry.getPublishedDate()); description = description.replace("</p></form>", " (" + dateString + ")</p></form>"); } else if (entry.getPublishedDate() != null) { String dateString = DateFormat.getDateInstance(DateFormat.MEDIUM).format(entry.getPublishedDate()); description = description + " (" + dateString + ")"; } text.setText(description, description.startsWith("<form>"), true); text.setForeground(feedColor); text.setBackground(toolkit.getColors().getBackground()); addImages(text, description); }
From source file:org.hoteia.qalingo.core.web.mvc.factory.ViewBeanFactory.java
/** * *//*w ww . j a v a2 s. c o m*/ public CurrencyReferentialViewBean buildViewBeanCurrencyReferential(final RequestData requestData, final CurrencyReferential currencyReferential) throws Exception { final CurrencyReferentialViewBean currencyReferentialViewBean = new CurrencyReferentialViewBean(); if (currencyReferential != null) { currencyReferentialViewBean.setName(currencyReferential.getName()); currencyReferentialViewBean.setDescription(currencyReferential.getDescription()); currencyReferentialViewBean.setCode(currencyReferential.getCode()); currencyReferentialViewBean.setSign(currencyReferential.getSign()); currencyReferentialViewBean.setAbbreviated(currencyReferential.getAbbreviated()); DateFormat dateFormat = requestUtil.getCommonFormatDate(requestData, DateFormat.MEDIUM, DateFormat.MEDIUM); if (currencyReferential.getDateCreate() != null) { currencyReferentialViewBean.setDateCreate(dateFormat.format(currencyReferential.getDateCreate())); } if (currencyReferential.getDateUpdate() != null) { currencyReferentialViewBean.setDateUpdate(dateFormat.format(currencyReferential.getDateUpdate())); } // CLONE THE CURRENT REQUEST DATE TO BUILD THE CHANGE CONTEXT URL (MENU) RequestData requestDataChangecontext = new RequestData(); BeanUtils.copyProperties(requestData, requestDataChangecontext); requestDataChangecontext.setMarketAreaCurrency(currencyReferential); currencyReferentialViewBean .setChangeContextUrl(urlService.buildChangeContextUrl(requestDataChangecontext)); currencyReferentialViewBean.setHomeUrl(urlService.generateUrl(FoUrls.HOME, requestDataChangecontext)); } return currencyReferentialViewBean; }
From source file:org.hoteia.qalingo.core.service.impl.WebManagementServiceImpl.java
/** * //ww w .j a v a 2s . c o m */ public void buildAndSaveNewOrderConfirmationMail(final RequestData requestData, final Customer customer, final OrderCustomer order) throws Exception { final MarketArea marketArea = requestData.getMarketArea(); final String contextNameValue = requestData.getContextNameValue(); final String velocityPath = requestData.getVelocityEmailPrefix(); final OrderConfirmationEmailBean orderConfirmationEmailBean = new OrderConfirmationEmailBean(); orderConfirmationEmailBean.setFromAddress( marketArea.getEmailFromAddress(contextNameValue, Email.EMAIl_TYPE_RESET_PASSWORD_CONFIRMATION)); orderConfirmationEmailBean.setFromName( marketArea.getEmailFromName(contextNameValue, Email.EMAIl_TYPE_RESET_PASSWORD_CONFIRMATION)); orderConfirmationEmailBean.setReplyToEmail( marketArea.getEmailFromAddress(contextNameValue, Email.EMAIl_TYPE_RESET_PASSWORD_CONFIRMATION)); orderConfirmationEmailBean.setToEmail(customer.getEmail()); if (order != null) { orderConfirmationEmailBean.setOrderNumber(order.getOrderNum()); DateFormat dateFormat = requestUtil.getFormatDate(requestData, DateFormat.MEDIUM, DateFormat.MEDIUM); if (order.getExpectedDeliveryDate() != null) { orderConfirmationEmailBean .setExpectedDeliveryDate(dateFormat.format(order.getExpectedDeliveryDate())); } else { orderConfirmationEmailBean.setExpectedDeliveryDate("NA"); } orderConfirmationEmailBean .setOrderItemsTotalWithCurrencySign(order.getOrderItemTotalWithStandardCurrencySign()); orderConfirmationEmailBean .setOrderShippingTotalWithCurrencySign(order.getShippingTotalWithStandardCurrencySign()); orderConfirmationEmailBean .setOrderTaxesTotalWithCurrencySign(order.getTaxTotalWithStandardCurrencySign()); orderConfirmationEmailBean.setOrderTotalWithCurrencySign(order.getOrderTotalWithStandardCurrencySign()); } emailService.buildAndSaveNewOrderConfirmationMail(requestData, customer, velocityPath, orderConfirmationEmailBean); }