Example usage for org.eclipse.jface.dialogs IDialogSettings getName

List of usage examples for org.eclipse.jface.dialogs IDialogSettings getName

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogSettings getName.

Prototype

String getName();

Source Link

Document

Returns the IDialogSettings name.

Usage

From source file:com.microsoft.tfs.client.common.ui.framework.dialog.DialogSettingsHelper.java

License:Open Source License

private static StoredDialogStatistics createStatistics(final IDialogSettings settings) {
    final String settingsKey = settings.getName();

    Point origin = null;// w  w w . j a  va  2s . c  o m
    try {
        origin = new Point(settings.getInt(DIALOG_ORIGIN_X), settings.getInt(DIALOG_ORIGIN_Y));
    } catch (final NumberFormatException ex) {

    }

    Point size = null;
    try {
        size = new Point(settings.getInt(DIALOG_WIDTH), settings.getInt(DIALOG_HEIGHT));
    } catch (final NumberFormatException ex) {

    }

    Date since = null;
    final String sinceValue = settings.get(SINCE);
    if (sinceValue != null) {
        try {
            final SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT);
            since = formatter.parse(sinceValue);
        } catch (final ParseException ex) {

        }
    }

    int views = -1;
    long accumulatedOpenTimeMs = -1;
    int timeCounts = -1;

    try {
        views = settings.getInt(VIEWS);
    } catch (final NumberFormatException ex) {

    }

    try {
        accumulatedOpenTimeMs = settings.getLong(ACCUMULATED_OPEN_TIME);
    } catch (final NumberFormatException ex) {

    }

    try {
        timeCounts = settings.getInt(TIME_COUNTS);
    } catch (final NumberFormatException ex) {

    }

    long averageOpenTimeMs = -1;

    if (accumulatedOpenTimeMs != -1 && timeCounts != -1) {
        averageOpenTimeMs = accumulatedOpenTimeMs / timeCounts;
    }

    return new StoredDialogStatistics(settingsKey, origin, size, since, views, accumulatedOpenTimeMs,
            timeCounts, averageOpenTimeMs);
}

From source file:ejs.base.settings.DialogSettingsWrapper.java

License:Open Source License

@Override
public void addSection(IDialogSettings section) {
    if (!(section instanceof DialogSettingsWrapper))
        throw new IllegalArgumentException();

    settings.addSection(section.getName()).mergeFrom(((DialogSettingsWrapper) section).settings);

}

From source file:ext.org.eclipse.jdt.internal.ui.javadocexport.RecentSettingsStore.java

License:Open Source License

/**
* Method creates a list of data structes that contain
* The destination, antfile location and the list of library/project references for every
* project in the workspace.Defaults are created for new project.
 * @param settings the settings to load from
*/// w  w  w.ja  va2s.  com
private void load(IDialogSettings settings) {

    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

    IDialogSettings projectsSection = settings.getSection(SECTION_PROJECTS);
    if (projectsSection != null) {
        IDialogSettings[] sections = projectsSection.getSections();
        for (int i = 0; i < sections.length; i++) {
            IDialogSettings curr = sections[i];
            String projectName = curr.getName();
            IProject project = root.getProject(projectName);
            //make sure project has not been removed
            if (project.isAccessible()) {
                IJavaProject javaProject = JavaCore.create(project);
                if (!fPerProjectSettings.containsKey(javaProject)) {
                    String hrefs = curr.get(HREF);
                    if (hrefs == null) {
                        hrefs = ""; //$NON-NLS-1$
                    }
                    String destdir = curr.get(DESTINATION);
                    if (destdir == null || destdir.length() == 0) {
                        destdir = getDefaultDestination(javaProject);
                    }
                    String antpath = curr.get(ANTPATH);
                    if (antpath == null || antpath.length() == 0) {
                        antpath = getDefaultAntPath(javaProject);
                    }
                    ProjectData data = new ProjectData();
                    data.setDestination(destdir);
                    data.setAntpath(antpath);
                    data.setHRefs(hrefs);
                    if (!fPerProjectSettings.containsValue(javaProject))
                        fPerProjectSettings.put(javaProject, data);
                }
            }
        }
    }
    //finds projects in the workspace that have been added since the
    //last time the wizard was run
    IProject[] projects = root.getProjects();
    for (int i = 0; i < projects.length; i++) {
        IProject project = projects[i];
        if (project.isAccessible()) {
            IJavaProject curr = JavaCore.create(project);
            if (!fPerProjectSettings.containsKey(curr)) {
                ProjectData data = new ProjectData();
                data.setDestination(getDefaultDestination(curr));
                data.setAntpath(getDefaultAntPath(curr));
                data.setHRefs(""); //$NON-NLS-1$
                fPerProjectSettings.put(curr, data);
            }
        }
    }
}

