private OperatorMenu createDefaultMenuBar() { return new OperatorMenu(getJDialog(), operatorDescriptor, parameterSupport, getAppContext(), getHelpID()); }
private DomElement readXml(Reader reader) throws IOException { try (BufferedReader br = new BufferedReader(reader)) { StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); line = br.readLine(); } return new XppDomElement(createDom(sb.toString())); } }
@Override public void actionPerformed(ActionEvent event) { showInformationDialog("About " + getOperatorName(), new JLabel(getOperatorAboutText())); } }
String getOperatorAboutText() { return makeHtmlConform(String.format("" + "<html>" + "<h2>%s Operator</h2>" + "<table>" + "<tr><td><b>Name:</b></td><td><code>%s</code></td></tr>" + "<tr><td><b>Version:</b></td><td>%s</td></tr>" + "<tr><td><b>Full name:</b></td><td><code>%s</code></td></tr>" + "<tr><td><b>Description:</b></td><td>%s</td></tr>" + "<tr><td><b>Authors:</b></td><td>%s</td></tr>" + "<tr><td><b>Copyright:</b></td><td>%s</td></tr></table></html>", getOperatorName(), getOperatorName(), opDescriptor.getVersion(), opDescriptor.getName(), opDescriptor.getDescription(), opDescriptor.getAuthors(), opDescriptor.getCopyright() )); }
public CollocationDialog(AppContext appContext) { super(appContext, "Collocation", ID_APPLY_CLOSE, HELP_ID); final OperatorSpi operatorSpi = GPF.getDefaultInstance().getOperatorSpiRegistry().getOperatorSpi(CollocateOp.Spi.class.getName()); parameterSupport = new OperatorParameterSupport(operatorSpi.getOperatorDescriptor()); OperatorMenu operatorMenu = new OperatorMenu(this.getJDialog(), operatorSpi.getOperatorDescriptor(), parameterSupport, appContext, HELP_ID); getJDialog().setJMenuBar(operatorMenu.createDefaultMenu()); form = new CollocationForm(parameterSupport.getPropertySet(), getTargetProductSelector(), appContext); }
@Override public int show() { this.ioParametersPanel.initSourceProductSelectors(); if (this.form == null) { initForm(); if (getJDialog().getJMenuBar() == null) { OperatorMenu operatorMenu = createDefaultMenuBar(); getJDialog().setJMenuBar(operatorMenu.createDefaultMenu()); } } setContent(this.form); return super.show(); }
@Test public void testOperatorAboutText() throws Exception { DefaultAppContext appContext = new DefaultAppContext("test"); final OperatorMenu support = new OperatorMenu(null, testOpSpi.getOperatorDescriptor(), null, appContext, ""); assertEquals("Tester", support.getOperatorName()); String operatorDescription = support.getOperatorAboutText(); assertTrue(operatorDescription.length() > 80); }
@Test public void testEscapingXmlParameters() throws Exception { DefaultDomElement domElement = new DefaultDomElement("parameter"); String unescapedString = "12 < 13 && 56 > 42 & \"true\" + 'a name'"; String escapedString = "12 < 13 && 56 > 42 & "true" + 'a name'"; domElement.addChild(new DefaultDomElement("expression", unescapedString)); DefaultDomElement withAttribute = new DefaultDomElement("withAttribute"); withAttribute.setAttribute("attrib", unescapedString); domElement.addChild(withAttribute); OperatorMenu.escapeXmlElements(domElement); assertEquals(escapedString, domElement.getChild("expression").getValue()); assertEquals(escapedString, domElement.getChild("withAttribute").getAttribute("attrib")); String xmlString = domElement.toXml(); XppDom readDomElement = OperatorMenu.createDom(xmlString); assertEquals(unescapedString, readDomElement.getChild("expression").getValue()); assertEquals(unescapedString, readDomElement.getChild("withAttribute").getAttribute("attrib")); } }
@Override public void actionPerformed(ActionEvent event) { JFileChooser fileChooser = new JFileChooser(); final FileNameExtensionFilter parameterFileFilter = createParameterFileFilter(); fileChooser.addChoosableFileFilter(parameterFileFilter); fileChooser.setFileFilter(parameterFileFilter); fileChooser.setDialogTitle(TITLE); fileChooser.setDialogType(JFileChooser.SAVE_DIALOG); applyCurrentDirectory(fileChooser); int response = fileChooser.showDialog(parentComponent, "Save"); if (JFileChooser.APPROVE_OPTION == response) { try { preserveCurrentDirectory(fileChooser); File selectedFile = fileChooser.getSelectedFile(); selectedFile = FileUtils.ensureExtension(selectedFile, "." + parameterFileFilter.getExtensions()[0]); DomElement domElement = parameterSupport.toDomElement(); escapeXmlElements(domElement); String xmlString = domElement.toXml(); writeToFile(xmlString, selectedFile); } catch (Exception e) { Debug.trace(e); Dialogs.showError(TITLE, "Could not load parameters.\n" + e.getMessage()); } } }
@Override public void actionPerformed(ActionEvent event) { String parameterXml; try { DomElement domElement = parameterSupport.toDomElement(); parameterXml = domElement.toXml(); } catch (Exception e) { Debug.trace(e); Dialogs.showError(TITLE, "Failed to convert parameters to XML." + e.getMessage()); return; } JTextArea textArea = new JTextArea(parameterXml); textArea.setEditable(false); JScrollPane textAreaScrollPane = new JScrollPane(textArea); textAreaScrollPane.setPreferredSize(new Dimension(360, 360)); showInformationDialog(getOperatorName() + " Parameters", textAreaScrollPane); }
private void initialize(ToolAdapterOperatorDescriptor descriptor) { //this.operatorDescriptor = new ToolAdapterOperatorDescriptor(descriptor); this.operatorDescriptor = descriptor; //add paraeters of template parameters artificiallyAddedParams = new ArrayList<>(); Arrays.stream(this.operatorDescriptor.getToolParameterDescriptors().toArray()).filter(p -> ((ToolParameterDescriptor)p).isTemplateParameter()). forEach(p -> artificiallyAddedParams.addAll(((TemplateParameterDescriptor)p).getParameterDescriptors())); this.operatorDescriptor.getToolParameterDescriptors().addAll(artificiallyAddedParams); this.parameterSupport = new OperatorParameterSupport(this.operatorDescriptor); Arrays.stream(this.operatorDescriptor.getToolParameterDescriptors().toArray()). filter(p -> ToolAdapterConstants.FOLDER_PARAM_MASK.equals(((ToolParameterDescriptor)p).getParameterType())). forEach(p -> parameterSupport.getPropertySet().getProperty(((ToolParameterDescriptor)p).getName()).getDescriptor().setAttribute("directory", true)); form = new ToolExecutionForm(appContext, this.operatorDescriptor, parameterSupport.getPropertySet(), getTargetProductSelector()); OperatorMenu operatorMenu = new OperatorMenu(this.getJDialog(), this.operatorDescriptor, parameterSupport, appContext, descriptor.getHelpID() != null ? descriptor.getHelpID() : helpID); getJDialog().setJMenuBar(operatorMenu.createDefaultMenu()); EscapeAction.register(getJDialog()); this.getJDialog().addWindowListener(new WindowAdapter() { public void windowOpened(WindowEvent e) {form.refreshDimension();} }); this.getJDialog().addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) {form.refreshDimension();} }); this.getJDialog().setMinimumSize(new Dimension(250, 250)); }
@Override public int show() { if (form == null) { initForm(); if (getJDialog().getJMenuBar() == null) { final OperatorMenu operatorMenu = createDefaultMenuBar(); getJDialog().setJMenuBar(operatorMenu.createDefaultMenu()); } } ioParametersPanel.initSourceProductSelectors(); setContent(form); return super.show(); }
static void escapeXmlElements(DomElement domElement) { domElement.setValue(StringEscapeUtils.escapeXml(domElement.getValue())); String[] attributeNames = domElement.getAttributeNames(); for (String attributeName : attributeNames) { domElement.setAttribute(attributeName, StringEscapeUtils.escapeXml(domElement.getAttribute(attributeName))); } DomElement[] children = domElement.getChildren(); for (DomElement child : children) { escapeXmlElements(child); } }
ReprojectionDialog(boolean orthorectify, final String title, final String helpID, AppContext appContext) { super(appContext, title, ID_APPLY_CLOSE, helpID); form = new ReprojectionForm(getTargetProductSelector(), orthorectify, appContext); final OperatorSpi operatorSpi = GPF.getDefaultInstance().getOperatorSpiRegistry().getOperatorSpi(OPERATOR_NAME); ParameterUpdater parameterUpdater = new ReprojectionParameterUpdater(); OperatorParameterSupport parameterSupport = new OperatorParameterSupport(operatorSpi.getOperatorDescriptor(), null, null, parameterUpdater); OperatorMenu operatorMenu = new OperatorMenu(this.getJDialog(), operatorSpi.getOperatorDescriptor(), parameterSupport, appContext, helpID); getJDialog().setJMenuBar(operatorMenu.createDefaultMenu()); }
private OperatorMenu createDefaultMenuBar() { return new OperatorMenu(getJDialog(), operatorDescriptor, parameterSupport, getAppContext(), getHelpID()); }
@Override public int show() { ioParametersPanel.initSourceProductSelectors(); if (form == null) { initForm(); if (getJDialog().getJMenuBar() == null) { final OperatorMenu operatorMenu = createDefaultMenuBar(); getJDialog().setJMenuBar(operatorMenu.createDefaultMenu()); } } setContent(form); return super.show(); }
public SpectralUnmixingDialog(AppContext appContext) { super(appContext, TITLE, ID_APPLY_CLOSE, HELP_ID); ParameterUpdater parameterUpdater = new ParameterUpdater() { @Override public void handleParameterSaveRequest(Map<String, Object> parameterMap) { updateParameterMap(parameterMap); } @Override public void handleParameterLoadRequest(Map<String, Object> parameterMap) { updateEndmemberFormModel(parameterMap); } }; final OperatorSpi operatorSpi = GPF.getDefaultInstance().getOperatorSpiRegistry().getOperatorSpi(SpectralUnmixingOp.Spi.class.getName()); parameterSupport = new OperatorParameterSupport(operatorSpi.getOperatorDescriptor(), null, null, parameterUpdater); form = new SpectralUnmixingForm(appContext, parameterSupport.getPropertySet(), getTargetProductSelector()); OperatorMenu operatorMenu = new OperatorMenu(this.getJDialog(), operatorSpi.getOperatorDescriptor(), parameterSupport, appContext, HELP_ID); getJDialog().setJMenuBar(operatorMenu.createDefaultMenu()); }
private OperatorMenu createDefaultMenuBar() { return new OperatorMenu(getJDialog(), operatorDescriptor, parameterSupport, getAppContext(), getHelpID()); }
@Override public int show() { ioParametersPanel.initSourceProductSelectors(); if (form == null) { initForm(); if (getJDialog().getJMenuBar() == null) { final OperatorMenu operatorMenu = createDefaultMenuBar(); getJDialog().setJMenuBar(operatorMenu.createDefaultMenu()); } } setContent(form); return super.show(); }
parameterMap, this); final OperatorMenu operatorMenu = new OperatorMenu(this.getJDialog(), operatorSpi.getOperatorDescriptor(), parameterSupport, appContext, getHelpID()); getJDialog().setJMenuBar(operatorMenu.createDefaultMenu());