|
Allow easy customization of editor tabs.
Question (arch-overall): Describe the overall architecture. Answer:The main purpose of this API is to allow third-party customizations of editor tabs. Instead of implementing many interfaces and creating various UI delegates it is possible to create a simple decorator-like class that can customize the appearance of a specific editor tab. For example change tabs background color according to file type or project type, change its icon etc.
Question (arch-usecases): Describe the main use cases of the new API. Who will use it under what circumstances? What kind of code would typically need to be written to use the module? Answer:
To customize the rendering of (some) editor tabs one needs subclass
TabDecorator
class and register it in the global Lookup
.
The example below shows a decorator that removes file extension from Java source files to have shorter tabs to show more file names without the need for scrolling.
ServiceProvider(service = TabDecorator.class, position = 1000) public class MyTabDecorator extends TabDecorator { public String getText( TabData tab ) { String res = tab.getText(); if( null != res ) res = res.replace( ".java", ""); return res; } }
If one needs a custom editor tab displayer for example to have special
tab layout or special layout of scrolling buttons etc it is necessary
to subclass TabDisplayer
class and register an instance
of TabDisplayerFactory
in the global Lookup
.
public class MyTabDisplayer extends TabDisplayer { public MyTabDisplayer( TabDataModel model ) { super( model ); } ServiceProvider(service = TabDisplayerFactory.class) public static class MyTabDisplayerFactory extends TabDisplayerFactory { public TabDisplayer createTabDisplayer( TabDataModel tabModel, int orientation ) { return new MyTabDisplayer( tabModel ); } } //implement all abstract methods here }Question (arch-time): What are the time estimates of the work? Answer:
The API is already implemented in org.netbeans.core.multitabs package.
Question (arch-quality): How will the quality of your code be tested and how are future regressions going to be prevented? Answer:The API will be covered by unit tests.
Question (arch-where): Where one can find sources for your module? Answer:
The sources for the module are in the Apache Git repositories or in the GitHub repositories.
These modules are required in project.xml:
The module depends on org.netbeans.swing.tabcontrol module (it reuses its data model) and on org.netbeans.core.windows module as it implements some of its tab container interfaces and classes.
Question (dep-platform): On which platforms does your module run? Does it run in the same way on each? Answer:It is platform independent.
Question (dep-jre): Which version of JRE do you need (1.2, 1.3, 1.4, etc.)? Answer:1.6 or better.
Question (dep-jrejdk): Do you require the JDK or is the JRE enough? Answer:JRE
JAR only
Question (deploy-nbm): Can you deploy an NBM via the Update Center? Answer:Yes
Question (deploy-shared): Do you need to be installed in the shared location only, or in the user directory only, or can your module be installed anywhere? Answer:Does not matter
Question (deploy-packages): Are packages of your module made inaccessible by not declaring them public? Answer:Only package org.netbeans.core.multitabs is exported as public.
Question (deploy-dependencies): What do other modules need to do to declare a dependency on this one, in addition to or instead of the normal module dependency declaration (e.g. tokens to require)? Answer:No other dependencies.
Yes
Question (compat-standards): Does the module implement or define any standards? Is the implementation exact or does it deviate somehow? Answer:No
Question (compat-version): Can your module coexist with earlier and future versions of itself? Can you correctly read all old settings? Will future versions be able to read your current settings? Can you read or politely ignore settings stored by a future version? Answer:Yes
Question (compat-deprecation): How the introduction of your project influences functionality provided by previous version of the product? Answer:This API doesn't not deprecate or replace any existing APIs.
java.io.File
directly?
Answer:
No
Question (resources-layer): Does your module provide own layer? Does it create any files or folders in it? What it is trying to communicate by that and with which components? Answer:Yes, it is used to register its options panel into Tools - Options window.
Question (resources-read): Does your module read any resources from layers? For what purpose? Answer:No
Question (resources-mask): Does your module mask/hide/override any resources provided by other modules in their layers? Answer:No
Question (resources-preferences): Does your module uses preferences via Preferences API? Does your module use NbPreferences or or regular JDK Preferences ? Does it read, write or both ? Does it share preferences with other modules ? If so, then why ? Answer:NbPreferences are used to store user settings in Tools - Options window.
org.openide.util.Lookup
or any similar technology to find any components to communicate with? Which ones?
Answer:
The module checks the global lookup for an instance of org.netbeans.core.multitabs.TabDisplayerFactory
to see if other than the default implementation of multi-tabs is available.
The default implementation of multi-tabs also looks for org.netbeans.core.multitabs.TabDecorator
instances to check if any third party wants to change the editor tab rendering.
The module registers an instance of
org.netbeans.swing.tabcontrol.customtabs.TabbedComponentFactory
to provide custom implementation of editor tabs displayer.
No
System.getProperty
) property?
On a similar note, is there something interesting that you
pass to java.util.logging.Logger
? Or do you observe
what others log?
Answer:
No
Question (exec-component): Is execution of your code influenced by any (string) property of any of your components? Answer:No
Question (exec-ant-tasks): Do you define or register any ant tasks that other can use? Answer:No
Question (exec-classloader): Does your code create its own class loader(s)? Answer:No
Question (exec-reflection): Does your code use Java Reflection to execute other code? Answer:No
Question (exec-privateaccess): Are you aware of any other parts of the system calling some of your methods by reflection? Answer:No
Question (exec-process): Do you execute an external process from your module? How do you ensure that the result is the same on different platforms? Do you parse output? Do you depend on result code? Answer:No
Question (exec-introspection): Does your module use any kind of runtime type information (instanceof
,
work with java.lang.Class
, etc.)?
Answer:
No
Question (exec-threading): What threading models, if any, does your module adhere to? How the project behaves with respect to threading? Answer:The API creates/uses Swing components which should be access from EDT only.
Question (security-policy): Does your functionality require modifications to the standard policy file? Answer:No
Question (security-grant): Does your code grant additional rights to some other code? Answer:No
No file formats
Question (format-dnd): Which protocols (if any) does your code understand during Drag & Drop? Answer:No custom d'n'd
Question (format-clipboard): Which data flavors (if any) does your code read from or insert to the clipboard (by access to clipboard on means calling methods onjava.awt.datatransfer.Transferable
?
Answer:
No custom data flavors.
No
Question (perf-exit): Does your module run any code on exit? Answer:No
Question (perf-scale): Which external criteria influence the performance of your program (size of file in editor, number of files in menu, in source directory, etc.) and how well your code scales? Answer:Does not apply
Question (perf-limit): Are there any hard-coded or practical limits in the number or size of elements your code can handle? Answer:No
Question (perf-mem): How much memory does your component consume? Estimate with a relation to the number of windows, etc. Answer:It's just a JTable showing an editor tab in each cell.
Question (perf-wakeup): Does any piece of your code wake up periodically and do something even when the system is otherwise idle (no user interaction)? Answer:No
Question (perf-progress): Does your module execute any long-running tasks? Answer:No
Question (perf-huge_dialogs): Does your module contain any dialogs or wizards with a large number of GUI controls such as combo boxes, lists, trees, or text areas? Answer:No
Question (perf-menus): Does your module use dynamically updated context menus, or context-sensitive actions with complicated and slow enablement logic? Answer:No
Question (perf-spi): How the performance of the plugged in code will be enforced? Answer:All the code will be executed in EDT, NetBeans slowness detector should kick-in when third-party plugin takes too much time.