From source file:gov.nasa.ensemble.common.ui.DialogUtils.java

License:Open Source License

public static void loadDialogSettingsFromPreferences(IPreferenceStore store, IDialogSettings settings) {
    String settingsString = store.getString(settings.getName());
    if (settingsString != null) {
        StringReader reader = new StringReader(settingsString);
        try {//from  w w w.  j av  a 2  s .co  m
            settings.load(reader);
        } catch (IOException e) {
            Logger.getLogger(DialogUtils.class)
                    .error("Couldn't load settings from preferences: " + settings.getName());
        } finally {
            reader.close();
        }
    }
}

From source file:gov.nasa.ensemble.common.ui.DialogUtils.java

License:Open Source License

public static void saveDialogSettingsToPreferences(IDialogSettings settings, IPreferenceStore store) {
    StringWriter writer = new StringWriter();
    try {/*from ww w  .j  av a  2s.com*/
        settings.save(writer);
    } catch (IOException e) {
        Logger.getLogger(DialogUtils.class)
                .error("Couldn't save settings to preferences: " + settings.getName());
        return;
    }
    store.setValue(settings.getName(), writer.toString());
}

From source file:gov.nasa.ensemble.common.ui.PickListSet.java

License:Open Source License

public PickListSet(IDialogSettings settings) {
    this.name = settings.getName();
    this.keys = Arrays.asList(settings.getArray(KEYS));
}

From source file:org.eclipse.rcptt.ctx.preferences.impl.DialogSettingsUtils.java

License:Open Source License

private static PrefNode convertDialogSettings(IDialogSettings settings) {
    List<PrefNode> childNodes = null;
    List<PrefData> data = null;

    IDialogSettings[] childs = settings.getSections();
    for (IDialogSettings child : childs) {
        PrefNode childNode = convertDialogSettings(child);
        if (childNode != null) {
            if (childNodes == null) {
                childNodes = new ArrayList<PrefNode>();
            }/*from w  w w.  j  a  v  a 2 s . c o  m*/
            childNodes.add(childNode);
        }
    }

    Object[] itemKeys = getItemKeys(settings);
    Object[] arrayItemKeys = getArrayItemKeys(settings);
    if (itemKeys.length > 0 || arrayItemKeys.length > 0) {
        data = new ArrayList<PrefData>();

        for (Object key : itemKeys) {
            String itemKey = (String) key;
            StringPrefData stringData = PreferencesFactory.eINSTANCE.createStringPrefData();
            stringData.setKey(itemKey);
            String value = settings.get(itemKey);
            value = PrefUtils.encodeWorkspaceLocation(value);
            stringData.setValue(value);
            data.add(stringData);
        }

        for (Object key : arrayItemKeys) {
            String arrayItemKey = (String) key;
            ListPrefData listPrefData = PreferencesFactory.eINSTANCE.createListPrefData();
            listPrefData.setKey(arrayItemKey);
            String[] values = settings.getArray(arrayItemKey);
            for (String value : values) {
                value = PrefUtils.encodeWorkspaceLocation(value);
                listPrefData.getValues().add(value);
            }
            data.add(listPrefData);
        }
    }

    if (childNodes != null || data != null) {
        PrefNode prefNode = PreferencesFactory.eINSTANCE.createPrefNode();
        prefNode.setName(settings.getName());
        if (childNodes != null) {
            prefNode.getChilds().addAll(childNodes);
        }
        if (data != null) {
            prefNode.getData().addAll(data);
        }
        return prefNode;
    }
    return null;
}

From source file:org.eclipse.wst.jsdt.internal.ui.javadocexport.RecentSettingsStore.java

License:Open Source License

