protected void createFormContent()

in CasViewerEclipsePlugin/uimaj-ep-casviewer/src/main/java/org/apache/uima/tools/preferences/CorePreferencePage.java [175:295]


    protected void createFormContent (IManagedForm mForm) 
    { 
        this.managedForm = mForm;
        this.toolkit = managedForm.getToolkit();
        // createToolBarActions(managedForm);
        managedForm.getForm().setText(formTitle);

        ///////////////////////////////////////////////////////////////////////
        
        final Menu subMenu = new Menu (managedForm.getForm().getBody());

        MenuItem itemMenuImportStyleFile = new MenuItem(subMenu, SWT.NONE);
        itemMenuImportStyleFile.setText("Import style from file...");
        itemMenuImportStyleFile.setData(null);
        itemMenuImportStyleFile.addSelectionListener(new SelectionListener() {
            public void widgetSelected(SelectionEvent e)
            {
                FileDialog dialog = new FileDialog(managedForm.getForm().getShell(), SWT.SINGLE);
                dialog.setFilterExtensions(new String[] { "*.xml" }); //$NON-NLS-1$;
                // dialog.setFilterPath(lastUsedPath);
                String result = dialog.open();
                if (result == null) {
                    return;
                }
                String fileName = result.trim();
                tsStyle.importAndApplyStyleMapFile(null, new File(fileName));
                fileName = fileName.replace('\\', '/');
                int i = fileName.lastIndexOf("/");
                if (i != -1) {
                    fileName = fileName.substring(i+1);
                }
                setInput(tsStyle, "Custom Style (" + fileName + ")");
//                if (tsStyle.getDefaultColors() != null) {
//                    tsStyle.populateDefaultColors ();
//                    setDefaultColors(tsStyle.getDefaultColors());
//                }
                
                ((ICASViewerListener) editor).onActionInvocation(this, 
                        ICASViewerListener.PAGE_EVENT_REFRESH_STYLE, null);
                            
            }

            public void widgetDefaultSelected(SelectionEvent e){}
        });

        MenuItem itemMenu = new MenuItem(subMenu, SWT.NONE);
        itemMenu.setText("Export style to file...");
        itemMenu.setData(null);
        itemMenu.addSelectionListener(new SelectionListener() {
            public void widgetSelected(SelectionEvent e)
            {
                doSaveCurrentStyles(false);
            }

            public void widgetDefaultSelected(SelectionEvent e){}
        });
        
        MenuItem itemMenuRestoreDefaults = new MenuItem(subMenu, SWT.NONE);
        itemMenuRestoreDefaults.setText("Restore default colors");
        itemMenuRestoreDefaults.setData(null);
        itemMenuRestoreDefaults.addSelectionListener(new SelectionListener() {
            public void widgetSelected(SelectionEvent e)
            {
                ((ICASViewerListener) editor).onActionInvocation(this, 
                        ICASViewerListener.PAGE_EVENT_RESTORE_DEFAULT_STYLE, null);
            }

            public void widgetDefaultSelected(SelectionEvent e){}
        });
        
        new MenuItem(subMenu, SWT.SEPARATOR);

        itemMenu = new MenuItem(subMenu, SWT.NONE);
        itemMenu.setText("Save type system to file...");
        itemMenu.setData(null);
        itemMenu.addSelectionListener(new SelectionListener() {
            public void widgetSelected(SelectionEvent e)
            {
                doSaveTypesystem();
            }

            public void widgetDefaultSelected(SelectionEvent e){}
        });
        
        Action optionsAction = new Action("Options", Action.AS_PUSH_BUTTON) {
            public void run() {
                subMenu.setVisible(true);
            }
        };
        optionsAction.setDescription("Import/Export style file");
        optionsAction.setText("Options");
        optionsAction.setChecked(false);
        optionsAction.setToolTipText("Options...");
        optionsAction.setImageDescriptor(ImageLoader.getInstance()
                .getImageDescriptor(ImageLoader.ICON_UI_IDE_IMPORT_PREF));
        managedForm.getForm().getToolBarManager().add(optionsAction);                
        managedForm.getForm().getToolBarManager().update(true);
        managedForm.getForm().getBody().setLayout(new GridLayout(1, false)); // this is required !
        
        Form2Panel form2Panel = setup2ColumnLayout(managedForm.getForm().getBody(), 55, 45);

        defaultStyleSection = DefaultColorTreeSectionPart.createInstance(this, managedForm, form2Panel.left,
                Section.TITLE_BAR | Section.TWISTIE | Section.DESCRIPTION,
                Messages.getString("DefaultColorTreeSection.Title"),
                Messages.getString("DefaultColorTreeSection.Description"),
                true, tsStyle);
        
        importedStyleSection = ColoredTypeTreeSectionPart.createInstance(managedForm, form2Panel.right,
                Section.TITLE_BAR | Section.TWISTIE | Section.DESCRIPTION,
                Messages.getString("CustomColorTreeSection.Title"),
                Messages.getString("CustomColorTreeSection.Description"),
                false);
        
        if (inputDefaultTypeStyles != null) {
            defaultStyleSection.setInput(inputDefaultTypeStyles, null);
        }
        
        if (inputObject != null) {
            importedStyleSection.setInput(inputObject, null);
        }
    }