Search in sources :

Example 6 with InstanceScope

use of org.eclipse.core.runtime.preferences.InstanceScope in project cubrid-manager by CUBRID.

the class CubridStatusMonitorInstance method saveSetting.

/**
	 * Save the info of StatusMonInstanceData relevant to key into preference
	 * 
	 * @param key the key relevant to saving instance of StatusMonInstanceData
	 */
public void saveSetting(String key) {
    synchronized (this) {
        StatusMonInstanceData data = map.get(key);
        ObjectOutputStream objectOutputStream;
        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
        try {
            objectOutputStream = new ObjectOutputStream(byteStream);
            objectOutputStream.writeObject(data);
            objectOutputStream.close();
            byte[] bytes = byteStream.toByteArray();
            IEclipsePreferences preference = new InstanceScope().getNode(CubridManagerUIPlugin.PLUGIN_ID);
            preference.putByteArray(key, bytes);
            preference.flush();
        } catch (Exception ex) {
            LOGGER.error(ex.getMessage());
        }
    }
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) BackingStoreException(org.osgi.service.prefs.BackingStoreException)

Example 7 with InstanceScope

use of org.eclipse.core.runtime.preferences.InstanceScope in project tmdm-studio-se by Talend.

the class TransformerMainPage method createCharacteristicsContent.

