Search in sources :

Example 6 with PluginPackageModel

use of com.liferay.ide.portlet.core.PluginPackageModel in project liferay-ide by liferay.

the class RequiredDeploymentContextsSection method _handleRemove.

@SuppressWarnings("rawtypes")
private void _handleRemove() {
    IStructuredSelection ssel = (IStructuredSelection) _fViewer.getSelection();
    PluginPackageModel model = (PluginPackageModel) getPage().getModel();
    int i = 0;
    String[] removedServiceDeps = new String[ssel.size()];
    for (Iterator iter = ssel.iterator(); iter.hasNext(); i++) {
        removedServiceDeps[i] = iter.next().toString();
    }
    model.removeRequiredDeploymentContexts(removedServiceDeps);
    _updateButtons();
}
Also used : PluginPackageModel(com.liferay.ide.portlet.core.PluginPackageModel) IPluginPackageModel(com.liferay.ide.portlet.core.IPluginPackageModel) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 7 with PluginPackageModel

use of com.liferay.ide.portlet.core.PluginPackageModel in project liferay-ide by liferay.

the class RequiredDeploymentContextsSection method _handleAdd.

private void _handleAdd() {
    PluginPackageModel model = (PluginPackageModel) getPage().getModel();
    String[] existingServiceDeps = model.getRequiredDeploymentContexts();
    ViewerFilter filter = new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (element instanceof IJavaProject) {
                IProject project = ((IJavaProject) element).getProject();
                for (String existingDep : existingServiceDeps) {
                    if (project.getName().equals(existingDep)) {
                        return false;
                    }
                }
                IDEFormEditor formEditor = getPage().getLiferayFormEditor();
                if (project.equals(formEditor.getCommonProject())) {
                    return false;
                }
                return true;
            } else {
                return false;
            }
        }
    };
    LiferayProjectSelectionDialog dialog = new LiferayProjectSelectionDialog(getPage().getShell(), filter);
    dialog.create();
    if (dialog.open() == Window.OK) {
        Object[] selectedProjects = dialog.getResult();
        try {
            for (int i = 0; i < selectedProjects.length; i++) {
                IJavaProject project = (IJavaProject) selectedProjects[i];
                if (project.exists()) {
                    model.addRequiredDeploymentContext(project.getProject().getName());
                }
            }
        } catch (Exception e) {
        }
    }
}
Also used : ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) IDEFormEditor(com.liferay.ide.ui.form.IDEFormEditor) IProject(org.eclipse.core.resources.IProject) IJavaProject(org.eclipse.jdt.core.IJavaProject) LiferayProjectSelectionDialog(com.liferay.ide.project.ui.dialog.LiferayProjectSelectionDialog) PluginPackageModel(com.liferay.ide.portlet.core.PluginPackageModel) IPluginPackageModel(com.liferay.ide.portlet.core.IPluginPackageModel)

Example 8 with PluginPackageModel

use of com.liferay.ide.portlet.core.PluginPackageModel in project liferay-ide by liferay.

the class PluginPackageEditor method _addPropertiesEditorPage.

private void _addPropertiesEditorPage() {
    editor = new PropertiesFileEditor();
    ((PluginPackageModel) getModel()).addModelChangedListener(this);
    // editor.setEditorPart(this);
    int index;
    try {
        index = addPage(editor, getEditorInput());
        setPageText(index, Msgs.source);
    } catch (PartInitException pie) {
        PortletUIPlugin.logError(pie);
    }
}
Also used : PluginPackageModel(com.liferay.ide.portlet.core.PluginPackageModel) PartInitException(org.eclipse.ui.PartInitException) PropertiesFileEditor(org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertiesFileEditor)

Example 9 with PluginPackageModel

use of com.liferay.ide.portlet.core.PluginPackageModel in project liferay-ide by liferay.

the class PluginPackageEditor method modelChanged.

public void modelChanged(IModelChangedEvent event) {
    if (ignoreModelChanges) {
        return;
    }
    PluginPackageModel model = (PluginPackageModel) getModel();
    IDocument doc = model.getDocument();
    IDocumentProvider provider = editor.getDocumentProvider();
    provider.getDocument(getEditorInput()).set(doc.get());
}
Also used : IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) PluginPackageModel(com.liferay.ide.portlet.core.PluginPackageModel) IDocument(org.eclipse.jface.text.IDocument)

Example 10 with PluginPackageModel

use of com.liferay.ide.portlet.core.PluginPackageModel in project liferay-ide by liferay.

the class PluginPackageEditor method pageChange.

@Override
protected void pageChange(int newPageIndex) {
    super.pageChange(newPageIndex);
    if ((lastPageIndex == 1) && (newPageIndex != 1)) {
        IDocument doc = editor.getDocumentProvider().getDocument(getEditorInput());
        String props = doc.get();
        try {
            ignoreModelChanges = true;
            if (getLastDirtyState()) {
                ((PluginPackageModel) getModel()).load(new ByteArrayInputStream(props.getBytes()), false);
            }
            ignoreModelChanges = false;
        } catch (CoreException ce) {
            PortletUIPlugin.logError(ce);
        }
    }
    lastPageIndex = newPageIndex;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ByteArrayInputStream(java.io.ByteArrayInputStream) PluginPackageModel(com.liferay.ide.portlet.core.PluginPackageModel) IDocument(org.eclipse.jface.text.IDocument)

Aggregations

PluginPackageModel (com.liferay.ide.portlet.core.PluginPackageModel)21 IPluginPackageModel (com.liferay.ide.portlet.core.IPluginPackageModel)17 File (java.io.File)6 IPath (org.eclipse.core.runtime.IPath)6 Iterator (java.util.Iterator)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 ExternalFileSelectionDialog (com.liferay.ide.ui.wizard.ExternalFileSelectionDialog)3 IProject (org.eclipse.core.resources.IProject)3 IDocument (org.eclipse.jface.text.IDocument)3 SDK (com.liferay.ide.sdk.core.SDK)2 IFolder (org.eclipse.core.resources.IFolder)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 Shell (org.eclipse.swt.widgets.Shell)2 LiferayProjectSelectionDialog (com.liferay.ide.project.ui.dialog.LiferayProjectSelectionDialog)1 IDEFormEditor (com.liferay.ide.ui.form.IDEFormEditor)1 TablePart (com.liferay.ide.ui.form.TablePart)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IFile (org.eclipse.core.resources.IFile)1 CoreException (org.eclipse.core.runtime.CoreException)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1