code
stringlengths
67
466k
docstring
stringlengths
1
13.2k
public PropertyConstraint ifTrue(PropertyConstraint ifConstraint, PropertyConstraint thenConstraint, PropertyConstraint elseConstraint) { return new ConditionalPropertyConstraint(ifConstraint, thenConstraint, elseConstraint); }
Returns a ConditionalPropertyConstraint: one property will trigger the validation of another. @see ConditionalPropertyConstraint
public PropertyConstraint ifTrue(PropertyConstraint ifConstraint, PropertyConstraint[] thenConstraints) { return new ConditionalPropertyConstraint(ifConstraint, new CompoundPropertyConstraint(new And(thenConstraints))); }
Returns a ConditionalPropertyConstraint: one property will trigger the validation of another. @see ConditionalPropertyConstraint
public PropertyConstraint ifTrue(PropertyConstraint ifConstraint, PropertyConstraint[] thenConstraints, PropertyConstraint[] elseConstraints) { return new ConditionalPropertyConstraint(ifConstraint, new CompoundPropertyConstraint(new And(thenConstraints)), new CompoundPropertyConstraint(new And( elseConstraints))); }
Returns a ConditionalPropertyConstraint: one property will trigger the validation of another. @see ConditionalPropertyConstraint
public Constraint regexp(String regexp, String type) { RegexpConstraint c = new RegexpConstraint(regexp); c.setType(type); return c; }
Creates a constraint backed by a regular expression, with a type for reporting. @param regexp The regular expression string. @return The constraint.
public Constraint method(Object target, String methodName, String constraintType) { return new MethodInvokingConstraint(target, methodName, constraintType); }
Returns a constraint whose test is determined by a boolean method on a target object. @param target The targetObject @param methodName The method name @return The constraint.
public Constraint not(Constraint constraint) { if (!(constraint instanceof Not)) return new Not(constraint); return ((Not)constraint).getConstraint(); }
Negate the specified constraint. @param constraint The constraint to negate @return The negated constraint.
public PropertyConstraint inGroup(String propertyName, Object[] group) { return value(propertyName, new InGroup(group)); }
Returns a 'in' group (or set) constraint appled to the provided property. @param propertyName the property @param group the group items @return The InGroup constraint.
public PropertyConstraint all(String propertyName, Constraint[] constraints) { return value(propertyName, all(constraints)); }
Apply an "all" value constraint to the provided bean property. @param propertyName The bean property name @param constraints The constraints that form a all conjunction @return
public PropertyConstraint any(String propertyName, Constraint[] constraints) { return value(propertyName, any(constraints)); }
Apply an "any" value constraint to the provided bean property. @param propertyName The bean property name @param constraints The constraints that form a all disjunction @return
public PropertyConstraint eq(String propertyName, Object propertyValue) { return new ParameterizedPropertyConstraint(propertyName, eq(propertyValue)); }
Apply a "equal to" constraint to a bean property. @param propertyName The first property @param propertyValue The constraint value @return The constraint
public PropertyConstraint gt(String propertyName, Comparable propertyValue) { return new ParameterizedPropertyConstraint(propertyName, gt(propertyValue)); }
Apply a "greater than" constraint to a bean property. @param propertyName The first property @param propertyValue The constraint value @return The constraint
public PropertyConstraint gte(String propertyName, Comparable propertyValue) { return new ParameterizedPropertyConstraint(propertyName, gte(propertyValue)); }
Apply a "greater than equal to" constraint to a bean property. @param propertyName The first property @param propertyValue The constraint value @return The constraint
public PropertyConstraint lt(String propertyName, Comparable propertyValue) { return new ParameterizedPropertyConstraint(propertyName, lt(propertyValue)); }
Apply a "less than" constraint to a bean property. @param propertyName The first property @param propertyValue The constraint value @return The constraint
public PropertyConstraint lte(String propertyName, Comparable propertyValue) { return new ParameterizedPropertyConstraint(propertyName, lte(propertyValue)); }
Apply a "less than equal to" constraint to a bean property. @param propertyName The first property @param propertyValue The constraint value @return The constraint
public PropertyConstraint inRange(String propertyName, Object min, Object max, Comparator comparator) { return value(propertyName, range(min, max, comparator)); }
Apply a inclusive "range" constraint to a bean property. @param propertyName the property with the range constraint. @param min the low edge of the range @param max the high edge of the range @param comparator the comparator to use while comparing the values @return The range constraint constraint @since 0.3.0
public PropertyConstraint eqProperty(String propertyName, String otherPropertyName) { return valueProperties(propertyName, EqualTo.instance(), otherPropertyName); }
Apply a "equal to" constraint to two bean properties. @param propertyName The first property @param otherPropertyName The other property @return The constraint
public PropertyConstraint gtProperty(String propertyName, String otherPropertyName) { return valueProperties(propertyName, GreaterThan.instance(), otherPropertyName); }
Apply a "greater than" constraint to two properties @param propertyName The first property @param otherPropertyName The other property @return The constraint
public PropertyConstraint gteProperty(String propertyName, String otherPropertyName) { return valueProperties(propertyName, GreaterThanEqualTo.instance(), otherPropertyName); }
Apply a "greater than or equal to" constraint to two properties. @param propertyName The first property @param otherPropertyName The other property @return The constraint
public PropertyConstraint ltProperty(String propertyName, String otherPropertyName) { return valueProperties(propertyName, LessThan.instance(), otherPropertyName); }
Apply a "less than" constraint to two properties. @param propertyName The first property @param otherPropertyName The other property @return The constraint
public PropertyConstraint lteProperty(String propertyName, String otherPropertyName) { return valueProperties(propertyName, LessThanEqualTo.instance(), otherPropertyName); }
Apply a "less than or equal to" constraint to two properties. @param propertyName The first property @param otherPropertyName The other property @return The constraint
public PropertyConstraint inRange(String propertyName, Comparable min, Comparable max) { return value(propertyName, range(min, max)); }
Apply a inclusive "range" constraint to a bean property. @param propertyName the property with the range constraint. @param min the low edge of the range @param max the high edge of the range @return The range constraint constraint
public PropertyConstraint inRangeProperties(String propertyName, String minPropertyName, String maxPropertyName) { Constraint min = gteProperty(propertyName, minPropertyName); Constraint max = lteProperty(propertyName, maxPropertyName); return new CompoundPropertyConstraint(new And(min, max)); }
Apply a inclusive "range" constraint between two other properties to a bean property. @param propertyName the property with the range constraint. @param minPropertyName the low edge of the range @param maxPropertyName the high edge of the range @return The range constraint constraint
public Contact[] getSelectedContacts() { int[] selected = getTable().getSelectedRows(); Contact[] contacts = new Contact[selected.length]; for (int i = 0; i < selected.length; i++) { contacts[i] = (Contact) getTableModel().getElementAt(selected[i]); } return contacts; }
Get the array of selected Contact objects in the table. @return array of Contacts, zero length if nothing is selected
@Override public final void processComponent(String propertyName, final JComponent component) { final AbstractOverlayHandler overlayHandler = this.createOverlayHandler(propertyName, component); // Wait until has parent and overlay is correctly installed final PropertyChangeListener wait4ParentListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { final JComponent targetComponent = overlayHandler.getTargetComponent(); final JComponent overlay = overlayHandler.getOverlay(); // Install overlay final int position = AbstractOverlayFormComponentInterceptor.this.getPosition(); final Boolean success = AbstractOverlayFormComponentInterceptor.this.// getOverlayService().installOverlay(targetComponent, overlay, position, null); if (success) { targetComponent.removePropertyChangeListener(// AbstractOverlayFormComponentInterceptor.ANCESTOR_PROPERTY, this); } } }; component.addPropertyChangeListener(// AbstractOverlayFormComponentInterceptor.ANCESTOR_PROPERTY, wait4ParentListener); }
Creates an overlay handler for the given property name and component and installs the overlay. @param propertyName the property name. @param component the component. @see OverlayService#installOverlay(JComponent, JComponent)
public void setValue(Object toEntity, Object newValue) throws IllegalAccessException, InvocationTargetException { writeMethod.invoke(toEntity, new Object[]{newValue}); }
{@inheritDoc}
protected void initRules() { this.validationRules = new Rules( getClass() ) { protected void initRules() { add( PROPERTY_USERNAME, all( new Constraint[] { required(), minLength( getUsernameMinLength() ) } ) ); add( PROPERTY_PASSWORD, all( new Constraint[] { required(), minLength( getPasswordMinLength() ) } ) ); } protected int getUsernameMinLength() { return 2; } protected int getPasswordMinLength() { return 2; } }; }
Initialize the field constraints for our properties. Minimal constraints are enforced here. If you need more control, you should override this in a subtype.
private Icon getIcon( Severity severity ) { if( severity == Severity.ERROR ) { return getErrorIcon(); } if( severity == Severity.WARNING ) { return getWarningIcon(); } return getInfoIcon(); }
Returns the icon for the given severity. @param severity The severity level. @return The icon for the given severity, never null.
public void setAuthorizingRoles(String roles) { // The ConfigAttributeEditor is named incorrectly, so you can't use it // to automatically convert the string to a ConfigAttributeDefinition. // So, we do it manually :-( ConfigAttributeEditor editor = new ConfigAttributeEditor(); editor.setAsText( roles ); this.roles = (List<ConfigAttribute>) editor.getValue(); rolesString = roles; }
Set the roles to compare against the current user's authenticated roles. The secured objects will be authorized if the user holds one or more of these roles. This should be specified as a simple list of comma separated role names. @param roles
public static Method getReadMethod(Class<?> clazz, String propertyName) throws NoSuchMethodError { String propertyNameCapitalized = capitalize(propertyName); try { return clazz.getMethod("get" + propertyNameCapitalized); } catch (Exception e) { try { return clazz.getMethod("is" + propertyNameCapitalized); } catch (Exception e1) { throw new NoSuchMethodError("Could not find getter (getXX or isXXX) for property: " + propertyName); } } }
Lookup the getter method for the given property. This can be a getXXX() or a isXXX() method. @param clazz type which contains the property. @param propertyName name of the property. @return a Method with read-access for the property.
public static Class<?> getTypeForProperty(Method getter) { Class<?> returnType = getter.getReturnType(); if (returnType.equals(Void.TYPE)) throw new IllegalArgumentException("Getter " + getter.toString() + " does not have a returntype."); else if (returnType.isPrimitive()) return MethodUtils.getPrimitiveWrapper(returnType); return returnType; }
Returns the type of the property checking if it actually does return something and wrapping primitives if needed. @param getter the method to access the property. @return the type of the property. @throws IllegalArgumentException if the method has a {@link Void} return type.
public static final Method getWriteMethod(Class<?> clazz, String propertyName, Class<?> propertyType) { String propertyNameCapitalized = capitalize(propertyName); try { return clazz.getMethod("set" + propertyNameCapitalized, new Class[]{propertyType}); } catch (Exception e) { return null; } }
Lookup the setter method for the given property. @param clazz type which contains the property. @param propertyName name of the property. @param propertyType type of the property. @return a Method with write-access for the property.
public static String capitalize(String s) { if (s == null || s.length() == 0) { return s; } char chars[] = s.toCharArray(); chars[0] = Character.toUpperCase(chars[0]); return new String(chars); }
Small helper method to capitalize the first character of the given string. @param s string to capitalize @return a string starting with a capital character.
public static Accessor getAccessorForProperty(final Class<?> clazz, final String propertyName) { int splitPoint = propertyName.indexOf('.'); if (splitPoint > 0) { String firstPart = propertyName.substring(0, splitPoint); String secondPart = propertyName.substring(splitPoint + 1); return new NestedAccessor(clazz, firstPart, secondPart); } return new SimpleAccessor(clazz, propertyName); }
Create an {@link Accessor} for the given property. A property may be nested using the dot character. @param clazz the type containing the property. @param propertyName the name of the property. @return an Accessor for the property.
public static Writer getWriterForProperty(final Class<?> beanClass, final String propertyName) { int splitPoint = propertyName.indexOf('.'); if (splitPoint > 0) { String firstPart = propertyName.substring(0, splitPoint); String secondPart = propertyName.substring(splitPoint + 1); return new NestedWriter(beanClass, firstPart, secondPart); } return new SimpleWriter(beanClass, propertyName); }
Create a {@link Writer} for the given property. A property may be nested using the dot character. @param clazz the type containing the property. @param propertyName the name of the property. @return a Writer for the property.
public static void attachOverlay(JComponent overlay, JComponent overlayTarget, int center, int xOffset, int yOffset) { new OverlayHelper(overlay, overlayTarget, center, xOffset, yOffset); }
Attaches an overlay to the specified component. @param overlay the overlay component @param overlayTarget the component over which <code>overlay</code> will be attached @param center position relative to <code>overlayTarget</code> that overlay should be centered. May be one of the <code>SwingConstants</code> compass positions or <code>SwingConstants.CENTER</code>. @param xOffset x offset from center @param yOffset y offset from center @see SwingConstants
private Rectangle findLargestVisibleRectFor(final Rectangle overlayRect) { Rectangle visibleRect = null; int curxoffset = 0; int curyoffset = 0; if (overlayTarget == null) { return null; } JComponent comp = overlayTarget; do { visibleRect = comp.getVisibleRect(); visibleRect.x -= curxoffset; visibleRect.y -= curyoffset; if (visibleRect.contains(overlayRect)) { return visibleRect; } curxoffset += comp.getX(); curyoffset += comp.getY(); comp = comp.getParent() instanceof JComponent ? (JComponent) comp.getParent() : null; } while (comp != null && !(comp instanceof JViewport) && !(comp instanceof JScrollPane)); return visibleRect; }
Searches up the component hierarchy to find the largest possible visible rect that can enclose the entire rectangle. @param overlayRect rectangle whose largest enclosing visible rect to find @return largest enclosing visible rect for the specified rectangle
protected void listWorkerDone(List<Object> rows, Map<String, Object> parameters) { setRows(rows); // remove maximumRowsExceededMessages if needed validationResultsModel.removeMessage(maximumRowsExceededMessage); if ((rows == null) || (rows.size() == 0)) { return; } Object defaultSelectedObject = null; if (parameters.containsKey(PARAMETER_DEFAULT_SELECTED_OBJECT)) { defaultSelectedObject = parameters .get(PARAMETER_DEFAULT_SELECTED_OBJECT); } if (defaultSelectedObject == null) { getTableWidget().selectRowObject(0, null); } else { getTableWidget().selectRowObject(defaultSelectedObject, null); } }
This method is called on the gui-thread when the worker ends. As default it will check for the PARAMETER_DEFAULT_SELECTED_OBJECT parameter in the map. @param rows fetched by the listWorker. @param parameters a map of parameters specific to this listWorker instance.
@Override public void setTitle(String title) { super.setTitle(title); getTableWidget().getTable().setName(title); }
}
@Override public Widget createDetailWidget() { return new AbstractWidget() { @Override public void onAboutToShow() { DefaultDataEditorWidget.this.onAboutToShow(); } @Override public void onAboutToHide() { DefaultDataEditorWidget.this.onAboutToHide(); } public JComponent getComponent() { return getDetailForm().getControl(); } @Override public List<? extends AbstractCommand> getCommands() { return Arrays.asList(getDetailForm().getCommitCommand()); } @Override public String getId() { return DefaultDataEditorWidget.this.getId() + "." + getDetailForm().getId(); } }; }
Returns only the detail form widget
protected void setDetailForm(AbstractForm detailForm) { if (this.detailForm != null) { validationResultsModel.remove(this.detailForm.getFormModel() .getValidationResults()); } this.detailForm = detailForm; if (this.detailForm != null) { validationResultsModel.add(this.detailForm.getFormModel() .getValidationResults()); } }
Set the form that will handle one detail item.
protected void setFilterForm(FilterForm filterForm) { if (this.filterForm != null) { validationResultsModel.remove(this.filterForm.getFormModel() .getValidationResults()); } this.filterForm = filterForm; if (this.filterForm != null) { validationResultsModel.add(filterForm.getFormModel() .getValidationResults()); } }
Set the form to use as filter. @see DataProvider#supportsFiltering()
protected void setTableWidget(final TableDescription tableDescription) { Assert.notNull(tableDescription); tableWidget = new CachedCallable<TableWidget>() { @Override protected TableWidget doCall() { TableWidget tableWidget = new GlazedListTableWidget(null, tableDescription); tableWidget.addSelectionObserver(tableSelectionObserver); return tableWidget; } }; }
Create a {@link GlazedListTableWidget} based on the given {@link TableDescription} to be used as listView. @param tableDescription description of columns used to create the table.
protected void setDataProvider(DataProvider provider) { if ((this.dataProvider != null) && (this.dataProvider.getRefreshPolicy() == DataProvider.RefreshPolicy.ON_USER_SWITCH)) { getApplicationConfig() .applicationSession() .removePropertyChangeListener(ApplicationSession.USER, this); } this.dataProvider = provider; if ((this.dataProvider != null) && (this.dataProvider.getRefreshPolicy() == DataProvider.RefreshPolicy.ON_USER_SWITCH)) { getApplicationConfig().applicationSession().addPropertyChangeListener( ApplicationSession.USER, this); } }
Set the provider to use for data manipulation.
@Override public synchronized void executeFilter(Map<String, Object> parameters) { if (listWorker == null) { if (dataProvider.supportsBaseCriteria()) { dataProvider.setBaseCriteria(getBaseCriteria()); } StatusBar statusBar = getApplicationConfig().windowManager() .getActiveWindow().getStatusBar(); statusBar.getProgressMonitor().taskStarted( getApplicationConfig().messageResolver().getMessage("statusBar", "loadTable", MessageConstants.LABEL), StatusBarProgressMonitor.UNKNOWN); // getFilterForm().getCommitCommand().setEnabled(false); // getRefreshCommand().setEnabled(false); listWorker = new ListRetrievingWorker(); if (dataProvider.supportsFiltering()) { if (parameters.containsKey(PARAMETER_FILTER)) { setFilterModel(parameters.get(PARAMETER_FILTER)); } listWorker.filterCriteria = getFilterForm().getFilterCriteria(); } listWorker.parameters = parameters; log.debug("Execute Filter with criteria: " + listWorker.filterCriteria + " and parameters: " + parameters); listWorker.execute(); } }
Executes filter and fills table in specific manner: <p/> <ul> <li>set baseCriteria if needed</li> <li>set searchCriteria on filterForm</li> <li>set searchCriteria on worker</li> <li>pass parameter map to worker</li> <li>launch worker to retrieve list from back-end and fill table</li> <li>when done, set list and execute additional code taking the parameters into account</li> </ul> @param parameters a number of parameters that can influence this run. Should be a non-modifiable map or a specific instance.
protected List getList(Object criteria) { if (this.dataProvider.supportsBaseCriteria()) { this.dataProvider.setBaseCriteria(getBaseCriteria()); } try { List dataSet = this.dataProvider.getList(criteria); setRows(dataSet); setMessage(null); return dataSet; } catch (MaximumRowsExceededException mre) { setRows(Collections.EMPTY_LIST); setMessage(new DefaultMessage(getApplicationConfig().messageResolver() .getMessage( "dataeditor.maximumRowsExceededException.notice", new Object[] { mre.getNumberOfRows(), mre.getMaxRows() }), Severity.WARNING)); if (getToggleFilterCommand() != null) { getToggleFilterCommand().doShow(); } return null; } }
<b>Warning!</b> this can block threads for an extended period, make sure you're aware of this. <p/> <p> Alternative: {@link #executeFilter()} will launch separate worker and fills table. </p> @param criteria @return
@Override public void onAboutToShow() { log.debug(getId() + ": onAboutToShow with refreshPolicy: " + dataProvider.getRefreshPolicy()); super.onAboutToShow(); dataProvider.addDataProviderListener(this); registerListeners(); if (detailForm instanceof Widget) { ((Widget) detailForm).onAboutToShow(); } getTableWidget().onAboutToShow(); // lazy loading, if no list is present, load when widget is shown // include RefreshPolicy given by DataProvider if ((dataProvider.getRefreshPolicy() != DataProvider.RefreshPolicy.NEVER) && (getTableWidget().isEmpty())) { executeFilter(); } else if (!getTableWidget().hasSelection()) { getTableWidget().selectRowObject(0, this); } }
{@inheritDoc}
@Override public void onAboutToHide() { log.debug(getId() + ": onAboutToHide with refreshPolicy: " + dataProvider.getRefreshPolicy()); super.onAboutToHide(); this.dataProvider.removeDataProviderListener(this); unRegisterListeners(); if (detailForm instanceof Widget) { ((Widget) detailForm).onAboutToHide(); } if (dataProvider.getRefreshPolicy() == DataProvider.RefreshPolicy.ALLWAYS) { getTableWidget().setRows(Collections.EMPTY_LIST); } }
{@inheritDoc}
public Object setSelectedSearch(Object criteria) { // filterField leegmaken if (getTableWidget().getTextFilterField() != null) { getTableWidget().getTextFilterField().setText(""); } // if Referable == null, empty filterForm and execute filter if (criteria == null) { if (dataProvider.supportsFiltering()) { getFilterForm().getNewFormObjectCommand().execute(); } executeFilter(); return null; } List resultList = getList(criteria); if (dataProvider.supportsFiltering()) { // adapt filterForm to reflect referable criteria if ((resultList == null) || (resultList.size() > 0)) // fill in // referable { getFilterForm().setFormObject(criteria); } else { // empty filterForm and execute getFilterForm().getNewFormObjectCommand().execute(); executeFilter(); } } if (resultList != null && resultList.size() == 1) { // return the detailObject // return loadEntityDetails(resultList.get(0)); return loadSimpleEntity(resultList.get(0)); } return resultList; }
note: differs from previous method to allow setting of formObject on filterForm. Will probably end up in refactoring of dataeditorwidget. @param criteria formObject to set on FilterForm. @return
protected CommandGroup createCommandGroup() { CommandGroup group; if (isExclusive()) { ExclusiveCommandGroup g = new ExclusiveCommandGroup(getGroupId(), getCommandRegistry()); g.setAllowsEmptySelection(isAllowsEmptySelection()); group = g; } else { group = new CommandGroup(getGroupId(), getCommandRegistry()); } // Apply our security controller id to the new group group.setSecurityControllerId(getSecurityControllerId()); initCommandGroupMembers(group); return group; }
registry has not been provided.
protected void initCommandGroupMembers(CommandGroup group) { for (int i = 0; i < members.length; i++) { Object o = members[i]; if (o instanceof AbstractCommand) { group.addInternal((AbstractCommand) o); configureIfNecessary((AbstractCommand) o); } else if (o instanceof Component) { group.addComponentInternal((Component) o); } else if (o instanceof String) { String str = (String) o; if (str.equalsIgnoreCase(SEPARATOR_MEMBER_CODE)) { group.addSeparatorInternal(); } else if (str.equalsIgnoreCase(GLUE_MEMBER_CODE)) { group.addGlueInternal(); } else if (str.startsWith(COMMAND_MEMBER_PREFIX)) { String commandId = str.substring(COMMAND_MEMBER_PREFIX.length()); if (!StringUtils.hasText(commandId)) { throw new InvalidGroupMemberEncodingException( "The group member encoding does not specify a command id", str); } addCommandMember(str.substring(COMMAND_MEMBER_PREFIX.length()), group); } else if (str.startsWith(GROUP_MEMBER_PREFIX)) { String commandId = str.substring(GROUP_MEMBER_PREFIX.length()); if (!StringUtils.hasText(commandId)) { throw new InvalidGroupMemberEncodingException( "The group member encoding does not specify a command id", str); } addCommandMember(commandId, group); } else { addCommandMember(str, group); } } } }
Iterates over the collection of encoded members and adds them to the given command group. @param group The group that is to contain the commands from the encoded members list. Must not be null. @throws InvalidGroupMemberEncodingException if a member prefix is provided without a command id.
private void addCommandMember(String commandId, CommandGroup group) { Assert.notNull(commandId, "commandId"); Assert.notNull(group, "group"); if (logger.isDebugEnabled()) { logger.debug("adding command group member with id [" + commandId + "] to group [" + group.getId() + "]"); } AbstractCommand command = null; if (getCommandRegistry() != null) { command = (AbstractCommand) getCommandRegistry().getCommand(commandId); if (command != null) { group.addInternal(command); } } if (command == null) { group.addLazyInternal(commandId); } }
Adds the command object with the given id to the given command group. If a command registry has not yet been provided to this factory, the command id will be passed as a 'lazy placeholder' to the group instead. @param commandId The id of the command to be added to the group. This is expected to be in decoded form, i.e. any command prefixes have been removed. Must not be null. @param group The group that the commands will be added to. Must not be null.
protected void configureIfNecessary(AbstractCommand command) { Assert.notNull(command, "command"); if (getCommandConfigurer() != null) { if (!command.isFaceConfigured()) { getCommandConfigurer().configure(command); } } }
Configures the given command if it has not already been configured and this instance has been provided with a {@link CommandConfigurer}. @param command The command to be configured. @throws IllegalArgumentException if {@code command} is null.
public void updateShowViewCommands(){ ViewDescriptorRegistry viewDescriptorRegistry = ValkyrieRepository.getInstance().getApplicationConfig().viewDescriptorRegistry(); ViewDescriptor[] views = viewDescriptorRegistry.getViewDescriptors(); for (ViewDescriptor view : views) { String id = view.getId(); CommandManager commandManager = window.getCommandManager(); /*if(commandManager.containsActionCommand(id)){ ActionCommand command = commandManager.getActionCommand(id); command.setVisible(pageViews.contains(views[i].getId())); }*/ if (commandManager.isTypeMatch(id, ActionCommand.class)) { ActionCommand command = (ActionCommand) commandManager.getCommand(id, ActionCommand.class); command.setVisible(pageViews.contains(view.getId())); } } }
This sets the visible flag on all show view commands that are registered with the command manager. If the page contains the view the command is visible, otherwise not. The registration of the show view command with the command manager is the responsibility of the view descriptor.
public void openEditor(Object editorInput, boolean activateAfterOpen){ if(log.isDebugEnabled()){ log.debug("Attempting to open editor for "+editorInput.getClass().getName()); } if(workspaceComponent == null){ log.debug("WorkspaceComponent is null"); return; } PageDescriptor descriptor = getPageDescriptor(); if(descriptor instanceof JidePageDescriptor){ if(editorInput.getClass().isArray()){ Object[] array = (Object[])editorInput; for (Object editorObject : array) { processEditorObject(editorObject, activateAfterOpen); } } else{ processEditorObject(editorInput, activateAfterOpen); } } }
Implementation of the openEditor command using the editor factory injected into the page descriptor. The editor input is used as the key the factory uses to get the requires editor descriptor. If not editor factory is injected into the page descriptor then the default factory is used which simply returns null for every editor object resulting in no editor being opened. @param editorInput the editor contents @param activateAfterOpen specifies if the document should be activated after opening
public void setValue(Object toEntity, Object newValue) throws IllegalAccessException, InvocationTargetException { Object propertyValue = getter.invoke(toEntity); if (propertyValue != null) nestedWriter.setValue(propertyValue, newValue); }
Set the value on the source entity. If at any point the chaining results in a null value. The chaining should end. @param toEntity the entity on which the getter should operate. @param newValue the value to set.
public Object getValue(Object fromEntity) throws IllegalAccessException, InvocationTargetException { Object propertyValue = getter.invoke(fromEntity); return propertyValue == null ? null : nestedWriter.getValue(propertyValue); }
Get the value from the source entity. If at any point the chaining results in a null value. The chaining should end and return <code>null</code>. @param fromEntity the entity on which the getter should operate. @return <code>null</code> if at any point in the chaining a property returned <code>null</code> or the value of the nested property.
protected JComponent createControl() { PropertyColumnTableDescription desc = new PropertyColumnTableDescription("contactViewTable", Contact.class); desc.addPropertyColumn("lastName").withMinWidth(150); desc.addPropertyColumn("firstName").withMinWidth(150); desc.addPropertyColumn("address.address1"); desc.addPropertyColumn("address.city"); desc.addPropertyColumn("address.state"); desc.addPropertyColumn("address.zip"); widget = new GlazedListTableWidget(Arrays.asList(contactDataStore.getAllContacts()), desc); JPanel table = new JPanel(new BorderLayout()); table.add(widget.getListSummaryLabel(), BorderLayout.NORTH); table.add(widget.getComponent(), BorderLayout.CENTER); table.add(widget.getButtonBar(), BorderLayout.SOUTH); CommandGroup popup = new CommandGroup(); popup.add((ActionCommand) getWindowCommandManager().getCommand("deleteCommand", ActionCommand.class)); popup.addSeparator(); popup.add((ActionCommand) getWindowCommandManager().getCommand("propertiesCommand", ActionCommand.class)); JPopupMenu popupMenu = popup.createPopupMenu(); widget.getTable().addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { // If the user right clicks on a row other than the selection, // then move the selection to the current row if (e.getButton() == MouseEvent.BUTTON3) { int rowUnderMouse = widget.getTable().rowAtPoint(e.getPoint()); if (rowUnderMouse != -1 && !widget.getTable().isRowSelected(rowUnderMouse)) { // Select the row under the mouse widget.getTable().getSelectionModel().setSelectionInterval(rowUnderMouse, rowUnderMouse); } } } @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() >= 2) { if (propertiesExecutor.isEnabled()) propertiesExecutor.execute(); } } }); widget.getTable().addMouseListener(new PopupMenuMouseListener(popupMenu)); ValueModel selectionHolder = new ListSelectionValueModelAdapter(widget.getTable().getSelectionModel()); new ListSingleSelectionGuard(selectionHolder, deleteExecutor); new ListSingleSelectionGuard(selectionHolder, propertiesExecutor); JPanel view = new JPanel(new BorderLayout()); view.add(widget.getTextFilterField(), BorderLayout.NORTH); view.add(table, BorderLayout.CENTER); return view; //"lastName", "firstName", "address.address1", "address.city", "address.state", "address.zip" // JPanel filterPanel = new JPanel(new BorderLayout()); // JLabel filterLabel = getComponentFactory().createLabel("nameAddressFilter.label"); // filterPanel.add(filterLabel, BorderLayout.WEST); // // String tip = getMessage("nameAddressFilter.caption"); // filterField = getComponentFactory().createTextField(); // filterField.setToolTipText(tip); // filterPanel.add(filterField, BorderLayout.CENTER); // filterPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); // // contactTable = new ContactTableFactory().createContactTable(); // // JPanel view = new JPanel(new BorderLayout()); // JScrollPane sp = getComponentFactory().createScrollPane(contactTable.getControl()); // view.add(filterPanel, BorderLayout.NORTH); // view.add(sp, BorderLayout.CENTER); // return view; }
Create the control for this view. This method is called by the platform in order to obtain the control to add to the surrounding window and page. @return component holding this view
protected void registerLocalCommandExecutors(PageComponentContext context) { context.register("newContactCommand", newContactExecutor); context.register(GlobalCommandIds.PROPERTIES, propertiesExecutor); getApplicationConfig().securityControllerManager().addSecuredObject(propertiesExecutor); context.register(GlobalCommandIds.DELETE, deleteExecutor); getApplicationConfig().securityControllerManager().addSecuredObject(deleteExecutor); }
Register the local command executors to be associated with named commands. This is called by the platform prior to making the view visible.
public EditorDescriptor getEditorDescriptor(Object editorObject) { Class editorClass = editorObject.getClass(); EditorDescriptor descriptor = (EditorDescriptor)editorMap.get(editorClass); if(descriptor == null){ Iterator it = editorMap.keySet().iterator(); while(it.hasNext()){ Class klass = (Class)it.next(); if(klass.isAssignableFrom(editorClass)){ descriptor = (EditorDescriptor)editorMap.get(klass); } } } return descriptor; }
Returns an EditorDescriptor keyed by the class of the injected object. If non exists null is returned.
protected Object doParseValue(String formattedString, Class targetClass) throws ParseException { return dateFormat.parse(formattedString); }
convert back from string to date
protected final Object buildGroupModel(Object parentModel, CommandGroup commandGroup, int level) { return buildGroupComponent((JComponent) parentModel, commandGroup, level); }
Implementation wrapping around the {@link #buildGroupComponent(JComponent, CommandGroup, int)}
protected final Object buildChildModel(Object parentModel, AbstractCommand command, int level) { return buildChildComponent((JComponent) parentModel, command, level); }
Implementation wrapping around the {@link #buildChildComponent(JComponent, AbstractCommand, int)}
public void setActiveComponent(PageComponent pageComponent) { if (!pageComponents.contains(pageComponent)) { return; } // if pageComponent is already active, don't do anything if (this.activeComponent == pageComponent || settingActiveComponent) { return; } settingActiveComponent = true; try { if (this.activeComponent != null) { fireFocusLost(this.activeComponent); } giveFocusTo(pageComponent); this.activeComponent = pageComponent; fireFocusGained(this.activeComponent); } finally { // If this is not done in a finally, any exception thrown in fireFocusGained // will prevent the user from leaving the screen settingActiveComponent = false; } }
Activates the given <code>PageComponent</code>. Does nothing if it is already the active one. <p> Does nothing if this <code>ApplicationPage</code> doesn't contain the given <code>PageComponent</code>. @param pageComponent the <code>PageComponent</code>
public boolean close(PageComponent pageComponent) { if (!pageComponent.canClose()) { return false; } if (!pageComponents.contains(pageComponent)) { return false; } if (pageComponent == activeComponent) { fireFocusLost(pageComponent); activeComponent = null; } doRemovePageComponent(pageComponent); pageComponents.remove(pageComponent); pageComponent.removePropertyChangeListener(pageComponentUpdater); if (pageComponent instanceof ApplicationListener && getApplicationEventMulticaster() != null) { getApplicationEventMulticaster().removeApplicationListener((ApplicationListener) pageComponent); } pageComponent.dispose(); fireClosed(pageComponent); if (activeComponent == null) { setActiveComponent(); } return true; }
Closes the given <code>PageComponent</code>. This method disposes the <code>PageComponent</code>, triggers all necessary events ("focus lost" and "closed"), and will activate another <code>PageComponent</code> (if there is one). <p> Returns <code>false</code> if this <code>ApplicationPage</code> doesn't contain the given <code>PageComponent</code>. @param pageComponent the <code>PageComponent</code> @return boolean <code>true</code> if pageComponent was successfully closed.
public boolean close() { for (Iterator<PageComponent> iter = new HashSet<PageComponent>(pageComponents).iterator(); iter.hasNext();) { PageComponent component = iter.next(); if (!close(component)) return false; } return true; }
Closes this <code>ApplicationPage</code>. This method calls {@link #close(PageComponent)} for each open <code>PageComponent</code>. @return <code>true</code> if the operation was successful, <code>false</code> otherwise.
protected void addPageComponent(PageComponent pageComponent) { pageComponents.add(pageComponent); doAddPageComponent(pageComponent); pageComponent.addPropertyChangeListener(pageComponentUpdater); fireOpened(pageComponent); }
Adds the pageComponent to the components list while registering listeners and firing appropriate events. (not yet setting the component as the active one) @param pageComponent the pageComponent to add.
protected PageComponent createPageComponent(PageComponentDescriptor descriptor) { PageComponent pageComponent = descriptor.createPageComponent(); pageComponent.setContext(new DefaultViewContext(this, createPageComponentPane(pageComponent))); if (pageComponent instanceof ApplicationListener && getApplicationEventMulticaster() != null) { getApplicationEventMulticaster().addApplicationListener((ApplicationListener) pageComponent); } return pageComponent; }
Creates a PageComponent for the given PageComponentDescriptor. @param descriptor the descriptor @return the created PageComponent
public boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) { if (ks == KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0) || ks == KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)) { return false; } return super.processKeyBinding(ks, e, condition, pressed); }
Overiding this method prevents the TextField from intercepting the Enter Key when focus is not on it. This allows default buttons to function. This should be removed when Swing fixes their bug. @see javax.swing.JComponent#processKeyBinding(javax.swing.KeyStroke, java.awt.event.KeyEvent, int, boolean)
private boolean managesCommand(Component component, String commandId) { if (component instanceof AbstractButton) { AbstractButton button = (AbstractButton) component; if (null != button.getActionCommand()) { if (button.getActionCommand().equals(commandId)) { return true; } } } else if (component instanceof Container) { Component[] subComponents = ((Container) component).getComponents(); for (int i = 0; i < subComponents.length; ++i) { if (managesCommand(subComponents[i], commandId)) { return true; } } } return false; }
Searches through the component and nested components in order to see if the command with supplied id exists in this component. @param component The component that should be searched. @param commandId The id of the command to be checked for. @return true if the component, or any of its nested components, is a command with the given command id.
protected void fill(GroupContainerPopulator containerPopulator, Object controlFactory, CommandButtonConfigurer buttonConfigurer, java.util.List previousButtons) { Assert.notNull(containerPopulator, "containerPopulator"); containerPopulator.add(component); }
Asks the given container populator to add a component to its underlying container.
protected void reallocateIndexes() { indexes = new Integer[getFilteredModel().getSize()]; for (int i = 0; i < indexes.length; i++) { indexes[i] = new Integer(i); } applyComparator(); }
Internally called to reallocate the indexes. This method should be called when the filtered model changes its element size
protected void update() { putValue(Action.ACTION_COMMAND_KEY, command.getActionCommand()); CommandFaceDescriptor face = command.getFaceDescriptor(); if (face != null) { face.configure(this); } setEnabled(command.isEnabled()); }
Updates this instance according to the properties provided by the underlying command.
public final void setConstraint(Constraint constraint) { Assert.notNull(constraint); if (!constraint.equals(this.constraint)) { if (this.constraint instanceof Observable) { ((Observable) constraint).deleteObserver(this); } this.constraint = constraint; if (constraint instanceof Observable) { ((Observable) constraint).addObserver(this); } fireContentsChanged(this, -1, -1); } }
Defines the constraint which is applied to the list model elements @param constraint the constraint to set @throws IllegalArgumentException if constraint is null
protected void reallocateIndexes() { if (this.indexes == null || this.indexes.length != getFilteredModel().getSize()) { this.indexes = new int[getFilteredModel().getSize()]; } applyConstraint(); }
Internally called to reallocate the indexes. This method should be called when the filtered model changes its element size
public void setNumShards(final int numShards) { Preconditions.checkArgument(numShards > 0, "A Counter must have at least 1 CounterShard!"); this.numShards = numShards; this.setUpdatedDateTime(new DateTime(DateTimeZone.UTC)); }
Setter for {@code numShards}. @param numShards @throws IllegalArgumentException if {@code numShards} is less-than or equals to zero.
public static Key<CounterData> key(final String counterName) { Preconditions.checkNotNull(counterName); Preconditions.checkArgument(!StringUtils.isBlank(counterName), "CounterData Names may not be null, blank, or empty!"); return Key.create(CounterData.class, counterName); }
Create a {@link Key Key<CounterData>}. Keys for this entity are not "parented" so that they can be added under high volume load in a given application. Note that CounterData will be in a namespace specific. @param counterName The name of the Counter to create a Key for. @return A {@link Key}
public static void customizeFocusTraversalOrder(JComponent container, java.util.List componentsInOrder) { for (Iterator i = componentsInOrder.iterator(); i.hasNext();) { Component comp = (Component)i.next(); if (comp.getParent() != container) { throw new IllegalArgumentException("Component [" + comp + "] is not a child of [" + container + "]."); } } container.putClientProperty(FOCUS_ORDER_PROPERTY_NAME, createOrderMapFromList(componentsInOrder)); }
Sets a custom focus traversal order for the given container. Child components for which there is no order specified will receive focus after components that do have an order specified in the standard "layout" order. @param container the container @param componentsInOrder a list of child components in the order that thay should receive focus
protected void init() { addPropertyChangeListener(ENABLED_PROPERTY, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { validatingUpdated(); } }); validationResultsModel.addPropertyChangeListener(ValidationResultsModel.HAS_ERRORS_PROPERTY, childStateChangeHandler); }
Initialization of DefaultFormModel. Adds a listener on the Enabled property in order to switch validating state on or off. When disabling a formModel, no validation will happen.
public boolean isValidating() { if (validating && isEnabled()) { if (getParent() instanceof ValidatingFormModel) { return ((ValidatingFormModel)getParent()).isValidating(); } return true; } return false; }
{@inheritDoc}
protected void childStateChanged(PropertyChangeEvent evt) { super.childStateChanged(evt); if (ValidationResultsModel.HAS_ERRORS_PROPERTY.equals(evt.getPropertyName())) { hasErrorsUpdated(); } }
{@inheritDoc} Additionally the {@link DefaultFormModel} adds the event: <ul> <li><em>Has errors event:</em> if the validation results model contains errors, the form model error state should be revised as well as the committable state.</li> </ul> Note that we see the {@link ValidationResultsModel} as a child model of the {@link DefaultFormModel} as the result model is bundled together with the value models.
protected void parentStateChanged(PropertyChangeEvent evt) { super.parentStateChanged(evt); if (ValidatingFormModel.VALIDATING_PROPERTY.equals(evt.getPropertyName())) { validatingUpdated(); } }
{@inheritDoc} Additionally the {@link DefaultFormModel} adds the event: <ul> <li><em>Validating state:</em> if validating is disabled on parent, child should not validate as well. If parent is set to validating the child's former validating state should apply.</li> </ul>
public ValidatingFormModel createChildPageFormModel(HierarchicalFormModel parentModel, String childPageName, String childFormObjectPropertyPath) { final ValueModel childValueModel = parentModel.getValueModel(childFormObjectPropertyPath); return createChildPageFormModel(parentModel, childPageName, childValueModel); }
Create a child form model nested by this form model identified by the provided name. The form object associated with the created child model is the value model at the specified parent property path. @param parentModel the model to create the FormModelFactory in @param childPageName the name to associate the created FormModelFactory with in the groupingModel @param childFormObjectPropertyPath the path into the groupingModel that the FormModelFactory is for @return The child form model
public FormModel getChild(HierarchicalFormModel formModel, String childPageName) { if (childPageName == null) throw new IllegalArgumentException("childPageName == null"); if (formModel == null) throw new IllegalArgumentException("formModel == null"); final FormModel[] children = formModel.getChildren(); if (children == null) return null; for (int i = 0; i < children.length; i++) { final FormModel child = children[i]; if (childPageName.equals(child.getId())) return child; } return null; }
Returns the child of the formModel with the given page name. @param formModel the parent model to get the child from @param childPageName the name of the child to retrieve @return null the child can not be found @throws IllegalArgumentException if childPageName or formModel are null
public static boolean isFieldProtected(FormModel formModel, String fieldName) { FieldMetadata metaData = formModel.getFieldMetadata(fieldName); return Boolean.TRUE.equals(metaData.getUserMetadata(UserMetadata.PROTECTED_FIELD)); }
tests if the usermetadata of the field has a boolean value true for the key {@value #PROTECTED_FIELD} @param fieldName the fieldname @return true if the field is protected, otherwise false
public static void setFieldProtected(FormModel formModel, String fieldName, boolean protectedField) { FieldMetadata metaData = formModel.getFieldMetadata(fieldName); metaData.getAllUserMetadata().put(PROTECTED_FIELD, Boolean.valueOf(protectedField)); }
defines the protectable state for a field @param formModel the formmodel @param fieldName the field to protect @param protectedField if true the field will be defined as protectable otherwise false
public CompoundConstraint addAll(List constraints) { Algorithms.instance().forEach(constraints, new Block() { protected void handle(Object o) { add((Constraint)o); } }); return this; }
Add the list of constraints to the set of constraints aggregated by this compound constraint. @param constraints the list of constraints to add @return A reference to this, to support chaining.
public final void uncaughtException(Thread thread, Throwable throwable) { Boolean infiniteLoopDetected = alreadyHandlingExceptionOnThisThread.get(); if (infiniteLoopDetected != null && infiniteLoopDetected.booleanValue()) { // Preventing infinite loop case 2 (see javadoc) // The original uncaughtException method has not yet returned String detectionLogMessage = "Infinite exception handling loop detected. " + "The ExceptionHandler has probably thrown the following exception itself:"; try { logger.error(detectionLogMessage, throwable); } catch (Throwable ignoredThrowable) { System.err.println(detectionLogMessage); throwable.printStackTrace(); } // Reset of alreadyHandlingExceptionOnThisThread not needed: // the original uncaughtException method will return and reset it. // Reset not wanted either: even if it's still looping, it is better to be able // to report the first exception and lose performance due to an infinite event loop // than to crash by hang-application-by-starvation due to too many dialogs. return; // Ignore the throwable } alreadyHandlingExceptionOnThisThread.set(Boolean.TRUE); try { processUncaughtException(thread, throwable); } catch (Throwable detectionThrowable) { // Preventing infinite loop case 1 (see javadoc) String detectionLogMessage = "The ExceptionHandler has thrown the following exception itself:"; try { logger.error(detectionLogMessage, detectionThrowable); } catch (Throwable ignoredThrowable) { System.err.println(detectionLogMessage); detectionThrowable.printStackTrace(); } } finally { alreadyHandlingExceptionOnThisThread.set(null); } }
Logs an exception and shows it to the user. <p/> Has infinite loop detection due to exception handling throwing an exception. An infinite loop can occur in different cases: <ul> <li> Case 1: The ExceptionHandler throws an exception, which is handled by the ExceptionHandler, which throws an exception, ... </li> <li> Case 2: notifyUserAboutException uses a modal dialog that triggers the event queue to do a focus lost That focus lost throws a new exception, catched by the event queue, which delegates it to the ExceptionHandler, which still hasn't returned from handling the original exception! Then the ExceptionHandler uses a modal dialog again, focus lost, throws exception, ... This causes a StackOverflowError or a hang-application-by-starvation due to too many dialogs.</li> </ul>
private void processUncaughtException(Thread thread, Throwable throwable) { if (exceptionPurger != null) { throwable = exceptionPurger.purge(throwable); } logException(thread, throwable); notifyUserAboutException(thread, throwable); }
Logs an exception and shows it to the user.
public void logException(Thread thread, Throwable throwable) { String logMessage; String errorCode = extractErrorCode(throwable); if (errorCode != null) { logMessage = "Uncaught throwable handled with errorCode (" + errorCode + ")."; } else { logMessage = "Uncaught throwable handled."; } doLogException(logMessage, throwable); }
Log an exception
public void setCommandExecutor(ActionCommandExecutor commandExecutor) { if (ObjectUtils.nullSafeEquals(this.commandExecutor, commandExecutor)) { return; } if (commandExecutor == null) { detachCommandExecutor(); } else { if (this.commandExecutor instanceof GuardedActionCommandExecutor) { unsubscribeFromGuardedCommandDelegate(); } this.commandExecutor = commandExecutor; attachCommandExecutor(); } }
Attaches the given executor to this command instance, detaching the current executor in the process. @param commandExecutor The executor to be attached. May be null, in which case this command will be disabled.
private void attachCommandExecutor() { if (this.commandExecutor instanceof GuardedActionCommandExecutor) { GuardedActionCommandExecutor dynamicHandler = (GuardedActionCommandExecutor)commandExecutor; setEnabled(dynamicHandler.isEnabled()); subscribeToGuardedCommandDelegate(); } else { setEnabled(true); } if (logger.isDebugEnabled()) { logger.debug("Command executor '" + this.commandExecutor + "' attached."); } }
Attaches the currently assigned command executor to this instance. The command will be enabled by default unless the executor is a {@link GuardedActionCommandExecutor}, in which case the command will be assigned the enabled state of the executor.
public void detachCommandExecutor() { if (this.commandExecutor instanceof GuardedActionCommandExecutor) { unsubscribeFromGuardedCommandDelegate(); } this.commandExecutor = null; setEnabled(false); logger.debug("Command delegate detached."); }
Detaches the current executor from this command and sets the command to disabled state.
protected void doExecuteCommand() { if (this.commandExecutor instanceof ParameterizableActionCommandExecutor) { ((ParameterizableActionCommandExecutor) this.commandExecutor).execute(getParameters()); } else { if (this.commandExecutor != null) { this.commandExecutor.execute(); } } }
Executes this command by delegating to the currently assigned executor.
public void validationResultsChanged(ValidationResults results) { if (resultsModel.getMessageCount() == 0) { messageReceiver.setMessage(null); } else { ValidationMessage message = getValidationMessage(resultsModel); messageReceiver.setMessage(message); } }
Handle a change in the validation results model. Update the message receiver based on our current results model state.
protected ValidationMessage getValidationMessage(ValidationResults resultsModel) { ValidationMessage validationMessage = null; for (Iterator i = resultsModel.getMessages().iterator(); i.hasNext();) { ValidationMessage tmpMessage = (ValidationMessage) i.next(); if (validationMessage == null || (validationMessage.getSeverity().compareTo(tmpMessage.getSeverity()) < 0) || ((validationMessage.getTimestamp() < tmpMessage.getTimestamp()) && (validationMessage .getSeverity() == tmpMessage.getSeverity()))) { validationMessage = tmpMessage; } } return validationMessage; }
<p> Get the message that should be reported. </p> Searching takes following rules into account: <ul> <li>Severity of the selected message is the most severe one (INFO < WARNING < ERROR).</li> <li>Timestamp of the selected message is the most recent one of the result of the previous rule.</li> </ul> Any custom Severities will be placed in order according to their given magnitude. @param resultsModel Search this model to find the message. @return the message to display on the Messagable.
protected void doExecuteCommand() { if(!ValkyrieRepository.getInstance().getApplicationConfig().applicationSecurityManager().isSecuritySupported()) { return ; } CompositeDialogPage tabbedPage = new TabbedDialogPage( "loginForm" ); final LoginForm loginForm = createLoginForm(); tabbedPage.addForm( loginForm ); if( getDefaultUserName() != null ) { loginForm.setUserName( getDefaultUserName() ); } dialog = new TitledPageApplicationDialog( tabbedPage ) { protected boolean onFinish() { loginForm.commit(); Authentication authentication = loginForm.getAuthentication(); // Hand this token to the security manager to actually attempt the login ApplicationSecurityManager sm = getApplicationConfig().applicationSecurityManager(); try { sm.doLogin( authentication ); postLogin(); return true; } finally { if( isClearPasswordOnFailure() ) { loginForm.setPassword(""); } loginForm.requestFocusInWindow(); } } protected void onCancel() { super.onCancel(); // Close the dialog // Now exit if configured if( isCloseOnCancel() ) { ApplicationSecurityManager sm = getApplicationConfig().applicationSecurityManager(); Authentication authentication = sm.getAuthentication(); if( authentication == null ) { LoginCommand.this.logger.info( "User canceled login; close the application." ); getApplicationConfig().application().close(); } } } protected ActionCommand getCallingCommand() { return LoginCommand.this; } protected void onAboutToShow() { loginForm.requestFocusInWindow(); } }; dialog.setDisplayFinishSuccessMessage( displaySuccessMessage ); dialog.showDialog(); }
Execute the login command. Display the dialog and attempt authentication.
public PageComponent createPageComponent() { AbstractView sv; sv = new WidgetView(getWidget()); sv.setDescriptor(this); return sv; }
{@inheritDoc}
@Override public void addDirtyRegion(JComponent c, int x, int y, int w, int h) { super.addDirtyRegion(c, x, y, w, h); // Aditional behaviour this.repaintOverlayable(c); }
{@inheritDoc}
protected void repaintOverlayable(JComponent c) { final Container parent = c.getParent(); if ((!(c instanceof Overlayable)) && (parent != null) && (parent instanceof DefaultOverlayable)) { OverlayableUtils.repaintOverlayable(c); } }
Repaints the parent container of the target component if that is a <code>DefaultOverlayable</code> instance. @param c the child component.
public static JideRepaintManager getInstance() { if (JideRepaintManager.instance == null) { JideRepaintManager.instance = new JideRepaintManager(); } return JideRepaintManager.instance; }
Gets the singleton instance initialized in a lazy mode (useful for reducing race conditions probability). @return the jide repaint manager.