@Override
protected void createCharacteristicsContent(final FormToolkit toolkit, Composite topComposite) {
    try {
        initTransformer();
        descriptionComposite = toolkit.createComposite(topComposite, SWT.NONE);
        descriptionComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        descriptionComposite.setLayout(new GridLayout(3, false));
        // edit by ymli; fix the bug:0012024 Make Process descriptions multilingual.
        // description
        /*
             * Label descriptionLabel = toolkit.createLabel(descriptionComposite, "Description", SWT.NULL);
             * descriptionLabel.setLayoutData( new GridData(SWT.FILL,SWT.CENTER,false,true,1,1) ); descriptionText =
             * toolkit.createText(descriptionComposite, "",SWT.BORDER|SWT.MULTI); descriptionText.setLayoutData( new
             * GridData(SWT.FILL,SWT.FILL,true,true,1,1) ); ((GridData)descriptionText.getLayoutData()).minimumHeight =
             * 30; descriptionText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if
             * (refreshing) return; //commit as we go TransformerMainPage.this.comitting= true;
             * //((WSTransformerV2)getXObject().getWsObject()) transformer.setDescription(descriptionText.getText());
             * TransformerMainPage.this.comitting= false; //markDirtyWithoutCommit(); markDirtyWithoutCommit(); } });
             */
        desAntionComposite = new DescAnnotationComposite(Messages.TransformerMainPage_Description, // $NON-NLS-1$
        " ...", // $NON-NLS-1$
        toolkit, // $NON-NLS-1$
        descriptionComposite, this, false);
        desAntionComposite.getTextWidget().addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                if (refreshing) {
                    return;
                }
                TransformerMainPage.this.comitting = true;
                transformer.setDescription(desAntionComposite.getText());
                TransformerMainPage.this.comitting = false;
                markDirtyWithoutCommit();
            }
        });
        // make the Page window a DropTarget - we need to dispose it
        windowTarget = new DropTarget(this.getPartControl(), DND.DROP_MOVE);
        windowTarget.setTransfer(new Transfer[] { TextTransfer.getInstance() });
        windowTarget.addDropListener(new DCDropTargetListener());
        sequenceGroup = this.getNewSectionComposite(Messages.TransformerMainPage_StepsSequence);
        sequenceGroup.setLayout(new GridLayout(1, false));
        Composite sequenceComposite = toolkit.createComposite(sequenceGroup, SWT.NONE);
        sequenceComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        sequenceComposite.setLayout(new GridLayout(6, false));
        Label l3 = toolkit.createLabel(sequenceComposite, Messages.TransformerMainPage_StepDesc, SWT.NULL);
        l3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
        // $NON-NLS-1$
        stepText = toolkit.createText(sequenceComposite, "", SWT.BORDER | SWT.SINGLE);
        stepText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
        stepText.addKeyListener(new KeyListener() {

            public void keyPressed(KeyEvent e) {
            }

            public void keyReleased(KeyEvent e) {
                if (e.keyCode == 13) {
                    // enter
                    performAdd();
                    int index = stepsList.getItemCount() - 1;
                    performSelect(index);
                }
            }
        });
        // $NON-NLS-1$
        Button addStepButton = toolkit.createButton(sequenceComposite, "", SWT.PUSH);
        addStepButton.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, false, true, 1, 1));
        addStepButton.setToolTipText(Messages.TransformerMainPage_Add);
        addStepButton.setImage(ImageCache.getCreatedImage(EImage.ADD_OBJ.getPath()));
        addStepButton.addSelectionListener(new SelectionListener() {

            public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
            }

            public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                // commit as we go
                performAdd();
            }
        });
        stepsList = new List(sequenceComposite, SWT.V_SCROLL | SWT.BORDER);
        stepsList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1));
        ((GridData) stepsList.getLayoutData()).heightHint = 40;
        /*
             * DragSource stepsSource = new DragSource(stepsList,DND.DROP_MOVE); stepsSource.setTransfer(new
             * Transfer[]{TextTransfer.getInstance()}); stepsSource.addDragListener(new DCDragSourceListener());
             */
        stepsList.addSelectionListener(new SelectionListener() {

            public void widgetDefaultSelected(SelectionEvent e) {
                widgetSelected(e);
            }

            public void widgetSelected(SelectionEvent e) {
                performSelect(stepsList.getSelectionIndex());
            }
        });
        wrap.Wrap(this, stepsList);
        stepsList.addFocusListener(new FocusListener() {

            public void focusGained(FocusEvent e) {
                if (stepsList.getSelectionIndex() >= 0) {
                    refreshStep(stepsList.getSelectionIndex());
                    section.setVisible(true);
                }
            }

            public void focusLost(FocusEvent e) {
            }
        });
        Composite stepUpDownComposite = toolkit.createComposite(sequenceComposite, SWT.NONE);
        stepUpDownComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
        stepUpDownComposite.setLayout(new GridLayout(1, false));
        // $NON-NLS-1$
        Button stepUpButton = toolkit.createButton(stepUpDownComposite, "", SWT.PUSH | SWT.CENTER);
        stepUpButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
        stepUpButton.setImage(ImageCache.getCreatedImage(EImage.PREV_NAV.getPath()));
        stepUpButton.setToolTipText(Messages.TransformerMainPage_MoveUpTheItem);
        stepUpButton.addSelectionListener(new SelectionListener() {

            public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
            }

            public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                int index = TransformerMainPage.this.stepsList.getSelectionIndex();
                if (index > 0) {
                    // commit as we go
                    TransformerMainPage.this.comitting = true;
                    String val = TransformerMainPage.this.stepsList.getItem(index);
                    TransformerMainPage.this.stepsList.remove(index);
                    TransformerMainPage.this.stepsList.add(val, index - 1);
                    TransformerMainPage.this.stepsList.select(index - 1);
                    // (WSTransformerV2)getXObject().getWsObject();
                    WSTransformerV2 wsTransformer = transformer;
                    java.util.List<WSTransformerProcessStep> list = wsTransformer.getProcessSteps();
                    WSTransformerProcessStep spec = list.get(index);
                    list.remove(index);
                    list.add(index - 1, spec);
                    performSelect(index - 1);
                    TransformerMainPage.this.comitting = false;
                    TransformerMainPage.this.stepsList.forceFocus();
                    markDirtyWithoutCommit();
                }
            }
        });
        // $NON-NLS-1$
        Button stepDownButton = toolkit.createButton(stepUpDownComposite, "", SWT.PUSH | SWT.CENTER);
        stepDownButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
        stepDownButton.setImage(ImageCache.getCreatedImage(EImage.NEXT_NAV.getPath()));
        stepDownButton.setToolTipText(Messages.TransformerMainPage_MoveDownTheItem);
        stepDownButton.addSelectionListener(new SelectionListener() {

            public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
            }

            public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                int index = TransformerMainPage.this.stepsList.getSelectionIndex();
                if ((index >= 0) && (index < TransformerMainPage.this.stepsList.getItemCount() - 1)) {
                    // commit as we go
                    TransformerMainPage.this.comitting = true;
                    String val = TransformerMainPage.this.stepsList.getItem(index);
                    TransformerMainPage.this.stepsList.remove(index);
                    TransformerMainPage.this.stepsList.add(val, index + 1);
                    TransformerMainPage.this.stepsList.select(index + 1);
                    // (WSTransformerV2)getXObject().getWsObject();
                    WSTransformerV2 wsTransformer = transformer;
                    java.util.List<WSTransformerProcessStep> list = wsTransformer.getProcessSteps();
                    WSTransformerProcessStep spec = list.get(index);
                    list.remove(index);
                    list.add(index + 1, spec);
                    TransformerMainPage.this.comitting = false;
                    TransformerMainPage.this.stepsList.forceFocus();
                    markDirtyWithoutCommit();
                }
            }
        });
        // $NON-NLS-1$
        Button deleteStepButton = toolkit.createButton(stepUpDownComposite, "", SWT.PUSH | SWT.CENTER);
        deleteStepButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
        deleteStepButton.setImage(ImageCache.getCreatedImage(EImage.DELETE_OBJ.getPath()));
        deleteStepButton.setToolTipText(Messages.TransformerMainPage_DelTheItem);
        deleteStepButton.addSelectionListener(new SelectionListener() {

            public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
            }

            public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                int index = TransformerMainPage.this.stepsList.getSelectionIndex();
                if ((index >= 0) && (index < TransformerMainPage.this.stepsList.getItemCount())) {
                    removeStep(index);
                }
            }
        });
        // Plugin Specifications
        // Sequence
        section = this.getNewSection(Messages.TransformerMainPage_StepSpecification);
        section.setVisible(false);
        sequenceGroup.setLayout(new GridLayout(4, false));
        disabledButton = toolkit.createButton((Composite) section.getClient(), Messages.TransformerMainPage_Disabled, SWT.CHECK);
        disabledButton.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true, 4, 1));
        specsComposite = toolkit.createComposite((Composite) section.getClient(), SWT.NULL);
        specsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        specsComposite.setLayout(new GridLayout(4, false));
        disabledButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                WidgetUtils.enable(specsComposite, !disabledButton.getSelection());
                markDirtyWithoutCommit();
                if (stepsList.getSelectionIndex() >= 0) {
                    transformer.getProcessSteps().get(stepsList.getSelectionIndex()).setDisabled(disabledButton.getSelection());
                }
            }
        });
        // $NON-NLS-1$
        stepLabel = toolkit.createLabel(specsComposite, "", SWT.NULL);
        stepLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
        FontData fd = stepLabel.getFont().getFontData()[0];
        fd.setStyle(SWT.BOLD);
        stepLabel.setFont(new Font(Display.getDefault(), fd));
        stepWidget = new TransformerStepWidget(toolkit, specsComposite);
        stepWidget.create();
        btnAutoIndent = new Button(specsComposite, SWT.CHECK);
        btnAutoIndent.setText(Messages.TransformerMainPage_AutoIndent);
        btnAutoIndent.setImage(ImageCache.getCreatedImage(EImage.INTENT.getPath()));
        btnAutoIndent.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
        // refreshAutoIndentTooltip();
        btnAutoIndent.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                refreshAutoIndentTooltip();
            }
        });
        btnOpenXsltEditor = new Button(specsComposite, SWT.PUSH);
        btnOpenXsltEditor.setText(Messages.TransformerMainPage_open);
        btnOpenXsltEditor.setToolTipText(Messages.TransformerMainPage_opentext);
        btnOpenXsltEditor.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
        btnOpenXsltEditor.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                openInXSLTEditor();
            }

            public void openInXSLTEditor() {
                refreshEnableState(false);
                try {
                    // $NON-NLS-1$
                    IPreferenceStore preference = new ScopedPreferenceStore(new InstanceScope(), "org.eclipse.wst.xsl.ui");
                    // $NON-NLS-1$
                    String charSet = preference.getString("outputCodeset");
                    String xslcontent = parameterEditor.getContent().getContent();
                    IFile file = FileProvider.createdTempFile(xslcontent, getXSLTFileName(), charSet);
                    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                    xsltEditorInput = new XSLTFileEditorInput(file, new MainPageRefresher(), true);
                    page.openEditor(xsltEditorInput, XSLTEditor.ID);
                } catch (PartInitException e) {
                    log.error(e.getMessage(), e);
                }
            }
        });
        Group parametersGroup = new Group(specsComposite, SWT.SHADOW_NONE);
        parametersGroup.setText(Messages.TransformerMainPage_Parameters);
        parametersGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
        ((GridData) parametersGroup.getLayoutData()).minimumHeight = 300;
        parametersGroup.setLayout(new GridLayout(1, true));
        parameterEditor = new ExtensibleContentEditor(parametersGroup, SWT.NONE, EXCONTENTEDITOR_ID);
        parameterEditor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
        parameterEditorListener = new ProcessPluginParameterEditorListener();
        refreshParameterEditor();
        refreshData();
        addToolBarItem();
        this.oldBackground = parameterEditor.getBackground();
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : ExtensibleContentEditor(com.amalto.workbench.widgets.xmleditor.ExtensibleContentEditor) XSLTFileEditorInput(com.amalto.workbench.editors.xslteditor.XSLTFileEditorInput) Group(org.eclipse.swt.widgets.Group) IFile(org.eclipse.core.resources.IFile) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) FocusEvent(org.eclipse.swt.events.FocusEvent) Font(org.eclipse.swt.graphics.Font) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) ArrayList(java.util.ArrayList) WSGetTransformerPluginV2SList(com.amalto.workbench.webservices.WSGetTransformerPluginV2SList) List(org.eclipse.swt.widgets.List) WSTransformerPluginV2SList(com.amalto.workbench.webservices.WSTransformerPluginV2SList) PartInitException(org.eclipse.ui.PartInitException) Composite(org.eclipse.swt.widgets.Composite) DescAnnotationComposite(com.amalto.workbench.widgets.DescAnnotationComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) FontData(org.eclipse.swt.graphics.FontData) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) XtentisException(com.amalto.workbench.utils.XtentisException) DescAnnotationComposite(com.amalto.workbench.widgets.DescAnnotationComposite) WSTransformerV2(com.amalto.workbench.webservices.WSTransformerV2) GridData(org.eclipse.swt.layout.GridData) WSTransformerProcessStep(com.amalto.workbench.webservices.WSTransformerProcessStep) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) KeyListener(org.eclipse.swt.events.KeyListener) DropTarget(org.eclipse.swt.dnd.DropTarget) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) FocusListener(org.eclipse.swt.events.FocusListener) ScopedPreferenceStore(org.eclipse.ui.preferences.ScopedPreferenceStore) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 8 with InstanceScope

