org.openpermis.editor.policy.view
Class PolicyView

java.lang.Object
  extended by org.openpermis.editor.policy.view.AbstractView
      extended by org.openpermis.editor.policy.view.ContextView
          extended by org.openpermis.editor.policy.view.PolicyView
All Implemented Interfaces:
ErrorReporter, DockControlListener, EventListener, PolicyLoader, PolicySaver, View, ViewContext

public class PolicyView
extends ContextView
implements PolicyLoader, PolicySaver

View for a complete PolicyBean.

The PolicyView describes the toplevel view including menubar and toolbar for a complete policy editor. This view will serve as a view manager for all other views used to edit the policy attached to the PolicyView.

Since:
0.1.0

Field Summary
private  PropertyChangeDispatcher commandManagerDispatcher
          Dispatcher for undo/redo events.
private  org.picocontainer.PicoContainer container
          The dependency injection container of this view.
private  ErrorStatusUpdater errorStatusUpdater
          Updater that syncs the status bar with error messages.
private  org.picocontainer.MutablePicoContainer factory
          The dependency injection container of this view.
private  org.jdesktop.swingx.JXFrame frame
          The frame used by this policy view to display its contents.
private static org.slf4j.Logger LOGGER
          The logger object of this class.
private  JMenuBar menuBar
          The menu bar of this policy view, lazily intialized.
private  PolicyPresenter presenter
          The active policy presenter of this view.
private static int STATUS_PROGRESS_BAR_WIDTH
          Width of the progress bar in the status bar in pixels.
private  org.jdesktop.swingx.JXStatusBar statusBar
          The status bar of this policy view, lazily intialized.
private  JToolBar toolBar
          The tool bar of this policy view, lazily intialized.
private static String TOOLS_MENU
          Virtual value for the tools menu entries.
private static String VIEW_MENUBAR
          Resource key for the view menubar.
private static String VIEW_TOOLBAR
          Resource key for the view toolbar.
 
Constructor Summary
PolicyView(Application application, org.jdesktop.swingx.JXFrame frame, PolicyIconRegistry iconRegistry, AdapterTrader trader)
          Creates a policy view for the specified application context.
 
Method Summary
 void actionsFromWsdlImport()
          Import the actions from a wsdl file.
 boolean canClose()
          Prompts the view to save unsaved changes before closing.
private  boolean canCreateTypedComponent(String type)
          Check if the factory can create the typed component specified.
 boolean canEditPart(org.openpermis.policy.bean.PartBean part)
          Tests if the part specified can be edited.
 org.jdesktop.application.FrameView configure(org.jdesktop.application.FrameView frameView)
          Configures the specified frame view for displaying this view.
private  void configureToolsMenu(JMenuBar toolsMenuBar)
          Configures the tools menu of the specified menu bar.
private  org.picocontainer.MutablePicoContainer createContainer(org.picocontainer.PicoContainer parent, Application application, PolicyIconRegistry iconRegistry, AdapterTrader trader)
          Creates and configures a pico container for this view.
private
<M> M
createTypedComponent(String type, Object parameter)
          Factory method to create a typed component of the specified type.
private  void doSavePolicy(boolean withCurrentFilename)
          Saves the current policy to a file.
private  String editorType(Class<? extends org.openpermis.policy.bean.PartBean> type)
          Returns a unique string identifier for an editor that renders the specified part bean type.
 Editor editPart(org.openpermis.policy.bean.PartBean part)
          Opens an editor for the specified part.
 void editRedo()
          Redo one action.
 void editUndo()
          Undo one action.
 void fileClose()
          Closes the currently edited policy.
 void fileNew()
          Creates a new policy.
 void fileOpen()
          Opens an existing policy.
 void fileQuit()
          Quits the policy editor.
 void fileRoleAssignment()
          Creates an attribute certificate assigning roles to a subject.
 void fileSave()
          Saves the policy editor.
 void fileSaveAs()
          Saves the policy editor.
 void fileSignedExport()
          Signs a policy.
 void fileSignedImport()
          Imports a signed policy.
 void fileValidate()
          Validates a policy.
private  JMenuBar getMenuBar()
          Returns the menu bar for this policy view.
private  org.jdesktop.swingx.JXStatusBar getStatusBar()
          Returns the status bar for this policy view.
