private void loadDefaultsClick(DialogAccess dlg) { updateStyleMaps(dlg); // Count styles that we will overwrite Config clean = ConverterFactory.createConverter(getMIMEType()).getConfig(); clean.readDefaultConfig(getDefaultConfigName()); int nCount = 0; int nFamilyCount = sFamilyNames.length; for (int i = 0; i < nFamilyCount; i++) { ComplexOption cleanMap = clean.getComplexOption(sFamilyNames[i] + "-map"); Map<String, String> displayNames = styleNameProvider.getDisplayNames(sOOoFamilyNames[i]); for (String sName : cleanMap.keySet()) { String sDisplayName = (displayNames != null && displayNames.containsKey(sName)) ? displayNames.get(sName) : ""; if (styleMap[i].containsKey(sDisplayName)) { nCount++; } } } // Display confirmation dialog boolean bConfirm = false; XDialog xDialog = getDialog(getDialogLibraryName() + ".LoadDefaults"); if (xDialog != null) { DialogAccess ldlg = new DialogAccess(xDialog); if (nCount > 0) { String sLabel = ldlg.getLabelText("OverwriteLabel"); sLabel = sLabel.replaceAll("%s", Integer.toString(nCount)); ldlg.setLabelText("OverwriteLabel", sLabel); } else { ldlg.setLabelText("OverwriteLabel", ""); } bConfirm = xDialog.execute() == ExecutableDialogResults.OK; xDialog.endExecute(); } // Do the replacement if (bConfirm) { for (int i = 0; i < nFamilyCount; i++) { ComplexOption cleanMap = clean.getComplexOption(sFamilyNames[i] + "-map"); Map<String, String> displayNames = styleNameProvider.getDisplayNames(sOOoFamilyNames[i]); copyStyles(cleanMap, styleMap[i], displayNames); } } // Force update of the user interface nCurrentFamily = -1; sCurrentStyleName = null; styleFamilyChange(dlg); }
// Method to display delete dialog protected boolean deleteItem(String sName) { XDialog xDialog = getDialog(getDialogLibraryName() + ".DeleteDialog"); if (xDialog != null) { DialogAccess ddlg = new DialogAccess(xDialog); String sLabel = ddlg.getLabelText("DeleteLabel"); sLabel = sLabel.replaceAll("%s", sName); ddlg.setLabelText("DeleteLabel", sLabel); boolean bDelete = xDialog.execute() == ExecutableDialogResults.OK; xDialog.endExecute(); return bDelete; } return false; }
private String newItem(Set<String> suggestions) { XDialog xDialog = getDialog(getDialogLibraryName() + ".NewDialog"); if (xDialog != null) { String[] sItems = Misc.sortStringSet(suggestions); DialogAccess ndlg = new DialogAccess(xDialog); ndlg.setListBoxStringItemList("Name", sItems); String sResult = null; if (xDialog.execute() == ExecutableDialogResults.OK) { DialogAccess dlg = new DialogAccess(xDialog); sResult = dlg.getTextFieldText("Name"); } xDialog.endExecute(); return sResult; } return null; }
public void close() throws Exception { XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xDialogContainer); // set the dialog invisible until it is executed xWindow.setVisible(false); Object oToolkit = xMultiComponentFactory.createInstanceWithContext( "com.sun.star.awt.Toolkit", xComponentContext); XWindowPeer xWindowParentPeer = ((XToolkit) UnoRuntime.queryInterface(XToolkit.class, oToolkit)).getDesktopWindow(); XToolkit xToolkit = (XToolkit) UnoRuntime.queryInterface(XToolkit.class, oToolkit); xDialogControl.createPeer(xToolkit, xWindowParentPeer); // the return value contains information about how the dialog has been closed XDialog xDialog = (XDialog) UnoRuntime.queryInterface(XDialog.class, xDialogControl); xDialog.endExecute(); }