use of org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor in project liferay-ide by liferay.
the class NewPortletClassDataModelProvider method getPropertyDescriptor.
@Override
public DataModelPropertyDescriptor getPropertyDescriptor(String propertyName) {
if (VIEW_MODE.equals(propertyName)) {
return new DataModelPropertyDescriptor(getProperty(propertyName), "view");
} else if (EDIT_MODE.equals(propertyName)) {
return new DataModelPropertyDescriptor(getProperty(propertyName), "edit");
} else if (HELP_MODE.equals(propertyName)) {
return new DataModelPropertyDescriptor(getProperty(propertyName), "help");
} else if (ABOUT_MODE.equals(propertyName)) {
return new DataModelPropertyDescriptor(getProperty(propertyName), "about");
} else if (CONFIG_MODE.equals(propertyName)) {
return new DataModelPropertyDescriptor(getProperty(propertyName), "config");
} else if (EDITDEFAULTS_MODE.equals(propertyName)) {
return new DataModelPropertyDescriptor(getProperty(propertyName), "edit_defaults");
} else if (EDITGUEST_MODE.equals(propertyName)) {
return new DataModelPropertyDescriptor(getProperty(propertyName), "edit_guest");
} else if (PREVIEW_MODE.equals(propertyName)) {
return new DataModelPropertyDescriptor(getProperty(propertyName), "preview");
} else if (PRINT_MODE.equals(propertyName)) {
return new DataModelPropertyDescriptor(getProperty(propertyName), "print");
} else if (CATEGORY.equals(propertyName)) {
if (getProperty(CATEGORY).equals("category.sample")) {
return new DataModelPropertyDescriptor("category.sample", "Sample");
}
} else if (ENTRY_CATEGORY.equals(propertyName)) {
// following if block is for modifying portlet class name will resynch the model
// and lose the user choice
// check for null is for switching projects of different portal versions
Object entryCategory = getProperty(ENTRY_CATEGORY);
if ((entryCategory != null) && (getEntryCategories() != null) && (getEntryCategories().get(entryCategory) != null)) {
Properties entryCategories = getEntryCategories();
DataModelPropertyDescriptor descriptor = new DataModelPropertyDescriptor(entryCategory, entryCategories.get(entryCategory).toString());
return descriptor;
}
ILiferayProject liferayProject = LiferayCore.create(getProject());
if (liferayProject == null) {
try {
liferayProject = LiferayCore.create(getRuntime());
} catch (CoreException ce) {
PortletCore.logError(ce);
}
}
ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
if (portal != null) {
Version portalVersion = Version.parseVersion(portal.getVersion());
if (CoreUtil.compareVersions(portalVersion, ILiferayConstants.V620) < 0) {
return new DataModelPropertyDescriptor("category.my", "My Account Section");
}
}
return new DataModelPropertyDescriptor("category.my", "My Account Administration");
}
return super.getPropertyDescriptor(propertyName);
}
use of org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor in project webtools.sourceediting by eclipse.
the class DataModelFacetCreationWizardPage method restoreRuntimeSettings.
public static void restoreRuntimeSettings(IDialogSettings settings, IDataModel model) {
if (settings != null) {
if (!model.isPropertySet(IFacetProjectCreationDataModelProperties.FACET_RUNTIME)) {
boolean runtimeSet = false;
String[] mruRuntimeArray = settings.getArray(MRU_RUNTIME_STORE);
DataModelPropertyDescriptor[] descriptors = model.getValidPropertyDescriptors(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
List mruRuntimes = new ArrayList();
if (mruRuntimeArray == null) {
List defRuntimes = ProductManager.getDefaultRuntimes();
for (Iterator iter = defRuntimes.iterator(); iter.hasNext(); ) mruRuntimes.add(((IRuntime) iter.next()).getName());
} else {
mruRuntimes.addAll(Arrays.asList(mruRuntimeArray));
}
if (!mruRuntimes.isEmpty()) {
for (int i = 0; i < mruRuntimes.size() && !runtimeSet; i++) {
for (int j = 0; j < descriptors.length - 1 && !runtimeSet; j++) {
if (mruRuntimes.get(i).equals(((IRuntime) descriptors[j].getPropertyValue()).getName())) {
model.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, descriptors[j].getPropertyValue());
runtimeSet = true;
}
}
if (!runtimeSet && mruRuntimes.get(i).equals(NULL_RUNTIME)) {
model.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, descriptors[descriptors.length - 1].getPropertyValue());
runtimeSet = true;
}
}
}
if (!runtimeSet && descriptors.length > 0) {
model.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, descriptors[0].getPropertyValue());
}
}
}
}
use of org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor in project webtools.sourceediting by eclipse.
the class DataModelFacetCreationWizardPage method launchNewRuntimeWizard.
public static boolean launchNewRuntimeWizard(Shell shell, final IDataModel model, String serverTypeID) {
if (model == null) {
return false;
}
final DataModelPropertyDescriptor[] preAdditionDescriptors = model.getValidPropertyDescriptors(FACET_RUNTIME);
final boolean[] keepWaiting = { true };
final IDataModelListener listener = new IDataModelListener() {
@Override
public void propertyChanged(final DataModelEvent event) {
if (event.getPropertyName().equals(FACET_RUNTIME) && event.getFlag() == DataModelEvent.VALID_VALUES_CHG) {
synchronized (keepWaiting) {
keepWaiting[0] = false;
keepWaiting.notify();
}
model.removeListener(this);
}
}
};
model.addListener(listener);
boolean isOK = ServerUIUtil.showNewRuntimeWizard(shell, serverTypeID, null);
if (isOK) {
// Do the rest of the processing in a separate thread. Since we are going to block
// and wait, doing this on the UI thread can cause hangs.
final Thread newRuntimeSelectionThread = new Thread() {
@Override
public void run() {
// Causes the list of runtimes held by the RuntimeManager to be refreshed and
// triggers events to listeners on that list.
RuntimeManager.getRuntimes();
synchronized (keepWaiting) {
while (keepWaiting[0] == true) {
try {
keepWaiting.wait();
} catch (InterruptedException e) {
}
}
}
// Select the new runtime.
DataModelPropertyDescriptor[] postAdditionDescriptors = model.getValidPropertyDescriptors(FACET_RUNTIME);
Object[] preAddition = new Object[preAdditionDescriptors.length];
for (int i = 0; i < preAddition.length; i++) {
preAddition[i] = preAdditionDescriptors[i].getPropertyValue();
}
Object[] postAddition = new Object[postAdditionDescriptors.length];
for (int i = 0; i < postAddition.length; i++) {
postAddition[i] = postAdditionDescriptors[i].getPropertyValue();
}
Object newAddition = getNewObject(preAddition, postAddition);
if (// can this ever be null?
newAddition != null)
model.setProperty(FACET_RUNTIME, newAddition);
}
};
newRuntimeSelectionThread.start();
return true;
}
model.removeListener(listener);
return false;
}
use of org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor in project liferay-ide by liferay.
the class PluginFacetProjectCreationDataModelProvider method init.
@Override
public void init() {
super.init();
getDataModel().setProperty(LIFERAY_USE_SDK_LOCATION, true);
DataModelPropertyDescriptor[] validDescriptors = getDataModel().getValidPropertyDescriptors(FACET_RUNTIME);
for (DataModelPropertyDescriptor desc : validDescriptors) {
Object runtime = desc.getPropertyValue();
if (runtime instanceof BridgedRuntime && ServerUtil.isLiferayRuntime((BridgedRuntime) runtime)) {
getDataModel().setProperty(FACET_RUNTIME, runtime);
break;
}
}
ProjectCore.getPortletFrameworks();
}
Aggregations