/** * Diese Methode erledigt den eigentlichen Aufbau der Seite. Here we create the contents of the * preference page */ @SuppressWarnings("unchecked") @Override protected Control createContents(final Composite parent) { Composite ret = new Composite(parent, SWT.NONE); ret.setLayout(new GridLayout()); ctabs = new CTabFolder(ret, SWT.NONE); ctabs.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); ctabs.setLayout(new FillLayout()); setup = Messwert.getSetup(); fields = setup.getMap("Befunde"); // $NON-NLS-1$ names = (String) fields.get("names"); // $NON-NLS-1$ if (!StringTool.isNothing(names)) { for (String f : names.split(Messwert.SETUP_SEPARATOR)) { CTabItem ci = new CTabItem(ctabs, SWT.NONE); ci.setText(f); PrefsPage fp = new PrefsPage(ctabs, fields, f); ci.setControl(fp); } } ctabs.setSelection(0); lastIDX = 0; ctabs.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (lastIDX != -1) { flush(lastIDX); lastIDX = ctabs.getSelectionIndex(); } } }); Composite cButtons = new Composite(ret, SWT.NONE); cButtons.setLayout(new FillLayout()); Button bAdd = new Button(cButtons, SWT.PUSH); bAdd.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { InputDialog id = new InputDialog( getShell(), Messages.getString("BefundePrefs.enterNameCaption"), Messages.getString("BefundePrefs.enterNameMessage"), "", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (id.open() == Dialog.OK) { String name = id.getValue(); if (StringTool.isNothing(names)) { names = name; } else { names += Messwert.SETUP_SEPARATOR + name; } fields.put("names", names); // $NON-NLS-1$ CTabItem ci = new CTabItem(ctabs, SWT.NONE); ci.setText(name); PrefsPage fp = new PrefsPage(ctabs, fields, name); ci.setControl(fp); ctabs.setSelection(ci); } } }); bAdd.setText(Messages.getString("BefundePrefs.add")); // $NON-NLS-1$ Button bRemove = new Button(cButtons, SWT.PUSH); bRemove.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { CTabItem ci = ctabs.getSelection(); if (ci != null) { PrefsPage pp = (PrefsPage) ci.getControl(); if (pp.remove()) { names = names.replaceFirst(ci.getText(), ""); // $NON-NLS-1$ names = names.replaceAll( Messwert.SETUP_SEPARATOR + Messwert.SETUP_SEPARATOR, Messwert.SETUP_SEPARATOR); names.replaceFirst(Messwert.SETUP_SEPARATOR + "$", ""); // $NON-NLS-1$ //$NON-NLS-2$ names = names.replaceFirst( "^" + Messwert.SETUP_SEPARATOR, ""); // $NON-NLS-1$ //$NON-NLS-2$ fields.put("names", names); // $NON-NLS-1$ lastIDX = -1; ci.dispose(); ctabs.setSelection(0); } } } }); bRemove.setText(Messages.getString("BefundePrefs.deleteText")); // $NON-NLS-1$ if (!Hub.acl.request(ACLContributor.DELETE_PARAM)) { bRemove.setEnabled(false); } return ret; }