input
stringlengths
10
828
output
stringlengths
5
107
private void register editor model observers observer editor model observers this main menu edit area tabs for observer editor model observer editor model observers editor model add observer editor model observer
many gui elements have to observe the prototype model so that they can
public void on saved changes since last save 0 set changed notify observers
should be called when the prototype model is saved
private void increase changes since last change increase changes since last change 1
adds code 1 code to the number of changes since the prototype was
public boolean confirm save if editor model get operation history is changed since last save int choice joption pane show confirm dialog this i18n t editor save confirmation dialog message i18n t editor save confirmation dialog title joption pane yes no cancel option if choice joption pane yes option try file save action get action editor actions id file save save as or save catch ioexception exc saving failed joption pane show message dialog this exc get localized message return false choice is 1 when the user pressed esc return choice joption pane cancel option choice 1 return true
if there have been any unsaved changes opens a dialog window which asks
private void decrease changes since last change increase changes since last change 1
substracts code 1 code from the number of changes since the
private void increase changes since last change int step this changes since last save step set changed notify observers
adds code step code to the number of changes since the prototype was
public icon cache get icon cache return icon cache
gets the cache that is responsible for all icons
private void build screen menu screen menu new jmenu i18n t menu screen screen menu set mnemonic i18n t menu screen mnemonic char at 0 refresh screen menu add screen menu
builds the screen menu
public edit area get edit area return edit area
gets the largest part of the user interface the working area
private void build element menu element menu new jmenu i18n t menu element element menu set mnemonic i18n t menu element mnemonic char at 0 refresh element menu add element menu
builds the element menu
public action get action editor actions id action id return actions get action id
gets the editor action with the given id
public action get id action id return map get action id
gets the action with the given id
private void update title bar string buffer title buffer new string buffer i18n t editor title if editor model get current prototype model null title buffer append title buffer append editor model get current prototype model get title if editor model get current prototype model get current screen null title buffer append title buffer append editor model get current prototype model get current screen id if editor model get operation history is changed since last save title buffer append set title title buffer to string
updates the titlebar
public void update look and feel string old laf class name look and feel manager get prototype look and feel class name string new laf class name editor model get current prototype model get look and feel class name if old laf class name equals new laf class name look and feel manager set prototype look and feel class name new laf class name
checks if the current prototype models look and feel class name has
private void build help menu jmenu help menu new jmenu i18n t menu help help menu set mnemonic i18n t menu help mnemonic char at 0 add help menu help menu add new jmenu item editor get action editor actions id help about help menu add new jmenu item editor get action editor actions id help online documentation
builds the prototype menu
public void on elements reordered list string factory ids
is called when elements were reordered
protected void register observers the set as start screen action is disabled when the current screen is already the start screen several operations are disabled when the model contains no screens editor get editor model add observer this copy delete selected element etc are only available when something is selected editor get edit area get selection layer get selection add observer this
this method registers all actions as observers of several parts of the
protected void set tooltip string tooltip put value action short description tooltip
sets the tooltip text that is the text that will float over components
protected void set icon filename string filename put value action small icon editor get icon cache get icon filename
returns the filename of the icon that should be shown on components that
public void on elements deleted
is called when elements were deleted
protected void set accelerator key stroke key stroke put value action accelerator key key stroke
sets the hotkey of this editor action
public void on elements restored linked hash map string outline ids to outlines
is called when elements were deleted
private string suggest filename string suggested filename if editor get editor model get filename null suggested filename editor get editor model get filename else suggested filename editor get editor model get current prototype model get title prot return suggested filename
suggests a filename for the current prototype
private void move selected value up int index factory id list get selected index if index 0 object value factory id list get model get element at index factory id list model remove index factory id list model add index 1 value factory id list set selected index index 1 autoscroll factory id list ensure index is visible index 1
moves the selected value up in the list
private void move selected value down int index factory id list get selected index if index factory id list get model get size 1 object value factory id list get model get element at index factory id list model remove index factory id list model add index 1 value factory id list set selected index index 1 autoscroll factory id list ensure index is visible index 1
moves the selected value down in the list
private jpanel create center panel jpanel center panel new jpanel layout new grid bag layout center panel set layout layout left column constraints new grid bag constraints left column constraints fill grid bag constraints both left column constraints insets new insets pad pad pad pad left column constraints gridwidth grid bag constraints relative right column constraints new grid bag constraints right column constraints fill grid bag constraints both right column constraints insets new insets pad pad pad pad right column constraints gridwidth grid bag constraints remainder fill center panel center panel return center panel
creates the panel that will be put into the center of this dialog
private jpanel create south panel jpanel south panel new jpanel jbutton ok button new jbutton i18n t general ok ok button set mnemonic i18n t general ok mnemonic char at 0 ok button set action command ok ok button add action listener this south panel add ok button jbutton cancel button new jbutton i18n t general cancel cancel button set mnemonic i18n t general cancel mnemonic char at 0 cancel button set action command cancel cancel button add action listener this south panel add cancel button return south panel
creates the south panel which contains the ok and cancel button
protected void apply changes prototype change title and description operation operation new prototype change title and description operation editor get editor model get operation history perform operation dispose
is invoked when the user presses ok
private boolean is dark color color unfortunatelly the color class has no get brightness method float hsb color rgbto hsb color get red color get green color get blue null float brightness hsb 2 return brightness 0 5f
checks whether the given color has a low brightness
public void set color color color color color without alpha new color color get red color get green color get blue set background color without alpha choose the text color in a way that contrast is ok if is dark color set foreground color white else set foreground color black set text i18n t dialog properties screen background color rgb color get red color get green color get blue
sets the color that should be represented by this label
public jlabel get color preview return color preview label
gets the label which shows a preview of the currently selected color
public jbutton get color selection button return color selection button
gets the button which when pressed opens a color selector dialog
private void insert at caret string text int caret pos text component get caret position string old text text component get text text component set text old text substring 0 caret pos text old text substring caret pos text component set caret position caret pos text length
inserts the given text into the text component at the caret position
public void set advanced mode boolean advanced mode this advanced mode advanced mode at the time when advanced mode toggled there can be only one transition in the dialog so we don t need the header text rebuild components false
toggles this panel between simple and advanced mode
private void ensure mutual exclusion password mode check box set enabled multiline check box is selected multiline check box set enabled password mode check box is selected
makes sure that the user cannot select the multi line checkbox and the
private void apply changes i18n prefs put language string language combo box get selected item dispose
is invoked when the user presses ok
private void create transition panels this transition panels new linked list transition panel list transition transitions factory get transitions for transition transition transitions transition panel panel new transition panel editor this transition advanced mode transition panels add panel
creates a panel for each transition
private boolean can be displayed in simple mode list transition transitions factory get transitions if transitions size 2 return false if transitions size 0 return true this regular expression matches a string literal it does however not match string literals that contain quotation marks string string literal regex transition transition transitions get 0 return transition get condition null transition get action null transition get target screen expression null transition get target screen expression matches string literal regex transition get target screen expression starts with screen history
checks whether this dialog can be displayed in simple mode
protected void refresh list string filenames get available filenames default list model list model new default list model if include null entry list model add element null for string filename filenames list model add element filename list box set model list model if list box get model get size 0 list box get selected index 1 list box set selected index 0 show preview of string list box get selected value
fills the list box with the filenames of all those files that are
protected void show import dialog file filter filter create file filter string directory prefs get directory null jfile chooser file chooser new jfile chooser directory file chooser set file filter filter file chooser set multi selection enabled true int return value file chooser show open dialog this if return value jfile chooser approve option prefs put directory file chooser get current directory get absolute path for file file file chooser get selected files import file file
shows a dialog with which the user can import an file into the
protected void import file final file file import file file file get name
imports the given file into the data directory using its original
protected void show export dialog string source filename string list box get selected value file filter filter create file filter string directory prefs get directory null jfile chooser file chooser new jfile chooser directory file chooser set dialog type jfile chooser save dialog file chooser set selected file new file source filename file chooser set file filter filter int return value file chooser show save dialog this if return value jfile chooser approve option prefs put directory file chooser get current directory get absolute path export file source filename file chooser get selected file
shows a dialog with which the user can export the currently selected
public void request child focus if child has focus if advanced mode condition field request focus else target screen expression box request focus
makes sure that one of the components or popup menus of this panel
private void export file string source filename final file target file try editor get editor model get file library export file source filename target file catch ioexception exc joption pane show message dialog editor exc get localized message i18n t general error joption pane error message
exports the file with the given filename from the data directory to
public void request condition field focus if advanced mode condition field request focus
makes sure that the condition text component has focus
protected void delete selected file string filename string list box get selected value delete file filename
deletes the currently selected file
public void request action area focus if advanced mode action area request focus
makes sure that the action text component has focus
private void delete file final string filename delete file operation operation new delete file operation filename editor get editor model get operation history perform operation
deletes the file with the given filename
public void request target screen expression box focus target screen expression box request focus
makes sure that the target screen expression component has focus
protected void fill center panel jpanel center panel jlabel id label new jlabel i18n t dialog properties screen element id jlabel right layout set constraints id label left column constraints center panel add id label id field new jtext field factory id layout set constraints id field right column constraints center panel add id field
fills the given center panel with the required components
private void apply changes if check input string description if mode mode add description i18n t dialog properties screen element operation add else description i18n t dialog properties screen element operation modify factory id screen element change operation operation create operation description editor get editor model get operation history perform operation dispose
is called when the ok button is pressed
public int get x return rectangle x
returns the horizontal position of the marquee
public int get y return rectangle y
returns the vertical position of the marquee
public int get width return rectangle width
returns the horizontal size of the marquee
private void apply changes if is entered id ok id field request focus else if is entered init action ok init action area request focus else string description if mode mode add description i18n t dialog properties screen operation add else description i18n t dialog properties screen operation modify old screen id screen change operation operation new screen change operation description editor get editor model get operation history perform operation dispose
is called when the ok button is pressed
public int get height return rectangle height
returns the vertical size of the marquee
public void set x int x rectangle x x set changed notify observers
changes the horizontal position of the marquee
public void set y int y rectangle y y set changed notify observers
changes the vertical position of the marquee
public void set width int width rectangle width width set changed notify observers
changes the horizontal size of the marquee
public void set height int height rectangle height height set changed notify observers
changes the vertical size of the marquee
public boolean intersects rectangle rect return normalize rectangle rectangle intersects rect
checks whether or not this marquee intersects the given rectangle
public outline get outline string id return ids to outlines get id
gets the outline with the given id from this selection
public boolean contains point p return normalize rectangle rectangle contains p
checks whether or not this marquee contains the given point
private rectangle normalize rectangle rectangle rect rectangle result new rectangle rect if result width 0 result x result width result width result width if result height 0 result y result height result height result height return result
you can assign negative values to width and height
public void paint graphics g g set color border color the draw rect method can t handle rectangles with negative width or height it simply wouldn t draw anything rectangle normalized rect normalize rectangle rectangle g draw rect normalized rect x normalized rect y normalized rect width normalized rect height g set color fill color g fill rect normalized rect x normalized rect y normalized rect width normalized rect height
paints this marquee to the given graphics
public void put all linked hash map string outline map for string id map key set outline outline map get id put id outline for outline outline ids to outlines values outline set adjustment handles enabled current selection needs adjustment handles
adds the given outlines to this selection and assigns the given ids to
public void remove string id ids to outlines remove id set changed notify observers
removes the outline with the given id from this selection
protected boolean current selection needs adjustment handles if ids to outlines size 1 string first id ids to outlines key set iterator next return is resizable first id return false
checks whether or not adjustment handles should currently be enabled
public rectangle get bounds return new rectangle rectangle
gets the position and size of this outline
public void clear for outline outline ids to outlines values outline set adjustment handles enabled false ids to outlines clear set changed notify observers
removes all outlines from this selection
public rectangle get normalized bounds return normalize rectangle rectangle
gets the position and size of this outline in a normalized form i
public boolean is empty return ids to outlines is empty
checks whether or not this selection currently contains any outlines
public int size return ids to outlines size
counts the outlines that this selection currently contains
public int get x2 return rectangle x rectangle width
gets the horizontal position of the right border of this outline
public boolean is movable string outline id return true
checks whether or not the outline with the given id is movable
private void show preview image in label jlabel label image scaled image image utils scale keeping aspect ratio scanned image max preview width max preview height label set icon new image icon scaled image label set bounds 0 0 scaled image get width null scaled image get height null
displays a scaled down version of the scanned and possibly
public boolean is resizable string outline id return true
checks whether or not the outline with the given id is resizable
public int get y2 return rectangle y rectangle height
gets the vertical position of the lower border of this outline
private void write image throws ioexception first write to a temp file having this will make it easier to make this operation undoable and redoable final file temp file file create temp file protoreto scan filename extension temp file delete on exit image io write scanned image filename extension temp file string target filename filename without extension filename extension choose image dialog get owner import file temp file target filename
saves the image to disk using the chosen filename
public point get position in invoker return position in invoker
returns the position at which this menu was last shown
public void set bounds rectangle rectangle this rectangle x rectangle x this rectangle y rectangle y this rectangle width rectangle width this rectangle height rectangle height recalculate adjustment handles set changed notify observers
gets the position and size of this outline
public void set x int x rectangle x x recalculate adjustment handles set changed notify observers
sets the horizontal position of the left border of this outline
public void set y int y rectangle y y recalculate adjustment handles set changed notify observers
sets the vertical position of the upper border of this outline
public void set width int width rectangle width width recalculate adjustment handles set changed notify observers
sets the horizontal size of this outline
public void set description string description this description description set changed notify observers
sets the description of this prototype
public void set height int height rectangle height height recalculate adjustment handles set changed notify observers
sets the vertical size of this outline
public boolean contains point p if rectangle contains p return true if adjustment handles enabled for rectangle rectangle adjustment handles values if rectangle contains p return true return false
checks whether this outline or one of its adjustment handles if any
public void set adjustment handles enabled boolean enabled adjustment handles enabled enabled
enables or disables the adjustment handles of this outline
public boolean is adjustment handles enabled return adjustment handles enabled
checks whether the adjustment handles of this outline are enabled or
public boolean is id assigned string id return screens contains key id
checks whether or not this prototype model contains a screen with
private void move outlines int diff x int diff y for outline outline selection get outlines outline set x outline get x diff x outline set y outline get y diff y on outline resized or moved drag mode move
moves all outlines by the given distance
public void add screen string screen id screen screen if screen id index of 1 throw new identifier exception screen id screen ids may not contain quotation marks if screens contains key screen id throw new identifier exception screen id duplicate screen id screen id screens put screen id screen the first screen that is added to an empty prototype will become the start screen note when add screen is called from the constructor the start screen id will be re assigned later in the constructor if start screen id null start screen id screen id set changed notify observers
adds a screen the prototype
public void remove screen string screen id if screens contains key screen id throw new identifier exception screen id unknown screen id screen id screens remove screen id if screen id equals get current screen id the current screen was deleted switch to another one if screens is empty set current screen string null else set current screen screens first key if screen id equals start screen id the start screen was deleted set a new one if screens is empty set start screen id null else set start screen id screens first key set changed notify observers
removes the screen with the given id from the model
private void refresh cursor point mouse position int modifiers the mouse cursor won t be changed while a drag operation is in progress if drag mode null drag mode drag mode under cursor drag mode at mouse position modifiers set cursor cursors get drag mode under cursor
refreshes the mouse cursor so that it indicates the mode of the drag
public void rename screen string old id string new id if old id equals new id if screens contains key old id throw new identifier exception old id unknown screen id old id if is id assigned new id throw new identifier exception new id duplicate screen id new id screen screen get screen old id add screen new id screen set current screen new id if old id equals start screen id start screen id new id remove screen old id update transitions to renamed screen old id new id
changes the id of an existing screen
public string get target screen expression return target screen expression
gets a scripting expression that evaluates to a string this string is
private void update transitions to renamed screen string old id string new id modify transitions that lead to the renamed screen for screen other screen screens values for screen element factory factory other screen get screen element factories values for transition transition factory get transitions if old id equals transition get target screen expression transition set target screen expression new id
updates the target screen id of those transitions that led to a screen
public void set target screen expression string target screen expression this target screen expression target screen expression
sets a scripting expression that evaluates to a string this string is
public boolean is empty return condition null action null target screen expression null comment null
checks whether or not all of this transitions attributes are set to
public void set current screen string screen id the previous screen needn t be observed anymore if get current screen null get current screen delete observers if screen id null current screen id null else if screens contains key screen id current screen id screen id else throw new identifier exception screen id unknown screen id screen id set changed notify observers
switches to another screen