Search in sources :

Example 1 with CatalogSet

use of org.eclipse.wst.xml.core.internal.catalog.CatalogSet in project webtools.sourceediting by eclipse.

the class AdvancedOptionsDialog method invokeImportDialog.

protected void invokeImportDialog() {
    SelectSingleFileDialog dialog = new SelectSingleFileDialog(getShell(), null, true);
    // $NON-NLS-1$ //$NON-NLS-2$
    String[] extensions = { ".xmlcatalog", ".xml" };
    dialog.addFilterExtensions(extensions);
    dialog.create();
    dialog.getShell().setText(XMLCatalogMessages.UI_LABEL_IMPORT_DIALOG_TITLE);
    dialog.setTitle(XMLCatalogMessages.UI_LABEL_IMPORT_DIALOG_HEADING);
    dialog.setMessage(XMLCatalogMessages.UI_LABEL_IMPORT_DIALOG_MESSAGE);
    dialog.setBlockOnOpen(true);
    int rc = dialog.open();
    if (rc == Window.OK) {
        IFile file = dialog.getFile();
        if (file != null) {
            String fileName = file.getLocation().toFile().toURI().toString();
            try {
                CatalogSet tempResourceSet = new CatalogSet();
                // $NON-NLS-1$
                ICatalog newCatalog = tempResourceSet.lookupOrCreateCatalog("temp", fileName);
                workingUserCatalog.addEntriesFromCatalog(newCatalog);
            } catch (Exception e) {
            // TODO... give error message
            }
        }
        close();
    }
}
Also used : SelectSingleFileDialog(org.eclipse.wst.common.ui.internal.dialogs.SelectSingleFileDialog) IFile(org.eclipse.core.resources.IFile) CatalogSet(org.eclipse.wst.xml.core.internal.catalog.CatalogSet) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)

Example 2 with CatalogSet

use of org.eclipse.wst.xml.core.internal.catalog.CatalogSet in project webtools.sourceediting by eclipse.

the class XMLCatalogPreferencePage method createContents.

/**
 * Creates preference page controls on demand.
 *
 * @param parent
 *            the parent for the preference page
 */
protected Control createContents(Composite parent) {
    // we create a working copy of the 'User Settings' for the Catalog
    // that we can modify
    CatalogSet tempCatalogSet = new CatalogSet();
    // $NON-NLS-1$ //$NON-NLS-2$
    workingUserCatalog = tempCatalogSet.lookupOrCreateCatalog("working", "");
    // TODO: add entries from the nested catalogs as well
    workingUserCatalog.addEntriesFromCatalog(userCatalog);
    workingUserCatalog.addListener(this);
    noDefaultAndApplyButton();
    Composite composite = new Composite(parent, SWT.NULL);
    // WorkbenchHelp.setHelp(composite, new
    // ControlContextComputer(composite,
    // XMLBuilderContextIds.XMLP_CATALOG_PAGE));
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    createCatalogEntriesView(composite);
    createCatalogDetailsView(composite);
    // createAdvancedButton(composite);
    // catalogEntriesView.updatePage();
    applyDialogFont(composite);
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) CatalogSet(org.eclipse.wst.xml.core.internal.catalog.CatalogSet)

Example 3 with CatalogSet

use of org.eclipse.wst.xml.core.internal.catalog.CatalogSet in project webtools.sourceediting by eclipse.

the class ImportXMLCatalogWizard method performFinish.

public boolean performFinish() {
    IFile file = importPage.getFile();
    if (file != null) {
        String fileName = file.getLocation().toFile().toURI().toString();
        try {
            CatalogSet tempResourceSet = new CatalogSet();
            // $NON-NLS-1$
            ICatalog newCatalog = tempResourceSet.lookupOrCreateCatalog("temp", fileName);
            workingUserCatalog.addEntriesFromCatalog(newCatalog);
            userCatalog.clear();
            userCatalog.addEntriesFromCatalog(workingUserCatalog);
            userCatalog.save();
        } catch (Exception e) {
            return false;
        }
    }
    return true;
}
Also used : IFile(org.eclipse.core.resources.IFile) CatalogSet(org.eclipse.wst.xml.core.internal.catalog.CatalogSet) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)

Example 4 with CatalogSet

use of org.eclipse.wst.xml.core.internal.catalog.CatalogSet in project webtools.sourceediting by eclipse.

the class XMLCorePlugin method getDefaultXMLCatalog.

public ICatalog getDefaultXMLCatalog() {
    if (catalogSet == null) {
        catalogSet = new CatalogSet();
        defaultCatalogFileStateLocation = getPluginStateLocation(Catalog.DEFAULT_CATALOG_FILE);
        catalogSet.putCatalogPersistenceLocation(DEFAULT_CATALOG_ID, defaultCatalogFileStateLocation);
        catalogSet.putCatalogPersistenceLocation(SYSTEM_CATALOG_ID, getPluginStateLocation(Catalog.SYSTEM_CATALOG_FILE));
        catalogSet.putCatalogPersistenceLocation(USER_CATALOG_ID, getPluginStateLocation(Catalog.USER_CATALOG_FILE));
    }
    return catalogSet.lookupOrCreateCatalog(DEFAULT_CATALOG_ID, defaultCatalogFileStateLocation);
}
Also used : CatalogSet(org.eclipse.wst.xml.core.internal.catalog.CatalogSet)

Example 5 with CatalogSet

use of org.eclipse.wst.xml.core.internal.catalog.CatalogSet in project webtools.sourceediting by eclipse.

the class SelectFromCatalogDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    // we create a working copy of the 'User Settings' for the Catalog
    // that we can modify
    CatalogSet tempCatalogSet = new CatalogSet();
    // $NON-NLS-1$ //$NON-NLS-2$
    workingUserCatalog = tempCatalogSet.lookupOrCreateCatalog("working", "");
    // TODO: add entries from the nested catalogs as well
    workingUserCatalog.addEntriesFromCatalog(userCatalog);
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout());
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = 500;
    composite.setLayoutData(gridData);
    createCatalogEntriesView(composite);
    createCatalogDetailsView(composite);
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) CatalogSet(org.eclipse.wst.xml.core.internal.catalog.CatalogSet)

Aggregations

CatalogSet (org.eclipse.wst.xml.core.internal.catalog.CatalogSet)5 IFile (org.eclipse.core.resources.IFile)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 ICatalog (org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)2 SelectSingleFileDialog (org.eclipse.wst.common.ui.internal.dialogs.SelectSingleFileDialog)1