Search in sources :

Example 1 with NewModuleFragmentOp

use of com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp in project liferay-ide by liferay.

the class MavenModuleFragmentProjectTests method testNewModuleFragmentProjectOpProjectName.

@Test
public void testNewModuleFragmentProjectOpProjectName() {
    NewModuleFragmentOp op = NewModuleFragmentOp.TYPE.instantiate();
    op.setProjectName("test-module-fragment");
    Status projectNameOkValidationStatus1 = op.getProjectName().validation();
    assertEquals("ok", projectNameOkValidationStatus1.message());
    op.setProjectName("#test-module-fragment");
    Status projectNameErrorValidationStatus = op.getProjectName().validation();
    assertEquals("The project name is invalid.", projectNameErrorValidationStatus.message());
    op.setProjectName("test_module_fragment");
    Status projectNameOkValidationStatus2 = op.getProjectName().validation();
    assertEquals("ok", projectNameOkValidationStatus2.message());
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NewModuleFragmentOp(com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp) Test(org.junit.Test)

Example 2 with NewModuleFragmentOp

use of com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp in project liferay-ide by liferay.

the class NewModuleFragmentWizard method performPostFinish.

@Override
protected void performPostFinish() {
    super.performPostFinish();
    final NewModuleFragmentOp op = element().nearest(NewModuleFragmentOp.class);
    final IProject project = CoreUtil.getProject(op.getProjectName().content());
    try {
        addToWorkingSets(project);
    } catch (Exception ex) {
        ProjectUI.logError("Unable to add project to working set", ex);
    }
    openLiferayPerspective(project);
}
Also used : NewModuleFragmentOp(com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp) IProject(org.eclipse.core.resources.IProject)

Example 3 with NewModuleFragmentOp

use of com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp in project liferay-ide by liferay.

the class AddFilesFromOSGiBundleAction method computeEnablementState.

@Override
protected boolean computeEnablementState() {
    boolean enabled = false;
    NewModuleFragmentOp op = getModelElement().nearest(NewModuleFragmentOp.class);
    String hostOsgiBundle = op.getHostOsgiBundle().content();
    if (hostOsgiBundle != null) {
        enabled = true;
    }
    return enabled;
}
Also used : NewModuleFragmentOp(com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp)

Example 4 with NewModuleFragmentOp

use of com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp in project liferay-ide by liferay.

the class AddFilesFromOSGiBundleAction method run.

@Override
protected Object run(Presentation context) {
    Element modelElement = context.part().getModelElement();
    final NewModuleFragmentOp op = modelElement.nearest(NewModuleFragmentOp.class);
    final ElementList<OverrideFilePath> currentFiles = op.getOverrideFiles();
    final String projectName = op.getProjectName().content();
    final OSGiBundleFileSelectionDialog dialog = new OSGiBundleFileSelectionDialog(null, currentFiles, projectName);
    final String runtimeName = op.getLiferayRuntimeName().content();
    final IRuntime runtime = ServerUtil.getRuntime(runtimeName);
    final IPath tempLocation = ProjectCore.getDefault().getStateLocation();
    dialog.setTitle("Add files from OSGi bundle to override");
    String currentOSGiBundle = op.getHostOsgiBundle().content();
    if (!currentOSGiBundle.endsWith("jar")) {
        currentOSGiBundle = currentOSGiBundle + ".jar";
    }
    File module = tempLocation.append(currentOSGiBundle).toFile();
    if (FileUtil.notExists(module)) {
        module = ServerUtil.getModuleFileFrom70Server(runtime, currentOSGiBundle, tempLocation);
    }
    if (FileUtil.exists(module)) {
        dialog.setInput(module);
    }
    if (dialog.open() == Window.OK) {
        Object[] selected = dialog.getResult();
        for (int i = 0; i < selected.length; i++) {
            OverrideFilePath file = op.getOverrideFiles().insert();
            file.setValue(selected[i].toString());
        }
    }
    return Status.createOkStatus();
}
Also used : OverrideFilePath(com.liferay.ide.project.core.modules.fragment.OverrideFilePath) IPath(org.eclipse.core.runtime.IPath) Element(org.eclipse.sapphire.Element) NewModuleFragmentOp(com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp) File(java.io.File) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 5 with NewModuleFragmentOp

use of com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp in project liferay-ide by liferay.

the class ModuleNewLiferayRuntimeAction method run.

@Override
protected Object run(Presentation context) {
    Element element = context.part().getModelElement();
    NewModuleFragmentOp op = element.nearest(NewModuleFragmentOp.class);
    boolean oK = ServerUIUtil.showNewRuntimeWizard(((SwtPresentation) context).shell(), "liferay.bundle", null, "com.liferay.");
    if (oK) {
        op.property(NewModuleFragmentOp.PROP_LIFERAY_RUNTIME_NAME).refresh();
    }
    return Status.createOkStatus();
}
Also used : Element(org.eclipse.sapphire.Element) NewModuleFragmentOp(com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp)

Aggregations

NewModuleFragmentOp (com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp)7 OverrideFilePath (com.liferay.ide.project.core.modules.fragment.OverrideFilePath)3 IProject (org.eclipse.core.resources.IProject)3 Status (org.eclipse.sapphire.modeling.Status)3 IRuntime (org.eclipse.wst.server.core.IRuntime)3 Test (org.junit.Test)3 IFile (org.eclipse.core.resources.IFile)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 Element (org.eclipse.sapphire.Element)2 IRuntimeWorkingCopy (org.eclipse.wst.server.core.IRuntimeWorkingCopy)2 NewModuleFragmentFilesOp (com.liferay.ide.project.core.modules.fragment.NewModuleFragmentFilesOp)1 File (java.io.File)1 IPath (org.eclipse.core.runtime.IPath)1