use of org.eclipse.core.runtime.preferences.InstanceScope in project liferay-ide by liferay.

the class WorkflowDefinitionValidator method validate.

@Override
public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
    if (resource.getType() != IResource.FILE) {
        return null;
    }
    ValidationResult result = new ValidationResult();
    IFile workflowDefinitionXml = (IFile) resource;
    if (workflowDefinitionXml.isAccessible() && CoreUtil.isLiferayProject(resource.getProject())) {
        IScopeContext[] scopes = { new InstanceScope(), new DefaultScope() };
        ProjectScope projectScope = new ProjectScope(workflowDefinitionXml.getProject());
        boolean useProjectSettings = projectScope.getNode(PREFERENCE_NODE_QUALIFIER).getBoolean(ProjectCore.USE_PROJECT_SETTINGS, false);
        if (useProjectSettings) {
            scopes = new IScopeContext[] { projectScope, new InstanceScope(), new DefaultScope() };
        }
        try {
            Map<String, Object>[] problems = detectProblems(workflowDefinitionXml, scopes);
            for (int i = 0; i < problems.length; i++) {
                Object messageValue = problems[i].get(IMarker.MESSAGE);
                ValidatorMessage message = ValidatorMessage.create(messageValue.toString(), resource);
                message.setType(MARKER_TYPE);
                message.setAttributes(problems[i]);
                result.add(message);
            }
            if (ListUtil.isNotEmpty(problems)) {
                IResource[] resources = { workflowDefinitionXml };
                result.setDependsOn(resources);
            }
        } catch (Exception e) {
            KaleoCore.logError(e);
        }
    }
    return result;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IFile(org.eclipse.core.resources.IFile) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope) ValidationResult(org.eclipse.wst.validation.ValidationResult) ValidatorMessage(org.eclipse.wst.validation.ValidatorMessage) CoreException(org.eclipse.core.runtime.CoreException) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) Map(java.util.Map) IResource(org.eclipse.core.resources.IResource)

