下面列出了怎么用org.eclipse.ui.forms.IManagedForm的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
protected void createFormContent(IManagedForm mform) {
var form = UI.formHeader(mform, getTitle(), Icon.PYTHON.get());
var tk = mform.getToolkit();
var body = UI.formBody(form, tk);
body.setLayout(new FillLayout());
try {
browser = new Browser(body, SWT.NONE);
browser.setJavascriptEnabled(true);
UI.onLoaded(browser,
HtmlFolder.getUrl("python.html"), this::initScript);
} catch (Exception e) {
Logger log = LoggerFactory.getLogger(getClass());
log.error("failed to create browser in Python editor", e);
}
}
@Override
protected void createFormContent(IManagedForm mform) {
ScrolledForm form = mform.getForm();
Composite comp = form.getBody();
comp.setLayout(new FillLayout());
try {
Browser b = new Browser(comp, SWT.NONE);
b.setJavascriptEnabled(true);
UI.onLoaded(b, HtmlFolder.getUrl("report.html"), () -> {
Gson gson = new Gson();
String json = gson.toJson(report);
String command = "setData(" + json + ")";
b.execute(command);
});
} catch (Exception e) {
Logger log = LoggerFactory.getLogger(getClass());
log.error("failed to load report in browser", e);
}
}
@Override
protected void createFormContent(IManagedForm managedForm) {
form = UI.formHeader(this);
toolkit = managedForm.getToolkit();
Composite body = UI.formBody(form, toolkit);
InfoSection infoSection = new InfoSection(getEditor());
infoSection.render(body, toolkit);
createButton(infoSection.getContainer());
new ImpactSection(editor).render(body, toolkit);
createVariantsSection(body);
Section section = UI.section(body, toolkit, M.Parameters);
parameterTable = new ProjectParameterTable(editor);
parameterTable.render(section, toolkit);
initialInput();
new ProcessContributionSection(editor).create(body, toolkit);
body.setFocus();
form.reflow(true);
}
@Override
protected void createFormContent(IManagedForm managedForm) {
final ScrolledForm form = managedForm.getForm();
FormToolkit toolkit = managedForm.getToolkit();
toolkit.decorateFormHeading(form.getForm());
IToolBarManager manager = form.getToolBarManager();
if (contributeToToolbar(manager)) {
form.updateToolBar();
}
String titleText = getFormTitleText();
if (titleText != null) {
form.setText(titleText);
}
Image titleImage = getFormTitleImage();
if (titleImage != null) {
form.setImage(titleImage);
}
toolkit.decorateFormHeading(form.getForm());
createUI(managedForm);
}
@Override
protected void createFormContent(IManagedForm mform) {
FormToolkit toolkit = mform.getToolkit();
UI.formHeader(mform, M.SearchParameters);
Composite body = UI.formBody(mform.getForm(), mform.getToolkit());
UI.gridLayout(body, 1);
Label filterLabel = UI.formLabel(body, toolkit, M.Filter);
filterLabel.setFont(UI.boldFont());
filterText = UI.formText(body, SWT.SEARCH);
filterText.addModifyListener(e -> viewer.refresh());
Section section = UI.section(body, toolkit, M.Parameters);
UI.gridData(section, true, true);
Composite composite = UI.sectionClient(section, toolkit, 1);
createViewer(composite);
}
@Override
protected void createFormContent(IManagedForm mform) {
ScrolledForm form = UI.formHeader(this);
FormToolkit tk = mform.getToolkit();
Composite body = UI.formBody(form, tk);
InfoSection info = new InfoSection(getEditor());
info.render(body, tk);
checkBox(info.getContainer(),
M.InfrastructureProcess, "infrastructureProcess");
createButtons(info.getContainer(), tk);
createTimeSection(body, tk);
createGeographySection(body, tk);
createTechnologySection(body, tk);
new ImageSection(getEditor(), tk, body);
createDqSection(body, tk);
body.setFocus();
form.reflow(true);
}
@Override
protected void createFormContent(IManagedForm mform) {
ContributionResult result = editor.result;
ScrolledForm form = UI.formHeader(mform,
Labels.name(editor.setup.productSystem),
Images.get(editor.result));
FormToolkit tk = mform.getToolkit();
Composite body = UI.formBody(form, tk);
InfoSection.create(body, tk, editor.setup);
if (editor.dqResult != null) {
new DQInfoSection(body, tk, result, editor.dqResult);
}
if (result.hasImpactResults()) {
ContributionChartSection.forImpacts(editor).render(body, tk);
}
ContributionChartSection.forFlows(editor).render(body, tk);
form.reflow(true);
}
@Override
protected void createFormContent(IManagedForm mform) {
ScrolledForm form = UI.formHeader(this);
FormToolkit tk = mform.getToolkit();
Composite body = UI.formBody(form, tk);
Section section = UI.section(body, tk, M.ImpactFactors);
UI.gridData(section, true, true);
Composite client = tk.createComposite(section);
section.setClient(client);
UI.gridLayout(client, 1);
render(client, section);
List<ImpactFactor> factors = impact().impactFactors;
sortFactors(factors);
viewer.setInput(factors);
form.reflow(true);
}
/**
* The Constructor
*
* @param section
* The new Section to be managed by the ICESectionPart.
* @param formEditor
* The FormEditor that is managing all of the Pages and
* SectionParts.
* @param managedForm
* The ManagedForm for the Section.
*/
public ICEDataComponentSectionPart(Section section,
ICEFormEditor formEditor, IManagedForm managedForm) {
// Call the parent constructor
super(section);
// Set the FormEditor if it is not null and throw an exception
// otherwise.
if (formEditor != null) {
editor = formEditor;
} else {
throw new RuntimeException("Editor in ICEFormSectionPart "
+ "constructor cannot be null.");
}
// Set the ManagedForm
if (managedForm != null) {
parentForm = managedForm;
} else {
throw new RuntimeException("ManagedForm in ICEFormSectionPart "
+ "constructor cannot be null.");
}
return;
}
@Override
protected void createFormContent(IManagedForm mform) {
FormToolkit tk = mform.getToolkit();
Composite comp = UI.formBody(mform.getForm(), tk);
UI.gridLayout(comp, 1, 10, 10);
UI.formLabel(comp, tk, "This will replace the flows in the database " +
"(the source system) with the flows in the target system.");
tree = new ModelCheckBoxTree(
ModelType.PROCESS,
ModelType.IMPACT_METHOD);
tree.drawOn(comp, tk);
Button delete = tk.createButton(comp,
"Delete replaced and unused flows", SWT.CHECK);
Controls.onSelect(delete, _e -> {
conf.deleteMapped = delete.getSelection();
});
}
@Override
protected void createFormContent(IManagedForm mform) {
String title = M.Diff;
if (this.title != null)
title += ": " + this.title;
ScrolledForm form = UI.formHeader(mform, title);
if (logo != null)
form.setImage(logo);
FormToolkit toolkit = mform.getToolkit();
Composite body = form.getBody();
UI.gridLayout(body, 1, 0, 0);
toolkit.paintBordersFor(body);
UI.gridData(body, true, true);
if (editMode)
editor = DiffEditor.forEditing(body, toolkit);
else
editor = DiffEditor.forViewing(body, toolkit);
editor.initialize(root, labelProvider, dependencyResolver, action);
UI.gridData(editor, true, true);
form.reflow(true);
}
/**
* Called by the 3.0 framework to fill in the contents
*
* @param managedForm the managed form
*/
@Override
protected void createFormContent(IManagedForm managedForm) {
final Form2Panel form2Panel = setup2ColumnLayout(managedForm, EQUAL_WIDTH);
managedForm.getForm().setText(
(isLocalProcessingDescriptor() || isIndexDescriptor()) ? "Indexes" : "Type Priorities");
if (!isTypePriorityDescriptor()) {
managedForm.addPart(indexSection = new IndexSection(editor, form2Panel.left));
managedForm.addPart(indexImportSection = new IndexImportSection(editor, form2Panel.right));
}
if (!isIndexDescriptor()) {
managedForm.addPart(priorityListSection = new PriorityListSection(editor, form2Panel.left));
managedForm.addPart(typePriorityImportSection = new TypePriorityImportSection(editor,
form2Panel.right));
}
createToolBarActions(managedForm);
}
@Override
protected void createFormContent(IManagedForm mform) {
FormToolkit tk = mform.getToolkit();
ScrolledForm form = UI.formHeader(mform,
Labels.name(setup.productSystem),
Images.get(result));
Composite body = UI.formBody(form, tk);
Composite comp = tk.createComposite(body);
UI.gridLayout(comp, 2);
ResultTypeCombo selector = ResultTypeCombo
.on(result)
.withEventHandler(new SelectionHandler())
.create(comp, tk);
Composite treeComp = tk.createComposite(body);
UI.gridLayout(treeComp, 1);
UI.gridData(treeComp, true, true);
createTree(tk, treeComp);
form.reflow(true);
selector.initWithEvent();
}
@Override
protected void createFormContent(IManagedForm mform) {
ScrolledForm form = UI.formHeader(mform,
Labels.name(setup.productSystem),
Images.get(result));
toolkit = mform.getToolkit();
body = UI.formBody(form, toolkit);
nwSetTable = loadNwSetTable();
if (nwSetTable == null)
return;
if (nwSetTable.hasNormalisationFactors())
createNormalisationSection();
else if (nwSetTable.hasWeightingFactors())
createWeightingSection();
if (nwSetTable.hasNormalisationFactors()
&& nwSetTable.hasWeightingFactors())
createSingleScoreSection();
}
@Override
public void initialize(IManagedForm form) {
parmSection = editor.getParameterPage().getParameterSection();
super.initialize(form);
sectionClient = newComposite(getSection());
tree = newTree(sectionClient);
Composite buttonContainer = new2ColumnComposite(sectionClient);
((GridData) buttonContainer.getLayoutData()).grabExcessVerticalSpace = false;
createOverrideButton = newPushButton(buttonContainer, "Create Override",
"Overrides allow an aggregate to replace a parameter's value in one or more of its delegates");
createNonSharedOverrideButton = newPushButton(buttonContainer, "Create non-shared Override",
"Click here to create a non-shared override for this parameter");
tree.addListener(SWT.MouseDoubleClick, this); // edit gesture
tree.addListener(SWT.MouseHover, this); // hover
enableBorders(sectionClient);
toolkit.paintBordersFor(sectionClient);
}
@Override
protected void createFormContent(IManagedForm mform) {
ScrolledForm form = UI.formHeader(mform,
Labels.name(setup.productSystem),
Images.get(result));
toolkit = mform.getToolkit();
Composite body = UI.formBody(form, toolkit);
TreeViewer inputTree = createTree(body, true);
TreeViewer outputTree = createTree(body, false);
TotalRequirementsSection reqSection = new TotalRequirementsSection(
result, dqResult);
reqSection.create(body, toolkit);
form.reflow(true);
fillTrees(inputTree, outputTree);
reqSection.fill();
}
@Override
protected void createFormContent(IManagedForm mform) {
form = UI.formHeader(this);
toolkit = mform.getToolkit();
Composite body = UI.formBody(form, toolkit);
SashForm sash = new SashForm(body, SWT.VERTICAL);
UI.gridData(sash, true, true);
toolkit.adapt(sash);
inputTable = createTable(sash, true);
outputTable = createTable(sash, false);
body.setFocus();
form.reflow(true);
sortExchanges();
inputTable.setInput(getModel());
outputTable.setInput(getModel());
editor.onSaved(() -> {
inputTable.setInput(getModel());
outputTable.setInput(getModel());
});
}
@Override
public void initialize(IManagedForm form) {
super.initialize(form);
Composite sectionClient = new2ColumnComposite(getSection());
enableBorders(sectionClient);
tree = newTree(sectionClient);
final Composite buttonContainer = newButtonContainer(sectionClient);
addSetButton = newPushButton(buttonContainer, "Add Set",
"Click here to add another priority list.");
addButton = newPushButton(buttonContainer, S_ADD, "Click here to add a type");
removeButton = newPushButton(buttonContainer, S_REMOVE, S_REMOVE_TIP);
new Button(buttonContainer, SWT.PUSH).setVisible(false); // spacer
upButton = newPushButton(buttonContainer, S_UP,
"Click here to move the selected item up in the priority order.");
downButton = newPushButton(buttonContainer, S_DOWN,
"Click here to move the selected item down in the priority order");
exportButton = newPushButton(buttonContainer, S_EXPORT, S_EXPORT_TIP);
toolkit.paintBordersFor(sectionClient);
}
@Override
public void initialize(IManagedForm form) {
super.initialize(form);
((GridData) this.getSection().getLayoutData()).grabExcessVerticalSpace = false;
Composite sectionClient = new2ColumnComposite(this.getSection());
((GridData) sectionClient.getLayoutData()).grabExcessVerticalSpace = false;
// FrameworkImplementation choose, 2 radio buttons
if (isAeDescriptor() || isCasConsumerDescriptor()) {
toolkit.createLabel(sectionClient, "Implementation Language").setToolTipText(
"Choose the implementation language here.");
Composite buttons = new2ColumnComposite(sectionClient);
cppButton = newRadioButton(buttons, "C/C++", "C/C++", NOT_SELECTED);
javaButton = newRadioButton(buttons, "Java", "Java", SELECTED);
// DescriptorType choose, 2 radio buttons
toolkit.createLabel(sectionClient, "Engine Type").setToolTipText(
"Choose the type of the engine here.");
buttons = new2ColumnComposite(sectionClient);
primitiveButton = newRadioButton(buttons, "Primitive", S_, SELECTED);
aggregateButton = newRadioButton(buttons, "Aggregate", S_, NOT_SELECTED);
}
}
public static ScrolledForm formHeader(IManagedForm mform, String title, Image image) {
ScrolledForm form = mform.getForm();
FormToolkit tk = mform.getToolkit();
tk.getHyperlinkGroup().setHyperlinkUnderlineMode(
HyperlinkSettings.UNDERLINE_HOVER);
if (title != null)
form.setText(title);
if (image != null)
form.setImage(image);
tk.decorateFormHeading(form.getForm());
return form;
}
@Override
protected void createFormContent(IManagedForm mform) {
ScrolledForm form = UI.formHeader(mform, M.CommitChangesToRepository);
FormToolkit toolkit = mform.getToolkit();
Composite body = form.getBody();
body.setLayout(new GridLayout());
toolkit.paintBordersFor(body);
UI.gridData(body, true, true);
createCommitMessage(body, toolkit);
createModelViewer(body, toolkit);
form.reflow(true);
viewer.setInput(Collections.singleton(node));
viewer.setSelection(initialSelection);
}
@Override
protected void createFormContent(IManagedForm mform) {
ScrolledForm form = mform.getForm();
Composite comp = form.getBody();
comp.setLayout(new FillLayout());
Browser browser = new Browser(comp, SWT.NONE);
browser.setJavascriptEnabled(true);
// handles link clicks and opens them in the browser
UI.bindFunction(browser, "onOpenLink", (args) -> {
if (args == null || args.length == 0)
return null;
Object s = args[0];
if (!(s instanceof String))
return null;
Desktop.browse(s.toString());
return null;
});
// handles click on the "native library hint"
UI.bindFunction(browser, "onLibHintClick", (args) -> {
LibraryDownload.open();
return null;
});
// set the start page configuration
UI.onLoaded(browser, HtmlFolder.getUrl("home.html"), () -> {
HashMap<String, Object> config = new HashMap<>();
config.put("version", getVersion());
String lang = AppArg.get("nl");
config.put("lang", Strings.nullOrEmpty(lang) ? "en" : lang);
config.put("showLibHint", !Julia.isWithUmfpack());
String json = new Gson().toJson(config);
browser.execute("setData(" + json + ")");
});
}
@Override
protected void createUI(IManagedForm managedForm) {
Composite body = managedForm.getForm().getBody();
body.setLayout(FormLayoutFactory.createFormGridLayout(true, 2));
createLeftContent(body);
// createRightContent(body);
}
@Override
protected void createUI(IManagedForm managedForm) {
Composite body = managedForm.getForm().getBody();
body.setLayout(FormLayoutFactory.createFormTableWrapLayout(true, 2));
createLeftContent(body);
createRightContent(body);
}
@Override
protected void createUI(IManagedForm managedForm) {
Composite body = managedForm.getForm().getBody();
body.setLayout(FormLayoutFactory.createFormGridLayout(true, 2));
createLeftContent(body);
createRightContent(body);
updateButtons();
}
@Override
protected void createFormContent(IManagedForm mform) {
ScrolledForm form = UI.formHeader(mform,
Labels.name(setup.productSystem),
Images.get(result));
FormToolkit toolkit = mform.getToolkit();
Composite body = UI.formBody(form, toolkit);
createGroupingSection(toolkit, body);
resultSection = new GroupResultSection(groups, result);
resultSection.render(body, toolkit);
form.reflow(true);
}
@Override
protected void createFormContent(IManagedForm managedForm) {
form = UI.formHeader(this);
toolkit = managedForm.getToolkit();
Composite body = UI.formBody(form, toolkit);
InfoSection infoSection = new InfoSection(getEditor());
infoSection.render(body, toolkit);
createAdditionalInfo(infoSection, body);
body.setFocus();
form.reflow(true);
}
@Override
protected void createFormContent(IManagedForm mform) {
ScrolledForm form = UI.formHeader(this);
FormToolkit tk = mform.getToolkit();
Composite body = UI.formBody(form, tk);
InfoSection info = new InfoSection(getEditor());
info.render(body, tk);
createIndicatorTable(tk, body);
body.setFocus();
form.reflow(true);
}
@Override
protected void createFormContent(IManagedForm mform) {
String message = M.CouldNotAllocateMemoryError;
FormToolkit toolkit = mform.getToolkit();
mform.getForm().setText(M.OutOfMemory);
Composite comp = UI.formBody(mform.getForm(), mform.getToolkit());
UI.gridLayout(comp, 1);
Label label = toolkit.createLabel(comp, message, SWT.WRAP);
UI.gridData(label, true, false);
Hyperlink link = UI.formLink(comp, toolkit, "Open preference dialog");
Controls.onClick(link, e -> openPreferences());
}
/**
* Provides a Plant View page with a single {@link PlantApplication} for use
* with RELAP-7.
*/
private void addPlantPage() {
// Do not add more than one plant page.
if (findPage(PLANT_PAGE_ID) == null) {
// Add a page with a plant view.
try {
addPage(new ICEFormPage(this, PLANT_PAGE_ID, "Plant View") {
@Override
protected void createFormContent(IManagedForm managedForm) {
// The plant view should consume the whole page.
Section section;
FormToolkit toolkit = managedForm.getToolkit();
// Set up the overall layout (FillLayout).
Composite body = managedForm.getForm().getBody();
body.setLayout(new FillLayout());
// Create a Section for the plant view.
section = toolkit.createSection(body,
ExpandableComposite.NO_TITLE
| ExpandableComposite.EXPANDED);
populatePlantViewSection(section, toolkit);
// No layout data to set for FillLayouts.
return;
}
});
} catch (PartInitException e) {
logger.error(getClass().getName() + " Exception!", e);
}
}
return;
}