code
stringlengths
67
466k
docstring
stringlengths
1
13.2k
public static void installJideRepaintManagerIfNeeded() { final RepaintManager current = RepaintManager.currentManager(null); if (current != JideRepaintManager.getInstance()) { // (JAF), 20110101, This is needed unless for setting a suitable PaintManager on target (RepaintManager // seems to be over-protected). ObjectUtils.shallowCopy(current, JideRepaintManager.getInstance()); RepaintManager.setCurrentManager(JideRepaintManager.getInstance()); } }
Installs this repaint manager if not already set. @see ObjectUtils#shallowCopy(Object, Object)
private static final void setBigDecimalFormat(NumberFormat format, Class numberClass) { if (format instanceof DecimalFormat && ((numberClass == BigDecimal.class) || (numberClass == BigInteger.class))) { ((DecimalFormat) format).setParseBigDecimal(true); } }
When parsing a number, BigDecimalFormat can return numbers different than BigDecimal. This method will ensure that when using a {@link BigDecimal} or a {@link java.math.BigInteger}, the formatter will return a {@link BigDecimal} in order to prevent loss of precision. Note that you should use the {@link DecimalFormat} to make this work. @param format @param numberClass @see #getValue() @see DecimalFormat#setParseBigDecimal(boolean)
public void addUserInputListener(UserInputListener listener) { if (this.listeners == null) this.listeners = new ArrayList(); this.listeners.add(listener); }
Add a UserInputListener. @param listener UserInputListener. @see UserInputListener
private void fireUserInputChange() { if (!internallySettingText && (this.listeners != null)) { for (Iterator it = this.listeners.iterator(); it.hasNext();) { UserInputListener userInputListener = (UserInputListener) it.next(); userInputListener.update(this); } } }
Fire an event to all UserInputListeners.
public Number getValue() { if ((getText() == null) || "".equals(getText().trim())) return null; try { Number n = format.parse(getText()); if (n.getClass() == this.numberClass) return n; else if (this.numberClass == BigDecimal.class) { BigDecimal bd = new BigDecimal(n.doubleValue()); if (scale != null) { bd = bd.setScale(scale.intValue(), BigDecimal.ROUND_HALF_UP); } return bd; } else if (this.numberClass == Double.class) return new Double(n.doubleValue()); else if (this.numberClass == Float.class) return new Float(n.floatValue()); else if (this.numberClass == BigInteger.class) // we have called setBigDecimalFormat to make sure a BigDecimal // is returned so use toBigInteger on that class return ((BigDecimal) n).toBigInteger(); else if (this.numberClass == Long.class) return new Long(n.longValue()); else if (this.numberClass == Integer.class) return new Integer(n.intValue()); else if (this.numberClass == Short.class) return new Short(n.shortValue()); else if (this.numberClass == Byte.class) return new Byte(n.byteValue()); return null; } catch (Exception pe) { log.error("Error: " + getText() + " is not a number.", pe); return null; } }
Parses a number from the inputField and will adjust it's class if needed. @return Number the Parsed number.
public void setValue(Number number) { String txt = null; if (number != null) { txt = this.format.format(number); } setText(txt); }
Format the number and show it. @param number Number to set.
public TableLayoutBuilder row() { ++currentRow; lastCC = null; maxColumns = Math.max(maxColumns, currentCol); currentCol = 0; return this; }
Inserts a new row. No gap row is inserted before this row.
public TableLayoutBuilder row(RowSpec gapRowSpec) { row(); gapRows.put(new Integer(currentRow), gapRowSpec); return this; }
Inserts a new row. A gap row with specified RowSpec will be inserted before this row.
public TableLayoutBuilder cell(JComponent component, String attributes) { Cell cc = cellInternal(component, attributes); lastCC = cc; items.add(cc); return this; }
Inserts a component at the current row/column. Attributes may be zero or more of rowSpec, columnSpec, colGrId, rowGrId, align and valign.
public TableLayoutBuilder separator(String labelKey, String attributes) { Cell cc = cellInternal(getComponentFactory().createLabeledSeparator(labelKey), attributes); lastCC = cc; items.add(cc); return this; }
Inserts a separator with the given label. Attributes my be zero or more of rowSpec, columnSpec, colGrId, rowGrId, align and valign. @deprecated this is a layout builder, creating components should be done elsewhere, use cell() methods instead
public JPanel getPanel() { if (panel == null) { panel = getComponentFactory().createPanel(); } insertMissingSpecs(); fixColSpans(); fillInGaps(); fillPanel(); if( focusOrder != null ) { installFocusOrder( focusOrder ); } return panel; }
Creates and returns a JPanel with all the given components in it, using the "hints" that were provided to the builder. @return a new JPanel with the components laid-out in it
public void setFocusTraversalOrder( int traversalOrder ) { Assert.isTrue( traversalOrder == COLUMN_MAJOR_FOCUS_ORDER || traversalOrder == ROW_MAJOR_FOCUS_ORDER, "traversalOrder must be one of COLUMN_MAJOR_FOCUS_ORDER or ROW_MAJOR_FOCUS_ORDER"); List focusOrder = new ArrayList(items.size()); if( traversalOrder == ROW_MAJOR_FOCUS_ORDER ) { for( int row=0; row < rowOccupiers.size() - 1; row++ ) { for( int col=0; col < maxColumns; col++ ) { Cell currentCell = getOccupier(row, col); if (currentCell != null && currentCell.getComponent() != null && !focusOrder.contains(currentCell.getComponent())) { focusOrder.add(currentCell.getComponent()); } } } } else if( traversalOrder == COLUMN_MAJOR_FOCUS_ORDER ) { for( int col = 0; col < maxColumns; col++ ) { for( int row = 0; row < rowOccupiers.size() - 1; row++ ) { Cell currentCell = getOccupier( row, col ); if( currentCell != null && currentCell.getComponent() != null && !focusOrder.contains( currentCell.getComponent() ) ) { focusOrder.add( currentCell.getComponent() ); } } } } setCustomFocusTraversalOrder( focusOrder ); }
Set the focus traversal order. @param traversalOrder focus traversal order. Must be one of {@link #COLUMN_MAJOR_FOCUS_ORDER} or {@link #ROW_MAJOR_FOCUS_ORDER}.
@Override protected void readOnlyChanged() { for (AbstractCommand abstractCommand : getCommands()) { if (isShowDetailSupported() && abstractCommand == getDetailCommand()) (abstractCommand).setEnabled(isEnabled()); else (abstractCommand).setEnabled(isEnabled() && !isReadOnly()); } }
Enable/disable the commands on readOnly change or valueModelChange
protected boolean containedIn(Throwable e, List<Class<? extends Throwable>> throwableClassList) { for (Class throwableClass : throwableClassList) { if (throwableClass.isInstance(e)) { return true; } } return false; }
}
public void documentComponentClosed(DocumentComponentEvent event) { if(logger.isDebugEnabled()){ logger.debug("Page component "+pageComponent.getId()+" closed"); } workspace.remove(pageComponent); ((JideApplicationPage)workspace.getContext().getPage()).fireClosed(pageComponent); }
Default closed implementation removes the given page component from the workspace view, and so the document from the document pane.
public boolean hasValueChanged(Object oldValue, Object newValue) { return !(oldValue == newValue || (oldValue != null && oldValue.equals( newValue ))); }
Determines if there has been a change in value between the provided arguments. The objects are compared using the <code>equals</code> method. @param oldValue Original object value @param newValue New object value @return true if the objects are different enough to indicate a change in the value model
public void setTitle(String title) { this.title = title; if (dialog != null) { dialog.setTitle(getTitle()); } }
{@inheritDoc}
protected String getTitle() { if (!StringUtils.hasText(this.title)) { if (StringUtils.hasText(getCallingCommandText())) return getCallingCommandText(); return DEFAULT_DIALOG_TITLE; } return this.title; }
Returns the title of this dialog. If no specific title has been set, the calling command's text will be used. If that doesn't yield a result, the default title is returned. @see #getCallingCommandText() @see #DEFAULT_DIALOG_TITLE
public void showDialog() { if (!isControlCreated()) { createDialog(); } if (!isShowing()) { onAboutToShow(); if (getLocation() != null) { dialog.setLocation(getLocation()); dialog.setPreferredSize(getPreferredSize()); } else { WindowUtils.centerOnParent(dialog, getLocationRelativeTo()); } dialog.setVisible(true); } }
<p> Show the dialog. The dialog will be created if it doesn't exist yet. Before setting the dialog visible, a hook method onAboutToShow is called and the location will be set. </p> <p> When showing the dialog several times, it will always be opened on the location that has been set, or relative to the parent. (former location will not persist) </p>
private void constructDialog() { if (getParentWindow() instanceof Frame) { dialog = new JDialog((Frame) getParentWindow(), getTitle(), modal); } else { dialog = new JDialog((Dialog) getParentWindow(), getTitle(), modal); } dialog.getContentPane().setLayout(new BorderLayout()); dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); dialog.setResizable(resizable); initStandardCommands(); addCancelByEscapeKey(); }
Construct the visual dialog frame on which the content needs to be added.
public static Window getWindowForComponent(Component parentComponent) throws HeadlessException { if (parentComponent == null) return JOptionPane.getRootFrame(); if (parentComponent instanceof Frame || parentComponent instanceof Dialog) return (Window) parentComponent; return getWindowForComponent(parentComponent.getParent()); }
<p> --jh-- This method is copied from JOptionPane. I'm still trying to figure out why they chose to have a static method with package visibility for this one instead of just making it public. </p> Returns the specified component's toplevel <code>Frame</code> or <code>Dialog</code>. @param parentComponent the <code>Component</code> to check for a <code>Frame</code> or <code>Dialog</code> @return the <code>Frame</code> or <code>Dialog</code> that contains the component, or the default frame if the component is <code>null</code>, or does not have a valid <code>Frame</code> or <code>Dialog</code> parent @exception HeadlessException if <code>GraphicsEnvironment.isHeadless</code> returns <code>true</code> @see java.awt.GraphicsEnvironment#isHeadless
private void initStandardCommands() { finishCommand = new ActionCommand(getFinishCommandId()) { public void doExecuteCommand() { boolean result = onFinish(); if (result) { if (getDisplayFinishSuccessMessage()) { showFinishSuccessMessageDialog(); } executeCloseAction(); } } }; finishCommand.setSecurityControllerId(getFinishSecurityControllerId()); finishCommand.setEnabled(defaultEnabled); cancelCommand = new ActionCommand(getCancelCommandId()) { public void doExecuteCommand() { onCancel(); } }; }
Initialize the standard commands needed on a Dialog: Ok/Cancel.
protected String getFinishSuccessMessage() { ActionCommand callingCommand = getCallingCommand(); if (callingCommand != null) { String[] successMessageKeys = new String[] { callingCommand.getId() + "." + SUCCESS_FINISH_MESSAGE_KEY, DEFAULT_FINISH_SUCCESS_MESSAGE_KEY }; return getApplicationConfig().messageResolver().getMessage(successMessageKeys, getFinishSuccessMessageArguments()); } return getApplicationConfig().messageResolver().getMessage(DEFAULT_FINISH_SUCCESS_MESSAGE_KEY); }
Returns the message to use upon succesful finish.
protected String getFinishSuccessTitle() { ActionCommand callingCommand = getCallingCommand(); if (callingCommand != null) { String[] successTitleKeys = new String[] { callingCommand.getId() + "." + SUCCESS_FINISH_TITLE_KEY, DEFAULT_FINISH_SUCCESS_TITLE_KEY }; return getApplicationConfig().messageResolver().getMessage(successTitleKeys, getFinishSuccessTitleArguments()); } return getApplicationConfig().messageResolver().getMessage(DEFAULT_FINISH_SUCCESS_TITLE_KEY); }
Returns the title to use upon succesful finish.
private void addCancelByEscapeKey() { int noModifiers = 0; KeyStroke escapeKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, noModifiers, false); addActionKeyBinding(escapeKey, cancelCommand.getId()); }
Force the escape key to call the same action as pressing the Cancel button. This does not always work. See class comment.
protected void addActionKeyBinding(KeyStroke key, String actionKey) { if (actionKey == finishCommand.getId()) { addActionKeyBinding(key, actionKey, finishCommand.getActionAdapter()); } else if (actionKey == cancelCommand.getId()) { addActionKeyBinding(key, actionKey, cancelCommand.getActionAdapter()); } else { throw new IllegalArgumentException("Unknown action key " + actionKey); } }
Add an action key binding to this dialog. @param key the {@link KeyStroke} that triggers the command/action. @param actionKey id of command that will be triggered by the {@link KeyStroke}. @see #addActionKeyBinding(KeyStroke, String, Action)
protected void addActionKeyBinding(KeyStroke key, String actionKey, Action action) { getInputMap().put(key, actionKey); getActionMap().put(actionKey, action); }
Add an action key binding to this dialog. @param key the {@link KeyStroke} that triggers the command/action. @param actionKey id of the action. @param action {@link Action} that will be triggered by the {@link KeyStroke}. @see #getActionMap() @see #getInputMap() @see ActionMap#put(Object, Action) @see InputMap#put(KeyStroke, Object)
protected void addDialogComponents() { JComponent dialogContentPane = createDialogContentPane(); GuiStandardUtils.attachDialogBorder(dialogContentPane); if (getPreferredSize() != null) { dialogContentPane.setPreferredSize(getPreferredSize()); } getDialogContentPane().add(dialogContentPane); getDialogContentPane().add(createButtonBar(), BorderLayout.SOUTH); }
Subclasses may override to customize how this dialog is built.
protected JComponent createButtonBar() { this.dialogCommandGroup = getCommandManager().createCommandGroup(null, getCommandGroupMembers()); JComponent buttonBar = this.dialogCommandGroup.createButtonBar(); GuiStandardUtils.attachDialogBorder(buttonBar); return buttonBar; }
Return a standardized row of command buttons, right-justified and all of the same size, with OK as the default button, and no mnemonics used, as per the Java Look and Feel guidelines.
protected java.util.List<? extends AbstractCommand> getCommandGroupMembers() { return Lists.<AbstractCommand>newArrayList(getFinishCommand(), getCancelCommand()); }
Template getter method to return the commands to populate the dialog button bar. @return The array of commands (may also be a separator or glue identifier)
public Window getParentWindow() { if (parentWindow == null) { if ((parentComponent == null) && (getApplicationConfig().windowManager().getActiveWindow() != null)) { parentWindow = getApplicationConfig().windowManager().getActiveWindow().getControl(); } else { parentWindow = getWindowForComponent(parentComponent); } } return parentWindow; }
Returns the parent window based on the internal parent Component. Will search for a Window in the parent hierarchy if needed (when parent Component isn't a Window). @return the parent window
protected void add(GroupMember member) { Assert.notNull(member, "member"); if (members.add(member)) { member.onAdded(); } }
Attempts to add the given member to this expansion point. The member will not be added if an equivalent entry (according to its equals() method) already exists. If added, the member's {@link GroupMember#onAdded()} method will be called. @param member The member to be added. Must not be null. @throws IllegalArgumentException if {@code member} is null.
protected void fill(GroupContainerPopulator containerPopulator, Object controlFactory, CommandButtonConfigurer configurer, List previousButtons) { Assert.notNull(containerPopulator, "containerPopulator"); Assert.notNull(controlFactory, "controlFactory"); Assert.notNull(configurer, "configurer"); if (members.size() > 0 && isLeadingSeparator()) { containerPopulator.addSeparator(); } for (Iterator iterator = members.iterator(); iterator.hasNext();) { GroupMember member = (GroupMember)iterator.next(); member.fill(containerPopulator, controlFactory, configurer, previousButtons); } if (members.size() > 0 && isEndingSeparator()) { containerPopulator.addSeparator(); } }
Adds each member of this expansion point to a GUI container using the given container populator. Leading and trailing separators will also be added as determined by the appropriate flags set on this instance. {@inheritDoc}
public GroupMember getMemberFor(String commandId) { for (Iterator it = members.iterator(); it.hasNext();) { GroupMember member = (GroupMember)it.next(); if (member.managesCommand(commandId)) { return member; } } return null; }
Returns the group member that manages the command with the given id, or null if none of the members in this expansion point manage a command with that id. @param commandId The id of the command whose managing member is to be returned. @return The group member that manages the command with the given id, or null.
public boolean managesCommand(String commandId) { for (Iterator iterator = members.iterator(); iterator.hasNext();) { GroupMember member = (GroupMember)iterator.next(); if (member.managesCommand(commandId)) return true; } return false; }
{@inheritDoc}
protected ConversionExecutor getPropertyConversionExecutor() { if (conversionExecutor == null) { conversionExecutor = getConversionService().getConversionExecutor(Object[].class, getPropertyType()); } return conversionExecutor; }
Returns a conversion executor which converts a value of the given sourceType into the fieldType @return true if a converter is available, otherwise false @see #getPropertyType()
protected void updateSelectedItemsFromValueModel() { Object value = getValue(); Object[] selectedValues = EMPTY_VALUES; if (value != null) { selectedValues = (Object[]) convertValue(value, Object[].class); } // flag is used to avoid a round trip while we are selecting the values selectingValues = true; try { ListSelectionModel selectionModel = getList().getSelectionModel(); selectionModel.setValueIsAdjusting(true); try { int[] valueIndexes = determineValueIndexes(selectedValues); int selectionMode = getSelectionMode(); if (selectionMode == ListSelectionModel.SINGLE_SELECTION && valueIndexes.length > 1) { getList().setSelectedIndex(valueIndexes[0]); } else { getList().setSelectedIndices(valueIndexes); } // update value model if selectedValues contain elements which where not found in the list model // elements if (valueIndexes.length != selectedValues.length && !isReadOnly() && isEnabled() || (selectionMode == ListSelectionModel.SINGLE_SELECTION && valueIndexes.length > 1)) { updateSelectedItemsFromSelectionModel(); } } finally { selectionModel.setValueIsAdjusting(false); } } finally { selectingValues = false; } }
Updates the selection model with the selected values from the value model.
public Object getValue(Object fromEntity) throws IllegalAccessException, InvocationTargetException { Object propertyValue = getter.invoke(fromEntity); return propertyValue == null ? null : getWrappedAccessor(propertyValue.getClass()).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.
private Accessor getWrappedAccessor(Class<?> propertyType) { if (wrappedAccessor == null) { try { wrappedAccessor = ClassUtils.getAccessorForProperty(getter.getReturnType(), nestedProperty); } catch (NoSuchMethodError nsme) { if (propertyType == null) throw nsme; wrappedAccessor = ClassUtils.getAccessorForProperty(propertyType, nestedProperty); } } return wrappedAccessor; }
<p> Get the wrapped accessor, instantiate it lazily if needed. </p> <p> Normally the return type of the getter method delivers the correct type on which the nested property can be found. There is however a specific case in which this isn't true. It may be that a specific type is only known at runtime and that you need to access a property of that specific type. The specific type can be found at runtime when the wrapped accessor is constructed. But it does imply that all other access will result in the same type. </p> <p> A specific type implementation is found in PeriodicValueAdapter->BTWPercentage, here a property of BTWPercentage can be accessed through the adapter, but all other adapters should contain a BTWPercentage. </p> @param propertyType property type to use if getter doesn't yield the correct one. @return an {@link Accessor} for the wrapped property.
public final void setSelected(boolean selected) { if (isExclusiveGroupMember()) { boolean oldState = isSelected(); exclusiveController.handleSelectionRequest(this, selected); // set back button state if controller didn't change this command; // needed b/c of natural button check box toggling in swing if (oldState == isSelected()) { Iterator iter = buttonIterator(); while (iter.hasNext()) { AbstractButton button = (AbstractButton)iter.next(); button.setSelected(isSelected()); } } } else { requestSetSelection(selected); } }
Set the selection state of the command.
protected boolean requestSetSelection(boolean selected) { boolean previousState = isSelected(); if (previousState != selected) { this.selected = onSelection(selected); if (logger.isDebugEnabled()) { logger.debug("Toggle command selection returned '" + this.selected + "'"); } } // we must always update toggle buttons Iterator it = buttonIterator(); if (logger.isDebugEnabled()) { logger.debug("Updating all attached toggle buttons to '" + isSelected() + "'"); } while (it.hasNext()) { AbstractButton button = (AbstractButton)it.next(); button.setSelected(isSelected()); } if (previousState != isSelected()) { if (logger.isDebugEnabled()) { logger.debug("Selection changed; firing property change event"); } firePropertyChange(SELECTED_PROPERTY, previousState, isSelected()); } return isSelected(); }
Handles the switching of the selected state. All attached buttons are updated. @param selected select state to set. @return the select state afterwards.
protected String[] getExtraTextKeys(String propertyName) { return new String[] { getFormModel().getId() + "." + propertyName + "." + textKey, propertyName + "." + textKey, textKey }; }
Returns the keys used to fetch the extra text from the <code>MessageSource</code>. <p> The keys returned are <code>&lt;formModelId&gt;.&lt;propertyName&gt;.&lt;textKey&gt;, &lt;propertyName&gt;.&lt;textKey&gt;, &lt;textKey&gt;</code> <p> Can safely be overridden to add extra keys @param propertyName the property name @return the keys
protected void addPage(String wizardConfigurationKey, WizardPage page) { pages.add(page); page.setWizard(this); if (autoConfigureChildPages) { String key = ((wizardConfigurationKey != null) ? wizardConfigurationKey + "." : "") + page.getId(); ValkyrieRepository.getInstance().getApplicationConfig().applicationObjectConfigurer().configure(page, key); } }
Adds a new page to this wizard. The page is inserted at the end of the page list. @param wizardConfigurationKey the parent configuration key of the page, used for configuration, by default this wizard's id * @param page the new page
public WizardPage addForm(Form formPage) { Assert.notNull(formPage, "The form page cannot be null"); WizardPage page = new FormBackedWizardPage(formPage, !autoConfigureChildPages); addPage(page); return page; }
Adds a new page to this wizard. The page is created by wrapping the form in a {@link FormBackedWizardPage} and appending it to the end of the page list. @param formPage The form page to be added to the wizard. @return the newly created wizard page that wraps the given form. @throws IllegalArgumentException if {@code formPage} is null.
public boolean canFinish() { // Default implementation is to check if all pages are complete. for (int i = 0; i < pages.size(); i++) { if (!((WizardPage)pages.get(i)).isPageComplete()) return false; } return true; }
Returns true if all the pages of this wizard have been completed.
public WizardPage getNextPage(WizardPage page) { int index = pages.indexOf(page); if (index == pages.size() - 1 || index == -1) { // last page or page not found return null; } return (WizardPage)pages.get(index + 1); }
{@inheritDoc}
public WizardPage getPage(String pageId) { Iterator it = pages.iterator(); while (it.hasNext()) { WizardPage page = (WizardPage)it.next(); if (page.getId().equals(pageId)) { return page; } } return null; }
{@inheritDoc}
public WizardPage getPreviousPage(WizardPage page) { int index = pages.indexOf(page); if (index == 0 || index == -1) { // first page or page not found return null; } logger.debug("Returning previous page..."); return (WizardPage)pages.get(index - 1); }
{@inheritDoc}
protected final Binding doBind(JComponent control, FormModel formModel, String formPropertyPath, Map context) { AbstractListBinding binding = createListBinding(control, formModel, formPropertyPath); Assert.notNull(binding); applyContext(binding, context); return binding; }
Creates the binding and applies any context values
protected void applyContext(AbstractListBinding binding, Map context) { if (context.containsKey(SELECTABLE_ITEMS_KEY)) { binding.setSelectableItems(decorate(context.get(SELECTABLE_ITEMS_KEY), selectableItems)); } else if (selectableItems != null) { binding.setSelectableItems(selectableItems); } if (context.containsKey(COMPARATOR_KEY)) { binding.setComparator((Comparator) decorate(context.get(COMPARATOR_KEY), comparator)); } else if (comparator != null) { binding.setComparator(comparator); } if (context.containsKey(FILTER_KEY)) { binding.setFilter((Constraint) decorate(context.get(FILTER_KEY), filter)); } else if (filter != null) { binding.setFilter(filter); } }
Applies any context or preset value. @param binding the binding to apply the values @param context contains context dependent values
protected Object decorate(Object closure, Object object) { if (closure instanceof Closure) { return ((Closure) closure).call(object); } return closure; }
Decorates an object instance if the <code>closure</code> value is an instance of {@link Closure}. @param closure the closure which is used to decorate the object. @param object the value to decorate @return the decorated instance if <code>closure</code> implements {@link Closure}, otherwise the value of <code>object</code>
protected JComponent createControl() { // In this view, we're just going to use standard Swing to place a // few controls. // The location of the text to display has been set as a Resource in the // property descriptionTextPath. So, use that resource to obtain a URL // and set that as the page for the text pane. JTextPane textPane = new JTextPane(); JScrollPane spDescription = getApplicationConfig().componentFactory().createScrollPane(textPane); try { textPane.setPage(getDescriptionTextPath().getURL()); } catch (IOException e) { throw new RuntimeException("Unable to load description URL", e); } JLabel lblMessage = getApplicationConfig().componentFactory().createLabel(getFirstMessage()); lblMessage.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); JPanel panel = getApplicationConfig().componentFactory().createPanel(new BorderLayout()); panel.add(spDescription); panel.add(lblMessage, BorderLayout.SOUTH); return panel; }
Create the actual UI control for this view. It will be placed into the window according to the layout of the page holding this view.
public void setUserMetadata(final String key, final Object value) { final Object old = userMetadata.put(key, value); firePropertyChange(key, old, value); }
Sets custom metadata to be associated with this property. A property change event will be fired (from this FieldMetadata, not from the associated form property) if <code>value</code> differs from the current value of the specified <code>key</code>. The property change event will use the value of <code>key</code> as the property name in the property change event. @param key @param value
public void clearUserMetadata() { // Copy keys into array to avoid concurrent modification exceptions // if any PropertyChangeListeners should modify user metadata during // clear operation. final Object[] keys = userMetadata.keySet().toArray(); for(int i = keys.length - 1;i >= 0;i--) { final Object old = userMetadata.remove(keys[i]); if(old != null) { firePropertyChange((String)keys[i], old, null); } } }
Clears all custom metadata associated with this property. A property change event will be fired for every <code>key</code> that contained a non-null value before this method was invoked. It is possible for a PropertyChangeListener to mutate user metadata, by setting a key value for example, in response to one of these property change events fired during the course of the clear operation. Because of this, there is no guarantee that all user metadata is in fact completely clear and empty by the time this method returns.
public static void registerExceptionHandler(RegisterableExceptionHandler exceptionHandlerDelegate) { AwtExceptionHandlerAdapterHack.exceptionHandlerDelegate = exceptionHandlerDelegate; // Registers this class with the system properties so Sun's JDK can pick it up. Always sets even if previously set. System.getProperties().put(SUN_AWT_EXCEPTION_HANDLER_KEY, AwtExceptionHandlerAdapterHack.class.getName()); }
Sets the {@link #SUN_AWT_EXCEPTION_HANDLER_KEY} system property to register this class as the event thread's exception handler. When called back, this class simply forwards to the delegate. @param exceptionHandlerDelegate the "real" exception handler to delegate to when an uncaught exception occurs.
public void notifyUserAboutException(Thread thread, final Throwable throwable) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { final ErrorInfo errorInfo = new ErrorInfo( resolveExceptionCaption(throwable), (String) createExceptionContent(throwable), getDetailsAsHTML(throwable.getMessage(), throwable), null, throwable, Level.SEVERE, null); JXErrorPane pane = new JXErrorPane(); pane.setErrorInfo(errorInfo); if (errorReporter != null) { pane.setErrorReporter(errorReporter); } JXErrorPane.showDialog(resolveParentFrame(), pane); } }); }
Shows the {@link org.jdesktop.swingx.JXErrorPane} to the user.
private static String escapeXml(String input) { return input == null ? "" : input.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;"); }
Converts the incoming string to an escaped output string. This method is far from perfect, only escaping &lt;, &gt; and &amp; characters
protected JFrame getParentWindowControl() { // allow subclasses to derive where the application window comes from final ApplicationWindow applicationWindow = getApplicationWindow(); if (applicationWindow == null) { return ValkyrieRepository.getInstance().getApplicationConfig().windowManager().getActiveWindow().getControl(); } return applicationWindow.getControl(); }
Returns the {@link javax.swing.JFrame} of the application window that this command belongs to. @return The control component of the application window, never null.
public int compareTo(Object o) { ViewDescriptor castObj = (ViewDescriptor)o; return this.getDisplayName().compareToIgnoreCase(castObj.getDisplayName()); }
Compares the display names of the view descriptors
public void splash() { frame = shadowBorder ? new ShadowBorderFrame() : new JFrame(); if (isRootFrame()) JOptionPane.setRootFrame(frame); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.setUndecorated(true); frame.setTitle(loadFrameTitle()); frame.setIconImage(loadFrameIcon()); Component content = createContentPane(); if (content != null) { frame.getContentPane().add(content); } frame.pack(); WindowUtils.centerOnScreen(frame); frame.setVisible(true); }
Creates and displays an undecorated, centered splash screen containing the component provided by {@link #createContentPane()}. If this instance has been provided with a {@link MessageSource}, it will be used to retrieve the splash screen's frame title under the key {@value #SPLASH_TITLE_KEY}.
private String loadFrameTitle() { try { return messageSource == null ? null : messageSource.getMessage( SPLASH_TITLE_KEY, null, null); } catch (NoSuchMessageException e) { return null; } }
Loads the message under the key {@value #SPLASH_TITLE_KEY} if a {@link MessageSource} has been set on this instance. @return The message resource stored under the key {@value #SPLASH_TITLE_KEY}, or null if no message source has been set.
public static void runInEventDispatcherThread(Runnable runnable, Boolean wait) { Assert.notNull(runnable, "runnable"); Assert.notNull(wait, "wait"); if (EventQueue.isDispatchThread()) { runnable.run(); } else if (wait) { try { EventQueue.invokeAndWait(runnable); } catch (InterruptedException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } } else { EventQueue.invokeLater(runnable); } }
Ensures the given runnable is executed into the event dispatcher thread. @param runnable the runnable. @param wait whether should wait until execution is completed.
public static Component getDescendantNamed(String name, Component parent) { Assert.notNull(name, "name"); Assert.notNull(parent, "parent"); if (name.equals(parent.getName())) { // Base case return parent; } else if (parent instanceof Container) { // Recursive case for (final Component component : ((Container) parent).getComponents()) { final Component foundComponent = SwingUtils.getDescendantNamed(name, component); if (foundComponent != null) { return foundComponent; } } } return null; }
Does a pre-order search of a component with a given name. @param name the name. @param parent the root component in hierarchy. @return the found component (may be null).
public static JComponent generateComponent(Image image) { if (image == null) { return new LabelUIResource("Image is null"); } return SwingUtils.generateComponent(new ImageIcon(image)); }
Generates a component to view an image. @param image the image. @return the component.
@Override public JTabbedPane createTabbedPane() { final JideTabbedPane tabbedPane = new JideTabbedPane(); tabbedPane.setShowTabButtons(Boolean.TRUE); tabbedPane.setHideOneTab(Boolean.FALSE); tabbedPane.setShowTabArea(Boolean.TRUE); tabbedPane.setShowTabContent(Boolean.TRUE); tabbedPane.setUseDefaultShowIconsOnTab(Boolean.FALSE); tabbedPane.setShowIconsOnTab(Boolean.TRUE); tabbedPane.setBoldActiveTab(Boolean.TRUE); tabbedPane.setScrollSelectedTabOnWheel(Boolean.TRUE); tabbedPane.setShowCloseButton(Boolean.FALSE); tabbedPane.setUseDefaultShowCloseButtonOnTab(Boolean.FALSE); tabbedPane.setShowCloseButtonOnTab(Boolean.TRUE); tabbedPane.setTabEditingAllowed(Boolean.FALSE); // Install tab trailing component final Image image = imageSource.getImage(JideOssComponentFactory.JIDE_TABBED_PANE_TAB_TRAILING_IMAGE); tabbedPane.setTabTrailingComponent(SwingUtils.generateComponent(image)); return tabbedPane; }
{@inheritDoc}
@Override protected void valueModelChanged(Object newValue) { if (newValue == null) setKeyComponentText(null); else setKeyComponentText(getObjectLabel(newValue)); readOnlyChanged(); }
{@inheritDoc} <p/> Sets the textComponent to reflect the label of the object
protected TabKeyListener createKeyListener() { return new TabKeyListener() { @Override public void onTabKey(Component component) { String textFieldValue = getKeyComponentText(); boolean empty = "".equals(textFieldValue.trim()); Object ref = LookupBinding.this.getValue(); // if something was filled in and it doesn't match the internal value if (!empty && ((ref == null) || !textFieldValue.equals(getObjectLabel(ref)))) { // call the dataEditor to fire the search Object result = initializeDataEditor(); //no match if (result == null || ((result instanceof java.util.List) && (((java.util.List<?>) result).size() == 0))) { if (!revertValueOnFocusLost()) getValueModel().setValue(createFilterFromString(textFieldValue)); if ((getAutoPopupDialog() & AUTOPOPUPDIALOG_NO_MATCH) == AUTOPOPUPDIALOG_NO_MATCH) getDataEditorCommand().execute(parameters); } // multiple matches else if ((result instanceof java.util.List) && (((java.util.List<?>) result).size() > 1)) { if (!revertValueOnFocusLost()) getValueModel().setValue(createFilterFromString(textFieldValue)); if ((getAutoPopupDialog() & AUTOPOPUPDIALOG_MULTIPLE_MATCH) == AUTOPOPUPDIALOG_MULTIPLE_MATCH) getDataEditorCommand().execute(parameters); } // exact match else { // in dit geval krijg je een object uit de lijst terug, dit is niet gedetaileerd, // daarom moet het eventueel gedetaileerd geladen worden. setValue(result, true); if ((getAutoPopupDialog() & AUTOPOPUPDIALOG_UNIQUE_MATCH) == AUTOPOPUPDIALOG_UNIQUE_MATCH) getDataEditorCommand().execute(parameters); } } // nothing filled in, underlying value isn't empty and we should not revert, set null else if (!revertValueOnFocusLost() && empty && ref != null) { getValueModel().setValue(null); } getDataEditorButton().transferFocus(); } }; }
Create a keyListener that reacts on tabs. Pop-up the dialog as defined in the {@link #getAutoPopupDialog()} mask.
protected FocusListener createFocusListener() { return new FocusAdapter() { @Override public void focusLost(FocusEvent e) { String textFieldValue = getKeyComponentText(); boolean empty = "".equals(textFieldValue.trim()); Object ref = LookupBinding.this.getValue(); if (evaluateFocusLost(e)) { // Revert if value isn't empty if (revertValueOnFocusLost()) { if (empty) getValueModel().setValue(null); else valueModelChanged(LookupBinding.super.getValue()); } // Create new referable if value isn't empty else { if (empty && (ref != null)) getValueModel().setValue(null); else if (!empty && ((ref == null) || !textFieldValue.equals(getObjectLabel(ref)))) getValueModel().setValue(createFilterFromString(textFieldValue)); } } } }; }
Create a focus listener to attach to the textComponent and dataEditorButton that will decide what happens with the changed value. Here a revert can be done if no value is selected or a new value can be created as needed. @return a focus listener.
protected Object initializeDataEditor() { final String textFieldValue = getKeyComponentText(); Object ref = super.getValue(); if ((ref != null) && textFieldValue.equals(getObjectLabel(ref))) return getDataEditor().setSelectedSearch(ref); return getDataEditor().setSelectedSearch(createFilterFromString(textFieldValue)); }
Initialize the dataEditor by passing the search referable as search parameter. @return a single object if the search has an unique match, a list if multiple matches occurred or <code>null</code> if nothing was found.
protected AbstractButton getDataEditorButton() { if (dataEditorButton == null) { dataEditorButton = getDataEditorCommand().createButton(); dataEditorButton.setFocusable(false); //dataEditorButton.addFocusListener(createFocusListener()); } return dataEditorButton; }
Get/create the button to open the dataEditor in selection mode
protected ActionCommand createDataEditorCommand() { ActionCommand selectDialogCommand = new ActionCommand(getSelectDialogCommandId()) { private ApplicationDialog dataEditorDialog; @Override protected void doExecuteCommand() { if (LookupBinding.this.propertyChangeMonitor.proceedOnChange()) { if (dataEditorDialog == null) { dataEditorDialog = new TitledWidgetApplicationDialog(getDataEditor(), TitledWidgetApplicationDialog.SELECT_CANCEL_MODE) { protected boolean onFinish() { if (getDataEditor().canClose()) return LookupBinding.this.onFinish(); return false; } @Override protected boolean onSelectNone() { getDataEditor().getTableWidget().unSelectAll(); return super.onSelectNone(); } @Override protected void onCancel() { if (getDataEditor().canClose()) super.onCancel(); } }; dataEditorDialog.setParentComponent(getDataEditorButton()); getDataEditor().setSelectMode(AbstractDataEditorWidget.ON); getApplicationConfig().applicationObjectConfigurer().configure(dataEditorDialog, getSelectDialogId()); } if (getParameter(NO_INITIALIZE_DATA_EDITOR) != ON) initializeDataEditor(); if (getDialogSize() != null) { dataEditorDialog.getDialog().setMinimumSize(getDialogSize()); } dataEditorDialog.showDialog(); } } }; getApplicationConfig().commandConfigurer().configure(selectDialogCommand); return selectDialogCommand; }
Create the dataEditorCommand.
protected String getMessage(String contextId, String fieldPath, String[] faceDescriptorProperty) { String[] keys = getMessageKeys(contextId, fieldPath, faceDescriptorProperty); return getMessageSourceAccessor().getMessage(new DefaultMessageSourceResolvable(keys, null, keys[0])); }
Returns the value of the required property of the FieldFace. Delegates to the getMessageKeys for the message key generation strategy. This method uses </code>[contextId + "." + ] fieldPath [ + "." + faceDescriptorProperty[0]]</code> for the default value
protected String getMessage(String contextId, String fieldPath, String[] faceDescriptorProperties, String defaultValue) { String[] keys = getMessageKeys(contextId, fieldPath, faceDescriptorProperties); try { return getMessageSourceAccessor().getMessage(new DefaultMessageSourceResolvable(keys, null, defaultValue)); } catch (NoSuchMessageException e) { if (log.isDebugEnabled()) { log.debug(e.getMessage()); } return null; } }
Returns the value of the required property of the FieldFace. Delegates to the getMessageKeys for the message key generation strategy.
protected String[] getMessageKeys(String contextId, String fieldPath, String[] faceDescriptorProperties) { return getMessageKeyStrategy().getMessageCodes(contextId, fieldPath, faceDescriptorProperties); }
Returns an array of message keys that are used to resolve the required property of the FieldFace. The property will be resolved from the message source using the returned message keys in order. <p> Subclasses my override this method to provide an alternative to the default message key generation strategy.
public void postProcessBeanFactory(final ConfigurableListableBeanFactory beanFactory) throws BeansException { if (beanFactory == null) { return; } String[] beanNames = beanFactory.getBeanDefinitionNames(); int singletonBeanCount = 0; for (int i = 0; i < beanNames.length; i++) { // using beanDefinition to check singleton property because when // accessing through // context (applicationContext.isSingleton(beanName)), bean will be // created already, // possibly bypassing other BeanFactoryPostProcessors BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanNames[i]); if (beanDefinition.isSingleton()) { singletonBeanCount++; } } this.progressMonitor.taskStarted(this.loadingAppContextMessage, singletonBeanCount); beanFactory.addBeanPostProcessor(new ProgressMonitoringBeanPostProcessor(beanFactory)); }
Notifies this instance's associated progress monitor of progress made while processing the given bean factory. @param beanFactory the bean factory that is to be processed.
public void setSearchString(String queryString) { this.searchString = queryString; if (this.textFilterField != null) { this.textFilterField.setText(this.searchString); } }
Set the local text filter field value @param queryString filterText.
protected ActionCommand createUpdateCommand() { ActionCommand command = new ActionCommand(UPDATE_COMMAND_ID) { @Override protected void doExecuteCommand() { doUpdate(); } }; command.setSecurityControllerId(getId() + "." + UPDATE_COMMAND_ID); getApplicationConfig().commandConfigurer().configure(command); getDetailForm().addGuarded(command, FormGuard.LIKE_COMMITCOMMAND); return command; }
Creates the save command. @see #doUpdate()
protected void doUpdate() { getDetailForm().commit(); Object savedObject = null; try { savedObject = saveEntity(getDetailForm().getFormObject()); setDetailFormObject(savedObject, tableSelectionObserver, false); } catch (RuntimeException e) { Object changedObject = getDetailForm().getFormObject(); // the following actually requests the object from the back-end boolean success = setDetailFormObject(changedObject, tableSelectionObserver, true); // set the changes back on the model if the object could be set on the form model if (success) ObjectUtils.mapObjectOnFormModel(getDetailForm().getFormModel(), changedObject); throw e; } }
Save the changes made in the detailForm according to following steps: <p/> <ol> <li>commit form</li> <li>formObject sent to back-end</li> <li>changes are handled in back-end</li> <li>changed object is returned to client</li> <li>old object is replaced by changed object</li> </ol>
protected ActionCommand createCreateCommand() { ActionCommand command = new ActionCommand(CREATE_COMMAND_ID) { @Override protected void doExecuteCommand() { doCreate(); } }; command.setSecurityControllerId(getId() + "." + CREATE_COMMAND_ID); getApplicationConfig().commandConfigurer().configure(command); getDetailForm().addGuarded(command, FormGuard.LIKE_COMMITCOMMAND); return command; }
Creates the create command. @see #doCreate()
protected void doCreate() { getDetailForm().commit(); Object newObject = null; try { newObject = createNewEntity(getDetailForm().getFormObject()); // select row only if user hasn't made another selection in // table and this commit is triggered by the save-changes // dialog and if not in quick add mode if (newObject != null && !getTableWidget().hasSelection()) { if (getTableWidget().selectRowObject(newObject, null) == -1) { // select row wasn't succesfull, maybe search string // was filled in? setSearchString(null); getTableWidget().selectRowObject(newObject, null); } } } catch (RuntimeException e) { Object changedFormObject = getDetailForm().getFormObject(); newRow(null); ObjectUtils.mapObjectOnFormModel(getDetailForm().getFormModel(), changedFormObject); throw e; // make form dirty, show error in messagepane and throw exception to display error dialog } }
Creates a new data object according to following steps: <p/> <ol> <li>form commit</li> <li>formObject sent to back-end</li> <li>back-end creates item</li> <li>back-end returns new item to client</li> <li>new item is selected in dataEditor if possible</li> </ol>
protected CommandGroup getTablePopupMenuCommandGroup() { return getApplicationConfig().commandManager().createCommandGroup(Lists.newArrayList(getEditRowCommand(), "separator", getAddRowCommand(), getCloneRowCommand(), getRemoveRowsCommand(), "separator", getRefreshCommand(), "separator", getCopySelectedRowsToClipboardCommand())); }
Returns the commandGroup that should be used to create the popup menu for the table.
public Throwable findChainPartThrowable(ChainPart chainPart, Throwable firstThrowable) { Throwable e = firstThrowable; int relativeDepth = 0; int minimumRelativeDepth = chainPart.getMinimumRelativeDepth(); int maximumRelativeDepth = chainPart.getMaximumRelativeDepth(); while (!chainPart.getThrowableClass().isInstance(e) || (relativeDepth < minimumRelativeDepth)) { relativeDepth++; Throwable cause = e.getCause(); if (cause == null || cause == e) { return null; // Chain is to short to find the chainPart } else { e = cause; } if ((maximumRelativeDepth >= 0) && (relativeDepth > maximumRelativeDepth)) { return null; // We did not find the chainPart early enough } } return e; }
}
public void dispose(){ Collection pageComponents = new ArrayList(pageComponentMap.values()); Iterator it = pageComponents.iterator(); while(it.hasNext()){ PageComponent pageComponent = (PageComponent)it.next(); remove(pageComponent); } contentPane.dispose(); contentPane = null; super.dispose(); }
Overridden close method to avoid memory leaks by Mikael Valot
public void fireFocusGainedOnActiveComponent(){ String documentName = contentPane.getActiveDocumentName(); if(documentName != null){ PageComponent component = (PageComponent)pageComponentMap.get(documentName); JideApplicationPage page = (JideApplicationPage)getActiveWindow().getPage(); page.fireFocusGained(component); } }
This is a bit of a hack to get over a limitation in the JIDE docking framework. When focus is regained to the workspace by activation the currently activated document the documentComponentActivated is not fired. This needs to be fired when we know the workspace has become active. For some reason it dosen't work when using the componentFocusGained method
public void addDocumentComponent(final PageComponent pageComponent, boolean activateAfterOpen){ String id = pageComponent.getId(); if(!closeAndReopenEditor && contentPane.getDocument(id) != null){ contentPane.setActiveDocument(id); } else{ if(contentPane.getDocument(id) != null){ contentPane.closeDocument(id); } DocumentComponent document = constructDocumentComponent(pageComponent); DocumentComponentListener lifecycleListener = constructLifecycleListener(pageComponent); document.addDocumentComponentListener(lifecycleListener); if(contentPane.getDocument(id) == null){ contentPane.openDocument(document); } if(activateAfterOpen){ contentPane.setActiveDocument(id); } registerDropTargetListeners(pageComponent.getControl()); // This listener ensures that the focus is transfered to the workspace // itself if the number of documents becomes zero. document.addDocumentComponentListener(new DocumentComponentAdapter(){ public void documentComponentClosed(DocumentComponentEvent event) { int count = contentPane.getDocumentCount(); if(count == 0){ fireFocusGainedOnWorkspace(); } } }); pageComponentMap.put(id, pageComponent); } }
Adds a document to the editor workspace. The behaviour when an editor is already open, with editor identity defined by id property, is determined by the closeAndReopenEditor property. If this property is true, the default, the editor is closed and reopened. If false, the existing editor becomes the active one. @param pageComponent The page component to be added as a document @param activateAfterOpen specifies if the component should be activated after opening
private DocumentComponent constructDocumentComponent(final PageComponent pageComponent) { String id = pageComponent.getId(); String title = pageComponent.getDisplayName(); Icon icon = pageComponent.getIcon(); DocumentComponent document = new DocumentComponent( pageComponent.getContext().getPane().getControl(), id, title, icon); document.setTooltip(pageComponent.getDescription()); return document; }
/* Actually constructs a Jide document component from the page component
public void propertyChange( PropertyChangeEvent evt ) { int[] selected = (int[]) selectionHolder.getValue(); guarded.setEnabled(shouldEnable(selected)); }
Handle a change in the selectionHolder value.
public JMenuBar getViewMenuBar(){ CommandGroup commandGroup = getCommandGroup(getMenuBarCommandGroupName()); if(commandGroup == null){ return null; } return commandGroup.createMenuBar(); }
Returns the view specific menu bar constructed from the command group given by the menuBarCommandGroupName or its default @return
public JComponent getViewToolBar(){ CommandGroup commandGroup = getCommandGroup(getToolBarCommandGroupName()); if(commandGroup == null){ return null; } return commandGroup.createToolBar(); }
Returns the view specific menu bar constructed from the command group given by the toolBarCommandGroupName or its default @return
public void activateView(){ if(SwingUtilities.isEventDispatchThread()){ ValkyrieRepository.getInstance().getApplicationConfig().windowManager().getActiveWindow().getPage().showView(getId()); } else{ SwingUtilities.invokeLater(new Runnable(){ public void run() { ValkyrieRepository.getInstance().getApplicationConfig().windowManager().getActiveWindow().getPage().showView(getId()); } }); } }
Activates this view taking care of EDT issues
private void loadIfNecessary() { if (loadedMember != null) { return; } CommandRegistry commandRegistry = parentGroup.getCommandRegistry(); Assert.isTrue(parentGroup.getCommandRegistry() != null, "Command registry must be set for group '" + parentGroup.getId() + "' in order to load lazy command '" + lazyCommandId + "'."); if (commandRegistry.containsCommandGroup(lazyCommandId)) { CommandGroup group = commandRegistry.getCommandGroup(lazyCommandId); loadedMember = new SimpleGroupMember(parentGroup, group); } else if (commandRegistry.containsActionCommand(lazyCommandId)) { ActionCommand command = commandRegistry.getActionCommand(lazyCommandId); loadedMember = new SimpleGroupMember(parentGroup, command); } else { if (logger.isWarnEnabled()) { logger.warn("Lazy command '" + lazyCommandId + "' was asked to display; however, no backing command instance exists in registry."); } } if (addedLazily && loadedMember != null) { loadedMember.onAdded(); } }
Attempts to load the lazy command from the command registry of the parent command group, but only if it hasn't already been loaded.
protected String getMessage(String key, Object[] params){ MessageSource messageSource = ValkyrieRepository.getInstance().getApplicationConfig().messageSource(); return messageSource.getMessage(key, params, Locale.getDefault()); }
Method to obtain a message from the message source defined via the services locator, at the default locale.
public void dispose(){ if(logger.isDebugEnabled()){ logger.debug("Disposing of editor "+getId()); } context.register(GlobalCommandIds.SAVE, null); context.register(GlobalCommandIds.SAVE_AS, null); //descriptor.removePropertyChangeListener((PropertyChangeListener)context.getPane()); concreteDispose(); }
This method is called when an editor is removed from the workspace.
private void registerCommandExecutors(PageComponentContext context){ context.register(GlobalCommandIds.SAVE, new SaveCommandExecutor()); context.register(GlobalCommandIds.SAVE_AS, new SaveAsCommandExecutor()); }
/* Registers some editor specific command executors for save and save as that just call the relevant methods within the editor.
public JComponent getEditorMenuBar(){ CommandGroup commandGroup = getCommandGroup(getMenuBarCommandGroupName()); if(commandGroup == null){ return null; } return commandGroup.createMenuBar(); }
Returns the view specific menu bar constructed from the command group given by the menuBarCommandGroupName or its default @return
public JComponent getEditorToolBar(){ CommandGroup commandGroup = getCommandGroup(getToolBarCommandGroupName()); if(commandGroup == null){ return null; } return commandGroup.createToolBar(); }
Returns the view specific menu bar constructed from the command group given by the toolBarCommandGroupName or its default @return
public void setCaption(String shortDescription) { String old = this.caption; this.caption = shortDescription; firePropertyChange(DescribedElement.CAPTION_PROPERTY, old, this.caption); }
{@inheritDoc}
public void setDescription(String longDescription) { String old = this.description; this.description = longDescription; firePropertyChange(DescribedElement.DESCRIPTION_PROPERTY, old, this.description); }
{@inheritDoc}
public void setBackground(Color background) { Color old = this.background; this.background = background; firePropertyChange(BACKGROUND_PROPERTY, old, this.background); }
{@inheritDoc}
public void setForeground(Color foreground) { Color old = this.foreground; this.foreground = foreground; firePropertyChange(FOREGROUND_PROPERTY, old, this.foreground); }
{@inheritDoc}