/**
* Method creates a list of data structes that contain
* The destination, antfile location and the list of library/project references for every
* project in the workspace.Defaults are created for new project.
*//*from  ww  w  .j  ava2 s  .  c  o  m*/
private void load(IDialogSettings settings) {

    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

    IDialogSettings projectsSection = settings.getSection(SECTION_PROJECTS);
    if (projectsSection != null) {
        IDialogSettings[] sections = projectsSection.getSections();
        for (int i = 0; i < sections.length; i++) {
            IDialogSettings curr = sections[i];
            String projectName = curr.getName();
            IProject project = root.getProject(projectName);
            //make sure project has not been removed
            if (project.isAccessible()) {
                IJavaScriptProject javaProject = JavaScriptCore.create(project);
                if (!fPerProjectSettings.containsKey(javaProject)) {
                    String hrefs = curr.get(HREF);
                    if (hrefs == null) {
                        hrefs = ""; //$NON-NLS-1$
                    }
                    String destdir = curr.get(DESTINATION);
                    if (destdir == null || destdir.length() == 0) {
                        destdir = getDefaultDestination(javaProject);
                    }
                    String antpath = curr.get(ANTPATH);
                    if (antpath == null || antpath.length() == 0) {
                        antpath = getDefaultAntPath(javaProject);
                    }
                    ProjectData data = new ProjectData();
                    data.setDestination(destdir);
                    data.setAntpath(antpath);
                    data.setHRefs(hrefs);
                    if (!fPerProjectSettings.containsValue(javaProject))
                        fPerProjectSettings.put(javaProject, data);
                }
            }
        }
    }
    //finds projects in the workspace that have been added since the
    //last time the wizard was run
    IProject[] projects = root.getProjects();
    for (int i = 0; i < projects.length; i++) {
        IProject project = projects[i];
        if (project.isAccessible()) {
            IJavaScriptProject curr = JavaScriptCore.create(project);
            if (!fPerProjectSettings.containsKey(curr)) {
                ProjectData data = new ProjectData();
                data.setDestination(getDefaultDestination(curr));
                data.setAntpath(getDefaultAntPath(curr));
                data.setHRefs(""); //$NON-NLS-1$
                fPerProjectSettings.put(curr, data);
            }
        }
    }
}

From source file:org.eclipsetrader.news.internal.ui.OpenNewsHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
    IWorkbenchSite site = HandlerUtil.getActiveSite(event);

    if (selection != null && !selection.isEmpty()) {
        for (Iterator<?> iter = selection.iterator(); iter.hasNext();) {
            Object target = iter.next();
            if (target instanceof IAdaptable) {
                target = ((IAdaptable) target).getAdapter(ISecurity.class);
            }/*from  w  w w .j a  v  a 2  s.c  o m*/
            if (target instanceof ISecurity) {
                ISecurity security = (ISecurity) target;
                try {
                    IStoreObject storeObject = (IStoreObject) security.getAdapter(IStoreObject.class);
                    IDialogSettings dialogSettings = Activator.getDefault()
                            .getDialogSettingsForView(storeObject.getStore().toURI());
                    site.getPage().showView(HeadLineViewer.VIEW_ID, dialogSettings.getName(),
                            IWorkbenchPage.VIEW_ACTIVATE);
                } catch (PartInitException e) {
                    Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0,
                            "Error opening news headlines for " + security.getName(), e); //$NON-NLS-1$
                    Activator.getDefault().getLog().log(status);
                }
            }
        }
    }

    return null;
}

From source file:org.eclipsetrader.ui.internal.ats.wizards.ScriptStrategyWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    final IRepository repository = namePage.getRepository();

    final ScriptStrategy resource = new ScriptStrategy(namePage.getScriptName());
    resource.setInstruments(instrumentsPage.getInstruments());
    resource.setBarsTimeSpan(barsPage.getValues());

    BundleContext bundleContext = UIActivator.getDefault().getBundle().getBundleContext();

    ServiceReference<IRepositoryService> serviceReference = bundleContext
            .getServiceReference(IRepositoryService.class);
    final IRepositoryService service = bundleContext.getService(serviceReference);

    service.runInService(new IRepositoryRunnable() {

        @Override//from   w  ww . j a v a2 s .  c  o  m
        public IStatus run(IProgressMonitor monitor) throws Exception {
            service.moveAdaptable(new IAdaptable[] { resource }, repository);
            return Status.OK_STATUS;
        }
    }, null);

    bundleContext.ungetService(serviceReference);

    IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
    try {
        IStoreObject storeObject = (IStoreObject) resource.getAdapter(IStoreObject.class);
        IDialogSettings dialogSettings = UIActivator.getDefault()
                .getDialogSettingsForView(storeObject.getStore().toURI());

        page.showView(ScriptEditor.VIEW_ID, dialogSettings.getName(), IWorkbenchPage.VIEW_ACTIVATE);
    } catch (PartInitException e) {
        Status status = new Status(IStatus.ERROR, UIActivator.PLUGIN_ID, 0, "Error opening script editor", e); //$NON-NLS-1$
        UIActivator.log(status);
    }

    return true;
}