private  JToolBar getToolBar()
          Returns the tool bar for this policy view.
 void loadPolicy()
          Opens a file chooser to load a policy.
 void loadPolicy(File file)
          Loads the specified policy from a file.
private  void loadPolicy(Reader reader, File file, boolean setLastFilename)
           
 void loadSignedPolicy()
           
private  String mapString(String msg)
          Maps a string in given ResourceMap.
private  String presenterType(Class<? extends org.openpermis.policy.bean.PartBean> type)
          Returns a unique string identifier for a presenter that holds the specified part bean type.
 void redoChanged(CommandManager commandManager, String property, boolean oldValue, boolean newValue)
          Called if the command manager changes.
protected  void refresh(org.openpermis.policy.bean.PolicyBean policy, PolicyContext context)
          Notifies all registered tools that the policy and the dispatcher have changed.
 void savePolicy()
          Saves the current policy to a file.
 void savePolicy(File file)
          Saves the policy to given file.
 void savePolicyAs()
          Saves the current policy to a file.
 void setPresenter(PolicyPresenter presenter)
          Sets the policy presenter of this view.
 void showStatusError(String message)
          Shows an error message.
 void undoChanged(CommandManager commandManager, String property, boolean oldValue, boolean newValue)
          Called if the command manager changes.
 
Methods inherited from class org.openpermis.editor.policy.view.ContextView
activateEditor, addViewContextListener, closeView, createContentPane, getEditorViews, openView, removeViewContextListener, updateViewTitle, viewActivated, viewClosed, viewDeactivated, viewOpened
 
Methods inherited from class org.openpermis.editor.policy.view.AbstractView
attach, contentPaneCreated, detach, getActionMap, getAdapteeTrader, getContentPane, getIcon, getResourceMap, getTitle, getTitleParameters, getViewContext, label, toolBar, updateTitle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static final org.slf4j.Logger LOGGER
The logger object of this class.

Since:
0.1.0

VIEW_MENUBAR

private static final String VIEW_MENUBAR
Resource key for the view menubar.

Constant Field Value:
"View.menubar"
Since:
0.1.0

VIEW_TOOLBAR

private static final String VIEW_TOOLBAR
Resource key for the view toolbar.

Constant Field Value:
"View.toolbar"
Since:
0.1.0

TOOLS_MENU

private static final String TOOLS_MENU
Virtual value for the tools menu entries.

Use this value in the menu configuration of the view resources.

Constant Field Value:
""
Since:
0.1.0

STATUS_PROGRESS_BAR_WIDTH

private static final int STATUS_PROGRESS_BAR_WIDTH
Width of the progress bar in the status bar in pixels.

Constant Field Value:
100
Since:
0.1.0

frame

private final org.jdesktop.swingx.JXFrame frame
The frame used by this policy view to display its contents.

Since:
0.1.0

toolBar

private JToolBar toolBar
The tool bar of this policy view, lazily intialized.

See Also:
getToolBar()
Since:
0.1.0

menuBar

private JMenuBar menuBar
The menu bar of this policy view, lazily intialized.

See Also:
getMenuBar()
Since:
0.1.0

statusBar

private org.jdesktop.swingx.JXStatusBar statusBar
The status bar of this policy view, lazily intialized.

See Also:
getStatusBar()
Since:
0.1.0

errorStatusUpdater

private ErrorStatusUpdater errorStatusUpdater
Updater that syncs the status bar with error messages.

Since:
0.1.0

factory

private final org.picocontainer.MutablePicoContainer factory
The dependency injection container of this view.

See Also:
createContainer(org.picocontainer.PicoContainer, org.openpermis.editor.policy.Application, org.openpermis.editor.policy.gui.PolicyIconRegistry, org.openpermis.editor.policy.adapter.AdapterTrader)
Since:
0.1.0

container

private final org.picocontainer.PicoContainer container
The dependency injection container of this view.

See Also:
createContainer(org.picocontainer.PicoContainer, org.openpermis.editor.policy.Application, org.openpermis.editor.policy.gui.PolicyIconRegistry, org.openpermis.editor.policy.adapter.AdapterTrader)
Since:
0.1.0

commandManagerDispatcher

private PropertyChangeDispatcher commandManagerDispatcher
Dispatcher for undo/redo events.

Since:
0.1.0

presenter

private PolicyPresenter presenter
The active policy presenter of this view.

