private void setData() { chkExtractStandalone.setSelection(params.getExtractStandalone()); rdExtractAllPairs.setSelection(params.getExtractAllPairs()); rdDontExtractPairs.setSelection(!params.getExtractAllPairs()); edExceptions.setText(params.getExceptions() == null ? "" : params.getExceptions()); chkUseCodeFinder.setSelection(params.getUseCodeFinder()); pnlCodeFinder.setRules(params.getCodeFinderData()); updateInlineCodes(); pnlCodeFinder.updateDisplay(); }
private boolean saveData() { if (chkUseCodeFinder.getSelection()) { if (pnlCodeFinder.getRules() == null) { return false; } else { params.setCodeFinderData(pnlCodeFinder.getRules()); } } String tmp = checkExceptionsSyntax(); if (tmp != null) { edExceptions.selectAll(); edExceptions.setFocus(); Dialogs.showError(shell, tmp, null); return false; } params.setUseCodeFinder(chkUseCodeFinder.getSelection()); params.setExceptions(edExceptions.getText()); params.setExtractStandalone(chkExtractStandalone.getSelection()); params.setExtractAllPairs(rdExtractAllPairs.getSelection()); return true; }
private void create(Shell parent, boolean readOnly) { shell.setText(Res.getString("EditorCaption")); if (parent != null) shell.setImage(parent.getImage()); GridLayout layTmp = new GridLayout(); layTmp.marginBottom = 0; layTmp.verticalSpacing = 0; shell.setLayout(layTmp); TabFolder tfTmp = new TabFolder(shell, SWT.NONE); GridData gdTmp = new GridData(GridData.FILL_BOTH); tfTmp.setLayoutData(gdTmp); // --- Options tab Composite cmpTmp = new Composite(tfTmp, SWT.NONE); layTmp = new GridLayout(); cmpTmp.setLayout(layTmp); Group grpTmp = new Group(cmpTmp, SWT.NONE); layTmp = new GridLayout(); grpTmp.setLayout(layTmp); grpTmp.setText(Res.getString("grpStandaloneStrings")); gdTmp = new GridData(GridData.FILL_HORIZONTAL); grpTmp.setLayoutData(gdTmp); chkExtractStandalone = new Button(grpTmp, SWT.CHECK); chkExtractStandalone.setText(Res.getString("chkExtractStandalone")); grpTmp = new Group(cmpTmp, SWT.NONE); grpTmp.setLayout(new GridLayout()); grpTmp.setText(Res.getString("grpKeyValuePairs")); gdTmp = new GridData(GridData.FILL_HORIZONTAL); grpTmp.setLayoutData(gdTmp); rdExtractAllPairs = new Button(grpTmp, SWT.RADIO); rdExtractAllPairs.setText(Res.getString("rdExtractAllPairs")); rdDontExtractPairs = new Button(grpTmp, SWT.RADIO); rdDontExtractPairs.setText(Res.getString("rdDontExtractPairs")); Label label = new Label(grpTmp, SWT.NONE); label.setText(Res.getString("stExceptions")); edExceptions = new Text(grpTmp, SWT.BORDER); gdTmp = new GridData(GridData.FILL_HORIZONTAL); edExceptions.setLayoutData(gdTmp); TabItem tiTmp = new TabItem(tfTmp, SWT.NONE); tiTmp.setText(Res.getString("tabOptions")); tiTmp.setControl(cmpTmp); // --- Inline tab cmpTmp = new Composite(tfTmp, SWT.NONE); layTmp = new GridLayout(); cmpTmp.setLayout(layTmp); chkUseCodeFinder = new Button(cmpTmp, SWT.CHECK); chkUseCodeFinder.setText("Has inline codes as defined below:"); chkUseCodeFinder.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateInlineCodes(); }; }); pnlCodeFinder = new InlineCodeFinderPanel(cmpTmp, SWT.NONE); pnlCodeFinder.setLayoutData(new GridData(GridData.FILL_BOTH)); tiTmp = new TabItem(tfTmp, SWT.NONE); tiTmp.setText("Inline Codes"); tiTmp.setControl(cmpTmp); // --- Output tab /*cmpTmp = new Composite(tfTmp, SWT.NONE); layTmp = new GridLayout(); cmpTmp.setLayout(layTmp); grpTmp = new Group(cmpTmp, SWT.NONE); layTmp = new GridLayout(); grpTmp.setLayout(layTmp); grpTmp.setText(Res.getString("grpExtendedChars")); gdTmp = new GridData(GridData.FILL_HORIZONTAL); grpTmp.setLayoutData(gdTmp); chkEscapeExtendedChars = new Button(grpTmp, SWT.CHECK); chkEscapeExtendedChars.setText(Res.getString("chkEscapeExtendedChars")); tiTmp = new TabItem(tfTmp, SWT.NONE); tiTmp.setText(Res.getString("tabOutput")); tiTmp.setControl(cmpTmp);*/ // --- Dialog-level buttons SelectionAdapter OKCancelActions = new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { result = false; if (e.widget.getData().equals("h")) { if (help != null) help.showWiki("JSON Filter"); return; } if (e.widget.getData().equals("o")) { if (!saveData()) return; result = true; } shell.close(); }; }; pnlActions = new OKCancelPanel(shell, SWT.NONE, OKCancelActions, true); gdTmp = new GridData(GridData.FILL_HORIZONTAL); pnlActions.setLayoutData(gdTmp); pnlActions.btOK.setEnabled(!readOnly); if (!readOnly) { shell.setDefaultButton(pnlActions.btOK); } shell.pack(); Rectangle Rect = shell.getBounds(); shell.setMinimumSize(Rect.width, Rect.height); Dialogs.centerWindow(shell, parent); setData(); }
private void updateInlineCodes() { pnlCodeFinder.setEnabled(chkUseCodeFinder.getSelection()); }