Exemplo n.º 1
0
	void Object::calculateLayout(const Object::Pointer & object)
	{
		hgeRect rect = getClientRect();
		hgeRect newRect = object->getRect();
		switch(object->alignHor)
		{
		case AlignManual:
			newRect.x1 = object->desiredX;
			newRect.x2 = object->desiredX + object->desiredWidth;
			break;
		case AlignCenter:		
			newRect.x1 = (rect.x1 + rect.x2 - object->desiredWidth)/2;
			newRect.x2 = (rect.x1 + rect.x2 + object->desiredWidth)/2;
			break;
		case AlignExpand:
			newRect.x1 = rect.x1;
			newRect.x2 = rect.x2;
			break;
		case AlignMin:		// left
			newRect.x1 = rect.x1;
			newRect.x2 = rect.x1 + object->desiredWidth;
			break;
		case AlignMax:		// right
			newRect.x1 = rect.x2 - object->desiredWidth;
			newRect.x2 = rect.x2;
		case AlignCell:		// TODO: implement
			break;
		}

		switch(object->alignVer)
		{
		case AlignManual:
			newRect.y1 = object->desiredY;
			newRect.y2 = object->desiredY + object->desiredHeight;
			break;
		case AlignCenter:
			newRect.y1 = (rect.y1 + rect.y2 - object->desiredHeight)/2;
			newRect.y2 = (rect.y1 + rect.y2 + object->desiredHeight)/2;
			break;
		case AlignExpand:
			newRect.y1 = rect.y1;
			newRect.y2 = rect.y2;
			break;
		case AlignMin:	// top
			newRect.y1 = rect.y1;
			newRect.y2 = rect.y1 + object->desiredHeight;
			break;			
		case AlignMax:	// bottom
			newRect.y1 = rect.y2 - object->desiredHeight;
			newRect.y2 = rect.y2;
			break;			
		case AlignCell:	// TODO: implement
			break;
		}
		object->setRect(newRect);
	}
