use of org.eclipse.sapphire.ui.forms.swt.SapphireDialog in project liferay-ide by liferay.
the class CreatePortletActionHandler method run.
/**
* (non-Javadoc)
*
* @see
* SapphireActionHandler#run(org.eclipse.sapphire.ui.
* SapphireRenderingContext)
*/
@Override
protected Object run(Presentation context) {
PortletApp rootModel = (PortletApp) context.part().getModelElement();
Portlet portlet = rootModel.getPortlets().insert();
// Open the dialog to capture the mandatory properties
SapphireDialog dialog = new SapphireDialog(((SwtPresentation) context).shell(), portlet, DefinitionLoader.sdef(PortletXmlEditor.class).dialog());
if ((dialog != null) && (Dialog.OK == dialog.open())) {
// Select the node
MasterDetailsEditorPagePart page = getPart().nearest(MasterDetailsEditorPagePart.class);
MasterDetailsContentNodePart root = page.outline().getRoot();
MasterDetailsContentNodePart node = root.findNode(portlet);
if (node != null) {
node.select();
}
try {
rootModel.resource().save();
} catch (ResourceStoreException rse) {
// Log it in PorletUI Plugin
}
return portlet;
} else {
rootModel.getPortlets().remove(portlet);
portlet = null;
try {
rootModel.resource().save();
} catch (ResourceStoreException rse) {
// Log it in PorletUI Plugin
}
return null;
}
}
use of org.eclipse.sapphire.ui.forms.swt.SapphireDialog in project liferay-ide by liferay.
the class LiferayProjectPropertyPage method createInfoGroup.
protected void createInfoGroup(final Composite parent) {
new Label(parent, SWT.LEFT).setText(Msgs.liferayPluginTypeLabel);
final Text pluginTypeLabel = new Text(parent, SWT.READ_ONLY | SWT.BORDER);
pluginTypeLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
final IProjectFacet liferayFacet = ProjectUtil.getLiferayFacet(getFacetedProject());
if (liferayFacet != null) {
pluginTypeLabel.setText(liferayFacet.getLabel());
}
final IProject proj = getProject();
if ((proj != null) && ProjectUtil.isLiferayFacetedProject(proj)) {
try {
if (!ProjectUtil.isMavenProject(proj)) {
final SDK projectSdk = SDKUtil.getSDK(getProject());
new Label(parent, SWT.LEFT).setText(Msgs.liferaySdkLabel);
_sdkLabel = new Text(parent, SWT.READ_ONLY | SWT.BORDER);
if (projectSdk != null) {
_sdkLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
_sdkLabel.setText(projectSdk.getName());
} else {
_sdkLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
_sdkLabel.setText("");
final Hyperlink link = new Hyperlink(parent, SWT.NULL);
link.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
link.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLUE));
link.setUnderlined(true);
link.setText(Msgs.changeliferaySdk);
link.addHyperlinkListener(new HyperlinkAdapter() {
public void linkActivated(HyperlinkEvent e) {
String dialogId = new String("com.liferay.ide.project.ui.dialog.SelectPluginsSDKDialog");
final LiferayPluginSDKOp op = (LiferayPluginSDKOp) (LiferayPluginSDKOp.TYPE.instantiate().initialize());
DefinitionLoader sdefLoader = DefinitionLoader.context(getClass()).sdef(dialogId);
final Reference<DialogDef> dialogRef = sdefLoader.dialog("ConfigureLiferaySDK");
final SapphireDialog dialog = new SapphireDialog(UIUtil.getActiveShell(), op, dialogRef);
dialog.setBlockOnOpen(true);
final int result = dialog.open();
if (result != SapphireDialog.CANCEL) {
_sdkLabel.setText(op.getPluginsSDKName().content());
}
}
});
}
if (CoreUtil.compareVersions(new Version(projectSdk.getVersion()), ILiferayConstants.V700) < 0) {
new Label(parent, SWT.LEFT).setText(Msgs.liferayRuntimeLabel);
_runtimeCombo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
_runtimeCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
String currentRuntimeName = null;
try {
ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(getProject());
if (liferayRuntime != null) {
currentRuntimeName = liferayRuntime.getRuntime().getName();
}
} catch (Exception e) {
ProjectUI.logError("Could not determine liferay runtime", e);
}
List<String> runtimeNames = new ArrayList<>();
int selectionIndex = -1;
for (IRuntime runtime : ServerCore.getRuntimes()) {
if (ServerUtil.isLiferayRuntime(runtime) && FileUtil.exists(runtime.getLocation()) && (LiferayServerCore.newPortalBundle(runtime.getLocation()) == null)) {
runtimeNames.add(runtime.getName());
if (runtime.getName().equals(currentRuntimeName)) {
selectionIndex = runtimeNames.size() - 1;
}
}
}
if (ListUtil.isEmpty(runtimeNames)) {
runtimeNames.add("No Liferay runtimes available.");
}
_runtimeCombo.setItems(runtimeNames.toArray(new String[0]));
if (selectionIndex > -1) {
_runtimeCombo.select(selectionIndex);
}
}
}
} catch (Exception e) {
ProjectUI.logError("Could not determine whether its a maven project ", e);
}
}
}
use of org.eclipse.sapphire.ui.forms.swt.SapphireDialog in project liferay-ide by liferay.
the class NewLiferayProfileActionHandler method run.
@Override
protected Object run(Presentation context) {
if (context instanceof SwtPresentation) {
final SwtPresentation swt = (SwtPresentation) context;
final NewLiferayPluginProjectOp op = _op(context);
final NewLiferayProfile newLiferayProfile = op.getNewLiferayProfiles().insert();
final SapphireDialog dialog = new SapphireDialog(swt.shell(), newLiferayProfile, DefinitionLoader.sdef(NewLiferayPluginProjectWizard.class).dialog("NewLiferayProfile"));
dialog.setBlockOnOpen(true);
final int result = dialog.open();
if (result == SapphireDialog.OK) {
addToActiveProfiles(op, newLiferayProfile);
} else {
op.getNewLiferayProfiles().remove(newLiferayProfile);
}
}
return null;
}
use of org.eclipse.sapphire.ui.forms.swt.SapphireDialog in project liferay-ide by liferay.
the class NewLiferayProfileMarkerResolution method promptUser.
@Override
protected int promptUser(IProject project, NewLiferayPluginProjectOp op) {
NewLiferayProfile newLiferayProfile = op.getNewLiferayProfiles().insert();
Reference<DialogDef> dialogRef = DefinitionLoader.sdef(NewLiferayPluginProjectWizard.class).dialog("NewLiferayProfile");
SapphireDialog dialog = new SapphireDialog(UIUtil.getActiveShell(), newLiferayProfile, dialogRef);
dialog.setBlockOnOpen(true);
int result = dialog.open();
if (result == SapphireDialog.OK) {
IDOMModel domModel = null;
try {
IFile pomFile = project.getFile(IMavenConstants.POM_FILE_NAME);
domModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(pomFile);
MavenUtil.createNewLiferayProfileNode(domModel.getDocument(), newLiferayProfile);
domModel.save();
} catch (Exception e) {
LiferayMavenCore.logError("Unable to save new Liferay profiles to project pom.", e);
} finally {
if (domModel != null) {
domModel.releaseFromEdit();
}
}
NewLiferayProfileActionHandler.addToActiveProfiles(op, newLiferayProfile);
} else {
op.getNewLiferayProfiles().remove(newLiferayProfile);
}
return result;
}
use of org.eclipse.sapphire.ui.forms.swt.SapphireDialog in project liferay-ide by liferay.
the class PluginsSDKNotSetResolution method run.
public void run(IMarker marker) {
if (marker.getResource() instanceof IProject) {
final IProject proj = (IProject) marker.getResource();
final LiferayPluginSDKOp op = (LiferayPluginSDKOp) (LiferayPluginSDKOp.TYPE.instantiate().initialize());
DefinitionLoader loader = DefinitionLoader.context(getClass());
final Reference<DialogDef> dialogRef = loader.sdef("com.liferay.ide.project.ui.dialog.SelectPluginsSDKDialog").dialog("ConfigureLiferaySDK");
final SapphireDialog dialog = new SapphireDialog(UIUtil.getActiveShell(), op, dialogRef);
dialog.setBlockOnOpen(true);
final int result = dialog.open();
if (result != SapphireDialog.CANCEL) {
String sdkName = op.getPluginsSDKName().content();
SDKUtil.saveSDKNameSetting(proj, sdkName);
}
}
}
Aggregations