Since:
0.1.0
Constructor Detail

PolicyView

public PolicyView(Application application,
                  org.jdesktop.swingx.JXFrame frame,
                  PolicyIconRegistry iconRegistry,
                  AdapterTrader trader)
Creates a policy view for the specified application context.

Parameters:
application - the application that this policy view belongs to.
frame - the frame to attach this policy view to.
iconRegistry - the icon registry to use.
Since:
0.1.0
0.3.0 added iconRegistry.
Method Detail

editorType

private String editorType(Class<? extends org.openpermis.policy.bean.PartBean> type)
Returns a unique string identifier for an editor that renders the specified part bean type.

Parameters:
type - the type of part bean.
Returns:
the unique string identifier.
Since:
0.1.0

presenterType

private String presenterType(Class<? extends org.openpermis.policy.bean.PartBean> type)
Returns a unique string identifier for a presenter that holds the specified part bean type.

Parameters:
type - the type of part bean.
Returns:
the unique string identifier.
Since:
0.1.0

createTypedComponent

private final <M> M createTypedComponent(String type,
                                         Object parameter)
Factory method to create a typed component of the specified type.

Type Parameters:
M - the type of the component to create.
Parameters:
type - the unique string identifier of its type.
parameter - the paramter for the component to create.
Returns:
the created component or null if it cannot be created.
Since:
0.1.0

canCreateTypedComponent

private final boolean canCreateTypedComponent(String type)
Check if the factory can create the typed component specified.

Parameters:
type - the type to test.
Returns:
true if components of the specified type can be created, false otherwise.
Since:
0.3.0

createContainer

private final org.picocontainer.MutablePicoContainer createContainer(org.picocontainer.PicoContainer parent,
                                                                     Application application,
                                                                     PolicyIconRegistry iconRegistry,
                                                                     AdapterTrader trader)
Creates and configures a pico container for this view.

The container will provide views and presenters in the context of this view.

Parameters:
parent - the parent container of the container to create.
application - the application that delivers the context and state.
iconRegistry - the icon registry to use.
Returns:
the dependency injection container created.
Since:
0.1.0
0.3.0 added iconRegistry.

configure

public org.jdesktop.application.FrameView configure(org.jdesktop.application.FrameView frameView)
Configures the specified frame view for displaying this view.

Parameters:
frameView - the frame view to configure.
Returns:
the frame view passed in to allow fluent style usage.
Since:
0.1.0

configureToolsMenu

private void configureToolsMenu(JMenuBar toolsMenuBar)
Configures the tools menu of the specified menu bar.

Parameters:
toolsMenuBar - the menu bar to configure.
Since:
0.1.0

getMenuBar

private JMenuBar getMenuBar()
Returns the menu bar for this policy view.

Returns:
the menu bar for this policy view.
Since:
0.1.0

getToolBar

private JToolBar getToolBar()
Returns the tool bar for this policy view.

Returns:
the tool bar for this policy view.
Since:
0.1.0

getStatusBar

private org.jdesktop.swingx.JXStatusBar getStatusBar()
Returns the status bar for this policy view.

Returns:
the status bar for this policy view.
Since:
0.1.0

setPresenter

public void setPresenter(PolicyPresenter presenter)
Sets the policy presenter of this view.

Parameters:
presenter - the presenter to set.
Since:
0.1.0

mapString

private String mapString(String msg)
Maps a string in given ResourceMap.

Parameters:
msg - String to map.
Returns:
mapped string if mapping found, original string else.
Since:
0.1.0

fileValidate

@Action
public void fileValidate()
Validates a policy.

Since:
0.1.0

editRedo

@Action
public void editRedo()
Redo one action.

Since:
0.1.0

editUndo

@Action
public void editUndo()
Undo one action.

Since:
0.1.0

fileClose

@Action
public void fileClose()
Closes the currently edited policy.

Since:
0.1.0

fileOpen

@Action
public void fileOpen()
Opens an existing policy.

Since:
0.1.0

fileQuit

@Action
public void fileQuit()
Quits the policy editor.

Since:
0.1.0

fileSave

@Action
public void fileSave()
Saves the policy editor.

Since:
0.1.0

fileSaveAs

@Action
public void fileSaveAs()
Saves the policy editor.

Since:
0.1.0

fileSignedImport

@Action
public void fileSignedImport()
Imports a signed policy.