Exemplo n.º 2
0
ISelection::Pointer HandlerUtil::GetShowInSelectionChecked(
    ExecutionEvent::Pointer event)
{
  Object::Pointer o = HandlerUtil::GetVariableChecked(event,
      ISources::SHOW_IN_SELECTION());
  if (o.Cast<ISelection>().IsNull())
  {
    HandlerUtil::IncorrectTypeFound(event, ISources::SHOW_IN_SELECTION(),
        "ISelection", o->GetClassName());
  }
  return o.Cast<ISelection>();
}
Exemplo n.º 3
0
ISelection::Pointer HandlerUtil::GetActiveMenuSelectionChecked(
    ExecutionEvent::Pointer event)
{
  Object::Pointer o = HandlerUtil::GetVariableChecked(event,
      ISources::ACTIVE_MENU_SELECTION_NAME());
  if (o.Cast<ISelection>().IsNull())
  {
    HandlerUtil::IncorrectTypeFound(event,
        ISources::ACTIVE_MENU_SELECTION_NAME(), "ISelection", o->GetClassName());
  }
  return o.Cast<ISelection>();
}
Exemplo n.º 4
0
HandlerUtil::StringVectorType::Pointer HandlerUtil::GetActiveMenusChecked(
    ExecutionEvent::Pointer event)
{
  Object::Pointer o = HandlerUtil::GetVariableChecked(event,
      ISources::ACTIVE_MENU_NAME());
  if (o.Cast<StringVectorType>().IsNull())
  {
    HandlerUtil::IncorrectTypeFound(event, ISources::ACTIVE_MENU_NAME(),
        "StringVectorType", o->GetClassName());
  }
  return o.Cast<StringVectorType>();
}
Exemplo n.º 5
0
IWorkbenchPartSite::Pointer HandlerUtil::GetActiveSiteChecked(
    ExecutionEvent::Pointer event)
{
  Object::Pointer o = HandlerUtil::GetVariableChecked(event,
      ISources::ACTIVE_SITE_NAME());
  if (o.Cast<IWorkbenchPartSite>().IsNull())
  {
    HandlerUtil::IncorrectTypeFound(event, ISources::ACTIVE_SITE_NAME(),
        "IWorkbenchSitePart", o->GetClassName());
  }
  return o.Cast<IWorkbenchPartSite>();
}
Exemplo n.º 6
0
ObjectString::Pointer HandlerUtil::GetActivePartIdChecked(
    ExecutionEvent::Pointer event)
{
  Object::Pointer o = HandlerUtil::GetVariableChecked(event,
      ISources::ACTIVE_PART_ID_NAME());
  if (o.Cast<ObjectString>().IsNull())
  {
    HandlerUtil::IncorrectTypeFound(event, ISources::ACTIVE_PART_ID_NAME(),
        "std::string", o->GetClassName());
  }
  return o.Cast<ObjectString>();
}
Exemplo n.º 7
0
void Command::FirePostExecuteSuccess(const Object::Pointer returnValue)
{
  // Debugging output
  if (DEBUG_COMMAND_EXECUTION)
  {
    CommandTracing::PrintTrace("COMMANDS", "execute" + CommandTracing::SEPARATOR
                               + "success: id=" + this->GetId() + "; returnValue=" +
                               (returnValue.IsNull() ? QString("NULL") : returnValue->ToString()));
  }

  executionEvents.postExecuteSuccess(this->GetId(), returnValue);
}
Exemplo n.º 8
0
Object* ServiceLocator::GetService(const QString& key)
{
  if (disposed)
  {
    return NULL;
  }

  KeyToServiceMapType::const_iterator iter = services.find(key);
  Object* service = NULL;

  if (iter != services.end())
  {
    service = iter.value();
  }
  else
  {
    // if we don't have a service in our cache then:
    // 1. check our local factory
    // 2. go to the registry
    // or 3. use the parent service
    IServiceLocator::Pointer factoryParent = WorkbenchServiceRegistry::GLOBAL_PARENT;
    if (parent)
    {
      factoryParent = new ParentLocator(parent, key);
    }
    if (factory)
    {
      service = factory->Create(key, factoryParent.GetPointer(), this);
    }
    if (!service)
    {
      Object::Pointer factoryService =
          WorkbenchServiceRegistry::GetRegistry()->GetService(key,
                                                              factoryParent.GetPointer(),
                                                              this);
      if (factoryService)
      {
        managedFactoryServices.push_back(factoryService);
      }
      service = factoryService.GetPointer();
    }
    if (!service)
    {
      service = factoryParent->GetService(key);
    }
    else
    {
      this->RegisterService(key, service);
    }
  }
  return service;
}
Exemplo n.º 9
0
IWorkbenchWindow::Pointer HandlerUtil::GetActiveWorkbenchWindowChecked(
    ExecutionEvent::Pointer event)
{
  Object::Pointer o = HandlerUtil::GetVariableChecked(event,
      ISources::ACTIVE_WORKBENCH_WINDOW_NAME());
  if (o.Cast<IWorkbenchWindow>().IsNull())
  {
    HandlerUtil::IncorrectTypeFound(event,
        ISources::ACTIVE_WORKBENCH_WINDOW_NAME(), "IWorkbenchWindow",
        o->GetClassName());
  }
  return o.Cast<IWorkbenchWindow>();
}
Exemplo n.º 10
0
  /*synchronized*/Property::Pointer
  TypeExtensionManager::GetProperty(
      Object::Pointer receiver, const std::string& namespaze,
      const std::string& method, bool forcePluginActivation)
  {
    std::clock_t start= 0;
    if (Expressions::TRACING)
    start = std::clock();

    // if we call a static method than the receiver is the class object
    //Class clazz= receiver instanceof Class ? (Class)receiver : receiver.getClass();

    Property::Pointer result(new Property(receiver, namespaze, method));
    Property::Pointer cached(fPropertyCache->Get(result));
    if (!cached.isNull())
    {
      if (cached->IsValidCacheEntry(forcePluginActivation))
      {
        if (Expressions::TRACING)
        {
          BERRY_INFO << "[Type Extension] - method " <<
          receiver->ToString() << "#" << method <<
          " found in cache: " <<
          (double(std::clock() - start))/(CLOCKS_PER_SEC/1000) << " ms.";
        }
        return cached;
      }
      // The type extender isn't loaded in the cached method but can be loaded
      // now. So remove method from cache and do the normal look up so that the
      // implementation class gets loaded.
      fPropertyCache->Remove(cached);
    }
    TypeExtension::Pointer extension(this->Get(receiver->GetClassName()));
    IPropertyTester::Pointer extender(extension->FindTypeExtender(*this, namespaze, method, false /*receiver instanceof Class*/, forcePluginActivation));
    if (!extender.Cast<TypeExtension::CONTINUE_>().IsNull() || extender.IsNull())
    {
      std::string msg("Unknown method for ");
      msg.append(receiver->GetClassName());
      throw CoreException(msg, method);
    }
    result->SetPropertyTester(extender);
    fPropertyCache->Put(result);
    if (Expressions::TRACING)
    {
      BERRY_INFO << "[Type Extension] - method " <<
      typeid(receiver).name() << "#" << method <<
      " not found in cache: " <<
      (double(std::clock() - start))/(CLOCKS_PER_SEC/1000) << " ms.";
    }
    return result;
  }
Exemplo n.º 11
0
  IIterable::Pointer
  Expressions::GetAsIIterable(Object::Pointer var, Expression::Pointer expression)
  {
    IIterable::Pointer iterable(var.Cast<IIterable>());
    if (!iterable.IsNull())
    {
      return iterable;
    }
    else
    {
      IAdapterManager::Pointer manager= Platform::GetServiceRegistry().GetServiceById<IAdapterManager>("org.blueberry.service.adaptermanager");
      Object::Pointer result;
      Poco::Any any(manager->GetAdapter(var, IIterable::GetStaticClassName()));
      if (!any.empty() && any.type() == typeid(Object::Pointer))
      {
        result = Poco::AnyCast<Object::Pointer>(any);
      }

      if (result)
      {
        iterable = result.Cast<IIterable>();
        return iterable;
      }

      if (manager->QueryAdapter(var->GetClassName(), IIterable::GetStaticClassName()) == IAdapterManager::NOT_LOADED)
        return IIterable::Pointer();

      throw CoreException("The variable is not iterable", expression->ToString());
    }
  }