Topic: (I search for a pattern) Podmeshivanie of a feature in a tree of classes

All greetings! At first a prehistory. All business goes in a web, but it is not so important. We admit, there is class Dialog - a window. We have 3 types of display (not simply stylization CSS, and even different structure HTML is really it is required). Now the code of different methods (buildDialogHtml (), getCssClass () and etc.) Represent branching if': protected buildDialogHtml () {if (ui == 0) this.buildDialogHtmlType0 (); else if (ui == 1) this.buildDialogHtmlType1 (); else this.buildDialogHtmlType2 (); the OOP Paradigm says that such code it is possible and it is necessary to divide into class hierarchy: - Dialog - DialogType0 - DialogType1 - DialogType2 OK, we do the private designer, a public factory method create () which returns to us  the necessary class. All anything, but we here had such hierarchy: - ABaseDialog (lib) - VeryCustomUserDialog (user) - Dialog (lib) - MessageDialog (lib) - StandardUserDialog (user) As you can see, it turns out, we cannot put our OOP in such structure.  . Such branching of classes approaches only when type UI is  the last link in hierarchy. How to implement such piece that it was beautiful and it is expanded? Can eat any pattern? While on mind the pattern of the delegate comes only: Creation of any object UIType inside Dialog to which the given methods are delegated. But it produces a heap of the code navigation on which so-so, and seems, what it is better if'. Besides after all the user of our library can casually redefine a method which causes the delegate, and will not understand, why all broke (or broke only on specific type UI).