Since:
0.3.0

fileSignedExport

@Action
public void fileSignedExport()
Signs a policy.

Since:
0.3.0

fileRoleAssignment

@Action
public void fileRoleAssignment()
Creates an attribute certificate assigning roles to a subject.

Since:
0.3.0

actionsFromWsdlImport

@Action
public void actionsFromWsdlImport()
Import the actions from a wsdl file.

Since:
0.3.0

fileNew

@Action
public void fileNew()
Creates a new policy.

Since:
0.1.0

editPart

public Editor editPart(org.openpermis.policy.bean.PartBean part)
Description copied from interface: ViewContext
Opens an editor for the specified part.

If there is already an editor open, the editor will be shown.

Specified by:
editPart in interface ViewContext
Specified by:
editPart in class ContextView
Parameters:
part - the part to edit.
Returns:
the editor of this part, null if the part cannot be edited.
Since:
0.1.0

canEditPart

public boolean canEditPart(org.openpermis.policy.bean.PartBean part)
Description copied from interface: ViewContext
Tests if the part specified can be edited.

There are part types for which there may be no editor type registered, in such a case the part is not editable and calling ViewContext.editPart(PartBean) will yield a null editor. Use this method if you want to test prior to actually creating the editor.

Specified by:
canEditPart in interface ViewContext
Specified by:
canEditPart in class ContextView
Parameters:
part - the part to test.
Returns:
true if the part can be edited, false otherwise.
Since:
0.3.0

refresh

protected void refresh(org.openpermis.policy.bean.PolicyBean policy,
                       PolicyContext context)
Notifies all registered tools that the policy and the dispatcher have changed.

In contrast to the superclass version this method will update the tools regardless if they are showing or not.

Overrides:
refresh in class ContextView
Parameters:
policy - the new policy that is active.
context - the policy context to use.
Since:
0.3.0

showStatusError

public void showStatusError(String message)
Description copied from interface: ErrorReporter
Shows an error message.

Specified by:
showStatusError in interface ErrorReporter
Overrides:
showStatusError in class AbstractView
Parameters:
message - the message to display.
Since:
0.1.0

canClose

public boolean canClose()
Description copied from interface: View
Prompts the view to save unsaved changes before closing.

Specified by:
canClose in interface View
Overrides:
canClose in class AbstractView
Returns:
true if the view may be closed, false otherwise.
Since:
0.1.0

loadPolicy

public void loadPolicy(File file)
Description copied from interface: PolicyLoader
Loads the specified policy from a file.

Specified by:
loadPolicy in interface PolicyLoader
Parameters:
file - the file to load the policy from.
Since:
0.1.0

loadPolicy

public void loadPolicy()
Description copied from interface: PolicyLoader
Opens a file chooser to load a policy.

Specified by:
loadPolicy in interface PolicyLoader
Since:
0.1.0

loadSignedPolicy

public void loadSignedPolicy()
Since:
0.3.0

loadPolicy

private void loadPolicy(Reader reader,
                        File file,
                        boolean setLastFilename)
Since:
0.3.0

savePolicy

public void savePolicy()
Saves the current policy to a file.

Specified by:
savePolicy in interface PolicySaver
Since:
0.1.0

savePolicyAs

public void savePolicyAs()
Saves the current policy to a file.

Specified by:
savePolicyAs in interface PolicySaver
Since:
0.1.0

doSavePolicy

private void doSavePolicy(boolean withCurrentFilename)
Saves the current policy to a file.

Parameters:
withCurrentFilename - save the policy with current filename, if exists
Since:
0.1.0

savePolicy

public void savePolicy(File file)
Description copied from interface: PolicySaver
Saves the policy to given file.

Specified by:
savePolicy in interface PolicySaver
Parameters:
file - the file to store the policy to.
Since:
0.1.0

undoChanged

public void undoChanged(CommandManager commandManager,
                        String property,
                        boolean oldValue,
                        boolean newValue)
Called if the command manager changes.

Since:
0.1.0

redoChanged

public void redoChanged(CommandManager commandManager,
                        String property,
                        boolean oldValue,
                        boolean newValue)
Called if the command manager changes.

Since:
0.1.0


PERMIS Role Based Access Control 0.4.0 (Build 15)
2009/05/20 08:15:22
Copyright (c) 2002-2007 Ergon Informatik AG