Search in sources :

Example 36 with WorkbenchException

use of org.eclipse.ui.WorkbenchException in project jbosstools-hibernate by jbosstools.

the class OrmDiagram method loadFromFile.

public void loadFromFile(IPath path, boolean format) {
    fileLoadSuccessfull = false;
    FileInputStream fis = null;
    try {
        File file = new File(path.toOSString());
        if (file.exists()) {
            fis = new FileInputStream(file);
            if (format) {
                BufferedReader reader = new BufferedReader(// $NON-NLS-1$
                new InputStreamReader(fis, "utf-8"));
                try {
                    IMemento memento = XMLMemento.createReadRoot(reader);
                    loadState(memento);
                    fileLoadSuccessfull = true;
                } catch (WorkbenchException e) {
                    // $NON-NLS-1$
                    HibernateConsolePlugin.getDefault().logErrorMessage("Can't load layout of mapping.", e);
                }
            } else {
                Properties properties = new Properties();
                properties.load(fis);
                loadFromProperties(properties);
                fileLoadSuccessfull = true;
            }
        }
    } catch (IOException ex) {
        // $NON-NLS-1$
        HibernateConsolePlugin.getDefault().logErrorMessage("Can't load layout of mapping.", ex);
    } finally {
        if (fis != null) {
            try {
                fis.close();
            } catch (IOException e) {
            // ignore
            }
        }
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) WorkbenchException(org.eclipse.ui.WorkbenchException) Properties(java.util.Properties) IFile(org.eclipse.core.resources.IFile) File(java.io.File) FileInputStream(java.io.FileInputStream) IMemento(org.eclipse.ui.IMemento)

Example 37 with WorkbenchException

use of org.eclipse.ui.WorkbenchException in project erlide_eclipse by erlang.

the class FilteredModulesSelectionDialog method restoreDialog.

@Override
protected void restoreDialog(final IDialogSettings settings) {
    super.restoreDialog(settings);
    final String setting = settings.get(FilteredModulesSelectionDialog.WORKINGS_SET_SETTINGS);
    if (setting != null) {
        try {
            final IMemento memento = XMLMemento.createReadRoot(new StringReader(setting));
            workingSetFilterActionGroup.restoreState(memento);
        } catch (final WorkbenchException e) {
            StatusManager.getManager().handle(new Status(IStatus.ERROR, ErlideUIPlugin.PLUGIN_ID, IStatus.ERROR, "", // $NON-NLS-1$
            e));
        // don't do anything. Simply don't restore the settings
        }
    }
    addListFilter(workingSetFilter);
    applyFilter();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) StringReader(java.io.StringReader) WorkbenchException(org.eclipse.ui.WorkbenchException) IMemento(org.eclipse.ui.IMemento)

Aggregations

WorkbenchException (org.eclipse.ui.WorkbenchException)37 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)16 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)15 IPerspectiveDescriptor (org.eclipse.ui.IPerspectiveDescriptor)11 IMemento (org.eclipse.ui.IMemento)7 IOException (java.io.IOException)6 IWorkbench (org.eclipse.ui.IWorkbench)5 IRepositoryView (org.talend.repository.ui.views.IRepositoryView)5 StringReader (java.io.StringReader)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)4 CoreException (org.eclipse.core.runtime.CoreException)3 IStatus (org.eclipse.core.runtime.IStatus)3 Status (org.eclipse.core.runtime.Status)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)3 TreeViewer (org.eclipse.jface.viewers.TreeViewer)3 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)3 RepositoryNode (org.talend.repository.model.RepositoryNode)3 ProcessExplorerView (com.centurylink.mdw.plugin.designer.views.ProcessExplorerView)2 BufferedReader (java.io.BufferedReader)2