Example 9 with InstanceScope

use of org.eclipse.core.runtime.preferences.InstanceScope in project liferay-ide by liferay.

the class LiferayUIPlugin method clearAllPersistentSettings.

// The shared instance
public static void clearAllPersistentSettings() throws BackingStoreException {
    IEclipsePreferences tomcatCorePrefs = new InstanceScope().getNode("com.liferay.ide.server.tomcat.core");
    tomcatCorePrefs.remove("ADDED_EXT_PLUGIN_TOGGLE_KEY");
    tomcatCorePrefs.remove("ADDED_EXT_PLUGIN_WITHOUT_ZIP_TOGGLE_KEY");
    tomcatCorePrefs.remove("REMOVE_EXT_PLUGIN_TOGGLE_KEY");
    tomcatCorePrefs.flush();
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope)

Example 10 with InstanceScope

use of org.eclipse.core.runtime.preferences.InstanceScope in project xtext-eclipse by eclipse.

the class PreferenceStoreWhitespaceInformationProvider method getLineSeparatorPreference.

protected String getLineSeparatorPreference(URI uri) {
    if (uri.isPlatformResource()) {
        IFile file = workspace.getRoot().getFile(new Path(uri.toPlatformString(true)));
        String delimiter = senseLineDelimiter(file);
        if (delimiter != null)
            return delimiter;
    }
    IProject project = null;
    if (uri.isPlatformResource()) {
        project = workspace.getRoot().getProject(uri.segment(1));
    } else {
        for (Pair<IStorage, IProject> storage : storage2UriMapper.getStorages(uri)) {
            project = storage.getSecond();
            break;
        }
    }
    if (project != null) {
        String result = getLineSeparatorPreference(new ProjectScope(project));
        if (result != null)
            return result;
    }
    @SuppressWarnings("all") String result = getLineSeparatorPreference(new InstanceScope());
    if (result != null)
        return result;
    return System.getProperty("line.separator");
}
Also used : Path(org.eclipse.core.runtime.Path) ProjectScope(org.eclipse.core.resources.ProjectScope) IFile(org.eclipse.core.resources.IFile) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) IStorage(org.eclipse.core.resources.IStorage) IProject(org.eclipse.core.resources.IProject)

Aggregations

InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)54 ProjectScope (org.eclipse.core.resources.ProjectScope)30 DefaultScope (org.eclipse.core.runtime.preferences.DefaultScope)16 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)16 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)15 IProject (org.eclipse.core.resources.IProject)11 BackingStoreException (org.osgi.service.prefs.BackingStoreException)9 IFile (org.eclipse.core.resources.IFile)7 ConfigurationScope (org.eclipse.core.runtime.preferences.ConfigurationScope)7 IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)6 IResource (org.eclipse.core.resources.IResource)5 Preferences (org.osgi.service.prefs.Preferences)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 Set (java.util.Set)4 IAdaptable (org.eclipse.core.runtime.IAdaptable)4 XMLMemento (com.cubrid.cubridmanager.core.common.xml.XMLMemento)3 List (java.util.List)3